@flytedesk/app-kit 6.0.0 → 7.1.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.
Files changed (45) hide show
  1. package/README.md +192 -41
  2. package/dist/auth/client/authSession.d.ts +168 -0
  3. package/dist/auth/client/authSession.js +581 -0
  4. package/dist/auth/client/authSession.js.map +1 -0
  5. package/dist/auth/client/browserEnvironment.d.ts +22 -0
  6. package/dist/auth/client/browserEnvironment.js +87 -0
  7. package/dist/auth/client/browserEnvironment.js.map +1 -0
  8. package/dist/auth/client/httpClient.d.ts +32 -28
  9. package/dist/auth/client/httpClient.js +91 -84
  10. package/dist/auth/client/httpClient.js.map +1 -1
  11. package/dist/auth/client/index.d.ts +15 -8
  12. package/dist/auth/client/index.js +13 -7
  13. package/dist/auth/client/index.js.map +1 -1
  14. package/dist/auth/client/testing.d.ts +6 -0
  15. package/dist/auth/client/testing.js +20 -0
  16. package/dist/auth/client/testing.js.map +1 -0
  17. package/dist/auth/client/useAuthSession.d.ts +54 -91
  18. package/dist/auth/client/useAuthSession.js +65 -252
  19. package/dist/auth/client/useAuthSession.js.map +1 -1
  20. package/dist/auth/index.d.ts +3 -4
  21. package/dist/auth/index.js +1 -2
  22. package/dist/auth/index.js.map +1 -1
  23. package/dist/auth/oidc-client.d.ts +18 -4
  24. package/dist/auth/oidc-client.js +18 -1
  25. package/dist/auth/oidc-client.js.map +1 -1
  26. package/dist/auth/plugin.js +244 -225
  27. package/dist/auth/plugin.js.map +1 -1
  28. package/dist/auth/returnTarget.d.ts +30 -0
  29. package/dist/auth/returnTarget.js +48 -0
  30. package/dist/auth/returnTarget.js.map +1 -0
  31. package/dist/auth/shared-types.d.ts +18 -41
  32. package/dist/auth/shared-types.js +18 -45
  33. package/dist/auth/shared-types.js.map +1 -1
  34. package/dist/auth/testing/fake-idp.d.ts +29 -1
  35. package/dist/auth/testing/fake-idp.js +142 -31
  36. package/dist/auth/testing/fake-idp.js.map +1 -1
  37. package/dist/auth/types.d.ts +26 -29
  38. package/dist/bigquery/index.d.ts +1 -1
  39. package/dist/bigquery/params.d.ts +6 -0
  40. package/dist/bigquery/params.js +79 -0
  41. package/dist/bigquery/params.js.map +1 -0
  42. package/dist/bigquery/query.js +3 -0
  43. package/dist/bigquery/query.js.map +1 -1
  44. package/dist/bigquery/types.d.ts +37 -4
  45. package/package.json +9 -3
@@ -0,0 +1,87 @@
1
+ /**
2
+ * The real browser behind `./authSession.ts`'s `AuthSessionEnvironment` (AK-35), and the
3
+ * one per-tab `authSession` every app reads. Browser-safe, ZERO Node imports.
4
+ *
5
+ * This package's tsconfig deliberately has no "DOM" lib (it is Node-first — see
6
+ * `./httpClient.ts`'s own `declare const window`), so the few browser globals used here
7
+ * are declared below with exactly the members this file touches. The declarations are
8
+ * erased at compile time and resolve to the real browser objects at runtime.
9
+ */
10
+ import { createAuthSession, SESSION_CHANNEL, } from "./authSession.js";
11
+ function isSessionMessage(data) {
12
+ if (typeof data !== "object" || data === null)
13
+ return false;
14
+ const { type, userId } = data;
15
+ return (type === "signed-out" ||
16
+ (type === "signed-in" && typeof userId === "string"));
17
+ }
18
+ export function browserEnvironment() {
19
+ return {
20
+ href: () => window.location.href,
21
+ navigate: (url) => window.location.assign(url),
22
+ replaceUrl: (url) => window.history.replaceState(null, "", url),
23
+ reload: () => window.location.reload(),
24
+ isVisible: () => document.visibilityState === "visible",
25
+ onAttention(listener) {
26
+ const onVisibility = () => {
27
+ if (document.visibilityState === "visible")
28
+ listener();
29
+ };
30
+ document.addEventListener("visibilitychange", onVisibility);
31
+ window.addEventListener("focus", listener);
32
+ return () => {
33
+ document.removeEventListener("visibilitychange", onVisibility);
34
+ window.removeEventListener("focus", listener);
35
+ };
36
+ },
37
+ onRestore(listener) {
38
+ const onPageShow = (event) => {
39
+ if (event.persisted)
40
+ listener();
41
+ };
42
+ window.addEventListener("pageshow", onPageShow);
43
+ return () => window.removeEventListener("pageshow", onPageShow);
44
+ },
45
+ // Read lazily, per call: merely touching `window.sessionStorage` throws when site data
46
+ // is blocked, which the lifecycle handles per key.
47
+ sessionStorage: () => window.sessionStorage,
48
+ localStorage: () => window.localStorage,
49
+ openChannel(onMessage) {
50
+ const channel = new BroadcastChannel(SESSION_CHANNEL);
51
+ channel.onmessage = (event) => {
52
+ if (isSessionMessage(event.data))
53
+ onMessage(event.data);
54
+ };
55
+ return {
56
+ post: (message) => channel.postMessage(message),
57
+ close: () => channel.close(),
58
+ };
59
+ },
60
+ };
61
+ }
62
+ let instance = null;
63
+ function current() {
64
+ instance ??= createAuthSession(browserEnvironment());
65
+ return instance;
66
+ }
67
+ /**
68
+ * THE session of this tab — one lifecycle, however many components or modules read it.
69
+ * Created on first use (never at import, so importing this module is safe during SSR or
70
+ * in a Node test). React code reads it through `useAuthSession()`; anything else (an
71
+ * API helper, a store outside React) through `authSession.getSnapshot()` and
72
+ * `authSession.subscribe()`.
73
+ */
74
+ export const authSession = {
75
+ getSnapshot: () => current().getSnapshot(),
76
+ subscribe: (listener) => current().subscribe(listener),
77
+ signOut: () => current().signOut(),
78
+ retry: () => current().retry(),
79
+ refreshUser: () => current().refreshUser(),
80
+ };
81
+ /** Test seam (`@flytedesk/app-kit/auth/client/testing`): stops and forgets the tab's
82
+ * lifecycle, so the next use starts a fresh one. */
83
+ export function resetAuthSession() {
84
+ instance?.stop();
85
+ instance = null;
86
+ }
87
+ //# sourceMappingURL=browserEnvironment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browserEnvironment.js","sourceRoot":"","sources":["../../../src/auth/client/browserEnvironment.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EACL,iBAAiB,EACjB,eAAe,GAKhB,MAAM,kBAAkB,CAAC;AA4B1B,SAAS,gBAAgB,CAAC,IAAa;IACrC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC5D,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE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AO,EAAE,CAAC,KAAK,EAAE;IAC9B,WAAW,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,WAAW,EAAE;CAC3C,CAAC;AAEF;qDACqD;AACrD,MAAM,UAAU,gBAAgB;IAC9B,QAAQ,EAAE,IAAI,EAAE,CAAC;IACjB,QAAQ,GAAG,IAAI,CAAC;AAClB,CAAC"}
@@ -43,8 +43,8 @@ export type AuthUnavailableErrorCode = AuthUnavailableCode | typeof AUTH_UNREACH
43
43
  * carrying one of `AUTH_UNAVAILABLE_CODES`) — or the automatic refresh reached no
44
44
  * decision at all (`AUTH_UNREACHABLE_CODE`). Transient, and NOT a sign-out: the session
45
45
  * (its refresh cookie) is intact and the same request can succeed once the dependency
46
- * recovers. This client never runs the auth recovery for it; `useAuthSession` keeps the
47
- * session and retries with backoff (its `"unavailable"` status). A subclass of
46
+ * recovers. It never announces a session end (`onSessionEnded`); `./authSession.ts` keeps
47
+ * the session and retries with backoff (its `"unavailable"` status). A subclass of
48
48
  * ApiRequestError, so existing `instanceof ApiRequestError` handling still sees it.
49
49
  */
50
50
  export declare class AuthUnavailableError extends ApiRequestError {
@@ -58,7 +58,7 @@ type AuthUnavailableListener = (error: AuthUnavailableError) => void;
58
58
  * layer learns that an ordinary request hit an outage, so it can show "reconnecting"
59
59
  * instead of treating the user as signed out. Returns the unsubscribe function. */
60
60
  export declare function onAuthUnavailable(listener: AuthUnavailableListener): () => void;
61
- /** A request that missed its deadline (see withDeadline). */
61
+ /** A request that missed its deadline (see withCancellation). */
62
62
  export declare class RequestDeadlineError extends Error {
63
63
  constructor(what: string, ms: number);
64
64
  }
@@ -70,33 +70,31 @@ export declare function getAccessToken(): string | null;
70
70
  /** As configured via configureApiClient — same origin/path every request in this
71
71
  * module targets. */
72
72
  export declare function getBaseUrl(): string;
73
- export interface AuthRecovery {
74
- /** Runs (or joins) the shared recovery; resolves when it is over, however it ended. */
75
- recover(): Promise<void>;
76
- /** Whose session this is right now — a stable user id — or null when signed out. */
77
- principal(): string | null;
78
- }
79
- /** Registers what runs when a request 401s and the automatic refresh-then-retry dance
80
- * (below) also fails to recover it — i.e. the session is genuinely gone, not just a
81
- * normal access-token expiry a refresh already fixed silently. A consuming app's own
82
- * session layer (e.g. one doing a silent OIDC resume, as media-planner's session.ts
83
- * does) is the one owner: it decides what "recovered" means and, failing that,
84
- * invalidates its session state. Left entirely unset is fine — decodeWithAuthRetry
85
- * then just reports the second 401 as a failure, with no recovery attempt. */
86
- export declare function setAuthRecovery(recovery: AuthRecovery): () => void;
73
+ type SessionEndedListener = () => void;
74
+ /**
75
+ * Subscribes to the ONE signal that a session is over (AK-35): a request answered 401
76
+ * and the shared `refreshAccessToken()` then resolved `null` — the plugin itself refused
77
+ * the refresh cookie. That verdict, and only that, is what `./authSession.ts` turns into
78
+ * the session-expired state and an automatic sign-in. A 401 that follows a SUCCESSFUL
79
+ * refresh-and-retry is that route's own answer about that request (the session was just
80
+ * proven live), so it is thrown to the caller and never announced here — treating it as
81
+ * a session loss would loop: expired -> sign in -> authenticated -> the same 401.
82
+ * Internal to `@flytedesk/app-kit/auth/client`: an app never subscribes itself.
83
+ */
84
+ export declare function onSessionEnded(listener: SessionEndedListener): () => void;
87
85
  /**
88
86
  * Runs — or joins, when one is already in flight — THE one `POST {routePrefix}/refresh`,
89
87
  * and resolves the new access token (also stored via setAccessToken). Single-flighted and
90
- * always deadline-bound: every caller that 401s, and useAuthSession's own loads, share
88
+ * always deadline-bound: every caller that 401s, and `./authSession.ts`'s own loads, share
91
89
  * this one refresh — the refresh cookie rotates on every call, so two concurrent
92
90
  * refreshes presenting one cookie would race, and a refresh that never answered would
93
91
  * stall them all.
94
92
  *
95
93
  * AK-23 (L-c): only the plugin's verdict signs anyone out. A 401 — the one answer the
96
94
  * plugin gives a refresh it refuses — resolves `null` ("no new token"), which
97
- * sendAndDecode treats as the session being gone. Every other outcome rejects with
98
- * AuthUnavailableError, shared by every waiting caller, so no caller ever runs the auth
99
- * recovery (the sign-out path) over an outage: the plugin's own 503 "could not decide",
95
+ * sendWithAuthRetry treats as the session being over (`onSessionEnded`). Every other
96
+ * outcome rejects with AuthUnavailableError, shared by every waiting caller, so no caller
97
+ * ever announces a session end over an outage: the plugin's own 503 "could not decide",
100
98
  * and an outcome that is no decision at all (AUTH_UNREACHABLE_CODE) — a network error,
101
99
  * the deadline (the server's `/refresh` can legitimately outlast it: a contended
102
100
  * session lock plus a slow flytedesk-id `/token` and authorization call), or a status
@@ -113,17 +111,23 @@ export interface RequestOptions {
113
111
  * body decode. Past it the call rejects with a RequestDeadlineError and does nothing
114
112
  * further (no retry, no auth-failure event). */
115
113
  deadlineMs?: number;
116
- /** Set only by a session layer's own bootstrap/probe calls, which ARE the auth
117
- * recovery (or start it): a 401 that survives the refresh still starts the shared
118
- * recovery, but this call does not wait for it — waiting would mean the recovery
119
- * waiting on itself. */
120
- ownsAuthRecovery?: boolean;
121
114
  /** Passed straight to `fetch`'s own `keepalive` — lets a request started right
122
115
  * before the page unloads actually complete instead of being cancelled the instant
123
116
  * the page goes away. Only meaningfully used with a small body: the browser caps
124
117
  * the total size of in-flight keepalive requests (~64KB combined). */
125
118
  keepalive?: boolean;
119
+ /** An external abort signal (e.g. a hook's cleanup when a newer request supersedes
120
+ * this one) — aborts the in-flight fetch immediately, independent of deadlineMs, and
121
+ * the call rejects with the signal's reason (the standard AbortError unless the caller
122
+ * passed another). An aborted call is nothing but cancelled: it never retries, starts
123
+ * no refresh and announces no session end. The shared token refresh a 401 may have
124
+ * started is not cancelled (other callers may be waiting on it). */
125
+ signal?: AbortSignal;
126
126
  }
127
+ /** The absolute URL of `path` on this client's api — for a top-level navigation (the
128
+ * sign-in route), which, unlike a fetch, can't be left relative to a dev proxy. A
129
+ * same-origin `baseUrl` resolves against `pageOrigin`. */
130
+ export declare function absoluteApiUrl(path: string, pageOrigin: string): string;
127
131
  /** The one place a browser app talks to its own BFF api. Handles bearer auth,
128
132
  * transparent access-token refresh on 401, and the { error, code, field? } error
129
133
  * contract every @flytedesk/app-kit/auth-backed api returns. */
@@ -141,8 +145,8 @@ export interface ApiDownloadOptions {
141
145
  /** Bounds the whole call exactly like RequestOptions.deadlineMs — first attempt, any
142
146
  * refresh it waits on, the retry and the blob read. */
143
147
  deadlineMs?: number;
144
- /** An external abort signal (e.g. a component's cleanup) — aborts the in-flight
145
- * fetch immediately, independent of deadlineMs. */
148
+ /** An external abort signal (e.g. a component's cleanup) — exactly RequestOptions.signal:
149
+ * aborts the in-flight fetch immediately, independent of deadlineMs. */
146
150
  signal?: AbortSignal;
147
151
  skipAuthRetry?: boolean;
148
152
  }
@@ -47,8 +47,8 @@ export const AUTH_UNREACHABLE_CODE = "auth_unreachable";
47
47
  * carrying one of `AUTH_UNAVAILABLE_CODES`) — or the automatic refresh reached no
48
48
  * decision at all (`AUTH_UNREACHABLE_CODE`). Transient, and NOT a sign-out: the session
49
49
  * (its refresh cookie) is intact and the same request can succeed once the dependency
50
- * recovers. This client never runs the auth recovery for it; `useAuthSession` keeps the
51
- * session and retries with backoff (its `"unavailable"` status). A subclass of
50
+ * recovers. It never announces a session end (`onSessionEnded`); `./authSession.ts` keeps
51
+ * the session and retries with backoff (its `"unavailable"` status). A subclass of
52
52
  * ApiRequestError, so existing `instanceof ApiRequestError` handling still sees it.
53
53
  */
54
54
  export class AuthUnavailableError extends ApiRequestError {
@@ -87,7 +87,7 @@ async function errorFromResponse(res) {
87
87
  }
88
88
  return new ApiRequestError(res.status, body);
89
89
  }
90
- /** A request that missed its deadline (see withDeadline). */
90
+ /** A request that missed its deadline (see withCancellation). */
91
91
  export class RequestDeadlineError extends Error {
92
92
  constructor(what, ms) {
93
93
  super(`${what} did not complete within ${ms}ms`);
@@ -111,46 +111,64 @@ export function getAccessToken() {
111
111
  export function getBaseUrl() {
112
112
  return baseUrl;
113
113
  }
114
- let authRecovery = null;
115
- /** Registers what runs when a request 401s and the automatic refresh-then-retry dance
116
- * (below) also fails to recover it — i.e. the session is genuinely gone, not just a
117
- * normal access-token expiry a refresh already fixed silently. A consuming app's own
118
- * session layer (e.g. one doing a silent OIDC resume, as media-planner's session.ts
119
- * does) is the one owner: it decides what "recovered" means and, failing that,
120
- * invalidates its session state. Left entirely unset is fine — decodeWithAuthRetry
121
- * then just reports the second 401 as a failure, with no recovery attempt. */
122
- export function setAuthRecovery(recovery) {
123
- authRecovery = recovery;
114
+ const sessionEndedListeners = new Set();
115
+ /**
116
+ * Subscribes to the ONE signal that a session is over (AK-35): a request answered 401
117
+ * and the shared `refreshAccessToken()` then resolved `null` — the plugin itself refused
118
+ * the refresh cookie. That verdict, and only that, is what `./authSession.ts` turns into
119
+ * the session-expired state and an automatic sign-in. A 401 that follows a SUCCESSFUL
120
+ * refresh-and-retry is that route's own answer about that request (the session was just
121
+ * proven live), so it is thrown to the caller and never announced here — treating it as
122
+ * a session loss would loop: expired -> sign in -> authenticated -> the same 401.
123
+ * Internal to `@flytedesk/app-kit/auth/client`: an app never subscribes itself.
124
+ */
125
+ export function onSessionEnded(listener) {
126
+ sessionEndedListeners.add(listener);
124
127
  return () => {
125
- if (authRecovery === recovery)
126
- authRecovery = null;
128
+ sessionEndedListeners.delete(listener);
127
129
  };
128
130
  }
129
- /** Runs `run` under a deadline: past `ms`, its AbortSignal aborts (so the underlying
130
- * fetch, and any body read on it, is cancelled) and the returned promise rejects with
131
- * a RequestDeadlineError — the rejection does not depend on whatever `run` awaits
132
- * honouring the signal, so this settles no matter what. */
133
- async function withDeadline(what, ms, run, externalSignal) {
131
+ function announceSessionEnded() {
132
+ for (const listener of sessionEndedListeners)
133
+ listener();
134
+ }
135
+ /** Runs `run` under an optional deadline and an optional caller abort signal — the one
136
+ * cancellation mechanism every request this client makes goes through. `run` gets an
137
+ * AbortSignal that aborts (so the underlying fetch, and any body read on it, is
138
+ * cancelled) when the deadline `ms` passes or when `externalSignal` aborts. The
139
+ * returned promise then rejects — with a RequestDeadlineError for the deadline, with the
140
+ * caller's own abort reason (the standard AbortError unless they passed another) for the
141
+ * signal — and that rejection does not depend on whatever `run` awaits honouring the
142
+ * signal, so this settles no matter what. A signal that is already aborted rejects
143
+ * before `run` starts. */
144
+ async function withCancellation(what, ms, run, externalSignal) {
145
+ externalSignal?.throwIfAborted();
134
146
  const controller = new AbortController();
135
- if (externalSignal) {
136
- if (externalSignal.aborted)
137
- controller.abort(externalSignal.reason);
138
- else
139
- externalSignal.addEventListener("abort", () => controller.abort(externalSignal.reason), { once: true });
140
- }
141
147
  let timer;
142
- const deadline = new Promise((_, reject) => {
143
- timer = setTimeout(() => {
144
- const reason = new RequestDeadlineError(what, ms);
145
- controller.abort(reason);
146
- reject(reason);
147
- }, ms);
148
+ let onExternalAbort;
149
+ const interrupted = new Promise((_, reject) => {
150
+ if (externalSignal) {
151
+ onExternalAbort = () => {
152
+ controller.abort(externalSignal.reason);
153
+ reject(externalSignal.reason);
154
+ };
155
+ externalSignal.addEventListener("abort", onExternalAbort, { once: true });
156
+ }
157
+ if (ms !== undefined) {
158
+ timer = setTimeout(() => {
159
+ const reason = new RequestDeadlineError(what, ms);
160
+ controller.abort(reason);
161
+ reject(reason);
162
+ }, ms);
163
+ }
148
164
  });
149
165
  try {
150
- return await Promise.race([run(controller.signal), deadline]);
166
+ return await Promise.race([run(controller.signal), interrupted]);
151
167
  }
152
168
  finally {
153
169
  clearTimeout(timer);
170
+ if (onExternalAbort)
171
+ externalSignal?.removeEventListener("abort", onExternalAbort);
154
172
  }
155
173
  }
156
174
  /** The AuthUnavailableError (announced to onAuthUnavailable listeners) for a refresh
@@ -164,16 +182,16 @@ function refreshUnreachable(status, cause) {
164
182
  /**
165
183
  * Runs — or joins, when one is already in flight — THE one `POST {routePrefix}/refresh`,
166
184
  * and resolves the new access token (also stored via setAccessToken). Single-flighted and
167
- * always deadline-bound: every caller that 401s, and useAuthSession's own loads, share
185
+ * always deadline-bound: every caller that 401s, and `./authSession.ts`'s own loads, share
168
186
  * this one refresh — the refresh cookie rotates on every call, so two concurrent
169
187
  * refreshes presenting one cookie would race, and a refresh that never answered would
170
188
  * stall them all.
171
189
  *
172
190
  * AK-23 (L-c): only the plugin's verdict signs anyone out. A 401 — the one answer the
173
191
  * plugin gives a refresh it refuses — resolves `null` ("no new token"), which
174
- * sendAndDecode treats as the session being gone. Every other outcome rejects with
175
- * AuthUnavailableError, shared by every waiting caller, so no caller ever runs the auth
176
- * recovery (the sign-out path) over an outage: the plugin's own 503 "could not decide",
192
+ * sendWithAuthRetry treats as the session being over (`onSessionEnded`). Every other
193
+ * outcome rejects with AuthUnavailableError, shared by every waiting caller, so no caller
194
+ * ever announces a session end over an outage: the plugin's own 503 "could not decide",
177
195
  * and an outcome that is no decision at all (AUTH_UNREACHABLE_CODE) — a network error,
178
196
  * the deadline (the server's `/refresh` can legitimately outlast it: a contended
179
197
  * session lock plus a slow flytedesk-id `/token` and authorization call), or a status
@@ -182,7 +200,7 @@ function refreshUnreachable(status, cause) {
182
200
  export async function refreshAccessToken() {
183
201
  if (!refreshPromise) {
184
202
  const refreshPath = authRoutePath(AUTH_ROUTE_PREFIX, "refresh");
185
- refreshPromise = withDeadline(`POST ${refreshPath}`, DEFAULT_REQUEST_DEADLINE_MS, async (signal) => {
203
+ refreshPromise = withCancellation(`POST ${refreshPath}`, DEFAULT_REQUEST_DEADLINE_MS, async (signal) => {
186
204
  const res = await fetch(`${baseUrl}${refreshPath}`, {
187
205
  method: "POST",
188
206
  credentials: "include",
@@ -216,6 +234,12 @@ export async function refreshAccessToken() {
216
234
  function isAbsoluteUrl(value) {
217
235
  return /^[a-z][a-z\d+.-]*:\/\//i.test(value);
218
236
  }
237
+ /** The absolute URL of `path` on this client's api — for a top-level navigation (the
238
+ * sign-in route), which, unlike a fetch, can't be left relative to a dev proxy. A
239
+ * same-origin `baseUrl` resolves against `pageOrigin`. */
240
+ export function absoluteApiUrl(path, pageOrigin) {
241
+ return isAbsoluteUrl(baseUrl) ? `${baseUrl}${path}` : `${pageOrigin}${baseUrl}${path}`;
242
+ }
219
243
  function buildUrl(path, query) {
220
244
  const url = new URL(baseUrl + path, typeof window !== "undefined" ? window.location.origin : "http://localhost");
221
245
  if (query) {
@@ -235,54 +259,40 @@ function buildUrl(path, query) {
235
259
  return isAbsoluteUrl(baseUrl) ? url.toString() : url.pathname + url.search;
236
260
  }
237
261
  /** Shared tail of both apiRequest and apiUpload: fires `doFetch`, transparently
238
- * retries once after a refresh on 401 (unless skipped) — and, if that still 401s, once
239
- * more after the shared auth recovery (see setAuthRecovery) — and applies the same
262
+ * retries once after a refresh on 401 (unless skipped), and applies the same
240
263
  * { error, code, field? } error contract / 204-handling / JSON decode to the result —
241
- * all under `deadlineMs` when one is given (see withDeadline). Kept as one place so
264
+ * all under the optional `deadlineMs` and the caller's optional abort `signal` (see
265
+ * withCancellation). Kept as one place so
242
266
  * the auth-retry dance can't drift between the JSON and multipart transports. */
243
267
  async function sendAndDecode(label, doFetch, options) {
244
- const { deadlineMs } = options;
245
- if (deadlineMs === undefined)
246
- return decodeWithAuthRetry(doFetch, options);
247
- return withDeadline(label, deadlineMs, (signal) => decodeWithAuthRetry(doFetch, options, signal));
268
+ const { deadlineMs, signal } = options;
269
+ return withCancellation(label, deadlineMs, (fetchSignal) => decodeWithAuthRetry(doFetch, options, fetchSignal), signal);
248
270
  }
249
- /** The shared tail of every transport this client offers: fires `doFetch`,
250
- * transparently retries once after a refresh on 401 (unless skipped), and once more
251
- * after the shared auth recovery if that still 401s (see setAuthRecovery) — then
252
- * throws the decoded error on any non-2xx. Returns the successful raw Response so
253
- * each transport (JSON body, blob download) can decode it its own way; this is the
254
- * ONE place the auth-retry dance lives, so it can't drift between them. */
255
- async function sendWithAuthRetry(doFetch, { skipAuthRetry, ownsAuthRecovery }, signal) {
256
- // Who this request is being sent as — the only identity a recovery may replay it for.
257
- const recovery = authRecovery;
258
- const sentAs = recovery?.principal() ?? null;
271
+ /** The shared tail of every transport this client offers: fires `doFetch`, and on a
272
+ * 401 (unless skipped) refreshes once through the shared single-flighted
273
+ * `refreshAccessToken` and retries. When that refresh is REFUSED (it resolves `null`),
274
+ * the session is over: `onSessionEnded` listeners hear it and the 401 is thrown. Any
275
+ * non-2xx left after that is thrown decoded. Returns the successful raw Response so
276
+ * each transport (JSON body, blob download) can decode it its own way; this is the ONE
277
+ * place the auth-retry dance lives, so it can't drift between them. */
278
+ async function sendWithAuthRetry(doFetch, { skipAuthRetry }, signal) {
259
279
  let res = await doFetch(signal);
260
280
  if (res.status === 401 && !skipAuthRetry) {
261
281
  // Rejects with AuthUnavailableError on an outage (AK-23) — straight out of this
262
- // call, past the recovery below: an outage is not a sign-out.
282
+ // call: an outage is not a sign-out.
263
283
  const refreshed = await refreshAccessToken();
264
- // The shared refresh is not cancelled by this call's deadline (other callers may
265
- // still want it) — but a call that has already missed its deadline must not act on
266
- // its outcome: no retry, and no auth-failure event for a caller that gave up.
284
+ // The shared refresh is not cancelled by this call's deadline or abort (other callers
285
+ // may still want it) — but a call that has already missed its deadline, or whose
286
+ // caller aborted it (AK-29), must not act on its outcome: no retry, and no
287
+ // session-ended announcement for a caller that gave up.
267
288
  signal?.throwIfAborted();
268
- if (refreshed)
289
+ if (refreshed === null) {
290
+ // AK-35: the plugin refused the refresh cookie — the only verdict that ends a
291
+ // session. See onSessionEnded.
292
+ announceSessionEnded();
293
+ }
294
+ else {
269
295
  res = await doFetch(signal);
270
- signal?.throwIfAborted();
271
- if (res.status === 401) {
272
- // Both the original request and the refresh-then-retry (or the refresh call
273
- // itself, if it never returned a token) came back 401 — the session is gone,
274
- // not just this in-memory access token. See setAuthRecovery.
275
- if (recovery && ownsAuthRecovery) {
276
- void recovery.recover();
277
- }
278
- else if (recovery) {
279
- await recovery.recover();
280
- signal?.throwIfAborted();
281
- // Replay only for the same user. A recovery that ended signed out, or signed
282
- // in as someone else, leaves this request failed.
283
- if (sentAs !== null && recovery.principal() === sentAs)
284
- res = await doFetch(signal);
285
- }
286
296
  signal?.throwIfAborted();
287
297
  }
288
298
  }
@@ -300,8 +310,8 @@ async function decodeWithAuthRetry(doFetch, options, signal) {
300
310
  * transparent access-token refresh on 401, and the { error, code, field? } error
301
311
  * contract every @flytedesk/app-kit/auth-backed api returns. */
302
312
  export async function apiRequest(path, options = {}) {
303
- const { method = "GET", body, query, skipAuthRetry, deadlineMs, ownsAuthRecovery, keepalive } = options;
304
- const doFetch = async (signal) => fetch(buildUrl(path, query), {
313
+ const { method = "GET", body, query, skipAuthRetry, deadlineMs, keepalive, signal } = options;
314
+ const doFetch = async (fetchSignal) => fetch(buildUrl(path, query), {
305
315
  method,
306
316
  credentials: "include",
307
317
  headers: {
@@ -309,10 +319,10 @@ export async function apiRequest(path, options = {}) {
309
319
  ...(accessToken ? { Authorization: `Bearer ${accessToken}` } : {}),
310
320
  },
311
321
  body: body != null ? JSON.stringify(body) : undefined,
312
- signal,
322
+ signal: fetchSignal,
313
323
  ...(keepalive ? { keepalive: true } : {}),
314
324
  });
315
- return sendAndDecode(`${method} ${path}`, doFetch, { skipAuthRetry, deadlineMs, ownsAuthRecovery });
325
+ return sendAndDecode(`${method} ${path}`, doFetch, { skipAuthRetry, deadlineMs, signal });
316
326
  }
317
327
  /** Sibling to apiRequest for multipart/form-data uploads. Same bearer auth, 401 ->
318
328
  * refresh -> retry-once dance, and error contract — but always POSTs `formData` as-is
@@ -377,10 +387,7 @@ export async function apiDownload(path, options = {}) {
377
387
  const filename = parseContentDispositionFilename(res.headers.get("content-disposition"));
378
388
  return { blob, filename, contentType };
379
389
  };
380
- const run = async (fetchSignal) => decode(await sendWithAuthRetry(doFetch, { skipAuthRetry }, fetchSignal));
381
- if (deadlineMs === undefined)
382
- return run(signal);
383
- return withDeadline(`GET ${path}`, deadlineMs, run, signal);
390
+ return withCancellation(`GET ${path}`, deadlineMs, async (fetchSignal) => decode(await sendWithAuthRetry(doFetch, { skipAuthRetry }, fetchSignal)), signal);
384
391
  }
385
392
  /** Triggers a browser "Save As" for an already-fetched blob (e.g. from apiDownload) —
386
393
  * a transient off-DOM anchor is the standard way to do this without navigating away.
@@ -1 +1 @@
1
- {"version":3,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E,CAAC;IACzC,CAAC,CAAC;IAEF,OAAO,gBAAgB,CACrB,OAAO,IAAI,EAAE,EACb,UAAU,EACV,KAAK,EAAE,WAAW,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,iBAAiB,CAAC,OAAO,EAAE,EAAE,aAAa,EAAE,EAAE,WAAW,CAAC,CAAC,EAC/F,MAAM,CACP,CAAC;AACJ,CAAC;AAED;;+CAE+C;AAC/C,MAAM,UAAU,QAAQ,CAAC,IAAU,EAAE,QAAgB;IACnD,IAAI,OAAO,QAAQ,KAAK,WAAW;QAAE,OAAO;IAC5C,MAAM,UAAU,GAAG,GAAkC,CAAC;IACtD,MAAM,GAAG,GAAG,UAAU,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAC7C,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QAC3C,MAAM,CAAC,IAAI,GAAG,GAAG,CAAC;QAClB,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAC3B,MAAM,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;YAAS,CAAC;QACT,UAAU,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC;AACH,CAAC"}
@@ -1,12 +1,19 @@
1
1
  /**
2
2
  * Browser-safe client for `@flytedesk/app-kit/auth` — a separate subpath export (see
3
3
  * package.json's "exports") so this never drags a single Node/Fastify import into a
4
- * browser bundle. See httpClient.ts and useAuthSession.ts's own doc comments for what
5
- * was extracted from where and why (AK-16).
4
+ * browser bundle.
5
+ *
6
+ * Two things live here, and an app uses both:
7
+ * - the flytedesk ID session lifecycle (AK-35): `SessionBoundary`, `useAuthSession` and
8
+ * `authSession` — sign-in, session loss, checks, sign-out and cross-tab, decided in
9
+ * ONE place (`./authSession.ts`). An app never builds any of it itself; see the
10
+ * README's "Building a flytedesk ID app";
11
+ * - the api client every request goes through (`apiRequest`, `apiUpload`,
12
+ * `apiDownload`), which carries the session's access token and refreshes it.
6
13
  */
7
- export { ApiRequestError, AuthUnavailableError, AUTH_UNREACHABLE_CODE, type AuthUnavailableErrorCode, RequestDeadlineError, onAuthUnavailable, DEFAULT_REQUEST_DEADLINE_MS, configureApiClient, setAccessToken, getAccessToken, getBaseUrl, setAuthRecovery, apiRequest, apiUpload, apiDownload, saveBlob, type AuthRecovery, type RequestOptions, type ApiDownloadOptions, type ApiDownloadResult, } from "./httpClient.js";
8
- export { useAuthSession, unavailableRetryDelayMs, UNAVAILABLE_RETRY_BASE_MS, UNAVAILABLE_RETRY_MAX_MS, type AuthStatus, type AuthSessionState, type LoadingSessionState, type AuthenticatedSessionState, type UnauthenticatedSessionState, type UnavailableSessionState, type ErrorSessionState, } from "./useAuthSession.js";
9
- export { attemptSilentResume, type SilentResumeResult, type AttemptSilentResumeOptions, } from "./silentAuth.js";
10
- export { consumeSignInError } from "./signInError.js";
11
- export type { AppSwitcherEntry, AuthedUserDto, IdpRole, ApiErrorBody, AuthUnavailableCode, SilentAuthDetailCode, SilentAuthMessage, } from "../shared-types.js";
12
- export { AUTH_ROUTE_PREFIX, AUTH_ROUTE_SEGMENTS, AUTH_UNAVAILABLE_CODES, authRoutePath, SILENT_AUTH_DETAIL_CODES, SIGNIN_ERROR_QUERY_PARAM, SIGNIN_ERROR_CODES, type AuthRouteSegment, type SignInErrorCode, } from "../shared-types.js";
14
+ export { ApiRequestError, AuthUnavailableError, AUTH_UNREACHABLE_CODE, type AuthUnavailableErrorCode, RequestDeadlineError, DEFAULT_REQUEST_DEADLINE_MS, configureApiClient, getBaseUrl, apiRequest, apiUpload, apiDownload, saveBlob, type RequestOptions, type ApiDownloadOptions, type ApiDownloadResult, } from "./httpClient.js";
15
+ export { type AuthSessionState, type AuthenticatedState, type CheckingState, type ErrorState, type SigningInState, type SigningOutState, type UnavailableState, } from "./authSession.js";
16
+ export { authSession } from "./browserEnvironment.js";
17
+ export { SessionBoundary, useAuthSession, type AuthSession, type AuthSessionActions, type SessionBoundaryProps, type SessionScreenKind, type SessionScreenState, type UsableSession, } from "./useAuthSession.js";
18
+ export type { AppSwitcherEntry, AuthedUserDto, IdpRole, ApiErrorBody, AuthUnavailableCode, } from "../shared-types.js";
19
+ export { AUTH_ROUTE_PREFIX, AUTH_ROUTE_SEGMENTS, AUTH_UNAVAILABLE_CODES, authRoutePath, type AuthRouteSegment, } from "../shared-types.js";
@@ -1,12 +1,18 @@
1
1
  /**
2
2
  * Browser-safe client for `@flytedesk/app-kit/auth` — a separate subpath export (see
3
3
  * package.json's "exports") so this never drags a single Node/Fastify import into a
4
- * browser bundle. See httpClient.ts and useAuthSession.ts's own doc comments for what
5
- * was extracted from where and why (AK-16).
4
+ * browser bundle.
5
+ *
6
+ * Two things live here, and an app uses both:
7
+ * - the flytedesk ID session lifecycle (AK-35): `SessionBoundary`, `useAuthSession` and
8
+ * `authSession` — sign-in, session loss, checks, sign-out and cross-tab, decided in
9
+ * ONE place (`./authSession.ts`). An app never builds any of it itself; see the
10
+ * README's "Building a flytedesk ID app";
11
+ * - the api client every request goes through (`apiRequest`, `apiUpload`,
12
+ * `apiDownload`), which carries the session's access token and refreshes it.
6
13
  */
7
- export { ApiRequestError, AuthUnavailableError, AUTH_UNREACHABLE_CODE, RequestDeadlineError, onAuthUnavailable, DEFAULT_REQUEST_DEADLINE_MS, configureApiClient, setAccessToken, getAccessToken, getBaseUrl, setAuthRecovery, apiRequest, apiUpload, apiDownload, saveBlob, } from "./httpClient.js";
8
- export { useAuthSession, unavailableRetryDelayMs, UNAVAILABLE_RETRY_BASE_MS, UNAVAILABLE_RETRY_MAX_MS, } from "./useAuthSession.js";
9
- export { attemptSilentResume, } from "./silentAuth.js";
10
- export { consumeSignInError } from "./signInError.js";
11
- export { AUTH_ROUTE_PREFIX, AUTH_ROUTE_SEGMENTS, AUTH_UNAVAILABLE_CODES, authRoutePath, SILENT_AUTH_DETAIL_CODES, SIGNIN_ERROR_QUERY_PARAM, SIGNIN_ERROR_CODES, } from "../shared-types.js";
14
+ export { ApiRequestError, AuthUnavailableError, AUTH_UNREACHABLE_CODE, RequestDeadlineError, DEFAULT_REQUEST_DEADLINE_MS, configureApiClient, getBaseUrl, apiRequest, apiUpload, apiDownload, saveBlob, } from "./httpClient.js";
15
+ export { authSession } from "./browserEnvironment.js";
16
+ export { SessionBoundary, useAuthSession, } from "./useAuthSession.js";
17
+ export { AUTH_ROUTE_PREFIX, AUTH_ROUTE_SEGMENTS, AUTH_UNAVAILABLE_CODES, authRoutePath, } from "../shared-types.js";
12
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/auth/client/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EAErB,oBAAoB,EACpB,iBAAiB,EACjB,2BAA2B,EAC3B,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,UAAU,EACV,eAAe,EACf,UAAU,EACV,SAAS,EACT,WAAW,EACX,QAAQ,GAKT,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,cAAc,EACd,uBAAuB,EACvB,yBAAyB,EACzB,wBAAwB,GAQzB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,mBAAmB,GAGpB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAWtD,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,aAAa,EACb,wBAAwB,EACxB,wBAAwB,EACxB,kBAAkB,GAGnB,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/auth/client/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EAErB,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,UAAU,EACV,UAAU,EACV,SAAS,EACT,WAAW,EACX,QAAQ,GAIT,MAAM,iBAAiB,CAAC;AAYzB,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EACL,eAAe,EACf,cAAc,GAOf,MAAM,qBAAqB,CAAC;AAS7B,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,aAAa,GAEd,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,6 @@
1
+ /** Makes every following `apiRequest`/`apiUpload`/`apiDownload` send `token` as its
2
+ * Bearer — as if the session had just refreshed. `null` clears it. */
3
+ export declare function setTestAccessToken(token: string | null): void;
4
+ /** Stops the tab's session lifecycle, forgets its state and clears the access token, so
5
+ * the next test starts from a fresh boot. */
6
+ export declare function resetAuthSessionForTests(): void;