ionblink-js 0.0.0-stage → 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.
Files changed (52) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/LICENSE +21 -0
  3. package/README.md +266 -2
  4. package/THIRD-PARTY-NOTICES.txt +66 -0
  5. package/dist/cjs/index.cjs +2789 -0
  6. package/dist/cjs/package.json +1 -0
  7. package/dist/cjs/protocol.cjs +73 -0
  8. package/dist/cjs/proxy.cjs +103 -0
  9. package/dist/esm/c-2BL72NP3.js +872 -0
  10. package/dist/esm/c-FF5JPOWW.js +120 -0
  11. package/dist/esm/c-FTUPFEXC.js +214 -0
  12. package/dist/esm/c-MLVABENR.js +107 -0
  13. package/dist/esm/c-VOZLB3UG.js +99 -0
  14. package/dist/esm/c-YTOQLBPZ.js +53 -0
  15. package/dist/esm/index.js +1308 -0
  16. package/dist/esm/package.json +1 -0
  17. package/dist/esm/protocol.js +10 -0
  18. package/dist/esm/proxy.js +82 -0
  19. package/dist/integrity.json +10 -0
  20. package/dist/ionblink.min.js +1 -0
  21. package/dist/r-fa1898205a.js +1 -0
  22. package/dist/r-fa1898205a.js.LICENSE.txt +66 -0
  23. package/dist/snippet.html +1 -0
  24. package/dist/snippet.min.js +1 -0
  25. package/dist/types/auto.d.ts +29 -0
  26. package/dist/types/automation.d.ts +2 -0
  27. package/dist/types/consent.d.ts +35 -0
  28. package/dist/types/context.d.ts +20 -0
  29. package/dist/types/core.d.ts +10 -0
  30. package/dist/types/dom.d.ts +7 -0
  31. package/dist/types/idb.d.ts +2 -0
  32. package/dist/types/index.d.ts +5 -0
  33. package/dist/types/mask.d.ts +63 -0
  34. package/dist/types/props.d.ts +5 -0
  35. package/dist/types/protocol.d.ts +626 -0
  36. package/dist/types/proxy.d.ts +21 -0
  37. package/dist/types/rage.d.ts +9 -0
  38. package/dist/types/replay.d.ts +3 -0
  39. package/dist/types/replayctl.d.ts +2 -0
  40. package/dist/types/scrub.d.ts +18 -0
  41. package/dist/types/session.d.ts +30 -0
  42. package/dist/types/signals.d.ts +31 -0
  43. package/dist/types/storage.d.ts +17 -0
  44. package/dist/types/transport.d.ts +63 -0
  45. package/dist/types/types.d.ts +215 -0
  46. package/dist/types/util.d.ts +27 -0
  47. package/dist/types/vitals.d.ts +10 -0
  48. package/dist/types/x-cdn.d.ts +1 -0
  49. package/dist/types/x.d.ts +2 -0
  50. package/dist/v1.js +1 -0
  51. package/dist/x-0e25e29517.js +1 -0
  52. package/package.json +69 -4
package/CHANGELOG.md ADDED
@@ -0,0 +1,56 @@
1
+ # Changelog: ionblink-js
2
+
3
+ ## 0.1.2 - Unreleased
4
+
5
+ Visitors who leave in the first seconds are no longer lost. Served from `cdn.ionblink.com/sdk/0.1.2` (2026-12-02);
6
+ not on npm yet. No change to the wire format or the events sent.
7
+
8
+ - The page's first batch (its `$page`) goes as soon as the SDK boots instead of after the 5 s cadence, so a visit that
9
+ ends in a second still starts a session. A first visit's batch still waits for the config answer (the region may ask
10
+ for consent). Later events coalesce as before; the automation hints, read at idle, ride the next batch's context.
11
+ - When the page is hidden, what is queued goes by `sendBeacon` at once, as on `pagehide`, instead of being compressed
12
+ and fetched: a phone may close a hidden tab without a `pagehide`, and a compressed request may never leave. What the
13
+ browser refuses goes to the offline queue, as before.
14
+ - A beacon round sends the events batches before the replay chunks, so a replay chunk can't use up the browser's 64 KB
15
+ keepalive quota first.
16
+
17
+ ## 0.1.1 - Unreleased
18
+
19
+ First npm release. 0.1.0 was served from `cdn.ionblink.com` only (2026-12-01) and lacks `headers()` and
20
+ `proxy()`'s country forwarding; its URL keeps working.
21
+
22
+ First public release.
23
+
24
+ - `init`, `event`, `set` / `identify`, `page`, `reset`, `consent`, `mask`, `flush`, `ready`, `ids`, `state`.
25
+ - `headers()`: the browser's ids as `x-ionblink-anon` / `x-ionblink-session` request headers, so the site's server can
26
+ bind the session to the person it signed in (ionblink-node `identify({ userId, ...whoFrom(req.headers) })`), which
27
+ IonBlink shows as verified.
28
+ - Automatic page views (SPA navigations included), page leave with engaged time and scroll depth, clicks, rage and dead
29
+ clicks, field focus and form submits (never values), JS errors and unhandled rejections, web vitals, agent signals.
30
+ - Session replay with rrweb, loaded only for recorded sessions; masking levels `inputs`, `controls` and `text`;
31
+ never-captured fields; PII scrubbing of text, attributes and URLs.
32
+ - Replay masks what rrweb's own masking misses: typing in `contenteditable` editors, hidden fields' values, `<meta
33
+ content>`, `data-*` values, text inside a masked shadow host, and cross-origin iframe URLs (security review).
34
+ - Consent modes `off`, `basic` (cookieless, id-free counts), `full` and `replay`; opt-in regions start in `basic`.
35
+ - Batching, gzip, backoff with `Retry-After`, 413 splitting, `sendBeacon` on page hide, an offline queue in IndexedDB.
36
+ - Script tag and inline snippet (`https://cdn.ionblink.com/sdk/v1.js`), npm ESM and CJS builds, a pinned CDN build
37
+ with Subresource Integrity (`dist/integrity.json`), and `ionblink-js/proxy` for a first-party route.
38
+ - `ionblink-js/proxy` forwards only `GET`, `HEAD`, `POST` and `OPTIONS` and refuses bodies over 4 MB; the README no
39
+ longer suggests a plain rewrite, which forwards the site's cookies (security review).
40
+ - `proxy()` forwards the visitor's country and region (`x-ib-client-country`, `x-ib-client-region`) from Cloudflare,
41
+ Vercel or Netlify, so IonBlink's consent rule sees the visitor's location rather than the proxy's. `clientGeo()` is
42
+ exported beside `clientIp()`.
43
+ - Stays out of the page's way: `init()` defers its work to an idle moment, replay starts only after the `load` event,
44
+ scroll position is read in `requestAnimationFrame`, sends pause while offline. Budgets in CI: core 10.7 KB brotli (10.6 KB today); the replay controller ships in the extras chunk.
45
+ - No cookies by default; `storage: 'cookie'` writes one first-party cookie of about 80 bytes (never the person).
46
+ - Scrubbing (security review): every pattern runs in linear time (a crafted 80 KB string took 6.7 s), `ib_sk_` keys
47
+ are scrubbed, a `key=value` path segment (an OAuth token in a hash route) is redacted, a padded or upper-case secret
48
+ key is refused too, and a `__proto__` prop key is dropped. Core budget 10.7 -> 10.75 KB.
49
+ - `https://cdn.ionblink.com/sdk/<version>/ionblink.min.js`, a pinned, immutable URL beside the moving `/sdk/v1.js`.
50
+ - Third-party notices: `THIRD-PARTY-NOTICES.txt` (rrweb and base64-arraybuffer, MIT, bundled in the CDN replay
51
+ chunk) ships in the package and beside the chunk as `dist/r-<hash>.js.LICENSE.txt`.
52
+ - Clear console errors for a malformed key, a secret key in a page (the SDK refuses to start), a Content-Security-Policy
53
+ block, and refused events (401, 403).
54
+ - Consent (security review): through a first-party proxy the timezone guess stays a floor (the server sees the
55
+ proxy's IP, not the visitor's); Global Privacy Control turns replay off unless `consent()` grants it; `off` sends
56
+ nothing, not even the config request.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Winding Labs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,267 @@
1
- # Temporary Holding Version
1
+ # ionblink-js
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ IonBlink for the browser: product analytics built for agents. Page views, autocapture, agent signals, and masked
4
+ session replay that loads only when a session is recorded. The core is 10.6 KB brotli, starts when the browser is
5
+ idle, sets no cookies and never throws into your page.
6
+
7
+ > Not on npm yet: the first release waits for a security review. IonBlink serves this package's CDN build at
8
+ > `https://cdn.ionblink.com/sdk/v1.js`.
9
+
10
+ ## Quickstart
11
+
12
+ ```sh
13
+ npm i ionblink-js
14
+ ```
15
+
16
+ ```ts
17
+ import { ionblink } from 'ionblink-js'
18
+ ionblink.init('ib_pk_…') // your site key, from Sites in the IonBlink app
19
+ ```
20
+
21
+ Importing is safe during server rendering: nothing touches `window` until `init()` runs in a browser. Your bundler
22
+ splits out the two lazy chunks (extras, and replay with rrweb). For React and Next.js, use
23
+ [`ionblink-react`](../react) on top of this package. For React Native and Expo, use
24
+ [`ionblink-react-native`](../react-native).
25
+
26
+ ## Other ways to install
27
+
28
+ ### Script tag (one line, no build step)
29
+
30
+ ```html
31
+ <script src="https://cdn.ionblink.com/sdk/v1.js" data-key="ib_pk_…" async></script>
32
+ ```
33
+
34
+ Attributes: `data-key` (required), `data-api-host` (a first-party proxy), `data-mode` (`basic`, `full`, `replay`),
35
+ `data-require-consent` (treat every visitor as opt-in until `consent()`). The global is `window.ionblink`.
36
+ `/sdk/v1.js` is the moving "latest 1.x" file: cached for 5 minutes, then revalidated in the background.
37
+ `cdn.ionblink.com` serves static files from Cloudflare's edge, brotli or gzip, and never sets or reads a cookie.
38
+
39
+ ### Pinned version with Subresource Integrity
40
+
41
+ Each release has a URL that never changes, cached for a year. The core then loads its two chunks from the same folder,
42
+ each with its own integrity hash built in:
43
+
44
+ ```html
45
+ <script src="https://cdn.ionblink.com/sdk/0.1.2/ionblink.min.js"
46
+ integrity="sha384-…" crossorigin="anonymous" data-key="ib_pk_…" async></script>
47
+ ```
48
+
49
+ The `integrity` value for each release is in `dist/integrity.json` of the package (and in the release notes). Every
50
+ npm release is also on jsDelivr and unpkg with no extra step, for example
51
+ `https://cdn.jsdelivr.net/npm/ionblink-js@0.1.2/dist/v1.js` (same bytes, same integrity). Batches still go to
52
+ `https://api.ionblink.com` (or your `data-api-host`).
53
+
54
+ ### Inline snippet (call the API before the SDK loads)
55
+
56
+ Calls made before the SDK arrives are queued with their timestamps and replayed in order (a queued `consent()` goes
57
+ first, so nothing it forbids ever starts). The minified copy is `dist/snippet.html` (0.28 KB brotli):
58
+
59
+ ```html
60
+ <script>
61
+ (function(i,n,a,s){if(!i.ionblink){var c=[],o=i.ionblink={_q:c,_k:a,_o:s||{}};"init event set identify page reset consent mask flush ready".split(" ").forEach(function(r){o[r]=function(){c.push([r,Array.prototype.slice.call(arguments),Date.now()])}});var e=n.createElement("script"),t=n.currentScript;e.async=!0,e.src=(o._o.apiHost||"https://cdn.ionblink.com")+"/sdk/v1.js",t&&t.nonce&&(e.nonce=t.nonce),(n.head||n.documentElement).appendChild(e)}})(window,document,"ib_pk_…",{});
62
+ </script>
63
+ ```
64
+
65
+ The last argument takes the `init` options (`{ apiHost: '/ib' }`). A CSP nonce on the snippet's tag is copied to the
66
+ SDK's tags.
67
+
68
+ ### Next.js without React helpers
69
+
70
+ Next.js 15.3+ runs `instrumentation-client.ts` before your app, with no provider needed:
71
+
72
+ ```ts
73
+ // instrumentation-client.ts
74
+ import { ionblink } from 'ionblink-js'
75
+ ionblink.init(process.env.NEXT_PUBLIC_IONBLINK_KEY!, { apiHost: '/ib' })
76
+ ```
77
+
78
+ Route changes are page views on their own. Add the `/ib` route with `ionblinkRoute()` from
79
+ [`ionblink-react/next`](../react#nextjs-app-router), or drop `apiHost` to send straight to IonBlink.
80
+
81
+ ## API
82
+
83
+ | Call | What it does |
84
+ |---|---|
85
+ | `init(key, options?)` | Starts the SDK. Once per page. |
86
+ | `event(name, props?)` | An app event: a name of 1-64 characters (not starting with `$`) and JSON props. |
87
+ | `set(person)` / `identify(id, traits?)` | Who the person is. Use your user id, never an email, as `id`. Raises masking to `controls`. |
88
+ | `page(path?, props?)` | A page view by hand: only for virtual pages or with `pages: false`. |
89
+ | `reset()` | On sign-out: new anonymous id and session, the person forgotten. |
90
+ | `consent(choice)` | From your banner: `'off' \| 'basic' \| 'full' \| 'replay'` or `{ analytics, replay }`. |
91
+ | `mask(level)` | `'inputs' \| 'controls' \| 'text'`. |
92
+ | `flush()` | Sends what is queued; resolves after one attempt, never rejects. |
93
+ | `ready(cb)`, `ids()`, `state()` | Ready callback; ids to join server events (undefined in `basic`); mode, masking and replay state. |
94
+ | `headers()` | This browser's ids as `{ 'x-ionblink-anon', 'x-ionblink-session' }` (`{}` without ids) for your own server. See [Verified people](#verified-people). |
95
+
96
+ Options: `apiHost`, `mode` (the most this site captures, default `replay`), `requireConsent`, `mask`, `storage`
97
+ (`local` default, `cookie` with `cookieDomain` for subdomains, `memory`), `pages`, `autocapture` (or per family:
98
+ `clicks`, `forms`, `errors`, `vitals`, `signals`), `replay: { sample, maskSelectors, blockSelectors, blockPaths }`,
99
+ `keepQuery`, `app: { version, build }`, `debug`, `beforeSend`. See `src/types.ts`.
100
+
101
+ **Sent for you:** page views (SPA navigations included), page leave with engaged time and scroll depth, clicks with a
102
+ masked target, rage clicks (3 in 1 s within 30 px), dead clicks, field focus and form submits (never values), JS
103
+ errors and unhandled rejections, web vitals, and `$signals`: a compact per-page summary of how the page was driven
104
+ (pointer, keys, scroll, timing), which IonBlink uses to tell people from agents. No raw coordinate streams leave the
105
+ page.
106
+
107
+ **Every batch carries** the page URL (query values masked), path, referrer, UTM and click ids, screen, viewport,
108
+ locale, time zone, the SDK version, and automation hints.
109
+
110
+ ## Consent
111
+
112
+ | Mode | What happens |
113
+ |---|---|
114
+ | `off` | Nothing, not even the remote config request. |
115
+ | `basic` | No storage, no ids, no device reads. One aggregate beacon per page with event-name counts. |
116
+ | `full` | Events, identity, autocapture, agent signals. |
117
+ | `replay` | Full plus session replay (sampled by remote config). |
118
+
119
+ In the EEA, UK, Switzerland and Quebec (the server decides from the request; the time zone guesses until it answers),
120
+ visitors start in `basic` until you call `consent()`. Elsewhere they start at your `mode`. `requireConsent: true` makes
121
+ every visitor opt-in. Through a first-party proxy the server sees the proxy's address, not the visitor's, so there a
122
+ European time zone keeps asking whatever the server says, and `proxy()` forwards the visitor's country from your
123
+ platform (Cloudflare, Vercel, Netlify). A proxy that sends no country makes the server ask every visitor. A browser that sends Global Privacy Control starts without
124
+ replay (`full` at most) until `consent()` says otherwise.
125
+
126
+ ```ts
127
+ banner.onAccept(() => ionblink.consent({ analytics: true, replay: true }))
128
+ banner.onReject(() => ionblink.consent({ analytics: false }))
129
+ ```
130
+
131
+ Lowering consent purges everything queued, deletes the SDK's storage, and sends one last `$consent` so the server
132
+ can carry out the withdrawal. The choice is kept for 6 months.
133
+
134
+ ## Masking
135
+
136
+ - Password, email, phone, card, one-time-code and hidden fields are never captured at any level: no value, no
137
+ length, no keystroke timing. Replay shows a fixed `********`.
138
+ - What people type in a `contenteditable` editor (or a `designMode` document) is masked at every level, like an input.
139
+ - Emails, card numbers, phone numbers, IBANs, SSNs, JWTs, API keys and long tokens are scrubbed from all text,
140
+ attributes and URLs before they leave the browser.
141
+ - Levels: `inputs` (default when signed out: input values hidden), `controls` (default after `identify()`: all text
142
+ hidden except buttons, links and labels), `text` (all text and images hidden). Remote config can only make it
143
+ stricter.
144
+ - Markup: `data-ib-mask` (or class `ib-mask`) masks an element's text and attributes, its open shadow root
145
+ included; `data-ib-unmask` keeps a control's label at `controls`; `data-ib-block` (or `ib-block`) replaces an
146
+ element with a placeholder in replay and stops autocapture inside it; `data-ib-no-capture` stops autocapture only;
147
+ `data-ib-name="checkout"` names a target.
148
+ - Attributes in replay: `data-*` values are masked like text (a short lowercase word such as `open` or `dark` stays,
149
+ so styles keep working), `<meta content>` is masked (CSRF tokens, keys) except `viewport`, `theme-color` and
150
+ `color-scheme`, a cross-origin iframe's URL is masked like a link, and inline handlers, `nonce` and `srcdoc` are
151
+ dropped.
152
+ - `blob:` and `data:` images and file inputs are always blocked in replay.
153
+
154
+ ## First-party proxy
155
+
156
+ Serving the SDK and ingest from your own domain keeps requests same-origin (ad blockers, Safari ITP) and passes the
157
+ visitor's IP. Point the SDK at the path: `init('ib_pk_…', { apiHost: '/ib' })`, or
158
+ `<script src="/ib/sdk/v1.js" data-key="ib_pk_…" async>` (the SDK then sends to `/ib` by itself).
159
+
160
+ **Cloudflare Worker** on `example.com/ib/*`:
161
+
162
+ ```ts
163
+ import { proxy } from 'ionblink-js/proxy'
164
+ export default { fetch: (req: Request) => proxy(req, { path: '/ib' }) }
165
+ ```
166
+
167
+ **Next.js** route handler, `app/ib/[...path]/route.ts`:
168
+
169
+ ```ts
170
+ import { proxy } from 'ionblink-js/proxy'
171
+ export const GET = (req: Request) => proxy(req, { path: '/ib' })
172
+ export const POST = GET
173
+ export const OPTIONS = GET
174
+ ```
175
+
176
+ **Not a plain rewrite.** A Vercel or Next.js rewrite to another host forwards every request header, your site's
177
+ cookies included: the script load and `sendBeacon` are same-origin, so they carry them. `proxy()` forwards only
178
+ `/v1/*` and `/sdk/*` with `GET`, `HEAD`, `POST` and `OPTIONS`, never cookies or `Authorization`, strips `Set-Cookie` from
179
+ answers, and refuses bodies over 4 MB. It adds the visitor's IP (`x-ib-client-ip`) and country and region
180
+ (`x-ib-client-country`, `x-ib-client-region`, from `request.cf`, `x-vercel-ip-country`, `cf-ipcountry` or `x-nf-geo`),
181
+ which IonBlink needs for rate limits and the consent rule.
182
+
183
+ ## Size and performance
184
+
185
+ | File | brotli | gzip | Loads |
186
+ |---|---|---|---|
187
+ | `v1.js` (core) | 10.66 KB | 11.72 KB | always, `async` |
188
+ | `x-<hash>.js` (signals, autocapture, vitals, offline queue, the replay controller) | 7.88 KB | 8.68 KB | when the core boots (idle) |
189
+ | `r-<hash>.js` (rrweb, masking, chunking) | 22.37 KB | 25.12 KB | only when this session is recorded, after the page's `load` event, at idle |
190
+ | snippet | 0.28 KB | 0.34 KB | inline |
191
+
192
+ CI fails when a file outgrows its budget (`scripts/size.ts`). How it stays out of your page's way:
193
+
194
+ - `init()` only checks the key and returns. Storage, the first page view, listeners and the config request wait for
195
+ `requestIdleCallback` (at most 1 s); calls made meanwhile are queued with their timestamps. Leaving the page first
196
+ still sends them.
197
+ - Listeners are passive. Scroll position is read once per frame in `requestAnimationFrame`, never inside an event
198
+ handler, and nothing else reads layout while the page scrolls or the pointer moves.
199
+ - The page view goes as soon as the SDK boots; then events go out every 5 s or at 20 events, replay every 10 s, at
200
+ most one request in flight per lane, each request gzipped (`CompressionStream`) when over 1 KB and at most 60 KB.
201
+ Requests use `fetch` with `keepalive`; when the page is hidden or left, what is left goes by `sendBeacon`. No
202
+ synchronous XHR, ever.
203
+ - Failed requests back off exponentially (2 s to 5 min, with jitter, honouring `Retry-After`). Offline, nothing is
204
+ tried until the browser is back online; batches wait in IndexedDB for the next page if they must.
205
+ - Every SDK task is timed and reported in `perf` (total main-thread ms, longest task, tasks over 4 and 50 ms), so the
206
+ SDK's own cost is visible per page. Failures are reported once per page as `$sdk_error` and never reach your code.
207
+
208
+ ## What it stores
209
+
210
+ No cookies by default, and never a third-party cookie. Everything is first-party, on your origin, and keyed by a
211
+ short hash of your site key (`<h>` below). `basic` and `off` store nothing at all.
212
+
213
+ | Where | Key | What | Size |
214
+ |---|---|---|---|
215
+ | localStorage | `ib_<h>` | anonymous id, session id, session start and last activity, person id after `identify()` | ~150 B |
216
+ | localStorage | `ib_consent_<h>` | the consent choice and when it was made (kept 6 months) | ~40 B |
217
+ | localStorage | `ib_cfg_<h>` | the site's remote config (replay sampling, masking), so the next page needn't wait | ~200 B |
218
+ | sessionStorage | `ib_w_<h>` | this tab's window id and batch counters | ~90 B |
219
+ | IndexedDB | `ib-<h>` | batches that could not be sent yet (offline), dropped after 24 h | usually empty |
220
+ | cookie (only `storage: 'cookie'`) | `ib_<h>` | anonymous id, session id and last activity, so subdomains share a visitor; never the person | ~80 B |
221
+
222
+ `storage: 'cookie'` (with `cookieDomain: '.example.com'`) is the one way to get a cookie: first-party, `SameSite=Lax`,
223
+ `Secure` on https, a year. `storage: 'memory'` stores nothing and keeps ids for one page load. Lowering consent deletes
224
+ all of it.
225
+
226
+ ## Debugging
227
+
228
+ `debug: true` (on by default on localhost, and with `?ib_debug=1` in the URL) logs what the SDK does. These say what to
229
+ fix even without it:
230
+
231
+ | Console says | Fix |
232
+ |---|---|
233
+ | `That does not look like a site key` | Copy the `ib_pk_…` key from Sites in the IonBlink app. |
234
+ | `That is a secret key: never put one in a page` | You pasted a server key (`ib_sk_…`). The SDK refuses to start. Revoke it in Sites and use the site key. |
235
+ | `Your Content-Security-Policy blocked https://api.ionblink.com` | Add it to `connect-src`, and `https://cdn.ionblink.com` to `script-src`, or use a first-party proxy. |
236
+ | `IonBlink refused events (403)` | Add your origin to Allowed origins in Sites (staging and preview hosts too), or turn capture on. |
237
+ | `IonBlink refused events (401)` | The key is unknown: check for a typo or a deleted site. |
238
+
239
+ `ionblink.state()` shows the mode, masking level and replay state; `ionblink.ids()` shows the ids (undefined until
240
+ consent allows storage).
241
+
242
+ ## Verified people
243
+
244
+ Any page can call `identify()` with any id, so IonBlink shows an id the browser set as *claimed*. It turns *verified*
245
+ when your server binds the session after sign-in, with [ionblink-node](https://github.com/Winding-Labs/ionblink-node)
246
+ and a secret key:
247
+
248
+ ```ts
249
+ // in the page: send the session's ids with the sign-in request
250
+ await fetch('/api/login', { method: 'POST', headers: { ...ionblink.headers(), 'content-type': 'application/json' }, body })
251
+
252
+ // on your server, once sign-in succeeded (userId from your own session, never from the request body)
253
+ ib.identify({ userId: user.id, ...whoFrom(req.headers) })
254
+ ```
255
+
256
+ If your API is on another origin, allow `x-ionblink-anon, x-ionblink-session` in its CORS allowed headers.
257
+
258
+ ## Development
259
+
260
+ ```sh
261
+ bun run check # typecheck, tests, build, size budgets
262
+ bun run demo # mock ingest + demo pages on http://localhost:8787, batches printed as they arrive
263
+ bun run verify # the same pages in headless Chrome (system install): every install path, no secret in any lane
264
+ ```
265
+
266
+ The wire format is in [`PROTOCOL.md`](../../PROTOCOL.md). `src/protocol.ts`, `scrub.ts`, `props.ts` and `rage.ts` are
267
+ generated from `packages/shared`: edit them there and run `bun run sync` from the repository root.
@@ -0,0 +1,66 @@
1
+ Third-party software in ionblink-js
2
+
3
+ ionblink-js's own code is MIT licensed (LICENSE). Its CDN builds bundle the software below:
4
+
5
+ dist/r-<hash>.js, the session replay chunk (also https://cdn.ionblink.com/sdk/r-<hash>.js), bundles
6
+ - rrweb: @rrweb/record, rrweb, rrweb-snapshot, @rrweb/types and @rrweb/utils (MIT)
7
+ - base64-arraybuffer, through rrweb (MIT)
8
+ dist/v1.js, dist/ionblink.min.js, dist/x-<hash>.js and dist/snippet.min.js hold only ionblink-js's own code.
9
+
10
+ The npm builds (dist/esm, dist/cjs) don't bundle it: @rrweb/record is a dependency, installed with its own licence.
11
+ The build writes this file beside the replay chunk as dist/r-<hash>.js.LICENSE.txt.
12
+
13
+ ================================================================================
14
+ rrweb: @rrweb/record, rrweb, rrweb-snapshot, @rrweb/types, @rrweb/utils
15
+ https://github.com/rrweb-io/rrweb
16
+ ================================================================================
17
+
18
+ MIT License
19
+
20
+ Copyright (c) 2018 Contributors (https://github.com/rrweb-io/rrweb/graphs/contributors)
21
+
22
+ Permission is hereby granted, free of charge, to any person obtaining a copy
23
+ of this software and associated documentation files (the "Software"), to deal
24
+ in the Software without restriction, including without limitation the rights
25
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
26
+ copies of the Software, and to permit persons to whom the Software is
27
+ furnished to do so, subject to the following conditions:
28
+
29
+ The above copyright notice and this permission notice shall be included in all
30
+ copies or substantial portions of the Software.
31
+
32
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
35
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
36
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
37
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
38
+ SOFTWARE.
39
+
40
+ ================================================================================
41
+ base64-arraybuffer
42
+ https://github.com/niklasvh/base64-arraybuffer
43
+ ================================================================================
44
+
45
+ Copyright (c) 2012 Niklas von Hertzen
46
+
47
+ Permission is hereby granted, free of charge, to any person
48
+ obtaining a copy of this software and associated documentation
49
+ files (the "Software"), to deal in the Software without
50
+ restriction, including without limitation the rights to use,
51
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
52
+ copies of the Software, and to permit persons to whom the
53
+ Software is furnished to do so, subject to the following
54
+ conditions:
55
+
56
+ The above copyright notice and this permission notice shall be
57
+ included in all copies or substantial portions of the Software.
58
+
59
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
60
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
61
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
62
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
63
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
64
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
65
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
66
+ OTHER DEALINGS IN THE SOFTWARE.