@glideidentity/web-client-sdk 5.0.1 → 5.1.1-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 (97) hide show
  1. package/README.md +8 -108
  2. package/dist/adapters/angular/index.js +1 -0
  3. package/dist/adapters/angular/phone-auth.service.d.ts +18 -0
  4. package/dist/adapters/angular/phone-auth.service.js +26 -0
  5. package/dist/adapters/react/index.js +3 -0
  6. package/dist/adapters/react/useClient.js +1 -0
  7. package/dist/adapters/react/usePhoneAuth.js +16 -1
  8. package/dist/adapters/vanilla/client.js +1 -0
  9. package/dist/adapters/vanilla/index.js +1 -0
  10. package/dist/adapters/vanilla/phone-auth.js +31 -0
  11. package/dist/adapters/vue/index.js +4 -0
  12. package/dist/adapters/vue/useClient.js +5 -0
  13. package/dist/adapters/vue/usePhoneAuth.js +20 -1
  14. package/dist/browser/web-client-sdk.min.js +1 -2
  15. package/dist/browser.js +6 -0
  16. package/dist/core/client.js +12 -0
  17. package/dist/core/logger.js +81 -1
  18. package/dist/core/phone-auth/api-types.d.ts +1 -4
  19. package/dist/core/phone-auth/api-types.js +83 -0
  20. package/dist/core/phone-auth/client.js +374 -38
  21. package/dist/core/phone-auth/error-utils.js +83 -1
  22. package/dist/core/phone-auth/index.d.ts +1 -1
  23. package/dist/core/phone-auth/index.js +2 -2
  24. package/dist/core/phone-auth/status-types.d.ts +78 -0
  25. package/dist/core/phone-auth/status-types.js +17 -0
  26. package/dist/core/phone-auth/strategies/desktop.d.ts +2 -0
  27. package/dist/core/phone-auth/strategies/desktop.js +136 -13
  28. package/dist/core/phone-auth/strategies/index.d.ts +4 -0
  29. package/dist/core/phone-auth/strategies/index.js +4 -0
  30. package/dist/core/phone-auth/strategies/link.d.ts +2 -0
  31. package/dist/core/phone-auth/strategies/link.js +97 -13
  32. package/dist/core/phone-auth/strategies/ts43.d.ts +19 -0
  33. package/dist/core/phone-auth/strategies/ts43.js +33 -2
  34. package/dist/core/phone-auth/strategies/types.js +4 -0
  35. package/dist/core/phone-auth/type-guards.js +131 -0
  36. package/dist/core/phone-auth/types.d.ts +5 -0
  37. package/dist/core/phone-auth/types.js +32 -0
  38. package/dist/core/phone-auth/ui/mobile-debug-console.js +28 -2
  39. package/dist/core/phone-auth/ui/modal.d.ts +55 -33
  40. package/dist/core/phone-auth/ui/modal.js +422 -889
  41. package/dist/core/phone-auth/validation-utils.d.ts +0 -9
  42. package/dist/core/phone-auth/validation-utils.js +34 -25
  43. package/dist/core/version.js +2 -1
  44. package/dist/esm/adapters/angular/index.js +1 -0
  45. package/dist/esm/adapters/angular/phone-auth.service.d.ts +18 -0
  46. package/dist/esm/adapters/angular/phone-auth.service.js +26 -0
  47. package/dist/esm/adapters/react/index.js +3 -0
  48. package/dist/esm/adapters/react/useClient.js +1 -0
  49. package/dist/esm/adapters/react/usePhoneAuth.js +16 -1
  50. package/dist/esm/adapters/vanilla/client.js +1 -0
  51. package/dist/esm/adapters/vanilla/index.js +1 -0
  52. package/dist/esm/adapters/vanilla/phone-auth.d.ts +24 -0
  53. package/dist/esm/adapters/vanilla/phone-auth.js +31 -0
  54. package/dist/esm/adapters/vue/index.js +4 -0
  55. package/dist/esm/adapters/vue/useClient.js +5 -0
  56. package/dist/esm/adapters/vue/usePhoneAuth.js +20 -1
  57. package/dist/esm/browser.js +6 -0
  58. package/dist/esm/core/client.d.ts +10 -0
  59. package/dist/esm/core/client.js +12 -0
  60. package/dist/esm/core/logger.d.ts +53 -0
  61. package/dist/esm/core/logger.js +81 -1
  62. package/dist/esm/core/phone-auth/api-types.d.ts +313 -1
  63. package/dist/esm/core/phone-auth/api-types.js +83 -0
  64. package/dist/esm/core/phone-auth/client.d.ts +144 -0
  65. package/dist/esm/core/phone-auth/client.js +375 -39
  66. package/dist/esm/core/phone-auth/error-utils.d.ts +29 -0
  67. package/dist/esm/core/phone-auth/error-utils.js +83 -1
  68. package/dist/esm/core/phone-auth/index.d.ts +1 -1
  69. package/dist/esm/core/phone-auth/index.js +4 -2
  70. package/dist/esm/core/phone-auth/status-types.d.ts +78 -0
  71. package/dist/esm/core/phone-auth/status-types.js +17 -0
  72. package/dist/esm/core/phone-auth/strategies/desktop.d.ts +65 -0
  73. package/dist/esm/core/phone-auth/strategies/desktop.js +136 -13
  74. package/dist/esm/core/phone-auth/strategies/index.d.ts +4 -0
  75. package/dist/esm/core/phone-auth/strategies/index.js +4 -0
  76. package/dist/esm/core/phone-auth/strategies/link.d.ts +50 -0
  77. package/dist/esm/core/phone-auth/strategies/link.js +97 -13
  78. package/dist/esm/core/phone-auth/strategies/ts43.d.ts +19 -0
  79. package/dist/esm/core/phone-auth/strategies/ts43.js +33 -2
  80. package/dist/esm/core/phone-auth/strategies/types.d.ts +13 -0
  81. package/dist/esm/core/phone-auth/strategies/types.js +4 -0
  82. package/dist/esm/core/phone-auth/type-guards.d.ts +128 -0
  83. package/dist/esm/core/phone-auth/type-guards.js +131 -0
  84. package/dist/esm/core/phone-auth/types.d.ts +113 -0
  85. package/dist/esm/core/phone-auth/types.js +32 -0
  86. package/dist/esm/core/phone-auth/ui/mobile-debug-console.d.ts +4 -0
  87. package/dist/esm/core/phone-auth/ui/mobile-debug-console.js +28 -2
  88. package/dist/esm/core/phone-auth/ui/modal.d.ts +68 -27
  89. package/dist/esm/core/phone-auth/ui/modal.js +422 -889
  90. package/dist/esm/core/phone-auth/validation-utils.d.ts +26 -4
  91. package/dist/esm/core/phone-auth/validation-utils.js +34 -24
  92. package/dist/esm/core/types.d.ts +35 -0
  93. package/dist/esm/core/version.js +2 -1
  94. package/dist/esm/index.js +9 -1
  95. package/dist/index.js +7 -0
  96. package/package.json +1 -1
  97. package/dist/browser/web-client-sdk.min.js.LICENSE.txt +0 -1
@@ -1,22 +1,44 @@
1
+ /**
2
+ * Validation utilities for phone authentication
3
+ */
1
4
  import { PhoneAuthErrorCode } from './error-utils';
2
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
+ */
3
11
  export declare function validatePhoneNumber(phoneNumber?: string): {
4
12
  valid: boolean;
5
13
  error?: string;
6
14
  };
15
+ /**
16
+ * Validates PLMN (MCC/MNC) values
17
+ * @param plmn - PLMN object with MCC and MNC
18
+ * @returns Validation result
19
+ */
7
20
  export declare function validatePlmn(plmn?: PLMN): {
8
21
  valid: boolean;
9
22
  error?: string;
10
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
+ */
11
31
  export declare function validateUseCaseRequirements(useCase: UseCase, phoneNumber?: string, hasParentSessionId?: boolean): {
12
32
  valid: boolean;
13
33
  error?: string;
14
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
+ */
15
41
  export declare function createValidationError(code: PhoneAuthErrorCode, message: string, field?: string): Error & {
16
42
  code: PhoneAuthErrorCode;
17
43
  field?: string;
18
44
  };
19
- export declare function validateNonce(nonce: string): {
20
- valid: boolean;
21
- error?: string;
22
- };
@@ -1,8 +1,17 @@
1
+ /**
2
+ * Validation utilities for phone authentication
3
+ */
1
4
  import { USE_CASE } from './api-types';
5
+ /**
6
+ * Validates E.164 phone number format
7
+ * @param phoneNumber - Phone number to validate
8
+ * @returns Validation result with error if invalid
9
+ */
2
10
  export function validatePhoneNumber(phoneNumber) {
3
11
  if (!phoneNumber) {
4
- return { valid: true };
12
+ return { valid: true }; // Phone number is optional for GetPhoneNumber
5
13
  }
14
+ // E.164 format validation - strict, no cleaning
6
15
  const e164Regex = /^\+[1-9]\d{1,14}$/;
7
16
  if (!phoneNumber.startsWith('+')) {
8
17
  return {
@@ -22,6 +31,7 @@ export function validatePhoneNumber(phoneNumber) {
22
31
  error: 'Phone number too long for E.164 format (maximum 15 digits after +)'
23
32
  };
24
33
  }
34
+ // Check for any invalid characters (spaces, dashes, parentheses, etc.)
25
35
  if (!/^\+\d+$/.test(phoneNumber)) {
26
36
  return {
27
37
  valid: false,
@@ -36,26 +46,42 @@ export function validatePhoneNumber(phoneNumber) {
36
46
  }
37
47
  return { valid: true };
38
48
  }
49
+ /**
50
+ * Validates PLMN (MCC/MNC) values
51
+ * @param plmn - PLMN object with MCC and MNC
52
+ * @returns Validation result
53
+ */
39
54
  export function validatePlmn(plmn) {
40
55
  if (!plmn) {
41
- return { valid: true };
56
+ return { valid: true }; // PLMN is optional
42
57
  }
43
58
  const { mcc, mnc } = plmn;
59
+ // MCC validation (3 digits) - no range check for telco labs
44
60
  if (!mcc || !/^\d{3}$/.test(mcc)) {
45
61
  return {
46
62
  valid: false,
47
63
  error: 'MCC must be exactly 3 digits'
48
64
  };
49
65
  }
66
+ // MNC validation (2 or 3 digits)
50
67
  if (!mnc || !/^\d{2,3}$/.test(mnc)) {
51
68
  return {
52
69
  valid: false,
53
70
  error: 'MNC must be 2 or 3 digits'
54
71
  };
55
72
  }
73
+ // No range validation - allowing unofficial MCCs for telco labs
56
74
  return { valid: true };
57
75
  }
76
+ /**
77
+ * Validates use case and phone number combination
78
+ * @param useCase - The use case
79
+ * @param phoneNumber - The phone number (required for VerifyPhoneNumber)
80
+ * @param hasParentSessionId - Whether parent_session_id is provided (allows skipping normal validation)
81
+ * @returns Validation result
82
+ */
58
83
  export function validateUseCaseRequirements(useCase, phoneNumber, hasParentSessionId) {
84
+ // VerifyPhoneNumber requires a phone number (unless parent_session_id is provided)
59
85
  if (useCase === USE_CASE.VERIFY_PHONE_NUMBER && !phoneNumber && !hasParentSessionId) {
60
86
  return {
61
87
  valid: false,
@@ -64,6 +90,12 @@ export function validateUseCaseRequirements(useCase, phoneNumber, hasParentSessi
64
90
  }
65
91
  return { valid: true };
66
92
  }
93
+ /**
94
+ * Creates a validation error
95
+ * @param code - Error code
96
+ * @param message - Error message
97
+ * @param field - Field that failed validation
98
+ */
67
99
  export function createValidationError(code, message, field) {
68
100
  const error = new Error(message);
69
101
  error.code = code;
@@ -72,25 +104,3 @@ export function createValidationError(code, message, field) {
72
104
  }
73
105
  return error;
74
106
  }
75
- export function validateNonce(nonce) {
76
- const base64urlRegex = /^[A-Za-z0-9_-]+$/;
77
- if (!nonce || nonce.length === 0) {
78
- return {
79
- valid: false,
80
- error: 'Nonce is required'
81
- };
82
- }
83
- if (!base64urlRegex.test(nonce)) {
84
- return {
85
- valid: false,
86
- error: 'Nonce must be base64url encoded'
87
- };
88
- }
89
- if (nonce.length < 32 || nonce.length > 128) {
90
- return {
91
- valid: false,
92
- error: 'Nonce must be between 32 and 128 characters'
93
- };
94
- }
95
- return { valid: true };
96
- }
@@ -1,16 +1,51 @@
1
1
  import { LogLevel, Logger } from './logger';
2
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
+ */
3
8
  baseURL?: string;
9
+ /**
10
+ * API key for authentication
11
+ * Currently not used in the SDK but kept for backward compatibility
12
+ */
4
13
  apiKey?: string;
14
+ /**
15
+ * Request timeout in milliseconds
16
+ * @default 10000
17
+ */
5
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
+ */
6
24
  authTargetOrigin?: string;
25
+ /**
26
+ * Phone authentication endpoints
27
+ * If not provided, uses default endpoints relative to baseURL
28
+ */
7
29
  phoneAuthEndpoints?: {
8
30
  prepareRequest: string;
9
31
  processResponse: string;
10
32
  };
33
+ /**
34
+ * Enable debug logging
35
+ * @default false
36
+ */
11
37
  debug?: boolean;
38
+ /**
39
+ * Set specific log level
40
+ */
12
41
  logLevel?: LogLevel;
42
+ /**
43
+ * Custom logger implementation
44
+ */
13
45
  logger?: Logger;
46
+ /**
47
+ * Remote logging configuration
48
+ */
14
49
  remoteLogging?: {
15
50
  endpoint: string;
16
51
  apiKey: string;
@@ -1 +1,2 @@
1
- export const SDK_VERSION = '5.0.1';
1
+ // SDK version - injected at build time
2
+ export const SDK_VERSION = '5.1.1-beta.1';
package/dist/esm/index.js CHANGED
@@ -1,8 +1,16 @@
1
+ // Phone Authentication
1
2
  export { PhoneAuthClient } from './core/phone-auth';
3
+ // Phone Auth Error Utilities
2
4
  export { PhoneAuthErrorCode, isPhoneAuthError, isUserError, getUserMessage, isErrorCode, getRetryDelay, isRetryableError, serializeError, createErrorBreadcrumb } from './core/phone-auth';
3
- export { isExtendedResponse, isCredential, isAuthCredential, isLinkStrategy, isTS43Strategy, isDesktopStrategy, getStrategy, hasPollingControls, hasTrigger, isHeadlessResult, requiresPolling, requiresUserAction } from './core/phone-auth';
5
+ // Phone Auth Type Guards and Helpers
6
+ export { isExtendedResponse, isCredential, isAuthCredential, isLinkStrategy, isTS43Strategy, isDesktopStrategy, getStrategy, hasPollingControls, hasTrigger,
7
+ // Deprecated aliases
8
+ isHeadlessResult, requiresPolling, requiresUserAction } from './core/phone-auth';
9
+ // Export constants for use case and strategy
4
10
  export { USE_CASE as UseCase, AUTHENTICATION_STRATEGY as AuthenticationStrategy, BrowserError, BrowserErrorCode, BrowserName } from './core/phone-auth/types';
11
+ // Desktop Strategy Exports
5
12
  export { DesktopHandler } from './core/phone-auth/strategies/desktop';
13
+ // Adapters
6
14
  export { useClient, usePhoneAuth } from './adapters/react';
7
15
  export { useClient as useVueClient, usePhoneAuth as useVuePhoneAuth } from './adapters/vue';
8
16
  export { ClientService, PhoneAuthService } from './adapters/angular';
package/dist/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PhoneAuthManager = exports.ClientManager = exports.PhoneAuthService = exports.ClientService = exports.useVuePhoneAuth = exports.useVueClient = exports.usePhoneAuth = exports.useClient = exports.DesktopHandler = exports.BrowserName = exports.BrowserErrorCode = exports.BrowserError = exports.AuthenticationStrategy = exports.UseCase = 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.createErrorBreadcrumb = exports.serializeError = exports.isRetryableError = exports.getRetryDelay = exports.isErrorCode = exports.getUserMessage = exports.isUserError = exports.isPhoneAuthError = exports.PhoneAuthErrorCode = exports.PhoneAuthClient = void 0;
4
+ // Phone Authentication
4
5
  var phone_auth_1 = require("./core/phone-auth");
5
6
  Object.defineProperty(exports, "PhoneAuthClient", { enumerable: true, get: function () { return phone_auth_1.PhoneAuthClient; } });
7
+ // Phone Auth Error Utilities
6
8
  var phone_auth_2 = require("./core/phone-auth");
7
9
  Object.defineProperty(exports, "PhoneAuthErrorCode", { enumerable: true, get: function () { return phone_auth_2.PhoneAuthErrorCode; } });
8
10
  Object.defineProperty(exports, "isPhoneAuthError", { enumerable: true, get: function () { return phone_auth_2.isPhoneAuthError; } });
@@ -13,6 +15,7 @@ Object.defineProperty(exports, "getRetryDelay", { enumerable: true, get: functio
13
15
  Object.defineProperty(exports, "isRetryableError", { enumerable: true, get: function () { return phone_auth_2.isRetryableError; } });
14
16
  Object.defineProperty(exports, "serializeError", { enumerable: true, get: function () { return phone_auth_2.serializeError; } });
15
17
  Object.defineProperty(exports, "createErrorBreadcrumb", { enumerable: true, get: function () { return phone_auth_2.createErrorBreadcrumb; } });
18
+ // Phone Auth Type Guards and Helpers
16
19
  var phone_auth_3 = require("./core/phone-auth");
17
20
  Object.defineProperty(exports, "isExtendedResponse", { enumerable: true, get: function () { return phone_auth_3.isExtendedResponse; } });
18
21
  Object.defineProperty(exports, "isCredential", { enumerable: true, get: function () { return phone_auth_3.isCredential; } });
@@ -23,17 +26,21 @@ Object.defineProperty(exports, "isDesktopStrategy", { enumerable: true, get: fun
23
26
  Object.defineProperty(exports, "getStrategy", { enumerable: true, get: function () { return phone_auth_3.getStrategy; } });
24
27
  Object.defineProperty(exports, "hasPollingControls", { enumerable: true, get: function () { return phone_auth_3.hasPollingControls; } });
25
28
  Object.defineProperty(exports, "hasTrigger", { enumerable: true, get: function () { return phone_auth_3.hasTrigger; } });
29
+ // Deprecated aliases
26
30
  Object.defineProperty(exports, "isHeadlessResult", { enumerable: true, get: function () { return phone_auth_3.isHeadlessResult; } });
27
31
  Object.defineProperty(exports, "requiresPolling", { enumerable: true, get: function () { return phone_auth_3.requiresPolling; } });
28
32
  Object.defineProperty(exports, "requiresUserAction", { enumerable: true, get: function () { return phone_auth_3.requiresUserAction; } });
33
+ // Export constants for use case and strategy
29
34
  var types_1 = require("./core/phone-auth/types");
30
35
  Object.defineProperty(exports, "UseCase", { enumerable: true, get: function () { return types_1.USE_CASE; } });
31
36
  Object.defineProperty(exports, "AuthenticationStrategy", { enumerable: true, get: function () { return types_1.AUTHENTICATION_STRATEGY; } });
32
37
  Object.defineProperty(exports, "BrowserError", { enumerable: true, get: function () { return types_1.BrowserError; } });
33
38
  Object.defineProperty(exports, "BrowserErrorCode", { enumerable: true, get: function () { return types_1.BrowserErrorCode; } });
34
39
  Object.defineProperty(exports, "BrowserName", { enumerable: true, get: function () { return types_1.BrowserName; } });
40
+ // Desktop Strategy Exports
35
41
  var desktop_1 = require("./core/phone-auth/strategies/desktop");
36
42
  Object.defineProperty(exports, "DesktopHandler", { enumerable: true, get: function () { return desktop_1.DesktopHandler; } });
43
+ // Adapters
37
44
  var react_1 = require("./adapters/react");
38
45
  Object.defineProperty(exports, "useClient", { enumerable: true, get: function () { return react_1.useClient; } });
39
46
  Object.defineProperty(exports, "usePhoneAuth", { enumerable: true, get: function () { return react_1.usePhoneAuth; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glideidentity/web-client-sdk",
3
- "version": "5.0.1",
3
+ "version": "5.1.1-beta.1",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/esm/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -1 +0,0 @@
1
- /*! Axios v1.13.2 Copyright (c) 2025 Matt Zabriskie and contributors */