siarashield_workspace 0.0.12 → 0.0.13

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 +44 -43
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,49 +1,55 @@
1
1
  # `siarashield_workspace`
2
2
 
3
- Easy Angular integration for CyberSiara SiaraShield captcha.
3
+ Simple Angular integration for CyberSiara SiaraShield captcha.
4
4
 
5
- ## Install
5
+ ## 1) Install
6
6
 
7
7
  ```bash
8
8
  npm i siarashield_workspace
9
9
  ```
10
10
 
11
- ## Setup steps
11
+ ## 2) Get keys
12
12
 
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
- - Note: Use public key `TEST-CYBERSIARA` for staging/development.
13
+ Get your public/private keys from <a href="https://mycybersiara.com" target="_blank" rel="noopener noreferrer">mycybersiara.com</a>.
15
14
 
16
- 2. Set key config in project (proper place)
17
- - Frontend public key file:
18
- - `src/environments/environment.ts` (development)
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.
21
- - Backend private key file:
22
- - backend server `.env` only (Node/.NET/Java API), never in Angular code.
15
+ - For staging/development, set public key as `TEST-CYBERSIARA` in your `.env`/environment config.
16
+
17
+
18
+ ## 3) Put keys in correct place
19
+
20
+ - **Frontend (Angular):** public key only
21
+ - **Backend (.env):** private key only (never expose in frontend)
22
+
23
+ Frontend should read public key from `.env` or your environment file.
24
+
25
+ Example `.env` values:
23
26
 
24
27
  ```env
25
28
  SIARASHIELD_PUBLIC_KEY=TEST-CYBERSIARA
26
29
  SIARASHIELD_PRIVATE_KEY=YOUR-PRIVATE-KEY
27
30
  ```
28
31
 
29
- 3. Add this import line in your page/component:
32
+ Backend example (`.env`):
30
33
 
31
- ```ts
32
- import { initSiaraShield, checkSiaraShieldCaptchaAsync } from 'siarashield_workspace';
34
+ ```env
35
+ SIARASHIELD_PRIVATE_KEY=YOUR-PRIVATE-KEY
33
36
  ```
34
37
 
35
- 4. Put below code where you want to load captcha plugin in body/template:
38
+ If your frontend project already uses `.env`, that is fine. Map it to the same public key value used in Angular config.
39
+
40
+ ## 4) Add captcha container in template
36
41
 
37
42
  ```html
38
43
  <div class="SiaraShield"></div>
44
+ <button class="CaptchaSubmit" (click)="onSubmit()">Login</button>
39
45
  ```
40
46
 
41
- 5. Initialize captcha and validate on submit:
47
+ ## 5) Add TypeScript integration (copy-paste)
42
48
 
43
49
  ```ts
44
50
  import { OnInit } from '@angular/core';
45
51
  import { environment } from '../environments/environment';
46
- import { checkSiaraShieldCaptcha, initSiaraShield } from 'siarashield_workspace';
52
+ import { initSiaraShield, checkSiaraShieldCaptcha } from 'siarashield_workspace';
47
53
 
48
54
  export class LoginComponent implements OnInit {
49
55
  ngOnInit() {
@@ -53,14 +59,10 @@ export class LoginComponent implements OnInit {
53
59
  initializeCaptcha() {
54
60
  initSiaraShield({
55
61
  publicKey: environment.siaraShield.publicKey,
56
- loadJQuery: true,
62
+ // If your project does NOT use jQuery, set this to true.
63
+ // Default is false, so package jQuery will not load.
64
+ loadJQuery: false,
57
65
  })
58
- .then(() => {
59
- console.log('SiaraShield Initialized ✅');
60
- })
61
- .catch((err: any) => {
62
- console.error('Initialization Error:', err);
63
- });
64
66
  }
65
67
 
66
68
  onSubmit() {
@@ -68,37 +70,36 @@ export class LoginComponent implements OnInit {
68
70
  if (result.ok) {
69
71
  console.log(result.token);
70
72
  // API call here
71
- alert('Login Successful');
72
- }
73
+ alert('Login Successful');
74
+ }
73
75
  }
74
76
  }
75
77
  ```
76
78
 
77
- Note: Please put your submit button code inside `if (result.ok)`.
78
- Add `CaptchaSubmit` class in your submit button:
79
-
80
- ```html
81
- <button class="CaptchaSubmit" (click)="onSubmit()">Login</button>
82
- ```
79
+ Important: keep your submit API logic inside `if (result.ok)`.
83
80
 
84
81
  ## jQuery loading behavior
85
82
 
86
- The package checks if jQuery already exists in the user project (`window.jQuery`, `window.$`, or existing jquery script tag).
87
- If jQuery is already available, package will not load it again.
88
- If jQuery is missing, package will load:
89
- - `https://embedcdn.mycybersiara.com/capcha-temple/js/jquery.min.js`
83
+ - Package checks existing jQuery (`window.jQuery`, `window.$`, or existing jquery script tag)
84
+ - If jQuery already exists, package does not load again
85
+ - If missing, package loads:
86
+ - `https://embedcdn.mycybersiara.com/capcha-temple/js/jquery.min.js`
87
+ - Package also loads:
88
+ - `https://embedcdn.mycybersiara.com/CaptchaFormate/CaptchaResources.js`
90
89
 
91
- Also loads:
92
- - `https://embedcdn.mycybersiara.com/CaptchaFormate/CaptchaResources.js`
90
+ ## CSP note
93
91
 
94
- ## CSP (strict policy) support
92
+ Allow this host in CSP:
95
93
 
96
- Keep CSP allowlist for required hosts:
97
94
  - `https://embedcdn.mycybersiara.com`
98
95
 
99
- ## Build and pack
96
+ ## Quick troubleshooting
97
+
98
+ - Captcha not visible -> confirm `<div class="SiaraShield"></div>` is present
99
+ - `CheckCaptcha` not available -> ensure `initSiaraShield(...)` ran successfully
100
+ - Token empty -> check browser console and network calls after clicking submit
100
101
 
101
- From workspace root:
102
+ ## Build and pack (library maintainers)
102
103
 
103
104
  ```bash
104
105
  npm run build:lib
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "siarashield_workspace",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "description": "Angular wrapper for CyberSiara SiaraShield captcha embed.",
5
5
  "keywords": [
6
6
  "cybersiara",