@glideidentity/web-client-sdk 5.1.2 → 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.
Files changed (203) hide show
  1. package/README.md +337 -526
  2. package/dist/browser/web-client-sdk.min.js +1 -1
  3. package/dist/cjs/adapters/index.js +15 -0
  4. package/dist/cjs/adapters/react.js +192 -0
  5. package/dist/cjs/adapters/vanilla.js +38 -0
  6. package/dist/cjs/adapters/vue.js +187 -0
  7. package/dist/cjs/browser.js +58 -0
  8. package/dist/cjs/client/http.js +159 -0
  9. package/dist/cjs/client/index.js +19 -0
  10. package/dist/cjs/client/logger.js +135 -0
  11. package/dist/cjs/client/phone-auth-client.js +439 -0
  12. package/dist/cjs/client/strategies/polling.js +177 -0
  13. package/dist/cjs/core/errors.js +204 -0
  14. package/dist/cjs/core/index.js +83 -0
  15. package/dist/cjs/core/type-guards.js +196 -0
  16. package/dist/cjs/core/types.js +25 -0
  17. package/dist/{core/phone-auth/validation-utils.js → cjs/core/validators.js} +70 -23
  18. package/dist/cjs/index.js +81 -0
  19. package/dist/cjs/ui/index.js +11 -0
  20. package/dist/{core/phone-auth → cjs}/ui/mobile-debug-console.js +149 -78
  21. package/dist/cjs/ui/modal.js +1122 -0
  22. package/dist/esm/adapters/index.js +11 -0
  23. package/dist/esm/adapters/react.js +182 -0
  24. package/dist/esm/adapters/vanilla.js +29 -0
  25. package/dist/esm/adapters/vue.js +177 -0
  26. package/dist/esm/browser.js +30 -11
  27. package/dist/esm/client/http.js +156 -0
  28. package/dist/esm/client/index.js +11 -0
  29. package/dist/esm/client/logger.js +131 -0
  30. package/dist/esm/client/phone-auth-client.js +435 -0
  31. package/dist/esm/client/strategies/polling.js +174 -0
  32. package/dist/esm/core/errors.js +193 -0
  33. package/dist/esm/core/index.js +60 -0
  34. package/dist/esm/core/type-guards.js +181 -0
  35. package/dist/esm/core/types.js +22 -1
  36. package/dist/esm/core/{phone-auth/validation-utils.js → validators.js} +66 -21
  37. package/dist/esm/index.js +45 -17
  38. package/dist/esm/ui/index.js +5 -0
  39. package/dist/esm/{core/phone-auth/ui → ui}/mobile-debug-console.js +149 -78
  40. package/dist/esm/ui/modal.js +1117 -0
  41. package/dist/types/adapters/index.d.ts +10 -0
  42. package/dist/types/adapters/index.d.ts.map +1 -0
  43. package/dist/types/adapters/react.d.ts +70 -0
  44. package/dist/types/adapters/react.d.ts.map +1 -0
  45. package/dist/types/adapters/vanilla.d.ts +29 -0
  46. package/dist/types/adapters/vanilla.d.ts.map +1 -0
  47. package/dist/types/adapters/vue.d.ts +71 -0
  48. package/dist/types/adapters/vue.d.ts.map +1 -0
  49. package/dist/types/browser.d.ts +27 -0
  50. package/dist/types/browser.d.ts.map +1 -0
  51. package/dist/types/client/http.d.ts +41 -0
  52. package/dist/types/client/http.d.ts.map +1 -0
  53. package/dist/types/client/index.d.ts +10 -0
  54. package/dist/types/client/index.d.ts.map +1 -0
  55. package/dist/types/client/logger.d.ts +36 -0
  56. package/dist/types/client/logger.d.ts.map +1 -0
  57. package/dist/types/client/phone-auth-client.d.ts +91 -0
  58. package/dist/types/client/phone-auth-client.d.ts.map +1 -0
  59. package/dist/types/client/strategies/polling.d.ts +36 -0
  60. package/dist/types/client/strategies/polling.d.ts.map +1 -0
  61. package/dist/types/core/errors.d.ts +71 -0
  62. package/dist/types/core/errors.d.ts.map +1 -0
  63. package/dist/types/core/index.d.ts +38 -0
  64. package/dist/types/core/index.d.ts.map +1 -0
  65. package/dist/types/core/type-guards.d.ts +118 -0
  66. package/dist/types/core/type-guards.d.ts.map +1 -0
  67. package/dist/types/core/types.d.ts +534 -0
  68. package/dist/types/core/types.d.ts.map +1 -0
  69. package/dist/types/core/validators.d.ts +63 -0
  70. package/dist/types/core/validators.d.ts.map +1 -0
  71. package/dist/types/index.d.ts +40 -0
  72. package/dist/types/index.d.ts.map +1 -0
  73. package/dist/types/ui/index.d.ts +6 -0
  74. package/dist/types/ui/index.d.ts.map +1 -0
  75. package/dist/{esm/core/phone-auth → types}/ui/mobile-debug-console.d.ts +1 -0
  76. package/dist/types/ui/mobile-debug-console.d.ts.map +1 -0
  77. package/dist/types/ui/modal.d.ts +87 -0
  78. package/dist/types/ui/modal.d.ts.map +1 -0
  79. package/package.json +48 -34
  80. package/dist/adapters/angular/client.service.d.ts +0 -7
  81. package/dist/adapters/angular/client.service.js +0 -30
  82. package/dist/adapters/angular/index.d.ts +0 -3
  83. package/dist/adapters/angular/index.js +0 -18
  84. package/dist/adapters/angular/phone-auth.service.d.ts +0 -38
  85. package/dist/adapters/angular/phone-auth.service.js +0 -130
  86. package/dist/adapters/react/index.d.ts +0 -9
  87. package/dist/adapters/react/index.js +0 -28
  88. package/dist/adapters/react/useClient.d.ts +0 -26
  89. package/dist/adapters/react/useClient.js +0 -121
  90. package/dist/adapters/react/usePhoneAuth.d.ts +0 -23
  91. package/dist/adapters/react/usePhoneAuth.js +0 -95
  92. package/dist/adapters/vanilla/client.d.ts +0 -8
  93. package/dist/adapters/vanilla/client.js +0 -33
  94. package/dist/adapters/vanilla/index.d.ts +0 -3
  95. package/dist/adapters/vanilla/index.js +0 -18
  96. package/dist/adapters/vanilla/phone-auth.d.ts +0 -46
  97. package/dist/adapters/vanilla/phone-auth.js +0 -138
  98. package/dist/adapters/vue/index.d.ts +0 -10
  99. package/dist/adapters/vue/index.js +0 -36
  100. package/dist/adapters/vue/useClient.d.ts +0 -115
  101. package/dist/adapters/vue/useClient.js +0 -131
  102. package/dist/adapters/vue/usePhoneAuth.d.ts +0 -94
  103. package/dist/adapters/vue/usePhoneAuth.js +0 -103
  104. package/dist/browser.d.ts +0 -7
  105. package/dist/browser.js +0 -31
  106. package/dist/core/client.d.ts +0 -22
  107. package/dist/core/client.js +0 -77
  108. package/dist/core/logger.d.ts +0 -130
  109. package/dist/core/logger.js +0 -370
  110. package/dist/core/phone-auth/api-types.d.ts +0 -593
  111. package/dist/core/phone-auth/api-types.js +0 -215
  112. package/dist/core/phone-auth/client.d.ts +0 -189
  113. package/dist/core/phone-auth/client.js +0 -1441
  114. package/dist/core/phone-auth/error-utils.d.ts +0 -110
  115. package/dist/core/phone-auth/error-utils.js +0 -350
  116. package/dist/core/phone-auth/index.d.ts +0 -7
  117. package/dist/core/phone-auth/index.js +0 -50
  118. package/dist/core/phone-auth/status-types.d.ts +0 -107
  119. package/dist/core/phone-auth/status-types.js +0 -31
  120. package/dist/core/phone-auth/strategies/desktop.d.ts +0 -122
  121. package/dist/core/phone-auth/strategies/desktop.js +0 -596
  122. package/dist/core/phone-auth/strategies/index.d.ts +0 -11
  123. package/dist/core/phone-auth/strategies/index.js +0 -15
  124. package/dist/core/phone-auth/strategies/link.d.ts +0 -89
  125. package/dist/core/phone-auth/strategies/link.js +0 -384
  126. package/dist/core/phone-auth/strategies/ts43.d.ts +0 -32
  127. package/dist/core/phone-auth/strategies/ts43.js +0 -151
  128. package/dist/core/phone-auth/strategies/types.d.ts +0 -18
  129. package/dist/core/phone-auth/strategies/types.js +0 -6
  130. package/dist/core/phone-auth/type-guards.d.ts +0 -143
  131. package/dist/core/phone-auth/type-guards.js +0 -198
  132. package/dist/core/phone-auth/types.d.ts +0 -237
  133. package/dist/core/phone-auth/types.js +0 -93
  134. package/dist/core/phone-auth/ui/mobile-debug-console.d.ts +0 -25
  135. package/dist/core/phone-auth/ui/modal.d.ts +0 -88
  136. package/dist/core/phone-auth/ui/modal.js +0 -598
  137. package/dist/core/phone-auth/validation-utils.d.ts +0 -44
  138. package/dist/core/types.d.ts +0 -62
  139. package/dist/core/types.js +0 -2
  140. package/dist/core/version.d.ts +0 -1
  141. package/dist/core/version.js +0 -5
  142. package/dist/esm/adapters/angular/client.service.d.ts +0 -7
  143. package/dist/esm/adapters/angular/client.service.js +0 -27
  144. package/dist/esm/adapters/angular/index.d.ts +0 -3
  145. package/dist/esm/adapters/angular/index.js +0 -4
  146. package/dist/esm/adapters/angular/phone-auth.service.d.ts +0 -38
  147. package/dist/esm/adapters/angular/phone-auth.service.js +0 -127
  148. package/dist/esm/adapters/react/index.d.ts +0 -9
  149. package/dist/esm/adapters/react/index.js +0 -8
  150. package/dist/esm/adapters/react/useClient.d.ts +0 -26
  151. package/dist/esm/adapters/react/useClient.js +0 -116
  152. package/dist/esm/adapters/react/usePhoneAuth.d.ts +0 -23
  153. package/dist/esm/adapters/react/usePhoneAuth.js +0 -92
  154. package/dist/esm/adapters/vanilla/client.d.ts +0 -8
  155. package/dist/esm/adapters/vanilla/client.js +0 -29
  156. package/dist/esm/adapters/vanilla/index.d.ts +0 -3
  157. package/dist/esm/adapters/vanilla/index.js +0 -4
  158. package/dist/esm/adapters/vanilla/phone-auth.d.ts +0 -46
  159. package/dist/esm/adapters/vanilla/phone-auth.js +0 -134
  160. package/dist/esm/adapters/vue/index.d.ts +0 -10
  161. package/dist/esm/adapters/vue/index.js +0 -11
  162. package/dist/esm/adapters/vue/useClient.d.ts +0 -115
  163. package/dist/esm/adapters/vue/useClient.js +0 -127
  164. package/dist/esm/adapters/vue/usePhoneAuth.d.ts +0 -94
  165. package/dist/esm/adapters/vue/usePhoneAuth.js +0 -100
  166. package/dist/esm/browser.d.ts +0 -7
  167. package/dist/esm/core/client.d.ts +0 -22
  168. package/dist/esm/core/client.js +0 -70
  169. package/dist/esm/core/logger.d.ts +0 -130
  170. package/dist/esm/core/logger.js +0 -359
  171. package/dist/esm/core/phone-auth/api-types.d.ts +0 -593
  172. package/dist/esm/core/phone-auth/api-types.js +0 -203
  173. package/dist/esm/core/phone-auth/client.d.ts +0 -189
  174. package/dist/esm/core/phone-auth/client.js +0 -1404
  175. package/dist/esm/core/phone-auth/error-utils.d.ts +0 -110
  176. package/dist/esm/core/phone-auth/error-utils.js +0 -338
  177. package/dist/esm/core/phone-auth/index.d.ts +0 -7
  178. package/dist/esm/core/phone-auth/index.js +0 -8
  179. package/dist/esm/core/phone-auth/status-types.d.ts +0 -107
  180. package/dist/esm/core/phone-auth/status-types.js +0 -26
  181. package/dist/esm/core/phone-auth/strategies/desktop.d.ts +0 -122
  182. package/dist/esm/core/phone-auth/strategies/desktop.js +0 -590
  183. package/dist/esm/core/phone-auth/strategies/index.d.ts +0 -11
  184. package/dist/esm/core/phone-auth/strategies/index.js +0 -7
  185. package/dist/esm/core/phone-auth/strategies/link.d.ts +0 -89
  186. package/dist/esm/core/phone-auth/strategies/link.js +0 -380
  187. package/dist/esm/core/phone-auth/strategies/ts43.d.ts +0 -32
  188. package/dist/esm/core/phone-auth/strategies/ts43.js +0 -147
  189. package/dist/esm/core/phone-auth/strategies/types.d.ts +0 -18
  190. package/dist/esm/core/phone-auth/strategies/types.js +0 -5
  191. package/dist/esm/core/phone-auth/type-guards.d.ts +0 -143
  192. package/dist/esm/core/phone-auth/type-guards.js +0 -185
  193. package/dist/esm/core/phone-auth/types.d.ts +0 -237
  194. package/dist/esm/core/phone-auth/types.js +0 -76
  195. package/dist/esm/core/phone-auth/ui/modal.d.ts +0 -88
  196. package/dist/esm/core/phone-auth/ui/modal.js +0 -594
  197. package/dist/esm/core/phone-auth/validation-utils.d.ts +0 -44
  198. package/dist/esm/core/types.d.ts +0 -62
  199. package/dist/esm/core/version.d.ts +0 -1
  200. package/dist/esm/core/version.js +0 -2
  201. package/dist/esm/index.d.ts +0 -12
  202. package/dist/index.d.ts +0 -12
  203. package/dist/index.js +0 -55
@@ -1,203 +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
- // ============================================================================
14
- // USE CASES
15
- // ============================================================================
16
- export const USE_CASE = {
17
- GET_PHONE_NUMBER: 'GetPhoneNumber',
18
- VERIFY_PHONE_NUMBER: 'VerifyPhoneNumber'
19
- };
20
- // ============================================================================
21
- // AUTHENTICATION STRATEGIES
22
- // ============================================================================
23
- export const AUTHENTICATION_STRATEGY = {
24
- TS43: 'ts43',
25
- LINK: 'link',
26
- DESKTOP: 'desktop'
27
- };
28
- // ============================================================================
29
- // ERROR HANDLING
30
- // ============================================================================
31
- /**
32
- * Error codes - MUST match server implementation
33
- */
34
- export const ERROR_CODE = {
35
- // 400 Bad Request
36
- INVALID_PHONE_NUMBER: 'INVALID_PHONE_NUMBER',
37
- MISSING_REQUIRED_FIELD: 'MISSING_REQUIRED_FIELD',
38
- INVALID_USE_CASE: 'INVALID_USE_CASE',
39
- // 404 Not Found
40
- INVALID_SESSION: 'INVALID_SESSION',
41
- SESSION_EXPIRED: 'SESSION_EXPIRED',
42
- // 422 Unprocessable Entity
43
- CARRIER_NOT_ELIGIBLE: 'CARRIER_NOT_ELIGIBLE',
44
- UNSUPPORTED_PLATFORM: 'UNSUPPORTED_PLATFORM',
45
- PHONE_NUMBER_MISMATCH: 'PHONE_NUMBER_MISMATCH',
46
- INVALID_CREDENTIAL: 'INVALID_CREDENTIAL',
47
- VERIFICATION_FAILED: 'VERIFICATION_FAILED',
48
- USE_CASE_MISMATCH: 'USE_CASE_MISMATCH',
49
- // 429 Too Many Requests
50
- RATE_LIMIT_EXCEEDED: 'RATE_LIMIT_EXCEEDED',
51
- // 500 Internal Server Error
52
- INTERNAL_SERVER_ERROR: 'INTERNAL_SERVER_ERROR',
53
- // 503 Service Unavailable
54
- SERVICE_UNAVAILABLE: 'SERVICE_UNAVAILABLE'
55
- };
56
- /**
57
- * Error messages - User-friendly messages for each error code
58
- */
59
- export const ERROR_MESSAGES = {
60
- [ERROR_CODE.INVALID_PHONE_NUMBER]: "Phone number must be in E.164 format",
61
- [ERROR_CODE.MISSING_REQUIRED_FIELD]: "Required field is missing",
62
- [ERROR_CODE.INVALID_USE_CASE]: "Use case must be 'GetPhoneNumber' or 'VerifyPhoneNumber'",
63
- [ERROR_CODE.INVALID_SESSION]: "Session not found or expired",
64
- [ERROR_CODE.SESSION_EXPIRED]: "Session has expired",
65
- [ERROR_CODE.CARRIER_NOT_ELIGIBLE]: "Your carrier does not support this verification method",
66
- [ERROR_CODE.UNSUPPORTED_PLATFORM]: "Your platform is not supported",
67
- [ERROR_CODE.PHONE_NUMBER_MISMATCH]: "Phone number does not match the device",
68
- [ERROR_CODE.INVALID_CREDENTIAL]: "Invalid or expired credential",
69
- [ERROR_CODE.VERIFICATION_FAILED]: "Phone number verification failed",
70
- [ERROR_CODE.USE_CASE_MISMATCH]: "Session was prepared for a different use case",
71
- [ERROR_CODE.RATE_LIMIT_EXCEEDED]: "Too many requests. Please try again later",
72
- [ERROR_CODE.INTERNAL_SERVER_ERROR]: "An unexpected error occurred",
73
- [ERROR_CODE.SERVICE_UNAVAILABLE]: "Service temporarily unavailable"
74
- };
75
- /**
76
- * HTTP status codes for each error
77
- */
78
- export const ERROR_STATUS_CODES = {
79
- [ERROR_CODE.INVALID_PHONE_NUMBER]: 400,
80
- [ERROR_CODE.MISSING_REQUIRED_FIELD]: 400,
81
- [ERROR_CODE.INVALID_USE_CASE]: 400,
82
- [ERROR_CODE.INVALID_SESSION]: 404,
83
- [ERROR_CODE.SESSION_EXPIRED]: 404,
84
- [ERROR_CODE.CARRIER_NOT_ELIGIBLE]: 422,
85
- [ERROR_CODE.UNSUPPORTED_PLATFORM]: 422,
86
- [ERROR_CODE.PHONE_NUMBER_MISMATCH]: 422,
87
- [ERROR_CODE.INVALID_CREDENTIAL]: 422,
88
- [ERROR_CODE.VERIFICATION_FAILED]: 422,
89
- [ERROR_CODE.USE_CASE_MISMATCH]: 422,
90
- [ERROR_CODE.RATE_LIMIT_EXCEEDED]: 429,
91
- [ERROR_CODE.INTERNAL_SERVER_ERROR]: 500,
92
- [ERROR_CODE.SERVICE_UNAVAILABLE]: 503
93
- };
94
- // ============================================================================
95
- // VALIDATION HELPERS
96
- // ============================================================================
97
- /**
98
- * E.164 phone number validation regex
99
- */
100
- export const E164_REGEX = /^\+[1-9]\d{1,14}$/;
101
- /**
102
- * Validate phone number format
103
- */
104
- export function validatePhoneNumber(phone) {
105
- return E164_REGEX.test(phone);
106
- }
107
- /**
108
- * Validate PLMN format
109
- */
110
- export function validatePLMN(plmn) {
111
- // MCC: exactly 3 digits
112
- if (!/^\d{3}$/.test(plmn.mcc))
113
- return false;
114
- // MNC: 2 or 3 digits
115
- if (!/^\d{2,3}$/.test(plmn.mnc))
116
- return false;
117
- return true;
118
- }
119
- /**
120
- * Validate session info
121
- */
122
- export function validateSession(session) {
123
- if (!session.session_key || session.session_key.length < 16)
124
- return false;
125
- // nonce is optional and stored in metadata if needed
126
- return true;
127
- }
128
- /**
129
- * Validate use case
130
- */
131
- export function validateUseCase(useCase) {
132
- return useCase === USE_CASE.GET_PHONE_NUMBER ||
133
- useCase === USE_CASE.VERIFY_PHONE_NUMBER;
134
- }
135
- /**
136
- * Create error response helper
137
- */
138
- export function createErrorResponse(code, details, requestId) {
139
- return {
140
- code,
141
- message: ERROR_MESSAGES[code],
142
- request_id: requestId,
143
- timestamp: new Date().toISOString(),
144
- details
145
- };
146
- }
147
- /**
148
- * Get HTTP status code for error
149
- */
150
- export function getErrorStatusCode(code) {
151
- return ERROR_STATUS_CODES[code] || 500;
152
- }
153
- // ============================================================================
154
- // TYPE GUARDS
155
- // ============================================================================
156
- /**
157
- * Check if data is TS43 strategy data
158
- */
159
- export function isTS43Data(data) {
160
- // Check for TS43 data structure - has protocol and data.dcql_query
161
- return data &&
162
- typeof data.protocol === 'string' &&
163
- data.data &&
164
- data.data.dcql_query;
165
- }
166
- /**
167
- * Check if data is Link strategy data
168
- */
169
- export function isLinkData(data) {
170
- return data && data.url && typeof data.url === 'string';
171
- }
172
- /**
173
- * Check if response is an error
174
- */
175
- export function isErrorResponse(response) {
176
- return response &&
177
- typeof response.code === 'string' &&
178
- typeof response.message === 'string';
179
- }
180
- // ============================================================================
181
- // EXPORTS FOR CONVENIENCE
182
- // ============================================================================
183
- export default {
184
- // Constants
185
- USE_CASE,
186
- AUTHENTICATION_STRATEGY,
187
- ERROR_CODE,
188
- ERROR_MESSAGES,
189
- ERROR_STATUS_CODES,
190
- E164_REGEX,
191
- // Validators
192
- validatePhoneNumber,
193
- validatePLMN,
194
- validateSession,
195
- validateUseCase,
196
- // Type guards
197
- isTS43Data,
198
- isLinkData,
199
- isErrorResponse,
200
- // Helpers
201
- createErrorResponse,
202
- getErrorStatusCode
203
- };
@@ -1,189 +0,0 @@
1
- import type { PrepareResponse, GetPhoneNumberResponse, VerifyPhoneNumberResponse, SecureCredentialResponse, SessionInfo, InvokeOptions, AuthCredential, AnyExtendedResponse } from './api-types';
2
- import type { AuthConfig, PhoneAuthOptions, PhoneAuthResult } from './types';
3
- import type { DesktopAuthOptions } from './strategies/desktop';
4
- export declare class PhoneAuthClient {
5
- private config;
6
- private debug;
7
- private logger;
8
- private crossDeviceActive;
9
- private retryCount;
10
- private sessionCache;
11
- private callbacks;
12
- private baseTimeout;
13
- private lastRequest?;
14
- constructor(config?: AuthConfig);
15
- /**
16
- * Get user-friendly error message using error utilities
17
- */
18
- private getUserFriendlyMessage;
19
- /**
20
- * Log error with proper context and sanitization
21
- */
22
- private logError;
23
- /**
24
- * Check if the browser supports secure phone authentication
25
- */
26
- isSupported(): boolean;
27
- /**
28
- * Get detailed browser support information
29
- */
30
- getBrowserSupportInfo(): {
31
- supported: boolean;
32
- browser: string;
33
- message?: string;
34
- helpUrl?: string;
35
- };
36
- /**
37
- * Main verification method with silent retry support
38
- */
39
- verify(options: PhoneAuthOptions): Promise<PhoneAuthResult>;
40
- private verifyWithRetry;
41
- /**
42
- * High-level method to get phone number (complete flow)
43
- * Handles prepare, credential prompt, and get phone number in one call
44
- */
45
- getPhoneNumberComplete(options?: Omit<PhoneAuthOptions, 'use_case' | 'phone_number'>): Promise<PhoneAuthResult>;
46
- /**
47
- * High-level method to verify phone number (complete flow)
48
- * Handles prepare, credential prompt, and verification in one call
49
- */
50
- verifyPhoneNumberComplete(phoneNumber: string, options?: Omit<PhoneAuthOptions, 'use_case' | 'phone_number'>): Promise<PhoneAuthResult>;
51
- /**
52
- * Step 1: Prepare phone verification request
53
- *
54
- * This method prepares a secure request for phone verification.
55
- * You can use this with your own backend or the glide-sdk-node.
56
- *
57
- * @example
58
- * ```typescript
59
- * const request = await phoneAuthClient.preparePhoneRequest({ useCase: 'GetPhoneNumber' });
60
- * // Handle the request with custom logic
61
- * ```
62
- */
63
- preparePhoneRequest(options: PhoneAuthOptions): Promise<PrepareResponse>;
64
- /**
65
- * Step 2: Invoke secure prompt for user consent
66
- *
67
- * This method can work in two modes:
68
- * 1. **UI Mode (default)**: Shows built-in UI components (modals/buttons)
69
- * 2. **Headless Mode**: Returns raw data for custom UI implementation
70
- *
71
- * **Important**: This method automatically handles reactive objects from frameworks
72
- * like Vue.js and React by deep cloning the input. This ensures compatibility with
73
- * browser APIs that expect plain objects.
74
- *
75
- * @example UI Mode (shows modal/button)
76
- * ```typescript
77
- * // Shows SDK's built-in UI
78
- * const credential = await phoneAuth.invokeSecurePrompt(prepareResult);
79
- *
80
- * // Customize the UI
81
- * const credential = await phoneAuth.invokeSecurePrompt(prepareResult, {
82
- * modalOptions: {
83
- * title: 'Verify Your Identity',
84
- * buttonText: 'Continue with Verizon'
85
- * }
86
- * });
87
- * ```
88
- *
89
- * @example Extended Mode (returns control methods)
90
- * ```typescript
91
- * // Get control methods for custom implementation
92
- * const result = await phoneAuth.invokeSecurePrompt(prepareResult, {
93
- * executionMode: 'extended',
94
- * preventDefaultUI: true // Desktop: no modal
95
- * });
96
- *
97
- * if (result.strategy === 'desktop') {
98
- * // Show custom QR UI
99
- * showCustomQR(result.qr_code_data);
100
- * // Start polling
101
- * await result.start_polling();
102
- * }
103
- * ```
104
- *
105
- * @param prepareResponse - Response from prepare() with strategy and data
106
- * @param options - Control UI behavior and response type
107
- * @returns Credential or ExtendedResponse based on executionMode
108
- */
109
- invokeSecurePrompt(prepareResponse: PrepareResponse, options?: InvokeOptions | DesktopAuthOptions): Promise<AuthCredential | SecureCredentialResponse['vp_token'] | AnyExtendedResponse>;
110
- /**
111
- * Step 3A: Get phone number from credential
112
- *
113
- * @example
114
- * ```typescript
115
- * const prepareResp = await phoneAuthClient.preparePhoneRequest({ useCase: 'GetPhoneNumber', plmn: {...} });
116
- * const credential = await phoneAuthClient.invokeSecurePrompt(prepareResp);
117
- * const result = await phoneAuthClient.getPhoneNumber(credential, prepareResp.session);
118
- * console.log(result.phone_number); // +1234567890
119
- * ```
120
- */
121
- getPhoneNumber(credentialResponse: SecureCredentialResponse['vp_token'] | string, session: SessionInfo): Promise<GetPhoneNumberResponse>;
122
- /**
123
- * Step 3B: Verify phone number with credential
124
- *
125
- * @example
126
- * ```typescript
127
- * const prepareResp = await phoneAuthClient.preparePhoneRequest({
128
- * useCase: 'VerifyPhoneNumber',
129
- * phoneNumber: '+1234567890'
130
- * });
131
- * const credential = await phoneAuthClient.invokeSecurePrompt(prepareResp);
132
- * const result = await phoneAuthClient.verifyPhoneNumber(credential, prepareResp.session);
133
- * console.log(result.verified); // true
134
- * ```
135
- */
136
- verifyPhoneNumber(credentialResponse: SecureCredentialResponse['vp_token'] | string, session: SessionInfo): Promise<VerifyPhoneNumberResponse>;
137
- /**
138
- * Helper to extract credential string from various formats
139
- */
140
- private extractCredentialString;
141
- /**
142
- * Helper to extract error details from response
143
- */
144
- private extractErrorDetails;
145
- /**
146
- * Fetch with timeout
147
- */
148
- private fetchWithTimeout;
149
- /**
150
- * Create an AuthError
151
- */
152
- private createError;
153
- /**
154
- * Type guard for AuthError
155
- */
156
- private isAuthError;
157
- /**
158
- * Debug logging
159
- */
160
- private log;
161
- /**
162
- * Determine if an error should trigger a retry
163
- */
164
- private shouldRetry;
165
- /**
166
- * Analyze and enhance errors specific to cross-device flows
167
- */
168
- private analyzeCrossDeviceError;
169
- /**
170
- * Cache successful session for retry scenarios
171
- */
172
- private cacheSession;
173
- /**
174
- * Retrieve cached session if available and recent
175
- */
176
- private getCachedSession;
177
- /**
178
- * Generate cache key for session storage
179
- */
180
- private getCacheKey;
181
- /**
182
- * Set up periodic cache cleanup
183
- */
184
- private setupCacheCleanup;
185
- /**
186
- * Utility delay function
187
- */
188
- private delay;
189
- }