diff --git a/javascript/tokenscript-viewer/src/components.d.ts b/javascript/tokenscript-viewer/src/components.d.ts index 2c1975f..e3ab9c0 100644 --- a/javascript/tokenscript-viewer/src/components.d.ts +++ b/javascript/tokenscript-viewer/src/components.d.ts @@ -281,10 +281,6 @@ export interface StsViewerCustomEvent extends CustomEvent { detail: T; target: HTMLStsViewerElement; } -export interface TlinkApiCustomEvent extends CustomEvent { - detail: T; - target: HTMLTlinkApiElement; -} export interface TlinkCardViewerCustomEvent extends CustomEvent { detail: T; target: HTMLTlinkCardViewerElement; @@ -596,19 +592,7 @@ declare global { prototype: HTMLTabbedViewerElement; new (): HTMLTabbedViewerElement; }; - interface HTMLTlinkApiElementEventMap { - "showLoader": void; - "hideLoader": void; - } interface HTMLTlinkApiElement extends Components.TlinkApi, HTMLStencilElement { - addEventListener(type: K, listener: (this: HTMLTlinkApiElement, ev: TlinkApiCustomEvent) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: HTMLTlinkApiElement, ev: TlinkApiCustomEvent) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; } var HTMLTlinkApiElement: { prototype: HTMLTlinkApiElement; @@ -1015,8 +999,6 @@ declare namespace LocalJSX { } interface TlinkApi { "app"?: AppRoot; - "onHideLoader"?: (event: TlinkApiCustomEvent) => void; - "onShowLoader"?: (event: TlinkApiCustomEvent) => void; } interface TlinkCardViewer { "app"?: AppRoot; diff --git a/javascript/tokenscript-viewer/src/components/viewers/tlink-api/tlink-api.tsx b/javascript/tokenscript-viewer/src/components/viewers/tlink-api/tlink-api.tsx index 35aae56..0e84d45 100644 --- a/javascript/tokenscript-viewer/src/components/viewers/tlink-api/tlink-api.tsx +++ b/javascript/tokenscript-viewer/src/components/viewers/tlink-api/tlink-api.tsx @@ -27,20 +27,6 @@ export class TlinkApi { @Prop() app: AppRoot; - @Event({ - eventName: 'showLoader', - composed: true, - cancelable: true, - bubbles: true, - }) showLoader: EventEmitter; - - @Event({ - eventName: 'hideLoader', - composed: true, - cancelable: true, - bubbles: true, - }) hideLoader: EventEmitter; - async componentDidLoad(){ const urlParams = new URLSearchParams(document.location.search); @@ -90,8 +76,8 @@ export class TlinkApi { Tapp Viewer -
- +
+

Please wait...

diff --git a/javascript/tokenscript-viewer/src/integration/googleRecaptcha.ts b/javascript/tokenscript-viewer/src/integration/googleRecaptcha.ts index a0da882..8f56845 100644 --- a/javascript/tokenscript-viewer/src/integration/googleRecaptcha.ts +++ b/javascript/tokenscript-viewer/src/integration/googleRecaptcha.ts @@ -1,5 +1,8 @@ declare global { + interface Window { + grecaptcha: any; + } var grecaptcha: any; } @@ -9,6 +12,15 @@ const widgetIds : {[siteKey: string]: number} = {}; export async function getRecaptchaToken(sitekey?: string, action?: string){ + // Wait for script tag to load + if (!window.grecaptcha){ + for (let i = 0; i<10; i++){ + await new Promise((resolve) => setTimeout(resolve, 500)); + if (window.grecaptcha) + break; + } + } + return new Promise((resolve, reject) => { if (!sitekey) diff --git a/javascript/tokenscript-viewer/src/integration/turnstileCaptcha.ts b/javascript/tokenscript-viewer/src/integration/turnstileCaptcha.ts index 9db07c0..48163d5 100644 --- a/javascript/tokenscript-viewer/src/integration/turnstileCaptcha.ts +++ b/javascript/tokenscript-viewer/src/integration/turnstileCaptcha.ts @@ -1,5 +1,8 @@ declare global { + interface Window { + turnstile: any; + } var turnstile: any; } @@ -7,6 +10,15 @@ const DEFAULT_SITE_KEY = "0x4AAAAAAA0Rmw6kZyekmiSB"; export async function getTurnstileToken(sitekey?: string){ + // Wait for script tag to load + if (!window.turnstile){ + for (let i = 0; i<10; i++){ + await new Promise((resolve) => setTimeout(resolve, 500)); + if (window.turnstile) + break; + } + } + return new Promise((resolve, reject) => { if (!sitekey)