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