siarashield_workspace 0.0.11 → 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.
- package/README.md +44 -43
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,49 +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
|
+
- 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
|
-
|
|
32
|
+
Backend example (`.env`):
|
|
30
33
|
|
|
31
|
-
```
|
|
32
|
-
|
|
34
|
+
```env
|
|
35
|
+
SIARASHIELD_PRIVATE_KEY=YOUR-PRIVATE-KEY
|
|
33
36
|
```
|
|
34
37
|
|
|
35
|
-
|
|
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
|
|
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 {
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
87
|
-
If jQuery
|
|
88
|
-
If
|
|
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
|
-
|
|
92
|
-
- `https://embedcdn.mycybersiara.com/CaptchaFormate/CaptchaResources.js`
|
|
90
|
+
## CSP note
|
|
93
91
|
|
|
94
|
-
|
|
92
|
+
Allow this host in CSP:
|
|
95
93
|
|
|
96
|
-
Keep CSP allowlist for required hosts:
|
|
97
94
|
- `https://embedcdn.mycybersiara.com`
|
|
98
95
|
|
|
99
|
-
##
|
|
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
|
-
|
|
102
|
+
## Build and pack (library maintainers)
|
|
102
103
|
|
|
103
104
|
```bash
|
|
104
105
|
npm run build:lib
|