siarashield_workspace 0.0.12 → 0.0.14

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