@boost33/shell-data 0.1.0 → 0.2.0
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 +76 -0
- package/README.md +31 -3
- package/dist/contract.d.ts +64 -0
- package/dist/contract.js +49 -0
- package/dist/contract.js.map +1 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.js +18 -4
- package/dist/index.js.map +1 -1
- package/dist/links.js +1 -0
- package/dist/links.js.map +1 -1
- package/dist/products.d.ts +61 -0
- package/dist/products.js +121 -11
- package/dist/products.js.map +1 -1
- package/dist/profile.js +6 -2
- package/dist/profile.js.map +1 -1
- package/dist/session.d.ts +96 -2
- package/dist/session.js +135 -34
- package/dist/session.js.map +1 -1
- package/dist/tokens.d.ts +30 -8
- package/dist/tokens.js +50 -18
- package/dist/tokens.js.map +1 -1
- package/dist/types.d.ts +54 -12
- package/package.json +8 -2
package/dist/products.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"products.js","sourceRoot":"","sources":["../src/products.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAGlD,MAAM,WAAW,GAAG,QAAQ,CAAA;AAC5B,MAAM,MAAM,GAAG,CAAC,CAAA;AAChB,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAA;AAIpC
|
|
1
|
+
{"version":3,"file":"products.js","sourceRoot":"","sources":["../src/products.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAGlD,MAAM,WAAW,GAAG,QAAQ,CAAA;AAC5B,MAAM,MAAM,GAAG,CAAC,CAAA;AAChB,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAA;AAIpC;;;;;;;;;;;;;;;G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,CAAC,MAAM,EAAE,CAAC;YACrD,KAAK,EAAE,UAAU;YACjB,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,eAAe,CAAC;SAC7C,CAAC,CAAA;QACF,OAAO,GAAG,CAAC,EAAE,CAAA;IACf,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;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 ${
|
|
12
|
-
'x-boost33-app':
|
|
15
|
+
authorization: `Bearer ${identityKey}`,
|
|
16
|
+
'x-boost33-app': appId,
|
|
13
17
|
'x-boost33-actor-session': input.sid,
|
|
14
18
|
},
|
|
15
19
|
cache: 'no-store',
|
package/dist/profile.js.map
CHANGED
|
@@ -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,EA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 +65,12 @@ export declare function cookiePair(setCookie: string): {
|
|
|
65
65
|
} | null;
|
|
66
66
|
export type GateOptions = {
|
|
67
67
|
identityUrl: string;
|
|
68
|
-
/**
|
|
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
|
|
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
|
|
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
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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
|
|
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',
|
|
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
|
|
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.
|
|
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 `${
|
|
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
|
|
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 ||
|
|
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)
|
package/dist/session.js.map
CHANGED
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAA;AACnC,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAA;AAEnC,iFAAiF;AACjF,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAA;AAExC,0DAA0D;AAC1D,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAA;AAEvC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,eAAe,CAAC,MAA0B,EAAE,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI;IACxF,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAA;IACxB,IAAI,CAAC;QACH,MAAM,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC,MAAM,CAAC,CAAA;QACjC,IAAI,OAAO,GAAG,KAAK,QAAQ;YAAE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AAC,OAAO,CAAC,CAAA;QAC1C,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YAAE,OAAO,KAAK,CAAA;QACpF,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAA;QAC3B,MAAM,UAAU,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;QAClF,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;QAC1E,OAAO,UAAU,IAAI,UAAU,CAAA;IACjC,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/tokens.d.ts
CHANGED
|
@@ -1,14 +1,36 @@
|
|
|
1
|
-
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
|
-
|
|
4
|
-
|
|
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,
|
|
10
|
-
* not a safe integer give unknown. No
|
|
11
|
-
* `nextGrantAt` stays an ISO string:
|
|
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,
|
|
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
|
-
/**
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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,
|
|
23
|
-
* not a safe integer give unknown. No
|
|
24
|
-
* `nextGrantAt` stays an ISO string:
|
|
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,
|
|
28
|
-
const
|
|
29
|
-
if (!
|
|
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
|
-
|
|
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))
|
package/dist/tokens.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,mBAAmB,GAGpB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAQ/C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,SAAS,CAAA;AAEpG;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,MAAoB;IAC/C,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAA;IAC5B,IAAI,MAAM,EAAE,GAAG,IAAI,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,GAAG,EAAE,CAAC;QAC5C,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,MAAM,CAAA;QAChC,OAAO;YACL,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,kBAAkB,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,aAAa,EAAE,eAAe,EAAE,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC;SAC5H,CAAA;IACH,CAAC;IACD,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,CAAC,GAAG,EAAE,EAAE,CACZ,mBA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