Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/wip multi auth #730

Merged
merged 37 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
5810967
added multi-auth updates to lib api
Jun 15, 2023
34de2eb
remove un-needed import
Jun 16, 2023
996c481
eas validate token data
Jun 19, 2023
d3b790b
wip changes for multi-auth
Jun 19, 2023
6b9d101
wip changes for multi-auth
Jun 20, 2023
e827241
Merge branch 'staging' into feat/wip-multi-auth
Jun 21, 2023
e305afb
removed un-needed changes. added logs.
Jun 21, 2023
d2a53bc
further progressed multi-auth flow up to point of sending data to aut…
Jun 22, 2023
d1b727b
further progressed multi-auth flow up to point of sending data to aut…
Jun 22, 2023
b2a9539
multi-flow working with iframe mode.
Jun 26, 2023
dc4d179
multi-flow working with iframe mode.
Jun 26, 2023
97ed27f
wip changes for multi-auth
Jun 27, 2023
874446b
chore: notes for nick
micwallace Jun 27, 2023
a34b2d2
iniital change to allow multi-auth to work one to many.
Jun 28, 2023
cbcda9e
fixed a race conndition with the cross origin multi-auth flow
Jul 3, 2023
f9e2dd7
correction made to multi auth for supporting passive flow.
Jul 3, 2023
16ea440
removal of code comments added during development, no longer needed.
Jul 3, 2023
1b25f57
updated readme and included types across the changes applied
Jul 3, 2023
96ceaf1
updated readme and included types across the changes applied
Jul 3, 2023
8e86da1
updated readme and included types across the changes applied
Jul 3, 2023
da20f3c
updated readme and included types across the changes applied
Jul 3, 2023
fc582b2
updated readme and included types across the changes applied
Jul 3, 2023
f3d8d1c
changes from PR. Inteface updates and clean up
Jul 4, 2023
b26ce99
changes from PR. Inteface updates and clean up
Jul 4, 2023
3cfaff8
changes from PR. Inteface updates and clean up
Jul 4, 2023
8e6f21f
fix for allowing multi sub issuers
Jul 5, 2023
b3c6cb1
support for re-didrect multi flow local
Jul 5, 2023
5de63bf
feat: batch attestation improvements
micwallace Jul 10, 2023
46c33fa
feat: new attestation.id client
micwallace Jul 11, 2023
2a04315
fix: various fixes
micwallace Jul 11, 2023
2f72c6b
fix: various fixes
micwallace Jul 11, 2023
db3ad00
fix: various fixes
micwallace Jul 12, 2023
e9e533f
chore: various cleanup of old code
micwallace Jul 12, 2023
a81c4a5
chore: various cleanup of old code
micwallace Jul 12, 2023
69a9bf3
chore: add todo
micwallace Jul 12, 2023
4b5cd4b
removed console log
Jul 12, 2023
1386861
Merge pull request #750 from TokenScript/feat/wip-multi-auth-improvem…
nicktaras Jul 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,9 @@ negotiator.on("tokens-selected", callback);
</tbody>
</table>

### Authenticate ownership of off chain Token
### Authenticate ownership of single off chain Token

Note: the proof callback object structure will change in version 3.0.0 to multiple call back data structure.

Authenticating ownership of the token will provide a proof with a limited expiry.

Expand All @@ -481,8 +483,28 @@ negotiator.authenticate({
unsignedToken,
});

negotiator.on("proof", () => {
negotiator.on("proof", ({ proof, issuer, error }) => {
// the proof will be received here (valid or failed)
});
```

### Authenticate ownership of multiple off chain Tokens

Authenticating ownership of the tokens will provide a list of proof data with a limited expiry.

```javascript
/**
* @param {{issuer: String, unsignedToken: Object}[]} tokens object array of tokens
*/
negotiator.authenticate([{
issuer,
unsignedToken,
}]);

negotiator.on("proof", ({ issuers, issuersProcessed }) => {
// the proof will be received here (valid or failed)
// issuers: { issuerName: [ token, ... ] }
// issuersProcessed: [ 'issuerName1', 'issuerName2', '...' ]
});
```

Expand Down
157 changes: 100 additions & 57 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,65 @@
collectionID: "devcon",
onChain: false,
title: "Devcon",
tokenIdName: "id",
image:
"https://raw.githubusercontent.com/TokenScript/token-negotiator/main/mock-images/devcon.svg",
tokenOrigin: "https://stltesting.tk/token-outlet/",
attestationOrigin: "https://attestation.id/",
unEndPoint:
"https://crypto-verify.herokuapp.com/use-devcon-ticket",
tokenOrigin: "http://localhost:3002/",
attestationOrigin: "https://test.attestation.id/",
base64senderPublicKeys: {
6: "MIIBMzCB7AYHKoZIzj0CATCB4AIBATAsBgcqhkjOPQEBAiEA/////////////////////////////////////v///C8wRAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHBEEEeb5mfvncu6xVoGKVzocLBwKb/NstzijZWfKBWxb4F5hIOtp3JqPEZV2k+/wOEQio/Re0SKaFVBmcR9CP+xDUuAIhAP////////////////////66rtzmr0igO7/SXozQNkFBAgEBA0IABGMxHraqggr2keTXszIcchTjYjH5WXpDaBOYgXva82mKcGnKgGRORXSmcjWN2suUCMkLQj3UNlZCFWF10wIrrlw=",
55: "MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEAGJAHCiHbrCNAY9fAMdom4dGD6v/KkTIgRCkwLCjXFTkXWGrCEXHaZ8kWwdqlu0oYCrNQ2vdlqOl0s26/LzO8A==",
55: "MIIBMzCB7AYHKoZIzj0CATCB4AIBATAsBgcqhkjOPQEBAiEA/////////////////////////////////////v///C8wRAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHBEEEeb5mfvncu6xVoGKVzocLBwKb/NstzijZWfKBWxb4F5hIOtp3JqPEZV2k+/wOEQio/Re0SKaFVBmcR9CP+xDUuAIhAP////////////////////66rtzmr0igO7/SXozQNkFBAgEBA0IABGMxHraqggr2keTXszIcchTjYjH5WXpDaBOYgXva82mKcGnKgGRORXSmcjWN2suUCMkLQj3UNlZCFWF10wIrrlw=",
},
base64attestorPubKey:
"MIIBMzCB7AYHKoZIzj0CATCB4AIBATAsBgcqhkjOPQEBAiEA/////////////////////////////////////v///C8wRAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHBEEEeb5mfvncu6xVoGKVzocLBwKb/NstzijZWfKBWxb4F5hIOtp3JqPEZV2k+/wOEQio/Re0SKaFVBmcR9CP+xDUuAIhAP////////////////////66rtzmr0igO7/SXozQNkFBAgEBA0IABL+y43T1OJFScEep69/yTqpqnV/jzONz9Sp4TEHyAJ7IPN9+GHweCX1hT4OFxt152sBN3jJc1s0Ymzd8pNGZNoQ=",
ticketIssuesUrlWebsitePrivateKey:
ticketIssuersUrlWebsitePrivateKey:
"MIICSwIBADCB7AYHKoZIzj0CATCB4AIBATAsBgcqhkjOPQEBAiEA/////////////////////////////////////v///C8wRAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHBEEEeb5mfvncu6xVoGKVzocLBwKb/NstzijZWfKBWxb4F5hIOtp3JqPEZV2k+/wOEQio/Re0SKaFVBmcR9CP+xDUuAIhAP////////////////////66rtzmr0igO7/SXozQNkFBAgEBBIIBVTCCAVECAQEEIM/T+SzcXcdtcNIqo6ck0nJTYzKL5ywYBFNSpI7R8AuBoIHjMIHgAgEBMCwGByqGSM49AQECIQD////////////////////////////////////+///8LzBEBCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcEQQR5vmZ++dy7rFWgYpXOhwsHApv82y3OKNlZ8oFbFvgXmEg62ncmo8RlXaT7/A4RCKj9F7RIpoVUGZxH0I/7ENS4AiEA/////////////////////rqu3OavSKA7v9JejNA2QUECAQGhRANCAARjMR62qoIK9pHk17MyHHIU42Ix+Vl6Q2gTmIF72vNpinBpyoBkTkV0pnI1jdrLlAjJC0I91DZWQhVhddMCK65c",
},
// {
// collectionID: "devcon",
// onChain: false,
// title: "Devcon",
// image:
// "https://raw.githubusercontent.com/TokenScript/token-negotiator/main/mock-images/devcon.svg",
// tokenOrigin: "http://localhost:3002/",
// attestationOrigin: "https://test.attestation.id/",
// base64senderPublicKeys: {
// 6: "MIIBMzCB7AYHKoZIzj0CATCB4AIBATAsBgcqhkjOPQEBAiEA/////////////////////////////////////v///C8wRAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHBEEEeb5mfvncu6xVoGKVzocLBwKb/NstzijZWfKBWxb4F5hIOtp3JqPEZV2k+/wOEQio/Re0SKaFVBmcR9CP+xDUuAIhAP////////////////////66rtzmr0igO7/SXozQNkFBAgEBA0IABGMxHraqggr2keTXszIcchTjYjH5WXpDaBOYgXva82mKcGnKgGRORXSmcjWN2suUCMkLQj3UNlZCFWF10wIrrlw=",
// },
// base64attestorPubKey:
// "MIIBMzCB7AYHKoZIzj0CATCB4AIBATAsBgcqhkjOPQEBAiEA/////////////////////////////////////v///C8wRAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHBEEEeb5mfvncu6xVoGKVzocLBwKb/NstzijZWfKBWxb4F5hIOtp3JqPEZV2k+/wOEQio/Re0SKaFVBmcR9CP+xDUuAIhAP////////////////////66rtzmr0igO7/SXozQNkFBAgEBA0IABL+y43T1OJFScEep69/yTqpqnV/jzONz9Sp4TEHyAJ7IPN9+GHweCX1hT4OFxt152sBN3jJc1s0Ymzd8pNGZNoQ=",
// ticketIssuersUrlWebsitePrivateKey:
// "MIICSwIBADCB7AYHKoZIzj0CATCB4AIBATAsBgcqhkjOPQEBAiEA/////////////////////////////////////v///C8wRAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHBEEEeb5mfvncu6xVoGKVzocLBwKb/NstzijZWfKBWxb4F5hIOtp3JqPEZV2k+/wOEQio/Re0SKaFVBmcR9CP+xDUuAIhAP////////////////////66rtzmr0igO7/SXozQNkFBAgEBBIIBVTCCAVECAQEEIM/T+SzcXcdtcNIqo6ck0nJTYzKL5ywYBFNSpI7R8AuBoIHjMIHgAgEBMCwGByqGSM49AQECIQD////////////////////////////////////+///8LzBEBCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcEQQR5vmZ++dy7rFWgYpXOhwsHApv82y3OKNlZ8oFbFvgXmEg62ncmo8RlXaT7/A4RCKj9F7RIpoVUGZxH0I/7ENS4AiEA/////////////////////rqu3OavSKA7v9JejNA2QUECAQGhRANCAARjMR62qoIK9pHk17MyHHIU42Ix+Vl6Q2gTmIF72vNpinBpyoBkTkV0pnI1jdrLlAjJC0I91DZWQhVhddMCK65c",
// },
// {
// collectionID: "edcon",
// onChain: false,
// title: "Edcon",
// image:
// "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRMSMZD26jgBM_da7b_0NfT7JZgyDk7rdk6o4iAVh4E12dV9LK-h0thJ_SdRWWptz1EYlk&usqp=CAU",
// tokenOrigin: "http://localhost:3002/",
// attestationOrigin: "https://test.attestation.id/",
// base64senderPublicKeys: {
// 6: "MIIBMzCB7AYHKoZIzj0CATCB4AIBATAsBgcqhkjOPQEBAiEA/////////////////////////////////////v///C8wRAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHBEEEeb5mfvncu6xVoGKVzocLBwKb/NstzijZWfKBWxb4F5hIOtp3JqPEZV2k+/wOEQio/Re0SKaFVBmcR9CP+xDUuAIhAP////////////////////66rtzmr0igO7/SXozQNkFBAgEBA0IABAjUvEi8UYyC+0rSFu+IwRBos/DEC6YMJV+eCnoYOC4nZU7uayKDJmBxVnmTOSwaM4+gufLbeqqxuovyF5gI3TQ=",
// },
// base64attestorPubKey:
// "MIIBMzCB7AYHKoZIzj0CATCB4AIBATAsBgcqhkjOPQEBAiEA/////////////////////////////////////v///C8wRAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHBEEEeb5mfvncu6xVoGKVzocLBwKb/NstzijZWfKBWxb4F5hIOtp3JqPEZV2k+/wOEQio/Re0SKaFVBmcR9CP+xDUuAIhAP////////////////////66rtzmr0igO7/SXozQNkFBAgEBA0IABL+y43T1OJFScEep69/yTqpqnV/jzONz9Sp4TEHyAJ7IPN9+GHweCX1hT4OFxt152sBN3jJc1s0Ymzd8pNGZNoQ=",
// },
// {
// collectionID: "devconnect",
// onChain: false,
// title: "Devconnect",
// image:
// "https://pbs.twimg.com/profile_images/1653427962350370816/GiJ0Wh-h_400x400.jpg",
// tokenOrigin: "http://localhost:3002/",
// attestationOrigin: "https://test.attestation.id/",
// base64senderPublicKeys: {
// 7: "MIIBMzCB7AYHKoZIzj0CATCB4AIBATAsBgcqhkjOPQEBAiEA/////////////////////////////////////v///C8wRAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHBEEEeb5mfvncu6xVoGKVzocLBwKb/NstzijZWfKBWxb4F5hIOtp3JqPEZV2k+/wOEQio/Re0SKaFVBmcR9CP+xDUuAIhAP////////////////////66rtzmr0igO7/SXozQNkFBAgEBA0IABAjUvEi8UYyC+0rSFu+IwRBos/DEC6YMJV+eCnoYOC4nZU7uayKDJmBxVnmTOSwaM4+gufLbeqqxuovyF5gI3TQ=",
// },
// base64attestorPubKey:
// "MIIBMzCB7AYHKoZIzj0CATCB4AIBATAsBgcqhkjOPQEBAiEA/////////////////////////////////////v///C8wRAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHBEEEeb5mfvncu6xVoGKVzocLBwKb/NstzijZWfKBWxb4F5hIOtp3JqPEZV2k+/wOEQio/Re0SKaFVBmcR9CP+xDUuAIhAP////////////////////66rtzmr0igO7/SXozQNkFBAgEBA0IABL+y43T1OJFScEep69/yTqpqnV/jzONz9Sp4TEHyAJ7IPN9+GHweCX1hT4OFxt152sBN3jJc1s0Ymzd8pNGZNoQ=",
// },
// {
// hideToggle : false,
// noTokenMsg: "<p>If you have a token please:</p><p>1. Open your magic link inside this browser.<br/>2. Refresh this page.</p>",
// collectionID: 'devcon',
Expand All @@ -57,17 +100,17 @@
// },
// base64attestorPubKey: "MIIBMzCB7AYHKoZIzj0CATCB4AIBATAsBgcqhkjOPQEBAiEA/////////////////////////////////////v///C8wRAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHBEEEeb5mfvncu6xVoGKVzocLBwKb/NstzijZWfKBWxb4F5hIOtp3JqPEZV2k+/wOEQio/Re0SKaFVBmcR9CP+xDUuAIhAP////////////////////66rtzmr0igO7/SXozQNkFBAgEBA0IABL+y43T1OJFScEep69/yTqpqnV/jzONz9Sp4TEHyAJ7IPN9+GHweCX1hT4OFxt152sBN3jJc1s0Ymzd8pNGZNoQ="
// },
{
collectionID: "crypto-cowboy-country",
tokenProgram: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
collectionAddress:
"bf0aae3dd0078a9feb975f1e3242ddcb7774d551c7fd2a3f07a89c827ed606b2",
updateAuthority: "CCCUzWanUNegjGby11DjujDvPaNN68jd9Rimwk2MZzqZ",
onChain: true,
symbol: "CCC",
chain: "mainnet",
blockchain: "solana",
},
// {
// collectionID: "crypto-cowboy-country",
// tokenProgram: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
// collectionAddress:
// "bf0aae3dd0078a9feb975f1e3242ddcb7774d551c7fd2a3f07a89c827ed606b2",
// updateAuthority: "CCCUzWanUNegjGby11DjujDvPaNN68jd9Rimwk2MZzqZ",
// onChain: true,
// symbol: "CCC",
// chain: "mainnet",
// blockchain: "solana",
// },
// {
// collectionID: "penthouse-panther-club",
// collectionAddress: "ff846ef2eed57e5367cf8826e63f4d53fe28d28aa67417accb6e4b48cbd19136",
Expand All @@ -87,13 +130,13 @@
// chain: "mainnet",
// blockchain: "solana",
// },
// {
// onChain: true,
// collectionID: "expansion-punks",
// contract: '0x0d0167a823c6619d430b1a96ad85b888bcf97c37',
// chain: 'eth',
// blockchain: "evm",
// },
{
onChain: true,
collectionID: "expansion-punks",
contract: "0x0d0167a823c6619d430b1a96ad85b888bcf97c37",
chain: "eth",
blockchain: "evm",
},
// {
// onChain: true,
// collectionID: "fantom-collection-test",
Expand All @@ -120,18 +163,18 @@
// { onChain: true, collectionID: "Perion", contract: '0x96af92ae2d822a0f191455ceca4d4e7ee227668e', chain: 'mumbai', blockchain: "evm" },
// { collectionID: 'COOLCATS-#2426-14', onChain: true, contract: '0x3C7e352481F4b2fdEc1e642a3f0018661c77513D', chain: 'eth', openSeaSlug: 'devcon-vi-suit-up-collection' },
// { collectionID: 'Town-Hall', onChain: true, contract: '0x81b30ff521D1fEB67EDE32db726D95714eb00637', chain: 'Optimism' },
{
collectionID: "Blusteak Kangaroo #64",
onChain: true,
contract: "0xa996F7F3BC647EebC98C684aB0A302c9b85d2FA1",
chain: "Avalanche",
},
{
collectionID: "Alone Pirate",
onChain: true,
contract: "0x36535ec384B94342558e37282527b5052587af6A",
chain: "Arbitrum",
},
// {
// collectionID: "Blusteak Kangaroo #64",
// onChain: true,
// contract: "0xa996F7F3BC647EebC98C684aB0A302c9b85d2FA1",
// chain: "Avalanche",
// },
// {
// collectionID: "Alone Pirate",
// onChain: true,
// contract: "0x36535ec384B94342558e37282527b5052587af6A",
// chain: "Arbitrum",
// },
// {
// collectionID: "NBA",
// onChain: true,
Expand All @@ -150,27 +193,27 @@
// // Add fungible as a boolean
// // symbol: 'USX'
// },
{
contract: "0x107065a122f92636a1358a70a0efe0f1a080a7e5",
onChain: true,
fungible: true,
collectionID: "USX",
chain: "matic",
},
{
contract: "0x429f49faec3d568ef83ec803e02df78e25d5ee7d",
onChain: true,
fungible: true,
collectionID: "Ella",
chain: "matic",
},
{
contract: "0xaaa5b9e6c589642f98a1cda99b9d024b8407285a",
onChain: true,
fungible: true,
collectionID: "TITAN",
chain: "matic",
},
// {
// contract: "0x107065a122f92636a1358a70a0efe0f1a080a7e5",
// onChain: true,
// fungible: true,
// collectionID: "USX",
// chain: "matic",
// },
// {
// contract: "0x429f49faec3d568ef83ec803e02df78e25d5ee7d",
// onChain: true,
// fungible: true,
// collectionID: "Ella",
// chain: "matic",
// },
// {
// contract: "0xaaa5b9e6c589642f98a1cda99b9d024b8407285a",
// onChain: true,
// fungible: true,
// collectionID: "TITAN",
// chain: "matic",
// },
],
uiOptions: {
openingHeading:
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tokenscript/token-negotiator",
"version": "2.8.0",
"version": "2.8.0-nick-test",
"description": "Token-negotiator a token attestation bridge between web 2.0 and 3.0.",
"module": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
20 changes: 19 additions & 1 deletion src/client/auth/abstractAuthentication.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AuthenticateInterface, OffChainTokenConfig, OnChainTokenConfig } from '../interface'
import { AuthenticateInterface, MultiTokenInterface, OffChainTokenConfig, OnChainTokenConfig } from '../interface'
import { Client } from '../index'

export interface AuthenticationResult {
Expand All @@ -19,6 +19,24 @@ export interface AuthenticationMethod {
): Promise<AuthenticationResult>
}

export interface AuthenticationMethodUN {
TYPE: string
getTokenProof(request: AuthenticateInterface): Promise<AuthenticationResult>
micwallace marked this conversation as resolved.
Show resolved Hide resolved
}

export interface MultiAuthenticateInterface {
options?: any
micwallace marked this conversation as resolved.
Show resolved Hide resolved
}

export interface AuthenticationMethodMulti {
TYPE: string
getTokenProofMulti(
tokenOrigin: string,
tokens: { [issuerName: string]: MultiTokenInterface },
options: MultiAuthenticateInterface,
): Promise<AuthenticationResult>
}

export abstract class AbstractAuthentication {
public abstract TYPE: string

Expand Down
10 changes: 3 additions & 7 deletions src/client/auth/signedUNChallenge.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import { AbstractAuthentication, AuthenticationMethod, AuthenticationResult } from './abstractAuthentication'
import { AbstractAuthentication, AuthenticationMethod, AuthenticationResult, AuthenticationMethodUN } from './abstractAuthentication'
import { AuthenticateInterface, OffChainTokenConfig, OnChainTokenConfig } from '../interface'
import { SafeConnectProvider } from '../../wallet/SafeConnectProvider'
import { UN, UNInterface } from './util/UN'
import { logger } from '../../utils'

export class SignedUNChallenge extends AbstractAuthentication implements AuthenticationMethod {
export class SignedUNChallenge extends AbstractAuthentication implements AuthenticationMethodUN {
TYPE = 'signedUN'
private static DEFAULT_ENDPOINT = 'https://attestation-verify.tokenscript.org/un'
nicktaras marked this conversation as resolved.
Show resolved Hide resolved

async getTokenProof(
_issuerConfig: OnChainTokenConfig | OffChainTokenConfig,
_tokens: Array<any>,
request: AuthenticateInterface,
): Promise<AuthenticationResult> {
async getTokenProof(request: AuthenticateInterface): Promise<any> {
let web3WalletProvider = await this.client.getWalletProvider()

// TODO: Update once Flow & Solana signing support is added
Expand Down
8 changes: 5 additions & 3 deletions src/client/auth/ticketZKProof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { Authenticator } from '@tokenscript/attestation'
import { SignedUNChallenge } from './signedUNChallenge'
import { UNInterface } from './util/UN'
import { LocalOutlet } from '../../outlet/localOutlet'
import { OutletIssuerInterface } from '../../outlet'
import { createIssuerHashArray, logger } from '../../utils'
import { shouldUseRedirectMode } from '../../utils/support/getBrowserData'
import { EasZkProof } from '@tokenscript/attestation/dist/eas/EasZkProof'
import { DEFAULT_EAS_SCHEMA, TokenType } from '../../outlet/ticketStorage'
import { EAS_RPC_CONFIG } from '../../core/eas'
import { OutletIssuerInterface } from '../../outlet/interfaces'

export class TicketZKProof extends AbstractAuthentication implements AuthenticationMethod {
TYPE = 'ticketZKProof'
Expand Down Expand Up @@ -39,7 +39,7 @@ export class TicketZKProof extends AbstractAuthentication implements Authenticat
...request.options,
unEndPoint: issuerConfig.unEndPoint,
}
let unRes = await unChallenge.getTokenProof(issuerConfig, tokens, request)
let unRes = await unChallenge.getTokenProof(request)
useEthKey = unRes.data as UNInterface
}

Expand All @@ -50,7 +50,9 @@ export class TicketZKProof extends AbstractAuthentication implements Authenticat
let data

if (new URL(issuerConfig.tokenOrigin).origin === window.location.origin) {
const localOutlet = new LocalOutlet(Object.values(this.client.getTokenStore().getCurrentIssuers(false)) as OffChainTokenConfig[])
const localOutlet = new LocalOutlet(
Object.values(this.client.getTokenStore().getCurrentIssuers(false)) as unknown as OutletIssuerInterface[],
)

const issuerHashes = createIssuerHashArray(issuerConfig)

Expand Down
Loading