From cceeafd7223052994791c8a645a476e604564a96 Mon Sep 17 00:00:00 2001 From: Nick Taras Date: Wed, 27 Sep 2023 21:08:49 +1000 Subject: [PATCH 1/4] added more text config options --- index.html | 5 +++++ src/client/index.ts | 26 ++++++++++++++++---------- src/client/ui.ts | 5 +++++ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/index.html b/index.html index d0b62a0a..b2e7d118 100644 --- a/index.html +++ b/index.html @@ -308,6 +308,11 @@ noTokensFoundEvent: 'No Tokens Found', balancesFoundEvent: 'Balance Found', nftsFoundEvent: 'Token(s) Found', + reDirectIssuerHeadingEvent: 'Connecting to Issuers...', + reDirectIssuerBodyEvent: "Your browser will re-direct shortly", + authenticationHeadingEvent: 'Authenticating...', + authenticationBodyEvent: "You may need to sign a new challenge in your wallet", + cancelAction: "Cancel", openingAction: "Let's Go!", theme: theme, position: "top-right", diff --git a/src/client/index.ts b/src/client/index.ts index 958a0b63..4b55e90d 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -749,9 +749,11 @@ export class Client { private async loadRemoteOutletTokens(issuer: OffChainTokenConfig): Promise { this.tokenStore.setTokens(issuer.collectionID, []) this.ui.showLoader( - '

Connecting to issuers...

', - 'Your browser will re-direct shortly', - "", + `

${this.config.uiOptions.reDirectIssuerEventHeading ?? 'Connecting to Issuers...'}

`, + `${this.config.uiOptions.reDirectIssuerBodyEvent ?? 'Your browser will re-direct shortly'}`, + ``, ) this.enableTokenAutoLoadCancel() if (this.config.uiOptions?.userCancelIssuerAutoRedirectTimer) await sleep(this.config.uiOptions.userCancelIssuerAutoRedirectTimer) @@ -850,9 +852,11 @@ export class Client { if (this.ui) { this.ui.showLoaderDelayed( [ - '

Authenticating...

', - 'You may need to sign a new challenge in your wallet', - "", + `

${this.config.uiOptions.authenticationHeadingEvent ?? 'Authenticating...'}

`, + `${this.config.uiOptions.authenticationBodyEvent ?? 'You may need to sign a new challenge in your wallet'}`, + ``, ], 600, true, @@ -881,7 +885,7 @@ export class Client { if (err.message === 'WALLET_REQUIRED') { return this.handleWalletRequired(authRequest) } - // errorHandler(err, 'error', () => this.handleProofError(err, `multi issuer authentication via ${tokenOrigin}`), null, false, true) + // errorHandler(err, 'error', () => this.handleProofError(err, `multi issuer authentication via ${ tokenOrigin }`), null, false, true) console.error(err) throw err } @@ -923,9 +927,11 @@ export class Client { if (this.ui) { this.ui.showLoaderDelayed( [ - '

Authenticating...

', - 'You may need to sign a new challenge in your wallet', - "", + `

${this.config.uiOptions.authenticationHeadingEvent ?? 'Authenticating...'}

`, + `${this.config.uiOptions.authenticationBodyEvent ?? 'You may need to sign a new challenge in your wallet'}`, + ``, ], 600, true, diff --git a/src/client/ui.ts b/src/client/ui.ts index c3590018..16b970e3 100644 --- a/src/client/ui.ts +++ b/src/client/ui.ts @@ -25,6 +25,11 @@ export interface UIOptionsInterface { openingAction?: string issuerHeading?: string repeatAction?: string + cancelAction?: string + authenticationHeadingEvent?: string + authenticationBodyEvent?: string + reDirectIssuerEventHeading?: string + reDirectIssuerBodyEvent?: string theme?: UItheme position?: PopupPosition autoPopup?: boolean From bad56d58335d40273f92aca9659a9f07950e3df2 Mon Sep 17 00:00:00 2001 From: Nick Taras Date: Wed, 27 Sep 2023 21:25:03 +1000 Subject: [PATCH 2/4] added more text config options --- index.html | 1 + src/client/auth/signedUNChallenge.ts | 2 +- src/client/index.ts | 20 ++++++++++---------- src/client/ui.ts | 2 ++ src/wallet/Web3WalletProvider.ts | 2 +- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/index.html b/index.html index b2e7d118..c435f7ae 100644 --- a/index.html +++ b/index.html @@ -312,6 +312,7 @@ reDirectIssuerBodyEvent: "Your browser will re-direct shortly", authenticationHeadingEvent: 'Authenticating...', authenticationBodyEvent: "You may need to sign a new challenge in your wallet", + walletDidntConnectAction: "Wallet didn't connect", cancelAction: "Cancel", openingAction: "Let's Go!", theme: theme, diff --git a/src/client/auth/signedUNChallenge.ts b/src/client/auth/signedUNChallenge.ts index 37cc4195..0e476ce7 100644 --- a/src/client/auth/signedUNChallenge.ts +++ b/src/client/auth/signedUNChallenge.ts @@ -34,7 +34,7 @@ export class SignedUNChallenge extends AbstractAuthentication implements Authent } } - if (!currentProof){ + if (!currentProof) { let walletConnection = connection.provider currentProof = { diff --git a/src/client/index.ts b/src/client/index.ts index 4b55e90d..9d8d532e 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -749,14 +749,14 @@ export class Client { private async loadRemoteOutletTokens(issuer: OffChainTokenConfig): Promise { this.tokenStore.setTokens(issuer.collectionID, []) this.ui.showLoader( - `

${this.config.uiOptions.reDirectIssuerEventHeading ?? 'Connecting to Issuers...'}

`, - `${this.config.uiOptions.reDirectIssuerBodyEvent ?? 'Your browser will re-direct shortly'}`, + `

${this.config.uiOptions?.reDirectIssuerEventHeading ?? 'Connecting to Issuers...'}

`, + `${this.config.uiOptions?.reDirectIssuerBodyEvent ?? 'Your browser will re-direct shortly'}`, ``, ) this.enableTokenAutoLoadCancel() - if (this.config.uiOptions?.userCancelIssuerAutoRedirectTimer) await sleep(this.config.uiOptions.userCancelIssuerAutoRedirectTimer) + if (this.config.uiOptions?.userCancelIssuerAutoRedirectTimer) await sleep(this.config.uiOptions?.userCancelIssuerAutoRedirectTimer) if (this.userCancelTokenAutoload) { return {} } @@ -852,10 +852,10 @@ export class Client { if (this.ui) { this.ui.showLoaderDelayed( [ - `

${this.config.uiOptions.authenticationHeadingEvent ?? 'Authenticating...'}

`, - `${this.config.uiOptions.authenticationBodyEvent ?? 'You may need to sign a new challenge in your wallet'}`, + `

${this.config.uiOptions?.authenticationHeadingEvent ?? 'Authenticating...'}

`, + `${this.config.uiOptions?.authenticationBodyEvent ?? 'You may need to sign a new challenge in your wallet'}`, ``, ], 600, @@ -927,10 +927,10 @@ export class Client { if (this.ui) { this.ui.showLoaderDelayed( [ - `

${this.config.uiOptions.authenticationHeadingEvent ?? 'Authenticating...'}

`, - `${this.config.uiOptions.authenticationBodyEvent ?? 'You may need to sign a new challenge in your wallet'}`, + `

${this.config.uiOptions?.authenticationHeadingEvent ?? 'Authenticating...'}

`, + `${this.config.uiOptions?.authenticationBodyEvent ?? 'You may need to sign a new challenge in your wallet'}`, ``, ], 600, diff --git a/src/client/ui.ts b/src/client/ui.ts index 16b970e3..cce414e5 100644 --- a/src/client/ui.ts +++ b/src/client/ui.ts @@ -26,10 +26,12 @@ export interface UIOptionsInterface { issuerHeading?: string repeatAction?: string cancelAction?: string + walletDidntConnectAction?: string authenticationHeadingEvent?: string authenticationBodyEvent?: string reDirectIssuerEventHeading?: string reDirectIssuerBodyEvent?: string + theme?: UItheme position?: PopupPosition autoPopup?: boolean diff --git a/src/wallet/Web3WalletProvider.ts b/src/wallet/Web3WalletProvider.ts index dbabf81f..e56dc4ef 100644 --- a/src/wallet/Web3WalletProvider.ts +++ b/src/wallet/Web3WalletProvider.ts @@ -161,7 +161,7 @@ export class Web3WalletProvider { // @ts-ignore let address = await this[walletType as keyof Web3WalletProvider](checkConnectionOnly) - if (!address) throw new Error("Wallet didn't connect") + if (!address) throw new Error(this.client.config.uiOptions?.walletDidntConnectAction ?? "Wallet didn't connect") this.saveConnections() this.emitSavedConnection(address) From 9855cb70ae575f608add97cb9c8af17d196eeee6 Mon Sep 17 00:00:00 2001 From: Nick Taras Date: Wed, 27 Sep 2023 21:26:29 +1000 Subject: [PATCH 3/4] added more text config options --- src/client/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/index.ts b/src/client/index.ts index 9d8d532e..a13182b9 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -756,7 +756,7 @@ export class Client { }`, ) this.enableTokenAutoLoadCancel() - if (this.config.uiOptions?.userCancelIssuerAutoRedirectTimer) await sleep(this.config.uiOptions?.userCancelIssuerAutoRedirectTimer) + if (this.config.uiOptions?.userCancelIssuerAutoRedirectTimer) await sleep(this.config.uiOptions.userCancelIssuerAutoRedirectTimer) if (this.userCancelTokenAutoload) { return {} } From 9ede23d182c87cb769bf5223fa82f5acd62b37ab Mon Sep 17 00:00:00 2001 From: Nick Taras Date: Thu, 28 Sep 2023 13:56:32 +1000 Subject: [PATCH 4/4] allow for forced non re-direct mode --- src/client/index.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/client/index.ts b/src/client/index.ts index a13182b9..3705eb68 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -747,7 +747,8 @@ export class Client { } private async loadRemoteOutletTokens(issuer: OffChainTokenConfig): Promise { - this.tokenStore.setTokens(issuer.collectionID, []) + const redirectRequired = shouldUseRedirectMode(this.config.offChainRedirectMode) + if (redirectRequired) this.tokenStore.setTokens(issuer.collectionID, []) this.ui.showLoader( `

${this.config.uiOptions?.reDirectIssuerEventHeading ?? 'Connecting to Issuers...'}

`, `${this.config.uiOptions?.reDirectIssuerBodyEvent ?? 'Your browser will re-direct shortly'}`, @@ -770,11 +771,9 @@ export class Client { }, this.config.messagingForceTab, this.config.type === 'active' ? this.ui : null, - window.location.href, + redirectRequired ? window.location.href : false, ) - if (!res) return // Site is redirecting - return res.data?.tokens ?? {} }