@passflow/react 0.9.0 → 0.10.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 (51) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/index.cjs.js +1 -1
  3. package/dist/index.cjs.js.map +1 -1
  4. package/dist/index.es.js +132 -122
  5. package/dist/index.es.js.map +1 -1
  6. package/dist/src/components/provider/index.d.ts +2 -1
  7. package/dist/src/components/provider/index.d.ts.map +1 -1
  8. package/dist/src/components/provider/passflow-provider.d.ts +39 -5
  9. package/dist/src/components/provider/passflow-provider.d.ts.map +1 -1
  10. package/dist/src/components/provider/upgrade-provider.d.ts +49 -0
  11. package/dist/src/components/provider/upgrade-provider.d.ts.map +1 -0
  12. package/dist/src/components/ui/button/index.d.ts +12 -1
  13. package/dist/src/components/ui/button/index.d.ts.map +1 -1
  14. package/dist/src/components/ui/index.d.ts +2 -0
  15. package/dist/src/components/ui/index.d.ts.map +1 -1
  16. package/dist/src/components/ui/login-screen/consent.d.ts +2 -0
  17. package/dist/src/components/ui/login-screen/consent.d.ts.map +1 -1
  18. package/dist/src/components/ui/spinner/index.d.ts +23 -0
  19. package/dist/src/components/ui/spinner/index.d.ts.map +1 -0
  20. package/dist/src/components/ui/upgrade-dialog/challenge.d.ts +12 -0
  21. package/dist/src/components/ui/upgrade-dialog/challenge.d.ts.map +1 -0
  22. package/dist/src/components/ui/upgrade-dialog/factor-list.d.ts +20 -0
  23. package/dist/src/components/ui/upgrade-dialog/factor-list.d.ts.map +1 -0
  24. package/dist/src/components/ui/upgrade-dialog/index.d.ts +8 -0
  25. package/dist/src/components/ui/upgrade-dialog/index.d.ts.map +1 -0
  26. package/dist/src/components/ui/upgrade-dialog/state-mapping.d.ts +119 -0
  27. package/dist/src/components/ui/upgrade-dialog/state-mapping.d.ts.map +1 -0
  28. package/dist/src/components/ui/upgrade-dialog/status.d.ts +27 -0
  29. package/dist/src/components/ui/upgrade-dialog/status.d.ts.map +1 -0
  30. package/dist/src/components/ui/upgrade-dialog/types.d.ts +188 -0
  31. package/dist/src/components/ui/upgrade-dialog/types.d.ts.map +1 -0
  32. package/dist/src/components/ui/upgrade-dialog/upgrade-dialog.d.ts +13 -0
  33. package/dist/src/components/ui/upgrade-dialog/upgrade-dialog.d.ts.map +1 -0
  34. package/dist/src/context/index.d.ts +1 -0
  35. package/dist/src/context/index.d.ts.map +1 -1
  36. package/dist/src/context/upgrade-context.d.ts +85 -0
  37. package/dist/src/context/upgrade-context.d.ts.map +1 -0
  38. package/dist/src/hooks/index.d.ts +1 -0
  39. package/dist/src/hooks/index.d.ts.map +1 -1
  40. package/dist/src/hooks/use-upgrade.d.ts +43 -0
  41. package/dist/src/hooks/use-upgrade.d.ts.map +1 -0
  42. package/dist/src/index.d.ts +4 -1
  43. package/dist/src/index.d.ts.map +1 -1
  44. package/dist/src/utils/index.d.ts +1 -0
  45. package/dist/src/utils/index.d.ts.map +1 -1
  46. package/dist/src/utils/upgrade-auth.d.ts +38 -0
  47. package/dist/src/utils/upgrade-auth.d.ts.map +1 -0
  48. package/dist/style.css +1 -1
  49. package/package.json +4 -4
  50. package/dist/src/components/flow/upgrade-required-placeholder.d.ts +0 -21
  51. package/dist/src/components/flow/upgrade-required-placeholder.d.ts.map +0 -1
@@ -0,0 +1,188 @@
1
+ /**
2
+ * Presentational contract for the assurance-upgrade dialog.
3
+ *
4
+ * The dialog is a pure projection: it takes a discriminated state and emits
5
+ * callbacks. Every transition belongs to the controller (architecture §13.2),
6
+ * so nothing here is a state machine — it is the rendering union.
7
+ *
8
+ * `UpgradeFactorType` is declared locally on purpose: P4a must build and run
9
+ * with no `@passflow/core` runtime import, and the union is the only type the
10
+ * dialog needs from the protocol. A later phase re-points it at the package.
11
+ */
12
+ /** Factor types the upgrade protocol understands, named as `upgrade.type` on the wire. */
13
+ export type UpgradeFactorType = 'totp' | 'recovery_codes' | 'passkey' | 'email_otp' | 'sms_otp';
14
+ /** What the UI must collect before the factor can be asserted. */
15
+ export type UpgradeFactorInput = 'code' | 'none';
16
+ /**
17
+ * An assurance requirement or achievement, carrying both axes (§13.4).
18
+ * `level` is the parsed bar, `acrValues` the raw winning list, `maxAge` the
19
+ * freshness constraint when freshness is what was demanded.
20
+ */
21
+ export type AssuranceBar = {
22
+ acrValues?: string;
23
+ level?: number;
24
+ maxAge?: number;
25
+ };
26
+ /**
27
+ * What a factor's typed answer actually accepts — the factor's own contract,
28
+ * not the dialog's guess.
29
+ *
30
+ * It exists because the field used to cap input at a TOTP-shaped six
31
+ * characters for every factor, which silently truncated a recovery code: the
32
+ * server issues those from `services/totp/recovery.go` at
33
+ * `DefaultRecoveryCodeLength` (12) and validates a configured length anywhere
34
+ * in 6..16 (`model/two_factor.go`), from an alphanumeric charset. A six-digit
35
+ * numeric keypad is wrong for that answer on every axis — length, charset and
36
+ * autofill — so all three travel together with the factor instead of being
37
+ * restated at the input.
38
+ */
39
+ export type UpgradeFactorCodeContract = {
40
+ /** The longest answer the server can accept for this factor. */
41
+ maxLength: number;
42
+ /** A numeric OTP gets the numeric keypad; a recovery code is alphanumeric. */
43
+ inputMode: 'numeric' | 'text';
44
+ /** Only a genuine one-time code claims the OTP autofill contract. */
45
+ autoComplete: 'one-time-code' | 'off';
46
+ /** Recovery codes are issued upper-case; an OTP must not be re-cased. */
47
+ autoCapitalize: 'off' | 'characters';
48
+ };
49
+ type UpgradeDialogFactorBase = {
50
+ type: UpgradeFactorType;
51
+ /** 'Authenticator app' */
52
+ label: string;
53
+ /** 'Enter the code from your authenticator app' */
54
+ hint?: string;
55
+ };
56
+ /**
57
+ * A factor as the dialog renders it. The `input` discriminant carries the code
58
+ * contract rather than leaving it optional: a `'code'` factor with no contract
59
+ * is unrepresentable, so the truncation defect cannot return by omission.
60
+ */
61
+ export type UpgradeDialogFactor = (UpgradeDialogFactorBase & {
62
+ input: 'none';
63
+ }) | (UpgradeDialogFactorBase & {
64
+ input: 'code';
65
+ code: UpgradeFactorCodeContract;
66
+ });
67
+ export type UpgradeDialogChallengeState = {
68
+ kind: 'challenge';
69
+ /** Already ranked; index 0 is the suggested factor. */
70
+ factors: readonly UpgradeDialogFactor[];
71
+ selected: UpgradeFactorType;
72
+ reason?: string;
73
+ busy?: boolean;
74
+ error?: string | null;
75
+ showAlternatives?: boolean;
76
+ submitLabel?: string;
77
+ cancelLabel?: string;
78
+ alternativesLabel?: string;
79
+ testId?: string;
80
+ /**
81
+ * Reports the user's factor choice. Called the moment a factor is picked and
82
+ * always before `onSubmit`, which is the late-join boundary of §13.2 (T3).
83
+ */
84
+ onSelectFactor: (factor: UpgradeFactorType) => void;
85
+ onToggleAlternatives: () => void;
86
+ onSubmit: (code?: string) => void;
87
+ onCancel: () => void;
88
+ };
89
+ export type UpgradeDialogWorkingState = {
90
+ kind: 'working';
91
+ message: string;
92
+ detail?: string;
93
+ testId?: string;
94
+ onCancel?: () => void;
95
+ };
96
+ /**
97
+ * Every waiter replayed cleanly and no stated bar went unmet (§13.4).
98
+ *
99
+ * Success is the happy path, so it is the one state that must never be able to
100
+ * trap the user: §13.4's story table says the modal "reports success and
101
+ * closes". `onDismiss` is therefore required, not optional — it is what Escape,
102
+ * an overlay click, the Done control and the auto-close timer all call.
103
+ * `autoCloseMs` is the timer's dwell; `0` disables it and leaves the explicit
104
+ * control as the only path out.
105
+ */
106
+ export type UpgradeDialogSuccessState = {
107
+ kind: 'success';
108
+ message: string;
109
+ detail?: string;
110
+ dismissLabel?: string;
111
+ /** Milliseconds before the dialog closes itself. Omitted: the component's default. */
112
+ autoCloseMs?: number;
113
+ testId?: string;
114
+ onDismiss: () => void;
115
+ };
116
+ /**
117
+ * Elevated, and still not enough: the replay was re-challenged (§13.3, §13.4).
118
+ * This state must never read as success — it is the honest
119
+ * "elevated to AAL2; this action requires AAL3" message.
120
+ */
121
+ export type UpgradeDialogInsufficientState = {
122
+ kind: 'insufficient';
123
+ message: string;
124
+ obtained: AssuranceBar;
125
+ required: AssuranceBar;
126
+ detail?: string;
127
+ dismissLabel?: string;
128
+ testId?: string;
129
+ onDismiss: () => void;
130
+ };
131
+ /** The offered factor list is empty — `no usable factor` of §13.3's table. */
132
+ export type UpgradeDialogUnsatisfiableState = {
133
+ kind: 'unsatisfiable';
134
+ message: string;
135
+ /** The diagnostic line: what was demanded, and why nothing could answer it. */
136
+ detail?: string;
137
+ required?: AssuranceBar;
138
+ dismissLabel?: string;
139
+ testId?: string;
140
+ onDismiss: () => void;
141
+ };
142
+ /** 501 / BFF — the deployment cannot elevate at all. */
143
+ export type UpgradeDialogUnavailableState = {
144
+ kind: 'unavailable';
145
+ message: string;
146
+ detail?: string;
147
+ dismissLabel?: string;
148
+ testId?: string;
149
+ onDismiss: () => void;
150
+ };
151
+ /** The attempt budget ran out. */
152
+ export type UpgradeDialogExhaustedState = {
153
+ kind: 'exhausted';
154
+ message: string;
155
+ detail?: string;
156
+ dismissLabel?: string;
157
+ testId?: string;
158
+ onDismiss: () => void;
159
+ };
160
+ /** A transport failure — FR1's non-retryable 400, or a retryable network fault. */
161
+ export type UpgradeDialogTransportState = {
162
+ kind: 'transport';
163
+ message: string;
164
+ detail?: string;
165
+ retryable?: boolean;
166
+ retryLabel?: string;
167
+ dismissLabel?: string;
168
+ testId?: string;
169
+ onRetry?: () => void;
170
+ onDismiss: () => void;
171
+ };
172
+ /** The user dismissed the dialog, or a passkey ceremony was cancelled. */
173
+ export type UpgradeDialogCancelledState = {
174
+ kind: 'cancelled';
175
+ message: string;
176
+ detail?: string;
177
+ dismissLabel?: string;
178
+ testId?: string;
179
+ onDismiss: () => void;
180
+ };
181
+ export type UpgradeDialogState = UpgradeDialogChallengeState | UpgradeDialogWorkingState | UpgradeDialogSuccessState | UpgradeDialogInsufficientState | UpgradeDialogUnsatisfiableState | UpgradeDialogUnavailableState | UpgradeDialogExhaustedState | UpgradeDialogTransportState | UpgradeDialogCancelledState;
182
+ export type UpgradeDialogProps = {
183
+ open: boolean;
184
+ title?: string;
185
+ state: UpgradeDialogState;
186
+ };
187
+ export {};
188
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/upgrade-dialog/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,0FAA0F;AAC1F,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,gBAAgB,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,CAAC;AAEhG,kEAAkE;AAClE,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,MAAM,CAAC;AAEjD;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,gEAAgE;IAChE,SAAS,EAAE,MAAM,CAAC;IAClB,8EAA8E;IAC9E,SAAS,EAAE,SAAS,GAAG,MAAM,CAAC;IAC9B,qEAAqE;IACrE,YAAY,EAAE,eAAe,GAAG,KAAK,CAAC;IACtC,yEAAyE;IACzE,cAAc,EAAE,KAAK,GAAG,YAAY,CAAC;CACtC,CAAC;AAEF,KAAK,uBAAuB,GAAG;IAC7B,IAAI,EAAE,iBAAiB,CAAC;IACxB,0BAA0B;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,mDAAmD;IACnD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAC3B,CAAC,uBAAuB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,GAC7C,CAAC,uBAAuB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,yBAAyB,CAAA;CAAE,CAAC,CAAC;AAEnF,MAAM,MAAM,2BAA2B,GAAG;IACxC,IAAI,EAAE,WAA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B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB,CAAC;AAEF,0EAA0E;AAC1E,MAAM,MAAM,2BAA2B,GAAG;IACxC,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAC1B,2BAA2B,GAC3B,yBAAyB,GACzB,yBAAyB,GACzB,8BAA8B,GAC9B,+BAA+B,GAC/B,6BAA6B,GAC7B,2BAA2B,GAC3B,2BAA2B,GAC3B,2BAA2B,CAAC;AAEhC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,kBAAkB,CAAC;CAC3B,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { FC } from 'react';
2
+ import { UpgradeDialogProps } from './types';
3
+ /**
4
+ * The assurance-upgrade modal. A switch over `state.kind`, modelled on
5
+ * `LoginScreen`: one discriminated union, one view per state, no transitions of
6
+ * its own.
7
+ *
8
+ * Escape and an overlay click route to the state's cancel or dismiss callback,
9
+ * never to a bare close — cancellation must reach the controller or the
10
+ * caller's promise never settles (§8.1).
11
+ */
12
+ export declare const UpgradeDialog: FC<UpgradeDialogProps>;
13
+ //# sourceMappingURL=upgrade-dialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upgrade-dialog.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/upgrade-dialog/upgrade-dialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAKhC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,sBAAsB,CAAC;AAI9B;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CAwBhD,CAAC"}
@@ -2,4 +2,5 @@ export * from './passflow-context';
2
2
  export * from './router-context';
3
3
  export * from './navigation-context';
4
4
  export * from './auth-context';
5
+ export * from './upgrade-context';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/context/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/context/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,85 @@
1
+ import { AssuranceBar, UpgradeChallenge, UpgradeFactor, UpgradeFactorType } from '@passflow/core';
2
+ /** What a protected elevation can fail with, in the hook's vocabulary (§13.3's table). */
3
+ export type UpgradeErrorStatusKind = 'exhausted' | 'unsatisfiable' | 'unavailable' | 'transport';
4
+ /**
5
+ * The hook's observable state. Exactly one terminal state per flight, taken
6
+ * from the controller's outcome summary (§13.4).
7
+ *
8
+ * `idle` is also where a flight abandoned by a session change lands: nothing
9
+ * happened, and nothing is reported as though it had.
10
+ */
11
+ export type UpgradeHookState = {
12
+ status: 'idle';
13
+ } | {
14
+ status: 'challenged';
15
+ challenge: UpgradeChallenge;
16
+ factors: UpgradeFactorType[];
17
+ } | {
18
+ status: 'submitting';
19
+ } | {
20
+ status: 'success';
21
+ } | {
22
+ status: 'insufficient';
23
+ obtained: AssuranceBar;
24
+ required: AssuranceBar;
25
+ } | {
26
+ status: 'error';
27
+ kind: UpgradeErrorStatusKind;
28
+ error: Error;
29
+ };
30
+ /** The states a flight can settle in. `null` alongside these is cancellation. */
31
+ export type UpgradeSettledState = Extract<UpgradeHookState, {
32
+ status: 'idle' | 'success' | 'insufficient' | 'error';
33
+ }>;
34
+ /** A bar a caller states for itself on the imperative seam (§13.2 T10 / H-6). */
35
+ export type UpgradeElevateOptions = {
36
+ acrValues?: string;
37
+ maxAge?: number;
38
+ };
39
+ /** The open prompt, as the dialog and the hook read it. */
40
+ export type UpgradePromptView = {
41
+ challenge: UpgradeChallenge;
42
+ /** Already ranked by `selectFactors`; index 0 is the suggested factor. */
43
+ factors: readonly UpgradeFactor[];
44
+ /** The previous attempt's failure, when the controller re-prompted. */
45
+ previousError?: Error;
46
+ };
47
+ export type UpgradeContextValue = {
48
+ /** True when the provider installed a prompt handler on this `Passflow` instance. */
49
+ enabled: boolean;
50
+ state: UpgradeHookState;
51
+ /** The open prompt, or `null` when no elevation is collecting an answer. */
52
+ prompt: UpgradePromptView | null;
53
+ selectedFactor: UpgradeFactorType | null;
54
+ /**
55
+ * The factor-selection signal. Reports the user's choice to the controller
56
+ * through `UpgradePromptRequest.onFactorSelected` the moment it is made and
57
+ * before any answer is submitted — §13.2's late-join boundary (T3), which is
58
+ * selection and not submission.
59
+ */
60
+ selectFactor: (factor: UpgradeFactorType) => void;
61
+ /** Answers the open prompt. Resolves the controller's promise exactly once. */
62
+ submit: (code?: string) => void;
63
+ /** Declines the open prompt. Exactly once; never leaves the promise pending. */
64
+ cancel: () => void;
65
+ /** Acknowledges a terminal state, closing the dialog. Settles nothing. */
66
+ dismiss: () => void;
67
+ /**
68
+ * Drives an elevation directly — a "verify now" button, or a headless
69
+ * caller. Resolves **`null`** when the user cancelled, and otherwise the
70
+ * flight's terminal state; it never rejects, because the hook's contract is
71
+ * a rendered decision rather than a thrown transport outcome.
72
+ */
73
+ elevate: (options?: UpgradeElevateOptions) => Promise<UpgradeSettledState | null>;
74
+ };
75
+ export declare const UpgradeContext: import('react').Context<UpgradeContextValue | undefined>;
76
+ /**
77
+ * What `useUpgrade` reads outside an `UpgradeProvider`: idle, inert, and it
78
+ * does not throw (§9.5 H8) — a component that merely wants to know whether an
79
+ * elevation is running is not a bug.
80
+ *
81
+ * `elevate` resolves `{ status: 'idle' }` rather than `null`: nothing was
82
+ * asked and nothing was declined, and `null` means the user declined.
83
+ */
84
+ export declare const INERT_UPGRADE_CONTEXT: UpgradeContextValue;
85
+ //# sourceMappingURL=upgrade-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upgrade-context.d.ts","sourceRoot":"","sources":["../../../src/context/upgrade-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGvG,0FAA0F;AAC1F,MAAM,MAAM,sBAAsB,GAAG,WAAW,GAAG,eAAe,GAAG,aAAa,GAAG,WAAW,CAAC;AAEjG;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GACxB;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAClB;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,SAAS,EAAE,gBAAgB,CAAC;IAAC,OAAO,EAAE,iBAAiB,EAAE,CAAA;CAAE,GACnF;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,GACxB;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,GACrB;IAAE,MAAM,EAAE,cAAc,CAAC;IAAC,QAAQ,EAAE,YAAY,CAAC;IAAC,QAAQ,EAAE,YAAY,CAAA;CAAE,GAC1E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AA4D,CAAC;AAIxF;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,EAAE,mBAUnC,CAAC"}
@@ -23,4 +23,5 @@ export { useTwoFactorMethods, type UseTwoFactorMethodsReturn } from './use-two-f
23
23
  export { useSessionExpired, type UseSessionExpiredOptions, type UseSessionExpiredResult, type SessionExpiredReason, } from './use-session-expired';
24
24
  export { useDeviceVerify, type UseDeviceVerifyProps, type DeviceVerifyStatus, type DeviceVerifyInfo, type DeviceUIMode, } from './use-device-verify';
25
25
  export { useConsent, type UseConsentProps, type ConsentStatus, type ConsentInfo, type ConsentError, type ConsentScopeMetadata, } from './use-consent';
26
+ export { useUpgrade, type UseUpgradeResult } from './use-upgrade';
26
27
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,KAAK,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACvF,OAAO,EAAE,gBAAgB,EAAE,KAAK,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,KAAK,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AACzG,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,E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E,kBAAkB,EAAE,KAAK,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAC3F,OAAO,EAAE,0BAA0B,EAAE,KAAK,gCAAgC,EAAE,MAAM,mCAAmC,CAAC;AACtH,OAAO,EAAE,qBAAqB,EAAE,KAAK,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACrG,OAAO,EAAE,mBAAmB,EAAE,KAAK,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAE/F,OAAO,EACL,iBAAiB,EACjB,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,GAC1B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,eAAe,EACf,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,YAAY,GAClB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,UAAU,EACV,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,oBAAoB,GAC1B,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { UpgradeElevateOptions, UpgradeErrorStatusKind, UpgradeHookState, UpgradeSettledState } from '../context/upgrade-context';
2
+ import { AssuranceBar, UpgradeChallenge, UpgradeFactor, UpgradeFactorType } from '@passflow/core';
3
+ export type UseUpgradeResult = {
4
+ /** True when an `UpgradeProvider` installed a prompt handler. */
5
+ enabled: boolean;
6
+ /** The whole state, as the discriminated union (§13.5's `UpgradeHookState`). */
7
+ state: UpgradeHookState;
8
+ /** The discriminant, for the common `status === 'challenged'` read. */
9
+ status: UpgradeHookState['status'];
10
+ /** What the server demanded — the MERGED requirement when challenges joined. */
11
+ challenge: UpgradeChallenge | null;
12
+ /** Usable factors, already ranked; index 0 is the suggested one. */
13
+ factors: readonly UpgradeFactor[];
14
+ /** The ranked factor types, which is what `UpgradeHookState.challenged` carries. */
15
+ factorTypes: readonly UpgradeFactorType[];
16
+ selectedFactor: UpgradeFactorType | null;
17
+ /**
18
+ * Elevated, and still not enough: the replay was re-challenged (§13.4).
19
+ * Non-null **only** in the `insufficient` state, and it never coexists with
20
+ * `status === 'success'` — this must not read as success.
21
+ */
22
+ insufficient: {
23
+ obtained: AssuranceBar;
24
+ required: AssuranceBar;
25
+ } | null;
26
+ /** The terminal failure, in the `error` state only. */
27
+ error: Error | null;
28
+ /** Which failure class, in the `error` state only. */
29
+ errorKind: UpgradeErrorStatusKind | null;
30
+ /** The previous attempt's failure while the prompt is re-shown (a wrong code). */
31
+ previousError: Error | null;
32
+ /** True while a ceremony is on the wire. */
33
+ busy: boolean;
34
+ /** The factor-selection signal — §13.2's late-join boundary (T3). */
35
+ selectFactor: (factor: UpgradeFactorType) => void;
36
+ submit: (code?: string) => void;
37
+ cancel: () => void;
38
+ dismiss: () => void;
39
+ /** Resolves `null` on cancellation; otherwise the flight's terminal state. */
40
+ elevate: (options?: UpgradeElevateOptions) => Promise<UpgradeSettledState | null>;
41
+ };
42
+ export declare const useUpgrade: () => UseUpgradeResult;
43
+ //# sourceMappingURL=use-upgrade.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-upgrade.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-upgrade.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAIL,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EAErB,KAAK,mBAAmB,EACzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGvG,MAAM,MAAM,gBAAgB,GAAG;IAC7B,iEAAiE;IACjE,OAAO,EAAE,OAAO,CAAC;IACjB,gFAAgF;IAChF,KAAK,EAAE,gBAAgB,CAAC;IACxB,uEAAuE;IACvE,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACnC,gFAAgF;IAChF,SAAS,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACnC,oEAAoE;IACpE,OAAO,EAAE,SAAS,aAAa,EAAE,CAAC;IAClC,oFAAoF;IACpF,WAAW,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAC1C,cAAc,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACzC;;;;OAIG;IACH,YAAY,EAAE;QAAE,QAAQ,EAAE,YAAY,CAAC;QAAC,QAAQ,EAAE,YAAY,CAAA;KAAE,GAAG,IAAI,CAAC;IACxE,uDAAuD;IACvD,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,sDAAsD;IACtD,SAAS,EAAE,sBAAsB,GAAG,IAAI,CAAC;IACzC,kFAAkF;IAClF,aAAa,EAAE,KAAK,GAAG,IAAI,CAAC;IAC5B,4CAA4C;IAC5C,IAAI,EAAE,OAAO,CAAC;IACd,qEAAqE;IACrE,YAAY,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAClD,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,8EAA8E;IAC9E,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE,qBAAqB,KAAK,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;CACnF,CAAC;AAOF,eAAO,MAAM,UAAU,QAAO,gBA2B7B,CAAC"}
@@ -1,7 +1,10 @@
1
1
  export * from './components/flow';
2
2
  export * from './components/form';
3
3
  export * from './components/ui';
4
- export { PassflowProvider } from './components/provider';
4
+ export { PassflowProvider, UpgradeProvider } from './components/provider';
5
+ export type { UpgradeProviderProps, PassflowUpgradeOptions } from './components/provider';
6
+ export { UpgradeContext, INERT_UPGRADE_CONTEXT, type UpgradeContextValue, type UpgradeElevateOptions, type UpgradeErrorStatusKind, type UpgradeHookState, type UpgradePromptView, type UpgradeSettledState, } from './context/upgrade-context';
7
+ export { withAuth, attachAuth } from './utils/upgrade-auth';
5
8
  export * from './hooks';
6
9
  export * from '@passflow/core';
7
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAC5B,OAAO,yBAAyB,CAAC;AAEjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAC5B,OAAO,yBAAyB,CAAC;AAEjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC1E,YAAY,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE1F,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,GACzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC5D,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC"}
@@ -13,4 +13,5 @@ export { classifyDeviceError, deviceErrorOfType, DeviceApiError } from './classi
13
13
  export { authErrorFor, authRedirectErrorMessage, invitationLinkErrorMessage, verificationLinkErrorMessage, verificationRequestErrorMessage, } from './auth-error';
14
14
  export { getInvitationAuthChrome, type InvitationAuthIntent } from './invitation-auth-chrome';
15
15
  export { TwoFactorLoopPrevention } from './two-factor-loop-prevention';
16
+ export { withAuth, attachAuth, registerUpgradeAuthInstance, releaseUpgradeAuthInstance, upgradeAuthInstance, } from './upgrade-auth';
16
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC9E,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AACpG,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAClG,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACjG,OAAO,EACL,YAAY,EACZ,wBAAwB,EACxB,0BAA0B,EAC1B,4BAA4B,EAC5B,+BAA+B,GAChC,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,uBAAuB,EAAE,KAAK,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC9F,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC9E,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AACpG,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAClG,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACjG,OAAO,EACL,YAAY,EACZ,wBAAwB,EACxB,0BAA0B,EAC1B,4BAA4B,EAC5B,+BAA+B,GAChC,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,uBAAuB,EAAE,KAAK,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC9F,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EACL,QAAQ,EACR,UAAU,EACV,2BAA2B,EAC3B,0BAA0B,EAC1B,mBAAmB,GACpB,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { FetchLike, Passflow, ResponseInterceptorHost } from '@passflow/core';
2
+ /**
3
+ * Publishes the provider's `Passflow` instance to the free functions, and
4
+ * returns an unregister suitable as a React effect cleanup.
5
+ *
6
+ * Last registration wins, and the returned unregister is *deferred*: it clears
7
+ * the instance on a microtask, and only if nothing has registered in the
8
+ * meantime. See the module comment — that deferral is what keeps a Strict Mode
9
+ * mount → unmount → remount from leaving the free functions unbound, and it is
10
+ * why register and release are symmetric rather than one in render and one in a
11
+ * cleanup that nothing undoes.
12
+ */
13
+ export declare const registerUpgradeAuthInstance: (instance: Passflow) => (() => void);
14
+ /**
15
+ * Clears `instance` if it is still the registered one, and does nothing
16
+ * otherwise. Idempotent, so an effect cleanup that runs after a newer provider
17
+ * has already published cannot unbind the live instance.
18
+ */
19
+ export declare const releaseUpgradeAuthInstance: (instance: Passflow) => void;
20
+ /** The instance the free functions bind to, or `null` outside a provider. */
21
+ export declare const upgradeAuthInstance: () => Passflow | null;
22
+ /**
23
+ * Wraps a `fetch` and returns the wrapper. Installs nothing and touches no
24
+ * global — two verbs exist because the semantics genuinely differ: an axios
25
+ * interceptor mutates, a fetch wrapper returns.
26
+ */
27
+ export declare const withAuth: (next?: FetchLike) => FetchLike;
28
+ /**
29
+ * Attaches step-up handling to an axios instance the caller already owns,
30
+ * **mutating** it, and returns the `detach()` disposer — which is exactly what
31
+ * a React effect needs.
32
+ *
33
+ * The parameter is typed structurally (duck-typed on
34
+ * `interceptors.response.use`), so this package's axios version is not a
35
+ * constraint on the caller's.
36
+ */
37
+ export declare const attachAuth: (instance: ResponseInterceptorHost) => (() => void);
38
+ //# sourceMappingURL=upgrade-auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upgrade-auth.d.ts","sourceRoot":"","sources":["../../../src/utils/upgrade-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAWnF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,2BAA2B,GAAI,UAAU,QAAQ,KAAG,CAAC,MAAM,IAAI,CAY3E,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,GAAI,UAAU,QAAQ,KAAG,IAE/D,CAAC;AAEF,6EAA6E;AAC7E,eAAO,MAAM,mBAAmB,QAAO,QAAQ,GAAG,IAAsB,CAAC;AAWzE;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,SAAS,KAAG,SAAuD,CAAC;AAEpG;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,GAAI,UAAU,uBAAuB,KAAG,CAAC,MAAM,IAAI,CACtB,CAAC"}