@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 CHANGED
@@ -3,7 +3,8 @@
3
3
  [![npm version](https://img.shields.io/npm/v/%40spilki/widget.svg)](https://www.npmjs.com/package/@spilki/widget)
4
4
  [![bundle size](https://img.shields.io/badge/gzip%20%3C=35kB-success)](#size-budget)
5
5
 
6
- Embeddable chat widget that connects your website visitors with the Spilki assistant backend via a secure Web Widget channel.
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 { initSpilkiWidget } from "@spilki/widget";
37
+ import {initSpilkiWidget} from "@spilki/widget";
37
38
 
38
39
  initSpilkiWidget({
39
- org: "ori-bar",
40
- assistant: "main-bot",
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 | Type | Default | Description |
48
- | --- | --- | --- | --- |
49
- | `org` | `string` | – | Spilki organisation identifier. |
50
- | `assistant` | `string` | – | Assistant identifier. |
51
- | `token` | `string?` | | Signed JWT obtained from the admin UI or backend. |
52
- | `apiBase` | `string?` | `https://api.spilki.ai` | Override API endpoint (useful for staging/local). |
53
- | `position` | `"bottom-right" \| "bottom-left"` | `"bottom-right"` | Corner to anchor the bubble + panel. |
54
- | `theme` | `"auto" \| "light" \| "dark"` | `"auto"` | Force light/dark or respect OS preference. |
55
- | `color` | `string?` | `#6366f1` | Accent color for bubble + primary CTA. |
56
- | `welcome` | `string?` | "Hi! I'm your assistant." | Greeting shown when no conversation exists. |
57
- | `persist` | `boolean?` | `true` | Persist session + history in localStorage. |
58
- | `allowedOriginsHint` | `string[]?` | – | List of origins expected to be in JWT allowlist. Logs warnings during misconfiguration. |
59
- | `i18n` | `Partial<WidgetI18n>?` | – | Override UI strings (welcome, placeholder, sendLabel, typing, offline, title). |
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
- "assistant_id": "main-bot",
70
- "allowed_origins": ["https://yourdomain.com"],
68
+ "allowed_origins": [
69
+ "https://yourdomain.com"
70
+ ],
71
71
  "exp": 1760000000
72
72
  }
73
73
  ```
74
74
 
75
- During `POST /widget/connect` the widget sends `Origin` and the JWT for verification. Expired tokens are rejected client-side before any network call. Rotate tokens frequently and limit the allowed origins array to trusted domains only.
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 relayed via websocket by default; stop the websocket server to see SSE fallback.
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 secrets before tagging `v0.1.0` or later.
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.