siarashield_workspace 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -34,7 +34,7 @@ SIARASHIELD_PRIVATE_KEY=TEST-CYBERSIARA
34
34
  5. **Initialize and validate**
35
35
 
36
36
  ```ts
37
- import { initSiaraShield, checkSiaraShieldCaptcha } from 'siarashield_workspace';
37
+ import { initSiaraShield, checkSiaraShieldCaptchaAsync } from 'siarashield_workspace';
38
38
 
39
39
  await initSiaraShield({
40
40
  publicKey: 'TEST-CYBERSIARA',
@@ -43,7 +43,7 @@ await initSiaraShield({
43
43
  // cspNonce: 'YOUR_NONCE_VALUE',
44
44
  });
45
45
 
46
- const result = checkSiaraShieldCaptcha();
46
+ const result = await checkSiaraShieldCaptchaAsync();
47
47
  if (result.ok) {
48
48
  console.log(result.token);
49
49
  // your submit API logic here
@@ -52,6 +52,7 @@ if (result.ok) {
52
52
 
53
53
  6. **Submit only when captcha is valid**
54
54
  - Put submit logic inside `if (result.ok)`.
55
+ - For best UX, use async check (`checkSiaraShieldCaptchaAsync`) to avoid first-click timing delay.
55
56
 
56
57
  ## jQuery behavior in this package
57
58
 
@@ -5,6 +5,9 @@ import { DOCUMENT } from '@angular/common';
5
5
  function getSiaraShieldGlobals() {
6
6
  return globalThis;
7
7
  }
8
+ function getInitCaptchaFn(g) {
9
+ return g.initCaptcha ?? g.InitCaptcha;
10
+ }
8
11
 
9
12
  class SiaraShieldLoaderService {
10
13
  document;
@@ -58,6 +61,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImpor
58
61
  }] }] });
59
62
 
60
63
  const JQUERY_FALLBACK_SRC$1 = 'https://embedcdn.mycybersiara.com/capcha-temple/js/jquery.min.js';
64
+ const CAPTCHA_READY_TIMEOUT_MS$1 = 8000;
61
65
  class SiaraShieldComponent {
62
66
  host;
63
67
  loader;
@@ -92,10 +96,12 @@ class SiaraShieldComponent {
92
96
  nonce: cspNonce,
93
97
  });
94
98
  const g = getSiaraShieldGlobals();
95
- if (!g.initCaptcha) {
96
- throw new Error('SiaraShield: initCaptcha() is not available after loading scripts.');
99
+ const initCaptchaFn = getInitCaptchaFn(g);
100
+ if (!initCaptchaFn) {
101
+ throw new Error('SiaraShield: InitCaptcha() is not available after loading scripts.');
97
102
  }
98
- g.initCaptcha(options.publicKey);
103
+ initCaptchaFn(options.publicKey);
104
+ await this.waitForCheckCaptchaApi();
99
105
  this.initialized = true;
100
106
  }
101
107
  /**
@@ -123,6 +129,16 @@ class SiaraShieldComponent {
123
129
  const nonceMeta = doc.querySelector('meta[name="csp-nonce"]');
124
130
  return nonceMeta?.content || undefined;
125
131
  }
132
+ async waitForCheckCaptchaApi(timeoutMs = CAPTCHA_READY_TIMEOUT_MS$1) {
133
+ const startedAt = Date.now();
134
+ while (Date.now() - startedAt < timeoutMs) {
135
+ if (getSiaraShieldGlobals().CheckCaptcha) {
136
+ return;
137
+ }
138
+ await new Promise((resolve) => setTimeout(resolve, 100));
139
+ }
140
+ throw new Error('SiaraShield: CheckCaptcha() was not available within timeout.');
141
+ }
126
142
  /**
127
143
  * Calls the global `CheckCaptcha()` from SiaraShield script.
128
144
  * Returns true when captcha is valid; emits token if available.
@@ -138,6 +154,25 @@ class SiaraShieldComponent {
138
154
  }
139
155
  return ok;
140
156
  }
157
+ /**
158
+ * Async-friendly captcha validation to avoid first-click timing issues.
159
+ * Retries briefly until token/check API settles.
160
+ */
161
+ async checkCaptchaAsync(options) {
162
+ const timeoutMs = options?.timeoutMs ?? 2000;
163
+ const pollIntervalMs = options?.pollIntervalMs ?? 120;
164
+ const startedAt = Date.now();
165
+ if (this.checkCaptcha()) {
166
+ return true;
167
+ }
168
+ while (Date.now() - startedAt < timeoutMs) {
169
+ await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
170
+ if (this.checkCaptcha()) {
171
+ return true;
172
+ }
173
+ }
174
+ return false;
175
+ }
141
176
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SiaraShieldComponent, deps: [{ token: i0.ElementRef }, { token: SiaraShieldLoaderService }], target: i0.ɵɵFactoryTarget.Component });
142
177
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.5", type: SiaraShieldComponent, isStandalone: true, selector: "siara-shield", inputs: { publicKey: "publicKey", loadJQuery: "loadJQuery", cspNonce: "cspNonce" }, outputs: { token: "token" }, ngImport: i0, template: `<div class="SiaraShield"></div>`, isInline: true, encapsulation: i0.ViewEncapsulation.None });
143
178
  }
@@ -161,6 +196,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImpor
161
196
  }] } });
162
197
 
163
198
  const JQUERY_FALLBACK_SRC = 'https://embedcdn.mycybersiara.com/capcha-temple/js/jquery.min.js';
199
+ const CAPTCHA_READY_TIMEOUT_MS = 8000;
164
200
  let pending = null;
165
201
  let initialized = false;
166
202
  function loadScript(src, nonce) {
@@ -195,6 +231,16 @@ function isJQueryAlreadyAvailable() {
195
231
  const existingJqueryScript = document.querySelector('script[src*="jquery"]');
196
232
  return Boolean(existingJqueryScript);
197
233
  }
234
+ async function waitForCheckCaptchaApi(timeoutMs = CAPTCHA_READY_TIMEOUT_MS) {
235
+ const startedAt = Date.now();
236
+ while (Date.now() - startedAt < timeoutMs) {
237
+ if (getSiaraShieldGlobals().CheckCaptcha) {
238
+ return;
239
+ }
240
+ await new Promise((resolve) => setTimeout(resolve, 100));
241
+ }
242
+ throw new Error('SiaraShield: CheckCaptcha() was not available within timeout.');
243
+ }
198
244
  /**
199
245
  * Drop-in initializer for SiaraShield.
200
246
  * - Loads required scripts (optionally jQuery)
@@ -218,10 +264,12 @@ async function initSiaraShield(options) {
218
264
  }
219
265
  await loadScript('https://embedcdn.mycybersiara.com/CaptchaFormate/CaptchaResources.js', cspNonce);
220
266
  const g = getSiaraShieldGlobals();
221
- if (!g.initCaptcha) {
222
- throw new Error('SiaraShield: initCaptcha() is not available after loading scripts.');
267
+ const initCaptchaFn = getInitCaptchaFn(g);
268
+ if (!initCaptchaFn) {
269
+ throw new Error('SiaraShield: InitCaptcha() is not available after loading scripts.');
223
270
  }
224
- g.initCaptcha(options.publicKey);
271
+ initCaptchaFn(options.publicKey);
272
+ await waitForCheckCaptchaApi();
225
273
  initialized = true;
226
274
  })();
227
275
  try {
@@ -244,6 +292,24 @@ function checkSiaraShieldCaptcha() {
244
292
  const token = typeof g.CyberSiaraToken === 'string' ? g.CyberSiaraToken : undefined;
245
293
  return ok ? { ok: true, token } : { ok: false };
246
294
  }
295
+ /**
296
+ * Async-friendly captcha check to handle delayed token population.
297
+ */
298
+ async function checkSiaraShieldCaptchaAsync(options) {
299
+ const timeoutMs = options?.timeoutMs ?? 2000;
300
+ const pollIntervalMs = options?.pollIntervalMs ?? 120;
301
+ const startedAt = Date.now();
302
+ const firstCheck = checkSiaraShieldCaptcha();
303
+ if (firstCheck.ok)
304
+ return firstCheck;
305
+ while (Date.now() - startedAt < timeoutMs) {
306
+ await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
307
+ const next = checkSiaraShieldCaptcha();
308
+ if (next.ok)
309
+ return next;
310
+ }
311
+ return { ok: false };
312
+ }
247
313
 
248
314
  /*
249
315
  * Public API Surface of siarashield-workspace
@@ -253,5 +319,5 @@ function checkSiaraShieldCaptcha() {
253
319
  * Generated bundle index. Do not edit.
254
320
  */
255
321
 
256
- export { SiaraShieldComponent, SiaraShieldLoaderService, checkSiaraShieldCaptcha, getSiaraShieldGlobals, initSiaraShield };
322
+ export { SiaraShieldComponent, SiaraShieldLoaderService, checkSiaraShieldCaptcha, checkSiaraShieldCaptchaAsync, getInitCaptchaFn, getSiaraShieldGlobals, initSiaraShield };
257
323
  //# sourceMappingURL=siarashield_workspace.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"siarashield_workspace.mjs","sources":["../../../projects/siarashield-workspace/src/lib/siara-shield.globals.ts","../../../projects/siarashield-workspace/src/lib/siara-shield-loader.service.ts","../../../projects/siarashield-workspace/src/lib/siara-shield.component.ts","../../../projects/siarashield-workspace/src/lib/siara-shield.ts","../../../projects/siarashield-workspace/src/public-api.ts","../../../projects/siarashield-workspace/src/siarashield_workspace.ts"],"sourcesContent":["export type InitCaptchaFn = (publicKey: string) => void;\nexport type CheckCaptchaFn = () => boolean;\n\nexport interface SiaraShieldGlobals {\n initCaptcha?: InitCaptchaFn;\n CheckCaptcha?: CheckCaptchaFn;\n CyberSiaraToken?: string;\n jQuery?: unknown;\n $?: unknown;\n}\n\nexport function getSiaraShieldGlobals(): SiaraShieldGlobals {\n return (globalThis as unknown as { [k: string]: unknown }) as SiaraShieldGlobals;\n}\n\n","import { DOCUMENT } from '@angular/common';\nimport { Inject, Injectable } from '@angular/core';\n\ntype ScriptStatus = 'idle' | 'loading' | 'loaded' | 'error';\n\nexport interface ScriptLoadOptions {\n nonce?: string;\n}\n\n@Injectable({ providedIn: 'root' })\nexport class SiaraShieldLoaderService {\n private statusBySrc = new Map<string, ScriptStatus>();\n private pendingBySrc = new Map<string, Promise<void>>();\n\n constructor(@Inject(DOCUMENT) private readonly document: Document) {}\n\n loadScript(src: string, options?: ScriptLoadOptions): Promise<void> {\n const existing = this.document.querySelector<HTMLScriptElement>(`script[src=\"${src}\"]`);\n if (existing) return Promise.resolve();\n\n const status = this.statusBySrc.get(src);\n if (status === 'loaded') return Promise.resolve();\n if (status === 'loading') {\n const pending = this.pendingBySrc.get(src);\n if (pending) return pending;\n }\n\n this.statusBySrc.set(src, 'loading');\n\n const pending = new Promise<void>((resolve, reject) => {\n const script = this.document.createElement('script');\n script.src = src;\n script.async = true;\n if (options?.nonce) {\n script.nonce = options.nonce;\n }\n script.onload = () => {\n this.statusBySrc.set(src, 'loaded');\n resolve();\n };\n script.onerror = () => {\n this.statusBySrc.set(src, 'error');\n reject(new Error(`Failed to load script: ${src}`));\n };\n this.document.head.appendChild(script);\n });\n\n this.pendingBySrc.set(src, pending);\n return pending;\n }\n}\n\n","import { AfterViewInit, Component, ElementRef, EventEmitter, Input, Output, ViewEncapsulation } from '@angular/core';\nimport { SiaraShieldLoaderService } from './siara-shield-loader.service';\nimport { getSiaraShieldGlobals } from './siara-shield.globals';\n\nconst JQUERY_FALLBACK_SRC = 'https://embedcdn.mycybersiara.com/capcha-temple/js/jquery.min.js';\n\nexport interface SiaraShieldInitOptions {\n /** SiaraShield public key. Use \"TEST-CYBERSIARA\" for staging/development. */\n publicKey: string;\n /** Loads jQuery before SiaraShield script. Keep true if your page doesn't already include jQuery. */\n loadJQuery?: boolean;\n /** CSP nonce for strict policies (`script-src 'nonce-...'`). */\n cspNonce?: string;\n}\n\n@Component({\n selector: 'siara-shield',\n standalone: true,\n template: `<div class=\"SiaraShield\"></div>`,\n encapsulation: ViewEncapsulation.None,\n})\nexport class SiaraShieldComponent implements AfterViewInit {\n @Input({ required: true }) publicKey!: string;\n @Input() loadJQuery = true;\n @Input() cspNonce?: string;\n\n /**\n * Emits the current `CyberSiaraToken` right after a successful `checkCaptcha()`.\n */\n @Output() token = new EventEmitter<string>();\n\n private initialized = false;\n\n constructor(\n private readonly host: ElementRef<HTMLElement>,\n private readonly loader: SiaraShieldLoaderService,\n ) {}\n\n async ngAfterViewInit(): Promise<void> {\n await this.init({ publicKey: this.publicKey, loadJQuery: this.loadJQuery, cspNonce: this.cspNonce });\n }\n\n async init(options: SiaraShieldInitOptions): Promise<void> {\n if (this.initialized) return;\n\n // Ensure the host element is in DOM before scripts run.\n void this.host.nativeElement;\n\n if (!options.publicKey) {\n throw new Error('SiaraShieldComponent: publicKey is required.');\n }\n const cspNonce = this.resolveCspNonce(options.cspNonce);\n\n if ((options.loadJQuery ?? true) && !this.isJQueryAlreadyAvailable()) {\n await this.loader.loadScript(JQUERY_FALLBACK_SRC, { nonce: cspNonce });\n }\n\n await this.loader.loadScript('https://embedcdn.mycybersiara.com/CaptchaFormate/CaptchaResources.js', {\n nonce: cspNonce,\n });\n\n const g = getSiaraShieldGlobals();\n if (!g.initCaptcha) {\n throw new Error('SiaraShield: initCaptcha() is not available after loading scripts.');\n }\n\n g.initCaptcha(options.publicKey);\n this.initialized = true;\n }\n\n /**\n * Detect preloaded jQuery from global object or an existing script tag.\n */\n private isJQueryAlreadyAvailable(): boolean {\n const g = getSiaraShieldGlobals();\n if (typeof g.jQuery === 'function' || typeof g.$ === 'function') {\n return true;\n }\n\n const existingJqueryScript = this.host.nativeElement.ownerDocument.querySelector<HTMLScriptElement>(\n 'script[src*=\"jquery\"]',\n );\n return Boolean(existingJqueryScript);\n }\n\n /**\n * Uses explicit nonce first. If not provided, tries to reuse nonce\n * from the first script tag or from `<meta name=\"csp-nonce\">`.\n */\n private resolveCspNonce(explicitNonce?: string): string | undefined {\n if (explicitNonce) return explicitNonce;\n const doc = this.host.nativeElement.ownerDocument;\n const scriptWithNonce = doc.querySelector<HTMLScriptElement>('script[nonce]');\n if (scriptWithNonce?.nonce) return scriptWithNonce.nonce;\n\n const nonceMeta = doc.querySelector<HTMLMetaElement>('meta[name=\"csp-nonce\"]');\n return nonceMeta?.content || undefined;\n }\n\n /**\n * Calls the global `CheckCaptcha()` from SiaraShield script.\n * Returns true when captcha is valid; emits token if available.\n */\n checkCaptcha(): boolean {\n const g = getSiaraShieldGlobals();\n if (!g.CheckCaptcha) {\n throw new Error('SiaraShield: CheckCaptcha() is not available. Did init() run?');\n }\n\n const ok = g.CheckCaptcha();\n if (ok && typeof g.CyberSiaraToken === 'string') {\n this.token.emit(g.CyberSiaraToken);\n }\n return ok;\n }\n}\n\n","import { getSiaraShieldGlobals } from './siara-shield.globals';\n\nconst JQUERY_FALLBACK_SRC = 'https://embedcdn.mycybersiara.com/capcha-temple/js/jquery.min.js';\n\nexport interface InitSiaraShieldOptions {\n /** SiaraShield public key. Use \"TEST-CYBERSIARA\" for staging/development. */\n publicKey: string;\n /**\n * Loads jQuery before SiaraShield script.\n * If your site/app already loads jQuery, set this to false (not required to load again).\n */\n loadJQuery?: boolean;\n /** CSP nonce for strict policies (`script-src 'nonce-...'`). */\n cspNonce?: string;\n}\n\nlet pending: Promise<void> | null = null;\nlet initialized = false;\n\nfunction loadScript(src: string, nonce?: string): Promise<void> {\n const existing = document.querySelector<HTMLScriptElement>(`script[src=\"${src}\"]`);\n if (existing) return Promise.resolve();\n\n return new Promise<void>((resolve, reject) => {\n const script = document.createElement('script');\n script.src = src;\n script.async = true;\n if (nonce) script.nonce = nonce;\n script.onload = () => resolve();\n script.onerror = () => reject(new Error(`Failed to load script: ${src}`));\n document.head.appendChild(script);\n });\n}\n\nfunction resolveCspNonce(explicitNonce?: string): string | undefined {\n if (explicitNonce) return explicitNonce;\n const scriptWithNonce = document.querySelector<HTMLScriptElement>('script[nonce]');\n if (scriptWithNonce?.nonce) return scriptWithNonce.nonce;\n\n const nonceMeta = document.querySelector<HTMLMetaElement>('meta[name=\"csp-nonce\"]');\n return nonceMeta?.content || undefined;\n}\n\nfunction isJQueryAlreadyAvailable(): boolean {\n const g = getSiaraShieldGlobals();\n if (typeof g.jQuery === 'function' || typeof g.$ === 'function') {\n return true;\n }\n\n const existingJqueryScript = document.querySelector<HTMLScriptElement>('script[src*=\"jquery\"]');\n return Boolean(existingJqueryScript);\n}\n\n/**\n * Drop-in initializer for SiaraShield.\n * - Loads required scripts (optionally jQuery)\n * - Calls global `initCaptcha(publicKey)`\n *\n * Requirements in your HTML/template:\n * - You must render: `<div class=\"SiaraShield\"></div>`\n */\nexport async function initSiaraShield(options: InitSiaraShieldOptions): Promise<void> {\n if (initialized) return;\n if (pending) return pending;\n\n if (!options?.publicKey) {\n throw new Error('initSiaraShield: publicKey is required.');\n }\n\n pending = (async () => {\n const cspNonce = resolveCspNonce(options.cspNonce);\n if ((options.loadJQuery ?? true) && !isJQueryAlreadyAvailable()) {\n await loadScript(JQUERY_FALLBACK_SRC, cspNonce);\n }\n\n await loadScript('https://embedcdn.mycybersiara.com/CaptchaFormate/CaptchaResources.js', cspNonce);\n\n const g = getSiaraShieldGlobals();\n if (!g.initCaptcha) {\n throw new Error('SiaraShield: initCaptcha() is not available after loading scripts.');\n }\n\n g.initCaptcha(options.publicKey);\n initialized = true;\n })();\n\n try {\n await pending;\n } finally {\n // keep `pending` cached for subsequent callers\n }\n}\n\n/**\n * Calls global `CheckCaptcha()` and returns its boolean result.\n * If successful, returns `{ ok: true, token?: string }`.\n */\nexport function checkSiaraShieldCaptcha(): { ok: boolean; token?: string } {\n const g = getSiaraShieldGlobals();\n if (!g.CheckCaptcha) {\n throw new Error('SiaraShield: CheckCaptcha() is not available. Did initSiaraShield() run?');\n }\n\n const ok = g.CheckCaptcha();\n const token = typeof g.CyberSiaraToken === 'string' ? g.CyberSiaraToken : undefined;\n return ok ? { ok: true, token } : { ok: false };\n}\n\n","/*\n * Public API Surface of siarashield-workspace\n */\n\nexport * from './lib/siarashield-workspace';\nexport * from './lib/siara-shield.component';\nexport * from './lib/siara-shield-loader.service';\nexport * from './lib/siara-shield.globals';\nexport * from './lib/siara-shield';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["JQUERY_FALLBACK_SRC","i1.SiaraShieldLoaderService"],"mappings":";;;;SAWgB,qBAAqB,GAAA;AACnC,IAAA,OAAQ,UAAwE;AAClF;;MCHa,wBAAwB,CAAA;AAIY,IAAA,QAAA;AAHvC,IAAA,WAAW,GAAG,IAAI,GAAG,EAAwB;AAC7C,IAAA,YAAY,GAAG,IAAI,GAAG,EAAyB;AAEvD,IAAA,WAAA,CAA+C,QAAkB,EAAA;QAAlB,IAAA,CAAA,QAAQ,GAAR,QAAQ;IAAa;IAEpE,UAAU,CAAC,GAAW,EAAE,OAA2B,EAAA;AACjD,QAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAoB,CAAA,YAAA,EAAe,GAAG,CAAA,EAAA,CAAI,CAAC;AACvF,QAAA,IAAI,QAAQ;AAAE,YAAA,OAAO,OAAO,CA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K,CAAC,oEAAoE,CAAC;QACvF;AAEA,QAAA,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,SAAS,CAAC;QAChC,WAAW,GAAG,IAAI;IACpB,CAAC,GAAG;AAEJ,IAAA,IAAI;AACF,QAAA,MAAM,OAAO;IACf;YAAU;;IAEV;AACF;AAEA;;;AAGG;SACa,uBAAuB,GAAA;AACrC,IAAA,MAAM,CAAC,GAAG,qBAAqB,EAAE;AACjC,IAAA,IAAI,CAAC,CAAC,CAAC,YAAY,EAAE;AACnB,QAAA,MAAM,IAAI,KAAK,CAAC,0EAA0E,CAAC;IAC7F;AAEA,IAAA,MAAM,EAAE,GAAG,CAAC,CAAC,YAAY,EAAE;AAC3B,IAAA,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,eAAe,KAAK,QAAQ,GAAG,CAAC,CAAC,eAAe,GAAG,SAAS;AACnF,IAAA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE;AACjD;;AC1GA;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"siarashield_workspace.mjs","sources":["../../../projects/siarashield-workspace/src/lib/siara-shield.globals.ts","../../../projects/siarashield-workspace/src/lib/siara-shield-loader.service.ts","../../../projects/siarashield-workspace/src/lib/siara-shield.component.ts","../../../projects/siarashield-workspace/src/lib/siara-shield.ts","../../../projects/siarashield-workspace/src/public-api.ts","../../../projects/siarashield-workspace/src/siarashield_workspace.ts"],"sourcesContent":["export type InitCaptchaFn = (publicKey: string) => void;\nexport type CheckCaptchaFn = () => boolean;\n\nexport interface SiaraShieldGlobals {\n initCaptcha?: InitCaptchaFn;\n InitCaptcha?: InitCaptchaFn;\n CheckCaptcha?: CheckCaptchaFn;\n CyberSiaraToken?: string;\n jQuery?: unknown;\n $?: unknown;\n}\n\nexport function getSiaraShieldGlobals(): SiaraShieldGlobals {\n return (globalThis as unknown as { [k: string]: unknown }) as SiaraShieldGlobals;\n}\n\nexport function getInitCaptchaFn(g: SiaraShieldGlobals): InitCaptchaFn | undefined {\n return g.initCaptcha ?? g.InitCaptcha;\n}\n\n","import { DOCUMENT } from '@angular/common';\nimport { Inject, Injectable } from '@angular/core';\n\ntype ScriptStatus = 'idle' | 'loading' | 'loaded' | 'error';\n\nexport interface ScriptLoadOptions {\n nonce?: string;\n}\n\n@Injectable({ providedIn: 'root' })\nexport class SiaraShieldLoaderService {\n private statusBySrc = new Map<string, ScriptStatus>();\n private pendingBySrc = new Map<string, Promise<void>>();\n\n constructor(@Inject(DOCUMENT) private readonly document: Document) {}\n\n loadScript(src: string, options?: ScriptLoadOptions): Promise<void> {\n const existing = this.document.querySelector<HTMLScriptElement>(`script[src=\"${src}\"]`);\n if (existing) return Promise.resolve();\n\n const status = this.statusBySrc.get(src);\n if (status === 'loaded') return Promise.resolve();\n if (status === 'loading') {\n const pending = this.pendingBySrc.get(src);\n if (pending) return pending;\n }\n\n this.statusBySrc.set(src, 'loading');\n\n const pending = new Promise<void>((resolve, reject) => {\n const script = this.document.createElement('script');\n script.src = src;\n script.async = true;\n if (options?.nonce) {\n script.nonce = options.nonce;\n }\n script.onload = () => {\n this.statusBySrc.set(src, 'loaded');\n resolve();\n };\n script.onerror = () => {\n this.statusBySrc.set(src, 'error');\n reject(new Error(`Failed to load script: ${src}`));\n };\n this.document.head.appendChild(script);\n });\n\n this.pendingBySrc.set(src, pending);\n return pending;\n }\n}\n\n","import { AfterViewInit, Component, ElementRef, EventEmitter, Input, Output, ViewEncapsulation } from '@angular/core';\nimport { SiaraShieldLoaderService } from './siara-shield-loader.service';\nimport { getInitCaptchaFn, getSiaraShieldGlobals } from './siara-shield.globals';\n\nconst JQUERY_FALLBACK_SRC = 'https://embedcdn.mycybersiara.com/capcha-temple/js/jquery.min.js';\nconst CAPTCHA_READY_TIMEOUT_MS = 8000;\n\nexport interface SiaraShieldInitOptions {\n /** SiaraShield public key. Use \"TEST-CYBERSIARA\" for staging/development. */\n publicKey: string;\n /** Loads jQuery before SiaraShield script. Keep true if your page doesn't already include jQuery. */\n loadJQuery?: boolean;\n /** CSP nonce for strict policies (`script-src 'nonce-...'`). */\n cspNonce?: string;\n}\n\n@Component({\n selector: 'siara-shield',\n standalone: true,\n template: `<div class=\"SiaraShield\"></div>`,\n encapsulation: ViewEncapsulation.None,\n})\nexport class SiaraShieldComponent implements AfterViewInit {\n @Input({ required: true }) publicKey!: string;\n @Input() loadJQuery = true;\n @Input() cspNonce?: string;\n\n /**\n * Emits the current `CyberSiaraToken` right after a successful `checkCaptcha()`.\n */\n @Output() token = new EventEmitter<string>();\n\n private initialized = false;\n\n constructor(\n private readonly host: ElementRef<HTMLElement>,\n private readonly loader: SiaraShieldLoaderService,\n ) {}\n\n async ngAfterViewInit(): Promise<void> {\n await this.init({ publicKey: this.publicKey, loadJQuery: this.loadJQuery, cspNonce: this.cspNonce });\n }\n\n async init(options: SiaraShieldInitOptions): Promise<void> {\n if (this.initialized) return;\n\n // Ensure the host element is in DOM before scripts run.\n void this.host.nativeElement;\n\n if (!options.publicKey) {\n throw new Error('SiaraShieldComponent: publicKey is required.');\n }\n const cspNonce = this.resolveCspNonce(options.cspNonce);\n\n if ((options.loadJQuery ?? true) && !this.isJQueryAlreadyAvailable()) {\n await this.loader.loadScript(JQUERY_FALLBACK_SRC, { nonce: cspNonce });\n }\n\n await this.loader.loadScript('https://embedcdn.mycybersiara.com/CaptchaFormate/CaptchaResources.js', {\n nonce: cspNonce,\n });\n\n const g = getSiaraShieldGlobals();\n const initCaptchaFn = getInitCaptchaFn(g);\n if (!initCaptchaFn) {\n throw new Error('SiaraShield: InitCaptcha() is not available after loading scripts.');\n }\n\n initCaptchaFn(options.publicKey);\n await this.waitForCheckCaptchaApi();\n this.initialized = true;\n }\n\n /**\n * Detect preloaded jQuery from global object or an existing script tag.\n */\n private isJQueryAlreadyAvailable(): boolean {\n const g = getSiaraShieldGlobals();\n if (typeof g.jQuery === 'function' || typeof g.$ === 'function') {\n return true;\n }\n\n const existingJqueryScript = this.host.nativeElement.ownerDocument.querySelector<HTMLScriptElement>(\n 'script[src*=\"jquery\"]',\n );\n return Boolean(existingJqueryScript);\n }\n\n /**\n * Uses explicit nonce first. If not provided, tries to reuse nonce\n * from the first script tag or from `<meta name=\"csp-nonce\">`.\n */\n private resolveCspNonce(explicitNonce?: string): string | undefined {\n if (explicitNonce) return explicitNonce;\n const doc = this.host.nativeElement.ownerDocument;\n const scriptWithNonce = doc.querySelector<HTMLScriptElement>('script[nonce]');\n if (scriptWithNonce?.nonce) return scriptWithNonce.nonce;\n\n const nonceMeta = doc.querySelector<HTMLMetaElement>('meta[name=\"csp-nonce\"]');\n return nonceMeta?.content || undefined;\n }\n\n private async waitForCheckCaptchaApi(timeoutMs = CAPTCHA_READY_TIMEOUT_MS): Promise<void> {\n const startedAt = Date.now();\n while (Date.now() - startedAt < timeoutMs) {\n if (getSiaraShieldGlobals().CheckCaptcha) {\n return;\n }\n await new Promise((resolve) => setTimeout(resolve, 100));\n }\n throw new Error('SiaraShield: CheckCaptcha() was not available within timeout.');\n }\n\n /**\n * Calls the global `CheckCaptcha()` from SiaraShield script.\n * Returns true when captcha is valid; emits token if available.\n */\n checkCaptcha(): boolean {\n const g = getSiaraShieldGlobals();\n if (!g.CheckCaptcha) {\n throw new Error('SiaraShield: CheckCaptcha() is not available. Did init() run?');\n }\n\n const ok = g.CheckCaptcha();\n if (ok && typeof g.CyberSiaraToken === 'string') {\n this.token.emit(g.CyberSiaraToken);\n }\n return ok;\n }\n\n /**\n * Async-friendly captcha validation to avoid first-click timing issues.\n * Retries briefly until token/check API settles.\n */\n async checkCaptchaAsync(options?: { timeoutMs?: number; pollIntervalMs?: number }): Promise<boolean> {\n const timeoutMs = options?.timeoutMs ?? 2000;\n const pollIntervalMs = options?.pollIntervalMs ?? 120;\n const startedAt = Date.now();\n\n if (this.checkCaptcha()) {\n return true;\n }\n\n while (Date.now() - startedAt < timeoutMs) {\n await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));\n if (this.checkCaptcha()) {\n return true;\n }\n }\n\n return false;\n }\n}\n\n","import { getInitCaptchaFn, getSiaraShieldGlobals } from './siara-shield.globals';\n\nconst JQUERY_FALLBACK_SRC = 'https://embedcdn.mycybersiara.com/capcha-temple/js/jquery.min.js';\nconst CAPTCHA_READY_TIMEOUT_MS = 8000;\n\nexport interface InitSiaraShieldOptions {\n /** SiaraShield public key. Use \"TEST-CYBERSIARA\" for staging/development. */\n publicKey: string;\n /**\n * Loads jQuery before SiaraShield script.\n * If your site/app already loads jQuery, set this to false (not required to load again).\n */\n loadJQuery?: boolean;\n /** CSP nonce for strict policies (`script-src 'nonce-...'`). */\n cspNonce?: string;\n}\n\nlet pending: Promise<void> | null = null;\nlet initialized = false;\n\nfunction loadScript(src: string, nonce?: string): Promise<void> {\n const existing = document.querySelector<HTMLScriptElement>(`script[src=\"${src}\"]`);\n if (existing) return Promise.resolve();\n\n return new Promise<void>((resolve, reject) => {\n const script = document.createElement('script');\n script.src = src;\n script.async = true;\n if (nonce) script.nonce = nonce;\n script.onload = () => resolve();\n script.onerror = () => reject(new Error(`Failed to load script: ${src}`));\n document.head.appendChild(script);\n });\n}\n\nfunction resolveCspNonce(explicitNonce?: string): string | undefined {\n if (explicitNonce) return explicitNonce;\n const scriptWithNonce = document.querySelector<HTMLScriptElement>('script[nonce]');\n if (scriptWithNonce?.nonce) return scriptWithNonce.nonce;\n\n const nonceMeta = document.querySelector<HTMLMetaElement>('meta[name=\"csp-nonce\"]');\n return nonceMeta?.content || undefined;\n}\n\nfunction isJQueryAlreadyAvailable(): boolean {\n const g = getSiaraShieldGlobals();\n if (typeof g.jQuery === 'function' || typeof g.$ === 'function') {\n return true;\n }\n\n const existingJqueryScript = document.querySelector<HTMLScriptElement>('script[src*=\"jquery\"]');\n return Boolean(existingJqueryScript);\n}\n\nasync function waitForCheckCaptchaApi(timeoutMs = CAPTCHA_READY_TIMEOUT_MS): Promise<void> {\n const startedAt = Date.now();\n while (Date.now() - startedAt < timeoutMs) {\n if (getSiaraShieldGlobals().CheckCaptcha) {\n return;\n }\n await new Promise((resolve) => setTimeout(resolve, 100));\n }\n throw new Error('SiaraShield: CheckCaptcha() was not available within timeout.');\n}\n\n/**\n * Drop-in initializer for SiaraShield.\n * - Loads required scripts (optionally jQuery)\n * - Calls global `initCaptcha(publicKey)`\n *\n * Requirements in your HTML/template:\n * - You must render: `<div class=\"SiaraShield\"></div>`\n */\nexport async function initSiaraShield(options: InitSiaraShieldOptions): Promise<void> {\n if (initialized) return;\n if (pending) return pending;\n\n if (!options?.publicKey) {\n throw new Error('initSiaraShield: publicKey is required.');\n }\n\n pending = (async () => {\n const cspNonce = resolveCspNonce(options.cspNonce);\n if ((options.loadJQuery ?? true) && !isJQueryAlreadyAvailable()) {\n await loadScript(JQUERY_FALLBACK_SRC, cspNonce);\n }\n\n await loadScript('https://embedcdn.mycybersiara.com/CaptchaFormate/CaptchaResources.js', cspNonce);\n\n const g = getSiaraShieldGlobals();\n const initCaptchaFn = getInitCaptchaFn(g);\n if (!initCaptchaFn) {\n throw new Error('SiaraShield: InitCaptcha() is not available after loading scripts.');\n }\n\n initCaptchaFn(options.publicKey);\n await waitForCheckCaptchaApi();\n initialized = true;\n })();\n\n try {\n await pending;\n } finally {\n // keep `pending` cached for subsequent callers\n }\n}\n\n/**\n * Calls global `CheckCaptcha()` and returns its boolean result.\n * If successful, returns `{ ok: true, token?: string }`.\n */\nexport function checkSiaraShieldCaptcha(): { ok: boolean; token?: string } {\n const g = getSiaraShieldGlobals();\n if (!g.CheckCaptcha) {\n throw new Error('SiaraShield: CheckCaptcha() is not available. Did initSiaraShield() run?');\n }\n\n const ok = g.CheckCaptcha();\n const token = typeof g.CyberSiaraToken === 'string' ? g.CyberSiaraToken : undefined;\n return ok ? { ok: true, token } : { ok: false };\n}\n\n/**\n * Async-friendly captcha check to handle delayed token population.\n */\nexport async function checkSiaraShieldCaptchaAsync(options?: {\n timeoutMs?: number;\n pollIntervalMs?: number;\n}): Promise<{ ok: boolean; token?: string }> {\n const timeoutMs = options?.timeoutMs ?? 2000;\n const pollIntervalMs = options?.pollIntervalMs ?? 120;\n const startedAt = Date.now();\n\n const firstCheck = checkSiaraShieldCaptcha();\n if (firstCheck.ok) return firstCheck;\n\n while (Date.now() - startedAt < timeoutMs) {\n await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));\n const next = checkSiaraShieldCaptcha();\n if (next.ok) return next;\n }\n\n return { ok: false };\n}\n\n","/*\n * Public API Surface of siarashield-workspace\n */\n\nexport * from './lib/siarashield-workspace';\nexport * from './lib/siara-shield.component';\nexport * from './lib/siara-shield-loader.service';\nexport * from './lib/siara-shield.globals';\nexport * from './lib/siara-shield';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["JQUERY_FALLBACK_SRC","CAPTCHA_READY_TIMEOUT_MS","i1.SiaraShieldLoaderService"],"mappings":";;;;SAYgB,qBAAqB,GAAA;AACnC,IAAA,OAAQ,UAAwE;AAClF;AAEM,SAAU,gBAAgB,CAAC,CAAqB,EAAA;AACpD,IAAA,OAAO,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,WAAW;AACvC;;MCRa,wBAAwB,CAAA;AAIY,IAAA,QAAA;AAHvC,IAAA,WAAW,GAAG,IAAI,GAAG,EAAwB;AAC7C,IAAA,YAAY,GAAG,IAAI,GAAG,EAAyB;AAEvD,IAAA,WAAA,CAA+C,QAAkB,EAAA;QAAlB,IAAA,CAAA,QAAQ,GAAR,QAAQ;IAAa;IAEpE,UAAU,CAAC,GAAW,EAAE,OAA2B,EAAA;AACjD,QAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAoB,CAAA,YAAA,EAAe,GAAG,CAAA,EAAA,CAAI,CAAC;AACvF,QAAA,IAAI,QAAQ;AAAE,YAAA,OAAO,OAAO,CAAC,OAAO,EAAE;QAEtC,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAA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E;AAAE,QAAA,OAAO,UAAU;IAEpC,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,GAAG,SAAS,EAAE;AACzC,QAAA,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,KAAK,UAAU,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;AACnE,QAAA,MAAM,IAAI,GAAG,uBAAuB,EAAE;QACtC,IAAI,IAAI,CAAC,EAAE;AAAE,YAAA,OAAO,IAAI;IAC1B;AAEA,IAAA,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE;AACtB;;AC/IA;;AAEG;;ACFH;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "siarashield_workspace",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "Angular wrapper for CyberSiara SiaraShield captcha embed.",
5
5
  "keywords": [
6
6
  "cybersiara",
@@ -45,11 +45,20 @@ declare class SiaraShieldComponent implements AfterViewInit {
45
45
  * from the first script tag or from `<meta name="csp-nonce">`.
46
46
  */
47
47
  private resolveCspNonce;
48
+ private waitForCheckCaptchaApi;
48
49
  /**
49
50
  * Calls the global `CheckCaptcha()` from SiaraShield script.
50
51
  * Returns true when captcha is valid; emits token if available.
51
52
  */
52
53
  checkCaptcha(): boolean;
54
+ /**
55
+ * Async-friendly captcha validation to avoid first-click timing issues.
56
+ * Retries briefly until token/check API settles.
57
+ */
58
+ checkCaptchaAsync(options?: {
59
+ timeoutMs?: number;
60
+ pollIntervalMs?: number;
61
+ }): Promise<boolean>;
53
62
  static ɵfac: i0.ɵɵFactoryDeclaration<SiaraShieldComponent, never>;
54
63
  static ɵcmp: i0.ɵɵComponentDeclaration<SiaraShieldComponent, "siara-shield", never, { "publicKey": { "alias": "publicKey"; "required": true; }; "loadJQuery": { "alias": "loadJQuery"; "required": false; }; "cspNonce": { "alias": "cspNonce"; "required": false; }; }, { "token": "token"; }, never, never, true, never>;
55
64
  }
@@ -58,12 +67,14 @@ type InitCaptchaFn = (publicKey: string) => void;
58
67
  type CheckCaptchaFn = () => boolean;
59
68
  interface SiaraShieldGlobals {
60
69
  initCaptcha?: InitCaptchaFn;
70
+ InitCaptcha?: InitCaptchaFn;
61
71
  CheckCaptcha?: CheckCaptchaFn;
62
72
  CyberSiaraToken?: string;
63
73
  jQuery?: unknown;
64
74
  $?: unknown;
65
75
  }
66
76
  declare function getSiaraShieldGlobals(): SiaraShieldGlobals;
77
+ declare function getInitCaptchaFn(g: SiaraShieldGlobals): InitCaptchaFn | undefined;
67
78
 
68
79
  interface InitSiaraShieldOptions {
69
80
  /** SiaraShield public key. Use "TEST-CYBERSIARA" for staging/development. */
@@ -93,6 +104,16 @@ declare function checkSiaraShieldCaptcha(): {
93
104
  ok: boolean;
94
105
  token?: string;
95
106
  };
107
+ /**
108
+ * Async-friendly captcha check to handle delayed token population.
109
+ */
110
+ declare function checkSiaraShieldCaptchaAsync(options?: {
111
+ timeoutMs?: number;
112
+ pollIntervalMs?: number;
113
+ }): Promise<{
114
+ ok: boolean;
115
+ token?: string;
116
+ }>;
96
117
 
97
- export { SiaraShieldComponent, SiaraShieldLoaderService, checkSiaraShieldCaptcha, getSiaraShieldGlobals, initSiaraShield };
118
+ export { SiaraShieldComponent, SiaraShieldLoaderService, checkSiaraShieldCaptcha, checkSiaraShieldCaptchaAsync, getInitCaptchaFn, getSiaraShieldGlobals, initSiaraShield };
98
119
  export type { CheckCaptchaFn, InitCaptchaFn, InitSiaraShieldOptions, ScriptLoadOptions, SiaraShieldGlobals, SiaraShieldInitOptions };