@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.
- 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 -151
- 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 -147
- 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,24 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Validation utilities for phone authentication
|
|
3
|
+
* Validation utilities for phone authentication.
|
|
4
|
+
*
|
|
5
|
+
* Pure functions with no runtime dependencies.
|
|
6
|
+
* All validators return { valid: boolean; error?: string }.
|
|
4
7
|
*/
|
|
5
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.E164_REGEX = void 0;
|
|
6
10
|
exports.validatePhoneNumber = validatePhoneNumber;
|
|
7
11
|
exports.validatePlmn = validatePlmn;
|
|
8
12
|
exports.validateUseCaseRequirements = validateUseCaseRequirements;
|
|
9
|
-
exports.
|
|
10
|
-
|
|
13
|
+
exports.validateNonce = validateNonce;
|
|
14
|
+
exports.validateSessionKey = validateSessionKey;
|
|
15
|
+
const types_1 = require("./types");
|
|
16
|
+
/** E.164 phone number regex */
|
|
17
|
+
exports.E164_REGEX = /^\+[1-9]\d{1,14}$/;
|
|
11
18
|
/**
|
|
12
|
-
* Validates E.164 phone number format
|
|
19
|
+
* Validates E.164 phone number format.
|
|
20
|
+
*
|
|
13
21
|
* @param phoneNumber - Phone number to validate
|
|
14
22
|
* @returns Validation result with error if invalid
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const result = validatePhoneNumber('+14155551234');
|
|
27
|
+
* if (!result.valid) {
|
|
28
|
+
* console.error(result.error);
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
15
31
|
*/
|
|
16
32
|
function validatePhoneNumber(phoneNumber) {
|
|
17
33
|
if (!phoneNumber) {
|
|
18
34
|
return { valid: true }; // Phone number is optional for GetPhoneNumber
|
|
19
35
|
}
|
|
20
|
-
// E.164 format validation - strict, no cleaning
|
|
21
|
-
const e164Regex = /^\+[1-9]\d{1,14}$/;
|
|
22
36
|
if (!phoneNumber.startsWith('+')) {
|
|
23
37
|
return {
|
|
24
38
|
valid: false,
|
|
@@ -37,14 +51,14 @@ function validatePhoneNumber(phoneNumber) {
|
|
|
37
51
|
error: 'Phone number too long for E.164 format (maximum 15 digits after +)'
|
|
38
52
|
};
|
|
39
53
|
}
|
|
40
|
-
// Check for
|
|
54
|
+
// Check for invalid characters (spaces, dashes, parentheses, etc.)
|
|
41
55
|
if (!/^\+\d+$/.test(phoneNumber)) {
|
|
42
56
|
return {
|
|
43
57
|
valid: false,
|
|
44
58
|
error: 'Phone number contains invalid characters. E.164 format only allows + followed by digits'
|
|
45
59
|
};
|
|
46
60
|
}
|
|
47
|
-
if (!
|
|
61
|
+
if (!exports.E164_REGEX.test(phoneNumber)) {
|
|
48
62
|
return {
|
|
49
63
|
valid: false,
|
|
50
64
|
error: 'Invalid E.164 phone number format'
|
|
@@ -53,7 +67,11 @@ function validatePhoneNumber(phoneNumber) {
|
|
|
53
67
|
return { valid: true };
|
|
54
68
|
}
|
|
55
69
|
/**
|
|
56
|
-
* Validates PLMN (MCC/MNC) values
|
|
70
|
+
* Validates PLMN (MCC/MNC) values.
|
|
71
|
+
*
|
|
72
|
+
* @deprecated PLMN validation will be removed with PLMN support.
|
|
73
|
+
* TODO: Remove in next major version
|
|
74
|
+
*
|
|
57
75
|
* @param plmn - PLMN object with MCC and MNC
|
|
58
76
|
* @returns Validation result
|
|
59
77
|
*/
|
|
@@ -76,19 +94,19 @@ function validatePlmn(plmn) {
|
|
|
76
94
|
error: 'MNC must be 2 or 3 digits'
|
|
77
95
|
};
|
|
78
96
|
}
|
|
79
|
-
// No range validation - allowing unofficial MCCs for telco labs
|
|
80
97
|
return { valid: true };
|
|
81
98
|
}
|
|
82
99
|
/**
|
|
83
|
-
* Validates use case and
|
|
100
|
+
* Validates use case and required parameters combination.
|
|
101
|
+
*
|
|
84
102
|
* @param useCase - The use case
|
|
85
103
|
* @param phoneNumber - The phone number (required for VerifyPhoneNumber)
|
|
86
|
-
* @param hasParentSessionId - Whether parent_session_id is provided
|
|
104
|
+
* @param hasParentSessionId - Whether parent_session_id is provided
|
|
87
105
|
* @returns Validation result
|
|
88
106
|
*/
|
|
89
107
|
function validateUseCaseRequirements(useCase, phoneNumber, hasParentSessionId) {
|
|
90
108
|
// VerifyPhoneNumber requires a phone number (unless parent_session_id is provided)
|
|
91
|
-
if (useCase ===
|
|
109
|
+
if (useCase === types_1.USE_CASE.VERIFY_PHONE_NUMBER && !phoneNumber && !hasParentSessionId) {
|
|
92
110
|
return {
|
|
93
111
|
valid: false,
|
|
94
112
|
error: 'Phone number is required for VerifyPhoneNumber use case'
|
|
@@ -97,16 +115,45 @@ function validateUseCaseRequirements(useCase, phoneNumber, hasParentSessionId) {
|
|
|
97
115
|
return { valid: true };
|
|
98
116
|
}
|
|
99
117
|
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
* @param
|
|
103
|
-
* @
|
|
118
|
+
* Validates nonce format.
|
|
119
|
+
*
|
|
120
|
+
* @param nonce - Nonce string to validate
|
|
121
|
+
* @returns Validation result
|
|
122
|
+
*/
|
|
123
|
+
function validateNonce(nonce) {
|
|
124
|
+
const base64urlRegex = /^[A-Za-z0-9_-]+$/;
|
|
125
|
+
if (!nonce || nonce.length === 0) {
|
|
126
|
+
return {
|
|
127
|
+
valid: false,
|
|
128
|
+
error: 'Nonce is required'
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
if (!base64urlRegex.test(nonce)) {
|
|
132
|
+
return {
|
|
133
|
+
valid: false,
|
|
134
|
+
error: 'Nonce must be base64url encoded'
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
if (nonce.length < 32 || nonce.length > 128) {
|
|
138
|
+
return {
|
|
139
|
+
valid: false,
|
|
140
|
+
error: 'Nonce must be between 32 and 128 characters'
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
return { valid: true };
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Validates session key format.
|
|
147
|
+
*
|
|
148
|
+
* @param sessionKey - Session key to validate
|
|
149
|
+
* @returns Validation result
|
|
104
150
|
*/
|
|
105
|
-
function
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
151
|
+
function validateSessionKey(sessionKey) {
|
|
152
|
+
if (!sessionKey || sessionKey.length < 16) {
|
|
153
|
+
return {
|
|
154
|
+
valid: false,
|
|
155
|
+
error: 'Session key is required and must be at least 16 characters'
|
|
156
|
+
};
|
|
110
157
|
}
|
|
111
|
-
return
|
|
158
|
+
return { valid: true };
|
|
112
159
|
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Glide Phone Authentication SDK
|
|
4
|
+
*
|
|
5
|
+
* @example Basic Usage
|
|
6
|
+
* ```typescript
|
|
7
|
+
* import { PhoneAuthClient } from '@glideidentity/web-client-sdk';
|
|
8
|
+
*
|
|
9
|
+
* const client = new PhoneAuthClient({ debug: true });
|
|
10
|
+
* const result = await client.authenticate({
|
|
11
|
+
* use_case: 'VerifyPhoneNumber',
|
|
12
|
+
* phone_number: '+14155551234'
|
|
13
|
+
* });
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @example React
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { usePhoneAuth } from '@glideidentity/web-client-sdk/react';
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @example Vue
|
|
22
|
+
* ```typescript
|
|
23
|
+
* import { usePhoneAuth } from '@glideidentity/web-client-sdk/vue';
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example Core Types Only
|
|
27
|
+
* ```typescript
|
|
28
|
+
* import type { PrepareRequest } from '@glideidentity/web-client-sdk/core';
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.createQRCodeDataFromDesktop = exports.AuthModal = exports.createNoopLogger = exports.createLogger = exports.createHttpClient = exports.E164_REGEX = exports.validateSessionKey = exports.validateNonce = exports.validateUseCaseRequirements = exports.validatePlmn = exports.validatePhoneNumber = exports.isErrorResponse = exports.isVerifyPhoneNumberResponse = exports.isGetPhoneNumberResponse = exports.isDesktopData = exports.isLinkData = exports.isTS43Data = exports.isCancellable = exports.isDesktopStrategy = exports.isLinkStrategy = exports.isTS43Strategy = exports.isAuthCredential = exports.isInvokeResult = exports.parseBackendError = exports.createAuthError = exports.getUserMessage = exports.isRetryableError = exports.isClientError = exports.isAuthError = exports.ERROR_CODES = exports.AUTHENTICATION_STRATEGY = exports.USE_CASE = exports.PhoneAuthClient = void 0;
|
|
33
|
+
// Main client
|
|
34
|
+
var phone_auth_client_1 = require("./client/phone-auth-client");
|
|
35
|
+
Object.defineProperty(exports, "PhoneAuthClient", { enumerable: true, get: function () { return phone_auth_client_1.PhoneAuthClient; } });
|
|
36
|
+
// Constants
|
|
37
|
+
var types_1 = require("./core/types");
|
|
38
|
+
Object.defineProperty(exports, "USE_CASE", { enumerable: true, get: function () { return types_1.USE_CASE; } });
|
|
39
|
+
Object.defineProperty(exports, "AUTHENTICATION_STRATEGY", { enumerable: true, get: function () { return types_1.AUTHENTICATION_STRATEGY; } });
|
|
40
|
+
// Error codes and utilities
|
|
41
|
+
var errors_1 = require("./core/errors");
|
|
42
|
+
Object.defineProperty(exports, "ERROR_CODES", { enumerable: true, get: function () { return errors_1.ERROR_CODES; } });
|
|
43
|
+
var errors_2 = require("./core/errors");
|
|
44
|
+
Object.defineProperty(exports, "isAuthError", { enumerable: true, get: function () { return errors_2.isAuthError; } });
|
|
45
|
+
Object.defineProperty(exports, "isClientError", { enumerable: true, get: function () { return errors_2.isClientError; } });
|
|
46
|
+
Object.defineProperty(exports, "isRetryableError", { enumerable: true, get: function () { return errors_2.isRetryableError; } });
|
|
47
|
+
Object.defineProperty(exports, "getUserMessage", { enumerable: true, get: function () { return errors_2.getUserMessage; } });
|
|
48
|
+
Object.defineProperty(exports, "createAuthError", { enumerable: true, get: function () { return errors_2.createAuthError; } });
|
|
49
|
+
Object.defineProperty(exports, "parseBackendError", { enumerable: true, get: function () { return errors_2.parseBackendError; } });
|
|
50
|
+
// Type guards
|
|
51
|
+
var type_guards_1 = require("./core/type-guards");
|
|
52
|
+
Object.defineProperty(exports, "isInvokeResult", { enumerable: true, get: function () { return type_guards_1.isInvokeResult; } });
|
|
53
|
+
Object.defineProperty(exports, "isAuthCredential", { enumerable: true, get: function () { return type_guards_1.isAuthCredential; } });
|
|
54
|
+
Object.defineProperty(exports, "isTS43Strategy", { enumerable: true, get: function () { return type_guards_1.isTS43Strategy; } });
|
|
55
|
+
Object.defineProperty(exports, "isLinkStrategy", { enumerable: true, get: function () { return type_guards_1.isLinkStrategy; } });
|
|
56
|
+
Object.defineProperty(exports, "isDesktopStrategy", { enumerable: true, get: function () { return type_guards_1.isDesktopStrategy; } });
|
|
57
|
+
Object.defineProperty(exports, "isCancellable", { enumerable: true, get: function () { return type_guards_1.isCancellable; } });
|
|
58
|
+
Object.defineProperty(exports, "isTS43Data", { enumerable: true, get: function () { return type_guards_1.isTS43Data; } });
|
|
59
|
+
Object.defineProperty(exports, "isLinkData", { enumerable: true, get: function () { return type_guards_1.isLinkData; } });
|
|
60
|
+
Object.defineProperty(exports, "isDesktopData", { enumerable: true, get: function () { return type_guards_1.isDesktopData; } });
|
|
61
|
+
Object.defineProperty(exports, "isGetPhoneNumberResponse", { enumerable: true, get: function () { return type_guards_1.isGetPhoneNumberResponse; } });
|
|
62
|
+
Object.defineProperty(exports, "isVerifyPhoneNumberResponse", { enumerable: true, get: function () { return type_guards_1.isVerifyPhoneNumberResponse; } });
|
|
63
|
+
Object.defineProperty(exports, "isErrorResponse", { enumerable: true, get: function () { return type_guards_1.isErrorResponse; } });
|
|
64
|
+
// Validators
|
|
65
|
+
var validators_1 = require("./core/validators");
|
|
66
|
+
Object.defineProperty(exports, "validatePhoneNumber", { enumerable: true, get: function () { return validators_1.validatePhoneNumber; } });
|
|
67
|
+
Object.defineProperty(exports, "validatePlmn", { enumerable: true, get: function () { return validators_1.validatePlmn; } });
|
|
68
|
+
Object.defineProperty(exports, "validateUseCaseRequirements", { enumerable: true, get: function () { return validators_1.validateUseCaseRequirements; } });
|
|
69
|
+
Object.defineProperty(exports, "validateNonce", { enumerable: true, get: function () { return validators_1.validateNonce; } });
|
|
70
|
+
Object.defineProperty(exports, "validateSessionKey", { enumerable: true, get: function () { return validators_1.validateSessionKey; } });
|
|
71
|
+
Object.defineProperty(exports, "E164_REGEX", { enumerable: true, get: function () { return validators_1.E164_REGEX; } });
|
|
72
|
+
// Client utilities (for advanced use)
|
|
73
|
+
var http_1 = require("./client/http");
|
|
74
|
+
Object.defineProperty(exports, "createHttpClient", { enumerable: true, get: function () { return http_1.createHttpClient; } });
|
|
75
|
+
var logger_1 = require("./client/logger");
|
|
76
|
+
Object.defineProperty(exports, "createLogger", { enumerable: true, get: function () { return logger_1.createLogger; } });
|
|
77
|
+
Object.defineProperty(exports, "createNoopLogger", { enumerable: true, get: function () { return logger_1.createNoopLogger; } });
|
|
78
|
+
// UI components
|
|
79
|
+
var modal_1 = require("./ui/modal");
|
|
80
|
+
Object.defineProperty(exports, "AuthModal", { enumerable: true, get: function () { return modal_1.AuthModal; } });
|
|
81
|
+
Object.defineProperty(exports, "createQRCodeDataFromDesktop", { enumerable: true, get: function () { return modal_1.createQRCodeDataFromDesktop; } });
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* UI Components for Phone Authentication SDK
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.MobileDebugConsole = exports.createQRCodeDataFromDesktop = exports.AuthModal = void 0;
|
|
7
|
+
var modal_1 = require("./modal");
|
|
8
|
+
Object.defineProperty(exports, "AuthModal", { enumerable: true, get: function () { return modal_1.AuthModal; } });
|
|
9
|
+
Object.defineProperty(exports, "createQRCodeDataFromDesktop", { enumerable: true, get: function () { return modal_1.createQRCodeDataFromDesktop; } });
|
|
10
|
+
var mobile_debug_console_1 = require("./mobile-debug-console");
|
|
11
|
+
Object.defineProperty(exports, "MobileDebugConsole", { enumerable: true, get: function () { return mobile_debug_console_1.MobileDebugConsole; } });
|
|
@@ -53,24 +53,31 @@ class MobileDebugConsole {
|
|
|
53
53
|
try {
|
|
54
54
|
return JSON.stringify(arg, null, 2);
|
|
55
55
|
}
|
|
56
|
-
catch
|
|
56
|
+
catch {
|
|
57
57
|
return '[Object]';
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
return String(arg);
|
|
61
61
|
}).join(' ');
|
|
62
|
-
//
|
|
62
|
+
// Color scheme for log types
|
|
63
63
|
const colors = {
|
|
64
|
-
log: '#
|
|
65
|
-
error: '#
|
|
66
|
-
warn: '#
|
|
67
|
-
info: '#
|
|
68
|
-
debug: '#
|
|
64
|
+
log: '#abb2bf', // Light gray
|
|
65
|
+
error: '#e06c75', // Soft red
|
|
66
|
+
warn: '#e5c07b', // Yellow/gold
|
|
67
|
+
info: '#61afef', // Blue
|
|
68
|
+
debug: '#5c6370' // Dim gray
|
|
69
|
+
};
|
|
70
|
+
const badges = {
|
|
71
|
+
log: '#3c3c3c',
|
|
72
|
+
error: 'rgba(224, 108, 117, 0.2)',
|
|
73
|
+
warn: 'rgba(229, 192, 123, 0.2)',
|
|
74
|
+
info: 'rgba(97, 175, 239, 0.2)',
|
|
75
|
+
debug: '#2d2d2d'
|
|
69
76
|
};
|
|
70
77
|
const logHtml = `
|
|
71
|
-
<div style="margin:
|
|
72
|
-
<span style="color: #
|
|
73
|
-
<span style="color: ${colors[type]}; font-weight:
|
|
78
|
+
<div style="margin: 3px 0; font-family: 'SF Mono', Menlo, Monaco, monospace; font-size: 11px; color: ${colors[type] || '#abb2bf'}; line-height: 1.5;">
|
|
79
|
+
<span style="color: #5c6370; font-size: 10px;">${timestamp}</span>
|
|
80
|
+
<span style="background: ${badges[type]}; color: ${colors[type]}; padding: 1px 5px; border-radius: 3px; font-size: 9px; font-weight: 500; text-transform: uppercase; margin: 0 6px;">${type}</span>
|
|
74
81
|
<span style="white-space: pre-wrap; word-break: break-all;">${this.escapeHtml(content)}</span>
|
|
75
82
|
</div>
|
|
76
83
|
`;
|
|
@@ -103,12 +110,14 @@ class MobileDebugConsole {
|
|
|
103
110
|
left: 0;
|
|
104
111
|
right: 0;
|
|
105
112
|
height: 45vh;
|
|
106
|
-
background:
|
|
113
|
+
background: #1e1e1e;
|
|
107
114
|
z-index: 999999;
|
|
108
115
|
display: flex;
|
|
109
116
|
flex-direction: column;
|
|
110
|
-
font-family: monospace;
|
|
111
|
-
transition: transform 0.
|
|
117
|
+
font-family: 'SF Mono', Menlo, Monaco, 'Courier New', monospace;
|
|
118
|
+
transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
|
|
119
|
+
border-top: 1px solid #3c3c3c;
|
|
120
|
+
box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
|
|
112
121
|
}
|
|
113
122
|
|
|
114
123
|
#mobile-debug-console.hidden {
|
|
@@ -119,74 +128,136 @@ class MobileDebugConsole {
|
|
|
119
128
|
display: flex;
|
|
120
129
|
justify-content: space-between;
|
|
121
130
|
align-items: center;
|
|
122
|
-
padding:
|
|
123
|
-
background: #
|
|
124
|
-
border-
|
|
131
|
+
padding: 8px 12px;
|
|
132
|
+
background: #2d2d2d;
|
|
133
|
+
border-bottom: 1px solid #3c3c3c;
|
|
134
|
+
min-height: 36px;
|
|
125
135
|
}
|
|
126
136
|
|
|
127
137
|
#debug-title {
|
|
128
|
-
|
|
138
|
+
display: flex;
|
|
139
|
+
align-items: center;
|
|
140
|
+
gap: 8px;
|
|
141
|
+
color: #9da5b4;
|
|
129
142
|
font-size: 12px;
|
|
130
|
-
font-weight:
|
|
143
|
+
font-weight: 500;
|
|
144
|
+
letter-spacing: 0.3px;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
#debug-title svg {
|
|
148
|
+
width: 14px;
|
|
149
|
+
height: 14px;
|
|
150
|
+
opacity: 0.8;
|
|
131
151
|
}
|
|
132
152
|
|
|
133
|
-
|
|
153
|
+
/* Traffic light buttons - using ID for specificity */
|
|
154
|
+
#mobile-debug-console .debug-traffic-lights {
|
|
134
155
|
display: flex;
|
|
135
|
-
gap:
|
|
156
|
+
gap: 8px;
|
|
157
|
+
align-items: center;
|
|
136
158
|
}
|
|
137
159
|
|
|
138
|
-
#debug-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
border-radius:
|
|
144
|
-
|
|
160
|
+
#mobile-debug-console button.debug-traffic-btn {
|
|
161
|
+
width: 16px;
|
|
162
|
+
height: 16px;
|
|
163
|
+
min-width: 16px;
|
|
164
|
+
min-height: 16px;
|
|
165
|
+
border-radius: 50%;
|
|
166
|
+
border: none;
|
|
145
167
|
cursor: pointer;
|
|
168
|
+
display: flex;
|
|
169
|
+
align-items: center;
|
|
170
|
+
justify-content: center;
|
|
171
|
+
padding: 0;
|
|
172
|
+
font-size: 0;
|
|
173
|
+
line-height: 1;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
#mobile-debug-console .debug-traffic-btn svg {
|
|
177
|
+
width: 8px;
|
|
178
|
+
height: 8px;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
#mobile-debug-console .debug-traffic-btn.close {
|
|
182
|
+
background: #ff5f57;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
#mobile-debug-console .debug-traffic-btn.close svg {
|
|
186
|
+
stroke: #820005;
|
|
187
|
+
stroke-width: 2;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
#mobile-debug-console .debug-traffic-btn.clear {
|
|
191
|
+
background: #febc2e;
|
|
146
192
|
}
|
|
147
193
|
|
|
148
|
-
#debug-
|
|
149
|
-
background: #
|
|
194
|
+
#mobile-debug-console .debug-traffic-btn.minimize {
|
|
195
|
+
background: #28c840;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
#mobile-debug-console .debug-traffic-btn.minimize svg {
|
|
199
|
+
stroke: #006500;
|
|
200
|
+
stroke-width: 2;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
#mobile-debug-console .debug-traffic-btn:active {
|
|
204
|
+
filter: brightness(0.85);
|
|
150
205
|
}
|
|
151
206
|
|
|
152
207
|
#debug-logs {
|
|
153
208
|
flex: 1;
|
|
154
209
|
overflow-y: auto;
|
|
155
|
-
padding:
|
|
210
|
+
padding: 12px;
|
|
211
|
+
background: #1e1e1e;
|
|
156
212
|
-webkit-overflow-scrolling: touch;
|
|
157
213
|
}
|
|
158
214
|
|
|
159
|
-
#debug-floating-toggle {
|
|
160
|
-
position: fixed;
|
|
161
|
-
bottom: 20px;
|
|
162
|
-
right: 20px;
|
|
163
|
-
width:
|
|
164
|
-
height:
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
border:
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
215
|
+
button#debug-floating-toggle {
|
|
216
|
+
position: fixed !important;
|
|
217
|
+
bottom: 20px !important;
|
|
218
|
+
right: 20px !important;
|
|
219
|
+
width: 42px !important;
|
|
220
|
+
height: 42px !important;
|
|
221
|
+
min-width: 42px !important;
|
|
222
|
+
min-height: 42px !important;
|
|
223
|
+
border-radius: 8px !important;
|
|
224
|
+
background: #2d2d2d !important;
|
|
225
|
+
border: 1px solid #3c3c3c !important;
|
|
226
|
+
color: #9da5b4 !important;
|
|
227
|
+
cursor: pointer !important;
|
|
228
|
+
z-index: 999998 !important;
|
|
171
229
|
display: none;
|
|
172
|
-
align-items: center;
|
|
173
|
-
justify-content: center;
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
230
|
+
align-items: center !important;
|
|
231
|
+
justify-content: center !important;
|
|
232
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
|
|
233
|
+
transition: all 0.2s ease !important;
|
|
234
|
+
padding: 0 !important;
|
|
235
|
+
margin: 0 !important;
|
|
177
236
|
}
|
|
178
237
|
|
|
179
|
-
#debug-floating-toggle:hover {
|
|
180
|
-
background:
|
|
181
|
-
|
|
182
|
-
|
|
238
|
+
button#debug-floating-toggle:hover {
|
|
239
|
+
background: #3c3c3c !important;
|
|
240
|
+
color: #fff !important;
|
|
241
|
+
transform: translateY(-2px) !important;
|
|
242
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
|
|
183
243
|
}
|
|
184
244
|
|
|
185
|
-
#debug-floating-toggle
|
|
186
|
-
|
|
245
|
+
button#debug-floating-toggle:active {
|
|
246
|
+
transform: translateY(0) !important;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
button#debug-floating-toggle.visible {
|
|
250
|
+
display: flex !important;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
button#debug-floating-toggle svg {
|
|
254
|
+
width: 20px !important;
|
|
255
|
+
height: 20px !important;
|
|
187
256
|
}
|
|
188
257
|
`;
|
|
189
258
|
document.head.appendChild(style);
|
|
259
|
+
// Terminal icon SVG (>_)
|
|
260
|
+
const terminalIcon = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 17 10 11 4 5"></polyline><line x1="12" y1="19" x2="20" y2="19"></line></svg>`;
|
|
190
261
|
// Create container
|
|
191
262
|
this.container = document.createElement('div');
|
|
192
263
|
this.container.id = 'mobile-debug-console';
|
|
@@ -198,27 +269,33 @@ class MobileDebugConsole {
|
|
|
198
269
|
header.id = 'debug-header';
|
|
199
270
|
const title = document.createElement('div');
|
|
200
271
|
title.id = 'debug-title';
|
|
201
|
-
title.
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
272
|
+
title.innerHTML = `${terminalIcon}<span>Mobile Console</span>`;
|
|
273
|
+
// Traffic light control buttons
|
|
274
|
+
const trafficLights = document.createElement('div');
|
|
275
|
+
trafficLights.className = 'debug-traffic-lights';
|
|
276
|
+
// Close button (red) - ×
|
|
277
|
+
const closeBtn = document.createElement('button');
|
|
278
|
+
closeBtn.className = 'debug-traffic-btn close';
|
|
279
|
+
closeBtn.title = 'Close';
|
|
280
|
+
closeBtn.innerHTML = `<svg viewBox="0 0 10 10" fill="none"><line x1="2.5" y1="2.5" x2="7.5" y2="7.5" stroke="currentColor"/><line x1="7.5" y1="2.5" x2="2.5" y2="7.5" stroke="currentColor"/></svg>`;
|
|
281
|
+
closeBtn.onclick = () => this.cleanup();
|
|
282
|
+
// Clear button (yellow) - trash icon
|
|
205
283
|
const clearBtn = document.createElement('button');
|
|
206
|
-
clearBtn.
|
|
284
|
+
clearBtn.className = 'debug-traffic-btn clear';
|
|
285
|
+
clearBtn.title = 'Clear';
|
|
286
|
+
clearBtn.innerHTML = `<svg viewBox="0 0 16 16" fill="currentColor"><path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5m2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5m3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0z"/><path d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1zM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4zM2.5 3h11V2h-11z"/></svg>`;
|
|
207
287
|
clearBtn.onclick = () => this.clear();
|
|
208
|
-
//
|
|
288
|
+
// Minimize button (green) - minimize to floating button
|
|
209
289
|
const toggleBtn = document.createElement('button');
|
|
210
|
-
toggleBtn.
|
|
290
|
+
toggleBtn.className = 'debug-traffic-btn minimize';
|
|
291
|
+
toggleBtn.title = 'Minimize';
|
|
292
|
+
toggleBtn.innerHTML = `<svg viewBox="0 0 10 10" fill="none"><path d="M2 3L5 6L8 3" stroke="currentColor" fill="none"/></svg>`;
|
|
211
293
|
toggleBtn.onclick = () => this.toggle();
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
closeBtn.onclick = () => this.cleanup();
|
|
217
|
-
buttons.appendChild(clearBtn);
|
|
218
|
-
buttons.appendChild(toggleBtn);
|
|
219
|
-
buttons.appendChild(closeBtn);
|
|
294
|
+
trafficLights.appendChild(closeBtn);
|
|
295
|
+
trafficLights.appendChild(clearBtn);
|
|
296
|
+
trafficLights.appendChild(toggleBtn);
|
|
297
|
+
header.appendChild(trafficLights);
|
|
220
298
|
header.appendChild(title);
|
|
221
|
-
header.appendChild(buttons);
|
|
222
299
|
// Create logs container
|
|
223
300
|
this.logsContainer = document.createElement('div');
|
|
224
301
|
this.logsContainer.id = 'debug-logs';
|
|
@@ -230,15 +307,13 @@ class MobileDebugConsole {
|
|
|
230
307
|
this.container.appendChild(header);
|
|
231
308
|
this.container.appendChild(this.logsContainer);
|
|
232
309
|
document.body.appendChild(this.container);
|
|
233
|
-
// Create floating toggle button
|
|
310
|
+
// Create floating toggle button with terminal icon
|
|
234
311
|
this.floatingToggle = document.createElement('button');
|
|
235
312
|
this.floatingToggle.id = 'debug-floating-toggle';
|
|
236
|
-
this.floatingToggle.innerHTML =
|
|
237
|
-
this.floatingToggle.title = 'Show
|
|
313
|
+
this.floatingToggle.innerHTML = terminalIcon;
|
|
314
|
+
this.floatingToggle.title = 'Show Console';
|
|
238
315
|
this.floatingToggle.onclick = () => this.toggle();
|
|
239
316
|
document.body.appendChild(this.floatingToggle);
|
|
240
|
-
// Store reference for toggle button
|
|
241
|
-
window.__debugToggleBtn = toggleBtn;
|
|
242
317
|
}
|
|
243
318
|
escapeHtml(text) {
|
|
244
319
|
const div = document.createElement('div');
|
|
@@ -251,13 +326,11 @@ class MobileDebugConsole {
|
|
|
251
326
|
if (this.isVisible) {
|
|
252
327
|
this.container.classList.remove('hidden');
|
|
253
328
|
this.floatingToggle.classList.remove('visible');
|
|
254
|
-
window.__debugToggleBtn.textContent = 'Hide';
|
|
255
329
|
this.updateDisplay();
|
|
256
330
|
}
|
|
257
331
|
else {
|
|
258
332
|
this.container.classList.add('hidden');
|
|
259
333
|
this.floatingToggle.classList.add('visible');
|
|
260
|
-
window.__debugToggleBtn.textContent = 'Show';
|
|
261
334
|
}
|
|
262
335
|
}
|
|
263
336
|
}
|
|
@@ -280,8 +353,6 @@ class MobileDebugConsole {
|
|
|
280
353
|
if (this.floatingToggle) {
|
|
281
354
|
this.floatingToggle.remove();
|
|
282
355
|
}
|
|
283
|
-
// Clean up references
|
|
284
|
-
delete window.__debugToggleBtn;
|
|
285
356
|
}
|
|
286
357
|
}
|
|
287
358
|
exports.MobileDebugConsole = MobileDebugConsole;
|