js-bao-wss-client 2.0.0 → 2.0.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 (48) hide show
  1. package/README.md +10 -7
  2. package/dist/JsBaoClient.d.ts +18 -24
  3. package/dist/JsBaoClient.d.ts.map +1 -1
  4. package/dist/JsBaoClient.js +9 -77
  5. package/dist/JsBaoClient.js.map +1 -1
  6. package/dist/api/blobBucketsApi.d.ts +43 -4
  7. package/dist/api/blobBucketsApi.d.ts.map +1 -1
  8. package/dist/api/blobBucketsApi.js +8 -0
  9. package/dist/api/blobBucketsApi.js.map +1 -1
  10. package/dist/api/databasesApi.d.ts +14 -1
  11. package/dist/api/databasesApi.d.ts.map +1 -1
  12. package/dist/api/databasesApi.js.map +1 -1
  13. package/dist/api/documentsApi.d.ts.map +1 -1
  14. package/dist/api/documentsApi.js +35 -7
  15. package/dist/api/documentsApi.js.map +1 -1
  16. package/dist/api/geminiApi.d.ts +34 -1
  17. package/dist/api/geminiApi.d.ts.map +1 -1
  18. package/dist/api/geminiApi.js +14 -1
  19. package/dist/api/geminiApi.js.map +1 -1
  20. package/dist/api/llmApi.d.ts +18 -1
  21. package/dist/api/llmApi.d.ts.map +1 -1
  22. package/dist/api/llmApi.js +8 -1
  23. package/dist/api/llmApi.js.map +1 -1
  24. package/dist/browser.umd.js +82 -86
  25. package/dist/browser.umd.js.map +1 -1
  26. package/dist/dev/DevTools.d.ts +38 -0
  27. package/dist/dev/DevTools.d.ts.map +1 -0
  28. package/dist/dev/DevTools.js +203 -0
  29. package/dist/dev/DevTools.js.map +1 -0
  30. package/dist/dev/index.d.ts +35 -0
  31. package/dist/dev/index.d.ts.map +1 -0
  32. package/dist/dev/index.js +40 -0
  33. package/dist/dev/index.js.map +1 -0
  34. package/dist/dev/storage.d.ts +61 -0
  35. package/dist/dev/storage.d.ts.map +1 -0
  36. package/dist/dev/storage.js +130 -0
  37. package/dist/dev/storage.js.map +1 -0
  38. package/dist/dev/useDevToken.d.ts +155 -0
  39. package/dist/dev/useDevToken.d.ts.map +1 -0
  40. package/dist/dev/useDevToken.js +266 -0
  41. package/dist/dev/useDevToken.js.map +1 -0
  42. package/dist/internal/authController.d.ts.map +1 -1
  43. package/dist/internal/authController.js +8 -0
  44. package/dist/internal/authController.js.map +1 -1
  45. package/dist/internal/databaseSubscriptions.d.ts +3 -0
  46. package/dist/internal/databaseSubscriptions.d.ts.map +1 -1
  47. package/dist/internal/databaseSubscriptions.js.map +1 -1
  48. package/package.json +11 -2
@@ -0,0 +1,38 @@
1
+ /**
2
+ * `<PrimitiveDevTools>` / `<DevTools>` — a floating dev-only panel for
3
+ * switching between test users (issue #420).
4
+ *
5
+ * Design constraints (locked forks):
6
+ * - Fork 4: inline styling, NO separate CSS file.
7
+ * - Fork 6: dual production gate — this whole `/dev` entrypoint tree-shakes
8
+ * out of production bundles, AND a runtime `import.meta.env.DEV` guard
9
+ * makes the component render `null` (installing no window hooks) when
10
+ * DEV === false.
11
+ * - React is an OPTIONAL peer dependency. We statically `import * as React`
12
+ * so bundlers (Vite/Webpack) see a real import edge and can externalize the
13
+ * `react` peer dep — this is the primary path in a normal ESM React app. We
14
+ * build elements via `createElement` (no JSX) and provide a local ambient
15
+ * `declare module "react"` so this compiles even when `@types/react` is not
16
+ * installed at build time. A graceful "react peer dep required" error is
17
+ * still surfaced for the case where react genuinely isn't present.
18
+ */
19
+ import { type DevClient } from "./useDevToken.js";
20
+ /** Props for `<DevTools>`. */
21
+ export interface DevToolsProps {
22
+ /** The JsBaoClient instance to drive (required). */
23
+ client: DevClient;
24
+ /** Auto-apply VITE_PRIMITIVE_DEV_TOKEN on mount (default true). */
25
+ autoApplyEnvToken?: boolean;
26
+ /** Override the DEV gate (mainly for tests / storybooks). */
27
+ isDev?: boolean;
28
+ /** Default TTL minted for switch-user (default "30m"). */
29
+ ttl?: string;
30
+ }
31
+ /**
32
+ * The DevTools panel. Renders `null` (and installs no window hooks) outside a
33
+ * dev build, per the dual production gate.
34
+ */
35
+ export declare function DevTools(props: DevToolsProps): any;
36
+ /** Alias matching the design's `<PrimitiveDevTools>` name. */
37
+ export declare const PrimitiveDevTools: typeof DevTools;
38
+ //# sourceMappingURL=DevTools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DevTools.d.ts","sourceRoot":"","sources":["../../dev/DevTools.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAQH,OAAO,EAEL,KAAK,SAAS,EAGf,MAAM,kBAAkB,CAAC;AAU1B,8BAA8B;AAC9B,MAAM,WAAW,aAAa;IAC5B,oDAAoD;IACpD,MAAM,EAAE,SAAS,CAAC;IAClB,mEAAmE;IACnE,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,6DAA6D;IAC7D,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,0DAA0D;IAC1D,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAwED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,GAAG,CAgKlD;AAED,8DAA8D;AAC9D,eAAO,MAAM,iBAAiB,iBAAW,CAAC"}
@@ -0,0 +1,203 @@
1
+ /**
2
+ * `<PrimitiveDevTools>` / `<DevTools>` — a floating dev-only panel for
3
+ * switching between test users (issue #420).
4
+ *
5
+ * Design constraints (locked forks):
6
+ * - Fork 4: inline styling, NO separate CSS file.
7
+ * - Fork 6: dual production gate — this whole `/dev` entrypoint tree-shakes
8
+ * out of production bundles, AND a runtime `import.meta.env.DEV` guard
9
+ * makes the component render `null` (installing no window hooks) when
10
+ * DEV === false.
11
+ * - React is an OPTIONAL peer dependency. We statically `import * as React`
12
+ * so bundlers (Vite/Webpack) see a real import edge and can externalize the
13
+ * `react` peer dep — this is the primary path in a normal ESM React app. We
14
+ * build elements via `createElement` (no JSX) and provide a local ambient
15
+ * `declare module "react"` so this compiles even when `@types/react` is not
16
+ * installed at build time. A graceful "react peer dep required" error is
17
+ * still surfaced for the case where react genuinely isn't present.
18
+ */
19
+ // Static import so bundlers can externalize/optimize the optional `react` peer
20
+ // dep. In an ESM React app this resolves to the host app's React; when react is
21
+ // genuinely absent the bundler/runtime fails the import (or `React` is
22
+ // undefined), which `resolveReact()` turns into an actionable error below.
23
+ import * as React from "react";
24
+ import { DevToolsController, } from "./useDevToken.js";
25
+ /**
26
+ * Resolve the host app's React. The primary path is the static
27
+ * `import * as React from "react"` at the top of this module — in a normal ESM
28
+ * React app the bundler externalizes `react` and `React` resolves to the host's
29
+ * copy. We still defensively fall back to a UMD `globalThis.React` (script-tag
30
+ * setups) and throw a clear, actionable error when React is genuinely absent,
31
+ * rather than a confusing `undefined.createElement` crash.
32
+ */
33
+ function resolveReact() {
34
+ // 1) Static ESM import (the path bundlers see and externalize). Interop:
35
+ // `import * as React` may surface the module under `.default` on some
36
+ // CJS-interop setups.
37
+ const candidate = (React?.default ?? React);
38
+ if (candidate && typeof candidate.createElement === "function") {
39
+ return candidate;
40
+ }
41
+ // 2) UMD / script-tag setups expose React on the global.
42
+ const g = globalThis;
43
+ if (g.React && typeof g.React.createElement === "function") {
44
+ return g.React;
45
+ }
46
+ throw new Error("[PrimitiveDevTools] React is required to use <DevTools> but was not found. " +
47
+ "Install it as a peer dependency: `npm install react react-dom`.");
48
+ }
49
+ const panelStyle = {
50
+ position: "fixed",
51
+ bottom: "16px",
52
+ right: "16px",
53
+ zIndex: 2147483647,
54
+ background: "#1f2430",
55
+ color: "#e6e6e6",
56
+ fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
57
+ fontSize: "12px",
58
+ padding: "12px",
59
+ borderRadius: "8px",
60
+ boxShadow: "0 4px 16px rgba(0,0,0,0.4)",
61
+ width: "260px",
62
+ };
63
+ const labelStyle = {
64
+ display: "block",
65
+ marginBottom: "4px",
66
+ opacity: 0.7,
67
+ };
68
+ const inputStyle = {
69
+ width: "100%",
70
+ boxSizing: "border-box",
71
+ marginBottom: "6px",
72
+ padding: "4px 6px",
73
+ background: "#11141b",
74
+ color: "#e6e6e6",
75
+ border: "1px solid #333a47",
76
+ borderRadius: "4px",
77
+ };
78
+ const buttonStyle = {
79
+ width: "100%",
80
+ padding: "6px",
81
+ marginBottom: "6px",
82
+ background: "#3b82f6",
83
+ color: "#fff",
84
+ border: "none",
85
+ borderRadius: "4px",
86
+ cursor: "pointer",
87
+ };
88
+ /**
89
+ * The DevTools panel. Renders `null` (and installs no window hooks) outside a
90
+ * dev build, per the dual production gate.
91
+ */
92
+ export function DevTools(props) {
93
+ if (!props || !props.client) {
94
+ throw new Error("<DevTools> requires a `client` prop (a JsBaoClient instance).");
95
+ }
96
+ const React = resolveReact();
97
+ const { createElement: h, useState, useEffect, useRef } = React;
98
+ const controllerRef = useRef(null);
99
+ if (!controllerRef.current) {
100
+ controllerRef.current = new DevToolsController({
101
+ client: props.client,
102
+ autoApplyEnvToken: props.autoApplyEnvToken,
103
+ isDev: props.isDev,
104
+ ttl: props.ttl,
105
+ });
106
+ }
107
+ const controller = controllerRef.current;
108
+ const [me, setMe] = useState(null);
109
+ const [users, setUsers] = useState([]);
110
+ const [adminError, setAdminError] = useState(null);
111
+ const [quickToken, setQuickToken] = useState("");
112
+ const [status, setStatus] = useState("");
113
+ useEffect(() => {
114
+ if (!controller.isDev)
115
+ return;
116
+ const cleanup = controller.activate();
117
+ // Load current user + (best-effort) the admin user list on open.
118
+ controller
119
+ .getCurrentUser()
120
+ .then((u) => setMe(u))
121
+ .catch(() => { });
122
+ controller
123
+ .listUsers()
124
+ .then((list) => {
125
+ setUsers(list);
126
+ setAdminError(null);
127
+ })
128
+ .catch(() => setAdminError("Admin/owner required to list users."));
129
+ return cleanup;
130
+ // eslint-disable-next-line react-hooks/exhaustive-deps
131
+ }, []);
132
+ // Production gate: render nothing.
133
+ if (!controller.isDev) {
134
+ return null;
135
+ }
136
+ const onSwitch = (userId) => {
137
+ setStatus(`Switching to ${userId}…`);
138
+ controller
139
+ .switchToUser(userId)
140
+ .then(() => setStatus(`Now acting as ${userId}`))
141
+ .catch((e) => setStatus(`Switch failed: ${e?.message ?? e}`));
142
+ };
143
+ const onQuickLogin = () => {
144
+ if (!quickToken.trim())
145
+ return;
146
+ controller.setToken(quickToken.trim());
147
+ setStatus("Applied pasted token");
148
+ setQuickToken("");
149
+ };
150
+ const onLogout = () => {
151
+ controller
152
+ .logout(me?.userId)
153
+ .then(() => {
154
+ setMe(null);
155
+ setStatus("Logged out");
156
+ })
157
+ .catch((e) => setStatus(`Logout failed: ${e?.message ?? e}`));
158
+ };
159
+ const children = [];
160
+ children.push(h("div", { key: "title", style: { fontWeight: "bold", marginBottom: "8px" } }, "Primitive DevTools"));
161
+ children.push(h("div", { key: "me", style: { marginBottom: "8px" } }, me
162
+ ? `${me.email ?? me.userId} (${me.appRole ?? "?"})`
163
+ : "Not signed in"));
164
+ // Admin-gated switch-user dropdown.
165
+ if (adminError) {
166
+ children.push(h("div", { key: "admin-err", style: { color: "#fca5a5", marginBottom: "8px" } }, adminError));
167
+ }
168
+ else if (users.length > 0) {
169
+ children.push(h("label", { key: "switch-label", style: labelStyle }, "Switch user"));
170
+ children.push(h("select", {
171
+ key: "switch",
172
+ style: inputStyle,
173
+ onChange: (e) => {
174
+ const v = e?.target?.value;
175
+ if (v)
176
+ onSwitch(v);
177
+ },
178
+ defaultValue: "",
179
+ }, [
180
+ h("option", { key: "_", value: "" }, "Select a user…"),
181
+ ...users.map((u) => h("option", { key: u.userId, value: u.userId }, `${u.email ?? u.name ?? u.userId}${u.role ? ` (${u.role})` : ""}`)),
182
+ ]));
183
+ }
184
+ // Quick login.
185
+ children.push(h("label", { key: "ql-label", style: labelStyle }, "Quick login (paste token)"));
186
+ children.push(h("input", {
187
+ key: "ql-input",
188
+ style: inputStyle,
189
+ placeholder: "prim_…",
190
+ value: quickToken,
191
+ onChange: (e) => setQuickToken(e?.target?.value ?? ""),
192
+ }));
193
+ children.push(h("button", { key: "ql-btn", style: buttonStyle, onClick: onQuickLogin }, "Apply token"));
194
+ // Logout.
195
+ children.push(h("button", { key: "logout", style: { ...buttonStyle, background: "#475569" }, onClick: onLogout }, "Logout"));
196
+ if (status) {
197
+ children.push(h("div", { key: "status", style: { marginTop: "6px", opacity: 0.8 } }, status));
198
+ }
199
+ return h("div", { style: panelStyle }, children);
200
+ }
201
+ /** Alias matching the design's `<PrimitiveDevTools>` name. */
202
+ export const PrimitiveDevTools = DevTools;
203
+ //# sourceMappingURL=DevTools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DevTools.js","sourceRoot":"","sources":["../../dev/DevTools.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,+EAA+E;AAC/E,gFAAgF;AAChF,uEAAuE;AACvE,2EAA2E;AAC3E,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EACL,kBAAkB,GAInB,MAAM,kBAAkB,CAAC;AAsB1B;;;;;;;GAOG;AACH,SAAS,YAAY;IACnB,yEAAyE;IACzE,yEAAyE;IACzE,yBAAyB;IACzB,MAAM,SAAS,GAAG,CAAE,KAAa,EAAE,OAAO,IAAI,KAAK,CAAQ,CAAC;IAC5D,IAAI,SAAS,IAAI,OAAO,SAAS,CAAC,aAAa,KAAK,UAAU,EAAE,CAAC;QAC/D,OAAO,SAAsB,CAAC;IAChC,CAAC;IACD,yDAAyD;IACzD,MAAM,CAAC,GAAG,UAAiB,CAAC;IAC5B,IAAI,CAAC,CAAC,KAAK,IAAI,OAAO,CAAC,CAAC,KAAK,CAAC,aAAa,KAAK,UAAU,EAAE,CAAC;QAC3D,OAAO,CAAC,CAAC,KAAkB,CAAC;IAC9B,CAAC;IACD,MAAM,IAAI,KAAK,CACb,6EAA6E;QAC3E,iEAAiE,CACpE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,GAAoC;IAClD,QAAQ,EAAE,OAAO;IACjB,MAAM,EAAE,MAAM;IACd,KAAK,EAAE,MAAM;IACb,MAAM,EAAE,UAAU;IAClB,UAAU,EAAE,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C,IAAI,CACX,CAAC,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,CAAC,CAC/E,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,QAAQ,CAAC,CAAC;AACnD,CAAC;AAED,8DAA8D;AAC9D,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAQ,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * `js-bao-wss-client/dev` — developer-only entrypoint (issue #420).
3
+ *
4
+ * Importing this subpath opts into the DevTools surface. It is a SEPARATE
5
+ * entrypoint from the main package so production bundles that never import it
6
+ * tree-shake all of this code out (Fork 6 dual gate, layer 1). The runtime
7
+ * `import.meta.env.DEV` guard is layer 2.
8
+ *
9
+ * ## React is NOT required to sign someone in
10
+ *
11
+ * The framework-agnostic API below ({@link injectDevToken}, {@link switchDevUser},
12
+ * {@link createDevTools}, {@link DevToolsController}) lets ANY app — vanilla JS,
13
+ * Vue, Svelte, Solid, Node — sign a test user into the client with a single
14
+ * function call and never import React:
15
+ *
16
+ * ```ts
17
+ * import { injectDevToken, switchDevUser } from "js-bao-wss-client/dev";
18
+ *
19
+ * // Sign in with a token (e.g. from `primitive tokens inject`):
20
+ * injectDevToken(client, "prim_…");
21
+ *
22
+ * // …or switch to a test user by id (mints/reuses a 30-min token):
23
+ * await switchDevUser({ client }, "user_123");
24
+ * ```
25
+ *
26
+ * The `<DevTools>` React component is an OPTIONAL convenience UI layered on top
27
+ * of the same controller. React is an OPTIONAL peer dependency, only pulled in
28
+ * if you import the component — the framework-agnostic helpers above never
29
+ * import React.
30
+ */
31
+ export { injectDevToken, switchDevUser, createDevTools, DevToolsController, type DevClient, type DevToolsConfig, type AppUserSummary, type CurrentUserInfo, type DevToolsWindowApi, } from "./useDevToken.js";
32
+ export { DevTools, PrimitiveDevTools } from "./DevTools.js";
33
+ export type { DevToolsProps } from "./DevTools.js";
34
+ export { DevTokenCache, DEV_TOKENS_STORAGE_KEY, type CachedDevToken, type DevTokenStore, } from "./storage.js";
35
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../dev/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,EAEL,cAAc,EACd,aAAa,EACb,cAAc,EAEd,kBAAkB,EAClB,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,iBAAiB,GACvB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC5D,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,KAAK,cAAc,EACnB,KAAK,aAAa,GACnB,MAAM,cAAc,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * `js-bao-wss-client/dev` — developer-only entrypoint (issue #420).
3
+ *
4
+ * Importing this subpath opts into the DevTools surface. It is a SEPARATE
5
+ * entrypoint from the main package so production bundles that never import it
6
+ * tree-shake all of this code out (Fork 6 dual gate, layer 1). The runtime
7
+ * `import.meta.env.DEV` guard is layer 2.
8
+ *
9
+ * ## React is NOT required to sign someone in
10
+ *
11
+ * The framework-agnostic API below ({@link injectDevToken}, {@link switchDevUser},
12
+ * {@link createDevTools}, {@link DevToolsController}) lets ANY app — vanilla JS,
13
+ * Vue, Svelte, Solid, Node — sign a test user into the client with a single
14
+ * function call and never import React:
15
+ *
16
+ * ```ts
17
+ * import { injectDevToken, switchDevUser } from "js-bao-wss-client/dev";
18
+ *
19
+ * // Sign in with a token (e.g. from `primitive tokens inject`):
20
+ * injectDevToken(client, "prim_…");
21
+ *
22
+ * // …or switch to a test user by id (mints/reuses a 30-min token):
23
+ * await switchDevUser({ client }, "user_123");
24
+ * ```
25
+ *
26
+ * The `<DevTools>` React component is an OPTIONAL convenience UI layered on top
27
+ * of the same controller. React is an OPTIONAL peer dependency, only pulled in
28
+ * if you import the component — the framework-agnostic helpers above never
29
+ * import React.
30
+ */
31
+ // ── Framework-agnostic API (NO React) ───────────────────────────────────────
32
+ export {
33
+ // Convenience helpers — the one-call non-React way to sign in.
34
+ injectDevToken, switchDevUser, createDevTools,
35
+ // The underlying controller (use directly for full control).
36
+ DevToolsController, } from "./useDevToken.js";
37
+ // ── Optional React convenience UI (only this pulls in `react`) ──────────────
38
+ export { DevTools, PrimitiveDevTools } from "./DevTools.js";
39
+ export { DevTokenCache, DEV_TOKENS_STORAGE_KEY, } from "./storage.js";
40
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../dev/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,+EAA+E;AAC/E,OAAO;AACL,+DAA+D;AAC/D,cAAc,EACd,aAAa,EACb,cAAc;AACd,6DAA6D;AAC7D,kBAAkB,GAMnB,MAAM,kBAAkB,CAAC;AAE1B,+EAA+E;AAC/E,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAG5D,OAAO,EACL,aAAa,EACb,sBAAsB,GAGvB,MAAM,cAAc,CAAC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Dev-token cache for `<DevTools>` (issue #420).
3
+ *
4
+ * Persists short-lived (30-min) dev tokens in localStorage, keyed by app and
5
+ * user, so switching back to a recently-used test user can reuse a cached
6
+ * token without a fresh API call. Falls back to an in-memory Map when
7
+ * localStorage is unavailable (Safari private mode / quota errors).
8
+ *
9
+ * This module is intentionally framework-agnostic and side-effect-free on
10
+ * import so it can be unit-tested in a plain Node environment with a fake
11
+ * `localStorage`.
12
+ */
13
+ export declare const DEV_TOKENS_STORAGE_KEY = "__primitive_dev_tokens_v1__";
14
+ export interface CachedDevToken {
15
+ token: string;
16
+ /** Epoch millis at which the token expires. */
17
+ expiresAt: number;
18
+ /** Epoch millis at which the token was minted/cached. */
19
+ createdAt: number;
20
+ /** Human-readable token name (e.g. "devtools-169..."). */
21
+ name: string;
22
+ }
23
+ /** Shape persisted under {@link DEV_TOKENS_STORAGE_KEY}. */
24
+ export type DevTokenStore = {
25
+ [appId: string]: {
26
+ [userId: string]: CachedDevToken;
27
+ };
28
+ };
29
+ /** Minimal Storage surface we depend on (matches the DOM `Storage` interface). */
30
+ export interface StorageLike {
31
+ getItem(key: string): string | null;
32
+ setItem(key: string, value: string): void;
33
+ removeItem(key: string): void;
34
+ }
35
+ /**
36
+ * A cache that prefers localStorage but transparently falls back to an
37
+ * in-memory Map if any localStorage operation throws (quota / private mode).
38
+ */
39
+ export declare class DevTokenCache {
40
+ private storage;
41
+ private memory;
42
+ private usingMemory;
43
+ constructor(storage?: StorageLike | null);
44
+ /** True when the cache has fallen back to the in-memory Map. */
45
+ get isInMemory(): boolean;
46
+ private read;
47
+ private write;
48
+ private fallBackToMemory;
49
+ /**
50
+ * Remove expired entries across all apps/users. Returns the pruned store.
51
+ * Called on panel open.
52
+ */
53
+ prune(now?: number): DevTokenStore;
54
+ /** Get a non-expired cached token for the app/user, or null. */
55
+ get(appId: string, userId: string, now?: number): CachedDevToken | null;
56
+ /** Store/replace the cached token for an app/user. */
57
+ set(appId: string, userId: string, entry: CachedDevToken): void;
58
+ /** Remove the cached token for an app/user (e.g. on logout). */
59
+ remove(appId: string, userId: string): void;
60
+ }
61
+ //# sourceMappingURL=storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../dev/storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,sBAAsB,gCAAgC,CA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K,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;CAQ5C"}
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Dev-token cache for `<DevTools>` (issue #420).
3
+ *
4
+ * Persists short-lived (30-min) dev tokens in localStorage, keyed by app and
5
+ * user, so switching back to a recently-used test user can reuse a cached
6
+ * token without a fresh API call. Falls back to an in-memory Map when
7
+ * localStorage is unavailable (Safari private mode / quota errors).
8
+ *
9
+ * This module is intentionally framework-agnostic and side-effect-free on
10
+ * import so it can be unit-tested in a plain Node environment with a fake
11
+ * `localStorage`.
12
+ */
13
+ export const DEV_TOKENS_STORAGE_KEY = "__primitive_dev_tokens_v1__";
14
+ function resolveStorage() {
15
+ try {
16
+ if (typeof localStorage !== "undefined" && localStorage) {
17
+ return localStorage;
18
+ }
19
+ }
20
+ catch {
21
+ // accessing localStorage can throw in sandboxed iframes
22
+ }
23
+ return null;
24
+ }
25
+ /**
26
+ * A cache that prefers localStorage but transparently falls back to an
27
+ * in-memory Map if any localStorage operation throws (quota / private mode).
28
+ */
29
+ export class DevTokenCache {
30
+ constructor(storage) {
31
+ this.memory = {};
32
+ this.usingMemory = false;
33
+ this.storage = storage === undefined ? resolveStorage() : storage;
34
+ if (!this.storage)
35
+ this.usingMemory = true;
36
+ }
37
+ /** True when the cache has fallen back to the in-memory Map. */
38
+ get isInMemory() {
39
+ return this.usingMemory;
40
+ }
41
+ read() {
42
+ if (this.usingMemory || !this.storage)
43
+ return this.memory;
44
+ try {
45
+ const raw = this.storage.getItem(DEV_TOKENS_STORAGE_KEY);
46
+ if (!raw)
47
+ return {};
48
+ const parsed = JSON.parse(raw);
49
+ return parsed && typeof parsed === "object" ? parsed : {};
50
+ }
51
+ catch {
52
+ // Corrupt JSON or read failure — fall back to memory.
53
+ this.fallBackToMemory();
54
+ return this.memory;
55
+ }
56
+ }
57
+ write(store) {
58
+ if (this.usingMemory || !this.storage) {
59
+ this.memory = store;
60
+ return;
61
+ }
62
+ try {
63
+ this.storage.setItem(DEV_TOKENS_STORAGE_KEY, JSON.stringify(store));
64
+ }
65
+ catch {
66
+ // Quota exceeded / private mode — switch to memory and keep working.
67
+ this.fallBackToMemory(store);
68
+ }
69
+ }
70
+ fallBackToMemory(seed) {
71
+ this.usingMemory = true;
72
+ if (seed)
73
+ this.memory = seed;
74
+ }
75
+ /**
76
+ * Remove expired entries across all apps/users. Returns the pruned store.
77
+ * Called on panel open.
78
+ */
79
+ prune(now = Date.now()) {
80
+ const store = this.read();
81
+ let changed = false;
82
+ for (const appId of Object.keys(store)) {
83
+ const users = store[appId];
84
+ for (const userId of Object.keys(users)) {
85
+ if (users[userId].expiresAt <= now) {
86
+ delete users[userId];
87
+ changed = true;
88
+ }
89
+ }
90
+ if (Object.keys(users).length === 0) {
91
+ delete store[appId];
92
+ changed = true;
93
+ }
94
+ }
95
+ if (changed)
96
+ this.write(store);
97
+ return store;
98
+ }
99
+ /** Get a non-expired cached token for the app/user, or null. */
100
+ get(appId, userId, now = Date.now()) {
101
+ const store = this.read();
102
+ const entry = store[appId]?.[userId];
103
+ if (!entry)
104
+ return null;
105
+ if (entry.expiresAt <= now) {
106
+ this.remove(appId, userId);
107
+ return null;
108
+ }
109
+ return entry;
110
+ }
111
+ /** Store/replace the cached token for an app/user. */
112
+ set(appId, userId, entry) {
113
+ const store = this.read();
114
+ if (!store[appId])
115
+ store[appId] = {};
116
+ store[appId][userId] = entry;
117
+ this.write(store);
118
+ }
119
+ /** Remove the cached token for an app/user (e.g. on logout). */
120
+ remove(appId, userId) {
121
+ const store = this.read();
122
+ if (store[appId]) {
123
+ delete store[appId][userId];
124
+ if (Object.keys(store[appId]).length === 0)
125
+ delete store[appId];
126
+ this.write(store);
127
+ }
128
+ }
129
+ }
130
+ //# sourceMappingURL=storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../dev/storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,CAAC,MAA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