@passflow/core 0.19.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.
Files changed (128) hide show
  1. package/dist/index.cjs +2 -2
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +5944 -0
  4. package/dist/index.d.ts +5944 -0
  5. package/dist/index.mjs +4618 -7244
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +38 -27
  8. package/dist/lib/api/app.d.ts +0 -11
  9. package/dist/lib/api/app.d.ts.map +0 -1
  10. package/dist/lib/api/auth.d.ts +0 -42
  11. package/dist/lib/api/auth.d.ts.map +0 -1
  12. package/dist/lib/api/axios-client.d.ts +0 -109
  13. package/dist/lib/api/axios-client.d.ts.map +0 -1
  14. package/dist/lib/api/cli-auth.d.ts +0 -12
  15. package/dist/lib/api/cli-auth.d.ts.map +0 -1
  16. package/dist/lib/api/index.d.ts +0 -11
  17. package/dist/lib/api/index.d.ts.map +0 -1
  18. package/dist/lib/api/invitation.d.ts +0 -80
  19. package/dist/lib/api/invitation.d.ts.map +0 -1
  20. package/dist/lib/api/model.d.ts +0 -844
  21. package/dist/lib/api/model.d.ts.map +0 -1
  22. package/dist/lib/api/setting.d.ts +0 -13
  23. package/dist/lib/api/setting.d.ts.map +0 -1
  24. package/dist/lib/api/tenant.d.ts +0 -216
  25. package/dist/lib/api/tenant.d.ts.map +0 -1
  26. package/dist/lib/api/two-factor.d.ts +0 -137
  27. package/dist/lib/api/two-factor.d.ts.map +0 -1
  28. package/dist/lib/api/upgrade.d.ts +0 -39
  29. package/dist/lib/api/upgrade.d.ts.map +0 -1
  30. package/dist/lib/api/user.d.ts +0 -22
  31. package/dist/lib/api/user.d.ts.map +0 -1
  32. package/dist/lib/constants/index.d.ts +0 -33
  33. package/dist/lib/constants/index.d.ts.map +0 -1
  34. package/dist/lib/device/index.d.ts +0 -17
  35. package/dist/lib/device/index.d.ts.map +0 -1
  36. package/dist/lib/index.d.ts +0 -23
  37. package/dist/lib/index.d.ts.map +0 -1
  38. package/dist/lib/interceptors/fetch-registry.d.ts +0 -96
  39. package/dist/lib/interceptors/fetch-registry.d.ts.map +0 -1
  40. package/dist/lib/m2m/client.d.ts +0 -196
  41. package/dist/lib/m2m/client.d.ts.map +0 -1
  42. package/dist/lib/m2m/errors.d.ts +0 -107
  43. package/dist/lib/m2m/errors.d.ts.map +0 -1
  44. package/dist/lib/m2m/index.d.ts +0 -27
  45. package/dist/lib/m2m/index.d.ts.map +0 -1
  46. package/dist/lib/m2m/types.d.ts +0 -217
  47. package/dist/lib/m2m/types.d.ts.map +0 -1
  48. package/dist/lib/passflow.d.ts +0 -1224
  49. package/dist/lib/passflow.d.ts.map +0 -1
  50. package/dist/lib/pkce.d.ts +0 -13
  51. package/dist/lib/pkce.d.ts.map +0 -1
  52. package/dist/lib/platform/index.d.ts +0 -4
  53. package/dist/lib/platform/index.d.ts.map +0 -1
  54. package/dist/lib/platform/types.d.ts +0 -206
  55. package/dist/lib/platform/types.d.ts.map +0 -1
  56. package/dist/lib/platform/web-adapter.d.ts +0 -104
  57. package/dist/lib/platform/web-adapter.d.ts.map +0 -1
  58. package/dist/lib/services/auth-service.d.ts +0 -197
  59. package/dist/lib/services/auth-service.d.ts.map +0 -1
  60. package/dist/lib/services/index.d.ts +0 -8
  61. package/dist/lib/services/index.d.ts.map +0 -1
  62. package/dist/lib/services/invitation-service.d.ts +0 -44
  63. package/dist/lib/services/invitation-service.d.ts.map +0 -1
  64. package/dist/lib/services/logger.d.ts +0 -24
  65. package/dist/lib/services/logger.d.ts.map +0 -1
  66. package/dist/lib/services/tenant-service.d.ts +0 -200
  67. package/dist/lib/services/tenant-service.d.ts.map +0 -1
  68. package/dist/lib/services/tenant-user-membership.d.ts +0 -76
  69. package/dist/lib/services/tenant-user-membership.d.ts.map +0 -1
  70. package/dist/lib/services/token-cache-service.d.ts +0 -36
  71. package/dist/lib/services/token-cache-service.d.ts.map +0 -1
  72. package/dist/lib/services/two-factor-service.d.ts +0 -193
  73. package/dist/lib/services/two-factor-service.d.ts.map +0 -1
  74. package/dist/lib/services/user-service.d.ts +0 -41
  75. package/dist/lib/services/user-service.d.ts.map +0 -1
  76. package/dist/lib/storage/index.d.ts +0 -106
  77. package/dist/lib/storage/index.d.ts.map +0 -1
  78. package/dist/lib/store.d.ts +0 -175
  79. package/dist/lib/store.d.ts.map +0 -1
  80. package/dist/lib/token/delivery-manager.d.ts +0 -121
  81. package/dist/lib/token/delivery-manager.d.ts.map +0 -1
  82. package/dist/lib/token/index.d.ts +0 -4
  83. package/dist/lib/token/index.d.ts.map +0 -1
  84. package/dist/lib/token/membership.d.ts +0 -37
  85. package/dist/lib/token/membership.d.ts.map +0 -1
  86. package/dist/lib/token/service.d.ts +0 -47
  87. package/dist/lib/token/service.d.ts.map +0 -1
  88. package/dist/lib/token/token.d.ts +0 -55
  89. package/dist/lib/token/token.d.ts.map +0 -1
  90. package/dist/lib/types/index.d.ts +0 -24
  91. package/dist/lib/types/index.d.ts.map +0 -1
  92. package/dist/lib/upgrade/acr.d.ts +0 -85
  93. package/dist/lib/upgrade/acr.d.ts.map +0 -1
  94. package/dist/lib/upgrade/axios-adapter.d.ts +0 -81
  95. package/dist/lib/upgrade/axios-adapter.d.ts.map +0 -1
  96. package/dist/lib/upgrade/challenge.d.ts +0 -217
  97. package/dist/lib/upgrade/challenge.d.ts.map +0 -1
  98. package/dist/lib/upgrade/client.d.ts +0 -29
  99. package/dist/lib/upgrade/client.d.ts.map +0 -1
  100. package/dist/lib/upgrade/controller.d.ts +0 -435
  101. package/dist/lib/upgrade/controller.d.ts.map +0 -1
  102. package/dist/lib/upgrade/core.d.ts +0 -353
  103. package/dist/lib/upgrade/core.d.ts.map +0 -1
  104. package/dist/lib/upgrade/errors.d.ts +0 -208
  105. package/dist/lib/upgrade/errors.d.ts.map +0 -1
  106. package/dist/lib/upgrade/facade.d.ts +0 -188
  107. package/dist/lib/upgrade/facade.d.ts.map +0 -1
  108. package/dist/lib/upgrade/factors.d.ts +0 -97
  109. package/dist/lib/upgrade/factors.d.ts.map +0 -1
  110. package/dist/lib/upgrade/fetch-adapter.d.ts +0 -30
  111. package/dist/lib/upgrade/fetch-adapter.d.ts.map +0 -1
  112. package/dist/lib/upgrade/index.d.ts +0 -20
  113. package/dist/lib/upgrade/index.d.ts.map +0 -1
  114. package/dist/lib/upgrade/markers.d.ts +0 -64
  115. package/dist/lib/upgrade/markers.d.ts.map +0 -1
  116. package/dist/lib/upgrade/replay.d.ts +0 -132
  117. package/dist/lib/upgrade/replay.d.ts.map +0 -1
  118. package/dist/lib/upgrade/select.d.ts +0 -48
  119. package/dist/lib/upgrade/select.d.ts.map +0 -1
  120. package/dist/lib/upgrade/session.d.ts +0 -72
  121. package/dist/lib/upgrade/session.d.ts.map +0 -1
  122. package/dist/lib/upgrade/snapshot.d.ts +0 -196
  123. package/dist/lib/upgrade/snapshot.d.ts.map +0 -1
  124. package/dist/lib/upgrade/transport.d.ts +0 -69
  125. package/dist/lib/upgrade/transport.d.ts.map +0 -1
  126. package/dist/lib/utils/validation.d.ts +0 -54
  127. package/dist/lib/utils/validation.d.ts.map +0 -1
  128. package/dist/tsconfig.build.tsbuildinfo +0 -1
@@ -1,188 +0,0 @@
1
- /**
2
- * The Facade: one object that assembles the controller, the transport and the
3
- * adapters, and the only construction surface a consumer touches.
4
- *
5
- * `UpgradeController`, the transport, `upgradeFetch` and the fetch registry stay
6
- * internal. Tests reach their types by importing this directory's modules
7
- * directly, not through the package entry, because a type on `lib/index.ts` is
8
- * a supported name whether or not anything public produces a value of it.
9
- * `UpgradeFacadeDeps` is declared here and exported for that in-tree use only.
10
- * `UpgradeSessionPin`, declared in `./session`, is the exception: it IS on the
11
- * entry, because `AuthService.readSessionPin()` is public and returns one.
12
- *
13
- * **Five members, and the rule is written down because `structural.md` names
14
- * Facade-as-God-Object as this family's characteristic failure: adding a sixth
15
- * requires deleting one.** `createClient` is deliberately NOT a member — it is
16
- * `axios.create(config)` followed by `attachAuth`, so it lives on the `Passflow`
17
- * instance where the constructor belongs, and it is not a fourth code path.
18
- *
19
- * ## The two gates
20
- *
21
- * Passflow's own API (domain 1) is derived from `PassflowConfig.url` and handled
22
- * with zero configuration. The customer's backend (domain 2) is touched only
23
- * when `backend` is declared AND an adapter is attached: declaring without
24
- * attaching observes nothing, attaching without declaring matches nothing
25
- * beyond domain 1. That double gate is why the elevated-credential replay
26
- * surface is unreachable in the default configuration — there is no default
27
- * interception surface at all.
28
- *
29
- * ## The session-change reset
30
- *
31
- * A challenge is server-bound to the session's `sid`, and an abandoned flight
32
- * must never elevate a NEW session. `UpgradeController.inFlight` is private with
33
- * no reset, so on `SignIn` / `SignOut` the controller is DISCARDED and a fresh
34
- * one constructed. A waiter whose elevation was running across that boundary is
35
- * settled with `UpgradeSessionChangedError` — never replayed — which §13.3's
36
- * table maps to the original response on fetch and a tagged rejection on axios.
37
- *
38
- * SSR-safe: no global is read at module scope, and nothing is installed until
39
- * `enable()` is called with `interceptFetch`.
40
- */
41
- import type { PlatformAdapter } from '../platform';
42
- import { type AxiosReissue, type ResponseInterceptorHost } from './axios-adapter';
43
- import type { AssuranceBar, UpgradeChallenge, UpgradeDiagnosticSink } from './challenge';
44
- import { type UpgradeElevation, type UpgradeFlightSummary, type UpgradePromptHandler, type Waiter } from './controller';
45
- import type { UpgradeFactor } from './factors';
46
- import type { FetchLike, ReplayPolicy } from './replay';
47
- import type { UpgradeSessionPin } from './session';
48
- import { type UpgradeTransportDeps } from './transport';
49
- /** Domain 1, as resolved once from `PassflowConfig.url`. `null` = unresolved. */
50
- export type PassflowUpgradeDomain = {
51
- origin: string;
52
- pathPrefix?: string;
53
- } | null;
54
- /**
55
- * What the facade needs from its host, as narrow function-shaped dependencies.
56
- *
57
- * Everything HTTP arrives pre-wired, which is what keeps this module free of
58
- * endpoints and of any opinion about delivery mode.
59
- */
60
- export type UpgradeFacadeDeps = UpgradeTransportDeps & {
61
- /** The platform adapter, for the WebAuthn ceremony. */
62
- platform: PlatformAdapter;
63
- /** Domain 1. Resolved by the host from `url`; the facade never derives it. */
64
- passflowDomain: PassflowUpgradeDomain;
65
- /** Construction-time factor override, from `PassflowConfig.upgrade`. */
66
- factors?: readonly UpgradeFactor[];
67
- /** The bar the elevation reached, read from the freshly stored access token. */
68
- readObtainedBar?: () => AssuranceBar | undefined;
69
- /** §5.5's credential swap. Snapshotted before the elevation, read again after. */
70
- authorizationSwap?: () => {
71
- from: string;
72
- to: string;
73
- } | undefined;
74
- /**
75
- * Installs (or clears, on `undefined`) the handler the SDK's OWN axios clients
76
- * consult inside their existing error interceptor — §4.4's internal seam,
77
- * which an ordinary customer-registered interceptor is structurally too late
78
- * to be.
79
- *
80
- * It receives a FACTORY rather than a handler because each of the SDK's
81
- * clients must replay through its own instance: a handler built around one
82
- * client's `request` would re-issue another client's request on the wrong
83
- * instance.
84
- */
85
- attachInternalSeam?: (factory: ((reissue: AxiosReissue) => (error: unknown) => Promise<unknown>) | undefined) => void;
86
- /** Subscribes to session changes (`SignIn` / `SignOut`). Returns unsubscribe. */
87
- onSessionChange?: (listener: () => void) => () => void;
88
- /**
89
- * The session and user identity the host can currently read, or `undefined`
90
- * when this delivery mode exposes none.
91
- *
92
- * Read ONCE per flight, when the flight starts, and handed to `commitRefresh`
93
- * so the token-applying path can refuse to write user A's tokens into user
94
- * B's session (§13.4 revision 6 / H2).
95
- */
96
- readSessionPin?: () => UpgradeSessionPin | undefined;
97
- };
98
- /**
99
- * Everything `enable()` accepts: the prompt, the interception scope and the
100
- * interception policy.
101
- *
102
- * `requireChallengeChannel`, `backend` and `shouldIntercept` are interception
103
- * policy and deliberately NOT on `PassflowConfig` — they are per-installation,
104
- * not client-wide.
105
- */
106
- export type UpgradeEnableOptions = {
107
- /** REQUIRED. The js-sdk ships no UI. */
108
- prompt: UpgradePromptHandler;
109
- /**
110
- * Where the customer's own API is: an origin, an origin with a path prefix, or
111
- * a same-origin path prefix (`'/api'`). Nothing outside this and domain 1 is
112
- * ever observed, and there is no allow-all opt-in — a developer who wants
113
- * every origin lists every origin, which is a sentence they can read in a diff.
114
- */
115
- backend?: string | string[];
116
- /**
117
- * Patches `globalThis.fetch` through the registry, at the upgrade priority.
118
- * **Off by default**, and a different decision from enabling the UI: one prop
119
- * for both would bundle "show me the 2FA prompt" with "patch the global", and
120
- * only the second has the blast radius. It widens which call sites are
121
- * observed, never the scope.
122
- */
123
- interceptFetch?: boolean;
124
- /** Requires the standards channel. The body is then never read. */
125
- requireChallengeChannel?: 'header';
126
- /** NARROWING ONLY: `false` excludes an admitted URL; `true` cannot widen. */
127
- shouldIntercept?: (url: string) => boolean;
128
- replay?: ReplayPolicy;
129
- /** The fetch surface's only option. Default `'resolve-original'`. */
130
- onCancel?: 'resolve-original' | 'reject';
131
- onUpgradeDiagnostic?: UpgradeDiagnosticSink;
132
- factors?: readonly UpgradeFactor[];
133
- maxAttempts?: number;
134
- /** One terminal state per flight, after every waiter has reported. */
135
- onFlightSettled?: (summary: UpgradeFlightSummary) => void;
136
- /** Forwarded verbatim to the prepare round for passkey upgrades. */
137
- relyingPartyId?: string;
138
- };
139
- /** What the imperative seam resolves with (§13.4). */
140
- export type UpgradeResult = {
141
- status: 'elevated';
142
- acr?: string;
143
- };
144
- /**
145
- * What the imperative seam accepts: a bar the CALLER states.
146
- *
147
- * Stating one is what makes `UpgradeInsufficientError` reachable on this
148
- * surface; an options-less call states no bar, has no protected operation to
149
- * replay, and resolves `{ status: 'elevated' }` (§13.3's `n/a` cell).
150
- */
151
- export type UpgradeOptions = {
152
- acrValues?: string;
153
- maxAge?: number;
154
- };
155
- export type UpgradeFacade = {
156
- /**
157
- * Drives an elevation directly — §13.4's imperative seam.
158
- *
159
- * The facade is CALLABLE, which is why this signature is here rather than on
160
- * a method: the documented surface is `passflow.upgrade(options?)`, and the
161
- * same object also carries `enable`, `withAuth` and the rest. Resolves on
162
- * proof completion; rejects `UpgradeCancelledError`,
163
- * `UpgradeUnsatisfiableError`, `UpgradeUnavailableError`,
164
- * `UpgradeSessionChangedError`, `UpgradeTransportError` — and, when the
165
- * caller stated a bar the proof did not reach, `UpgradeInsufficientError`.
166
- */
167
- (options?: UpgradeOptions): Promise<UpgradeResult>;
168
- /**
169
- * Installs the prompt handler and the selected interceptors. Returns an
170
- * idempotent teardown. Calling `enable()` twice replaces the previous
171
- * installation and tears the first one down.
172
- */
173
- enable(options: UpgradeEnableOptions): () => void;
174
- /** True when a prompt handler is installed AND the delivery mode can commit. */
175
- readonly enabled: boolean;
176
- /**
177
- * Drives an elevation directly — headless clients, a "verify now" button,
178
- * tests. Single-flight with the interceptors: concurrent callers share one
179
- * prompt, because they share one controller.
180
- */
181
- elevate(challenge: UpgradeChallenge, waiter?: Waiter): Promise<UpgradeElevation>;
182
- /** Wraps a fetch and returns the wrapper. Touches no global. */
183
- withAuth(next?: FetchLike): FetchLike;
184
- /** Attaches to an axios instance the developer owns, MUTATING it. Returns `detach()`. */
185
- attachAuth(instance: ResponseInterceptorHost): () => void;
186
- };
187
- export declare const createUpgradeFacade: (deps: UpgradeFacadeDeps) => UpgradeFacade;
188
- //# sourceMappingURL=facade.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"facade.d.ts","sourceRoot":"","sources":["../../../lib/upgrade/facade.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGnD,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,uBAAuB,EAAgD,MAAM,iBAAiB,CAAC;AAChI,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACzF,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EAEzB,KAAK,MAAM,EACZ,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAA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OAAO,CAAC,gBAAgB,CAAC,CAAC;IACjF,gEAAgE;IAChE,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IACtC,yFAAyF;IACzF,UAAU,CAAC,QAAQ,EAAE,uBAAuB,GAAG,MAAM,IAAI,CAAC;CAC3D,CAAC;AAwBF,eAAO,MAAM,mBAAmB,GAAI,MAAM,iBAAiB,KAAG,aA6R7D,CAAC"}
@@ -1,97 +0,0 @@
1
- /**
2
- * Upgrade factor abstraction.
3
- *
4
- * A factor knows two things: whether proving it needs a server round-trip
5
- * first, and how to turn whatever the user did into the `upgrade.assertion`
6
- * blob `POST /auth/refresh` expects.
7
- *
8
- * `requiresPrepare` is declared statically rather than discovered by trying.
9
- * The server actively REJECTS a prepare call for one-shot factors
10
- * (`ErrorUpgradePrepareNotRequired`), so "call /begin and see what happens"
11
- * costs a guaranteed round-trip and a 400 on every TOTP upgrade.
12
- */
13
- import type { AuthenticationResponseJSON, PublicKeyCredentialRequestOptionsJSON } from '@simplewebauthn/types';
14
- import type { PlatformAdapter } from '../platform';
15
- /** Factor types the upgrade protocol understands, named as `upgrade.type` on the wire. */
16
- export type UpgradeFactorType = 'totp' | 'recovery_codes' | 'passkey' | 'email_otp' | 'sms_otp';
17
- /** The prepare round's result — `POST /auth/upgrade/begin`, normalised to camelCase. */
18
- export type UpgradePrepared = {
19
- challengeId: string;
20
- method: string;
21
- /** RFC 3339. The server gives a challenge five minutes; treat it as a hard deadline. */
22
- expiresAt: string;
23
- /** WebAuthn assertion options, present only for a passkey upgrade. */
24
- webauthn?: PublicKeyCredentialRequestOptionsJSON;
25
- /** Masked delivery target (`j***@x.com`), present only for email / SMS OTP. */
26
- codeSentTo?: string;
27
- };
28
- /**
29
- * The `upgrade.assertion` payload. Deliberately an open record: the server
30
- * types this field as `json.RawMessage` so new factors can extend the shape
31
- * without a wire-format change.
32
- */
33
- export type UpgradeAssertion = {
34
- challenge_id?: string;
35
- code?: string;
36
- credential?: AuthenticationResponseJSON;
37
- };
38
- /** What a factor needs from the UI before it can be asserted. */
39
- export type UpgradeFactorInput =
40
- /** A user-typed value: an OTP or a recovery code. */
41
- 'code'
42
- /** Nothing typed — the ceremony itself collects the proof (a passkey prompt). */
43
- | 'none';
44
- export type UpgradeAssertContext = {
45
- /** The value the user typed, for factors whose `input` is `'code'`. */
46
- code?: string;
47
- /** The prepare round's result, for factors where `requiresPrepare` is true. */
48
- prepared?: UpgradePrepared;
49
- /** Platform seam for the WebAuthn ceremony — keeps non-web adapters working. */
50
- platform: PlatformAdapter;
51
- };
52
- export type UpgradeFactor = {
53
- type: UpgradeFactorType;
54
- /** Whether `POST /auth/upgrade/begin` must run before the user can produce proof. */
55
- requiresPrepare: boolean;
56
- /** What the UI must collect before `assert` can run. */
57
- input: UpgradeFactorInput;
58
- /** Turns the user's response into the assertion blob sent as `upgrade.assertion`. */
59
- assert(ctx: UpgradeAssertContext): Promise<UpgradeAssertion>;
60
- };
61
- /** Thrown when a factor cannot produce proof — a cancelled prompt, or missing prerequisites. */
62
- export declare class UpgradeFactorError extends Error {
63
- readonly factor: UpgradeFactorType;
64
- /** True when the user dismissed the ceremony rather than failing it. */
65
- readonly cancelled: boolean;
66
- constructor(factor: UpgradeFactorType, message: string, cancelled?: boolean);
67
- }
68
- /**
69
- * TOTP — the canonical one-shot factor. The code is derived from a shared
70
- * secret and the clock, so nothing needs to be fetched first.
71
- */
72
- export declare const totpFactor: UpgradeFactor;
73
- /**
74
- * Recovery codes — also one-shot. Verified against the user's stored code set,
75
- * so like TOTP there is no challenge to issue.
76
- */
77
- export declare const recoveryCodesFactor: UpgradeFactor;
78
- /**
79
- * Passkey — the challenge-response factor. The prepare round supplies the
80
- * server nonce and, critically, an `allowCredentials` list scoped to the
81
- * signed-in user; the ceremony signs it and the assertion goes back with the
82
- * challenge id that binds it to this session.
83
- */
84
- export declare const passkeyFactor: UpgradeFactor;
85
- /**
86
- * The factors this SDK can actually complete.
87
- *
88
- * `email_otp` and `sms_otp` are intentionally ABSENT. The server routes them
89
- * (`upgradePrepareMethod` accepts both) but has no OTP transport, so no user can
90
- * enrol them and `upgradeMethodRegistered` refuses the prepare round. Adding
91
- * them later is one entry here plus a factor whose assert returns
92
- * `{ challenge_id, code }` — no change to anything that consumes this registry.
93
- */
94
- export declare const DEFAULT_UPGRADE_FACTORS: readonly UpgradeFactor[];
95
- /** Indexes a factor list by type for lookup during a challenge. */
96
- export declare const factorRegistry: (factors?: readonly UpgradeFactor[]) => Map<UpgradeFactorType, UpgradeFactor>;
97
- //# sourceMappingURL=factors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"factors.d.ts","sourceRoot":"","sources":["../../../lib/upgrade/factors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,0BAA0B,EAAE,qCAAqC,EAAE,MAAM,uBAAuB,CAAC;AAC/G,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,0FAA0F;AAC1F,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,gBAAgB,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,CAAC;AAEhG,wFAAwF;AACxF,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,wFAAwF;IACxF,SAAS,EAAE,MAAM,CAAC;IAClB,sEAAsE;IACtE,QAAQ,CAAC,EAAE,qCAAqC,CAAC;IACjD,+EAA+E;IAC/E,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,0BAA0B,CAAC;CACzC,CAAC;AAEF,iEAAiE;AACjE,MAAM,MAAM,kBAAkB;AAC5B,qDAAqD;AACnD,MAAM;AACR,iFAAiF;GAC/E,MAAM,CAAC;AAEX,MAAM,MAAM,oBAAoB,GAAG;IACjC,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,gFAAgF;IAChF,QAAQ,EAAE,eAAe,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,iBAAiB,CAAC;IACxB,qFAAqF;IACrF,eAAe,EAAE,OAAO,CAAC;IACzB,wDAAwD;IACxD,KAAK,EAAE,kBAAkB,CAAC;IAC1B,qFAAqF;IACrF,MAAM,CAAC,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC9D,CAAC;AAEF,gGAAgG;AAChG,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,wEAAwE;IACxE,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;gBAEhB,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,UAAQ;CAM1E;AAWD;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,aAKxB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,aAKjC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,EAAE,aAgC3B,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,EAAE,SAAS,aAAa,EAI1D,CAAC;AAEH,mEAAmE;AACnE,eAAO,MAAM,cAAc,GACzB,UAAS,SAAS,aAAa,EAA4B,KAC1D,GAAG,CAAC,iBAAiB,EAAE,aAAa,CAA6C,CAAC"}
@@ -1,30 +0,0 @@
1
- /**
2
- * The FETCH adapter over `handleChallenge`. One of four, and the thinnest.
3
- *
4
- * **NO LOGIC IN AN ADAPTER.** Everything here is translation: a `Response`
5
- * becomes a `ChallengeContext` on the way in, and a `CoreOutcome` becomes a
6
- * `Response` (or a throw) on the way out, through `settleFetchOutcome`. It
7
- * parses no challenge, compares no bar, decides no scope, counts no retry and
8
- * chooses no error class. If something in this file ever looks like a decision,
9
- * it belongs in `core.ts` instead — a row that passes here and fails on the
10
- * axios surface is a leak out of the core, not a difference between transports.
11
- *
12
- * The one genuinely transport-shaped obligation it carries is the body: a
13
- * replay needs the request body while it is still unread, so `planReplay` runs
14
- * BEFORE the first call and the core is told whether a replay is even possible
15
- * before any prompt opens. The caller's own response is never consumed — every
16
- * body read is taken from `clone()`, so `bodyUsed === false` holds on the object
17
- * the caller receives.
18
- *
19
- * SSR-safe: no global is read at module scope. `withAuth()`'s default `next` is
20
- * resolved inside the call, not here.
21
- */
22
- import { type UpgradeInterceptorOptionsSource } from './core';
23
- import { type FetchLike } from './replay';
24
- /**
25
- * Wraps a `fetch`, returning a new function. Installs nothing and touches no
26
- * global — this is the SSR- and React-Native-safe entry point, and the one the
27
- * global patch itself is built from.
28
- */
29
- export declare const upgradeFetch: (next: FetchLike, source: UpgradeInterceptorOptionsSource) => FetchLike;
30
- //# sourceMappingURL=fetch-adapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetch-adapter.d.ts","sourceRoot":"","sources":["../../../lib/upgrade/fetch-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAGL,KAAK,+BAA+B,EAIrC,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,KAAK,SAAS,EAAiD,MAAM,UAAU,CAAC;AA2HzF;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,SAAS,EAAE,QAAQ,+BAA+B,KAAG,SA2CvF,CAAC"}
@@ -1,20 +0,0 @@
1
- export { INSUFFICIENT_USER_AUTHENTICATION, UPGRADE_REQUIRED, parseChallengeBody, parseChallengeHeader, parseUpgradeChallenge, type UpgradeChallenge, } from './challenge';
2
- export { DEFAULT_UPGRADE_FACTORS, factorRegistry, passkeyFactor, recoveryCodesFactor, UpgradeFactorError, totpFactor, type UpgradeAssertion, type UpgradeAssertContext, type UpgradeFactor, type UpgradeFactorInput, type UpgradeFactorType, type UpgradePrepared, } from './factors';
3
- export { UpgradeCancelledError, UpgradeController, UpgradeUnsatisfiableError, type UpgradeControllerOptions, type UpgradePromptHandler, type UpgradePromptRequest, type UpgradePromptResult, type UpgradeTransport, } from './controller';
4
- export { RECOVERABLE_COMMIT_ERROR_IDS, SESSION_INVALIDATING_COMMIT_ERROR_IDS, UpgradeErrorIds, UpgradeTransportError, classifyUpgradeError, invalidatesSessionOnCommit, isRecoverableCommitFailure, isRetryableUpgradeKind, isUpgradeTransportError, type UpgradeEndpoint, type UpgradeErrorKind, type UpgradeTransportErrorInit, } from './errors';
5
- export { UPGRADE_REPLAYED_MARKER, UPGRADE_TRANSACTION_MARKER, hasUpgradeReplayedMarker, hasUpgradeTransactionMarker, markUpgradeReplayed, markUpgradeTransaction, type UpgradeRequestMarkers, } from './markers';
6
- export { selectFactors } from './select';
7
- export { RELATIVE_BASE, captureHeaders, createRequestSnapshot, headersToObject, normaliseUrl, snapshotHeader, swapAuthorization, type NormalisedUrl, type RequestSnapshot, type RequestSnapshotInit, type SnapshotHeader, } from './snapshot';
8
- export { readSessionPin, sessionPinMatches, type UpgradeSessionClaims, type UpgradeSessionPin, } from './session';
9
- export { createUpgradeTransport, toPrepared, type UpgradeTransportDeps } from './transport';
10
- export { parseAcrToken, readAcrValues, requiredAcrLevel, type AcrReading } from './acr';
11
- export { parseMaxAge, readUpgradeChallenge, type AssuranceBar, type ChallengeChannel, type ChallengeInput, type ChallengeReadOptions, type ChallengeReading, type MaxAgeReading, type UpgradeDiagnostic, type UpgradeDiagnosticReason, type UpgradeDiagnosticSink, } from './challenge';
12
- export { barMeets, barOf, mergeChallenges, type UpgradeElevation, type UpgradeFlightState, type UpgradeFlightSummary, type UpgradeProof, type UpgradeWaiterSummary, type Waiter, type WaiterEntry, type WaiterOutcome, type WaiterReport, } from './controller';
13
- export { UpgradeInsufficientError, UpgradeSessionChangedError, UpgradeUnavailableError, } from './errors';
14
- export { coreOutcomeToError, handleChallenge, isInterceptionScope, isUpgradeCancelled, isUpgradeExhausted, isUpgradeInsufficient, isUpgradeSessionChanged, isUpgradeTransportFailure, isUpgradeUnavailable, isUpgradeUnsatisfiable, settleAxiosOutcome, settleFetchOutcome, tagUpgradeOutcome, type ChallengeContext, type CoreOutcome, type InterceptionScope, type Settlement, type UpgradeInterceptorOptions, } from './core';
15
- export { methodOf, planReplay, policyPermits, urlOf, type BodyKind, type FetchLike, type ReplayHints, type ReplayPlan, type ReplayPolicy, type UpgradeReplayInfo, } from './replay';
16
- export { attachUpgradeAuth, createAxiosUpgradeHandler, type AxiosConfigLike, type AxiosReissue, type ResponseInterceptorHost, } from './axios-adapter';
17
- export { upgradeFetch } from './fetch-adapter';
18
- export { createUpgradeClient, type CreateClientConfig } from './client';
19
- export { createUpgradeFacade, type PassflowUpgradeDomain, type UpgradeEnableOptions, type UpgradeFacade, type UpgradeFacadeDeps, type UpgradeOptions, type UpgradeResult, } from './facade';
20
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/upgrade/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gCAAgC,EAChC,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,KAAK,gBAAgB,GACtB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,UAAU,EACV,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,eAAe,GACrB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,yBAAyB,EACzB,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AK,aAAa,GACnB,MAAM,UAAU,CAAC"}
@@ -1,64 +0,0 @@
1
- /**
2
- * Per-request markers for the upgrade transaction.
3
- *
4
- * Two 401s look identical on the wire and mean opposite things. A protected
5
- * resource's 401 says "this session is not strong enough"; the elevation's own
6
- * `POST /auth/refresh` 401 says "that TOTP code was wrong, try again". Neither
7
- * carries RFC 9470 vocabulary on the commit path — `refreshErrorStatus` maps the
8
- * four recoverable upgrade errors to a bare 401 with no `WWW-Authenticate` and no
9
- * `upgrade_required` body — so the response alone cannot tell them apart from an
10
- * expired session.
11
- *
12
- * The evidence that CAN tell them apart is the request: we know we issued it.
13
- * Both rounds of the elevation (`POST /auth/upgrade/start` and the committing
14
- * `POST /auth/refresh`) carry a marker on their axios config, set at the call
15
- * site immediately before dispatch. The response interceptor reads it off
16
- * `error.config`, which axios hands back unchanged, and suppresses
17
- * `setSessionInvalid()` for that one request only. An unrelated background 401
18
- * arriving while a prompt is open is unmarked and invalidates exactly as before.
19
- *
20
- * A second marker records that a request has already been replayed after an
21
- * elevation, so an adapter that re-issues through the same interceptor cannot
22
- * elevate twice for one challenge.
23
- *
24
- * ## Why these are enumerable, against the design's "non-enumerable"
25
- *
26
- * The design asks for non-enumerable properties, reasoning that they must never
27
- * reach the wire. Non-enumerable does not survive the trip: `AxiosClient.send`
28
- * spreads the caller's config into a fresh object (`{ method, url, ...options }`)
29
- * and axios' own `mergeConfig` iterates `Object.keys`, so both drop a
30
- * non-enumerable property before the request is dispatched — verified against
31
- * `axios@1.13` with a stub adapter. An enumerable key reaches both the adapter
32
- * and `error.config`.
33
- *
34
- * The property the design actually wanted is preserved regardless: axios
35
- * serializes only `data` (and `params`/`headers`), never unknown config keys, so
36
- * a marker is never transmitted. The same mechanism already carries
37
- * `_retryCount` through the rate-limit retry path.
38
- */
39
- /** Config key marking a request as one of the upgrade transaction's two rounds. */
40
- export declare const UPGRADE_TRANSACTION_MARKER = "__passflowUpgradeTransaction";
41
- /** Config key marking a request as the single post-elevation replay (FR3). */
42
- export declare const UPGRADE_REPLAYED_MARKER = "__passflowUpgradeReplayed";
43
- /** The markers as they appear on a request config. Both are absent unless set. */
44
- export type UpgradeRequestMarkers = {
45
- /** Set by the upgrade transport on `prepare` and `commit`. */
46
- __passflowUpgradeTransaction?: true;
47
- /** Set by the replaying adapter before it re-issues the original request. */
48
- __passflowUpgradeReplayed?: true;
49
- };
50
- /**
51
- * Returns a copy of `config` marked as part of the upgrade transaction.
52
- *
53
- * Copies rather than mutates: the caller may be reusing a config object, and a
54
- * marker that outlives its request would suppress invalidation for an unrelated
55
- * 401 — the exact over-broad behaviour the per-request rule replaces.
56
- */
57
- export declare const markUpgradeTransaction: <T extends object>(config?: T) => T & UpgradeRequestMarkers;
58
- /** Reports whether a request config carries the upgrade-transaction marker. */
59
- export declare const hasUpgradeTransactionMarker: (config: unknown) => boolean;
60
- /** Returns a copy of `config` marked as the one permitted post-elevation replay. */
61
- export declare const markUpgradeReplayed: <T extends object>(config: T) => T & UpgradeRequestMarkers;
62
- /** Reports whether a request config has already been replayed after an elevation. */
63
- export declare const hasUpgradeReplayedMarker: (config: unknown) => boolean;
64
- //# sourceMappingURL=markers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"markers.d.ts","sourceRoot":"","sources":["../../../lib/upgrade/markers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,mFAAmF;AACnF,eAAO,MAAM,0BAA0B,iCAAiC,CAAC;AAEzE,8EAA8E;AAC9E,eAAO,MAAM,uBAAuB,8BAA8B,CAAC;AAEnE,kFAAkF;AAClF,MAAM,MAAM,qBAAqB,GAAG;IAClC,8DAA8D;IAC9D,4BAA4B,CAAC,EAAE,IAAI,CAAC;IACpC,6EAA6E;IAC7E,yBAAyB,CAAC,EAAE,IAAI,CAAC;CAClC,CAAC;AAKF;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,GAAI,CAAC,SAAS,MAAM,EAAE,SAAS,CAAC,KAAG,CAAC,GAAG,qBAGxE,CAAC;AAEH,+EAA+E;AAC/E,eAAO,MAAM,2BAA2B,GAAI,QAAQ,OAAO,KAAG,OAAyD,CAAC;AAExH,oFAAoF;AACpF,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,MAAM,EAAE,QAAQ,CAAC,KAAG,CAAC,GAAG,qBAGpE,CAAC;AAEH,qFAAqF;AACrF,eAAO,MAAM,wBAAwB,GAAI,QAAQ,OAAO,KAAG,OAAsD,CAAC"}
@@ -1,132 +0,0 @@
1
- /**
2
- * The replay planner.
3
- *
4
- * Pure, no I/O, and it runs BEFORE the first call — a `Request` body must be
5
- * cloned while it is still unread, so by the time a 401 has come back it is too
6
- * late to decide whether a replay is possible. Planning first is also what lets
7
- * the core fail BEFORE opening a prompt: prompting the user, elevating their
8
- * session and only then discovering we cannot honour it is the worst possible
9
- * ordering, because it spends a server challenge and a user interaction for
10
- * nothing.
11
- *
12
- * ## Why replaying a challenged request is safe at all
13
- *
14
- * An RFC 9470 challenge is emitted by the authorization middleware —
15
- * `RequireAuthLevel` / `RequireFreshAuth` — BEFORE the handler runs, so the
16
- * request had no effect. That is categorically different from a 429 or a 502,
17
- * where the request may have partially executed, which is why
18
- * `AxiosClient.handleRateLimitError` correctly refuses to retry non-idempotent
19
- * requests and why this correctly does the opposite.
20
- *
21
- * The guarantee depends on the CUSTOMER's middleware placement, though, so
22
- * there is an escape hatch rather than an assumption: a backend that emits an
23
- * `insufficient_user_authentication` challenge after a side effect is violating
24
- * RFC 9470, and such a backend sets `'idempotent-only'`. Stating the
25
- * precondition is the design; silently assuming it would not be.
26
- *
27
- * ## Per-waiter binding
28
- *
29
- * A plan is bound to the request that carried the challenge: its own URL, its
30
- * own method and its own pre-captured body. No waiter's challenge, outcome or
31
- * response ever changes what another waiter replays, or where — requirement
32
- * AGGREGATION across waiters sharing a session is permitted and happens in the
33
- * controller; replay SUBSTITUTION is prohibited, and that prohibition is this
34
- * module's whole job.
35
- */
36
- import { type RequestSnapshot } from './snapshot';
37
- /** Our own `fetch` shape. Declared here rather than imported so no DOM lib is required. */
38
- export type FetchLike = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
39
- /** How a body can be re-sent, which is the only thing that decides replayability. */
40
- export type BodyKind =
41
- /** No body at all. Re-issue the same input. */
42
- 'none'
43
- /** A value the caller still holds and `fetch` re-reads: string, Blob, buffer, FormData, params. */
44
- | 'reusable'
45
- /** A `Request` with a body, cloned before the first send. */
46
- | 'request-clone'
47
- /** Consumed by the first send and unrecoverable: a `ReadableStream`, or a failed clone. */
48
- | 'one-shot';
49
- /** What the policy predicate is told about a request. */
50
- export type UpgradeReplayInfo = {
51
- url: string;
52
- method: string;
53
- bodyKind: BodyKind;
54
- };
55
- /**
56
- * Replay policy.
57
- *
58
- * The object form is §13.5's: size and streaming limits. The three string and
59
- * function forms are §5.1's escape hatch, kept because `'idempotent-only'`
60
- * expresses a constraint the object form cannot — a backend whose challenge may
61
- * arrive after a side effect.
62
- */
63
- export type ReplayPolicy = {
64
- /** Refuse to buffer a `Request` body larger than this many bytes, when the size is known. */
65
- maxBodyBytes?: number;
66
- /** A stream is never replayable; the field exists so the intent is written down. */
67
- allowStreamingBody?: false;
68
- } | 'always' | 'idempotent-only' | ((info: UpgradeReplayInfo) => boolean);
69
- /** Hints the core passes at replay time. The planner applies them; it decides nothing. */
70
- export type ReplayHints = {
71
- /**
72
- * The §5.5 credential swap, already resolved by the core.
73
- *
74
- * Applied if and only if the outgoing `Authorization` header value EXACTLY
75
- * equals `from`: equality with the token we hold in storage is what proves the
76
- * header was ours. Any other value is forwarded untouched, because rewriting a
77
- * header we do not own would be a security bug.
78
- *
79
- * Without this the replay re-sends the stale `Authorization` header, every
80
- * elevation ends in a surfaced second 401, and the feature silently never
81
- * works. Cookie mode needs none of it: the browser attaches the current —
82
- * now elevated — cookie by itself.
83
- */
84
- authorizationSwap?: {
85
- from: string;
86
- to: string;
87
- };
88
- };
89
- export type ReplayPlan = {
90
- /** False when the body cannot be re-sent, or the policy refused. */
91
- replayable: boolean;
92
- bodyKind: BodyKind;
93
- /** Why it is not replayable, for the `'replay-unsupported'` diagnostic. */
94
- reason?: string;
95
- /** What to pass to `next()` on the FIRST call. */
96
- forwardInput: RequestInfo | URL;
97
- forwardInit?: RequestInit;
98
- /**
99
- * The normalised, immutable snapshot of this request — §13.4 revision 6.
100
- *
101
- * EXPOSED rather than hidden as a plan-time url, so the scope check, the
102
- * challenge context, the diagnostics and the replay all read the same object
103
- * and the request that is *authorized* cannot differ from the one that is
104
- * *sent*.
105
- */
106
- snapshot: RequestSnapshot;
107
- /** Re-issues the original request, once. Rejects if `!replayable`. */
108
- replay: (next: FetchLike, hints?: ReplayHints) => Promise<Response>;
109
- };
110
- /** The URL of whatever shape the caller passed, without touching the network. */
111
- export declare const urlOf: (input: RequestInfo | URL) => string;
112
- /** The method of whatever shape the caller passed. `init` wins, as `fetch` itself has it. */
113
- export declare const methodOf: (input: RequestInfo | URL, init?: RequestInit) => string;
114
- /**
115
- * Applies the policy. The planner asks; it never decides what the policy means.
116
- *
117
- * Exported because the axios adapter needs the same answer about an
118
- * `AxiosRequestConfig`, which has no `Request` and no `BodyInit` to plan over.
119
- * Two readings of `'idempotent-only'` — one here and one there — is exactly the
120
- * per-surface drift the single core forbids, so there is one reading and both
121
- * surfaces call it.
122
- */
123
- export declare const policyPermits: (policy: ReplayPolicy | undefined, info: UpgradeReplayInfo, bodyBytes?: number) => boolean;
124
- /**
125
- * Decides whether a request can be replayed, and produces the thunk that does it.
126
- *
127
- * Call it BEFORE the first send. The returned `forwardInput` / `forwardInit` are
128
- * what the first send must use: for a `Request` with a body they are the
129
- * original, with the spare clone held for the replay.
130
- */
131
- export declare const planReplay: (input: RequestInfo | URL, init?: RequestInit, policy?: ReplayPolicy) => ReplayPlan;
132
- //# sourceMappingURL=replay.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"replay.d.ts","sourceRoot":"","sources":["../../../lib/upgrade/repl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ChC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;;;;;;OAOG;IACH,QAAQ,EAAE,eAAe,CAAC;IAC1B,sEAAsE;IACtE,MAAM,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;CACrE,CAAC;AAYF,iFAAiF;AACjF,eAAO,MAAM,KAAK,GAAI,OAAO,WAAW,GAAG,GAAG,KAAG,MAQhD,CAAC;AAEF,6FAA6F;AAC7F,eAAO,MAAM,QAAQ,GAAI,OAAO,WAAW,GAAG,GAAG,EAAE,OAAO,WAAW,KAAG,MAGvE,CAAC;AAwCF;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,GAAI,QAAQ,YAAY,GAAG,SAAS,EAAE,MAAM,iBAAiB,EAAE,YAAY,MAAM,KAAG,OAc7G,CAAC;AAoHF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,WAAW,GAAG,GAAG,EAAE,OAAO,WAAW,EAAE,SAAS,YAAY,KAAG,UAyGhG,CAAC"}
@@ -1,48 +0,0 @@
1
- /**
2
- * Which factor do we put in front of the user, and in what order?
3
- *
4
- * The challenge names what the server wants (`acrValues`, `maxAge`); this
5
- * module decides which of the SDK's registered factors to offer and which one
6
- * leads. The first entry is the "suggested" method the UI renders immediately
7
- * — everything after it sits behind "use another way" (PFL-509).
8
- *
9
- * ## Rank, never filter
10
- *
11
- * It is tempting to drop factors that "cannot reach" the demanded level. The
12
- * SDK cannot know that. The server computes `acr` from the *combination* of the
13
- * session's base methods and the verified factor, so a code factor DOES satisfy
14
- * an AAL3 challenge when the base session already reaches AAL3 — and for a
15
- * passkey the level depends on what the assertion reports, which is unknowable
16
- * until the ceremony runs.
17
- *
18
- * Getting that wrong is asymmetric. Offering a factor that turns out to be
19
- * insufficient costs one round-trip and a retry. Hiding one that would have
20
- * worked tells the user to re-authenticate when they did not have to, and
21
- * there is no way back from that. So every factor stays on the list; the
22
- * ordering carries the opinion, and the server stays the authority.
23
- *
24
- * ## Enrolment is filtered upstream, not here
25
- *
26
- * `available` is what this SDK can complete, not what the user has. The server
27
- * refuses a prepare round for an unenrolled factor
28
- * (`ErrorUpgradeMethodNotRegistered`). Narrowing `available` to the user's
29
- * actual credentials belongs to the caller — see the note at the bottom.
30
- */
31
- import type { UpgradeChallenge } from './challenge';
32
- import type { UpgradeFactor } from './factors';
33
- /**
34
- * Orders the factors to offer for a challenge. Index 0 is the suggested
35
- * method; the rest are the "use another way" alternatives.
36
- *
37
- * The suggested slot is not only a UX choice: PFL-510 treats a non-suggested
38
- * choice as a minor risk signal, so whatever leads here becomes the behavioural
39
- * baseline deviation is measured against.
40
- *
41
- * @param available - Factors this SDK can complete. Narrow to the user's
42
- * enrolled credentials before calling, when known.
43
- * @param challenge - What the server demanded (`acrValues`, `maxAge`).
44
- * @returns The factors to offer, most-preferred first. Empty only when
45
- * `available` was empty — this never drops a factor of its own accord.
46
- */
47
- export declare const selectFactors: (available: readonly UpgradeFactor[], challenge: UpgradeChallenge) => readonly UpgradeFactor[];
48
- //# sourceMappingURL=select.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../lib/upgrade/select.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAqB,MAAM,WAAW,CAAC;AAiElE;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa,GAAI,WAAW,SAAS,aAAa,EAAE,EAAE,WAAW,gBAAgB,KAAG,SAAS,aAAa,EAKtH,CAAC"}