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