@mission_sciences/provider-sdk 0.1.2 → 0.2.0-dev.03bcad5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +365 -416
- package/dist/index.d.ts +3 -1
- package/dist/marketplace-sdk.es.js +9 -5
- package/dist/marketplace-sdk.es.js.map +1 -1
- package/dist/marketplace-sdk.umd.js +1 -1
- package/dist/marketplace-sdk.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marketplace-sdk.umd.js","sources":["../src/types/index.ts","../src/core/JWTParser.ts","../node_modules/jose/dist/webapi/lib/buffer_utils.js","../node_modules/jose/dist/webapi/util/base64url.js","../node_modules/jose/dist/webapi/lib/base64.js","../node_modules/jose/dist/webapi/util/errors.js","../node_modules/jose/dist/webapi/lib/crypto_key.js","../node_modules/jose/dist/webapi/lib/invalid_key_input.js","../node_modules/jose/dist/webapi/lib/is_key_like.js","../node_modules/jose/dist/webapi/lib/is_object.js","../node_modules/jose/dist/webapi/lib/jwk_to_key.js","../node_modules/jose/dist/webapi/lib/is_jwk.js","../node_modules/jose/dist/webapi/lib/normalize_key.js","../node_modules/jose/dist/webapi/lib/check_key_type.js","../node_modules/jose/dist/webapi/lib/get_sign_verify_key.js","../node_modules/jose/dist/webapi/lib/verify.js","../node_modules/jose/dist/webapi/lib/check_key_length.js","../node_modules/jose/dist/webapi/lib/subtle_dsa.js","../node_modules/jose/dist/webapi/jws/flattened/verify.js","../node_modules/jose/dist/webapi/lib/is_disjoint.js","../node_modules/jose/dist/webapi/lib/validate_crit.js","../node_modules/jose/dist/webapi/lib/validate_algorithms.js","../node_modules/jose/dist/webapi/lib/epoch.js","../node_modules/jose/dist/webapi/lib/secs.js","../node_modules/jose/dist/webapi/lib/jwt_claims_set.js","../node_modules/jose/dist/webapi/jwt/verify.js","../node_modules/jose/dist/webapi/jws/compact/verify.js","../node_modules/jose/dist/webapi/jwks/local.js","../node_modules/jose/dist/webapi/key/import.js","../node_modules/jose/dist/webapi/jwks/remote.js","../src/utils/logger.ts","../src/core/JWKSValidator.ts","../src/core/TimerManager.ts","../src/core/HeartbeatManager.ts","../src/core/TabSyncManager.ts","../src/styles/theme.ts","../src/ui/WarningModal.ts","../src/utils/url.ts","../src/core/MarketplaceSDK.ts","../src/ui/SessionHeader.ts"],"sourcesContent":["/**\n * SDK Configuration\n */\nexport interface SDKConfig {\n /** JWKS endpoint URL (default: https://api.generalwisdom.com/.well-known/jwks.json) */\n jwksUri?: string;\n /** API endpoint for backend integration (Phase 2) */\n apiEndpoint?: string;\n /** Enable debug logging */\n debug?: boolean;\n /** Auto-start timer after initialization */\n autoStart?: boolean;\n /** Warning threshold in seconds (default: 300 = 5 minutes) */\n warningThresholdSeconds?: number;\n /** Custom styling for warning modal (Legacy - prefer using themeMode) */\n customStyles?: Partial<ModalStyles>;\n /** Theme mode for modal styling (default: 'light') */\n themeMode?: ThemeMode;\n /** Application ID for validation */\n applicationId?: string;\n /** Marketplace URL for redirects (default: https://d3p2yqofgy75sz.cloudfront.net/) */\n marketplaceUrl?: string;\n\n // Phase 2 Features\n /** Enable heartbeat system (default: false) */\n enableHeartbeat?: boolean;\n /** Heartbeat interval in seconds (default: 30) */\n heartbeatIntervalSeconds?: number;\n /** Enable multi-tab synchronization (default: false) */\n enableTabSync?: boolean;\n /** Pause timer when tab is hidden (default: false) */\n pauseOnHidden?: boolean;\n /** Use backend validation instead of JWKS (default: false) */\n useBackendValidation?: boolean;\n\n // Lifecycle Hooks\n /** Optional hooks for synchronizing app auth state with marketplace sessions */\n hooks?: SessionLifecycleHooks;\n /** Hook execution timeout in milliseconds (default: 5000) */\n hookTimeoutMs?: number;\n}\n\n/**\n * Session Data extracted from JWT\n */\nexport interface SessionData {\n /** Unique session UUID */\n sessionId: string;\n /** Application ID */\n applicationId: string;\n /** User ID */\n userId: string;\n /** Organization ID */\n orgId: string;\n /** Session start time (Unix timestamp seconds) */\n startTime: number;\n /** Session duration in minutes */\n durationMinutes: number;\n /** Issued at timestamp (Unix seconds) */\n iat: number;\n /** Expiration timestamp (Unix seconds) */\n exp: number;\n /** Issuer */\n iss: string;\n /** Subject (user ID) */\n sub: string;\n}\n\n/**\n * Modal styling options (Legacy - prefer using theme)\n * @deprecated Use theme configuration from src/styles/theme.ts instead\n */\nexport interface ModalStyles {\n backgroundColor: string;\n textColor: string;\n primaryColor: string;\n borderRadius: string;\n fontFamily: string;\n}\n\n/**\n * Theme mode for modal styling\n */\nexport type ThemeMode = 'light' | 'dark' | 'auto';\n\n/**\n * SDK Event Handlers\n */\nexport interface SDKEvents {\n /** Called when session successfully initialized */\n onSessionStart: (data: SessionData) => void;\n /** Called when warning threshold reached */\n onSessionWarning: (data: { remainingSeconds: number }) => void;\n /** Called when session expires or is ended */\n onSessionEnd: () => void;\n /** Called on any error */\n onError: (error: Error) => void;\n}\n\n/**\n * Session Lifecycle Hook Contexts\n */\nexport interface SessionStartContext {\n /** Unique session UUID */\n sessionId: string;\n /** User ID from JWT */\n userId: string;\n /** User email (if available in JWT) */\n email?: string;\n /** Organization ID */\n orgId: string;\n /** Application ID */\n applicationId: string;\n /** Session duration in minutes */\n durationMinutes: number;\n /** Expiration timestamp (Unix seconds) */\n expiresAt: number;\n /** Full JWT token for app use */\n jwt: string;\n}\n\nexport interface SessionEndContext {\n /** Unique session UUID */\n sessionId: string;\n /** User ID */\n userId: string;\n /** Reason for session end */\n reason: 'expired' | 'manual' | 'error';\n /** Actual session duration in minutes (if available) */\n actualDurationMinutes?: number;\n}\n\nexport interface SessionExtendContext {\n /** Unique session UUID */\n sessionId: string;\n /** User ID */\n userId: string;\n /** Additional minutes added to session */\n additionalMinutes: number;\n /** New expiration timestamp (Unix seconds) */\n newExpiresAt: number;\n}\n\nexport interface SessionWarningContext {\n /** Unique session UUID */\n sessionId: string;\n /** User ID */\n userId: string;\n /** Remaining seconds until expiration */\n remainingSeconds: number;\n}\n\n/**\n * Session Lifecycle Hooks\n * Optional callbacks that allow applications to synchronize their auth state with marketplace sessions\n */\nexport interface SessionLifecycleHooks {\n /**\n * Called after JWT validation succeeds but before session timer starts\n * Use to: Auto-login user to your app's auth system\n * Note: Hook failure will prevent session from starting\n */\n onSessionStart?: (context: SessionStartContext) => Promise<void> | void;\n\n /**\n * Called when session expires or is manually ended, before redirect\n * Use to: Force logout user from your app's auth system\n * Note: Hook failure will be logged but won't prevent session end\n */\n onSessionEnd?: (context: SessionEndContext) => Promise<void> | void;\n\n /**\n * Called when session extension succeeds\n * Use to: Refresh app auth tokens if needed\n */\n onSessionExtend?: (context: SessionExtendContext) => Promise<void> | void;\n\n /**\n * Called before session warning modal is shown\n * Use to: Prepare user for session expiration\n */\n onSessionWarning?: (context: SessionWarningContext) => Promise<void> | void;\n}\n\n/**\n * Custom SDK Error\n */\nexport class SDKError extends Error {\n constructor(\n message: string,\n public code: string,\n public statusCode?: number\n ) {\n super(message);\n this.name = 'SDKError';\n\n // Maintains proper stack trace for where our error was thrown (only available on V8)\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, SDKError);\n }\n }\n}\n\n/**\n * JWT Header\n */\nexport interface JWTHeader {\n alg: string;\n typ: string;\n kid: string;\n}\n\n/**\n * JWT Claims (raw payload from token)\n */\nexport interface JWTClaims {\n sessionId: string;\n applicationId: string;\n userId: string;\n orgId: string;\n startTime: number;\n durationMinutes: number;\n iat: number;\n exp: number;\n iss: string;\n sub: string;\n}\n\n/**\n * JWKS Key\n */\nexport interface JWKSKey {\n kty: string;\n use: string;\n kid: string;\n alg: string;\n n: string;\n e: string;\n}\n\n/**\n * JWKS Response\n */\nexport interface JWKSResponse {\n keys: JWKSKey[];\n}\n","import { SDKError, JWTHeader, JWTClaims } from '../types';\n\n/**\n * JWT Parser for client-side token decoding\n * Note: Does NOT verify signature - use JWKSValidator for verification\n */\nexport class JWTParser {\n /**\n * Decode JWT payload without verification\n * @param token - JWT token string\n * @returns Decoded payload\n */\n static decode(token: string): JWTClaims {\n if (!token || typeof token !== 'string') {\n throw new SDKError('Invalid JWT token format', 'INVALID_TOKEN');\n }\n\n const parts = token.split('.');\n if (parts.length !== 3) {\n throw new SDKError('Malformed JWT token - expected 3 parts', 'MALFORMED_TOKEN');\n }\n\n try {\n const payload = parts[1];\n const decoded = this.base64UrlDecode(payload);\n return JSON.parse(decoded) as JWTClaims;\n } catch (error) {\n throw new SDKError(\n `Failed to decode JWT payload: ${error instanceof Error ? error.message : 'Unknown error'}`,\n 'DECODE_ERROR'\n );\n }\n }\n\n /**\n * Decode JWT header\n * @param token - JWT token string\n * @returns Decoded header\n */\n static decodeHeader(token: string): JWTHeader {\n if (!token || typeof token !== 'string') {\n throw new SDKError('Invalid JWT token format', 'INVALID_TOKEN');\n }\n\n const parts = token.split('.');\n if (parts.length !== 3) {\n throw new SDKError('Malformed JWT token - expected 3 parts', 'MALFORMED_TOKEN');\n }\n\n try {\n const header = parts[0];\n const decoded = this.base64UrlDecode(header);\n return JSON.parse(decoded) as JWTHeader;\n } catch (error) {\n throw new SDKError(\n `Failed to decode JWT header: ${error instanceof Error ? error.message : 'Unknown error'}`,\n 'DECODE_ERROR'\n );\n }\n }\n\n /**\n * Extract specific claim from JWT\n * @param token - JWT token string\n * @param claim - Claim name to extract\n * @returns Claim value\n */\n static extractClaim<T = any>(token: string, claim: string): T {\n const payload = this.decode(token);\n return (payload as any)[claim];\n }\n\n /**\n * Check if JWT is expired (client-side only, not authoritative)\n * @param token - JWT token string\n * @returns True if token is expired\n */\n static isExpired(token: string): boolean {\n const payload = this.decode(token);\n const exp = payload.exp;\n\n if (!exp) {\n return false;\n }\n\n // exp is in seconds, Date.now() is in milliseconds\n return Date.now() >= exp * 1000;\n }\n\n /**\n * Get time remaining until expiration\n * @param token - JWT token string\n * @returns Seconds remaining (0 if expired)\n */\n static getTimeRemaining(token: string): number {\n const payload = this.decode(token);\n const exp = payload.exp;\n\n if (!exp) {\n return 0;\n }\n\n const remaining = exp - Math.floor(Date.now() / 1000);\n return Math.max(0, remaining);\n }\n\n /**\n * Base64 URL decode\n * @param str - Base64 URL encoded string\n * @returns Decoded string\n */\n private static base64UrlDecode(str: string): string {\n // Replace URL-safe characters\n let base64 = str.replace(/-/g, '+').replace(/_/g, '/');\n\n // Add padding if needed\n const padding = base64.length % 4;\n if (padding) {\n base64 += '='.repeat(4 - padding);\n }\n\n try {\n // Use Buffer in Node.js, atob in browser\n if (typeof Buffer !== 'undefined') {\n return Buffer.from(base64, 'base64').toString('utf-8');\n } else if (typeof atob !== 'undefined') {\n return atob(base64);\n } else {\n throw new Error('No base64 decoding available');\n }\n } catch (error) {\n throw new SDKError(\n 'Invalid base64 encoding',\n 'ENCODING_ERROR'\n );\n }\n }\n}\n","export const encoder = new TextEncoder();\nexport const decoder = new TextDecoder();\nconst MAX_INT32 = 2 ** 32;\nexport function concat(...buffers) {\n const size = buffers.reduce((acc, { length }) => acc + length, 0);\n const buf = new Uint8Array(size);\n let i = 0;\n for (const buffer of buffers) {\n buf.set(buffer, i);\n i += buffer.length;\n }\n return buf;\n}\nfunction writeUInt32BE(buf, value, offset) {\n if (value < 0 || value >= MAX_INT32) {\n throw new RangeError(`value must be >= 0 and <= ${MAX_INT32 - 1}. Received ${value}`);\n }\n buf.set([value >>> 24, value >>> 16, value >>> 8, value & 0xff], offset);\n}\nexport function uint64be(value) {\n const high = Math.floor(value / MAX_INT32);\n const low = value % MAX_INT32;\n const buf = new Uint8Array(8);\n writeUInt32BE(buf, high, 0);\n writeUInt32BE(buf, low, 4);\n return buf;\n}\nexport function uint32be(value) {\n const buf = new Uint8Array(4);\n writeUInt32BE(buf, value);\n return buf;\n}\n","import { encoder, decoder } from '../lib/buffer_utils.js';\nimport { encodeBase64, decodeBase64 } from '../lib/base64.js';\nexport function decode(input) {\n if (Uint8Array.fromBase64) {\n return Uint8Array.fromBase64(typeof input === 'string' ? input : decoder.decode(input), {\n alphabet: 'base64url',\n });\n }\n let encoded = input;\n if (encoded instanceof Uint8Array) {\n encoded = decoder.decode(encoded);\n }\n encoded = encoded.replace(/-/g, '+').replace(/_/g, '/').replace(/\\s/g, '');\n try {\n return decodeBase64(encoded);\n }\n catch {\n throw new TypeError('The input to be decoded is not correctly encoded.');\n }\n}\nexport function encode(input) {\n let unencoded = input;\n if (typeof unencoded === 'string') {\n unencoded = encoder.encode(unencoded);\n }\n if (Uint8Array.prototype.toBase64) {\n return unencoded.toBase64({ alphabet: 'base64url', omitPadding: true });\n }\n return encodeBase64(unencoded).replace(/=/g, '').replace(/\\+/g, '-').replace(/\\//g, '_');\n}\n","export function encodeBase64(input) {\n if (Uint8Array.prototype.toBase64) {\n return input.toBase64();\n }\n const CHUNK_SIZE = 0x8000;\n const arr = [];\n for (let i = 0; i < input.length; i += CHUNK_SIZE) {\n arr.push(String.fromCharCode.apply(null, input.subarray(i, i + CHUNK_SIZE)));\n }\n return btoa(arr.join(''));\n}\nexport function decodeBase64(encoded) {\n if (Uint8Array.fromBase64) {\n return Uint8Array.fromBase64(encoded);\n }\n const binary = atob(encoded);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) {\n bytes[i] = binary.charCodeAt(i);\n }\n return bytes;\n}\n","export class JOSEError extends Error {\n static code = 'ERR_JOSE_GENERIC';\n code = 'ERR_JOSE_GENERIC';\n constructor(message, options) {\n super(message, options);\n this.name = this.constructor.name;\n Error.captureStackTrace?.(this, this.constructor);\n }\n}\nexport class JWTClaimValidationFailed extends JOSEError {\n static code = 'ERR_JWT_CLAIM_VALIDATION_FAILED';\n code = 'ERR_JWT_CLAIM_VALIDATION_FAILED';\n claim;\n reason;\n payload;\n constructor(message, payload, claim = 'unspecified', reason = 'unspecified') {\n super(message, { cause: { claim, reason, payload } });\n this.claim = claim;\n this.reason = reason;\n this.payload = payload;\n }\n}\nexport class JWTExpired extends JOSEError {\n static code = 'ERR_JWT_EXPIRED';\n code = 'ERR_JWT_EXPIRED';\n claim;\n reason;\n payload;\n constructor(message, payload, claim = 'unspecified', reason = 'unspecified') {\n super(message, { cause: { claim, reason, payload } });\n this.claim = claim;\n this.reason = reason;\n this.payload = payload;\n }\n}\nexport class JOSEAlgNotAllowed extends JOSEError {\n static code = 'ERR_JOSE_ALG_NOT_ALLOWED';\n code = 'ERR_JOSE_ALG_NOT_ALLOWED';\n}\nexport class JOSENotSupported extends JOSEError {\n static code = 'ERR_JOSE_NOT_SUPPORTED';\n code = 'ERR_JOSE_NOT_SUPPORTED';\n}\nexport class JWEDecryptionFailed extends JOSEError {\n static code = 'ERR_JWE_DECRYPTION_FAILED';\n code = 'ERR_JWE_DECRYPTION_FAILED';\n constructor(message = 'decryption operation failed', options) {\n super(message, options);\n }\n}\nexport class JWEInvalid extends JOSEError {\n static code = 'ERR_JWE_INVALID';\n code = 'ERR_JWE_INVALID';\n}\nexport class JWSInvalid extends JOSEError {\n static code = 'ERR_JWS_INVALID';\n code = 'ERR_JWS_INVALID';\n}\nexport class JWTInvalid extends JOSEError {\n static code = 'ERR_JWT_INVALID';\n code = 'ERR_JWT_INVALID';\n}\nexport class JWKInvalid extends JOSEError {\n static code = 'ERR_JWK_INVALID';\n code = 'ERR_JWK_INVALID';\n}\nexport class JWKSInvalid extends JOSEError {\n static code = 'ERR_JWKS_INVALID';\n code = 'ERR_JWKS_INVALID';\n}\nexport class JWKSNoMatchingKey extends JOSEError {\n static code = 'ERR_JWKS_NO_MATCHING_KEY';\n code = 'ERR_JWKS_NO_MATCHING_KEY';\n constructor(message = 'no applicable key found in the JSON Web Key Set', options) {\n super(message, options);\n }\n}\nexport class JWKSMultipleMatchingKeys extends JOSEError {\n [Symbol.asyncIterator];\n static code = 'ERR_JWKS_MULTIPLE_MATCHING_KEYS';\n code = 'ERR_JWKS_MULTIPLE_MATCHING_KEYS';\n constructor(message = 'multiple matching keys found in the JSON Web Key Set', options) {\n super(message, options);\n }\n}\nexport class JWKSTimeout extends JOSEError {\n static code = 'ERR_JWKS_TIMEOUT';\n code = 'ERR_JWKS_TIMEOUT';\n constructor(message = 'request timed out', options) {\n super(message, options);\n }\n}\nexport class JWSSignatureVerificationFailed extends JOSEError {\n static code = 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED';\n code = 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED';\n constructor(message = 'signature verification failed', options) {\n super(message, options);\n }\n}\n","function unusable(name, prop = 'algorithm.name') {\n return new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);\n}\nfunction isAlgorithm(algorithm, name) {\n return algorithm.name === name;\n}\nfunction getHashLength(hash) {\n return parseInt(hash.name.slice(4), 10);\n}\nfunction getNamedCurve(alg) {\n switch (alg) {\n case 'ES256':\n return 'P-256';\n case 'ES384':\n return 'P-384';\n case 'ES512':\n return 'P-521';\n default:\n throw new Error('unreachable');\n }\n}\nfunction checkUsage(key, usage) {\n if (usage && !key.usages.includes(usage)) {\n throw new TypeError(`CryptoKey does not support this operation, its usages must include ${usage}.`);\n }\n}\nexport function checkSigCryptoKey(key, alg, usage) {\n switch (alg) {\n case 'HS256':\n case 'HS384':\n case 'HS512': {\n if (!isAlgorithm(key.algorithm, 'HMAC'))\n throw unusable('HMAC');\n const expected = parseInt(alg.slice(2), 10);\n const actual = getHashLength(key.algorithm.hash);\n if (actual !== expected)\n throw unusable(`SHA-${expected}`, 'algorithm.hash');\n break;\n }\n case 'RS256':\n case 'RS384':\n case 'RS512': {\n if (!isAlgorithm(key.algorithm, 'RSASSA-PKCS1-v1_5'))\n throw unusable('RSASSA-PKCS1-v1_5');\n const expected = parseInt(alg.slice(2), 10);\n const actual = getHashLength(key.algorithm.hash);\n if (actual !== expected)\n throw unusable(`SHA-${expected}`, 'algorithm.hash');\n break;\n }\n case 'PS256':\n case 'PS384':\n case 'PS512': {\n if (!isAlgorithm(key.algorithm, 'RSA-PSS'))\n throw unusable('RSA-PSS');\n const expected = parseInt(alg.slice(2), 10);\n const actual = getHashLength(key.algorithm.hash);\n if (actual !== expected)\n throw unusable(`SHA-${expected}`, 'algorithm.hash');\n break;\n }\n case 'Ed25519':\n case 'EdDSA': {\n if (!isAlgorithm(key.algorithm, 'Ed25519'))\n throw unusable('Ed25519');\n break;\n }\n case 'ML-DSA-44':\n case 'ML-DSA-65':\n case 'ML-DSA-87': {\n if (!isAlgorithm(key.algorithm, alg))\n throw unusable(alg);\n break;\n }\n case 'ES256':\n case 'ES384':\n case 'ES512': {\n if (!isAlgorithm(key.algorithm, 'ECDSA'))\n throw unusable('ECDSA');\n const expected = getNamedCurve(alg);\n const actual = key.algorithm.namedCurve;\n if (actual !== expected)\n throw unusable(expected, 'algorithm.namedCurve');\n break;\n }\n default:\n throw new TypeError('CryptoKey does not support this operation');\n }\n checkUsage(key, usage);\n}\nexport function checkEncCryptoKey(key, alg, usage) {\n switch (alg) {\n case 'A128GCM':\n case 'A192GCM':\n case 'A256GCM': {\n if (!isAlgorithm(key.algorithm, 'AES-GCM'))\n throw unusable('AES-GCM');\n const expected = parseInt(alg.slice(1, 4), 10);\n const actual = key.algorithm.length;\n if (actual !== expected)\n throw unusable(expected, 'algorithm.length');\n break;\n }\n case 'A128KW':\n case 'A192KW':\n case 'A256KW': {\n if (!isAlgorithm(key.algorithm, 'AES-KW'))\n throw unusable('AES-KW');\n const expected = parseInt(alg.slice(1, 4), 10);\n const actual = key.algorithm.length;\n if (actual !== expected)\n throw unusable(expected, 'algorithm.length');\n break;\n }\n case 'ECDH': {\n switch (key.algorithm.name) {\n case 'ECDH':\n case 'X25519':\n break;\n default:\n throw unusable('ECDH or X25519');\n }\n break;\n }\n case 'PBES2-HS256+A128KW':\n case 'PBES2-HS384+A192KW':\n case 'PBES2-HS512+A256KW':\n if (!isAlgorithm(key.algorithm, 'PBKDF2'))\n throw unusable('PBKDF2');\n break;\n case 'RSA-OAEP':\n case 'RSA-OAEP-256':\n case 'RSA-OAEP-384':\n case 'RSA-OAEP-512': {\n if (!isAlgorithm(key.algorithm, 'RSA-OAEP'))\n throw unusable('RSA-OAEP');\n const expected = parseInt(alg.slice(9), 10) || 1;\n const actual = getHashLength(key.algorithm.hash);\n if (actual !== expected)\n throw unusable(`SHA-${expected}`, 'algorithm.hash');\n break;\n }\n default:\n throw new TypeError('CryptoKey does not support this operation');\n }\n checkUsage(key, usage);\n}\n","function message(msg, actual, ...types) {\n types = types.filter(Boolean);\n if (types.length > 2) {\n const last = types.pop();\n msg += `one of type ${types.join(', ')}, or ${last}.`;\n }\n else if (types.length === 2) {\n msg += `one of type ${types[0]} or ${types[1]}.`;\n }\n else {\n msg += `of type ${types[0]}.`;\n }\n if (actual == null) {\n msg += ` Received ${actual}`;\n }\n else if (typeof actual === 'function' && actual.name) {\n msg += ` Received function ${actual.name}`;\n }\n else if (typeof actual === 'object' && actual != null) {\n if (actual.constructor?.name) {\n msg += ` Received an instance of ${actual.constructor.name}`;\n }\n }\n return msg;\n}\nexport default (actual, ...types) => {\n return message('Key must be ', actual, ...types);\n};\nexport function withAlg(alg, actual, ...types) {\n return message(`Key for the ${alg} algorithm must be `, actual, ...types);\n}\n","export function assertCryptoKey(key) {\n if (!isCryptoKey(key)) {\n throw new Error('CryptoKey instance expected');\n }\n}\nexport function isCryptoKey(key) {\n return key?.[Symbol.toStringTag] === 'CryptoKey';\n}\nexport function isKeyObject(key) {\n return key?.[Symbol.toStringTag] === 'KeyObject';\n}\nexport default (key) => {\n return isCryptoKey(key) || isKeyObject(key);\n};\n","function isObjectLike(value) {\n return typeof value === 'object' && value !== null;\n}\nexport default (input) => {\n if (!isObjectLike(input) || Object.prototype.toString.call(input) !== '[object Object]') {\n return false;\n }\n if (Object.getPrototypeOf(input) === null) {\n return true;\n }\n let proto = input;\n while (Object.getPrototypeOf(proto) !== null) {\n proto = Object.getPrototypeOf(proto);\n }\n return Object.getPrototypeOf(input) === proto;\n};\n","import { JOSENotSupported } from '../util/errors.js';\nfunction subtleMapping(jwk) {\n let algorithm;\n let keyUsages;\n switch (jwk.kty) {\n case 'AKP': {\n switch (jwk.alg) {\n case 'ML-DSA-44':\n case 'ML-DSA-65':\n case 'ML-DSA-87':\n algorithm = { name: jwk.alg };\n keyUsages = jwk.priv ? ['sign'] : ['verify'];\n break;\n default:\n throw new JOSENotSupported('Invalid or unsupported JWK \"alg\" (Algorithm) Parameter value');\n }\n break;\n }\n case 'RSA': {\n switch (jwk.alg) {\n case 'PS256':\n case 'PS384':\n case 'PS512':\n algorithm = { name: 'RSA-PSS', hash: `SHA-${jwk.alg.slice(-3)}` };\n keyUsages = jwk.d ? ['sign'] : ['verify'];\n break;\n case 'RS256':\n case 'RS384':\n case 'RS512':\n algorithm = { name: 'RSASSA-PKCS1-v1_5', hash: `SHA-${jwk.alg.slice(-3)}` };\n keyUsages = jwk.d ? ['sign'] : ['verify'];\n break;\n case 'RSA-OAEP':\n case 'RSA-OAEP-256':\n case 'RSA-OAEP-384':\n case 'RSA-OAEP-512':\n algorithm = {\n name: 'RSA-OAEP',\n hash: `SHA-${parseInt(jwk.alg.slice(-3), 10) || 1}`,\n };\n keyUsages = jwk.d ? ['decrypt', 'unwrapKey'] : ['encrypt', 'wrapKey'];\n break;\n default:\n throw new JOSENotSupported('Invalid or unsupported JWK \"alg\" (Algorithm) Parameter value');\n }\n break;\n }\n case 'EC': {\n switch (jwk.alg) {\n case 'ES256':\n algorithm = { name: 'ECDSA', namedCurve: 'P-256' };\n keyUsages = jwk.d ? ['sign'] : ['verify'];\n break;\n case 'ES384':\n algorithm = { name: 'ECDSA', namedCurve: 'P-384' };\n keyUsages = jwk.d ? ['sign'] : ['verify'];\n break;\n case 'ES512':\n algorithm = { name: 'ECDSA', namedCurve: 'P-521' };\n keyUsages = jwk.d ? ['sign'] : ['verify'];\n break;\n case 'ECDH-ES':\n case 'ECDH-ES+A128KW':\n case 'ECDH-ES+A192KW':\n case 'ECDH-ES+A256KW':\n algorithm = { name: 'ECDH', namedCurve: jwk.crv };\n keyUsages = jwk.d ? ['deriveBits'] : [];\n break;\n default:\n throw new JOSENotSupported('Invalid or unsupported JWK \"alg\" (Algorithm) Parameter value');\n }\n break;\n }\n case 'OKP': {\n switch (jwk.alg) {\n case 'Ed25519':\n case 'EdDSA':\n algorithm = { name: 'Ed25519' };\n keyUsages = jwk.d ? ['sign'] : ['verify'];\n break;\n case 'ECDH-ES':\n case 'ECDH-ES+A128KW':\n case 'ECDH-ES+A192KW':\n case 'ECDH-ES+A256KW':\n algorithm = { name: jwk.crv };\n keyUsages = jwk.d ? ['deriveBits'] : [];\n break;\n default:\n throw new JOSENotSupported('Invalid or unsupported JWK \"alg\" (Algorithm) Parameter value');\n }\n break;\n }\n default:\n throw new JOSENotSupported('Invalid or unsupported JWK \"kty\" (Key Type) Parameter value');\n }\n return { algorithm, keyUsages };\n}\nexport default async (jwk) => {\n if (!jwk.alg) {\n throw new TypeError('\"alg\" argument is required when \"jwk.alg\" is not present');\n }\n const { algorithm, keyUsages } = subtleMapping(jwk);\n const keyData = { ...jwk };\n if (keyData.kty !== 'AKP') {\n delete keyData.alg;\n }\n delete keyData.use;\n return crypto.subtle.importKey('jwk', keyData, algorithm, jwk.ext ?? (jwk.d || jwk.priv ? false : true), jwk.key_ops ?? keyUsages);\n};\n","import isObject from './is_object.js';\nexport function isJWK(key) {\n return isObject(key) && typeof key.kty === 'string';\n}\nexport function isPrivateJWK(key) {\n return (key.kty !== 'oct' &&\n ((key.kty === 'AKP' && typeof key.priv === 'string') || typeof key.d === 'string'));\n}\nexport function isPublicJWK(key) {\n return key.kty !== 'oct' && typeof key.d === 'undefined' && typeof key.priv === 'undefined';\n}\nexport function isSecretJWK(key) {\n return key.kty === 'oct' && typeof key.k === 'string';\n}\n","import { isJWK } from './is_jwk.js';\nimport { decode } from '../util/base64url.js';\nimport importJWK from './jwk_to_key.js';\nimport { isCryptoKey, isKeyObject } from './is_key_like.js';\nlet cache;\nconst handleJWK = async (key, jwk, alg, freeze = false) => {\n cache ||= new WeakMap();\n let cached = cache.get(key);\n if (cached?.[alg]) {\n return cached[alg];\n }\n const cryptoKey = await importJWK({ ...jwk, alg });\n if (freeze)\n Object.freeze(key);\n if (!cached) {\n cache.set(key, { [alg]: cryptoKey });\n }\n else {\n cached[alg] = cryptoKey;\n }\n return cryptoKey;\n};\nconst handleKeyObject = (keyObject, alg) => {\n cache ||= new WeakMap();\n let cached = cache.get(keyObject);\n if (cached?.[alg]) {\n return cached[alg];\n }\n const isPublic = keyObject.type === 'public';\n const extractable = isPublic ? true : false;\n let cryptoKey;\n if (keyObject.asymmetricKeyType === 'x25519') {\n switch (alg) {\n case 'ECDH-ES':\n case 'ECDH-ES+A128KW':\n case 'ECDH-ES+A192KW':\n case 'ECDH-ES+A256KW':\n break;\n default:\n throw new TypeError('given KeyObject instance cannot be used for this algorithm');\n }\n cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, isPublic ? [] : ['deriveBits']);\n }\n if (keyObject.asymmetricKeyType === 'ed25519') {\n if (alg !== 'EdDSA' && alg !== 'Ed25519') {\n throw new TypeError('given KeyObject instance cannot be used for this algorithm');\n }\n cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [\n isPublic ? 'verify' : 'sign',\n ]);\n }\n switch (keyObject.asymmetricKeyType) {\n case 'ml-dsa-44':\n case 'ml-dsa-65':\n case 'ml-dsa-87': {\n if (alg !== keyObject.asymmetricKeyType.toUpperCase()) {\n throw new TypeError('given KeyObject instance cannot be used for this algorithm');\n }\n cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [\n isPublic ? 'verify' : 'sign',\n ]);\n }\n }\n if (keyObject.asymmetricKeyType === 'rsa') {\n let hash;\n switch (alg) {\n case 'RSA-OAEP':\n hash = 'SHA-1';\n break;\n case 'RS256':\n case 'PS256':\n case 'RSA-OAEP-256':\n hash = 'SHA-256';\n break;\n case 'RS384':\n case 'PS384':\n case 'RSA-OAEP-384':\n hash = 'SHA-384';\n break;\n case 'RS512':\n case 'PS512':\n case 'RSA-OAEP-512':\n hash = 'SHA-512';\n break;\n default:\n throw new TypeError('given KeyObject instance cannot be used for this algorithm');\n }\n if (alg.startsWith('RSA-OAEP')) {\n return keyObject.toCryptoKey({\n name: 'RSA-OAEP',\n hash,\n }, extractable, isPublic ? ['encrypt'] : ['decrypt']);\n }\n cryptoKey = keyObject.toCryptoKey({\n name: alg.startsWith('PS') ? 'RSA-PSS' : 'RSASSA-PKCS1-v1_5',\n hash,\n }, extractable, [isPublic ? 'verify' : 'sign']);\n }\n if (keyObject.asymmetricKeyType === 'ec') {\n const nist = new Map([\n ['prime256v1', 'P-256'],\n ['secp384r1', 'P-384'],\n ['secp521r1', 'P-521'],\n ]);\n const namedCurve = nist.get(keyObject.asymmetricKeyDetails?.namedCurve);\n if (!namedCurve) {\n throw new TypeError('given KeyObject instance cannot be used for this algorithm');\n }\n if (alg === 'ES256' && namedCurve === 'P-256') {\n cryptoKey = keyObject.toCryptoKey({\n name: 'ECDSA',\n namedCurve,\n }, extractable, [isPublic ? 'verify' : 'sign']);\n }\n if (alg === 'ES384' && namedCurve === 'P-384') {\n cryptoKey = keyObject.toCryptoKey({\n name: 'ECDSA',\n namedCurve,\n }, extractable, [isPublic ? 'verify' : 'sign']);\n }\n if (alg === 'ES512' && namedCurve === 'P-521') {\n cryptoKey = keyObject.toCryptoKey({\n name: 'ECDSA',\n namedCurve,\n }, extractable, [isPublic ? 'verify' : 'sign']);\n }\n if (alg.startsWith('ECDH-ES')) {\n cryptoKey = keyObject.toCryptoKey({\n name: 'ECDH',\n namedCurve,\n }, extractable, isPublic ? [] : ['deriveBits']);\n }\n }\n if (!cryptoKey) {\n throw new TypeError('given KeyObject instance cannot be used for this algorithm');\n }\n if (!cached) {\n cache.set(keyObject, { [alg]: cryptoKey });\n }\n else {\n cached[alg] = cryptoKey;\n }\n return cryptoKey;\n};\nexport default async (key, alg) => {\n if (key instanceof Uint8Array) {\n return key;\n }\n if (isCryptoKey(key)) {\n return key;\n }\n if (isKeyObject(key)) {\n if (key.type === 'secret') {\n return key.export();\n }\n if ('toCryptoKey' in key && typeof key.toCryptoKey === 'function') {\n try {\n return handleKeyObject(key, alg);\n }\n catch (err) {\n if (err instanceof TypeError) {\n throw err;\n }\n }\n }\n let jwk = key.export({ format: 'jwk' });\n return handleJWK(key, jwk, alg);\n }\n if (isJWK(key)) {\n if (key.k) {\n return decode(key.k);\n }\n return handleJWK(key, key, alg, true);\n }\n throw new Error('unreachable');\n};\n","import { withAlg as invalidKeyInput } from './invalid_key_input.js';\nimport isKeyLike from './is_key_like.js';\nimport * as jwk from './is_jwk.js';\nconst tag = (key) => key?.[Symbol.toStringTag];\nconst jwkMatchesOp = (alg, key, usage) => {\n if (key.use !== undefined) {\n let expected;\n switch (usage) {\n case 'sign':\n case 'verify':\n expected = 'sig';\n break;\n case 'encrypt':\n case 'decrypt':\n expected = 'enc';\n break;\n }\n if (key.use !== expected) {\n throw new TypeError(`Invalid key for this operation, its \"use\" must be \"${expected}\" when present`);\n }\n }\n if (key.alg !== undefined && key.alg !== alg) {\n throw new TypeError(`Invalid key for this operation, its \"alg\" must be \"${alg}\" when present`);\n }\n if (Array.isArray(key.key_ops)) {\n let expectedKeyOp;\n switch (true) {\n case usage === 'sign' || usage === 'verify':\n case alg === 'dir':\n case alg.includes('CBC-HS'):\n expectedKeyOp = usage;\n break;\n case alg.startsWith('PBES2'):\n expectedKeyOp = 'deriveBits';\n break;\n case /^A\\d{3}(?:GCM)?(?:KW)?$/.test(alg):\n if (!alg.includes('GCM') && alg.endsWith('KW')) {\n expectedKeyOp = usage === 'encrypt' ? 'wrapKey' : 'unwrapKey';\n }\n else {\n expectedKeyOp = usage;\n }\n break;\n case usage === 'encrypt' && alg.startsWith('RSA'):\n expectedKeyOp = 'wrapKey';\n break;\n case usage === 'decrypt':\n expectedKeyOp = alg.startsWith('RSA') ? 'unwrapKey' : 'deriveBits';\n break;\n }\n if (expectedKeyOp && key.key_ops?.includes?.(expectedKeyOp) === false) {\n throw new TypeError(`Invalid key for this operation, its \"key_ops\" must include \"${expectedKeyOp}\" when present`);\n }\n }\n return true;\n};\nconst symmetricTypeCheck = (alg, key, usage) => {\n if (key instanceof Uint8Array)\n return;\n if (jwk.isJWK(key)) {\n if (jwk.isSecretJWK(key) && jwkMatchesOp(alg, key, usage))\n return;\n throw new TypeError(`JSON Web Key for symmetric algorithms must have JWK \"kty\" (Key Type) equal to \"oct\" and the JWK \"k\" (Key Value) present`);\n }\n if (!isKeyLike(key)) {\n throw new TypeError(invalidKeyInput(alg, key, 'CryptoKey', 'KeyObject', 'JSON Web Key', 'Uint8Array'));\n }\n if (key.type !== 'secret') {\n throw new TypeError(`${tag(key)} instances for symmetric algorithms must be of type \"secret\"`);\n }\n};\nconst asymmetricTypeCheck = (alg, key, usage) => {\n if (jwk.isJWK(key)) {\n switch (usage) {\n case 'decrypt':\n case 'sign':\n if (jwk.isPrivateJWK(key) && jwkMatchesOp(alg, key, usage))\n return;\n throw new TypeError(`JSON Web Key for this operation be a private JWK`);\n case 'encrypt':\n case 'verify':\n if (jwk.isPublicJWK(key) && jwkMatchesOp(alg, key, usage))\n return;\n throw new TypeError(`JSON Web Key for this operation be a public JWK`);\n }\n }\n if (!isKeyLike(key)) {\n throw new TypeError(invalidKeyInput(alg, key, 'CryptoKey', 'KeyObject', 'JSON Web Key'));\n }\n if (key.type === 'secret') {\n throw new TypeError(`${tag(key)} instances for asymmetric algorithms must not be of type \"secret\"`);\n }\n if (key.type === 'public') {\n switch (usage) {\n case 'sign':\n throw new TypeError(`${tag(key)} instances for asymmetric algorithm signing must be of type \"private\"`);\n case 'decrypt':\n throw new TypeError(`${tag(key)} instances for asymmetric algorithm decryption must be of type \"private\"`);\n default:\n break;\n }\n }\n if (key.type === 'private') {\n switch (usage) {\n case 'verify':\n throw new TypeError(`${tag(key)} instances for asymmetric algorithm verifying must be of type \"public\"`);\n case 'encrypt':\n throw new TypeError(`${tag(key)} instances for asymmetric algorithm encryption must be of type \"public\"`);\n default:\n break;\n }\n }\n};\nexport default (alg, key, usage) => {\n const symmetric = alg.startsWith('HS') ||\n alg === 'dir' ||\n alg.startsWith('PBES2') ||\n /^A(?:128|192|256)(?:GCM)?(?:KW)?$/.test(alg) ||\n /^A(?:128|192|256)CBC-HS(?:256|384|512)$/.test(alg);\n if (symmetric) {\n symmetricTypeCheck(alg, key, usage);\n }\n else {\n asymmetricTypeCheck(alg, key, usage);\n }\n};\n","import { checkSigCryptoKey } from './crypto_key.js';\nimport invalidKeyInput from './invalid_key_input.js';\nexport default async (alg, key, usage) => {\n if (key instanceof Uint8Array) {\n if (!alg.startsWith('HS')) {\n throw new TypeError(invalidKeyInput(key, 'CryptoKey', 'KeyObject', 'JSON Web Key'));\n }\n return crypto.subtle.importKey('raw', key, { hash: `SHA-${alg.slice(-3)}`, name: 'HMAC' }, false, [usage]);\n }\n checkSigCryptoKey(key, alg, usage);\n return key;\n};\n","import subtleAlgorithm from './subtle_dsa.js';\nimport checkKeyLength from './check_key_length.js';\nimport getVerifyKey from './get_sign_verify_key.js';\nexport default async (alg, key, signature, data) => {\n const cryptoKey = await getVerifyKey(alg, key, 'verify');\n checkKeyLength(alg, cryptoKey);\n const algorithm = subtleAlgorithm(alg, cryptoKey.algorithm);\n try {\n return await crypto.subtle.verify(algorithm, cryptoKey, signature, data);\n }\n catch {\n return false;\n }\n};\n","export default (alg, key) => {\n if (alg.startsWith('RS') || alg.startsWith('PS')) {\n const { modulusLength } = key.algorithm;\n if (typeof modulusLength !== 'number' || modulusLength < 2048) {\n throw new TypeError(`${alg} requires key modulusLength to be 2048 bits or larger`);\n }\n }\n};\n","import { JOSENotSupported } from '../util/errors.js';\nexport default (alg, algorithm) => {\n const hash = `SHA-${alg.slice(-3)}`;\n switch (alg) {\n case 'HS256':\n case 'HS384':\n case 'HS512':\n return { hash, name: 'HMAC' };\n case 'PS256':\n case 'PS384':\n case 'PS512':\n return { hash, name: 'RSA-PSS', saltLength: parseInt(alg.slice(-3), 10) >> 3 };\n case 'RS256':\n case 'RS384':\n case 'RS512':\n return { hash, name: 'RSASSA-PKCS1-v1_5' };\n case 'ES256':\n case 'ES384':\n case 'ES512':\n return { hash, name: 'ECDSA', namedCurve: algorithm.namedCurve };\n case 'Ed25519':\n case 'EdDSA':\n return { name: 'Ed25519' };\n case 'ML-DSA-44':\n case 'ML-DSA-65':\n case 'ML-DSA-87':\n return { name: alg };\n default:\n throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);\n }\n};\n","import { decode as b64u } from '../../util/base64url.js';\nimport verify from '../../lib/verify.js';\nimport { JOSEAlgNotAllowed, JWSInvalid, JWSSignatureVerificationFailed } from '../../util/errors.js';\nimport { concat, encoder, decoder } from '../../lib/buffer_utils.js';\nimport isDisjoint from '../../lib/is_disjoint.js';\nimport isObject from '../../lib/is_object.js';\nimport checkKeyType from '../../lib/check_key_type.js';\nimport validateCrit from '../../lib/validate_crit.js';\nimport validateAlgorithms from '../../lib/validate_algorithms.js';\nimport normalizeKey from '../../lib/normalize_key.js';\nexport async function flattenedVerify(jws, key, options) {\n if (!isObject(jws)) {\n throw new JWSInvalid('Flattened JWS must be an object');\n }\n if (jws.protected === undefined && jws.header === undefined) {\n throw new JWSInvalid('Flattened JWS must have either of the \"protected\" or \"header\" members');\n }\n if (jws.protected !== undefined && typeof jws.protected !== 'string') {\n throw new JWSInvalid('JWS Protected Header incorrect type');\n }\n if (jws.payload === undefined) {\n throw new JWSInvalid('JWS Payload missing');\n }\n if (typeof jws.signature !== 'string') {\n throw new JWSInvalid('JWS Signature missing or incorrect type');\n }\n if (jws.header !== undefined && !isObject(jws.header)) {\n throw new JWSInvalid('JWS Unprotected Header incorrect type');\n }\n let parsedProt = {};\n if (jws.protected) {\n try {\n const protectedHeader = b64u(jws.protected);\n parsedProt = JSON.parse(decoder.decode(protectedHeader));\n }\n catch {\n throw new JWSInvalid('JWS Protected Header is invalid');\n }\n }\n if (!isDisjoint(parsedProt, jws.header)) {\n throw new JWSInvalid('JWS Protected and JWS Unprotected Header Parameter names must be disjoint');\n }\n const joseHeader = {\n ...parsedProt,\n ...jws.header,\n };\n const extensions = validateCrit(JWSInvalid, new Map([['b64', true]]), options?.crit, parsedProt, joseHeader);\n let b64 = true;\n if (extensions.has('b64')) {\n b64 = parsedProt.b64;\n if (typeof b64 !== 'boolean') {\n throw new JWSInvalid('The \"b64\" (base64url-encode payload) Header Parameter must be a boolean');\n }\n }\n const { alg } = joseHeader;\n if (typeof alg !== 'string' || !alg) {\n throw new JWSInvalid('JWS \"alg\" (Algorithm) Header Parameter missing or invalid');\n }\n const algorithms = options && validateAlgorithms('algorithms', options.algorithms);\n if (algorithms && !algorithms.has(alg)) {\n throw new JOSEAlgNotAllowed('\"alg\" (Algorithm) Header Parameter value not allowed');\n }\n if (b64) {\n if (typeof jws.payload !== 'string') {\n throw new JWSInvalid('JWS Payload must be a string');\n }\n }\n else if (typeof jws.payload !== 'string' && !(jws.payload instanceof Uint8Array)) {\n throw new JWSInvalid('JWS Payload must be a string or an Uint8Array instance');\n }\n let resolvedKey = false;\n if (typeof key === 'function') {\n key = await key(parsedProt, jws);\n resolvedKey = true;\n }\n checkKeyType(alg, key, 'verify');\n const data = concat(encoder.encode(jws.protected ?? ''), encoder.encode('.'), typeof jws.payload === 'string' ? encoder.encode(jws.payload) : jws.payload);\n let signature;\n try {\n signature = b64u(jws.signature);\n }\n catch {\n throw new JWSInvalid('Failed to base64url decode the signature');\n }\n const k = await normalizeKey(key, alg);\n const verified = await verify(alg, k, signature, data);\n if (!verified) {\n throw new JWSSignatureVerificationFailed();\n }\n let payload;\n if (b64) {\n try {\n payload = b64u(jws.payload);\n }\n catch {\n throw new JWSInvalid('Failed to base64url decode the payload');\n }\n }\n else if (typeof jws.payload === 'string') {\n payload = encoder.encode(jws.payload);\n }\n else {\n payload = jws.payload;\n }\n const result = { payload };\n if (jws.protected !== undefined) {\n result.protectedHeader = parsedProt;\n }\n if (jws.header !== undefined) {\n result.unprotectedHeader = jws.header;\n }\n if (resolvedKey) {\n return { ...result, key: k };\n }\n return result;\n}\n","export default (...headers) => {\n const sources = headers.filter(Boolean);\n if (sources.length === 0 || sources.length === 1) {\n return true;\n }\n let acc;\n for (const header of sources) {\n const parameters = Object.keys(header);\n if (!acc || acc.size === 0) {\n acc = new Set(parameters);\n continue;\n }\n for (const parameter of parameters) {\n if (acc.has(parameter)) {\n return false;\n }\n acc.add(parameter);\n }\n }\n return true;\n};\n","import { JOSENotSupported, JWEInvalid, JWSInvalid } from '../util/errors.js';\nexport default (Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) => {\n if (joseHeader.crit !== undefined && protectedHeader?.crit === undefined) {\n throw new Err('\"crit\" (Critical) Header Parameter MUST be integrity protected');\n }\n if (!protectedHeader || protectedHeader.crit === undefined) {\n return new Set();\n }\n if (!Array.isArray(protectedHeader.crit) ||\n protectedHeader.crit.length === 0 ||\n protectedHeader.crit.some((input) => typeof input !== 'string' || input.length === 0)) {\n throw new Err('\"crit\" (Critical) Header Parameter MUST be an array of non-empty strings when present');\n }\n let recognized;\n if (recognizedOption !== undefined) {\n recognized = new Map([...Object.entries(recognizedOption), ...recognizedDefault.entries()]);\n }\n else {\n recognized = recognizedDefault;\n }\n for (const parameter of protectedHeader.crit) {\n if (!recognized.has(parameter)) {\n throw new JOSENotSupported(`Extension Header Parameter \"${parameter}\" is not recognized`);\n }\n if (joseHeader[parameter] === undefined) {\n throw new Err(`Extension Header Parameter \"${parameter}\" is missing`);\n }\n if (recognized.get(parameter) && protectedHeader[parameter] === undefined) {\n throw new Err(`Extension Header Parameter \"${parameter}\" MUST be integrity protected`);\n }\n }\n return new Set(protectedHeader.crit);\n};\n","export default (option, algorithms) => {\n if (algorithms !== undefined &&\n (!Array.isArray(algorithms) || algorithms.some((s) => typeof s !== 'string'))) {\n throw new TypeError(`\"${option}\" option must be an array of strings`);\n }\n if (!algorithms) {\n return undefined;\n }\n return new Set(algorithms);\n};\n","export default (date) => Math.floor(date.getTime() / 1000);\n","const minute = 60;\nconst hour = minute * 60;\nconst day = hour * 24;\nconst week = day * 7;\nconst year = day * 365.25;\nconst REGEX = /^(\\+|\\-)? ?(\\d+|\\d+\\.\\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;\nexport default (str) => {\n const matched = REGEX.exec(str);\n if (!matched || (matched[4] && matched[1])) {\n throw new TypeError('Invalid time period format');\n }\n const value = parseFloat(matched[2]);\n const unit = matched[3].toLowerCase();\n let numericDate;\n switch (unit) {\n case 'sec':\n case 'secs':\n case 'second':\n case 'seconds':\n case 's':\n numericDate = Math.round(value);\n break;\n case 'minute':\n case 'minutes':\n case 'min':\n case 'mins':\n case 'm':\n numericDate = Math.round(value * minute);\n break;\n case 'hour':\n case 'hours':\n case 'hr':\n case 'hrs':\n case 'h':\n numericDate = Math.round(value * hour);\n break;\n case 'day':\n case 'days':\n case 'd':\n numericDate = Math.round(value * day);\n break;\n case 'week':\n case 'weeks':\n case 'w':\n numericDate = Math.round(value * week);\n break;\n default:\n numericDate = Math.round(value * year);\n break;\n }\n if (matched[1] === '-' || matched[4] === 'ago') {\n return -numericDate;\n }\n return numericDate;\n};\n","import { JWTClaimValidationFailed, JWTExpired, JWTInvalid } from '../util/errors.js';\nimport { decoder } from './buffer_utils.js';\nimport epoch from './epoch.js';\nimport secs from './secs.js';\nimport isObject from './is_object.js';\nimport { encoder } from './buffer_utils.js';\nfunction validateInput(label, input) {\n if (!Number.isFinite(input)) {\n throw new TypeError(`Invalid ${label} input`);\n }\n return input;\n}\nconst normalizeTyp = (value) => {\n if (value.includes('/')) {\n return value.toLowerCase();\n }\n return `application/${value.toLowerCase()}`;\n};\nconst checkAudiencePresence = (audPayload, audOption) => {\n if (typeof audPayload === 'string') {\n return audOption.includes(audPayload);\n }\n if (Array.isArray(audPayload)) {\n return audOption.some(Set.prototype.has.bind(new Set(audPayload)));\n }\n return false;\n};\nexport function validateClaimsSet(protectedHeader, encodedPayload, options = {}) {\n let payload;\n try {\n payload = JSON.parse(decoder.decode(encodedPayload));\n }\n catch {\n }\n if (!isObject(payload)) {\n throw new JWTInvalid('JWT Claims Set must be a top-level JSON object');\n }\n const { typ } = options;\n if (typ &&\n (typeof protectedHeader.typ !== 'string' ||\n normalizeTyp(protectedHeader.typ) !== normalizeTyp(typ))) {\n throw new JWTClaimValidationFailed('unexpected \"typ\" JWT header value', payload, 'typ', 'check_failed');\n }\n const { requiredClaims = [], issuer, subject, audience, maxTokenAge } = options;\n const presenceCheck = [...requiredClaims];\n if (maxTokenAge !== undefined)\n presenceCheck.push('iat');\n if (audience !== undefined)\n presenceCheck.push('aud');\n if (subject !== undefined)\n presenceCheck.push('sub');\n if (issuer !== undefined)\n presenceCheck.push('iss');\n for (const claim of new Set(presenceCheck.reverse())) {\n if (!(claim in payload)) {\n throw new JWTClaimValidationFailed(`missing required \"${claim}\" claim`, payload, claim, 'missing');\n }\n }\n if (issuer &&\n !(Array.isArray(issuer) ? issuer : [issuer]).includes(payload.iss)) {\n throw new JWTClaimValidationFailed('unexpected \"iss\" claim value', payload, 'iss', 'check_failed');\n }\n if (subject && payload.sub !== subject) {\n throw new JWTClaimValidationFailed('unexpected \"sub\" claim value', payload, 'sub', 'check_failed');\n }\n if (audience &&\n !checkAudiencePresence(payload.aud, typeof audience === 'string' ? [audience] : audience)) {\n throw new JWTClaimValidationFailed('unexpected \"aud\" claim value', payload, 'aud', 'check_failed');\n }\n let tolerance;\n switch (typeof options.clockTolerance) {\n case 'string':\n tolerance = secs(options.clockTolerance);\n break;\n case 'number':\n tolerance = options.clockTolerance;\n break;\n case 'undefined':\n tolerance = 0;\n break;\n default:\n throw new TypeError('Invalid clockTolerance option type');\n }\n const { currentDate } = options;\n const now = epoch(currentDate || new Date());\n if ((payload.iat !== undefined || maxTokenAge) && typeof payload.iat !== 'number') {\n throw new JWTClaimValidationFailed('\"iat\" claim must be a number', payload, 'iat', 'invalid');\n }\n if (payload.nbf !== undefined) {\n if (typeof payload.nbf !== 'number') {\n throw new JWTClaimValidationFailed('\"nbf\" claim must be a number', payload, 'nbf', 'invalid');\n }\n if (payload.nbf > now + tolerance) {\n throw new JWTClaimValidationFailed('\"nbf\" claim timestamp check failed', payload, 'nbf', 'check_failed');\n }\n }\n if (payload.exp !== undefined) {\n if (typeof payload.exp !== 'number') {\n throw new JWTClaimValidationFailed('\"exp\" claim must be a number', payload, 'exp', 'invalid');\n }\n if (payload.exp <= now - tolerance) {\n throw new JWTExpired('\"exp\" claim timestamp check failed', payload, 'exp', 'check_failed');\n }\n }\n if (maxTokenAge) {\n const age = now - payload.iat;\n const max = typeof maxTokenAge === 'number' ? maxTokenAge : secs(maxTokenAge);\n if (age - tolerance > max) {\n throw new JWTExpired('\"iat\" claim timestamp check failed (too far in the past)', payload, 'iat', 'check_failed');\n }\n if (age < 0 - tolerance) {\n throw new JWTClaimValidationFailed('\"iat\" claim timestamp check failed (it should be in the past)', payload, 'iat', 'check_failed');\n }\n }\n return payload;\n}\nexport class JWTClaimsBuilder {\n #payload;\n constructor(payload) {\n if (!isObject(payload)) {\n throw new TypeError('JWT Claims Set MUST be an object');\n }\n this.#payload = structuredClone(payload);\n }\n data() {\n return encoder.encode(JSON.stringify(this.#payload));\n }\n get iss() {\n return this.#payload.iss;\n }\n set iss(value) {\n this.#payload.iss = value;\n }\n get sub() {\n return this.#payload.sub;\n }\n set sub(value) {\n this.#payload.sub = value;\n }\n get aud() {\n return this.#payload.aud;\n }\n set aud(value) {\n this.#payload.aud = value;\n }\n set jti(value) {\n this.#payload.jti = value;\n }\n set nbf(value) {\n if (typeof value === 'number') {\n this.#payload.nbf = validateInput('setNotBefore', value);\n }\n else if (value instanceof Date) {\n this.#payload.nbf = validateInput('setNotBefore', epoch(value));\n }\n else {\n this.#payload.nbf = epoch(new Date()) + secs(value);\n }\n }\n set exp(value) {\n if (typeof value === 'number') {\n this.#payload.exp = validateInput('setExpirationTime', value);\n }\n else if (value instanceof Date) {\n this.#payload.exp = validateInput('setExpirationTime', epoch(value));\n }\n else {\n this.#payload.exp = epoch(new Date()) + secs(value);\n }\n }\n set iat(value) {\n if (typeof value === 'undefined') {\n this.#payload.iat = epoch(new Date());\n }\n else if (value instanceof Date) {\n this.#payload.iat = validateInput('setIssuedAt', epoch(value));\n }\n else if (typeof value === 'string') {\n this.#payload.iat = validateInput('setIssuedAt', epoch(new Date()) + secs(value));\n }\n else {\n this.#payload.iat = validateInput('setIssuedAt', value);\n }\n }\n}\n","import { compactVerify } from '../jws/compact/verify.js';\nimport { validateClaimsSet } from '../lib/jwt_claims_set.js';\nimport { JWTInvalid } from '../util/errors.js';\nexport async function jwtVerify(jwt, key, options) {\n const verified = await compactVerify(jwt, key, options);\n if (verified.protectedHeader.crit?.includes('b64') && verified.protectedHeader.b64 === false) {\n throw new JWTInvalid('JWTs MUST NOT use unencoded payload');\n }\n const payload = validateClaimsSet(verified.protectedHeader, verified.payload, options);\n const result = { payload, protectedHeader: verified.protectedHeader };\n if (typeof key === 'function') {\n return { ...result, key: verified.key };\n }\n return result;\n}\n","import { flattenedVerify } from '../flattened/verify.js';\nimport { JWSInvalid } from '../../util/errors.js';\nimport { decoder } from '../../lib/buffer_utils.js';\nexport async function compactVerify(jws, key, options) {\n if (jws instanceof Uint8Array) {\n jws = decoder.decode(jws);\n }\n if (typeof jws !== 'string') {\n throw new JWSInvalid('Compact JWS must be a string or Uint8Array');\n }\n const { 0: protectedHeader, 1: payload, 2: signature, length } = jws.split('.');\n if (length !== 3) {\n throw new JWSInvalid('Invalid Compact JWS');\n }\n const verified = await flattenedVerify({ payload, protected: protectedHeader, signature }, key, options);\n const result = { payload: verified.payload, protectedHeader: verified.protectedHeader };\n if (typeof key === 'function') {\n return { ...result, key: verified.key };\n }\n return result;\n}\n","import { importJWK } from '../key/import.js';\nimport { JWKSInvalid, JOSENotSupported, JWKSNoMatchingKey, JWKSMultipleMatchingKeys, } from '../util/errors.js';\nimport isObject from '../lib/is_object.js';\nfunction getKtyFromAlg(alg) {\n switch (typeof alg === 'string' && alg.slice(0, 2)) {\n case 'RS':\n case 'PS':\n return 'RSA';\n case 'ES':\n return 'EC';\n case 'Ed':\n return 'OKP';\n case 'ML':\n return 'AKP';\n default:\n throw new JOSENotSupported('Unsupported \"alg\" value for a JSON Web Key Set');\n }\n}\nfunction isJWKSLike(jwks) {\n return (jwks &&\n typeof jwks === 'object' &&\n Array.isArray(jwks.keys) &&\n jwks.keys.every(isJWKLike));\n}\nfunction isJWKLike(key) {\n return isObject(key);\n}\nclass LocalJWKSet {\n #jwks;\n #cached = new WeakMap();\n constructor(jwks) {\n if (!isJWKSLike(jwks)) {\n throw new JWKSInvalid('JSON Web Key Set malformed');\n }\n this.#jwks = structuredClone(jwks);\n }\n jwks() {\n return this.#jwks;\n }\n async getKey(protectedHeader, token) {\n const { alg, kid } = { ...protectedHeader, ...token?.header };\n const kty = getKtyFromAlg(alg);\n const candidates = this.#jwks.keys.filter((jwk) => {\n let candidate = kty === jwk.kty;\n if (candidate && typeof kid === 'string') {\n candidate = kid === jwk.kid;\n }\n if (candidate && (typeof jwk.alg === 'string' || kty === 'AKP')) {\n candidate = alg === jwk.alg;\n }\n if (candidate && typeof jwk.use === 'string') {\n candidate = jwk.use === 'sig';\n }\n if (candidate && Array.isArray(jwk.key_ops)) {\n candidate = jwk.key_ops.includes('verify');\n }\n if (candidate) {\n switch (alg) {\n case 'ES256':\n candidate = jwk.crv === 'P-256';\n break;\n case 'ES384':\n candidate = jwk.crv === 'P-384';\n break;\n case 'ES512':\n candidate = jwk.crv === 'P-521';\n break;\n case 'Ed25519':\n case 'EdDSA':\n candidate = jwk.crv === 'Ed25519';\n break;\n }\n }\n return candidate;\n });\n const { 0: jwk, length } = candidates;\n if (length === 0) {\n throw new JWKSNoMatchingKey();\n }\n if (length !== 1) {\n const error = new JWKSMultipleMatchingKeys();\n const _cached = this.#cached;\n error[Symbol.asyncIterator] = async function* () {\n for (const jwk of candidates) {\n try {\n yield await importWithAlgCache(_cached, jwk, alg);\n }\n catch { }\n }\n };\n throw error;\n }\n return importWithAlgCache(this.#cached, jwk, alg);\n }\n}\nasync function importWithAlgCache(cache, jwk, alg) {\n const cached = cache.get(jwk) || cache.set(jwk, {}).get(jwk);\n if (cached[alg] === undefined) {\n const key = await importJWK({ ...jwk, ext: true }, alg);\n if (key instanceof Uint8Array || key.type !== 'public') {\n throw new JWKSInvalid('JSON Web Key Set members must be public keys');\n }\n cached[alg] = key;\n }\n return cached[alg];\n}\nexport function createLocalJWKSet(jwks) {\n const set = new LocalJWKSet(jwks);\n const localJWKSet = async (protectedHeader, token) => set.getKey(protectedHeader, token);\n Object.defineProperties(localJWKSet, {\n jwks: {\n value: () => structuredClone(set.jwks()),\n enumerable: false,\n configurable: false,\n writable: false,\n },\n });\n return localJWKSet;\n}\n","import { decode as decodeBase64URL } from '../util/base64url.js';\nimport { fromSPKI, fromPKCS8, fromX509 } from '../lib/asn1.js';\nimport toCryptoKey from '../lib/jwk_to_key.js';\nimport { JOSENotSupported } from '../util/errors.js';\nimport isObject from '../lib/is_object.js';\nexport async function importSPKI(spki, alg, options) {\n if (typeof spki !== 'string' || spki.indexOf('-----BEGIN PUBLIC KEY-----') !== 0) {\n throw new TypeError('\"spki\" must be SPKI formatted string');\n }\n return fromSPKI(spki, alg, options);\n}\nexport async function importX509(x509, alg, options) {\n if (typeof x509 !== 'string' || x509.indexOf('-----BEGIN CERTIFICATE-----') !== 0) {\n throw new TypeError('\"x509\" must be X.509 formatted string');\n }\n return fromX509(x509, alg, options);\n}\nexport async function importPKCS8(pkcs8, alg, options) {\n if (typeof pkcs8 !== 'string' || pkcs8.indexOf('-----BEGIN PRIVATE KEY-----') !== 0) {\n throw new TypeError('\"pkcs8\" must be PKCS#8 formatted string');\n }\n return fromPKCS8(pkcs8, alg, options);\n}\nexport async function importJWK(jwk, alg, options) {\n if (!isObject(jwk)) {\n throw new TypeError('JWK must be an object');\n }\n let ext;\n alg ??= jwk.alg;\n ext ??= options?.extractable ?? jwk.ext;\n switch (jwk.kty) {\n case 'oct':\n if (typeof jwk.k !== 'string' || !jwk.k) {\n throw new TypeError('missing \"k\" (Key Value) Parameter value');\n }\n return decodeBase64URL(jwk.k);\n case 'RSA':\n if ('oth' in jwk && jwk.oth !== undefined) {\n throw new JOSENotSupported('RSA JWK \"oth\" (Other Primes Info) Parameter value is not supported');\n }\n return toCryptoKey({ ...jwk, alg, ext });\n case 'AKP': {\n if (typeof jwk.alg !== 'string' || !jwk.alg) {\n throw new TypeError('missing \"alg\" (Algorithm) Parameter value');\n }\n if (alg !== undefined && alg !== jwk.alg) {\n throw new TypeError('JWK alg and alg option value mismatch');\n }\n return toCryptoKey({ ...jwk, ext });\n }\n case 'EC':\n case 'OKP':\n return toCryptoKey({ ...jwk, alg, ext });\n default:\n throw new JOSENotSupported('Unsupported \"kty\" (Key Type) Parameter value');\n }\n}\n","import { JOSEError, JWKSNoMatchingKey, JWKSTimeout } from '../util/errors.js';\nimport { createLocalJWKSet } from './local.js';\nimport isObject from '../lib/is_object.js';\nfunction isCloudflareWorkers() {\n return (typeof WebSocketPair !== 'undefined' ||\n (typeof navigator !== 'undefined' && navigator.userAgent === 'Cloudflare-Workers') ||\n (typeof EdgeRuntime !== 'undefined' && EdgeRuntime === 'vercel'));\n}\nlet USER_AGENT;\nif (typeof navigator === 'undefined' || !navigator.userAgent?.startsWith?.('Mozilla/5.0 ')) {\n const NAME = 'jose';\n const VERSION = 'v6.1.0';\n USER_AGENT = `${NAME}/${VERSION}`;\n}\nexport const customFetch = Symbol();\nasync function fetchJwks(url, headers, signal, fetchImpl = fetch) {\n const response = await fetchImpl(url, {\n method: 'GET',\n signal,\n redirect: 'manual',\n headers,\n }).catch((err) => {\n if (err.name === 'TimeoutError') {\n throw new JWKSTimeout();\n }\n throw err;\n });\n if (response.status !== 200) {\n throw new JOSEError('Expected 200 OK from the JSON Web Key Set HTTP response');\n }\n try {\n return await response.json();\n }\n catch {\n throw new JOSEError('Failed to parse the JSON Web Key Set HTTP response as JSON');\n }\n}\nexport const jwksCache = Symbol();\nfunction isFreshJwksCache(input, cacheMaxAge) {\n if (typeof input !== 'object' || input === null) {\n return false;\n }\n if (!('uat' in input) || typeof input.uat !== 'number' || Date.now() - input.uat >= cacheMaxAge) {\n return false;\n }\n if (!('jwks' in input) ||\n !isObject(input.jwks) ||\n !Array.isArray(input.jwks.keys) ||\n !Array.prototype.every.call(input.jwks.keys, isObject)) {\n return false;\n }\n return true;\n}\nclass RemoteJWKSet {\n #url;\n #timeoutDuration;\n #cooldownDuration;\n #cacheMaxAge;\n #jwksTimestamp;\n #pendingFetch;\n #headers;\n #customFetch;\n #local;\n #cache;\n constructor(url, options) {\n if (!(url instanceof URL)) {\n throw new TypeError('url must be an instance of URL');\n }\n this.#url = new URL(url.href);\n this.#timeoutDuration =\n typeof options?.timeoutDuration === 'number' ? options?.timeoutDuration : 5000;\n this.#cooldownDuration =\n typeof options?.cooldownDuration === 'number' ? options?.cooldownDuration : 30000;\n this.#cacheMaxAge = typeof options?.cacheMaxAge === 'number' ? options?.cacheMaxAge : 600000;\n this.#headers = new Headers(options?.headers);\n if (USER_AGENT && !this.#headers.has('User-Agent')) {\n this.#headers.set('User-Agent', USER_AGENT);\n }\n if (!this.#headers.has('accept')) {\n this.#headers.set('accept', 'application/json');\n this.#headers.append('accept', 'application/jwk-set+json');\n }\n this.#customFetch = options?.[customFetch];\n if (options?.[jwksCache] !== undefined) {\n this.#cache = options?.[jwksCache];\n if (isFreshJwksCache(options?.[jwksCache], this.#cacheMaxAge)) {\n this.#jwksTimestamp = this.#cache.uat;\n this.#local = createLocalJWKSet(this.#cache.jwks);\n }\n }\n }\n pendingFetch() {\n return !!this.#pendingFetch;\n }\n coolingDown() {\n return typeof this.#jwksTimestamp === 'number'\n ? Date.now() < this.#jwksTimestamp + this.#cooldownDuration\n : false;\n }\n fresh() {\n return typeof this.#jwksTimestamp === 'number'\n ? Date.now() < this.#jwksTimestamp + this.#cacheMaxAge\n : false;\n }\n jwks() {\n return this.#local?.jwks();\n }\n async getKey(protectedHeader, token) {\n if (!this.#local || !this.fresh()) {\n await this.reload();\n }\n try {\n return await this.#local(protectedHeader, token);\n }\n catch (err) {\n if (err instanceof JWKSNoMatchingKey) {\n if (this.coolingDown() === false) {\n await this.reload();\n return this.#local(protectedHeader, token);\n }\n }\n throw err;\n }\n }\n async reload() {\n if (this.#pendingFetch && isCloudflareWorkers()) {\n this.#pendingFetch = undefined;\n }\n this.#pendingFetch ||= fetchJwks(this.#url.href, this.#headers, AbortSignal.timeout(this.#timeoutDuration), this.#customFetch)\n .then((json) => {\n this.#local = createLocalJWKSet(json);\n if (this.#cache) {\n this.#cache.uat = Date.now();\n this.#cache.jwks = json;\n }\n this.#jwksTimestamp = Date.now();\n this.#pendingFetch = undefined;\n })\n .catch((err) => {\n this.#pendingFetch = undefined;\n throw err;\n });\n await this.#pendingFetch;\n }\n}\nexport function createRemoteJWKSet(url, options) {\n const set = new RemoteJWKSet(url, options);\n const remoteJWKSet = async (protectedHeader, token) => set.getKey(protectedHeader, token);\n Object.defineProperties(remoteJWKSet, {\n coolingDown: {\n get: () => set.coolingDown(),\n enumerable: true,\n configurable: false,\n },\n fresh: {\n get: () => set.fresh(),\n enumerable: true,\n configurable: false,\n },\n reload: {\n value: () => set.reload(),\n enumerable: true,\n configurable: false,\n writable: false,\n },\n reloading: {\n get: () => set.pendingFetch(),\n enumerable: true,\n configurable: false,\n },\n jwks: {\n value: () => set.jwks(),\n enumerable: true,\n configurable: false,\n writable: false,\n },\n });\n return remoteJWKSet;\n}\n","/**\n * Simple logger with debug mode support\n */\nexport class Logger {\n private debug: boolean;\n private prefix: string;\n\n constructor(debug: boolean = false, prefix: string = '[MarketplaceSDK]') {\n this.debug = debug;\n this.prefix = prefix;\n }\n\n /**\n * Log debug message (only if debug enabled)\n */\n log(...args: any[]): void {\n if (this.debug) {\n console.log(this.prefix, ...args);\n }\n }\n\n /**\n * Log info message (only if debug enabled)\n */\n info(...args: any[]): void {\n if (this.debug) {\n console.info(this.prefix, ...args);\n }\n }\n\n /**\n * Log warning message (always shown)\n */\n warn(...args: any[]): void {\n console.warn(this.prefix, ...args);\n }\n\n /**\n * Log error message (always shown)\n */\n error(...args: any[]): void {\n console.error(this.prefix, ...args);\n }\n}\n","import { createRemoteJWKSet, jwtVerify, JWTVerifyResult, JWTPayload } from 'jose';\nimport { SDKError, JWTClaims } from '../types';\nimport { Logger } from '../utils/logger';\n\n/**\n * JWKS Validator for RS256 JWT signature verification\n * Uses jose library for browser and Node.js compatibility\n */\nexport class JWKSValidator {\n private jwksUri: string;\n private logger: Logger;\n private jwks: ReturnType<typeof createRemoteJWKSet>;\n\n constructor(jwksUri: string, debug: boolean = false) {\n this.jwksUri = jwksUri;\n this.logger = new Logger(debug, '[JWKSValidator]');\n\n // Create JWKS fetcher (works in browser and Node.js)\n this.jwks = createRemoteJWKSet(new URL(this.jwksUri));\n\n this.logger.info('Initialized with JWKS URI:', this.jwksUri);\n }\n\n /**\n * Verify JWT signature using JWKS public key\n * @param token - JWT token to verify\n * @param expectedIssuer - Expected issuer (default: 'generalwisdom.com')\n * @param expectedApplicationId - Optional application ID to validate\n * @returns Decoded and verified JWT claims\n */\n async verify(\n token: string,\n expectedIssuer: string = 'generalwisdom.com',\n expectedApplicationId?: string\n ): Promise<JWTClaims> {\n this.logger.log('Verifying JWT signature...');\n\n try {\n // Verify JWT using JWKS\n const result: JWTVerifyResult = await jwtVerify(token, this.jwks, {\n issuer: expectedIssuer,\n algorithms: ['RS256'],\n });\n\n const payload = result.payload as JWTPayload & Partial<JWTClaims>;\n\n // Validate required claims\n const requiredClaims: (keyof JWTClaims)[] = [\n 'sessionId',\n 'userId',\n 'orgId',\n 'applicationId',\n 'exp',\n 'iat',\n ];\n\n for (const claim of requiredClaims) {\n if (!(claim in payload)) {\n throw new SDKError(\n `Missing required claim: ${claim}`,\n 'MISSING_CLAIM'\n );\n }\n }\n\n // Validate application ID if provided\n if (expectedApplicationId && payload.applicationId !== expectedApplicationId) {\n this.logger.error(\n `Application ID mismatch: expected ${expectedApplicationId}, got ${payload.applicationId}`\n );\n throw new SDKError(\n 'Token is for a different application',\n 'APPLICATION_MISMATCH'\n );\n }\n\n const claims: JWTClaims = {\n sessionId: payload.sessionId!,\n applicationId: payload.applicationId!,\n userId: payload.userId!,\n orgId: payload.orgId!,\n startTime: payload.startTime!,\n durationMinutes: payload.durationMinutes!,\n iat: payload.iat!,\n exp: payload.exp!,\n iss: payload.iss!,\n sub: payload.sub!,\n };\n\n this.logger.log('JWT verified successfully');\n return claims;\n\n } catch (error) {\n this.logger.error('JWT verification failed:', error);\n\n if (error instanceof SDKError) {\n throw error;\n }\n\n // Handle jose-specific errors\n const errorMessage = error instanceof Error ? error.message : 'Unknown error';\n const errorName = error instanceof Error ? error.name : 'Error';\n\n if (errorName === 'JWTExpired' || errorMessage.includes('expired')) {\n throw new SDKError('Session expired', 'SESSION_EXPIRED');\n }\n\n if (errorName === 'JWSSignatureVerificationFailed') {\n throw new SDKError('Invalid JWT signature', 'INVALID_SIGNATURE');\n }\n\n if (errorName === 'JWTClaimValidationFailed') {\n throw new SDKError(`JWT claim validation failed: ${errorMessage}`, 'INVALID_CLAIM');\n }\n\n throw new SDKError(\n `JWT verification failed: ${errorMessage}`,\n 'VERIFICATION_FAILED'\n );\n }\n }\n\n /**\n * Update JWKS URI\n * @param jwksUri - New JWKS URI\n */\n updateJwksUri(jwksUri: string): void {\n this.jwksUri = jwksUri;\n this.jwks = createRemoteJWKSet(new URL(this.jwksUri));\n this.logger.info('Updated JWKS URI:', this.jwksUri);\n }\n}\n","import { Logger } from '../utils/logger';\nimport { SDKEvents } from '../types';\n\n/**\n * Timer Manager for session countdown\n */\nexport class TimerManager {\n private remainingSeconds: number;\n private intervalId: number | null = null;\n private warningThreshold: number;\n private warningShown: boolean = false;\n private logger: Logger;\n private events: Partial<SDKEvents>;\n\n constructor(\n durationSeconds: number,\n warningThresholdSeconds: number = 300,\n events: Partial<SDKEvents> = {},\n debug: boolean = false\n ) {\n this.remainingSeconds = durationSeconds;\n this.warningThreshold = warningThresholdSeconds;\n this.events = events;\n this.logger = new Logger(debug, '[TimerManager]');\n\n this.logger.log('Initialized with duration:', durationSeconds, 'seconds');\n }\n\n /**\n * Start countdown timer\n */\n start(): void {\n if (this.intervalId !== null) {\n this.logger.warn('Timer already running');\n return;\n }\n\n this.logger.log('Starting timer with', this.remainingSeconds, 'seconds remaining');\n\n this.intervalId = window.setInterval(() => {\n this.remainingSeconds--;\n\n // Check for warning threshold\n if (\n !this.warningShown &&\n this.remainingSeconds <= this.warningThreshold &&\n this.remainingSeconds > 0\n ) {\n this.warningShown = true;\n this.logger.warn('Warning threshold reached:', this.remainingSeconds, 'seconds remaining');\n this.events.onSessionWarning?.({\n remainingSeconds: this.remainingSeconds,\n });\n }\n\n // Check for expiration\n if (this.remainingSeconds <= 0) {\n this.logger.warn('Session expired');\n this.stop();\n this.events.onSessionEnd?.();\n }\n }, 1000);\n }\n\n /**\n * Stop timer\n */\n stop(): void {\n if (this.intervalId !== null) {\n clearInterval(this.intervalId);\n this.intervalId = null;\n this.logger.log('Timer stopped');\n }\n }\n\n /**\n * Pause timer\n */\n pause(): void {\n this.stop();\n this.logger.log('Timer paused at:', this.remainingSeconds, 'seconds');\n }\n\n /**\n * Resume timer\n */\n resume(): void {\n if (this.intervalId === null && this.remainingSeconds > 0) {\n this.start();\n this.logger.log('Timer resumed at:', this.remainingSeconds, 'seconds');\n }\n }\n\n /**\n * Get remaining time in seconds\n */\n getRemainingSeconds(): number {\n return this.remainingSeconds;\n }\n\n /**\n * Get formatted time string (MM:SS)\n */\n getFormattedTime(): string {\n const minutes = Math.floor(this.remainingSeconds / 60);\n const seconds = this.remainingSeconds % 60;\n return `${minutes}:${seconds.toString().padStart(2, '0')}`;\n }\n\n /**\n * Get formatted time string with hours (HH:MM:SS)\n */\n getFormattedTimeWithHours(): string {\n const hours = Math.floor(this.remainingSeconds / 3600);\n const minutes = Math.floor((this.remainingSeconds % 3600) / 60);\n const seconds = this.remainingSeconds % 60;\n\n if (hours > 0) {\n return `${hours}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;\n }\n\n return this.getFormattedTime();\n }\n\n /**\n * Check if timer is running\n */\n isRunning(): boolean {\n return this.intervalId !== null;\n }\n\n /**\n * Check if warning has been shown\n */\n hasWarningBeenShown(): boolean {\n return this.warningShown;\n }\n\n /**\n * Update remaining time (useful for syncing with server)\n */\n updateRemainingTime(seconds: number): void {\n this.remainingSeconds = seconds;\n this.logger.log('Remaining time updated to:', seconds, 'seconds');\n }\n}\n","import { Logger } from '../utils/logger';\nimport { SDKError } from '../types';\n\n/**\n * Heartbeat Manager for active session tracking\n * Phase 2 Feature - Sends periodic heartbeats to backend\n */\nexport class HeartbeatManager {\n private intervalId: number | null = null;\n private heartbeatInterval: number;\n private failureCount: number = 0;\n private maxFailures: number = 3;\n private isEnabled: boolean = false;\n private logger: Logger;\n\n constructor(\n private sessionId: string,\n private apiEndpoint: string,\n private token: string,\n private onSync?: (remainingSeconds: number) => void,\n private onError?: (error: Error) => void,\n heartbeatIntervalSeconds: number = 30,\n debug: boolean = false\n ) {\n this.heartbeatInterval = heartbeatIntervalSeconds * 1000;\n this.logger = new Logger(debug, '[HeartbeatManager]');\n this.logger.log('Initialized with', heartbeatIntervalSeconds, 'second interval');\n }\n\n /**\n * Start sending heartbeats\n */\n start(): void {\n if (this.intervalId !== null) {\n this.logger.warn('Heartbeat already running');\n return;\n }\n\n this.isEnabled = true;\n this.logger.log('Starting heartbeat for session:', this.sessionId);\n\n // Send initial heartbeat immediately\n this.sendHeartbeat();\n\n // Then send periodically\n this.intervalId = window.setInterval(() => {\n this.sendHeartbeat();\n }, this.heartbeatInterval);\n }\n\n /**\n * Stop sending heartbeats\n */\n stop(): void {\n if (this.intervalId !== null) {\n clearInterval(this.intervalId);\n this.intervalId = null;\n this.isEnabled = false;\n this.logger.log('Heartbeat stopped');\n }\n }\n\n /**\n * Send a single heartbeat to backend\n */\n private async sendHeartbeat(): Promise<void> {\n if (!this.isEnabled) {\n return;\n }\n\n this.logger.log('Sending heartbeat...');\n\n try {\n const response = await fetch(\n `${this.apiEndpoint}/sessions/${this.sessionId}/heartbeat`,\n {\n method: 'POST',\n headers: {\n 'Authorization': `Bearer ${this.token}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n timestamp: Date.now(),\n active: true,\n }),\n }\n );\n\n if (!response.ok) {\n throw new SDKError(\n `Heartbeat failed with status ${response.status}`,\n 'HEARTBEAT_FAILED',\n response.status\n );\n }\n\n const data = await response.json();\n\n // Reset failure count on success\n this.failureCount = 0;\n\n // Sync remaining time with server\n if (typeof data.remaining_seconds === 'number') {\n this.logger.log('Server reports', data.remaining_seconds, 'seconds remaining');\n this.onSync?.(data.remaining_seconds);\n }\n\n this.logger.log('Heartbeat acknowledged');\n\n } catch (error) {\n this.failureCount++;\n this.logger.error('Heartbeat failed:', error, `(${this.failureCount}/${this.maxFailures})`);\n\n if (this.failureCount >= this.maxFailures) {\n this.logger.error('Max heartbeat failures reached, stopping');\n this.stop();\n\n const sdkError = error instanceof SDKError ? error : new SDKError(\n error instanceof Error ? error.message : 'Heartbeat failed',\n 'HEARTBEAT_ERROR'\n );\n this.onError?.(sdkError);\n }\n }\n }\n\n /**\n * Check if heartbeat is running\n */\n isRunning(): boolean {\n return this.intervalId !== null;\n }\n\n /**\n * Get failure count\n */\n getFailureCount(): number {\n return this.failureCount;\n }\n\n /**\n * Update heartbeat interval\n */\n updateInterval(seconds: number): void {\n const wasRunning = this.isRunning();\n\n if (wasRunning) {\n this.stop();\n }\n\n this.heartbeatInterval = seconds * 1000;\n this.logger.log('Heartbeat interval updated to', seconds, 'seconds');\n\n if (wasRunning) {\n this.start();\n }\n }\n}\n","import { Logger } from '../utils/logger';\n\nexport interface TabSyncMessage {\n type: 'timer_update' | 'pause' | 'resume' | 'end';\n sessionId: string;\n remainingSeconds?: number;\n timestamp: number;\n}\n\n/**\n * Tab Synchronization Manager\n * Phase 2 Feature - Syncs session state across multiple tabs\n */\nexport class TabSyncManager {\n private channel: BroadcastChannel | null = null;\n private storageKey: string;\n private logger: Logger;\n private isMaster: boolean = false;\n\n constructor(\n private sessionId: string,\n private onMessage: (message: TabSyncMessage) => void,\n debug: boolean = false\n ) {\n this.storageKey = `gw_session_sync_${sessionId}`;\n this.logger = new Logger(debug, '[TabSyncManager]');\n\n this.initialize();\n }\n\n /**\n * Initialize sync mechanism\n */\n private initialize(): void {\n // Try BroadcastChannel API first (modern browsers)\n if (typeof BroadcastChannel !== 'undefined') {\n this.logger.log('Using BroadcastChannel for tab sync');\n this.channel = new BroadcastChannel(`gw-session-${this.sessionId}`);\n this.channel.onmessage = (event) => {\n this.handleMessage(event.data);\n };\n } else {\n // Fallback to localStorage events (older browsers)\n this.logger.log('Using localStorage for tab sync (fallback)');\n window.addEventListener('storage', this.handleStorageEvent);\n }\n\n // Elect this tab as master if no other tab exists\n this.electMaster();\n }\n\n /**\n * Broadcast message to other tabs\n */\n broadcast(type: TabSyncMessage['type'], data?: Partial<TabSyncMessage>): void {\n const message: TabSyncMessage = {\n type,\n sessionId: this.sessionId,\n timestamp: Date.now(),\n ...data,\n };\n\n if (this.channel) {\n this.channel.postMessage(message);\n this.logger.log('Broadcasted:', type);\n } else {\n // Fallback: use localStorage\n localStorage.setItem(this.storageKey, JSON.stringify(message));\n this.logger.log('Broadcasted via localStorage:', type);\n }\n }\n\n /**\n * Handle incoming message\n */\n private handleMessage(data: TabSyncMessage): void {\n if (data.sessionId !== this.sessionId) {\n return; // Ignore messages for other sessions\n }\n\n this.logger.log('Received message:', data.type);\n this.onMessage(data);\n }\n\n /**\n * Handle storage event (fallback mechanism)\n */\n private handleStorageEvent = (event: StorageEvent): void => {\n if (event.key === this.storageKey && event.newValue) {\n try {\n const data = JSON.parse(event.newValue) as TabSyncMessage;\n this.handleMessage(data);\n } catch (error) {\n this.logger.error('Failed to parse storage event:', error);\n }\n }\n };\n\n /**\n * Elect this tab as master if appropriate\n * Master tab is responsible for heartbeats\n */\n private electMaster(): void {\n const masterKey = `gw_session_master_${this.sessionId}`;\n const existingMaster = localStorage.getItem(masterKey);\n\n if (!existingMaster) {\n // No master exists, become master\n this.isMaster = true;\n localStorage.setItem(masterKey, Date.now().toString());\n this.logger.log('Elected as master tab');\n\n // Set up heartbeat to maintain master status\n setInterval(() => {\n if (this.isMaster) {\n localStorage.setItem(masterKey, Date.now().toString());\n }\n }, 5000);\n\n // Clear master status on unload\n window.addEventListener('beforeunload', () => {\n if (this.isMaster) {\n localStorage.removeItem(masterKey);\n this.logger.log('Removed master status');\n }\n });\n } else {\n this.logger.log('Another tab is master');\n\n // Check periodically if master is still alive\n setInterval(() => {\n const masterTimestamp = localStorage.getItem(masterKey);\n if (masterTimestamp) {\n const age = Date.now() - parseInt(masterTimestamp);\n if (age > 10000) {\n // Master hasn't updated in 10s, assume dead\n this.logger.warn('Master tab appears dead, becoming master');\n this.isMaster = true;\n localStorage.setItem(masterKey, Date.now().toString());\n }\n }\n }, 5000);\n }\n }\n\n /**\n * Check if this tab is the master\n */\n isMasterTab(): boolean {\n return this.isMaster;\n }\n\n /**\n * Cleanup and destroy\n */\n destroy(): void {\n if (this.channel) {\n this.channel.close();\n this.channel = null;\n } else {\n window.removeEventListener('storage', this.handleStorageEvent);\n }\n\n // Clean up storage\n localStorage.removeItem(this.storageKey);\n\n if (this.isMaster) {\n localStorage.removeItem(`gw_session_master_${this.sessionId}`);\n }\n\n this.logger.log('Tab sync destroyed');\n }\n}\n","/**\n * Theme configuration matching the General Wisdom SPA design system\n * Based on gw-spa/src/styles/globals.css and Tailwind CSS v4\n */\n\nexport interface ThemeColors {\n // Background colors\n background: string;\n foreground: string;\n\n // Card colors\n card: string;\n cardForeground: string;\n\n // Popover colors\n popover: string;\n popoverForeground: string;\n\n // Primary colors (brand blue)\n primary: string;\n primaryForeground: string;\n\n // Secondary colors (light gray)\n secondary: string;\n secondaryForeground: string;\n\n // Muted colors\n muted: string;\n mutedForeground: string;\n\n // Accent colors\n accent: string;\n accentForeground: string;\n\n // Destructive colors (red for errors/warnings)\n destructive: string;\n destructiveForeground: string;\n\n // Success colors (green for success actions)\n success: string;\n successForeground: string;\n\n // Border and input\n border: string;\n input: string;\n ring: string;\n}\n\nexport interface ThemeTypography {\n fontFamily: string;\n fontSize: {\n xs: string;\n sm: string;\n base: string;\n lg: string;\n xl: string;\n '2xl': string;\n };\n fontWeight: {\n normal: string;\n medium: string;\n semibold: string;\n bold: string;\n };\n lineHeight: {\n tight: string;\n normal: string;\n relaxed: string;\n };\n}\n\nexport interface ThemeSpacing {\n borderRadius: {\n sm: string;\n md: string;\n lg: string;\n };\n padding: {\n sm: string;\n md: string;\n lg: string;\n xl: string;\n };\n gap: {\n sm: string;\n md: string;\n lg: string;\n };\n}\n\nexport interface Theme {\n colors: ThemeColors;\n typography: ThemeTypography;\n spacing: ThemeSpacing;\n}\n\n/**\n * Light theme matching gw-spa design system\n */\nexport const lightTheme: Theme = {\n colors: {\n // Background\n background: 'hsl(0 0% 100%)',\n foreground: 'hsl(222.2 84% 4.9%)',\n\n // Card\n card: 'hsl(0 0% 100%)',\n cardForeground: 'hsl(222.2 84% 4.9%)',\n\n // Popover\n popover: 'hsl(0 0% 100%)',\n popoverForeground: 'hsl(222.2 84% 4.9%)',\n\n // Primary (brand blue)\n primary: 'hsl(221.2 83.2% 53.3%)',\n primaryForeground: 'hsl(210 40% 98%)',\n\n // Secondary (light gray)\n secondary: 'hsl(210 40% 96.1%)',\n secondaryForeground: 'hsl(222.2 47.4% 11.2%)',\n\n // Muted\n muted: 'hsl(210 40% 96.1%)',\n mutedForeground: 'hsl(215.4 16.3% 46.9%)',\n\n // Accent\n accent: 'hsl(210 40% 96.1%)',\n accentForeground: 'hsl(222.2 47.4% 11.2%)',\n\n // Destructive (red)\n destructive: 'hsl(0 84.2% 60.2%)',\n destructiveForeground: 'hsl(210 40% 98%)',\n\n // Success (green)\n success: 'hsl(142 76% 36%)', // Tailwind green-600 equivalent\n successForeground: 'hsl(0 0% 100%)',\n\n // Border and input\n border: 'hsl(214.3 31.8% 91.4%)',\n input: 'hsl(214.3 31.8% 91.4%)',\n ring: 'hsl(221.2 83.2% 53.3%)',\n },\n typography: {\n fontFamily: '-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif',\n fontSize: {\n xs: '12px',\n sm: '14px',\n base: '16px',\n lg: '18px',\n xl: '20px',\n '2xl': '24px',\n },\n fontWeight: {\n normal: '400',\n medium: '500',\n semibold: '600',\n bold: '700',\n },\n lineHeight: {\n tight: '1.25',\n normal: '1.5',\n relaxed: '1.75',\n },\n },\n spacing: {\n borderRadius: {\n sm: '4px', // calc(0.5rem - 4px)\n md: '6px', // calc(0.5rem - 2px)\n lg: '8px', // 0.5rem\n },\n padding: {\n sm: '8px',\n md: '16px',\n lg: '24px',\n xl: '32px',\n },\n gap: {\n sm: '8px',\n md: '12px',\n lg: '16px',\n },\n },\n};\n\n/**\n * Dark theme matching gw-spa design system\n */\nexport const darkTheme: Theme = {\n colors: {\n // Background\n background: 'hsl(222.2 84% 4.9%)',\n foreground: 'hsl(210 40% 98%)',\n\n // Card\n card: 'hsl(222.2 84% 4.9%)',\n cardForeground: 'hsl(210 40% 98%)',\n\n // Popover\n popover: 'hsl(222.2 84% 4.9%)',\n popoverForeground: 'hsl(210 40% 98%)',\n\n // Primary (lighter blue for dark mode)\n primary: 'hsl(217.2 91.2% 59.8%)',\n primaryForeground: 'hsl(222.2 47.4% 11.2%)',\n\n // Secondary (dark gray)\n secondary: 'hsl(217.2 32.6% 17.5%)',\n secondaryForeground: 'hsl(210 40% 98%)',\n\n // Muted\n muted: 'hsl(217.2 32.6% 17.5%)',\n mutedForeground: 'hsl(215 20.2% 65.1%)',\n\n // Accent\n accent: 'hsl(217.2 32.6% 17.5%)',\n accentForeground: 'hsl(210 40% 98%)',\n\n // Destructive (darker red for dark mode)\n destructive: 'hsl(0 62.8% 30.6%)',\n destructiveForeground: 'hsl(210 40% 98%)',\n\n // Success (darker green for dark mode)\n success: 'hsl(142 71% 45%)', // Tailwind green-500 equivalent\n successForeground: 'hsl(0 0% 100%)',\n\n // Border and input\n border: 'hsl(217.2 32.6% 17.5%)',\n input: 'hsl(217.2 32.6% 17.5%)',\n ring: 'hsl(224.3 76.3% 48%)',\n },\n typography: {\n fontFamily: '-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif',\n fontSize: {\n xs: '12px',\n sm: '14px',\n base: '16px',\n lg: '18px',\n xl: '20px',\n '2xl': '24px',\n },\n fontWeight: {\n normal: '400',\n medium: '500',\n semibold: '600',\n bold: '700',\n },\n lineHeight: {\n tight: '1.25',\n normal: '1.5',\n relaxed: '1.75',\n },\n },\n spacing: {\n borderRadius: {\n sm: '4px',\n md: '6px',\n lg: '8px',\n },\n padding: {\n sm: '8px',\n md: '16px',\n lg: '24px',\n xl: '32px',\n },\n gap: {\n sm: '8px',\n md: '12px',\n lg: '16px',\n },\n },\n};\n\n/**\n * Get theme based on user preference or system setting\n */\nexport function getTheme(prefersDark?: boolean): Theme {\n // Check for explicit preference\n if (prefersDark !== undefined) {\n return prefersDark ? darkTheme : lightTheme;\n }\n\n // Check system preference\n if (typeof window !== 'undefined' && window.matchMedia) {\n const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches;\n return isDarkMode ? darkTheme : lightTheme;\n }\n\n // Default to light theme\n return lightTheme;\n}\n\n/**\n * Generate CSS string from theme colors for inline styles\n */\nexport function generateCSSVariables(theme: Theme): string {\n return `\n --gw-background: ${theme.colors.background};\n --gw-foreground: ${theme.colors.foreground};\n --gw-card: ${theme.colors.card};\n --gw-card-foreground: ${theme.colors.cardForeground};\n --gw-primary: ${theme.colors.primary};\n --gw-primary-foreground: ${theme.colors.primaryForeground};\n --gw-secondary: ${theme.colors.secondary};\n --gw-secondary-foreground: ${theme.colors.secondaryForeground};\n --gw-muted: ${theme.colors.muted};\n --gw-muted-foreground: ${theme.colors.mutedForeground};\n --gw-accent: ${theme.colors.accent};\n --gw-accent-foreground: ${theme.colors.accentForeground};\n --gw-destructive: ${theme.colors.destructive};\n --gw-destructive-foreground: ${theme.colors.destructiveForeground};\n --gw-success: ${theme.colors.success};\n --gw-success-foreground: ${theme.colors.successForeground};\n --gw-border: ${theme.colors.border};\n --gw-input: ${theme.colors.input};\n --gw-ring: ${theme.colors.ring};\n `.trim();\n}\n","import { ModalStyles, ThemeMode } from '../types';\nimport { getTheme, Theme } from '../styles/theme';\n\n/**\n * Warning Modal for session expiration alerts\n */\nexport class WarningModal {\n private modal: HTMLDivElement | null = null;\n private theme: Theme;\n private legacyStyles: ModalStyles | null = null;\n private updateInterval: number | null = null;\n private timeDisplay: HTMLElement | null = null;\n private startTime: number = 0;\n private initialSeconds: number = 0;\n private onEndCallback: (() => void) | undefined = undefined;\n\n constructor(themeMode: ThemeMode = 'light', customStyles?: Partial<ModalStyles>) {\n // Use new theme system\n const prefersDark = themeMode === 'dark' || (themeMode === 'auto' && this.detectDarkMode());\n this.theme = getTheme(prefersDark);\n\n // Keep legacy styles for backward compatibility\n if (customStyles) {\n this.legacyStyles = {\n backgroundColor: customStyles.backgroundColor || '#ffffff',\n textColor: customStyles.textColor || '#333333',\n primaryColor: customStyles.primaryColor || '#007bff',\n borderRadius: customStyles.borderRadius || '8px',\n fontFamily:\n customStyles.fontFamily ||\n '-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif',\n };\n }\n }\n\n private detectDarkMode(): boolean {\n if (typeof window !== 'undefined' && window.matchMedia) {\n return window.matchMedia('(prefers-color-scheme: dark)').matches;\n }\n return false;\n }\n\n /**\n * Show warning modal\n */\n show(options: {\n remainingSeconds: number;\n onExtend?: () => void;\n onEnd?: () => void;\n }): void {\n // Remove existing modal if any\n this.hide();\n\n // Create modal\n this.modal = document.createElement('div');\n this.modal.id = 'gw-session-warning-modal';\n this.modal.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.5);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 99999;\n font-family: ${this.legacyStyles?.fontFamily || this.theme.typography.fontFamily};\n `;\n\n // Create modal content\n const content = document.createElement('div');\n const bgColor = this.legacyStyles?.backgroundColor || this.theme.colors.card;\n const textColor = this.legacyStyles?.textColor || this.theme.colors.cardForeground;\n const borderRadius = this.legacyStyles?.borderRadius || this.theme.spacing.borderRadius.lg;\n\n content.style.cssText = `\n background-color: ${bgColor};\n color: ${textColor};\n border-radius: ${borderRadius};\n padding: ${this.theme.spacing.padding.lg};\n max-width: 400px;\n width: 90%;\n box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);\n border: 1px solid ${this.theme.colors.border};\n `;\n\n this.initialSeconds = options.remainingSeconds;\n this.startTime = Date.now();\n this.onEndCallback = options.onEnd;\n\n const minutes = Math.floor(options.remainingSeconds / 60);\n const seconds = options.remainingSeconds % 60;\n\n content.innerHTML = `\n <h2 style=\"margin: 0 0 ${this.theme.spacing.padding.md} 0; font-size: ${this.theme.typography.fontSize.xl}; font-weight: ${this.theme.typography.fontWeight.semibold}; color: ${textColor};\">\n ⏱️ Time Running Low\n </h2>\n <p style=\"margin: 0 0 ${this.theme.spacing.padding.lg} 0; font-size: ${this.theme.typography.fontSize.base}; line-height: ${this.theme.typography.lineHeight.normal}; color: ${this.theme.colors.mutedForeground};\">\n Your session will expire in <strong id=\"gw-time-display\" style=\"color: ${textColor};\">${minutes}:${seconds.toString().padStart(2, '0')}</strong>.\n </p>\n <div style=\"display: flex; gap: ${this.theme.spacing.gap.md}; justify-content: flex-end;\">\n <button id=\"gw-dismiss-btn\" style=\"\n padding: 10px 20px;\n background-color: ${this.theme.colors.secondary};\n color: ${this.theme.colors.secondaryForeground};\n border: 1px solid ${this.theme.colors.border};\n border-radius: ${this.theme.spacing.borderRadius.sm};\n font-size: ${this.theme.typography.fontSize.sm};\n font-weight: ${this.theme.typography.fontWeight.medium};\n cursor: pointer;\n transition: all 0.2s;\n font-family: ${this.theme.typography.fontFamily};\n \">\n Continue\n </button>\n ${\n options.onExtend\n ? `<button id=\"gw-extend-btn\" style=\"\n padding: 10px 20px;\n background-color: ${this.theme.colors.success};\n color: ${this.theme.colors.successForeground};\n border: none;\n border-radius: ${this.theme.spacing.borderRadius.sm};\n font-size: ${this.theme.typography.fontSize.sm};\n font-weight: ${this.theme.typography.fontWeight.medium};\n cursor: pointer;\n transition: all 0.2s;\n font-family: ${this.theme.typography.fontFamily};\n \">\n Extend Session\n </button>`\n : ''\n }\n ${\n options.onEnd\n ? `<button id=\"gw-end-btn\" style=\"\n padding: 10px 20px;\n background-color: ${this.theme.colors.destructive};\n color: ${this.theme.colors.destructiveForeground};\n border: none;\n border-radius: ${this.theme.spacing.borderRadius.sm};\n font-size: ${this.theme.typography.fontSize.sm};\n font-weight: ${this.theme.typography.fontWeight.medium};\n cursor: pointer;\n transition: all 0.2s;\n font-family: ${this.theme.typography.fontFamily};\n \">\n End Session\n </button>`\n : ''\n }\n </div>\n `;\n\n this.modal.appendChild(content);\n document.body.appendChild(this.modal);\n\n // Add event listeners\n const extendBtn = document.getElementById('gw-extend-btn');\n if (extendBtn && options.onExtend) {\n extendBtn.addEventListener('click', () => {\n options.onExtend?.();\n this.hide();\n });\n }\n\n const dismissBtn = document.getElementById('gw-dismiss-btn');\n if (dismissBtn) {\n dismissBtn.addEventListener('click', () => {\n this.hide();\n });\n }\n\n const endBtn = document.getElementById('gw-end-btn');\n if (endBtn && options.onEnd) {\n endBtn.addEventListener('click', () => {\n options.onEnd?.();\n // Don't call this.hide() here - the onEnd callback will handle showing\n // the ending modal, and calling hide() would remove it immediately\n });\n }\n\n // Add hover effects\n const buttons = content.querySelectorAll('button');\n buttons.forEach((button) => {\n button.addEventListener('mouseenter', () => {\n (button as HTMLElement).style.opacity = '0.9';\n });\n button.addEventListener('mouseleave', () => {\n (button as HTMLElement).style.opacity = '1';\n });\n // Add focus ring\n button.addEventListener('focus', () => {\n (button as HTMLElement).style.outline = `2px solid ${this.theme.colors.ring}`;\n (button as HTMLElement).style.outlineOffset = '2px';\n });\n button.addEventListener('blur', () => {\n (button as HTMLElement).style.outline = 'none';\n });\n });\n\n // Start updating the timer display\n this.timeDisplay = document.getElementById('gw-time-display');\n this.updateInterval = window.setInterval(() => {\n const elapsed = Math.floor((Date.now() - this.startTime) / 1000);\n const remaining = Math.max(0, this.initialSeconds - elapsed);\n\n const minutes = Math.floor(remaining / 60);\n const seconds = remaining % 60;\n\n if (this.timeDisplay) {\n this.timeDisplay.textContent = `${minutes}:${seconds.toString().padStart(2, '0')}`;\n }\n\n // If time runs out, trigger session end if callback exists\n if (remaining === 0) {\n if (this.onEndCallback) {\n this.onEndCallback();\n }\n this.hide();\n }\n }, 1000);\n }\n\n /**\n * Hide and remove modal\n */\n hide(): void {\n // Clear the update interval\n if (this.updateInterval !== null) {\n clearInterval(this.updateInterval);\n this.updateInterval = null;\n }\n\n // Remove modal from DOM\n if (this.modal && this.modal.parentNode) {\n this.modal.parentNode.removeChild(this.modal);\n this.modal = null;\n this.timeDisplay = null;\n }\n }\n\n /**\n * Check if modal is currently shown\n */\n isShown(): boolean {\n return this.modal !== null;\n }\n\n /**\n * Show \"Session Ending\" modal before redirect\n * Displays for a fixed duration (3 seconds) then calls callback\n */\n showEndingMessage(onComplete: () => void, durationMs: number = 3000): void {\n // Hide any existing modal first\n this.hide();\n\n const bgColor = this.legacyStyles?.backgroundColor || this.theme.colors.card;\n const textColor = this.legacyStyles?.textColor || this.theme.colors.cardForeground;\n const borderRadius = this.legacyStyles?.borderRadius || this.theme.spacing.borderRadius.lg;\n\n // Create modal overlay\n this.modal = document.createElement('div');\n this.modal.id = 'gw-session-ending-modal';\n this.modal.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.5);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 99999;\n font-family: ${this.legacyStyles?.fontFamily || this.theme.typography.fontFamily};\n animation: fadeIn 0.2s ease-in;\n `;\n\n // Create modal content\n const content = document.createElement('div');\n content.style.cssText = `\n background-color: ${bgColor};\n color: ${textColor};\n border-radius: ${borderRadius};\n padding: ${this.theme.spacing.padding.xl};\n max-width: 400px;\n width: 90%;\n box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);\n text-align: center;\n animation: slideIn 0.3s ease-out;\n border: 1px solid ${this.theme.colors.border};\n `;\n\n content.innerHTML = `\n <div style=\"font-size: 48px; margin-bottom: ${this.theme.spacing.padding.lg};\">⏱️</div>\n <h2 style=\"margin: 0 0 ${this.theme.spacing.padding.md} 0; font-size: ${this.theme.typography.fontSize['2xl']}; font-weight: ${this.theme.typography.fontWeight.semibold}; color: ${this.theme.colors.destructive};\">\n Session Ending\n </h2>\n <p style=\"margin: 0 0 ${this.theme.spacing.padding.lg} 0; font-size: ${this.theme.typography.fontSize.base}; line-height: ${this.theme.typography.lineHeight.normal}; color: ${this.theme.colors.mutedForeground};\">\n Your session has expired.<br/>\n Redirecting to marketplace...\n </p>\n <div style=\"\n width: 100%;\n height: 4px;\n background: ${this.theme.colors.muted};\n border-radius: ${this.theme.spacing.borderRadius.sm};\n overflow: hidden;\n margin-top: ${this.theme.spacing.padding.lg};\n \">\n <div id=\"gw-progress-bar\" style=\"\n width: 100%;\n height: 100%;\n background: linear-gradient(90deg, ${this.theme.colors.destructive}, ${this.theme.colors.primary});\n animation: progressBar ${durationMs}ms linear forwards;\n \"></div>\n </div>\n `;\n\n // Add animations\n const style = document.createElement('style');\n style.textContent = `\n @keyframes fadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n @keyframes slideIn {\n from { transform: translateY(-20px); opacity: 0; }\n to { transform: translateY(0); opacity: 1; }\n }\n @keyframes progressBar {\n from { width: 100%; }\n to { width: 0%; }\n }\n `;\n document.head.appendChild(style);\n\n this.modal.appendChild(content);\n document.body.appendChild(this.modal);\n\n // Call callback after duration\n setTimeout(() => {\n this.hide();\n onComplete();\n }, durationMs);\n }\n}\n","import { SDKError } from '../types';\n\n/**\n * Extract JWT token from URL parameter\n * @param paramName - URL parameter name (default: 'jwt')\n * @param url - URL to extract from (default: window.location.href)\n * @returns JWT token or null if not found\n */\nexport function extractTokenFromURL(\n paramName: string = 'jwt',\n url?: string\n): string | null {\n try {\n const targetUrl = url || (typeof window !== 'undefined' ? window.location.href : '');\n\n if (!targetUrl) {\n return null;\n }\n\n const urlObj = new URL(targetUrl);\n const token = urlObj.searchParams.get(paramName);\n\n return token;\n } catch (error) {\n throw new SDKError(\n `Failed to extract token from URL: ${error instanceof Error ? error.message : 'Unknown error'}`,\n 'URL_PARSE_ERROR'\n );\n }\n}\n\n/**\n * Check if code is running in browser environment\n */\nexport function isBrowser(): boolean {\n return typeof window !== 'undefined' && typeof window.document !== 'undefined';\n}\n","import { JWTParser } from './JWTParser';\nimport { JWKSValidator } from './JWKSValidator';\nimport { TimerManager } from './TimerManager';\nimport { HeartbeatManager } from './HeartbeatManager';\nimport { TabSyncManager, TabSyncMessage } from './TabSyncManager';\nimport { WarningModal } from '../ui/WarningModal';\nimport { extractTokenFromURL } from '../utils/url';\nimport { Logger } from '../utils/logger';\nimport { SDKConfig, SDKEvents, SessionData, SDKError, SessionStartContext, SessionEndContext, SessionExtendContext, SessionWarningContext } from '../types';\n\n/**\n * Marketplace SDK with Phase 2 Features\n * - Heartbeat system\n * - Multi-tab synchronization\n * - Visibility API integration\n * - Session extension/completion\n * - Backend validation\n */\nexport class MarketplaceSDK {\n private config: Required<SDKConfig>;\n private validator: JWKSValidator;\n private timer: TimerManager | null = null;\n private heartbeat: HeartbeatManager | null = null;\n private tabSync: TabSyncManager | null = null;\n private modal: WarningModal | null = null;\n private logger: Logger;\n private events: Partial<SDKEvents> = {};\n private sessionData: SessionData | null = null;\n private jwtToken: string | null = null;\n private endReason: 'expired' | 'manual' | 'error' = 'manual';\n\n constructor(config: SDKConfig) {\n this.config = {\n jwksUri: config.jwksUri || 'https://api.generalwisdom.com/.well-known/jwks.json',\n apiEndpoint: config.apiEndpoint || 'http://localhost:3000',\n debug: config.debug ?? false,\n autoStart: config.autoStart ?? true,\n warningThresholdSeconds: config.warningThresholdSeconds ?? 300,\n customStyles: config.customStyles ?? {},\n themeMode: config.themeMode ?? 'light',\n applicationId: config.applicationId ?? '',\n marketplaceUrl: config.marketplaceUrl ?? 'https://d3p2yqofgy75sz.cloudfront.net/',\n // Phase 2 options\n enableHeartbeat: config.enableHeartbeat ?? false,\n heartbeatIntervalSeconds: config.heartbeatIntervalSeconds ?? 30,\n enableTabSync: config.enableTabSync ?? false,\n pauseOnHidden: config.pauseOnHidden ?? false,\n useBackendValidation: config.useBackendValidation ?? false,\n // Lifecycle hooks\n hooks: config.hooks ?? {},\n hookTimeoutMs: config.hookTimeoutMs ?? 5000,\n };\n\n this.validator = new JWKSValidator(this.config.jwksUri, this.config.debug);\n this.logger = new Logger(this.config.debug, '[MarketplaceSDK]');\n\n this.logger.info('SDK initialized with config:', {\n jwksUri: this.config.jwksUri,\n apiEndpoint: this.config.apiEndpoint,\n enableHeartbeat: this.config.enableHeartbeat,\n enableTabSync: this.config.enableTabSync,\n pauseOnHidden: this.config.pauseOnHidden,\n });\n }\n\n /**\n * Register event handlers\n */\n on<K extends keyof SDKEvents>(event: K, handler: SDKEvents[K]): void {\n this.events[event] = handler;\n this.logger.log('Event handler registered:', event);\n }\n\n /**\n * Execute a lifecycle hook with timeout\n */\n private async executeHook<T>(\n hookName: string,\n hook: ((context: T) => Promise<void> | void) | undefined,\n context: T,\n isStrict: boolean = true\n ): Promise<void> {\n if (!hook) return;\n\n this.logger.log(`Calling ${hookName} hook`);\n\n const timeout = new Promise<never>((_, reject) =>\n setTimeout(\n () => reject(new SDKError(`${hookName} hook timeout after ${this.config.hookTimeoutMs}ms`, 'HOOK_TIMEOUT')),\n this.config.hookTimeoutMs\n )\n );\n\n try {\n await Promise.race([\n Promise.resolve(hook(context)),\n timeout\n ]);\n this.logger.log(`${hookName} hook completed successfully`);\n } catch (error) {\n this.logger.error(`${hookName} hook failed:`, error);\n\n if (isStrict) {\n // Strict mode: throw error to prevent session operation\n throw new SDKError(\n `${hookName} hook failed: ${error instanceof Error ? error.message : 'Unknown error'}`,\n 'HOOK_ERROR'\n );\n } else {\n // Lenient mode: log but don't throw\n this.logger.warn(`${hookName} hook failed but continuing (lenient mode)`);\n }\n }\n }\n\n /**\n * Calculate actual session duration in minutes\n */\n private calculateActualDuration(): number | undefined {\n if (!this.sessionData) return undefined;\n const now = Math.floor(Date.now() / 1000);\n const durationSeconds = now - this.sessionData.startTime;\n return Math.ceil(durationSeconds / 60);\n }\n\n /**\n * Initialize SDK and validate session\n */\n async initialize(): Promise<SessionData> {\n this.logger.info('Initializing session...');\n\n try {\n // Extract JWT from URL or retrieve from storage\n const JWT_STORAGE_KEY = 'gw_marketplace_jwt';\n\n // First try URL parameter\n this.jwtToken = extractTokenFromURL('jwt');\n\n // If not in URL, try storage (for persistence through OAuth redirects)\n if (!this.jwtToken && typeof sessionStorage !== 'undefined') {\n this.jwtToken = sessionStorage.getItem(JWT_STORAGE_KEY);\n if (this.jwtToken) {\n this.logger.log('JWT token retrieved from storage');\n }\n }\n\n // Still no token? Error out\n if (!this.jwtToken) {\n throw new SDKError(\n 'No jwt token found in URL or storage',\n 'MISSING_TOKEN'\n );\n }\n\n // Store JWT for persistence through navigation\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.setItem(JWT_STORAGE_KEY, this.jwtToken);\n this.logger.log('JWT token stored in sessionStorage');\n }\n\n this.logger.log('JWT token extracted from URL');\n\n // Validate JWT\n let verifiedClaims;\n if (this.config.useBackendValidation) {\n // Phase 2: Backend validation\n this.logger.log('Using backend validation');\n verifiedClaims = await this.validateWithBackend(this.jwtToken);\n } else {\n // Phase 1: JWKS validation\n this.logger.log('Using JWKS validation');\n verifiedClaims = await this.validator.verify(\n this.jwtToken,\n 'generalwisdom.com',\n this.config.applicationId || undefined\n );\n }\n\n this.logger.log('JWT verified successfully');\n\n // Map to SessionData\n this.sessionData = {\n sessionId: verifiedClaims.sessionId,\n applicationId: verifiedClaims.applicationId,\n userId: verifiedClaims.userId,\n orgId: verifiedClaims.orgId,\n startTime: verifiedClaims.startTime,\n durationMinutes: verifiedClaims.durationMinutes,\n iat: verifiedClaims.iat,\n exp: verifiedClaims.exp,\n iss: verifiedClaims.iss,\n sub: verifiedClaims.sub,\n };\n\n // Calculate remaining time\n const now = Math.floor(Date.now() / 1000);\n const remainingSeconds = Math.max(0, this.sessionData.exp - now);\n\n if (remainingSeconds <= 0) {\n throw new SDKError(\n 'Session has already expired',\n 'SESSION_EXPIRED'\n );\n }\n\n this.logger.log('Remaining time:', remainingSeconds, 'seconds');\n\n // Call onSessionStart hook if provided (STRICT - failure prevents session start)\n if (this.config.hooks?.onSessionStart) {\n const startContext: SessionStartContext = {\n sessionId: this.sessionData.sessionId,\n userId: this.sessionData.userId,\n email: (verifiedClaims as any).email, // May not be in all JWTs\n orgId: this.sessionData.orgId,\n applicationId: this.sessionData.applicationId,\n durationMinutes: this.sessionData.durationMinutes,\n expiresAt: this.sessionData.exp,\n jwt: this.jwtToken!,\n };\n\n await this.executeHook('onSessionStart', this.config.hooks.onSessionStart, startContext, true);\n this.logger.log('Application auth synchronized with marketplace session');\n }\n\n // Initialize timer\n this.timer = new TimerManager(\n remainingSeconds,\n this.config.warningThresholdSeconds,\n {\n onSessionWarning: (data) => {\n // Call warning hook if provided (lenient)\n if (this.config.hooks?.onSessionWarning) {\n const warningContext: SessionWarningContext = {\n sessionId: this.sessionData!.sessionId,\n userId: this.sessionData!.userId,\n remainingSeconds: data.remainingSeconds,\n };\n this.executeHook('onSessionWarning', this.config.hooks.onSessionWarning, warningContext, false)\n .catch(error => this.logger.error('onSessionWarning hook failed:', error));\n }\n\n this.showWarningModal(data.remainingSeconds);\n this.events.onSessionWarning?.(data);\n },\n onSessionEnd: () => {\n this.endReason = 'expired'; // Track that this was an expiration\n this.endSession();\n },\n },\n this.config.debug\n );\n\n // Phase 2: Initialize heartbeat if enabled\n if (this.config.enableHeartbeat && this.jwtToken) {\n this.heartbeat = new HeartbeatManager(\n this.sessionData.sessionId,\n this.config.apiEndpoint,\n this.jwtToken,\n (remainingSeconds) => {\n // Sync timer with server\n this.timer?.updateRemainingTime(remainingSeconds);\n },\n (error) => {\n this.logger.error('Heartbeat error:', error);\n this.events.onError?.(error);\n },\n this.config.heartbeatIntervalSeconds,\n this.config.debug\n );\n }\n\n // Phase 2: Initialize tab sync if enabled\n if (this.config.enableTabSync) {\n this.tabSync = new TabSyncManager(\n this.sessionData.sessionId,\n (message) => this.handleTabSyncMessage(message),\n this.config.debug\n );\n }\n\n // Phase 2: Set up Visibility API if enabled\n if (this.config.pauseOnHidden) {\n this.initializeVisibilityHandling();\n }\n\n // Start timer if autoStart enabled\n if (this.config.autoStart) {\n this.timer.start();\n this.logger.log('Timer started automatically');\n\n // Start heartbeat only if this is the master tab\n if (this.config.enableHeartbeat && this.heartbeat) {\n const isMaster = !this.tabSync || this.tabSync.isMasterTab();\n if (isMaster) {\n this.heartbeat.start();\n this.logger.log('Heartbeat started (master tab)');\n } else {\n this.logger.log('Heartbeat not started (slave tab)');\n }\n }\n }\n\n // Trigger session start event\n this.events.onSessionStart?.(this.sessionData);\n\n this.logger.info('Session initialized successfully');\n return this.sessionData;\n\n } catch (error) {\n this.logger.error('Initialization failed:', error);\n const sdkError = error instanceof SDKError ? error : new SDKError(\n error instanceof Error ? error.message : 'Unknown error',\n 'INITIALIZATION_ERROR'\n );\n this.events.onError?.(sdkError);\n throw sdkError;\n }\n }\n\n /**\n * Phase 2: Validate JWT with backend\n */\n private async validateWithBackend(token: string): Promise<any> {\n const response = await fetch(\n `${this.config.apiEndpoint}/sessions/validate`,\n {\n method: 'POST',\n headers: {\n 'Authorization': `Bearer ${token}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ session_jwt: token }),\n }\n );\n\n if (!response.ok) {\n throw new SDKError(\n 'Backend validation failed',\n 'BACKEND_VALIDATION_FAILED',\n response.status\n );\n }\n\n const data = await response.json();\n if (!data.valid) {\n throw new SDKError(\n data.error || 'Session validation failed',\n 'SESSION_INVALID'\n );\n }\n\n // Return decoded claims from backend\n const decoded = JWTParser.decode(token);\n return decoded;\n }\n\n /**\n * Phase 2: Handle tab sync messages\n */\n private handleTabSyncMessage(message: TabSyncMessage): void {\n this.logger.log('Tab sync message:', message.type);\n\n switch (message.type) {\n case 'pause':\n this.timer?.pause();\n break;\n case 'resume':\n this.timer?.resume();\n break;\n case 'end':\n this.endSession();\n break;\n case 'timer_update':\n if (message.remainingSeconds !== undefined) {\n this.timer?.updateRemainingTime(message.remainingSeconds);\n }\n break;\n }\n }\n\n /**\n * Phase 2: Initialize Visibility API handling\n */\n private initializeVisibilityHandling(): void {\n document.addEventListener('visibilitychange', () => {\n if (document.hidden) {\n this.logger.log('Tab hidden, pausing timer');\n this.pauseTimer();\n } else {\n this.logger.log('Tab visible, resuming timer');\n this.resumeTimer();\n }\n });\n this.logger.log('Visibility API handler initialized');\n }\n\n /**\n * Start session timer manually\n */\n startTimer(): void {\n if (!this.timer) {\n throw new SDKError(\n 'SDK not initialized. Call initialize() first.',\n 'NOT_INITIALIZED'\n );\n }\n this.timer.start();\n this.tabSync?.broadcast('resume');\n this.logger.info('Timer started manually');\n }\n\n /**\n * Pause session timer\n */\n pauseTimer(): void {\n this.timer?.pause();\n this.tabSync?.broadcast('pause');\n this.logger.info('Timer paused');\n }\n\n /**\n * Resume session timer\n */\n resumeTimer(): void {\n this.timer?.resume();\n this.tabSync?.broadcast('resume');\n this.logger.info('Timer resumed');\n }\n\n /**\n * Phase 2: Extend session\n */\n async extendSession(additionalMinutes: number): Promise<void> {\n if (!this.sessionData || !this.jwtToken) {\n throw new SDKError('No active session', 'NO_SESSION');\n }\n\n this.logger.info('Extending session by', additionalMinutes, 'minutes');\n\n try {\n const response = await fetch(\n `${this.config.apiEndpoint}/sessions/${this.sessionData.sessionId}/renew`,\n {\n method: 'PUT',\n headers: {\n 'Authorization': `Bearer ${this.jwtToken}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n additional_minutes: additionalMinutes,\n }),\n }\n );\n\n if (!response.ok) {\n throw new SDKError(\n 'Session extension failed',\n 'EXTENSION_FAILED',\n response.status\n );\n }\n\n const data = await response.json();\n\n // Update session data\n this.sessionData.exp = data.new_expires_at;\n\n // Update timer\n const now = Math.floor(Date.now() / 1000);\n const remainingSeconds = data.new_expires_at - now;\n this.timer?.updateRemainingTime(remainingSeconds);\n\n // Broadcast to other tabs\n this.tabSync?.broadcast('timer_update', { remainingSeconds });\n\n // Call onSessionExtend hook if provided\n if (this.config.hooks?.onSessionExtend) {\n const extendContext: SessionExtendContext = {\n sessionId: this.sessionData.sessionId,\n userId: this.sessionData.userId,\n additionalMinutes,\n newExpiresAt: data.new_expires_at,\n };\n\n await this.executeHook('onSessionExtend', this.config.hooks.onSessionExtend, extendContext, false);\n }\n\n this.logger.info('Session extended successfully');\n\n } catch (error) {\n this.logger.error('Failed to extend session:', error);\n const sdkError = error instanceof SDKError ? error : new SDKError(\n error instanceof Error ? error.message : 'Extension failed',\n 'EXTENSION_ERROR'\n );\n this.events.onError?.(sdkError);\n throw sdkError;\n }\n }\n\n /**\n * Phase 2: Complete session\n */\n async completeSession(actualUsageMinutes?: number): Promise<void> {\n if (!this.sessionData || !this.jwtToken) {\n throw new SDKError('No active session', 'NO_SESSION');\n }\n\n this.logger.info('Completing session...');\n\n try {\n const response = await fetch(\n `${this.config.apiEndpoint}/sessions/${this.sessionData.sessionId}/complete`,\n {\n method: 'POST',\n headers: {\n 'Authorization': `Bearer ${this.jwtToken}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n actual_usage_minutes: actualUsageMinutes,\n metadata: {},\n }),\n }\n );\n\n if (!response.ok) {\n throw new SDKError(\n 'Session completion failed',\n 'COMPLETION_FAILED',\n response.status\n );\n }\n\n const data = await response.json();\n this.logger.info('Session completed:', data);\n\n // End the session\n this.endSession();\n\n } catch (error) {\n this.logger.error('Failed to complete session:', error);\n const sdkError = error instanceof SDKError ? error : new SDKError(\n error instanceof Error ? error.message : 'Completion failed',\n 'COMPLETION_ERROR'\n );\n this.events.onError?.(sdkError);\n throw sdkError;\n }\n }\n\n /**\n * End session\n */\n async endSession(): Promise<void> {\n this.logger.info('Ending session...');\n\n // Build session end context\n const endContext: SessionEndContext = {\n sessionId: this.sessionData?.sessionId || '',\n userId: this.sessionData?.userId || '',\n reason: this.endReason,\n actualDurationMinutes: this.calculateActualDuration(),\n };\n\n // Call onSessionEnd hook if provided (LENIENT - errors logged but don't block)\n if (this.config.hooks?.onSessionEnd) {\n try {\n await this.executeHook('onSessionEnd', this.config.hooks.onSessionEnd, endContext, false);\n this.logger.log('Application auth cleanup completed');\n } catch (error) {\n // This shouldn't throw due to lenient mode, but catch anyway\n this.logger.error('onSessionEnd hook error (continuing anyway):', error);\n }\n }\n\n // Stop timer\n this.timer?.stop();\n\n // Stop heartbeat\n this.heartbeat?.stop();\n\n // Broadcast to other tabs\n this.tabSync?.broadcast('end');\n\n // Clear JWT from storage\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.removeItem('gw_marketplace_jwt');\n this.logger.log('JWT token cleared from storage');\n }\n\n // Trigger end event\n this.events.onSessionEnd?.();\n\n this.logger.info('Session ended');\n\n // Show \"Session Ending\" modal, then redirect after 3 seconds\n if (typeof window !== 'undefined') {\n // Create modal if it doesn't exist\n if (!this.modal) {\n this.modal = new WarningModal(\n this.config.themeMode || 'light',\n this.config.customStyles\n );\n }\n\n // Show ending message with redirect callback\n this.modal.showEndingMessage(() => {\n window.location.href = this.config.marketplaceUrl;\n }, 3000); // 3 second delay\n }\n }\n\n /**\n * Show warning modal\n */\n private showWarningModal(remainingSeconds: number): void {\n if (!this.modal) {\n this.modal = new WarningModal(\n this.config.themeMode || 'light',\n this.config.customStyles\n );\n }\n\n this.modal.show({\n remainingSeconds,\n onExtend: async () => {\n // Try to extend session via API\n try {\n await this.extendSession(15); // Extend by 15 minutes\n this.modal?.hide();\n this.logger.log('Session extended successfully from modal');\n } catch (error) {\n // If extension fails (likely insufficient tokens), show ending modal then redirect to marketplace\n this.logger.error('Extension failed, redirecting to marketplace:', error);\n const marketplaceUrl = `${this.config.marketplaceUrl}extend-session?sessionId=${this.sessionData?.sessionId}`;\n\n // Show ending modal before redirect\n if (typeof window !== 'undefined') {\n if (!this.modal) {\n this.modal = new WarningModal(\n this.config.themeMode || 'light',\n this.config.customStyles\n );\n }\n this.modal.showEndingMessage(() => {\n window.location.href = marketplaceUrl;\n }, 3000);\n }\n }\n },\n onEnd: () => {\n // endSession() handles cleanup and redirect\n this.endSession();\n },\n });\n }\n\n /**\n * Get current session data\n */\n getSessionData(): SessionData | null {\n return this.sessionData;\n }\n\n /**\n * Get remaining time\n */\n getRemainingTime(): number {\n return this.timer?.getRemainingSeconds() ?? 0;\n }\n\n /**\n * Get formatted time (MM:SS)\n */\n getFormattedTime(): string {\n return this.timer?.getFormattedTime() ?? '0:00';\n }\n\n /**\n * Get formatted time with hours (HH:MM:SS)\n */\n getFormattedTimeWithHours(): string {\n return this.timer?.getFormattedTimeWithHours() ?? '0:00:00';\n }\n\n /**\n * Check if timer is running\n */\n isTimerRunning(): boolean {\n return this.timer?.isRunning() ?? false;\n }\n\n /**\n * Cleanup and destroy SDK instance\n */\n destroy(): void {\n this.logger.info('Destroying SDK instance...');\n this.timer?.stop();\n this.heartbeat?.stop();\n this.tabSync?.destroy();\n this.modal?.hide();\n\n // Clear JWT from storage\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.removeItem('gw_marketplace_jwt');\n this.logger.log('JWT token cleared from storage');\n }\n\n this.sessionData = null;\n this.jwtToken = null;\n }\n}\n","import { ThemeMode } from '../types';\nimport { getTheme, Theme } from '../styles/theme';\n\n/**\n * Session Header Component\n * Compact header widget showing session timer with extend/end controls\n */\nexport class SessionHeader {\n private container: HTMLDivElement | null = null;\n private theme: Theme;\n private updateInterval: number | null = null;\n private timeDisplay: HTMLElement | null = null;\n private getTimeCallback: (() => string) | undefined;\n private onExtendCallback: (() => void) | undefined;\n private onEndCallback: (() => void) | undefined;\n private mounted: boolean = false;\n\n constructor(themeMode: ThemeMode = 'auto') {\n const prefersDark = themeMode === 'dark' || (themeMode === 'auto' && this.detectDarkMode());\n this.theme = getTheme(prefersDark);\n }\n\n private detectDarkMode(): boolean {\n if (typeof window !== 'undefined' && window.matchMedia) {\n return window.matchMedia('(prefers-color-scheme: dark)').matches;\n }\n return false;\n }\n\n /**\n * Mount the session header to a DOM element\n * @param targetElement - Element to mount to (or selector string)\n * @param options - Configuration options\n */\n mount(\n targetElement: HTMLElement | string,\n options: {\n getTime: () => string;\n onExtend?: () => void;\n onEnd?: () => void;\n position?: 'left' | 'center' | 'right';\n }\n ): void {\n // Unmount if already mounted\n if (this.mounted) {\n this.unmount();\n }\n\n // Get target element\n const target =\n typeof targetElement === 'string'\n ? document.querySelector<HTMLElement>(targetElement)\n : targetElement;\n\n if (!target) {\n console.error('[SessionHeader] Mount target not found');\n return;\n }\n\n this.getTimeCallback = options.getTime;\n this.onExtendCallback = options.onExtend;\n this.onEndCallback = options.onEnd;\n\n // Create container\n this.container = document.createElement('div');\n this.container.id = 'gw-session-header';\n\n const position = options.position || 'right';\n const justifyContent =\n position === 'left' ? 'flex-start' :\n position === 'center' ? 'center' :\n 'flex-end';\n\n this.container.style.cssText = `\n display: flex;\n align-items: center;\n justify-content: ${justifyContent};\n gap: ${this.theme.spacing.gap.md};\n padding: ${this.theme.spacing.padding.sm} ${this.theme.spacing.padding.md};\n background-color: ${this.theme.colors.card};\n border: 1px solid ${this.theme.colors.border};\n border-radius: ${this.theme.spacing.borderRadius.md};\n font-family: ${this.theme.typography.fontFamily};\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);\n `;\n\n // Create timer display\n const timerWrapper = document.createElement('div');\n timerWrapper.style.cssText = `\n display: flex;\n align-items: center;\n gap: ${this.theme.spacing.gap.sm};\n color: ${this.theme.colors.foreground};\n font-size: ${this.theme.typography.fontSize.sm};\n font-weight: ${this.theme.typography.fontWeight.medium};\n `;\n\n const clockIcon = document.createElement('span');\n clockIcon.textContent = '⏱️';\n clockIcon.style.fontSize = this.theme.typography.fontSize.base;\n\n this.timeDisplay = document.createElement('span');\n this.timeDisplay.id = 'gw-session-time';\n this.timeDisplay.textContent = this.getTimeCallback?.() || '--:--';\n this.timeDisplay.style.cssText = `\n font-variant-numeric: tabular-nums;\n min-width: 50px;\n text-align: center;\n `;\n\n timerWrapper.appendChild(clockIcon);\n timerWrapper.appendChild(this.timeDisplay);\n this.container.appendChild(timerWrapper);\n\n // Create button container\n const buttonContainer = document.createElement('div');\n buttonContainer.style.cssText = `\n display: flex;\n gap: ${this.theme.spacing.gap.sm};\n `;\n\n // Extend button (if callback provided)\n if (this.onExtendCallback) {\n const extendBtn = document.createElement('button');\n extendBtn.textContent = 'Extend';\n extendBtn.style.cssText = `\n padding: ${this.theme.spacing.padding.sm};\n background-color: ${this.theme.colors.success};\n color: ${this.theme.colors.successForeground};\n border: none;\n border-radius: ${this.theme.spacing.borderRadius.sm};\n font-size: ${this.theme.typography.fontSize.sm};\n font-weight: ${this.theme.typography.fontWeight.medium};\n font-family: ${this.theme.typography.fontFamily};\n cursor: pointer;\n transition: opacity 0.2s;\n `;\n extendBtn.addEventListener('mouseenter', () => {\n extendBtn.style.opacity = '0.9';\n });\n extendBtn.addEventListener('mouseleave', () => {\n extendBtn.style.opacity = '1';\n });\n extendBtn.addEventListener('click', () => {\n this.onExtendCallback?.();\n });\n buttonContainer.appendChild(extendBtn);\n }\n\n // End button (if callback provided)\n if (this.onEndCallback) {\n const endBtn = document.createElement('button');\n endBtn.textContent = 'End';\n endBtn.style.cssText = `\n padding: ${this.theme.spacing.padding.sm};\n background-color: ${this.theme.colors.secondary};\n color: ${this.theme.colors.secondaryForeground};\n border: 1px solid ${this.theme.colors.border};\n border-radius: ${this.theme.spacing.borderRadius.sm};\n font-size: ${this.theme.typography.fontSize.sm};\n font-weight: ${this.theme.typography.fontWeight.medium};\n font-family: ${this.theme.typography.fontFamily};\n cursor: pointer;\n transition: opacity 0.2s;\n `;\n endBtn.addEventListener('mouseenter', () => {\n endBtn.style.opacity = '0.9';\n });\n endBtn.addEventListener('mouseleave', () => {\n endBtn.style.opacity = '1';\n });\n endBtn.addEventListener('click', () => {\n this.onEndCallback?.();\n });\n buttonContainer.appendChild(endBtn);\n }\n\n if (buttonContainer.children.length > 0) {\n this.container.appendChild(buttonContainer);\n }\n\n // Mount to target\n target.appendChild(this.container);\n this.mounted = true;\n\n // Start updating time display\n this.startUpdating();\n }\n\n /**\n * Start updating the time display\n */\n private startUpdating(): void {\n if (this.updateInterval) {\n clearInterval(this.updateInterval);\n }\n\n this.updateInterval = window.setInterval(() => {\n if (this.timeDisplay && this.getTimeCallback) {\n const newTime = this.getTimeCallback();\n this.timeDisplay.textContent = newTime;\n\n // Change color if warning state (< 5 minutes = MM:SS where MM < 05)\n const [minutes] = newTime.split(':').map(Number);\n if (!isNaN(minutes) && minutes < 5) {\n this.timeDisplay.style.color = this.theme.colors.destructive;\n this.timeDisplay.style.fontWeight = this.theme.typography.fontWeight.bold;\n } else {\n this.timeDisplay.style.color = this.theme.colors.foreground;\n this.timeDisplay.style.fontWeight = this.theme.typography.fontWeight.medium;\n }\n }\n }, 1000);\n }\n\n /**\n * Unmount and cleanup the session header\n */\n unmount(): void {\n if (this.updateInterval) {\n clearInterval(this.updateInterval);\n this.updateInterval = null;\n }\n\n if (this.container && this.container.parentNode) {\n this.container.parentNode.removeChild(this.container);\n }\n\n this.container = null;\n this.timeDisplay = null;\n this.mounted = false;\n }\n\n /**\n * Check if component is mounted\n */\n isMounted(): boolean {\n return this.mounted;\n }\n\n /**\n * Update the theme\n */\n updateTheme(themeMode: ThemeMode): void {\n const prefersDark = themeMode === 'dark' || (themeMode === 'auto' && this.detectDarkMode());\n this.theme = getTheme(prefersDark);\n\n // Re-mount with new theme if currently mounted\n if (this.mounted && this.container && this.container.parentElement) {\n const parent = this.container.parentElement;\n const options = {\n getTime: this.getTimeCallback!,\n onExtend: this.onExtendCallback,\n onEnd: this.onEndCallback,\n };\n this.unmount();\n this.mount(parent, options);\n }\n }\n}\n"],"names":["SDKError","Error","constructor","message","code","statusCode","super","this","name","captureStackTrace","JWTParser","decode","token","parts","split","length","payload","decoded","base64UrlDecode","JSON","parse","error","decodeHeader","header","extractClaim","claim","isExpired","exp","Date","now","getTimeRemaining","remaining","Math","floor","max","str","base64","replace","padding","repeat","Buffer","from","toString","atob","encoder","TextEncoder","decoder","TextDecoder","input","Uint8Array","fromBase64","alphabet","encoded","binary","bytes","i","charCodeAt","decodeBase64","TypeError","JOSEError","options","__publicField","JWTClaimValidationFailed","reason","cause","JWTExpired","JOSEAlgNotAllowed","arguments","JOSENotSupported","JWSInvalid","JWTInvalid","JWKSInvalid","JWKSNoMatchingKey","JWKSMultipleMatchingKeys","_b","_a","Symbol","asyncIterator","JWKSTimeout","JWSSignatureVerificationFailed","unusable","prop","isAlgorithm","algorithm","getHashLength","hash","parseInt","slice","checkSigCryptoKey","key","alg","usage","expected","getNamedCurve","namedCurve","usages","includes","checkUsage","msg","actual","types","filter","Boolean","last","pop","join","withAlg","isCryptoKey","toStringTag","isKeyObject","isKeyLike","isObject","value","Object","prototype","call","getPrototypeOf","proto","importJWK$1","async","jwk","keyUsages","kty","priv","d","crv","subtleMapping","keyData","use","crypto","subtle","importKey","ext","key_ops","isJWK","cache","handleJWK","freeze","WeakMap","cached","get","cryptoKey","importJWK","set","normalizeKey","type","export","toCryptoKey","keyObject","isPublic","extractable","asymmetricKeyType","toUpperCase","startsWith","Map","asymmetricKeyDetails","handleKeyObject","err","format","k","tag","jwkMatchesOp","Array","isArray","expectedKeyOp","test","endsWith","checkKeyType","jwk.isJWK","jwk.isSecretJWK","invalidKeyInput","symmetricTypeCheck","jwk.isPrivateJWK","jwk.isPublicJWK","asymmetricTypeCheck","getSignKey","verify","signature","data","getVerifyKey","modulusLength","checkKeyLength","saltLength","subtleAlgorithm","flattenedVerify","jws","protected","parsedProt","protectedHeader","b64u","headers","sources","acc","parameters","keys","size","parameter","has","add","Set","isDisjoint","joseHeader","extensions","Err","recognizedDefault","recognizedOption","crit","some","recognized","entries","validateCrit","b64","algorithms","option","s","validateAlgorithms","resolvedKey","buffers","reduce","buf","buffer","concat","encode","result","unprotectedHeader","day","hour","REGEX","secs","matched","exec","parseFloat","numericDate","toLowerCase","round","minute","normalizeTyp","validateClaimsSet","encodedPayload","typ","requiredClaims","issuer","subject","audience","maxTokenAge","presenceCheck","push","reverse","iss","sub","audPayload","aud","audOption","bind","tolerance","clockTolerance","currentDate","date","getTime","iat","nbf","age","jwtVerify","jwt","verified","compactVerify","isJWKLike","LocalJWKSet","jwks","__privateAdd","_jwks","_cached","every","isJWKSLike","__privateSet","structuredClone","__privateGet","getKey","kid","getKtyFromAlg","candidates","candidate","importWithAlgCache","decodeBase64URL","oth","createLocalJWKSet","localJWKSet","defineProperties","enumerable","configurable","writable","USER_AGENT","navigator","userAgent","customFetch","jwksCache","RemoteJWKSet","url","_url","_timeoutDuration","_cooldownDuration","_cacheMaxAge","_jwksTimestamp","_pendingFetch","_headers","_customFetch","_local","_cache","URL","cacheMaxAge","href","timeoutDuration","cooldownDuration","Headers","append","uat","pendingFetch","coolingDown","fresh","reload","WebSocketPair","EdgeRuntime","signal","fetchImpl","fetch","response","method","redirect","catch","status","json","fetchJwks","AbortSignal","timeout","then","createRemoteJWKSet","remoteJWKSet","reloading","Logger","debug","prefix","log","args","info","warn","JWKSValidator","jwksUri","logger","expectedIssuer","expectedApplicationId","applicationId","claims","sessionId","userId","orgId","startTime","durationMinutes","errorMessage","errorName","updateJwksUri","TimerManager","durationSeconds","warningThresholdSeconds","events","intervalId","warningShown","remainingSeconds","warningThreshold","start","window","setInterval","onSessionWarning","stop","onSessionEnd","clearInterval","pause","resume","getRemainingSeconds","getFormattedTime","padStart","getFormattedTimeWithHours","hours","minutes","seconds","isRunning","hasWarningBeenShown","updateRemainingTime","HeartbeatManager","apiEndpoint","onSync","onError","heartbeatIntervalSeconds","failureCount","maxFailures","isEnabled","heartbeatInterval","sendHeartbeat","Authorization","body","stringify","timestamp","active","ok","remaining_seconds","sdkError","getFailureCount","updateInterval","wasRunning","TabSyncManager","onMessage","channel","isMaster","handleStorageEvent","event","storageKey","newValue","handleMessage","initialize","BroadcastChannel","onmessage","addEventListener","electMaster","broadcast","postMessage","localStorage","setItem","masterKey","getItem","masterTimestamp","removeItem","isMasterTab","destroy","close","removeEventListener","lightTheme","colors","background","foreground","card","cardForeground","popover","popoverForeground","primary","primaryForeground","secondary","secondaryForeground","muted","mutedForeground","accent","accentForeground","destructive","destructiveForeground","success","successForeground","border","ring","typography","fontFamily","fontSize","xs","sm","base","lg","xl","fontWeight","normal","medium","semibold","bold","lineHeight","tight","relaxed","spacing","borderRadius","md","gap","darkTheme","getTheme","prefersDark","matchMedia","matches","WarningModal","themeMode","customStyles","modal","legacyStyles","timeDisplay","initialSeconds","onEndCallback","detectDarkMode","theme","backgroundColor","textColor","primaryColor","show","hide","document","createElement","id","style","cssText","content","bgColor","onEnd","innerHTML","onExtend","appendChild","extendBtn","getElementById","dismissBtn","endBtn","querySelectorAll","forEach","button","opacity","outline","outlineOffset","elapsed","textContent","parentNode","removeChild","isShown","showEndingMessage","onComplete","durationMs","head","setTimeout","extractTokenFromURL","paramName","targetUrl","location","urlObj","searchParams","MarketplaceSDK","config","timer","heartbeat","tabSync","sessionData","jwtToken","endReason","autoStart","marketplaceUrl","enableHeartbeat","enableTabSync","pauseOnHidden","useBackendValidation","hooks","hookTimeoutMs","validator","on","handler","executeHook","hookName","hook","context","isStrict","Promise","_","reject","race","resolve","calculateActualDuration","ceil","JWT_STORAGE_KEY","sessionStorage","verifiedClaims","validateWithBackend","onSessionStart","startContext","email","expiresAt","warningContext","showWarningModal","endSession","handleTabSyncMessage","initializeVisibilityHandling","session_jwt","valid","hidden","pauseTimer","resumeTimer","startTimer","extendSession","additionalMinutes","additional_minutes","new_expires_at","onSessionExtend","extendContext","newExpiresAt","completeSession","actualUsageMinutes","actual_usage_minutes","metadata","endContext","actualDurationMinutes","getSessionData","getRemainingTime","isTimerRunning","container","mounted","mount","targetElement","unmount","target","querySelector","getTimeCallback","onExtendCallback","position","justifyContent","timerWrapper","clockIcon","buttonContainer","children","startUpdating","newTime","map","Number","isNaN","color","isMounted","updateTheme","parentElement","parent","trim"],"mappings":"0uBA2LO,MAAMA,UAAiBC,MAC5B,WAAAC,CACEC,EACOC,EACAC,GAEPC,MAAMH,GAHCI,KAAAH,KAAAA,EACAG,KAAAF,WAAAA,EAGPE,KAAKC,KAAO,WAGRP,MAAMQ,mBACRR,MAAMQ,kBAAkBF,KAAMP,EAElC,EClMK,MAAMU,EAMX,aAAOC,CAAOC,GACZ,IAAKA,GAA0B,iBAAVA,EACnB,MAAM,IAAIZ,EAAS,2BAA4B,iBAGjD,MAAMa,EAAQD,EAAME,MAAM,KAC1B,GAAqB,IAAjBD,EAAME,OACR,MAAM,IAAIf,EAAS,yCAA0C,mBAG/D,IACE,MAAMgB,EAAUH,EAAM,GAChBI,EAAUV,KAAKW,gBAAgBF,GACrC,OAAOG,KAAKC,MAAMH,EACpB,OAASI,GACP,MAAM,IAAIrB,EACR,iCAAiCqB,aAAiBpB,MAAQoB,EAAMlB,QAAU,kBAC1E,eAEJ,CACF,CAOA,mBAAOmB,CAAaV,GAClB,IAAKA,GAA0B,iBAAVA,EACnB,MAAM,IAAIZ,EAAS,2BAA4B,iBAGjD,MAAMa,EAAQD,EAAME,MAAM,KAC1B,GAAqB,IAAjBD,EAAME,OACR,MAAM,IAAIf,EAAS,yCAA0C,mBAG/D,IACE,MAAMuB,EAASV,EAAM,GACfI,EAAUV,KAAKW,gBAAgBK,GACrC,OAAOJ,KAAKC,MAAMH,EACpB,OAASI,GACP,MAAM,IAAIrB,EACR,gCAAgCqB,aAAiBpB,MAAQoB,EAAMlB,QAAU,kBACzE,eAEJ,CACF,CAQA,mBAAOqB,CAAsBZ,EAAea,GAE1C,OADgBlB,KAAKI,OAAOC,GACJa,EAC1B,CAOA,gBAAOC,CAAUd,GACf,MACMe,EADUpB,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B,GACE,OAAOrmB,KAAKilB,OACd,CAKA,WAAAqB,CAAY3I,GACV,MAAMJ,EAA4B,SAAdI,GAAuC,SAAdA,GAAwB3d,KAAKke,iBAI1E,GAHAle,KAAKme,MAAQb,GAASC,GAGlBvd,KAAKilB,SAAWjlB,KAAKglB,WAAahlB,KAAKglB,UAAUuB,cAAe,CAClE,MAAMC,EAASxmB,KAAKglB,UAAUuB,cACxBljB,EAAU,CACdsM,QAAS3P,KAAKulB,gBACdrG,SAAUlf,KAAKwlB,iBACfxG,MAAOhf,KAAKie,eAEdje,KAAKolB,UACLplB,KAAKklB,MAAMsB,EAAQnjB,EACrB,CACF,uIJoCK,SAA8B8a,GACnC,MAAO,0BACcA,EAAMvD,OAAOC,qCACbsD,EAAMvD,OAAOE,+BACnBqD,EAAMvD,OAAOG,oCACFoD,EAAMvD,OAAOI,sCACrBmD,EAAMvD,OAAOO,0CACFgD,EAAMvD,OAAOQ,2CACtB+C,EAAMvD,OAAOS,8CACF8C,EAAMvD,OAAOU,yCAC5B6C,EAAMvD,OAAOW,sCACF4C,EAAMvD,OAAOY,sCACvB2C,EAAMvD,OAAOa,wCACF0C,EAAMvD,OAAOc,4CACnByC,EAAMvD,OAAOe,kDACFwC,EAAMvD,OAAOgB,6CAC5BuC,EAAMvD,OAAOiB,0CACFsC,EAAMvD,OAAOkB,wCACzBqC,EAAMvD,OAAOmB,4BACdoC,EAAMvD,OAAOnY,0BACd0b,EAAMvD,OAAOoB,YAC1ByK,MACJ,4BE1RO,WACL,MAAyB,oBAAX/P,aAAqD,IAApBA,OAAO+H,QACxD","x_google_ignoreList":[2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29]}
|
|
1
|
+
{"version":3,"file":"marketplace-sdk.umd.js","sources":["../src/types/index.ts","../src/core/JWTParser.ts","../node_modules/jose/dist/webapi/lib/buffer_utils.js","../node_modules/jose/dist/webapi/util/base64url.js","../node_modules/jose/dist/webapi/lib/base64.js","../node_modules/jose/dist/webapi/util/errors.js","../node_modules/jose/dist/webapi/lib/crypto_key.js","../node_modules/jose/dist/webapi/lib/invalid_key_input.js","../node_modules/jose/dist/webapi/lib/is_key_like.js","../node_modules/jose/dist/webapi/lib/is_object.js","../node_modules/jose/dist/webapi/lib/jwk_to_key.js","../node_modules/jose/dist/webapi/lib/is_jwk.js","../node_modules/jose/dist/webapi/lib/normalize_key.js","../node_modules/jose/dist/webapi/lib/check_key_type.js","../node_modules/jose/dist/webapi/lib/get_sign_verify_key.js","../node_modules/jose/dist/webapi/lib/verify.js","../node_modules/jose/dist/webapi/lib/check_key_length.js","../node_modules/jose/dist/webapi/lib/subtle_dsa.js","../node_modules/jose/dist/webapi/jws/flattened/verify.js","../node_modules/jose/dist/webapi/lib/is_disjoint.js","../node_modules/jose/dist/webapi/lib/validate_crit.js","../node_modules/jose/dist/webapi/lib/validate_algorithms.js","../node_modules/jose/dist/webapi/lib/epoch.js","../node_modules/jose/dist/webapi/lib/secs.js","../node_modules/jose/dist/webapi/lib/jwt_claims_set.js","../node_modules/jose/dist/webapi/jwt/verify.js","../node_modules/jose/dist/webapi/jws/compact/verify.js","../node_modules/jose/dist/webapi/jwks/local.js","../node_modules/jose/dist/webapi/key/import.js","../node_modules/jose/dist/webapi/jwks/remote.js","../src/utils/logger.ts","../src/core/JWKSValidator.ts","../src/core/TimerManager.ts","../src/core/HeartbeatManager.ts","../src/core/TabSyncManager.ts","../src/styles/theme.ts","../src/ui/WarningModal.ts","../src/utils/url.ts","../src/core/MarketplaceSDK.ts","../src/ui/SessionHeader.ts"],"sourcesContent":["/**\n * SDK Configuration\n */\nexport interface SDKConfig {\n /** JWKS endpoint URL (default: https://api.generalwisdom.com/.well-known/jwks.json) */\n jwksUri?: string;\n /** URL query parameter name containing the JWT (default: 'gwSession') */\n jwtParamName?: string;\n /** API endpoint for backend integration (Phase 2) */\n apiEndpoint?: string;\n /** Enable debug logging */\n debug?: boolean;\n /** Auto-start timer after initialization */\n autoStart?: boolean;\n /** Warning threshold in seconds (default: 300 = 5 minutes) */\n warningThresholdSeconds?: number;\n /** Custom styling for warning modal (Legacy - prefer using themeMode) */\n customStyles?: Partial<ModalStyles>;\n /** Theme mode for modal styling (default: 'light') */\n themeMode?: ThemeMode;\n /** Application ID for validation */\n applicationId?: string;\n /** Marketplace URL for redirects (default: https://d3p2yqofgy75sz.cloudfront.net/) */\n marketplaceUrl?: string;\n\n // Phase 2 Features\n /** Enable heartbeat system (default: false) */\n enableHeartbeat?: boolean;\n /** Heartbeat interval in seconds (default: 30) */\n heartbeatIntervalSeconds?: number;\n /** Enable multi-tab synchronization (default: false) */\n enableTabSync?: boolean;\n /** Pause timer when tab is hidden (default: false) */\n pauseOnHidden?: boolean;\n /** Use backend validation instead of JWKS (default: false) */\n useBackendValidation?: boolean;\n\n // Lifecycle Hooks\n /** Optional hooks for synchronizing app auth state with marketplace sessions */\n hooks?: SessionLifecycleHooks;\n /** Hook execution timeout in milliseconds (default: 5000) */\n hookTimeoutMs?: number;\n}\n\n/**\n * Session Data extracted from JWT\n */\nexport interface SessionData {\n /** Unique session UUID */\n sessionId: string;\n /** Application ID */\n applicationId: string;\n /** User ID */\n userId: string;\n /** Organization ID */\n orgId: string;\n /** Session start time (Unix timestamp seconds) */\n startTime: number;\n /** Session duration in minutes */\n durationMinutes: number;\n /** Issued at timestamp (Unix seconds) */\n iat: number;\n /** Expiration timestamp (Unix seconds) */\n exp: number;\n /** Issuer */\n iss: string;\n /** Subject (user ID) */\n sub: string;\n}\n\n/**\n * Modal styling options (Legacy - prefer using theme)\n * @deprecated Use theme configuration from src/styles/theme.ts instead\n */\nexport interface ModalStyles {\n backgroundColor: string;\n textColor: string;\n primaryColor: string;\n borderRadius: string;\n fontFamily: string;\n}\n\n/**\n * Theme mode for modal styling\n */\nexport type ThemeMode = 'light' | 'dark' | 'auto';\n\n/**\n * SDK Event Handlers\n */\nexport interface SDKEvents {\n /** Called when session successfully initialized */\n onSessionStart: (data: SessionData) => void;\n /** Called when warning threshold reached */\n onSessionWarning: (data: { remainingSeconds: number }) => void;\n /** Called when session expires or is ended */\n onSessionEnd: () => void;\n /** Called on any error */\n onError: (error: Error) => void;\n}\n\n/**\n * Session Lifecycle Hook Contexts\n */\nexport interface SessionStartContext {\n /** Unique session UUID */\n sessionId: string;\n /** User ID from JWT */\n userId: string;\n /** User email (if available in JWT) */\n email?: string;\n /** Organization ID */\n orgId: string;\n /** Application ID */\n applicationId: string;\n /** Session duration in minutes */\n durationMinutes: number;\n /** Expiration timestamp (Unix seconds) */\n expiresAt: number;\n /** Full JWT token for app use */\n jwt: string;\n}\n\nexport interface SessionEndContext {\n /** Unique session UUID */\n sessionId: string;\n /** User ID */\n userId: string;\n /** Reason for session end */\n reason: 'expired' | 'manual' | 'error';\n /** Actual session duration in minutes (if available) */\n actualDurationMinutes?: number;\n}\n\nexport interface SessionExtendContext {\n /** Unique session UUID */\n sessionId: string;\n /** User ID */\n userId: string;\n /** Additional minutes added to session */\n additionalMinutes: number;\n /** New expiration timestamp (Unix seconds) */\n newExpiresAt: number;\n}\n\nexport interface SessionWarningContext {\n /** Unique session UUID */\n sessionId: string;\n /** User ID */\n userId: string;\n /** Remaining seconds until expiration */\n remainingSeconds: number;\n}\n\n/**\n * Session Lifecycle Hooks\n * Optional callbacks that allow applications to synchronize their auth state with marketplace sessions\n */\nexport interface SessionLifecycleHooks {\n /**\n * Called after JWT validation succeeds but before session timer starts\n * Use to: Auto-login user to your app's auth system\n * Note: Hook failure will prevent session from starting\n */\n onSessionStart?: (context: SessionStartContext) => Promise<void> | void;\n\n /**\n * Called when session expires or is manually ended, before redirect\n * Use to: Force logout user from your app's auth system\n * Note: Hook failure will be logged but won't prevent session end\n */\n onSessionEnd?: (context: SessionEndContext) => Promise<void> | void;\n\n /**\n * Called when session extension succeeds\n * Use to: Refresh app auth tokens if needed\n */\n onSessionExtend?: (context: SessionExtendContext) => Promise<void> | void;\n\n /**\n * Called before session warning modal is shown\n * Use to: Prepare user for session expiration\n */\n onSessionWarning?: (context: SessionWarningContext) => Promise<void> | void;\n}\n\n/**\n * Custom SDK Error\n */\nexport class SDKError extends Error {\n constructor(\n message: string,\n public code: string,\n public statusCode?: number\n ) {\n super(message);\n this.name = 'SDKError';\n\n // Maintains proper stack trace for where our error was thrown (only available on V8)\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, SDKError);\n }\n }\n}\n\n/**\n * JWT Header\n */\nexport interface JWTHeader {\n alg: string;\n typ: string;\n kid: string;\n}\n\n/**\n * JWT Claims (raw payload from token)\n */\nexport interface JWTClaims {\n sessionId: string;\n applicationId: string;\n userId: string;\n orgId: string;\n startTime: number;\n durationMinutes: number;\n iat: number;\n exp: number;\n iss: string;\n sub: string;\n}\n\n/**\n * JWKS Key\n */\nexport interface JWKSKey {\n kty: string;\n use: string;\n kid: string;\n alg: string;\n n: string;\n e: string;\n}\n\n/**\n * JWKS Response\n */\nexport interface JWKSResponse {\n keys: JWKSKey[];\n}\n","import { SDKError, JWTHeader, JWTClaims } from '../types';\n\n/**\n * JWT Parser for client-side token decoding\n * Note: Does NOT verify signature - use JWKSValidator for verification\n */\nexport class JWTParser {\n /**\n * Decode JWT payload without verification\n * @param token - JWT token string\n * @returns Decoded payload\n */\n static decode(token: string): JWTClaims {\n if (!token || typeof token !== 'string') {\n throw new SDKError('Invalid JWT token format', 'INVALID_TOKEN');\n }\n\n const parts = token.split('.');\n if (parts.length !== 3) {\n throw new SDKError('Malformed JWT token - expected 3 parts', 'MALFORMED_TOKEN');\n }\n\n try {\n const payload = parts[1];\n const decoded = this.base64UrlDecode(payload);\n return JSON.parse(decoded) as JWTClaims;\n } catch (error) {\n throw new SDKError(\n `Failed to decode JWT payload: ${error instanceof Error ? error.message : 'Unknown error'}`,\n 'DECODE_ERROR'\n );\n }\n }\n\n /**\n * Decode JWT header\n * @param token - JWT token string\n * @returns Decoded header\n */\n static decodeHeader(token: string): JWTHeader {\n if (!token || typeof token !== 'string') {\n throw new SDKError('Invalid JWT token format', 'INVALID_TOKEN');\n }\n\n const parts = token.split('.');\n if (parts.length !== 3) {\n throw new SDKError('Malformed JWT token - expected 3 parts', 'MALFORMED_TOKEN');\n }\n\n try {\n const header = parts[0];\n const decoded = this.base64UrlDecode(header);\n return JSON.parse(decoded) as JWTHeader;\n } catch (error) {\n throw new SDKError(\n `Failed to decode JWT header: ${error instanceof Error ? error.message : 'Unknown error'}`,\n 'DECODE_ERROR'\n );\n }\n }\n\n /**\n * Extract specific claim from JWT\n * @param token - JWT token string\n * @param claim - Claim name to extract\n * @returns Claim value\n */\n static extractClaim<T = any>(token: string, claim: string): T {\n const payload = this.decode(token);\n return (payload as any)[claim];\n }\n\n /**\n * Check if JWT is expired (client-side only, not authoritative)\n * @param token - JWT token string\n * @returns True if token is expired\n */\n static isExpired(token: string): boolean {\n const payload = this.decode(token);\n const exp = payload.exp;\n\n if (!exp) {\n return false;\n }\n\n // exp is in seconds, Date.now() is in milliseconds\n return Date.now() >= exp * 1000;\n }\n\n /**\n * Get time remaining until expiration\n * @param token - JWT token string\n * @returns Seconds remaining (0 if expired)\n */\n static getTimeRemaining(token: string): number {\n const payload = this.decode(token);\n const exp = payload.exp;\n\n if (!exp) {\n return 0;\n }\n\n const remaining = exp - Math.floor(Date.now() / 1000);\n return Math.max(0, remaining);\n }\n\n /**\n * Base64 URL decode\n * @param str - Base64 URL encoded string\n * @returns Decoded string\n */\n private static base64UrlDecode(str: string): string {\n // Replace URL-safe characters\n let base64 = str.replace(/-/g, '+').replace(/_/g, '/');\n\n // Add padding if needed\n const padding = base64.length % 4;\n if (padding) {\n base64 += '='.repeat(4 - padding);\n }\n\n try {\n // Use Buffer in Node.js, atob in browser\n if (typeof Buffer !== 'undefined') {\n return Buffer.from(base64, 'base64').toString('utf-8');\n } else if (typeof atob !== 'undefined') {\n return atob(base64);\n } else {\n throw new Error('No base64 decoding available');\n }\n } catch (error) {\n throw new SDKError(\n 'Invalid base64 encoding',\n 'ENCODING_ERROR'\n );\n }\n }\n}\n","export const encoder = new TextEncoder();\nexport const decoder = new TextDecoder();\nconst MAX_INT32 = 2 ** 32;\nexport function concat(...buffers) {\n const size = buffers.reduce((acc, { length }) => acc + length, 0);\n const buf = new Uint8Array(size);\n let i = 0;\n for (const buffer of buffers) {\n buf.set(buffer, i);\n i += buffer.length;\n }\n return buf;\n}\nfunction writeUInt32BE(buf, value, offset) {\n if (value < 0 || value >= MAX_INT32) {\n throw new RangeError(`value must be >= 0 and <= ${MAX_INT32 - 1}. Received ${value}`);\n }\n buf.set([value >>> 24, value >>> 16, value >>> 8, value & 0xff], offset);\n}\nexport function uint64be(value) {\n const high = Math.floor(value / MAX_INT32);\n const low = value % MAX_INT32;\n const buf = new Uint8Array(8);\n writeUInt32BE(buf, high, 0);\n writeUInt32BE(buf, low, 4);\n return buf;\n}\nexport function uint32be(value) {\n const buf = new Uint8Array(4);\n writeUInt32BE(buf, value);\n return buf;\n}\n","import { encoder, decoder } from '../lib/buffer_utils.js';\nimport { encodeBase64, decodeBase64 } from '../lib/base64.js';\nexport function decode(input) {\n if (Uint8Array.fromBase64) {\n return Uint8Array.fromBase64(typeof input === 'string' ? input : decoder.decode(input), {\n alphabet: 'base64url',\n });\n }\n let encoded = input;\n if (encoded instanceof Uint8Array) {\n encoded = decoder.decode(encoded);\n }\n encoded = encoded.replace(/-/g, '+').replace(/_/g, '/').replace(/\\s/g, '');\n try {\n return decodeBase64(encoded);\n }\n catch {\n throw new TypeError('The input to be decoded is not correctly encoded.');\n }\n}\nexport function encode(input) {\n let unencoded = input;\n if (typeof unencoded === 'string') {\n unencoded = encoder.encode(unencoded);\n }\n if (Uint8Array.prototype.toBase64) {\n return unencoded.toBase64({ alphabet: 'base64url', omitPadding: true });\n }\n return encodeBase64(unencoded).replace(/=/g, '').replace(/\\+/g, '-').replace(/\\//g, '_');\n}\n","export function encodeBase64(input) {\n if (Uint8Array.prototype.toBase64) {\n return input.toBase64();\n }\n const CHUNK_SIZE = 0x8000;\n const arr = [];\n for (let i = 0; i < input.length; i += CHUNK_SIZE) {\n arr.push(String.fromCharCode.apply(null, input.subarray(i, i + CHUNK_SIZE)));\n }\n return btoa(arr.join(''));\n}\nexport function decodeBase64(encoded) {\n if (Uint8Array.fromBase64) {\n return Uint8Array.fromBase64(encoded);\n }\n const binary = atob(encoded);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) {\n bytes[i] = binary.charCodeAt(i);\n }\n return bytes;\n}\n","export class JOSEError extends Error {\n static code = 'ERR_JOSE_GENERIC';\n code = 'ERR_JOSE_GENERIC';\n constructor(message, options) {\n super(message, options);\n this.name = this.constructor.name;\n Error.captureStackTrace?.(this, this.constructor);\n }\n}\nexport class JWTClaimValidationFailed extends JOSEError {\n static code = 'ERR_JWT_CLAIM_VALIDATION_FAILED';\n code = 'ERR_JWT_CLAIM_VALIDATION_FAILED';\n claim;\n reason;\n payload;\n constructor(message, payload, claim = 'unspecified', reason = 'unspecified') {\n super(message, { cause: { claim, reason, payload } });\n this.claim = claim;\n this.reason = reason;\n this.payload = payload;\n }\n}\nexport class JWTExpired extends JOSEError {\n static code = 'ERR_JWT_EXPIRED';\n code = 'ERR_JWT_EXPIRED';\n claim;\n reason;\n payload;\n constructor(message, payload, claim = 'unspecified', reason = 'unspecified') {\n super(message, { cause: { claim, reason, payload } });\n this.claim = claim;\n this.reason = reason;\n this.payload = payload;\n }\n}\nexport class JOSEAlgNotAllowed extends JOSEError {\n static code = 'ERR_JOSE_ALG_NOT_ALLOWED';\n code = 'ERR_JOSE_ALG_NOT_ALLOWED';\n}\nexport class JOSENotSupported extends JOSEError {\n static code = 'ERR_JOSE_NOT_SUPPORTED';\n code = 'ERR_JOSE_NOT_SUPPORTED';\n}\nexport class JWEDecryptionFailed extends JOSEError {\n static code = 'ERR_JWE_DECRYPTION_FAILED';\n code = 'ERR_JWE_DECRYPTION_FAILED';\n constructor(message = 'decryption operation failed', options) {\n super(message, options);\n }\n}\nexport class JWEInvalid extends JOSEError {\n static code = 'ERR_JWE_INVALID';\n code = 'ERR_JWE_INVALID';\n}\nexport class JWSInvalid extends JOSEError {\n static code = 'ERR_JWS_INVALID';\n code = 'ERR_JWS_INVALID';\n}\nexport class JWTInvalid extends JOSEError {\n static code = 'ERR_JWT_INVALID';\n code = 'ERR_JWT_INVALID';\n}\nexport class JWKInvalid extends JOSEError {\n static code = 'ERR_JWK_INVALID';\n code = 'ERR_JWK_INVALID';\n}\nexport class JWKSInvalid extends JOSEError {\n static code = 'ERR_JWKS_INVALID';\n code = 'ERR_JWKS_INVALID';\n}\nexport class JWKSNoMatchingKey extends JOSEError {\n static code = 'ERR_JWKS_NO_MATCHING_KEY';\n code = 'ERR_JWKS_NO_MATCHING_KEY';\n constructor(message = 'no applicable key found in the JSON Web Key Set', options) {\n super(message, options);\n }\n}\nexport class JWKSMultipleMatchingKeys extends JOSEError {\n [Symbol.asyncIterator];\n static code = 'ERR_JWKS_MULTIPLE_MATCHING_KEYS';\n code = 'ERR_JWKS_MULTIPLE_MATCHING_KEYS';\n constructor(message = 'multiple matching keys found in the JSON Web Key Set', options) {\n super(message, options);\n }\n}\nexport class JWKSTimeout extends JOSEError {\n static code = 'ERR_JWKS_TIMEOUT';\n code = 'ERR_JWKS_TIMEOUT';\n constructor(message = 'request timed out', options) {\n super(message, options);\n }\n}\nexport class JWSSignatureVerificationFailed extends JOSEError {\n static code = 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED';\n code = 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED';\n constructor(message = 'signature verification failed', options) {\n super(message, options);\n }\n}\n","function unusable(name, prop = 'algorithm.name') {\n return new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);\n}\nfunction isAlgorithm(algorithm, name) {\n return algorithm.name === name;\n}\nfunction getHashLength(hash) {\n return parseInt(hash.name.slice(4), 10);\n}\nfunction getNamedCurve(alg) {\n switch (alg) {\n case 'ES256':\n return 'P-256';\n case 'ES384':\n return 'P-384';\n case 'ES512':\n return 'P-521';\n default:\n throw new Error('unreachable');\n }\n}\nfunction checkUsage(key, usage) {\n if (usage && !key.usages.includes(usage)) {\n throw new TypeError(`CryptoKey does not support this operation, its usages must include ${usage}.`);\n }\n}\nexport function checkSigCryptoKey(key, alg, usage) {\n switch (alg) {\n case 'HS256':\n case 'HS384':\n case 'HS512': {\n if (!isAlgorithm(key.algorithm, 'HMAC'))\n throw unusable('HMAC');\n const expected = parseInt(alg.slice(2), 10);\n const actual = getHashLength(key.algorithm.hash);\n if (actual !== expected)\n throw unusable(`SHA-${expected}`, 'algorithm.hash');\n break;\n }\n case 'RS256':\n case 'RS384':\n case 'RS512': {\n if (!isAlgorithm(key.algorithm, 'RSASSA-PKCS1-v1_5'))\n throw unusable('RSASSA-PKCS1-v1_5');\n const expected = parseInt(alg.slice(2), 10);\n const actual = getHashLength(key.algorithm.hash);\n if (actual !== expected)\n throw unusable(`SHA-${expected}`, 'algorithm.hash');\n break;\n }\n case 'PS256':\n case 'PS384':\n case 'PS512': {\n if (!isAlgorithm(key.algorithm, 'RSA-PSS'))\n throw unusable('RSA-PSS');\n const expected = parseInt(alg.slice(2), 10);\n const actual = getHashLength(key.algorithm.hash);\n if (actual !== expected)\n throw unusable(`SHA-${expected}`, 'algorithm.hash');\n break;\n }\n case 'Ed25519':\n case 'EdDSA': {\n if (!isAlgorithm(key.algorithm, 'Ed25519'))\n throw unusable('Ed25519');\n break;\n }\n case 'ML-DSA-44':\n case 'ML-DSA-65':\n case 'ML-DSA-87': {\n if (!isAlgorithm(key.algorithm, alg))\n throw unusable(alg);\n break;\n }\n case 'ES256':\n case 'ES384':\n case 'ES512': {\n if (!isAlgorithm(key.algorithm, 'ECDSA'))\n throw unusable('ECDSA');\n const expected = getNamedCurve(alg);\n const actual = key.algorithm.namedCurve;\n if (actual !== expected)\n throw unusable(expected, 'algorithm.namedCurve');\n break;\n }\n default:\n throw new TypeError('CryptoKey does not support this operation');\n }\n checkUsage(key, usage);\n}\nexport function checkEncCryptoKey(key, alg, usage) {\n switch (alg) {\n case 'A128GCM':\n case 'A192GCM':\n case 'A256GCM': {\n if (!isAlgorithm(key.algorithm, 'AES-GCM'))\n throw unusable('AES-GCM');\n const expected = parseInt(alg.slice(1, 4), 10);\n const actual = key.algorithm.length;\n if (actual !== expected)\n throw unusable(expected, 'algorithm.length');\n break;\n }\n case 'A128KW':\n case 'A192KW':\n case 'A256KW': {\n if (!isAlgorithm(key.algorithm, 'AES-KW'))\n throw unusable('AES-KW');\n const expected = parseInt(alg.slice(1, 4), 10);\n const actual = key.algorithm.length;\n if (actual !== expected)\n throw unusable(expected, 'algorithm.length');\n break;\n }\n case 'ECDH': {\n switch (key.algorithm.name) {\n case 'ECDH':\n case 'X25519':\n break;\n default:\n throw unusable('ECDH or X25519');\n }\n break;\n }\n case 'PBES2-HS256+A128KW':\n case 'PBES2-HS384+A192KW':\n case 'PBES2-HS512+A256KW':\n if (!isAlgorithm(key.algorithm, 'PBKDF2'))\n throw unusable('PBKDF2');\n break;\n case 'RSA-OAEP':\n case 'RSA-OAEP-256':\n case 'RSA-OAEP-384':\n case 'RSA-OAEP-512': {\n if (!isAlgorithm(key.algorithm, 'RSA-OAEP'))\n throw unusable('RSA-OAEP');\n const expected = parseInt(alg.slice(9), 10) || 1;\n const actual = getHashLength(key.algorithm.hash);\n if (actual !== expected)\n throw unusable(`SHA-${expected}`, 'algorithm.hash');\n break;\n }\n default:\n throw new TypeError('CryptoKey does not support this operation');\n }\n checkUsage(key, usage);\n}\n","function message(msg, actual, ...types) {\n types = types.filter(Boolean);\n if (types.length > 2) {\n const last = types.pop();\n msg += `one of type ${types.join(', ')}, or ${last}.`;\n }\n else if (types.length === 2) {\n msg += `one of type ${types[0]} or ${types[1]}.`;\n }\n else {\n msg += `of type ${types[0]}.`;\n }\n if (actual == null) {\n msg += ` Received ${actual}`;\n }\n else if (typeof actual === 'function' && actual.name) {\n msg += ` Received function ${actual.name}`;\n }\n else if (typeof actual === 'object' && actual != null) {\n if (actual.constructor?.name) {\n msg += ` Received an instance of ${actual.constructor.name}`;\n }\n }\n return msg;\n}\nexport default (actual, ...types) => {\n return message('Key must be ', actual, ...types);\n};\nexport function withAlg(alg, actual, ...types) {\n return message(`Key for the ${alg} algorithm must be `, actual, ...types);\n}\n","export function assertCryptoKey(key) {\n if (!isCryptoKey(key)) {\n throw new Error('CryptoKey instance expected');\n }\n}\nexport function isCryptoKey(key) {\n return key?.[Symbol.toStringTag] === 'CryptoKey';\n}\nexport function isKeyObject(key) {\n return key?.[Symbol.toStringTag] === 'KeyObject';\n}\nexport default (key) => {\n return isCryptoKey(key) || isKeyObject(key);\n};\n","function isObjectLike(value) {\n return typeof value === 'object' && value !== null;\n}\nexport default (input) => {\n if (!isObjectLike(input) || Object.prototype.toString.call(input) !== '[object Object]') {\n return false;\n }\n if (Object.getPrototypeOf(input) === null) {\n return true;\n }\n let proto = input;\n while (Object.getPrototypeOf(proto) !== null) {\n proto = Object.getPrototypeOf(proto);\n }\n return Object.getPrototypeOf(input) === proto;\n};\n","import { JOSENotSupported } from '../util/errors.js';\nfunction subtleMapping(jwk) {\n let algorithm;\n let keyUsages;\n switch (jwk.kty) {\n case 'AKP': {\n switch (jwk.alg) {\n case 'ML-DSA-44':\n case 'ML-DSA-65':\n case 'ML-DSA-87':\n algorithm = { name: jwk.alg };\n keyUsages = jwk.priv ? ['sign'] : ['verify'];\n break;\n default:\n throw new JOSENotSupported('Invalid or unsupported JWK \"alg\" (Algorithm) Parameter value');\n }\n break;\n }\n case 'RSA': {\n switch (jwk.alg) {\n case 'PS256':\n case 'PS384':\n case 'PS512':\n algorithm = { name: 'RSA-PSS', hash: `SHA-${jwk.alg.slice(-3)}` };\n keyUsages = jwk.d ? ['sign'] : ['verify'];\n break;\n case 'RS256':\n case 'RS384':\n case 'RS512':\n algorithm = { name: 'RSASSA-PKCS1-v1_5', hash: `SHA-${jwk.alg.slice(-3)}` };\n keyUsages = jwk.d ? ['sign'] : ['verify'];\n break;\n case 'RSA-OAEP':\n case 'RSA-OAEP-256':\n case 'RSA-OAEP-384':\n case 'RSA-OAEP-512':\n algorithm = {\n name: 'RSA-OAEP',\n hash: `SHA-${parseInt(jwk.alg.slice(-3), 10) || 1}`,\n };\n keyUsages = jwk.d ? ['decrypt', 'unwrapKey'] : ['encrypt', 'wrapKey'];\n break;\n default:\n throw new JOSENotSupported('Invalid or unsupported JWK \"alg\" (Algorithm) Parameter value');\n }\n break;\n }\n case 'EC': {\n switch (jwk.alg) {\n case 'ES256':\n algorithm = { name: 'ECDSA', namedCurve: 'P-256' };\n keyUsages = jwk.d ? ['sign'] : ['verify'];\n break;\n case 'ES384':\n algorithm = { name: 'ECDSA', namedCurve: 'P-384' };\n keyUsages = jwk.d ? ['sign'] : ['verify'];\n break;\n case 'ES512':\n algorithm = { name: 'ECDSA', namedCurve: 'P-521' };\n keyUsages = jwk.d ? ['sign'] : ['verify'];\n break;\n case 'ECDH-ES':\n case 'ECDH-ES+A128KW':\n case 'ECDH-ES+A192KW':\n case 'ECDH-ES+A256KW':\n algorithm = { name: 'ECDH', namedCurve: jwk.crv };\n keyUsages = jwk.d ? ['deriveBits'] : [];\n break;\n default:\n throw new JOSENotSupported('Invalid or unsupported JWK \"alg\" (Algorithm) Parameter value');\n }\n break;\n }\n case 'OKP': {\n switch (jwk.alg) {\n case 'Ed25519':\n case 'EdDSA':\n algorithm = { name: 'Ed25519' };\n keyUsages = jwk.d ? ['sign'] : ['verify'];\n break;\n case 'ECDH-ES':\n case 'ECDH-ES+A128KW':\n case 'ECDH-ES+A192KW':\n case 'ECDH-ES+A256KW':\n algorithm = { name: jwk.crv };\n keyUsages = jwk.d ? ['deriveBits'] : [];\n break;\n default:\n throw new JOSENotSupported('Invalid or unsupported JWK \"alg\" (Algorithm) Parameter value');\n }\n break;\n }\n default:\n throw new JOSENotSupported('Invalid or unsupported JWK \"kty\" (Key Type) Parameter value');\n }\n return { algorithm, keyUsages };\n}\nexport default async (jwk) => {\n if (!jwk.alg) {\n throw new TypeError('\"alg\" argument is required when \"jwk.alg\" is not present');\n }\n const { algorithm, keyUsages } = subtleMapping(jwk);\n const keyData = { ...jwk };\n if (keyData.kty !== 'AKP') {\n delete keyData.alg;\n }\n delete keyData.use;\n return crypto.subtle.importKey('jwk', keyData, algorithm, jwk.ext ?? (jwk.d || jwk.priv ? false : true), jwk.key_ops ?? keyUsages);\n};\n","import isObject from './is_object.js';\nexport function isJWK(key) {\n return isObject(key) && typeof key.kty === 'string';\n}\nexport function isPrivateJWK(key) {\n return (key.kty !== 'oct' &&\n ((key.kty === 'AKP' && typeof key.priv === 'string') || typeof key.d === 'string'));\n}\nexport function isPublicJWK(key) {\n return key.kty !== 'oct' && typeof key.d === 'undefined' && typeof key.priv === 'undefined';\n}\nexport function isSecretJWK(key) {\n return key.kty === 'oct' && typeof key.k === 'string';\n}\n","import { isJWK } from './is_jwk.js';\nimport { decode } from '../util/base64url.js';\nimport importJWK from './jwk_to_key.js';\nimport { isCryptoKey, isKeyObject } from './is_key_like.js';\nlet cache;\nconst handleJWK = async (key, jwk, alg, freeze = false) => {\n cache ||= new WeakMap();\n let cached = cache.get(key);\n if (cached?.[alg]) {\n return cached[alg];\n }\n const cryptoKey = await importJWK({ ...jwk, alg });\n if (freeze)\n Object.freeze(key);\n if (!cached) {\n cache.set(key, { [alg]: cryptoKey });\n }\n else {\n cached[alg] = cryptoKey;\n }\n return cryptoKey;\n};\nconst handleKeyObject = (keyObject, alg) => {\n cache ||= new WeakMap();\n let cached = cache.get(keyObject);\n if (cached?.[alg]) {\n return cached[alg];\n }\n const isPublic = keyObject.type === 'public';\n const extractable = isPublic ? true : false;\n let cryptoKey;\n if (keyObject.asymmetricKeyType === 'x25519') {\n switch (alg) {\n case 'ECDH-ES':\n case 'ECDH-ES+A128KW':\n case 'ECDH-ES+A192KW':\n case 'ECDH-ES+A256KW':\n break;\n default:\n throw new TypeError('given KeyObject instance cannot be used for this algorithm');\n }\n cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, isPublic ? [] : ['deriveBits']);\n }\n if (keyObject.asymmetricKeyType === 'ed25519') {\n if (alg !== 'EdDSA' && alg !== 'Ed25519') {\n throw new TypeError('given KeyObject instance cannot be used for this algorithm');\n }\n cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [\n isPublic ? 'verify' : 'sign',\n ]);\n }\n switch (keyObject.asymmetricKeyType) {\n case 'ml-dsa-44':\n case 'ml-dsa-65':\n case 'ml-dsa-87': {\n if (alg !== keyObject.asymmetricKeyType.toUpperCase()) {\n throw new TypeError('given KeyObject instance cannot be used for this algorithm');\n }\n cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [\n isPublic ? 'verify' : 'sign',\n ]);\n }\n }\n if (keyObject.asymmetricKeyType === 'rsa') {\n let hash;\n switch (alg) {\n case 'RSA-OAEP':\n hash = 'SHA-1';\n break;\n case 'RS256':\n case 'PS256':\n case 'RSA-OAEP-256':\n hash = 'SHA-256';\n break;\n case 'RS384':\n case 'PS384':\n case 'RSA-OAEP-384':\n hash = 'SHA-384';\n break;\n case 'RS512':\n case 'PS512':\n case 'RSA-OAEP-512':\n hash = 'SHA-512';\n break;\n default:\n throw new TypeError('given KeyObject instance cannot be used for this algorithm');\n }\n if (alg.startsWith('RSA-OAEP')) {\n return keyObject.toCryptoKey({\n name: 'RSA-OAEP',\n hash,\n }, extractable, isPublic ? ['encrypt'] : ['decrypt']);\n }\n cryptoKey = keyObject.toCryptoKey({\n name: alg.startsWith('PS') ? 'RSA-PSS' : 'RSASSA-PKCS1-v1_5',\n hash,\n }, extractable, [isPublic ? 'verify' : 'sign']);\n }\n if (keyObject.asymmetricKeyType === 'ec') {\n const nist = new Map([\n ['prime256v1', 'P-256'],\n ['secp384r1', 'P-384'],\n ['secp521r1', 'P-521'],\n ]);\n const namedCurve = nist.get(keyObject.asymmetricKeyDetails?.namedCurve);\n if (!namedCurve) {\n throw new TypeError('given KeyObject instance cannot be used for this algorithm');\n }\n if (alg === 'ES256' && namedCurve === 'P-256') {\n cryptoKey = keyObject.toCryptoKey({\n name: 'ECDSA',\n namedCurve,\n }, extractable, [isPublic ? 'verify' : 'sign']);\n }\n if (alg === 'ES384' && namedCurve === 'P-384') {\n cryptoKey = keyObject.toCryptoKey({\n name: 'ECDSA',\n namedCurve,\n }, extractable, [isPublic ? 'verify' : 'sign']);\n }\n if (alg === 'ES512' && namedCurve === 'P-521') {\n cryptoKey = keyObject.toCryptoKey({\n name: 'ECDSA',\n namedCurve,\n }, extractable, [isPublic ? 'verify' : 'sign']);\n }\n if (alg.startsWith('ECDH-ES')) {\n cryptoKey = keyObject.toCryptoKey({\n name: 'ECDH',\n namedCurve,\n }, extractable, isPublic ? [] : ['deriveBits']);\n }\n }\n if (!cryptoKey) {\n throw new TypeError('given KeyObject instance cannot be used for this algorithm');\n }\n if (!cached) {\n cache.set(keyObject, { [alg]: cryptoKey });\n }\n else {\n cached[alg] = cryptoKey;\n }\n return cryptoKey;\n};\nexport default async (key, alg) => {\n if (key instanceof Uint8Array) {\n return key;\n }\n if (isCryptoKey(key)) {\n return key;\n }\n if (isKeyObject(key)) {\n if (key.type === 'secret') {\n return key.export();\n }\n if ('toCryptoKey' in key && typeof key.toCryptoKey === 'function') {\n try {\n return handleKeyObject(key, alg);\n }\n catch (err) {\n if (err instanceof TypeError) {\n throw err;\n }\n }\n }\n let jwk = key.export({ format: 'jwk' });\n return handleJWK(key, jwk, alg);\n }\n if (isJWK(key)) {\n if (key.k) {\n return decode(key.k);\n }\n return handleJWK(key, key, alg, true);\n }\n throw new Error('unreachable');\n};\n","import { withAlg as invalidKeyInput } from './invalid_key_input.js';\nimport isKeyLike from './is_key_like.js';\nimport * as jwk from './is_jwk.js';\nconst tag = (key) => key?.[Symbol.toStringTag];\nconst jwkMatchesOp = (alg, key, usage) => {\n if (key.use !== undefined) {\n let expected;\n switch (usage) {\n case 'sign':\n case 'verify':\n expected = 'sig';\n break;\n case 'encrypt':\n case 'decrypt':\n expected = 'enc';\n break;\n }\n if (key.use !== expected) {\n throw new TypeError(`Invalid key for this operation, its \"use\" must be \"${expected}\" when present`);\n }\n }\n if (key.alg !== undefined && key.alg !== alg) {\n throw new TypeError(`Invalid key for this operation, its \"alg\" must be \"${alg}\" when present`);\n }\n if (Array.isArray(key.key_ops)) {\n let expectedKeyOp;\n switch (true) {\n case usage === 'sign' || usage === 'verify':\n case alg === 'dir':\n case alg.includes('CBC-HS'):\n expectedKeyOp = usage;\n break;\n case alg.startsWith('PBES2'):\n expectedKeyOp = 'deriveBits';\n break;\n case /^A\\d{3}(?:GCM)?(?:KW)?$/.test(alg):\n if (!alg.includes('GCM') && alg.endsWith('KW')) {\n expectedKeyOp = usage === 'encrypt' ? 'wrapKey' : 'unwrapKey';\n }\n else {\n expectedKeyOp = usage;\n }\n break;\n case usage === 'encrypt' && alg.startsWith('RSA'):\n expectedKeyOp = 'wrapKey';\n break;\n case usage === 'decrypt':\n expectedKeyOp = alg.startsWith('RSA') ? 'unwrapKey' : 'deriveBits';\n break;\n }\n if (expectedKeyOp && key.key_ops?.includes?.(expectedKeyOp) === false) {\n throw new TypeError(`Invalid key for this operation, its \"key_ops\" must include \"${expectedKeyOp}\" when present`);\n }\n }\n return true;\n};\nconst symmetricTypeCheck = (alg, key, usage) => {\n if (key instanceof Uint8Array)\n return;\n if (jwk.isJWK(key)) {\n if (jwk.isSecretJWK(key) && jwkMatchesOp(alg, key, usage))\n return;\n throw new TypeError(`JSON Web Key for symmetric algorithms must have JWK \"kty\" (Key Type) equal to \"oct\" and the JWK \"k\" (Key Value) present`);\n }\n if (!isKeyLike(key)) {\n throw new TypeError(invalidKeyInput(alg, key, 'CryptoKey', 'KeyObject', 'JSON Web Key', 'Uint8Array'));\n }\n if (key.type !== 'secret') {\n throw new TypeError(`${tag(key)} instances for symmetric algorithms must be of type \"secret\"`);\n }\n};\nconst asymmetricTypeCheck = (alg, key, usage) => {\n if (jwk.isJWK(key)) {\n switch (usage) {\n case 'decrypt':\n case 'sign':\n if (jwk.isPrivateJWK(key) && jwkMatchesOp(alg, key, usage))\n return;\n throw new TypeError(`JSON Web Key for this operation be a private JWK`);\n case 'encrypt':\n case 'verify':\n if (jwk.isPublicJWK(key) && jwkMatchesOp(alg, key, usage))\n return;\n throw new TypeError(`JSON Web Key for this operation be a public JWK`);\n }\n }\n if (!isKeyLike(key)) {\n throw new TypeError(invalidKeyInput(alg, key, 'CryptoKey', 'KeyObject', 'JSON Web Key'));\n }\n if (key.type === 'secret') {\n throw new TypeError(`${tag(key)} instances for asymmetric algorithms must not be of type \"secret\"`);\n }\n if (key.type === 'public') {\n switch (usage) {\n case 'sign':\n throw new TypeError(`${tag(key)} instances for asymmetric algorithm signing must be of type \"private\"`);\n case 'decrypt':\n throw new TypeError(`${tag(key)} instances for asymmetric algorithm decryption must be of type \"private\"`);\n default:\n break;\n }\n }\n if (key.type === 'private') {\n switch (usage) {\n case 'verify':\n throw new TypeError(`${tag(key)} instances for asymmetric algorithm verifying must be of type \"public\"`);\n case 'encrypt':\n throw new TypeError(`${tag(key)} instances for asymmetric algorithm encryption must be of type \"public\"`);\n default:\n break;\n }\n }\n};\nexport default (alg, key, usage) => {\n const symmetric = alg.startsWith('HS') ||\n alg === 'dir' ||\n alg.startsWith('PBES2') ||\n /^A(?:128|192|256)(?:GCM)?(?:KW)?$/.test(alg) ||\n /^A(?:128|192|256)CBC-HS(?:256|384|512)$/.test(alg);\n if (symmetric) {\n symmetricTypeCheck(alg, key, usage);\n }\n else {\n asymmetricTypeCheck(alg, key, usage);\n }\n};\n","import { checkSigCryptoKey } from './crypto_key.js';\nimport invalidKeyInput from './invalid_key_input.js';\nexport default async (alg, key, usage) => {\n if (key instanceof Uint8Array) {\n if (!alg.startsWith('HS')) {\n throw new TypeError(invalidKeyInput(key, 'CryptoKey', 'KeyObject', 'JSON Web Key'));\n }\n return crypto.subtle.importKey('raw', key, { hash: `SHA-${alg.slice(-3)}`, name: 'HMAC' }, false, [usage]);\n }\n checkSigCryptoKey(key, alg, usage);\n return key;\n};\n","import subtleAlgorithm from './subtle_dsa.js';\nimport checkKeyLength from './check_key_length.js';\nimport getVerifyKey from './get_sign_verify_key.js';\nexport default async (alg, key, signature, data) => {\n const cryptoKey = await getVerifyKey(alg, key, 'verify');\n checkKeyLength(alg, cryptoKey);\n const algorithm = subtleAlgorithm(alg, cryptoKey.algorithm);\n try {\n return await crypto.subtle.verify(algorithm, cryptoKey, signature, data);\n }\n catch {\n return false;\n }\n};\n","export default (alg, key) => {\n if (alg.startsWith('RS') || alg.startsWith('PS')) {\n const { modulusLength } = key.algorithm;\n if (typeof modulusLength !== 'number' || modulusLength < 2048) {\n throw new TypeError(`${alg} requires key modulusLength to be 2048 bits or larger`);\n }\n }\n};\n","import { JOSENotSupported } from '../util/errors.js';\nexport default (alg, algorithm) => {\n const hash = `SHA-${alg.slice(-3)}`;\n switch (alg) {\n case 'HS256':\n case 'HS384':\n case 'HS512':\n return { hash, name: 'HMAC' };\n case 'PS256':\n case 'PS384':\n case 'PS512':\n return { hash, name: 'RSA-PSS', saltLength: parseInt(alg.slice(-3), 10) >> 3 };\n case 'RS256':\n case 'RS384':\n case 'RS512':\n return { hash, name: 'RSASSA-PKCS1-v1_5' };\n case 'ES256':\n case 'ES384':\n case 'ES512':\n return { hash, name: 'ECDSA', namedCurve: algorithm.namedCurve };\n case 'Ed25519':\n case 'EdDSA':\n return { name: 'Ed25519' };\n case 'ML-DSA-44':\n case 'ML-DSA-65':\n case 'ML-DSA-87':\n return { name: alg };\n default:\n throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);\n }\n};\n","import { decode as b64u } from '../../util/base64url.js';\nimport verify from '../../lib/verify.js';\nimport { JOSEAlgNotAllowed, JWSInvalid, JWSSignatureVerificationFailed } from '../../util/errors.js';\nimport { concat, encoder, decoder } from '../../lib/buffer_utils.js';\nimport isDisjoint from '../../lib/is_disjoint.js';\nimport isObject from '../../lib/is_object.js';\nimport checkKeyType from '../../lib/check_key_type.js';\nimport validateCrit from '../../lib/validate_crit.js';\nimport validateAlgorithms from '../../lib/validate_algorithms.js';\nimport normalizeKey from '../../lib/normalize_key.js';\nexport async function flattenedVerify(jws, key, options) {\n if (!isObject(jws)) {\n throw new JWSInvalid('Flattened JWS must be an object');\n }\n if (jws.protected === undefined && jws.header === undefined) {\n throw new JWSInvalid('Flattened JWS must have either of the \"protected\" or \"header\" members');\n }\n if (jws.protected !== undefined && typeof jws.protected !== 'string') {\n throw new JWSInvalid('JWS Protected Header incorrect type');\n }\n if (jws.payload === undefined) {\n throw new JWSInvalid('JWS Payload missing');\n }\n if (typeof jws.signature !== 'string') {\n throw new JWSInvalid('JWS Signature missing or incorrect type');\n }\n if (jws.header !== undefined && !isObject(jws.header)) {\n throw new JWSInvalid('JWS Unprotected Header incorrect type');\n }\n let parsedProt = {};\n if (jws.protected) {\n try {\n const protectedHeader = b64u(jws.protected);\n parsedProt = JSON.parse(decoder.decode(protectedHeader));\n }\n catch {\n throw new JWSInvalid('JWS Protected Header is invalid');\n }\n }\n if (!isDisjoint(parsedProt, jws.header)) {\n throw new JWSInvalid('JWS Protected and JWS Unprotected Header Parameter names must be disjoint');\n }\n const joseHeader = {\n ...parsedProt,\n ...jws.header,\n };\n const extensions = validateCrit(JWSInvalid, new Map([['b64', true]]), options?.crit, parsedProt, joseHeader);\n let b64 = true;\n if (extensions.has('b64')) {\n b64 = parsedProt.b64;\n if (typeof b64 !== 'boolean') {\n throw new JWSInvalid('The \"b64\" (base64url-encode payload) Header Parameter must be a boolean');\n }\n }\n const { alg } = joseHeader;\n if (typeof alg !== 'string' || !alg) {\n throw new JWSInvalid('JWS \"alg\" (Algorithm) Header Parameter missing or invalid');\n }\n const algorithms = options && validateAlgorithms('algorithms', options.algorithms);\n if (algorithms && !algorithms.has(alg)) {\n throw new JOSEAlgNotAllowed('\"alg\" (Algorithm) Header Parameter value not allowed');\n }\n if (b64) {\n if (typeof jws.payload !== 'string') {\n throw new JWSInvalid('JWS Payload must be a string');\n }\n }\n else if (typeof jws.payload !== 'string' && !(jws.payload instanceof Uint8Array)) {\n throw new JWSInvalid('JWS Payload must be a string or an Uint8Array instance');\n }\n let resolvedKey = false;\n if (typeof key === 'function') {\n key = await key(parsedProt, jws);\n resolvedKey = true;\n }\n checkKeyType(alg, key, 'verify');\n const data = concat(encoder.encode(jws.protected ?? ''), encoder.encode('.'), typeof jws.payload === 'string' ? encoder.encode(jws.payload) : jws.payload);\n let signature;\n try {\n signature = b64u(jws.signature);\n }\n catch {\n throw new JWSInvalid('Failed to base64url decode the signature');\n }\n const k = await normalizeKey(key, alg);\n const verified = await verify(alg, k, signature, data);\n if (!verified) {\n throw new JWSSignatureVerificationFailed();\n }\n let payload;\n if (b64) {\n try {\n payload = b64u(jws.payload);\n }\n catch {\n throw new JWSInvalid('Failed to base64url decode the payload');\n }\n }\n else if (typeof jws.payload === 'string') {\n payload = encoder.encode(jws.payload);\n }\n else {\n payload = jws.payload;\n }\n const result = { payload };\n if (jws.protected !== undefined) {\n result.protectedHeader = parsedProt;\n }\n if (jws.header !== undefined) {\n result.unprotectedHeader = jws.header;\n }\n if (resolvedKey) {\n return { ...result, key: k };\n }\n return result;\n}\n","export default (...headers) => {\n const sources = headers.filter(Boolean);\n if (sources.length === 0 || sources.length === 1) {\n return true;\n }\n let acc;\n for (const header of sources) {\n const parameters = Object.keys(header);\n if (!acc || acc.size === 0) {\n acc = new Set(parameters);\n continue;\n }\n for (const parameter of parameters) {\n if (acc.has(parameter)) {\n return false;\n }\n acc.add(parameter);\n }\n }\n return true;\n};\n","import { JOSENotSupported, JWEInvalid, JWSInvalid } from '../util/errors.js';\nexport default (Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) => {\n if (joseHeader.crit !== undefined && protectedHeader?.crit === undefined) {\n throw new Err('\"crit\" (Critical) Header Parameter MUST be integrity protected');\n }\n if (!protectedHeader || protectedHeader.crit === undefined) {\n return new Set();\n }\n if (!Array.isArray(protectedHeader.crit) ||\n protectedHeader.crit.length === 0 ||\n protectedHeader.crit.some((input) => typeof input !== 'string' || input.length === 0)) {\n throw new Err('\"crit\" (Critical) Header Parameter MUST be an array of non-empty strings when present');\n }\n let recognized;\n if (recognizedOption !== undefined) {\n recognized = new Map([...Object.entries(recognizedOption), ...recognizedDefault.entries()]);\n }\n else {\n recognized = recognizedDefault;\n }\n for (const parameter of protectedHeader.crit) {\n if (!recognized.has(parameter)) {\n throw new JOSENotSupported(`Extension Header Parameter \"${parameter}\" is not recognized`);\n }\n if (joseHeader[parameter] === undefined) {\n throw new Err(`Extension Header Parameter \"${parameter}\" is missing`);\n }\n if (recognized.get(parameter) && protectedHeader[parameter] === undefined) {\n throw new Err(`Extension Header Parameter \"${parameter}\" MUST be integrity protected`);\n }\n }\n return new Set(protectedHeader.crit);\n};\n","export default (option, algorithms) => {\n if (algorithms !== undefined &&\n (!Array.isArray(algorithms) || algorithms.some((s) => typeof s !== 'string'))) {\n throw new TypeError(`\"${option}\" option must be an array of strings`);\n }\n if (!algorithms) {\n return undefined;\n }\n return new Set(algorithms);\n};\n","export default (date) => Math.floor(date.getTime() / 1000);\n","const minute = 60;\nconst hour = minute * 60;\nconst day = hour * 24;\nconst week = day * 7;\nconst year = day * 365.25;\nconst REGEX = /^(\\+|\\-)? ?(\\d+|\\d+\\.\\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;\nexport default (str) => {\n const matched = REGEX.exec(str);\n if (!matched || (matched[4] && matched[1])) {\n throw new TypeError('Invalid time period format');\n }\n const value = parseFloat(matched[2]);\n const unit = matched[3].toLowerCase();\n let numericDate;\n switch (unit) {\n case 'sec':\n case 'secs':\n case 'second':\n case 'seconds':\n case 's':\n numericDate = Math.round(value);\n break;\n case 'minute':\n case 'minutes':\n case 'min':\n case 'mins':\n case 'm':\n numericDate = Math.round(value * minute);\n break;\n case 'hour':\n case 'hours':\n case 'hr':\n case 'hrs':\n case 'h':\n numericDate = Math.round(value * hour);\n break;\n case 'day':\n case 'days':\n case 'd':\n numericDate = Math.round(value * day);\n break;\n case 'week':\n case 'weeks':\n case 'w':\n numericDate = Math.round(value * week);\n break;\n default:\n numericDate = Math.round(value * year);\n break;\n }\n if (matched[1] === '-' || matched[4] === 'ago') {\n return -numericDate;\n }\n return numericDate;\n};\n","import { JWTClaimValidationFailed, JWTExpired, JWTInvalid } from '../util/errors.js';\nimport { decoder } from './buffer_utils.js';\nimport epoch from './epoch.js';\nimport secs from './secs.js';\nimport isObject from './is_object.js';\nimport { encoder } from './buffer_utils.js';\nfunction validateInput(label, input) {\n if (!Number.isFinite(input)) {\n throw new TypeError(`Invalid ${label} input`);\n }\n return input;\n}\nconst normalizeTyp = (value) => {\n if (value.includes('/')) {\n return value.toLowerCase();\n }\n return `application/${value.toLowerCase()}`;\n};\nconst checkAudiencePresence = (audPayload, audOption) => {\n if (typeof audPayload === 'string') {\n return audOption.includes(audPayload);\n }\n if (Array.isArray(audPayload)) {\n return audOption.some(Set.prototype.has.bind(new Set(audPayload)));\n }\n return false;\n};\nexport function validateClaimsSet(protectedHeader, encodedPayload, options = {}) {\n let payload;\n try {\n payload = JSON.parse(decoder.decode(encodedPayload));\n }\n catch {\n }\n if (!isObject(payload)) {\n throw new JWTInvalid('JWT Claims Set must be a top-level JSON object');\n }\n const { typ } = options;\n if (typ &&\n (typeof protectedHeader.typ !== 'string' ||\n normalizeTyp(protectedHeader.typ) !== normalizeTyp(typ))) {\n throw new JWTClaimValidationFailed('unexpected \"typ\" JWT header value', payload, 'typ', 'check_failed');\n }\n const { requiredClaims = [], issuer, subject, audience, maxTokenAge } = options;\n const presenceCheck = [...requiredClaims];\n if (maxTokenAge !== undefined)\n presenceCheck.push('iat');\n if (audience !== undefined)\n presenceCheck.push('aud');\n if (subject !== undefined)\n presenceCheck.push('sub');\n if (issuer !== undefined)\n presenceCheck.push('iss');\n for (const claim of new Set(presenceCheck.reverse())) {\n if (!(claim in payload)) {\n throw new JWTClaimValidationFailed(`missing required \"${claim}\" claim`, payload, claim, 'missing');\n }\n }\n if (issuer &&\n !(Array.isArray(issuer) ? issuer : [issuer]).includes(payload.iss)) {\n throw new JWTClaimValidationFailed('unexpected \"iss\" claim value', payload, 'iss', 'check_failed');\n }\n if (subject && payload.sub !== subject) {\n throw new JWTClaimValidationFailed('unexpected \"sub\" claim value', payload, 'sub', 'check_failed');\n }\n if (audience &&\n !checkAudiencePresence(payload.aud, typeof audience === 'string' ? [audience] : audience)) {\n throw new JWTClaimValidationFailed('unexpected \"aud\" claim value', payload, 'aud', 'check_failed');\n }\n let tolerance;\n switch (typeof options.clockTolerance) {\n case 'string':\n tolerance = secs(options.clockTolerance);\n break;\n case 'number':\n tolerance = options.clockTolerance;\n break;\n case 'undefined':\n tolerance = 0;\n break;\n default:\n throw new TypeError('Invalid clockTolerance option type');\n }\n const { currentDate } = options;\n const now = epoch(currentDate || new Date());\n if ((payload.iat !== undefined || maxTokenAge) && typeof payload.iat !== 'number') {\n throw new JWTClaimValidationFailed('\"iat\" claim must be a number', payload, 'iat', 'invalid');\n }\n if (payload.nbf !== undefined) {\n if (typeof payload.nbf !== 'number') {\n throw new JWTClaimValidationFailed('\"nbf\" claim must be a number', payload, 'nbf', 'invalid');\n }\n if (payload.nbf > now + tolerance) {\n throw new JWTClaimValidationFailed('\"nbf\" claim timestamp check failed', payload, 'nbf', 'check_failed');\n }\n }\n if (payload.exp !== undefined) {\n if (typeof payload.exp !== 'number') {\n throw new JWTClaimValidationFailed('\"exp\" claim must be a number', payload, 'exp', 'invalid');\n }\n if (payload.exp <= now - tolerance) {\n throw new JWTExpired('\"exp\" claim timestamp check failed', payload, 'exp', 'check_failed');\n }\n }\n if (maxTokenAge) {\n const age = now - payload.iat;\n const max = typeof maxTokenAge === 'number' ? maxTokenAge : secs(maxTokenAge);\n if (age - tolerance > max) {\n throw new JWTExpired('\"iat\" claim timestamp check failed (too far in the past)', payload, 'iat', 'check_failed');\n }\n if (age < 0 - tolerance) {\n throw new JWTClaimValidationFailed('\"iat\" claim timestamp check failed (it should be in the past)', payload, 'iat', 'check_failed');\n }\n }\n return payload;\n}\nexport class JWTClaimsBuilder {\n #payload;\n constructor(payload) {\n if (!isObject(payload)) {\n throw new TypeError('JWT Claims Set MUST be an object');\n }\n this.#payload = structuredClone(payload);\n }\n data() {\n return encoder.encode(JSON.stringify(this.#payload));\n }\n get iss() {\n return this.#payload.iss;\n }\n set iss(value) {\n this.#payload.iss = value;\n }\n get sub() {\n return this.#payload.sub;\n }\n set sub(value) {\n this.#payload.sub = value;\n }\n get aud() {\n return this.#payload.aud;\n }\n set aud(value) {\n this.#payload.aud = value;\n }\n set jti(value) {\n this.#payload.jti = value;\n }\n set nbf(value) {\n if (typeof value === 'number') {\n this.#payload.nbf = validateInput('setNotBefore', value);\n }\n else if (value instanceof Date) {\n this.#payload.nbf = validateInput('setNotBefore', epoch(value));\n }\n else {\n this.#payload.nbf = epoch(new Date()) + secs(value);\n }\n }\n set exp(value) {\n if (typeof value === 'number') {\n this.#payload.exp = validateInput('setExpirationTime', value);\n }\n else if (value instanceof Date) {\n this.#payload.exp = validateInput('setExpirationTime', epoch(value));\n }\n else {\n this.#payload.exp = epoch(new Date()) + secs(value);\n }\n }\n set iat(value) {\n if (typeof value === 'undefined') {\n this.#payload.iat = epoch(new Date());\n }\n else if (value instanceof Date) {\n this.#payload.iat = validateInput('setIssuedAt', epoch(value));\n }\n else if (typeof value === 'string') {\n this.#payload.iat = validateInput('setIssuedAt', epoch(new Date()) + secs(value));\n }\n else {\n this.#payload.iat = validateInput('setIssuedAt', value);\n }\n }\n}\n","import { compactVerify } from '../jws/compact/verify.js';\nimport { validateClaimsSet } from '../lib/jwt_claims_set.js';\nimport { JWTInvalid } from '../util/errors.js';\nexport async function jwtVerify(jwt, key, options) {\n const verified = await compactVerify(jwt, key, options);\n if (verified.protectedHeader.crit?.includes('b64') && verified.protectedHeader.b64 === false) {\n throw new JWTInvalid('JWTs MUST NOT use unencoded payload');\n }\n const payload = validateClaimsSet(verified.protectedHeader, verified.payload, options);\n const result = { payload, protectedHeader: verified.protectedHeader };\n if (typeof key === 'function') {\n return { ...result, key: verified.key };\n }\n return result;\n}\n","import { flattenedVerify } from '../flattened/verify.js';\nimport { JWSInvalid } from '../../util/errors.js';\nimport { decoder } from '../../lib/buffer_utils.js';\nexport async function compactVerify(jws, key, options) {\n if (jws instanceof Uint8Array) {\n jws = decoder.decode(jws);\n }\n if (typeof jws !== 'string') {\n throw new JWSInvalid('Compact JWS must be a string or Uint8Array');\n }\n const { 0: protectedHeader, 1: payload, 2: signature, length } = jws.split('.');\n if (length !== 3) {\n throw new JWSInvalid('Invalid Compact JWS');\n }\n const verified = await flattenedVerify({ payload, protected: protectedHeader, signature }, key, options);\n const result = { payload: verified.payload, protectedHeader: verified.protectedHeader };\n if (typeof key === 'function') {\n return { ...result, key: verified.key };\n }\n return result;\n}\n","import { importJWK } from '../key/import.js';\nimport { JWKSInvalid, JOSENotSupported, JWKSNoMatchingKey, JWKSMultipleMatchingKeys, } from '../util/errors.js';\nimport isObject from '../lib/is_object.js';\nfunction getKtyFromAlg(alg) {\n switch (typeof alg === 'string' && alg.slice(0, 2)) {\n case 'RS':\n case 'PS':\n return 'RSA';\n case 'ES':\n return 'EC';\n case 'Ed':\n return 'OKP';\n case 'ML':\n return 'AKP';\n default:\n throw new JOSENotSupported('Unsupported \"alg\" value for a JSON Web Key Set');\n }\n}\nfunction isJWKSLike(jwks) {\n return (jwks &&\n typeof jwks === 'object' &&\n Array.isArray(jwks.keys) &&\n jwks.keys.every(isJWKLike));\n}\nfunction isJWKLike(key) {\n return isObject(key);\n}\nclass LocalJWKSet {\n #jwks;\n #cached = new WeakMap();\n constructor(jwks) {\n if (!isJWKSLike(jwks)) {\n throw new JWKSInvalid('JSON Web Key Set malformed');\n }\n this.#jwks = structuredClone(jwks);\n }\n jwks() {\n return this.#jwks;\n }\n async getKey(protectedHeader, token) {\n const { alg, kid } = { ...protectedHeader, ...token?.header };\n const kty = getKtyFromAlg(alg);\n const candidates = this.#jwks.keys.filter((jwk) => {\n let candidate = kty === jwk.kty;\n if (candidate && typeof kid === 'string') {\n candidate = kid === jwk.kid;\n }\n if (candidate && (typeof jwk.alg === 'string' || kty === 'AKP')) {\n candidate = alg === jwk.alg;\n }\n if (candidate && typeof jwk.use === 'string') {\n candidate = jwk.use === 'sig';\n }\n if (candidate && Array.isArray(jwk.key_ops)) {\n candidate = jwk.key_ops.includes('verify');\n }\n if (candidate) {\n switch (alg) {\n case 'ES256':\n candidate = jwk.crv === 'P-256';\n break;\n case 'ES384':\n candidate = jwk.crv === 'P-384';\n break;\n case 'ES512':\n candidate = jwk.crv === 'P-521';\n break;\n case 'Ed25519':\n case 'EdDSA':\n candidate = jwk.crv === 'Ed25519';\n break;\n }\n }\n return candidate;\n });\n const { 0: jwk, length } = candidates;\n if (length === 0) {\n throw new JWKSNoMatchingKey();\n }\n if (length !== 1) {\n const error = new JWKSMultipleMatchingKeys();\n const _cached = this.#cached;\n error[Symbol.asyncIterator] = async function* () {\n for (const jwk of candidates) {\n try {\n yield await importWithAlgCache(_cached, jwk, alg);\n }\n catch { }\n }\n };\n throw error;\n }\n return importWithAlgCache(this.#cached, jwk, alg);\n }\n}\nasync function importWithAlgCache(cache, jwk, alg) {\n const cached = cache.get(jwk) || cache.set(jwk, {}).get(jwk);\n if (cached[alg] === undefined) {\n const key = await importJWK({ ...jwk, ext: true }, alg);\n if (key instanceof Uint8Array || key.type !== 'public') {\n throw new JWKSInvalid('JSON Web Key Set members must be public keys');\n }\n cached[alg] = key;\n }\n return cached[alg];\n}\nexport function createLocalJWKSet(jwks) {\n const set = new LocalJWKSet(jwks);\n const localJWKSet = async (protectedHeader, token) => set.getKey(protectedHeader, token);\n Object.defineProperties(localJWKSet, {\n jwks: {\n value: () => structuredClone(set.jwks()),\n enumerable: false,\n configurable: false,\n writable: false,\n },\n });\n return localJWKSet;\n}\n","import { decode as decodeBase64URL } from '../util/base64url.js';\nimport { fromSPKI, fromPKCS8, fromX509 } from '../lib/asn1.js';\nimport toCryptoKey from '../lib/jwk_to_key.js';\nimport { JOSENotSupported } from '../util/errors.js';\nimport isObject from '../lib/is_object.js';\nexport async function importSPKI(spki, alg, options) {\n if (typeof spki !== 'string' || spki.indexOf('-----BEGIN PUBLIC KEY-----') !== 0) {\n throw new TypeError('\"spki\" must be SPKI formatted string');\n }\n return fromSPKI(spki, alg, options);\n}\nexport async function importX509(x509, alg, options) {\n if (typeof x509 !== 'string' || x509.indexOf('-----BEGIN CERTIFICATE-----') !== 0) {\n throw new TypeError('\"x509\" must be X.509 formatted string');\n }\n return fromX509(x509, alg, options);\n}\nexport async function importPKCS8(pkcs8, alg, options) {\n if (typeof pkcs8 !== 'string' || pkcs8.indexOf('-----BEGIN PRIVATE KEY-----') !== 0) {\n throw new TypeError('\"pkcs8\" must be PKCS#8 formatted string');\n }\n return fromPKCS8(pkcs8, alg, options);\n}\nexport async function importJWK(jwk, alg, options) {\n if (!isObject(jwk)) {\n throw new TypeError('JWK must be an object');\n }\n let ext;\n alg ??= jwk.alg;\n ext ??= options?.extractable ?? jwk.ext;\n switch (jwk.kty) {\n case 'oct':\n if (typeof jwk.k !== 'string' || !jwk.k) {\n throw new TypeError('missing \"k\" (Key Value) Parameter value');\n }\n return decodeBase64URL(jwk.k);\n case 'RSA':\n if ('oth' in jwk && jwk.oth !== undefined) {\n throw new JOSENotSupported('RSA JWK \"oth\" (Other Primes Info) Parameter value is not supported');\n }\n return toCryptoKey({ ...jwk, alg, ext });\n case 'AKP': {\n if (typeof jwk.alg !== 'string' || !jwk.alg) {\n throw new TypeError('missing \"alg\" (Algorithm) Parameter value');\n }\n if (alg !== undefined && alg !== jwk.alg) {\n throw new TypeError('JWK alg and alg option value mismatch');\n }\n return toCryptoKey({ ...jwk, ext });\n }\n case 'EC':\n case 'OKP':\n return toCryptoKey({ ...jwk, alg, ext });\n default:\n throw new JOSENotSupported('Unsupported \"kty\" (Key Type) Parameter value');\n }\n}\n","import { JOSEError, JWKSNoMatchingKey, JWKSTimeout } from '../util/errors.js';\nimport { createLocalJWKSet } from './local.js';\nimport isObject from '../lib/is_object.js';\nfunction isCloudflareWorkers() {\n return (typeof WebSocketPair !== 'undefined' ||\n (typeof navigator !== 'undefined' && navigator.userAgent === 'Cloudflare-Workers') ||\n (typeof EdgeRuntime !== 'undefined' && EdgeRuntime === 'vercel'));\n}\nlet USER_AGENT;\nif (typeof navigator === 'undefined' || !navigator.userAgent?.startsWith?.('Mozilla/5.0 ')) {\n const NAME = 'jose';\n const VERSION = 'v6.1.0';\n USER_AGENT = `${NAME}/${VERSION}`;\n}\nexport const customFetch = Symbol();\nasync function fetchJwks(url, headers, signal, fetchImpl = fetch) {\n const response = await fetchImpl(url, {\n method: 'GET',\n signal,\n redirect: 'manual',\n headers,\n }).catch((err) => {\n if (err.name === 'TimeoutError') {\n throw new JWKSTimeout();\n }\n throw err;\n });\n if (response.status !== 200) {\n throw new JOSEError('Expected 200 OK from the JSON Web Key Set HTTP response');\n }\n try {\n return await response.json();\n }\n catch {\n throw new JOSEError('Failed to parse the JSON Web Key Set HTTP response as JSON');\n }\n}\nexport const jwksCache = Symbol();\nfunction isFreshJwksCache(input, cacheMaxAge) {\n if (typeof input !== 'object' || input === null) {\n return false;\n }\n if (!('uat' in input) || typeof input.uat !== 'number' || Date.now() - input.uat >= cacheMaxAge) {\n return false;\n }\n if (!('jwks' in input) ||\n !isObject(input.jwks) ||\n !Array.isArray(input.jwks.keys) ||\n !Array.prototype.every.call(input.jwks.keys, isObject)) {\n return false;\n }\n return true;\n}\nclass RemoteJWKSet {\n #url;\n #timeoutDuration;\n #cooldownDuration;\n #cacheMaxAge;\n #jwksTimestamp;\n #pendingFetch;\n #headers;\n #customFetch;\n #local;\n #cache;\n constructor(url, options) {\n if (!(url instanceof URL)) {\n throw new TypeError('url must be an instance of URL');\n }\n this.#url = new URL(url.href);\n this.#timeoutDuration =\n typeof options?.timeoutDuration === 'number' ? options?.timeoutDuration : 5000;\n this.#cooldownDuration =\n typeof options?.cooldownDuration === 'number' ? options?.cooldownDuration : 30000;\n this.#cacheMaxAge = typeof options?.cacheMaxAge === 'number' ? options?.cacheMaxAge : 600000;\n this.#headers = new Headers(options?.headers);\n if (USER_AGENT && !this.#headers.has('User-Agent')) {\n this.#headers.set('User-Agent', USER_AGENT);\n }\n if (!this.#headers.has('accept')) {\n this.#headers.set('accept', 'application/json');\n this.#headers.append('accept', 'application/jwk-set+json');\n }\n this.#customFetch = options?.[customFetch];\n if (options?.[jwksCache] !== undefined) {\n this.#cache = options?.[jwksCache];\n if (isFreshJwksCache(options?.[jwksCache], this.#cacheMaxAge)) {\n this.#jwksTimestamp = this.#cache.uat;\n this.#local = createLocalJWKSet(this.#cache.jwks);\n }\n }\n }\n pendingFetch() {\n return !!this.#pendingFetch;\n }\n coolingDown() {\n return typeof this.#jwksTimestamp === 'number'\n ? Date.now() < this.#jwksTimestamp + this.#cooldownDuration\n : false;\n }\n fresh() {\n return typeof this.#jwksTimestamp === 'number'\n ? Date.now() < this.#jwksTimestamp + this.#cacheMaxAge\n : false;\n }\n jwks() {\n return this.#local?.jwks();\n }\n async getKey(protectedHeader, token) {\n if (!this.#local || !this.fresh()) {\n await this.reload();\n }\n try {\n return await this.#local(protectedHeader, token);\n }\n catch (err) {\n if (err instanceof JWKSNoMatchingKey) {\n if (this.coolingDown() === false) {\n await this.reload();\n return this.#local(protectedHeader, token);\n }\n }\n throw err;\n }\n }\n async reload() {\n if (this.#pendingFetch && isCloudflareWorkers()) {\n this.#pendingFetch = undefined;\n }\n this.#pendingFetch ||= fetchJwks(this.#url.href, this.#headers, AbortSignal.timeout(this.#timeoutDuration), this.#customFetch)\n .then((json) => {\n this.#local = createLocalJWKSet(json);\n if (this.#cache) {\n this.#cache.uat = Date.now();\n this.#cache.jwks = json;\n }\n this.#jwksTimestamp = Date.now();\n this.#pendingFetch = undefined;\n })\n .catch((err) => {\n this.#pendingFetch = undefined;\n throw err;\n });\n await this.#pendingFetch;\n }\n}\nexport function createRemoteJWKSet(url, options) {\n const set = new RemoteJWKSet(url, options);\n const remoteJWKSet = async (protectedHeader, token) => set.getKey(protectedHeader, token);\n Object.defineProperties(remoteJWKSet, {\n coolingDown: {\n get: () => set.coolingDown(),\n enumerable: true,\n configurable: false,\n },\n fresh: {\n get: () => set.fresh(),\n enumerable: true,\n configurable: false,\n },\n reload: {\n value: () => set.reload(),\n enumerable: true,\n configurable: false,\n writable: false,\n },\n reloading: {\n get: () => set.pendingFetch(),\n enumerable: true,\n configurable: false,\n },\n jwks: {\n value: () => set.jwks(),\n enumerable: true,\n configurable: false,\n writable: false,\n },\n });\n return remoteJWKSet;\n}\n","/**\n * Simple logger with debug mode support\n */\nexport class Logger {\n private debug: boolean;\n private prefix: string;\n\n constructor(debug: boolean = false, prefix: string = '[MarketplaceSDK]') {\n this.debug = debug;\n this.prefix = prefix;\n }\n\n /**\n * Log debug message (only if debug enabled)\n */\n log(...args: any[]): void {\n if (this.debug) {\n console.log(this.prefix, ...args);\n }\n }\n\n /**\n * Log info message (only if debug enabled)\n */\n info(...args: any[]): void {\n if (this.debug) {\n console.info(this.prefix, ...args);\n }\n }\n\n /**\n * Log warning message (always shown)\n */\n warn(...args: any[]): void {\n console.warn(this.prefix, ...args);\n }\n\n /**\n * Log error message (always shown)\n */\n error(...args: any[]): void {\n console.error(this.prefix, ...args);\n }\n}\n","import { createRemoteJWKSet, jwtVerify, JWTVerifyResult, JWTPayload } from 'jose';\nimport { SDKError, JWTClaims } from '../types';\nimport { Logger } from '../utils/logger';\n\n/**\n * JWKS Validator for RS256 JWT signature verification\n * Uses jose library for browser and Node.js compatibility\n */\nexport class JWKSValidator {\n private jwksUri: string;\n private logger: Logger;\n private jwks: ReturnType<typeof createRemoteJWKSet>;\n\n constructor(jwksUri: string, debug: boolean = false) {\n this.jwksUri = jwksUri;\n this.logger = new Logger(debug, '[JWKSValidator]');\n\n // Create JWKS fetcher (works in browser and Node.js)\n // Resolve relative URIs against the page origin in browser environments\n const resolvedUrl = this.jwksUri.startsWith('http')\n ? new URL(this.jwksUri)\n : new URL(this.jwksUri, typeof window !== 'undefined' ? window.location.origin : undefined);\n this.jwks = createRemoteJWKSet(resolvedUrl);\n\n this.logger.info('Initialized with JWKS URI:', this.jwksUri);\n }\n\n /**\n * Verify JWT signature using JWKS public key\n * @param token - JWT token to verify\n * @param expectedIssuer - Expected issuer (default: 'generalwisdom.com')\n * @param expectedApplicationId - Optional application ID to validate\n * @returns Decoded and verified JWT claims\n */\n async verify(\n token: string,\n expectedIssuer: string = 'generalwisdom.com',\n expectedApplicationId?: string\n ): Promise<JWTClaims> {\n this.logger.log('Verifying JWT signature...');\n\n try {\n // Verify JWT using JWKS\n const result: JWTVerifyResult = await jwtVerify(token, this.jwks, {\n issuer: expectedIssuer,\n algorithms: ['RS256'],\n });\n\n const payload = result.payload as JWTPayload & Partial<JWTClaims>;\n\n // Validate required claims\n const requiredClaims: (keyof JWTClaims)[] = [\n 'sessionId',\n 'userId',\n 'orgId',\n 'applicationId',\n 'exp',\n 'iat',\n ];\n\n for (const claim of requiredClaims) {\n if (!(claim in payload)) {\n throw new SDKError(\n `Missing required claim: ${claim}`,\n 'MISSING_CLAIM'\n );\n }\n }\n\n // Validate application ID if provided\n if (expectedApplicationId && payload.applicationId !== expectedApplicationId) {\n this.logger.error(\n `Application ID mismatch: expected ${expectedApplicationId}, got ${payload.applicationId}`\n );\n throw new SDKError(\n 'Token is for a different application',\n 'APPLICATION_MISMATCH'\n );\n }\n\n const claims: JWTClaims = {\n sessionId: payload.sessionId!,\n applicationId: payload.applicationId!,\n userId: payload.userId!,\n orgId: payload.orgId!,\n startTime: payload.startTime!,\n durationMinutes: payload.durationMinutes!,\n iat: payload.iat!,\n exp: payload.exp!,\n iss: payload.iss!,\n sub: payload.sub!,\n };\n\n this.logger.log('JWT verified successfully');\n return claims;\n\n } catch (error) {\n this.logger.error('JWT verification failed:', error);\n\n if (error instanceof SDKError) {\n throw error;\n }\n\n // Handle jose-specific errors\n const errorMessage = error instanceof Error ? error.message : 'Unknown error';\n const errorName = error instanceof Error ? error.name : 'Error';\n\n if (errorName === 'JWTExpired' || errorMessage.includes('expired')) {\n throw new SDKError('Session expired', 'SESSION_EXPIRED');\n }\n\n if (errorName === 'JWSSignatureVerificationFailed') {\n throw new SDKError('Invalid JWT signature', 'INVALID_SIGNATURE');\n }\n\n if (errorName === 'JWTClaimValidationFailed') {\n throw new SDKError(`JWT claim validation failed: ${errorMessage}`, 'INVALID_CLAIM');\n }\n\n throw new SDKError(\n `JWT verification failed: ${errorMessage}`,\n 'VERIFICATION_FAILED'\n );\n }\n }\n\n /**\n * Update JWKS URI\n * @param jwksUri - New JWKS URI\n */\n updateJwksUri(jwksUri: string): void {\n this.jwksUri = jwksUri;\n const resolvedUrl = this.jwksUri.startsWith('http')\n ? new URL(this.jwksUri)\n : new URL(this.jwksUri, typeof window !== 'undefined' ? window.location.origin : undefined);\n this.jwks = createRemoteJWKSet(resolvedUrl);\n this.logger.info('Updated JWKS URI:', this.jwksUri);\n }\n}\n","import { Logger } from '../utils/logger';\nimport { SDKEvents } from '../types';\n\n/**\n * Timer Manager for session countdown\n */\nexport class TimerManager {\n private remainingSeconds: number;\n private intervalId: number | null = null;\n private warningThreshold: number;\n private warningShown: boolean = false;\n private logger: Logger;\n private events: Partial<SDKEvents>;\n\n constructor(\n durationSeconds: number,\n warningThresholdSeconds: number = 300,\n events: Partial<SDKEvents> = {},\n debug: boolean = false\n ) {\n this.remainingSeconds = durationSeconds;\n this.warningThreshold = warningThresholdSeconds;\n this.events = events;\n this.logger = new Logger(debug, '[TimerManager]');\n\n this.logger.log('Initialized with duration:', durationSeconds, 'seconds');\n }\n\n /**\n * Start countdown timer\n */\n start(): void {\n if (this.intervalId !== null) {\n this.logger.warn('Timer already running');\n return;\n }\n\n this.logger.log('Starting timer with', this.remainingSeconds, 'seconds remaining');\n\n this.intervalId = window.setInterval(() => {\n this.remainingSeconds--;\n\n // Check for warning threshold\n if (\n !this.warningShown &&\n this.remainingSeconds <= this.warningThreshold &&\n this.remainingSeconds > 0\n ) {\n this.warningShown = true;\n this.logger.warn('Warning threshold reached:', this.remainingSeconds, 'seconds remaining');\n this.events.onSessionWarning?.({\n remainingSeconds: this.remainingSeconds,\n });\n }\n\n // Check for expiration\n if (this.remainingSeconds <= 0) {\n this.logger.warn('Session expired');\n this.stop();\n this.events.onSessionEnd?.();\n }\n }, 1000);\n }\n\n /**\n * Stop timer\n */\n stop(): void {\n if (this.intervalId !== null) {\n clearInterval(this.intervalId);\n this.intervalId = null;\n this.logger.log('Timer stopped');\n }\n }\n\n /**\n * Pause timer\n */\n pause(): void {\n this.stop();\n this.logger.log('Timer paused at:', this.remainingSeconds, 'seconds');\n }\n\n /**\n * Resume timer\n */\n resume(): void {\n if (this.intervalId === null && this.remainingSeconds > 0) {\n this.start();\n this.logger.log('Timer resumed at:', this.remainingSeconds, 'seconds');\n }\n }\n\n /**\n * Get remaining time in seconds\n */\n getRemainingSeconds(): number {\n return this.remainingSeconds;\n }\n\n /**\n * Get formatted time string (MM:SS)\n */\n getFormattedTime(): string {\n const minutes = Math.floor(this.remainingSeconds / 60);\n const seconds = this.remainingSeconds % 60;\n return `${minutes}:${seconds.toString().padStart(2, '0')}`;\n }\n\n /**\n * Get formatted time string with hours (HH:MM:SS)\n */\n getFormattedTimeWithHours(): string {\n const hours = Math.floor(this.remainingSeconds / 3600);\n const minutes = Math.floor((this.remainingSeconds % 3600) / 60);\n const seconds = this.remainingSeconds % 60;\n\n if (hours > 0) {\n return `${hours}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;\n }\n\n return this.getFormattedTime();\n }\n\n /**\n * Check if timer is running\n */\n isRunning(): boolean {\n return this.intervalId !== null;\n }\n\n /**\n * Check if warning has been shown\n */\n hasWarningBeenShown(): boolean {\n return this.warningShown;\n }\n\n /**\n * Update remaining time (useful for syncing with server)\n */\n updateRemainingTime(seconds: number): void {\n this.remainingSeconds = seconds;\n this.logger.log('Remaining time updated to:', seconds, 'seconds');\n }\n}\n","import { Logger } from '../utils/logger';\nimport { SDKError } from '../types';\n\n/**\n * Heartbeat Manager for active session tracking\n * Phase 2 Feature - Sends periodic heartbeats to backend\n */\nexport class HeartbeatManager {\n private intervalId: number | null = null;\n private heartbeatInterval: number;\n private failureCount: number = 0;\n private maxFailures: number = 3;\n private isEnabled: boolean = false;\n private logger: Logger;\n\n constructor(\n private sessionId: string,\n private apiEndpoint: string,\n private token: string,\n private onSync?: (remainingSeconds: number) => void,\n private onError?: (error: Error) => void,\n heartbeatIntervalSeconds: number = 30,\n debug: boolean = false\n ) {\n this.heartbeatInterval = heartbeatIntervalSeconds * 1000;\n this.logger = new Logger(debug, '[HeartbeatManager]');\n this.logger.log('Initialized with', heartbeatIntervalSeconds, 'second interval');\n }\n\n /**\n * Start sending heartbeats\n */\n start(): void {\n if (this.intervalId !== null) {\n this.logger.warn('Heartbeat already running');\n return;\n }\n\n this.isEnabled = true;\n this.logger.log('Starting heartbeat for session:', this.sessionId);\n\n // Send initial heartbeat immediately\n this.sendHeartbeat();\n\n // Then send periodically\n this.intervalId = window.setInterval(() => {\n this.sendHeartbeat();\n }, this.heartbeatInterval);\n }\n\n /**\n * Stop sending heartbeats\n */\n stop(): void {\n if (this.intervalId !== null) {\n clearInterval(this.intervalId);\n this.intervalId = null;\n this.isEnabled = false;\n this.logger.log('Heartbeat stopped');\n }\n }\n\n /**\n * Send a single heartbeat to backend\n */\n private async sendHeartbeat(): Promise<void> {\n if (!this.isEnabled) {\n return;\n }\n\n this.logger.log('Sending heartbeat...');\n\n try {\n const response = await fetch(\n `${this.apiEndpoint}/sessions/${this.sessionId}/heartbeat`,\n {\n method: 'POST',\n headers: {\n 'Authorization': `Bearer ${this.token}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n timestamp: Date.now(),\n active: true,\n }),\n }\n );\n\n if (!response.ok) {\n throw new SDKError(\n `Heartbeat failed with status ${response.status}`,\n 'HEARTBEAT_FAILED',\n response.status\n );\n }\n\n const data = await response.json();\n\n // Reset failure count on success\n this.failureCount = 0;\n\n // Sync remaining time with server\n if (typeof data.remaining_seconds === 'number') {\n this.logger.log('Server reports', data.remaining_seconds, 'seconds remaining');\n this.onSync?.(data.remaining_seconds);\n }\n\n this.logger.log('Heartbeat acknowledged');\n\n } catch (error) {\n this.failureCount++;\n this.logger.error('Heartbeat failed:', error, `(${this.failureCount}/${this.maxFailures})`);\n\n if (this.failureCount >= this.maxFailures) {\n this.logger.error('Max heartbeat failures reached, stopping');\n this.stop();\n\n const sdkError = error instanceof SDKError ? error : new SDKError(\n error instanceof Error ? error.message : 'Heartbeat failed',\n 'HEARTBEAT_ERROR'\n );\n this.onError?.(sdkError);\n }\n }\n }\n\n /**\n * Check if heartbeat is running\n */\n isRunning(): boolean {\n return this.intervalId !== null;\n }\n\n /**\n * Get failure count\n */\n getFailureCount(): number {\n return this.failureCount;\n }\n\n /**\n * Update heartbeat interval\n */\n updateInterval(seconds: number): void {\n const wasRunning = this.isRunning();\n\n if (wasRunning) {\n this.stop();\n }\n\n this.heartbeatInterval = seconds * 1000;\n this.logger.log('Heartbeat interval updated to', seconds, 'seconds');\n\n if (wasRunning) {\n this.start();\n }\n }\n}\n","import { Logger } from '../utils/logger';\n\nexport interface TabSyncMessage {\n type: 'timer_update' | 'pause' | 'resume' | 'end';\n sessionId: string;\n remainingSeconds?: number;\n timestamp: number;\n}\n\n/**\n * Tab Synchronization Manager\n * Phase 2 Feature - Syncs session state across multiple tabs\n */\nexport class TabSyncManager {\n private channel: BroadcastChannel | null = null;\n private storageKey: string;\n private logger: Logger;\n private isMaster: boolean = false;\n\n constructor(\n private sessionId: string,\n private onMessage: (message: TabSyncMessage) => void,\n debug: boolean = false\n ) {\n this.storageKey = `gw_session_sync_${sessionId}`;\n this.logger = new Logger(debug, '[TabSyncManager]');\n\n this.initialize();\n }\n\n /**\n * Initialize sync mechanism\n */\n private initialize(): void {\n // Try BroadcastChannel API first (modern browsers)\n if (typeof BroadcastChannel !== 'undefined') {\n this.logger.log('Using BroadcastChannel for tab sync');\n this.channel = new BroadcastChannel(`gw-session-${this.sessionId}`);\n this.channel.onmessage = (event) => {\n this.handleMessage(event.data);\n };\n } else {\n // Fallback to localStorage events (older browsers)\n this.logger.log('Using localStorage for tab sync (fallback)');\n window.addEventListener('storage', this.handleStorageEvent);\n }\n\n // Elect this tab as master if no other tab exists\n this.electMaster();\n }\n\n /**\n * Broadcast message to other tabs\n */\n broadcast(type: TabSyncMessage['type'], data?: Partial<TabSyncMessage>): void {\n const message: TabSyncMessage = {\n type,\n sessionId: this.sessionId,\n timestamp: Date.now(),\n ...data,\n };\n\n if (this.channel) {\n this.channel.postMessage(message);\n this.logger.log('Broadcasted:', type);\n } else {\n // Fallback: use localStorage\n localStorage.setItem(this.storageKey, JSON.stringify(message));\n this.logger.log('Broadcasted via localStorage:', type);\n }\n }\n\n /**\n * Handle incoming message\n */\n private handleMessage(data: TabSyncMessage): void {\n if (data.sessionId !== this.sessionId) {\n return; // Ignore messages for other sessions\n }\n\n this.logger.log('Received message:', data.type);\n this.onMessage(data);\n }\n\n /**\n * Handle storage event (fallback mechanism)\n */\n private handleStorageEvent = (event: StorageEvent): void => {\n if (event.key === this.storageKey && event.newValue) {\n try {\n const data = JSON.parse(event.newValue) as TabSyncMessage;\n this.handleMessage(data);\n } catch (error) {\n this.logger.error('Failed to parse storage event:', error);\n }\n }\n };\n\n /**\n * Elect this tab as master if appropriate\n * Master tab is responsible for heartbeats\n */\n private electMaster(): void {\n const masterKey = `gw_session_master_${this.sessionId}`;\n const existingMaster = localStorage.getItem(masterKey);\n\n if (!existingMaster) {\n // No master exists, become master\n this.isMaster = true;\n localStorage.setItem(masterKey, Date.now().toString());\n this.logger.log('Elected as master tab');\n\n // Set up heartbeat to maintain master status\n setInterval(() => {\n if (this.isMaster) {\n localStorage.setItem(masterKey, Date.now().toString());\n }\n }, 5000);\n\n // Clear master status on unload\n window.addEventListener('beforeunload', () => {\n if (this.isMaster) {\n localStorage.removeItem(masterKey);\n this.logger.log('Removed master status');\n }\n });\n } else {\n this.logger.log('Another tab is master');\n\n // Check periodically if master is still alive\n setInterval(() => {\n const masterTimestamp = localStorage.getItem(masterKey);\n if (masterTimestamp) {\n const age = Date.now() - parseInt(masterTimestamp);\n if (age > 10000) {\n // Master hasn't updated in 10s, assume dead\n this.logger.warn('Master tab appears dead, becoming master');\n this.isMaster = true;\n localStorage.setItem(masterKey, Date.now().toString());\n }\n }\n }, 5000);\n }\n }\n\n /**\n * Check if this tab is the master\n */\n isMasterTab(): boolean {\n return this.isMaster;\n }\n\n /**\n * Cleanup and destroy\n */\n destroy(): void {\n if (this.channel) {\n this.channel.close();\n this.channel = null;\n } else {\n window.removeEventListener('storage', this.handleStorageEvent);\n }\n\n // Clean up storage\n localStorage.removeItem(this.storageKey);\n\n if (this.isMaster) {\n localStorage.removeItem(`gw_session_master_${this.sessionId}`);\n }\n\n this.logger.log('Tab sync destroyed');\n }\n}\n","/**\n * Theme configuration matching the General Wisdom SPA design system\n * Based on gw-spa/src/styles/globals.css and Tailwind CSS v4\n */\n\nexport interface ThemeColors {\n // Background colors\n background: string;\n foreground: string;\n\n // Card colors\n card: string;\n cardForeground: string;\n\n // Popover colors\n popover: string;\n popoverForeground: string;\n\n // Primary colors (brand blue)\n primary: string;\n primaryForeground: string;\n\n // Secondary colors (light gray)\n secondary: string;\n secondaryForeground: string;\n\n // Muted colors\n muted: string;\n mutedForeground: string;\n\n // Accent colors\n accent: string;\n accentForeground: string;\n\n // Destructive colors (red for errors/warnings)\n destructive: string;\n destructiveForeground: string;\n\n // Success colors (green for success actions)\n success: string;\n successForeground: string;\n\n // Border and input\n border: string;\n input: string;\n ring: string;\n}\n\nexport interface ThemeTypography {\n fontFamily: string;\n fontSize: {\n xs: string;\n sm: string;\n base: string;\n lg: string;\n xl: string;\n '2xl': string;\n };\n fontWeight: {\n normal: string;\n medium: string;\n semibold: string;\n bold: string;\n };\n lineHeight: {\n tight: string;\n normal: string;\n relaxed: string;\n };\n}\n\nexport interface ThemeSpacing {\n borderRadius: {\n sm: string;\n md: string;\n lg: string;\n };\n padding: {\n sm: string;\n md: string;\n lg: string;\n xl: string;\n };\n gap: {\n sm: string;\n md: string;\n lg: string;\n };\n}\n\nexport interface Theme {\n colors: ThemeColors;\n typography: ThemeTypography;\n spacing: ThemeSpacing;\n}\n\n/**\n * Light theme matching gw-spa design system\n */\nexport const lightTheme: Theme = {\n colors: {\n // Background\n background: 'hsl(0 0% 100%)',\n foreground: 'hsl(222.2 84% 4.9%)',\n\n // Card\n card: 'hsl(0 0% 100%)',\n cardForeground: 'hsl(222.2 84% 4.9%)',\n\n // Popover\n popover: 'hsl(0 0% 100%)',\n popoverForeground: 'hsl(222.2 84% 4.9%)',\n\n // Primary (brand blue)\n primary: 'hsl(221.2 83.2% 53.3%)',\n primaryForeground: 'hsl(210 40% 98%)',\n\n // Secondary (light gray)\n secondary: 'hsl(210 40% 96.1%)',\n secondaryForeground: 'hsl(222.2 47.4% 11.2%)',\n\n // Muted\n muted: 'hsl(210 40% 96.1%)',\n mutedForeground: 'hsl(215.4 16.3% 46.9%)',\n\n // Accent\n accent: 'hsl(210 40% 96.1%)',\n accentForeground: 'hsl(222.2 47.4% 11.2%)',\n\n // Destructive (red)\n destructive: 'hsl(0 84.2% 60.2%)',\n destructiveForeground: 'hsl(210 40% 98%)',\n\n // Success (green)\n success: 'hsl(142 76% 36%)', // Tailwind green-600 equivalent\n successForeground: 'hsl(0 0% 100%)',\n\n // Border and input\n border: 'hsl(214.3 31.8% 91.4%)',\n input: 'hsl(214.3 31.8% 91.4%)',\n ring: 'hsl(221.2 83.2% 53.3%)',\n },\n typography: {\n fontFamily: '-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif',\n fontSize: {\n xs: '12px',\n sm: '14px',\n base: '16px',\n lg: '18px',\n xl: '20px',\n '2xl': '24px',\n },\n fontWeight: {\n normal: '400',\n medium: '500',\n semibold: '600',\n bold: '700',\n },\n lineHeight: {\n tight: '1.25',\n normal: '1.5',\n relaxed: '1.75',\n },\n },\n spacing: {\n borderRadius: {\n sm: '4px', // calc(0.5rem - 4px)\n md: '6px', // calc(0.5rem - 2px)\n lg: '8px', // 0.5rem\n },\n padding: {\n sm: '8px',\n md: '16px',\n lg: '24px',\n xl: '32px',\n },\n gap: {\n sm: '8px',\n md: '12px',\n lg: '16px',\n },\n },\n};\n\n/**\n * Dark theme matching gw-spa design system\n */\nexport const darkTheme: Theme = {\n colors: {\n // Background\n background: 'hsl(222.2 84% 4.9%)',\n foreground: 'hsl(210 40% 98%)',\n\n // Card\n card: 'hsl(222.2 84% 4.9%)',\n cardForeground: 'hsl(210 40% 98%)',\n\n // Popover\n popover: 'hsl(222.2 84% 4.9%)',\n popoverForeground: 'hsl(210 40% 98%)',\n\n // Primary (lighter blue for dark mode)\n primary: 'hsl(217.2 91.2% 59.8%)',\n primaryForeground: 'hsl(222.2 47.4% 11.2%)',\n\n // Secondary (dark gray)\n secondary: 'hsl(217.2 32.6% 17.5%)',\n secondaryForeground: 'hsl(210 40% 98%)',\n\n // Muted\n muted: 'hsl(217.2 32.6% 17.5%)',\n mutedForeground: 'hsl(215 20.2% 65.1%)',\n\n // Accent\n accent: 'hsl(217.2 32.6% 17.5%)',\n accentForeground: 'hsl(210 40% 98%)',\n\n // Destructive (darker red for dark mode)\n destructive: 'hsl(0 62.8% 30.6%)',\n destructiveForeground: 'hsl(210 40% 98%)',\n\n // Success (darker green for dark mode)\n success: 'hsl(142 71% 45%)', // Tailwind green-500 equivalent\n successForeground: 'hsl(0 0% 100%)',\n\n // Border and input\n border: 'hsl(217.2 32.6% 17.5%)',\n input: 'hsl(217.2 32.6% 17.5%)',\n ring: 'hsl(224.3 76.3% 48%)',\n },\n typography: {\n fontFamily: '-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif',\n fontSize: {\n xs: '12px',\n sm: '14px',\n base: '16px',\n lg: '18px',\n xl: '20px',\n '2xl': '24px',\n },\n fontWeight: {\n normal: '400',\n medium: '500',\n semibold: '600',\n bold: '700',\n },\n lineHeight: {\n tight: '1.25',\n normal: '1.5',\n relaxed: '1.75',\n },\n },\n spacing: {\n borderRadius: {\n sm: '4px',\n md: '6px',\n lg: '8px',\n },\n padding: {\n sm: '8px',\n md: '16px',\n lg: '24px',\n xl: '32px',\n },\n gap: {\n sm: '8px',\n md: '12px',\n lg: '16px',\n },\n },\n};\n\n/**\n * Get theme based on user preference or system setting\n */\nexport function getTheme(prefersDark?: boolean): Theme {\n // Check for explicit preference\n if (prefersDark !== undefined) {\n return prefersDark ? darkTheme : lightTheme;\n }\n\n // Check system preference\n if (typeof window !== 'undefined' && window.matchMedia) {\n const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches;\n return isDarkMode ? darkTheme : lightTheme;\n }\n\n // Default to light theme\n return lightTheme;\n}\n\n/**\n * Generate CSS string from theme colors for inline styles\n */\nexport function generateCSSVariables(theme: Theme): string {\n return `\n --gw-background: ${theme.colors.background};\n --gw-foreground: ${theme.colors.foreground};\n --gw-card: ${theme.colors.card};\n --gw-card-foreground: ${theme.colors.cardForeground};\n --gw-primary: ${theme.colors.primary};\n --gw-primary-foreground: ${theme.colors.primaryForeground};\n --gw-secondary: ${theme.colors.secondary};\n --gw-secondary-foreground: ${theme.colors.secondaryForeground};\n --gw-muted: ${theme.colors.muted};\n --gw-muted-foreground: ${theme.colors.mutedForeground};\n --gw-accent: ${theme.colors.accent};\n --gw-accent-foreground: ${theme.colors.accentForeground};\n --gw-destructive: ${theme.colors.destructive};\n --gw-destructive-foreground: ${theme.colors.destructiveForeground};\n --gw-success: ${theme.colors.success};\n --gw-success-foreground: ${theme.colors.successForeground};\n --gw-border: ${theme.colors.border};\n --gw-input: ${theme.colors.input};\n --gw-ring: ${theme.colors.ring};\n `.trim();\n}\n","import { ModalStyles, ThemeMode } from '../types';\nimport { getTheme, Theme } from '../styles/theme';\n\n/**\n * Warning Modal for session expiration alerts\n */\nexport class WarningModal {\n private modal: HTMLDivElement | null = null;\n private theme: Theme;\n private legacyStyles: ModalStyles | null = null;\n private updateInterval: number | null = null;\n private timeDisplay: HTMLElement | null = null;\n private startTime: number = 0;\n private initialSeconds: number = 0;\n private onEndCallback: (() => void) | undefined = undefined;\n\n constructor(themeMode: ThemeMode = 'light', customStyles?: Partial<ModalStyles>) {\n // Use new theme system\n const prefersDark = themeMode === 'dark' || (themeMode === 'auto' && this.detectDarkMode());\n this.theme = getTheme(prefersDark);\n\n // Keep legacy styles for backward compatibility\n if (customStyles) {\n this.legacyStyles = {\n backgroundColor: customStyles.backgroundColor || '#ffffff',\n textColor: customStyles.textColor || '#333333',\n primaryColor: customStyles.primaryColor || '#007bff',\n borderRadius: customStyles.borderRadius || '8px',\n fontFamily:\n customStyles.fontFamily ||\n '-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif',\n };\n }\n }\n\n private detectDarkMode(): boolean {\n if (typeof window !== 'undefined' && window.matchMedia) {\n return window.matchMedia('(prefers-color-scheme: dark)').matches;\n }\n return false;\n }\n\n /**\n * Show warning modal\n */\n show(options: {\n remainingSeconds: number;\n onExtend?: () => void;\n onEnd?: () => void;\n }): void {\n // Remove existing modal if any\n this.hide();\n\n // Create modal\n this.modal = document.createElement('div');\n this.modal.id = 'gw-session-warning-modal';\n this.modal.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.5);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 99999;\n font-family: ${this.legacyStyles?.fontFamily || this.theme.typography.fontFamily};\n `;\n\n // Create modal content\n const content = document.createElement('div');\n const bgColor = this.legacyStyles?.backgroundColor || this.theme.colors.card;\n const textColor = this.legacyStyles?.textColor || this.theme.colors.cardForeground;\n const borderRadius = this.legacyStyles?.borderRadius || this.theme.spacing.borderRadius.lg;\n\n content.style.cssText = `\n background-color: ${bgColor};\n color: ${textColor};\n border-radius: ${borderRadius};\n padding: ${this.theme.spacing.padding.lg};\n max-width: 400px;\n width: 90%;\n box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);\n border: 1px solid ${this.theme.colors.border};\n `;\n\n this.initialSeconds = options.remainingSeconds;\n this.startTime = Date.now();\n this.onEndCallback = options.onEnd;\n\n const minutes = Math.floor(options.remainingSeconds / 60);\n const seconds = options.remainingSeconds % 60;\n\n content.innerHTML = `\n <h2 style=\"margin: 0 0 ${this.theme.spacing.padding.md} 0; font-size: ${this.theme.typography.fontSize.xl}; font-weight: ${this.theme.typography.fontWeight.semibold}; color: ${textColor};\">\n ⏱️ Time Running Low\n </h2>\n <p style=\"margin: 0 0 ${this.theme.spacing.padding.lg} 0; font-size: ${this.theme.typography.fontSize.base}; line-height: ${this.theme.typography.lineHeight.normal}; color: ${this.theme.colors.mutedForeground};\">\n Your session will expire in <strong id=\"gw-time-display\" style=\"color: ${textColor};\">${minutes}:${seconds.toString().padStart(2, '0')}</strong>.\n </p>\n <div style=\"display: flex; gap: ${this.theme.spacing.gap.md}; justify-content: flex-end;\">\n <button id=\"gw-dismiss-btn\" style=\"\n padding: 10px 20px;\n background-color: ${this.theme.colors.secondary};\n color: ${this.theme.colors.secondaryForeground};\n border: 1px solid ${this.theme.colors.border};\n border-radius: ${this.theme.spacing.borderRadius.sm};\n font-size: ${this.theme.typography.fontSize.sm};\n font-weight: ${this.theme.typography.fontWeight.medium};\n cursor: pointer;\n transition: all 0.2s;\n font-family: ${this.theme.typography.fontFamily};\n \">\n Continue\n </button>\n ${\n options.onExtend\n ? `<button id=\"gw-extend-btn\" style=\"\n padding: 10px 20px;\n background-color: ${this.theme.colors.success};\n color: ${this.theme.colors.successForeground};\n border: none;\n border-radius: ${this.theme.spacing.borderRadius.sm};\n font-size: ${this.theme.typography.fontSize.sm};\n font-weight: ${this.theme.typography.fontWeight.medium};\n cursor: pointer;\n transition: all 0.2s;\n font-family: ${this.theme.typography.fontFamily};\n \">\n Extend Session\n </button>`\n : ''\n }\n ${\n options.onEnd\n ? `<button id=\"gw-end-btn\" style=\"\n padding: 10px 20px;\n background-color: ${this.theme.colors.destructive};\n color: ${this.theme.colors.destructiveForeground};\n border: none;\n border-radius: ${this.theme.spacing.borderRadius.sm};\n font-size: ${this.theme.typography.fontSize.sm};\n font-weight: ${this.theme.typography.fontWeight.medium};\n cursor: pointer;\n transition: all 0.2s;\n font-family: ${this.theme.typography.fontFamily};\n \">\n End Session\n </button>`\n : ''\n }\n </div>\n `;\n\n this.modal.appendChild(content);\n document.body.appendChild(this.modal);\n\n // Add event listeners\n const extendBtn = document.getElementById('gw-extend-btn');\n if (extendBtn && options.onExtend) {\n extendBtn.addEventListener('click', () => {\n options.onExtend?.();\n this.hide();\n });\n }\n\n const dismissBtn = document.getElementById('gw-dismiss-btn');\n if (dismissBtn) {\n dismissBtn.addEventListener('click', () => {\n this.hide();\n });\n }\n\n const endBtn = document.getElementById('gw-end-btn');\n if (endBtn && options.onEnd) {\n endBtn.addEventListener('click', () => {\n options.onEnd?.();\n // Don't call this.hide() here - the onEnd callback will handle showing\n // the ending modal, and calling hide() would remove it immediately\n });\n }\n\n // Add hover effects\n const buttons = content.querySelectorAll('button');\n buttons.forEach((button) => {\n button.addEventListener('mouseenter', () => {\n (button as HTMLElement).style.opacity = '0.9';\n });\n button.addEventListener('mouseleave', () => {\n (button as HTMLElement).style.opacity = '1';\n });\n // Add focus ring\n button.addEventListener('focus', () => {\n (button as HTMLElement).style.outline = `2px solid ${this.theme.colors.ring}`;\n (button as HTMLElement).style.outlineOffset = '2px';\n });\n button.addEventListener('blur', () => {\n (button as HTMLElement).style.outline = 'none';\n });\n });\n\n // Start updating the timer display\n this.timeDisplay = document.getElementById('gw-time-display');\n this.updateInterval = window.setInterval(() => {\n const elapsed = Math.floor((Date.now() - this.startTime) / 1000);\n const remaining = Math.max(0, this.initialSeconds - elapsed);\n\n const minutes = Math.floor(remaining / 60);\n const seconds = remaining % 60;\n\n if (this.timeDisplay) {\n this.timeDisplay.textContent = `${minutes}:${seconds.toString().padStart(2, '0')}`;\n }\n\n // If time runs out, trigger session end if callback exists\n if (remaining === 0) {\n if (this.onEndCallback) {\n this.onEndCallback();\n }\n this.hide();\n }\n }, 1000);\n }\n\n /**\n * Hide and remove modal\n */\n hide(): void {\n // Clear the update interval\n if (this.updateInterval !== null) {\n clearInterval(this.updateInterval);\n this.updateInterval = null;\n }\n\n // Remove modal from DOM\n if (this.modal && this.modal.parentNode) {\n this.modal.parentNode.removeChild(this.modal);\n this.modal = null;\n this.timeDisplay = null;\n }\n }\n\n /**\n * Check if modal is currently shown\n */\n isShown(): boolean {\n return this.modal !== null;\n }\n\n /**\n * Show \"Session Ending\" modal before redirect\n * Displays for a fixed duration (3 seconds) then calls callback\n */\n showEndingMessage(onComplete: () => void, durationMs: number = 3000): void {\n // Hide any existing modal first\n this.hide();\n\n const bgColor = this.legacyStyles?.backgroundColor || this.theme.colors.card;\n const textColor = this.legacyStyles?.textColor || this.theme.colors.cardForeground;\n const borderRadius = this.legacyStyles?.borderRadius || this.theme.spacing.borderRadius.lg;\n\n // Create modal overlay\n this.modal = document.createElement('div');\n this.modal.id = 'gw-session-ending-modal';\n this.modal.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.5);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 99999;\n font-family: ${this.legacyStyles?.fontFamily || this.theme.typography.fontFamily};\n animation: fadeIn 0.2s ease-in;\n `;\n\n // Create modal content\n const content = document.createElement('div');\n content.style.cssText = `\n background-color: ${bgColor};\n color: ${textColor};\n border-radius: ${borderRadius};\n padding: ${this.theme.spacing.padding.xl};\n max-width: 400px;\n width: 90%;\n box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);\n text-align: center;\n animation: slideIn 0.3s ease-out;\n border: 1px solid ${this.theme.colors.border};\n `;\n\n content.innerHTML = `\n <div style=\"font-size: 48px; margin-bottom: ${this.theme.spacing.padding.lg};\">⏱️</div>\n <h2 style=\"margin: 0 0 ${this.theme.spacing.padding.md} 0; font-size: ${this.theme.typography.fontSize['2xl']}; font-weight: ${this.theme.typography.fontWeight.semibold}; color: ${this.theme.colors.destructive};\">\n Session Ending\n </h2>\n <p style=\"margin: 0 0 ${this.theme.spacing.padding.lg} 0; font-size: ${this.theme.typography.fontSize.base}; line-height: ${this.theme.typography.lineHeight.normal}; color: ${this.theme.colors.mutedForeground};\">\n Your session has expired.<br/>\n Redirecting to marketplace...\n </p>\n <div style=\"\n width: 100%;\n height: 4px;\n background: ${this.theme.colors.muted};\n border-radius: ${this.theme.spacing.borderRadius.sm};\n overflow: hidden;\n margin-top: ${this.theme.spacing.padding.lg};\n \">\n <div id=\"gw-progress-bar\" style=\"\n width: 100%;\n height: 100%;\n background: linear-gradient(90deg, ${this.theme.colors.destructive}, ${this.theme.colors.primary});\n animation: progressBar ${durationMs}ms linear forwards;\n \"></div>\n </div>\n `;\n\n // Add animations\n const style = document.createElement('style');\n style.textContent = `\n @keyframes fadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n @keyframes slideIn {\n from { transform: translateY(-20px); opacity: 0; }\n to { transform: translateY(0); opacity: 1; }\n }\n @keyframes progressBar {\n from { width: 100%; }\n to { width: 0%; }\n }\n `;\n document.head.appendChild(style);\n\n this.modal.appendChild(content);\n document.body.appendChild(this.modal);\n\n // Call callback after duration\n setTimeout(() => {\n this.hide();\n onComplete();\n }, durationMs);\n }\n}\n","import { SDKError } from '../types';\n\n/**\n * Extract JWT token from URL parameter\n * @param paramName - URL parameter name (default: 'gwSession')\n * @param url - URL to extract from (default: window.location.href)\n * @returns JWT token or null if not found\n */\nexport function extractTokenFromURL(\n paramName: string = 'gwSession',\n url?: string\n): string | null {\n try {\n const targetUrl = url || (typeof window !== 'undefined' ? window.location.href : '');\n\n if (!targetUrl) {\n return null;\n }\n\n const urlObj = new URL(targetUrl);\n const token = urlObj.searchParams.get(paramName);\n\n return token;\n } catch (error) {\n throw new SDKError(\n `Failed to extract token from URL: ${error instanceof Error ? error.message : 'Unknown error'}`,\n 'URL_PARSE_ERROR'\n );\n }\n}\n\n/**\n * Check if code is running in browser environment\n */\nexport function isBrowser(): boolean {\n return typeof window !== 'undefined' && typeof window.document !== 'undefined';\n}\n","import { JWTParser } from './JWTParser';\nimport { JWKSValidator } from './JWKSValidator';\nimport { TimerManager } from './TimerManager';\nimport { HeartbeatManager } from './HeartbeatManager';\nimport { TabSyncManager, TabSyncMessage } from './TabSyncManager';\nimport { WarningModal } from '../ui/WarningModal';\nimport { extractTokenFromURL } from '../utils/url';\nimport { Logger } from '../utils/logger';\nimport { SDKConfig, SDKEvents, SessionData, SDKError, SessionStartContext, SessionEndContext, SessionExtendContext, SessionWarningContext } from '../types';\n\n/**\n * Marketplace SDK with Phase 2 Features\n * - Heartbeat system\n * - Multi-tab synchronization\n * - Visibility API integration\n * - Session extension/completion\n * - Backend validation\n */\nexport class MarketplaceSDK {\n private config: Required<SDKConfig>;\n private validator: JWKSValidator;\n private timer: TimerManager | null = null;\n private heartbeat: HeartbeatManager | null = null;\n private tabSync: TabSyncManager | null = null;\n private modal: WarningModal | null = null;\n private logger: Logger;\n private events: Partial<SDKEvents> = {};\n private sessionData: SessionData | null = null;\n private jwtToken: string | null = null;\n private endReason: 'expired' | 'manual' | 'error' = 'manual';\n\n constructor(config: SDKConfig) {\n this.config = {\n jwksUri: config.jwksUri || 'https://api.generalwisdom.com/.well-known/jwks.json',\n jwtParamName: config.jwtParamName || 'gwSession',\n apiEndpoint: config.apiEndpoint || 'http://localhost:3000',\n debug: config.debug ?? false,\n autoStart: config.autoStart ?? true,\n warningThresholdSeconds: config.warningThresholdSeconds ?? 300,\n customStyles: config.customStyles ?? {},\n themeMode: config.themeMode ?? 'light',\n applicationId: config.applicationId ?? '',\n marketplaceUrl: config.marketplaceUrl ?? 'https://d3p2yqofgy75sz.cloudfront.net/',\n // Phase 2 options\n enableHeartbeat: config.enableHeartbeat ?? false,\n heartbeatIntervalSeconds: config.heartbeatIntervalSeconds ?? 30,\n enableTabSync: config.enableTabSync ?? false,\n pauseOnHidden: config.pauseOnHidden ?? false,\n useBackendValidation: config.useBackendValidation ?? false,\n // Lifecycle hooks\n hooks: config.hooks ?? {},\n hookTimeoutMs: config.hookTimeoutMs ?? 5000,\n };\n\n this.validator = new JWKSValidator(this.config.jwksUri, this.config.debug);\n this.logger = new Logger(this.config.debug, '[MarketplaceSDK]');\n\n this.logger.info('SDK initialized with config:', {\n jwksUri: this.config.jwksUri,\n jwtParamName: this.config.jwtParamName,\n apiEndpoint: this.config.apiEndpoint,\n enableHeartbeat: this.config.enableHeartbeat,\n enableTabSync: this.config.enableTabSync,\n pauseOnHidden: this.config.pauseOnHidden,\n });\n }\n\n /**\n * Register event handlers\n */\n on<K extends keyof SDKEvents>(event: K, handler: SDKEvents[K]): void {\n this.events[event] = handler;\n this.logger.log('Event handler registered:', event);\n }\n\n /**\n * Execute a lifecycle hook with timeout\n */\n private async executeHook<T>(\n hookName: string,\n hook: ((context: T) => Promise<void> | void) | undefined,\n context: T,\n isStrict: boolean = true\n ): Promise<void> {\n if (!hook) return;\n\n this.logger.log(`Calling ${hookName} hook`);\n\n const timeout = new Promise<never>((_, reject) =>\n setTimeout(\n () => reject(new SDKError(`${hookName} hook timeout after ${this.config.hookTimeoutMs}ms`, 'HOOK_TIMEOUT')),\n this.config.hookTimeoutMs\n )\n );\n\n try {\n await Promise.race([\n Promise.resolve(hook(context)),\n timeout\n ]);\n this.logger.log(`${hookName} hook completed successfully`);\n } catch (error) {\n this.logger.error(`${hookName} hook failed:`, error);\n\n if (isStrict) {\n // Strict mode: throw error to prevent session operation\n throw new SDKError(\n `${hookName} hook failed: ${error instanceof Error ? error.message : 'Unknown error'}`,\n 'HOOK_ERROR'\n );\n } else {\n // Lenient mode: log but don't throw\n this.logger.warn(`${hookName} hook failed but continuing (lenient mode)`);\n }\n }\n }\n\n /**\n * Calculate actual session duration in minutes\n */\n private calculateActualDuration(): number | undefined {\n if (!this.sessionData) return undefined;\n const now = Math.floor(Date.now() / 1000);\n const durationSeconds = now - this.sessionData.startTime;\n return Math.ceil(durationSeconds / 60);\n }\n\n /**\n * Initialize SDK and validate session\n */\n async initialize(): Promise<SessionData> {\n this.logger.info('Initializing session...');\n\n try {\n // Extract JWT from URL or retrieve from storage\n const JWT_STORAGE_KEY = 'gw_marketplace_jwt';\n\n // First try URL parameter\n this.jwtToken = extractTokenFromURL(this.config.jwtParamName);\n\n // If not in URL, try storage (for persistence through OAuth redirects)\n if (!this.jwtToken && typeof sessionStorage !== 'undefined') {\n this.jwtToken = sessionStorage.getItem(JWT_STORAGE_KEY);\n if (this.jwtToken) {\n this.logger.log('JWT token retrieved from storage');\n }\n }\n\n // Still no token? Error out\n if (!this.jwtToken) {\n throw new SDKError(\n `No token found in URL parameter '${this.config.jwtParamName}' or storage`,\n 'MISSING_TOKEN'\n );\n }\n\n // Store JWT for persistence through navigation\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.setItem(JWT_STORAGE_KEY, this.jwtToken);\n this.logger.log('JWT token stored in sessionStorage');\n }\n\n this.logger.log('JWT token extracted from URL');\n\n // Validate JWT\n let verifiedClaims;\n if (this.config.useBackendValidation) {\n // Phase 2: Backend validation\n this.logger.log('Using backend validation');\n verifiedClaims = await this.validateWithBackend(this.jwtToken);\n } else {\n // Phase 1: JWKS validation\n this.logger.log('Using JWKS validation');\n verifiedClaims = await this.validator.verify(\n this.jwtToken,\n 'generalwisdom.com',\n this.config.applicationId || undefined\n );\n }\n\n this.logger.log('JWT verified successfully');\n\n // Map to SessionData\n this.sessionData = {\n sessionId: verifiedClaims.sessionId,\n applicationId: verifiedClaims.applicationId,\n userId: verifiedClaims.userId,\n orgId: verifiedClaims.orgId,\n startTime: verifiedClaims.startTime,\n durationMinutes: verifiedClaims.durationMinutes,\n iat: verifiedClaims.iat,\n exp: verifiedClaims.exp,\n iss: verifiedClaims.iss,\n sub: verifiedClaims.sub,\n };\n\n // Calculate remaining time\n const now = Math.floor(Date.now() / 1000);\n const remainingSeconds = Math.max(0, this.sessionData.exp - now);\n\n if (remainingSeconds <= 0) {\n throw new SDKError(\n 'Session has already expired',\n 'SESSION_EXPIRED'\n );\n }\n\n this.logger.log('Remaining time:', remainingSeconds, 'seconds');\n\n // Call onSessionStart hook if provided (STRICT - failure prevents session start)\n if (this.config.hooks?.onSessionStart) {\n const startContext: SessionStartContext = {\n sessionId: this.sessionData.sessionId,\n userId: this.sessionData.userId,\n email: (verifiedClaims as any).email, // May not be in all JWTs\n orgId: this.sessionData.orgId,\n applicationId: this.sessionData.applicationId,\n durationMinutes: this.sessionData.durationMinutes,\n expiresAt: this.sessionData.exp,\n jwt: this.jwtToken!,\n };\n\n await this.executeHook('onSessionStart', this.config.hooks.onSessionStart, startContext, true);\n this.logger.log('Application auth synchronized with marketplace session');\n }\n\n // Initialize timer\n this.timer = new TimerManager(\n remainingSeconds,\n this.config.warningThresholdSeconds,\n {\n onSessionWarning: (data) => {\n // Call warning hook if provided (lenient)\n if (this.config.hooks?.onSessionWarning) {\n const warningContext: SessionWarningContext = {\n sessionId: this.sessionData!.sessionId,\n userId: this.sessionData!.userId,\n remainingSeconds: data.remainingSeconds,\n };\n this.executeHook('onSessionWarning', this.config.hooks.onSessionWarning, warningContext, false)\n .catch(error => this.logger.error('onSessionWarning hook failed:', error));\n }\n\n this.showWarningModal(data.remainingSeconds);\n this.events.onSessionWarning?.(data);\n },\n onSessionEnd: () => {\n this.endReason = 'expired'; // Track that this was an expiration\n this.endSession();\n },\n },\n this.config.debug\n );\n\n // Phase 2: Initialize heartbeat if enabled\n if (this.config.enableHeartbeat && this.jwtToken) {\n this.heartbeat = new HeartbeatManager(\n this.sessionData.sessionId,\n this.config.apiEndpoint,\n this.jwtToken,\n (remainingSeconds) => {\n // Sync timer with server\n this.timer?.updateRemainingTime(remainingSeconds);\n },\n (error) => {\n this.logger.error('Heartbeat error:', error);\n this.events.onError?.(error);\n },\n this.config.heartbeatIntervalSeconds,\n this.config.debug\n );\n }\n\n // Phase 2: Initialize tab sync if enabled\n if (this.config.enableTabSync) {\n this.tabSync = new TabSyncManager(\n this.sessionData.sessionId,\n (message) => this.handleTabSyncMessage(message),\n this.config.debug\n );\n }\n\n // Phase 2: Set up Visibility API if enabled\n if (this.config.pauseOnHidden) {\n this.initializeVisibilityHandling();\n }\n\n // Start timer if autoStart enabled\n if (this.config.autoStart) {\n this.timer.start();\n this.logger.log('Timer started automatically');\n\n // Start heartbeat only if this is the master tab\n if (this.config.enableHeartbeat && this.heartbeat) {\n const isMaster = !this.tabSync || this.tabSync.isMasterTab();\n if (isMaster) {\n this.heartbeat.start();\n this.logger.log('Heartbeat started (master tab)');\n } else {\n this.logger.log('Heartbeat not started (slave tab)');\n }\n }\n }\n\n // Trigger session start event\n this.events.onSessionStart?.(this.sessionData);\n\n this.logger.info('Session initialized successfully');\n return this.sessionData;\n\n } catch (error) {\n this.logger.error('Initialization failed:', error);\n const sdkError = error instanceof SDKError ? error : new SDKError(\n error instanceof Error ? error.message : 'Unknown error',\n 'INITIALIZATION_ERROR'\n );\n this.events.onError?.(sdkError);\n throw sdkError;\n }\n }\n\n /**\n * Phase 2: Validate JWT with backend\n */\n private async validateWithBackend(token: string): Promise<any> {\n const response = await fetch(\n `${this.config.apiEndpoint}/sessions/validate`,\n {\n method: 'POST',\n headers: {\n 'Authorization': `Bearer ${token}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ session_jwt: token }),\n }\n );\n\n if (!response.ok) {\n throw new SDKError(\n 'Backend validation failed',\n 'BACKEND_VALIDATION_FAILED',\n response.status\n );\n }\n\n const data = await response.json();\n if (!data.valid) {\n throw new SDKError(\n data.error || 'Session validation failed',\n 'SESSION_INVALID'\n );\n }\n\n // Return decoded claims from backend\n const decoded = JWTParser.decode(token);\n return decoded;\n }\n\n /**\n * Phase 2: Handle tab sync messages\n */\n private handleTabSyncMessage(message: TabSyncMessage): void {\n this.logger.log('Tab sync message:', message.type);\n\n switch (message.type) {\n case 'pause':\n this.timer?.pause();\n break;\n case 'resume':\n this.timer?.resume();\n break;\n case 'end':\n this.endSession();\n break;\n case 'timer_update':\n if (message.remainingSeconds !== undefined) {\n this.timer?.updateRemainingTime(message.remainingSeconds);\n }\n break;\n }\n }\n\n /**\n * Phase 2: Initialize Visibility API handling\n */\n private initializeVisibilityHandling(): void {\n document.addEventListener('visibilitychange', () => {\n if (document.hidden) {\n this.logger.log('Tab hidden, pausing timer');\n this.pauseTimer();\n } else {\n this.logger.log('Tab visible, resuming timer');\n this.resumeTimer();\n }\n });\n this.logger.log('Visibility API handler initialized');\n }\n\n /**\n * Start session timer manually\n */\n startTimer(): void {\n if (!this.timer) {\n throw new SDKError(\n 'SDK not initialized. Call initialize() first.',\n 'NOT_INITIALIZED'\n );\n }\n this.timer.start();\n this.tabSync?.broadcast('resume');\n this.logger.info('Timer started manually');\n }\n\n /**\n * Pause session timer\n */\n pauseTimer(): void {\n this.timer?.pause();\n this.tabSync?.broadcast('pause');\n this.logger.info('Timer paused');\n }\n\n /**\n * Resume session timer\n */\n resumeTimer(): void {\n this.timer?.resume();\n this.tabSync?.broadcast('resume');\n this.logger.info('Timer resumed');\n }\n\n /**\n * Phase 2: Extend session\n */\n async extendSession(additionalMinutes: number): Promise<void> {\n if (!this.sessionData || !this.jwtToken) {\n throw new SDKError('No active session', 'NO_SESSION');\n }\n\n this.logger.info('Extending session by', additionalMinutes, 'minutes');\n\n try {\n const response = await fetch(\n `${this.config.apiEndpoint}/sessions/${this.sessionData.sessionId}/renew`,\n {\n method: 'PUT',\n headers: {\n 'Authorization': `Bearer ${this.jwtToken}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n additional_minutes: additionalMinutes,\n }),\n }\n );\n\n if (!response.ok) {\n throw new SDKError(\n 'Session extension failed',\n 'EXTENSION_FAILED',\n response.status\n );\n }\n\n const data = await response.json();\n\n // Update session data\n this.sessionData.exp = data.new_expires_at;\n\n // Update timer\n const now = Math.floor(Date.now() / 1000);\n const remainingSeconds = data.new_expires_at - now;\n this.timer?.updateRemainingTime(remainingSeconds);\n\n // Broadcast to other tabs\n this.tabSync?.broadcast('timer_update', { remainingSeconds });\n\n // Call onSessionExtend hook if provided\n if (this.config.hooks?.onSessionExtend) {\n const extendContext: SessionExtendContext = {\n sessionId: this.sessionData.sessionId,\n userId: this.sessionData.userId,\n additionalMinutes,\n newExpiresAt: data.new_expires_at,\n };\n\n await this.executeHook('onSessionExtend', this.config.hooks.onSessionExtend, extendContext, false);\n }\n\n this.logger.info('Session extended successfully');\n\n } catch (error) {\n this.logger.error('Failed to extend session:', error);\n const sdkError = error instanceof SDKError ? error : new SDKError(\n error instanceof Error ? error.message : 'Extension failed',\n 'EXTENSION_ERROR'\n );\n this.events.onError?.(sdkError);\n throw sdkError;\n }\n }\n\n /**\n * Phase 2: Complete session\n */\n async completeSession(actualUsageMinutes?: number): Promise<void> {\n if (!this.sessionData || !this.jwtToken) {\n throw new SDKError('No active session', 'NO_SESSION');\n }\n\n this.logger.info('Completing session...');\n\n try {\n const response = await fetch(\n `${this.config.apiEndpoint}/sessions/${this.sessionData.sessionId}/complete`,\n {\n method: 'POST',\n headers: {\n 'Authorization': `Bearer ${this.jwtToken}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n actual_usage_minutes: actualUsageMinutes,\n metadata: {},\n }),\n }\n );\n\n if (!response.ok) {\n throw new SDKError(\n 'Session completion failed',\n 'COMPLETION_FAILED',\n response.status\n );\n }\n\n const data = await response.json();\n this.logger.info('Session completed:', data);\n\n // End the session\n this.endSession();\n\n } catch (error) {\n this.logger.error('Failed to complete session:', error);\n const sdkError = error instanceof SDKError ? error : new SDKError(\n error instanceof Error ? error.message : 'Completion failed',\n 'COMPLETION_ERROR'\n );\n this.events.onError?.(sdkError);\n throw sdkError;\n }\n }\n\n /**\n * End session\n */\n async endSession(): Promise<void> {\n this.logger.info('Ending session...');\n\n // Build session end context\n const endContext: SessionEndContext = {\n sessionId: this.sessionData?.sessionId || '',\n userId: this.sessionData?.userId || '',\n reason: this.endReason,\n actualDurationMinutes: this.calculateActualDuration(),\n };\n\n // Call onSessionEnd hook if provided (LENIENT - errors logged but don't block)\n if (this.config.hooks?.onSessionEnd) {\n try {\n await this.executeHook('onSessionEnd', this.config.hooks.onSessionEnd, endContext, false);\n this.logger.log('Application auth cleanup completed');\n } catch (error) {\n // This shouldn't throw due to lenient mode, but catch anyway\n this.logger.error('onSessionEnd hook error (continuing anyway):', error);\n }\n }\n\n // Stop timer\n this.timer?.stop();\n\n // Stop heartbeat\n this.heartbeat?.stop();\n\n // Broadcast to other tabs\n this.tabSync?.broadcast('end');\n\n // Clear JWT from storage\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.removeItem('gw_marketplace_jwt');\n this.logger.log('JWT token cleared from storage');\n }\n\n // Trigger end event\n this.events.onSessionEnd?.();\n\n this.logger.info('Session ended');\n\n // Show \"Session Ending\" modal, then redirect after 3 seconds\n if (typeof window !== 'undefined') {\n // Create modal if it doesn't exist\n if (!this.modal) {\n this.modal = new WarningModal(\n this.config.themeMode || 'light',\n this.config.customStyles\n );\n }\n\n // Show ending message with redirect callback\n this.modal.showEndingMessage(() => {\n window.location.href = this.config.marketplaceUrl;\n }, 3000); // 3 second delay\n }\n }\n\n /**\n * Show warning modal\n */\n private showWarningModal(remainingSeconds: number): void {\n if (!this.modal) {\n this.modal = new WarningModal(\n this.config.themeMode || 'light',\n this.config.customStyles\n );\n }\n\n this.modal.show({\n remainingSeconds,\n onExtend: async () => {\n // Try to extend session via API\n try {\n await this.extendSession(15); // Extend by 15 minutes\n this.modal?.hide();\n this.logger.log('Session extended successfully from modal');\n } catch (error) {\n // If extension fails (likely insufficient tokens), show ending modal then redirect to marketplace\n this.logger.error('Extension failed, redirecting to marketplace:', error);\n const marketplaceUrl = `${this.config.marketplaceUrl}extend-session?sessionId=${this.sessionData?.sessionId}`;\n\n // Show ending modal before redirect\n if (typeof window !== 'undefined') {\n if (!this.modal) {\n this.modal = new WarningModal(\n this.config.themeMode || 'light',\n this.config.customStyles\n );\n }\n this.modal.showEndingMessage(() => {\n window.location.href = marketplaceUrl;\n }, 3000);\n }\n }\n },\n onEnd: () => {\n // endSession() handles cleanup and redirect\n this.endSession();\n },\n });\n }\n\n /**\n * Get current session data\n */\n getSessionData(): SessionData | null {\n return this.sessionData;\n }\n\n /**\n * Get remaining time\n */\n getRemainingTime(): number {\n return this.timer?.getRemainingSeconds() ?? 0;\n }\n\n /**\n * Get formatted time (MM:SS)\n */\n getFormattedTime(): string {\n return this.timer?.getFormattedTime() ?? '0:00';\n }\n\n /**\n * Get formatted time with hours (HH:MM:SS)\n */\n getFormattedTimeWithHours(): string {\n return this.timer?.getFormattedTimeWithHours() ?? '0:00:00';\n }\n\n /**\n * Check if timer is running\n */\n isTimerRunning(): boolean {\n return this.timer?.isRunning() ?? false;\n }\n\n /**\n * Cleanup and destroy SDK instance\n */\n destroy(): void {\n this.logger.info('Destroying SDK instance...');\n this.timer?.stop();\n this.heartbeat?.stop();\n this.tabSync?.destroy();\n this.modal?.hide();\n\n // Clear JWT from storage\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.removeItem('gw_marketplace_jwt');\n this.logger.log('JWT token cleared from storage');\n }\n\n this.sessionData = null;\n this.jwtToken = null;\n }\n}\n","import { ThemeMode } from '../types';\nimport { getTheme, Theme } from '../styles/theme';\n\n/**\n * Session Header Component\n * Compact header widget showing session timer with extend/end controls\n */\nexport class SessionHeader {\n private container: HTMLDivElement | null = null;\n private theme: Theme;\n private updateInterval: number | null = null;\n private timeDisplay: HTMLElement | null = null;\n private getTimeCallback: (() => string) | undefined;\n private onExtendCallback: (() => void) | undefined;\n private onEndCallback: (() => void) | undefined;\n private mounted: boolean = false;\n\n constructor(themeMode: ThemeMode = 'auto') {\n const prefersDark = themeMode === 'dark' || (themeMode === 'auto' && this.detectDarkMode());\n this.theme = getTheme(prefersDark);\n }\n\n private detectDarkMode(): boolean {\n if (typeof window !== 'undefined' && window.matchMedia) {\n return window.matchMedia('(prefers-color-scheme: dark)').matches;\n }\n return false;\n }\n\n /**\n * Mount the session header to a DOM element\n * @param targetElement - Element to mount to (or selector string)\n * @param options - Configuration options\n */\n mount(\n targetElement: HTMLElement | string,\n options: {\n getTime: () => string;\n onExtend?: () => void;\n onEnd?: () => void;\n position?: 'left' | 'center' | 'right';\n }\n ): void {\n // Unmount if already mounted\n if (this.mounted) {\n this.unmount();\n }\n\n // Get target element\n const target =\n typeof targetElement === 'string'\n ? document.querySelector<HTMLElement>(targetElement)\n : targetElement;\n\n if (!target) {\n console.error('[SessionHeader] Mount target not found');\n return;\n }\n\n this.getTimeCallback = options.getTime;\n this.onExtendCallback = options.onExtend;\n this.onEndCallback = options.onEnd;\n\n // Create container\n this.container = document.createElement('div');\n this.container.id = 'gw-session-header';\n\n const position = options.position || 'right';\n const justifyContent =\n position === 'left' ? 'flex-start' :\n position === 'center' ? 'center' :\n 'flex-end';\n\n this.container.style.cssText = `\n display: flex;\n align-items: center;\n justify-content: ${justifyContent};\n gap: ${this.theme.spacing.gap.md};\n padding: ${this.theme.spacing.padding.sm} ${this.theme.spacing.padding.md};\n background-color: ${this.theme.colors.card};\n border: 1px solid ${this.theme.colors.border};\n border-radius: ${this.theme.spacing.borderRadius.md};\n font-family: ${this.theme.typography.fontFamily};\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);\n `;\n\n // Create timer display\n const timerWrapper = document.createElement('div');\n timerWrapper.style.cssText = `\n display: flex;\n align-items: center;\n gap: ${this.theme.spacing.gap.sm};\n color: ${this.theme.colors.foreground};\n font-size: ${this.theme.typography.fontSize.sm};\n font-weight: ${this.theme.typography.fontWeight.medium};\n `;\n\n const clockIcon = document.createElement('span');\n clockIcon.textContent = '⏱️';\n clockIcon.style.fontSize = this.theme.typography.fontSize.base;\n\n this.timeDisplay = document.createElement('span');\n this.timeDisplay.id = 'gw-session-time';\n this.timeDisplay.textContent = this.getTimeCallback?.() || '--:--';\n this.timeDisplay.style.cssText = `\n font-variant-numeric: tabular-nums;\n min-width: 50px;\n text-align: center;\n `;\n\n timerWrapper.appendChild(clockIcon);\n timerWrapper.appendChild(this.timeDisplay);\n this.container.appendChild(timerWrapper);\n\n // Create button container\n const buttonContainer = document.createElement('div');\n buttonContainer.style.cssText = `\n display: flex;\n gap: ${this.theme.spacing.gap.sm};\n `;\n\n // Extend button (if callback provided)\n if (this.onExtendCallback) {\n const extendBtn = document.createElement('button');\n extendBtn.textContent = 'Extend';\n extendBtn.style.cssText = `\n padding: ${this.theme.spacing.padding.sm};\n background-color: ${this.theme.colors.success};\n color: ${this.theme.colors.successForeground};\n border: none;\n border-radius: ${this.theme.spacing.borderRadius.sm};\n font-size: ${this.theme.typography.fontSize.sm};\n font-weight: ${this.theme.typography.fontWeight.medium};\n font-family: ${this.theme.typography.fontFamily};\n cursor: pointer;\n transition: opacity 0.2s;\n `;\n extendBtn.addEventListener('mouseenter', () => {\n extendBtn.style.opacity = '0.9';\n });\n extendBtn.addEventListener('mouseleave', () => {\n extendBtn.style.opacity = '1';\n });\n extendBtn.addEventListener('click', () => {\n this.onExtendCallback?.();\n });\n buttonContainer.appendChild(extendBtn);\n }\n\n // End button (if callback provided)\n if (this.onEndCallback) {\n const endBtn = document.createElement('button');\n endBtn.textContent = 'End';\n endBtn.style.cssText = `\n padding: ${this.theme.spacing.padding.sm};\n background-color: ${this.theme.colors.secondary};\n color: ${this.theme.colors.secondaryForeground};\n border: 1px solid ${this.theme.colors.border};\n border-radius: ${this.theme.spacing.borderRadius.sm};\n font-size: ${this.theme.typography.fontSize.sm};\n font-weight: ${this.theme.typography.fontWeight.medium};\n font-family: ${this.theme.typography.fontFamily};\n cursor: pointer;\n transition: opacity 0.2s;\n `;\n endBtn.addEventListener('mouseenter', () => {\n endBtn.style.opacity = '0.9';\n });\n endBtn.addEventListener('mouseleave', () => {\n endBtn.style.opacity = '1';\n });\n endBtn.addEventListener('click', () => {\n this.onEndCallback?.();\n });\n buttonContainer.appendChild(endBtn);\n }\n\n if (buttonContainer.children.length > 0) {\n this.container.appendChild(buttonContainer);\n }\n\n // Mount to target\n target.appendChild(this.container);\n this.mounted = true;\n\n // Start updating time display\n this.startUpdating();\n }\n\n /**\n * Start updating the time display\n */\n private startUpdating(): void {\n if (this.updateInterval) {\n clearInterval(this.updateInterval);\n }\n\n this.updateInterval = window.setInterval(() => {\n if (this.timeDisplay && this.getTimeCallback) {\n const newTime = this.getTimeCallback();\n this.timeDisplay.textContent = newTime;\n\n // Change color if warning state (< 5 minutes = MM:SS where MM < 05)\n const [minutes] = newTime.split(':').map(Number);\n if (!isNaN(minutes) && minutes < 5) {\n this.timeDisplay.style.color = this.theme.colors.destructive;\n this.timeDisplay.style.fontWeight = this.theme.typography.fontWeight.bold;\n } else {\n this.timeDisplay.style.color = this.theme.colors.foreground;\n this.timeDisplay.style.fontWeight = this.theme.typography.fontWeight.medium;\n }\n }\n }, 1000);\n }\n\n /**\n * Unmount and cleanup the session header\n */\n unmount(): void {\n if (this.updateInterval) {\n clearInterval(this.updateInterval);\n this.updateInterval = null;\n }\n\n if (this.container && this.container.parentNode) {\n this.container.parentNode.removeChild(this.container);\n }\n\n this.container = null;\n this.timeDisplay = null;\n this.mounted = false;\n }\n\n /**\n * Check if component is mounted\n */\n isMounted(): boolean {\n return this.mounted;\n }\n\n /**\n * Update the theme\n */\n updateTheme(themeMode: ThemeMode): void {\n const prefersDark = themeMode === 'dark' || (themeMode === 'auto' && this.detectDarkMode());\n this.theme = getTheme(prefersDark);\n\n // Re-mount with new theme if currently mounted\n if (this.mounted && this.container && this.container.parentElement) {\n const parent = this.container.parentElement;\n const options = {\n getTime: this.getTimeCallback!,\n onExtend: this.onExtendCallback,\n onEnd: this.onEndCallback,\n };\n this.unmount();\n this.mount(parent, options);\n }\n }\n}\n"],"names":["SDKError","Error","constructor","message","code","statusCode","super","this","name","captureStackTrace","JWTParser","decode","token","parts","split","length","payload","decoded","base64UrlDecode","JSON","parse","error","decodeHeader","header","extractClaim","claim","isExpired","exp","Date","now","getTimeRemaining","remaining","Math","floor","max","str","base64","replace","padding","repeat","Buffer","from","toString","atob","encoder","TextEncoder","decoder","TextDecoder","input","Uint8Array","fromBase64","alphabet","encoded","binary","bytes","i","charCodeAt","decodeBase64","TypeError","JOSEError","options","__publicField","JWTClaimValidationFailed","reason","cause","JWTExpired","JOSEAlgNotAllowed","arguments","JOSENotSupported","JWSInvalid","JWTInvalid","JWKSInvalid","JWKSNoMatchingKey","JWKSMultipleMatchingKeys","_b","_a","Symbol","asyncIterator","JWKSTimeout","JWSSignatureVerificationFailed","unusable","prop","isAlgorithm","algorithm","getHashLength","hash","parseInt","slice","checkSigCryptoKey","key","alg","usage","expected","getNamedCurve","namedCurve","usages","includes","checkUsage","msg","actual","types","filter","Boolean","last","pop","join","withAlg","isCryptoKey","toStringTag","isKeyObject","isKeyLike","isObject","value","Object","prototype","call","getPrototypeOf","proto","importJWK$1","async","jwk","keyUsages","kty","priv","d","crv","subtleMapping","keyData","use","crypto","subtle","importKey","ext","key_ops","isJWK","cache","handleJWK","freeze","WeakMap","cached","get","cryptoKey","importJWK","set","normalizeKey","type","export","toCryptoKey","keyObject","isPublic","extractable","asymmetricKeyType","toUpperCase","startsWith","Map","asymmetricKeyDetails","handleKeyObject","err","format","k","tag","jwkMatchesOp","Array","isArray","expectedKeyOp","test","endsWith","checkKeyType","jwk.isJWK","jwk.isSecretJWK","invalidKeyInput","symmetricTypeCheck","jwk.isPrivateJWK","jwk.isPublicJWK","asymmetricTypeCheck","getSignKey","verify","signature","data","getVerifyKey","modulusLength","checkKeyLength","saltLength","subtleAlgorithm","flattenedVerify","jws","protected","parsedProt","protectedHeader","b64u","headers","sources","acc","parameters","keys","size","parameter","has","add","Set","isDisjoint","joseHeader","extensions","Err","recognizedDefault","recognizedOption","crit","some","recognized","entries","validateCrit","b64","algorithms","option","s","validateAlgorithms","resolvedKey","buffers","reduce","buf","buffer","concat","encode","result","unprotectedHeader","day","hour","REGEX","secs","matched","exec","parseFloat","numericDate","toLowerCase","round","minute","normalizeTyp","validateClaimsSet","encodedPayload","typ","requiredClaims","issuer","subject","audience","maxTokenAge","presenceCheck","push","reverse","iss","sub","audPayload","aud","audOption","bind","tolerance","clockTolerance","currentDate","date","getTime","iat","nbf","age","jwtVerify","jwt","verified","compactVerify","isJWKLike","LocalJWKSet","jwks","__privateAdd","_jwks","_cached","every","isJWKSLike","__privateSet","structuredClone","__privateGet","getKey","kid","getKtyFromAlg","candidates","candidate","importWithAlgCache","decodeBase64URL","oth","createLocalJWKSet","localJWKSet","defineProperties","enumerable","configurable","writable","USER_AGENT","navigator","userAgent","customFetch","jwksCache","RemoteJWKSet","url","_url","_timeoutDuration","_cooldownDuration","_cacheMaxAge","_jwksTimestamp","_pendingFetch","_headers","_customFetch","_local","_cache","URL","cacheMaxAge","href","timeoutDuration","cooldownDuration","Headers","append","uat","pendingFetch","coolingDown","fresh","reload","WebSocketPair","EdgeRuntime","signal","fetchImpl","fetch","response","method","redirect","catch","status","json","fetchJwks","AbortSignal","timeout","then","createRemoteJWKSet","remoteJWKSet","reloading","Logger","debug","prefix","log","args","info","warn","JWKSValidator","jwksUri","logger","resolvedUrl","window","location","origin","expectedIssuer","expectedApplicationId","applicationId","claims","sessionId","userId","orgId","startTime","durationMinutes","errorMessage","errorName","updateJwksUri","TimerManager","durationSeconds","warningThresholdSeconds","events","intervalId","warningShown","remainingSeconds","warningThreshold","start","setInterval","onSessionWarning","stop","onSessionEnd","clearInterval","pause","resume","getRemainingSeconds","getFormattedTime","padStart","getFormattedTimeWithHours","hours","minutes","seconds","isRunning","hasWarningBeenShown","updateRemainingTime","HeartbeatManager","apiEndpoint","onSync","onError","heartbeatIntervalSeconds","failureCount","maxFailures","isEnabled","heartbeatInterval","sendHeartbeat","Authorization","body","stringify","timestamp","active","ok","remaining_seconds","sdkError","getFailureCount","updateInterval","wasRunning","TabSyncManager","onMessage","channel","isMaster","handleStorageEvent","event","storageKey","newValue","handleMessage","initialize","BroadcastChannel","onmessage","addEventListener","electMaster","broadcast","postMessage","localStorage","setItem","masterKey","getItem","masterTimestamp","removeItem","isMasterTab","destroy","close","removeEventListener","lightTheme","colors","background","foreground","card","cardForeground","popover","popoverForeground","primary","primaryForeground","secondary","secondaryForeground","muted","mutedForeground","accent","accentForeground","destructive","destructiveForeground","success","successForeground","border","ring","typography","fontFamily","fontSize","xs","sm","base","lg","xl","fontWeight","normal","medium","semibold","bold","lineHeight","tight","relaxed","spacing","borderRadius","md","gap","darkTheme","getTheme","prefersDark","matchMedia","matches","WarningModal","themeMode","customStyles","modal","legacyStyles","timeDisplay","initialSeconds","onEndCallback","detectDarkMode","theme","backgroundColor","textColor","primaryColor","show","hide","document","createElement","id","style","cssText","content","bgColor","onEnd","innerHTML","onExtend","appendChild","extendBtn","getElementById","dismissBtn","endBtn","querySelectorAll","forEach","button","opacity","outline","outlineOffset","elapsed","textContent","parentNode","removeChild","isShown","showEndingMessage","onComplete","durationMs","head","setTimeout","extractTokenFromURL","paramName","targetUrl","urlObj","searchParams","MarketplaceSDK","config","timer","heartbeat","tabSync","sessionData","jwtToken","endReason","jwtParamName","autoStart","marketplaceUrl","enableHeartbeat","enableTabSync","pauseOnHidden","useBackendValidation","hooks","hookTimeoutMs","validator","on","handler","executeHook","hookName","hook","context","isStrict","Promise","_","reject","race","resolve","calculateActualDuration","ceil","JWT_STORAGE_KEY","sessionStorage","verifiedClaims","validateWithBackend","onSessionStart","startContext","email","expiresAt","warningContext","showWarningModal","endSession","handleTabSyncMessage","initializeVisibilityHandling","session_jwt","valid","hidden","pauseTimer","resumeTimer","startTimer","extendSession","additionalMinutes","additional_minutes","new_expires_at","onSessionExtend","extendContext","newExpiresAt","completeSession","actualUsageMinutes","actual_usage_minutes","metadata","endContext","actualDurationMinutes","getSessionData","getRemainingTime","isTimerRunning","container","mounted","mount","targetElement","unmount","target","querySelector","getTimeCallback","onExtendCallback","position","justifyContent","timerWrapper","clockIcon","buttonContainer","children","startUpdating","newTime","map","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