@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,134 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { PhoneAuthClient } from '../../core/phone-auth';
11
- export class PhoneAuthManager {
12
- constructor(config = {}) {
13
- this.listeners = [];
14
- this.client = new PhoneAuthClient(config);
15
- this.state = {
16
- isLoading: false,
17
- error: null,
18
- result: null,
19
- currentStep: 'idle',
20
- isSupported: this.client.isSupported()
21
- };
22
- }
23
- /**
24
- * Get current state
25
- */
26
- getState() {
27
- return Object.assign({}, this.state);
28
- }
29
- /**
30
- * Subscribe to state changes
31
- */
32
- subscribe(listener) {
33
- this.listeners.push(listener);
34
- // Return unsubscribe function
35
- return () => {
36
- const index = this.listeners.indexOf(listener);
37
- if (index !== -1) {
38
- this.listeners.splice(index, 1);
39
- }
40
- };
41
- }
42
- /**
43
- * Update state and notify listeners
44
- */
45
- updateState(updates) {
46
- this.state = Object.assign(Object.assign({}, this.state), updates);
47
- this.listeners.forEach(listener => listener(this.getState()));
48
- }
49
- /**
50
- * Verify phone number
51
- */
52
- verify(options) {
53
- return __awaiter(this, void 0, void 0, function* () {
54
- this.updateState({
55
- isLoading: true,
56
- error: null,
57
- result: null,
58
- currentStep: 'requesting'
59
- });
60
- try {
61
- // Step 1: Prepare request
62
- const preparedRequest = yield this.client.preparePhoneRequest(options);
63
- // Step 2: Show authenticating state
64
- this.updateState({ currentStep: 'authenticating' });
65
- const credentialResponse = yield this.client.invokeSecurePrompt(preparedRequest);
66
- // Step 3: Process response through appropriate endpoint
67
- this.updateState({ currentStep: 'processing' });
68
- // Cast to credential type - adapters never use headless mode
69
- const credential = credentialResponse;
70
- const processedResult = options.use_case === 'GetPhoneNumber'
71
- ? yield this.client.getPhoneNumber(credential, preparedRequest.session)
72
- : yield this.client.verifyPhoneNumber(credential, preparedRequest.session);
73
- // Create final result
74
- const isVerifyResponse = 'verified' in processedResult;
75
- const result = processedResult;
76
- this.updateState({
77
- result,
78
- currentStep: 'complete',
79
- isLoading: false
80
- });
81
- return result;
82
- }
83
- catch (error) {
84
- // Enhance error with context
85
- const authError = error;
86
- const enhancedError = Object.assign(Object.assign({}, authError), { context: authError.context || {
87
- useCase: options.use_case,
88
- timestamp: new Date().toISOString(),
89
- userAgent: typeof navigator !== 'undefined' ? navigator.userAgent : undefined,
90
- url: typeof window !== 'undefined' ? window.location.href : undefined
91
- } });
92
- this.updateState({
93
- error: enhancedError,
94
- currentStep: 'idle',
95
- isLoading: false
96
- });
97
- throw enhancedError;
98
- }
99
- });
100
- }
101
- /**
102
- * Get phone number
103
- */
104
- getPhoneNumber(options) {
105
- return __awaiter(this, void 0, void 0, function* () {
106
- return this.verify(Object.assign({ use_case: 'GetPhoneNumber' }, options));
107
- });
108
- }
109
- /**
110
- * Verify specific phone number
111
- */
112
- verifyPhoneNumber(phoneNumber, options) {
113
- return __awaiter(this, void 0, void 0, function* () {
114
- return this.verify(Object.assign({ use_case: 'VerifyPhoneNumber', phone_number: phoneNumber }, options));
115
- });
116
- }
117
- /**
118
- * Reset state
119
- */
120
- reset() {
121
- this.updateState({
122
- isLoading: false,
123
- error: null,
124
- result: null,
125
- currentStep: 'idle'
126
- });
127
- }
128
- /**
129
- * Check if browser supports secure phone authentication
130
- */
131
- isSupported() {
132
- return this.state.isSupported;
133
- }
134
- }
@@ -1,10 +0,0 @@
1
- export { usePhoneAuth } from './usePhoneAuth';
2
- export { useClient } from './useClient';
3
- export { SDKClient } from '../../core/client';
4
- export { PhoneAuthClient } from '../../core/phone-auth';
5
- export type { ClientConfig, ClientResponse, RequestOptions } from '../../core/types';
6
- export type { AuthConfig as PhoneAuthConfig, PhoneAuthOptions, PhoneAuthResult, AuthError, AuthStep } from '../../core/phone-auth';
7
- export { PhoneAuthErrorCode, isPhoneAuthError, isUserError, getUserMessage, isErrorCode, getRetryDelay, isRetryableError, serializeError, createErrorBreadcrumb } from '../../core/phone-auth';
8
- export type { PhoneAuthCallbacks, PLMN, SessionInfo, PrepareRequest, PrepareResponse, GetPhoneNumberRequest, GetPhoneNumberResponse, VerifyPhoneNumberRequest, VerifyPhoneNumberResponse, SecureCredentialRequest, SecureCredentialResponse, DigitalCredential, TS43Data, LinkData, ClientInfo, BrowserErrorType, BrowserErrorCodeType, BrowserNameType } from '../../core/phone-auth/types';
9
- export { USE_CASE as UseCase, AUTHENTICATION_STRATEGY as AuthenticationStrategy, BrowserError, BrowserErrorCode, BrowserName } from '../../core/phone-auth/types';
10
- export { USE_CASE, ERROR_CODE, ERROR_MESSAGES, ERROR_STATUS_CODES } from '../../core/phone-auth/api-types';
@@ -1,11 +0,0 @@
1
- export { usePhoneAuth } from './usePhoneAuth';
2
- export { useClient } from './useClient';
3
- export { SDKClient } from '../../core/client';
4
- export { PhoneAuthClient } from '../../core/phone-auth';
5
- // API response types are already exported via core/phone-auth/types
6
- // Export error utilities
7
- export { PhoneAuthErrorCode, isPhoneAuthError, isUserError, getUserMessage, isErrorCode, getRetryDelay, isRetryableError, serializeError, createErrorBreadcrumb } from '../../core/phone-auth';
8
- // Export constants for use case and strategy
9
- export { USE_CASE as UseCase, AUTHENTICATION_STRATEGY as AuthenticationStrategy, BrowserError, BrowserErrorCode, BrowserName } from '../../core/phone-auth/types';
10
- // Export API constants from api-types
11
- export { USE_CASE, ERROR_CODE, ERROR_MESSAGES, ERROR_STATUS_CODES } from '../../core/phone-auth/api-types';
@@ -1,115 +0,0 @@
1
- import { Ref } from 'vue';
2
- import type { ClientConfig, ClientResponse } from '../../core/types';
3
- import type { PhoneAuthResult, AuthError, PhoneAuthOptions } from '../../core/phone-auth';
4
- export declare function useClient<T>(config: ClientConfig): {
5
- client: {
6
- phoneAuth: {
7
- isSupported: () => boolean;
8
- getBrowserSupportInfo: () => {
9
- supported: boolean;
10
- browser: string;
11
- message?: string;
12
- helpUrl?: string;
13
- };
14
- verify: (options: PhoneAuthOptions) => Promise<PhoneAuthResult>;
15
- getPhoneNumberComplete: (options?: Omit<PhoneAuthOptions, "use_case" | "phone_number">) => Promise<PhoneAuthResult>;
16
- verifyPhoneNumberComplete: (phoneNumber: string, options?: Omit<PhoneAuthOptions, "use_case" | "phone_number">) => Promise<PhoneAuthResult>;
17
- preparePhoneRequest: (options: PhoneAuthOptions) => Promise<import("../../core/phone-auth").PrepareResponse>;
18
- invokeSecurePrompt: (prepareResponse: import("../../core/phone-auth").PrepareResponse, options?: import("../../core/phone-auth").InvokeOptions | import("../..").DesktopAuthOptions) => Promise<import("../../core/phone-auth").AuthCredential | import("../../core/phone-auth").SecureCredentialResponse["vp_token"] | import("../../core/phone-auth").AnyExtendedResponse>;
19
- getPhoneNumber: (credentialResponse: import("../../core/phone-auth").SecureCredentialResponse["vp_token"] | string, session: import("../../core/phone-auth").SessionInfo) => Promise<import("../../core/phone-auth").GetPhoneNumberResponse>;
20
- verifyPhoneNumber: (credentialResponse: import("../../core/phone-auth").SecureCredentialResponse["vp_token"] | string, session: import("../../core/phone-auth").SessionInfo) => Promise<import("../../core/phone-auth").VerifyPhoneNumberResponse>;
21
- };
22
- setToken: (token: string) => void;
23
- clearToken: () => void;
24
- get: <T_1 = any>(path: string, options?: import("../../core/types").RequestOptions) => Promise<ClientResponse<T_1>>;
25
- };
26
- useQuery: (path: string) => {
27
- data: [T | null] extends [Ref<any, any>] ? import("@vue/shared").IfAny<Ref<any, any> & T, Ref<Ref<any, any> & T, Ref<any, any> & T>, Ref<any, any> & T> : Ref<import("vue").UnwrapRef<T> | null, T | import("vue").UnwrapRef<T> | null>;
28
- loading: Ref<boolean, boolean>;
29
- error: Ref<Error | null, Error | null>;
30
- refetch: () => Promise<void>;
31
- };
32
- useAuth: (options?: any) => {
33
- token: Ref<string | null, string | null>;
34
- loading: Ref<boolean, boolean>;
35
- error: Ref<Error | null, Error | null>;
36
- authenticate: (authUrl: string) => Promise<never>;
37
- };
38
- usePhoneAuth: () => {
39
- result: Ref<{
40
- phone_number: import("../../core/phone-auth").PhoneNumber;
41
- aud?: string | undefined;
42
- } | {
43
- phone_number: import("../../core/phone-auth").PhoneNumber;
44
- verified: boolean;
45
- aud?: string | undefined;
46
- } | null, PhoneAuthResult | {
47
- phone_number: import("../../core/phone-auth").PhoneNumber;
48
- aud?: string | undefined;
49
- } | {
50
- phone_number: import("../../core/phone-auth").PhoneNumber;
51
- verified: boolean;
52
- aud?: string | undefined;
53
- } | null>;
54
- loading: Ref<boolean, boolean>;
55
- error: Ref<{
56
- code: import("../../core/phone-auth/types").PhoneAuthErrorCode;
57
- message: string;
58
- details?: any;
59
- status?: number | undefined;
60
- requestId?: string | undefined;
61
- timestamp?: string | undefined;
62
- traceId?: string | undefined;
63
- spanId?: string | undefined;
64
- service?: string | undefined;
65
- retryAfter?: number | undefined;
66
- browserError?: {
67
- name: string;
68
- message: string;
69
- stack?: string;
70
- code?: number;
71
- } | undefined;
72
- context?: {
73
- [x: string]: any;
74
- step?: "prepare" | "prompt" | "process" | "complete" | undefined;
75
- useCase?: string | undefined;
76
- timestamp: string;
77
- userAgent?: string | undefined;
78
- url?: string | undefined;
79
- } | undefined;
80
- } | null, AuthError | {
81
- code: import("../../core/phone-auth/types").PhoneAuthErrorCode;
82
- message: string;
83
- details?: any;
84
- status?: number | undefined;
85
- requestId?: string | undefined;
86
- timestamp?: string | undefined;
87
- traceId?: string | undefined;
88
- spanId?: string | undefined;
89
- service?: string | undefined;
90
- retryAfter?: number | undefined;
91
- browserError?: {
92
- name: string;
93
- message: string;
94
- stack?: string;
95
- code?: number;
96
- } | undefined;
97
- context?: {
98
- [x: string]: any;
99
- step?: "prepare" | "prompt" | "process" | "complete" | undefined;
100
- useCase?: string | undefined;
101
- timestamp: string;
102
- userAgent?: string | undefined;
103
- url?: string | undefined;
104
- } | undefined;
105
- } | null>;
106
- isSupported: Ref<boolean, boolean>;
107
- getPhoneNumber: (options?: Omit<PhoneAuthOptions, "useCase" | "phoneNumber">) => Promise<PhoneAuthResult>;
108
- verifyPhoneNumber: (phoneNumber: string, options?: Omit<PhoneAuthOptions, "useCase" | "phoneNumber">) => Promise<PhoneAuthResult>;
109
- preparePhoneRequest: (options: Parameters<(options: PhoneAuthOptions) => Promise<import("../../core/phone-auth").PrepareResponse>>[0]) => Promise<import("../../core/phone-auth").PrepareResponse>;
110
- invokeSecurePrompt: (request: Parameters<(prepareResponse: import("../../core/phone-auth").PrepareResponse, options?: import("../../core/phone-auth").InvokeOptions | import("../..").DesktopAuthOptions) => Promise<import("../../core/phone-auth").AuthCredential | import("../../core/phone-auth").SecureCredentialResponse["vp_token"] | import("../../core/phone-auth").AnyExtendedResponse>>[0]) => Promise<{
111
- [aggregator_id: string]: string | string[];
112
- } | import("../../core/phone-auth").AuthCredential | import("../../core/phone-auth").AnyExtendedResponse>;
113
- };
114
- };
115
- export declare const useVueClient: typeof useClient;
@@ -1,127 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { ref, onUnmounted } from 'vue';
11
- import { SDKClient } from '../../core/client';
12
- export function useClient(config) {
13
- const client = ref(new SDKClient(config));
14
- return {
15
- client: client.value,
16
- useQuery: (path) => {
17
- const data = ref(null);
18
- const loading = ref(true);
19
- const error = ref(null);
20
- const fetchData = () => __awaiter(this, void 0, void 0, function* () {
21
- try {
22
- const response = yield client.value.get(path);
23
- data.value = response.data;
24
- }
25
- catch (err) {
26
- error.value = err;
27
- }
28
- finally {
29
- loading.value = false;
30
- }
31
- });
32
- fetchData();
33
- return { data, loading, error, refetch: fetchData };
34
- },
35
- useAuth: (options = {}) => {
36
- const token = ref(null);
37
- const loading = ref(false);
38
- const error = ref(null);
39
- let cleanup = null;
40
- const authenticate = (authUrl) => __awaiter(this, void 0, void 0, function* () {
41
- loading.value = true;
42
- error.value = null;
43
- // Clean up previous authentication if exists
44
- if (cleanup) {
45
- cleanup();
46
- cleanup = null;
47
- }
48
- // Legacy authentication removed - use setToken directly
49
- error.value = new Error('authenticate method is deprecated. Use client.setToken() directly.');
50
- loading.value = false;
51
- throw error.value;
52
- });
53
- // Cleanup on component unmount
54
- onUnmounted(() => {
55
- if (cleanup) {
56
- cleanup();
57
- cleanup = null;
58
- }
59
- });
60
- return {
61
- token,
62
- loading,
63
- error,
64
- authenticate
65
- };
66
- },
67
- usePhoneAuth: () => {
68
- const result = ref(null);
69
- const loading = ref(false);
70
- const error = ref(null);
71
- const isSupported = ref(client.value.phoneAuth.isSupported());
72
- const getPhoneNumber = (options) => __awaiter(this, void 0, void 0, function* () {
73
- loading.value = true;
74
- error.value = null;
75
- result.value = null;
76
- try {
77
- const res = yield client.value.phoneAuth.getPhoneNumberComplete(options);
78
- result.value = res;
79
- return res;
80
- }
81
- catch (err) {
82
- error.value = err;
83
- throw err;
84
- }
85
- finally {
86
- loading.value = false;
87
- }
88
- });
89
- const verifyPhoneNumber = (phoneNumber, options) => __awaiter(this, void 0, void 0, function* () {
90
- loading.value = true;
91
- error.value = null;
92
- result.value = null;
93
- try {
94
- const res = yield client.value.phoneAuth.verifyPhoneNumberComplete(phoneNumber, options);
95
- result.value = res;
96
- return res;
97
- }
98
- catch (err) {
99
- error.value = err;
100
- throw err;
101
- }
102
- finally {
103
- loading.value = false;
104
- }
105
- });
106
- // Low-level methods for advanced control
107
- const preparePhoneRequest = (options) => __awaiter(this, void 0, void 0, function* () {
108
- return client.value.phoneAuth.preparePhoneRequest(options);
109
- });
110
- const invokeSecurePrompt = (request) => __awaiter(this, void 0, void 0, function* () {
111
- return client.value.phoneAuth.invokeSecurePrompt(request);
112
- });
113
- return {
114
- result,
115
- loading,
116
- error,
117
- isSupported,
118
- getPhoneNumber,
119
- verifyPhoneNumber,
120
- // Low-level API for advanced usage
121
- preparePhoneRequest,
122
- invokeSecurePrompt
123
- };
124
- }
125
- };
126
- }
127
- export const useVueClient = useClient;
@@ -1,94 +0,0 @@
1
- import { PhoneAuthClient } from '../../core/phone-auth';
2
- import type { AuthConfig, AuthStep, PhoneAuthOptions } from '../../core/phone-auth';
3
- import * as API from '../../core/phone-auth/api-types';
4
- export interface UsePhoneAuthOptions extends AuthConfig {
5
- }
6
- export declare function usePhoneAuth(config?: UsePhoneAuthOptions): {
7
- isLoading: Readonly<import("vue").Ref<boolean, boolean>>;
8
- error: Readonly<import("vue").Ref<{
9
- readonly code: import("../../core/phone-auth/types").PhoneAuthErrorCode;
10
- readonly message: string;
11
- readonly details?: any;
12
- readonly status?: number | undefined;
13
- readonly requestId?: string | undefined;
14
- readonly timestamp?: string | undefined;
15
- readonly traceId?: string | undefined;
16
- readonly spanId?: string | undefined;
17
- readonly service?: string | undefined;
18
- readonly retryAfter?: number | undefined;
19
- readonly browserError?: {
20
- name: string;
21
- message: string;
22
- stack?: string;
23
- code?: number;
24
- } | undefined;
25
- readonly context?: {
26
- readonly [x: string]: any;
27
- readonly step?: "prepare" | "prompt" | "process" | "complete" | undefined;
28
- readonly useCase?: string | undefined;
29
- readonly timestamp: string;
30
- readonly userAgent?: string | undefined;
31
- readonly url?: string | undefined;
32
- } | undefined;
33
- } | null, {
34
- readonly code: import("../../core/phone-auth/types").PhoneAuthErrorCode;
35
- readonly message: string;
36
- readonly details?: any;
37
- readonly status?: number | undefined;
38
- readonly requestId?: string | undefined;
39
- readonly timestamp?: string | undefined;
40
- readonly traceId?: string | undefined;
41
- readonly spanId?: string | undefined;
42
- readonly service?: string | undefined;
43
- readonly retryAfter?: number | undefined;
44
- readonly browserError?: {
45
- name: string;
46
- message: string;
47
- stack?: string;
48
- code?: number;
49
- } | undefined;
50
- readonly context?: {
51
- readonly [x: string]: any;
52
- readonly step?: "prepare" | "prompt" | "process" | "complete" | undefined;
53
- readonly useCase?: string | undefined;
54
- readonly timestamp: string;
55
- readonly userAgent?: string | undefined;
56
- readonly url?: string | undefined;
57
- } | undefined;
58
- } | null>>;
59
- result: Readonly<import("vue").Ref<{
60
- readonly phone_number: API.PhoneNumber;
61
- readonly aud?: string | undefined;
62
- } | {
63
- readonly phone_number: API.PhoneNumber;
64
- readonly verified: boolean;
65
- readonly aud?: string | undefined;
66
- } | null, {
67
- readonly phone_number: API.PhoneNumber;
68
- readonly aud?: string | undefined;
69
- } | {
70
- readonly phone_number: API.PhoneNumber;
71
- readonly verified: boolean;
72
- readonly aud?: string | undefined;
73
- } | null>>;
74
- currentStep: Readonly<import("vue").Ref<AuthStep, AuthStep>>;
75
- isSupported: Readonly<import("vue").Ref<boolean, boolean>>;
76
- verify: (options: PhoneAuthOptions) => Promise<{
77
- phone_number: API.PhoneNumber;
78
- aud?: string | undefined;
79
- }>;
80
- getPhoneNumber: (options?: Omit<PhoneAuthOptions, "use_case" | "phone_number">) => Promise<{
81
- phone_number: API.PhoneNumber;
82
- aud?: string | undefined;
83
- }>;
84
- verifyPhoneNumber: (phoneNumber: string, options?: Omit<PhoneAuthOptions, "use_case" | "phone_number">) => Promise<{
85
- phone_number: API.PhoneNumber;
86
- aud?: string | undefined;
87
- }>;
88
- reset: () => void;
89
- preparePhoneRequest: (options: PhoneAuthOptions) => Promise<API.PrepareResponse>;
90
- invokeSecurePrompt: (prepareResponse: API.PrepareResponse, options?: API.InvokeOptions | import("../..").DesktopAuthOptions) => Promise<API.AuthCredential | API.SecureCredentialResponse["vp_token"] | API.AnyExtendedResponse>;
91
- getPhoneNumberCredential: (credentialResponse: API.SecureCredentialResponse["vp_token"] | string, session: API.SessionInfo) => Promise<API.GetPhoneNumberResponse>;
92
- verifyPhoneNumberCredential: (credentialResponse: API.SecureCredentialResponse["vp_token"] | string, session: API.SessionInfo) => Promise<API.VerifyPhoneNumberResponse>;
93
- client: PhoneAuthClient;
94
- };
@@ -1,100 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { ref, computed, readonly } from 'vue';
11
- import { PhoneAuthClient } from '../../core/phone-auth';
12
- export function usePhoneAuth(config = {}) {
13
- // State management
14
- const isLoading = ref(false);
15
- const error = ref(null);
16
- const result = ref(null);
17
- const currentStep = ref('idle');
18
- // Create client instance with callbacks
19
- const client = new PhoneAuthClient(Object.assign(Object.assign({}, config), {
20
- // Callbacks are now properly typed through AuthConfig
21
- onCrossDeviceDetected: config.onCrossDeviceDetected, onRetryAttempt: config.onRetryAttempt }));
22
- // Check browser support
23
- const isSupported = computed(() => client.isSupported());
24
- // Verify method - internal wrapper that converts to API format
25
- const verify = (options) => __awaiter(this, void 0, void 0, function* () {
26
- isLoading.value = true;
27
- error.value = null;
28
- result.value = null;
29
- currentStep.value = 'requesting';
30
- try {
31
- // Step 1: Prepare the request
32
- const preparedRequest = yield client.preparePhoneRequest(options);
33
- // Step 2: User authentication
34
- currentStep.value = 'authenticating';
35
- const credentialResponse = yield client.invokeSecurePrompt(preparedRequest);
36
- // Step 3: Process the response through appropriate endpoint
37
- currentStep.value = 'processing';
38
- // Cast to credential type - adapters never use headless mode
39
- const credential = credentialResponse;
40
- const verificationResult = options.use_case === 'GetPhoneNumber'
41
- ? yield client.getPhoneNumber(credential, preparedRequest.session)
42
- : yield client.verifyPhoneNumber(credential, preparedRequest.session);
43
- // Use the result directly - it's already the correct type
44
- result.value = verificationResult;
45
- currentStep.value = 'complete';
46
- return result.value;
47
- }
48
- catch (err) {
49
- // Enhance error with context if it's an AuthError
50
- const authError = err;
51
- const enhancedError = Object.assign(Object.assign({}, authError), { context: authError.context || {
52
- useCase: options.use_case,
53
- timestamp: new Date().toISOString(),
54
- userAgent: typeof navigator !== 'undefined' ? navigator.userAgent : undefined,
55
- url: typeof window !== 'undefined' ? window.location.href : undefined
56
- } });
57
- error.value = enhancedError;
58
- currentStep.value = 'idle';
59
- throw enhancedError;
60
- }
61
- finally {
62
- isLoading.value = false;
63
- }
64
- });
65
- // Convenience methods
66
- const getPhoneNumber = (options) => verify(Object.assign({ use_case: 'GetPhoneNumber' }, options));
67
- const verifyPhoneNumber = (phoneNumber, options) => verify(Object.assign({ use_case: 'VerifyPhoneNumber', phone_number: phoneNumber }, options));
68
- // Reset state
69
- const reset = () => {
70
- isLoading.value = false;
71
- error.value = null;
72
- result.value = null;
73
- currentStep.value = 'idle';
74
- };
75
- // Expose granular methods directly from client for better discoverability
76
- const preparePhoneRequest = client.preparePhoneRequest.bind(client);
77
- const invokeSecurePrompt = client.invokeSecurePrompt.bind(client);
78
- const getPhoneNumberCredential = client.getPhoneNumber.bind(client);
79
- const verifyPhoneNumberCredential = client.verifyPhoneNumber.bind(client);
80
- return {
81
- // State (readonly)
82
- isLoading: readonly(isLoading),
83
- error: readonly(error),
84
- result: readonly(result),
85
- currentStep: readonly(currentStep),
86
- isSupported: readonly(isSupported),
87
- // High-level methods
88
- verify,
89
- getPhoneNumber,
90
- verifyPhoneNumber,
91
- reset,
92
- // Granular methods (directly exposed for better discoverability)
93
- preparePhoneRequest,
94
- invokeSecurePrompt,
95
- getPhoneNumberCredential,
96
- verifyPhoneNumberCredential,
97
- // Client instance (still available for advanced usage)
98
- client
99
- };
100
- }
@@ -1,7 +0,0 @@
1
- export { PhoneAuthClient } from './core/phone-auth';
2
- export type { AuthConfig as PhoneAuthConfig, PhoneAuthOptions, PhoneAuthResult, AuthError as PhoneAuthError, AuthStep as PhoneAuthStep } from './core/phone-auth';
3
- export { PhoneAuthErrorCode, isPhoneAuthError, isUserError, getUserMessage, isErrorCode, getRetryDelay, isRetryableError, serializeError, createErrorBreadcrumb } from './core/phone-auth';
4
- export type { PhoneAuthCallbacks, PLMN, SessionInfo, PrepareRequest, PrepareResponse, GetPhoneNumberRequest, GetPhoneNumberResponse, VerifyPhoneNumberRequest, VerifyPhoneNumberResponse, SecureCredentialRequest, SecureCredentialResponse, DigitalCredential, TS43Data, LinkData, ClientInfo, BrowserErrorType, BrowserErrorCodeType, BrowserNameType } from './core/phone-auth/types';
5
- export { USE_CASE as UseCase, AUTHENTICATION_STRATEGY as AuthenticationStrategy, BrowserError, BrowserErrorCode, BrowserName } from './core/phone-auth/types';
6
- export { VanillaClient as ClientManager } from './adapters/vanilla/client';
7
- export { PhoneAuthManager } from './adapters/vanilla/phone-auth';
@@ -1,22 +0,0 @@
1
- import { ClientConfig, RequestOptions, ClientResponse } from './types';
2
- import { PhoneAuthClient } from './phone-auth';
3
- export declare class SDKClient {
4
- private client;
5
- private config;
6
- private token?;
7
- phoneAuth: PhoneAuthClient;
8
- constructor(config: ClientConfig);
9
- /**
10
- * Set authentication token for API requests
11
- */
12
- setToken(token: string): void;
13
- /**
14
- * Clear authentication token
15
- */
16
- clearToken(): void;
17
- /**
18
- * Make a GET request to the API
19
- * Note: Requires baseURL to be set in the config
20
- */
21
- get<T = any>(path: string, options?: RequestOptions): Promise<ClientResponse<T>>;
22
- }