@glideidentity/web-client-sdk 5.0.0 → 5.0.1-beta.0
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
|
@@ -1,27 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type Guards and Helper Functions for Phone Authentication
|
|
3
|
-
*
|
|
4
|
-
* These utilities help developers work with the SDK responses in a type-safe way
|
|
5
|
-
* without having to write their own type checking logic.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Type guard to check if the result is an ExtendedResponse (extended mode)
|
|
9
|
-
* or a Credential (standard mode).
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* const result = await invokeSecurePrompt(sdkRequest, { executionMode: 'extended' });
|
|
14
|
-
*
|
|
15
|
-
* if (isExtendedResponse(result)) {
|
|
16
|
-
* // TypeScript knows this is ExtendedResponse
|
|
17
|
-
* console.log(result.strategy);
|
|
18
|
-
* await result.cancel();
|
|
19
|
-
* } else {
|
|
20
|
-
* // TypeScript knows this is a Credential
|
|
21
|
-
* const processedResult = await verifyPhoneNumberCredential(result, session);
|
|
22
|
-
* }
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
1
|
export function isExtendedResponse(result) {
|
|
26
2
|
return result &&
|
|
27
3
|
typeof result === 'object' &&
|
|
@@ -30,41 +6,16 @@ export function isExtendedResponse(result) {
|
|
|
30
6
|
'cancel' in result &&
|
|
31
7
|
typeof result.cancel === 'function';
|
|
32
8
|
}
|
|
33
|
-
/**
|
|
34
|
-
* Type guard to check if the result is a Credential (standard mode response).
|
|
35
|
-
* A credential is either a string token or an object without ExtendedResponse properties.
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```typescript
|
|
39
|
-
* if (isCredential(result)) {
|
|
40
|
-
* // Process the credential directly
|
|
41
|
-
* const verified = await verifyPhoneNumberCredential(result, session);
|
|
42
|
-
* }
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
9
|
export function isCredential(result) {
|
|
46
10
|
if (!result)
|
|
47
11
|
return false;
|
|
48
|
-
// String credentials are valid
|
|
49
12
|
if (typeof result === 'string')
|
|
50
13
|
return true;
|
|
51
|
-
// Object credentials should NOT have ExtendedResponse properties
|
|
52
14
|
if (typeof result === 'object') {
|
|
53
15
|
return !('strategy' in result) && !('credential' in result) && !('cancel' in result);
|
|
54
16
|
}
|
|
55
17
|
return false;
|
|
56
18
|
}
|
|
57
|
-
/**
|
|
58
|
-
* Type guard to check if the result is an AuthCredential object.
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* ```typescript
|
|
62
|
-
* if (isAuthCredential(result)) {
|
|
63
|
-
* console.log(result.credential);
|
|
64
|
-
* console.log(result.authenticated);
|
|
65
|
-
* }
|
|
66
|
-
* ```
|
|
67
|
-
*/
|
|
68
19
|
export function isAuthCredential(result) {
|
|
69
20
|
return result &&
|
|
70
21
|
typeof result === 'object' &&
|
|
@@ -72,114 +23,32 @@ export function isAuthCredential(result) {
|
|
|
72
23
|
'authenticated' in result &&
|
|
73
24
|
'session' in result;
|
|
74
25
|
}
|
|
75
|
-
/**
|
|
76
|
-
* Type guard to check if an ExtendedResponse is using the Link strategy.
|
|
77
|
-
* Link strategy involves opening an app link (App Clip on iOS, app on Android).
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
* ```typescript
|
|
81
|
-
* if (isExtendedResponse(result) && isLinkStrategy(result)) {
|
|
82
|
-
* // Re-trigger app opening if needed
|
|
83
|
-
* result.trigger();
|
|
84
|
-
* await result.credential;
|
|
85
|
-
* }
|
|
86
|
-
* ```
|
|
87
|
-
*/
|
|
88
26
|
export function isLinkStrategy(result) {
|
|
89
27
|
return result.strategy === 'link';
|
|
90
28
|
}
|
|
91
|
-
/**
|
|
92
|
-
* Type guard to check if an ExtendedResponse is using the TS43 strategy.
|
|
93
|
-
* TS43 strategy uses the browser's Digital Credentials API.
|
|
94
|
-
*
|
|
95
|
-
* @example
|
|
96
|
-
* ```typescript
|
|
97
|
-
* if (isExtendedResponse(result) && isTS43Strategy(result)) {
|
|
98
|
-
* // Re-trigger credential request if needed
|
|
99
|
-
* await result.trigger();
|
|
100
|
-
* }
|
|
101
|
-
* ```
|
|
102
|
-
*/
|
|
103
29
|
export function isTS43Strategy(result) {
|
|
104
30
|
return result.strategy === 'ts43';
|
|
105
31
|
}
|
|
106
|
-
/**
|
|
107
|
-
* Type guard to check if an ExtendedResponse is using the Desktop strategy.
|
|
108
|
-
* Desktop strategy involves QR codes for cross-device authentication.
|
|
109
|
-
*
|
|
110
|
-
* @example
|
|
111
|
-
* ```typescript
|
|
112
|
-
* if (isExtendedResponse(result) && isDesktopStrategy(result)) {
|
|
113
|
-
* // Show custom QR code UI
|
|
114
|
-
* displayQRCode(result.qr_code_data);
|
|
115
|
-
* await result.start_polling();
|
|
116
|
-
* }
|
|
117
|
-
* ```
|
|
118
|
-
*/
|
|
119
32
|
export function isDesktopStrategy(result) {
|
|
120
33
|
return result.strategy === 'desktop';
|
|
121
34
|
}
|
|
122
|
-
/**
|
|
123
|
-
* Helper function to safely get the authentication strategy from any result.
|
|
124
|
-
* Returns undefined if the result is not an ExtendedResponse.
|
|
125
|
-
*
|
|
126
|
-
* @example
|
|
127
|
-
* ```typescript
|
|
128
|
-
* const strategy = getStrategy(result);
|
|
129
|
-
* if (strategy === 'link') {
|
|
130
|
-
* // Handle link strategy
|
|
131
|
-
* }
|
|
132
|
-
* ```
|
|
133
|
-
*/
|
|
134
35
|
export function getStrategy(result) {
|
|
135
36
|
if (isExtendedResponse(result)) {
|
|
136
37
|
return result.strategy;
|
|
137
38
|
}
|
|
138
39
|
return undefined;
|
|
139
40
|
}
|
|
140
|
-
/**
|
|
141
|
-
* Helper function to determine if a result has polling controls.
|
|
142
|
-
* Link and Desktop strategies have polling controls in extended mode.
|
|
143
|
-
*
|
|
144
|
-
* @example
|
|
145
|
-
* ```typescript
|
|
146
|
-
* if (hasPollingControls(result)) {
|
|
147
|
-
* await result.start_polling();
|
|
148
|
-
* }
|
|
149
|
-
* ```
|
|
150
|
-
*/
|
|
151
41
|
export function hasPollingControls(result) {
|
|
152
42
|
if (!isExtendedResponse(result))
|
|
153
43
|
return false;
|
|
154
44
|
return (result.strategy === 'link' && 'start_polling' in result) ||
|
|
155
45
|
(result.strategy === 'desktop' && 'start_polling' in result);
|
|
156
46
|
}
|
|
157
|
-
/**
|
|
158
|
-
* Helper function to determine if a result has a trigger method.
|
|
159
|
-
* Link and TS43 strategies have trigger methods in extended mode.
|
|
160
|
-
*
|
|
161
|
-
* @example
|
|
162
|
-
* ```typescript
|
|
163
|
-
* if (hasTrigger(result)) {
|
|
164
|
-
* result.trigger();
|
|
165
|
-
* }
|
|
166
|
-
* ```
|
|
167
|
-
*/
|
|
168
47
|
export function hasTrigger(result) {
|
|
169
48
|
if (!isExtendedResponse(result))
|
|
170
49
|
return false;
|
|
171
50
|
return 'trigger' in result && typeof result.trigger === 'function';
|
|
172
51
|
}
|
|
173
|
-
// Export legacy function names as deprecated aliases for backward compatibility
|
|
174
|
-
/**
|
|
175
|
-
* @deprecated Use isExtendedResponse instead
|
|
176
|
-
*/
|
|
177
52
|
export const isHeadlessResult = isExtendedResponse;
|
|
178
|
-
/**
|
|
179
|
-
* @deprecated Use hasPollingControls instead
|
|
180
|
-
*/
|
|
181
53
|
export const requiresPolling = hasPollingControls;
|
|
182
|
-
/**
|
|
183
|
-
* @deprecated This function is no longer needed as extended mode handles user actions differently
|
|
184
|
-
*/
|
|
185
54
|
export const requiresUserAction = (result) => false;
|
|
@@ -1,100 +1,33 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Phone Authentication Types
|
|
3
|
-
*
|
|
4
|
-
* This file exports the types used by the Phone Auth SDK.
|
|
5
|
-
* All API types are imported from api-types.ts to ensure consistency.
|
|
6
|
-
* No backward compatibility - using clean API specification only.
|
|
7
|
-
*/
|
|
8
1
|
export * from './api-types';
|
|
9
2
|
import type { PrepareRequest as APIPrepareRequest, GetPhoneNumberResponse, VerifyPhoneNumberResponse, UseCase as APIUseCase, AuthenticationStrategy as APIAuthStrategy } from './api-types';
|
|
10
3
|
export type PhoneAuthOptions = APIPrepareRequest;
|
|
11
4
|
export type PhoneAuthResult = GetPhoneNumberResponse | VerifyPhoneNumberResponse;
|
|
12
5
|
export type UseCaseType = APIUseCase;
|
|
13
6
|
export type AuthenticationStrategyType = APIAuthStrategy;
|
|
14
|
-
/**
|
|
15
|
-
* SDK-specific error codes from error-utils
|
|
16
|
-
*/
|
|
17
7
|
import type { PhoneAuthErrorCode as ErrorCodeFromUtils } from './error-utils';
|
|
18
8
|
export type PhoneAuthErrorCode = ErrorCodeFromUtils;
|
|
19
|
-
/**
|
|
20
|
-
* SDK configuration callbacks
|
|
21
|
-
*/
|
|
22
9
|
export interface PhoneAuthCallbacks {
|
|
23
|
-
/**
|
|
24
|
-
* Called when cross-device authentication is detected (e.g., QR code shown)
|
|
25
|
-
*/
|
|
26
10
|
onCrossDeviceDetected?: () => void;
|
|
27
|
-
/**
|
|
28
|
-
* Called when a retry attempt is made
|
|
29
|
-
* @param attempt Current attempt number
|
|
30
|
-
* @param maxAttempts Maximum number of attempts
|
|
31
|
-
*/
|
|
32
11
|
onRetryAttempt?: (attempt: number, maxAttempts: number) => void;
|
|
33
|
-
/**
|
|
34
|
-
* Called when authentication times out
|
|
35
|
-
*/
|
|
36
12
|
onTimeout?: () => void;
|
|
37
|
-
/**
|
|
38
|
-
* Called when user cancels authentication
|
|
39
|
-
*/
|
|
40
13
|
onCancel?: () => void;
|
|
41
|
-
/**
|
|
42
|
-
* Called when polling starts
|
|
43
|
-
*/
|
|
44
14
|
onPollingStart?: () => void;
|
|
45
|
-
/**
|
|
46
|
-
* Called when polling stops
|
|
47
|
-
*/
|
|
48
15
|
onPollingStop?: () => void;
|
|
49
16
|
}
|
|
50
|
-
/**
|
|
51
|
-
* SDK configuration options
|
|
52
|
-
*/
|
|
53
17
|
export interface AuthConfig extends PhoneAuthCallbacks {
|
|
54
|
-
/**
|
|
55
|
-
* Custom endpoints for authentication flow
|
|
56
|
-
*/
|
|
57
18
|
endpoints?: {
|
|
58
19
|
prepare?: string;
|
|
59
20
|
process?: string;
|
|
60
|
-
/** Desktop authentication status polling endpoint */
|
|
61
21
|
polling?: string;
|
|
62
22
|
};
|
|
63
|
-
/**
|
|
64
|
-
* Timeout for API calls in milliseconds
|
|
65
|
-
* @default 30000
|
|
66
|
-
*/
|
|
67
23
|
timeout?: number;
|
|
68
|
-
/**
|
|
69
|
-
* Polling interval in milliseconds for status checks
|
|
70
|
-
* @default 2000
|
|
71
|
-
*/
|
|
72
24
|
pollingInterval?: number;
|
|
73
|
-
/**
|
|
74
|
-
* Maximum polling attempts before timeout
|
|
75
|
-
* @default 30 (1 minute with 2s interval)
|
|
76
|
-
*/
|
|
77
25
|
maxPollingAttempts?: number;
|
|
78
|
-
/**
|
|
79
|
-
* Enable debug logging
|
|
80
|
-
* @default false
|
|
81
|
-
*/
|
|
82
26
|
debug?: boolean;
|
|
83
|
-
/**
|
|
84
|
-
* Developer tools configuration for debugging
|
|
85
|
-
*/
|
|
86
27
|
devtools?: {
|
|
87
|
-
/**
|
|
88
|
-
* Show mobile console overlay for on-device debugging
|
|
89
|
-
* Displays all console logs at the bottom of the screen
|
|
90
|
-
* @default false
|
|
91
|
-
*/
|
|
92
28
|
showMobileConsole?: boolean;
|
|
93
29
|
};
|
|
94
30
|
}
|
|
95
|
-
/**
|
|
96
|
-
* SDK-enhanced error type with additional context
|
|
97
|
-
*/
|
|
98
31
|
export interface AuthError {
|
|
99
32
|
code: PhoneAuthErrorCode;
|
|
100
33
|
message: string;
|
|
@@ -121,13 +54,7 @@ export interface AuthError {
|
|
|
121
54
|
[key: string]: any;
|
|
122
55
|
};
|
|
123
56
|
}
|
|
124
|
-
/**
|
|
125
|
-
* SDK authentication flow steps
|
|
126
|
-
*/
|
|
127
57
|
export type AuthStep = 'idle' | 'requesting' | 'authenticating' | 'processing' | 'complete';
|
|
128
|
-
/**
|
|
129
|
-
* Browser error names
|
|
130
|
-
*/
|
|
131
58
|
export declare const BrowserError: {
|
|
132
59
|
readonly NOT_ALLOWED: "NotAllowedError";
|
|
133
60
|
readonly NETWORK: "NetworkError";
|
|
@@ -145,9 +72,6 @@ export declare const BrowserError: {
|
|
|
145
72
|
readonly SYNTAX: "SyntaxError";
|
|
146
73
|
};
|
|
147
74
|
export type BrowserErrorType = typeof BrowserError[keyof typeof BrowserError];
|
|
148
|
-
/**
|
|
149
|
-
* Browser error codes
|
|
150
|
-
*/
|
|
151
75
|
export declare const BrowserErrorCode: {
|
|
152
76
|
readonly USER_CANCELLED_DC_API: 19;
|
|
153
77
|
readonly PERMISSION_DENIED: 1;
|
|
@@ -159,9 +83,6 @@ export declare const BrowserErrorCode: {
|
|
|
159
83
|
readonly SECURITY: 18;
|
|
160
84
|
};
|
|
161
85
|
export type BrowserErrorCodeType = typeof BrowserErrorCode[keyof typeof BrowserErrorCode];
|
|
162
|
-
/**
|
|
163
|
-
* Browser names for detection
|
|
164
|
-
*/
|
|
165
86
|
export declare const BrowserName: {
|
|
166
87
|
readonly CHROME: "Chrome";
|
|
167
88
|
readonly EDGE: "Edge";
|
|
@@ -172,9 +93,6 @@ export declare const BrowserName: {
|
|
|
172
93
|
readonly OTHER: "other";
|
|
173
94
|
};
|
|
174
95
|
export type BrowserNameType = typeof BrowserName[keyof typeof BrowserName];
|
|
175
|
-
/**
|
|
176
|
-
* Browser Digital Credential type (extends standard Credential)
|
|
177
|
-
*/
|
|
178
96
|
export interface DigitalCredential extends Credential {
|
|
179
97
|
data: {
|
|
180
98
|
vp_token: {
|
|
@@ -182,9 +100,6 @@ export interface DigitalCredential extends Credential {
|
|
|
182
100
|
};
|
|
183
101
|
};
|
|
184
102
|
}
|
|
185
|
-
/**
|
|
186
|
-
* Browser credential request structure
|
|
187
|
-
*/
|
|
188
103
|
export interface SecureCredentialRequest {
|
|
189
104
|
digital: {
|
|
190
105
|
requests: Array<{
|
|
@@ -193,40 +108,17 @@ export interface SecureCredentialRequest {
|
|
|
193
108
|
}>;
|
|
194
109
|
};
|
|
195
110
|
}
|
|
196
|
-
/**
|
|
197
|
-
* Authentication status constants
|
|
198
|
-
* Maps to both client-side states and backend responses
|
|
199
|
-
*/
|
|
200
111
|
export declare const AuthStatus: {
|
|
201
|
-
/** Authentication in progress */
|
|
202
112
|
readonly PENDING: "pending";
|
|
203
|
-
/** Authentication completed successfully */
|
|
204
113
|
readonly COMPLETED: "completed";
|
|
205
|
-
/** User cancelled authentication */
|
|
206
114
|
readonly CANCELLED: "cancelled";
|
|
207
|
-
/** Authentication failed or expired */
|
|
208
115
|
readonly FAILED: "failed";
|
|
209
|
-
/** Session expired (backend returns 410 Gone) */
|
|
210
116
|
readonly EXPIRED: "expired";
|
|
211
|
-
/** Session not found (backend returns 404) */
|
|
212
117
|
readonly NOT_FOUND: "not_found";
|
|
213
118
|
};
|
|
214
119
|
export type AuthStatusType = typeof AuthStatus[keyof typeof AuthStatus];
|
|
215
|
-
/**
|
|
216
|
-
* Controller for managing authentication sessions
|
|
217
|
-
* Allows cancellation and cleanup of ongoing authentication
|
|
218
|
-
*/
|
|
219
120
|
export interface AuthController {
|
|
220
|
-
/**
|
|
221
|
-
* Cancel the ongoing authentication
|
|
222
|
-
*/
|
|
223
121
|
cancel(): void;
|
|
224
|
-
/**
|
|
225
|
-
* The authentication promise
|
|
226
|
-
*/
|
|
227
122
|
promise: Promise<any>;
|
|
228
|
-
/**
|
|
229
|
-
* Current status of the authentication
|
|
230
|
-
*/
|
|
231
123
|
status: AuthStatusType;
|
|
232
124
|
}
|
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Phone Authentication Types
|
|
3
|
-
*
|
|
4
|
-
* This file exports the types used by the Phone Auth SDK.
|
|
5
|
-
* All API types are imported from api-types.ts to ensure consistency.
|
|
6
|
-
* No backward compatibility - using clean API specification only.
|
|
7
|
-
*/
|
|
8
|
-
// ============================================================================
|
|
9
|
-
// RE-EXPORT ALL API TYPES
|
|
10
|
-
// ============================================================================
|
|
11
1
|
export * from './api-types';
|
|
12
|
-
// ============================================================================
|
|
13
|
-
// BROWSER-SPECIFIC TYPES
|
|
14
|
-
// ============================================================================
|
|
15
|
-
/**
|
|
16
|
-
* Browser error names
|
|
17
|
-
*/
|
|
18
2
|
export const BrowserError = {
|
|
19
3
|
NOT_ALLOWED: 'NotAllowedError',
|
|
20
4
|
NETWORK: 'NetworkError',
|
|
@@ -31,9 +15,6 @@ export const BrowserError = {
|
|
|
31
15
|
RANGE: 'RangeError',
|
|
32
16
|
SYNTAX: 'SyntaxError'
|
|
33
17
|
};
|
|
34
|
-
/**
|
|
35
|
-
* Browser error codes
|
|
36
|
-
*/
|
|
37
18
|
export const BrowserErrorCode = {
|
|
38
19
|
USER_CANCELLED_DC_API: 19,
|
|
39
20
|
PERMISSION_DENIED: 1,
|
|
@@ -44,9 +25,6 @@ export const BrowserErrorCode = {
|
|
|
44
25
|
NETWORK: 19,
|
|
45
26
|
SECURITY: 18
|
|
46
27
|
};
|
|
47
|
-
/**
|
|
48
|
-
* Browser names for detection
|
|
49
|
-
*/
|
|
50
28
|
export const BrowserName = {
|
|
51
29
|
CHROME: 'Chrome',
|
|
52
30
|
EDGE: 'Edge',
|
|
@@ -56,21 +34,11 @@ export const BrowserName = {
|
|
|
56
34
|
BRAVE: 'Brave',
|
|
57
35
|
OTHER: 'other'
|
|
58
36
|
};
|
|
59
|
-
/**
|
|
60
|
-
* Authentication status constants
|
|
61
|
-
* Maps to both client-side states and backend responses
|
|
62
|
-
*/
|
|
63
37
|
export const AuthStatus = {
|
|
64
|
-
/** Authentication in progress */
|
|
65
38
|
PENDING: 'pending',
|
|
66
|
-
/** Authentication completed successfully */
|
|
67
39
|
COMPLETED: 'completed',
|
|
68
|
-
/** User cancelled authentication */
|
|
69
40
|
CANCELLED: 'cancelled',
|
|
70
|
-
/** Authentication failed or expired */
|
|
71
41
|
FAILED: 'failed',
|
|
72
|
-
/** Session expired (backend returns 410 Gone) */
|
|
73
42
|
EXPIRED: 'expired',
|
|
74
|
-
/** Session not found (backend returns 404) */
|
|
75
43
|
NOT_FOUND: 'not_found'
|
|
76
44
|
};
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Mobile Debug Console
|
|
3
|
-
* A lightweight console overlay for debugging on mobile devices where dev tools aren't available
|
|
4
|
-
*/
|
|
5
1
|
export class MobileDebugConsole {
|
|
6
2
|
constructor() {
|
|
7
3
|
this.logs = [];
|
|
@@ -36,15 +32,13 @@ export class MobileDebugConsole {
|
|
|
36
32
|
['log', 'error', 'warn', 'debug', 'info'].forEach(method => {
|
|
37
33
|
const originalMethod = this.originalConsole[method];
|
|
38
34
|
console[method] = (...args) => {
|
|
39
|
-
// Call original
|
|
40
35
|
originalMethod.apply(console, args);
|
|
41
|
-
// Add to our display
|
|
42
36
|
this.addLog(method, args);
|
|
43
37
|
};
|
|
44
38
|
});
|
|
45
39
|
}
|
|
46
40
|
addLog(type, args) {
|
|
47
|
-
const timestamp = new Date().toTimeString().split(' ')[0];
|
|
41
|
+
const timestamp = new Date().toTimeString().split(' ')[0];
|
|
48
42
|
const content = args.map(arg => {
|
|
49
43
|
if (typeof arg === 'object') {
|
|
50
44
|
try {
|
|
@@ -56,7 +50,6 @@ export class MobileDebugConsole {
|
|
|
56
50
|
}
|
|
57
51
|
return String(arg);
|
|
58
52
|
}).join(' ');
|
|
59
|
-
// Create colored log entry
|
|
60
53
|
const colors = {
|
|
61
54
|
log: '#fff',
|
|
62
55
|
error: '#ff6b6b',
|
|
@@ -72,7 +65,6 @@ export class MobileDebugConsole {
|
|
|
72
65
|
</div>
|
|
73
66
|
`;
|
|
74
67
|
this.logs.push(logHtml);
|
|
75
|
-
// Keep only last 500 logs
|
|
76
68
|
if (this.logs.length > 500) {
|
|
77
69
|
this.logs.shift();
|
|
78
70
|
}
|
|
@@ -81,17 +73,13 @@ export class MobileDebugConsole {
|
|
|
81
73
|
updateDisplay() {
|
|
82
74
|
if (!this.logsContainer || !this.isVisible)
|
|
83
75
|
return;
|
|
84
|
-
// Check if scrolled to bottom before update
|
|
85
76
|
this.isAtBottom = this.logsContainer.scrollHeight - this.logsContainer.scrollTop <= this.logsContainer.clientHeight + 50;
|
|
86
|
-
// Update content
|
|
87
77
|
this.logsContainer.innerHTML = this.logs.join('');
|
|
88
|
-
// Auto-scroll only if was at bottom
|
|
89
78
|
if (this.isAtBottom) {
|
|
90
79
|
this.logsContainer.scrollTop = this.logsContainer.scrollHeight;
|
|
91
80
|
}
|
|
92
81
|
}
|
|
93
82
|
createUI() {
|
|
94
|
-
// Create styles
|
|
95
83
|
const style = document.createElement('style');
|
|
96
84
|
style.textContent = `
|
|
97
85
|
#mobile-debug-console {
|
|
@@ -184,13 +172,11 @@ export class MobileDebugConsole {
|
|
|
184
172
|
}
|
|
185
173
|
`;
|
|
186
174
|
document.head.appendChild(style);
|
|
187
|
-
// Create container
|
|
188
175
|
this.container = document.createElement('div');
|
|
189
176
|
this.container.id = 'mobile-debug-console';
|
|
190
177
|
if (!this.isVisible) {
|
|
191
178
|
this.container.className = 'hidden';
|
|
192
179
|
}
|
|
193
|
-
// Create header
|
|
194
180
|
const header = document.createElement('div');
|
|
195
181
|
header.id = 'debug-header';
|
|
196
182
|
const title = document.createElement('div');
|
|
@@ -198,15 +184,12 @@ export class MobileDebugConsole {
|
|
|
198
184
|
title.textContent = '📱 Mobile Debug Console';
|
|
199
185
|
const buttons = document.createElement('div');
|
|
200
186
|
buttons.id = 'debug-buttons';
|
|
201
|
-
// Clear button
|
|
202
187
|
const clearBtn = document.createElement('button');
|
|
203
188
|
clearBtn.textContent = 'Clear';
|
|
204
189
|
clearBtn.onclick = () => this.clear();
|
|
205
|
-
// Show/Hide button
|
|
206
190
|
const toggleBtn = document.createElement('button');
|
|
207
191
|
toggleBtn.textContent = 'Hide';
|
|
208
192
|
toggleBtn.onclick = () => this.toggle();
|
|
209
|
-
// Close button
|
|
210
193
|
const closeBtn = document.createElement('button');
|
|
211
194
|
closeBtn.textContent = '✕';
|
|
212
195
|
closeBtn.style.color = '#ff6b6b';
|
|
@@ -216,25 +199,20 @@ export class MobileDebugConsole {
|
|
|
216
199
|
buttons.appendChild(closeBtn);
|
|
217
200
|
header.appendChild(title);
|
|
218
201
|
header.appendChild(buttons);
|
|
219
|
-
// Create logs container
|
|
220
202
|
this.logsContainer = document.createElement('div');
|
|
221
203
|
this.logsContainer.id = 'debug-logs';
|
|
222
|
-
// Track scroll position
|
|
223
204
|
this.logsContainer.addEventListener('scroll', () => {
|
|
224
205
|
this.isAtBottom = this.logsContainer.scrollHeight - this.logsContainer.scrollTop <= this.logsContainer.clientHeight + 50;
|
|
225
206
|
});
|
|
226
|
-
// Assemble
|
|
227
207
|
this.container.appendChild(header);
|
|
228
208
|
this.container.appendChild(this.logsContainer);
|
|
229
209
|
document.body.appendChild(this.container);
|
|
230
|
-
// Create floating toggle button
|
|
231
210
|
this.floatingToggle = document.createElement('button');
|
|
232
211
|
this.floatingToggle.id = 'debug-floating-toggle';
|
|
233
|
-
this.floatingToggle.innerHTML = '🖥️';
|
|
212
|
+
this.floatingToggle.innerHTML = '🖥️';
|
|
234
213
|
this.floatingToggle.title = 'Show Debug Console';
|
|
235
214
|
this.floatingToggle.onclick = () => this.toggle();
|
|
236
215
|
document.body.appendChild(this.floatingToggle);
|
|
237
|
-
// Store reference for toggle button
|
|
238
216
|
window.__debugToggleBtn = toggleBtn;
|
|
239
217
|
}
|
|
240
218
|
escapeHtml(text) {
|
|
@@ -265,19 +243,15 @@ export class MobileDebugConsole {
|
|
|
265
243
|
}
|
|
266
244
|
}
|
|
267
245
|
cleanup() {
|
|
268
|
-
// Restore original console
|
|
269
246
|
Object.keys(this.originalConsole).forEach(method => {
|
|
270
247
|
console[method] = this.originalConsole[method];
|
|
271
248
|
});
|
|
272
|
-
// Remove UI
|
|
273
249
|
if (this.container) {
|
|
274
250
|
this.container.remove();
|
|
275
251
|
}
|
|
276
|
-
// Remove floating toggle
|
|
277
252
|
if (this.floatingToggle) {
|
|
278
253
|
this.floatingToggle.remove();
|
|
279
254
|
}
|
|
280
|
-
// Clean up references
|
|
281
255
|
delete window.__debugToggleBtn;
|
|
282
256
|
}
|
|
283
257
|
}
|
|
@@ -1,22 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Modal UI Component for Phone Authentication
|
|
3
|
-
*
|
|
4
|
-
* This file creates the UI components (modals, buttons) that are shown
|
|
5
|
-
* when the SDK is NOT in headless mode. Think of it like a popup window
|
|
6
|
-
* that handles the authentication flow for you.
|
|
7
|
-
*/
|
|
8
1
|
import type { InvokeOptions } from '../api-types';
|
|
9
2
|
import type { QRCodeData } from '../strategies/desktop';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* description: "Complete authentication to continue"
|
|
17
|
-
* });
|
|
18
|
-
* modal.show();
|
|
19
|
-
*/
|
|
3
|
+
export type ModalViewMode = 'toggle' | 'dual' | 'pre-step';
|
|
4
|
+
export type ModalTheme = 'dark' | 'light' | 'auto';
|
|
5
|
+
export type AuthModalOptions = NonNullable<InvokeOptions['modalOptions']> & {
|
|
6
|
+
viewMode?: ModalViewMode;
|
|
7
|
+
theme?: ModalTheme;
|
|
8
|
+
};
|
|
20
9
|
export declare class AuthModal {
|
|
21
10
|
private container;
|
|
22
11
|
private backdrop;
|
|
@@ -24,65 +13,35 @@ export declare class AuthModal {
|
|
|
24
13
|
private options;
|
|
25
14
|
private callbacks;
|
|
26
15
|
private closeCallback?;
|
|
27
|
-
|
|
16
|
+
private theme;
|
|
17
|
+
private currentStep;
|
|
18
|
+
private qrCodeData;
|
|
19
|
+
private statusMessage;
|
|
20
|
+
private originalBodyOverflow;
|
|
21
|
+
private isClosing;
|
|
22
|
+
private readonly iconApple;
|
|
23
|
+
private readonly iconAndroid;
|
|
24
|
+
private readonly iconBack;
|
|
25
|
+
constructor(options?: AuthModalOptions, callbacks?: InvokeOptions['callbacks']);
|
|
26
|
+
private shouldUseDarkMode;
|
|
28
27
|
private handleEscapeKey;
|
|
29
|
-
/**
|
|
30
|
-
* Escape HTML to prevent XSS attacks
|
|
31
|
-
*/
|
|
32
28
|
private escapeHtml;
|
|
33
|
-
/**
|
|
34
|
-
* Shows the modal with a QR code for desktop authentication
|
|
35
|
-
* Supports both single QR code (legacy) and dual-platform QR codes (iOS + Android)
|
|
36
|
-
*/
|
|
37
29
|
showQRCode(qrCodeData: string | QRCodeData, statusMessage?: string): void;
|
|
38
|
-
|
|
39
|
-
* Creates a modal with iOS/Android platform toggle
|
|
40
|
-
*/
|
|
41
|
-
private createDualPlatformQRModal;
|
|
42
|
-
/**
|
|
43
|
-
* Sets a callback to be called when the modal is cancelled/closed
|
|
44
|
-
*/
|
|
30
|
+
updateStatus(status: string, isError?: boolean): void;
|
|
45
31
|
setCloseCallback(callback: () => void): void;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
* Shows the modal with a button for TS43 authentication
|
|
53
|
-
* IMPORTANT: The button click is required for Digital Credentials API (transient activation)
|
|
54
|
-
*/
|
|
55
|
-
showTS43Button(onAuthenticate: () => Promise<any>): Promise<any>;
|
|
56
|
-
/**
|
|
57
|
-
* Updates the status message in the modal
|
|
58
|
-
*/
|
|
59
|
-
updateStatus(message: string, isError?: boolean): void;
|
|
60
|
-
/**
|
|
61
|
-
* Creates the modal HTML structure
|
|
62
|
-
*/
|
|
32
|
+
private renderToggleMode;
|
|
33
|
+
private renderDualMode;
|
|
34
|
+
private renderPreStepMode;
|
|
35
|
+
private setupPreStepListeners;
|
|
36
|
+
private updatePreStepUI;
|
|
37
|
+
private setupBackButton;
|
|
63
38
|
private createModal;
|
|
64
|
-
|
|
65
|
-
* Injects CSS styles for the modal
|
|
66
|
-
*/
|
|
39
|
+
private setupHelpInteraction;
|
|
67
40
|
private injectStyles;
|
|
68
|
-
/**
|
|
69
|
-
* Shows the modal with animation
|
|
70
|
-
*/
|
|
71
41
|
show(): void;
|
|
72
|
-
/**
|
|
73
|
-
* Setup click handlers for iOS/Android platform toggle
|
|
74
|
-
*/
|
|
75
42
|
private setupPlatformToggles;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
*/
|
|
43
|
+
private lockBodyScroll;
|
|
44
|
+
private unlockBodyScroll;
|
|
79
45
|
close(): void;
|
|
80
|
-
/**
|
|
81
|
-
* Removes modal elements from DOM
|
|
82
|
-
*/
|
|
83
46
|
private cleanup;
|
|
84
|
-
/**
|
|
85
|
-
* Check if modal is currently open
|
|
86
|
-
*/
|
|
87
|
-
isModalOpen(): boolean;
|
|
88
47
|
}
|