@boost33/shell-data 0.1.0 → 0.1.1

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/CHANGELOG.md CHANGED
@@ -2,6 +2,35 @@
2
2
 
3
3
  Changes to the published surface of `@boost33/shell-data`. Consumers upgrade by hand, as with `@boost33/ui`, so this file is the only notice they get.
4
4
 
5
+ ## 0.1.1 — 2026-11-13
6
+
7
+ ### Added — `gate()` and `isNavigation()`, for an app whose proxy does more than refresh
8
+
9
+ **Not breaking.** `gateRequest` behaves exactly as in 0.1.0; it is now built on `gate()`.
10
+
11
+ - **`gate(request, options) → GateResult`**: the same §5.1 decision without building a response. It takes any `Request` and returns one of five outcomes:
12
+ - `none`: no session cookie.
13
+ - `live`: the short-lived cookie is not near expiry. This is an unverified check, so verify it yourself.
14
+ - `refreshed`: the new token, already verified, plus the cookies to forward verbatim and the rewritten Cookie header.
15
+ - `dead`: a ready 307 to sign in that clears both cookies.
16
+ - `unwell`: forward nothing.
17
+
18
+ This is for apps that verify `b33_ctx` in their own proxy and hand claims to the page, as Results does.
19
+ - **`isNavigation(request)`**: the matcher's rule in code, for an app whose proxy must run on every request and so cannot narrow its matcher.
20
+ - **`CLAIMS_PROXY_MATCHER` and `isPrefetch(request)`, for an app whose proxy hands claims to its pages in a request header.** `SESSION_GATE_MATCHER` is safe only where pages verify `b33_ctx` themselves. Its prefetch exclusions read headers the client sets, so in a header-passing app a request marked as a prefetch would skip the proxy, and the page would trust a forged header. `CLAIMS_PROXY_MATCHER` runs the proxy on every request but Next's static assets. `isPrefetch` (Next's router, `purpose` and `sec-purpose`) and `isNavigation` then skip only the refresh. The README, and each matcher's JSDoc, name the architecture it assumes. Found by activity-jmini and hub-jmini.
21
+ - `isNavigation` now also treats `sec-purpose: prefetch` (a browser's speculative load) as a prefetch. `SESSION_GATE_MATCHER` is unchanged, so an app's existing literal copy still passes `matcherIsNavigationOnly`.
22
+ - **A viewer-credential mode for apps with no service keys** (Results, from activity-jmini). `identityKey`, `appId` and `ledger` are now optional.
23
+ - Without `identityKey`, there is no profile read: `profileName` resolves null and the name claim stands.
24
+ - Without a ledger `key` and `app`, the tokens are read as the viewer through `@boost33/ledger-client`'s `tokenSplitForViewer(b33_ctx)`, which is read-only and keyless.
25
+ - The product list was already read as the viewer.
26
+ - In viewer mode, an expired `b33_ctx` gives `unknown` with no retry, and the ledger's `no_wallet` gives `none`.
27
+
28
+ An app with keys passes them exactly as in 0.1.0, and nothing changes for it. The output shape is unchanged.
29
+ - **Fixed: a ledger URL ending in `/api/v1` read every token as "unknown".** The package appended `/api/v1` to whatever it was given, so an app whose `BOOST33_LEDGER_URL` already ends in it (Outbound, B33-660) asked for `/api/v1/api/v1/…`. The URL is now accepted with or without the suffix and trailing slashes, and never doubled. Found by outbound-jmini on 0.1.0.
30
+ - `appId` is documented as Identity's `APPS` slug (`outbound`), not the product slug (`boostoutbound`).
31
+ - **A compile-time check against `@boost33/ui` 0.11.0's `BackdropStandardChromeProps`** (both directions), so the data this package returns and what the chrome takes cannot drift apart without this package's build failing. `@boost33/ui` is a types-only devDependency; a test holds that `src/` never imports it. The check compiles with `moduleResolution: "bundler"`, as a Next app does (`tsconfig.drift.json`). Under this package's own NodeNext setting, `@boost33/ui`'s types silently resolve to `any` and the check could never fail; a negative control proved that before the fix.
32
+ - **`client` is identity's caller slug** from `APPS` in boost33-identity `src/config/apps.ts`, not a product slug: `outbound`, `passport`, `hub`, `boostscore`… An unlisted value still works; identity logs it as `unrecognised`.
33
+
5
34
  ## 0.1.0 — 2026-11-13
6
35
 
7
36
  ### Added — `getBackdropChromeData`, everything the Backdrop chrome draws, from one call (B33-1726)
package/README.md CHANGED
@@ -12,20 +12,36 @@ return <BackdropStandardChrome {...data} variant="app" place="boostscore" labels
12
12
 
13
13
  - **`claims`**: the claims your app already verified from `b33_ctx`. This package does not verify them again, and it never reads `design`. Deciding which design a person sees is your app's `isBackdropPreview`, and only that.
14
14
  - **`cookies`**: the request's `b33_sid` and `b33_ctx` values.
15
- - **`config`**: origins and keys from your server environment: `identityUrl`, `hubUrl`, `identityKey`, `appId`, and `ledger: { url, key, app }`. Optionally `docsUrl` and `supportEmail`.
15
+ - **`config`**: origins, and keys if your app has them, from your server environment: `identityUrl`, `hubUrl`, and optionally `identityKey` with `appId`, `ledger: { url, key, app }`, `docsUrl` and `supportEmail`.
16
+
17
+ **Two credential modes, chosen by what you pass.**
18
+ - **An app with service keys** (it is in Identity's `APPS`, with a ledger key) passes `identityKey`, `appId` and `ledger: { url, key, app }`. **`appId` is your slug in Identity's `APPS`** (boost33-identity `src/config/apps.ts`), not your product slug: Outbound passes `outbound`, not `boostoutbound`. The ledger `url` may be the origin or end in `/api/v1`; either works. The profile is read with the Identity key, and the tokens with the ledger key.
19
+ - **An app without them** (Results, for one) leaves the keys out and reads everything as the viewer, with the cookies it was given:
20
+ - the product list, which is always read this way;
21
+ - the tokens, through the ledger's `tokenSplitForViewer` with the viewer's `b33_ctx`.
22
+
23
+ The profile read is skipped, so `profileName` resolves null and the `name` claim stands. This needs no new secret and grants the least privilege.
16
24
 
17
25
  `person` and `links` are ready at once. `profileName`, `products` and `tokens` are promises. All three start together and none ever rejects, so the chrome streams each one in its own Suspense boundary. Each read fails alone, and the chrome always renders.
18
26
 
19
27
  | Read | Source | On failure |
20
28
  | --- | --- | --- |
21
29
  | `products` | Identity `GET /api/v1/products`, as the viewer (their cookies) | the last good list, `stale: true`; else `null` (global rail items only) |
22
- | `profileName` | Identity `GET /api/v1/profile`, with your service key | `null`: the `name` claim stays |
23
- | `tokens` | `@boost33/ledger-client` `tokenSplit()` | `{ kind: 'unknown' }`; no wallet gives `{ kind: 'none' }` |
30
+ | `profileName` | Identity `GET /api/v1/profile`, with your service key (skipped without one) | `null`: the `name` claim stays |
31
+ | `tokens` | `@boost33/ledger-client` `tokenSplit()` with your key, else `tokenSplitForViewer()` with the viewer's `b33_ctx` | `{ kind: 'unknown' }`; no wallet gives `{ kind: 'none' }` |
24
32
 
25
33
  The package returns no words. Labels, date formats and the mailto subject are your app's, in its language. App order is Identity's, as returned; nothing here hardcodes a product list.
26
34
 
27
35
  ## The session gate: `@boost33/shell-data/session`
28
36
 
37
+ > [!warning] Pick the matcher for how your pages trust the session
38
+ > **Your pages verify `b33_ctx` themselves** (every page runs its own `jwtVerify`, and your proxy sets no request header a page trusts; the Hub is one). Use `gateRequest` behind `SESSION_GATE_MATCHER`.
39
+ >
40
+ > **Your proxy hands claims to the page in a request header** (Results' `x-results-claims`). Use `gate()` behind `CLAIMS_PROXY_MATCHER`, and call it only when `isNavigation(request)` is true. Delete the claims header from every incoming request first.
41
+ >
42
+ > **Why the second kind cannot use `SESSION_GATE_MATCHER`.** Its prefetch exclusions read headers the client sets. A client can send an ordinary page request marked as a prefetch. That request skips your proxy, and the page then trusts a claims header the client wrote. `isPrefetch` and `isNavigation` decide only whether to spend a refresh, never whether your proxy runs.
43
+
44
+
29
45
  Refreshes an expired `b33_ctx` before the page renders, exactly as boost33-identity's contract §5.1 requires. It is lifted from Passport's production gate (B33-1751). Without it, a person on the Backdrop preview flips back to the classic design whenever their ten-minute `b33_ctx` runs out.
30
46
 
31
47
  ```ts
@@ -51,3 +67,15 @@ export const config = { matcher: [ /* … */ ] }
51
67
  - **One-bounce guard (§5.1.7)**: if your page redirects to Identity when it finds no claims, pass `markBounce(returnUrl)` as the return URL. On arrival, send `isRepeatBounce(url)` to a terminal page instead of back to Identity.
52
68
 
53
69
  `next` and `jose` are optional peer dependencies, needed only for this entry.
70
+
71
+ ### When your proxy does more than refresh
72
+
73
+ If your proxy also verifies `b33_ctx` and hands claims to the page, use `gate(request, options)`. It returns a decision rather than a response; see `GateResult`.
74
+
75
+ - `refreshed` gives you `freshCtx` (already verified), the `setCookies` to forward verbatim, and the `cookieHeader` to render this request with.
76
+ - `dead` gives you a `redirect` to return as is.
77
+
78
+ Use it behind `CLAIMS_PROXY_MATCHER`, which runs your proxy on every request except Next's static assets, and call `gate` only when `isNavigation(request)` is true. **Delete your claims header from the incoming request first, on every path**, and set it only from claims your proxy verified (a live `b33_ctx` you verified, or `freshCtx`).
79
+
80
+ `client` is your slug in Identity's `APPS` (`src/config/apps.ts` in boost33-identity), not your product slug.
81
+
package/dist/index.d.ts CHANGED
@@ -17,6 +17,7 @@ export type GetBackdropChromeDataDeps = {
17
17
  fetch?: typeof fetch;
18
18
  tokenSplit?: TokenSplitReader;
19
19
  };
20
+ export type { TokenSplitReader } from './tokens.js';
20
21
  /**
21
22
  * Everything the Backdrop chrome draws, from one call (B33-1726).
22
23
  *
@@ -28,9 +29,16 @@ export type GetBackdropChromeDataDeps = {
28
29
  *
29
30
  * - Identity's products unreachable: the last good list (`stale: true`), or
30
31
  * else null, which draws the rail's global items and no apps.
31
- * - Identity's profile unreachable: null, so the `name` claim stays.
32
+ * - Identity's profile unreachable, or no `identityKey`: null, so the `name` claim stays.
32
33
  * - The ledger unreachable or unclear: tokens `{ kind: 'unknown' }`.
33
34
  *
35
+ * Two credential modes, chosen by `config`. An app with service keys reads the
36
+ * profile with `identityKey` and the tokens with `ledger.key`. An app without
37
+ * them (one not in Identity's `APPS`) reads everything as the viewer, with the
38
+ * cookies it was given: the product list, and the tokens through
39
+ * `tokenSplitForViewer`; the profile read is skipped. Least privilege, and no
40
+ * new secret.
41
+ *
34
42
  * Server only: it reads service keys and must never reach a browser bundle.
35
43
  * It reads no secret of its own; every key comes in `config`, from the app's
36
44
  * server environment.
package/dist/index.js CHANGED
@@ -15,9 +15,16 @@ import { ledgerReader, readTokens } from './tokens.js';
15
15
  *
16
16
  * - Identity's products unreachable: the last good list (`stale: true`), or
17
17
  * else null, which draws the rail's global items and no apps.
18
- * - Identity's profile unreachable: null, so the `name` claim stays.
18
+ * - Identity's profile unreachable, or no `identityKey`: null, so the `name` claim stays.
19
19
  * - The ledger unreachable or unclear: tokens `{ kind: 'unknown' }`.
20
20
  *
21
+ * Two credential modes, chosen by `config`. An app with service keys reads the
22
+ * profile with `identityKey` and the tokens with `ledger.key`. An app without
23
+ * them (one not in Identity's `APPS`) reads everything as the viewer, with the
24
+ * cookies it was given: the product list, and the tokens through
25
+ * `tokenSplitForViewer`; the profile read is skipped. Least privilege, and no
26
+ * new secret.
27
+ *
21
28
  * Server only: it reads service keys and must never reach a browser bundle.
22
29
  * It reads no secret of its own; every key comes in `config`, from the app's
23
30
  * server environment.
@@ -28,7 +35,7 @@ export function getBackdropChromeData(input, deps = {}) {
28
35
  person: personFrom(input.claims),
29
36
  profileName: readProfileName({ sid: input.cookies.sid, config: input.config }, fetchImpl),
30
37
  products: readProducts(input, fetchImpl),
31
- tokens: readTokens(input.claims, deps.tokenSplit ?? ledgerReader(input.config)),
38
+ tokens: readTokens(input.claims, input.cookies.ctx, deps.tokenSplit ?? ledgerReader(input.config)),
32
39
  links: linksFrom(input.config),
33
40
  };
34
41
  }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AACpB,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAyB,MAAM,aAAa,CAAA;AA4B7E;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,qBAAqB,CACnC,KAAiC,EACjC,OAAkC,EAAE;IAEpC,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,IAAI,KAAK,CAAA;IACrC,OAAO;QACL,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC;QAChC,WAAW,EAAE,eAAe,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE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CAAC,MAAM,CAAC;KAC/B,CAAA;AACH,CAAC"}
package/dist/profile.js CHANGED
@@ -5,11 +5,15 @@ import { READ_TIMEOUT_MS } from './products.js';
5
5
  * which tells the chrome to keep the `name` claim.
6
6
  */
7
7
  export async function readProfileName(input, fetchImpl) {
8
+ // Viewer-only mode: no service key, so no profile read. The name claim stands.
9
+ const { identityKey, appId } = input.config;
10
+ if (!identityKey || !appId)
11
+ return null;
8
12
  try {
9
13
  const res = await fetchImpl(`${input.config.identityUrl.replace(/\/+$/, '')}/api/v1/profile`, {
10
14
  headers: {
11
- authorization: `Bearer ${input.config.identityKey}`,
12
- 'x-boost33-app': input.config.appId,
15
+ authorization: `Bearer ${identityKey}`,
16
+ 'x-boost33-app': appId,
13
17
  'x-boost33-actor-session': input.sid,
14
18
  },
15
19
  cache: 'no-store',
@@ -1 +1 @@
1
- {"version":3,"file":"profile.js","sourceRoot":"","sources":["../src/profile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAG/C;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,KAA4C,EAC5C,SAAuB;IAEvB,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,iBAAiB,EAAE;YAC5F,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE;gBACnD,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK;gBACnC,yBAAyB,EAAE,KAAK,CAAC,GAAG;aACrC;YACD,KAAK,EAAE,UAAU;YACjB,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,eAAe,CAAC;SAC7C,CAAC,CAAA;QACF,IAAI,CAAC,GAAG,CAAC,EAAE;YAAE,OAAO,IAAI,CAAA;QACxB,MAAM,IAAI,GAAG,CAAC,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,EAAE,CAAC,IAAI,CAAC,CAAkD,CAAA;QAClG,MAAM,IAAI,GAAG,IAAI,EAAE,MAAM,EAAE,WAAW,CAAA;QACtC,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAA;IACrE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC"}
package/dist/session.d.ts CHANGED
@@ -65,7 +65,12 @@ export declare function cookiePair(setCookie: string): {
65
65
  } | null;
66
66
  export type GateOptions = {
67
67
  identityUrl: string;
68
- /** This app's slug in identity's `APPS`, sent as `x-boost33-client` (§5.1.6). */
68
+ /**
69
+ * This caller's slug in identity's `APPS` (boost33-identity src/config/apps.ts),
70
+ * sent as `x-boost33-client` (§5.1.6). These are identity's caller slugs, not
71
+ * product slugs: `outbound`, `passport`, `hub`, `boostscore`. A value not in
72
+ * that list still works; identity logs it as `unrecognised`.
73
+ */
69
74
  client: string;
70
75
  /**
71
76
  * The app's own full verify of a `b33_ctx` (its `jwtVerify` against identity's
@@ -76,9 +81,50 @@ export type GateOptions = {
76
81
  /** For tests: replaces the call to identity. */
77
82
  refresh?: (cookieHeader: string) => Promise<RefreshOutcome>;
78
83
  };
84
+ /**
85
+ * What the gate decided for one request, for an app that runs its own proxy
86
+ * logic around it (for instance, verifying `b33_ctx` and handing claims to the
87
+ * page in a header) and so cannot return `gateRequest`'s response as is.
88
+ *
89
+ * - `none`: no `b33_sid`. Nothing to refresh from; the page decides.
90
+ * - `live`: `b33_ctx` is not within 30s of `exp`, by an UNVERIFIED decode. This
91
+ * says nothing about whether it is genuine: verify it yourself, as always.
92
+ * - `refreshed`: identity re-issued the session and the new `b33_ctx` VERIFIED
93
+ * with your verifier. Forward `setCookies` verbatim on your response (§5.1.3),
94
+ * and render this request with `cookieHeader` (§5.1.2); `freshCtx` is the new
95
+ * token, already verified, for an app that reads its claims here.
96
+ * - `dead`: identity answered 401. Return `redirect`: both cookies cleared, and
97
+ * on to sign in with a `return` here (§5.1.7). Do not retry.
98
+ * - `unwell`: identity timed out, failed or rate-limited, or re-issued a token
99
+ * that does not verify. Change nothing and forward nothing; the request goes
100
+ * on with its expired `b33_ctx`, which your verify will then reject.
101
+ */
102
+ export type GateResult = {
103
+ outcome: 'none';
104
+ } | {
105
+ outcome: 'live';
106
+ } | {
107
+ outcome: 'refreshed';
108
+ freshCtx: string;
109
+ setCookies: string[];
110
+ cookieHeader: string;
111
+ } | {
112
+ outcome: 'dead';
113
+ redirect: Response;
114
+ } | {
115
+ outcome: 'unwell';
116
+ };
117
+ /**
118
+ * The gate's decision without building a response: §5.1 in full (one refresh,
119
+ * 1.5s, exp - 30s, `x-boost33-client`, 401 versus unwell, the re-issued token
120
+ * verified before anything is forwarded). `gateRequest` is this, turned into
121
+ * the response a plain proxy returns. Takes any `Request`.
122
+ */
123
+ export declare function gate(request: Request, options: GateOptions): Promise<GateResult>;
79
124
  /**
80
125
  * The request gate: step 2 of identity's contract §5, with §5.1's server-side
81
- * refresh. Run it on navigations only (SESSION_GATE_MATCHER).
126
+ * refresh, as the response a proxy returns. Run it on navigations only
127
+ * (SESSION_GATE_MATCHER, or `isNavigation` in code behind a broad matcher).
82
128
  *
83
129
  * `b33_sid` present, `b33_ctx` absent or past `exp - 30s`
84
130
  * → POST identity's /auth/refresh, relaying `b33_sid` (one call, 1.5s cap)
@@ -102,12 +148,39 @@ export type GateOptions = {
102
148
  * one-bounce guard §5.1.7 asks for: see `markBounce` and `isRepeatBounce`.
103
149
  */
104
150
  export declare function gateRequest(request: NextRequest, options: GateOptions): Promise<NextResponse>;
151
+ /**
152
+ * Whether this request is a navigation the gate should run on, decided in code
153
+ * the way SESSION_GATE_MATCHER decides it in config: a document request that
154
+ * accepts HTML, or an in-app navigation (`rsc: 1`); never a prefetch; never
155
+ * Next's own assets, `api/`, or a file with an extension. For an app whose
156
+ * proxy must run on every request for other reasons and so cannot narrow its
157
+ * matcher.
158
+ */
159
+ export declare function isNavigation(request: Request): boolean;
160
+ /**
161
+ * Whether the request says it is a prefetch: Next's router (`next-router-prefetch`),
162
+ * or a browser's speculative load (`purpose: prefetch`, `sec-purpose: prefetch`).
163
+ *
164
+ * THESE HEADERS ARE SET BY THE CLIENT. Use this only to decide whether to SPEND a
165
+ * refresh, never to decide whether to run your proxy at all. In an app whose
166
+ * pages trust a header the proxy sets, the proxy must run on every request
167
+ * (CLAIMS_PROXY_MATCHER) and call this to skip the refresh alone.
168
+ */
169
+ export declare function isPrefetch(request: Request): boolean;
105
170
  export declare const BOUNCE_PARAM = "b33_bounced";
106
171
  /** The return URL with the bounce mark added. Pass it as identity's `return`. */
107
172
  export declare function markBounce(returnTo: string | URL): string;
108
173
  /** Whether this arrival is already the bounce back from identity. */
109
174
  export declare function isRepeatBounce(url: string | URL): boolean;
110
175
  /**
176
+ * FOR APPS WHOSE PAGES VERIFY `b33_ctx` THEMSELVES, and only those. The Hub is
177
+ * one: every page runs its own `jwtVerify`, and the proxy sets no request
178
+ * header a page trusts. If your proxy hands claims to the page in a request
179
+ * header, use CLAIMS_PROXY_MATCHER instead. This matcher's prefetch exclusions
180
+ * read headers the CLIENT sets, so a document request marked as a prefetch
181
+ * skips your proxy entirely, and a page that trusts a proxy-set header would
182
+ * then trust whatever the client sent.
183
+ *
111
184
  * The matcher the gate must run behind (§5.1.1): navigations only, meaning a
112
185
  * document request that accepts HTML, or an in-app navigation, which Next sends
113
186
  * as an RSC fetch marked `rsc: 1`. Never a prefetch, so hovering links cannot
@@ -149,10 +222,31 @@ export declare const SESSION_GATE_MATCHER: readonly [{
149
222
  readonly value: "prefetch";
150
223
  }];
151
224
  }];
225
+ /**
226
+ * The matcher for an app whose proxy hands claims to its pages in a request
227
+ * header (Results, `x-results-claims`). It runs the proxy on EVERY request but
228
+ * Next's own static assets, with no `has`/`missing` conditions, because any
229
+ * condition on a client-set header is a way around the proxy. In code:
230
+ *
231
+ * headers.delete('x-<app>-claims') // always, first
232
+ * if (isNavigation(request)) result = await gate(request, options)
233
+ * // set the claims header only from claims your proxy verified
234
+ *
235
+ * `isNavigation` (and so `isPrefetch`) only decides whether to spend a refresh.
236
+ * A request that lies about being a prefetch skips the refresh, never the proxy.
237
+ *
238
+ * Copy it into `export const config` AS A LITERAL, as with SESSION_GATE_MATCHER.
239
+ */
240
+ export declare const CLAIMS_PROXY_MATCHER: readonly ["/((?!_next/static|_next/image).*)"];
152
241
  /**
153
242
  * For an app's tests: whether its literal matcher copy is SESSION_GATE_MATCHER,
154
243
  * or narrows only its paths (Outbound scopes it to its Backdrop routes). A
155
244
  * matcher that drops the prefetch exclusion or the `_next/`/`api/` exclusions
156
245
  * fails.
246
+ *
247
+ * Passing says the matcher spends no refresh on a prefetch. It does NOT say the
248
+ * app is safe: this matcher is only safe where pages verify `b33_ctx`
249
+ * themselves. An app that passes claims in a request header must use
250
+ * CLAIMS_PROXY_MATCHER, and this check does not apply to it.
157
251
  */
158
252
  export declare function matcherIsNavigationOnly(matcher: unknown): boolean;
package/dist/session.js CHANGED
@@ -111,9 +111,67 @@ export function cookiePair(setCookie) {
111
111
  return null;
112
112
  return { name: pair.slice(0, eq).trim(), value: pair.slice(eq + 1).trim() };
113
113
  }
114
+ /** The cookies on a request's Cookie header, by name. Works on any `Request`. */
115
+ function cookiesOf(request) {
116
+ const jar = new Map();
117
+ for (const part of (request.headers.get('cookie') ?? '').split(';')) {
118
+ const eq = part.indexOf('=');
119
+ if (eq <= 0)
120
+ continue;
121
+ const name = part.slice(0, eq).trim();
122
+ if (name && !jar.has(name))
123
+ jar.set(name, part.slice(eq + 1).trim());
124
+ }
125
+ return jar;
126
+ }
127
+ /**
128
+ * The gate's decision without building a response: §5.1 in full (one refresh,
129
+ * 1.5s, exp - 30s, `x-boost33-client`, 401 versus unwell, the re-issued token
130
+ * verified before anything is forwarded). `gateRequest` is this, turned into
131
+ * the response a plain proxy returns. Takes any `Request`.
132
+ */
133
+ export async function gate(request, options) {
134
+ const jar = cookiesOf(request);
135
+ if (!jar.get(SID_COOKIE))
136
+ return { outcome: 'none' };
137
+ if (!ctxLooksExpired(jar.get(CTX_COOKIE)))
138
+ return { outcome: 'live' };
139
+ const refresh = options.refresh ??
140
+ ((cookieHeader) => refreshSession({ identityUrl: options.identityUrl, cookieHeader, client: options.client }));
141
+ const outcome = await refresh(request.headers.get('cookie') ?? '');
142
+ if (outcome.kind === 'dead') {
143
+ // §5.1.7: no retry; identity would only bounce them back.
144
+ const signin = new URL(`${options.identityUrl.replace(/\/+$/, '')}/signin`);
145
+ signin.searchParams.set('return', returnUrl(request));
146
+ const headers = new Headers({ location: signin.toString() });
147
+ for (const name of [SID_COOKIE, CTX_COOKIE])
148
+ headers.append('set-cookie', expiredCookie(name, request));
149
+ return { outcome: 'dead', redirect: new Response(null, { status: 307, headers }) };
150
+ }
151
+ if (outcome.kind === 'unwell')
152
+ return { outcome: 'unwell' };
153
+ // The re-issued token is verified here, not only by the page, so a refresh
154
+ // whose token would not verify (wrong key, keys unreachable) changes nothing:
155
+ // no cookie is forwarded, and the page takes the path it took before.
156
+ for (const raw of outcome.setCookies) {
157
+ const pair = cookiePair(raw);
158
+ if (pair)
159
+ jar.set(pair.name, pair.value);
160
+ }
161
+ const fresh = jar.get(CTX_COOKIE);
162
+ if (!fresh || !(await options.verify(fresh).catch(() => false)))
163
+ return { outcome: 'unwell' };
164
+ return {
165
+ outcome: 'refreshed',
166
+ freshCtx: fresh,
167
+ setCookies: outcome.setCookies,
168
+ cookieHeader: [...jar].map(([name, value]) => `${name}=${value}`).join('; '),
169
+ };
170
+ }
114
171
  /**
115
172
  * The request gate: step 2 of identity's contract §5, with §5.1's server-side
116
- * refresh. Run it on navigations only (SESSION_GATE_MATCHER).
173
+ * refresh, as the response a proxy returns. Run it on navigations only
174
+ * (SESSION_GATE_MATCHER, or `isNavigation` in code behind a broad matcher).
117
175
  *
118
176
  * `b33_sid` present, `b33_ctx` absent or past `exp - 30s`
119
177
  * → POST identity's /auth/refresh, relaying `b33_sid` (one call, 1.5s cap)
@@ -137,53 +195,66 @@ export function cookiePair(setCookie) {
137
195
  * one-bounce guard §5.1.7 asks for: see `markBounce` and `isRepeatBounce`.
138
196
  */
139
197
  export async function gateRequest(request, options) {
140
- if (!request.cookies.get(SID_COOKIE)?.value)
141
- return NextResponse.next();
142
- if (!ctxLooksExpired(request.cookies.get(CTX_COOKIE)?.value))
143
- return NextResponse.next();
144
- const refresh = options.refresh ??
145
- ((cookieHeader) => refreshSession({ identityUrl: options.identityUrl, cookieHeader, client: options.client }));
146
- const outcome = await refresh(request.headers.get('cookie') ?? '');
147
- if (outcome.kind === 'dead') {
148
- // §5.1.7: no retry; identity would only bounce them back.
149
- const signin = new URL(`${options.identityUrl.replace(/\/+$/, '')}/signin`);
150
- signin.searchParams.set('return', returnUrl(request));
151
- const response = NextResponse.redirect(signin);
152
- for (const name of [SID_COOKIE, CTX_COOKIE])
153
- response.headers.append('set-cookie', expiredCookie(name, request));
198
+ const result = await gate(request, options);
199
+ if (result.outcome === 'dead') {
200
+ const response = NextResponse.redirect(result.redirect.headers.get('location'));
201
+ for (const raw of result.redirect.headers.getSetCookie())
202
+ response.headers.append('set-cookie', raw);
154
203
  return response;
155
204
  }
156
- if (outcome.kind === 'unwell')
157
- return NextResponse.next();
158
- // The re-issued token is verified here, not only by the page, so a refresh
159
- // whose token would not verify (wrong key, keys unreachable) changes nothing:
160
- // no cookie is forwarded, and the page takes the path it took before.
161
- const jar = new Map(request.cookies.getAll().map((c) => [c.name, c.value]));
162
- for (const raw of outcome.setCookies) {
163
- const pair = cookiePair(raw);
164
- if (pair)
165
- jar.set(pair.name, pair.value);
166
- }
167
- const fresh = jar.get(CTX_COOKIE);
168
- if (!fresh || !(await options.verify(fresh).catch(() => false)))
205
+ if (result.outcome !== 'refreshed')
169
206
  return NextResponse.next();
170
207
  const headers = new Headers(request.headers);
171
- headers.set('cookie', [...jar].map(([name, value]) => `${name}=${value}`).join('; '));
208
+ headers.set('cookie', result.cookieHeader);
172
209
  const response = NextResponse.next({ request: { headers } });
173
210
  // §5.1.3: verbatim, never rebuilt. Both cookies: `b33_sid` slides forward too.
174
- for (const raw of outcome.setCookies)
211
+ for (const raw of result.setCookies)
175
212
  response.headers.append('set-cookie', raw);
176
213
  return response;
177
214
  }
215
+ /**
216
+ * Whether this request is a navigation the gate should run on, decided in code
217
+ * the way SESSION_GATE_MATCHER decides it in config: a document request that
218
+ * accepts HTML, or an in-app navigation (`rsc: 1`); never a prefetch; never
219
+ * Next's own assets, `api/`, or a file with an extension. For an app whose
220
+ * proxy must run on every request for other reasons and so cannot narrow its
221
+ * matcher.
222
+ */
223
+ export function isNavigation(request) {
224
+ const { pathname } = new URL(request.url);
225
+ if (pathname.startsWith('/_next/') || pathname.startsWith('/api/'))
226
+ return false;
227
+ if (/\.[^/]*$/.test(pathname))
228
+ return false;
229
+ if (isPrefetch(request))
230
+ return false;
231
+ const h = request.headers;
232
+ return (h.get('accept') ?? '').includes('text/html') || h.get('rsc') === '1';
233
+ }
234
+ /**
235
+ * Whether the request says it is a prefetch: Next's router (`next-router-prefetch`),
236
+ * or a browser's speculative load (`purpose: prefetch`, `sec-purpose: prefetch`).
237
+ *
238
+ * THESE HEADERS ARE SET BY THE CLIENT. Use this only to decide whether to SPEND a
239
+ * refresh, never to decide whether to run your proxy at all. In an app whose
240
+ * pages trust a header the proxy sets, the proxy must run on every request
241
+ * (CLAIMS_PROXY_MATCHER) and call this to skip the refresh alone.
242
+ */
243
+ export function isPrefetch(request) {
244
+ const h = request.headers;
245
+ return (h.has('next-router-prefetch') ||
246
+ h.get('purpose') === 'prefetch' ||
247
+ (h.get('sec-purpose') ?? '').split(';')[0]?.trim() === 'prefetch');
248
+ }
178
249
  /**
179
250
  * Where identity sends them back to after sign-in: the forwarded host first, so
180
251
  * it is the address the person used rather than the one the platform routed to.
181
252
  */
182
253
  function returnUrl(request) {
183
- const { pathname, search } = request.nextUrl;
254
+ const { pathname, search, origin } = new URL(request.url);
184
255
  const host = request.headers.get('x-forwarded-host') ?? request.headers.get('host');
185
256
  if (!host)
186
- return `${request.nextUrl.origin}${pathname}${search}`;
257
+ return `${origin}${pathname}${search}`;
187
258
  const local = host.startsWith('localhost') || host.startsWith('127.0.0.1');
188
259
  const proto = request.headers.get('x-forwarded-proto') ?? (local ? 'http' : 'https');
189
260
  return `${proto}://${host}${pathname}${search}`;
@@ -194,10 +265,11 @@ function returnUrl(request) {
194
265
  * when this host is under it, so local development still clears.
195
266
  */
196
267
  function expiredCookie(name, request) {
197
- const host = (request.headers.get('x-forwarded-host') ?? request.nextUrl.hostname).split(':')[0] ?? '';
268
+ const url = new URL(request.url);
269
+ const host = (request.headers.get('x-forwarded-host') ?? url.hostname).split(':')[0] ?? '';
198
270
  const shared = host === 'boost33.com' || host.endsWith('.boost33.com');
199
271
  const domain = shared ? '; Domain=.boost33.com' : '';
200
- const secure = shared || request.nextUrl.protocol === 'https:' ? '; Secure' : '';
272
+ const secure = shared || url.protocol === 'https:' ? '; Secure' : '';
201
273
  return `${name}=; Path=/${domain}; Max-Age=0; HttpOnly; SameSite=Lax${secure}`;
202
274
  }
203
275
  /* ── The one-bounce guard (§5.1.7) ─────────────────────────────────────────
@@ -220,6 +292,14 @@ export function isRepeatBounce(url) {
220
292
  return new URL(url).searchParams.get(BOUNCE_PARAM) === '1';
221
293
  }
222
294
  /**
295
+ * FOR APPS WHOSE PAGES VERIFY `b33_ctx` THEMSELVES, and only those. The Hub is
296
+ * one: every page runs its own `jwtVerify`, and the proxy sets no request
297
+ * header a page trusts. If your proxy hands claims to the page in a request
298
+ * header, use CLAIMS_PROXY_MATCHER instead. This matcher's prefetch exclusions
299
+ * read headers the CLIENT sets, so a document request marked as a prefetch
300
+ * skips your proxy entirely, and a page that trusts a proxy-set header would
301
+ * then trust whatever the client sent.
302
+ *
223
303
  * The matcher the gate must run behind (§5.1.1): navigations only, meaning a
224
304
  * document request that accepts HTML, or an in-app navigation, which Next sends
225
305
  * as an RSC fetch marked `rsc: 1`. Never a prefetch, so hovering links cannot
@@ -248,11 +328,32 @@ export const SESSION_GATE_MATCHER = [
248
328
  ],
249
329
  },
250
330
  ];
331
+ /**
332
+ * The matcher for an app whose proxy hands claims to its pages in a request
333
+ * header (Results, `x-results-claims`). It runs the proxy on EVERY request but
334
+ * Next's own static assets, with no `has`/`missing` conditions, because any
335
+ * condition on a client-set header is a way around the proxy. In code:
336
+ *
337
+ * headers.delete('x-<app>-claims') // always, first
338
+ * if (isNavigation(request)) result = await gate(request, options)
339
+ * // set the claims header only from claims your proxy verified
340
+ *
341
+ * `isNavigation` (and so `isPrefetch`) only decides whether to spend a refresh.
342
+ * A request that lies about being a prefetch skips the refresh, never the proxy.
343
+ *
344
+ * Copy it into `export const config` AS A LITERAL, as with SESSION_GATE_MATCHER.
345
+ */
346
+ export const CLAIMS_PROXY_MATCHER = ['/((?!_next/static|_next/image).*)'];
251
347
  /**
252
348
  * For an app's tests: whether its literal matcher copy is SESSION_GATE_MATCHER,
253
349
  * or narrows only its paths (Outbound scopes it to its Backdrop routes). A
254
350
  * matcher that drops the prefetch exclusion or the `_next/`/`api/` exclusions
255
351
  * fails.
352
+ *
353
+ * Passing says the matcher spends no refresh on a prefetch. It does NOT say the
354
+ * app is safe: this matcher is only safe where pages verify `b33_ctx`
355
+ * themselves. An app that passes claims in a request header must use
356
+ * CLAIMS_PROXY_MATCHER, and this check does not apply to it.
256
357
  */
257
358
  export function matcherIsNavigationOnly(matcher) {
258
359
  if (!Array.isArray(matcher) || matcher.length === 0)
@@ -1 +1 @@
1
- {"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,6EAA6E;AAC7E,0EAA0E;AAC1E,uDAAuD;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAA;AAChC,OAAO,EAAE,YAAY,EAAoB,MAAM,gBAAgB,CAAA;AAE/D;;;;;;;;;;;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
- import { type TokenSplitResult } from '@boost33/ledger-client';
1
+ import { type TokenSplitResult, type ViewerTokenSplitResult } from '@boost33/ledger-client';
2
2
  import type { ChromeClaims, ChromeConfig, ChromeTokens } from './types.js';
3
- export type TokenSplitReader = (walletId: string) => Promise<TokenSplitResult>;
4
- /** The real reader: `@boost33/ledger-client`'s `tokenSplit()`, built per call. */
3
+ /** Reads one acting account's split, by its wallet id (keyed) or the viewer's `b33_ctx` (viewer). */
4
+ export type TokenSplitReader = {
5
+ mode: 'keyed';
6
+ read: (walletId: string) => Promise<TokenSplitResult>;
7
+ } | {
8
+ mode: 'viewer';
9
+ read: (ctx: string) => Promise<ViewerTokenSplitResult>;
10
+ };
11
+ /**
12
+ * The ledger client's base URL, which includes `/api/v1`. Accepts the ledger's
13
+ * origin with or without a trailing `/api/v1` and slashes, and never doubles
14
+ * it: some apps' `BOOST33_LEDGER_URL` already ends in `/api/v1` (Outbound,
15
+ * B33-660), and a doubled path made every token read "unknown".
16
+ */
17
+ export declare const apiUrl: (url: string) => string;
18
+ /**
19
+ * The real reader for this config: `tokenSplit()` with the app's ledger key
20
+ * when it has one, else `tokenSplitForViewer()` with the viewer's own token.
21
+ * Built per call: the client holds no connection.
22
+ */
5
23
  export declare function ledgerReader(config: ChromeConfig): TokenSplitReader;
6
24
  /**
7
25
  * The ledger's split in the chip's terms (B33-1726, from the Hub's toTokenChip):
8
26
  * known gives both halves; overdrawn and negative_bucket give the true total
9
- * and no split; unavailable, account_not_found, a throw, or a figure that is
10
- * not a safe integer give unknown. No account or no wallet gives none.
11
- * `nextGrantAt` stays an ISO string: formatting a date is the app's, in its
12
- * language.
27
+ * and no split; unavailable, account_not_found, an expired viewer token, a
28
+ * throw, or a figure that is not a safe integer give unknown. No acting
29
+ * account, or no wallet, gives none. `nextGrantAt` stays an ISO string:
30
+ * formatting a date is the app's, in its language.
31
+ *
32
+ * Viewer mode reads with the viewer's own `b33_ctx`, so a request with none
33
+ * (only `b33_sid` arrived) is unknown: the session gate refreshes it on the
34
+ * next navigation, and nothing here retries.
13
35
  */
14
- export declare function readTokens(claims: ChromeClaims, read: TokenSplitReader): Promise<ChromeTokens>;
36
+ export declare function readTokens(claims: ChromeClaims, ctx: string | null, reader: TokenSplitReader): Promise<ChromeTokens>;
package/dist/tokens.js CHANGED
@@ -1,15 +1,31 @@
1
- import { createLedgerClient } from '@boost33/ledger-client';
1
+ import { createLedgerClient, tokenSplitForViewer, } from '@boost33/ledger-client';
2
2
  import { actingAccount } from './person.js';
3
3
  import { READ_TIMEOUT_MS } from './products.js';
4
- /** The real reader: `@boost33/ledger-client`'s `tokenSplit()`, built per call. */
4
+ /**
5
+ * The ledger client's base URL, which includes `/api/v1`. Accepts the ledger's
6
+ * origin with or without a trailing `/api/v1` and slashes, and never doubles
7
+ * it: some apps' `BOOST33_LEDGER_URL` already ends in `/api/v1` (Outbound,
8
+ * B33-660), and a doubled path made every token read "unknown".
9
+ */
10
+ export const apiUrl = (url) => `${url.replace(/\/+$/, '').replace(/\/api\/v1$/, '')}/api/v1`;
11
+ /**
12
+ * The real reader for this config: `tokenSplit()` with the app's ledger key
13
+ * when it has one, else `tokenSplitForViewer()` with the viewer's own token.
14
+ * Built per call: the client holds no connection.
15
+ */
5
16
  export function ledgerReader(config) {
6
- return (walletId) => createLedgerClient({
7
- // The client's URL includes `/api/v1`; the config holds the origin.
8
- url: `${config.ledger.url.replace(/\/+$/, '')}/api/v1`,
9
- key: config.ledger.key,
10
- app: config.ledger.app,
11
- readTimeoutMs: READ_TIMEOUT_MS,
12
- }).tokenSplit(walletId);
17
+ const ledger = config.ledger;
18
+ if (ledger?.url && ledger.key && ledger.app) {
19
+ const { url, key, app } = ledger;
20
+ return {
21
+ mode: 'keyed',
22
+ read: (walletId) => createLedgerClient({ url: apiUrl(url), key, app, readTimeoutMs: READ_TIMEOUT_MS }).tokenSplit(walletId),
23
+ };
24
+ }
25
+ return {
26
+ mode: 'viewer',
27
+ read: (ctx) => tokenSplitForViewer(ctx, { ...(ledger?.url ? { url: apiUrl(ledger.url) } : {}), timeoutMs: READ_TIMEOUT_MS }),
28
+ };
13
29
  }
14
30
  /** An integer string the chip can draw exactly, or null. */
15
31
  function figure(value) {
@@ -19,18 +35,34 @@ function figure(value) {
19
35
  /**
20
36
  * The ledger's split in the chip's terms (B33-1726, from the Hub's toTokenChip):
21
37
  * known gives both halves; overdrawn and negative_bucket give the true total
22
- * and no split; unavailable, account_not_found, a throw, or a figure that is
23
- * not a safe integer give unknown. No account or no wallet gives none.
24
- * `nextGrantAt` stays an ISO string: formatting a date is the app's, in its
25
- * language.
38
+ * and no split; unavailable, account_not_found, an expired viewer token, a
39
+ * throw, or a figure that is not a safe integer give unknown. No acting
40
+ * account, or no wallet, gives none. `nextGrantAt` stays an ISO string:
41
+ * formatting a date is the app's, in its language.
42
+ *
43
+ * Viewer mode reads with the viewer's own `b33_ctx`, so a request with none
44
+ * (only `b33_sid` arrived) is unknown: the session gate refreshes it on the
45
+ * next navigation, and nothing here retries.
26
46
  */
27
- export async function readTokens(claims, read) {
28
- const walletId = actingAccount(claims)?.walletId;
29
- if (!walletId)
47
+ export async function readTokens(claims, ctx, reader) {
48
+ const account = actingAccount(claims);
49
+ if (!account)
50
+ return { kind: 'none' };
51
+ // The claims say this account has no wallet: no chip, and no call, in either mode.
52
+ if (account.walletId === null)
30
53
  return { kind: 'none' };
31
54
  let result;
32
55
  try {
33
- result = await read(walletId);
56
+ if (reader.mode === 'keyed') {
57
+ if (!account.walletId)
58
+ return { kind: 'none' };
59
+ result = await reader.read(account.walletId);
60
+ }
61
+ else {
62
+ if (!ctx)
63
+ return { kind: 'unknown' };
64
+ result = await reader.read(ctx);
65
+ }
34
66
  }
35
67
  catch {
36
68
  return { kind: 'unknown' };
@@ -39,7 +71,7 @@ export async function readTokens(claims, read) {
39
71
  return { kind: 'unknown' };
40
72
  const { split } = result;
41
73
  if (split.kind === 'unavailable')
42
- return { kind: 'unknown' };
74
+ return split.reason === 'no_wallet' ? { kind: 'none' } : { kind: 'unknown' };
43
75
  const granted = figure(split.granted);
44
76
  const purchased = figure(split.purchased);
45
77
  if (granted === null || purchased === null || !Number.isSafeInteger(granted + purchased))
@@ -1 +1 @@
1
- {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAyB,MAAM,wBAAwB,CAAA;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAK/C,kFAAkF;AAClF,MAAM,UAAU,YAAY,CAAC,MAAoB;IAC/C,OAAO,CAAC,QAAQ,EAAE,EAAE,CAClB,kBAAkB,CAAC;QACjB,oEAAoE;QACpE,GAAG,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,SAAS;QACtD,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG;QACtB,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG;QACtB,aAAa,EAAE,eAAe;KAC/B,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;AAC3B,CAAC;AAED,4DAA4D;AAC5D,SAAS,MAAM,CAAC,KAAa;IAC3B,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;IACvB,OAAO,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AAC3C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,MAAoB,EAAE,IAAsB;IAC3E,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAA;IAChD,IAAI,CAAC,QAAQ;QAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;IACtC,IAAI,MAAwB,CAAA;IAC5B,IAAI,CAAC;Q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,EAAE,KAAK,KAAK,IAAI,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;QACzD,WAAW,EAAE,IAAI;KAClB,CAAA;AACH,CAAC"}
package/dist/types.d.ts CHANGED
@@ -28,15 +28,32 @@ export type ChromeConfig = {
28
28
  docsUrl?: string;
29
29
  /** Defaults to `support@boost33.com`. */
30
30
  supportEmail?: string;
31
- /** This app's Identity service key, for the profile read. Server env only. */
32
- identityKey: string;
33
- /** This app's slug as Identity knows it, sent as `x-boost33-app`. */
34
- appId: string;
35
- ledger: {
36
- /** The ledger's origin. `/api/v1` is appended here. */
37
- url: string;
38
- key: string;
39
- app: string;
31
+ /**
32
+ * This app's Identity service key, for the profile read. Server env only.
33
+ * Optional: an app with no key (one not in Identity's `APPS`) reads as the
34
+ * viewer only, so `profileName` resolves null and the `name` claim stands.
35
+ * The product list is always read as the viewer and needs no key.
36
+ */
37
+ identityKey?: string;
38
+ /**
39
+ * This app's slug in Identity's `APPS` (boost33-identity src/config/apps.ts),
40
+ * sent as `x-boost33-app` with `identityKey`. Identity's caller slug, NOT the
41
+ * product slug: Outbound is `outbound`, not `boostoutbound`. Identity checks
42
+ * it against the key, so a product slug here fails the profile read.
43
+ */
44
+ appId?: string;
45
+ /**
46
+ * The ledger. With `key` and `app`, the token split is read with this app's
47
+ * ledger key (`tokenSplit`). Without them, or without `ledger` at all, it is
48
+ * read as the viewer with their own `b33_ctx` (`tokenSplitForViewer`): no key,
49
+ * read-only, the wallet taken from the token's acting account. With no `url`
50
+ * the ledger client falls back to `BOOST33_LEDGER_URL`.
51
+ */
52
+ ledger?: {
53
+ /** The ledger's origin. A trailing `/api/v1` is accepted and never doubled. */
54
+ url?: string;
55
+ key?: string;
56
+ app?: string;
40
57
  };
41
58
  };
42
59
  export type ChromePerson = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boost33/shell-data",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Server-only reads that hand the Backdrop chrome in @boost33/ui exactly the data it draws.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -26,7 +26,7 @@
26
26
  }
27
27
  },
28
28
  "scripts": {
29
- "typecheck": "tsc --noEmit",
29
+ "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.drift.json",
30
30
  "test": "vitest run",
31
31
  "build": "rm -rf dist && tsc -p tsconfig.build.json",
32
32
  "prepublishOnly": "npm run typecheck && npm run test && npm run build"
@@ -48,7 +48,9 @@
48
48
  }
49
49
  },
50
50
  "devDependencies": {
51
+ "@boost33/ui": "0.11.0",
51
52
  "@types/node": "^24.0.0",
53
+ "@types/react": "19.3.0",
52
54
  "jose": "^6.2.17",
53
55
  "next": "^16.4.6",
54
56
  "react": "^19.3.1",