@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.
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 -161
  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 -157
  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,215 +0,0 @@
1
- "use strict";
2
- /**
3
- * Glide Phone Authentication API Types
4
- *
5
- * This file is copied from the master API specification at /glide-api-types.ts
6
- * It defines the exact contract that ALL implementations must follow.
7
- *
8
- * NAMING CONVENTION:
9
- * - ALL TYPES USE snake_case FOR API COMMUNICATION
10
- * - Frontend SDKs should use snake_case throughout for consistency
11
- * - This eliminates conversion errors and makes debugging easier
12
- * - While not idiomatic JavaScript, it matches the API exactly
13
- */
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.E164_REGEX = exports.ERROR_STATUS_CODES = exports.ERROR_MESSAGES = exports.ERROR_CODE = exports.AUTHENTICATION_STRATEGY = exports.USE_CASE = void 0;
16
- exports.validatePhoneNumber = validatePhoneNumber;
17
- exports.validatePLMN = validatePLMN;
18
- exports.validateSession = validateSession;
19
- exports.validateUseCase = validateUseCase;
20
- exports.createErrorResponse = createErrorResponse;
21
- exports.getErrorStatusCode = getErrorStatusCode;
22
- exports.isTS43Data = isTS43Data;
23
- exports.isLinkData = isLinkData;
24
- exports.isErrorResponse = isErrorResponse;
25
- // ============================================================================
26
- // USE CASES
27
- // ============================================================================
28
- exports.USE_CASE = {
29
- GET_PHONE_NUMBER: 'GetPhoneNumber',
30
- VERIFY_PHONE_NUMBER: 'VerifyPhoneNumber'
31
- };
32
- // ============================================================================
33
- // AUTHENTICATION STRATEGIES
34
- // ============================================================================
35
- exports.AUTHENTICATION_STRATEGY = {
36
- TS43: 'ts43',
37
- LINK: 'link',
38
- DESKTOP: 'desktop'
39
- };
40
- // ============================================================================
41
- // ERROR HANDLING
42
- // ============================================================================
43
- /**
44
- * Error codes - MUST match server implementation
45
- */
46
- exports.ERROR_CODE = {
47
- // 400 Bad Request
48
- INVALID_PHONE_NUMBER: 'INVALID_PHONE_NUMBER',
49
- MISSING_REQUIRED_FIELD: 'MISSING_REQUIRED_FIELD',
50
- INVALID_USE_CASE: 'INVALID_USE_CASE',
51
- // 404 Not Found
52
- INVALID_SESSION: 'INVALID_SESSION',
53
- SESSION_EXPIRED: 'SESSION_EXPIRED',
54
- // 422 Unprocessable Entity
55
- CARRIER_NOT_ELIGIBLE: 'CARRIER_NOT_ELIGIBLE',
56
- UNSUPPORTED_PLATFORM: 'UNSUPPORTED_PLATFORM',
57
- PHONE_NUMBER_MISMATCH: 'PHONE_NUMBER_MISMATCH',
58
- INVALID_CREDENTIAL: 'INVALID_CREDENTIAL',
59
- VERIFICATION_FAILED: 'VERIFICATION_FAILED',
60
- USE_CASE_MISMATCH: 'USE_CASE_MISMATCH',
61
- // 429 Too Many Requests
62
- RATE_LIMIT_EXCEEDED: 'RATE_LIMIT_EXCEEDED',
63
- // 500 Internal Server Error
64
- INTERNAL_SERVER_ERROR: 'INTERNAL_SERVER_ERROR',
65
- // 503 Service Unavailable
66
- SERVICE_UNAVAILABLE: 'SERVICE_UNAVAILABLE'
67
- };
68
- /**
69
- * Error messages - User-friendly messages for each error code
70
- */
71
- exports.ERROR_MESSAGES = {
72
- [exports.ERROR_CODE.INVALID_PHONE_NUMBER]: "Phone number must be in E.164 format",
73
- [exports.ERROR_CODE.MISSING_REQUIRED_FIELD]: "Required field is missing",
74
- [exports.ERROR_CODE.INVALID_USE_CASE]: "Use case must be 'GetPhoneNumber' or 'VerifyPhoneNumber'",
75
- [exports.ERROR_CODE.INVALID_SESSION]: "Session not found or expired",
76
- [exports.ERROR_CODE.SESSION_EXPIRED]: "Session has expired",
77
- [exports.ERROR_CODE.CARRIER_NOT_ELIGIBLE]: "Your carrier does not support this verification method",
78
- [exports.ERROR_CODE.UNSUPPORTED_PLATFORM]: "Your platform is not supported",
79
- [exports.ERROR_CODE.PHONE_NUMBER_MISMATCH]: "Phone number does not match the device",
80
- [exports.ERROR_CODE.INVALID_CREDENTIAL]: "Invalid or expired credential",
81
- [exports.ERROR_CODE.VERIFICATION_FAILED]: "Phone number verification failed",
82
- [exports.ERROR_CODE.USE_CASE_MISMATCH]: "Session was prepared for a different use case",
83
- [exports.ERROR_CODE.RATE_LIMIT_EXCEEDED]: "Too many requests. Please try again later",
84
- [exports.ERROR_CODE.INTERNAL_SERVER_ERROR]: "An unexpected error occurred",
85
- [exports.ERROR_CODE.SERVICE_UNAVAILABLE]: "Service temporarily unavailable"
86
- };
87
- /**
88
- * HTTP status codes for each error
89
- */
90
- exports.ERROR_STATUS_CODES = {
91
- [exports.ERROR_CODE.INVALID_PHONE_NUMBER]: 400,
92
- [exports.ERROR_CODE.MISSING_REQUIRED_FIELD]: 400,
93
- [exports.ERROR_CODE.INVALID_USE_CASE]: 400,
94
- [exports.ERROR_CODE.INVALID_SESSION]: 404,
95
- [exports.ERROR_CODE.SESSION_EXPIRED]: 404,
96
- [exports.ERROR_CODE.CARRIER_NOT_ELIGIBLE]: 422,
97
- [exports.ERROR_CODE.UNSUPPORTED_PLATFORM]: 422,
98
- [exports.ERROR_CODE.PHONE_NUMBER_MISMATCH]: 422,
99
- [exports.ERROR_CODE.INVALID_CREDENTIAL]: 422,
100
- [exports.ERROR_CODE.VERIFICATION_FAILED]: 422,
101
- [exports.ERROR_CODE.USE_CASE_MISMATCH]: 422,
102
- [exports.ERROR_CODE.RATE_LIMIT_EXCEEDED]: 429,
103
- [exports.ERROR_CODE.INTERNAL_SERVER_ERROR]: 500,
104
- [exports.ERROR_CODE.SERVICE_UNAVAILABLE]: 503
105
- };
106
- // ============================================================================
107
- // VALIDATION HELPERS
108
- // ============================================================================
109
- /**
110
- * E.164 phone number validation regex
111
- */
112
- exports.E164_REGEX = /^\+[1-9]\d{1,14}$/;
113
- /**
114
- * Validate phone number format
115
- */
116
- function validatePhoneNumber(phone) {
117
- return exports.E164_REGEX.test(phone);
118
- }
119
- /**
120
- * Validate PLMN format
121
- */
122
- function validatePLMN(plmn) {
123
- // MCC: exactly 3 digits
124
- if (!/^\d{3}$/.test(plmn.mcc))
125
- return false;
126
- // MNC: 2 or 3 digits
127
- if (!/^\d{2,3}$/.test(plmn.mnc))
128
- return false;
129
- return true;
130
- }
131
- /**
132
- * Validate session info
133
- */
134
- function validateSession(session) {
135
- if (!session.session_key || session.session_key.length < 16)
136
- return false;
137
- // nonce is optional and stored in metadata if needed
138
- return true;
139
- }
140
- /**
141
- * Validate use case
142
- */
143
- function validateUseCase(useCase) {
144
- return useCase === exports.USE_CASE.GET_PHONE_NUMBER ||
145
- useCase === exports.USE_CASE.VERIFY_PHONE_NUMBER;
146
- }
147
- /**
148
- * Create error response helper
149
- */
150
- function createErrorResponse(code, details, requestId) {
151
- return {
152
- code,
153
- message: exports.ERROR_MESSAGES[code],
154
- request_id: requestId,
155
- timestamp: new Date().toISOString(),
156
- details
157
- };
158
- }
159
- /**
160
- * Get HTTP status code for error
161
- */
162
- function getErrorStatusCode(code) {
163
- return exports.ERROR_STATUS_CODES[code] || 500;
164
- }
165
- // ============================================================================
166
- // TYPE GUARDS
167
- // ============================================================================
168
- /**
169
- * Check if data is TS43 strategy data
170
- */
171
- function isTS43Data(data) {
172
- // Check for TS43 data structure - has protocol and data.dcql_query
173
- return data &&
174
- typeof data.protocol === 'string' &&
175
- data.data &&
176
- data.data.dcql_query;
177
- }
178
- /**
179
- * Check if data is Link strategy data
180
- */
181
- function isLinkData(data) {
182
- return data && data.url && typeof data.url === 'string';
183
- }
184
- /**
185
- * Check if response is an error
186
- */
187
- function isErrorResponse(response) {
188
- return response &&
189
- typeof response.code === 'string' &&
190
- typeof response.message === 'string';
191
- }
192
- // ============================================================================
193
- // EXPORTS FOR CONVENIENCE
194
- // ============================================================================
195
- exports.default = {
196
- // Constants
197
- USE_CASE: exports.USE_CASE,
198
- AUTHENTICATION_STRATEGY: exports.AUTHENTICATION_STRATEGY,
199
- ERROR_CODE: exports.ERROR_CODE,
200
- ERROR_MESSAGES: exports.ERROR_MESSAGES,
201
- ERROR_STATUS_CODES: exports.ERROR_STATUS_CODES,
202
- E164_REGEX: exports.E164_REGEX,
203
- // Validators
204
- validatePhoneNumber,
205
- validatePLMN,
206
- validateSession,
207
- validateUseCase,
208
- // Type guards
209
- isTS43Data,
210
- isLinkData,
211
- isErrorResponse,
212
- // Helpers
213
- createErrorResponse,
214
- getErrorStatusCode
215
- };
@@ -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
- }