Skip to content

Commit

Permalink
Merge pull request #847 from TokenScript/feature/text-config
Browse files Browse the repository at this point in the history
added more text config options
  • Loading branch information
nicktaras authored Sep 28, 2023
2 parents 9cc4f10 + 9ede23d commit 78dd7cc
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 16 deletions.
6 changes: 6 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,12 @@
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",
walletDidntConnectAction: "Wallet didn't connect",
cancelAction: "Cancel",
openingAction: "Let's Go!",
theme: theme,
position: "top-right",
Expand Down
2 changes: 1 addition & 1 deletion src/client/auth/signedUNChallenge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class SignedUNChallenge extends AbstractAuthentication implements Authent
}
}

if (!currentProof){
if (!currentProof) {
let walletConnection = connection.provider

currentProof = {
Expand Down
33 changes: 19 additions & 14 deletions src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -747,11 +747,14 @@ export class Client {
}

private async loadRemoteOutletTokens(issuer: OffChainTokenConfig): Promise<OutletTokenResult | void> {
this.tokenStore.setTokens(issuer.collectionID, [])
const redirectRequired = shouldUseRedirectMode(this.config.offChainRedirectMode)
if (redirectRequired) this.tokenStore.setTokens(issuer.collectionID, [])
this.ui.showLoader(
'<h4>Connecting to issuers...</h4>',
'<small>Your browser will re-direct shortly</small>',
"<button class='cancel-autoload-btn btn-tn' aria-label='Cancel authentication'>Cancel</button>",
`<h4>${this.config.uiOptions?.reDirectIssuerEventHeading ?? 'Connecting to Issuers...'}</h4>`,
`<small>${this.config.uiOptions?.reDirectIssuerBodyEvent ?? 'Your browser will re-direct shortly'}</small>`,
`<button class='cancel-autoload-btn btn-tn' aria-label='Cancel page re-direct'>${
this.config.uiOptions?.cancelAction ?? 'Cancel'
}</button>`,
)
this.enableTokenAutoLoadCancel()
if (this.config.uiOptions?.userCancelIssuerAutoRedirectTimer) await sleep(this.config.uiOptions.userCancelIssuerAutoRedirectTimer)
Expand All @@ -768,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 ?? {}
}

Expand Down Expand Up @@ -850,9 +851,11 @@ export class Client {
if (this.ui) {
this.ui.showLoaderDelayed(
[
'<h4>Authenticating...</h4>',
'<small>You may need to sign a new challenge in your wallet</small>',
"<button class='cancel-auth-btn btn-tn' aria-label='Cancel authentication'>Cancel</button>",
`<h4>${this.config.uiOptions?.authenticationHeadingEvent ?? 'Authenticating...'}</h4>`,
`<small>${this.config.uiOptions?.authenticationBodyEvent ?? 'You may need to sign a new challenge in your wallet'}</small>`,
`<button class='cancel-auth-btn btn-tn' aria-label='Cancel authentication'>${
this.config.uiOptions?.cancelAction ?? 'Cancel'
}</button>`,
],
600,
true,
Expand Down Expand Up @@ -881,7 +884,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
}
Expand Down Expand Up @@ -923,9 +926,11 @@ export class Client {
if (this.ui) {
this.ui.showLoaderDelayed(
[
'<h4>Authenticating...</h4>',
'<small>You may need to sign a new challenge in your wallet</small>',
"<button class='cancel-auth-btn btn-tn' aria-label='Cancel authentication'>Cancel</button>",
`<h4>${this.config.uiOptions?.authenticationHeadingEvent ?? 'Authenticating...'}</h4>`,
`<small>${this.config.uiOptions?.authenticationBodyEvent ?? 'You may need to sign a new challenge in your wallet'}</small>`,
`<button class='cancel-auth-btn btn-tn' aria-label='Cancel authentication'>${
this.config.uiOptions?.cancelAction ?? 'Cancel'
}</button>`,
],
600,
true,
Expand Down
7 changes: 7 additions & 0 deletions src/client/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ export interface UIOptionsInterface {
openingAction?: string
issuerHeading?: string
repeatAction?: string
cancelAction?: string
walletDidntConnectAction?: string
authenticationHeadingEvent?: string
authenticationBodyEvent?: string
reDirectIssuerEventHeading?: string
reDirectIssuerBodyEvent?: string

theme?: UItheme
position?: PopupPosition
autoPopup?: boolean
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/Web3WalletProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 78dd7cc

Please sign in to comment.