@glideidentity/glide-be-node-magical-auth 3.0.0 → 3.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/LICENSE +190 -23
- package/README.md +167 -1
- package/dist/index.cjs +716 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +168 -7
- package/dist/index.d.ts +168 -7
- package/dist/index.js +708 -11
- package/dist/index.js.map +1 -1
- package/dist/{types-DgXuYYzq.d.cts → types-BPuPzIcL.d.cts} +456 -178
- package/dist/{types-DgXuYYzq.d.ts → types-BPuPzIcL.d.ts} +456 -178
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +4 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AuthenticationStrategy, P as PLMN,
|
|
2
|
-
export { B as BadRequestError,
|
|
1
|
+
import { A as AuthenticationStrategy, P as PLMN, f as ClientInfo, O as PhoneNumberDetails, a as BiometricVerification, M as MagicalAuthConfig, U as PrepareRequest, W as PrepareResult, R as PrepareMultipleRequest, S as PrepareMultipleResult, aj as VerifyPhoneNumberRequest, ak as VerifyPhoneNumberResponse, G as GetPhoneNumberRequest, s as GetPhoneNumberResponse, _ as ReportInvocationResponse, a8 as StatusResponse, H as HttpClient, w as Logger } from './types-BPuPzIcL.cjs';
|
|
2
|
+
export { B as BadRequestError, b as BrowserMismatchError, C as CarrierAppUnavailableError, c as CarrierNotEligibleError, d as CarrierRejectedError, e as Challenge, g as ConsentData, D as DCQLCredential, h as DCQLCredentialMeta, i as DCQLQuery, j as DEFAULT_BASE_URL, k as DEFAULT_TIMEOUT, l as DesktopQRData, m as DesktopStrategyData, n as DesktopWaitError, o as DeviceBindingError, p as DeviceInfo, q as DeviceSwapInfo, E as ErrorCode, r as ErrorResponse, F as ForbiddenError, t as HttpRequestOptions, u as HttpResponse, I as InternalServerError, v as InvalidCredentialError, L as LinkStrategyData, x as LoggerConfig, y as MagicalAuthError, z as MissingBindingCookieError, N as NetworkCheck, J as NetworkOrigin, K as PREPARE_MULTIPLE_MAX, Q as PhoneNumberMismatchError, T as PrepareOptions, V as PrepareResponse, X as ProtocolType, Y as RateLimitError, Z as ReportInvocationRequest, $ as ResolvedConfig, a0 as RiskLevel, a1 as ServiceUnavailableError, a2 as SessionInfo, a3 as SessionNotEligibleError, a4 as SessionNotFoundError, a5 as SessionStatus, a6 as SimSwapFailureReason, a7 as SimSwapInfo, a9 as StrategyData, aa as TS43RequestData, ab as TS43StrategyData, ac as Theme, ad as UnauthorizedError, ae as UnsupportedPlatformError, af as UseCase, ag as ValidationError, ah as VerificationRecordError, ai as VerificationRecordErrorCode, al as createErrorFromResponse, am as createLogger, an as defaultHttpClient, ao as noopLogger, ap as resolveConfig, aq as sanitize } from './types-BPuPzIcL.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Request body for device-bound session completion (link protocol only).
|
|
@@ -25,6 +25,18 @@ interface CompleteRequest {
|
|
|
25
25
|
interface CompleteResponse {
|
|
26
26
|
/** Session status after successful device binding validation (always "completed") */
|
|
27
27
|
status: 'completed';
|
|
28
|
+
/**
|
|
29
|
+
* The session this response is about (the key prepare returned), so a result
|
|
30
|
+
* can be stored or logged without the request. Absent from servers older than
|
|
31
|
+
* the release that added it.
|
|
32
|
+
*/
|
|
33
|
+
session_key?: string;
|
|
34
|
+
/**
|
|
35
|
+
* The id of this request, the same value as the `X-Request-ID` response
|
|
36
|
+
* header. Quote it to Glide support. Absent from servers older than the
|
|
37
|
+
* release that added it.
|
|
38
|
+
*/
|
|
39
|
+
request_id?: string;
|
|
28
40
|
}
|
|
29
41
|
/**
|
|
30
42
|
* Returned with HTTP 202 when a desktop (QR) session's wait timer expires
|
|
@@ -46,6 +58,12 @@ interface DesktopWaitResponse {
|
|
|
46
58
|
retry: boolean;
|
|
47
59
|
/** Approximate seconds until the session expires */
|
|
48
60
|
session_expires_in_seconds: number;
|
|
61
|
+
/**
|
|
62
|
+
* The id of this request, the same value as the `X-Request-ID` response
|
|
63
|
+
* header. Quote it to Glide support. Absent from servers older than the
|
|
64
|
+
* release that added it.
|
|
65
|
+
*/
|
|
66
|
+
request_id?: string;
|
|
49
67
|
}
|
|
50
68
|
|
|
51
69
|
/** Request to check authentication eligibility. */
|
|
@@ -54,8 +72,12 @@ interface EligibilityRequest {
|
|
|
54
72
|
phone_number?: string;
|
|
55
73
|
/** PLMN (MCC+MNC). At least one of phone_number or plmn required. */
|
|
56
74
|
plmn?: PLMN;
|
|
57
|
-
/**
|
|
58
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Client info (with a non-blank `user_agent`). Required: eligibility filtering
|
|
77
|
+
* is device-aware and the server rejects a missing `client_info` or blank
|
|
78
|
+
* `user_agent` with 400 VALIDATION_ERROR.
|
|
79
|
+
*/
|
|
80
|
+
client_info: ClientInfo;
|
|
59
81
|
}
|
|
60
82
|
/** Constraints for the device that completes an option (always the phone). */
|
|
61
83
|
interface Requirements {
|
|
@@ -89,6 +111,111 @@ interface EligibilityResponse {
|
|
|
89
111
|
eligible: boolean;
|
|
90
112
|
/** Available authentication strategy options. */
|
|
91
113
|
available_options: AvailableOption[];
|
|
114
|
+
/**
|
|
115
|
+
* Normalized carrier name for the resolved network. Present only for callers
|
|
116
|
+
* the gateway has explicitly enabled to receive carrier information (the same
|
|
117
|
+
* per-app gate as `/prepare`); omitted otherwise and whenever `eligible` is false.
|
|
118
|
+
*/
|
|
119
|
+
carrier_name?: string;
|
|
120
|
+
/**
|
|
121
|
+
* The id of this request, the same value as the `X-Request-ID` response
|
|
122
|
+
* header. Quote it to Glide support. Absent from servers older than the
|
|
123
|
+
* release that added it.
|
|
124
|
+
*/
|
|
125
|
+
request_id?: string;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Options for `MagicalAuthClient.verifyVerificationRecord`. All optional.
|
|
130
|
+
*/
|
|
131
|
+
interface VerificationRecordOptions {
|
|
132
|
+
/** When set, must equal the record's nonce (the prepare nonce). */
|
|
133
|
+
expectedNonce?: string;
|
|
134
|
+
/**
|
|
135
|
+
* Accept a record past `exp`, for audit of stored records. The record's
|
|
136
|
+
* `iat` must still be within `maxAuditAgeSeconds`.
|
|
137
|
+
*/
|
|
138
|
+
allowExpired?: boolean;
|
|
139
|
+
/** Bounds `iat` when `allowExpired` is set. Missing, zero or negative means 90 days. */
|
|
140
|
+
maxAuditAgeSeconds?: number;
|
|
141
|
+
/** Overrides the expected `iss`. Empty means the client base URL without trailing "/". */
|
|
142
|
+
issuer?: string;
|
|
143
|
+
/** Rejected in addition to the SDK's built-in revoked list. */
|
|
144
|
+
revokedKids?: string[];
|
|
145
|
+
/** The record `aud` to require. Missing or empty means this client's ID. */
|
|
146
|
+
expectedAudience?: string;
|
|
147
|
+
/** When non-empty, the record's `origin` must equal one entry exactly. */
|
|
148
|
+
expectedOrigin?: readonly string[];
|
|
149
|
+
/** Overrides the clock used for claim checks (not the key cache). */
|
|
150
|
+
now?: () => Date;
|
|
151
|
+
}
|
|
152
|
+
/** One entry of the record's `sign_offs` claim. */
|
|
153
|
+
interface VerificationRecordSignOff {
|
|
154
|
+
role: string;
|
|
155
|
+
signer: string;
|
|
156
|
+
status: 'unavailable' | 'present';
|
|
157
|
+
reason?: string;
|
|
158
|
+
format?: string;
|
|
159
|
+
token?: string;
|
|
160
|
+
}
|
|
161
|
+
/** Optional carrier claim on a verified record. */
|
|
162
|
+
interface VerificationRecordCarrier {
|
|
163
|
+
id: string;
|
|
164
|
+
name?: string;
|
|
165
|
+
mvno?: string;
|
|
166
|
+
}
|
|
167
|
+
/** Swap age band in whole hours; -1 means unknown. */
|
|
168
|
+
interface VerificationRecordAgeBand {
|
|
169
|
+
from: number;
|
|
170
|
+
to: number;
|
|
171
|
+
}
|
|
172
|
+
/** A record's `sim_swap` or `device_swap` claim. */
|
|
173
|
+
interface VerificationRecordSwap {
|
|
174
|
+
checked: boolean;
|
|
175
|
+
risk_level?: string;
|
|
176
|
+
age_band?: VerificationRecordAgeBand;
|
|
177
|
+
carrier_name?: string;
|
|
178
|
+
reason?: string;
|
|
179
|
+
swapped?: boolean;
|
|
180
|
+
max_age_hours?: number;
|
|
181
|
+
}
|
|
182
|
+
/** Claims of a verified record, under their wire (snake_case) names. */
|
|
183
|
+
interface VerificationRecordClaims {
|
|
184
|
+
ver: '1.0';
|
|
185
|
+
iss: string;
|
|
186
|
+
sub: string;
|
|
187
|
+
aud: string;
|
|
188
|
+
iat: number;
|
|
189
|
+
nbf: number;
|
|
190
|
+
exp: number;
|
|
191
|
+
jti: string;
|
|
192
|
+
nonce: string;
|
|
193
|
+
origin: string;
|
|
194
|
+
use_case: string;
|
|
195
|
+
verified: boolean;
|
|
196
|
+
strategy?: string;
|
|
197
|
+
phone_number_details?: PhoneNumberDetails;
|
|
198
|
+
carrier?: VerificationRecordCarrier;
|
|
199
|
+
biometric_verification: BiometricVerification;
|
|
200
|
+
sim_swap?: VerificationRecordSwap;
|
|
201
|
+
device_swap?: VerificationRecordSwap;
|
|
202
|
+
sign_offs: VerificationRecordSignOff[];
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* How the SDK treated one sign-off: `unavailable` (with the server's reason)
|
|
206
|
+
* or `unverified`. A present sign-off is never treated as carrier trust in
|
|
207
|
+
* this version.
|
|
208
|
+
*/
|
|
209
|
+
interface SignOffResult {
|
|
210
|
+
role: string;
|
|
211
|
+
signer: string;
|
|
212
|
+
result: 'unavailable' | 'unverified';
|
|
213
|
+
reason?: string;
|
|
214
|
+
}
|
|
215
|
+
/** A record whose signature and claims passed every check. */
|
|
216
|
+
interface VerifiedVerificationRecord {
|
|
217
|
+
claims: VerificationRecordClaims;
|
|
218
|
+
signOffResults: SignOffResult[];
|
|
92
219
|
}
|
|
93
220
|
|
|
94
221
|
/**
|
|
@@ -125,6 +252,7 @@ interface RequestOptions {
|
|
|
125
252
|
declare class MagicalAuthClient {
|
|
126
253
|
private readonly config;
|
|
127
254
|
private readonly tokenManager;
|
|
255
|
+
private readonly recordKeys;
|
|
128
256
|
/**
|
|
129
257
|
* Creates a new MagicalAuthClient instance.
|
|
130
258
|
*
|
|
@@ -158,6 +286,20 @@ declare class MagicalAuthClient {
|
|
|
158
286
|
* @throws {MagicalAuthError} For other API errors
|
|
159
287
|
*/
|
|
160
288
|
prepare(request: PrepareRequest, options?: RequestOptions): Promise<PrepareResult>;
|
|
289
|
+
/**
|
|
290
|
+
* Prepares authentication for several phone numbers at once.
|
|
291
|
+
*
|
|
292
|
+
* Fans out one ordinary {@link prepare} call per number, so each number gets
|
|
293
|
+
* its own carrier resolution, residency routing and session. Per-number
|
|
294
|
+
* failures are returned as items rather than thrown; this only throws
|
|
295
|
+
* {@link ValidationError}, and only before any request is issued.
|
|
296
|
+
*
|
|
297
|
+
* @param request - Shared prepare fields plus `phone_numbers` (1..10)
|
|
298
|
+
* @param options - Per-request options (e.g., correlationId)
|
|
299
|
+
* @returns One result per input number, in input order
|
|
300
|
+
* @throws {ValidationError} If the list is empty, over the cap, has blank entries, or a shared prepare field is invalid
|
|
301
|
+
*/
|
|
302
|
+
prepareMultiple(request: PrepareMultipleRequest, options?: RequestOptions): Promise<PrepareMultipleResult[]>;
|
|
161
303
|
/**
|
|
162
304
|
* Validates device binding codes and completes a link protocol session.
|
|
163
305
|
*
|
|
@@ -189,6 +331,20 @@ declare class MagicalAuthClient {
|
|
|
189
331
|
* @throws {MagicalAuthError} For other API errors
|
|
190
332
|
*/
|
|
191
333
|
verifyPhoneNumber(request: VerifyPhoneNumberRequest, options?: RequestOptions): Promise<VerifyPhoneNumberResponse>;
|
|
334
|
+
/**
|
|
335
|
+
* Verifies a verification record returned by {@link verifyPhoneNumber}: the
|
|
336
|
+
* ES256 signature against Glide's published record keys, then issuer,
|
|
337
|
+
* the expected audience (default this client's ID), validity window, shape, nonce and origin.
|
|
338
|
+
*
|
|
339
|
+
* A missing or empty record fails with `RECORD_UNAVAILABLE`, so a caller
|
|
340
|
+
* that requires records can pass `response.verification_record` straight in.
|
|
341
|
+
*
|
|
342
|
+
* @param record - Compact JWS from `VerifyPhoneNumberResponse.verification_record`
|
|
343
|
+
* @param options - Expected nonce, expected audience, expected origins, audit mode, issuer override, extra revoked kids, clock
|
|
344
|
+
* @returns The verified claims and how each sign-off was treated
|
|
345
|
+
* @throws {VerificationRecordError} On any failed check; `code` is a {@link VerificationRecordErrorCode}
|
|
346
|
+
*/
|
|
347
|
+
verifyVerificationRecord(record: string | undefined, options?: VerificationRecordOptions): Promise<VerifiedVerificationRecord>;
|
|
192
348
|
/**
|
|
193
349
|
* Retrieves the phone number associated with the device using digital credentials.
|
|
194
350
|
*
|
|
@@ -412,8 +568,13 @@ declare function clearStaleBindingCookies(cookieHeader: string | undefined, opti
|
|
|
412
568
|
* `_glide_bind_{sessionKey}` HttpOnly cookie), and displays the result.
|
|
413
569
|
*
|
|
414
570
|
* On successful completion, a localStorage signal is written
|
|
415
|
-
* (`glide_signal_{session_key}`) so the FE SDK in the original
|
|
416
|
-
* detect completion via `StorageEvent` without polling
|
|
571
|
+
* (`glide_signal_{session_key}` = session_key) so the FE SDK in the original
|
|
572
|
+
* tab can detect completion via `StorageEvent` without polling, plus a
|
|
573
|
+
* sibling timestamp (`glide_sigmeta_{session_key}` = epoch ms) the FE SDK
|
|
574
|
+
* uses to sweep stale signals. Both keys stay for the session lifetime: the
|
|
575
|
+
* waiting tab may be suspended while the App Clip is in the foreground and
|
|
576
|
+
* must still find the signal when it resumes. The FE SDK removes them on
|
|
577
|
+
* consume; the page only erases them after 10 minutes as a fallback.
|
|
417
578
|
*
|
|
418
579
|
* @param completeEndpoint - Relative path to POST to (e.g., "/api/glide/complete")
|
|
419
580
|
* @returns Complete HTML string ready to serve
|
|
@@ -470,4 +631,4 @@ declare function getCompletionPageHtml(completeEndpoint: string): string;
|
|
|
470
631
|
*/
|
|
471
632
|
declare const VERSION: string;
|
|
472
633
|
|
|
473
|
-
export { AuthenticationStrategy, type AvailableOption, BINDING_COOKIE_MAX_AGE, BINDING_COOKIE_PREFIX, type BindingCookieOptions, ClientInfo, type CompleteRequest, type CompleteResponse, type DesktopWaitResponse, type EligibilityRequest, type EligibilityResponse, GetPhoneNumberRequest, GetPhoneNumberResponse, HEX_64, HttpClient, Logger, MagicalAuthClient, MagicalAuthConfig, PLMN, PrepareRequest, PrepareResult, ReportInvocationResponse, type RequestOptions, type Requirements, SENSITIVE_KEYS, StatusResponse, TokenManager, VERSION, VerifyPhoneNumberRequest, VerifyPhoneNumberResponse, assertValidFeCode, buildClearBindingCookieHeader, buildSetBindingCookieHeader, clearStaleBindingCookies, computeFeHash, generateFeCode, getBindingCookieName, getCompletionPageHtml, parseBindingCookie };
|
|
634
|
+
export { AuthenticationStrategy, type AvailableOption, BINDING_COOKIE_MAX_AGE, BINDING_COOKIE_PREFIX, type BindingCookieOptions, BiometricVerification, ClientInfo, type CompleteRequest, type CompleteResponse, type DesktopWaitResponse, type EligibilityRequest, type EligibilityResponse, GetPhoneNumberRequest, GetPhoneNumberResponse, HEX_64, HttpClient, Logger, MagicalAuthClient, MagicalAuthConfig, PLMN, PrepareMultipleRequest, PrepareMultipleResult, PrepareRequest, PrepareResult, ReportInvocationResponse, type RequestOptions, type Requirements, SENSITIVE_KEYS, type SignOffResult, StatusResponse, TokenManager, VERSION, type VerificationRecordAgeBand, type VerificationRecordCarrier, type VerificationRecordClaims, type VerificationRecordOptions, type VerificationRecordSignOff, type VerificationRecordSwap, type VerifiedVerificationRecord, VerifyPhoneNumberRequest, VerifyPhoneNumberResponse, assertValidFeCode, buildClearBindingCookieHeader, buildSetBindingCookieHeader, clearStaleBindingCookies, computeFeHash, generateFeCode, getBindingCookieName, getCompletionPageHtml, parseBindingCookie };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AuthenticationStrategy, P as PLMN,
|
|
2
|
-
export { B as BadRequestError,
|
|
1
|
+
import { A as AuthenticationStrategy, P as PLMN, f as ClientInfo, O as PhoneNumberDetails, a as BiometricVerification, M as MagicalAuthConfig, U as PrepareRequest, W as PrepareResult, R as PrepareMultipleRequest, S as PrepareMultipleResult, aj as VerifyPhoneNumberRequest, ak as VerifyPhoneNumberResponse, G as GetPhoneNumberRequest, s as GetPhoneNumberResponse, _ as ReportInvocationResponse, a8 as StatusResponse, H as HttpClient, w as Logger } from './types-BPuPzIcL.js';
|
|
2
|
+
export { B as BadRequestError, b as BrowserMismatchError, C as CarrierAppUnavailableError, c as CarrierNotEligibleError, d as CarrierRejectedError, e as Challenge, g as ConsentData, D as DCQLCredential, h as DCQLCredentialMeta, i as DCQLQuery, j as DEFAULT_BASE_URL, k as DEFAULT_TIMEOUT, l as DesktopQRData, m as DesktopStrategyData, n as DesktopWaitError, o as DeviceBindingError, p as DeviceInfo, q as DeviceSwapInfo, E as ErrorCode, r as ErrorResponse, F as ForbiddenError, t as HttpRequestOptions, u as HttpResponse, I as InternalServerError, v as InvalidCredentialError, L as LinkStrategyData, x as LoggerConfig, y as MagicalAuthError, z as MissingBindingCookieError, N as NetworkCheck, J as NetworkOrigin, K as PREPARE_MULTIPLE_MAX, Q as PhoneNumberMismatchError, T as PrepareOptions, V as PrepareResponse, X as ProtocolType, Y as RateLimitError, Z as ReportInvocationRequest, $ as ResolvedConfig, a0 as RiskLevel, a1 as ServiceUnavailableError, a2 as SessionInfo, a3 as SessionNotEligibleError, a4 as SessionNotFoundError, a5 as SessionStatus, a6 as SimSwapFailureReason, a7 as SimSwapInfo, a9 as StrategyData, aa as TS43RequestData, ab as TS43StrategyData, ac as Theme, ad as UnauthorizedError, ae as UnsupportedPlatformError, af as UseCase, ag as ValidationError, ah as VerificationRecordError, ai as VerificationRecordErrorCode, al as createErrorFromResponse, am as createLogger, an as defaultHttpClient, ao as noopLogger, ap as resolveConfig, aq as sanitize } from './types-BPuPzIcL.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Request body for device-bound session completion (link protocol only).
|
|
@@ -25,6 +25,18 @@ interface CompleteRequest {
|
|
|
25
25
|
interface CompleteResponse {
|
|
26
26
|
/** Session status after successful device binding validation (always "completed") */
|
|
27
27
|
status: 'completed';
|
|
28
|
+
/**
|
|
29
|
+
* The session this response is about (the key prepare returned), so a result
|
|
30
|
+
* can be stored or logged without the request. Absent from servers older than
|
|
31
|
+
* the release that added it.
|
|
32
|
+
*/
|
|
33
|
+
session_key?: string;
|
|
34
|
+
/**
|
|
35
|
+
* The id of this request, the same value as the `X-Request-ID` response
|
|
36
|
+
* header. Quote it to Glide support. Absent from servers older than the
|
|
37
|
+
* release that added it.
|
|
38
|
+
*/
|
|
39
|
+
request_id?: string;
|
|
28
40
|
}
|
|
29
41
|
/**
|
|
30
42
|
* Returned with HTTP 202 when a desktop (QR) session's wait timer expires
|
|
@@ -46,6 +58,12 @@ interface DesktopWaitResponse {
|
|
|
46
58
|
retry: boolean;
|
|
47
59
|
/** Approximate seconds until the session expires */
|
|
48
60
|
session_expires_in_seconds: number;
|
|
61
|
+
/**
|
|
62
|
+
* The id of this request, the same value as the `X-Request-ID` response
|
|
63
|
+
* header. Quote it to Glide support. Absent from servers older than the
|
|
64
|
+
* release that added it.
|
|
65
|
+
*/
|
|
66
|
+
request_id?: string;
|
|
49
67
|
}
|
|
50
68
|
|
|
51
69
|
/** Request to check authentication eligibility. */
|
|
@@ -54,8 +72,12 @@ interface EligibilityRequest {
|
|
|
54
72
|
phone_number?: string;
|
|
55
73
|
/** PLMN (MCC+MNC). At least one of phone_number or plmn required. */
|
|
56
74
|
plmn?: PLMN;
|
|
57
|
-
/**
|
|
58
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Client info (with a non-blank `user_agent`). Required: eligibility filtering
|
|
77
|
+
* is device-aware and the server rejects a missing `client_info` or blank
|
|
78
|
+
* `user_agent` with 400 VALIDATION_ERROR.
|
|
79
|
+
*/
|
|
80
|
+
client_info: ClientInfo;
|
|
59
81
|
}
|
|
60
82
|
/** Constraints for the device that completes an option (always the phone). */
|
|
61
83
|
interface Requirements {
|
|
@@ -89,6 +111,111 @@ interface EligibilityResponse {
|
|
|
89
111
|
eligible: boolean;
|
|
90
112
|
/** Available authentication strategy options. */
|
|
91
113
|
available_options: AvailableOption[];
|
|
114
|
+
/**
|
|
115
|
+
* Normalized carrier name for the resolved network. Present only for callers
|
|
116
|
+
* the gateway has explicitly enabled to receive carrier information (the same
|
|
117
|
+
* per-app gate as `/prepare`); omitted otherwise and whenever `eligible` is false.
|
|
118
|
+
*/
|
|
119
|
+
carrier_name?: string;
|
|
120
|
+
/**
|
|
121
|
+
* The id of this request, the same value as the `X-Request-ID` response
|
|
122
|
+
* header. Quote it to Glide support. Absent from servers older than the
|
|
123
|
+
* release that added it.
|
|
124
|
+
*/
|
|
125
|
+
request_id?: string;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Options for `MagicalAuthClient.verifyVerificationRecord`. All optional.
|
|
130
|
+
*/
|
|
131
|
+
interface VerificationRecordOptions {
|
|
132
|
+
/** When set, must equal the record's nonce (the prepare nonce). */
|
|
133
|
+
expectedNonce?: string;
|
|
134
|
+
/**
|
|
135
|
+
* Accept a record past `exp`, for audit of stored records. The record's
|
|
136
|
+
* `iat` must still be within `maxAuditAgeSeconds`.
|
|
137
|
+
*/
|
|
138
|
+
allowExpired?: boolean;
|
|
139
|
+
/** Bounds `iat` when `allowExpired` is set. Missing, zero or negative means 90 days. */
|
|
140
|
+
maxAuditAgeSeconds?: number;
|
|
141
|
+
/** Overrides the expected `iss`. Empty means the client base URL without trailing "/". */
|
|
142
|
+
issuer?: string;
|
|
143
|
+
/** Rejected in addition to the SDK's built-in revoked list. */
|
|
144
|
+
revokedKids?: string[];
|
|
145
|
+
/** The record `aud` to require. Missing or empty means this client's ID. */
|
|
146
|
+
expectedAudience?: string;
|
|
147
|
+
/** When non-empty, the record's `origin` must equal one entry exactly. */
|
|
148
|
+
expectedOrigin?: readonly string[];
|
|
149
|
+
/** Overrides the clock used for claim checks (not the key cache). */
|
|
150
|
+
now?: () => Date;
|
|
151
|
+
}
|
|
152
|
+
/** One entry of the record's `sign_offs` claim. */
|
|
153
|
+
interface VerificationRecordSignOff {
|
|
154
|
+
role: string;
|
|
155
|
+
signer: string;
|
|
156
|
+
status: 'unavailable' | 'present';
|
|
157
|
+
reason?: string;
|
|
158
|
+
format?: string;
|
|
159
|
+
token?: string;
|
|
160
|
+
}
|
|
161
|
+
/** Optional carrier claim on a verified record. */
|
|
162
|
+
interface VerificationRecordCarrier {
|
|
163
|
+
id: string;
|
|
164
|
+
name?: string;
|
|
165
|
+
mvno?: string;
|
|
166
|
+
}
|
|
167
|
+
/** Swap age band in whole hours; -1 means unknown. */
|
|
168
|
+
interface VerificationRecordAgeBand {
|
|
169
|
+
from: number;
|
|
170
|
+
to: number;
|
|
171
|
+
}
|
|
172
|
+
/** A record's `sim_swap` or `device_swap` claim. */
|
|
173
|
+
interface VerificationRecordSwap {
|
|
174
|
+
checked: boolean;
|
|
175
|
+
risk_level?: string;
|
|
176
|
+
age_band?: VerificationRecordAgeBand;
|
|
177
|
+
carrier_name?: string;
|
|
178
|
+
reason?: string;
|
|
179
|
+
swapped?: boolean;
|
|
180
|
+
max_age_hours?: number;
|
|
181
|
+
}
|
|
182
|
+
/** Claims of a verified record, under their wire (snake_case) names. */
|
|
183
|
+
interface VerificationRecordClaims {
|
|
184
|
+
ver: '1.0';
|
|
185
|
+
iss: string;
|
|
186
|
+
sub: string;
|
|
187
|
+
aud: string;
|
|
188
|
+
iat: number;
|
|
189
|
+
nbf: number;
|
|
190
|
+
exp: number;
|
|
191
|
+
jti: string;
|
|
192
|
+
nonce: string;
|
|
193
|
+
origin: string;
|
|
194
|
+
use_case: string;
|
|
195
|
+
verified: boolean;
|
|
196
|
+
strategy?: string;
|
|
197
|
+
phone_number_details?: PhoneNumberDetails;
|
|
198
|
+
carrier?: VerificationRecordCarrier;
|
|
199
|
+
biometric_verification: BiometricVerification;
|
|
200
|
+
sim_swap?: VerificationRecordSwap;
|
|
201
|
+
device_swap?: VerificationRecordSwap;
|
|
202
|
+
sign_offs: VerificationRecordSignOff[];
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* How the SDK treated one sign-off: `unavailable` (with the server's reason)
|
|
206
|
+
* or `unverified`. A present sign-off is never treated as carrier trust in
|
|
207
|
+
* this version.
|
|
208
|
+
*/
|
|
209
|
+
interface SignOffResult {
|
|
210
|
+
role: string;
|
|
211
|
+
signer: string;
|
|
212
|
+
result: 'unavailable' | 'unverified';
|
|
213
|
+
reason?: string;
|
|
214
|
+
}
|
|
215
|
+
/** A record whose signature and claims passed every check. */
|
|
216
|
+
interface VerifiedVerificationRecord {
|
|
217
|
+
claims: VerificationRecordClaims;
|
|
218
|
+
signOffResults: SignOffResult[];
|
|
92
219
|
}
|
|
93
220
|
|
|
94
221
|
/**
|
|
@@ -125,6 +252,7 @@ interface RequestOptions {
|
|
|
125
252
|
declare class MagicalAuthClient {
|
|
126
253
|
private readonly config;
|
|
127
254
|
private readonly tokenManager;
|
|
255
|
+
private readonly recordKeys;
|
|
128
256
|
/**
|
|
129
257
|
* Creates a new MagicalAuthClient instance.
|
|
130
258
|
*
|
|
@@ -158,6 +286,20 @@ declare class MagicalAuthClient {
|
|
|
158
286
|
* @throws {MagicalAuthError} For other API errors
|
|
159
287
|
*/
|
|
160
288
|
prepare(request: PrepareRequest, options?: RequestOptions): Promise<PrepareResult>;
|
|
289
|
+
/**
|
|
290
|
+
* Prepares authentication for several phone numbers at once.
|
|
291
|
+
*
|
|
292
|
+
* Fans out one ordinary {@link prepare} call per number, so each number gets
|
|
293
|
+
* its own carrier resolution, residency routing and session. Per-number
|
|
294
|
+
* failures are returned as items rather than thrown; this only throws
|
|
295
|
+
* {@link ValidationError}, and only before any request is issued.
|
|
296
|
+
*
|
|
297
|
+
* @param request - Shared prepare fields plus `phone_numbers` (1..10)
|
|
298
|
+
* @param options - Per-request options (e.g., correlationId)
|
|
299
|
+
* @returns One result per input number, in input order
|
|
300
|
+
* @throws {ValidationError} If the list is empty, over the cap, has blank entries, or a shared prepare field is invalid
|
|
301
|
+
*/
|
|
302
|
+
prepareMultiple(request: PrepareMultipleRequest, options?: RequestOptions): Promise<PrepareMultipleResult[]>;
|
|
161
303
|
/**
|
|
162
304
|
* Validates device binding codes and completes a link protocol session.
|
|
163
305
|
*
|
|
@@ -189,6 +331,20 @@ declare class MagicalAuthClient {
|
|
|
189
331
|
* @throws {MagicalAuthError} For other API errors
|
|
190
332
|
*/
|
|
191
333
|
verifyPhoneNumber(request: VerifyPhoneNumberRequest, options?: RequestOptions): Promise<VerifyPhoneNumberResponse>;
|
|
334
|
+
/**
|
|
335
|
+
* Verifies a verification record returned by {@link verifyPhoneNumber}: the
|
|
336
|
+
* ES256 signature against Glide's published record keys, then issuer,
|
|
337
|
+
* the expected audience (default this client's ID), validity window, shape, nonce and origin.
|
|
338
|
+
*
|
|
339
|
+
* A missing or empty record fails with `RECORD_UNAVAILABLE`, so a caller
|
|
340
|
+
* that requires records can pass `response.verification_record` straight in.
|
|
341
|
+
*
|
|
342
|
+
* @param record - Compact JWS from `VerifyPhoneNumberResponse.verification_record`
|
|
343
|
+
* @param options - Expected nonce, expected audience, expected origins, audit mode, issuer override, extra revoked kids, clock
|
|
344
|
+
* @returns The verified claims and how each sign-off was treated
|
|
345
|
+
* @throws {VerificationRecordError} On any failed check; `code` is a {@link VerificationRecordErrorCode}
|
|
346
|
+
*/
|
|
347
|
+
verifyVerificationRecord(record: string | undefined, options?: VerificationRecordOptions): Promise<VerifiedVerificationRecord>;
|
|
192
348
|
/**
|
|
193
349
|
* Retrieves the phone number associated with the device using digital credentials.
|
|
194
350
|
*
|
|
@@ -412,8 +568,13 @@ declare function clearStaleBindingCookies(cookieHeader: string | undefined, opti
|
|
|
412
568
|
* `_glide_bind_{sessionKey}` HttpOnly cookie), and displays the result.
|
|
413
569
|
*
|
|
414
570
|
* On successful completion, a localStorage signal is written
|
|
415
|
-
* (`glide_signal_{session_key}`) so the FE SDK in the original
|
|
416
|
-
* detect completion via `StorageEvent` without polling
|
|
571
|
+
* (`glide_signal_{session_key}` = session_key) so the FE SDK in the original
|
|
572
|
+
* tab can detect completion via `StorageEvent` without polling, plus a
|
|
573
|
+
* sibling timestamp (`glide_sigmeta_{session_key}` = epoch ms) the FE SDK
|
|
574
|
+
* uses to sweep stale signals. Both keys stay for the session lifetime: the
|
|
575
|
+
* waiting tab may be suspended while the App Clip is in the foreground and
|
|
576
|
+
* must still find the signal when it resumes. The FE SDK removes them on
|
|
577
|
+
* consume; the page only erases them after 10 minutes as a fallback.
|
|
417
578
|
*
|
|
418
579
|
* @param completeEndpoint - Relative path to POST to (e.g., "/api/glide/complete")
|
|
419
580
|
* @returns Complete HTML string ready to serve
|
|
@@ -470,4 +631,4 @@ declare function getCompletionPageHtml(completeEndpoint: string): string;
|
|
|
470
631
|
*/
|
|
471
632
|
declare const VERSION: string;
|
|
472
633
|
|
|
473
|
-
export { AuthenticationStrategy, type AvailableOption, BINDING_COOKIE_MAX_AGE, BINDING_COOKIE_PREFIX, type BindingCookieOptions, ClientInfo, type CompleteRequest, type CompleteResponse, type DesktopWaitResponse, type EligibilityRequest, type EligibilityResponse, GetPhoneNumberRequest, GetPhoneNumberResponse, HEX_64, HttpClient, Logger, MagicalAuthClient, MagicalAuthConfig, PLMN, PrepareRequest, PrepareResult, ReportInvocationResponse, type RequestOptions, type Requirements, SENSITIVE_KEYS, StatusResponse, TokenManager, VERSION, VerifyPhoneNumberRequest, VerifyPhoneNumberResponse, assertValidFeCode, buildClearBindingCookieHeader, buildSetBindingCookieHeader, clearStaleBindingCookies, computeFeHash, generateFeCode, getBindingCookieName, getCompletionPageHtml, parseBindingCookie };
|
|
634
|
+
export { AuthenticationStrategy, type AvailableOption, BINDING_COOKIE_MAX_AGE, BINDING_COOKIE_PREFIX, type BindingCookieOptions, BiometricVerification, ClientInfo, type CompleteRequest, type CompleteResponse, type DesktopWaitResponse, type EligibilityRequest, type EligibilityResponse, GetPhoneNumberRequest, GetPhoneNumberResponse, HEX_64, HttpClient, Logger, MagicalAuthClient, MagicalAuthConfig, PLMN, PrepareMultipleRequest, PrepareMultipleResult, PrepareRequest, PrepareResult, ReportInvocationResponse, type RequestOptions, type Requirements, SENSITIVE_KEYS, type SignOffResult, StatusResponse, TokenManager, VERSION, type VerificationRecordAgeBand, type VerificationRecordCarrier, type VerificationRecordClaims, type VerificationRecordOptions, type VerificationRecordSignOff, type VerificationRecordSwap, type VerifiedVerificationRecord, VerifyPhoneNumberRequest, VerifyPhoneNumberResponse, assertValidFeCode, buildClearBindingCookieHeader, buildSetBindingCookieHeader, clearStaleBindingCookies, computeFeHash, generateFeCode, getBindingCookieName, getCompletionPageHtml, parseBindingCookie };
|