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.
- package/README.md +46 -47
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,51 +1,55 @@
|
|
|
1
1
|
# `siarashield_workspace`
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
##
|
|
11
|
+
## 2) Get keys
|
|
12
12
|
|
|
13
|
-
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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=
|
|
25
|
+
SIARASHIELD_PUBLIC_KEY=YOUR-PUBLIC-KEY
|
|
26
26
|
SIARASHIELD_PRIVATE_KEY=YOUR-PRIVATE-KEY
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
|
|
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
|
-
|
|
32
|
-
|
|
31
|
+
## 4) Add captcha container in template
|
|
32
|
+
|
|
33
|
+
```html
|
|
34
|
+
<div class="SiaraShield"></div>
|
|
33
35
|
```
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
In your submit button, make sure to add this class:
|
|
36
38
|
|
|
37
39
|
```html
|
|
38
|
-
<
|
|
40
|
+
<button class="CaptchaSubmit"></button>
|
|
39
41
|
```
|
|
40
42
|
|
|
41
|
-
5
|
|
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 {
|
|
50
|
+
import { initSiaraShield, checkSiaraShieldCaptcha } from 'siarashield_workspace';
|
|
47
51
|
|
|
48
|
-
export class
|
|
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
|
-
|
|
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('
|
|
72
|
-
}
|
|
70
|
+
// API call here (Login/Contact/Signup/etc.)
|
|
71
|
+
alert('Form submitted successfully');
|
|
72
|
+
}
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
-
|
|
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
|
-
|
|
87
|
-
If jQuery
|
|
88
|
-
If
|
|
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
|
-
|
|
92
|
-
- `https://embedcdn.mycybersiara.com/CaptchaFormate/CaptchaResources.js`
|
|
88
|
+
## CSP note
|
|
93
89
|
|
|
94
|
-
|
|
90
|
+
Allow this host in CSP:
|
|
95
91
|
|
|
96
|
-
Keep CSP allowlist for required hosts:
|
|
97
92
|
- `https://embedcdn.mycybersiara.com`
|
|
98
93
|
|
|
99
|
-
##
|
|
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
|
-
|
|
100
|
+
## Build and pack (library maintainers)
|
|
102
101
|
|
|
103
102
|
```bash
|
|
104
103
|
npm run build:lib
|