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