@spilki/widget 0.1.0 → 0.1.2
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 +29 -25
- package/dist/bootstrap.es.js +168 -120
- package/dist/bootstrap.es.js.map +1 -1
- package/dist/bootstrap.umd.js +4 -4
- package/dist/bootstrap.umd.js.map +1 -1
- package/dist/core/jwt.d.ts.map +1 -1
- package/dist/core/state.d.ts +5 -2
- package/dist/core/state.d.ts.map +1 -1
- package/dist/core/transport.d.ts +1 -2
- package/dist/core/transport.d.ts.map +1 -1
- package/dist/core/utils.d.ts +4 -4
- package/dist/core/utils.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/types.d.ts +4 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/widget.es.js +169 -121
- package/dist/widget.es.js.map +1 -1
- package/dist/widget.umd.js +4 -4
- package/dist/widget.umd.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/@spilki/widget)
|
|
4
4
|
[](#size-budget)
|
|
5
5
|
|
|
6
|
-
Embeddable chat widget that connects your website visitors with the Spilki assistant backend via a secure Web Widget
|
|
6
|
+
Embeddable chat widget that connects your website visitors with the Spilki assistant backend via a secure Web Widget
|
|
7
|
+
channel.
|
|
7
8
|
|
|
8
9
|
## Features
|
|
9
10
|
|
|
@@ -24,40 +25,38 @@ npm install @spilki/widget
|
|
|
24
25
|
### CDN (UMD)
|
|
25
26
|
|
|
26
27
|
```html
|
|
28
|
+
|
|
27
29
|
<script src="https://cdn.jsdelivr.net/npm/@spilki/widget/dist/widget.umd.js"
|
|
28
30
|
data-org="ori-bar"
|
|
29
|
-
data-assistant="main-bot"
|
|
30
31
|
data-token="<your-jwt>"></script>
|
|
31
32
|
```
|
|
32
33
|
|
|
33
34
|
### ESM
|
|
34
35
|
|
|
35
36
|
```ts
|
|
36
|
-
import {
|
|
37
|
+
import {initSpilkiWidget} from "@spilki/widget";
|
|
37
38
|
|
|
38
39
|
initSpilkiWidget({
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
token: "<your-jwt>"
|
|
40
|
+
org: "ori-bar",
|
|
41
|
+
token: "<your-jwt>"
|
|
42
42
|
});
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
## Options
|
|
46
46
|
|
|
47
|
-
| Option
|
|
48
|
-
|
|
49
|
-
| `org`
|
|
50
|
-
| `
|
|
51
|
-
| `
|
|
52
|
-
| `
|
|
53
|
-
| `
|
|
54
|
-
| `
|
|
55
|
-
| `
|
|
56
|
-
| `
|
|
57
|
-
| `
|
|
58
|
-
| `
|
|
59
|
-
| `
|
|
60
|
-
| `hooks` | `Partial<WidgetHooks>?` | – | Telemetry callbacks for open/close/message/error/transport change. |
|
|
47
|
+
| Option | Type | Default | Description |
|
|
48
|
+
|----------------------|-----------------------------------|---------------------------|-----------------------------------------------------------------------------------------|
|
|
49
|
+
| `org` | `string` | – | Spilki organisation identifier. |
|
|
50
|
+
| `token` | `string?` | – | Signed JWT obtained from the admin UI or backend. |
|
|
51
|
+
| `apiBase` | `string?` | `https://api.spilki.ai` | Override API endpoint (useful for staging/local). |
|
|
52
|
+
| `position` | `"bottom-right" \| "bottom-left"` | `"bottom-right"` | Corner to anchor the bubble + panel. |
|
|
53
|
+
| `theme` | `"auto" \| "light" \| "dark"` | `"auto"` | Force light/dark or respect OS preference. |
|
|
54
|
+
| `color` | `string?` | `#6366f1` | Accent color for bubble + primary CTA. |
|
|
55
|
+
| `welcome` | `string?` | "Hi! I'm your assistant." | Greeting shown when no conversation exists. |
|
|
56
|
+
| `persist` | `boolean?` | `true` | Persist session + history in localStorage. |
|
|
57
|
+
| `allowedOriginsHint` | `string[]?` | – | List of origins expected to be in JWT allowlist. Logs warnings during misconfiguration. |
|
|
58
|
+
| `i18n` | `Partial<WidgetI18n>?` | – | Override UI strings (welcome, placeholder, sendLabel, typing, offline, title). |
|
|
59
|
+
| `hooks` | `Partial<WidgetHooks>?` | – | Telemetry callbacks for open/close/message/error/transport change. |
|
|
61
60
|
|
|
62
61
|
## Security
|
|
63
62
|
|
|
@@ -66,13 +65,16 @@ The widget never stores credentials. Provide a short-lived JWT (HS256) issued se
|
|
|
66
65
|
```json
|
|
67
66
|
{
|
|
68
67
|
"organisation_id": "ori-bar",
|
|
69
|
-
"
|
|
70
|
-
|
|
68
|
+
"allowed_origins": [
|
|
69
|
+
"https://yourdomain.com"
|
|
70
|
+
],
|
|
71
71
|
"exp": 1760000000
|
|
72
72
|
}
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
-
During `POST /widget/
|
|
75
|
+
During `POST /widget/session` the widget sends `Origin` and the JWT for verification. Expired tokens are rejected
|
|
76
|
+
client-side before any network call. Rotate tokens frequently and limit the allowed origins array to trusted domains
|
|
77
|
+
only.
|
|
76
78
|
|
|
77
79
|
See [`apps/mock-server/openapi.yaml`](../apps/mock-server/openapi.yaml) for the full handshake specification.
|
|
78
80
|
|
|
@@ -92,8 +94,10 @@ pnpm install
|
|
|
92
94
|
pnpm -w dev # runs mock server + demo site
|
|
93
95
|
```
|
|
94
96
|
|
|
95
|
-
Open [http://localhost:5174](http://localhost:5174) and use **Issue token** to obtain a development JWT. Messages are
|
|
97
|
+
Open [http://localhost:5174](http://localhost:5174) and use **Issue token** to obtain a development JWT. Messages are
|
|
98
|
+
relayed via websocket by default; stop the websocket server to see SSE fallback.
|
|
96
99
|
|
|
97
100
|
## Publishing
|
|
98
101
|
|
|
99
|
-
The GitHub Actions workflow publishes on tags that match `v*`. Ensure `NPM_TOKEN` is configured in the repository
|
|
102
|
+
The GitHub Actions workflow publishes on tags that match `v*`. Ensure `NPM_TOKEN` is configured in the repository
|
|
103
|
+
secrets before tagging `v0.1.2` or later.
|