@glideidentity/web-client-sdk 4.4.10 → 5.0.1-beta.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 +167 -19
- package/dist/adapters/angular/index.js +0 -1
- package/dist/adapters/angular/phone-auth.service.d.ts +0 -18
- package/dist/adapters/angular/phone-auth.service.js +0 -26
- package/dist/adapters/react/index.d.ts +1 -1
- package/dist/adapters/react/index.js +0 -3
- package/dist/adapters/react/useClient.js +0 -1
- package/dist/adapters/react/usePhoneAuth.js +1 -16
- package/dist/adapters/vanilla/client.js +0 -1
- package/dist/adapters/vanilla/index.js +0 -1
- package/dist/adapters/vanilla/phone-auth.js +0 -31
- package/dist/adapters/vue/index.d.ts +1 -1
- package/dist/adapters/vue/index.js +0 -4
- package/dist/adapters/vue/useClient.js +0 -5
- package/dist/adapters/vue/usePhoneAuth.js +1 -20
- package/dist/browser/web-client-sdk.min.js +1 -1
- package/dist/browser/web-client-sdk.min.js.LICENSE.txt +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +0 -6
- package/dist/core/client.js +0 -12
- package/dist/core/logger.js +1 -81
- package/dist/core/phone-auth/api-types.d.ts +0 -13
- package/dist/core/phone-auth/api-types.js +0 -83
- package/dist/core/phone-auth/client.js +27 -374
- package/dist/core/phone-auth/error-utils.js +1 -83
- package/dist/core/phone-auth/index.d.ts +1 -1
- package/dist/core/phone-auth/index.js +1 -3
- package/dist/core/phone-auth/status-types.d.ts +0 -78
- package/dist/core/phone-auth/status-types.js +0 -17
- package/dist/core/phone-auth/strategies/desktop.js +8 -126
- package/dist/core/phone-auth/strategies/index.d.ts +0 -4
- package/dist/core/phone-auth/strategies/index.js +0 -4
- package/dist/core/phone-auth/strategies/link.js +10 -88
- package/dist/core/phone-auth/strategies/ts43.d.ts +0 -19
- package/dist/core/phone-auth/strategies/ts43.js +2 -33
- package/dist/core/phone-auth/strategies/types.js +0 -4
- package/dist/core/phone-auth/type-guards.js +0 -131
- package/dist/core/phone-auth/types.js +0 -32
- package/dist/core/phone-auth/ui/mobile-debug-console.js +2 -28
- package/dist/core/phone-auth/ui/modal.d.ts +33 -55
- package/dist/core/phone-auth/ui/modal.js +889 -422
- package/dist/core/phone-auth/validation-utils.d.ts +0 -13
- package/dist/core/phone-auth/validation-utils.js +2 -81
- package/dist/core/version.js +1 -2
- package/dist/esm/adapters/angular/index.js +0 -1
- package/dist/esm/adapters/angular/phone-auth.service.d.ts +0 -18
- package/dist/esm/adapters/angular/phone-auth.service.js +0 -26
- package/dist/esm/adapters/react/index.d.ts +1 -1
- package/dist/esm/adapters/react/index.js +0 -3
- package/dist/esm/adapters/react/useClient.js +0 -1
- package/dist/esm/adapters/react/usePhoneAuth.js +1 -16
- package/dist/esm/adapters/vanilla/client.js +0 -1
- package/dist/esm/adapters/vanilla/index.js +0 -1
- package/dist/esm/adapters/vanilla/phone-auth.d.ts +0 -24
- package/dist/esm/adapters/vanilla/phone-auth.js +0 -31
- package/dist/esm/adapters/vue/index.d.ts +1 -1
- package/dist/esm/adapters/vue/index.js +0 -4
- package/dist/esm/adapters/vue/useClient.js +0 -5
- package/dist/esm/adapters/vue/usePhoneAuth.js +1 -20
- package/dist/esm/browser.d.ts +1 -1
- package/dist/esm/browser.js +0 -6
- package/dist/esm/core/client.d.ts +0 -10
- package/dist/esm/core/client.js +0 -12
- package/dist/esm/core/logger.d.ts +0 -53
- package/dist/esm/core/logger.js +1 -81
- package/dist/esm/core/phone-auth/api-types.d.ts +0 -328
- package/dist/esm/core/phone-auth/api-types.js +0 -83
- package/dist/esm/core/phone-auth/client.d.ts +0 -144
- package/dist/esm/core/phone-auth/client.js +28 -375
- package/dist/esm/core/phone-auth/error-utils.d.ts +0 -29
- package/dist/esm/core/phone-auth/error-utils.js +1 -83
- package/dist/esm/core/phone-auth/index.d.ts +1 -1
- package/dist/esm/core/phone-auth/index.js +2 -4
- package/dist/esm/core/phone-auth/status-types.d.ts +0 -78
- package/dist/esm/core/phone-auth/status-types.js +0 -17
- package/dist/esm/core/phone-auth/strategies/desktop.d.ts +0 -63
- package/dist/esm/core/phone-auth/strategies/desktop.js +8 -126
- package/dist/esm/core/phone-auth/strategies/index.d.ts +0 -4
- package/dist/esm/core/phone-auth/strategies/index.js +0 -4
- package/dist/esm/core/phone-auth/strategies/link.d.ts +0 -48
- package/dist/esm/core/phone-auth/strategies/link.js +10 -88
- package/dist/esm/core/phone-auth/strategies/ts43.d.ts +0 -19
- package/dist/esm/core/phone-auth/strategies/ts43.js +2 -33
- package/dist/esm/core/phone-auth/strategies/types.d.ts +0 -13
- package/dist/esm/core/phone-auth/strategies/types.js +0 -4
- package/dist/esm/core/phone-auth/type-guards.d.ts +0 -128
- package/dist/esm/core/phone-auth/type-guards.js +0 -131
- package/dist/esm/core/phone-auth/types.d.ts +0 -108
- package/dist/esm/core/phone-auth/types.js +0 -32
- package/dist/esm/core/phone-auth/ui/mobile-debug-console.d.ts +0 -4
- package/dist/esm/core/phone-auth/ui/mobile-debug-console.js +2 -28
- package/dist/esm/core/phone-auth/ui/modal.d.ts +27 -68
- package/dist/esm/core/phone-auth/ui/modal.js +889 -422
- package/dist/esm/core/phone-auth/validation-utils.d.ts +0 -44
- package/dist/esm/core/phone-auth/validation-utils.js +2 -80
- package/dist/esm/core/types.d.ts +0 -35
- package/dist/esm/core/version.js +1 -2
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.js +0 -7
- package/package.json +2 -2
|
@@ -1,63 +1,18 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Glide Phone Authentication API Types
|
|
3
|
-
*
|
|
4
|
-
* This file is copied from the master API specification at /glide-api-types.ts
|
|
5
|
-
* It defines the exact contract that ALL implementations must follow.
|
|
6
|
-
*
|
|
7
|
-
* NAMING CONVENTION:
|
|
8
|
-
* - ALL TYPES USE snake_case FOR API COMMUNICATION
|
|
9
|
-
* - Frontend SDKs should use snake_case throughout for consistency
|
|
10
|
-
* - This eliminates conversion errors and makes debugging easier
|
|
11
|
-
* - While not idiomatic JavaScript, it matches the API exactly
|
|
12
|
-
*/
|
|
13
|
-
/** E.164 format phone number: "+1234567890" */
|
|
14
1
|
export type PhoneNumber = string;
|
|
15
|
-
/** ISO 8601 timestamp: "2024-01-15T09:30:00Z" */
|
|
16
2
|
export type Timestamp = string;
|
|
17
|
-
/** RFC 4122 UUID: "550e8400-e29b-41d4-a716-446655440000" */
|
|
18
3
|
export type UUID = string;
|
|
19
|
-
/**
|
|
20
|
-
* Session information used across all operations
|
|
21
|
-
* Maintains state between prepare and process steps
|
|
22
|
-
*/
|
|
23
4
|
export interface SessionInfo {
|
|
24
|
-
/** Unique session identifier */
|
|
25
5
|
session_key: string;
|
|
26
|
-
/** Security nonce */
|
|
27
6
|
nonce?: string;
|
|
28
|
-
/** Encryption key for secure operations */
|
|
29
7
|
enc_key?: string;
|
|
30
|
-
/** Additional metadata from server */
|
|
31
8
|
metadata?: Record<string, string>;
|
|
32
9
|
}
|
|
33
|
-
/**
|
|
34
|
-
* Public Land Mobile Network identifiers
|
|
35
|
-
* Identifies the carrier network
|
|
36
|
-
*/
|
|
37
10
|
export interface PLMN {
|
|
38
|
-
/** Mobile Country Code (exactly 3 digits) */
|
|
39
11
|
mcc: string;
|
|
40
|
-
/** Mobile Network Code (2-3 digits) */
|
|
41
12
|
mnc: string;
|
|
42
13
|
}
|
|
43
|
-
/**
|
|
44
|
-
* User consent information for privacy compliance
|
|
45
|
-
*/
|
|
46
|
-
export interface ConsentData {
|
|
47
|
-
/** What the user is consenting to */
|
|
48
|
-
consent_text: string;
|
|
49
|
-
/** URL to privacy policy */
|
|
50
|
-
policy_link: string;
|
|
51
|
-
/** Brief policy description */
|
|
52
|
-
policy_text: string;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Browser/client information for strategy selection
|
|
56
|
-
*/
|
|
57
14
|
export interface ClientInfo {
|
|
58
|
-
/** navigator.userAgent */
|
|
59
15
|
user_agent: string;
|
|
60
|
-
/** navigator.platform */
|
|
61
16
|
platform: string;
|
|
62
17
|
}
|
|
63
18
|
export declare const USE_CASE: {
|
|
@@ -71,65 +26,25 @@ export declare const AUTHENTICATION_STRATEGY: {
|
|
|
71
26
|
readonly DESKTOP: "desktop";
|
|
72
27
|
};
|
|
73
28
|
export type AuthenticationStrategy = typeof AUTHENTICATION_STRATEGY[keyof typeof AUTHENTICATION_STRATEGY];
|
|
74
|
-
/**
|
|
75
|
-
* Advanced options for prepare requests
|
|
76
|
-
* Contains optional configuration for special features and future extensibility
|
|
77
|
-
*/
|
|
78
29
|
export interface PrepareOptions {
|
|
79
|
-
/**
|
|
80
|
-
* Parent session ID for desktop-mobile binding.
|
|
81
|
-
* When a mobile device scans a desktop QR code, the mobile session (child)
|
|
82
|
-
* links back to the desktop session (parent)
|
|
83
|
-
*/
|
|
84
30
|
parent_session_id?: string;
|
|
85
|
-
/**
|
|
86
|
-
* UI theme preference for consistency across all authentication touchpoints.
|
|
87
|
-
* Affects SDK modals, mobile app, and OAuth callback pages.
|
|
88
|
-
* @default 'dark'
|
|
89
|
-
*/
|
|
90
31
|
theme?: 'dark' | 'light';
|
|
91
|
-
/** Additional options can be added here for future extensibility */
|
|
92
32
|
[key: string]: any;
|
|
93
33
|
}
|
|
94
|
-
/**
|
|
95
|
-
* Request to prepare authentication session
|
|
96
|
-
* Note: nonce and id are auto-generated by SDKs if not provided
|
|
97
|
-
*/
|
|
98
34
|
export interface PrepareRequest {
|
|
99
|
-
/** Use case for this authentication (optional when parent_session_id is provided - inherited from parent) */
|
|
100
35
|
use_case?: UseCase;
|
|
101
|
-
/** One of these is required (or parent_session_id in options) */
|
|
102
|
-
/** E.164 format phone number */
|
|
103
36
|
phone_number?: PhoneNumber;
|
|
104
|
-
/** Alternative to phone_number */
|
|
105
37
|
plmn?: PLMN;
|
|
106
|
-
/** Optional: Auto-generated by SDKs if not provided */
|
|
107
|
-
/** Unique nonce (SDK generates secure random if not provided) */
|
|
108
38
|
nonce?: string;
|
|
109
|
-
/** Request identifier (SDK generates unique ID if not provided) */
|
|
110
39
|
id?: string;
|
|
111
|
-
/** Optional fields */
|
|
112
|
-
/** User consent information */
|
|
113
|
-
consent_data?: ConsentData;
|
|
114
|
-
/** Client information for strategy selection */
|
|
115
40
|
client_info?: ClientInfo;
|
|
116
|
-
/** Advanced options for special features */
|
|
117
41
|
options?: PrepareOptions;
|
|
118
42
|
}
|
|
119
|
-
/**
|
|
120
|
-
* Response from prepare authentication
|
|
121
|
-
*/
|
|
122
43
|
export interface PrepareResponse {
|
|
123
|
-
/** Selected authentication strategy */
|
|
124
44
|
authentication_strategy: AuthenticationStrategy;
|
|
125
|
-
/** Session information for subsequent requests - named 'session' consistently */
|
|
126
45
|
session: SessionInfo;
|
|
127
|
-
/** Strategy-specific data */
|
|
128
46
|
data: TS43Data | LinkData | DesktopData;
|
|
129
47
|
}
|
|
130
|
-
/**
|
|
131
|
-
* TS43 strategy data
|
|
132
|
-
*/
|
|
133
48
|
export interface TS43Data {
|
|
134
49
|
protocol: string;
|
|
135
50
|
data: {
|
|
@@ -149,142 +64,65 @@ export interface TS43Data {
|
|
|
149
64
|
};
|
|
150
65
|
};
|
|
151
66
|
}
|
|
152
|
-
/**
|
|
153
|
-
* Link strategy data
|
|
154
|
-
*/
|
|
155
67
|
export interface LinkData {
|
|
156
|
-
/** URL to redirect user to */
|
|
157
68
|
url: string;
|
|
158
|
-
/** URL to return to after authentication */
|
|
159
69
|
return_url?: string;
|
|
160
|
-
/** Status URL for polling authentication status */
|
|
161
70
|
status_url?: string;
|
|
162
|
-
/** Additional parameters */
|
|
163
71
|
params?: Record<string, string>;
|
|
164
72
|
}
|
|
165
|
-
/**
|
|
166
|
-
* Desktop strategy data
|
|
167
|
-
* Used for QR code-based authentication from desktop browsers
|
|
168
|
-
*/
|
|
169
73
|
export interface DesktopData {
|
|
170
|
-
/** Protocol version for QR authentication */
|
|
171
74
|
protocol?: string;
|
|
172
|
-
/** Inner data container with QR code details */
|
|
173
75
|
data?: {
|
|
174
|
-
/** QR code image as base64 data URI (data:image/png;base64,...) */
|
|
175
76
|
qr_code_image?: string;
|
|
176
|
-
/** Alternative field name for QR code (for compatibility) */
|
|
177
77
|
qr_code?: string;
|
|
178
|
-
/** iOS-specific QR code image */
|
|
179
78
|
ios_qr_image?: string;
|
|
180
|
-
/** Android-specific QR code image */
|
|
181
79
|
android_qr_image?: string;
|
|
182
|
-
/** iOS authentication URL */
|
|
183
80
|
ios_url?: string;
|
|
184
|
-
/** Android authentication URL */
|
|
185
81
|
android_url?: string;
|
|
186
|
-
/** Unique session identifier for the QR code */
|
|
187
82
|
session_id?: string;
|
|
188
|
-
/** Status polling URL */
|
|
189
83
|
status_url?: string;
|
|
190
|
-
/** Mobile authentication URL */
|
|
191
84
|
url?: string;
|
|
192
|
-
/** Polling interval in milliseconds (default: 2000) */
|
|
193
85
|
polling_interval?: number;
|
|
194
|
-
/** QR code expiration time in seconds */
|
|
195
86
|
expires_in?: number;
|
|
196
87
|
};
|
|
197
|
-
/** Legacy flat structure support */
|
|
198
|
-
/** QR code image as base64 data URI (data:image/png;base64,...) */
|
|
199
88
|
qr_code_image?: string;
|
|
200
|
-
/** Alternative field name for QR code (for compatibility) */
|
|
201
89
|
qr_code?: string;
|
|
202
|
-
/** iOS-specific QR code image */
|
|
203
90
|
ios_qr_image?: string;
|
|
204
|
-
/** Android-specific QR code image */
|
|
205
91
|
android_qr_image?: string;
|
|
206
|
-
/** iOS authentication URL */
|
|
207
92
|
ios_url?: string;
|
|
208
|
-
/** Android authentication URL */
|
|
209
93
|
android_url?: string;
|
|
210
|
-
/** Unique session identifier for the QR code */
|
|
211
94
|
session_id?: string;
|
|
212
|
-
/** Polling endpoint to check authentication status */
|
|
213
95
|
polling_endpoint?: string;
|
|
214
|
-
/** Status polling URL */
|
|
215
96
|
status_url?: string;
|
|
216
|
-
/** Polling interval in milliseconds (default: 2000) */
|
|
217
97
|
polling_interval?: number;
|
|
218
|
-
/** QR code expiration time in seconds */
|
|
219
98
|
expires_in?: number;
|
|
220
|
-
/** Optional deep link URL for mobile app */
|
|
221
99
|
deep_link?: string;
|
|
222
|
-
/** Mobile authentication URL */
|
|
223
100
|
url?: string;
|
|
224
101
|
}
|
|
225
|
-
/**
|
|
226
|
-
* Response from browser's Digital Credentials API
|
|
227
|
-
* This type is only used in frontend SDKs
|
|
228
|
-
*/
|
|
229
102
|
export interface SecureCredentialResponse {
|
|
230
103
|
vp_token: {
|
|
231
104
|
[aggregator_id: string]: string | string[];
|
|
232
105
|
};
|
|
233
106
|
}
|
|
234
|
-
/**
|
|
235
|
-
* Base type for processing credential requests
|
|
236
|
-
* Both GetPhoneNumber and VerifyPhoneNumber use the same request structure
|
|
237
|
-
* but are kept as separate types for:
|
|
238
|
-
* - Future extensibility (each may add unique fields)
|
|
239
|
-
* - Clear API semantics (distinct operations)
|
|
240
|
-
* - Type safety (prevents accidental misuse)
|
|
241
|
-
*/
|
|
242
|
-
/**
|
|
243
|
-
* Request to get phone number
|
|
244
|
-
*/
|
|
245
107
|
export interface GetPhoneNumberRequest {
|
|
246
|
-
/** Session from PrepareResponse - consistent naming */
|
|
247
108
|
session: SessionInfo;
|
|
248
|
-
/** Credential string extracted from SecureCredentialResponse.vp_token[id] */
|
|
249
109
|
credential: string;
|
|
250
|
-
/** Use case must be 'GetPhoneNumber' - required for server routing */
|
|
251
110
|
use_case: typeof USE_CASE.GET_PHONE_NUMBER;
|
|
252
111
|
}
|
|
253
|
-
/**
|
|
254
|
-
* Response with phone number
|
|
255
|
-
*/
|
|
256
112
|
export interface GetPhoneNumberResponse {
|
|
257
|
-
/** E.164 format phone number */
|
|
258
113
|
phone_number: PhoneNumber;
|
|
259
|
-
/** Audience from TS43 (optional) */
|
|
260
114
|
aud?: string;
|
|
261
115
|
}
|
|
262
|
-
/**
|
|
263
|
-
* Request to verify phone number
|
|
264
|
-
* Note: Similar to GetPhoneNumberRequest but with different use_case value
|
|
265
|
-
*/
|
|
266
116
|
export interface VerifyPhoneNumberRequest {
|
|
267
|
-
/** Session from PrepareResponse - consistent naming */
|
|
268
117
|
session: SessionInfo;
|
|
269
|
-
/** Credential string extracted from SecureCredentialResponse.vp_token[id] */
|
|
270
118
|
credential: string;
|
|
271
|
-
/** Use case must be 'VerifyPhoneNumber' - required for server routing */
|
|
272
119
|
use_case: typeof USE_CASE.VERIFY_PHONE_NUMBER;
|
|
273
120
|
}
|
|
274
|
-
/**
|
|
275
|
-
* Response from phone number verification
|
|
276
|
-
*/
|
|
277
121
|
export interface VerifyPhoneNumberResponse {
|
|
278
|
-
/** The phone number that was verified */
|
|
279
122
|
phone_number: PhoneNumber;
|
|
280
|
-
/** Whether verification was successful */
|
|
281
123
|
verified: boolean;
|
|
282
|
-
/** Audience from TS43 (optional) */
|
|
283
124
|
aud?: string;
|
|
284
125
|
}
|
|
285
|
-
/**
|
|
286
|
-
* Error codes - MUST match server implementation
|
|
287
|
-
*/
|
|
288
126
|
export declare const ERROR_CODE: {
|
|
289
127
|
readonly INVALID_PHONE_NUMBER: "INVALID_PHONE_NUMBER";
|
|
290
128
|
readonly MISSING_REQUIRED_FIELD: "MISSING_REQUIRED_FIELD";
|
|
@@ -302,272 +140,106 @@ export declare const ERROR_CODE: {
|
|
|
302
140
|
readonly SERVICE_UNAVAILABLE: "SERVICE_UNAVAILABLE";
|
|
303
141
|
};
|
|
304
142
|
export type ErrorCode = typeof ERROR_CODE[keyof typeof ERROR_CODE];
|
|
305
|
-
/**
|
|
306
|
-
* Error messages - User-friendly messages for each error code
|
|
307
|
-
*/
|
|
308
143
|
export declare const ERROR_MESSAGES: Record<ErrorCode, string>;
|
|
309
|
-
/**
|
|
310
|
-
* HTTP status codes for each error
|
|
311
|
-
*/
|
|
312
144
|
export declare const ERROR_STATUS_CODES: Record<ErrorCode, number>;
|
|
313
|
-
/**
|
|
314
|
-
* Additional error details
|
|
315
|
-
*/
|
|
316
145
|
export interface ErrorDetails {
|
|
317
|
-
/** Field that caused the error */
|
|
318
146
|
field?: string;
|
|
319
|
-
/** Detailed reason for the error */
|
|
320
147
|
reason?: string;
|
|
321
|
-
/** Carrier name for carrier-specific errors */
|
|
322
148
|
carrier_name?: string;
|
|
323
|
-
/** Seconds until retry allowed (for rate limits) */
|
|
324
149
|
retry_after?: number;
|
|
325
|
-
/** Additional context */
|
|
326
150
|
[key: string]: any;
|
|
327
151
|
}
|
|
328
|
-
/**
|
|
329
|
-
* Standard error response format
|
|
330
|
-
*/
|
|
331
152
|
export interface ErrorResponse {
|
|
332
|
-
/** Machine-readable error code */
|
|
333
153
|
code: ErrorCode;
|
|
334
|
-
/** User-friendly error message */
|
|
335
154
|
message: string;
|
|
336
|
-
/** Request tracking ID */
|
|
337
155
|
request_id?: UUID;
|
|
338
|
-
/** ISO 8601 timestamp */
|
|
339
156
|
timestamp?: Timestamp;
|
|
340
|
-
/** Distributed tracing ID */
|
|
341
157
|
trace_id?: string;
|
|
342
|
-
/** Span ID for tracing */
|
|
343
158
|
span_id?: string;
|
|
344
|
-
/** Service that generated the error */
|
|
345
159
|
service?: string;
|
|
346
|
-
/** Additional error context */
|
|
347
160
|
details?: ErrorDetails;
|
|
348
161
|
}
|
|
349
|
-
/**
|
|
350
|
-
* E.164 phone number validation regex
|
|
351
|
-
*/
|
|
352
162
|
export declare const E164_REGEX: RegExp;
|
|
353
|
-
/**
|
|
354
|
-
* Validate phone number format
|
|
355
|
-
*/
|
|
356
163
|
export declare function validatePhoneNumber(phone: string): boolean;
|
|
357
|
-
/**
|
|
358
|
-
* Validate PLMN format
|
|
359
|
-
*/
|
|
360
164
|
export declare function validatePLMN(plmn: PLMN): boolean;
|
|
361
|
-
/**
|
|
362
|
-
* Validate session info
|
|
363
|
-
*/
|
|
364
165
|
export declare function validateSession(session: SessionInfo): boolean;
|
|
365
|
-
/**
|
|
366
|
-
* Validate use case
|
|
367
|
-
*/
|
|
368
166
|
export declare function validateUseCase(useCase: string): useCase is UseCase;
|
|
369
|
-
/**
|
|
370
|
-
* Create error response helper
|
|
371
|
-
*/
|
|
372
167
|
export declare function createErrorResponse(code: ErrorCode, details?: ErrorDetails, requestId?: string): ErrorResponse;
|
|
373
|
-
/**
|
|
374
|
-
* Get HTTP status code for error
|
|
375
|
-
*/
|
|
376
168
|
export declare function getErrorStatusCode(code: ErrorCode): number;
|
|
377
|
-
/**
|
|
378
|
-
* Check if data is TS43 strategy data
|
|
379
|
-
*/
|
|
380
169
|
export declare function isTS43Data(data: any): data is TS43Data;
|
|
381
|
-
/**
|
|
382
|
-
* Check if data is Link strategy data
|
|
383
|
-
*/
|
|
384
170
|
export declare function isLinkData(data: any): data is LinkData;
|
|
385
|
-
/**
|
|
386
|
-
* Check if response is an error
|
|
387
|
-
*/
|
|
388
171
|
export declare function isErrorResponse(response: any): response is ErrorResponse;
|
|
389
|
-
/**
|
|
390
|
-
* Execution mode for authentication flow
|
|
391
|
-
*/
|
|
392
172
|
export type ExecutionMode = 'standard' | 'extended';
|
|
393
|
-
/**
|
|
394
|
-
* Options for invokeSecurePrompt to control UI behavior
|
|
395
|
-
*/
|
|
396
173
|
export interface InvokeOptions {
|
|
397
|
-
/**
|
|
398
|
-
* Prevents SDK from showing its own UI components.
|
|
399
|
-
* Only affects Desktop strategy (shows modal by default).
|
|
400
|
-
* Link/TS43 never show SDK UI, so this has no effect on them.
|
|
401
|
-
*
|
|
402
|
-
* @default false
|
|
403
|
-
*/
|
|
404
174
|
preventDefaultUI?: boolean;
|
|
405
|
-
/**
|
|
406
|
-
* Controls the response type:
|
|
407
|
-
* - 'standard': Returns credential when complete (Promise<AuthCredential>)
|
|
408
|
-
* - 'extended': Returns control methods + credential promise
|
|
409
|
-
*
|
|
410
|
-
* @default 'standard'
|
|
411
|
-
*/
|
|
412
175
|
executionMode?: ExecutionMode;
|
|
413
|
-
/**
|
|
414
|
-
* UI theme to use for modals and components
|
|
415
|
-
* @default 'dark'
|
|
416
|
-
*/
|
|
417
176
|
theme?: 'dark' | 'light';
|
|
418
|
-
/**
|
|
419
|
-
* Whether to automatically trigger the authentication
|
|
420
|
-
* - For Link: automatically opens App Clip URL on invocation
|
|
421
|
-
* - For TS43: attempts to trigger credential API (may fail due to browser restrictions)
|
|
422
|
-
* - For Desktop: N/A (QR code is shown)
|
|
423
|
-
* @default true
|
|
424
|
-
*/
|
|
425
177
|
autoTrigger?: boolean;
|
|
426
|
-
/**
|
|
427
|
-
* Called when trigger is attempted (for Link/TS43)
|
|
428
|
-
* @param data Information about the trigger attempt
|
|
429
|
-
*/
|
|
430
178
|
onTriggerAttempt?: (data: {
|
|
431
179
|
strategy: string;
|
|
432
180
|
url?: string;
|
|
433
181
|
success?: boolean;
|
|
434
182
|
error?: any;
|
|
435
183
|
}) => void;
|
|
436
|
-
/**
|
|
437
|
-
* Options for customizing the modal UI (only used when preventDefaultUI=false)
|
|
438
|
-
* Simplified to only include commonly used options
|
|
439
|
-
*/
|
|
440
184
|
modalOptions?: {
|
|
441
|
-
/** CSS class to add to the modal container */
|
|
442
185
|
className?: string;
|
|
443
|
-
/** Title text for the modal */
|
|
444
186
|
title?: string;
|
|
445
|
-
/** Description text for the modal */
|
|
446
187
|
description?: string;
|
|
447
|
-
/** Button text */
|
|
448
188
|
buttonText?: string;
|
|
449
|
-
/** Whether to show close button @default true */
|
|
450
189
|
showCloseButton?: boolean;
|
|
451
|
-
/** Allow closing modal by clicking backdrop/overlay @default true */
|
|
452
190
|
closeOnBackdrop?: boolean;
|
|
453
|
-
/** Allow closing modal by pressing Escape key @default true */
|
|
454
191
|
closeOnEscape?: boolean;
|
|
455
192
|
};
|
|
456
|
-
/**
|
|
457
|
-
* Callback functions for UI events (only used when preventDefaultUI=false)
|
|
458
|
-
*/
|
|
459
193
|
callbacks?: {
|
|
460
|
-
/** Called when modal is opened */
|
|
461
194
|
onOpen?: () => void;
|
|
462
|
-
/** Called when modal is closed */
|
|
463
195
|
onClose?: () => void;
|
|
464
|
-
/** Called when authentication starts */
|
|
465
196
|
onAuthStart?: () => void;
|
|
466
|
-
/** Called when authentication completes */
|
|
467
197
|
onAuthComplete?: (result: any) => void;
|
|
468
|
-
/** Called on error */
|
|
469
198
|
onError?: (error: Error) => void;
|
|
470
199
|
};
|
|
471
|
-
/**
|
|
472
|
-
* Custom polling endpoint for Desktop/Link strategies
|
|
473
|
-
* Overrides the SDK configured endpoint and backend-provided status URL
|
|
474
|
-
* Useful for testing or using a proxy endpoint
|
|
475
|
-
* @example '/api/phone-auth/status' or 'https://custom-polling.example.com/status'
|
|
476
|
-
*/
|
|
477
200
|
pollingEndpoint?: string;
|
|
478
|
-
/**
|
|
479
|
-
* Custom polling interval in milliseconds
|
|
480
|
-
* @default 2000 (2 seconds)
|
|
481
|
-
*/
|
|
482
201
|
pollingInterval?: number;
|
|
483
|
-
/**
|
|
484
|
-
* Maximum number of polling attempts before timeout
|
|
485
|
-
* @default 30 (1 minute with 2s interval)
|
|
486
|
-
*/
|
|
487
202
|
maxPollingAttempts?: number;
|
|
488
203
|
}
|
|
489
|
-
/**
|
|
490
|
-
* Authentication credential result
|
|
491
|
-
*/
|
|
492
204
|
export interface AuthCredential {
|
|
493
|
-
/** Authentication credential token */
|
|
494
205
|
credential: string;
|
|
495
|
-
/** Phone number if available */
|
|
496
206
|
phone_number?: PhoneNumber;
|
|
497
|
-
/** Session information */
|
|
498
207
|
session: SessionInfo;
|
|
499
|
-
/** Whether authentication was successful */
|
|
500
208
|
authenticated: boolean;
|
|
501
209
|
}
|
|
502
|
-
/**
|
|
503
|
-
* Base interface for extended mode responses
|
|
504
|
-
*/
|
|
505
210
|
export interface ExtendedResponse {
|
|
506
|
-
/** Authentication strategy */
|
|
507
211
|
strategy: AuthenticationStrategy;
|
|
508
|
-
/** Session information */
|
|
509
212
|
session: SessionInfo;
|
|
510
|
-
/** Promise that resolves to the credential */
|
|
511
213
|
credential: Promise<AuthCredential>;
|
|
512
|
-
/** Cancel the authentication flow */
|
|
513
214
|
cancel: () => void;
|
|
514
215
|
}
|
|
515
|
-
/**
|
|
516
|
-
* Extended response for Desktop strategy.
|
|
517
|
-
* Note: Polling starts immediately even with preventDefaultUI: true (consistent with Link strategy)
|
|
518
|
-
*/
|
|
519
216
|
export interface DesktopExtendedResponse extends ExtendedResponse {
|
|
520
217
|
strategy: 'desktop';
|
|
521
|
-
/** QR code data for custom UI */
|
|
522
218
|
qr_code_data: {
|
|
523
|
-
/** iOS QR code image */
|
|
524
219
|
ios_qr_image?: string;
|
|
525
|
-
/** Android QR code image */
|
|
526
220
|
android_qr_image?: string;
|
|
527
|
-
/** Generic QR code image */
|
|
528
221
|
qr_code?: string;
|
|
529
|
-
/** Challenge pattern */
|
|
530
222
|
challenge?: any;
|
|
531
223
|
};
|
|
532
|
-
/** Returns the existing polling promise (polling starts immediately) */
|
|
533
224
|
start_polling: () => Promise<AuthCredential>;
|
|
534
|
-
/** Stop polling */
|
|
535
225
|
stop_polling: () => void;
|
|
536
|
-
/** Whether currently polling */
|
|
537
226
|
is_polling: boolean;
|
|
538
|
-
/** Modal reference if UI was shown */
|
|
539
227
|
modal_ref?: any;
|
|
540
228
|
}
|
|
541
|
-
/**
|
|
542
|
-
* Extended response for Link strategy
|
|
543
|
-
*/
|
|
544
229
|
export interface LinkExtendedResponse extends ExtendedResponse {
|
|
545
230
|
strategy: 'link';
|
|
546
|
-
/** Additional data for Link strategy */
|
|
547
231
|
data: {
|
|
548
|
-
/** App URL that was opened */
|
|
549
232
|
app_url: string;
|
|
550
233
|
};
|
|
551
|
-
/** Re-open the app link */
|
|
552
234
|
trigger: () => void;
|
|
553
|
-
/** Start or restart polling */
|
|
554
235
|
start_polling?: () => Promise<AuthCredential>;
|
|
555
|
-
/** Stop polling */
|
|
556
236
|
stop_polling?: () => void;
|
|
557
|
-
/** Whether currently polling */
|
|
558
237
|
is_polling?: boolean;
|
|
559
238
|
}
|
|
560
|
-
/**
|
|
561
|
-
* Extended response for TS43 strategy
|
|
562
|
-
*/
|
|
563
239
|
export interface TS43ExtendedResponse extends ExtendedResponse {
|
|
564
240
|
strategy: 'ts43';
|
|
565
|
-
/** Re-trigger credential request */
|
|
566
241
|
trigger: () => Promise<void>;
|
|
567
242
|
}
|
|
568
|
-
/**
|
|
569
|
-
* Combined type for all extended responses
|
|
570
|
-
*/
|
|
571
243
|
export type AnyExtendedResponse = DesktopExtendedResponse | LinkExtendedResponse | TS43ExtendedResponse;
|
|
572
244
|
declare const _default: {
|
|
573
245
|
USE_CASE: {
|