@corbado/autocapture 1.0.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -5
- package/dist/chunk-GWLL2VST.mjs +1 -0
- package/dist/chunk-JR557W27.mjs +1 -0
- package/dist/chunk-WY3VIPYX.mjs +1 -0
- package/dist/guards-BmrxoYBR.d.mts +351 -0
- package/dist/guards-Bwsr1zMi.d.ts +351 -0
- package/dist/index.d.mts +27 -247
- package/dist/index.d.ts +27 -247
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/probe/fixtures.d.mts +38 -0
- package/dist/probe/fixtures.d.ts +38 -0
- package/dist/probe/fixtures.js +1 -0
- package/dist/probe/fixtures.mjs +1 -0
- package/dist/probe.d.mts +28 -0
- package/dist/probe.d.ts +28 -0
- package/dist/probe.js +2 -0
- package/dist/probe.mjs +2 -0
- package/dist/types-lamU1Fd3.d.mts +317 -0
- package/dist/types-lamU1Fd3.d.ts +317 -0
- package/package.json +49 -4
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import { WebAuthnIdentifierProjectors } from '@corbado/observe';
|
|
2
|
+
|
|
3
|
+
/** Receives optional diagnostics. Capture functions remain silent when no logger is provided. */
|
|
4
|
+
type Logger = {
|
|
5
|
+
/** Records a non-fatal diagnostic message. */
|
|
6
|
+
log: (...args: unknown[]) => void;
|
|
7
|
+
};
|
|
8
|
+
/** Controls a capture session. */
|
|
9
|
+
type CaptureHandle = {
|
|
10
|
+
/**
|
|
11
|
+
* Result of starting the capture.
|
|
12
|
+
*
|
|
13
|
+
* - `"standard"`: capture started normally.
|
|
14
|
+
* - `"unavailable"`: capture could not be started and will not emit events.
|
|
15
|
+
*/
|
|
16
|
+
readonly mode: "standard" | "unavailable";
|
|
17
|
+
/** Stops future event delivery. Safe to call more than once. */
|
|
18
|
+
disconnect(): void;
|
|
19
|
+
};
|
|
20
|
+
/** Normalized Credential Management mediation. Missing mediation defaults to `optional`. */
|
|
21
|
+
type CredentialMediation = "silent" | "optional" | "conditional" | "required" | "unknown";
|
|
22
|
+
/** Normalized Credential Management mediation of a WebAuthn ceremony. */
|
|
23
|
+
type WebAuthnMediation = CredentialMediation;
|
|
24
|
+
/** Normalized Credential Management UI mode for authentication ceremonies. */
|
|
25
|
+
type WebAuthnUiMode = "default" | "immediate" | "unknown";
|
|
26
|
+
/** Browser-native facts that remain stable for one ceremony. */
|
|
27
|
+
type WebAuthnCeremonyContext = {
|
|
28
|
+
kind: "authentication";
|
|
29
|
+
mediation: WebAuthnMediation;
|
|
30
|
+
uiMode: WebAuthnUiMode;
|
|
31
|
+
/** Whether the RP supplied a non-empty allow list or requested discoverable credentials. */
|
|
32
|
+
credentialSet: "allowlisted" | "discoverable";
|
|
33
|
+
} | {
|
|
34
|
+
kind: "registration";
|
|
35
|
+
mediation: WebAuthnMediation;
|
|
36
|
+
};
|
|
37
|
+
type WebAuthnCeremonyBase = WebAuthnCeremonyContext & {
|
|
38
|
+
/** Identifier shared by all events belonging to the same ceremony. */
|
|
39
|
+
ceremonyId: string;
|
|
40
|
+
};
|
|
41
|
+
type WebAuthnCeremonyStartedEvent = WebAuthnCeremonyBase & {
|
|
42
|
+
phase: "started";
|
|
43
|
+
/** Whether transient user activation was active when the ceremony started, when exposed by the browser. */
|
|
44
|
+
userActivation?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* JSON-encoded authentication publicKey options. All fields are retained.
|
|
47
|
+
* Binary values are base64url-encoded. Treat this value as sensitive telemetry.
|
|
48
|
+
*/
|
|
49
|
+
requestOptionsJson?: string;
|
|
50
|
+
/** Creation publicKey options with user.name and user.displayName removed. */
|
|
51
|
+
creationOptionsJson?: string;
|
|
52
|
+
};
|
|
53
|
+
type WebAuthnCeremonyCompletedEvent = WebAuthnCeremonyBase & {
|
|
54
|
+
phase: "completed";
|
|
55
|
+
/** JSON-encoded credential after the centralized blacklist; present only when applicable and serializable. Treat this value as sensitive telemetry. */
|
|
56
|
+
credentialJson?: string;
|
|
57
|
+
/** A credential manager may complete even after the ceremony signal was aborted. */
|
|
58
|
+
aborted?: true;
|
|
59
|
+
};
|
|
60
|
+
type WebAuthnCeremonyFailedEvent = WebAuthnCeremonyBase & {
|
|
61
|
+
phase: "failed";
|
|
62
|
+
/** Rejection value from the failed ceremony. This may contain application-specific data. */
|
|
63
|
+
error: unknown;
|
|
64
|
+
/** DOM exception name, or `UnknownError` when no name is available. */
|
|
65
|
+
errorName: string;
|
|
66
|
+
/** Present when the request signal was aborted before settlement. */
|
|
67
|
+
aborted?: true;
|
|
68
|
+
};
|
|
69
|
+
/** A protocol-native lifecycle event for WebAuthn authentication or registration. */
|
|
70
|
+
type WebAuthnCeremonyEvent = WebAuthnCeremonyStartedEvent | WebAuthnCeremonyCompletedEvent | WebAuthnCeremonyFailedEvent;
|
|
71
|
+
/**
|
|
72
|
+
* Surface WebAuthn capture may attach to.
|
|
73
|
+
*
|
|
74
|
+
* - `"methods"`: `credentials.get` / `credentials.create` only.
|
|
75
|
+
* - `"container"`: additionally the `navigator.credentials` container, used when the methods are
|
|
76
|
+
* held by another integration in a form that cannot be shared.
|
|
77
|
+
*/
|
|
78
|
+
type WebAuthnAttachSurface = "methods" | "container";
|
|
79
|
+
/** Options for {@link captureWebAuthn}. */
|
|
80
|
+
type WebAuthnCaptureOptions = {
|
|
81
|
+
/** Receives WebAuthn lifecycle events. Return values are not awaited. */
|
|
82
|
+
onEvent: (event: WebAuthnCeremonyEvent) => void;
|
|
83
|
+
/** Optional diagnostic logger. */
|
|
84
|
+
logger?: Logger;
|
|
85
|
+
/**
|
|
86
|
+
* Synchronous SDK user identifier projection for creation user.id and response userHandle.
|
|
87
|
+
* Missing callbacks preserve user IDs; callback errors omit them. Credential IDs stay unchanged.
|
|
88
|
+
* Use the same projector in network fallback serializers.
|
|
89
|
+
* Projection affects telemetry only; authentication arguments, results and errors stay unchanged.
|
|
90
|
+
*/
|
|
91
|
+
identifierProjectors?: WebAuthnIdentifierProjectors;
|
|
92
|
+
/**
|
|
93
|
+
* Highest surface capture may attach to. Defaults to `"methods"`.
|
|
94
|
+
*
|
|
95
|
+
* With `"container"`, a capture that cannot patch the methods attaches to the
|
|
96
|
+
* `navigator.credentials` container instead: reads of `get`/`create` are observed while the
|
|
97
|
+
* integration holding them keeps handling the ceremony. The methods surface is always tried
|
|
98
|
+
* first, so this changes nothing when it is available.
|
|
99
|
+
*/
|
|
100
|
+
attach?: WebAuthnAttachSurface;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Handle returned by {@link captureWebAuthn}.
|
|
104
|
+
*
|
|
105
|
+
* `surface` reports where the capture actually attached, which is not implied by `mode`: an
|
|
106
|
+
* `attach: "container"` capture reports `mode: "standard"` from either surface.
|
|
107
|
+
*/
|
|
108
|
+
type WebAuthnCaptureHandle = CaptureHandle & {
|
|
109
|
+
/** Surface this capture attached to; `"none"` when `mode` is `"unavailable"`. */
|
|
110
|
+
readonly surface: WebAuthnAttachSurface | "none";
|
|
111
|
+
};
|
|
112
|
+
/** FedCM request context. Missing context defaults to `signin`. */
|
|
113
|
+
type FederatedIdentityContext = "signin" | "signup" | "use" | "continue" | "unknown";
|
|
114
|
+
/** FedCM UI mode: `passive` is a prompt the browser shows by itself, `active` follows a user gesture. Missing mode defaults to `passive`. */
|
|
115
|
+
type FederatedIdentityMode = "passive" | "active" | "unknown";
|
|
116
|
+
/** An identity provider named in a FedCM request. Nonce and parameters are never read. */
|
|
117
|
+
type FederatedIdentityProvider = {
|
|
118
|
+
/** The provider's FedCM config file URL; it names the provider. */
|
|
119
|
+
configURL: string;
|
|
120
|
+
/** The relying party's public client ID at the provider. */
|
|
121
|
+
clientId?: string;
|
|
122
|
+
};
|
|
123
|
+
type FederatedIdentityBase = {
|
|
124
|
+
/** Identifier shared by all events belonging to the same request. */
|
|
125
|
+
requestId: string;
|
|
126
|
+
};
|
|
127
|
+
type FederatedIdentityStartedEvent = FederatedIdentityBase & {
|
|
128
|
+
phase: "started";
|
|
129
|
+
/** Providers with a string `configURL`, in request order. */
|
|
130
|
+
providers: FederatedIdentityProvider[];
|
|
131
|
+
context: FederatedIdentityContext;
|
|
132
|
+
mode: FederatedIdentityMode;
|
|
133
|
+
mediation: CredentialMediation;
|
|
134
|
+
/** Whether transient user activation was active when the request started, when exposed by the browser. */
|
|
135
|
+
userActivation?: boolean;
|
|
136
|
+
};
|
|
137
|
+
type FederatedIdentityCompletedEvent = FederatedIdentityBase & {
|
|
138
|
+
phase: "completed";
|
|
139
|
+
/** Config file URL of the provider whose account was chosen, when the browser exposes it. */
|
|
140
|
+
configURL?: string;
|
|
141
|
+
/** Whether the browser chose the account without user interaction, when exposed. */
|
|
142
|
+
isAutoSelected?: boolean;
|
|
143
|
+
};
|
|
144
|
+
type FederatedIdentityFailedEvent = FederatedIdentityBase & {
|
|
145
|
+
phase: "failed";
|
|
146
|
+
/**
|
|
147
|
+
* DOM exception name, or `UnknownError`. Typical values: `NotAllowedError` (declined or blocked),
|
|
148
|
+
* `NetworkError` (no account, provider unavailable or cooldown), `AbortError`,
|
|
149
|
+
* `IdentityCredentialError` (the provider refused after an account was chosen). `NoCredential`
|
|
150
|
+
* when the request resolved without a credential.
|
|
151
|
+
*/
|
|
152
|
+
errorName: string;
|
|
153
|
+
/** Error code of an `IdentityCredentialError`, when non-empty. */
|
|
154
|
+
code?: string;
|
|
155
|
+
/** Present when the request signal was aborted before settlement. */
|
|
156
|
+
aborted?: true;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Lifecycle event of a FedCM request (`navigator.credentials.get({ identity })`). Tokens, nonces,
|
|
160
|
+
* parameters and login hints never appear in events.
|
|
161
|
+
*/
|
|
162
|
+
type FederatedIdentityEvent = FederatedIdentityStartedEvent | FederatedIdentityCompletedEvent | FederatedIdentityFailedEvent;
|
|
163
|
+
/** Options for {@link captureFederatedIdentity}. */
|
|
164
|
+
type FederatedIdentityCaptureOptions = {
|
|
165
|
+
/** Receives FedCM lifecycle events. Return values are not awaited. */
|
|
166
|
+
onEvent: (event: FederatedIdentityEvent) => void;
|
|
167
|
+
/** Optional diagnostic logger. */
|
|
168
|
+
logger?: Logger;
|
|
169
|
+
/**
|
|
170
|
+
* Highest surface capture may attach to when no other capture is attached yet; see
|
|
171
|
+
* {@link WebAuthnCaptureOptions.attach}. Defaults to `"methods"`.
|
|
172
|
+
*/
|
|
173
|
+
attach?: WebAuthnAttachSurface;
|
|
174
|
+
};
|
|
175
|
+
/** Handle returned by {@link captureFederatedIdentity}. */
|
|
176
|
+
type FederatedIdentityCaptureHandle = CaptureHandle & {
|
|
177
|
+
/** Surface the shared attachment uses; `"none"` when `mode` is `"unavailable"`. */
|
|
178
|
+
readonly surface: WebAuthnAttachSurface | "none";
|
|
179
|
+
};
|
|
180
|
+
/** Network API used for an observed exchange. */
|
|
181
|
+
type NetworkTransport = "xhr" | "fetch";
|
|
182
|
+
/** Direction of a projected body within an observed network exchange. */
|
|
183
|
+
type NetworkBodyDirection = "request" | "response";
|
|
184
|
+
/** A matched network request immediately after the platform accepted it. */
|
|
185
|
+
type HttpRequestStarted<RequestBody = unknown> = {
|
|
186
|
+
/** Identifier shared with the eventual {@link HttpExchange}. */
|
|
187
|
+
requestId: string;
|
|
188
|
+
/** Network API used for the request. */
|
|
189
|
+
transport: NetworkTransport;
|
|
190
|
+
/** Uppercase HTTP method. */
|
|
191
|
+
method: string;
|
|
192
|
+
/** Resolved absolute request input URL. */
|
|
193
|
+
url: string;
|
|
194
|
+
/** Pathname component of the request URL. */
|
|
195
|
+
path: string;
|
|
196
|
+
/** Timestamp captured at the request boundary. */
|
|
197
|
+
startedAt: number;
|
|
198
|
+
/** Request-body value returned by the configured projector, when synchronously available. */
|
|
199
|
+
requestBody?: RequestBody;
|
|
200
|
+
};
|
|
201
|
+
/** An observed network request and its outcome. */
|
|
202
|
+
type HttpExchange<RequestBody = unknown, ResponseBody = unknown> = {
|
|
203
|
+
/** Identifier shared with the corresponding {@link HttpRequestStarted}. */
|
|
204
|
+
requestId: string;
|
|
205
|
+
/** Network API used for the request. */
|
|
206
|
+
transport: NetworkTransport;
|
|
207
|
+
/** Uppercase HTTP method. */
|
|
208
|
+
method: string;
|
|
209
|
+
/**
|
|
210
|
+
* Resolved absolute request input URL, including its query string and
|
|
211
|
+
* fragment. Redact it before forwarding if either component may be sensitive.
|
|
212
|
+
*/
|
|
213
|
+
url: string;
|
|
214
|
+
/** Pathname component of the request URL. */
|
|
215
|
+
path: string;
|
|
216
|
+
/** HTTP status code, or `0` when a status is unavailable. */
|
|
217
|
+
status: number;
|
|
218
|
+
/** Whether the status code represents a successful response. */
|
|
219
|
+
ok: boolean;
|
|
220
|
+
/**
|
|
221
|
+
* How the request completed. `load` includes successful and non-successful
|
|
222
|
+
* HTTP responses; inspect `ok` or `status` for HTTP success.
|
|
223
|
+
*/
|
|
224
|
+
outcome: "load" | "abort" | "timeout" | "error";
|
|
225
|
+
/** Elapsed request time in milliseconds, when available. */
|
|
226
|
+
durationMs?: number;
|
|
227
|
+
/**
|
|
228
|
+
* Final absolute response URL, when available. This may differ from `url`
|
|
229
|
+
* after redirects and may contain sensitive query or fragment values.
|
|
230
|
+
*/
|
|
231
|
+
responseUrl?: string;
|
|
232
|
+
/** Request-body value returned by the configured projector, when available. */
|
|
233
|
+
requestBody?: RequestBody;
|
|
234
|
+
/** Response-body value returned by the configured projector, when available. */
|
|
235
|
+
responseBody?: ResponseBody;
|
|
236
|
+
};
|
|
237
|
+
/** Metadata supplied to a body projector for one matched exchange. */
|
|
238
|
+
type NetworkBodyProjectionContext<Direction extends NetworkBodyDirection = NetworkBodyDirection> = {
|
|
239
|
+
/** Whether the observed body belongs to the request or response. */
|
|
240
|
+
direction: Direction;
|
|
241
|
+
/** Network API used by the application. */
|
|
242
|
+
transport: NetworkTransport;
|
|
243
|
+
/** Uppercase HTTP method. */
|
|
244
|
+
method: string;
|
|
245
|
+
/** Resolved absolute request URL. */
|
|
246
|
+
url: string;
|
|
247
|
+
/** Pathname component of the request URL. */
|
|
248
|
+
path: string;
|
|
249
|
+
};
|
|
250
|
+
/**
|
|
251
|
+
* Synchronously selects the only body data that may leave network capture.
|
|
252
|
+
* Textual bodies are supplied as strings; an XHR with `responseType="json"`
|
|
253
|
+
* supplies the browser-parsed value. Returning `undefined`, throwing, or
|
|
254
|
+
* returning a Promise omits the body without affecting the application.
|
|
255
|
+
* `ProjectedBody` describes the exact value delivered to callbacks.
|
|
256
|
+
*/
|
|
257
|
+
type NetworkBodyProjector<ProjectedBody = unknown, Direction extends NetworkBodyDirection = NetworkBodyDirection> = (body: unknown, context: NetworkBodyProjectionContext<Direction>) => ProjectedBody | undefined;
|
|
258
|
+
/**
|
|
259
|
+
* Options for {@link captureNetwork}. Request and response body types are
|
|
260
|
+
* inferred from their projectors and propagated to the corresponding callbacks.
|
|
261
|
+
*/
|
|
262
|
+
type NetworkCaptureOptions<RequestBody = unknown, ResponseBody = unknown> = {
|
|
263
|
+
/**
|
|
264
|
+
* Selects requests to observe. The URL is resolved against the document base
|
|
265
|
+
* URL and the method is uppercase. Return `true` to observe the request.
|
|
266
|
+
* This callback must return synchronously; Promise results are not matched.
|
|
267
|
+
*/
|
|
268
|
+
match: (url: URL, method: string) => boolean;
|
|
269
|
+
/** Receives completed network exchanges. Return values are not awaited. */
|
|
270
|
+
onExchange: (exchange: HttpExchange<NoInfer<RequestBody>, NoInfer<ResponseBody>>) => void;
|
|
271
|
+
/**
|
|
272
|
+
* Receives matched requests after the platform call succeeds. The request ID
|
|
273
|
+
* matches the eventual exchange. Return values are not awaited.
|
|
274
|
+
*/
|
|
275
|
+
onRequest?: (request: HttpRequestStarted<NoInfer<RequestBody>>) => void;
|
|
276
|
+
/**
|
|
277
|
+
* Network APIs to observe. Defaults to both `xhr` and `fetch`. Unavailable
|
|
278
|
+
* transports are skipped if at least one requested transport can be observed.
|
|
279
|
+
*/
|
|
280
|
+
transports?: readonly NetworkTransport[];
|
|
281
|
+
/**
|
|
282
|
+
* Best-effort body observation, enabled independently per direction by a
|
|
283
|
+
* mandatory projector. Without a projector, that direction is never read.
|
|
284
|
+
* Autocapture performs no generic parsing or redaction: the projector owns
|
|
285
|
+
* data minimization and its return value is the only body data reported.
|
|
286
|
+
*/
|
|
287
|
+
bodyCapture?: {
|
|
288
|
+
/** Projects a request body. */
|
|
289
|
+
request?: NetworkBodyProjector<RequestBody, "request">;
|
|
290
|
+
/** Projects a response body. */
|
|
291
|
+
response?: NetworkBodyProjector<ResponseBody, "response">;
|
|
292
|
+
};
|
|
293
|
+
/** Optional diagnostic logger. */
|
|
294
|
+
logger?: Logger;
|
|
295
|
+
};
|
|
296
|
+
/** Mechanism that produced a navigation event. */
|
|
297
|
+
type NavigationSource = "push" | "replace" | "pop" | "hash";
|
|
298
|
+
/** A same-document navigation. */
|
|
299
|
+
type NavigationEvent = {
|
|
300
|
+
/** Current URL pathname. */
|
|
301
|
+
path: string;
|
|
302
|
+
/** Current URL query string, including the leading `?` when present. May contain sensitive data. */
|
|
303
|
+
search: string;
|
|
304
|
+
/** Current URL fragment, including the leading `#` when present. May contain sensitive data. */
|
|
305
|
+
hash: string;
|
|
306
|
+
/** Mechanism that produced the event. */
|
|
307
|
+
source: NavigationSource;
|
|
308
|
+
};
|
|
309
|
+
/** Options for {@link captureNavigation}. */
|
|
310
|
+
type NavigationCaptureOptions = {
|
|
311
|
+
/** Receives same-document navigation events. Return values are not awaited. */
|
|
312
|
+
onNavigate: (event: NavigationEvent) => void;
|
|
313
|
+
/** Optional diagnostic logger. */
|
|
314
|
+
logger?: Logger;
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
export type { CaptureHandle as C, FederatedIdentityCaptureOptions as F, HttpExchange as H, Logger as L, NetworkCaptureOptions as N, WebAuthnCaptureOptions as W, WebAuthnCaptureHandle as a, FederatedIdentityCaptureHandle as b, NavigationCaptureOptions as c, CredentialMediation as d, FederatedIdentityCompletedEvent as e, FederatedIdentityContext as f, FederatedIdentityEvent as g, FederatedIdentityFailedEvent as h, FederatedIdentityMode as i, FederatedIdentityProvider as j, FederatedIdentityStartedEvent as k, HttpRequestStarted as l, NavigationEvent as m, NavigationSource as n, NetworkBodyDirection as o, NetworkBodyProjectionContext as p, NetworkBodyProjector as q, NetworkTransport as r, WebAuthnAttachSurface as s, WebAuthnCeremonyCompletedEvent as t, WebAuthnCeremonyContext as u, WebAuthnCeremonyEvent as v, WebAuthnCeremonyFailedEvent as w, WebAuthnCeremonyStartedEvent as x, WebAuthnMediation as y, WebAuthnUiMode as z };
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import { WebAuthnIdentifierProjectors } from '@corbado/observe';
|
|
2
|
+
|
|
3
|
+
/** Receives optional diagnostics. Capture functions remain silent when no logger is provided. */
|
|
4
|
+
type Logger = {
|
|
5
|
+
/** Records a non-fatal diagnostic message. */
|
|
6
|
+
log: (...args: unknown[]) => void;
|
|
7
|
+
};
|
|
8
|
+
/** Controls a capture session. */
|
|
9
|
+
type CaptureHandle = {
|
|
10
|
+
/**
|
|
11
|
+
* Result of starting the capture.
|
|
12
|
+
*
|
|
13
|
+
* - `"standard"`: capture started normally.
|
|
14
|
+
* - `"unavailable"`: capture could not be started and will not emit events.
|
|
15
|
+
*/
|
|
16
|
+
readonly mode: "standard" | "unavailable";
|
|
17
|
+
/** Stops future event delivery. Safe to call more than once. */
|
|
18
|
+
disconnect(): void;
|
|
19
|
+
};
|
|
20
|
+
/** Normalized Credential Management mediation. Missing mediation defaults to `optional`. */
|
|
21
|
+
type CredentialMediation = "silent" | "optional" | "conditional" | "required" | "unknown";
|
|
22
|
+
/** Normalized Credential Management mediation of a WebAuthn ceremony. */
|
|
23
|
+
type WebAuthnMediation = CredentialMediation;
|
|
24
|
+
/** Normalized Credential Management UI mode for authentication ceremonies. */
|
|
25
|
+
type WebAuthnUiMode = "default" | "immediate" | "unknown";
|
|
26
|
+
/** Browser-native facts that remain stable for one ceremony. */
|
|
27
|
+
type WebAuthnCeremonyContext = {
|
|
28
|
+
kind: "authentication";
|
|
29
|
+
mediation: WebAuthnMediation;
|
|
30
|
+
uiMode: WebAuthnUiMode;
|
|
31
|
+
/** Whether the RP supplied a non-empty allow list or requested discoverable credentials. */
|
|
32
|
+
credentialSet: "allowlisted" | "discoverable";
|
|
33
|
+
} | {
|
|
34
|
+
kind: "registration";
|
|
35
|
+
mediation: WebAuthnMediation;
|
|
36
|
+
};
|
|
37
|
+
type WebAuthnCeremonyBase = WebAuthnCeremonyContext & {
|
|
38
|
+
/** Identifier shared by all events belonging to the same ceremony. */
|
|
39
|
+
ceremonyId: string;
|
|
40
|
+
};
|
|
41
|
+
type WebAuthnCeremonyStartedEvent = WebAuthnCeremonyBase & {
|
|
42
|
+
phase: "started";
|
|
43
|
+
/** Whether transient user activation was active when the ceremony started, when exposed by the browser. */
|
|
44
|
+
userActivation?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* JSON-encoded authentication publicKey options. All fields are retained.
|
|
47
|
+
* Binary values are base64url-encoded. Treat this value as sensitive telemetry.
|
|
48
|
+
*/
|
|
49
|
+
requestOptionsJson?: string;
|
|
50
|
+
/** Creation publicKey options with user.name and user.displayName removed. */
|
|
51
|
+
creationOptionsJson?: string;
|
|
52
|
+
};
|
|
53
|
+
type WebAuthnCeremonyCompletedEvent = WebAuthnCeremonyBase & {
|
|
54
|
+
phase: "completed";
|
|
55
|
+
/** JSON-encoded credential after the centralized blacklist; present only when applicable and serializable. Treat this value as sensitive telemetry. */
|
|
56
|
+
credentialJson?: string;
|
|
57
|
+
/** A credential manager may complete even after the ceremony signal was aborted. */
|
|
58
|
+
aborted?: true;
|
|
59
|
+
};
|
|
60
|
+
type WebAuthnCeremonyFailedEvent = WebAuthnCeremonyBase & {
|
|
61
|
+
phase: "failed";
|
|
62
|
+
/** Rejection value from the failed ceremony. This may contain application-specific data. */
|
|
63
|
+
error: unknown;
|
|
64
|
+
/** DOM exception name, or `UnknownError` when no name is available. */
|
|
65
|
+
errorName: string;
|
|
66
|
+
/** Present when the request signal was aborted before settlement. */
|
|
67
|
+
aborted?: true;
|
|
68
|
+
};
|
|
69
|
+
/** A protocol-native lifecycle event for WebAuthn authentication or registration. */
|
|
70
|
+
type WebAuthnCeremonyEvent = WebAuthnCeremonyStartedEvent | WebAuthnCeremonyCompletedEvent | WebAuthnCeremonyFailedEvent;
|
|
71
|
+
/**
|
|
72
|
+
* Surface WebAuthn capture may attach to.
|
|
73
|
+
*
|
|
74
|
+
* - `"methods"`: `credentials.get` / `credentials.create` only.
|
|
75
|
+
* - `"container"`: additionally the `navigator.credentials` container, used when the methods are
|
|
76
|
+
* held by another integration in a form that cannot be shared.
|
|
77
|
+
*/
|
|
78
|
+
type WebAuthnAttachSurface = "methods" | "container";
|
|
79
|
+
/** Options for {@link captureWebAuthn}. */
|
|
80
|
+
type WebAuthnCaptureOptions = {
|
|
81
|
+
/** Receives WebAuthn lifecycle events. Return values are not awaited. */
|
|
82
|
+
onEvent: (event: WebAuthnCeremonyEvent) => void;
|
|
83
|
+
/** Optional diagnostic logger. */
|
|
84
|
+
logger?: Logger;
|
|
85
|
+
/**
|
|
86
|
+
* Synchronous SDK user identifier projection for creation user.id and response userHandle.
|
|
87
|
+
* Missing callbacks preserve user IDs; callback errors omit them. Credential IDs stay unchanged.
|
|
88
|
+
* Use the same projector in network fallback serializers.
|
|
89
|
+
* Projection affects telemetry only; authentication arguments, results and errors stay unchanged.
|
|
90
|
+
*/
|
|
91
|
+
identifierProjectors?: WebAuthnIdentifierProjectors;
|
|
92
|
+
/**
|
|
93
|
+
* Highest surface capture may attach to. Defaults to `"methods"`.
|
|
94
|
+
*
|
|
95
|
+
* With `"container"`, a capture that cannot patch the methods attaches to the
|
|
96
|
+
* `navigator.credentials` container instead: reads of `get`/`create` are observed while the
|
|
97
|
+
* integration holding them keeps handling the ceremony. The methods surface is always tried
|
|
98
|
+
* first, so this changes nothing when it is available.
|
|
99
|
+
*/
|
|
100
|
+
attach?: WebAuthnAttachSurface;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Handle returned by {@link captureWebAuthn}.
|
|
104
|
+
*
|
|
105
|
+
* `surface` reports where the capture actually attached, which is not implied by `mode`: an
|
|
106
|
+
* `attach: "container"` capture reports `mode: "standard"` from either surface.
|
|
107
|
+
*/
|
|
108
|
+
type WebAuthnCaptureHandle = CaptureHandle & {
|
|
109
|
+
/** Surface this capture attached to; `"none"` when `mode` is `"unavailable"`. */
|
|
110
|
+
readonly surface: WebAuthnAttachSurface | "none";
|
|
111
|
+
};
|
|
112
|
+
/** FedCM request context. Missing context defaults to `signin`. */
|
|
113
|
+
type FederatedIdentityContext = "signin" | "signup" | "use" | "continue" | "unknown";
|
|
114
|
+
/** FedCM UI mode: `passive` is a prompt the browser shows by itself, `active` follows a user gesture. Missing mode defaults to `passive`. */
|
|
115
|
+
type FederatedIdentityMode = "passive" | "active" | "unknown";
|
|
116
|
+
/** An identity provider named in a FedCM request. Nonce and parameters are never read. */
|
|
117
|
+
type FederatedIdentityProvider = {
|
|
118
|
+
/** The provider's FedCM config file URL; it names the provider. */
|
|
119
|
+
configURL: string;
|
|
120
|
+
/** The relying party's public client ID at the provider. */
|
|
121
|
+
clientId?: string;
|
|
122
|
+
};
|
|
123
|
+
type FederatedIdentityBase = {
|
|
124
|
+
/** Identifier shared by all events belonging to the same request. */
|
|
125
|
+
requestId: string;
|
|
126
|
+
};
|
|
127
|
+
type FederatedIdentityStartedEvent = FederatedIdentityBase & {
|
|
128
|
+
phase: "started";
|
|
129
|
+
/** Providers with a string `configURL`, in request order. */
|
|
130
|
+
providers: FederatedIdentityProvider[];
|
|
131
|
+
context: FederatedIdentityContext;
|
|
132
|
+
mode: FederatedIdentityMode;
|
|
133
|
+
mediation: CredentialMediation;
|
|
134
|
+
/** Whether transient user activation was active when the request started, when exposed by the browser. */
|
|
135
|
+
userActivation?: boolean;
|
|
136
|
+
};
|
|
137
|
+
type FederatedIdentityCompletedEvent = FederatedIdentityBase & {
|
|
138
|
+
phase: "completed";
|
|
139
|
+
/** Config file URL of the provider whose account was chosen, when the browser exposes it. */
|
|
140
|
+
configURL?: string;
|
|
141
|
+
/** Whether the browser chose the account without user interaction, when exposed. */
|
|
142
|
+
isAutoSelected?: boolean;
|
|
143
|
+
};
|
|
144
|
+
type FederatedIdentityFailedEvent = FederatedIdentityBase & {
|
|
145
|
+
phase: "failed";
|
|
146
|
+
/**
|
|
147
|
+
* DOM exception name, or `UnknownError`. Typical values: `NotAllowedError` (declined or blocked),
|
|
148
|
+
* `NetworkError` (no account, provider unavailable or cooldown), `AbortError`,
|
|
149
|
+
* `IdentityCredentialError` (the provider refused after an account was chosen). `NoCredential`
|
|
150
|
+
* when the request resolved without a credential.
|
|
151
|
+
*/
|
|
152
|
+
errorName: string;
|
|
153
|
+
/** Error code of an `IdentityCredentialError`, when non-empty. */
|
|
154
|
+
code?: string;
|
|
155
|
+
/** Present when the request signal was aborted before settlement. */
|
|
156
|
+
aborted?: true;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Lifecycle event of a FedCM request (`navigator.credentials.get({ identity })`). Tokens, nonces,
|
|
160
|
+
* parameters and login hints never appear in events.
|
|
161
|
+
*/
|
|
162
|
+
type FederatedIdentityEvent = FederatedIdentityStartedEvent | FederatedIdentityCompletedEvent | FederatedIdentityFailedEvent;
|
|
163
|
+
/** Options for {@link captureFederatedIdentity}. */
|
|
164
|
+
type FederatedIdentityCaptureOptions = {
|
|
165
|
+
/** Receives FedCM lifecycle events. Return values are not awaited. */
|
|
166
|
+
onEvent: (event: FederatedIdentityEvent) => void;
|
|
167
|
+
/** Optional diagnostic logger. */
|
|
168
|
+
logger?: Logger;
|
|
169
|
+
/**
|
|
170
|
+
* Highest surface capture may attach to when no other capture is attached yet; see
|
|
171
|
+
* {@link WebAuthnCaptureOptions.attach}. Defaults to `"methods"`.
|
|
172
|
+
*/
|
|
173
|
+
attach?: WebAuthnAttachSurface;
|
|
174
|
+
};
|
|
175
|
+
/** Handle returned by {@link captureFederatedIdentity}. */
|
|
176
|
+
type FederatedIdentityCaptureHandle = CaptureHandle & {
|
|
177
|
+
/** Surface the shared attachment uses; `"none"` when `mode` is `"unavailable"`. */
|
|
178
|
+
readonly surface: WebAuthnAttachSurface | "none";
|
|
179
|
+
};
|
|
180
|
+
/** Network API used for an observed exchange. */
|
|
181
|
+
type NetworkTransport = "xhr" | "fetch";
|
|
182
|
+
/** Direction of a projected body within an observed network exchange. */
|
|
183
|
+
type NetworkBodyDirection = "request" | "response";
|
|
184
|
+
/** A matched network request immediately after the platform accepted it. */
|
|
185
|
+
type HttpRequestStarted<RequestBody = unknown> = {
|
|
186
|
+
/** Identifier shared with the eventual {@link HttpExchange}. */
|
|
187
|
+
requestId: string;
|
|
188
|
+
/** Network API used for the request. */
|
|
189
|
+
transport: NetworkTransport;
|
|
190
|
+
/** Uppercase HTTP method. */
|
|
191
|
+
method: string;
|
|
192
|
+
/** Resolved absolute request input URL. */
|
|
193
|
+
url: string;
|
|
194
|
+
/** Pathname component of the request URL. */
|
|
195
|
+
path: string;
|
|
196
|
+
/** Timestamp captured at the request boundary. */
|
|
197
|
+
startedAt: number;
|
|
198
|
+
/** Request-body value returned by the configured projector, when synchronously available. */
|
|
199
|
+
requestBody?: RequestBody;
|
|
200
|
+
};
|
|
201
|
+
/** An observed network request and its outcome. */
|
|
202
|
+
type HttpExchange<RequestBody = unknown, ResponseBody = unknown> = {
|
|
203
|
+
/** Identifier shared with the corresponding {@link HttpRequestStarted}. */
|
|
204
|
+
requestId: string;
|
|
205
|
+
/** Network API used for the request. */
|
|
206
|
+
transport: NetworkTransport;
|
|
207
|
+
/** Uppercase HTTP method. */
|
|
208
|
+
method: string;
|
|
209
|
+
/**
|
|
210
|
+
* Resolved absolute request input URL, including its query string and
|
|
211
|
+
* fragment. Redact it before forwarding if either component may be sensitive.
|
|
212
|
+
*/
|
|
213
|
+
url: string;
|
|
214
|
+
/** Pathname component of the request URL. */
|
|
215
|
+
path: string;
|
|
216
|
+
/** HTTP status code, or `0` when a status is unavailable. */
|
|
217
|
+
status: number;
|
|
218
|
+
/** Whether the status code represents a successful response. */
|
|
219
|
+
ok: boolean;
|
|
220
|
+
/**
|
|
221
|
+
* How the request completed. `load` includes successful and non-successful
|
|
222
|
+
* HTTP responses; inspect `ok` or `status` for HTTP success.
|
|
223
|
+
*/
|
|
224
|
+
outcome: "load" | "abort" | "timeout" | "error";
|
|
225
|
+
/** Elapsed request time in milliseconds, when available. */
|
|
226
|
+
durationMs?: number;
|
|
227
|
+
/**
|
|
228
|
+
* Final absolute response URL, when available. This may differ from `url`
|
|
229
|
+
* after redirects and may contain sensitive query or fragment values.
|
|
230
|
+
*/
|
|
231
|
+
responseUrl?: string;
|
|
232
|
+
/** Request-body value returned by the configured projector, when available. */
|
|
233
|
+
requestBody?: RequestBody;
|
|
234
|
+
/** Response-body value returned by the configured projector, when available. */
|
|
235
|
+
responseBody?: ResponseBody;
|
|
236
|
+
};
|
|
237
|
+
/** Metadata supplied to a body projector for one matched exchange. */
|
|
238
|
+
type NetworkBodyProjectionContext<Direction extends NetworkBodyDirection = NetworkBodyDirection> = {
|
|
239
|
+
/** Whether the observed body belongs to the request or response. */
|
|
240
|
+
direction: Direction;
|
|
241
|
+
/** Network API used by the application. */
|
|
242
|
+
transport: NetworkTransport;
|
|
243
|
+
/** Uppercase HTTP method. */
|
|
244
|
+
method: string;
|
|
245
|
+
/** Resolved absolute request URL. */
|
|
246
|
+
url: string;
|
|
247
|
+
/** Pathname component of the request URL. */
|
|
248
|
+
path: string;
|
|
249
|
+
};
|
|
250
|
+
/**
|
|
251
|
+
* Synchronously selects the only body data that may leave network capture.
|
|
252
|
+
* Textual bodies are supplied as strings; an XHR with `responseType="json"`
|
|
253
|
+
* supplies the browser-parsed value. Returning `undefined`, throwing, or
|
|
254
|
+
* returning a Promise omits the body without affecting the application.
|
|
255
|
+
* `ProjectedBody` describes the exact value delivered to callbacks.
|
|
256
|
+
*/
|
|
257
|
+
type NetworkBodyProjector<ProjectedBody = unknown, Direction extends NetworkBodyDirection = NetworkBodyDirection> = (body: unknown, context: NetworkBodyProjectionContext<Direction>) => ProjectedBody | undefined;
|
|
258
|
+
/**
|
|
259
|
+
* Options for {@link captureNetwork}. Request and response body types are
|
|
260
|
+
* inferred from their projectors and propagated to the corresponding callbacks.
|
|
261
|
+
*/
|
|
262
|
+
type NetworkCaptureOptions<RequestBody = unknown, ResponseBody = unknown> = {
|
|
263
|
+
/**
|
|
264
|
+
* Selects requests to observe. The URL is resolved against the document base
|
|
265
|
+
* URL and the method is uppercase. Return `true` to observe the request.
|
|
266
|
+
* This callback must return synchronously; Promise results are not matched.
|
|
267
|
+
*/
|
|
268
|
+
match: (url: URL, method: string) => boolean;
|
|
269
|
+
/** Receives completed network exchanges. Return values are not awaited. */
|
|
270
|
+
onExchange: (exchange: HttpExchange<NoInfer<RequestBody>, NoInfer<ResponseBody>>) => void;
|
|
271
|
+
/**
|
|
272
|
+
* Receives matched requests after the platform call succeeds. The request ID
|
|
273
|
+
* matches the eventual exchange. Return values are not awaited.
|
|
274
|
+
*/
|
|
275
|
+
onRequest?: (request: HttpRequestStarted<NoInfer<RequestBody>>) => void;
|
|
276
|
+
/**
|
|
277
|
+
* Network APIs to observe. Defaults to both `xhr` and `fetch`. Unavailable
|
|
278
|
+
* transports are skipped if at least one requested transport can be observed.
|
|
279
|
+
*/
|
|
280
|
+
transports?: readonly NetworkTransport[];
|
|
281
|
+
/**
|
|
282
|
+
* Best-effort body observation, enabled independently per direction by a
|
|
283
|
+
* mandatory projector. Without a projector, that direction is never read.
|
|
284
|
+
* Autocapture performs no generic parsing or redaction: the projector owns
|
|
285
|
+
* data minimization and its return value is the only body data reported.
|
|
286
|
+
*/
|
|
287
|
+
bodyCapture?: {
|
|
288
|
+
/** Projects a request body. */
|
|
289
|
+
request?: NetworkBodyProjector<RequestBody, "request">;
|
|
290
|
+
/** Projects a response body. */
|
|
291
|
+
response?: NetworkBodyProjector<ResponseBody, "response">;
|
|
292
|
+
};
|
|
293
|
+
/** Optional diagnostic logger. */
|
|
294
|
+
logger?: Logger;
|
|
295
|
+
};
|
|
296
|
+
/** Mechanism that produced a navigation event. */
|
|
297
|
+
type NavigationSource = "push" | "replace" | "pop" | "hash";
|
|
298
|
+
/** A same-document navigation. */
|
|
299
|
+
type NavigationEvent = {
|
|
300
|
+
/** Current URL pathname. */
|
|
301
|
+
path: string;
|
|
302
|
+
/** Current URL query string, including the leading `?` when present. May contain sensitive data. */
|
|
303
|
+
search: string;
|
|
304
|
+
/** Current URL fragment, including the leading `#` when present. May contain sensitive data. */
|
|
305
|
+
hash: string;
|
|
306
|
+
/** Mechanism that produced the event. */
|
|
307
|
+
source: NavigationSource;
|
|
308
|
+
};
|
|
309
|
+
/** Options for {@link captureNavigation}. */
|
|
310
|
+
type NavigationCaptureOptions = {
|
|
311
|
+
/** Receives same-document navigation events. Return values are not awaited. */
|
|
312
|
+
onNavigate: (event: NavigationEvent) => void;
|
|
313
|
+
/** Optional diagnostic logger. */
|
|
314
|
+
logger?: Logger;
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
export type { CaptureHandle as C, FederatedIdentityCaptureOptions as F, HttpExchange as H, Logger as L, NetworkCaptureOptions as N, WebAuthnCaptureOptions as W, WebAuthnCaptureHandle as a, FederatedIdentityCaptureHandle as b, NavigationCaptureOptions as c, CredentialMediation as d, FederatedIdentityCompletedEvent as e, FederatedIdentityContext as f, FederatedIdentityEvent as g, FederatedIdentityFailedEvent as h, FederatedIdentityMode as i, FederatedIdentityProvider as j, FederatedIdentityStartedEvent as k, HttpRequestStarted as l, NavigationEvent as m, NavigationSource as n, NetworkBodyDirection as o, NetworkBodyProjectionContext as p, NetworkBodyProjector as q, NetworkTransport as r, WebAuthnAttachSurface as s, WebAuthnCeremonyCompletedEvent as t, WebAuthnCeremonyContext as u, WebAuthnCeremonyEvent as v, WebAuthnCeremonyFailedEvent as w, WebAuthnCeremonyStartedEvent as x, WebAuthnMediation as y, WebAuthnUiMode as z };
|