@glideidentity/web-client-sdk 5.1.2 → 6.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +439 -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 +435 -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 +534 -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 -151
  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 -147
  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,44 +0,0 @@
1
- /**
2
- * Validation utilities for phone authentication
3
- */
4
- import { PhoneAuthErrorCode } from './error-utils';
5
- import type { PLMN, UseCase } from './api-types';
6
- /**
7
- * Validates E.164 phone number format
8
- * @param phoneNumber - Phone number to validate
9
- * @returns Validation result with error if invalid
10
- */
11
- export declare function validatePhoneNumber(phoneNumber?: string): {
12
- valid: boolean;
13
- error?: string;
14
- };
15
- /**
16
- * Validates PLMN (MCC/MNC) values
17
- * @param plmn - PLMN object with MCC and MNC
18
- * @returns Validation result
19
- */
20
- export declare function validatePlmn(plmn?: PLMN): {
21
- valid: boolean;
22
- error?: string;
23
- };
24
- /**
25
- * Validates use case and phone number combination
26
- * @param useCase - The use case
27
- * @param phoneNumber - The phone number (required for VerifyPhoneNumber)
28
- * @param hasParentSessionId - Whether parent_session_id is provided (allows skipping normal validation)
29
- * @returns Validation result
30
- */
31
- export declare function validateUseCaseRequirements(useCase: UseCase, phoneNumber?: string, hasParentSessionId?: boolean): {
32
- valid: boolean;
33
- error?: string;
34
- };
35
- /**
36
- * Creates a validation error
37
- * @param code - Error code
38
- * @param message - Error message
39
- * @param field - Field that failed validation
40
- */
41
- export declare function createValidationError(code: PhoneAuthErrorCode, message: string, field?: string): Error & {
42
- code: PhoneAuthErrorCode;
43
- field?: string;
44
- };
@@ -1,62 +0,0 @@
1
- import { LogLevel, Logger } from './logger';
2
- export interface ClientConfig {
3
- /**
4
- * Base URL for API requests
5
- * Required only if using useQuery() or client.get() methods
6
- * Not required for phone authentication
7
- */
8
- baseURL?: string;
9
- /**
10
- * API key for authentication
11
- * Currently not used in the SDK but kept for backward compatibility
12
- */
13
- apiKey?: string;
14
- /**
15
- * Request timeout in milliseconds
16
- * @default 10000
17
- */
18
- timeout?: number;
19
- /**
20
- * Target origin for authentication
21
- * Used for cross-origin authentication flows
22
- * If not provided, uses baseURL or current origin
23
- */
24
- authTargetOrigin?: string;
25
- /**
26
- * Phone authentication endpoints
27
- * If not provided, uses default endpoints relative to baseURL
28
- */
29
- phoneAuthEndpoints?: {
30
- prepareRequest: string;
31
- processResponse: string;
32
- };
33
- /**
34
- * Enable debug logging
35
- * @default false
36
- */
37
- debug?: boolean;
38
- /**
39
- * Set specific log level
40
- */
41
- logLevel?: LogLevel;
42
- /**
43
- * Custom logger implementation
44
- */
45
- logger?: Logger;
46
- /**
47
- * Remote logging configuration
48
- */
49
- remoteLogging?: {
50
- endpoint: string;
51
- apiKey: string;
52
- };
53
- }
54
- export interface RequestOptions {
55
- headers?: Record<string, string>;
56
- params?: Record<string, any>;
57
- }
58
- export interface ClientResponse<T = any> {
59
- data: T;
60
- status: number;
61
- headers: Record<string, string>;
62
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +0,0 @@
1
- export declare const SDK_VERSION = "__SDK_VERSION__";
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SDK_VERSION = void 0;
4
- // SDK version - injected at build time
5
- exports.SDK_VERSION = '5.1.2';
@@ -1,7 +0,0 @@
1
- import type { ClientConfig, ClientResponse } from '../../core/types';
2
- import { Observable } from 'rxjs';
3
- export declare class ClientService {
4
- private client;
5
- constructor(config: ClientConfig);
6
- query<T>(path: string): Observable<ClientResponse<T>>;
7
- }
@@ -1,27 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- import { Injectable } from '@angular/core';
11
- import { SDKClient } from '../../core/client';
12
- import { from } from 'rxjs';
13
- let ClientService = class ClientService {
14
- constructor(config) {
15
- this.client = new SDKClient(config);
16
- }
17
- query(path) {
18
- return from(this.client.get(path));
19
- }
20
- };
21
- ClientService = __decorate([
22
- Injectable({
23
- providedIn: 'root',
24
- }),
25
- __metadata("design:paramtypes", [Object])
26
- ], ClientService);
27
- export { ClientService };
@@ -1,3 +0,0 @@
1
- export { ClientService } from './client.service';
2
- export { PhoneAuthService } from './phone-auth.service';
3
- export { PhoneAuthErrorCode, isPhoneAuthError, isUserError, getUserMessage, isErrorCode, getRetryDelay, isRetryableError, serializeError, createErrorBreadcrumb } from '../../core/phone-auth';
@@ -1,4 +0,0 @@
1
- export { ClientService } from './client.service';
2
- export { PhoneAuthService } from './phone-auth.service';
3
- // Export error utilities
4
- export { PhoneAuthErrorCode, isPhoneAuthError, isUserError, getUserMessage, isErrorCode, getRetryDelay, isRetryableError, serializeError, createErrorBreadcrumb } from '../../core/phone-auth';
@@ -1,38 +0,0 @@
1
- import type { AuthConfig, PhoneAuthResult, AuthError, AuthStep, PhoneAuthOptions } from '../../core/phone-auth';
2
- import { Observable } from 'rxjs';
3
- export declare class PhoneAuthService {
4
- private client;
5
- private isLoadingSubject;
6
- private errorSubject;
7
- private resultSubject;
8
- private currentStepSubject;
9
- isLoading$: Observable<boolean>;
10
- error$: Observable<AuthError | null>;
11
- result$: Observable<PhoneAuthResult | null>;
12
- currentStep$: Observable<AuthStep>;
13
- constructor();
14
- /**
15
- * Configure the phone auth client
16
- */
17
- configure(config: AuthConfig): void;
18
- /**
19
- * Check if browser supports secure phone authentication
20
- */
21
- isSupported(): boolean;
22
- /**
23
- * Verify phone number
24
- */
25
- verify(options: PhoneAuthOptions): Promise<PhoneAuthResult>;
26
- /**
27
- * Get phone number
28
- */
29
- getPhoneNumber(options?: Omit<PhoneAuthOptions, 'use_case' | 'phone_number'>): Promise<PhoneAuthResult>;
30
- /**
31
- * Verify specific phone number
32
- */
33
- verifyPhoneNumber(phoneNumber: string, options?: Omit<PhoneAuthOptions, 'use_case' | 'phone_number'>): Promise<PhoneAuthResult>;
34
- /**
35
- * Reset state
36
- */
37
- reset(): void;
38
- }
@@ -1,127 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
11
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
12
- return new (P || (P = Promise))(function (resolve, reject) {
13
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
14
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
15
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
16
- step((generator = generator.apply(thisArg, _arguments || [])).next());
17
- });
18
- };
19
- import { Injectable } from '@angular/core';
20
- import { PhoneAuthClient } from '../../core/phone-auth';
21
- import { BehaviorSubject } from 'rxjs';
22
- let PhoneAuthService = class PhoneAuthService {
23
- constructor() {
24
- // State subjects
25
- this.isLoadingSubject = new BehaviorSubject(false);
26
- this.errorSubject = new BehaviorSubject(null);
27
- this.resultSubject = new BehaviorSubject(null);
28
- this.currentStepSubject = new BehaviorSubject('idle');
29
- // Public observables
30
- this.isLoading$ = this.isLoadingSubject.asObservable();
31
- this.error$ = this.errorSubject.asObservable();
32
- this.result$ = this.resultSubject.asObservable();
33
- this.currentStep$ = this.currentStepSubject.asObservable();
34
- this.client = new PhoneAuthClient();
35
- }
36
- /**
37
- * Configure the phone auth client
38
- */
39
- configure(config) {
40
- this.client = new PhoneAuthClient(config);
41
- }
42
- /**
43
- * Check if browser supports secure phone authentication
44
- */
45
- isSupported() {
46
- return this.client.isSupported();
47
- }
48
- /**
49
- * Verify phone number
50
- */
51
- verify(options) {
52
- return __awaiter(this, void 0, void 0, function* () {
53
- this.isLoadingSubject.next(true);
54
- this.errorSubject.next(null);
55
- this.resultSubject.next(null);
56
- this.currentStepSubject.next('requesting');
57
- try {
58
- // Step 1: Prepare request
59
- const preparedRequest = yield this.client.preparePhoneRequest(options);
60
- // Step 2: Show authenticating state
61
- this.currentStepSubject.next('authenticating');
62
- const credentialResponse = yield this.client.invokeSecurePrompt(preparedRequest);
63
- // Step 3: Process response through appropriate endpoint
64
- this.currentStepSubject.next('processing');
65
- // Cast to credential type - adapters never use headless mode
66
- const credential = credentialResponse;
67
- const processedResult = options.use_case === 'GetPhoneNumber'
68
- ? yield this.client.getPhoneNumber(credential, preparedRequest.session)
69
- : yield this.client.verifyPhoneNumber(credential, preparedRequest.session);
70
- // Create final result
71
- const isVerifyResponse = 'verified' in processedResult;
72
- const result = processedResult;
73
- this.resultSubject.next(result);
74
- this.currentStepSubject.next('complete');
75
- return result;
76
- }
77
- catch (error) {
78
- // Enhance error with context
79
- const authError = error;
80
- const enhancedError = Object.assign(Object.assign({}, authError), { context: authError.context || {
81
- useCase: options.use_case,
82
- timestamp: new Date().toISOString(),
83
- userAgent: typeof navigator !== 'undefined' ? navigator.userAgent : undefined,
84
- url: typeof window !== 'undefined' ? window.location.href : undefined
85
- } });
86
- this.errorSubject.next(enhancedError);
87
- this.currentStepSubject.next('idle');
88
- throw enhancedError;
89
- }
90
- finally {
91
- this.isLoadingSubject.next(false);
92
- }
93
- });
94
- }
95
- /**
96
- * Get phone number
97
- */
98
- getPhoneNumber(options) {
99
- return __awaiter(this, void 0, void 0, function* () {
100
- return this.verify(Object.assign({ use_case: 'GetPhoneNumber' }, options));
101
- });
102
- }
103
- /**
104
- * Verify specific phone number
105
- */
106
- verifyPhoneNumber(phoneNumber, options) {
107
- return __awaiter(this, void 0, void 0, function* () {
108
- return this.verify(Object.assign({ use_case: 'VerifyPhoneNumber', phone_number: phoneNumber }, options));
109
- });
110
- }
111
- /**
112
- * Reset state
113
- */
114
- reset() {
115
- this.isLoadingSubject.next(false);
116
- this.errorSubject.next(null);
117
- this.resultSubject.next(null);
118
- this.currentStepSubject.next('idle');
119
- }
120
- };
121
- PhoneAuthService = __decorate([
122
- Injectable({
123
- providedIn: 'root'
124
- }),
125
- __metadata("design:paramtypes", [])
126
- ], PhoneAuthService);
127
- export { PhoneAuthService };
@@ -1,9 +0,0 @@
1
- export { usePhoneAuth } from './usePhoneAuth';
2
- export { useClient } from './useClient';
3
- export type { UsePhoneAuthOptions } from './usePhoneAuth';
4
- export type { ClientConfig, ClientResponse, RequestOptions } from '../../core/types';
5
- export type { AuthConfig as PhoneAuthConfig, PhoneAuthOptions, PhoneAuthResult, AuthError, AuthStep } from '../../core/phone-auth';
6
- export { PhoneAuthErrorCode, isPhoneAuthError, isUserError, getUserMessage, isErrorCode, getRetryDelay, isRetryableError, serializeError, createErrorBreadcrumb } from '../../core/phone-auth';
7
- 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';
8
- export { USE_CASE as UseCase, AUTHENTICATION_STRATEGY as AuthenticationStrategy, BrowserError, BrowserErrorCode, BrowserName } from '../../core/phone-auth/types';
9
- export { PhoneAuthClient } from '../../core/phone-auth';
@@ -1,8 +0,0 @@
1
- export { usePhoneAuth } from './usePhoneAuth';
2
- export { useClient } from './useClient';
3
- // Export error utilities
4
- export { PhoneAuthErrorCode, isPhoneAuthError, isUserError, getUserMessage, isErrorCode, getRetryDelay, isRetryableError, serializeError, createErrorBreadcrumb } from '../../core/phone-auth';
5
- // Export constants for use case and strategy
6
- export { USE_CASE as UseCase, AUTHENTICATION_STRATEGY as AuthenticationStrategy, BrowserError, BrowserErrorCode, BrowserName } from '../../core/phone-auth/types';
7
- // Export the PhoneAuthClient class for direct use
8
- export { PhoneAuthClient } from '../../core/phone-auth';
@@ -1,26 +0,0 @@
1
- import { SDKClient } from '../../core/client';
2
- import type { ClientConfig } from '../../core/types';
3
- import type { PhoneAuthResult, AuthError, PhoneAuthOptions } from '../../core/phone-auth';
4
- export declare function useClient(config: ClientConfig): {
5
- client: SDKClient;
6
- isAuthenticated: boolean;
7
- token: string | null;
8
- loading: boolean;
9
- error: Error | null;
10
- authenticate: (authUrl: string, options?: any) => Promise<never>;
11
- useQuery: <T>(path: string) => {
12
- data: T | null;
13
- loading: boolean;
14
- error: Error | null;
15
- refetch: () => Promise<void>;
16
- };
17
- usePhoneAuth: () => {
18
- result: PhoneAuthResult | null;
19
- loading: boolean;
20
- error: AuthError | null;
21
- isSupported: boolean;
22
- getPhoneNumber: (options?: Omit<PhoneAuthOptions, "useCase" | "phoneNumber">) => Promise<PhoneAuthResult>;
23
- verifyPhoneNumber: (phoneNumber: string, options?: Omit<PhoneAuthOptions, "useCase" | "phoneNumber">) => Promise<PhoneAuthResult>;
24
- };
25
- };
26
- export { useClient as useReactClient } from './useClient';
@@ -1,116 +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 { useState, useEffect, useCallback } from 'react';
11
- import { SDKClient } from '../../core/client';
12
- export function useClient(config) {
13
- const [client] = useState(() => new SDKClient(config));
14
- const [isAuthenticated, setIsAuthenticated] = useState(false);
15
- const [token, setToken] = useState(null);
16
- const [loading, setLoading] = useState(false);
17
- const [error, setError] = useState(null);
18
- useEffect(() => {
19
- let cleanupFn;
20
- const setCleanup = (fn) => {
21
- cleanupFn = fn;
22
- };
23
- return () => {
24
- if (cleanupFn) {
25
- cleanupFn();
26
- }
27
- };
28
- }, []);
29
- const authenticate = (authUrl, options) => __awaiter(this, void 0, void 0, function* () {
30
- // Legacy authentication removed - use setToken directly
31
- const error = new Error('authenticate method is deprecated. Use client.setToken() directly.');
32
- setError(error);
33
- setLoading(false);
34
- throw error;
35
- });
36
- const useQuery = (path) => {
37
- const [data, setData] = useState(null);
38
- const [queryLoading, setQueryLoading] = useState(true);
39
- const [queryError, setQueryError] = useState(null);
40
- const fetchData = useCallback(() => __awaiter(this, void 0, void 0, function* () {
41
- try {
42
- const response = yield client.get(path);
43
- setData(response.data);
44
- }
45
- catch (err) {
46
- setQueryError(err);
47
- }
48
- finally {
49
- setQueryLoading(false);
50
- }
51
- }), [path]);
52
- useEffect(() => {
53
- fetchData();
54
- }, [fetchData]);
55
- return { data, loading: queryLoading, error: queryError, refetch: fetchData };
56
- };
57
- const usePhoneAuth = () => {
58
- const [phoneAuthResult, setPhoneAuthResult] = useState(null);
59
- const [phoneAuthLoading, setPhoneAuthLoading] = useState(false);
60
- const [phoneAuthError, setPhoneAuthError] = useState(null);
61
- const [isSupported] = useState(() => client.phoneAuth.isSupported());
62
- const getPhoneNumber = useCallback((options) => __awaiter(this, void 0, void 0, function* () {
63
- setPhoneAuthLoading(true);
64
- setPhoneAuthError(null);
65
- setPhoneAuthResult(null);
66
- try {
67
- const result = yield client.phoneAuth.getPhoneNumberComplete(options);
68
- setPhoneAuthResult(result);
69
- return result;
70
- }
71
- catch (err) {
72
- setPhoneAuthError(err);
73
- throw err;
74
- }
75
- finally {
76
- setPhoneAuthLoading(false);
77
- }
78
- }), [client]);
79
- const verifyPhoneNumber = useCallback((phoneNumber, options) => __awaiter(this, void 0, void 0, function* () {
80
- setPhoneAuthLoading(true);
81
- setPhoneAuthError(null);
82
- setPhoneAuthResult(null);
83
- try {
84
- const result = yield client.phoneAuth.verifyPhoneNumberComplete(phoneNumber, options);
85
- setPhoneAuthResult(result);
86
- return result;
87
- }
88
- catch (err) {
89
- setPhoneAuthError(err);
90
- throw err;
91
- }
92
- finally {
93
- setPhoneAuthLoading(false);
94
- }
95
- }), [client]);
96
- return {
97
- result: phoneAuthResult,
98
- loading: phoneAuthLoading,
99
- error: phoneAuthError,
100
- isSupported,
101
- getPhoneNumber,
102
- verifyPhoneNumber
103
- };
104
- };
105
- return {
106
- client,
107
- isAuthenticated,
108
- token,
109
- loading,
110
- error,
111
- authenticate,
112
- useQuery,
113
- usePhoneAuth,
114
- };
115
- }
116
- export { useClient as useReactClient } from './useClient';
@@ -1,23 +0,0 @@
1
- import { PhoneAuthClient } from '../../core/phone-auth';
2
- import type { AuthConfig, PhoneAuthResult, AuthError, AuthStep, PhoneAuthOptions } from '../../core/phone-auth';
3
- export interface UsePhoneAuthOptions extends AuthConfig {
4
- }
5
- export declare function usePhoneAuth(config?: UsePhoneAuthOptions): {
6
- isLoading: boolean;
7
- error: AuthError | null;
8
- result: PhoneAuthResult | null;
9
- currentStep: AuthStep;
10
- isSupported: boolean;
11
- verify: (options: PhoneAuthOptions) => Promise<PhoneAuthResult>;
12
- getPhoneNumber: (options?: Omit<PhoneAuthOptions, "use_case">) => Promise<PhoneAuthResult>;
13
- verifyPhoneNumber: (phoneNumber: string, options?: Omit<PhoneAuthOptions, "use_case" | "phone_number">) => Promise<PhoneAuthResult>;
14
- retryLastRequest: () => Promise<PhoneAuthResult>;
15
- reset: () => void;
16
- preparePhoneRequest: (options: PhoneAuthOptions) => Promise<import("../../core/phone-auth").PrepareResponse>;
17
- invokeSecurePrompt: (prepareResponse: any) => Promise<{
18
- [aggregator_id: string]: string | string[];
19
- } | import("../../core/phone-auth").AuthCredential | import("../../core/phone-auth").AnyExtendedResponse>;
20
- getPhoneNumberCredential: (credentialResponse: any, session: any) => Promise<import("../../core/phone-auth").GetPhoneNumberResponse>;
21
- verifyPhoneNumberCredential: (credentialResponse: any, session: any) => Promise<import("../../core/phone-auth").VerifyPhoneNumberResponse>;
22
- client: PhoneAuthClient;
23
- };
@@ -1,92 +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 { useState, useCallback, useMemo, useRef } from 'react';
11
- import { PhoneAuthClient } from '../../core/phone-auth';
12
- export function usePhoneAuth(config = {}) {
13
- const [isLoading, setIsLoading] = useState(false);
14
- const [error, setError] = useState(null);
15
- const [result, setResult] = useState(null);
16
- const [currentStep, setCurrentStep] = useState('idle');
17
- const lastRequestRef = useRef(null);
18
- // Create client instance with callbacks
19
- const client = useMemo(() => new PhoneAuthClient(Object.assign(Object.assign({}, config), {
20
- // Pass through callbacks if provided
21
- onCrossDeviceDetected: config.onCrossDeviceDetected, onRetryAttempt: config.onRetryAttempt })), [JSON.stringify(config)]);
22
- // Check browser support
23
- const isSupported = useMemo(() => client.isSupported(), [client]);
24
- // Verify method with silent retry support
25
- const verify = useCallback((options) => __awaiter(this, void 0, void 0, function* () {
26
- setIsLoading(true);
27
- setError(null);
28
- setResult(null);
29
- setCurrentStep('requesting');
30
- lastRequestRef.current = options;
31
- try {
32
- // Use the client's verify method which includes retry logic
33
- const verificationResult = yield client.verify(options);
34
- setResult(verificationResult);
35
- setCurrentStep('complete');
36
- return verificationResult;
37
- }
38
- catch (err) {
39
- // Error is only set after all retries are exhausted
40
- const authError = err;
41
- setError(authError);
42
- setCurrentStep('idle');
43
- throw authError;
44
- }
45
- finally {
46
- setIsLoading(false);
47
- }
48
- }), [client]);
49
- // Manual retry method
50
- const retryLastRequest = useCallback(() => __awaiter(this, void 0, void 0, function* () {
51
- if (!lastRequestRef.current) {
52
- throw new Error('No previous request to retry');
53
- }
54
- return verify(lastRequestRef.current);
55
- }), [verify]);
56
- // Convenience methods
57
- const getPhoneNumber = useCallback((options) => verify(Object.assign({ use_case: 'GetPhoneNumber' }, options)), [verify]);
58
- const verifyPhoneNumber = useCallback((phoneNumber, options) => verify(Object.assign({ use_case: 'VerifyPhoneNumber', phone_number: phoneNumber }, options)), [verify]);
59
- // Reset state
60
- const reset = useCallback(() => {
61
- setIsLoading(false);
62
- setError(null);
63
- setResult(null);
64
- setCurrentStep('idle');
65
- }, []);
66
- // Expose granular methods directly from client for better discoverability
67
- const preparePhoneRequest = useCallback((options) => client.preparePhoneRequest(options), [client]);
68
- const invokeSecurePrompt = useCallback((prepareResponse) => client.invokeSecurePrompt(prepareResponse), [client]);
69
- const getPhoneNumberCredential = useCallback((credentialResponse, session) => client.getPhoneNumber(credentialResponse, session), [client]);
70
- const verifyPhoneNumberCredential = useCallback((credentialResponse, session) => client.verifyPhoneNumber(credentialResponse, session), [client]);
71
- return {
72
- // State
73
- isLoading,
74
- error,
75
- result,
76
- currentStep,
77
- isSupported,
78
- // High-level methods
79
- verify,
80
- getPhoneNumber,
81
- verifyPhoneNumber,
82
- retryLastRequest,
83
- reset,
84
- // Granular methods (directly exposed for better discoverability)
85
- preparePhoneRequest,
86
- invokeSecurePrompt,
87
- getPhoneNumberCredential,
88
- verifyPhoneNumberCredential,
89
- // Client instance (still available for advanced usage)
90
- client
91
- };
92
- }
@@ -1,8 +0,0 @@
1
- import type { ClientConfig, ClientResponse, RequestOptions } from '../../core/types';
2
- export declare class VanillaClient {
3
- private client;
4
- constructor(config: ClientConfig);
5
- authenticate(authUrl: string, options?: any): Promise<void>;
6
- setToken(token: string): void;
7
- get<T>(path: string, options?: RequestOptions): Promise<ClientResponse<T>>;
8
- }
@@ -1,29 +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 { SDKClient } from '../../core/client';
11
- export class VanillaClient {
12
- constructor(config) {
13
- this.client = new SDKClient(config);
14
- }
15
- authenticate(authUrl, options) {
16
- return __awaiter(this, void 0, void 0, function* () {
17
- // Legacy authentication removed - use setToken directly
18
- throw new Error('authenticate method is deprecated. Use client.setToken() directly.');
19
- });
20
- }
21
- setToken(token) {
22
- this.client.setToken(token);
23
- }
24
- get(path, options) {
25
- return __awaiter(this, void 0, void 0, function* () {
26
- return this.client.get(path, options);
27
- });
28
- }
29
- }
@@ -1,3 +0,0 @@
1
- export { VanillaClient as ClientManager } from './client';
2
- export { PhoneAuthManager } from './phone-auth';
3
- export { PhoneAuthErrorCode, isPhoneAuthError, isUserError, getUserMessage, isErrorCode, getRetryDelay, isRetryableError, serializeError, createErrorBreadcrumb } from '../../core/phone-auth';