@glideidentity/web-client-sdk 4.4.9 → 5.0.0
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 +59 -11
- package/dist/adapters/react/index.d.ts +1 -1
- package/dist/adapters/vue/index.d.ts +1 -1
- package/dist/browser/web-client-sdk.min.js +1 -1
- package/dist/browser/web-client-sdk.min.js.LICENSE.txt +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/core/phone-auth/api-types.d.ts +3 -15
- package/dist/core/phone-auth/client.js +32 -72
- package/dist/core/phone-auth/index.d.ts +1 -1
- package/dist/core/phone-auth/index.js +1 -2
- package/dist/core/phone-auth/validation-utils.d.ts +0 -13
- package/dist/core/phone-auth/validation-utils.js +0 -41
- package/dist/core/version.js +1 -1
- package/dist/esm/adapters/react/index.d.ts +1 -1
- package/dist/esm/adapters/vue/index.d.ts +1 -1
- package/dist/esm/browser.d.ts +1 -1
- package/dist/esm/core/phone-auth/api-types.d.ts +3 -15
- package/dist/esm/core/phone-auth/client.js +33 -73
- package/dist/esm/core/phone-auth/index.d.ts +1 -1
- package/dist/esm/core/phone-auth/index.js +1 -1
- package/dist/esm/core/phone-auth/validation-utils.d.ts +0 -13
- package/dist/esm/core/phone-auth/validation-utils.js +0 -40
- package/dist/esm/core/version.js +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
/*! Axios v1.
|
|
1
|
+
/*! Axios v1.13.2 Copyright (c) 2025 Matt Zabriskie and contributors */
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { PhoneAuthClient } from './core/phone-auth';
|
|
2
2
|
export type { AuthConfig as PhoneAuthConfig, PhoneAuthOptions, PhoneAuthResult, AuthError as PhoneAuthError, AuthStep as PhoneAuthStep } from './core/phone-auth';
|
|
3
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,
|
|
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
5
|
export { USE_CASE as UseCase, AUTHENTICATION_STRATEGY as AuthenticationStrategy, BrowserError, BrowserErrorCode, BrowserName } from './core/phone-auth/types';
|
|
6
6
|
export { VanillaClient as ClientManager } from './adapters/vanilla/client';
|
|
7
7
|
export { PhoneAuthManager } from './adapters/vanilla/phone-auth';
|
|
@@ -40,17 +40,6 @@ export interface PLMN {
|
|
|
40
40
|
/** Mobile Network Code (2-3 digits) */
|
|
41
41
|
mnc: string;
|
|
42
42
|
}
|
|
43
|
-
/**
|
|
44
|
-
* User consent information for privacy compliance
|
|
45
|
-
*/
|
|
46
|
-
export interface ConsentData {
|
|
47
|
-
/** What the user is consenting to */
|
|
48
|
-
consent_text: string;
|
|
49
|
-
/** URL to privacy policy */
|
|
50
|
-
policy_link: string;
|
|
51
|
-
/** Brief policy description */
|
|
52
|
-
policy_text: string;
|
|
53
|
-
}
|
|
54
43
|
/**
|
|
55
44
|
* Browser/client information for strategy selection
|
|
56
45
|
*/
|
|
@@ -109,8 +98,6 @@ export interface PrepareRequest {
|
|
|
109
98
|
/** Request identifier (SDK generates unique ID if not provided) */
|
|
110
99
|
id?: string;
|
|
111
100
|
/** Optional fields */
|
|
112
|
-
/** User consent information */
|
|
113
|
-
consent_data?: ConsentData;
|
|
114
101
|
/** Client information for strategy selection */
|
|
115
102
|
client_info?: ClientInfo;
|
|
116
103
|
/** Advanced options for special features */
|
|
@@ -513,7 +500,8 @@ export interface ExtendedResponse {
|
|
|
513
500
|
cancel: () => void;
|
|
514
501
|
}
|
|
515
502
|
/**
|
|
516
|
-
* Extended response for Desktop strategy
|
|
503
|
+
* Extended response for Desktop strategy.
|
|
504
|
+
* Note: Polling starts immediately even with preventDefaultUI: true (consistent with Link strategy)
|
|
517
505
|
*/
|
|
518
506
|
export interface DesktopExtendedResponse extends ExtendedResponse {
|
|
519
507
|
strategy: 'desktop';
|
|
@@ -528,7 +516,7 @@ export interface DesktopExtendedResponse extends ExtendedResponse {
|
|
|
528
516
|
/** Challenge pattern */
|
|
529
517
|
challenge?: any;
|
|
530
518
|
};
|
|
531
|
-
/**
|
|
519
|
+
/** Returns the existing polling promise (polling starts immediately) */
|
|
532
520
|
start_polling: () => Promise<AuthCredential>;
|
|
533
521
|
/** Stop polling */
|
|
534
522
|
stop_polling: () => void;
|
|
@@ -333,13 +333,6 @@ class PhoneAuthClient {
|
|
|
333
333
|
throw this.createError(error_utils_1.PhoneAuthErrorCode.BAD_REQUEST, plmnValidation.error, { field: 'plmn' });
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
|
-
// Validate consent data if provided
|
|
337
|
-
if (options.consent_data) {
|
|
338
|
-
const consentValidation = (0, validation_utils_1.validateConsentData)(options.consent_data);
|
|
339
|
-
if (!consentValidation.valid) {
|
|
340
|
-
throw this.createError(error_utils_1.PhoneAuthErrorCode.BAD_REQUEST, consentValidation.error, { field: 'consent_data' });
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
336
|
// Validate use_case is provided (unless only parent_session_id is given)
|
|
344
337
|
if (!options.use_case && !(((_a = options.options) === null || _a === void 0 ? void 0 : _a.parent_session_id) && !options.phone_number && !options.plmn)) {
|
|
345
338
|
throw this.createError(error_utils_1.PhoneAuthErrorCode.MISSING_PARAMETERS, 'use_case is required', { field: 'use_case' });
|
|
@@ -391,7 +384,6 @@ class PhoneAuthClient {
|
|
|
391
384
|
nonce: nonce,
|
|
392
385
|
id: requestId,
|
|
393
386
|
// Optional fields
|
|
394
|
-
consent_data: options.consent_data,
|
|
395
387
|
client_info: {
|
|
396
388
|
user_agent: navigator.userAgent,
|
|
397
389
|
platform: navigator.platform
|
|
@@ -531,19 +523,13 @@ class PhoneAuthClient {
|
|
|
531
523
|
console.log('[PhoneAuth] Session cache size:', this.sessionCache.size);
|
|
532
524
|
console.log('[PhoneAuth] Retry count:', this.retryCount);
|
|
533
525
|
console.log('[PhoneAuth] PrepareResponse received:', JSON.stringify(plainResponse, null, 2));
|
|
534
|
-
//
|
|
535
|
-
//
|
|
536
|
-
const
|
|
537
|
-
|
|
538
|
-
'theme' in options ||
|
|
539
|
-
'modalOptions' in options ||
|
|
540
|
-
'callbacks' in options) ? options : undefined;
|
|
541
|
-
// Get configuration from options
|
|
526
|
+
// Treat options as InvokeOptions (the modern format)
|
|
527
|
+
// Legacy DesktopAuthOptions properties will still work through property access
|
|
528
|
+
const opts = options;
|
|
529
|
+
// Get configuration from options - access properties directly
|
|
542
530
|
const strategy = plainResponse.authentication_strategy;
|
|
543
|
-
const preventDefaultUI = (_a =
|
|
544
|
-
const executionMode = (_b =
|
|
545
|
-
// DesktopAuthOptions is only used if not InvokeOptions
|
|
546
|
-
const desktopOptions = options && !invokeOptions ? options : undefined;
|
|
531
|
+
const preventDefaultUI = (_a = opts === null || opts === void 0 ? void 0 : opts.preventDefaultUI) !== null && _a !== void 0 ? _a : false;
|
|
532
|
+
const executionMode = (_b = opts === null || opts === void 0 ? void 0 : opts.executionMode) !== null && _b !== void 0 ? _b : 'standard';
|
|
547
533
|
// Handle based on authentication strategy
|
|
548
534
|
if (plainResponse.authentication_strategy === API.AUTHENTICATION_STRATEGY.TS43) {
|
|
549
535
|
// Check browser support for TS43 strategy which requires Digital Credentials API
|
|
@@ -665,14 +651,14 @@ class PhoneAuthClient {
|
|
|
665
651
|
var _a, _b;
|
|
666
652
|
try {
|
|
667
653
|
const result = yield triggerTS43();
|
|
668
|
-
(_a =
|
|
654
|
+
(_a = opts === null || opts === void 0 ? void 0 : opts.onTriggerAttempt) === null || _a === void 0 ? void 0 : _a.call(opts, {
|
|
669
655
|
strategy: API.AUTHENTICATION_STRATEGY.TS43,
|
|
670
656
|
success: true
|
|
671
657
|
});
|
|
672
658
|
return result;
|
|
673
659
|
}
|
|
674
660
|
catch (error) {
|
|
675
|
-
(_b =
|
|
661
|
+
(_b = opts === null || opts === void 0 ? void 0 : opts.onTriggerAttempt) === null || _b === void 0 ? void 0 : _b.call(opts, {
|
|
676
662
|
strategy: API.AUTHENTICATION_STRATEGY.TS43,
|
|
677
663
|
success: false,
|
|
678
664
|
error
|
|
@@ -763,11 +749,10 @@ class PhoneAuthClient {
|
|
|
763
749
|
qr_code: ((_k = desktopData.data) === null || _k === void 0 ? void 0 : _k.qr_code_image) || desktopData.qr_code_image || desktopData.qr_code,
|
|
764
750
|
challenge: (_l = desktopData.data) === null || _l === void 0 ? void 0 : _l.challenge
|
|
765
751
|
};
|
|
766
|
-
// Polling options
|
|
767
|
-
const pollingEndpointToUse = (
|
|
768
|
-
(desktopOptions === null || desktopOptions === void 0 ? void 0 : desktopOptions.pollingEndpoint) ||
|
|
752
|
+
// Polling options - gather from any options format
|
|
753
|
+
const pollingEndpointToUse = (opts === null || opts === void 0 ? void 0 : opts.pollingEndpoint) ||
|
|
769
754
|
((_m = this.config.endpoints) === null || _m === void 0 ? void 0 : _m.polling);
|
|
770
|
-
const pollingOptions = Object.assign(Object.assign({},
|
|
755
|
+
const pollingOptions = Object.assign(Object.assign({}, opts), { pollingEndpoint: pollingEndpointToUse, pollingInterval: (opts === null || opts === void 0 ? void 0 : opts.pollingInterval) || this.config.pollingInterval || 2000, maxPollingAttempts: (opts === null || opts === void 0 ? void 0 : opts.maxPollingAttempts) || this.config.maxPollingAttempts || 30, onQRCodeReady: undefined, onStatusUpdate: undefined });
|
|
771
756
|
// Decide whether to show modal based on preventDefaultUI
|
|
772
757
|
const showModal = !preventDefaultUI;
|
|
773
758
|
let modal;
|
|
@@ -776,13 +761,12 @@ class PhoneAuthClient {
|
|
|
776
761
|
preventDefaultUI,
|
|
777
762
|
showModal,
|
|
778
763
|
executionMode,
|
|
779
|
-
|
|
780
|
-
hasDesktopOptions: !!desktopOptions
|
|
764
|
+
hasOptions: !!opts
|
|
781
765
|
});
|
|
782
766
|
if (showModal) {
|
|
783
767
|
console.log('[Desktop] Creating modal with QR data:', qrCodeData);
|
|
784
768
|
// Create and setup modal
|
|
785
|
-
modal = new modal_1.AuthModal(
|
|
769
|
+
modal = new modal_1.AuthModal(opts === null || opts === void 0 ? void 0 : opts.modalOptions, opts === null || opts === void 0 ? void 0 : opts.callbacks);
|
|
786
770
|
modal.setCloseCallback(() => {
|
|
787
771
|
this.log('Desktop QR modal closed by user, cancelling polling');
|
|
788
772
|
handler.cancel();
|
|
@@ -830,41 +814,20 @@ class PhoneAuthClient {
|
|
|
830
814
|
// Handle based on execution mode
|
|
831
815
|
if (executionMode === 'extended') {
|
|
832
816
|
// Extended mode - return control methods
|
|
833
|
-
|
|
834
|
-
let credentialReject = null;
|
|
835
|
-
let pollingStarted = false;
|
|
836
|
-
// Create a promise that will remain pending until polling starts
|
|
817
|
+
// Create a promise and always start polling immediately
|
|
837
818
|
const credentialPromise = new Promise((resolve, reject) => {
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
//
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
.then(resolve)
|
|
845
|
-
.catch(reject);
|
|
846
|
-
}
|
|
847
|
-
// Otherwise, promise remains pending until start_polling() is called
|
|
819
|
+
// Always start polling immediately in extended mode (consistent with Link)
|
|
820
|
+
// This prevents the "unresolved promise trap" where developers might await
|
|
821
|
+
// the credential before calling start_polling()
|
|
822
|
+
startPolling()
|
|
823
|
+
.then(resolve)
|
|
824
|
+
.catch(reject);
|
|
848
825
|
});
|
|
849
826
|
// Create wrapped functions
|
|
850
827
|
const wrappedStartPolling = () => __awaiter(this, void 0, void 0, function* () {
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
pollingStarted = true;
|
|
855
|
-
try {
|
|
856
|
-
const result = yield startPolling();
|
|
857
|
-
if (credentialResolve) {
|
|
858
|
-
credentialResolve(result);
|
|
859
|
-
}
|
|
860
|
-
return result;
|
|
861
|
-
}
|
|
862
|
-
catch (err) {
|
|
863
|
-
if (credentialReject) {
|
|
864
|
-
credentialReject(err);
|
|
865
|
-
}
|
|
866
|
-
throw err;
|
|
867
|
-
}
|
|
828
|
+
// Polling has already started automatically in extended mode
|
|
829
|
+
// This method just returns the existing credential promise for consistency
|
|
830
|
+
return credentialPromise;
|
|
868
831
|
});
|
|
869
832
|
const wrappedStopPolling = () => {
|
|
870
833
|
handler.cleanup();
|
|
@@ -876,10 +839,7 @@ class PhoneAuthClient {
|
|
|
876
839
|
handler.cleanup();
|
|
877
840
|
if (modal)
|
|
878
841
|
modal.close();
|
|
879
|
-
//
|
|
880
|
-
if (!pollingStarted && credentialReject) {
|
|
881
|
-
credentialReject(this.createError(error_utils_1.PhoneAuthErrorCode.USER_DENIED, 'Desktop authentication cancelled by user'));
|
|
882
|
-
}
|
|
842
|
+
// The credential promise will be rejected by the handler.cancel() call
|
|
883
843
|
};
|
|
884
844
|
// Create the response object with a getter for is_polling
|
|
885
845
|
const response = {
|
|
@@ -937,14 +897,14 @@ class PhoneAuthClient {
|
|
|
937
897
|
var _a, _b;
|
|
938
898
|
try {
|
|
939
899
|
window.open(linkData.url, '_blank');
|
|
940
|
-
(_a =
|
|
900
|
+
(_a = opts === null || opts === void 0 ? void 0 : opts.onTriggerAttempt) === null || _a === void 0 ? void 0 : _a.call(opts, {
|
|
941
901
|
strategy: API.AUTHENTICATION_STRATEGY.LINK,
|
|
942
902
|
url: linkData.url,
|
|
943
903
|
success: true
|
|
944
904
|
});
|
|
945
905
|
}
|
|
946
906
|
catch (error) {
|
|
947
|
-
(_b =
|
|
907
|
+
(_b = opts === null || opts === void 0 ? void 0 : opts.onTriggerAttempt) === null || _b === void 0 ? void 0 : _b.call(opts, {
|
|
948
908
|
strategy: API.AUTHENTICATION_STRATEGY.LINK,
|
|
949
909
|
url: linkData.url,
|
|
950
910
|
success: false,
|
|
@@ -954,19 +914,19 @@ class PhoneAuthClient {
|
|
|
954
914
|
};
|
|
955
915
|
// Link always auto-opens the app (no SDK UI by default)
|
|
956
916
|
// Open immediately to preserve user gesture context
|
|
957
|
-
if ((
|
|
917
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.autoTrigger) !== false) {
|
|
958
918
|
triggerLink();
|
|
959
919
|
}
|
|
960
920
|
// Start polling in the background
|
|
961
921
|
console.log('[PhoneAuth Client] Link polling config:', {
|
|
962
|
-
|
|
922
|
+
fromOptions: opts === null || opts === void 0 ? void 0 : opts.pollingEndpoint,
|
|
963
923
|
fromClientConfig: (_o = this.config.endpoints) === null || _o === void 0 ? void 0 : _o.polling,
|
|
964
|
-
finalPollingEndpoint: (
|
|
924
|
+
finalPollingEndpoint: (opts === null || opts === void 0 ? void 0 : opts.pollingEndpoint) || ((_p = this.config.endpoints) === null || _p === void 0 ? void 0 : _p.polling)
|
|
965
925
|
});
|
|
966
926
|
const pollingOptions = {
|
|
967
|
-
pollingEndpoint: (
|
|
968
|
-
pollingInterval: (
|
|
969
|
-
maxPollingAttempts: (
|
|
927
|
+
pollingEndpoint: (opts === null || opts === void 0 ? void 0 : opts.pollingEndpoint) || ((_q = this.config.endpoints) === null || _q === void 0 ? void 0 : _q.polling),
|
|
928
|
+
pollingInterval: (opts === null || opts === void 0 ? void 0 : opts.pollingInterval) || this.config.pollingInterval || 2000,
|
|
929
|
+
maxPollingAttempts: (opts === null || opts === void 0 ? void 0 : opts.maxPollingAttempts) || this.config.maxPollingAttempts || 30,
|
|
970
930
|
onLinkOpened: undefined,
|
|
971
931
|
onStatusUpdate: undefined
|
|
972
932
|
};
|
|
@@ -2,6 +2,6 @@ export { PhoneAuthClient } from './client';
|
|
|
2
2
|
export * from './types';
|
|
3
3
|
export { PhoneAuthErrorCode, isPhoneAuthError, isUserError, getUserMessage, isErrorCode, getRetryDelay, isRetryableError, serializeError, createErrorBreadcrumb } from './error-utils';
|
|
4
4
|
export type { PhoneAuthErrorCode as PhoneAuthErrorCodeType } from './error-utils';
|
|
5
|
-
export { validatePhoneNumber, validatePlmn, validateUseCaseRequirements,
|
|
5
|
+
export { validatePhoneNumber, validatePlmn, validateUseCaseRequirements, validateNonce } from './validation-utils';
|
|
6
6
|
export { MobileDebugConsole } from './ui/mobile-debug-console';
|
|
7
7
|
export { isExtendedResponse, isCredential, isAuthCredential, isLinkStrategy, isTS43Strategy, isDesktopStrategy, getStrategy, hasPollingControls, hasTrigger, isHeadlessResult, requiresPolling, requiresUserAction } from './type-guards';
|
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.requiresUserAction = exports.requiresPolling = exports.isHeadlessResult = exports.hasTrigger = exports.hasPollingControls = exports.getStrategy = exports.isDesktopStrategy = exports.isTS43Strategy = exports.isLinkStrategy = exports.isAuthCredential = exports.isCredential = exports.isExtendedResponse = exports.MobileDebugConsole = exports.validateNonce = exports.
|
|
17
|
+
exports.requiresUserAction = exports.requiresPolling = exports.isHeadlessResult = exports.hasTrigger = exports.hasPollingControls = exports.getStrategy = exports.isDesktopStrategy = exports.isTS43Strategy = exports.isLinkStrategy = exports.isAuthCredential = exports.isCredential = exports.isExtendedResponse = exports.MobileDebugConsole = exports.validateNonce = exports.validateUseCaseRequirements = exports.validatePlmn = exports.validatePhoneNumber = exports.createErrorBreadcrumb = exports.serializeError = exports.isRetryableError = exports.getRetryDelay = exports.isErrorCode = exports.getUserMessage = exports.isUserError = exports.isPhoneAuthError = exports.PhoneAuthErrorCode = exports.PhoneAuthClient = void 0;
|
|
18
18
|
var client_1 = require("./client");
|
|
19
19
|
Object.defineProperty(exports, "PhoneAuthClient", { enumerable: true, get: function () { return client_1.PhoneAuthClient; } });
|
|
20
20
|
__exportStar(require("./types"), exports);
|
|
@@ -32,7 +32,6 @@ var validation_utils_1 = require("./validation-utils");
|
|
|
32
32
|
Object.defineProperty(exports, "validatePhoneNumber", { enumerable: true, get: function () { return validation_utils_1.validatePhoneNumber; } });
|
|
33
33
|
Object.defineProperty(exports, "validatePlmn", { enumerable: true, get: function () { return validation_utils_1.validatePlmn; } });
|
|
34
34
|
Object.defineProperty(exports, "validateUseCaseRequirements", { enumerable: true, get: function () { return validation_utils_1.validateUseCaseRequirements; } });
|
|
35
|
-
Object.defineProperty(exports, "validateConsentData", { enumerable: true, get: function () { return validation_utils_1.validateConsentData; } });
|
|
36
35
|
Object.defineProperty(exports, "validateNonce", { enumerable: true, get: function () { return validation_utils_1.validateNonce; } });
|
|
37
36
|
var mobile_debug_console_1 = require("./ui/mobile-debug-console");
|
|
38
37
|
Object.defineProperty(exports, "MobileDebugConsole", { enumerable: true, get: function () { return mobile_debug_console_1.MobileDebugConsole; } });
|
|
@@ -32,19 +32,6 @@ export declare function validateUseCaseRequirements(useCase: UseCase, phoneNumbe
|
|
|
32
32
|
valid: boolean;
|
|
33
33
|
error?: string;
|
|
34
34
|
};
|
|
35
|
-
/**
|
|
36
|
-
* Validates consent data
|
|
37
|
-
* @param consentData - Consent data object
|
|
38
|
-
* @returns Validation result
|
|
39
|
-
*/
|
|
40
|
-
export declare function validateConsentData(consentData?: {
|
|
41
|
-
consent_text: string;
|
|
42
|
-
policy_link: string;
|
|
43
|
-
policy_text: string;
|
|
44
|
-
}): {
|
|
45
|
-
valid: boolean;
|
|
46
|
-
error?: string;
|
|
47
|
-
};
|
|
48
35
|
/**
|
|
49
36
|
* Creates a validation error
|
|
50
37
|
* @param code - Error code
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.validatePhoneNumber = validatePhoneNumber;
|
|
7
7
|
exports.validatePlmn = validatePlmn;
|
|
8
8
|
exports.validateUseCaseRequirements = validateUseCaseRequirements;
|
|
9
|
-
exports.validateConsentData = validateConsentData;
|
|
10
9
|
exports.createValidationError = createValidationError;
|
|
11
10
|
exports.validateNonce = validateNonce;
|
|
12
11
|
const api_types_1 = require("./api-types");
|
|
@@ -98,46 +97,6 @@ function validateUseCaseRequirements(useCase, phoneNumber, hasParentSessionId) {
|
|
|
98
97
|
}
|
|
99
98
|
return { valid: true };
|
|
100
99
|
}
|
|
101
|
-
/**
|
|
102
|
-
* Validates consent data
|
|
103
|
-
* @param consentData - Consent data object
|
|
104
|
-
* @returns Validation result
|
|
105
|
-
*/
|
|
106
|
-
function validateConsentData(consentData) {
|
|
107
|
-
if (!consentData) {
|
|
108
|
-
return { valid: true }; // Consent data is optional
|
|
109
|
-
}
|
|
110
|
-
const { consent_text: consentText, policy_link: policyLink, policy_text: policyText } = consentData;
|
|
111
|
-
if (!consentText || consentText.trim().length === 0) {
|
|
112
|
-
return {
|
|
113
|
-
valid: false,
|
|
114
|
-
error: 'Consent text is required when consent data is provided'
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
if (!policyLink || policyLink.trim().length === 0) {
|
|
118
|
-
return {
|
|
119
|
-
valid: false,
|
|
120
|
-
error: 'Policy link is required when consent data is provided'
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
// Validate URL format for policy link
|
|
124
|
-
try {
|
|
125
|
-
new URL(policyLink);
|
|
126
|
-
}
|
|
127
|
-
catch (_a) {
|
|
128
|
-
return {
|
|
129
|
-
valid: false,
|
|
130
|
-
error: 'Policy link must be a valid URL'
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
if (!policyText || policyText.trim().length === 0) {
|
|
134
|
-
return {
|
|
135
|
-
valid: false,
|
|
136
|
-
error: 'Policy text is required when consent data is provided'
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
return { valid: true };
|
|
140
|
-
}
|
|
141
100
|
/**
|
|
142
101
|
* Creates a validation error
|
|
143
102
|
* @param code - Error code
|
package/dist/core/version.js
CHANGED
|
@@ -4,6 +4,6 @@ export type { UsePhoneAuthOptions } from './usePhoneAuth';
|
|
|
4
4
|
export type { ClientConfig, ClientResponse, RequestOptions } from '../../core/types';
|
|
5
5
|
export type { AuthConfig as PhoneAuthConfig, PhoneAuthOptions, PhoneAuthResult, AuthError, AuthStep } from '../../core/phone-auth';
|
|
6
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,
|
|
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
8
|
export { USE_CASE as UseCase, AUTHENTICATION_STRATEGY as AuthenticationStrategy, BrowserError, BrowserErrorCode, BrowserName } from '../../core/phone-auth/types';
|
|
9
9
|
export { PhoneAuthClient } from '../../core/phone-auth';
|
|
@@ -5,6 +5,6 @@ export { PhoneAuthClient } from '../../core/phone-auth';
|
|
|
5
5
|
export type { ClientConfig, ClientResponse, RequestOptions } from '../../core/types';
|
|
6
6
|
export type { AuthConfig as PhoneAuthConfig, PhoneAuthOptions, PhoneAuthResult, AuthError, AuthStep } from '../../core/phone-auth';
|
|
7
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,
|
|
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
9
|
export { USE_CASE as UseCase, AUTHENTICATION_STRATEGY as AuthenticationStrategy, BrowserError, BrowserErrorCode, BrowserName } from '../../core/phone-auth/types';
|
|
10
10
|
export { USE_CASE, ERROR_CODE, ERROR_MESSAGES, ERROR_STATUS_CODES } from '../../core/phone-auth/api-types';
|
package/dist/esm/browser.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { PhoneAuthClient } from './core/phone-auth';
|
|
2
2
|
export type { AuthConfig as PhoneAuthConfig, PhoneAuthOptions, PhoneAuthResult, AuthError as PhoneAuthError, AuthStep as PhoneAuthStep } from './core/phone-auth';
|
|
3
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,
|
|
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
5
|
export { USE_CASE as UseCase, AUTHENTICATION_STRATEGY as AuthenticationStrategy, BrowserError, BrowserErrorCode, BrowserName } from './core/phone-auth/types';
|
|
6
6
|
export { VanillaClient as ClientManager } from './adapters/vanilla/client';
|
|
7
7
|
export { PhoneAuthManager } from './adapters/vanilla/phone-auth';
|
|
@@ -40,17 +40,6 @@ export interface PLMN {
|
|
|
40
40
|
/** Mobile Network Code (2-3 digits) */
|
|
41
41
|
mnc: string;
|
|
42
42
|
}
|
|
43
|
-
/**
|
|
44
|
-
* User consent information for privacy compliance
|
|
45
|
-
*/
|
|
46
|
-
export interface ConsentData {
|
|
47
|
-
/** What the user is consenting to */
|
|
48
|
-
consent_text: string;
|
|
49
|
-
/** URL to privacy policy */
|
|
50
|
-
policy_link: string;
|
|
51
|
-
/** Brief policy description */
|
|
52
|
-
policy_text: string;
|
|
53
|
-
}
|
|
54
43
|
/**
|
|
55
44
|
* Browser/client information for strategy selection
|
|
56
45
|
*/
|
|
@@ -109,8 +98,6 @@ export interface PrepareRequest {
|
|
|
109
98
|
/** Request identifier (SDK generates unique ID if not provided) */
|
|
110
99
|
id?: string;
|
|
111
100
|
/** Optional fields */
|
|
112
|
-
/** User consent information */
|
|
113
|
-
consent_data?: ConsentData;
|
|
114
101
|
/** Client information for strategy selection */
|
|
115
102
|
client_info?: ClientInfo;
|
|
116
103
|
/** Advanced options for special features */
|
|
@@ -513,7 +500,8 @@ export interface ExtendedResponse {
|
|
|
513
500
|
cancel: () => void;
|
|
514
501
|
}
|
|
515
502
|
/**
|
|
516
|
-
* Extended response for Desktop strategy
|
|
503
|
+
* Extended response for Desktop strategy.
|
|
504
|
+
* Note: Polling starts immediately even with preventDefaultUI: true (consistent with Link strategy)
|
|
517
505
|
*/
|
|
518
506
|
export interface DesktopExtendedResponse extends ExtendedResponse {
|
|
519
507
|
strategy: 'desktop';
|
|
@@ -528,7 +516,7 @@ export interface DesktopExtendedResponse extends ExtendedResponse {
|
|
|
528
516
|
/** Challenge pattern */
|
|
529
517
|
challenge?: any;
|
|
530
518
|
};
|
|
531
|
-
/**
|
|
519
|
+
/** Returns the existing polling promise (polling starts immediately) */
|
|
532
520
|
start_polling: () => Promise<AuthCredential>;
|
|
533
521
|
/** Stop polling */
|
|
534
522
|
stop_polling: () => void;
|