siarashield_workspace 0.0.9 → 0.0.11

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.
Files changed (2) hide show
  1. package/README.md +33 -13
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -10,13 +10,14 @@ npm i siarashield_workspace
10
10
 
11
11
  ## Setup steps
12
12
 
13
- 1. Get your public & private key from `mycybersiara.com`
13
+ 1. Get your public & private key from <a href="https://mycybersiara.com" target="_blank" rel="noopener noreferrer">mycybersiara.com</a> (register if needed)
14
14
  - Note: Use public key `TEST-CYBERSIARA` for staging/development.
15
15
 
16
16
  2. Set key config in project (proper place)
17
17
  - Frontend public key file:
18
18
  - `src/environments/environment.ts` (development)
19
19
  - `src/environments/environment.prod.ts` (production)
20
+ - If your project already uses `.env`, that is also okay. Map `.env` value to the same public key in frontend config.
20
21
  - Backend private key file:
21
22
  - backend server `.env` only (Node/.NET/Java API), never in Angular code.
22
23
 
@@ -40,12 +41,36 @@ import { initSiaraShield, checkSiaraShieldCaptchaAsync } from 'siarashield_works
40
41
  5. Initialize captcha and validate on submit:
41
42
 
42
43
  ```ts
43
- await initSiaraShield({ publicKey: 'TEST-CYBERSIARA', loadJQuery: true });
44
-
45
- const result = await checkSiaraShieldCaptchaAsync();
46
- if (result.ok) {
47
- console.log(result.token);
48
- // Please write your submit button click event function here //
44
+ import { OnInit } from '@angular/core';
45
+ import { environment } from '../environments/environment';
46
+ import { checkSiaraShieldCaptcha, initSiaraShield } from 'siarashield_workspace';
47
+
48
+ export class LoginComponent implements OnInit {
49
+ ngOnInit() {
50
+ this.initializeCaptcha();
51
+ }
52
+
53
+ initializeCaptcha() {
54
+ initSiaraShield({
55
+ publicKey: environment.siaraShield.publicKey,
56
+ loadJQuery: true,
57
+ })
58
+ .then(() => {
59
+ console.log('SiaraShield Initialized ✅');
60
+ })
61
+ .catch((err: any) => {
62
+ console.error('Initialization Error:', err);
63
+ });
64
+ }
65
+
66
+ onSubmit() {
67
+ const result = checkSiaraShieldCaptcha();
68
+ if (result.ok) {
69
+ console.log(result.token);
70
+ // API call here
71
+ alert('Login Successful ✅');
72
+ }
73
+ }
49
74
  }
50
75
  ```
51
76
 
@@ -53,7 +78,7 @@ Note: Please put your submit button code inside `if (result.ok)`.
53
78
  Add `CaptchaSubmit` class in your submit button:
54
79
 
55
80
  ```html
56
- <button class="CaptchaSubmit"></button>
81
+ <button class="CaptchaSubmit" (click)="onSubmit()">Login</button>
57
82
  ```
58
83
 
59
84
  ## jQuery loading behavior
@@ -66,11 +91,6 @@ If jQuery is missing, package will load:
66
91
  Also loads:
67
92
  - `https://embedcdn.mycybersiara.com/CaptchaFormate/CaptchaResources.js`
68
93
 
69
- ## Submit only when captcha is valid
70
-
71
- Put submit logic inside `if (result.ok)`.
72
- For best UX, use async check (`checkSiaraShieldCaptchaAsync`) to avoid first-click timing delay.
73
-
74
94
  ## CSP (strict policy) support
75
95
 
76
96
  Keep CSP allowlist for required hosts:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "siarashield_workspace",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "description": "Angular wrapper for CyberSiara SiaraShield captcha embed.",
5
5
  "keywords": [
6
6
  "cybersiara",