@nibssplc/cams-sdk 0.0.1-beta.35 → 0.0.1-beta.37

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/dist/index.esm.js CHANGED
@@ -54,7 +54,7 @@ var LogLevel;
54
54
  LogLevel[LogLevel["DEBUG"] = 3] = "DEBUG";
55
55
  })(LogLevel || (LogLevel = {}));
56
56
  class Logger {
57
- static level = LogLevel.WARN;
57
+ static level = LogLevel.DEBUG;
58
58
  static prefix = '[CAMS-SDK]';
59
59
  static isTestEnv = typeof process !== 'undefined' && process.env && process.env.NODE_ENV === 'test';
60
60
  static setLevel(level) {
@@ -82,18 +82,17 @@ class Logger {
82
82
  }
83
83
  }
84
84
 
85
- // Capture original functions to prevent tampering
86
- const originalWindowOpen = window.open;
87
- const originalAddEventListener = window.addEventListener;
88
- const originalRemoveEventListener = window.removeEventListener;
89
- const originalSetTimeout = window.setTimeout;
90
- const originalClearTimeout = window.clearTimeout;
85
+ // Capture original functions to prevent tampering (client-side only)
86
+ const originalAddEventListener = typeof window !== "undefined" ? window.addEventListener : null;
87
+ const originalRemoveEventListener = typeof window !== "undefined" ? window.removeEventListener : null;
88
+ const originalSetTimeout = typeof window !== "undefined" ? window.setTimeout : setTimeout;
89
+ const originalClearTimeout = typeof window !== "undefined" ? window.clearTimeout : clearTimeout;
91
90
  // Generate random window name to prevent targeting
92
91
  const generateSecureWindowName = () => `cams_auth_${Math.random().toString(36).slice(2, 9)}_${Date.now()}`;
93
- // Track active auth window for manual closure
94
- let activeAuthWindow = null;
95
92
  // Detect if current window is a popup
96
93
  const isPopupWindow = () => {
94
+ if (typeof window === "undefined")
95
+ return false;
97
96
  try {
98
97
  return window.opener !== null && window.opener !== window;
99
98
  }
@@ -101,24 +100,6 @@ const isPopupWindow = () => {
101
100
  return false;
102
101
  }
103
102
  };
104
- // Forward authentication result to parent window
105
- const forwardAuthToParent = (data, targetOrigin = '*') => {
106
- if (isPopupWindow() && window.opener) {
107
- try {
108
- window.opener.postMessage(data, targetOrigin);
109
- window.close();
110
- }
111
- catch (error) {
112
- console.error('Failed to forward auth to parent:', error);
113
- }
114
- }
115
- };
116
- const closeWindow = () => {
117
- if (activeAuthWindow && !activeAuthWindow.closed) {
118
- activeAuthWindow.close();
119
- activeAuthWindow = null;
120
- }
121
- };
122
103
  function validateConfig(config) {
123
104
  // Validate URL format and parse once
124
105
  const urlValidation = URLSchema.safeParse(config.camsUrl);
@@ -134,6 +115,10 @@ function validateConfig(config) {
134
115
  }
135
116
  function openCAMSPopUpLogin(config) {
136
117
  return new Promise((resolve, reject) => {
118
+ if (typeof window === "undefined") {
119
+ reject(new CAMSError(CAMSErrorType.POPUP_BLOCKED, "Cannot open popup in server-side environment"));
120
+ return;
121
+ }
137
122
  if (config.debug)
138
123
  Logger.setLevel(LogLevel.DEBUG);
139
124
  // If this is a popup window, don't open another popup
@@ -171,9 +156,7 @@ function openCAMSPopUpLogin(config) {
171
156
  const left = (window.screen.width - windowWidth) / 2;
172
157
  const top = (window.screen.height - windowHeight) / 2;
173
158
  const secureWindowName = generateSecureWindowName();
174
- authWindow = originalWindowOpen.call(window, validatedUrl.toString(), secureWindowName, `width=${windowWidth},height=${windowHeight},left=${left},top=${top},scrollbars=yes,resizable=yes`);
175
- // Track active window for manual closure
176
- activeAuthWindow = authWindow;
159
+ authWindow = window.open(validatedUrl.toString(), secureWindowName, `width=${windowWidth},height=${windowHeight},left=${left},top=${top},scrollbars=yes,resizable=yes`);
177
160
  }
178
161
  catch (error) {
179
162
  Logger.error("Failed to open popup window", {
@@ -195,7 +178,9 @@ function openCAMSPopUpLogin(config) {
195
178
  }
196
179
  Logger.debug("Popup window opened successfully");
197
180
  const cleanup = () => {
198
- originalRemoveEventListener.call(window, "message", listener);
181
+ if (originalRemoveEventListener) {
182
+ originalRemoveEventListener.call(window, "message", listener);
183
+ }
199
184
  if (idleTimeoutId)
200
185
  originalClearTimeout(idleTimeoutId);
201
186
  if (authTimeoutId)
@@ -302,7 +287,6 @@ function openCAMSPopUpLogin(config) {
302
287
  if (authWindow && !authWindow.closed) {
303
288
  authWindow.close();
304
289
  }
305
- activeAuthWindow = null;
306
290
  }
307
291
  catch {
308
292
  // Ignore close errors
@@ -341,8 +325,13 @@ function openCAMSPopUpLogin(config) {
341
325
  };
342
326
  checkClosedInterval = originalSetTimeout(checkClosed, pollInterval);
343
327
  try {
344
- originalAddEventListener.call(window, "message", listener);
345
- Logger.debug("Message listener attached");
328
+ if (originalAddEventListener) {
329
+ originalAddEventListener.call(window, "message", listener);
330
+ Logger.debug("Message listener attached");
331
+ }
332
+ else {
333
+ throw new Error("addEventListener not available");
334
+ }
346
335
  }
347
336
  catch (error) {
348
337
  Logger.error("Failed to attach message listener", {
@@ -365,75 +354,6 @@ function openCAMSPopUpLogin(config) {
365
354
  });
366
355
  }
367
356
 
368
- /**
369
- * Initialize popup authentication handler
370
- * This should be called in the popup window to handle auth completion
371
- */
372
- function initializePopupAuth(targetOrigin) {
373
- if (!isPopupWindow()) {
374
- Logger.debug("Not in popup window, skipping popup auth initialization");
375
- return;
376
- }
377
- Logger.info("Initializing popup authentication handler");
378
- // Listen for auth completion events from the popup app
379
- const handleAuthComplete = (profile) => {
380
- Logger.info("Authentication completed in popup, forwarding to parent");
381
- forwardAuthToParent(profile, targetOrigin);
382
- };
383
- // Listen for auth errors
384
- const handleAuthError = (error) => {
385
- Logger.warn("Authentication error in popup, forwarding to parent");
386
- forwardAuthToParent({
387
- type: "AUTH_FAILURE",
388
- error: error.message || "Authentication failed",
389
- errorCode: error.code,
390
- errorDetails: error
391
- }, targetOrigin);
392
- };
393
- // Expose global handlers for the popup app to use
394
- window.__CAMS_POPUP_AUTH__ = {
395
- completeAuth: handleAuthComplete,
396
- errorAuth: handleAuthError,
397
- isPopup: true
398
- };
399
- Logger.debug("Popup authentication handlers registered");
400
- }
401
- /**
402
- * Complete authentication in popup window
403
- * Call this when authentication is successful in the popup
404
- */
405
- function completePopupAuth(profile, targetOrigin) {
406
- if (!isPopupWindow()) {
407
- Logger.warn("completePopupAuth called outside of popup window");
408
- return;
409
- }
410
- Logger.info("Completing popup authentication");
411
- forwardAuthToParent(profile, targetOrigin);
412
- }
413
- /**
414
- * Report authentication error in popup window
415
- * Call this when authentication fails in the popup
416
- */
417
- function errorPopupAuth(error, targetOrigin) {
418
- if (!isPopupWindow()) {
419
- Logger.warn("errorPopupAuth called outside of popup window");
420
- return;
421
- }
422
- Logger.warn("Reporting popup authentication error");
423
- forwardAuthToParent({
424
- type: "AUTH_FAILURE",
425
- error: error.message || "Authentication failed",
426
- errorCode: error.code,
427
- errorDetails: error
428
- }, targetOrigin);
429
- }
430
- /**
431
- * Check if current window is a CAMS popup
432
- */
433
- function isCAMSPopup() {
434
- return isPopupWindow() && !!window.__CAMS_POPUP_AUTH__;
435
- }
436
-
437
357
  class CAMSSessionManager {
438
358
  storage;
439
359
  keyPrefix;
@@ -642,13 +562,11 @@ class CAMSSessionManager {
642
562
  this.profile = profile;
643
563
  this.setToken(profile.userProfile.tokens.Bearer);
644
564
  Logger.info("Authentication completed in popup, forwarding to parent");
645
- completePopupAuth(profile, targetOrigin);
646
565
  }
647
566
  catch (error) {
648
567
  Logger.error("Failed to complete popup authentication", {
649
568
  error: error instanceof Error ? error.message : "Unknown error"
650
569
  });
651
- errorPopupAuth(error, targetOrigin);
652
570
  }
653
571
  }
654
572
  /**
@@ -660,7 +578,6 @@ class CAMSSessionManager {
660
578
  return;
661
579
  }
662
580
  Logger.warn("Reporting authentication error from popup");
663
- errorPopupAuth(error, targetOrigin);
664
581
  }
665
582
  }
666
583
  // 🔹 Safe fallback for Node/SSR
@@ -729,6 +646,7 @@ class CAMSMFAAuthenticator {
729
646
  throw new Error(`HTTP ${response.status}: ${response.statusText}`);
730
647
  }
731
648
  const data = await response.json();
649
+ console.log("MFA Response >>>", data);
732
650
  if (data.isAuthenticated) {
733
651
  Logger.info("MFA verification successful");
734
652
  this.resetAttempts();
@@ -754,5 +672,5 @@ class CAMSMFAAuthenticator {
754
672
  }
755
673
  }
756
674
 
757
- export { AuthFailureMessageSchema, CAMSError, CAMSErrorType, CAMSMFAAuthenticator, CAMSSessionManager, ErrorMessageSchema, LogLevel, Logger, ProfileSchema, URLSchema, closeWindow, completePopupAuth, errorPopupAuth, forwardAuthToParent, generateSecureWindowName, initializePopupAuth, isCAMSPopup, isPopupWindow, openCAMSPopUpLogin, validateConfig };
675
+ export { AuthFailureMessageSchema, CAMSError, CAMSErrorType, CAMSMFAAuthenticator, CAMSSessionManager, ErrorMessageSchema, LogLevel, Logger, ProfileSchema, URLSchema, generateSecureWindowName, isPopupWindow, openCAMSPopUpLogin, validateConfig };
758
676
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/types.ts","../src/validators.ts","../src/logger.ts","../src/auth.ts","../src/popupAuth.ts","../src/sessionManager.ts","../src/mfaAuth.ts"],"sourcesContent":["export interface CAMSConfig {\n camsUrl: string;\n messageOrigin: string; // Expected message origin\n windowWidth: number;\n windowHeight: number;\n authTimeout?: number; // Auth timeout in ms (default: 300000) // 5 minutes as a final failsafe\n idleTimeout?: number; // 1 minute of inactivity\n storageKey?: string; // Custom storage key\n retryAttempts?: number; // Auto-retry on failure (default: 0)\n debug?: boolean; // Enable debug logging (default: false)\n}\n\nexport enum CAMSErrorType {\n POPUP_BLOCKED = \"POPUP_BLOCKED\",\n TIMEOUT = \"TIMEOUT\",\n INVALID_ORIGIN = \"INVALID_ORIGIN\",\n USER_CANCELLED = \"USER_CANCELLED\",\n INVALID_URL = \"INVALID_URL\",\n MAX_RETRIES_EXCEEDED = \"MAX_RETRIES_EXCEEDED\",\n API_VALIDATION_ERROR = \"VALIDATION_ERROR\",\n}\n\nexport class CAMSError extends Error {\n constructor(public type: CAMSErrorType, message: string) {\n super(message);\n this.name = this.constructor.name;\n }\n}","import { z } from \"zod\";\n\n// Validate the returned token - non-empty string\nexport const ProfileSchema = z.object({\n type: z.literal(\"AUTH_SUCCESS\").or(z.literal(\"AUTH_FAILURE\")),\n userProfile: z.object({\n name: z.string(),\n email: z.email(),\n mfaIsEnabled: z.boolean(),\n message: z.string(),\n isAuthenticated: z.boolean(),\n userType: z.enum([\"SUPER_ADMIN\", \"ADMIN\", \"USER\"]),\n tokens: z.object({\n Nonce: z.string(),\n Bearer: z.string(),\n }),\n }),\n});\n\nexport type Profile = z.infer<typeof ProfileSchema>;\n\nexport const ErrorMessageSchema = z.object({\n error: z.string().min(1, \"Error message cannot be empty\"),\n});\n\nexport const AuthFailureMessageSchema = z.object({\n type: z.literal(\"AUTH_FAILURE\"),\n error: z.string().min(1, \"Error message cannot be empty\"),\n errorCode: z.string(),\n errorDetails: z.object().or(z.any()),\n});\n\nexport type AuthFailureMessage = z.infer<typeof AuthFailureMessageSchema>;\n\nexport const URLSchema = z.url();\n","export enum LogLevel {\n ERROR = 0,\n WARN = 1,\n INFO = 2,\n DEBUG = 3\n}\n\nexport interface LogContext {\n [key: string]: any;\n}\n\nexport class Logger {\n private static level: LogLevel = LogLevel.WARN;\n private static readonly prefix = '[CAMS-SDK]';\n private static readonly isTestEnv = typeof process !== 'undefined' && process.env && process.env.NODE_ENV === 'test';\n\n static setLevel(level: LogLevel): void {\n Logger.level = level;\n }\n\n static error(message: string, context?: LogContext): void {\n if (!Logger.isTestEnv && Logger.level >= LogLevel.ERROR) {\n console.error(`${Logger.prefix} ERROR:`, message, context || '');\n }\n }\n\n static warn(message: string, context?: LogContext): void {\n if (!Logger.isTestEnv && Logger.level >= LogLevel.WARN) {\n console.warn(`${Logger.prefix} WARN:`, message, context || '');\n }\n }\n\n static info(message: string, context?: LogContext): void {\n if (!Logger.isTestEnv && Logger.level >= LogLevel.INFO) {\n console.info(`${Logger.prefix} INFO:`, message, context || '');\n }\n }\n\n static debug(message: string, context?: LogContext): void {\n if (!Logger.isTestEnv && Logger.level >= LogLevel.DEBUG) {\n console.debug(`${Logger.prefix} DEBUG:`, message, context || '');\n }\n }\n}","import { CAMSConfig, CAMSError, CAMSErrorType } from \"./types\";\nimport {\n ProfileSchema,\n ErrorMessageSchema,\n AuthFailureMessageSchema,\n URLSchema,\n Profile,\n} from \"./validators\";\nimport { Logger, LogLevel } from \"./logger\";\n\n// Capture original functions to prevent tampering\nconst originalWindowOpen = window.open;\nconst originalAddEventListener = window.addEventListener;\nconst originalRemoveEventListener = window.removeEventListener;\nconst originalSetTimeout = window.setTimeout;\nconst originalClearTimeout = window.clearTimeout;\n\n// Generate random window name to prevent targeting\nexport const generateSecureWindowName = () =>\n `cams_auth_${Math.random().toString(36).slice(2, 9)}_${Date.now()}`;\n\n// Track active auth window for manual closure\nlet activeAuthWindow: Window | null = null;\n\n// Detect if current window is a popup\nexport const isPopupWindow = (): boolean => {\n try {\n return window.opener !== null && window.opener !== window;\n } catch {\n return false;\n }\n};\n\n// Forward authentication result to parent window\nexport const forwardAuthToParent = (data: any, targetOrigin: string = '*'): void => {\n if (isPopupWindow() && window.opener) {\n try {\n window.opener.postMessage(data, targetOrigin);\n window.close();\n } catch (error) {\n console.error('Failed to forward auth to parent:', error);\n }\n }\n};\n\nexport const closeWindow = (): void => {\n if (activeAuthWindow && !activeAuthWindow.closed) {\n activeAuthWindow.close();\n activeAuthWindow = null;\n }\n};\n\nexport function validateConfig(config: CAMSConfig): URL {\n // Validate URL format and parse once\n const urlValidation = URLSchema.safeParse(config.camsUrl);\n if (!urlValidation.success) {\n throw new CAMSError(CAMSErrorType.INVALID_URL, \"Invalid CAMS URL format\");\n }\n\n // Domain validation is mandatory for security\n if (!config.messageOrigin) {\n throw new CAMSError(\n CAMSErrorType.INVALID_URL,\n \"Message Origin must be specified for security\"\n );\n }\n\n const url = new URL(config.camsUrl);\n\n return url;\n}\n\nexport function openCAMSPopUpLogin(config: CAMSConfig): Promise<Profile> {\n return new Promise((resolve, reject) => {\n if (config.debug) Logger.setLevel(LogLevel.DEBUG);\n\n // If this is a popup window, don't open another popup\n if (isPopupWindow()) {\n Logger.warn(\"Cannot open popup from within popup window\");\n reject(new CAMSError(\n CAMSErrorType.POPUP_BLOCKED,\n \"Cannot open authentication popup from within popup window\"\n ));\n return;\n }\n\n Logger.info(\"Starting CAMS authentication\", { url: config.camsUrl });\n\n let validatedUrl: URL;\n try {\n validatedUrl = validateConfig(config);\n Logger.debug(\"Config validation passed\");\n } catch (error) {\n Logger.error(\"Config validation failed\", {\n error: error instanceof Error ? error.message : \"Unknown error\",\n });\n reject(error as Error);\n return;\n }\n\n const {\n messageOrigin,\n windowHeight,\n windowWidth,\n authTimeout = 300000, // 5 minutes as a final failsafe\n idleTimeout = 120000, // 2 minutes of inactivity\n } = config;\n let authWindow: Window | null;\n let authTimeoutId: number | null = null;\n let idleTimeoutId: number | null = null;\n let checkClosedInterval: number | null = null;\n\n try {\n Logger.debug(\"Opening popup window\", {\n width: windowWidth,\n height: windowHeight,\n });\n\n // Center the popup window\n const left = (window.screen.width - windowWidth) / 2;\n const top = (window.screen.height - windowHeight) / 2;\n\n const secureWindowName = generateSecureWindowName();\n authWindow = originalWindowOpen.call(\n window,\n validatedUrl.toString(),\n secureWindowName,\n `width=${windowWidth},height=${windowHeight},left=${left},top=${top},scrollbars=yes,resizable=yes`\n );\n \n // Track active window for manual closure\n activeAuthWindow = authWindow;\n } catch (error) {\n Logger.error(\"Failed to open popup window\", {\n error: error instanceof Error ? error.message : \"Unknown error\",\n });\n reject(\n new CAMSError(\n CAMSErrorType.POPUP_BLOCKED,\n \"Popup blocked by browser. Please allow popups and try again.\"\n )\n );\n return;\n }\n\n if (!authWindow) {\n Logger.error(\"Popup window blocked\");\n reject(\n new CAMSError(\n CAMSErrorType.POPUP_BLOCKED,\n \"Popup blocked by browser. Please allow popups and try again.\"\n )\n );\n return;\n }\n\n // Only check for immediate closure (true popup blocking)\n if (authWindow.closed) {\n Logger.error(\"Popup immediately closed by blocker\");\n reject(\n new CAMSError(\n CAMSErrorType.POPUP_BLOCKED,\n \"Popup blocked by browser. Please allow popups and try again.\"\n )\n );\n return;\n }\n\n Logger.debug(\"Popup window opened successfully\");\n\n const cleanup = () => {\n originalRemoveEventListener.call(window, \"message\", listener);\n\n if (idleTimeoutId) originalClearTimeout(idleTimeoutId);\n if (authTimeoutId) originalClearTimeout(authTimeoutId);\n if (checkClosedInterval) originalClearTimeout(checkClosedInterval);\n idleTimeoutId = null;\n authTimeoutId = null;\n checkClosedInterval = null;\n };\n\n const listener = (event: Event) => {\n const messageEvent = event as MessageEvent;\n Logger.debug(\"Received message\", {\n origin: messageEvent.origin,\n expectedOrigin: messageOrigin,\n data: messageEvent.data,\n });\n\n const originUrl = new URL(messageEvent.origin);\n const expectedHostname = messageOrigin.startsWith(\"http\")\n ? new URL(messageOrigin).hostname\n : messageOrigin;\n\n // Allow Microsoft redirect domains for Azure AD authentication\n const isMicrosoftDomain =\n originUrl.hostname.endsWith(\".microsoft.com\") ||\n originUrl.hostname.endsWith(\".microsoftonline.com\") ||\n originUrl.hostname.endsWith(\".live.com\");\n\n const isAllowedOrigin =\n originUrl.hostname === expectedHostname ||\n originUrl.hostname.endsWith(\".\" + expectedHostname) ||\n isMicrosoftDomain;\n\n if (!isAllowedOrigin) {\n Logger.warn(\"Blocked message from unauthorized origin\", {\n origin: messageEvent.origin,\n expected: messageOrigin,\n data: messageEvent.data,\n });\n return;\n }\n\n // Validate event source\n if (messageEvent.source !== authWindow) {\n Logger.warn(\"Message from unexpected source\", {\n source: messageEvent.source,\n origin: messageEvent.origin,\n expected: messageOrigin,\n data: messageEvent.data,\n });\n return;\n }\n\n // Validate event source\n if (messageEvent.source !== authWindow) {\n Logger.warn(\"Message from unexpected source\", {\n source: messageEvent.source,\n origin: messageEvent.origin,\n expected: messageOrigin,\n data: messageEvent.data,\n });\n return;\n }\n\n // Ignore heartbeat messages\n if (messageEvent.data?.type === \"heartbeat\") {\n Logger.debug(\"Received heartbeat message\");\n resetIdleTimeout();\n return;\n }\n\n // ✅ Validate payload\n const tokenMsg = ProfileSchema.safeParse(messageEvent.data);\n if (tokenMsg.success) {\n Logger.info(\"Authentication successful\");\n cleanupAndClose();\n resolve(tokenMsg.data);\n return;\n }\n\n const authFailureMsg = AuthFailureMessageSchema.safeParse(\n messageEvent.data\n );\n if (authFailureMsg.success) {\n Logger.warn(\"Authentication failure received\", {\n errorDetails: authFailureMsg.data.errorDetails,\n error: authFailureMsg.data.error,\n errorCode: authFailureMsg.data.errorCode,\n });\n cleanupAndClose(\n new CAMSError(\n CAMSErrorType.API_VALIDATION_ERROR,\n \"Authentication failed: \" + authFailureMsg.data.error\n )\n );\n return;\n }\n\n const errorMsg = ErrorMessageSchema.safeParse(messageEvent.data);\n if (errorMsg.success) {\n Logger.warn(\"Authentication error received\", {\n error: errorMsg.data.error,\n });\n cleanupAndClose(\n new CAMSError(\n CAMSErrorType.USER_CANCELLED,\n \"Authentication failed: \" + errorMsg.data.error\n )\n );\n return;\n }\n\n Logger.error(\"Invalid message format received\", {\n messageData: messageEvent.data,\n dataType: typeof messageEvent.data,\n tokenValidationError: tokenMsg.error\n ? tokenMsg.error.issues\n : undefined,\n errorValidationError: errorMsg.error\n ? errorMsg.error.issues\n : undefined,\n });\n cleanupAndClose(\n new CAMSError(CAMSErrorType.INVALID_ORIGIN, \"Invalid message format\")\n );\n };\n\n const cleanupAndClose = (error?: CAMSError) => {\n cleanup();\n try {\n if (authWindow && !authWindow.closed) {\n authWindow.close();\n }\n activeAuthWindow = null;\n } catch {\n // Ignore close errors\n }\n if (error) reject(error);\n };\n\n const resetIdleTimeout = () => {\n // Timeout handler\n if (idleTimeoutId) originalClearTimeout(idleTimeoutId);\n Logger.debug(\"Resetting idle timeout\", { idleTimeout });\n idleTimeoutId = originalSetTimeout(() => {\n Logger.warn(\"Authentication idle timeout reached\", { idleTimeout });\n cleanupAndClose(\n new CAMSError(\n CAMSErrorType.TIMEOUT,\n `Authentication timed out due to inactivity after ${idleTimeout}ms`\n )\n );\n }, idleTimeout);\n };\n\n Logger.debug(\"Setting auth timeout\", { authTimeout });\n authTimeoutId = originalSetTimeout(() => {\n Logger.warn(\"Authentication auth timeout reached\", { authTimeout });\n cleanupAndClose(\n new CAMSError(\n CAMSErrorType.TIMEOUT,\n `Authentication process exceeded auth time limit of ${authTimeout}ms`\n )\n );\n }, authTimeout);\n\n resetIdleTimeout();\n\n // Use exponential backoff for popup closure checking\n let pollInterval = 1000; // Start with 1 second\n const maxPollInterval = 5000; // Max 5 seconds\n\n const checkClosed = () => {\n if (authWindow?.closed) {\n Logger.info(\"Authentication window closed by user\");\n cleanupAndClose(\n new CAMSError(\n CAMSErrorType.USER_CANCELLED,\n \"Authentication window was closed\"\n )\n );\n return;\n }\n\n // Exponential backoff: increase interval up to max\n pollInterval = Math.min(pollInterval * 1.2, maxPollInterval);\n checkClosedInterval = originalSetTimeout(checkClosed, pollInterval);\n };\n\n checkClosedInterval = originalSetTimeout(checkClosed, pollInterval);\n\n try {\n originalAddEventListener.call(window, \"message\", listener);\n Logger.debug(\"Message listener attached\");\n } catch (error) {\n Logger.error(\"Failed to attach message listener\", {\n error: error instanceof Error ? error.message : \"Unknown error\",\n });\n cleanup();\n reject(\n new CAMSError(\n CAMSErrorType.POPUP_BLOCKED,\n \"Failed to set up message listener: \" +\n (error instanceof Error ? error.message : \"Unknown error\")\n )\n );\n return;\n }\n\n // Add focus to the popup for better UX\n try {\n if (authWindow && !authWindow.closed) {\n authWindow.focus();\n }\n } catch {\n // Ignore focus errors (cross-origin restrictions)\n }\n });\n}\n","import { Profile } from \"./validators\";\nimport { Logger } from \"./logger\";\nimport { isPopupWindow, forwardAuthToParent } from \"./auth\";\n\n/**\n * Initialize popup authentication handler\n * This should be called in the popup window to handle auth completion\n */\nexport function initializePopupAuth(targetOrigin?: string): void {\n if (!isPopupWindow()) {\n Logger.debug(\"Not in popup window, skipping popup auth initialization\");\n return;\n }\n\n Logger.info(\"Initializing popup authentication handler\");\n\n // Listen for auth completion events from the popup app\n const handleAuthComplete = (profile: Profile) => {\n Logger.info(\"Authentication completed in popup, forwarding to parent\");\n forwardAuthToParent(profile, targetOrigin);\n };\n\n // Listen for auth errors\n const handleAuthError = (error: any) => {\n Logger.warn(\"Authentication error in popup, forwarding to parent\");\n forwardAuthToParent({\n type: \"AUTH_FAILURE\",\n error: error.message || \"Authentication failed\",\n errorCode: error.code,\n errorDetails: error\n }, targetOrigin);\n };\n\n // Expose global handlers for the popup app to use\n (window as any).__CAMS_POPUP_AUTH__ = {\n completeAuth: handleAuthComplete,\n errorAuth: handleAuthError,\n isPopup: true\n };\n\n Logger.debug(\"Popup authentication handlers registered\");\n}\n\n/**\n * Complete authentication in popup window\n * Call this when authentication is successful in the popup\n */\nexport function completePopupAuth(profile: Profile, targetOrigin?: string): void {\n if (!isPopupWindow()) {\n Logger.warn(\"completePopupAuth called outside of popup window\");\n return;\n }\n\n Logger.info(\"Completing popup authentication\");\n forwardAuthToParent(profile, targetOrigin);\n}\n\n/**\n * Report authentication error in popup window\n * Call this when authentication fails in the popup\n */\nexport function errorPopupAuth(error: any, targetOrigin?: string): void {\n if (!isPopupWindow()) {\n Logger.warn(\"errorPopupAuth called outside of popup window\");\n return;\n }\n\n Logger.warn(\"Reporting popup authentication error\");\n forwardAuthToParent({\n type: \"AUTH_FAILURE\",\n error: error.message || \"Authentication failed\",\n errorCode: error.code,\n errorDetails: error\n }, targetOrigin);\n}\n\n/**\n * Check if current window is a CAMS popup\n */\nexport function isCAMSPopup(): boolean {\n return isPopupWindow() && !!(window as any).__CAMS_POPUP_AUTH__;\n}","import {\n CAMSConfig,\n CAMSError,\n CAMSErrorType,\n} from \"./types\";\nimport { openCAMSPopUpLogin, isPopupWindow } from \"./auth\";\nimport { AuthFailureMessage, Profile } from \"./validators\";\nimport { Logger } from \"./logger\";\nimport { completePopupAuth, errorPopupAuth } from \"./popupAuth\";\n\nexport interface CAMSEvents {\n onAuthStart?: () => void;\n onAuthSuccess?: (profile: Profile) => void;\n onAuthError?: (error: CAMSError) => void;\n onTokenExpired?: () => void;\n}\n\nexport class CAMSSessionManager {\n private readonly storage: StorageLike;\n private readonly keyPrefix: string;\n private readonly events: CAMSEvents;\n\n private token: string | null = null;\n private profile: Profile | null = null;\n\n constructor(\n storage: StorageLike | null = null,\n keyPrefix?: string,\n events: CAMSEvents = {}\n ) {\n this.storage = storage || getDefaultStorage();\n this.keyPrefix = keyPrefix ?? \"CAMS-SDK\";\n this.events = events;\n }\n\n setItem(key: string, value: string) {\n this.storage.setItem(`${this.keyPrefix}:${key}`, value);\n }\n\n getItem(key: string) {\n return this.storage.getItem(`${this.keyPrefix}:${key}`);\n }\n\n removeItem(key: string) {\n this.storage.removeItem(`${this.keyPrefix}:${key}`);\n }\n\n clear() {\n // clear only CAMS-prefixed items\n Object.keys(this.storage).forEach((k) => {\n if (k.startsWith(this.keyPrefix)) {\n this.storage.removeItem(k);\n }\n });\n }\n\n async login(config: CAMSConfig): Promise<Profile> {\n try {\n Logger.info(\"Session login started\");\n \n // If we're in a popup, don't attempt to open another popup\n if (isPopupWindow()) {\n Logger.warn(\"Cannot initiate login from popup window\");\n throw new CAMSError(\n CAMSErrorType.POPUP_BLOCKED,\n \"Cannot initiate authentication from within popup window\"\n );\n }\n \n if (this.events.onAuthStart) this.events.onAuthStart();\n\n let attempts = 0;\n const maxAttempts = (config.retryAttempts ?? 0) + 1;\n Logger.debug(\"Login retry configuration\", { maxAttempts });\n\n while (attempts < maxAttempts) {\n try {\n attempts++;\n Logger.debug(\"Login attempt\", { attempt: attempts, maxAttempts });\n\n // Add exponential backoff delay for retries\n if (attempts > 1) {\n const delay = Math.min(1000 * Math.pow(2, attempts - 2), 10000); // Max 10s delay\n Logger.debug(\"Retry delay\", { delay });\n await new Promise((resolve) => setTimeout(resolve, delay));\n }\n\n const response = await openCAMSPopUpLogin(config);\n\n Logger.debug(\"Login Response\", response);\n this.profile = response;\n this.setToken(response.userProfile.tokens.Bearer);\n Logger.info(\"Session login successful\");\n if (this.events.onAuthSuccess) this.events.onAuthSuccess(response);\n return response;\n } catch (error) {\n Logger.warn(\"Login attempt failed\", {\n attempt: attempts,\n error: error instanceof Error ? error.message : \"Unknown error\",\n });\n if (attempts >= maxAttempts || !(error instanceof CAMSError)) {\n throw error;\n }\n // Only retry on specific error types\n if (\n ![CAMSErrorType.TIMEOUT, CAMSErrorType.POPUP_BLOCKED].includes(\n error.type\n )\n ) {\n throw error;\n }\n Logger.info(\"Retrying login\", { nextAttempt: attempts + 1 });\n }\n }\n\n throw new CAMSError(\n CAMSErrorType.MAX_RETRIES_EXCEEDED,\n \"Max retry attempts exceeded\"\n );\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : \"Unknown error\";\n const camsError =\n error instanceof CAMSError\n ? error\n : new CAMSError(CAMSErrorType.USER_CANCELLED, errorMessage);\n Logger.error(\"Session login failed\", {\n error: camsError.message,\n type: camsError.type,\n });\n if (this.events.onAuthError) this.events.onAuthError(camsError);\n throw camsError;\n }\n }\n\n async logout(): Promise<void> {\n Logger.info(\"Session logout\");\n this.clearToken();\n }\n\n setToken(token: string) {\n this.token = token;\n this.storage.setItem(this.keyPrefix, token);\n Logger.debug(\"Token stored\", { storageKey: this.keyPrefix });\n }\n\n getAccessToken(): string | null {\n // Return cached token if available, avoiding redundant storage access\n if (this.token) return this.token;\n\n const raw = this.storage.getItem(this.keyPrefix);\n if (!raw) return null;\n\n this.token = raw;\n Logger.debug(\"Token loaded from storage\");\n return this.token;\n }\n\n clearToken() {\n this.token = null;\n this.storage.removeItem(this.keyPrefix);\n Logger.debug(\"Token cleared\");\n }\n\n private isExpired(): boolean {\n const token = this.getAccessToken();\n if (!token) return true;\n\n try {\n const parts = token.split(\".\");\n if (parts.length < 3) return true; // Invalid JWT format\n const payload = JSON.parse(atob(parts[1]));\n if (typeof payload.exp !== \"number\") return true;\n const exp = payload.exp * 1000;\n return Date.now() > exp;\n } catch (error) {\n Logger.warn(\"Failed to parse JWT token\", {\n error: error instanceof Error ? error.message : \"Unknown error\",\n });\n return true;\n }\n }\n\n isPaddedExpired(): boolean {\n const token = this.getAccessToken();\n if (!token) return true;\n\n try {\n const parts = token.split(\".\");\n if (parts.length < 3) return true; // Invalid JWT format\n const base64 = parts[1].replace(/-/g, \"+\").replace(/_/g, \"/\");\n const padded = base64.padEnd(\n base64.length + ((4 - (base64.length % 4)) % 4),\n \"=\"\n );\n const payload = JSON.parse(atob(padded));\n if (typeof payload.exp !== \"number\") return true;\n const exp = payload.exp * 1000;\n return Date.now() > exp;\n } catch (error) {\n Logger.warn(\"Failed to parse JWT token\", {\n error: error instanceof Error ? error.message : \"Unknown error\",\n });\n return true;\n }\n }\n\n private checkTokenExpiration(): boolean {\n if (this.isExpired()) {\n Logger.info(\"Token expired\");\n if (this.events.onTokenExpired) this.events.onTokenExpired();\n return true;\n }\n return false;\n }\n\n isAuthenticated(): boolean {\n const token = this.getAccessToken();\n if (!token) {\n Logger.debug(\"No token found\");\n return false;\n }\n\n if (this.checkTokenExpiration()) {\n return false;\n }\n\n Logger.debug(\"Token is valid\");\n return true;\n }\n\n async getProfile(): Promise<Profile | null> {\n const storedToken = this.getAccessToken();\n if (!storedToken) return null;\n\n // Check token expiration before processing\n if (this.checkTokenExpiration()) {\n return null;\n }\n\n return this.profile;\n }\n\n getSessionError(): AuthFailureMessage | null {\n return null;\n }\n\n /**\n * Complete authentication in popup window\n * This should be called by popup apps when authentication is successful\n */\n completePopupAuth(profile: Profile, targetOrigin?: string): void {\n if (!isPopupWindow()) {\n Logger.warn(\"completePopupAuth called outside of popup window\");\n return;\n }\n\n try {\n // Store the authentication data locally in the popup\n this.profile = profile;\n this.setToken(profile.userProfile.tokens.Bearer);\n \n Logger.info(\"Authentication completed in popup, forwarding to parent\");\n completePopupAuth(profile, targetOrigin);\n } catch (error) {\n Logger.error(\"Failed to complete popup authentication\", {\n error: error instanceof Error ? error.message : \"Unknown error\"\n });\n errorPopupAuth(error, targetOrigin);\n }\n }\n\n /**\n * Report authentication error in popup window\n */\n errorPopupAuth(error: any, targetOrigin?: string): void {\n if (!isPopupWindow()) {\n Logger.warn(\"errorPopupAuth called outside of popup window\");\n return;\n }\n\n Logger.warn(\"Reporting authentication error from popup\");\n errorPopupAuth(error, targetOrigin);\n }\n}\n\ninterface StorageLike {\n getItem(key: string): string | null;\n setItem(key: string, value: string): void;\n removeItem(key: string): void;\n [key: string]: any; // allows Object.keys to work\n}\n\n// 🔹 Safe fallback for Node/SSR\nfunction getDefaultStorage(): StorageLike {\n if (typeof window !== \"undefined\" && window.localStorage) {\n return window.localStorage;\n }\n\n const memoryStore: Record<string, string> = {};\n return {\n getItem: (key) => (key in memoryStore ? memoryStore[key] : null),\n setItem: (key, value) => {\n memoryStore[key] = value;\n },\n removeItem: (key) => {\n delete memoryStore[key];\n },\n key: (i: number) => Object.keys(memoryStore)[i] ?? null,\n get length() {\n return Object.keys(memoryStore).length;\n },\n };\n}\n","import { CAMSError, CAMSErrorType } from \"./types\";\nimport { Logger } from \"./logger\";\n\nexport interface MFAConfig {\n accessToken: string;\n idToken: string;\n appCode: string;\n provider: string;\n apiEndpoint?: string;\n}\n\nexport interface MFAResponse {\n name: string;\n email: string;\n isAuthenticated: boolean;\n message: string;\n mfaIsEnabled: boolean;\n userType: string;\n tokens: {\n Bearer: string;\n Nonce: string;\n };\n}\n\nexport interface MFAAuthenticator {\n sendEmailOTP(): Promise<boolean>;\n verifyOTP(code: string, type: 'EmailOTP' | 'AuthenticatorCode'): Promise<MFAResponse>;\n getRemainingAttempts(): number;\n resetAttempts(): void;\n}\n\nexport class CAMSMFAAuthenticator implements MFAAuthenticator {\n private config: MFAConfig;\n private attemptCount = 0;\n private readonly maxAttempts = 3;\n\n constructor(config: MFAConfig) {\n this.config = config;\n }\n\n async sendEmailOTP(): Promise<boolean> {\n try {\n Logger.debug(\"Sending Email OTP\");\n // Implementation would call your API to send email OTP\n // For now, return true as placeholder\n return true;\n } catch (error) {\n Logger.error(\"Failed to send Email OTP\", { error });\n return false;\n }\n }\n\n async verifyOTP(code: string, type: 'EmailOTP' | 'AuthenticatorCode'): Promise<MFAResponse> {\n if (this.attemptCount >= this.maxAttempts) {\n throw new CAMSError(\n CAMSErrorType.MAX_RETRIES_EXCEEDED,\n \"Maximum MFA attempts exceeded\"\n );\n }\n\n this.attemptCount++;\n\n try {\n Logger.debug(\"Verifying MFA code\", { type, attempt: this.attemptCount });\n\n const response = await fetch(this.config.apiEndpoint || '/api/auth/verify-mfa', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${this.config.accessToken}`,\n },\n body: JSON.stringify({\n provider: this.config.provider,\n accessToken: this.config.accessToken,\n idToken: this.config.idToken,\n authenticationType: type,\n MFACode: code,\n appCode: this.config.appCode,\n }),\n });\n\n if (!response.ok) {\n throw new Error(`HTTP ${response.status}: ${response.statusText}`);\n }\n\n const data: MFAResponse = await response.json();\n \n if (data.isAuthenticated) {\n Logger.info(\"MFA verification successful\");\n this.resetAttempts();\n return data;\n } else {\n throw new CAMSError(\n CAMSErrorType.API_VALIDATION_ERROR,\n data.message || \"MFA verification failed\"\n );\n }\n } catch (error) {\n Logger.error(\"MFA verification failed\", { error, attempt: this.attemptCount });\n \n if (error instanceof CAMSError) {\n throw error;\n }\n \n throw new CAMSError(\n CAMSErrorType.API_VALIDATION_ERROR,\n `MFA verification failed: ${error instanceof Error ? error.message : 'Unknown error'}`\n );\n }\n }\n\n getRemainingAttempts(): number {\n return Math.max(0, this.maxAttempts - this.attemptCount);\n }\n\n resetAttempts(): void {\n this.attemptCount = 0;\n }\n}"],"names":[],"mappings":";;IAYY;AAAZ,CAAA,UAAY,aAAa,EAAA;AACvB,IAAA,aAAA,CAAA,eAAA,CAAA,GAAA,eAA+B;AAC/B,IAAA,aAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB,IAAA,aAAA,CAAA,gBAAA,CAAA,GAAA,gBAAiC;AACjC,IAAA,aAAA,CAAA,gBAAA,CAAA,GAAA,gBAAiC;AACjC,IAAA,aAAA,CAAA,aAAA,CAAA,GAAA,aAA2B;AAC3B,IAAA,aAAA,CAAA,sBAAA,CAA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CAAC;AAEF,YAAA,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;AAChB,gBAAA,MAAM,IAAI,KAAK,CAAC,CAAA,KAAA,EAAQ,QAAQ,CAAC,MAAM,CAAA,EAAA,EAAK,QAAQ,CAAC,UAAU,CAAA,CAAE,CAAC;YACpE;AAEA,YAAA,MAAM,IAAI,GAAgB,MAAM,QAAQ,CAAC,IAAI,EAAE;AAE/C,YAAA,IAAI,IAAI,CAAC,eAAe,EAAE;AACxB,gBAAA,MAAM,CAAC,IAAI,CAAC,6BAA6B,CAAC;gBAC1C,IAAI,CAAC,aAAa,EAAE;AACpB,gBAAA,OAAO,IAAI;YACb;iBAAO;AACL,gBAAA,MAAM,IAAI,SAAS,CACjB,aAAa,CAAC,oBAAoB,EAClC,IAAI,CAAC,OAAO,IAAI,yBAAyB,CAC1C;YACH;QACF;QAAE,OAAO,KAAK,EAAE;AACd,YAAA,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC;AAE9E,YAAA,IAAI,KAAK,YAAY,SAAS,EAAE;AAC9B,gBAAA,MAAM,KAAK;YACb;YAEA,MAAM,IAAI,SAAS,CACjB,aAAa,CAAC,oBAAoB,EAClC,CAAA,yBAAA,EAA4B,KAAK,YAAY,KAAK,GAAG,KAAK,CAAC,OAAO,GAAG,eAAe,CAAA,CAAE,CACvF;QACH;IACF;IAEA,oBAAoB,GAAA;AAClB,QAAA,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC;IAC1D;IAEA,aAAa,GAAA;AACX,QAAA,IAAI,CAAC,YAAY,GAAG,CAAC;IACvB;AACD;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":["../src/types.ts","../src/validators.ts","../src/logger.ts","../src/auth.ts","../src/sessionManager.ts","../src/MFAAuth.ts"],"sourcesContent":["export interface CAMSConfig {\n camsUrl: string;\n messageOrigin: string; // Expected message origin\n windowWidth: number;\n windowHeight: number;\n authTimeout?: number; // Auth timeout in ms (default: 300000) // 5 minutes as a final failsafe\n idleTimeout?: number; // 1 minute of inactivity\n storageKey?: string; // Custom storage key\n retryAttempts?: number; // Auto-retry on failure (default: 0)\n debug?: boolean; // Enable debug logging (default: false)\n}\n\nexport enum CAMSErrorType {\n POPUP_BLOCKED = \"POPUP_BLOCKED\",\n TIMEOUT = \"TIMEOUT\",\n INVALID_ORIGIN = \"INVALID_ORIGIN\",\n USER_CANCELLED = \"USER_CANCELLED\",\n INVALID_URL = \"INVALID_URL\",\n MAX_RETRIES_EXCEEDED = \"MAX_RETRIES_EXCEEDED\",\n API_VALIDATION_ERROR = \"VALIDATION_ERROR\",\n}\n\nexport class CAMSError extends Error {\n constructor(public type: CAMSErrorType, message: string) {\n super(message);\n this.name = this.constructor.name;\n }\n}","import { z } from \"zod\";\n\n// Validate the returned token - non-empty string\nexport const ProfileSchema = z.object({\n type: z.literal(\"AUTH_SUCCESS\").or(z.literal(\"AUTH_FAILURE\")),\n userProfile: z.object({\n name: z.string(),\n email: z.email(),\n mfaIsEnabled: z.boolean(),\n message: z.string(),\n isAuthenticated: z.boolean(),\n userType: z.enum([\"SUPER_ADMIN\", \"ADMIN\", \"USER\"]),\n tokens: z.object({\n Nonce: z.string(),\n Bearer: z.string(),\n }),\n }),\n});\n\nexport type Profile = z.infer<typeof ProfileSchema>;\n\nexport const ErrorMessageSchema = z.object({\n error: z.string().min(1, \"Error message cannot be empty\"),\n});\n\nexport const AuthFailureMessageSchema = z.object({\n type: z.literal(\"AUTH_FAILURE\"),\n error: z.string().min(1, \"Error message cannot be empty\"),\n errorCode: z.string(),\n errorDetails: z.object().or(z.any()),\n});\n\nexport type AuthFailureMessage = z.infer<typeof AuthFailureMessageSchema>;\n\nexport const URLSchema = z.url();\n","export enum LogLevel {\n ERROR = 0,\n WARN = 1,\n INFO = 2,\n DEBUG = 3\n}\n\nexport interface LogContext {\n [key: string]: any;\n}\n\nexport class Logger {\n private static level: LogLevel = LogLevel.DEBUG;\n private static readonly prefix = '[CAMS-SDK]';\n private static readonly isTestEnv = typeof process !== 'undefined' && process.env && process.env.NODE_ENV === 'test';\n\n static setLevel(level: LogLevel): void {\n Logger.level = level;\n }\n\n static error(message: string, context?: LogContext): void {\n if (!Logger.isTestEnv && Logger.level >= LogLevel.ERROR) {\n console.error(`${Logger.prefix} ERROR:`, message, context || '');\n }\n }\n\n static warn(message: string, context?: LogContext): void {\n if (!Logger.isTestEnv && Logger.level >= LogLevel.WARN) {\n console.warn(`${Logger.prefix} WARN:`, message, context || '');\n }\n }\n\n static info(message: string, context?: LogContext): void {\n if (!Logger.isTestEnv && Logger.level >= LogLevel.INFO) {\n console.info(`${Logger.prefix} INFO:`, message, context || '');\n }\n }\n\n static debug(message: string, context?: LogContext): void {\n if (!Logger.isTestEnv && Logger.level >= LogLevel.DEBUG) {\n console.debug(`${Logger.prefix} DEBUG:`, message, context || '');\n }\n }\n}","import { CAMSConfig, CAMSError, CAMSErrorType } from \"./types\";\nimport {\n ProfileSchema,\n ErrorMessageSchema,\n AuthFailureMessageSchema,\n URLSchema,\n Profile,\n} from \"./validators\";\nimport { Logger, LogLevel } from \"./logger\";\n\n// Capture original functions to prevent tampering (client-side only)\nconst originalAddEventListener =\n typeof window !== \"undefined\" ? window.addEventListener : null;\nconst originalRemoveEventListener =\n typeof window !== \"undefined\" ? window.removeEventListener : null;\nconst originalSetTimeout =\n typeof window !== \"undefined\" ? window.setTimeout : setTimeout;\nconst originalClearTimeout =\n typeof window !== \"undefined\" ? window.clearTimeout : clearTimeout;\n\n// Generate random window name to prevent targeting\nexport const generateSecureWindowName = () =>\n `cams_auth_${Math.random().toString(36).slice(2, 9)}_${Date.now()}`;\n\n// Detect if current window is a popup\nexport const isPopupWindow = (): boolean => {\n if (typeof window === \"undefined\") return false;\n try {\n return window.opener !== null && window.opener !== window;\n } catch {\n return false;\n }\n};\n\nexport function validateConfig(config: CAMSConfig): URL {\n // Validate URL format and parse once\n const urlValidation = URLSchema.safeParse(config.camsUrl);\n if (!urlValidation.success) {\n throw new CAMSError(CAMSErrorType.INVALID_URL, \"Invalid CAMS URL format\");\n }\n\n // Domain validation is mandatory for security\n if (!config.messageOrigin) {\n throw new CAMSError(\n CAMSErrorType.INVALID_URL,\n \"Message Origin must be specified for security\"\n );\n }\n\n const url = new URL(config.camsUrl);\n\n return url;\n}\n\nexport function openCAMSPopUpLogin(config: CAMSConfig): Promise<Profile> {\n return new Promise((resolve, reject) => {\n if (typeof window === \"undefined\") {\n reject(\n new CAMSError(\n CAMSErrorType.POPUP_BLOCKED,\n \"Cannot open popup in server-side environment\"\n )\n );\n return;\n }\n\n if (config.debug) Logger.setLevel(LogLevel.DEBUG);\n\n // If this is a popup window, don't open another popup\n if (isPopupWindow()) {\n Logger.warn(\"Cannot open popup from within popup window\");\n reject(\n new CAMSError(\n CAMSErrorType.POPUP_BLOCKED,\n \"Cannot open authentication popup from within popup window\"\n )\n );\n return;\n }\n\n Logger.info(\"Starting CAMS authentication\", { url: config.camsUrl });\n\n let validatedUrl: URL;\n try {\n validatedUrl = validateConfig(config);\n Logger.debug(\"Config validation passed\");\n } catch (error) {\n Logger.error(\"Config validation failed\", {\n error: error instanceof Error ? error.message : \"Unknown error\",\n });\n reject(error as Error);\n return;\n }\n\n const {\n messageOrigin,\n windowHeight,\n windowWidth,\n authTimeout = 300000, // 5 minutes as a final failsafe\n idleTimeout = 120000, // 2 minutes of inactivity\n } = config;\n let authWindow: Window | null;\n let authTimeoutId: ReturnType<typeof setTimeout> | null = null;\n let idleTimeoutId: ReturnType<typeof setTimeout> | null = null;\n let checkClosedInterval: ReturnType<typeof setTimeout> | null = null;\n\n try {\n Logger.debug(\"Opening popup window\", {\n width: windowWidth,\n height: windowHeight,\n });\n\n // Center the popup window\n const left = (window.screen.width - windowWidth) / 2;\n const top = (window.screen.height - windowHeight) / 2;\n\n const secureWindowName = generateSecureWindowName();\n authWindow = window.open(\n validatedUrl.toString(),\n secureWindowName,\n `width=${windowWidth},height=${windowHeight},left=${left},top=${top},scrollbars=yes,resizable=yes`\n );\n } catch (error) {\n Logger.error(\"Failed to open popup window\", {\n error: error instanceof Error ? error.message : \"Unknown error\",\n });\n reject(\n new CAMSError(\n CAMSErrorType.POPUP_BLOCKED,\n \"Popup blocked by browser. Please allow popups and try again.\"\n )\n );\n return;\n }\n\n if (!authWindow) {\n Logger.error(\"Popup window blocked\");\n reject(\n new CAMSError(\n CAMSErrorType.POPUP_BLOCKED,\n \"Popup blocked by browser. Please allow popups and try again.\"\n )\n );\n return;\n }\n\n // Only check for immediate closure (true popup blocking)\n if (authWindow.closed) {\n Logger.error(\"Popup immediately closed by blocker\");\n reject(\n new CAMSError(\n CAMSErrorType.POPUP_BLOCKED,\n \"Popup blocked by browser. Please allow popups and try again.\"\n )\n );\n return;\n }\n\n Logger.debug(\"Popup window opened successfully\");\n\n const cleanup = () => {\n if (originalRemoveEventListener) {\n originalRemoveEventListener.call(window, \"message\", listener);\n }\n\n if (idleTimeoutId) originalClearTimeout(idleTimeoutId);\n if (authTimeoutId) originalClearTimeout(authTimeoutId);\n if (checkClosedInterval) originalClearTimeout(checkClosedInterval);\n idleTimeoutId = null;\n authTimeoutId = null;\n checkClosedInterval = null;\n };\n\n const listener = (event: Event) => {\n const messageEvent = event as MessageEvent;\n Logger.debug(\"Received message\", {\n origin: messageEvent.origin,\n expectedOrigin: messageOrigin,\n data: messageEvent.data,\n });\n\n const originUrl = new URL(messageEvent.origin);\n const expectedHostname = messageOrigin.startsWith(\"http\")\n ? new URL(messageOrigin).hostname\n : messageOrigin;\n\n // Allow Microsoft redirect domains for Azure AD authentication\n const isMicrosoftDomain =\n originUrl.hostname.endsWith(\".microsoft.com\") ||\n originUrl.hostname.endsWith(\".microsoftonline.com\") ||\n originUrl.hostname.endsWith(\".live.com\");\n\n const isAllowedOrigin =\n originUrl.hostname === expectedHostname ||\n originUrl.hostname.endsWith(\".\" + expectedHostname) ||\n isMicrosoftDomain;\n\n if (!isAllowedOrigin) {\n Logger.warn(\"Blocked message from unauthorized origin\", {\n origin: messageEvent.origin,\n expected: messageOrigin,\n data: messageEvent.data,\n });\n return;\n }\n\n // Validate event source\n if (messageEvent.source !== authWindow) {\n Logger.warn(\"Message from unexpected source\", {\n source: messageEvent.source,\n origin: messageEvent.origin,\n expected: messageOrigin,\n data: messageEvent.data,\n });\n return;\n }\n\n // Validate event source\n if (messageEvent.source !== authWindow) {\n Logger.warn(\"Message from unexpected source\", {\n source: messageEvent.source,\n origin: messageEvent.origin,\n expected: messageOrigin,\n data: messageEvent.data,\n });\n return;\n }\n\n // Ignore heartbeat messages\n if (messageEvent.data?.type === \"heartbeat\") {\n Logger.debug(\"Received heartbeat message\");\n resetIdleTimeout();\n return;\n }\n\n // ✅ Validate payload\n const tokenMsg = ProfileSchema.safeParse(messageEvent.data);\n if (tokenMsg.success) {\n Logger.info(\"Authentication successful\");\n cleanupAndClose();\n resolve(tokenMsg.data);\n return;\n }\n\n const authFailureMsg = AuthFailureMessageSchema.safeParse(\n messageEvent.data\n );\n if (authFailureMsg.success) {\n Logger.warn(\"Authentication failure received\", {\n errorDetails: authFailureMsg.data.errorDetails,\n error: authFailureMsg.data.error,\n errorCode: authFailureMsg.data.errorCode,\n });\n cleanupAndClose(\n new CAMSError(\n CAMSErrorType.API_VALIDATION_ERROR,\n \"Authentication failed: \" + authFailureMsg.data.error\n )\n );\n return;\n }\n\n const errorMsg = ErrorMessageSchema.safeParse(messageEvent.data);\n if (errorMsg.success) {\n Logger.warn(\"Authentication error received\", {\n error: errorMsg.data.error,\n });\n cleanupAndClose(\n new CAMSError(\n CAMSErrorType.USER_CANCELLED,\n \"Authentication failed: \" + errorMsg.data.error\n )\n );\n return;\n }\n\n Logger.error(\"Invalid message format received\", {\n messageData: messageEvent.data,\n dataType: typeof messageEvent.data,\n tokenValidationError: tokenMsg.error\n ? tokenMsg.error.issues\n : undefined,\n errorValidationError: errorMsg.error\n ? errorMsg.error.issues\n : undefined,\n });\n cleanupAndClose(\n new CAMSError(CAMSErrorType.INVALID_ORIGIN, \"Invalid message format\")\n );\n };\n\n const cleanupAndClose = (error?: CAMSError) => {\n cleanup();\n try {\n if (authWindow && !authWindow.closed) {\n authWindow.close();\n }\n } catch {\n // Ignore close errors\n }\n if (error) reject(error);\n };\n\n const resetIdleTimeout = () => {\n // Timeout handler\n if (idleTimeoutId) originalClearTimeout(idleTimeoutId);\n Logger.debug(\"Resetting idle timeout\", { idleTimeout });\n idleTimeoutId = originalSetTimeout(() => {\n Logger.warn(\"Authentication idle timeout reached\", { idleTimeout });\n cleanupAndClose(\n new CAMSError(\n CAMSErrorType.TIMEOUT,\n `Authentication timed out due to inactivity after ${idleTimeout}ms`\n )\n );\n }, idleTimeout);\n };\n\n Logger.debug(\"Setting auth timeout\", { authTimeout });\n authTimeoutId = originalSetTimeout(() => {\n Logger.warn(\"Authentication auth timeout reached\", { authTimeout });\n cleanupAndClose(\n new CAMSError(\n CAMSErrorType.TIMEOUT,\n `Authentication process exceeded auth time limit of ${authTimeout}ms`\n )\n );\n }, authTimeout);\n\n resetIdleTimeout();\n\n // Use exponential backoff for popup closure checking\n let pollInterval = 1000; // Start with 1 second\n const maxPollInterval = 5000; // Max 5 seconds\n\n const checkClosed = () => {\n if (authWindow?.closed) {\n Logger.info(\"Authentication window closed by user\");\n cleanupAndClose(\n new CAMSError(\n CAMSErrorType.USER_CANCELLED,\n \"Authentication window was closed\"\n )\n );\n return;\n }\n\n // Exponential backoff: increase interval up to max\n pollInterval = Math.min(pollInterval * 1.2, maxPollInterval);\n checkClosedInterval = originalSetTimeout(\n checkClosed,\n pollInterval\n );\n };\n\n checkClosedInterval = originalSetTimeout(\n checkClosed,\n pollInterval\n );\n\n try {\n if (originalAddEventListener) {\n originalAddEventListener.call(window, \"message\", listener);\n Logger.debug(\"Message listener attached\");\n } else {\n throw new Error(\"addEventListener not available\");\n }\n } catch (error) {\n Logger.error(\"Failed to attach message listener\", {\n error: error instanceof Error ? error.message : \"Unknown error\",\n });\n cleanup();\n reject(\n new CAMSError(\n CAMSErrorType.POPUP_BLOCKED,\n \"Failed to set up message listener: \" +\n (error instanceof Error ? error.message : \"Unknown error\")\n )\n );\n return;\n }\n\n // Add focus to the popup for better UX\n try {\n if (authWindow && !authWindow.closed) {\n authWindow.focus();\n }\n } catch {\n // Ignore focus errors (cross-origin restrictions)\n }\n });\n}\n","import {\n CAMSConfig,\n CAMSError,\n CAMSErrorType,\n} from \"./types\";\nimport { openCAMSPopUpLogin, isPopupWindow } from \"./auth\";\nimport { AuthFailureMessage, Profile } from \"./validators\";\nimport { Logger } from \"./logger\";\n\nexport interface CAMSEvents {\n onAuthStart?: () => void;\n onAuthSuccess?: (profile: Profile) => void;\n onAuthError?: (error: CAMSError) => void;\n onTokenExpired?: () => void;\n}\n\nexport class CAMSSessionManager {\n private readonly storage: StorageLike;\n private readonly keyPrefix: string;\n private readonly events: CAMSEvents;\n\n private token: string | null = null;\n private profile: Profile | null = null;\n\n constructor(\n storage: StorageLike | null = null,\n keyPrefix?: string,\n events: CAMSEvents = {}\n ) {\n this.storage = storage || getDefaultStorage();\n this.keyPrefix = keyPrefix ?? \"CAMS-SDK\";\n this.events = events;\n }\n\n setItem(key: string, value: string) {\n this.storage.setItem(`${this.keyPrefix}:${key}`, value);\n }\n\n getItem(key: string) {\n return this.storage.getItem(`${this.keyPrefix}:${key}`);\n }\n\n removeItem(key: string) {\n this.storage.removeItem(`${this.keyPrefix}:${key}`);\n }\n\n clear() {\n // clear only CAMS-prefixed items\n Object.keys(this.storage).forEach((k) => {\n if (k.startsWith(this.keyPrefix)) {\n this.storage.removeItem(k);\n }\n });\n }\n\n async login(config: CAMSConfig): Promise<Profile> {\n try {\n Logger.info(\"Session login started\");\n \n // If we're in a popup, don't attempt to open another popup\n if (isPopupWindow()) {\n Logger.warn(\"Cannot initiate login from popup window\");\n throw new CAMSError(\n CAMSErrorType.POPUP_BLOCKED,\n \"Cannot initiate authentication from within popup window\"\n );\n }\n \n if (this.events.onAuthStart) this.events.onAuthStart();\n\n let attempts = 0;\n const maxAttempts = (config.retryAttempts ?? 0) + 1;\n Logger.debug(\"Login retry configuration\", { maxAttempts });\n\n while (attempts < maxAttempts) {\n try {\n attempts++;\n Logger.debug(\"Login attempt\", { attempt: attempts, maxAttempts });\n\n // Add exponential backoff delay for retries\n if (attempts > 1) {\n const delay = Math.min(1000 * Math.pow(2, attempts - 2), 10000); // Max 10s delay\n Logger.debug(\"Retry delay\", { delay });\n await new Promise((resolve) => setTimeout(resolve, delay));\n }\n\n const response = await openCAMSPopUpLogin(config);\n\n Logger.debug(\"Login Response\", response);\n this.profile = response;\n this.setToken(response.userProfile.tokens.Bearer);\n Logger.info(\"Session login successful\");\n if (this.events.onAuthSuccess) this.events.onAuthSuccess(response);\n return response;\n } catch (error) {\n Logger.warn(\"Login attempt failed\", {\n attempt: attempts,\n error: error instanceof Error ? error.message : \"Unknown error\",\n });\n if (attempts >= maxAttempts || !(error instanceof CAMSError)) {\n throw error;\n }\n // Only retry on specific error types\n if (\n ![CAMSErrorType.TIMEOUT, CAMSErrorType.POPUP_BLOCKED].includes(\n error.type\n )\n ) {\n throw error;\n }\n Logger.info(\"Retrying login\", { nextAttempt: attempts + 1 });\n }\n }\n\n throw new CAMSError(\n CAMSErrorType.MAX_RETRIES_EXCEEDED,\n \"Max retry attempts exceeded\"\n );\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : \"Unknown error\";\n const camsError =\n error instanceof CAMSError\n ? error\n : new CAMSError(CAMSErrorType.USER_CANCELLED, errorMessage);\n Logger.error(\"Session login failed\", {\n error: camsError.message,\n type: camsError.type,\n });\n if (this.events.onAuthError) this.events.onAuthError(camsError);\n throw camsError;\n }\n }\n\n async logout(): Promise<void> {\n Logger.info(\"Session logout\");\n this.clearToken();\n }\n\n setToken(token: string) {\n this.token = token;\n this.storage.setItem(this.keyPrefix, token);\n Logger.debug(\"Token stored\", { storageKey: this.keyPrefix });\n }\n\n getAccessToken(): string | null {\n // Return cached token if available, avoiding redundant storage access\n if (this.token) return this.token;\n\n const raw = this.storage.getItem(this.keyPrefix);\n if (!raw) return null;\n\n this.token = raw;\n Logger.debug(\"Token loaded from storage\");\n return this.token;\n }\n\n clearToken() {\n this.token = null;\n this.storage.removeItem(this.keyPrefix);\n Logger.debug(\"Token cleared\");\n }\n\n private isExpired(): boolean {\n const token = this.getAccessToken();\n if (!token) return true;\n\n try {\n const parts = token.split(\".\");\n if (parts.length < 3) return true; // Invalid JWT format\n const payload = JSON.parse(atob(parts[1]));\n if (typeof payload.exp !== \"number\") return true;\n const exp = payload.exp * 1000;\n return Date.now() > exp;\n } catch (error) {\n Logger.warn(\"Failed to parse JWT token\", {\n error: error instanceof Error ? error.message : \"Unknown error\",\n });\n return true;\n }\n }\n\n isPaddedExpired(): boolean {\n const token = this.getAccessToken();\n if (!token) return true;\n\n try {\n const parts = token.split(\".\");\n if (parts.length < 3) return true; // Invalid JWT format\n const base64 = parts[1].replace(/-/g, \"+\").replace(/_/g, \"/\");\n const padded = base64.padEnd(\n base64.length + ((4 - (base64.length % 4)) % 4),\n \"=\"\n );\n const payload = JSON.parse(atob(padded));\n if (typeof payload.exp !== \"number\") return true;\n const exp = payload.exp * 1000;\n return Date.now() > exp;\n } catch (error) {\n Logger.warn(\"Failed to parse JWT token\", {\n error: error instanceof Error ? error.message : \"Unknown error\",\n });\n return true;\n }\n }\n\n private checkTokenExpiration(): boolean {\n if (this.isExpired()) {\n Logger.info(\"Token expired\");\n if (this.events.onTokenExpired) this.events.onTokenExpired();\n return true;\n }\n return false;\n }\n\n isAuthenticated(): boolean {\n const token = this.getAccessToken();\n if (!token) {\n Logger.debug(\"No token found\");\n return false;\n }\n\n if (this.checkTokenExpiration()) {\n return false;\n }\n\n Logger.debug(\"Token is valid\");\n return true;\n }\n\n async getProfile(): Promise<Profile | null> {\n const storedToken = this.getAccessToken();\n if (!storedToken) return null;\n\n // Check token expiration before processing\n if (this.checkTokenExpiration()) {\n return null;\n }\n\n return this.profile;\n }\n\n getSessionError(): AuthFailureMessage | null {\n return null;\n }\n\n /**\n * Complete authentication in popup window\n * This should be called by popup apps when authentication is successful\n */\n completePopupAuth(profile: Profile, targetOrigin?: string): void {\n if (!isPopupWindow()) {\n Logger.warn(\"completePopupAuth called outside of popup window\");\n return;\n }\n\n try {\n // Store the authentication data locally in the popup\n this.profile = profile;\n this.setToken(profile.userProfile.tokens.Bearer);\n \n Logger.info(\"Authentication completed in popup, forwarding to parent\");\n } catch (error) {\n Logger.error(\"Failed to complete popup authentication\", {\n error: error instanceof Error ? error.message : \"Unknown error\"\n });\n }\n }\n\n /**\n * Report authentication error in popup window\n */\n errorPopupAuth(error: any, targetOrigin?: string): void {\n if (!isPopupWindow()) {\n Logger.warn(\"errorPopupAuth called outside of popup window\");\n return;\n }\n\n Logger.warn(\"Reporting authentication error from popup\");\n }\n}\n\ninterface StorageLike {\n getItem(key: string): string | null;\n setItem(key: string, value: string): void;\n removeItem(key: string): void;\n [key: string]: any; // allows Object.keys to work\n}\n\n// 🔹 Safe fallback for Node/SSR\nfunction getDefaultStorage(): StorageLike {\n if (typeof window !== \"undefined\" && window.localStorage) {\n return window.localStorage;\n }\n\n const memoryStore: Record<string, string> = {};\n return {\n getItem: (key) => (key in memoryStore ? memoryStore[key] : null),\n setItem: (key, value) => {\n memoryStore[key] = value;\n },\n removeItem: (key) => {\n delete memoryStore[key];\n },\n key: (i: number) => Object.keys(memoryStore)[i] ?? null,\n get length() {\n return Object.keys(memoryStore).length;\n },\n };\n}\n","import { CAMSError, CAMSErrorType } from \"./types\";\nimport { Logger } from \"./logger\";\n\nexport interface MFAConfig {\n accessToken: string;\n idToken: string;\n appCode: string;\n provider: string;\n apiEndpoint?: string;\n}\n\nexport interface MFAResponse {\n name: string;\n email: string;\n isAuthenticated: boolean;\n message: string;\n mfaIsEnabled: boolean;\n userType: string;\n tokens: {\n Bearer: string;\n Nonce: string;\n };\n}\n\nexport interface MFAAuthenticator {\n sendEmailOTP(): Promise<boolean>;\n verifyOTP(code: string, type: 'EmailOTP' | 'AuthenticatorCode'): Promise<MFAResponse>;\n getRemainingAttempts(): number;\n resetAttempts(): void;\n}\n\nexport class CAMSMFAAuthenticator implements MFAAuthenticator {\n private config: MFAConfig;\n private attemptCount = 0;\n private readonly maxAttempts = 3;\n\n constructor(config: MFAConfig) {\n this.config = config;\n }\n\n async sendEmailOTP(): Promise<boolean> {\n try {\n Logger.debug(\"Sending Email OTP\");\n // Implementation would call your API to send email OTP\n // For now, return true as placeholder\n return true;\n } catch (error) {\n Logger.error(\"Failed to send Email OTP\", { error });\n return false;\n }\n }\n\n async verifyOTP(code: string, type: 'EmailOTP' | 'AuthenticatorCode'): Promise<MFAResponse> {\n if (this.attemptCount >= this.maxAttempts) {\n throw new CAMSError(\n CAMSErrorType.MAX_RETRIES_EXCEEDED,\n \"Maximum MFA attempts exceeded\"\n );\n }\n\n this.attemptCount++;\n\n try {\n Logger.debug(\"Verifying MFA code\", { type, attempt: this.attemptCount });\n\n const response = await fetch(this.config.apiEndpoint || '/api/auth/verify-mfa', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${this.config.accessToken}`,\n },\n body: JSON.stringify({\n provider: this.config.provider,\n accessToken: this.config.accessToken,\n idToken: this.config.idToken,\n authenticationType: type,\n MFACode: code,\n appCode: this.config.appCode,\n }),\n });\n\n if (!response.ok) {\n throw new Error(`HTTP ${response.status}: ${response.statusText}`);\n }\n\n const data: MFAResponse = await response.json();\n console.log(\"MFA Response >>>\", data)\n \n if (data.isAuthenticated) {\n Logger.info(\"MFA verification successful\");\n this.resetAttempts();\n return data;\n } else {\n throw new CAMSError(\n CAMSErrorType.API_VALIDATION_ERROR,\n data.message || \"MFA verification failed\"\n );\n }\n } catch (error) {\n Logger.error(\"MFA verification failed\", { error, attempt: this.attemptCount });\n \n if (error instanceof CAMSError) {\n throw error;\n }\n \n throw new CAMSError(\n CAMSErrorType.API_VALIDATION_ERROR,\n `MFA verification failed: ${error instanceof Error ? error.message : 'Unknown error'}`\n );\n }\n }\n\n getRemainingAttempts(): number {\n return Math.max(0, this.maxAttempts - this.attemptCount);\n }\n\n resetAttempts(): void {\n this.attemptCount = 0;\n }\n}"],"names":[],"mappings":";;IAYY;AAAZ,CAAA,UAAY,aAAa,EAAA;AACvB,IAAA,aAAA,CAAA,eAAA,CAAA,GAAA,eAA+B;AAC/B,IAAA,aAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB,IAAA,aAAA,CAAA,gBAAA,CAAA,GAAA,gBAAiC;AACjC,IAAA,aAAA,CAAA,gBAAA,CAAA,GAAA,gBAAiC;AACjC,IAAA,aAAA,CAAA,aAAA,CAAA,GAAA,aAA2B;AAC3B,IAAA,aAAA,CAAA,sBAAA,CAAA,GAAA,sBAA6C;AAC7C,IAAA,aAAA,CAAA,sBAAA,CAAA,GAAA,kBAAyC;AAC3C,CAAC,EARW,aAAa,KAAb,aAAa,GAAA,EAAA,CAAA,CAAA;AAUnB,MAAO,SAAU,SAAQ,KAAK,CAAA;AACf,IAAA,IAAA;IAAnB,WAAA,CAAmB,IAAmB,EAAE,OAAe,EAAA;QACrD,KAAK,CAAC,OAAO,CAAC;QADG,IAAA,CAAA,IAAI,GAAJ,IAAI;QAErB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI;IACnC;AACD;;ACzBD;AACO,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;AACpC,IAAA,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;AAC7D,IAAA,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;AACpB,QAAA,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;AAChB,QAAA,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE;AAChB,QAAA,YAAY,EAAE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