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