@glideidentity/web-client-sdk 4.4.8-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.
- package/README.md +938 -0
- package/dist/adapters/angular/client.service.d.ts +7 -0
- package/dist/adapters/angular/client.service.js +30 -0
- package/dist/adapters/angular/index.d.ts +3 -0
- package/dist/adapters/angular/index.js +18 -0
- package/dist/adapters/angular/phone-auth.service.d.ts +38 -0
- package/dist/adapters/angular/phone-auth.service.js +130 -0
- package/dist/adapters/react/index.d.ts +9 -0
- package/dist/adapters/react/index.js +28 -0
- package/dist/adapters/react/useClient.d.ts +26 -0
- package/dist/adapters/react/useClient.js +121 -0
- package/dist/adapters/react/usePhoneAuth.d.ts +23 -0
- package/dist/adapters/react/usePhoneAuth.js +95 -0
- package/dist/adapters/vanilla/client.d.ts +8 -0
- package/dist/adapters/vanilla/client.js +33 -0
- package/dist/adapters/vanilla/index.d.ts +3 -0
- package/dist/adapters/vanilla/index.js +18 -0
- package/dist/adapters/vanilla/phone-auth.d.ts +46 -0
- package/dist/adapters/vanilla/phone-auth.js +138 -0
- package/dist/adapters/vue/index.d.ts +10 -0
- package/dist/adapters/vue/index.js +36 -0
- package/dist/adapters/vue/useClient.d.ts +115 -0
- package/dist/adapters/vue/useClient.js +131 -0
- package/dist/adapters/vue/usePhoneAuth.d.ts +94 -0
- package/dist/adapters/vue/usePhoneAuth.js +103 -0
- package/dist/browser/web-client-sdk.min.js +2 -0
- package/dist/browser/web-client-sdk.min.js.LICENSE.txt +1 -0
- package/dist/browser.d.ts +7 -0
- package/dist/browser.js +31 -0
- package/dist/core/client.d.ts +22 -0
- package/dist/core/client.js +77 -0
- package/dist/core/logger.d.ts +130 -0
- package/dist/core/logger.js +370 -0
- package/dist/core/phone-auth/api-types.d.ts +525 -0
- package/dist/core/phone-auth/api-types.js +215 -0
- package/dist/core/phone-auth/client.d.ts +187 -0
- package/dist/core/phone-auth/client.js +1353 -0
- package/dist/core/phone-auth/error-utils.d.ts +110 -0
- package/dist/core/phone-auth/error-utils.js +350 -0
- package/dist/core/phone-auth/index.d.ts +7 -0
- package/dist/core/phone-auth/index.js +47 -0
- package/dist/core/phone-auth/status-types.d.ts +107 -0
- package/dist/core/phone-auth/status-types.js +31 -0
- package/dist/core/phone-auth/strategies/desktop.d.ts +113 -0
- package/dist/core/phone-auth/strategies/desktop.js +502 -0
- package/dist/core/phone-auth/strategies/index.d.ts +11 -0
- package/dist/core/phone-auth/strategies/index.js +15 -0
- package/dist/core/phone-auth/strategies/link.d.ts +81 -0
- package/dist/core/phone-auth/strategies/link.js +265 -0
- package/dist/core/phone-auth/strategies/ts43.d.ts +32 -0
- package/dist/core/phone-auth/strategies/ts43.js +146 -0
- package/dist/core/phone-auth/strategies/types.d.ts +18 -0
- package/dist/core/phone-auth/strategies/types.js +6 -0
- package/dist/core/phone-auth/type-guards.d.ts +125 -0
- package/dist/core/phone-auth/type-guards.js +160 -0
- package/dist/core/phone-auth/types.d.ts +232 -0
- package/dist/core/phone-auth/types.js +93 -0
- package/dist/core/phone-auth/ui/mobile-debug-console.d.ts +25 -0
- package/dist/core/phone-auth/ui/mobile-debug-console.js +288 -0
- package/dist/core/phone-auth/ui/modal.d.ts +84 -0
- package/dist/core/phone-auth/ui/modal.js +574 -0
- package/dist/core/phone-auth/validation-utils.d.ts +66 -0
- package/dist/core/phone-auth/validation-utils.js +182 -0
- package/dist/core/types.d.ts +62 -0
- package/dist/core/types.js +2 -0
- package/dist/core/version.d.ts +1 -0
- package/dist/core/version.js +5 -0
- package/dist/esm/adapters/angular/client.service.d.ts +7 -0
- package/dist/esm/adapters/angular/client.service.js +27 -0
- package/dist/esm/adapters/angular/index.d.ts +3 -0
- package/dist/esm/adapters/angular/index.js +4 -0
- package/dist/esm/adapters/angular/phone-auth.service.d.ts +38 -0
- package/dist/esm/adapters/angular/phone-auth.service.js +127 -0
- package/dist/esm/adapters/react/index.d.ts +9 -0
- package/dist/esm/adapters/react/index.js +8 -0
- package/dist/esm/adapters/react/useClient.d.ts +26 -0
- package/dist/esm/adapters/react/useClient.js +116 -0
- package/dist/esm/adapters/react/usePhoneAuth.d.ts +23 -0
- package/dist/esm/adapters/react/usePhoneAuth.js +92 -0
- package/dist/esm/adapters/vanilla/client.d.ts +8 -0
- package/dist/esm/adapters/vanilla/client.js +29 -0
- package/dist/esm/adapters/vanilla/index.d.ts +3 -0
- package/dist/esm/adapters/vanilla/index.js +4 -0
- package/dist/esm/adapters/vanilla/phone-auth.d.ts +46 -0
- package/dist/esm/adapters/vanilla/phone-auth.js +134 -0
- package/dist/esm/adapters/vue/index.d.ts +10 -0
- package/dist/esm/adapters/vue/index.js +11 -0
- package/dist/esm/adapters/vue/useClient.d.ts +115 -0
- package/dist/esm/adapters/vue/useClient.js +127 -0
- package/dist/esm/adapters/vue/usePhoneAuth.d.ts +94 -0
- package/dist/esm/adapters/vue/usePhoneAuth.js +100 -0
- package/dist/esm/browser.d.ts +7 -0
- package/dist/esm/browser.js +11 -0
- package/dist/esm/core/client.d.ts +22 -0
- package/dist/esm/core/client.js +70 -0
- package/dist/esm/core/logger.d.ts +130 -0
- package/dist/esm/core/logger.js +359 -0
- package/dist/esm/core/phone-auth/api-types.d.ts +525 -0
- package/dist/esm/core/phone-auth/api-types.js +203 -0
- package/dist/esm/core/phone-auth/client.d.ts +187 -0
- package/dist/esm/core/phone-auth/client.js +1316 -0
- package/dist/esm/core/phone-auth/error-utils.d.ts +110 -0
- package/dist/esm/core/phone-auth/error-utils.js +338 -0
- package/dist/esm/core/phone-auth/index.d.ts +7 -0
- package/dist/esm/core/phone-auth/index.js +6 -0
- package/dist/esm/core/phone-auth/status-types.d.ts +107 -0
- package/dist/esm/core/phone-auth/status-types.js +26 -0
- package/dist/esm/core/phone-auth/strategies/desktop.d.ts +113 -0
- package/dist/esm/core/phone-auth/strategies/desktop.js +496 -0
- package/dist/esm/core/phone-auth/strategies/index.d.ts +11 -0
- package/dist/esm/core/phone-auth/strategies/index.js +7 -0
- package/dist/esm/core/phone-auth/strategies/link.d.ts +81 -0
- package/dist/esm/core/phone-auth/strategies/link.js +261 -0
- package/dist/esm/core/phone-auth/strategies/ts43.d.ts +32 -0
- package/dist/esm/core/phone-auth/strategies/ts43.js +142 -0
- package/dist/esm/core/phone-auth/strategies/types.d.ts +18 -0
- package/dist/esm/core/phone-auth/strategies/types.js +5 -0
- package/dist/esm/core/phone-auth/type-guards.d.ts +125 -0
- package/dist/esm/core/phone-auth/type-guards.js +150 -0
- package/dist/esm/core/phone-auth/types.d.ts +232 -0
- package/dist/esm/core/phone-auth/types.js +76 -0
- package/dist/esm/core/phone-auth/ui/mobile-debug-console.d.ts +25 -0
- package/dist/esm/core/phone-auth/ui/mobile-debug-console.js +284 -0
- package/dist/esm/core/phone-auth/ui/modal.d.ts +84 -0
- package/dist/esm/core/phone-auth/ui/modal.js +570 -0
- package/dist/esm/core/phone-auth/validation-utils.d.ts +66 -0
- package/dist/esm/core/phone-auth/validation-utils.js +174 -0
- package/dist/esm/core/types.d.ts +62 -0
- package/dist/esm/core/types.js +1 -0
- package/dist/esm/core/version.d.ts +1 -0
- package/dist/esm/core/version.js +2 -0
- package/dist/esm/index.d.ts +12 -0
- package/dist/esm/index.js +15 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +52 -0
- package/package.json +92 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { AuthConfig, PhoneAuthResult, AuthError, AuthStep, PhoneAuthOptions } from '../../core/phone-auth';
|
|
2
|
+
export interface PhoneAuthState {
|
|
3
|
+
isLoading: boolean;
|
|
4
|
+
error: AuthError | null;
|
|
5
|
+
result: PhoneAuthResult | null;
|
|
6
|
+
currentStep: AuthStep;
|
|
7
|
+
isSupported: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare class PhoneAuthManager {
|
|
10
|
+
private client;
|
|
11
|
+
private state;
|
|
12
|
+
private listeners;
|
|
13
|
+
constructor(config?: AuthConfig);
|
|
14
|
+
/**
|
|
15
|
+
* Get current state
|
|
16
|
+
*/
|
|
17
|
+
getState(): PhoneAuthState;
|
|
18
|
+
/**
|
|
19
|
+
* Subscribe to state changes
|
|
20
|
+
*/
|
|
21
|
+
subscribe(listener: (state: PhoneAuthState) => void): () => void;
|
|
22
|
+
/**
|
|
23
|
+
* Update state and notify listeners
|
|
24
|
+
*/
|
|
25
|
+
private updateState;
|
|
26
|
+
/**
|
|
27
|
+
* Verify phone number
|
|
28
|
+
*/
|
|
29
|
+
verify(options: PhoneAuthOptions): Promise<PhoneAuthResult>;
|
|
30
|
+
/**
|
|
31
|
+
* Get phone number
|
|
32
|
+
*/
|
|
33
|
+
getPhoneNumber(options?: Omit<PhoneAuthOptions, 'use_case' | 'phone_number'>): Promise<PhoneAuthResult>;
|
|
34
|
+
/**
|
|
35
|
+
* Verify specific phone number
|
|
36
|
+
*/
|
|
37
|
+
verifyPhoneNumber(phoneNumber: string, options?: Omit<PhoneAuthOptions, 'use_case' | 'phone_number'>): Promise<PhoneAuthResult>;
|
|
38
|
+
/**
|
|
39
|
+
* Reset state
|
|
40
|
+
*/
|
|
41
|
+
reset(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Check if browser supports secure phone authentication
|
|
44
|
+
*/
|
|
45
|
+
isSupported(): boolean;
|
|
46
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PhoneAuthManager = void 0;
|
|
13
|
+
const phone_auth_1 = require("../../core/phone-auth");
|
|
14
|
+
class PhoneAuthManager {
|
|
15
|
+
constructor(config = {}) {
|
|
16
|
+
this.listeners = [];
|
|
17
|
+
this.client = new phone_auth_1.PhoneAuthClient(config);
|
|
18
|
+
this.state = {
|
|
19
|
+
isLoading: false,
|
|
20
|
+
error: null,
|
|
21
|
+
result: null,
|
|
22
|
+
currentStep: 'idle',
|
|
23
|
+
isSupported: this.client.isSupported()
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Get current state
|
|
28
|
+
*/
|
|
29
|
+
getState() {
|
|
30
|
+
return Object.assign({}, this.state);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Subscribe to state changes
|
|
34
|
+
*/
|
|
35
|
+
subscribe(listener) {
|
|
36
|
+
this.listeners.push(listener);
|
|
37
|
+
// Return unsubscribe function
|
|
38
|
+
return () => {
|
|
39
|
+
const index = this.listeners.indexOf(listener);
|
|
40
|
+
if (index !== -1) {
|
|
41
|
+
this.listeners.splice(index, 1);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Update state and notify listeners
|
|
47
|
+
*/
|
|
48
|
+
updateState(updates) {
|
|
49
|
+
this.state = Object.assign(Object.assign({}, this.state), updates);
|
|
50
|
+
this.listeners.forEach(listener => listener(this.getState()));
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Verify phone number
|
|
54
|
+
*/
|
|
55
|
+
verify(options) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
this.updateState({
|
|
58
|
+
isLoading: true,
|
|
59
|
+
error: null,
|
|
60
|
+
result: null,
|
|
61
|
+
currentStep: 'requesting'
|
|
62
|
+
});
|
|
63
|
+
try {
|
|
64
|
+
// Step 1: Prepare request
|
|
65
|
+
const preparedRequest = yield this.client.preparePhoneRequest(options);
|
|
66
|
+
// Step 2: Show authenticating state
|
|
67
|
+
this.updateState({ currentStep: 'authenticating' });
|
|
68
|
+
const credentialResponse = yield this.client.invokeSecurePrompt(preparedRequest);
|
|
69
|
+
// Step 3: Process response through appropriate endpoint
|
|
70
|
+
this.updateState({ currentStep: 'processing' });
|
|
71
|
+
// Cast to credential type - adapters never use headless mode
|
|
72
|
+
const credential = credentialResponse;
|
|
73
|
+
const processedResult = options.use_case === 'GetPhoneNumber'
|
|
74
|
+
? yield this.client.getPhoneNumber(credential, preparedRequest.session)
|
|
75
|
+
: yield this.client.verifyPhoneNumber(credential, preparedRequest.session);
|
|
76
|
+
// Create final result
|
|
77
|
+
const isVerifyResponse = 'verified' in processedResult;
|
|
78
|
+
const result = processedResult;
|
|
79
|
+
this.updateState({
|
|
80
|
+
result,
|
|
81
|
+
currentStep: 'complete',
|
|
82
|
+
isLoading: false
|
|
83
|
+
});
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
// Enhance error with context
|
|
88
|
+
const authError = error;
|
|
89
|
+
const enhancedError = Object.assign(Object.assign({}, authError), { context: authError.context || {
|
|
90
|
+
useCase: options.use_case,
|
|
91
|
+
timestamp: new Date().toISOString(),
|
|
92
|
+
userAgent: typeof navigator !== 'undefined' ? navigator.userAgent : undefined,
|
|
93
|
+
url: typeof window !== 'undefined' ? window.location.href : undefined
|
|
94
|
+
} });
|
|
95
|
+
this.updateState({
|
|
96
|
+
error: enhancedError,
|
|
97
|
+
currentStep: 'idle',
|
|
98
|
+
isLoading: false
|
|
99
|
+
});
|
|
100
|
+
throw enhancedError;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Get phone number
|
|
106
|
+
*/
|
|
107
|
+
getPhoneNumber(options) {
|
|
108
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
+
return this.verify(Object.assign({ use_case: 'GetPhoneNumber' }, options));
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Verify specific phone number
|
|
114
|
+
*/
|
|
115
|
+
verifyPhoneNumber(phoneNumber, options) {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
return this.verify(Object.assign({ use_case: 'VerifyPhoneNumber', phone_number: phoneNumber }, options));
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Reset state
|
|
122
|
+
*/
|
|
123
|
+
reset() {
|
|
124
|
+
this.updateState({
|
|
125
|
+
isLoading: false,
|
|
126
|
+
error: null,
|
|
127
|
+
result: null,
|
|
128
|
+
currentStep: 'idle'
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Check if browser supports secure phone authentication
|
|
133
|
+
*/
|
|
134
|
+
isSupported() {
|
|
135
|
+
return this.state.isSupported;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
exports.PhoneAuthManager = PhoneAuthManager;
|
|
@@ -0,0 +1,10 @@
|
|
|
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, ConsentData, 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';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ERROR_STATUS_CODES = exports.ERROR_MESSAGES = exports.ERROR_CODE = exports.USE_CASE = exports.BrowserName = exports.BrowserErrorCode = exports.BrowserError = exports.AuthenticationStrategy = exports.UseCase = exports.createErrorBreadcrumb = exports.serializeError = exports.isRetryableError = exports.getRetryDelay = exports.isErrorCode = exports.getUserMessage = exports.isUserError = exports.isPhoneAuthError = exports.PhoneAuthErrorCode = exports.PhoneAuthClient = exports.SDKClient = exports.useClient = exports.usePhoneAuth = void 0;
|
|
4
|
+
var usePhoneAuth_1 = require("./usePhoneAuth");
|
|
5
|
+
Object.defineProperty(exports, "usePhoneAuth", { enumerable: true, get: function () { return usePhoneAuth_1.usePhoneAuth; } });
|
|
6
|
+
var useClient_1 = require("./useClient");
|
|
7
|
+
Object.defineProperty(exports, "useClient", { enumerable: true, get: function () { return useClient_1.useClient; } });
|
|
8
|
+
var client_1 = require("../../core/client");
|
|
9
|
+
Object.defineProperty(exports, "SDKClient", { enumerable: true, get: function () { return client_1.SDKClient; } });
|
|
10
|
+
var phone_auth_1 = require("../../core/phone-auth");
|
|
11
|
+
Object.defineProperty(exports, "PhoneAuthClient", { enumerable: true, get: function () { return phone_auth_1.PhoneAuthClient; } });
|
|
12
|
+
// API response types are already exported via core/phone-auth/types
|
|
13
|
+
// Export error utilities
|
|
14
|
+
var phone_auth_2 = require("../../core/phone-auth");
|
|
15
|
+
Object.defineProperty(exports, "PhoneAuthErrorCode", { enumerable: true, get: function () { return phone_auth_2.PhoneAuthErrorCode; } });
|
|
16
|
+
Object.defineProperty(exports, "isPhoneAuthError", { enumerable: true, get: function () { return phone_auth_2.isPhoneAuthError; } });
|
|
17
|
+
Object.defineProperty(exports, "isUserError", { enumerable: true, get: function () { return phone_auth_2.isUserError; } });
|
|
18
|
+
Object.defineProperty(exports, "getUserMessage", { enumerable: true, get: function () { return phone_auth_2.getUserMessage; } });
|
|
19
|
+
Object.defineProperty(exports, "isErrorCode", { enumerable: true, get: function () { return phone_auth_2.isErrorCode; } });
|
|
20
|
+
Object.defineProperty(exports, "getRetryDelay", { enumerable: true, get: function () { return phone_auth_2.getRetryDelay; } });
|
|
21
|
+
Object.defineProperty(exports, "isRetryableError", { enumerable: true, get: function () { return phone_auth_2.isRetryableError; } });
|
|
22
|
+
Object.defineProperty(exports, "serializeError", { enumerable: true, get: function () { return phone_auth_2.serializeError; } });
|
|
23
|
+
Object.defineProperty(exports, "createErrorBreadcrumb", { enumerable: true, get: function () { return phone_auth_2.createErrorBreadcrumb; } });
|
|
24
|
+
// Export constants for use case and strategy
|
|
25
|
+
var types_1 = require("../../core/phone-auth/types");
|
|
26
|
+
Object.defineProperty(exports, "UseCase", { enumerable: true, get: function () { return types_1.USE_CASE; } });
|
|
27
|
+
Object.defineProperty(exports, "AuthenticationStrategy", { enumerable: true, get: function () { return types_1.AUTHENTICATION_STRATEGY; } });
|
|
28
|
+
Object.defineProperty(exports, "BrowserError", { enumerable: true, get: function () { return types_1.BrowserError; } });
|
|
29
|
+
Object.defineProperty(exports, "BrowserErrorCode", { enumerable: true, get: function () { return types_1.BrowserErrorCode; } });
|
|
30
|
+
Object.defineProperty(exports, "BrowserName", { enumerable: true, get: function () { return types_1.BrowserName; } });
|
|
31
|
+
// Export API constants from api-types
|
|
32
|
+
var api_types_1 = require("../../core/phone-auth/api-types");
|
|
33
|
+
Object.defineProperty(exports, "USE_CASE", { enumerable: true, get: function () { return api_types_1.USE_CASE; } });
|
|
34
|
+
Object.defineProperty(exports, "ERROR_CODE", { enumerable: true, get: function () { return api_types_1.ERROR_CODE; } });
|
|
35
|
+
Object.defineProperty(exports, "ERROR_MESSAGES", { enumerable: true, get: function () { return api_types_1.ERROR_MESSAGES; } });
|
|
36
|
+
Object.defineProperty(exports, "ERROR_STATUS_CODES", { enumerable: true, get: function () { return api_types_1.ERROR_STATUS_CODES; } });
|
|
@@ -0,0 +1,115 @@
|
|
|
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").SecureCredentialResponse["vp_token"] | import("../../core/phone-auth").HeadlessResult>;
|
|
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").SecureCredentialResponse["vp_token"] | import("../../core/phone-auth").HeadlessResult>>[0]) => Promise<{
|
|
111
|
+
[aggregator_id: string]: string | string[];
|
|
112
|
+
} | import("../../core/phone-auth").HeadlessResult>;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
export declare const useVueClient: typeof useClient;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.useVueClient = void 0;
|
|
13
|
+
exports.useClient = useClient;
|
|
14
|
+
const vue_1 = require("vue");
|
|
15
|
+
const client_1 = require("../../core/client");
|
|
16
|
+
function useClient(config) {
|
|
17
|
+
const client = (0, vue_1.ref)(new client_1.SDKClient(config));
|
|
18
|
+
return {
|
|
19
|
+
client: client.value,
|
|
20
|
+
useQuery: (path) => {
|
|
21
|
+
const data = (0, vue_1.ref)(null);
|
|
22
|
+
const loading = (0, vue_1.ref)(true);
|
|
23
|
+
const error = (0, vue_1.ref)(null);
|
|
24
|
+
const fetchData = () => __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
try {
|
|
26
|
+
const response = yield client.value.get(path);
|
|
27
|
+
data.value = response.data;
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
error.value = err;
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
loading.value = false;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
fetchData();
|
|
37
|
+
return { data, loading, error, refetch: fetchData };
|
|
38
|
+
},
|
|
39
|
+
useAuth: (options = {}) => {
|
|
40
|
+
const token = (0, vue_1.ref)(null);
|
|
41
|
+
const loading = (0, vue_1.ref)(false);
|
|
42
|
+
const error = (0, vue_1.ref)(null);
|
|
43
|
+
let cleanup = null;
|
|
44
|
+
const authenticate = (authUrl) => __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
loading.value = true;
|
|
46
|
+
error.value = null;
|
|
47
|
+
// Clean up previous authentication if exists
|
|
48
|
+
if (cleanup) {
|
|
49
|
+
cleanup();
|
|
50
|
+
cleanup = null;
|
|
51
|
+
}
|
|
52
|
+
// Legacy authentication removed - use setToken directly
|
|
53
|
+
error.value = new Error('authenticate method is deprecated. Use client.setToken() directly.');
|
|
54
|
+
loading.value = false;
|
|
55
|
+
throw error.value;
|
|
56
|
+
});
|
|
57
|
+
// Cleanup on component unmount
|
|
58
|
+
(0, vue_1.onUnmounted)(() => {
|
|
59
|
+
if (cleanup) {
|
|
60
|
+
cleanup();
|
|
61
|
+
cleanup = null;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return {
|
|
65
|
+
token,
|
|
66
|
+
loading,
|
|
67
|
+
error,
|
|
68
|
+
authenticate
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
usePhoneAuth: () => {
|
|
72
|
+
const result = (0, vue_1.ref)(null);
|
|
73
|
+
const loading = (0, vue_1.ref)(false);
|
|
74
|
+
const error = (0, vue_1.ref)(null);
|
|
75
|
+
const isSupported = (0, vue_1.ref)(client.value.phoneAuth.isSupported());
|
|
76
|
+
const getPhoneNumber = (options) => __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
loading.value = true;
|
|
78
|
+
error.value = null;
|
|
79
|
+
result.value = null;
|
|
80
|
+
try {
|
|
81
|
+
const res = yield client.value.phoneAuth.getPhoneNumberComplete(options);
|
|
82
|
+
result.value = res;
|
|
83
|
+
return res;
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
error.value = err;
|
|
87
|
+
throw err;
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
loading.value = false;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
const verifyPhoneNumber = (phoneNumber, options) => __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
loading.value = true;
|
|
95
|
+
error.value = null;
|
|
96
|
+
result.value = null;
|
|
97
|
+
try {
|
|
98
|
+
const res = yield client.value.phoneAuth.verifyPhoneNumberComplete(phoneNumber, options);
|
|
99
|
+
result.value = res;
|
|
100
|
+
return res;
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
error.value = err;
|
|
104
|
+
throw err;
|
|
105
|
+
}
|
|
106
|
+
finally {
|
|
107
|
+
loading.value = false;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
// Low-level methods for advanced control
|
|
111
|
+
const preparePhoneRequest = (options) => __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
return client.value.phoneAuth.preparePhoneRequest(options);
|
|
113
|
+
});
|
|
114
|
+
const invokeSecurePrompt = (request) => __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
return client.value.phoneAuth.invokeSecurePrompt(request);
|
|
116
|
+
});
|
|
117
|
+
return {
|
|
118
|
+
result,
|
|
119
|
+
loading,
|
|
120
|
+
error,
|
|
121
|
+
isSupported,
|
|
122
|
+
getPhoneNumber,
|
|
123
|
+
verifyPhoneNumber,
|
|
124
|
+
// Low-level API for advanced usage
|
|
125
|
+
preparePhoneRequest,
|
|
126
|
+
invokeSecurePrompt
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
exports.useVueClient = useClient;
|
|
@@ -0,0 +1,94 @@
|
|
|
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.SecureCredentialResponse["vp_token"] | API.HeadlessResult>;
|
|
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
|
+
};
|