@glideidentity/web-client-sdk 5.0.1-beta.0 → 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,4 +1,11 @@
1
1
  "use strict";
2
+ /**
3
+ * Phone Authentication Types
4
+ *
5
+ * This file exports the types used by the Phone Auth SDK.
6
+ * All API types are imported from api-types.ts to ensure consistency.
7
+ * No backward compatibility - using clean API specification only.
8
+ */
2
9
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
10
  if (k2 === undefined) k2 = k;
4
11
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -15,7 +22,16 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
22
  };
16
23
  Object.defineProperty(exports, "__esModule", { value: true });
17
24
  exports.AuthStatus = exports.BrowserName = exports.BrowserErrorCode = exports.BrowserError = void 0;
25
+ // ============================================================================
26
+ // RE-EXPORT ALL API TYPES
27
+ // ============================================================================
18
28
  __exportStar(require("./api-types"), exports);
29
+ // ============================================================================
30
+ // BROWSER-SPECIFIC TYPES
31
+ // ============================================================================
32
+ /**
33
+ * Browser error names
34
+ */
19
35
  exports.BrowserError = {
20
36
  NOT_ALLOWED: 'NotAllowedError',
21
37
  NETWORK: 'NetworkError',
@@ -32,6 +48,9 @@ exports.BrowserError = {
32
48
  RANGE: 'RangeError',
33
49
  SYNTAX: 'SyntaxError'
34
50
  };
51
+ /**
52
+ * Browser error codes
53
+ */
35
54
  exports.BrowserErrorCode = {
36
55
  USER_CANCELLED_DC_API: 19,
37
56
  PERMISSION_DENIED: 1,
@@ -42,6 +61,9 @@ exports.BrowserErrorCode = {
42
61
  NETWORK: 19,
43
62
  SECURITY: 18
44
63
  };
64
+ /**
65
+ * Browser names for detection
66
+ */
45
67
  exports.BrowserName = {
46
68
  CHROME: 'Chrome',
47
69
  EDGE: 'Edge',
@@ -51,11 +73,21 @@ exports.BrowserName = {
51
73
  BRAVE: 'Brave',
52
74
  OTHER: 'other'
53
75
  };
76
+ /**
77
+ * Authentication status constants
78
+ * Maps to both client-side states and backend responses
79
+ */
54
80
  exports.AuthStatus = {
81
+ /** Authentication in progress */
55
82
  PENDING: 'pending',
83
+ /** Authentication completed successfully */
56
84
  COMPLETED: 'completed',
85
+ /** User cancelled authentication */
57
86
  CANCELLED: 'cancelled',
87
+ /** Authentication failed or expired */
58
88
  FAILED: 'failed',
89
+ /** Session expired (backend returns 410 Gone) */
59
90
  EXPIRED: 'expired',
91
+ /** Session not found (backend returns 404) */
60
92
  NOT_FOUND: 'not_found'
61
93
  };
@@ -1,4 +1,8 @@
1
1
  "use strict";
2
+ /**
3
+ * Mobile Debug Console
4
+ * A lightweight console overlay for debugging on mobile devices where dev tools aren't available
5
+ */
2
6
  Object.defineProperty(exports, "__esModule", { value: true });
3
7
  exports.MobileDebugConsole = void 0;
4
8
  class MobileDebugConsole {
@@ -35,13 +39,15 @@ class MobileDebugConsole {
35
39
  ['log', 'error', 'warn', 'debug', 'info'].forEach(method => {
36
40
  const originalMethod = this.originalConsole[method];
37
41
  console[method] = (...args) => {
42
+ // Call original
38
43
  originalMethod.apply(console, args);
44
+ // Add to our display
39
45
  this.addLog(method, args);
40
46
  };
41
47
  });
42
48
  }
43
49
  addLog(type, args) {
44
- const timestamp = new Date().toTimeString().split(' ')[0];
50
+ const timestamp = new Date().toTimeString().split(' ')[0]; // HH:MM:SS
45
51
  const content = args.map(arg => {
46
52
  if (typeof arg === 'object') {
47
53
  try {
@@ -53,6 +59,7 @@ class MobileDebugConsole {
53
59
  }
54
60
  return String(arg);
55
61
  }).join(' ');
62
+ // Create colored log entry
56
63
  const colors = {
57
64
  log: '#fff',
58
65
  error: '#ff6b6b',
@@ -68,6 +75,7 @@ class MobileDebugConsole {
68
75
  </div>
69
76
  `;
70
77
  this.logs.push(logHtml);
78
+ // Keep only last 500 logs
71
79
  if (this.logs.length > 500) {
72
80
  this.logs.shift();
73
81
  }
@@ -76,13 +84,17 @@ class MobileDebugConsole {
76
84
  updateDisplay() {
77
85
  if (!this.logsContainer || !this.isVisible)
78
86
  return;
87
+ // Check if scrolled to bottom before update
79
88
  this.isAtBottom = this.logsContainer.scrollHeight - this.logsContainer.scrollTop <= this.logsContainer.clientHeight + 50;
89
+ // Update content
80
90
  this.logsContainer.innerHTML = this.logs.join('');
91
+ // Auto-scroll only if was at bottom
81
92
  if (this.isAtBottom) {
82
93
  this.logsContainer.scrollTop = this.logsContainer.scrollHeight;
83
94
  }
84
95
  }
85
96
  createUI() {
97
+ // Create styles
86
98
  const style = document.createElement('style');
87
99
  style.textContent = `
88
100
  #mobile-debug-console {
@@ -175,11 +187,13 @@ class MobileDebugConsole {
175
187
  }
176
188
  `;
177
189
  document.head.appendChild(style);
190
+ // Create container
178
191
  this.container = document.createElement('div');
179
192
  this.container.id = 'mobile-debug-console';
180
193
  if (!this.isVisible) {
181
194
  this.container.className = 'hidden';
182
195
  }
196
+ // Create header
183
197
  const header = document.createElement('div');
184
198
  header.id = 'debug-header';
185
199
  const title = document.createElement('div');
@@ -187,12 +201,15 @@ class MobileDebugConsole {
187
201
  title.textContent = '📱 Mobile Debug Console';
188
202
  const buttons = document.createElement('div');
189
203
  buttons.id = 'debug-buttons';
204
+ // Clear button
190
205
  const clearBtn = document.createElement('button');
191
206
  clearBtn.textContent = 'Clear';
192
207
  clearBtn.onclick = () => this.clear();
208
+ // Show/Hide button
193
209
  const toggleBtn = document.createElement('button');
194
210
  toggleBtn.textContent = 'Hide';
195
211
  toggleBtn.onclick = () => this.toggle();
212
+ // Close button
196
213
  const closeBtn = document.createElement('button');
197
214
  closeBtn.textContent = '✕';
198
215
  closeBtn.style.color = '#ff6b6b';
@@ -202,20 +219,25 @@ class MobileDebugConsole {
202
219
  buttons.appendChild(closeBtn);
203
220
  header.appendChild(title);
204
221
  header.appendChild(buttons);
222
+ // Create logs container
205
223
  this.logsContainer = document.createElement('div');
206
224
  this.logsContainer.id = 'debug-logs';
225
+ // Track scroll position
207
226
  this.logsContainer.addEventListener('scroll', () => {
208
227
  this.isAtBottom = this.logsContainer.scrollHeight - this.logsContainer.scrollTop <= this.logsContainer.clientHeight + 50;
209
228
  });
229
+ // Assemble
210
230
  this.container.appendChild(header);
211
231
  this.container.appendChild(this.logsContainer);
212
232
  document.body.appendChild(this.container);
233
+ // Create floating toggle button
213
234
  this.floatingToggle = document.createElement('button');
214
235
  this.floatingToggle.id = 'debug-floating-toggle';
215
- this.floatingToggle.innerHTML = '🖥️';
236
+ this.floatingToggle.innerHTML = '🖥️'; // Console icon
216
237
  this.floatingToggle.title = 'Show Debug Console';
217
238
  this.floatingToggle.onclick = () => this.toggle();
218
239
  document.body.appendChild(this.floatingToggle);
240
+ // Store reference for toggle button
219
241
  window.__debugToggleBtn = toggleBtn;
220
242
  }
221
243
  escapeHtml(text) {
@@ -246,15 +268,19 @@ class MobileDebugConsole {
246
268
  }
247
269
  }
248
270
  cleanup() {
271
+ // Restore original console
249
272
  Object.keys(this.originalConsole).forEach(method => {
250
273
  console[method] = this.originalConsole[method];
251
274
  });
275
+ // Remove UI
252
276
  if (this.container) {
253
277
  this.container.remove();
254
278
  }
279
+ // Remove floating toggle
255
280
  if (this.floatingToggle) {
256
281
  this.floatingToggle.remove();
257
282
  }
283
+ // Clean up references
258
284
  delete window.__debugToggleBtn;
259
285
  }
260
286
  }
@@ -2,19 +2,20 @@
2
2
  * Modal UI Component for Phone Authentication
3
3
  *
4
4
  * This file creates the UI components (modals, buttons) that are shown
5
- * when the SDK is NOT in headless mode.
5
+ * when the SDK is NOT in headless mode. Think of it like a popup window
6
+ * that handles the authentication flow for you.
6
7
  */
7
8
  import type { InvokeOptions } from '../api-types';
8
9
  import type { QRCodeData } from '../strategies/desktop';
9
- export type ModalViewMode = 'toggle' | 'dual' | 'pre-step';
10
- export type ModalTheme = 'dark' | 'light' | 'auto';
11
- export type AuthModalOptions = NonNullable<InvokeOptions['modalOptions']> & {
12
- viewMode?: ModalViewMode;
13
- /** Modal theme: 'dark', 'light', or 'auto' (uses system preference) */
14
- theme?: ModalTheme;
15
- };
16
10
  /**
17
11
  * Creates and manages a modal dialog for authentication
12
+ *
13
+ * @example
14
+ * const modal = new AuthModal({
15
+ * title: "Verify Your Phone",
16
+ * description: "Complete authentication to continue"
17
+ * });
18
+ * modal.show();
18
19
  */
19
20
  export declare class AuthModal {
20
21
  private container;
@@ -23,44 +24,65 @@ export declare class AuthModal {
23
24
  private options;
24
25
  private callbacks;
25
26
  private closeCallback?;
26
- private theme;
27
- private currentStep;
28
- private qrCodeData;
29
- private statusMessage;
30
- private originalBodyOverflow;
31
- private isClosing;
32
- private readonly iconApple;
33
- private readonly iconAndroid;
34
- private readonly iconBack;
35
- constructor(options?: AuthModalOptions, callbacks?: InvokeOptions['callbacks']);
27
+ constructor(options?: InvokeOptions['modalOptions'], callbacks?: InvokeOptions['callbacks']);
28
+ private handleEscapeKey;
36
29
  /**
37
- * Determines if dark mode should be used based on theme setting
30
+ * Escape HTML to prevent XSS attacks
38
31
  */
39
- private shouldUseDarkMode;
40
- private handleEscapeKey;
41
32
  private escapeHtml;
42
33
  /**
43
- * Shows the modal with a QR code
34
+ * Shows the modal with a QR code for desktop authentication
35
+ * Supports both single QR code (legacy) and dual-platform QR codes (iOS + Android)
44
36
  */
45
37
  showQRCode(qrCodeData: string | QRCodeData, statusMessage?: string): void;
46
38
  /**
47
- * Updates the status message shown in the modal
39
+ * Creates a modal with iOS/Android platform toggle
40
+ */
41
+ private createDualPlatformQRModal;
42
+ /**
43
+ * Sets a callback to be called when the modal is cancelled/closed
48
44
  */
49
- updateStatus(status: string, isError?: boolean): void;
50
45
  setCloseCallback(callback: () => void): void;
51
- private renderToggleMode;
52
- private renderDualMode;
53
- private renderPreStepMode;
54
- private setupPreStepListeners;
55
- private updatePreStepUI;
56
- private setupBackButton;
46
+ /**
47
+ * Shows the modal with a button for Link authentication (App Clips)
48
+ * IMPORTANT: The button click is required for iOS to recognize the app link
49
+ */
50
+ showLinkButton(url: string, buttonText?: string): Promise<void>;
51
+ /**
52
+ * Shows the modal with a button for TS43 authentication
53
+ * IMPORTANT: The button click is required for Digital Credentials API (transient activation)
54
+ */
55
+ showTS43Button(onAuthenticate: () => Promise<any>): Promise<any>;
56
+ /**
57
+ * Updates the status message in the modal
58
+ */
59
+ updateStatus(message: string, isError?: boolean): void;
60
+ /**
61
+ * Creates the modal HTML structure
62
+ */
57
63
  private createModal;
58
- private setupHelpInteraction;
64
+ /**
65
+ * Injects CSS styles for the modal
66
+ */
59
67
  private injectStyles;
68
+ /**
69
+ * Shows the modal with animation
70
+ */
60
71
  show(): void;
72
+ /**
73
+ * Setup click handlers for iOS/Android platform toggle
74
+ */
61
75
  private setupPlatformToggles;
62
- private lockBodyScroll;
63
- private unlockBodyScroll;
76
+ /**
77
+ * Closes the modal with animation
78
+ */
64
79
  close(): void;
80
+ /**
81
+ * Removes modal elements from DOM
82
+ */
65
83
  private cleanup;
84
+ /**
85
+ * Check if modal is currently open
86
+ */
87
+ isModalOpen(): boolean;
66
88
  }