Skip to content

Commit

Permalink
Merge pull request #794 from TokenScript/fix/authenticate-on-chain
Browse files Browse the repository at this point in the history
fix authentication for on chain
  • Loading branch information
nicktaras authored Aug 16, 2023
2 parents b489a92 + f66605c commit 7ad2475
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -895,16 +895,16 @@ export class Client {
async authenticateToken(authRequest: AuthenticateInterface) {
await this.checkUserAgentSupport('authentication')

const { unsignedToken } = authRequest
const issuer = unsignedToken.collectionId
const { unsignedToken, issuer } = authRequest
const tokenIssuer = issuer ?? unsignedToken.collectionId

requiredParams(issuer && unsignedToken, 'Issuer and unsigned token required.')
requiredParams(tokenIssuer && unsignedToken, 'Issuer and unsigned token required.')

if (unsignedToken.signedToken) {
delete unsignedToken.signedToken
}

const config = this.tokenStore.getCurrentIssuers()[issuer]
const config = this.tokenStore.getCurrentIssuers()[tokenIssuer]

if (!config) errorHandler('Provided issuer was not found.', 'error', null, null, true, true)

Expand All @@ -920,7 +920,7 @@ export class Client {
600,
true,
)
this.enableAuthCancel(issuer)
this.enableAuthCancel(tokenIssuer)
}

let AuthType
Expand Down Expand Up @@ -951,15 +951,15 @@ export class Client {

logger(2, 'Ticket proof successfully validated.')

this.eventSender('token-proof', { data: res.data, error: null, issuer })
this.eventSender('token-proof', { data: res.data, error: null, issuer: tokenIssuer })
} catch (err) {
logger(2, err)

if (err.message === 'WALLET_REQUIRED') {
return this.handleWalletRequired(authRequest)
}

errorHandler(err, 'error', () => this.handleProofError(err, issuer), null, false, true)
errorHandler(err, 'error', () => this.handleProofError(err, tokenIssuer), null, false, true)
}

if (this.ui) {
Expand Down

0 comments on commit 7ad2475

Please sign in to comment.