@passflow/core 0.20.0 → 0.20.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/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5944 -0
- package/dist/index.d.ts +5944 -0
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -7
- package/dist/lib/api/app.d.ts +0 -11
- package/dist/lib/api/app.d.ts.map +0 -1
- package/dist/lib/api/auth.d.ts +0 -42
- package/dist/lib/api/auth.d.ts.map +0 -1
- package/dist/lib/api/axios-client.d.ts +0 -109
- package/dist/lib/api/axios-client.d.ts.map +0 -1
- package/dist/lib/api/cli-auth.d.ts +0 -12
- package/dist/lib/api/cli-auth.d.ts.map +0 -1
- package/dist/lib/api/index.d.ts +0 -11
- package/dist/lib/api/index.d.ts.map +0 -1
- package/dist/lib/api/invitation.d.ts +0 -80
- package/dist/lib/api/invitation.d.ts.map +0 -1
- package/dist/lib/api/model.d.ts +0 -844
- package/dist/lib/api/model.d.ts.map +0 -1
- package/dist/lib/api/setting.d.ts +0 -13
- package/dist/lib/api/setting.d.ts.map +0 -1
- package/dist/lib/api/tenant.d.ts +0 -216
- package/dist/lib/api/tenant.d.ts.map +0 -1
- package/dist/lib/api/two-factor.d.ts +0 -137
- package/dist/lib/api/two-factor.d.ts.map +0 -1
- package/dist/lib/api/upgrade.d.ts +0 -39
- package/dist/lib/api/upgrade.d.ts.map +0 -1
- package/dist/lib/api/user.d.ts +0 -22
- package/dist/lib/api/user.d.ts.map +0 -1
- package/dist/lib/constants/index.d.ts +0 -33
- package/dist/lib/constants/index.d.ts.map +0 -1
- package/dist/lib/device/index.d.ts +0 -17
- package/dist/lib/device/index.d.ts.map +0 -1
- package/dist/lib/index.d.ts +0 -22
- package/dist/lib/index.d.ts.map +0 -1
- package/dist/lib/interceptors/fetch-registry.d.ts +0 -96
- package/dist/lib/interceptors/fetch-registry.d.ts.map +0 -1
- package/dist/lib/m2m/client.d.ts +0 -196
- package/dist/lib/m2m/client.d.ts.map +0 -1
- package/dist/lib/m2m/errors.d.ts +0 -107
- package/dist/lib/m2m/errors.d.ts.map +0 -1
- package/dist/lib/m2m/index.d.ts +0 -27
- package/dist/lib/m2m/index.d.ts.map +0 -1
- package/dist/lib/m2m/types.d.ts +0 -217
- package/dist/lib/m2m/types.d.ts.map +0 -1
- package/dist/lib/passflow.d.ts +0 -1224
- package/dist/lib/passflow.d.ts.map +0 -1
- package/dist/lib/pkce.d.ts +0 -13
- package/dist/lib/pkce.d.ts.map +0 -1
- package/dist/lib/platform/index.d.ts +0 -4
- package/dist/lib/platform/index.d.ts.map +0 -1
- package/dist/lib/platform/types.d.ts +0 -206
- package/dist/lib/platform/types.d.ts.map +0 -1
- package/dist/lib/platform/web-adapter.d.ts +0 -104
- package/dist/lib/platform/web-adapter.d.ts.map +0 -1
- package/dist/lib/services/auth-service.d.ts +0 -197
- package/dist/lib/services/auth-service.d.ts.map +0 -1
- package/dist/lib/services/index.d.ts +0 -8
- package/dist/lib/services/index.d.ts.map +0 -1
- package/dist/lib/services/invitation-service.d.ts +0 -44
- package/dist/lib/services/invitation-service.d.ts.map +0 -1
- package/dist/lib/services/logger.d.ts +0 -24
- package/dist/lib/services/logger.d.ts.map +0 -1
- package/dist/lib/services/tenant-service.d.ts +0 -200
- package/dist/lib/services/tenant-service.d.ts.map +0 -1
- package/dist/lib/services/tenant-user-membership.d.ts +0 -76
- package/dist/lib/services/tenant-user-membership.d.ts.map +0 -1
- package/dist/lib/services/token-cache-service.d.ts +0 -36
- package/dist/lib/services/token-cache-service.d.ts.map +0 -1
- package/dist/lib/services/two-factor-service.d.ts +0 -193
- package/dist/lib/services/two-factor-service.d.ts.map +0 -1
- package/dist/lib/services/user-service.d.ts +0 -41
- package/dist/lib/services/user-service.d.ts.map +0 -1
- package/dist/lib/storage/index.d.ts +0 -106
- package/dist/lib/storage/index.d.ts.map +0 -1
- package/dist/lib/store.d.ts +0 -175
- package/dist/lib/store.d.ts.map +0 -1
- package/dist/lib/token/delivery-manager.d.ts +0 -121
- package/dist/lib/token/delivery-manager.d.ts.map +0 -1
- package/dist/lib/token/index.d.ts +0 -4
- package/dist/lib/token/index.d.ts.map +0 -1
- package/dist/lib/token/membership.d.ts +0 -37
- package/dist/lib/token/membership.d.ts.map +0 -1
- package/dist/lib/token/service.d.ts +0 -47
- package/dist/lib/token/service.d.ts.map +0 -1
- package/dist/lib/token/token.d.ts +0 -55
- package/dist/lib/token/token.d.ts.map +0 -1
- package/dist/lib/types/index.d.ts +0 -24
- package/dist/lib/types/index.d.ts.map +0 -1
- package/dist/lib/upgrade/acr.d.ts +0 -85
- package/dist/lib/upgrade/acr.d.ts.map +0 -1
- package/dist/lib/upgrade/axios-adapter.d.ts +0 -81
- package/dist/lib/upgrade/axios-adapter.d.ts.map +0 -1
- package/dist/lib/upgrade/challenge.d.ts +0 -217
- package/dist/lib/upgrade/challenge.d.ts.map +0 -1
- package/dist/lib/upgrade/client.d.ts +0 -29
- package/dist/lib/upgrade/client.d.ts.map +0 -1
- package/dist/lib/upgrade/controller.d.ts +0 -435
- package/dist/lib/upgrade/controller.d.ts.map +0 -1
- package/dist/lib/upgrade/core.d.ts +0 -353
- package/dist/lib/upgrade/core.d.ts.map +0 -1
- package/dist/lib/upgrade/errors.d.ts +0 -208
- package/dist/lib/upgrade/errors.d.ts.map +0 -1
- package/dist/lib/upgrade/facade.d.ts +0 -188
- package/dist/lib/upgrade/facade.d.ts.map +0 -1
- package/dist/lib/upgrade/factors.d.ts +0 -97
- package/dist/lib/upgrade/factors.d.ts.map +0 -1
- package/dist/lib/upgrade/fetch-adapter.d.ts +0 -30
- package/dist/lib/upgrade/fetch-adapter.d.ts.map +0 -1
- package/dist/lib/upgrade/index.d.ts +0 -17
- package/dist/lib/upgrade/index.d.ts.map +0 -1
- package/dist/lib/upgrade/markers.d.ts +0 -64
- package/dist/lib/upgrade/markers.d.ts.map +0 -1
- package/dist/lib/upgrade/replay.d.ts +0 -132
- package/dist/lib/upgrade/replay.d.ts.map +0 -1
- package/dist/lib/upgrade/select.d.ts +0 -48
- package/dist/lib/upgrade/select.d.ts.map +0 -1
- package/dist/lib/upgrade/session.d.ts +0 -72
- package/dist/lib/upgrade/session.d.ts.map +0 -1
- package/dist/lib/upgrade/snapshot.d.ts +0 -196
- package/dist/lib/upgrade/snapshot.d.ts.map +0 -1
- package/dist/lib/upgrade/transport.d.ts +0 -69
- package/dist/lib/upgrade/transport.d.ts.map +0 -1
- package/dist/lib/utils/validation.d.ts +0 -54
- package/dist/lib/utils/validation.d.ts.map +0 -1
- package/dist/tsconfig.build.tsbuildinfo +0 -1
|
@@ -1,353 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The upgrade core: ONE implementation, transport-agnostic by construction.
|
|
3
|
-
*
|
|
4
|
-
* Every behaviour lives here — recognise a challenge on both channels, decide
|
|
5
|
-
* whether the URL is in scope, run or join the elevation, replay once behind the
|
|
6
|
-
* re-entry guard, and decide the outcome. The four surfaces the SDK offers
|
|
7
|
-
* (`withAuth`, `attachAuth`, `createClient` and the internal axios seam) are
|
|
8
|
-
* ADAPTERS over this function, and the prohibition on them is absolute:
|
|
9
|
-
*
|
|
10
|
-
* **NO LOGIC IN AN ADAPTER.**
|
|
11
|
-
*
|
|
12
|
-
* An adapter translates transport shapes in and out and does nothing else. It
|
|
13
|
-
* may not parse a challenge, compare a bar, decide scope, count a retry, choose
|
|
14
|
-
* an error class or read a body. If an adapter would need a decision, the
|
|
15
|
-
* decision belongs here instead. The reason is not elegance: an axios response
|
|
16
|
-
* interceptor receives an `AxiosError`, not a callable `next`, and re-issues
|
|
17
|
-
* through `instance.request(config)` — so four independent wirings with two
|
|
18
|
-
* outcome vocabularies is what happens by default, and it is the largest
|
|
19
|
-
* quantity of parallel behaviour in this feature. A row that passes on one
|
|
20
|
-
* adapter and fails on another is a leak of logic out of this file, and the fix
|
|
21
|
-
* is to move it back in, never to fork the expectation per surface.
|
|
22
|
-
*
|
|
23
|
-
* `CoreOutcome` is the settlement table as a discriminated union, which is what
|
|
24
|
-
* makes that table the adapters' specification rather than a prose parallel.
|
|
25
|
-
*/
|
|
26
|
-
import { type AssuranceBar, type ChallengeChannel, type UpgradeChallenge, type UpgradeDiagnosticSink } from './challenge';
|
|
27
|
-
import { type UpgradeElevation, type Waiter } from './controller';
|
|
28
|
-
import type { ReplayHints, ReplayPolicy } from './replay';
|
|
29
|
-
import type { RequestSnapshot } from './snapshot';
|
|
30
|
-
/**
|
|
31
|
-
* Where the SDK is allowed to act on a challenge.
|
|
32
|
-
*
|
|
33
|
-
* Two domains, each with its own rule, and NO derived default. Deriving the set
|
|
34
|
-
* was the category error the previous model made: same-origin by default, the
|
|
35
|
-
* document origin, "the origin the first 401 came from" — every one of those is
|
|
36
|
-
* the SDK inferring a trust boundary it has no information about, and a
|
|
37
|
-
* fabricated 403 body from an observed endpoint can provoke a genuine elevation
|
|
38
|
-
* whose replay then carries the freshly elevated credential to that endpoint.
|
|
39
|
-
*
|
|
40
|
-
* The resolved scope is passed IN. No adapter and no wrapper derives it.
|
|
41
|
-
*/
|
|
42
|
-
export type InterceptionScope = {
|
|
43
|
-
/**
|
|
44
|
-
* Domain 1 — Passflow's own API, derived from `PassflowConfig.url`. Always in
|
|
45
|
-
* scope on any surface the SDK is attached to, which is what makes the
|
|
46
|
-
* zero-config half of the design work. `null` when no `url` is configured:
|
|
47
|
-
* domain 1 is then EMPTY and nothing throws, but the first parseable challenge
|
|
48
|
-
* raises a diagnostic naming `url`, because an app with no `url` would
|
|
49
|
-
* otherwise silently drop `/auth/session/exchange`'s own 403.
|
|
50
|
-
*/
|
|
51
|
-
passflow: {
|
|
52
|
-
origin: string;
|
|
53
|
-
pathPrefix?: string;
|
|
54
|
-
} | null;
|
|
55
|
-
/**
|
|
56
|
-
* Domain 2 — the customer's own backend, exactly as declared. An absolute
|
|
57
|
-
* origin (optionally with a path prefix) or a same-origin path prefix
|
|
58
|
-
* (`'/api'`). `[]` means nothing beyond domain 1 is in scope — and the
|
|
59
|
-
* predicate must NOT early-return on it.
|
|
60
|
-
*/
|
|
61
|
-
backend: string[];
|
|
62
|
-
};
|
|
63
|
-
export type UpgradeInterceptorOptions = {
|
|
64
|
-
/**
|
|
65
|
-
* Starts or joins the single flight, registering this waiter.
|
|
66
|
-
*
|
|
67
|
-
* Typed to accept a `void`-returning host as well, so a caller that does not
|
|
68
|
-
* use the controller's waiter bookkeeping still works — it just forfeits the
|
|
69
|
-
* per-waiter outcome summary, and the core then trusts the server's verdict on
|
|
70
|
-
* the replay for the `insufficient` decision, which it does anyway.
|
|
71
|
-
*/
|
|
72
|
-
elevate: (challenge: UpgradeChallenge, waiter: Waiter) => Promise<UpgradeElevation | void>;
|
|
73
|
-
/** REQUIRED. Resolved once, where the client is built. */
|
|
74
|
-
scope: InterceptionScope;
|
|
75
|
-
/** `'header'` requires the standards channel and never reads the body. */
|
|
76
|
-
requireChallengeChannel?: 'header';
|
|
77
|
-
/**
|
|
78
|
-
* NARROWING ONLY. Returning `false` excludes a URL the two domains admitted;
|
|
79
|
-
* returning `true` can never widen, so an always-true predicate cannot
|
|
80
|
-
* restore the allow-all default this design abolished.
|
|
81
|
-
*
|
|
82
|
-
* It is given the snapshot's **normalised absolute `href`**, never the raw
|
|
83
|
-
* string the caller passed: a narrowing decision is an authorization decision,
|
|
84
|
-
* and those are made on the URL the platform will actually send to (§13.4
|
|
85
|
-
* revision 6). A predicate written against relative paths must therefore
|
|
86
|
-
* match on the path of an absolute URL — `new URL(url).pathname` — rather than
|
|
87
|
-
* on `startsWith('/…')`.
|
|
88
|
-
*/
|
|
89
|
-
shouldIntercept?: (url: string) => boolean;
|
|
90
|
-
replay?: ReplayPolicy;
|
|
91
|
-
/** Default `'resolve-original'`. The fetch adapter's only option. */
|
|
92
|
-
onCancel?: 'resolve-original' | 'reject';
|
|
93
|
-
/** §5.5. Snapshotted before the elevation and read again after it. */
|
|
94
|
-
authorizationSwap?: () => {
|
|
95
|
-
from: string;
|
|
96
|
-
to: string;
|
|
97
|
-
} | undefined;
|
|
98
|
-
/** Default sink is `console.warn`; pass a function to route elsewhere. */
|
|
99
|
-
onUpgradeDiagnostic?: UpgradeDiagnosticSink;
|
|
100
|
-
/** The bar the elevation reached, when the host can read it from the new token. */
|
|
101
|
-
readObtainedBar?: () => AssuranceBar | undefined;
|
|
102
|
-
};
|
|
103
|
-
/**
|
|
104
|
-
* How an adapter is given its options: a value, or a getter read per challenge.
|
|
105
|
-
*
|
|
106
|
-
* The getter form is the one the facade uses, and the reason is a defect this
|
|
107
|
-
* seam actually had. `enable()` resolves the interception policy — the scope in
|
|
108
|
-
* particular — and an adapter handed the RESULT of that resolution freezes it at
|
|
109
|
-
* attach time: a client built at module scope, or in a child's `useMemo`, is
|
|
110
|
-
* attached before the provider's enable effect runs, so it would hold
|
|
111
|
-
* `backend: []` forever and never intercept the customer's own backend. A
|
|
112
|
-
* getter also makes re-enabling with a NARROWER `backend` take effect on
|
|
113
|
-
* clients that were already attached, instead of leaving them on the wider
|
|
114
|
-
* scope.
|
|
115
|
-
*
|
|
116
|
-
* A plain value is still accepted: a caller wiring the adapters directly, with
|
|
117
|
-
* a scope it resolved itself, has nothing to re-read.
|
|
118
|
-
*/
|
|
119
|
-
export type UpgradeInterceptorOptionsSource = UpgradeInterceptorOptions | (() => UpgradeInterceptorOptions);
|
|
120
|
-
/** Resolves an options source. Call it ONCE per challenge, never per module. */
|
|
121
|
-
export declare const resolveInterceptorOptions: (source: UpgradeInterceptorOptionsSource) => UpgradeInterceptorOptions;
|
|
122
|
-
/**
|
|
123
|
-
* What the core is given about one challenged request, and what it can do with
|
|
124
|
-
* it. The adapter builds this and nothing more.
|
|
125
|
-
*/
|
|
126
|
-
/**
|
|
127
|
-
* A live view of one caller's abort state, with optional subscription.
|
|
128
|
-
*
|
|
129
|
-
* `AbortSignal` satisfies this structurally, and so does the minimal
|
|
130
|
-
* `{ get aborted() }` getter object the adapters build. The listener pair is
|
|
131
|
-
* what makes the abort an EVENT rather than a flag polled after the fact.
|
|
132
|
-
*/
|
|
133
|
-
export type AbortView = {
|
|
134
|
-
aborted: boolean;
|
|
135
|
-
reason?: unknown;
|
|
136
|
-
addEventListener?(type: 'abort', listener: () => void): void;
|
|
137
|
-
removeEventListener?(type: 'abort', listener: () => void): void;
|
|
138
|
-
};
|
|
139
|
-
export type ChallengeContext = {
|
|
140
|
-
status: number;
|
|
141
|
-
/** The shipped callback shape, which is why one parser serves both surfaces. */
|
|
142
|
-
getHeader(name: string): string | null | undefined;
|
|
143
|
-
/**
|
|
144
|
-
* Reads the body. MUST be safe to call only in scope, and MUST NOT disturb the
|
|
145
|
-
* original payload — on the fetch surface that means `res.clone().json()`, so
|
|
146
|
-
* the response the caller receives still has `bodyUsed === false`. The core
|
|
147
|
-
* calls it only when the scope and the channel policy both permit.
|
|
148
|
-
*/
|
|
149
|
-
readBody(): Promise<unknown>;
|
|
150
|
-
/**
|
|
151
|
-
* The normalised, immutable snapshot of the request that was challenged —
|
|
152
|
-
* §13.4 revision 6's invariant, and the ONLY description of the request this
|
|
153
|
-
* function will look at.
|
|
154
|
-
*
|
|
155
|
-
* The adapter takes it once, before dispatch, and hands the same object to
|
|
156
|
-
* the scope check, this context, the diagnostics and `planReplay`. Nothing
|
|
157
|
-
* here re-reads the caller's `Request`, `RequestInit` or axios config, so a
|
|
158
|
-
* mutation while the prompt is open cannot change what was authorized, what
|
|
159
|
-
* was reported or what is replayed.
|
|
160
|
-
*/
|
|
161
|
-
request: RequestSnapshot;
|
|
162
|
-
/**
|
|
163
|
-
* Replays the ORIGINAL request, once, with the elevated credential. The
|
|
164
|
-
* adapter supplies it; the core decides whether and when it is called, and
|
|
165
|
-
* marks it replayed.
|
|
166
|
-
*/
|
|
167
|
-
replay(hints?: ReplayHints): Promise<ChallengeContext>;
|
|
168
|
-
/** Where the adapter stores the core's per-request markers. */
|
|
169
|
-
markers: {
|
|
170
|
-
upgradeTransaction?: true;
|
|
171
|
-
replayed?: true;
|
|
172
|
-
};
|
|
173
|
-
/**
|
|
174
|
-
* The adapter's native payload — a `Response`, an `AxiosResponse`, an
|
|
175
|
-
* `AxiosError`. The core never inspects it; it only hands it back so the
|
|
176
|
-
* adapter can return the real thing.
|
|
177
|
-
*/
|
|
178
|
-
raw?: unknown;
|
|
179
|
-
/** `false` when `planReplay` refused. The prompt is then never opened. */
|
|
180
|
-
replayable?: boolean;
|
|
181
|
-
/** Why the replay is unsupported, for the diagnostic. */
|
|
182
|
-
replayUnsupportedReason?: string;
|
|
183
|
-
/**
|
|
184
|
-
* The caller's abort state. The SDK never aborts it.
|
|
185
|
-
*
|
|
186
|
-
* Read as a LIVE view, never a snapshot, because the core reads it after
|
|
187
|
-
* awaiting the elevation. The two listener methods are optional and carry
|
|
188
|
-
* REQ-C12: with them the core races the abort against the pending proof, so
|
|
189
|
-
* the caller's own promise settles at abort time instead of waiting for a
|
|
190
|
-
* prompt it has walked away from; without them (a bare `{ aborted }` view)
|
|
191
|
-
* the core falls back to reading the flag once the elevation settles. The
|
|
192
|
-
* elevation itself is never cancelled either way — it is shared.
|
|
193
|
-
*/
|
|
194
|
-
signal?: AbortView;
|
|
195
|
-
/** `'cors'` distinguishes the one actionable `'no-channel'` variant. */
|
|
196
|
-
responseType?: string;
|
|
197
|
-
/**
|
|
198
|
-
* `true` when the adapter received this exchange as a REJECTION rather than
|
|
199
|
-
* as a response — axios' `validateStatus` contract, where every non-2xx
|
|
200
|
-
* rejects. `fetch` resolves a 401, so its adapter never sets it.
|
|
201
|
-
*
|
|
202
|
-
* The core classifies the exchange identically either way: this flag decides
|
|
203
|
-
* only how a `replayed` outcome is handed back, so a replay that failed on
|
|
204
|
-
* its own terms keeps failing on the surface's own convention instead of
|
|
205
|
-
* being resolved as a value.
|
|
206
|
-
*/
|
|
207
|
-
rejected?: boolean;
|
|
208
|
-
};
|
|
209
|
-
/**
|
|
210
|
-
* Every terminal outcome, as the settlement table defines them.
|
|
211
|
-
*
|
|
212
|
-
* The invariant: **every path settles.** There is no input that produces a
|
|
213
|
-
* pending promise.
|
|
214
|
-
*/
|
|
215
|
-
export type CoreOutcome =
|
|
216
|
-
/** Not a challenge. Pass the response through untouched. */
|
|
217
|
-
{
|
|
218
|
-
kind: 'not-a-challenge';
|
|
219
|
-
}
|
|
220
|
-
/** A challenge the SDK is not allowed to act on. Diagnostic only; no body was read. */
|
|
221
|
-
| {
|
|
222
|
-
kind: 'out-of-scope';
|
|
223
|
-
} | {
|
|
224
|
-
kind: 'replayed';
|
|
225
|
-
response: ChallengeContext;
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* The proof completed and the operation's replay was challenged again.
|
|
229
|
-
*
|
|
230
|
-
* `response` is the SECOND challenge response, which the fetch surface
|
|
231
|
-
* resolves and tags (§13.3) — so the decision "which response does the caller
|
|
232
|
-
* receive" stays here rather than becoming a per-adapter `??` chain. It is
|
|
233
|
-
* absent only on the re-entry path, where the adapter already holds the object
|
|
234
|
-
* it was handed.
|
|
235
|
-
*/
|
|
236
|
-
| {
|
|
237
|
-
kind: 'insufficient';
|
|
238
|
-
obtained: AssuranceBar;
|
|
239
|
-
required: AssuranceBar;
|
|
240
|
-
response?: ChallengeContext;
|
|
241
|
-
} | {
|
|
242
|
-
kind: 'cancelled';
|
|
243
|
-
} | {
|
|
244
|
-
kind: 'exhausted';
|
|
245
|
-
error: Error;
|
|
246
|
-
} | {
|
|
247
|
-
kind: 'unsatisfiable';
|
|
248
|
-
} | {
|
|
249
|
-
kind: 'unavailable';
|
|
250
|
-
} | {
|
|
251
|
-
kind: 'session-changed';
|
|
252
|
-
} | {
|
|
253
|
-
kind: 'transport-failure';
|
|
254
|
-
status?: number;
|
|
255
|
-
retryable: boolean;
|
|
256
|
-
error: Error;
|
|
257
|
-
} | {
|
|
258
|
-
kind: 'replay-unsupported';
|
|
259
|
-
} | {
|
|
260
|
-
kind: 'aborted';
|
|
261
|
-
reason: unknown;
|
|
262
|
-
};
|
|
263
|
-
/**
|
|
264
|
-
* The scope decision, identical for every surface, and made on the SNAPSHOT.
|
|
265
|
-
*
|
|
266
|
-
* Precedence, in one ordered rule: domain 1, then domain 2, then
|
|
267
|
-
* `shouldIntercept` as a narrowing-only hook. There is no allow-all opt-in — a
|
|
268
|
-
* developer who genuinely wants every origin lists every origin, which is a
|
|
269
|
-
* sentence they can read in a diff.
|
|
270
|
-
*
|
|
271
|
-
* It takes a `RequestSnapshot` and not a string by design (§13.4 revision 6): a
|
|
272
|
-
* string parameter is an invitation to decide authorization on an un-normalised
|
|
273
|
-
* value, which is exactly the defect this signature removes.
|
|
274
|
-
*/
|
|
275
|
-
export declare const isInterceptionScope: (request: RequestSnapshot, scope: InterceptionScope, shouldIntercept?: (url: string) => boolean) => boolean;
|
|
276
|
-
/**
|
|
277
|
-
* Detect → scope → elevate → replay once → classify. The one implementation.
|
|
278
|
-
*
|
|
279
|
-
* "Retry exactly once" is structural rather than counted: there is no path from
|
|
280
|
-
* the replay back to the elevation. On a surface that re-enters this function
|
|
281
|
-
* with the replayed request — axios does, because the replay goes back through
|
|
282
|
-
* `instance.request(config)` and hits the same response interceptor — the replay
|
|
283
|
-
* marker is read first and the response is classified without elevating. That
|
|
284
|
-
* guard is written here, once; the adapter only supplies the marker's storage.
|
|
285
|
-
*/
|
|
286
|
-
export declare const handleChallenge: (ctx: ChallengeContext, options: UpgradeInterceptorOptions) => Promise<CoreOutcome>;
|
|
287
|
-
/**
|
|
288
|
-
* The error class a non-fetch surface rejects with, or `undefined` when the
|
|
289
|
-
* outcome is not a rejection.
|
|
290
|
-
*
|
|
291
|
-
* axios' own contract, expressed in `validateStatus`, is that a non-2xx response
|
|
292
|
-
* REJECTS. Resolving a declined step-up there would invert the library's
|
|
293
|
-
* contract: every caller's post-`await` success path would run after the user
|
|
294
|
-
* clicked "Not now", and `await api.post('/transfer')` would resolve with only a
|
|
295
|
-
* status check the customer was never instructed to write standing between that
|
|
296
|
-
* and treating an unperformed elevated action as performed.
|
|
297
|
-
*
|
|
298
|
-
* Every class carries a literal `code` discriminant as well as being
|
|
299
|
-
* `instanceof`-checkable, and the `code` is the testable tag: it survives
|
|
300
|
-
* bundling, duplicate package copies and cross-realm boundaries.
|
|
301
|
-
*/
|
|
302
|
-
export declare const coreOutcomeToError: (outcome: CoreOutcome) => Error | undefined;
|
|
303
|
-
/**
|
|
304
|
-
* What an adapter must do with an outcome: hand back an object, or throw.
|
|
305
|
-
*
|
|
306
|
-
* Both surfaces settle from this, so §13.3's table has exactly one encoding in
|
|
307
|
-
* the codebase. An adapter that reached its own conclusion about which response
|
|
308
|
-
* a caller receives, or which error class, would be the per-surface drift the
|
|
309
|
-
* single core exists to prevent.
|
|
310
|
-
*/
|
|
311
|
-
export type Settlement<T> = {
|
|
312
|
-
settle: 'resolve';
|
|
313
|
-
value: T;
|
|
314
|
-
} | {
|
|
315
|
-
settle: 'reject';
|
|
316
|
-
error: unknown;
|
|
317
|
-
};
|
|
318
|
-
/**
|
|
319
|
-
* The fetch surface's settlement.
|
|
320
|
-
*
|
|
321
|
-
* `fetch` resolves on 401 and every caller is written as `if (!res.ok)`, so a
|
|
322
|
-
* declined step-up comes back as the original response — tagged, so it is
|
|
323
|
-
* discriminable — rather than as a rejection their code has never handled. The
|
|
324
|
-
* two exceptions are an abort (which throws the signal's reason, as `fetch`
|
|
325
|
-
* itself does) and the explicit `onCancel: 'reject'` opt-out.
|
|
326
|
-
*/
|
|
327
|
-
export declare const settleFetchOutcome: <T extends object>(outcome: CoreOutcome, original: T, options: UpgradeInterceptorOptions) => Settlement<T>;
|
|
328
|
-
/**
|
|
329
|
-
* The axios surface's settlement.
|
|
330
|
-
*
|
|
331
|
-
* axios' own contract, expressed in `validateStatus`, is that a non-2xx
|
|
332
|
-
* response rejects, so every non-success outcome rejects here — with the tagged
|
|
333
|
-
* error class for a step-up outcome, and with the transport's own error when
|
|
334
|
-
* the SDK did not act.
|
|
335
|
-
*/
|
|
336
|
-
export declare const settleAxiosOutcome: <T>(outcome: CoreOutcome, originalError: unknown) => Settlement<T>;
|
|
337
|
-
/**
|
|
338
|
-
* Tags the response an adapter is about to resolve with the outcome that
|
|
339
|
-
* produced it. The mapping is here, not in the adapter: choosing which set a
|
|
340
|
-
* `CoreOutcome` belongs to is a decision.
|
|
341
|
-
*/
|
|
342
|
-
export declare const tagUpgradeOutcome: <T extends object>(response: T, outcome: CoreOutcome) => T;
|
|
343
|
-
/** "You were challenged and you declined" — as opposed to "you were not authorised". */
|
|
344
|
-
export declare const isUpgradeCancelled: (response: object) => boolean;
|
|
345
|
-
export declare const isUpgradeExhausted: (response: object) => boolean;
|
|
346
|
-
export declare const isUpgradeInsufficient: (response: object) => boolean;
|
|
347
|
-
export declare const isUpgradeUnsatisfiable: (response: object) => boolean;
|
|
348
|
-
export declare const isUpgradeUnavailable: (response: object) => boolean;
|
|
349
|
-
export declare const isUpgradeSessionChanged: (response: object) => boolean;
|
|
350
|
-
/** FR1's non-retryable 400 class. */
|
|
351
|
-
export declare const isUpgradeTransportFailure: (response: object) => boolean;
|
|
352
|
-
export type { ChallengeChannel };
|
|
353
|
-
//# sourceMappingURL=core.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../lib/upgrade/core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,gBAAgB,EAErB,KAAK,gBAAgB,EAGrB,KAAK,qBAAqB,EAC3B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAgC,KAAK,gBAAgB,EAA6B,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3H,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;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CAAA;CAAE,CAAC;AAEnG;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,MAAM,WACxC,WAAW,YACV,CAAC,WACF,yBAAyB,KACjC,UAAU,CAAC,CAAC,CAuBd,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,WAAW,WAAW,iBAAiB,OAAO,KAAG,UAAU,CAAC,CAAC,CAmBhG,CAAC;AA+BF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,MAAM,YAAY,CAAC,WAAW,WAAW,KAAG,CA2BvF,CAAC;AAEF,wFAAwF;AACxF,eAAO,MAAM,kBAAkB,aAAc,MAAM,KAAG,OAAkC,CAAC;AACzF,eAAO,MAAM,kBAAkB,aAAc,MAAM,KAAG,OAAkC,CAAC;AACzF,eAAO,MAAM,qBAAqB,aAAc,MAAM,KAAG,OAAqC,CAAC;AAC/F,eAAO,MAAM,sBAAsB,aAAc,MAAM,KAAG,OAAsC,CAAC;AACjG,eAAO,MAAM,oBAAoB,aAAc,MAAM,KAAG,OAAoC,CAAC;AAC7F,eAAO,MAAM,uBAAuB,aAAc,MAAM,KAAG,OAAuC,CAAC;AACnG,qCAAqC;AACrC,eAAO,MAAM,yBAAyB,aAAc,MAAM,KAAG,OAAyC,CAAC;AAEvG,YAAY,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Upgrade transport error classification.
|
|
3
|
-
*
|
|
4
|
-
* The server speaks two languages about the same failure: an exact
|
|
5
|
-
* `PassflowError.id` and an HTTP status. The id is read FIRST and the status only
|
|
6
|
-
* as a fallback, because the id names the cause while the status is a bucket —
|
|
7
|
-
* `refreshErrorStatus` maps four unrelated upgrade errors onto one bare 401, and
|
|
8
|
-
* three of them want the prompt kept open while the fourth ends the elevation.
|
|
9
|
-
*
|
|
10
|
-
* This module is pure: it imports nothing and touches no transport. It
|
|
11
|
-
* duck-types whatever it is handed — a `PassflowError`, a raw `AxiosError`, or a
|
|
12
|
-
* bare object — so it can be tested with literals and reused from any surface.
|
|
13
|
-
*/
|
|
14
|
-
/** What kind of failure the server reported, in remedy terms rather than status terms. */
|
|
15
|
-
export type UpgradeErrorKind =
|
|
16
|
-
/** The user typed the wrong code. Retry with a FRESH prepare round; the modal stays open. */
|
|
17
|
-
'wrong_code'
|
|
18
|
-
/** Bad, expired, spent or foreign challenge. Same remedy as `wrong_code`. */
|
|
19
|
-
| 'challenge_spent'
|
|
20
|
-
/** The server's per-challenge attempt budget is burned. Stop; a fresh prepare will not help. */
|
|
21
|
-
| 'exhausted'
|
|
22
|
-
/**
|
|
23
|
-
* The CONTROLLER's local attempt budget is burned: the user has answered
|
|
24
|
-
* wrongly `maxAttempts` times and the elevation gives up.
|
|
25
|
-
*
|
|
26
|
-
* Terminal, and distinct from the four retryable kinds for one specific
|
|
27
|
-
* reason: the loop's last failure is usually a `wrong_code`, which IS
|
|
28
|
-
* retryable, and returning that error as the flight's outcome told every
|
|
29
|
-
* surface above "ask them again" for a flight that will never ask again — so
|
|
30
|
-
* the UI re-prompted forever against a budget the server had already closed.
|
|
31
|
-
* The budget being spent is the fact that must travel, not the last answer
|
|
32
|
-
* that spent it; the answer travels on `cause`.
|
|
33
|
-
*/
|
|
34
|
-
| 'attempts_exhausted'
|
|
35
|
-
/** This FACTOR is not enrolled for this user. Drop it for this flight, offer the others. */
|
|
36
|
-
| 'not_registered'
|
|
37
|
-
/** Our static `requiresPrepare` disagrees with the server. Recover by asserting directly. */
|
|
38
|
-
| 'prepare_not_required'
|
|
39
|
-
/** Unsupported factor, or no session at all. Not retryable; surface it, do not log the user out. */
|
|
40
|
-
| 'fatal'
|
|
41
|
-
/** The deployment cannot serve an upgrade at all (no challenge storage, or a BFF commit). */
|
|
42
|
-
| 'unavailable'
|
|
43
|
-
/** A malformed response from a server that claimed success. */
|
|
44
|
-
| 'protocol'
|
|
45
|
-
/** No response: the request never completed. */
|
|
46
|
-
| 'network'
|
|
47
|
-
/**
|
|
48
|
-
* A genuine session failure DURING the elevation — a commit 401 that is none of
|
|
49
|
-
* the four recoverable upgrade errors, so it is an expired or revoked refresh
|
|
50
|
-
* token rather than a bad answer. Terminates the elevation instead of
|
|
51
|
-
* re-prompting, and the transport invalidates the session itself.
|
|
52
|
-
*/
|
|
53
|
-
| 'session_changed';
|
|
54
|
-
/** Server error ids this module classifies. Verified against `src/l/messages_const.go`. */
|
|
55
|
-
export declare const UpgradeErrorIds: {
|
|
56
|
-
readonly twoFactorCodeInvalid: 'error.api.request.2fa_code.invalid';
|
|
57
|
-
readonly challengeInvalid: 'error.upgrade.challenge_invalid';
|
|
58
|
-
readonly challengeSessionMismatch: 'error.upgrade.challenge_session_mismatch';
|
|
59
|
-
readonly challengeTooManyAttempts: 'error.upgrade.challenge_too_many_attempts';
|
|
60
|
-
readonly unsupportedFactor: 'error.upgrade.unsupported_factor';
|
|
61
|
-
readonly noSession: 'error.upgrade.no_session';
|
|
62
|
-
readonly unavailable: 'error.upgrade.unavailable';
|
|
63
|
-
readonly methodNotRegistered: 'error.upgrade.method_not_registered';
|
|
64
|
-
readonly prepareNotRequired: 'error.upgrade.prepare_not_required';
|
|
65
|
-
readonly methodNotSupported: 'error.2fa.method_not_supported';
|
|
66
|
-
readonly twoFactorNotEnabled: 'error.2fa.not_enabled';
|
|
67
|
-
readonly notImplemented: 'error.not.implemented';
|
|
68
|
-
readonly tokenInvalid: 'error.api.request.token.invalid';
|
|
69
|
-
};
|
|
70
|
-
/**
|
|
71
|
-
* **Every** error `refreshErrorStatus` maps to a 401 on the commit path, as
|
|
72
|
-
* enumerated by `src/web/api/refresh_token.go:157-178`.
|
|
73
|
-
*
|
|
74
|
-
* All five are "recoverable" in the session sense: every one of them is the
|
|
75
|
-
* upgrade protocol talking, so none of them means the session died. Note that
|
|
76
|
-
* `challenge_too_many_attempts` is in here yet is NOT retryable — it ends the
|
|
77
|
-
* elevation while leaving the session intact. The two axes are independent and
|
|
78
|
-
* are deliberately not collapsed.
|
|
79
|
-
*
|
|
80
|
-
* `error.2fa.not_enabled` was missing from this list, which signed out a user
|
|
81
|
-
* who had no 2FA enrolled the moment an elevation reached the commit round —
|
|
82
|
-
* the exact lock-out PFL-497 exists to prevent. The set is kept complete for
|
|
83
|
-
* documentation and for callers, but the invalidation decision no longer rests
|
|
84
|
-
* on it: see `invalidatesSessionOnCommit`, which is the inverse predicate.
|
|
85
|
-
*/
|
|
86
|
-
export declare const RECOVERABLE_COMMIT_ERROR_IDS: readonly string[];
|
|
87
|
-
/**
|
|
88
|
-
* Error ids that positively mean the SESSION is gone, not merely the elevation.
|
|
89
|
-
*
|
|
90
|
-
* This is the predicate the transport invalidates on, and it is deliberately a
|
|
91
|
-
* POSITIVE list rather than the complement of the recoverable one. The server's
|
|
92
|
-
* 401 set on the commit path is enumerated and small, so a list of "ids that
|
|
93
|
-
* mean the session died" can be complete in a way that "everything else" never
|
|
94
|
-
* is; and when a future server adds a sixth 401 id, an allow-list of expiries
|
|
95
|
-
* fails toward "I don't know" rather than toward "log them out", which is this
|
|
96
|
-
* feature's governing rule. A client-side miss costs a stale session that the
|
|
97
|
-
* next ordinary 401 clears; a false positive costs the user their session in
|
|
98
|
-
* the middle of proving who they are.
|
|
99
|
-
*/
|
|
100
|
-
export declare const SESSION_INVALIDATING_COMMIT_ERROR_IDS: readonly string[];
|
|
101
|
-
/** True when a kind leaves the elevation alive. Single source for `retryable`. */
|
|
102
|
-
export declare const isRetryableUpgradeKind: (kind: UpgradeErrorKind) => boolean;
|
|
103
|
-
export type UpgradeTransportErrorInit = {
|
|
104
|
-
kind: UpgradeErrorKind;
|
|
105
|
-
message?: string;
|
|
106
|
-
status?: number;
|
|
107
|
-
/** The `PassflowError.id`, verbatim, when the server supplied one. */
|
|
108
|
-
errorId?: string;
|
|
109
|
-
cause?: unknown;
|
|
110
|
-
};
|
|
111
|
-
/** Which round of the transaction failed. The same status means different things on each. */
|
|
112
|
-
export type UpgradeEndpoint = 'start' | 'refresh';
|
|
113
|
-
/**
|
|
114
|
-
* A classified transport failure.
|
|
115
|
-
*
|
|
116
|
-
* `code` is the literal, bundling-proof discriminant every upgrade error class
|
|
117
|
-
* carries; the server's own id lives in `errorId`. (The design's §3.3 called the
|
|
118
|
-
* latter `code`, which §13.3 then claimed for the literal tag — `errorId` keeps
|
|
119
|
-
* both without one shadowing the other.)
|
|
120
|
-
*/
|
|
121
|
-
export declare class UpgradeTransportError extends Error {
|
|
122
|
-
readonly name = "UpgradeTransportError";
|
|
123
|
-
readonly code: 'upgrade_transport';
|
|
124
|
-
readonly kind: UpgradeErrorKind;
|
|
125
|
-
readonly status?: number;
|
|
126
|
-
readonly errorId?: string;
|
|
127
|
-
readonly retryable: boolean;
|
|
128
|
-
/** Declared here rather than inherited: `Error.cause` is ES2022 and this build targets ES2021 libs. */
|
|
129
|
-
readonly cause?: unknown;
|
|
130
|
-
constructor(init: UpgradeTransportErrorInit);
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Reports whether a value is one of the SDK's own upgrade error classes — an
|
|
134
|
-
* outcome that has already been decided, on any surface.
|
|
135
|
-
*
|
|
136
|
-
* Used where a lower layer must not re-bucket a settled outcome: classifying an
|
|
137
|
-
* `UpgradeSessionChangedError` as a bare network failure (which is what
|
|
138
|
-
* happened, because it carries no `response`) turned §13.3's `session changed
|
|
139
|
-
* mid-flight` row into `upgrade_transport` on all four adapters.
|
|
140
|
-
*/
|
|
141
|
-
export declare const isUpgradeSdkError: (e: unknown) => e is Error & {
|
|
142
|
-
code: string;
|
|
143
|
-
};
|
|
144
|
-
/** Reports whether a value is an already-classified transport failure. */
|
|
145
|
-
export declare const isUpgradeTransportError: (e: unknown) => e is UpgradeTransportError;
|
|
146
|
-
/**
|
|
147
|
-
* Classifies a rejection from either upgrade round into an `UpgradeTransportError`.
|
|
148
|
-
*
|
|
149
|
-
* Already-classified errors pass through unchanged, so a nested call cannot
|
|
150
|
-
* re-bucket a `prepare_not_required` into something terminal.
|
|
151
|
-
*/
|
|
152
|
-
export declare const classifyUpgradeError: (e: unknown, endpoint: UpgradeEndpoint) => UpgradeTransportError;
|
|
153
|
-
/**
|
|
154
|
-
* Reports whether a classified commit failure is a KNOWN upgrade-protocol error
|
|
155
|
-
* that leaves the session intact.
|
|
156
|
-
*
|
|
157
|
-
* Informational: it answers "is this one of the server's enumerated commit
|
|
158
|
-
* 401s". It is NOT the invalidation decision — `invalidatesSessionOnCommit` is,
|
|
159
|
-
* and an unrecognised id is not an expiry just because this list has not heard
|
|
160
|
-
* of it.
|
|
161
|
-
*/
|
|
162
|
-
export declare const isRecoverableCommitFailure: (error: UpgradeTransportError) => boolean;
|
|
163
|
-
/**
|
|
164
|
-
* Reports whether a classified commit failure means the SESSION has ended.
|
|
165
|
-
*
|
|
166
|
-
* The one predicate the transport invalidates on, and the inverse of what this
|
|
167
|
-
* module used to ask. `undefined` — no id at all — is explicitly NOT an expiry:
|
|
168
|
-
* a 401 the SDK cannot explain is "I don't know", and "I don't know" must never
|
|
169
|
-
* resolve to signing the user out mid-verification.
|
|
170
|
-
*/
|
|
171
|
-
export declare const invalidatesSessionOnCommit: (error: UpgradeTransportError) => boolean;
|
|
172
|
-
/** The bar a challenge demanded, or an elevation reached, on both axes. */
|
|
173
|
-
export type AssuranceBar = {
|
|
174
|
-
/** The raw winning `acr_values` list, for display and diagnostics. */
|
|
175
|
-
acrValues?: string;
|
|
176
|
-
/** The parsed bar. `undefined` = unknown, or not constrained on this axis. */
|
|
177
|
-
level?: number;
|
|
178
|
-
/** The freshness constraint, when that is what was demanded. */
|
|
179
|
-
maxAge?: number;
|
|
180
|
-
};
|
|
181
|
-
/**
|
|
182
|
-
* The elevation completed, and the protected operation's replay was challenged
|
|
183
|
-
* again: the proof was real but did not reach this operation's bar.
|
|
184
|
-
*
|
|
185
|
-
* This is the outcome that makes the AAL3-with-only-TOTP path honest. It is
|
|
186
|
-
* per-operation, never per-proof — a requestless `passflow.upgrade()` with no
|
|
187
|
-
* stated bar can never produce it, because it has nothing to replay.
|
|
188
|
-
*/
|
|
189
|
-
export declare class UpgradeInsufficientError extends Error {
|
|
190
|
-
readonly name = "UpgradeInsufficientError";
|
|
191
|
-
readonly code: 'upgrade_insufficient';
|
|
192
|
-
readonly obtained: AssuranceBar;
|
|
193
|
-
readonly required: AssuranceBar;
|
|
194
|
-
constructor(obtained: AssuranceBar, required: AssuranceBar, message?: string);
|
|
195
|
-
}
|
|
196
|
-
/** The deployment cannot serve an upgrade at all — no challenge storage, or a BFF commit. */
|
|
197
|
-
export declare class UpgradeUnavailableError extends Error {
|
|
198
|
-
readonly name = "UpgradeUnavailableError";
|
|
199
|
-
readonly code: 'upgrade_unavailable';
|
|
200
|
-
constructor(message?: string);
|
|
201
|
-
}
|
|
202
|
-
/** The session ended or changed while the elevation was running (§7.4). */
|
|
203
|
-
export declare class UpgradeSessionChangedError extends Error {
|
|
204
|
-
readonly name = "UpgradeSessionChangedError";
|
|
205
|
-
readonly code: 'upgrade_session_changed';
|
|
206
|
-
constructor(message?: string);
|
|
207
|
-
}
|
|
208
|
-
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../lib/upgrade/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,0FAA0F;AAC1F,MAAM,MAAM,gBAAgB;AAC1B,6FAA6F;AAC3F,YAAY;AACd,6EAA6E;GAC3E,iBAAiB;AACnB,gGAAgG;GAC9F,WAAW;AACb;;;;;;;;;;;GAWG;GACD,oBAAoB;AACtB,4FAA4F;GAC1F,gBAAgB;AAClB,6FAA6F;GAC3F,sBAAsB;AACxB,oGAAoG;GAClG,OAAO;AACT,6FAA6F;GAC3F,aAAa;AACf,+DAA+D;GAC7D,UAAU;AACZ,gDAAgD;GAC9C,SAAS;AACX;;;;;GAKG;GACD,iBAAiB,CAAC;AAEtB,2FAA2F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