@glideidentity/web-client-sdk 5.0.0 → 5.0.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 +108 -8
- package/dist/adapters/angular/index.js +0 -1
- package/dist/adapters/angular/phone-auth.service.d.ts +0 -18
- package/dist/adapters/angular/phone-auth.service.js +0 -26
- package/dist/adapters/react/index.js +0 -3
- package/dist/adapters/react/useClient.js +0 -1
- package/dist/adapters/react/usePhoneAuth.js +1 -16
- package/dist/adapters/vanilla/client.js +0 -1
- package/dist/adapters/vanilla/index.js +0 -1
- package/dist/adapters/vanilla/phone-auth.js +0 -31
- package/dist/adapters/vue/index.js +0 -4
- package/dist/adapters/vue/useClient.js +0 -5
- package/dist/adapters/vue/usePhoneAuth.js +1 -20
- package/dist/browser/web-client-sdk.min.js +1 -1
- package/dist/browser.js +0 -6
- package/dist/core/client.js +0 -12
- package/dist/core/logger.js +1 -81
- package/dist/core/phone-auth/api-types.js +0 -83
- package/dist/core/phone-auth/client.js +27 -366
- package/dist/core/phone-auth/error-utils.js +1 -83
- package/dist/core/phone-auth/index.js +0 -1
- package/dist/core/phone-auth/status-types.d.ts +0 -78
- package/dist/core/phone-auth/status-types.js +0 -17
- package/dist/core/phone-auth/strategies/desktop.js +8 -126
- package/dist/core/phone-auth/strategies/index.d.ts +0 -4
- package/dist/core/phone-auth/strategies/index.js +0 -4
- package/dist/core/phone-auth/strategies/link.js +10 -88
- package/dist/core/phone-auth/strategies/ts43.d.ts +0 -19
- package/dist/core/phone-auth/strategies/ts43.js +2 -33
- package/dist/core/phone-auth/strategies/types.js +0 -4
- package/dist/core/phone-auth/type-guards.js +0 -131
- package/dist/core/phone-auth/types.js +0 -32
- package/dist/core/phone-auth/ui/mobile-debug-console.js +2 -28
- package/dist/core/phone-auth/ui/modal.d.ts +33 -55
- package/dist/core/phone-auth/ui/modal.js +889 -422
- package/dist/core/phone-auth/validation-utils.js +2 -40
- package/dist/core/version.js +1 -2
- package/dist/esm/adapters/angular/index.js +0 -1
- package/dist/esm/adapters/angular/phone-auth.service.d.ts +0 -18
- package/dist/esm/adapters/angular/phone-auth.service.js +0 -26
- package/dist/esm/adapters/react/index.js +0 -3
- package/dist/esm/adapters/react/useClient.js +0 -1
- package/dist/esm/adapters/react/usePhoneAuth.js +1 -16
- package/dist/esm/adapters/vanilla/client.js +0 -1
- package/dist/esm/adapters/vanilla/index.js +0 -1
- package/dist/esm/adapters/vanilla/phone-auth.d.ts +0 -24
- package/dist/esm/adapters/vanilla/phone-auth.js +0 -31
- package/dist/esm/adapters/vue/index.js +0 -4
- package/dist/esm/adapters/vue/useClient.js +0 -5
- package/dist/esm/adapters/vue/usePhoneAuth.js +1 -20
- package/dist/esm/browser.js +0 -6
- package/dist/esm/core/client.d.ts +0 -10
- package/dist/esm/core/client.js +0 -12
- package/dist/esm/core/logger.d.ts +0 -53
- package/dist/esm/core/logger.js +1 -81
- package/dist/esm/core/phone-auth/api-types.d.ts +0 -315
- package/dist/esm/core/phone-auth/api-types.js +0 -83
- package/dist/esm/core/phone-auth/client.d.ts +0 -144
- package/dist/esm/core/phone-auth/client.js +27 -366
- package/dist/esm/core/phone-auth/error-utils.d.ts +0 -29
- package/dist/esm/core/phone-auth/error-utils.js +1 -83
- package/dist/esm/core/phone-auth/index.js +1 -3
- package/dist/esm/core/phone-auth/status-types.d.ts +0 -78
- package/dist/esm/core/phone-auth/status-types.js +0 -17
- package/dist/esm/core/phone-auth/strategies/desktop.d.ts +0 -63
- package/dist/esm/core/phone-auth/strategies/desktop.js +8 -126
- package/dist/esm/core/phone-auth/strategies/index.d.ts +0 -4
- package/dist/esm/core/phone-auth/strategies/index.js +0 -4
- package/dist/esm/core/phone-auth/strategies/link.d.ts +0 -48
- package/dist/esm/core/phone-auth/strategies/link.js +10 -88
- package/dist/esm/core/phone-auth/strategies/ts43.d.ts +0 -19
- package/dist/esm/core/phone-auth/strategies/ts43.js +2 -33
- package/dist/esm/core/phone-auth/strategies/types.d.ts +0 -13
- package/dist/esm/core/phone-auth/strategies/types.js +0 -4
- package/dist/esm/core/phone-auth/type-guards.d.ts +0 -128
- package/dist/esm/core/phone-auth/type-guards.js +0 -131
- package/dist/esm/core/phone-auth/types.d.ts +0 -108
- package/dist/esm/core/phone-auth/types.js +0 -32
- package/dist/esm/core/phone-auth/ui/mobile-debug-console.d.ts +0 -4
- package/dist/esm/core/phone-auth/ui/mobile-debug-console.js +2 -28
- package/dist/esm/core/phone-auth/ui/modal.d.ts +27 -68
- package/dist/esm/core/phone-auth/ui/modal.js +889 -422
- package/dist/esm/core/phone-auth/validation-utils.d.ts +0 -31
- package/dist/esm/core/phone-auth/validation-utils.js +2 -40
- package/dist/esm/core/types.d.ts +0 -35
- package/dist/esm/core/version.js +1 -2
- package/dist/esm/index.js +1 -9
- package/dist/index.js +0 -7
- package/package.json +1 -1
|
@@ -11,38 +11,31 @@ exports.parseBackendError = parseBackendError;
|
|
|
11
11
|
exports.serializeError = serializeError;
|
|
12
12
|
exports.createErrorBreadcrumb = createErrorBreadcrumb;
|
|
13
13
|
const version_1 = require("../version");
|
|
14
|
-
// Error constants matching the backend for consistency
|
|
15
14
|
exports.PhoneAuthErrorCode = {
|
|
16
|
-
// 400 Bad Request errors
|
|
17
15
|
BAD_REQUEST: 'BAD_REQUEST',
|
|
18
16
|
VALIDATION_ERROR: 'VALIDATION_ERROR',
|
|
19
17
|
INVALID_PARAMETERS: 'INVALID_PARAMETERS',
|
|
20
18
|
MISSING_PARAMETERS: 'MISSING_PARAMETERS',
|
|
21
19
|
INVALID_PHONE_NUMBER: 'INVALID_PHONE_NUMBER',
|
|
22
20
|
INVALID_MCC_MNC: 'INVALID_MCC_MNC',
|
|
23
|
-
// 401 Unauthorized errors
|
|
24
21
|
UNAUTHORIZED: 'UNAUTHORIZED',
|
|
25
22
|
INVALID_CREDENTIALS: 'INVALID_CREDENTIALS',
|
|
26
23
|
EXPIRED_TOKEN: 'EXPIRED_TOKEN',
|
|
27
24
|
TOKEN_ACQUISITION_FAILED: 'TOKEN_ACQUISITION_FAILED',
|
|
28
25
|
INVALID_API_KEY: 'INVALID_API_KEY',
|
|
29
26
|
MISSING_AUTH_HEADER: 'MISSING_AUTH_HEADER',
|
|
30
|
-
// 403 Forbidden errors
|
|
31
27
|
FORBIDDEN: 'FORBIDDEN',
|
|
32
28
|
INSUFFICIENT_PERMISSIONS: 'INSUFFICIENT_PERMISSIONS',
|
|
33
29
|
ACCESS_DENIED: 'ACCESS_DENIED',
|
|
34
|
-
// 404 Not Found errors
|
|
35
30
|
NOT_FOUND: 'NOT_FOUND',
|
|
36
31
|
RESOURCE_NOT_FOUND: 'RESOURCE_NOT_FOUND',
|
|
37
32
|
SESSION_NOT_FOUND: 'SESSION_NOT_FOUND',
|
|
38
33
|
CARRIER_NOT_FOUND: 'CARRIER_NOT_FOUND',
|
|
39
34
|
ENDPOINT_NOT_FOUND: 'ENDPOINT_NOT_FOUND',
|
|
40
|
-
// 409 Conflict errors
|
|
41
35
|
CONFLICT: 'CONFLICT',
|
|
42
36
|
RESOURCE_ALREADY_EXISTS: 'RESOURCE_ALREADY_EXISTS',
|
|
43
37
|
DUPLICATE_SESSION: 'DUPLICATE_SESSION',
|
|
44
38
|
CONCURRENT_MODIFICATION: 'CONCURRENT_MODIFICATION',
|
|
45
|
-
// 422 Unprocessable Entity errors
|
|
46
39
|
UNPROCESSABLE_ENTITY: 'UNPROCESSABLE_ENTITY',
|
|
47
40
|
UNSUPPORTED_VERIFICATION: 'UNSUPPORTED_VERIFICATION',
|
|
48
41
|
INVALID_VERIFICATION: 'INVALID_VERIFICATION',
|
|
@@ -58,160 +51,117 @@ exports.PhoneAuthErrorCode = {
|
|
|
58
51
|
INVALID_SESSION_STATE: 'INVALID_SESSION_STATE',
|
|
59
52
|
PHONE_NUMBER_MISMATCH: 'PHONE_NUMBER_MISMATCH',
|
|
60
53
|
INVALID_CREDENTIAL_FORMAT: 'INVALID_CREDENTIAL_FORMAT',
|
|
61
|
-
// 429 Too Many Requests errors
|
|
62
54
|
RATE_LIMIT_EXCEEDED: 'RATE_LIMIT_EXCEEDED',
|
|
63
55
|
TOO_MANY_REQUESTS: 'TOO_MANY_REQUESTS',
|
|
64
56
|
QUOTA_EXCEEDED: 'QUOTA_EXCEEDED',
|
|
65
|
-
// 500 Internal Server errors
|
|
66
57
|
INTERNAL_SERVER_ERROR: 'INTERNAL_SERVER_ERROR',
|
|
67
58
|
CIRCUIT_BREAKER_CONFIGURATION_ERROR: 'CIRCUIT_BREAKER_CONFIGURATION_ERROR',
|
|
68
59
|
DATABASE_ERROR: 'DATABASE_ERROR',
|
|
69
60
|
CACHE_ERROR: 'CACHE_ERROR',
|
|
70
61
|
SERIALIZATION_ERROR: 'SERIALIZATION_ERROR',
|
|
71
62
|
CRYPTO_ERROR: 'CRYPTO_ERROR',
|
|
72
|
-
// 502 Bad Gateway errors
|
|
73
63
|
BAD_GATEWAY: 'BAD_GATEWAY',
|
|
74
64
|
UPSTREAM_ERROR: 'UPSTREAM_ERROR',
|
|
75
65
|
INVALID_RESPONSE: 'INVALID_RESPONSE',
|
|
76
|
-
// 503 Service Unavailable errors
|
|
77
66
|
SERVICE_UNAVAILABLE: 'SERVICE_UNAVAILABLE',
|
|
78
67
|
DOWNSTREAM_SERVICE_ERROR: 'DOWNSTREAM_SERVICE_ERROR',
|
|
79
68
|
PROVIDER_ERROR: 'PROVIDER_ERROR',
|
|
80
69
|
CIRCUIT_BREAKER_OPEN: 'CIRCUIT_BREAKER_OPEN',
|
|
81
70
|
MAINTENANCE_MODE: 'MAINTENANCE_MODE',
|
|
82
|
-
// 504 Gateway Timeout errors
|
|
83
71
|
GATEWAY_TIMEOUT: 'GATEWAY_TIMEOUT',
|
|
84
72
|
REQUEST_TIMEOUT: 'REQUEST_TIMEOUT',
|
|
85
73
|
UPSTREAM_TIMEOUT: 'UPSTREAM_TIMEOUT',
|
|
86
74
|
DEADLINE_EXCEEDED: 'DEADLINE_EXCEEDED',
|
|
87
|
-
// Browser-specific errors (never thrown by backend)
|
|
88
75
|
BROWSER_NOT_SUPPORTED: 'BROWSER_NOT_SUPPORTED',
|
|
89
76
|
USER_DENIED: 'USER_DENIED',
|
|
90
77
|
NETWORK_ERROR: 'NETWORK_ERROR',
|
|
91
78
|
};
|
|
92
|
-
// User-facing error messages - NEVER expose carrier names or phone numbers
|
|
93
79
|
const USER_ERROR_MESSAGES = {
|
|
94
|
-
// Privacy-conscious messages - no carrier/phone info exposed
|
|
95
80
|
CARRIER_NOT_ELIGIBLE: 'Your carrier is not eligible for this verification method.',
|
|
96
81
|
CARRIER_IDENTIFICATION_FAILED: 'Unable to identify carrier for the provided phone number.',
|
|
97
82
|
CARRIER_NOT_FOUND: 'Carrier information not available.',
|
|
98
83
|
UNSUPPORTED_CARRIER: 'This carrier is not supported.',
|
|
99
|
-
// Rate limiting
|
|
100
84
|
RATE_LIMIT_EXCEEDED: 'Too many attempts. Please wait a moment and try again.',
|
|
101
85
|
TOO_MANY_REQUESTS: 'Too many requests. Please slow down and try again.',
|
|
102
86
|
QUOTA_EXCEEDED: 'Usage limit reached. Please try again later.',
|
|
103
|
-
// Session errors
|
|
104
87
|
SESSION_NOT_FOUND: 'Your session has expired. Please start over.',
|
|
105
88
|
INVALID_SESSION_STATE: 'Invalid session state. Please start over.',
|
|
106
89
|
DUPLICATE_SESSION: 'A session already exists. Please complete or cancel it first.',
|
|
107
|
-
// Browser/platform errors
|
|
108
90
|
BROWSER_NOT_SUPPORTED: 'Digital Credentials API is not available. Please enable the #web-identity-digital-credentials flag in chrome://flags',
|
|
109
91
|
UNSUPPORTED_PLATFORM: 'This platform is not supported for authentication.',
|
|
110
92
|
UNSUPPORTED_STRATEGY: 'This authentication method is not available.',
|
|
111
93
|
USER_DENIED: 'Authentication was cancelled. Please try again when you\'re ready.',
|
|
112
|
-
// Service availability
|
|
113
94
|
SERVICE_UNAVAILABLE: 'The service is temporarily unavailable. Please try again later.',
|
|
114
95
|
CIRCUIT_BREAKER_OPEN: 'Service is experiencing issues. Please try again later.',
|
|
115
96
|
MAINTENANCE_MODE: 'Service is under maintenance. Please try again later.',
|
|
116
97
|
DOWNSTREAM_SERVICE_ERROR: 'A required service is unavailable. Please try again later.',
|
|
117
|
-
// Authentication errors
|
|
118
98
|
TOKEN_ACQUISITION_FAILED: 'Failed to acquire authentication token. Please try again.',
|
|
119
99
|
EXPIRED_TOKEN: 'Your authentication has expired. Please start over.',
|
|
120
100
|
INVALID_CREDENTIALS: 'Invalid credentials provided.',
|
|
121
|
-
// Validation errors
|
|
122
101
|
INVALID_PHONE_NUMBER: 'Please enter a valid phone number.',
|
|
123
102
|
PHONE_NUMBER_MISMATCH: 'Phone number mismatch. Please verify your number.',
|
|
124
103
|
INVALID_PARAMETERS: 'Invalid parameters provided.',
|
|
125
104
|
MISSING_PARAMETERS: 'Required information is missing.',
|
|
126
105
|
VALIDATION_ERROR: 'Validation failed. Please check your input.',
|
|
127
|
-
// Network errors
|
|
128
106
|
NETWORK_ERROR: 'Network connection failed. Please check your connection and try again.',
|
|
129
107
|
GATEWAY_TIMEOUT: 'Request timed out. Please try again.',
|
|
130
108
|
REQUEST_TIMEOUT: 'Request timed out. Please try again.',
|
|
131
109
|
DEADLINE_EXCEEDED: 'Operation took too long. Please try again.',
|
|
132
|
-
// Verification errors
|
|
133
110
|
VERIFICATION_FAILED: 'Verification failed. Please try again.',
|
|
134
111
|
INVALID_VERIFICATION: 'Invalid verification response.',
|
|
135
112
|
INVALID_CREDENTIAL_FORMAT: 'Invalid credential format.',
|
|
136
|
-
// Generic fallbacks
|
|
137
113
|
BAD_REQUEST: 'Invalid request. Please try again.',
|
|
138
114
|
UNAUTHORIZED: 'Authentication required.',
|
|
139
115
|
FORBIDDEN: 'Access denied.',
|
|
140
116
|
NOT_FOUND: 'Resource not found.',
|
|
141
117
|
INTERNAL_SERVER_ERROR: 'An error occurred. Please try again later.',
|
|
142
118
|
};
|
|
143
|
-
// Errors that should be shown to users vs logged internally
|
|
144
119
|
const USER_FACING_ERRORS = new Set([
|
|
145
|
-
// Carrier errors (privacy-safe messages)
|
|
146
120
|
'CARRIER_NOT_ELIGIBLE',
|
|
147
121
|
'CARRIER_IDENTIFICATION_FAILED',
|
|
148
122
|
'CARRIER_NOT_FOUND',
|
|
149
123
|
'UNSUPPORTED_CARRIER',
|
|
150
|
-
// Rate limiting
|
|
151
124
|
'RATE_LIMIT_EXCEEDED',
|
|
152
125
|
'TOO_MANY_REQUESTS',
|
|
153
126
|
'QUOTA_EXCEEDED',
|
|
154
|
-
// Browser/platform
|
|
155
127
|
'BROWSER_NOT_SUPPORTED',
|
|
156
128
|
'UNSUPPORTED_PLATFORM',
|
|
157
129
|
'UNSUPPORTED_STRATEGY',
|
|
158
130
|
'USER_DENIED',
|
|
159
|
-
// Session
|
|
160
131
|
'SESSION_NOT_FOUND',
|
|
161
132
|
'INVALID_SESSION_STATE',
|
|
162
133
|
'EXPIRED_TOKEN',
|
|
163
|
-
// Service availability
|
|
164
134
|
'SERVICE_UNAVAILABLE',
|
|
165
135
|
'CIRCUIT_BREAKER_OPEN',
|
|
166
136
|
'MAINTENANCE_MODE',
|
|
167
|
-
// Network
|
|
168
137
|
'NETWORK_ERROR',
|
|
169
138
|
'GATEWAY_TIMEOUT',
|
|
170
139
|
'REQUEST_TIMEOUT',
|
|
171
|
-
// Validation
|
|
172
140
|
'INVALID_PHONE_NUMBER',
|
|
173
141
|
'PHONE_NUMBER_MISMATCH',
|
|
174
142
|
'MISSING_PARAMETERS',
|
|
175
143
|
'VALIDATION_ERROR',
|
|
176
144
|
]);
|
|
177
|
-
/**
|
|
178
|
-
* Type guard to check if an error is a PhoneAuthError
|
|
179
|
-
*/
|
|
180
145
|
function isPhoneAuthError(error) {
|
|
181
146
|
return error &&
|
|
182
147
|
typeof error.code === 'string' &&
|
|
183
148
|
typeof error.message === 'string';
|
|
184
149
|
}
|
|
185
|
-
/**
|
|
186
|
-
* Check if error should be shown to user
|
|
187
|
-
*/
|
|
188
150
|
function isUserError(error) {
|
|
189
151
|
return USER_FACING_ERRORS.has(error.code);
|
|
190
152
|
}
|
|
191
|
-
/**
|
|
192
|
-
* Get user-friendly error message
|
|
193
|
-
*/
|
|
194
153
|
function getUserMessage(error) {
|
|
195
154
|
return USER_ERROR_MESSAGES[error.code] || 'An unexpected error occurred. Please try again.';
|
|
196
155
|
}
|
|
197
|
-
/**
|
|
198
|
-
* Check if error matches a specific code
|
|
199
|
-
*/
|
|
200
156
|
function isErrorCode(error, code) {
|
|
201
157
|
return error.code === code;
|
|
202
158
|
}
|
|
203
|
-
/**
|
|
204
|
-
* Get retry delay for rate-limited requests
|
|
205
|
-
*/
|
|
206
159
|
function getRetryDelay(error) {
|
|
207
160
|
if (error.code === exports.PhoneAuthErrorCode.RATE_LIMIT_EXCEEDED && error.retryAfter) {
|
|
208
|
-
return error.retryAfter * 1000;
|
|
161
|
+
return error.retryAfter * 1000;
|
|
209
162
|
}
|
|
210
163
|
return null;
|
|
211
164
|
}
|
|
212
|
-
/**
|
|
213
|
-
* Check if error is retryable
|
|
214
|
-
*/
|
|
215
165
|
function isRetryableError(error) {
|
|
216
166
|
const retryableCodes = [
|
|
217
167
|
exports.PhoneAuthErrorCode.NETWORK_ERROR,
|
|
@@ -221,12 +171,8 @@ function isRetryableError(error) {
|
|
|
221
171
|
];
|
|
222
172
|
return retryableCodes.includes(error.code);
|
|
223
173
|
}
|
|
224
|
-
/**
|
|
225
|
-
* Parse error response from backend API
|
|
226
|
-
*/
|
|
227
174
|
function parseBackendError(response) {
|
|
228
175
|
var _a, _b;
|
|
229
|
-
// Direct error structure from backend
|
|
230
176
|
if (response && typeof response === 'object' && (response.code || response.error)) {
|
|
231
177
|
const errorCode = response.code || response.error;
|
|
232
178
|
const error = {
|
|
@@ -236,18 +182,15 @@ function parseBackendError(response) {
|
|
|
236
182
|
requestId: response.requestId || response.request_id,
|
|
237
183
|
timestamp: response.timestamp,
|
|
238
184
|
details: response.details,
|
|
239
|
-
// Include trace info for observability
|
|
240
185
|
traceId: response.trace_id || response.traceId,
|
|
241
186
|
spanId: response.span_id || response.spanId,
|
|
242
187
|
service: response.service
|
|
243
188
|
};
|
|
244
|
-
// Extract retryAfter from details if present
|
|
245
189
|
if ((_a = response.details) === null || _a === void 0 ? void 0 : _a.retryAfter) {
|
|
246
190
|
error.retryAfter = response.details.retryAfter;
|
|
247
191
|
}
|
|
248
192
|
return error;
|
|
249
193
|
}
|
|
250
|
-
// Handle HTTP response with error
|
|
251
194
|
if (response && response.status) {
|
|
252
195
|
const code = mapStatusToErrorCode(response.status);
|
|
253
196
|
return {
|
|
@@ -257,16 +200,12 @@ function parseBackendError(response) {
|
|
|
257
200
|
requestId: (_b = response.headers) === null || _b === void 0 ? void 0 : _b['x-request-id']
|
|
258
201
|
};
|
|
259
202
|
}
|
|
260
|
-
// Default to unexpected error
|
|
261
203
|
return {
|
|
262
204
|
code: exports.PhoneAuthErrorCode.INTERNAL_SERVER_ERROR,
|
|
263
205
|
message: 'An unexpected error occurred',
|
|
264
206
|
status: 500
|
|
265
207
|
};
|
|
266
208
|
}
|
|
267
|
-
/**
|
|
268
|
-
* Map HTTP status to error code
|
|
269
|
-
*/
|
|
270
209
|
function mapStatusToErrorCode(status) {
|
|
271
210
|
switch (status) {
|
|
272
211
|
case 400: return exports.PhoneAuthErrorCode.BAD_REQUEST;
|
|
@@ -283,56 +222,35 @@ function mapStatusToErrorCode(status) {
|
|
|
283
222
|
default: return exports.PhoneAuthErrorCode.INTERNAL_SERVER_ERROR;
|
|
284
223
|
}
|
|
285
224
|
}
|
|
286
|
-
/**
|
|
287
|
-
* Serialize error for logging/observability tools like Sentry
|
|
288
|
-
* This ensures all error details are captured in a format that can be sent over the network
|
|
289
|
-
*/
|
|
290
225
|
function serializeError(error) {
|
|
291
226
|
return {
|
|
292
|
-
// Core error info
|
|
293
227
|
code: error.code,
|
|
294
228
|
message: error.message,
|
|
295
|
-
// Backend error details
|
|
296
229
|
status: error.status,
|
|
297
230
|
requestId: error.requestId,
|
|
298
231
|
timestamp: error.timestamp,
|
|
299
|
-
// Trace context for distributed tracing
|
|
300
232
|
traceId: error.traceId,
|
|
301
233
|
spanId: error.spanId,
|
|
302
234
|
service: error.service,
|
|
303
|
-
// Specific error fields
|
|
304
235
|
retryAfter: error.retryAfter,
|
|
305
|
-
// Browser error details
|
|
306
236
|
browserError: error.browserError,
|
|
307
|
-
// Context
|
|
308
237
|
context: error.context,
|
|
309
|
-
// Additional details (sanitized - no sensitive info)
|
|
310
238
|
details: sanitizeDetails(error.details),
|
|
311
|
-
// SDK metadata
|
|
312
239
|
sdkVersion: version_1.SDK_VERSION,
|
|
313
240
|
errorCapturedAt: new Date().toISOString()
|
|
314
241
|
};
|
|
315
242
|
}
|
|
316
|
-
/**
|
|
317
|
-
* Sanitize error details to remove sensitive information
|
|
318
|
-
*/
|
|
319
243
|
function sanitizeDetails(details) {
|
|
320
244
|
if (!details || typeof details !== 'object') {
|
|
321
245
|
return details;
|
|
322
246
|
}
|
|
323
|
-
// Clone the object
|
|
324
247
|
const sanitized = JSON.parse(JSON.stringify(details));
|
|
325
|
-
// Remove sensitive fields
|
|
326
248
|
const sensitiveFields = ['carrier', 'phone_number', 'mnc', 'mcc', 'carrier_name'];
|
|
327
249
|
for (const field of sensitiveFields) {
|
|
328
250
|
delete sanitized[field];
|
|
329
251
|
}
|
|
330
252
|
return sanitized;
|
|
331
253
|
}
|
|
332
|
-
/**
|
|
333
|
-
* Create a breadcrumb trail for error tracking
|
|
334
|
-
* Useful for understanding the sequence of events leading to an error
|
|
335
|
-
*/
|
|
336
254
|
function createErrorBreadcrumb(error) {
|
|
337
255
|
var _a, _b, _c;
|
|
338
256
|
return {
|
|
@@ -45,7 +45,6 @@ Object.defineProperty(exports, "isDesktopStrategy", { enumerable: true, get: fun
|
|
|
45
45
|
Object.defineProperty(exports, "getStrategy", { enumerable: true, get: function () { return type_guards_1.getStrategy; } });
|
|
46
46
|
Object.defineProperty(exports, "hasPollingControls", { enumerable: true, get: function () { return type_guards_1.hasPollingControls; } });
|
|
47
47
|
Object.defineProperty(exports, "hasTrigger", { enumerable: true, get: function () { return type_guards_1.hasTrigger; } });
|
|
48
|
-
// Deprecated aliases
|
|
49
48
|
Object.defineProperty(exports, "isHeadlessResult", { enumerable: true, get: function () { return type_guards_1.isHeadlessResult; } });
|
|
50
49
|
Object.defineProperty(exports, "requiresPolling", { enumerable: true, get: function () { return type_guards_1.requiresPolling; } });
|
|
51
50
|
Object.defineProperty(exports, "requiresUserAction", { enumerable: true, get: function () { return type_guards_1.requiresUserAction; } });
|
|
@@ -1,69 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Status Types for Public Status Endpoint
|
|
3
|
-
*
|
|
4
|
-
* These types define the response format for the public status endpoint
|
|
5
|
-
* Used for polling authentication status without exposing sensitive data
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Status values returned by the public endpoint (HTTP 200 only)
|
|
9
|
-
*/
|
|
10
1
|
export type AuthenticationStatus = 'pending' | 'completed';
|
|
11
|
-
/**
|
|
12
|
-
* Authentication protocol/strategy used
|
|
13
|
-
*/
|
|
14
2
|
export type AuthenticationProtocol = 'ts43' | 'link' | 'desktop';
|
|
15
|
-
/**
|
|
16
|
-
* Public Status Response (HTTP 200 OK)
|
|
17
|
-
*
|
|
18
|
-
* This response is only returned with HTTP 200 status code
|
|
19
|
-
* Failed/expired sessions return HTTP 4xx with ErrorResponse
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```typescript
|
|
23
|
-
* // Public endpoint (no auth required)
|
|
24
|
-
* const response = await fetch('/public/public/status/{sessionKey}');
|
|
25
|
-
*
|
|
26
|
-
* if (response.status === 200) {
|
|
27
|
-
* const status: StatusResponse = await response.json();
|
|
28
|
-
* if (status.status === 'completed') {
|
|
29
|
-
* // Authentication successful - now call process endpoint
|
|
30
|
-
* const result = await processAuthentication(sessionKey);
|
|
31
|
-
* }
|
|
32
|
-
* } else if (response.status === 410) {
|
|
33
|
-
* // Session expired
|
|
34
|
-
* } else if (response.status === 422) {
|
|
35
|
-
* // Authentication failed (user cancelled, etc.)
|
|
36
|
-
* }
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
3
|
export interface StatusResponse {
|
|
40
|
-
/**
|
|
41
|
-
* The session key/identifier
|
|
42
|
-
*/
|
|
43
4
|
session_key: string;
|
|
44
|
-
/**
|
|
45
|
-
* Current status of the authentication (only successful states)
|
|
46
|
-
*/
|
|
47
5
|
status: AuthenticationStatus;
|
|
48
|
-
/**
|
|
49
|
-
* Protocol/strategy used for authentication
|
|
50
|
-
* Optional - may not be present during pending state
|
|
51
|
-
*/
|
|
52
6
|
protocol?: AuthenticationProtocol;
|
|
53
|
-
/**
|
|
54
|
-
* ISO 8601 timestamp when session was created
|
|
55
|
-
*/
|
|
56
7
|
created_at: string;
|
|
57
|
-
/**
|
|
58
|
-
* ISO 8601 timestamp of last status update
|
|
59
|
-
*/
|
|
60
8
|
last_updated: string;
|
|
61
9
|
}
|
|
62
|
-
/**
|
|
63
|
-
* Error Response (HTTP 4xx)
|
|
64
|
-
*
|
|
65
|
-
* Returned when session is expired, failed, or not found
|
|
66
|
-
*/
|
|
67
10
|
export interface StatusErrorResponse {
|
|
68
11
|
code: 'SESSION_EXPIRED' | 'USER_CANCELLED' | 'AUTHENTICATION_FAILED' | 'SESSION_NOT_FOUND' | 'INVALID_SESSION_KEY';
|
|
69
12
|
message: string;
|
|
@@ -76,32 +19,11 @@ export interface StatusErrorResponse {
|
|
|
76
19
|
duration_seconds?: number;
|
|
77
20
|
};
|
|
78
21
|
}
|
|
79
|
-
/**
|
|
80
|
-
* Type guard to check if authentication was successful
|
|
81
|
-
*/
|
|
82
22
|
export declare function isSuccessStatus(status: AuthenticationStatus): boolean;
|
|
83
|
-
/**
|
|
84
|
-
* Helper to determine if polling should continue based on HTTP status
|
|
85
|
-
*/
|
|
86
23
|
export declare function shouldContinuePolling(httpStatus: number, response?: StatusResponse): boolean;
|
|
87
|
-
/**
|
|
88
|
-
* Helper to determine if session is terminated based on HTTP status
|
|
89
|
-
*/
|
|
90
24
|
export declare function isTerminalHttpStatus(httpStatus: number): boolean;
|
|
91
|
-
/**
|
|
92
|
-
* Session binding types for parent-child relationships
|
|
93
|
-
*/
|
|
94
25
|
export interface SessionBinding {
|
|
95
|
-
/**
|
|
96
|
-
* Parent session ID (desktop QR code session)
|
|
97
|
-
*/
|
|
98
26
|
parent_session_id?: string;
|
|
99
|
-
/**
|
|
100
|
-
* Child session ID (mobile authentication session)
|
|
101
|
-
*/
|
|
102
27
|
child_session_id?: string;
|
|
103
|
-
/**
|
|
104
|
-
* Whether this is a parent or child session
|
|
105
|
-
*/
|
|
106
28
|
session_type?: 'parent' | 'child';
|
|
107
29
|
}
|
|
@@ -1,31 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Status Types for Public Status Endpoint
|
|
4
|
-
*
|
|
5
|
-
* These types define the response format for the public status endpoint
|
|
6
|
-
* Used for polling authentication status without exposing sensitive data
|
|
7
|
-
*/
|
|
8
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
3
|
exports.isSuccessStatus = isSuccessStatus;
|
|
10
4
|
exports.shouldContinuePolling = shouldContinuePolling;
|
|
11
5
|
exports.isTerminalHttpStatus = isTerminalHttpStatus;
|
|
12
|
-
/**
|
|
13
|
-
* Type guard to check if authentication was successful
|
|
14
|
-
*/
|
|
15
6
|
function isSuccessStatus(status) {
|
|
16
7
|
return status === 'completed';
|
|
17
8
|
}
|
|
18
|
-
/**
|
|
19
|
-
* Helper to determine if polling should continue based on HTTP status
|
|
20
|
-
*/
|
|
21
9
|
function shouldContinuePolling(httpStatus, response) {
|
|
22
|
-
// Only continue if HTTP 200 and status is pending
|
|
23
10
|
return httpStatus === 200 && (response === null || response === void 0 ? void 0 : response.status) === 'pending';
|
|
24
11
|
}
|
|
25
|
-
/**
|
|
26
|
-
* Helper to determine if session is terminated based on HTTP status
|
|
27
|
-
*/
|
|
28
12
|
function isTerminalHttpStatus(httpStatus) {
|
|
29
|
-
// 410 Gone (expired), 422 Unprocessable (failed), 404 Not Found
|
|
30
13
|
return httpStatus === 410 || httpStatus === 422 || httpStatus === 404;
|
|
31
14
|
}
|