@glideidentity/web-client-sdk 5.1.3 → 6.0.0-beta.2
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 +428 -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 +424 -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 +535 -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 -161
- 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 -157
- 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,143 +0,0 @@
|
|
|
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
|
-
import type { AnyExtendedResponse, DesktopExtendedResponse, LinkExtendedResponse, TS43ExtendedResponse, AuthCredential } from './api-types';
|
|
8
|
-
/**
|
|
9
|
-
* Type guard to check if the result is an ExtendedResponse (extended mode)
|
|
10
|
-
* or a Credential (standard mode).
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* const result = await invokeSecurePrompt(sdkRequest, { executionMode: 'extended' });
|
|
15
|
-
*
|
|
16
|
-
* if (isExtendedResponse(result)) {
|
|
17
|
-
* // TypeScript knows this is ExtendedResponse
|
|
18
|
-
* console.log(result.strategy);
|
|
19
|
-
* await result.cancel();
|
|
20
|
-
* } else {
|
|
21
|
-
* // TypeScript knows this is a Credential
|
|
22
|
-
* const processedResult = await verifyPhoneNumberCredential(result, session);
|
|
23
|
-
* }
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
export declare function isExtendedResponse(result: any): result is AnyExtendedResponse;
|
|
27
|
-
/**
|
|
28
|
-
* Type guard to check if the result is a Credential (standard mode response).
|
|
29
|
-
* A credential is either a string token or an object without ExtendedResponse properties.
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```typescript
|
|
33
|
-
* if (isCredential(result)) {
|
|
34
|
-
* // Process the credential directly
|
|
35
|
-
* const verified = await verifyPhoneNumberCredential(result, session);
|
|
36
|
-
* }
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
export declare function isCredential(result: any): result is string | {
|
|
40
|
-
[aggregator_id: string]: string | string[];
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Type guard to check if the result is an AuthCredential object.
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* ```typescript
|
|
47
|
-
* if (isAuthCredential(result)) {
|
|
48
|
-
* console.log(result.credential);
|
|
49
|
-
* console.log(result.authenticated);
|
|
50
|
-
* }
|
|
51
|
-
* ```
|
|
52
|
-
*/
|
|
53
|
-
export declare function isAuthCredential(result: any): result is AuthCredential;
|
|
54
|
-
/**
|
|
55
|
-
* Type guard to check if an ExtendedResponse is using the Link strategy.
|
|
56
|
-
* Link strategy involves opening an app link (App Clip on iOS, app on Android).
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* ```typescript
|
|
60
|
-
* if (isExtendedResponse(result) && isLinkStrategy(result)) {
|
|
61
|
-
* // Re-trigger app opening if needed
|
|
62
|
-
* result.trigger();
|
|
63
|
-
* await result.credential;
|
|
64
|
-
* }
|
|
65
|
-
* ```
|
|
66
|
-
*/
|
|
67
|
-
export declare function isLinkStrategy(result: AnyExtendedResponse): result is LinkExtendedResponse;
|
|
68
|
-
/**
|
|
69
|
-
* Type guard to check if an ExtendedResponse is using the TS43 strategy.
|
|
70
|
-
* TS43 strategy uses the browser's Digital Credentials API.
|
|
71
|
-
*
|
|
72
|
-
* @example
|
|
73
|
-
* ```typescript
|
|
74
|
-
* if (isExtendedResponse(result) && isTS43Strategy(result)) {
|
|
75
|
-
* // Re-trigger credential request if needed
|
|
76
|
-
* await result.trigger();
|
|
77
|
-
* }
|
|
78
|
-
* ```
|
|
79
|
-
*/
|
|
80
|
-
export declare function isTS43Strategy(result: AnyExtendedResponse): result is TS43ExtendedResponse;
|
|
81
|
-
/**
|
|
82
|
-
* Type guard to check if an ExtendedResponse is using the Desktop strategy.
|
|
83
|
-
* Desktop strategy involves QR codes for cross-device authentication.
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* ```typescript
|
|
87
|
-
* if (isExtendedResponse(result) && isDesktopStrategy(result)) {
|
|
88
|
-
* // Show custom QR code UI
|
|
89
|
-
* displayQRCode(result.qr_code_data);
|
|
90
|
-
* await result.start_polling();
|
|
91
|
-
* }
|
|
92
|
-
* ```
|
|
93
|
-
*/
|
|
94
|
-
export declare function isDesktopStrategy(result: AnyExtendedResponse): result is DesktopExtendedResponse;
|
|
95
|
-
/**
|
|
96
|
-
* Helper function to safely get the authentication strategy from any result.
|
|
97
|
-
* Returns undefined if the result is not an ExtendedResponse.
|
|
98
|
-
*
|
|
99
|
-
* @example
|
|
100
|
-
* ```typescript
|
|
101
|
-
* const strategy = getStrategy(result);
|
|
102
|
-
* if (strategy === 'link') {
|
|
103
|
-
* // Handle link strategy
|
|
104
|
-
* }
|
|
105
|
-
* ```
|
|
106
|
-
*/
|
|
107
|
-
export declare function getStrategy(result: any): 'link' | 'ts43' | 'desktop' | undefined;
|
|
108
|
-
/**
|
|
109
|
-
* Helper function to determine if a result has polling controls.
|
|
110
|
-
* Link and Desktop strategies have polling controls in extended mode.
|
|
111
|
-
*
|
|
112
|
-
* @example
|
|
113
|
-
* ```typescript
|
|
114
|
-
* if (hasPollingControls(result)) {
|
|
115
|
-
* await result.start_polling();
|
|
116
|
-
* }
|
|
117
|
-
* ```
|
|
118
|
-
*/
|
|
119
|
-
export declare function hasPollingControls(result: any): boolean;
|
|
120
|
-
/**
|
|
121
|
-
* Helper function to determine if a result has a trigger method.
|
|
122
|
-
* Link and TS43 strategies have trigger methods in extended mode.
|
|
123
|
-
*
|
|
124
|
-
* @example
|
|
125
|
-
* ```typescript
|
|
126
|
-
* if (hasTrigger(result)) {
|
|
127
|
-
* result.trigger();
|
|
128
|
-
* }
|
|
129
|
-
* ```
|
|
130
|
-
*/
|
|
131
|
-
export declare function hasTrigger(result: any): boolean;
|
|
132
|
-
/**
|
|
133
|
-
* @deprecated Use isExtendedResponse instead
|
|
134
|
-
*/
|
|
135
|
-
export declare const isHeadlessResult: typeof isExtendedResponse;
|
|
136
|
-
/**
|
|
137
|
-
* @deprecated Use hasPollingControls instead
|
|
138
|
-
*/
|
|
139
|
-
export declare const requiresPolling: typeof hasPollingControls;
|
|
140
|
-
/**
|
|
141
|
-
* @deprecated This function is no longer needed as extended mode handles user actions differently
|
|
142
|
-
*/
|
|
143
|
-
export declare const requiresUserAction: (result: any) => boolean;
|
|
@@ -1,185 +0,0 @@
|
|
|
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
|
-
export function isExtendedResponse(result) {
|
|
26
|
-
return result &&
|
|
27
|
-
typeof result === 'object' &&
|
|
28
|
-
'strategy' in result &&
|
|
29
|
-
'credential' in result &&
|
|
30
|
-
'cancel' in result &&
|
|
31
|
-
typeof result.cancel === 'function';
|
|
32
|
-
}
|
|
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
|
-
export function isCredential(result) {
|
|
46
|
-
if (!result)
|
|
47
|
-
return false;
|
|
48
|
-
// String credentials are valid
|
|
49
|
-
if (typeof result === 'string')
|
|
50
|
-
return true;
|
|
51
|
-
// Object credentials should NOT have ExtendedResponse properties
|
|
52
|
-
if (typeof result === 'object') {
|
|
53
|
-
return !('strategy' in result) && !('credential' in result) && !('cancel' in result);
|
|
54
|
-
}
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
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
|
-
export function isAuthCredential(result) {
|
|
69
|
-
return result &&
|
|
70
|
-
typeof result === 'object' &&
|
|
71
|
-
'credential' in result &&
|
|
72
|
-
'authenticated' in result &&
|
|
73
|
-
'session' in result;
|
|
74
|
-
}
|
|
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
|
-
export function isLinkStrategy(result) {
|
|
89
|
-
return result.strategy === 'link';
|
|
90
|
-
}
|
|
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
|
-
export function isTS43Strategy(result) {
|
|
104
|
-
return result.strategy === 'ts43';
|
|
105
|
-
}
|
|
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
|
-
export function isDesktopStrategy(result) {
|
|
120
|
-
return result.strategy === 'desktop';
|
|
121
|
-
}
|
|
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
|
-
export function getStrategy(result) {
|
|
135
|
-
if (isExtendedResponse(result)) {
|
|
136
|
-
return result.strategy;
|
|
137
|
-
}
|
|
138
|
-
return undefined;
|
|
139
|
-
}
|
|
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
|
-
export function hasPollingControls(result) {
|
|
152
|
-
if (!isExtendedResponse(result))
|
|
153
|
-
return false;
|
|
154
|
-
return (result.strategy === 'link' && 'start_polling' in result) ||
|
|
155
|
-
(result.strategy === 'desktop' && 'start_polling' in result);
|
|
156
|
-
}
|
|
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
|
-
export function hasTrigger(result) {
|
|
169
|
-
if (!isExtendedResponse(result))
|
|
170
|
-
return false;
|
|
171
|
-
return 'trigger' in result && typeof result.trigger === 'function';
|
|
172
|
-
}
|
|
173
|
-
// Export legacy function names as deprecated aliases for backward compatibility
|
|
174
|
-
/**
|
|
175
|
-
* @deprecated Use isExtendedResponse instead
|
|
176
|
-
*/
|
|
177
|
-
export const isHeadlessResult = isExtendedResponse;
|
|
178
|
-
/**
|
|
179
|
-
* @deprecated Use hasPollingControls instead
|
|
180
|
-
*/
|
|
181
|
-
export const requiresPolling = hasPollingControls;
|
|
182
|
-
/**
|
|
183
|
-
* @deprecated This function is no longer needed as extended mode handles user actions differently
|
|
184
|
-
*/
|
|
185
|
-
export const requiresUserAction = (result) => false;
|
|
@@ -1,237 +0,0 @@
|
|
|
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
|
-
export * from './api-types';
|
|
9
|
-
import type { PrepareRequest as APIPrepareRequest, GetPhoneNumberResponse, VerifyPhoneNumberResponse, UseCase as APIUseCase, AuthenticationStrategy as APIAuthStrategy } from './api-types';
|
|
10
|
-
export type PhoneAuthOptions = APIPrepareRequest;
|
|
11
|
-
export type PhoneAuthResult = GetPhoneNumberResponse | VerifyPhoneNumberResponse;
|
|
12
|
-
export type UseCaseType = APIUseCase;
|
|
13
|
-
export type AuthenticationStrategyType = APIAuthStrategy;
|
|
14
|
-
/**
|
|
15
|
-
* SDK-specific error codes from error-utils
|
|
16
|
-
*/
|
|
17
|
-
import type { PhoneAuthErrorCode as ErrorCodeFromUtils } from './error-utils';
|
|
18
|
-
export type PhoneAuthErrorCode = ErrorCodeFromUtils;
|
|
19
|
-
/**
|
|
20
|
-
* SDK configuration callbacks
|
|
21
|
-
*/
|
|
22
|
-
export interface PhoneAuthCallbacks {
|
|
23
|
-
/**
|
|
24
|
-
* Called when cross-device authentication is detected (e.g., QR code shown)
|
|
25
|
-
*/
|
|
26
|
-
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
|
-
onRetryAttempt?: (attempt: number, maxAttempts: number) => void;
|
|
33
|
-
/**
|
|
34
|
-
* Called when authentication times out
|
|
35
|
-
*/
|
|
36
|
-
onTimeout?: () => void;
|
|
37
|
-
/**
|
|
38
|
-
* Called when user cancels authentication
|
|
39
|
-
*/
|
|
40
|
-
onCancel?: () => void;
|
|
41
|
-
/**
|
|
42
|
-
* Called when polling starts
|
|
43
|
-
*/
|
|
44
|
-
onPollingStart?: () => void;
|
|
45
|
-
/**
|
|
46
|
-
* Called when polling stops
|
|
47
|
-
*/
|
|
48
|
-
onPollingStop?: () => void;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* SDK configuration options
|
|
52
|
-
*/
|
|
53
|
-
export interface AuthConfig extends PhoneAuthCallbacks {
|
|
54
|
-
/**
|
|
55
|
-
* Custom endpoints for authentication flow
|
|
56
|
-
*/
|
|
57
|
-
endpoints?: {
|
|
58
|
-
prepare?: string;
|
|
59
|
-
process?: string;
|
|
60
|
-
/** Desktop authentication status polling endpoint */
|
|
61
|
-
polling?: string;
|
|
62
|
-
};
|
|
63
|
-
/**
|
|
64
|
-
* Timeout for API calls in milliseconds
|
|
65
|
-
* @default 30000
|
|
66
|
-
*/
|
|
67
|
-
timeout?: number;
|
|
68
|
-
/**
|
|
69
|
-
* Polling interval in milliseconds for status checks
|
|
70
|
-
* @default 2000
|
|
71
|
-
*/
|
|
72
|
-
pollingInterval?: number;
|
|
73
|
-
/**
|
|
74
|
-
* Maximum polling attempts before timeout
|
|
75
|
-
* @default 30 (1 minute with 2s interval)
|
|
76
|
-
*/
|
|
77
|
-
maxPollingAttempts?: number;
|
|
78
|
-
/**
|
|
79
|
-
* Enable debug logging
|
|
80
|
-
* @default false
|
|
81
|
-
*/
|
|
82
|
-
debug?: boolean;
|
|
83
|
-
/**
|
|
84
|
-
* Developer environment for testing (e.g., 'dev1', 'dev2')
|
|
85
|
-
* When set, adds a 'developer' header to polling requests
|
|
86
|
-
*/
|
|
87
|
-
devEnv?: string;
|
|
88
|
-
/**
|
|
89
|
-
* Developer tools configuration for debugging
|
|
90
|
-
*/
|
|
91
|
-
devtools?: {
|
|
92
|
-
/**
|
|
93
|
-
* Show mobile console overlay for on-device debugging
|
|
94
|
-
* Displays all console logs at the bottom of the screen
|
|
95
|
-
* @default false
|
|
96
|
-
*/
|
|
97
|
-
showMobileConsole?: boolean;
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* SDK-enhanced error type with additional context
|
|
102
|
-
*/
|
|
103
|
-
export interface AuthError {
|
|
104
|
-
code: PhoneAuthErrorCode;
|
|
105
|
-
message: string;
|
|
106
|
-
details?: any;
|
|
107
|
-
status?: number;
|
|
108
|
-
requestId?: string;
|
|
109
|
-
timestamp?: string;
|
|
110
|
-
traceId?: string;
|
|
111
|
-
spanId?: string;
|
|
112
|
-
service?: string;
|
|
113
|
-
retryAfter?: number;
|
|
114
|
-
browserError?: {
|
|
115
|
-
name: string;
|
|
116
|
-
message: string;
|
|
117
|
-
stack?: string;
|
|
118
|
-
code?: number;
|
|
119
|
-
};
|
|
120
|
-
context?: {
|
|
121
|
-
step?: 'prepare' | 'prompt' | 'process' | 'complete';
|
|
122
|
-
useCase?: string;
|
|
123
|
-
timestamp: string;
|
|
124
|
-
userAgent?: string;
|
|
125
|
-
url?: string;
|
|
126
|
-
[key: string]: any;
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* SDK authentication flow steps
|
|
131
|
-
*/
|
|
132
|
-
export type AuthStep = 'idle' | 'requesting' | 'authenticating' | 'processing' | 'complete';
|
|
133
|
-
/**
|
|
134
|
-
* Browser error names
|
|
135
|
-
*/
|
|
136
|
-
export declare const BrowserError: {
|
|
137
|
-
readonly NOT_ALLOWED: "NotAllowedError";
|
|
138
|
-
readonly NETWORK: "NetworkError";
|
|
139
|
-
readonly NOT_SUPPORTED: "NotSupportedError";
|
|
140
|
-
readonly SECURITY: "SecurityError";
|
|
141
|
-
readonly ABORT: "AbortError";
|
|
142
|
-
readonly TIMEOUT: "TimeoutError";
|
|
143
|
-
readonly INVALID_STATE: "InvalidStateError";
|
|
144
|
-
readonly DATA_CLONE: "DataCloneError";
|
|
145
|
-
readonly ENCODING: "EncodingError";
|
|
146
|
-
readonly NOT_READABLE: "NotReadableError";
|
|
147
|
-
readonly UNKNOWN: "UnknownError";
|
|
148
|
-
readonly TYPE: "TypeError";
|
|
149
|
-
readonly RANGE: "RangeError";
|
|
150
|
-
readonly SYNTAX: "SyntaxError";
|
|
151
|
-
};
|
|
152
|
-
export type BrowserErrorType = typeof BrowserError[keyof typeof BrowserError];
|
|
153
|
-
/**
|
|
154
|
-
* Browser error codes
|
|
155
|
-
*/
|
|
156
|
-
export declare const BrowserErrorCode: {
|
|
157
|
-
readonly USER_CANCELLED_DC_API: 19;
|
|
158
|
-
readonly PERMISSION_DENIED: 1;
|
|
159
|
-
readonly POSITION_UNAVAILABLE: 2;
|
|
160
|
-
readonly TIMEOUT: 3;
|
|
161
|
-
readonly NOT_FOUND: 8;
|
|
162
|
-
readonly ABORT: 20;
|
|
163
|
-
readonly NETWORK: 19;
|
|
164
|
-
readonly SECURITY: 18;
|
|
165
|
-
};
|
|
166
|
-
export type BrowserErrorCodeType = typeof BrowserErrorCode[keyof typeof BrowserErrorCode];
|
|
167
|
-
/**
|
|
168
|
-
* Browser names for detection
|
|
169
|
-
*/
|
|
170
|
-
export declare const BrowserName: {
|
|
171
|
-
readonly CHROME: "Chrome";
|
|
172
|
-
readonly EDGE: "Edge";
|
|
173
|
-
readonly SAFARI: "Safari";
|
|
174
|
-
readonly FIREFOX: "Firefox";
|
|
175
|
-
readonly OPERA: "Opera";
|
|
176
|
-
readonly BRAVE: "Brave";
|
|
177
|
-
readonly OTHER: "other";
|
|
178
|
-
};
|
|
179
|
-
export type BrowserNameType = typeof BrowserName[keyof typeof BrowserName];
|
|
180
|
-
/**
|
|
181
|
-
* Browser Digital Credential type (extends standard Credential)
|
|
182
|
-
*/
|
|
183
|
-
export interface DigitalCredential extends Credential {
|
|
184
|
-
data: {
|
|
185
|
-
vp_token: {
|
|
186
|
-
[aggregatorId: string]: string | string[];
|
|
187
|
-
};
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Browser credential request structure
|
|
192
|
-
*/
|
|
193
|
-
export interface SecureCredentialRequest {
|
|
194
|
-
digital: {
|
|
195
|
-
requests: Array<{
|
|
196
|
-
protocol: string;
|
|
197
|
-
data: any;
|
|
198
|
-
}>;
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Authentication status constants
|
|
203
|
-
* Maps to both client-side states and backend responses
|
|
204
|
-
*/
|
|
205
|
-
export declare const AuthStatus: {
|
|
206
|
-
/** Authentication in progress */
|
|
207
|
-
readonly PENDING: "pending";
|
|
208
|
-
/** Authentication completed successfully */
|
|
209
|
-
readonly COMPLETED: "completed";
|
|
210
|
-
/** User cancelled authentication */
|
|
211
|
-
readonly CANCELLED: "cancelled";
|
|
212
|
-
/** Authentication failed or expired */
|
|
213
|
-
readonly FAILED: "failed";
|
|
214
|
-
/** Session expired (backend returns 410 Gone) */
|
|
215
|
-
readonly EXPIRED: "expired";
|
|
216
|
-
/** Session not found (backend returns 404) */
|
|
217
|
-
readonly NOT_FOUND: "not_found";
|
|
218
|
-
};
|
|
219
|
-
export type AuthStatusType = typeof AuthStatus[keyof typeof AuthStatus];
|
|
220
|
-
/**
|
|
221
|
-
* Controller for managing authentication sessions
|
|
222
|
-
* Allows cancellation and cleanup of ongoing authentication
|
|
223
|
-
*/
|
|
224
|
-
export interface AuthController {
|
|
225
|
-
/**
|
|
226
|
-
* Cancel the ongoing authentication
|
|
227
|
-
*/
|
|
228
|
-
cancel(): void;
|
|
229
|
-
/**
|
|
230
|
-
* The authentication promise
|
|
231
|
-
*/
|
|
232
|
-
promise: Promise<any>;
|
|
233
|
-
/**
|
|
234
|
-
* Current status of the authentication
|
|
235
|
-
*/
|
|
236
|
-
status: AuthStatusType;
|
|
237
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
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
|
-
export * from './api-types';
|
|
12
|
-
// ============================================================================
|
|
13
|
-
// BROWSER-SPECIFIC TYPES
|
|
14
|
-
// ============================================================================
|
|
15
|
-
/**
|
|
16
|
-
* Browser error names
|
|
17
|
-
*/
|
|
18
|
-
export const BrowserError = {
|
|
19
|
-
NOT_ALLOWED: 'NotAllowedError',
|
|
20
|
-
NETWORK: 'NetworkError',
|
|
21
|
-
NOT_SUPPORTED: 'NotSupportedError',
|
|
22
|
-
SECURITY: 'SecurityError',
|
|
23
|
-
ABORT: 'AbortError',
|
|
24
|
-
TIMEOUT: 'TimeoutError',
|
|
25
|
-
INVALID_STATE: 'InvalidStateError',
|
|
26
|
-
DATA_CLONE: 'DataCloneError',
|
|
27
|
-
ENCODING: 'EncodingError',
|
|
28
|
-
NOT_READABLE: 'NotReadableError',
|
|
29
|
-
UNKNOWN: 'UnknownError',
|
|
30
|
-
TYPE: 'TypeError',
|
|
31
|
-
RANGE: 'RangeError',
|
|
32
|
-
SYNTAX: 'SyntaxError'
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Browser error codes
|
|
36
|
-
*/
|
|
37
|
-
export const BrowserErrorCode = {
|
|
38
|
-
USER_CANCELLED_DC_API: 19,
|
|
39
|
-
PERMISSION_DENIED: 1,
|
|
40
|
-
POSITION_UNAVAILABLE: 2,
|
|
41
|
-
TIMEOUT: 3,
|
|
42
|
-
NOT_FOUND: 8,
|
|
43
|
-
ABORT: 20,
|
|
44
|
-
NETWORK: 19,
|
|
45
|
-
SECURITY: 18
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* Browser names for detection
|
|
49
|
-
*/
|
|
50
|
-
export const BrowserName = {
|
|
51
|
-
CHROME: 'Chrome',
|
|
52
|
-
EDGE: 'Edge',
|
|
53
|
-
SAFARI: 'Safari',
|
|
54
|
-
FIREFOX: 'Firefox',
|
|
55
|
-
OPERA: 'Opera',
|
|
56
|
-
BRAVE: 'Brave',
|
|
57
|
-
OTHER: 'other'
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* Authentication status constants
|
|
61
|
-
* Maps to both client-side states and backend responses
|
|
62
|
-
*/
|
|
63
|
-
export const AuthStatus = {
|
|
64
|
-
/** Authentication in progress */
|
|
65
|
-
PENDING: 'pending',
|
|
66
|
-
/** Authentication completed successfully */
|
|
67
|
-
COMPLETED: 'completed',
|
|
68
|
-
/** User cancelled authentication */
|
|
69
|
-
CANCELLED: 'cancelled',
|
|
70
|
-
/** Authentication failed or expired */
|
|
71
|
-
FAILED: 'failed',
|
|
72
|
-
/** Session expired (backend returns 410 Gone) */
|
|
73
|
-
EXPIRED: 'expired',
|
|
74
|
-
/** Session not found (backend returns 404) */
|
|
75
|
-
NOT_FOUND: 'not_found'
|
|
76
|
-
};
|