@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.
Files changed (203) hide show
  1. package/README.md +337 -526
  2. package/dist/browser/web-client-sdk.min.js +1 -1
  3. package/dist/cjs/adapters/index.js +15 -0
  4. package/dist/cjs/adapters/react.js +192 -0
  5. package/dist/cjs/adapters/vanilla.js +38 -0
  6. package/dist/cjs/adapters/vue.js +187 -0
  7. package/dist/cjs/browser.js +58 -0
  8. package/dist/cjs/client/http.js +159 -0
  9. package/dist/cjs/client/index.js +19 -0
  10. package/dist/cjs/client/logger.js +135 -0
  11. package/dist/cjs/client/phone-auth-client.js +428 -0
  12. package/dist/cjs/client/strategies/polling.js +177 -0
  13. package/dist/cjs/core/errors.js +204 -0
  14. package/dist/cjs/core/index.js +83 -0
  15. package/dist/cjs/core/type-guards.js +196 -0
  16. package/dist/cjs/core/types.js +25 -0
  17. package/dist/{core/phone-auth/validation-utils.js → cjs/core/validators.js} +70 -23
  18. package/dist/cjs/index.js +81 -0
  19. package/dist/cjs/ui/index.js +11 -0
  20. package/dist/{core/phone-auth → cjs}/ui/mobile-debug-console.js +149 -78
  21. package/dist/cjs/ui/modal.js +1122 -0
  22. package/dist/esm/adapters/index.js +11 -0
  23. package/dist/esm/adapters/react.js +182 -0
  24. package/dist/esm/adapters/vanilla.js +29 -0
  25. package/dist/esm/adapters/vue.js +177 -0
  26. package/dist/esm/browser.js +30 -11
  27. package/dist/esm/client/http.js +156 -0
  28. package/dist/esm/client/index.js +11 -0
  29. package/dist/esm/client/logger.js +131 -0
  30. package/dist/esm/client/phone-auth-client.js +424 -0
  31. package/dist/esm/client/strategies/polling.js +174 -0
  32. package/dist/esm/core/errors.js +193 -0
  33. package/dist/esm/core/index.js +60 -0
  34. package/dist/esm/core/type-guards.js +181 -0
  35. package/dist/esm/core/types.js +22 -1
  36. package/dist/esm/core/{phone-auth/validation-utils.js → validators.js} +66 -21
  37. package/dist/esm/index.js +45 -17
  38. package/dist/esm/ui/index.js +5 -0
  39. package/dist/esm/{core/phone-auth/ui → ui}/mobile-debug-console.js +149 -78
  40. package/dist/esm/ui/modal.js +1117 -0
  41. package/dist/types/adapters/index.d.ts +10 -0
  42. package/dist/types/adapters/index.d.ts.map +1 -0
  43. package/dist/types/adapters/react.d.ts +70 -0
  44. package/dist/types/adapters/react.d.ts.map +1 -0
  45. package/dist/types/adapters/vanilla.d.ts +29 -0
  46. package/dist/types/adapters/vanilla.d.ts.map +1 -0
  47. package/dist/types/adapters/vue.d.ts +71 -0
  48. package/dist/types/adapters/vue.d.ts.map +1 -0
  49. package/dist/types/browser.d.ts +27 -0
  50. package/dist/types/browser.d.ts.map +1 -0
  51. package/dist/types/client/http.d.ts +41 -0
  52. package/dist/types/client/http.d.ts.map +1 -0
  53. package/dist/types/client/index.d.ts +10 -0
  54. package/dist/types/client/index.d.ts.map +1 -0
  55. package/dist/types/client/logger.d.ts +36 -0
  56. package/dist/types/client/logger.d.ts.map +1 -0
  57. package/dist/types/client/phone-auth-client.d.ts +91 -0
  58. package/dist/types/client/phone-auth-client.d.ts.map +1 -0
  59. package/dist/types/client/strategies/polling.d.ts +36 -0
  60. package/dist/types/client/strategies/polling.d.ts.map +1 -0
  61. package/dist/types/core/errors.d.ts +71 -0
  62. package/dist/types/core/errors.d.ts.map +1 -0
  63. package/dist/types/core/index.d.ts +38 -0
  64. package/dist/types/core/index.d.ts.map +1 -0
  65. package/dist/types/core/type-guards.d.ts +118 -0
  66. package/dist/types/core/type-guards.d.ts.map +1 -0
  67. package/dist/types/core/types.d.ts +535 -0
  68. package/dist/types/core/types.d.ts.map +1 -0
  69. package/dist/types/core/validators.d.ts +63 -0
  70. package/dist/types/core/validators.d.ts.map +1 -0
  71. package/dist/types/index.d.ts +40 -0
  72. package/dist/types/index.d.ts.map +1 -0
  73. package/dist/types/ui/index.d.ts +6 -0
  74. package/dist/types/ui/index.d.ts.map +1 -0
  75. package/dist/{esm/core/phone-auth → types}/ui/mobile-debug-console.d.ts +1 -0
  76. package/dist/types/ui/mobile-debug-console.d.ts.map +1 -0
  77. package/dist/types/ui/modal.d.ts +87 -0
  78. package/dist/types/ui/modal.d.ts.map +1 -0
  79. package/package.json +48 -34
  80. package/dist/adapters/angular/client.service.d.ts +0 -7
  81. package/dist/adapters/angular/client.service.js +0 -30
  82. package/dist/adapters/angular/index.d.ts +0 -3
  83. package/dist/adapters/angular/index.js +0 -18
  84. package/dist/adapters/angular/phone-auth.service.d.ts +0 -38
  85. package/dist/adapters/angular/phone-auth.service.js +0 -130
  86. package/dist/adapters/react/index.d.ts +0 -9
  87. package/dist/adapters/react/index.js +0 -28
  88. package/dist/adapters/react/useClient.d.ts +0 -26
  89. package/dist/adapters/react/useClient.js +0 -121
  90. package/dist/adapters/react/usePhoneAuth.d.ts +0 -23
  91. package/dist/adapters/react/usePhoneAuth.js +0 -95
  92. package/dist/adapters/vanilla/client.d.ts +0 -8
  93. package/dist/adapters/vanilla/client.js +0 -33
  94. package/dist/adapters/vanilla/index.d.ts +0 -3
  95. package/dist/adapters/vanilla/index.js +0 -18
  96. package/dist/adapters/vanilla/phone-auth.d.ts +0 -46
  97. package/dist/adapters/vanilla/phone-auth.js +0 -138
  98. package/dist/adapters/vue/index.d.ts +0 -10
  99. package/dist/adapters/vue/index.js +0 -36
  100. package/dist/adapters/vue/useClient.d.ts +0 -115
  101. package/dist/adapters/vue/useClient.js +0 -131
  102. package/dist/adapters/vue/usePhoneAuth.d.ts +0 -94
  103. package/dist/adapters/vue/usePhoneAuth.js +0 -103
  104. package/dist/browser.d.ts +0 -7
  105. package/dist/browser.js +0 -31
  106. package/dist/core/client.d.ts +0 -22
  107. package/dist/core/client.js +0 -77
  108. package/dist/core/logger.d.ts +0 -130
  109. package/dist/core/logger.js +0 -370
  110. package/dist/core/phone-auth/api-types.d.ts +0 -593
  111. package/dist/core/phone-auth/api-types.js +0 -215
  112. package/dist/core/phone-auth/client.d.ts +0 -189
  113. package/dist/core/phone-auth/client.js +0 -1441
  114. package/dist/core/phone-auth/error-utils.d.ts +0 -110
  115. package/dist/core/phone-auth/error-utils.js +0 -350
  116. package/dist/core/phone-auth/index.d.ts +0 -7
  117. package/dist/core/phone-auth/index.js +0 -50
  118. package/dist/core/phone-auth/status-types.d.ts +0 -107
  119. package/dist/core/phone-auth/status-types.js +0 -31
  120. package/dist/core/phone-auth/strategies/desktop.d.ts +0 -122
  121. package/dist/core/phone-auth/strategies/desktop.js +0 -596
  122. package/dist/core/phone-auth/strategies/index.d.ts +0 -11
  123. package/dist/core/phone-auth/strategies/index.js +0 -15
  124. package/dist/core/phone-auth/strategies/link.d.ts +0 -89
  125. package/dist/core/phone-auth/strategies/link.js +0 -384
  126. package/dist/core/phone-auth/strategies/ts43.d.ts +0 -32
  127. package/dist/core/phone-auth/strategies/ts43.js +0 -161
  128. package/dist/core/phone-auth/strategies/types.d.ts +0 -18
  129. package/dist/core/phone-auth/strategies/types.js +0 -6
  130. package/dist/core/phone-auth/type-guards.d.ts +0 -143
  131. package/dist/core/phone-auth/type-guards.js +0 -198
  132. package/dist/core/phone-auth/types.d.ts +0 -237
  133. package/dist/core/phone-auth/types.js +0 -93
  134. package/dist/core/phone-auth/ui/mobile-debug-console.d.ts +0 -25
  135. package/dist/core/phone-auth/ui/modal.d.ts +0 -88
  136. package/dist/core/phone-auth/ui/modal.js +0 -598
  137. package/dist/core/phone-auth/validation-utils.d.ts +0 -44
  138. package/dist/core/types.d.ts +0 -62
  139. package/dist/core/types.js +0 -2
  140. package/dist/core/version.d.ts +0 -1
  141. package/dist/core/version.js +0 -5
  142. package/dist/esm/adapters/angular/client.service.d.ts +0 -7
  143. package/dist/esm/adapters/angular/client.service.js +0 -27
  144. package/dist/esm/adapters/angular/index.d.ts +0 -3
  145. package/dist/esm/adapters/angular/index.js +0 -4
  146. package/dist/esm/adapters/angular/phone-auth.service.d.ts +0 -38
  147. package/dist/esm/adapters/angular/phone-auth.service.js +0 -127
  148. package/dist/esm/adapters/react/index.d.ts +0 -9
  149. package/dist/esm/adapters/react/index.js +0 -8
  150. package/dist/esm/adapters/react/useClient.d.ts +0 -26
  151. package/dist/esm/adapters/react/useClient.js +0 -116
  152. package/dist/esm/adapters/react/usePhoneAuth.d.ts +0 -23
  153. package/dist/esm/adapters/react/usePhoneAuth.js +0 -92
  154. package/dist/esm/adapters/vanilla/client.d.ts +0 -8
  155. package/dist/esm/adapters/vanilla/client.js +0 -29
  156. package/dist/esm/adapters/vanilla/index.d.ts +0 -3
  157. package/dist/esm/adapters/vanilla/index.js +0 -4
  158. package/dist/esm/adapters/vanilla/phone-auth.d.ts +0 -46
  159. package/dist/esm/adapters/vanilla/phone-auth.js +0 -134
  160. package/dist/esm/adapters/vue/index.d.ts +0 -10
  161. package/dist/esm/adapters/vue/index.js +0 -11
  162. package/dist/esm/adapters/vue/useClient.d.ts +0 -115
  163. package/dist/esm/adapters/vue/useClient.js +0 -127
  164. package/dist/esm/adapters/vue/usePhoneAuth.d.ts +0 -94
  165. package/dist/esm/adapters/vue/usePhoneAuth.js +0 -100
  166. package/dist/esm/browser.d.ts +0 -7
  167. package/dist/esm/core/client.d.ts +0 -22
  168. package/dist/esm/core/client.js +0 -70
  169. package/dist/esm/core/logger.d.ts +0 -130
  170. package/dist/esm/core/logger.js +0 -359
  171. package/dist/esm/core/phone-auth/api-types.d.ts +0 -593
  172. package/dist/esm/core/phone-auth/api-types.js +0 -203
  173. package/dist/esm/core/phone-auth/client.d.ts +0 -189
  174. package/dist/esm/core/phone-auth/client.js +0 -1404
  175. package/dist/esm/core/phone-auth/error-utils.d.ts +0 -110
  176. package/dist/esm/core/phone-auth/error-utils.js +0 -338
  177. package/dist/esm/core/phone-auth/index.d.ts +0 -7
  178. package/dist/esm/core/phone-auth/index.js +0 -8
  179. package/dist/esm/core/phone-auth/status-types.d.ts +0 -107
  180. package/dist/esm/core/phone-auth/status-types.js +0 -26
  181. package/dist/esm/core/phone-auth/strategies/desktop.d.ts +0 -122
  182. package/dist/esm/core/phone-auth/strategies/desktop.js +0 -590
  183. package/dist/esm/core/phone-auth/strategies/index.d.ts +0 -11
  184. package/dist/esm/core/phone-auth/strategies/index.js +0 -7
  185. package/dist/esm/core/phone-auth/strategies/link.d.ts +0 -89
  186. package/dist/esm/core/phone-auth/strategies/link.js +0 -380
  187. package/dist/esm/core/phone-auth/strategies/ts43.d.ts +0 -32
  188. package/dist/esm/core/phone-auth/strategies/ts43.js +0 -157
  189. package/dist/esm/core/phone-auth/strategies/types.d.ts +0 -18
  190. package/dist/esm/core/phone-auth/strategies/types.js +0 -5
  191. package/dist/esm/core/phone-auth/type-guards.d.ts +0 -143
  192. package/dist/esm/core/phone-auth/type-guards.js +0 -185
  193. package/dist/esm/core/phone-auth/types.d.ts +0 -237
  194. package/dist/esm/core/phone-auth/types.js +0 -76
  195. package/dist/esm/core/phone-auth/ui/modal.d.ts +0 -88
  196. package/dist/esm/core/phone-auth/ui/modal.js +0 -594
  197. package/dist/esm/core/phone-auth/validation-utils.d.ts +0 -44
  198. package/dist/esm/core/types.d.ts +0 -62
  199. package/dist/esm/core/version.d.ts +0 -1
  200. package/dist/esm/core/version.js +0 -2
  201. package/dist/esm/index.d.ts +0 -12
  202. package/dist/index.d.ts +0 -12
  203. package/dist/index.js +0 -55
@@ -1,18 +0,0 @@
1
- /**
2
- * Strategy Handler Interface
3
- * Defines the contract for authentication strategy implementations
4
- */
5
- export interface StrategyHandler {
6
- /**
7
- * Invoke authentication using strategy-specific data
8
- */
9
- invoke(data: any): Promise<any>;
10
- /**
11
- * Format response for backend processing
12
- */
13
- formatResponse(response: any): any;
14
- /**
15
- * Check if this strategy is supported in the current environment
16
- */
17
- isSupported(): boolean;
18
- }
@@ -1,6 +0,0 @@
1
- "use strict";
2
- /**
3
- * Strategy Handler Interface
4
- * Defines the contract for authentication strategy implementations
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -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,198 +0,0 @@
1
- "use strict";
2
- /**
3
- * Type Guards and Helper Functions for Phone Authentication
4
- *
5
- * These utilities help developers work with the SDK responses in a type-safe way
6
- * without having to write their own type checking logic.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.requiresUserAction = exports.requiresPolling = exports.isHeadlessResult = void 0;
10
- exports.isExtendedResponse = isExtendedResponse;
11
- exports.isCredential = isCredential;
12
- exports.isAuthCredential = isAuthCredential;
13
- exports.isLinkStrategy = isLinkStrategy;
14
- exports.isTS43Strategy = isTS43Strategy;
15
- exports.isDesktopStrategy = isDesktopStrategy;
16
- exports.getStrategy = getStrategy;
17
- exports.hasPollingControls = hasPollingControls;
18
- exports.hasTrigger = hasTrigger;
19
- /**
20
- * Type guard to check if the result is an ExtendedResponse (extended mode)
21
- * or a Credential (standard mode).
22
- *
23
- * @example
24
- * ```typescript
25
- * const result = await invokeSecurePrompt(sdkRequest, { executionMode: 'extended' });
26
- *
27
- * if (isExtendedResponse(result)) {
28
- * // TypeScript knows this is ExtendedResponse
29
- * console.log(result.strategy);
30
- * await result.cancel();
31
- * } else {
32
- * // TypeScript knows this is a Credential
33
- * const processedResult = await verifyPhoneNumberCredential(result, session);
34
- * }
35
- * ```
36
- */
37
- function isExtendedResponse(result) {
38
- return result &&
39
- typeof result === 'object' &&
40
- 'strategy' in result &&
41
- 'credential' in result &&
42
- 'cancel' in result &&
43
- typeof result.cancel === 'function';
44
- }
45
- /**
46
- * Type guard to check if the result is a Credential (standard mode response).
47
- * A credential is either a string token or an object without ExtendedResponse properties.
48
- *
49
- * @example
50
- * ```typescript
51
- * if (isCredential(result)) {
52
- * // Process the credential directly
53
- * const verified = await verifyPhoneNumberCredential(result, session);
54
- * }
55
- * ```
56
- */
57
- function isCredential(result) {
58
- if (!result)
59
- return false;
60
- // String credentials are valid
61
- if (typeof result === 'string')
62
- return true;
63
- // Object credentials should NOT have ExtendedResponse properties
64
- if (typeof result === 'object') {
65
- return !('strategy' in result) && !('credential' in result) && !('cancel' in result);
66
- }
67
- return false;
68
- }
69
- /**
70
- * Type guard to check if the result is an AuthCredential object.
71
- *
72
- * @example
73
- * ```typescript
74
- * if (isAuthCredential(result)) {
75
- * console.log(result.credential);
76
- * console.log(result.authenticated);
77
- * }
78
- * ```
79
- */
80
- function isAuthCredential(result) {
81
- return result &&
82
- typeof result === 'object' &&
83
- 'credential' in result &&
84
- 'authenticated' in result &&
85
- 'session' in result;
86
- }
87
- /**
88
- * Type guard to check if an ExtendedResponse is using the Link strategy.
89
- * Link strategy involves opening an app link (App Clip on iOS, app on Android).
90
- *
91
- * @example
92
- * ```typescript
93
- * if (isExtendedResponse(result) && isLinkStrategy(result)) {
94
- * // Re-trigger app opening if needed
95
- * result.trigger();
96
- * await result.credential;
97
- * }
98
- * ```
99
- */
100
- function isLinkStrategy(result) {
101
- return result.strategy === 'link';
102
- }
103
- /**
104
- * Type guard to check if an ExtendedResponse is using the TS43 strategy.
105
- * TS43 strategy uses the browser's Digital Credentials API.
106
- *
107
- * @example
108
- * ```typescript
109
- * if (isExtendedResponse(result) && isTS43Strategy(result)) {
110
- * // Re-trigger credential request if needed
111
- * await result.trigger();
112
- * }
113
- * ```
114
- */
115
- function isTS43Strategy(result) {
116
- return result.strategy === 'ts43';
117
- }
118
- /**
119
- * Type guard to check if an ExtendedResponse is using the Desktop strategy.
120
- * Desktop strategy involves QR codes for cross-device authentication.
121
- *
122
- * @example
123
- * ```typescript
124
- * if (isExtendedResponse(result) && isDesktopStrategy(result)) {
125
- * // Show custom QR code UI
126
- * displayQRCode(result.qr_code_data);
127
- * await result.start_polling();
128
- * }
129
- * ```
130
- */
131
- function isDesktopStrategy(result) {
132
- return result.strategy === 'desktop';
133
- }
134
- /**
135
- * Helper function to safely get the authentication strategy from any result.
136
- * Returns undefined if the result is not an ExtendedResponse.
137
- *
138
- * @example
139
- * ```typescript
140
- * const strategy = getStrategy(result);
141
- * if (strategy === 'link') {
142
- * // Handle link strategy
143
- * }
144
- * ```
145
- */
146
- function getStrategy(result) {
147
- if (isExtendedResponse(result)) {
148
- return result.strategy;
149
- }
150
- return undefined;
151
- }
152
- /**
153
- * Helper function to determine if a result has polling controls.
154
- * Link and Desktop strategies have polling controls in extended mode.
155
- *
156
- * @example
157
- * ```typescript
158
- * if (hasPollingControls(result)) {
159
- * await result.start_polling();
160
- * }
161
- * ```
162
- */
163
- function hasPollingControls(result) {
164
- if (!isExtendedResponse(result))
165
- return false;
166
- return (result.strategy === 'link' && 'start_polling' in result) ||
167
- (result.strategy === 'desktop' && 'start_polling' in result);
168
- }
169
- /**
170
- * Helper function to determine if a result has a trigger method.
171
- * Link and TS43 strategies have trigger methods in extended mode.
172
- *
173
- * @example
174
- * ```typescript
175
- * if (hasTrigger(result)) {
176
- * result.trigger();
177
- * }
178
- * ```
179
- */
180
- function hasTrigger(result) {
181
- if (!isExtendedResponse(result))
182
- return false;
183
- return 'trigger' in result && typeof result.trigger === 'function';
184
- }
185
- // Export legacy function names as deprecated aliases for backward compatibility
186
- /**
187
- * @deprecated Use isExtendedResponse instead
188
- */
189
- exports.isHeadlessResult = isExtendedResponse;
190
- /**
191
- * @deprecated Use hasPollingControls instead
192
- */
193
- exports.requiresPolling = hasPollingControls;
194
- /**
195
- * @deprecated This function is no longer needed as extended mode handles user actions differently
196
- */
197
- const requiresUserAction = (result) => false;
198
- exports.requiresUserAction = requiresUserAction;
@@ -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,93 +0,0 @@
1
- "use strict";
2
- /**
3
- * Phone Authentication Types
4
- *
5
- * This file exports the types used by the Phone Auth SDK.
6
- * All API types are imported from api-types.ts to ensure consistency.
7
- * No backward compatibility - using clean API specification only.
8
- */
9
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- var desc = Object.getOwnPropertyDescriptor(m, k);
12
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
- desc = { enumerable: true, get: function() { return m[k]; } };
14
- }
15
- Object.defineProperty(o, k2, desc);
16
- }) : (function(o, m, k, k2) {
17
- if (k2 === undefined) k2 = k;
18
- o[k2] = m[k];
19
- }));
20
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
21
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
22
- };
23
- Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.AuthStatus = exports.BrowserName = exports.BrowserErrorCode = exports.BrowserError = void 0;
25
- // ============================================================================
26
- // RE-EXPORT ALL API TYPES
27
- // ============================================================================
28
- __exportStar(require("./api-types"), exports);
29
- // ============================================================================
30
- // BROWSER-SPECIFIC TYPES
31
- // ============================================================================
32
- /**
33
- * Browser error names
34
- */
35
- exports.BrowserError = {
36
- NOT_ALLOWED: 'NotAllowedError',
37
- NETWORK: 'NetworkError',
38
- NOT_SUPPORTED: 'NotSupportedError',
39
- SECURITY: 'SecurityError',
40
- ABORT: 'AbortError',
41
- TIMEOUT: 'TimeoutError',
42
- INVALID_STATE: 'InvalidStateError',
43
- DATA_CLONE: 'DataCloneError',
44
- ENCODING: 'EncodingError',
45
- NOT_READABLE: 'NotReadableError',
46
- UNKNOWN: 'UnknownError',
47
- TYPE: 'TypeError',
48
- RANGE: 'RangeError',
49
- SYNTAX: 'SyntaxError'
50
- };
51
- /**
52
- * Browser error codes
53
- */
54
- exports.BrowserErrorCode = {
55
- USER_CANCELLED_DC_API: 19,
56
- PERMISSION_DENIED: 1,
57
- POSITION_UNAVAILABLE: 2,
58
- TIMEOUT: 3,
59
- NOT_FOUND: 8,
60
- ABORT: 20,
61
- NETWORK: 19,
62
- SECURITY: 18
63
- };
64
- /**
65
- * Browser names for detection
66
- */
67
- exports.BrowserName = {
68
- CHROME: 'Chrome',
69
- EDGE: 'Edge',
70
- SAFARI: 'Safari',
71
- FIREFOX: 'Firefox',
72
- OPERA: 'Opera',
73
- BRAVE: 'Brave',
74
- OTHER: 'other'
75
- };
76
- /**
77
- * Authentication status constants
78
- * Maps to both client-side states and backend responses
79
- */
80
- exports.AuthStatus = {
81
- /** Authentication in progress */
82
- PENDING: 'pending',
83
- /** Authentication completed successfully */
84
- COMPLETED: 'completed',
85
- /** User cancelled authentication */
86
- CANCELLED: 'cancelled',
87
- /** Authentication failed or expired */
88
- FAILED: 'failed',
89
- /** Session expired (backend returns 410 Gone) */
90
- EXPIRED: 'expired',
91
- /** Session not found (backend returns 404) */
92
- NOT_FOUND: 'not_found'
93
- };