siarashield_workspace 0.0.1
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
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# `siarashield_workspace`
|
|
2
|
+
|
|
3
|
+
Angular library wrapper for **CyberSiara SiaraShield** captcha.
|
|
4
|
+
|
|
5
|
+
## When you need this (and when you don't)
|
|
6
|
+
|
|
7
|
+
- **Use this** if your Angular app needs to integrate **SiaraShield** captcha.
|
|
8
|
+
- **Not required** if your app already uses a different captcha and you don't want SiaraShield.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
Once published:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm i siarashield_workspace
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage (Angular)
|
|
19
|
+
|
|
20
|
+
1. Get your **public & private key** from `mycybersiara.com`
|
|
21
|
+
- For staging/development you can use public key: `TEST-CYBERSIARA`
|
|
22
|
+
|
|
23
|
+
2. Add the component in your page/component:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { Component, ViewChild } from '@angular/core';
|
|
27
|
+
import { SiaraShieldComponent } from 'siarashield_workspace';
|
|
28
|
+
|
|
29
|
+
@Component({
|
|
30
|
+
selector: 'app-login',
|
|
31
|
+
standalone: true,
|
|
32
|
+
imports: [SiaraShieldComponent],
|
|
33
|
+
template: `
|
|
34
|
+
<siara-shield [publicKey]="publicKey" (token)="onToken($event)"></siara-shield>
|
|
35
|
+
<button type="button" (click)="onSubmit()">Submit</button>
|
|
36
|
+
`,
|
|
37
|
+
})
|
|
38
|
+
export class LoginComponent {
|
|
39
|
+
publicKey = 'TEST-CYBERSIARA';
|
|
40
|
+
|
|
41
|
+
@ViewChild(SiaraShieldComponent) shield?: SiaraShieldComponent;
|
|
42
|
+
|
|
43
|
+
onToken(token: string) {
|
|
44
|
+
console.log('CyberSiaraToken', token);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
onSubmit() {
|
|
48
|
+
// Put your submit logic inside this if-check (as per SiaraShield docs)
|
|
49
|
+
if (this.shield?.checkCaptcha()) {
|
|
50
|
+
// submit here
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## What this library does
|
|
57
|
+
|
|
58
|
+
- Loads:
|
|
59
|
+
- jQuery: `https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js`
|
|
60
|
+
- SiaraShield script: `https://embedcdn.mycybersiara.com/CaptchaFormate/CaptchaResources.js`
|
|
61
|
+
- Renders `<div class="SiaraShield"></div>`
|
|
62
|
+
- Calls `initCaptcha(publicKey)`
|
|
63
|
+
- Exposes `checkCaptcha()` which calls global `CheckCaptcha()` and emits `CyberSiaraToken`
|
|
64
|
+
|
|
65
|
+
## Build & pack (for release)
|
|
66
|
+
|
|
67
|
+
From the workspace root:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
npm run build:lib
|
|
71
|
+
npm run pack:lib
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Pack output will be in `dist/siarashield-workspace`.
|
|
75
|
+
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Inject, Injectable, EventEmitter, Output, Input, ViewEncapsulation, Component } from '@angular/core';
|
|
3
|
+
import { DOCUMENT } from '@angular/common';
|
|
4
|
+
|
|
5
|
+
function getSiaraShieldGlobals() {
|
|
6
|
+
return globalThis;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
class SiaraShieldLoaderService {
|
|
10
|
+
document;
|
|
11
|
+
statusBySrc = new Map();
|
|
12
|
+
pendingBySrc = new Map();
|
|
13
|
+
constructor(document) {
|
|
14
|
+
this.document = document;
|
|
15
|
+
}
|
|
16
|
+
loadScript(src) {
|
|
17
|
+
const existing = this.document.querySelector(`script[src="${src}"]`);
|
|
18
|
+
if (existing)
|
|
19
|
+
return Promise.resolve();
|
|
20
|
+
const status = this.statusBySrc.get(src);
|
|
21
|
+
if (status === 'loaded')
|
|
22
|
+
return Promise.resolve();
|
|
23
|
+
if (status === 'loading') {
|
|
24
|
+
const pending = this.pendingBySrc.get(src);
|
|
25
|
+
if (pending)
|
|
26
|
+
return pending;
|
|
27
|
+
}
|
|
28
|
+
this.statusBySrc.set(src, 'loading');
|
|
29
|
+
const pending = new Promise((resolve, reject) => {
|
|
30
|
+
const script = this.document.createElement('script');
|
|
31
|
+
script.src = src;
|
|
32
|
+
script.async = true;
|
|
33
|
+
script.onload = () => {
|
|
34
|
+
this.statusBySrc.set(src, 'loaded');
|
|
35
|
+
resolve();
|
|
36
|
+
};
|
|
37
|
+
script.onerror = () => {
|
|
38
|
+
this.statusBySrc.set(src, 'error');
|
|
39
|
+
reject(new Error(`Failed to load script: ${src}`));
|
|
40
|
+
};
|
|
41
|
+
this.document.head.appendChild(script);
|
|
42
|
+
});
|
|
43
|
+
this.pendingBySrc.set(src, pending);
|
|
44
|
+
return pending;
|
|
45
|
+
}
|
|
46
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SiaraShieldLoaderService, deps: [{ token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
47
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SiaraShieldLoaderService, providedIn: 'root' });
|
|
48
|
+
}
|
|
49
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SiaraShieldLoaderService, decorators: [{
|
|
50
|
+
type: Injectable,
|
|
51
|
+
args: [{ providedIn: 'root' }]
|
|
52
|
+
}], ctorParameters: () => [{ type: Document, decorators: [{
|
|
53
|
+
type: Inject,
|
|
54
|
+
args: [DOCUMENT]
|
|
55
|
+
}] }] });
|
|
56
|
+
|
|
57
|
+
class SiaraShieldComponent {
|
|
58
|
+
host;
|
|
59
|
+
loader;
|
|
60
|
+
publicKey;
|
|
61
|
+
loadJQuery = true;
|
|
62
|
+
/**
|
|
63
|
+
* Emits the current `CyberSiaraToken` right after a successful `checkCaptcha()`.
|
|
64
|
+
*/
|
|
65
|
+
token = new EventEmitter();
|
|
66
|
+
initialized = false;
|
|
67
|
+
constructor(host, loader) {
|
|
68
|
+
this.host = host;
|
|
69
|
+
this.loader = loader;
|
|
70
|
+
}
|
|
71
|
+
async ngAfterViewInit() {
|
|
72
|
+
await this.init({ publicKey: this.publicKey, loadJQuery: this.loadJQuery });
|
|
73
|
+
}
|
|
74
|
+
async init(options) {
|
|
75
|
+
if (this.initialized)
|
|
76
|
+
return;
|
|
77
|
+
// Ensure the host element is in DOM before scripts run.
|
|
78
|
+
void this.host.nativeElement;
|
|
79
|
+
if (!options.publicKey) {
|
|
80
|
+
throw new Error('SiaraShieldComponent: publicKey is required.');
|
|
81
|
+
}
|
|
82
|
+
if (options.loadJQuery ?? true) {
|
|
83
|
+
await this.loader.loadScript('https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js');
|
|
84
|
+
}
|
|
85
|
+
await this.loader.loadScript('https://embedcdn.mycybersiara.com/CaptchaFormate/CaptchaResources.js');
|
|
86
|
+
const g = getSiaraShieldGlobals();
|
|
87
|
+
if (!g.initCaptcha) {
|
|
88
|
+
throw new Error('SiaraShield: initCaptcha() is not available after loading scripts.');
|
|
89
|
+
}
|
|
90
|
+
g.initCaptcha(options.publicKey);
|
|
91
|
+
this.initialized = true;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Calls the global `CheckCaptcha()` from SiaraShield script.
|
|
95
|
+
* Returns true when captcha is valid; emits token if available.
|
|
96
|
+
*/
|
|
97
|
+
checkCaptcha() {
|
|
98
|
+
const g = getSiaraShieldGlobals();
|
|
99
|
+
if (!g.CheckCaptcha) {
|
|
100
|
+
throw new Error('SiaraShield: CheckCaptcha() is not available. Did init() run?');
|
|
101
|
+
}
|
|
102
|
+
const ok = g.CheckCaptcha();
|
|
103
|
+
if (ok && typeof g.CyberSiaraToken === 'string') {
|
|
104
|
+
this.token.emit(g.CyberSiaraToken);
|
|
105
|
+
}
|
|
106
|
+
return ok;
|
|
107
|
+
}
|
|
108
|
+
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 });
|
|
109
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.5", type: SiaraShieldComponent, isStandalone: true, selector: "siara-shield", inputs: { publicKey: "publicKey", loadJQuery: "loadJQuery" }, outputs: { token: "token" }, ngImport: i0, template: `<div class="SiaraShield"></div>`, isInline: true, encapsulation: i0.ViewEncapsulation.None });
|
|
110
|
+
}
|
|
111
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: SiaraShieldComponent, decorators: [{
|
|
112
|
+
type: Component,
|
|
113
|
+
args: [{
|
|
114
|
+
selector: 'siara-shield',
|
|
115
|
+
standalone: true,
|
|
116
|
+
template: `<div class="SiaraShield"></div>`,
|
|
117
|
+
encapsulation: ViewEncapsulation.None,
|
|
118
|
+
}]
|
|
119
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: SiaraShieldLoaderService }], propDecorators: { publicKey: [{
|
|
120
|
+
type: Input,
|
|
121
|
+
args: [{ required: true }]
|
|
122
|
+
}], loadJQuery: [{
|
|
123
|
+
type: Input
|
|
124
|
+
}], token: [{
|
|
125
|
+
type: Output
|
|
126
|
+
}] } });
|
|
127
|
+
|
|
128
|
+
/*
|
|
129
|
+
* Public API Surface of siarashield-workspace
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Generated bundle index. Do not edit.
|
|
134
|
+
*/
|
|
135
|
+
|
|
136
|
+
export { SiaraShieldComponent, SiaraShieldLoaderService, getSiaraShieldGlobals };
|
|
137
|
+
//# sourceMappingURL=siarashield_workspace.mjs.map
|
|
@@ -0,0 +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/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}\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\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): 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 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\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}\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\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 });\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\n if (options.loadJQuery ?? true) {\n await this.loader.loadScript('https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js');\n }\n\n await this.loader.loadScript('https://embedcdn.mycybersiara.com/CaptchaFormate/CaptchaResources.js');\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 * 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","/*\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';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.SiaraShieldLoaderService"],"mappings":";;;;SASgB,qBAAqB,GAAA;AACnC,IAAA,OAAQ,UAAwE;AAClF;;MCLa,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;AAEpE,IAAA,UAAU,CAAC,GAAW,EAAA;AACpB,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,CAAC,GAAG,CAAC,GAAG,CAAC;QACxC,IAAI,MAAM,KAAK,QAAQ;AAAE,YAAA,OAAO,OAAO,CAAC,OAAO,EAAE;AACjD,QAAA,IAAI,MAAM,KAAK,SAAS,EAAE;YACxB,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC;AAC1C,YAAA,I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E,IAAI,EAAE;;sBACxB;;sBAKA;;;ACxBH;;AAEG;;ACFH;;AAEG;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "siarashield_workspace",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Angular wrapper for CyberSiara SiaraShield captcha embed.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cybersiara",
|
|
7
|
+
"siarashield",
|
|
8
|
+
"captcha",
|
|
9
|
+
"angular"
|
|
10
|
+
],
|
|
11
|
+
"peerDependencies": {
|
|
12
|
+
"@angular/core": "^16.0.0",
|
|
13
|
+
"@angular/common": "^16.0.0"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"tslib": "^2.3.0"
|
|
17
|
+
},
|
|
18
|
+
"sideEffects": false,
|
|
19
|
+
"module": "fesm2022/siarashield_workspace.mjs",
|
|
20
|
+
"typings": "types/siarashield_workspace.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
"./package.json": {
|
|
23
|
+
"default": "./package.json"
|
|
24
|
+
},
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./types/siarashield_workspace.d.ts",
|
|
27
|
+
"default": "./fesm2022/siarashield_workspace.mjs"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { AfterViewInit, EventEmitter, ElementRef } from '@angular/core';
|
|
3
|
+
|
|
4
|
+
declare class SiaraShieldLoaderService {
|
|
5
|
+
private readonly document;
|
|
6
|
+
private statusBySrc;
|
|
7
|
+
private pendingBySrc;
|
|
8
|
+
constructor(document: Document);
|
|
9
|
+
loadScript(src: string): Promise<void>;
|
|
10
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SiaraShieldLoaderService, never>;
|
|
11
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<SiaraShieldLoaderService>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface SiaraShieldInitOptions {
|
|
15
|
+
/** SiaraShield public key. Use "TEST-CYBERSIARA" for staging/development. */
|
|
16
|
+
publicKey: string;
|
|
17
|
+
/** Loads jQuery before SiaraShield script. Keep true if your page doesn't already include jQuery. */
|
|
18
|
+
loadJQuery?: boolean;
|
|
19
|
+
}
|
|
20
|
+
declare class SiaraShieldComponent implements AfterViewInit {
|
|
21
|
+
private readonly host;
|
|
22
|
+
private readonly loader;
|
|
23
|
+
publicKey: string;
|
|
24
|
+
loadJQuery: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Emits the current `CyberSiaraToken` right after a successful `checkCaptcha()`.
|
|
27
|
+
*/
|
|
28
|
+
token: EventEmitter<string>;
|
|
29
|
+
private initialized;
|
|
30
|
+
constructor(host: ElementRef<HTMLElement>, loader: SiaraShieldLoaderService);
|
|
31
|
+
ngAfterViewInit(): Promise<void>;
|
|
32
|
+
init(options: SiaraShieldInitOptions): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Calls the global `CheckCaptcha()` from SiaraShield script.
|
|
35
|
+
* Returns true when captcha is valid; emits token if available.
|
|
36
|
+
*/
|
|
37
|
+
checkCaptcha(): boolean;
|
|
38
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SiaraShieldComponent, never>;
|
|
39
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<SiaraShieldComponent, "siara-shield", never, { "publicKey": { "alias": "publicKey"; "required": true; }; "loadJQuery": { "alias": "loadJQuery"; "required": false; }; }, { "token": "token"; }, never, never, true, never>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
type InitCaptchaFn = (publicKey: string) => void;
|
|
43
|
+
type CheckCaptchaFn = () => boolean;
|
|
44
|
+
interface SiaraShieldGlobals {
|
|
45
|
+
initCaptcha?: InitCaptchaFn;
|
|
46
|
+
CheckCaptcha?: CheckCaptchaFn;
|
|
47
|
+
CyberSiaraToken?: string;
|
|
48
|
+
}
|
|
49
|
+
declare function getSiaraShieldGlobals(): SiaraShieldGlobals;
|
|
50
|
+
|
|
51
|
+
export { SiaraShieldComponent, SiaraShieldLoaderService, getSiaraShieldGlobals };
|
|
52
|
+
export type { CheckCaptchaFn, InitCaptchaFn, SiaraShieldGlobals, SiaraShieldInitOptions };
|