@thavguard/arc-pay 0.1.23 → 0.1.25

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/errors.ts","../src/core/env.ts","../src/core/sandbox-banner.ts","../src/elements/postmessage.ts","../src/elements/style.ts","../src/elements/element.ts","../src/elements/elements.ts","../src/core/arcpay.ts","../src/three-ds/actions.ts","../src/index.ts"],"names":["validatePublishableKey","_a","mounted"],"mappings":";AAsBO,IAAM,WAAA,GAAN,cAA0B,KAAA,CAAM;AAAA,EASrC,YAAY,IAAA,EAAuB;AACjC,IAAA,KAAA,CAAM,KAAK,OAAO,CAAA;AAClB,IAAA,IAAA,CAAK,IAAA,GAAO,aAAA;AACZ,IAAA,IAAA,CAAK,OAAO,IAAA,CAAK,IAAA;AACjB,IAAA,IAAA,CAAK,OAAO,IAAA,CAAK,IAAA;AACjB,IAAA,IAAA,CAAK,QAAQ,IAAA,CAAK,KAAA;AAClB,IAAA,IAAA,CAAK,YAAY,IAAA,CAAK,SAAA;AACtB,IAAA,IAAA,CAAK,cAAc,IAAA,CAAK,WAAA;AACxB,IAAA,IAAA,CAAK,YAAY,IAAA,CAAK,SAAA;AACtB,IAAA,IAAA,CAAK,YAAY,IAAA,CAAK,SAAA;AAAA,EACxB;AACF;AAEO,IAAM,oBAAoB,CAAC,CAAA,KAChC,CAAA,YAAa,WAAA,IAAe,EAAE,IAAA,KAAS;AAGlC,IAAM,wBAAwB,CAAC,CAAA,KACpC,CAAA,YAAa,WAAA,IAAe,EAAE,IAAA,KAAS;AAClC,IAAM,uBAAuB,CAAC,CAAA,KACnC,CAAA,YAAa,WAAA,IAAe,EAAE,IAAA,KAAS;AAClC,IAAM,eAAe,CAAC,CAAA,KAC3B,CAAA,YAAa,WAAA,IAAe,EAAE,IAAA,KAAS;AAClC,IAAM,mBAAmB,CAAC,CAAA,KAC/B,CAAA,YAAa,WAAA,IAAe,EAAE,I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A,EAAa,MAAM,CAAA,EAAA,EAAK,MAAM,CAAA,iEAAA,CAAA;AACpK;;;ACxSO,IAAM,WAAA,GAAc","file":"index.mjs","sourcesContent":["export type ArcPayErrorType =\n | \"validation_error\"\n | \"configuration_error\"\n | \"authentication_error\"\n | \"authorization_error\"\n | \"state_error\"\n | \"rate_limit_error\"\n | \"api_error\"\n | \"network_error\"\n | \"challenge_aborted\";\n\ninterface ArcPayErrorInit {\n type: ArcPayErrorType;\n message: string;\n code?: string;\n param?: string;\n paymentId?: string;\n declineCode?: string;\n retryable: boolean;\n requestId?: string;\n}\n\nexport class ArcPayError extends Error {\n readonly type: ArcPayErrorType;\n readonly code?: string;\n readonly param?: string;\n readonly paymentId?: string;\n readonly declineCode?: string;\n readonly retryable: boolean;\n readonly requestId?: string;\n\n constructor(init: ArcPayErrorInit) {\n super(init.message);\n this.name = \"ArcPayError\";\n this.type = init.type;\n this.code = init.code;\n this.param = init.param;\n this.paymentId = init.paymentId;\n this.declineCode = init.declineCode;\n this.retryable = init.retryable;\n this.requestId = init.requestId;\n }\n}\n\nexport const isValidationError = (e: unknown): e is ArcPayError =>\n e instanceof ArcPayError && e.type === \"validation_error\";\nconst isConfigurationError = (e: unknown): e is ArcPayError =>\n e instanceof ArcPayError && e.type === \"configuration_error\";\nexport const isAuthenticationError = (e: unknown): e is ArcPayError =>\n e instanceof ArcPayError && e.type === \"authentication_error\";\nexport const isAuthorizationError = (e: unknown): e is ArcPayError =>\n e instanceof ArcPayError && e.type === \"authorization_error\";\nexport const isStateError = (e: unknown): e is ArcPayError =>\n e instanceof ArcPayError && e.type === \"state_error\";\nexport const isRateLimitError = (e: unknown): e is ArcPayError =>\n e instanceof ArcPayError && e.type === \"rate_limit_error\";\nexport const isApiError = (e: unknown): e is ArcPayError =>\n e instanceof ArcPayError && e.type === \"api_error\";\nexport const isNetworkError = (e: unknown): e is ArcPayError =>\n e instanceof ArcPayError && e.type === \"network_error\";\nexport const isChallengeAborted = (e: unknown): e is ArcPayError =>\n e instanceof ArcPayError && e.type === \"challenge_aborted\";\n","import { ArcPayError } from \"./errors\";\n\nexport type Environment = \"sandbox\" | \"live\";\n\nexport const detectEnvironment = (publishableKey: string): Environment =>\n publishableKey.startsWith(\"pk_test_\") ? \"sandbox\" : \"live\";\n\nexport const validatePublishableKey = (key: unknown): asserts key is string => {\n if (typeof key !== \"string\" || key.length === 0) {\n throw new ArcPayError({\n type: \"validation_error\",\n code: \"invalid_publishable_key\",\n message: \"Publishable key must be a non-empty string\",\n retryable: false,\n });\n }\n if (!key.startsWith(\"pk_test_\") && !key.startsWith(\"pk_live_\")) {\n throw new ArcPayError({\n type: \"validation_error\",\n code: \"invalid_publishable_key\",\n message:\n \"Publishable key must start with pk_test_ or pk_live_. Secret keys (sk_*) cannot be used in browser.\",\n retryable: false,\n });\n }\n};\n","const BANNER_ATTR = \"data-arcpay-sandbox-banner\";\n\nexport const showSandboxBanner = (): void => {\n if (typeof document === \"undefined\") return;\n if (document.querySelector(`[${BANNER_ATTR}]`)) return;\n\n const bar = document.createElement(\"div\");\n bar.setAttribute(BANNER_ATTR, \"\");\n bar.style.cssText =\n \"position:fixed;top:0;left:0;right:0;z-index:2147483647;background:#ffd166;color:#222;font:13px/1.4 system-ui,sans-serif;padding:6px 12px;display:flex;align-items:center;justify-content:center;box-shadow:0 1px 3px rgba(0,0,0,0.1);\";\n\n const text = document.createElement(\"span\");\n text.textContent = \"ARC PAY TEST MODE — payments are simulated\";\n bar.appendChild(text);\n\n const dismiss = document.createElement(\"button\");\n dismiss.type = \"button\";\n dismiss.setAttribute(\"data-arcpay-banner-dismiss\", \"\");\n dismiss.textContent = \"×\";\n dismiss.setAttribute(\"aria-label\", \"Dismiss test mode banner\");\n dismiss.style.cssText =\n \"margin-left:12px;background:transparent;border:0;font-size:18px;cursor:pointer;color:inherit;\";\n dismiss.addEventListener(\"click\", () => bar.remove());\n bar.appendChild(dismiss);\n\n document.body.appendChild(bar);\n};\n","import { ArcPayError } from \"../core/errors\";\n\nexport type FieldType = \"cardNumber\" | \"cardExpiry\" | \"cardCvv\";\n\n// Parent → iframe\nexport type ParentToIframe =\n | { type: \"arcpay:hello\"; origin: string; publishableKey: string; channelId: string }\n | { type: \"arcpay:style\"; payload: StyleSubset }\n | { type: \"arcpay:placeholder\"; field: FieldType; placeholder: string }\n | { type: \"arcpay:focus\" }\n | { type: \"arcpay:clear\" }\n | { type: \"arcpay:tokenize\"; paymentId: string; idempotencyKey: string };\n\n// iframe → parent\nexport type IframeToParent =\n | { type: \"arcpay:ready\" }\n | { type: \"arcpay:rejected\"; reason: string }\n | {\n type: \"arcpay:change\";\n field: FieldType;\n isValid: boolean;\n brand?: string;\n lastFour?: string;\n }\n | {\n type: \"arcpay:tokenize-result\";\n cardTokenId: string;\n cardMask: string;\n cardScheme: string;\n cardBin: string;\n expiresIn: number;\n expiresAt: string;\n }\n | { type: \"arcpay:tokenize-error\"; errorType: string; code?: string; message: string };\n\nexport interface StyleSubset {\n base: Record<string, string>;\n invalid?: Record<string, string>;\n focus?: Record<string, string>;\n}\n\ntype TokenizeErrorType = \"validation_error\" | \"configuration_error\" | \"network_error\" | \"api_error\";\n\nconst ARCPAY_TYPE_PREFIX = \"arcpay:\";\n\nconst isArcpayMessage = (data: unknown): data is { type: string } =>\n typeof data === \"object\" &&\n data !== null &&\n \"type\" in data &&\n typeof (data as { type: unknown }).type === \"string\" &&\n (data as { type: string }).type.startsWith(ARCPAY_TYPE_PREFIX);\n\nexport const postToIframe = (\n iframe: HTMLIFrameElement,\n message: ParentToIframe,\n targetOrigin: string,\n): void => {\n if (targetOrigin === \"*\") {\n throw new ArcPayError({\n type: \"validation_error\",\n code: \"wildcard_origin_forbidden\",\n message: \"postToIframe: targetOrigin cannot be '*'\",\n retryable: false,\n });\n }\n if (!iframe.contentWindow) {\n throw new ArcPayError({\n type: \"validation_error\",\n code: \"iframe_not_loaded\",\n message: \"postToIframe: iframe.contentWindow is null (iframe not mounted)\",\n retryable: false,\n });\n }\n iframe.contentWindow.postMessage(message, targetOrigin);\n};\n\nexport const postToParent = (message: IframeToParent, targetOrigin: string): void => {\n if (targetOrigin === \"*\") {\n throw new Error(\"postToParent: targetOrigin cannot be '*'\");\n }\n window.parent.postMessage(message, targetOrigin);\n};\n\nexport const parseIncoming = <T extends { type: string }>(\n event: MessageEvent,\n expectedOrigin: string,\n): T | null => {\n if (event.origin !== expectedOrigin) return null;\n if (!isArcpayMessage(event.data)) return null;\n return event.data as T;\n};\n","import type { StyleSubset } from \"./postmessage\";\n\n// Spec calls out position:fixed, transform, pointer-events:none as forbidden.\n// We extend to cover the full clickjacking attack surface: any positioning\n// (fixed/absolute/sticky), transform, all pointer-events values, z-index, and\n// inset properties (top/left/right/bottom/inset). The legitimate use cases\n// for these in a 1-line input field are zero, so blanket drop.\nconst FORBIDDEN_PROPERTIES = new Set([\n \"position\",\n \"transform\",\n \"pointer-events\",\n \"pointerevents\",\n \"z-index\",\n \"zindex\",\n \"top\",\n \"left\",\n \"right\",\n \"bottom\",\n \"inset\",\n]);\n\nconst sanitizeBlock = (block: Record<string, string>): Record<string, string> => {\n const out: Record<string, string> = {};\n for (const [key, value] of Object.entries(block)) {\n const normalizedKey = key.toLowerCase();\n if (FORBIDDEN_PROPERTIES.has(normalizedKey)) {\n // Defense against position/transform-based clickjacking. Silently drop.\n continue;\n }\n out[key] = value;\n }\n return out;\n};\n\nexport const sanitizeStyle = (style: StyleSubset): StyleSubset => {\n const result: StyleSubset = { base: sanitizeBlock(style.base) };\n if (style.invalid !== undefined) result.invalid = sanitizeBlock(style.invalid);\n if (style.focus !== undefined) result.focus = sanitizeBlock(style.focus);\n return result;\n};\n","import { ArcPayError } from \"../core/errors\";\nimport {\n type FieldType,\n type ParentToIframe,\n type IframeToParent,\n type StyleSubset,\n postToIframe,\n parseIncoming,\n} from \"./postmessage\";\nimport { sanitizeStyle } from \"./style\";\n\nexport interface ElementOptions {\n /** StyleSubset applied via arcpay:style postMessage. */\n style?: StyleSubset;\n placeholder?: string;\n}\n\nexport type ElementEvent =\n | { type: \"ready\" }\n | { type: \"change\"; isValid: boolean; brand?: string; lastFour?: string }\n | { type: \"error\"; reason: string };\n\ntype Listener = (event: ElementEvent) => void;\ntype ElementEventName = ElementEvent[\"type\"];\n\nconst FIELD_TITLES: Record<FieldType, string> = {\n cardNumber: \"Arc Pay card number\",\n cardExpiry: \"Arc Pay card expiration date\",\n cardCvv: \"Arc Pay card security code\",\n};\n\nexport interface ElementContext {\n iframeBase: string;\n publishableKey: string;\n channelId: string;\n}\n\nexport class Element {\n private iframe: HTMLIFrameElement | null = null;\n private readonly listeners: Record<ElementEventName, Set<Listener>> = {\n ready: new Set<Listener>(),\n change: new Set<Listener>(),\n error: new Set<Listener>(),\n };\n private status: \"pending\" | \"ready\" | \"error\" = \"pending\";\n private messageHandler: ((e: MessageEvent) => void) | null = null;\n\n constructor(\n public readonly field: FieldType,\n private readonly options: ElementOptions,\n private readonly context: ElementContext,\n ) {}\n\n mount(target: string | HTMLElement): void {\n if (this.iframe) {\n throw new ArcPayError({\n type: \"validation_error\",\n code: \"already_mounted\",\n message: `Element ${this.field} is already mounted`,\n retryable: false,\n });\n }\n const container = typeof target === \"string\" ? document.querySelector(target) : target;\n if (!(container instanceof HTMLElement)) {\n throw new ArcPayError({\n type: \"validation_error\",\n code: \"mount_target_not_found\",\n message: `mount target not found: ${String(target)}`,\n retryable: false,\n });\n }\n\n const iframe = document.createElement(\"iframe\");\n iframe.src = `${this.context.iframeBase}/iframe/${this.field}`;\n iframe.style.cssText = \"border:0;width:100%;height:100%;display:block;\";\n iframe.setAttribute(\"allow\", \"payment\");\n iframe.setAttribute(\"data-arcpay-element\", this.field);\n iframe.setAttribute(\"title\", FIELD_TITLES[this.field]);\n iframe.setAttribute(\"aria-label\", FIELD_TITLES[this.field]);\n container.appendChild(iframe);\n this.iframe = iframe;\n\n const expectedOrigin = new URL(this.context.iframeBase).origin;\n\n this.messageHandler = (event: MessageEvent) => {\n // C1: source guard — only accept messages from this element's own iframe.\n // Without this, any iframe at the same origin (e.g. cardExpiry, cardCvv)\n // could trigger handlers on cardNumber and vice-versa.\n if (event.source !== this.iframe?.contentWindow) return;\n // C4: use parseIncoming for origin + arcpay: prefix guard.\n const data = parseIncoming<IframeToParent>(event, expectedOrigin);\n if (!data) return;\n this.handleMessage(data);\n };\n window.addEventListener(\"message\", this.messageHandler);\n\n iframe.addEventListener(\n \"load\",\n () => {\n if (!this.iframe) return;\n const hello: ParentToIframe = {\n type: \"arcpay:hello\",\n origin: window.location.origin,\n publishableKey: this.context.publishableKey,\n channelId: this.context.channelId,\n };\n postToIframe(this.iframe, hello, expectedOrigin);\n },\n { once: true },\n );\n }\n\n private handleMessage(data: IframeToParent): void {\n if (data.type === \"arcpay:ready\") {\n this.status = \"ready\";\n // Apply initial style if provided at construction time.\n if (this.options.style) {\n this.send({ type: \"arcpay:style\", payload: sanitizeStyle(this.options.style) });\n }\n if (this.options.placeholder) {\n this.send({\n type: \"arcpay:placeholder\",\n field: this.field,\n placeholder: this.options.placeholder,\n });\n }\n this.emit({ type: \"ready\" });\n } else if (data.type === \"arcpay:rejected\") {\n this.status = \"error\";\n this.emit({ type: \"error\", reason: data.reason });\n } else if (data.type === \"arcpay:change\" && data.field === this.field) {\n this.emit({\n type: \"change\",\n isValid: data.isValid,\n brand: data.brand,\n lastFour: data.lastFour,\n });\n }\n // arcpay:tokenize-result / arcpay:tokenize-error handled by Elements factory (Task 9).\n }\n\n update(options: { style?: StyleSubset; placeholder?: string }): void {\n if (options.style) {\n this.send({ type: \"arcpay:style\", payload: sanitizeStyle(options.style) });\n }\n if (options.placeholder) {\n this.send({\n type: \"arcpay:placeholder\",\n field: this.field,\n placeholder: options.placeholder,\n });\n }\n }\n\n destroy(): void {\n if (this.iframe) {\n this.iframe.remove();\n this.iframe = null;\n }\n if (this.messageHandler) {\n window.removeEventListener(\"message\", this.messageHandler);\n this.messageHandler = null;\n }\n for (const listeners of Object.values(this.listeners)) {\n listeners.clear();\n }\n this.status = \"pending\";\n }\n\n on(event: ElementEventName, callback: Listener): () => void {\n this.listeners[event].add(callback);\n return () => this.listeners[event].delete(callback);\n }\n\n focus(): void {\n this.send({ type: \"arcpay:focus\" });\n }\n\n clear(): void {\n this.send({ type: \"arcpay:clear\" });\n }\n\n isReady(): boolean {\n return this.status === \"ready\";\n }\n\n /**\n * Internal: returns the iframe's contentWindow for source-filtering in\n * Elements.doTokenize(). Returns null when the iframe is not yet mounted\n * or when jsdom has not yet populated contentWindow (test environment).\n */\n getIframeContentWindow(): Window | null {\n return this.iframe?.contentWindow ?? null;\n }\n\n /** Internal: used by Elements factory to send tokenize commands. */\n send(message: ParentToIframe): void {\n if (!this.iframe) {\n throw new ArcPayError({\n type: \"validation_error\",\n code: \"not_mounted\",\n message: `Element ${this.field} is not mounted`,\n retryable: false,\n });\n }\n postToIframe(this.iframe, message, new URL(this.context.iframeBase).origin);\n }\n\n private emit(event: ElementEvent): void {\n for (const listener of this.listeners[event.type]) {\n listener(event);\n }\n }\n}\n","import { ArcPayError } from \"../core/errors\";\nimport { Element, type ElementContext, type ElementOptions } from \"./element\";\nimport type { FieldType, IframeToParent } from \"./postmessage\";\nimport { parseIncoming } from \"./postmessage\";\nimport type { TokenizeResult } from \"../tokenize/tokenize\";\n\nexport type {};\n\nexport type ElementsOptions = Record<string, never>;\n\nconst DEFAULT_IFRAME_BASE = \"https://sdk.arcpay.space\";\n\nconst createChannelId = (): string => {\n if (!globalThis.crypto?.randomUUID) {\n throw new ArcPayError({\n type: \"validation_error\",\n code: \"crypto_unavailable\",\n message: \"crypto.randomUUID is required for Hosted Fields\",\n retryable: false,\n });\n }\n return globalThis.crypto.randomUUID();\n};\n\nexport class Elements {\n private readonly elementMap = new Map<FieldType, Element>();\n private readonly iframeBase: string;\n private readonly publishableKey: string;\n private readonly channelId: string;\n private tokenizeInFlight = false;\n\n constructor(opts: { publishableKey: string; iframeBase?: string }) {\n this.publishableKey = opts.publishableKey;\n this.iframeBase = opts.iframeBase ?? DEFAULT_IFRAME_BASE;\n this.channelId = createChannelId();\n }\n\n create(field: FieldType, options: ElementOptions = {}): Element {\n if (this.elementMap.has(field)) {\n throw new ArcPayError({\n type: \"validation_error\",\n code: \"duplicate_element\",\n message: `Element for ${field} already created`,\n retryable: false,\n });\n }\n const ctx: ElementContext = {\n iframeBase: this.iframeBase,\n publishableKey: this.publishableKey,\n channelId: this.channelId,\n };\n const element = new Element(field, options, ctx);\n this.elementMap.set(field, element);\n return element;\n }\n\n async tokenize(paymentId: string, idempotencyKey: string): Promise<TokenizeResult> {\n // C2: concurrent-call guard — only one tokenize() may be in-flight at a time.\n if (this.tokenizeInFlight) {\n throw new ArcPayError({\n type: \"validation_error\",\n code: \"tokenize_in_progress\",\n message: \"A tokenize() call is already in progress for this Elements instance\",\n retryable: false,\n });\n }\n\n const cardNumber = this.elementMap.get(\"cardNumber\");\n const cardExpiry = this.elementMap.get(\"cardExpiry\");\n const cardCvv = this.elementMap.get(\"cardCvv\");\n\n if (!cardNumber || !cardExpiry || !cardCvv) {\n throw new ArcPayError({\n type: \"validation_error\",\n code: \"incomplete_elements\",\n message:\n \"All three elements (cardNumber, cardExpiry, cardCvv) must be created and mounted before tokenize()\",\n retryable: false,\n });\n }\n if (!cardNumber.isReady() || !cardExpiry.isReady() || !cardCvv.isReady()) {\n throw new ArcPayError({\n type: \"validation_error\",\n code: \"elements_not_ready\",\n message: \"Wait for all elements to fire 'ready' event before tokenize()\",\n retryable: false,\n });\n }\n\n this.tokenizeInFlight = true;\n try {\n return await this.doTokenize(cardNumber, paymentId, idempotencyKey);\n } finally {\n this.tokenizeInFlight = false;\n }\n }\n\n private doTokenize(\n cardNumber: Element,\n paymentId: string,\n idempotencyKey: string,\n ): Promise<TokenizeResult> {\n const iframeOrigin = new URL(this.iframeBase).origin;\n // C1: obtain reference to the cardNumber iframe's contentWindow before\n // registering the listener so we can filter by source.\n const cardIframeWindow = cardNumber.getIframeContentWindow();\n\n return new Promise<TokenizeResult>((resolve, reject) => {\n // C3: 30-second timeout — rejects and cleans up if no result arrives.\n const timer = window.setTimeout(() => {\n window.removeEventListener(\"message\", onMessage);\n reject(\n new ArcPayError({\n type: \"network_error\",\n code: \"tokenize_timeout\",\n message: \"tokenize() timed out after 30 seconds\",\n retryable: true,\n paymentId,\n }),\n );\n }, 30_000);\n\n const onMessage = (event: MessageEvent) => {\n // C1: source guard — only accept messages from the cardNumber iframe.\n if (cardIframeWindow !== null && event.source !== cardIframeWindow) return;\n // C4: use parseIncoming for origin + arcpay: prefix guard.\n const data = parseIncoming<IframeToParent>(event, iframeOrigin);\n if (!data) return;\n\n if (data.type === \"arcpay:tokenize-result\") {\n clearTimeout(timer);\n window.removeEventListener(\"message\", onMessage);\n resolve({\n cardTokenId: data.cardTokenId,\n cardMask: data.cardMask,\n cardScheme: data.cardScheme,\n cardBin: data.cardBin,\n expiresIn: data.expiresIn,\n expiresAt: data.expiresAt,\n });\n } else if (data.type === \"arcpay:tokenize-error\") {\n clearTimeout(timer);\n window.removeEventListener(\"message\", onMessage);\n reject(\n new ArcPayError({\n type:\n data.errorType === \"validation_error\" ||\n data.errorType === \"configuration_error\" ||\n data.errorType === \"network_error\" ||\n data.errorType === \"api_error\"\n ? data.errorType\n : \"api_error\",\n code: data.code,\n message: data.message,\n retryable: false,\n paymentId,\n }),\n );\n }\n };\n\n window.addEventListener(\"message\", onMessage);\n cardNumber.send({ type: \"arcpay:tokenize\", paymentId, idempotencyKey });\n });\n }\n\n destroy(): void {\n for (const el of this.elementMap.values()) {\n el.destroy();\n }\n this.elementMap.clear();\n }\n}\n","import {\n detectEnvironment,\n type Environment,\n validatePublishableKey as _validatePublishableKey,\n} from \"./env\";\nimport { showSandboxBanner } from \"./sandbox-banner\";\nimport { Elements, type ElementsOptions } from \"../elements/elements\";\n\nconst validatePublishableKey: (key: unknown) => asserts key is string = _validatePublishableKey;\n\nexport interface ArcPayLoadOptions {\n readonly _reserved?: never;\n}\n\nexport interface ArcPayInstance {\n readonly publishableKey: string;\n readonly environment: Environment;\n elements: (opts?: ElementsOptions) => Elements;\n}\n\nconst cache = new Map<string, Promise<ArcPayInstance>>();\n\nconst buildInstance = (publishableKey: string): ArcPayInstance => {\n if (detectEnvironment(publishableKey) === \"sandbox\") {\n showSandboxBanner();\n }\n return {\n publishableKey,\n environment: detectEnvironment(publishableKey),\n elements: () => new Elements({ publishableKey }),\n };\n};\n\nfunction load(publishableKey: string): Promise<ArcPayInstance> {\n try {\n validatePublishableKey(publishableKey);\n } catch (err) {\n return Promise.reject(err);\n }\n const key = publishableKey;\n const existing = cache.get(key);\n if (existing) return existing;\n const promise = Promise.resolve(buildInstance(publishableKey));\n cache.set(key, promise);\n return promise;\n}\n\nconst resetForTests = (): void => {\n cache.clear();\n};\n\nexport const ArcPay = {\n load,\n __resetForTests: resetForTests,\n};\n","import type { CardBrowserInfo, ExecutePaymentResponse, PaymentNextAction } from \"../server/types\";\n\nexport type ThreeDSAction = PaymentNextAction;\nexport type BrowserInfo = CardBrowserInfo;\n\nexport interface BrowserFormField {\n name: string;\n value: string;\n}\n\nexport interface BrowserPostForm {\n action: string;\n method: \"POST\";\n target: \"hidden_iframe\" | \"browser\";\n fields: BrowserFormField[];\n}\n\nexport interface ThreeDSBrowserStep {\n kind: \"method\" | \"challenge\";\n protocolVersion: \"1\" | \"2\";\n form: BrowserPostForm;\n completionEndpoint?: string;\n threeDSServerTransId?: string;\n}\n\nexport interface MountedThreeDSForm {\n form: HTMLFormElement;\n iframe?: HTMLIFrameElement;\n submit: () => void;\n remove: () => void;\n}\n\nexport interface ThreeDSMountOptions {\n document?: Document;\n container?: HTMLElement;\n challengeTarget?: \"_self\";\n submitter?: (form: HTMLFormElement) => void;\n}\n\nexport interface RunThreeDSBrowserFlowOptions extends ThreeDSMountOptions {\n completeThreeDSMethod?: (\n completion: ReturnType<typeof buildThreeDSMethodCompletion>,\n nextAction: PaymentNextAction,\n ) => Promise<ExecutePaymentResponse>;\n methodCompletionIndicator?: \"Y\" | \"N\" | \"U\";\n methodTimeoutMs?: number;\n signal?: AbortSignal;\n}\n\nexport type ThreeDSBrowserFlowResult =\n | {\n status: \"no_action\";\n response?: ExecutePaymentResponse;\n }\n | {\n status: \"method_completed\";\n response: ExecutePaymentResponse;\n methodResult: \"loaded\" | \"timeout\";\n }\n | {\n status: \"challenge_submitted\";\n action: PaymentNextAction;\n response?: ExecutePaymentResponse;\n mounted: MountedThreeDSForm;\n methodResult?: \"loaded\" | \"timeout\";\n };\n\nconst supportedColorDepths = [1, 4, 8, 15, 16, 24, 32, 48] as const;\n\nconst normalizeColorDepth = (value: number): BrowserInfo[\"color_depth\"] =>\n supportedColorDepths.includes(value as BrowserInfo[\"color_depth\"])\n ? (value as BrowserInfo[\"color_depth\"])\n : 24;\n\nconst resolveWindowSize = (width: number): NonNullable<BrowserInfo[\"window_size\"]> => {\n if (width >= 1000) return \"05\";\n if (width >= 600) return \"04\";\n if (width >= 500) return \"03\";\n if (width >= 390) return \"02\";\n return \"01\";\n};\n\nexport const collectBrowserInfo = (\n acceptHeader = \"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\",\n): BrowserInfo => {\n if (\n typeof window === \"undefined\" ||\n typeof navigator === \"undefined\" ||\n typeof screen === \"undefined\"\n ) {\n throw new Error(\"collectBrowserInfo must be called in a browser environment\");\n }\n return {\n accept_header: acceptHeader,\n language: navigator.language || \"en\",\n screen_width: screen.width,\n screen_height: screen.height,\n color_depth: normalizeColorDepth(screen.colorDepth),\n timezone_offset_minutes: new Date().getTimezoneOffset(),\n java_enabled: false,\n user_agent: navigator.userAgent,\n window_size: resolveWindowSize(window.innerWidth || screen.width),\n };\n};\n\nexport const getThreeDSAction = (nextAction?: PaymentNextAction): PaymentNextAction | null => {\n return nextAction ?? null;\n};\n\nexport const isThreeDSMethodAction = (nextAction?: PaymentNextAction): boolean => {\n return nextAction?.type === \"three_ds_method\" && nextAction.three_ds.phase === \"method\";\n};\n\nexport const isThreeDSChallengeAction = (nextAction?: PaymentNextAction): boolean => {\n return nextAction?.type === \"three_ds_challenge\" && nextAction.three_ds.phase === \"challenge\";\n};\n\nexport const buildThreeDSBrowserForm = (nextAction: PaymentNextAction): BrowserPostForm => ({\n action: nextAction.three_ds.submit.url,\n method: nextAction.three_ds.submit.method,\n target: nextAction.three_ds.submit.target,\n fields: nextAction.three_ds.submit.fields,\n});\n\nconst assertHTTPSActionURL = (action: string): void => {\n let parsed: URL;\n try {\n parsed = new URL(action);\n } catch {\n throw new Error(\"3DS form action must be an absolute HTTPS URL\");\n }\n if (parsed.protocol !== \"https:\") {\n throw new Error(\"3DS form action must use HTTPS\");\n }\n};\n\nexport const buildThreeDSBrowserStep = (\n nextAction?: PaymentNextAction,\n): ThreeDSBrowserStep | null => {\n const action = getThreeDSAction(nextAction);\n if (!action) return null;\n return {\n kind: action.three_ds.phase,\n protocolVersion: action.three_ds.version,\n form: buildThreeDSBrowserForm(action),\n completionEndpoint: action.three_ds.completion_endpoint,\n threeDSServerTransId: action.three_ds.three_ds_server_trans_id,\n };\n};\n\nexport const buildThreeDSMethodCompletion = (\n nextAction: PaymentNextAction,\n completionIndicator: \"Y\" | \"N\" | \"U\" = \"Y\",\n): { completion_indicator: \"Y\" | \"N\" | \"U\"; three_ds_server_trans_id: string } => {\n if (!isThreeDSMethodAction(nextAction) || !nextAction.three_ds.three_ds_server_trans_id) {\n throw new Error(\"nextAction must be a three_ds_method action with three_ds_server_trans_id\");\n }\n return {\n completion_indicator: completionIndicator,\n three_ds_server_trans_id: nextAction.three_ds.three_ds_server_trans_id,\n };\n};\n\nconst requireDocument = (explicitDocument?: Document): Document => {\n if (explicitDocument) return explicitDocument;\n if (typeof document === \"undefined\") {\n throw new Error(\"3DS browser helpers must be called in a browser environment\");\n }\n return document;\n};\n\nconst defaultSubmitter = (form: HTMLFormElement): void => {\n form.submit();\n};\n\nexport const mountThreeDSBrowserForm = (\n nextAction: PaymentNextAction,\n options: ThreeDSMountOptions = {},\n): MountedThreeDSForm => {\n const doc = requireDocument(options.document);\n const container = options.container ?? doc.body;\n const formDescriptor = buildThreeDSBrowserForm(nextAction);\n assertHTTPSActionURL(formDescriptor.action);\n const form = doc.createElement(\"form\");\n const target =\n formDescriptor.target === \"hidden_iframe\"\n ? `arcpay-three-ds-method-${crypto.randomUUID()}`\n : (options.challengeTarget ?? \"_self\");\n let iframe: HTMLIFrameElement | undefined;\n\n form.method = formDescriptor.method;\n form.action = formDescriptor.action;\n form.target = target;\n form.hidden = true;\n\n for (const field of formDescriptor.fields) {\n const input = doc.createElement(\"input\");\n input.type = \"hidden\";\n input.name = field.name;\n input.value = field.value;\n form.append(input);\n }\n\n if (formDescriptor.target === \"hidden_iframe\") {\n iframe = doc.createElement(\"iframe\");\n iframe.name = target;\n iframe.title = \"3-D Secure method\";\n iframe.hidden = true;\n container.append(iframe);\n }\n\n container.append(form);\n\n return {\n form,\n iframe,\n submit: () => (options.submitter ?? defaultSubmitter)(form),\n remove: () => {\n form.remove();\n iframe?.remove();\n },\n };\n};\n\nconst waitForMethodFrame = (\n mounted: MountedThreeDSForm,\n timeoutMs: number,\n signal?: AbortSignal,\n): Promise<\"loaded\" | \"timeout\"> =>\n new Promise((resolve, reject) => {\n if (!mounted.iframe) {\n resolve(\"loaded\");\n return;\n }\n if (signal?.aborted) {\n reject(new DOMException(\"The operation was aborted\", \"AbortError\"));\n return;\n }\n\n let settled = false;\n const cleanup = () => {\n mounted.iframe?.removeEventListener(\"load\", onLoad);\n signal?.removeEventListener(\"abort\", onAbort);\n clearTimeout(timer);\n };\n const settle = (result: \"loaded\" | \"timeout\") => {\n if (settled) return;\n settled = true;\n cleanup();\n resolve(result);\n };\n const onLoad = () => settle(\"loaded\");\n const onAbort = () => {\n if (settled) return;\n settled = true;\n cleanup();\n reject(new DOMException(\"The operation was aborted\", \"AbortError\"));\n };\n const timer = setTimeout(() => settle(\"timeout\"), timeoutMs);\n\n mounted.iframe.addEventListener(\"load\", onLoad, { once: true });\n signal?.addEventListener(\"abort\", onAbort, { once: true });\n });\n\nexport const runThreeDSBrowserFlow = async (\n nextAction: PaymentNextAction | undefined,\n options: RunThreeDSBrowserFlowOptions,\n): Promise<ThreeDSBrowserFlowResult> => {\n if (!nextAction) return { status: \"no_action\" };\n\n if (isThreeDSChallengeAction(nextAction)) {\n const mounted = mountThreeDSBrowserForm(nextAction, options);\n mounted.submit();\n return { status: \"challenge_submitted\", action: nextAction, mounted };\n }\n\n if (!isThreeDSMethodAction(nextAction)) return { status: \"no_action\" };\n const completeThreeDSMethod = options.completeThreeDSMethod;\n if (!completeThreeDSMethod) {\n throw new Error(\"completeThreeDSMethod is required for 3DS Method actions\");\n }\n\n const mounted = mountThreeDSBrowserForm(nextAction, options);\n try {\n mounted.submit();\n const methodResult = await waitForMethodFrame(\n mounted,\n options.methodTimeoutMs ?? 10_000,\n options.signal,\n );\n const indicator = options.methodCompletionIndicator ?? (methodResult === \"loaded\" ? \"Y\" : \"N\");\n const response = await completeThreeDSMethod(\n buildThreeDSMethodCompletion(nextAction, indicator),\n nextAction,\n );\n const followUpAction = getThreeDSAction(response.next_action);\n if (followUpAction && isThreeDSChallengeAction(followUpAction)) {\n const challengeMounted = mountThreeDSBrowserForm(followUpAction, options);\n challengeMounted.submit();\n return {\n status: \"challenge_submitted\",\n action: followUpAction,\n response,\n mounted: challengeMounted,\n methodResult,\n };\n }\n return { status: \"method_completed\", response, methodResult };\n } finally {\n mounted.remove();\n }\n};\n\nconst htmlEscape = (value: string): string =>\n value\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&#39;\");\n\nexport const buildThreeDSAutoSubmitHtml = (nextAction: PaymentNextAction): string => {\n const form = buildThreeDSBrowserForm(nextAction);\n assertHTTPSActionURL(form.action);\n const target = form.target === \"hidden_iframe\" ? \"arcpay-three-ds-method\" : \"_self\";\n const inputs = form.fields\n .map(\n (field) =>\n `<input type=\"hidden\" name=\"${htmlEscape(field.name)}\" value=\"${htmlEscape(field.value)}\">`,\n )\n .join(\"\");\n const iframe =\n form.target === \"hidden_iframe\"\n ? '<iframe name=\"arcpay-three-ds-method\" title=\"3-D Secure method\" hidden></iframe>'\n : \"\";\n return `<!doctype html><html><head><meta charset=\"utf-8\"></head><body>${iframe}<form method=\"POST\" action=\"${htmlEscape(form.action)}\" target=\"${target}\">${inputs}</form><script>document.forms[0].submit();</script></body></html>`;\n};\n","export { ArcPay } from \"./core/arcpay\";\nexport type { ArcPayInstance, ArcPayLoadOptions } from \"./core/arcpay\";\nexport {\n ArcPayError,\n isValidationError,\n isAuthenticationError,\n isAuthorizationError,\n isStateError,\n isRateLimitError,\n isApiError,\n isNetworkError,\n isChallengeAborted,\n} from \"./core/errors\";\nexport type { ArcPayErrorType } from \"./core/errors\";\nexport type { Environment } from \"./core/env\";\nexport type { TokenizeResult } from \"./tokenize/tokenize\";\nexport type { CardScheme } from \"./tokenize/scheme\";\nexport {\n buildThreeDSAutoSubmitHtml,\n buildThreeDSBrowserForm,\n buildThreeDSBrowserStep,\n buildThreeDSMethodCompletion,\n collectBrowserInfo,\n getThreeDSAction,\n isThreeDSChallengeAction,\n isThreeDSMethodAction,\n mountThreeDSBrowserForm,\n runThreeDSBrowserFlow,\n} from \"./three-ds\";\nexport type {\n BrowserFormField,\n BrowserInfo,\n BrowserPostForm,\n MountedThreeDSForm,\n RunThreeDSBrowserFlowOptions,\n ThreeDSAction,\n ThreeDSBrowserStep,\n ThreeDSBrowserFlowResult,\n ThreeDSMountOptions,\n} from \"./three-ds\";\nexport const SDK_VERSION = \"0.1.23\";\n\nexport type { FieldType } from \"./elements/postmessage\";\nexport type { ElementOptions, ElementEvent } from \"./elements/element\";\nexport { Elements } from \"./elements/elements\";\nexport type { ElementsOptions } from \"./elements/elements\";\n"]}
1
+ {"version":3,"sources":["../src/core/errors.ts","../src/core/env.ts","../src/core/sandbox-banner.ts","../src/elements/postmessage.ts","../src/elements/style.ts","../src/elements/element.ts","../src/elements/elements.ts","../src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AC,KAAA,KAClB,KAAA,CACG,QAAQ,IAAA,EAAM,OAAO,CAAA,CACrB,OAAA,CAAQ,IAAA,EAAM,MAAM,EACpB,OAAA,CAAQ,IAAA,EAAM,MAAM,CAAA,CACpB,OAAA,CAAQ,MAAM,QAAQ,CAAA,CACtB,OAAA,CAAQ,IAAA,EAAM,OAAO,CAAA;AAEnB,IAAM,0BAAA,GAA6B,CAAC,UAAA,KAA0C;AACnF,EAAA,MAAM,IAAA,GAAO,wBAAwB,UAAU,CAAA;AAC/C,EAAA,oBAAA,CAAqB,KAAK,MAAM,CAAA;AAChC,EAAA,MAAM,MAAA,GAAS,IAAA,CAAK,MAAA,KAAW,eAAA,GAAkB,wBAAA,GAA2B,OAAA;AAC5E,EAAA,MAAM,MAAA,GAAS,KAAK,MAAA,CACjB,GAAA;AAAA,IACC,CAAC,KAAA,KACC,CAAA,2BAAA,EAA8B,UAAA,CAAW,KAAA,CAAM,IAAI,CAAC,CAAA,SAAA,EAAY,UAAA,CAAW,KAAA,CAAM,KAAK,CAAC,CAAA,EAAA;AAAA,GAC3F,CACC,KAAK,EAAE,CAAA;AACV,EAAA,MAAM,MAAA,GACJ,IAAA,CAAK,MAAA,KAAW,eAAA,GACZ,kFAAA,GACA,EAAA;AACN,EAAA,OAAO,CAAA,8DAAA,EAAiE,MAAM,CAAA,4BAAA,EAA+B,UAAA,CAAW,IAAA,CAAK,MAAM,CAAC,CAAA,UAAA,EAAa,MAAM,CAAA,EAAA,EAAK,MAAM,CAAA,iEAAA,CAAA;AACpK;;;ACxSO,IAAM,WAAA,GAAc","file":"index.mjs","sourcesContent":["export type ArcPayErrorType =\n | \"validation_error\"\n | \"configuration_error\"\n | \"authentication_error\"\n | \"authorization_error\"\n | \"state_error\"\n | \"rate_limit_error\"\n | \"api_error\"\n | \"network_error\"\n | \"challenge_aborted\";\n\ninterface ArcPayErrorInit {\n type: ArcPayErrorType;\n message: string;\n code?: string;\n param?: string;\n paymentId?: string;\n declineCode?: string;\n retryable: boolean;\n requestId?: string;\n}\n\nexport class ArcPayError extends Error {\n readonly type: ArcPayErrorType;\n readonly code?: string;\n readonly param?: string;\n readonly paymentId?: string;\n readonly declineCode?: string;\n readonly retryable: boolean;\n readonly requestId?: string;\n\n constructor(init: ArcPayErrorInit) {\n super(init.message);\n this.name = \"ArcPayError\";\n this.type = init.type;\n this.code = init.code;\n this.param = init.param;\n this.paymentId = init.paymentId;\n this.declineCode = init.declineCode;\n this.retryable = init.retryable;\n this.requestId = init.requestId;\n }\n}\n\nexport const isValidationError = (e: unknown): e is ArcPayError =>\n e instanceof ArcPayError && e.type === \"validation_error\";\nconst isConfigurationError = (e: unknown): e is ArcPayError =>\n e instanceof ArcPayError && e.type === \"configuration_error\";\nexport const isAuthenticationError = (e: unknown): e is ArcPayError =>\n e instanceof ArcPayError && e.type === \"authentication_error\";\nexport const isAuthorizationError = (e: unknown): e is ArcPayError =>\n e instanceof ArcPayError && e.type === \"authorization_error\";\nexport const isStateError = (e: unknown): e is ArcPayError =>\n e instanceof ArcPayError && e.type === \"state_error\";\nexport const isRateLimitError = (e: unknown): e is ArcPayError =>\n e instanceof ArcPayError && e.type === \"rate_limit_error\";\nexport const isApiError = (e: unknown): e is ArcPayError =>\n e instanceof ArcPayError && e.type === \"api_error\";\nexport const isNetworkError = (e: unknown): e is ArcPayError =>\n e instanceof ArcPayError && e.type === \"network_error\";\nexport const isChallengeAborted = (e: unknown): e is ArcPayError =>\n e instanceof ArcPayError && e.type === \"challenge_aborted\";\n","import { ArcPayError } from \"./errors\";\n\nexport type Environment = \"sandbox\" | \"live\";\n\nexport const detectEnvironment = (publishableKey: string): Environment =>\n publishableKey.startsWith(\"pk_test_\") ? \"sandbox\" : \"live\";\n\nexport const validatePublishableKey = (key: unknown): asserts key is string => {\n if (typeof key !== \"string\" || key.length === 0) {\n throw new ArcPayError({\n type: \"validation_error\",\n code: \"invalid_publishable_key\",\n message: \"Publishable key must be a non-empty string\",\n retryable: false,\n });\n }\n if (!key.startsWith(\"pk_test_\") && !key.startsWith(\"pk_live_\")) {\n throw new ArcPayError({\n type: \"validation_error\",\n code: \"invalid_publishable_key\",\n message:\n \"Publishable key must start with pk_test_ or pk_live_. Secret keys (sk_*) cannot be used in browser.\",\n retryable: false,\n });\n }\n};\n","const BANNER_ATTR = \"data-arcpay-sandbox-banner\";\n\nexport const showSandboxBanner = (): void => {\n if (typeof document === \"undefined\") return;\n if (document.querySelector(`[${BANNER_ATTR}]`)) return;\n\n const bar = document.createElement(\"div\");\n bar.setAttribute(BANNER_ATTR, \"\");\n bar.style.cssText =\n \"position:fixed;top:0;left:0;right:0;z-index:2147483647;background:#ffd166;color:#222;font:13px/1.4 system-ui,sans-serif;padding:6px 12px;display:flex;align-items:center;justify-content:center;box-shadow:0 1px 3px rgba(0,0,0,0.1);\";\n\n const text = document.createElement(\"span\");\n text.textContent = \"ARC PAY TEST MODE — payments are simulated\";\n bar.appendChild(text);\n\n const dismiss = document.createElement(\"button\");\n dismiss.type = \"button\";\n dismiss.setAttribute(\"data-arcpay-banner-dismiss\", \"\");\n dismiss.textContent = \"×\";\n dismiss.setAttribute(\"aria-label\", \"Dismiss test mode banner\");\n dismiss.style.cssText =\n \"margin-left:12px;background:transparent;border:0;font-size:18px;cursor:pointer;color:inherit;\";\n dismiss.addEventListener(\"click\", () => bar.remove());\n bar.appendChild(dismiss);\n\n document.body.appendChild(bar);\n};\n","import { ArcPayError } from \"../core/errors\";\n\nexport type FieldType = \"cardNumber\" | \"cardExpiry\" | \"cardCvv\";\n\n// Parent → iframe\nexport type ParentToIframe =\n | { type: \"arcpay:hello\"; origin: string; publishableKey: string; channelId: string }\n | { type: \"arcpay:style\"; payload: StyleSubset }\n | { type: \"arcpay:placeholder\"; field: FieldType; placeholder: string }\n | { type: \"arcpay:focus\" }\n | { type: \"arcpay:clear\" }\n | { type: \"arcpay:tokenize\"; paymentId: string; idempotencyKey: string };\n\n// iframe → parent\nexport type IframeToParent =\n | { type: \"arcpay:ready\" }\n | { type: \"arcpay:rejected\"; reason: string }\n | {\n type: \"arcpay:change\";\n field: FieldType;\n isValid: boolean;\n isEmpty: boolean;\n isComplete: boolean;\n brand?: string;\n lastFour?: string;\n }\n | {\n type: \"arcpay:tokenize-result\";\n cardTokenId: string;\n cardMask: string;\n cardScheme: string;\n cardBin: string;\n expiresIn: number;\n expiresAt: string;\n }\n | { type: \"arcpay:tokenize-error\"; errorType: string; code?: string; message: string };\n\nexport interface StyleSubset {\n base: Record<string, string>;\n invalid?: Record<string, string>;\n focus?: Record<string, string>;\n complete?: Record<string, string>;\n empty?: Record<string, string>;\n}\n\ntype TokenizeErrorType = \"validation_error\" | \"configuration_error\" | \"network_error\" | \"api_error\";\n\nconst ARCPAY_TYPE_PREFIX = \"arcpay:\";\n\nconst isArcpayMessage = (data: unknown): data is { type: string } =>\n typeof data === \"object\" &&\n data !== null &&\n \"type\" in data &&\n typeof (data as { type: unknown }).type === \"string\" &&\n (data as { type: string }).type.startsWith(ARCPAY_TYPE_PREFIX);\n\nexport const postToIframe = (\n iframe: HTMLIFrameElement,\n message: ParentToIframe,\n targetOrigin: string,\n): void => {\n if (targetOrigin === \"*\") {\n throw new ArcPayError({\n type: \"validation_error\",\n code: \"wildcard_origin_forbidden\",\n message: \"postToIframe: targetOrigin cannot be '*'\",\n retryable: false,\n });\n }\n if (!iframe.contentWindow) {\n throw new ArcPayError({\n type: \"validation_error\",\n code: \"iframe_not_loaded\",\n message: \"postToIframe: iframe.contentWindow is null (iframe not mounted)\",\n retryable: false,\n });\n }\n iframe.contentWindow.postMessage(message, targetOrigin);\n};\n\nexport const postToParent = (message: IframeToParent, targetOrigin: string): void => {\n if (targetOrigin === \"*\") {\n throw new Error(\"postToParent: targetOrigin cannot be '*'\");\n }\n window.parent.postMessage(message, targetOrigin);\n};\n\nexport const parseIncoming = <T extends { type: string }>(\n event: MessageEvent,\n expectedOrigin: string,\n): T | null => {\n if (event.origin !== expectedOrigin) return null;\n if (!isArcpayMessage(event.data)) return null;\n return event.data as T;\n};\n","import type { StyleSubset } from \"./postmessage\";\nimport { ArcPayError } from \"../core/errors\";\n\nexport type HostedFieldsTheme = \"none\" | \"arcpay\";\n\nexport interface HostedFieldsAppearanceVariables {\n fontFamily?: string;\n fontSize?: string;\n fontWeight?: string;\n fontStyle?: string;\n lineHeight?: string;\n letterSpacing?: string;\n textAlign?: string;\n colorText?: string;\n colorPlaceholder?: string;\n colorDanger?: string;\n colorSuccess?: string;\n colorBackground?: string;\n caretColor?: string;\n}\n\nexport type HostedFieldsAppearanceRule = \"base\" | \"focus\" | \"invalid\" | \"complete\" | \"empty\";\n\nexport interface HostedFieldsAppearance {\n theme?: HostedFieldsTheme;\n variables?: HostedFieldsAppearanceVariables;\n rules?: Partial<Record<HostedFieldsAppearanceRule, Record<string, string>>>;\n}\n\nconst ALLOWED_PROPERTIES = new Set([\n \"--arcpay-placeholder-color\",\n \"background-color\",\n \"caret-color\",\n \"color\",\n \"font-family\",\n \"font-size\",\n \"font-style\",\n \"font-weight\",\n \"letter-spacing\",\n \"line-height\",\n \"opacity\",\n \"text-align\",\n \"text-decoration\",\n \"text-transform\",\n]);\n\nconst ARCPAY_THEME: StyleSubset = {\n base: {\n \"font-family\":\n 'Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif',\n \"font-size\": \"16px\",\n \"line-height\": \"24px\",\n color: \"#111827\",\n \"--arcpay-placeholder-color\": \"#9ca3af\",\n \"caret-color\": \"#111827\",\n },\n focus: {\n color: \"#111827\",\n },\n invalid: {\n color: \"#dc2626\",\n },\n complete: {\n color: \"#111827\",\n },\n empty: {\n color: \"#111827\",\n },\n};\n\nconst mergeBlock = (\n target: Record<string, string> | undefined,\n source: Record<string, string> | undefined,\n): Record<string, string> | undefined => {\n if (!target && !source) return undefined;\n return { ...(target ?? {}), ...(source ?? {}) };\n};\n\nconst setIfPresent = (\n block: Record<string, string>,\n key: string,\n value: string | undefined,\n): void => {\n if (value !== undefined) block[key] = value;\n};\n\nconst assertKnownTheme = (theme: HostedFieldsTheme | undefined): void => {\n if (theme === undefined || theme === \"none\" || theme === \"arcpay\") return;\n throw new ArcPayError({\n type: \"validation_error\",\n code: \"invalid_hosted_fields_theme\",\n message: `Unsupported Hosted Fields appearance theme: ${String(theme)}`,\n retryable: false,\n });\n};\n\nconst sanitizeBlock = (block: Record<string, string>): Record<string, string> => {\n const out: Record<string, string> = {};\n for (const [key, value] of Object.entries(block)) {\n const normalizedKey = key.toLowerCase();\n if (!ALLOWED_PROPERTIES.has(normalizedKey)) {\n continue;\n }\n out[normalizedKey] = value;\n }\n return out;\n};\n\nexport const sanitizeStyle = (style: StyleSubset): StyleSubset => {\n const result: StyleSubset = { base: sanitizeBlock(style.base) };\n if (style.invalid !== undefined) result.invalid = sanitizeBlock(style.invalid);\n if (style.focus !== undefined) result.focus = sanitizeBlock(style.focus);\n if (style.complete !== undefined) result.complete = sanitizeBlock(style.complete);\n if (style.empty !== undefined) result.empty = sanitizeBlock(style.empty);\n return result;\n};\n\nexport const buildStyleFromAppearance = (appearance?: HostedFieldsAppearance): StyleSubset => {\n assertKnownTheme(appearance?.theme);\n const themeStyle: StyleSubset = appearance?.theme === \"arcpay\" ? ARCPAY_THEME : { base: {} };\n const variableStyle: StyleSubset = { base: {} };\n const variables = appearance?.variables;\n\n if (variables) {\n setIfPresent(variableStyle.base, \"font-family\", variables.fontFamily);\n setIfPresent(variableStyle.base, \"font-size\", variables.fontSize);\n setIfPresent(variableStyle.base, \"font-weight\", variables.fontWeight);\n setIfPresent(variableStyle.base, \"font-style\", variables.fontStyle);\n setIfPresent(variableStyle.base, \"line-height\", variables.lineHeight);\n setIfPresent(variableStyle.base, \"letter-spacing\", variables.letterSpacing);\n setIfPresent(variableStyle.base, \"text-align\", variables.textAlign);\n setIfPresent(variableStyle.base, \"color\", variables.colorText);\n setIfPresent(variableStyle.base, \"--arcpay-placeholder-color\", variables.colorPlaceholder);\n setIfPresent(variableStyle.base, \"background-color\", variables.colorBackground);\n setIfPresent(variableStyle.base, \"caret-color\", variables.caretColor);\n\n if (variables.colorDanger !== undefined) {\n variableStyle.invalid = { color: variables.colorDanger };\n }\n if (variables.colorSuccess !== undefined) {\n variableStyle.complete = { color: variables.colorSuccess };\n }\n }\n\n const rules = appearance?.rules;\n const combined: StyleSubset = {\n base: {\n ...themeStyle.base,\n ...variableStyle.base,\n ...(rules?.base ?? {}),\n },\n };\n\n const focus = mergeBlock(mergeBlock(themeStyle.focus, variableStyle.focus), rules?.focus);\n const invalid = mergeBlock(mergeBlock(themeStyle.invalid, variableStyle.invalid), rules?.invalid);\n const complete = mergeBlock(\n mergeBlock(themeStyle.complete, variableStyle.complete),\n rules?.complete,\n );\n const empty = mergeBlock(mergeBlock(themeStyle.empty, variableStyle.empty), rules?.empty);\n\n if (focus !== undefined) combined.focus = focus;\n if (invalid !== undefined) combined.invalid = invalid;\n if (complete !== undefined) combined.complete = complete;\n if (empty !== undefined) combined.empty = empty;\n\n return sanitizeStyle(combined);\n};\n","import { ArcPayError } from \"../core/errors\";\nimport {\n type FieldType,\n type ParentToIframe,\n type IframeToParent,\n postToIframe,\n parseIncoming,\n} from \"./postmessage\";\nimport { buildStyleFromAppearance, type HostedFieldsAppearance } from \"./style\";\n\nexport interface ElementOptions {\n /** Iframe-safe input appearance. Container layout remains merchant-owned CSS. */\n appearance?: HostedFieldsAppearance;\n placeholder?: string;\n}\n\nexport type ElementEvent =\n | { type: \"ready\" }\n | {\n type: \"change\";\n isValid: boolean;\n isEmpty: boolean;\n isComplete: boolean;\n brand?: string;\n lastFour?: string;\n }\n | { type: \"error\"; reason: string };\n\ntype Listener = (event: ElementEvent) => void;\ntype ElementEventName = ElementEvent[\"type\"];\n\nconst FIELD_TITLES: Record<FieldType, string> = {\n cardNumber: \"Arc Pay card number\",\n cardExpiry: \"Arc Pay card expiration date\",\n cardCvv: \"Arc Pay card security code\",\n};\n\nexport interface ElementContext {\n iframeBase: string;\n publishableKey: string;\n channelId: string;\n}\n\nexport class Element {\n private iframe: HTMLIFrameElement | null = null;\n private readonly listeners: Record<ElementEventName, Set<Listener>> = {\n ready: new Set<Listener>(),\n change: new Set<Listener>(),\n error: new Set<Listener>(),\n };\n private status: \"pending\" | \"ready\" | \"error\" = \"pending\";\n private messageHandler: ((e: MessageEvent) => void) | null = null;\n\n constructor(\n public readonly field: FieldType,\n private readonly options: ElementOptions,\n private readonly context: ElementContext,\n ) {}\n\n mount(target: string | HTMLElement): void {\n if (this.iframe) {\n throw new ArcPayError({\n type: \"validation_error\",\n code: \"already_mounted\",\n message: `Element ${this.field} is already mounted`,\n retryable: false,\n });\n }\n const container = typeof target === \"string\" ? document.querySelector(target) : target;\n if (!(container instanceof HTMLElement)) {\n throw new ArcPayError({\n type: \"validation_error\",\n code: \"mount_target_not_found\",\n message: `mount target not found: ${String(target)}`,\n retryable: false,\n });\n }\n\n const iframe = document.createElement(\"iframe\");\n iframe.src = `${this.context.iframeBase}/iframe/${this.field}`;\n iframe.style.cssText = \"border:0;width:100%;height:100%;display:block;\";\n iframe.setAttribute(\"allow\", \"payment\");\n iframe.setAttribute(\"data-arcpay-element\", this.field);\n iframe.setAttribute(\"title\", FIELD_TITLES[this.field]);\n iframe.setAttribute(\"aria-label\", FIELD_TITLES[this.field]);\n container.appendChild(iframe);\n this.iframe = iframe;\n\n const expectedOrigin = new URL(this.context.iframeBase).origin;\n\n this.messageHandler = (event: MessageEvent) => {\n // C1: source guard — only accept messages from this element's own iframe.\n // Without this, any iframe at the same origin (e.g. cardExpiry, cardCvv)\n // could trigger handlers on cardNumber and vice-versa.\n if (event.source !== this.iframe?.contentWindow) return;\n // C4: use parseIncoming for origin + arcpay: prefix guard.\n const data = parseIncoming<IframeToParent>(event, expectedOrigin);\n if (!data) return;\n this.handleMessage(data);\n };\n window.addEventListener(\"message\", this.messageHandler);\n\n iframe.addEventListener(\n \"load\",\n () => {\n if (!this.iframe) return;\n const hello: ParentToIframe = {\n type: \"arcpay:hello\",\n origin: window.location.origin,\n publishableKey: this.context.publishableKey,\n channelId: this.context.channelId,\n };\n postToIframe(this.iframe, hello, expectedOrigin);\n },\n { once: true },\n );\n }\n\n private handleMessage(data: IframeToParent): void {\n if (data.type === \"arcpay:ready\") {\n this.status = \"ready\";\n if (this.options.appearance) {\n this.send({\n type: \"arcpay:style\",\n payload: buildStyleFromAppearance(this.options.appearance),\n });\n }\n if (this.options.placeholder) {\n this.send({\n type: \"arcpay:placeholder\",\n field: this.field,\n placeholder: this.options.placeholder,\n });\n }\n this.emit({ type: \"ready\" });\n } else if (data.type === \"arcpay:rejected\") {\n this.status = \"error\";\n this.emit({ type: \"error\", reason: data.reason });\n } else if (data.type === \"arcpay:change\" && data.field === this.field) {\n this.emit({\n type: \"change\",\n isValid: data.isValid,\n isEmpty: data.isEmpty,\n isComplete: data.isComplete,\n brand: data.brand,\n lastFour: data.lastFour,\n });\n }\n // arcpay:tokenize-result / arcpay:tokenize-error handled by Elements factory (Task 9).\n }\n\n update(options: { appearance?: HostedFieldsAppearance; placeholder?: string }): void {\n if (options.appearance) {\n this.send({\n type: \"arcpay:style\",\n payload: buildStyleFromAppearance(options.appearance),\n });\n }\n if (options.placeholder) {\n this.send({\n type: \"arcpay:placeholder\",\n field: this.field,\n placeholder: options.placeholder,\n });\n }\n }\n\n destroy(): void {\n if (this.iframe) {\n this.iframe.remove();\n this.iframe = null;\n }\n if (this.messageHandler) {\n window.removeEventListener(\"message\", this.messageHandler);\n this.messageHandler = null;\n }\n for (const listeners of Object.values(this.listeners)) {\n listeners.clear();\n }\n this.status = \"pending\";\n }\n\n on(event: ElementEventName, callback: Listener): () => void {\n this.listeners[event].add(callback);\n return () => this.listeners[event].delete(callback);\n }\n\n focus(): void {\n this.send({ type: \"arcpay:focus\" });\n }\n\n clear(): void {\n this.send({ type: \"arcpay:clear\" });\n }\n\n isReady(): boolean {\n return this.status === \"ready\";\n }\n\n /**\n * Internal: returns the iframe's contentWindow for source-filtering in\n * Elements.doTokenize(). Returns null when the iframe is not yet mounted\n * or when jsdom has not yet populated contentWindow (test environment).\n */\n getIframeContentWindow(): Window | null {\n return this.iframe?.contentWindow ?? null;\n }\n\n /** Internal: used by Elements factory to send tokenize commands. */\n send(message: ParentToIframe): void {\n if (!this.iframe) {\n throw new ArcPayError({\n type: \"validation_error\",\n code: \"not_mounted\",\n message: `Element ${this.field} is not mounted`,\n retryable: false,\n });\n }\n postToIframe(this.iframe, message, new URL(this.context.iframeBase).origin);\n }\n\n private emit(event: ElementEvent): void {\n for (const listener of this.listeners[event.type]) {\n listener(event);\n }\n }\n}\n","import { ArcPayError } from \"../core/errors\";\nimport { Element, type ElementContext, type ElementOptions } from \"./element\";\nimport type { FieldType, IframeToParent } from \"./postmessage\";\nimport { parseIncoming } from \"./postmessage\";\nimport type { TokenizeResult } from \"../tokenize/tokenize\";\nimport type { HostedFieldsAppearance } from \"./style\";\n\nexport type {};\n\nexport interface ElementsOptions {\n /** Default iframe-safe input appearance applied to elements created by this factory. */\n appearance?: HostedFieldsAppearance;\n}\n\nconst DEFAULT_IFRAME_BASE = \"https://sdk.arcpay.space\";\n\nconst createChannelId = (): string => {\n if (!globalThis.crypto?.randomUUID) {\n throw new ArcPayError({\n type: \"validation_error\",\n code: \"crypto_unavailable\",\n message: \"crypto.randomUUID is required for Hosted Fields\",\n retryable: false,\n });\n }\n return globalThis.crypto.randomUUID();\n};\n\nexport class Elements {\n private readonly elementMap = new Map<FieldType, Element>();\n private readonly iframeBase: string;\n private readonly publishableKey: string;\n private readonly channelId: string;\n private tokenizeInFlight = false;\n private readonly appearance?: HostedFieldsAppearance;\n\n constructor(opts: {\n publishableKey: string;\n iframeBase?: string;\n appearance?: HostedFieldsAppearance;\n }) {\n this.publishableKey = opts.publishableKey;\n this.iframeBase = opts.iframeBase ?? DEFAULT_IFRAME_BASE;\n this.channelId = createChannelId();\n this.appearance = opts.appearance;\n }\n\n create(field: FieldType, options: ElementOptions = {}): Element {\n if (this.elementMap.has(field)) {\n throw new ArcPayError({\n type: \"validation_error\",\n code: \"duplicate_element\",\n message: `Element for ${field} already created`,\n retryable: false,\n });\n }\n const ctx: ElementContext = {\n iframeBase: this.iframeBase,\n publishableKey: this.publishableKey,\n channelId: this.channelId,\n };\n const element = new Element(\n field,\n {\n ...options,\n appearance: options.appearance ?? this.appearance,\n },\n ctx,\n );\n this.elementMap.set(field, element);\n return element;\n }\n\n async tokenize(paymentId: string, idempotencyKey: string): Promise<TokenizeResult> {\n // C2: concurrent-call guard — only one tokenize() may be in-flight at a time.\n if (this.tokenizeInFlight) {\n throw new ArcPayError({\n type: \"validation_error\",\n code: \"tokenize_in_progress\",\n message: \"A tokenize() call is already in progress for this Elements instance\",\n retryable: false,\n });\n }\n\n const cardNumber = this.elementMap.get(\"cardNumber\");\n const cardExpiry = this.elementMap.get(\"cardExpiry\");\n const cardCvv = this.elementMap.get(\"cardCvv\");\n\n if (!cardNumber || !cardExpiry || !cardCvv) {\n throw new ArcPayError({\n type: \"validation_error\",\n code: \"incomplete_elements\",\n message:\n \"All three elements (cardNumber, cardExpiry, cardCvv) must be created and mounted before tokenize()\",\n retryable: false,\n });\n }\n if (!cardNumber.isReady() || !cardExpiry.isReady() || !cardCvv.isReady()) {\n throw new ArcPayError({\n type: \"validation_error\",\n code: \"elements_not_ready\",\n message: \"Wait for all elements to fire 'ready' event before tokenize()\",\n retryable: false,\n });\n }\n\n this.tokenizeInFlight = true;\n try {\n return await this.doTokenize(cardNumber, paymentId, idempotencyKey);\n } finally {\n this.tokenizeInFlight = false;\n }\n }\n\n private doTokenize(\n cardNumber: Element,\n paymentId: string,\n idempotencyKey: string,\n ): Promise<TokenizeResult> {\n const iframeOrigin = new URL(this.iframeBase).origin;\n // C1: obtain reference to the cardNumber iframe's contentWindow before\n // registering the listener so we can filter by source.\n const cardIframeWindow = cardNumber.getIframeContentWindow();\n\n return new Promise<TokenizeResult>((resolve, reject) => {\n // C3: 30-second timeout — rejects and cleans up if no result arrives.\n const timer = window.setTimeout(() => {\n window.removeEventListener(\"message\", onMessage);\n reject(\n new ArcPayError({\n type: \"network_error\",\n code: \"tokenize_timeout\",\n message: \"tokenize() timed out after 30 seconds\",\n retryable: true,\n paymentId,\n }),\n );\n }, 30_000);\n\n const onMessage = (event: MessageEvent) => {\n // C1: source guard — only accept messages from the cardNumber iframe.\n if (cardIframeWindow !== null && event.source !== cardIframeWindow) return;\n // C4: use parseIncoming for origin + arcpay: prefix guard.\n const data = parseIncoming<IframeToParent>(event, iframeOrigin);\n if (!data) return;\n\n if (data.type === \"arcpay:tokenize-result\") {\n clearTimeout(timer);\n window.removeEventListener(\"message\", onMessage);\n resolve({\n cardTokenId: data.cardTokenId,\n cardMask: data.cardMask,\n cardScheme: data.cardScheme,\n cardBin: data.cardBin,\n expiresIn: data.expiresIn,\n expiresAt: data.expiresAt,\n });\n } else if (data.type === \"arcpay:tokenize-error\") {\n clearTimeout(timer);\n window.removeEventListener(\"message\", onMessage);\n reject(\n new ArcPayError({\n type:\n data.errorType === \"validation_error\" ||\n data.errorType === \"configuration_error\" ||\n data.errorType === \"network_error\" ||\n data.errorType === \"api_error\"\n ? data.errorType\n : \"api_error\",\n code: data.code,\n message: data.message,\n retryable: false,\n paymentId,\n }),\n );\n }\n };\n\n window.addEventListener(\"message\", onMessage);\n cardNumber.send({ type: \"arcpay:tokenize\", paymentId, idempotencyKey });\n });\n }\n\n destroy(): void {\n for (const el of this.elementMap.values()) {\n el.destroy();\n }\n this.elementMap.clear();\n }\n}\n","import {\n detectEnvironment,\n type Environment,\n validatePublishableKey as _validatePublishableKey,\n} from \"./env\";\nimport { showSandboxBanner } from \"./sandbox-banner\";\nimport { Elements, type ElementsOptions } from \"../elements/elements\";\n\nconst validatePublishableKey: (key: unknown) => asserts key is string = _validatePublishableKey;\n\nexport interface ArcPayLoadOptions {\n readonly _reserved?: never;\n}\n\nexport interface ArcPayInstance {\n readonly publishableKey: string;\n readonly environment: Environment;\n elements: (opts?: ElementsOptions) => Elements;\n}\n\nconst cache = new Map<string, Promise<ArcPayInstance>>();\n\nconst buildInstance = (publishableKey: string): ArcPayInstance => {\n if (detectEnvironment(publishableKey) === \"sandbox\") {\n showSandboxBanner();\n }\n return {\n publishableKey,\n environment: detectEnvironment(publishableKey),\n elements: (opts = {}) => new Elements({ publishableKey, ...opts }),\n };\n};\n\nfunction load(publishableKey: string): Promise<ArcPayInstance> {\n try {\n validatePublishableKey(publishableKey);\n } catch (err) {\n return Promise.reject(err);\n }\n const key = publishableKey;\n const existing = cache.get(key);\n if (existing) return existing;\n const promise = Promise.resolve(buildInstance(publishableKey));\n cache.set(key, promise);\n return promise;\n}\n\nconst resetForTests = (): void => {\n cache.clear();\n};\n\nexport const ArcPay = {\n load,\n __resetForTests: resetForTests,\n};\n","import type { CardBrowserInfo, ExecutePaymentResponse, PaymentNextAction } from \"../server/types\";\n\nexport type ThreeDSAction = PaymentNextAction;\nexport type BrowserInfo = CardBrowserInfo;\n\nexport interface BrowserFormField {\n name: string;\n value: string;\n}\n\nexport interface BrowserPostForm {\n action: string;\n method: \"POST\";\n target: \"hidden_iframe\" | \"browser\";\n fields: BrowserFormField[];\n}\n\nexport interface ThreeDSBrowserStep {\n kind: \"method\" | \"challenge\";\n protocolVersion: \"1\" | \"2\";\n form: BrowserPostForm;\n completionEndpoint?: string;\n threeDSServerTransId?: string;\n}\n\nexport interface MountedThreeDSForm {\n form: HTMLFormElement;\n iframe?: HTMLIFrameElement;\n submit: () => void;\n remove: () => void;\n}\n\nexport interface ThreeDSMountOptions {\n document?: Document;\n container?: HTMLElement;\n challengeTarget?: \"_self\";\n submitter?: (form: HTMLFormElement) => void;\n}\n\nexport interface RunThreeDSBrowserFlowOptions extends ThreeDSMountOptions {\n completeThreeDSMethod?: (\n completion: ReturnType<typeof buildThreeDSMethodCompletion>,\n nextAction: PaymentNextAction,\n ) => Promise<ExecutePaymentResponse>;\n methodCompletionIndicator?: \"Y\" | \"N\" | \"U\";\n methodTimeoutMs?: number;\n signal?: AbortSignal;\n}\n\nexport type ThreeDSBrowserFlowResult =\n | {\n status: \"no_action\";\n response?: ExecutePaymentResponse;\n }\n | {\n status: \"method_completed\";\n response: ExecutePaymentResponse;\n methodResult: \"loaded\" | \"timeout\";\n }\n | {\n status: \"challenge_submitted\";\n action: PaymentNextAction;\n response?: ExecutePaymentResponse;\n mounted: MountedThreeDSForm;\n methodResult?: \"loaded\" | \"timeout\";\n };\n\nconst supportedColorDepths = [1, 4, 8, 15, 16, 24, 32, 48] as const;\n\nconst normalizeColorDepth = (value: number): BrowserInfo[\"color_depth\"] =>\n supportedColorDepths.includes(value as BrowserInfo[\"color_depth\"])\n ? (value as BrowserInfo[\"color_depth\"])\n : 24;\n\nconst resolveWindowSize = (width: number): NonNullable<BrowserInfo[\"window_size\"]> => {\n if (width >= 1000) return \"05\";\n if (width >= 600) return \"04\";\n if (width >= 500) return \"03\";\n if (width >= 390) return \"02\";\n return \"01\";\n};\n\nexport const collectBrowserInfo = (\n acceptHeader = \"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\",\n): BrowserInfo => {\n if (\n typeof window === \"undefined\" ||\n typeof navigator === \"undefined\" ||\n typeof screen === \"undefined\"\n ) {\n throw new Error(\"collectBrowserInfo must be called in a browser environment\");\n }\n return {\n accept_header: acceptHeader,\n language: navigator.language || \"en\",\n screen_width: screen.width,\n screen_height: screen.height,\n color_depth: normalizeColorDepth(screen.colorDepth),\n timezone_offset_minutes: new Date().getTimezoneOffset(),\n java_enabled: false,\n user_agent: navigator.userAgent,\n window_size: resolveWindowSize(window.innerWidth || screen.width),\n };\n};\n\nexport const getThreeDSAction = (nextAction?: PaymentNextAction): PaymentNextAction | null => {\n return nextAction ?? null;\n};\n\nexport const isThreeDSMethodAction = (nextAction?: PaymentNextAction): boolean => {\n return nextAction?.type === \"three_ds_method\" && nextAction.three_ds.phase === \"method\";\n};\n\nexport const isThreeDSChallengeAction = (nextAction?: PaymentNextAction): boolean => {\n return nextAction?.type === \"three_ds_challenge\" && nextAction.three_ds.phase === \"challenge\";\n};\n\nexport const buildThreeDSBrowserForm = (nextAction: PaymentNextAction): BrowserPostForm => ({\n action: nextAction.three_ds.submit.url,\n method: nextAction.three_ds.submit.method,\n target: nextAction.three_ds.submit.target,\n fields: nextAction.three_ds.submit.fields,\n});\n\nconst assertHTTPSActionURL = (action: string): void => {\n let parsed: URL;\n try {\n parsed = new URL(action);\n } catch {\n throw new Error(\"3DS form action must be an absolute HTTPS URL\");\n }\n if (parsed.protocol !== \"https:\") {\n throw new Error(\"3DS form action must use HTTPS\");\n }\n};\n\nexport const buildThreeDSBrowserStep = (\n nextAction?: PaymentNextAction,\n): ThreeDSBrowserStep | null => {\n const action = getThreeDSAction(nextAction);\n if (!action) return null;\n return {\n kind: action.three_ds.phase,\n protocolVersion: action.three_ds.version,\n form: buildThreeDSBrowserForm(action),\n completionEndpoint: action.three_ds.completion_endpoint,\n threeDSServerTransId: action.three_ds.three_ds_server_trans_id,\n };\n};\n\nexport const buildThreeDSMethodCompletion = (\n nextAction: PaymentNextAction,\n completionIndicator: \"Y\" | \"N\" | \"U\" = \"Y\",\n): { completion_indicator: \"Y\" | \"N\" | \"U\"; three_ds_server_trans_id: string } => {\n if (!isThreeDSMethodAction(nextAction) || !nextAction.three_ds.three_ds_server_trans_id) {\n throw new Error(\"nextAction must be a three_ds_method action with three_ds_server_trans_id\");\n }\n return {\n completion_indicator: completionIndicator,\n three_ds_server_trans_id: nextAction.three_ds.three_ds_server_trans_id,\n };\n};\n\nconst requireDocument = (explicitDocument?: Document): Document => {\n if (explicitDocument) return explicitDocument;\n if (typeof document === \"undefined\") {\n throw new Error(\"3DS browser helpers must be called in a browser environment\");\n }\n return document;\n};\n\nconst defaultSubmitter = (form: HTMLFormElement): void => {\n form.submit();\n};\n\nexport const mountThreeDSBrowserForm = (\n nextAction: PaymentNextAction,\n options: ThreeDSMountOptions = {},\n): MountedThreeDSForm => {\n const doc = requireDocument(options.document);\n const container = options.container ?? doc.body;\n const formDescriptor = buildThreeDSBrowserForm(nextAction);\n assertHTTPSActionURL(formDescriptor.action);\n const form = doc.createElement(\"form\");\n const target =\n formDescriptor.target === \"hidden_iframe\"\n ? `arcpay-three-ds-method-${crypto.randomUUID()}`\n : (options.challengeTarget ?? \"_self\");\n let iframe: HTMLIFrameElement | undefined;\n\n form.method = formDescriptor.method;\n form.action = formDescriptor.action;\n form.target = target;\n form.hidden = true;\n\n for (const field of formDescriptor.fields) {\n const input = doc.createElement(\"input\");\n input.type = \"hidden\";\n input.name = field.name;\n input.value = field.value;\n form.append(input);\n }\n\n if (formDescriptor.target === \"hidden_iframe\") {\n iframe = doc.createElement(\"iframe\");\n iframe.name = target;\n iframe.title = \"3-D Secure method\";\n iframe.hidden = true;\n container.append(iframe);\n }\n\n container.append(form);\n\n return {\n form,\n iframe,\n submit: () => (options.submitter ?? defaultSubmitter)(form),\n remove: () => {\n form.remove();\n iframe?.remove();\n },\n };\n};\n\nconst waitForMethodFrame = (\n mounted: MountedThreeDSForm,\n timeoutMs: number,\n signal?: AbortSignal,\n): Promise<\"loaded\" | \"timeout\"> =>\n new Promise((resolve, reject) => {\n if (!mounted.iframe) {\n resolve(\"loaded\");\n return;\n }\n if (signal?.aborted) {\n reject(new DOMException(\"The operation was aborted\", \"AbortError\"));\n return;\n }\n\n let settled = false;\n const cleanup = () => {\n mounted.iframe?.removeEventListener(\"load\", onLoad);\n signal?.removeEventListener(\"abort\", onAbort);\n clearTimeout(timer);\n };\n const settle = (result: \"loaded\" | \"timeout\") => {\n if (settled) return;\n settled = true;\n cleanup();\n resolve(result);\n };\n const onLoad = () => settle(\"loaded\");\n const onAbort = () => {\n if (settled) return;\n settled = true;\n cleanup();\n reject(new DOMException(\"The operation was aborted\", \"AbortError\"));\n };\n const timer = setTimeout(() => settle(\"timeout\"), timeoutMs);\n\n mounted.iframe.addEventListener(\"load\", onLoad, { once: true });\n signal?.addEventListener(\"abort\", onAbort, { once: true });\n });\n\nexport const runThreeDSBrowserFlow = async (\n nextAction: PaymentNextAction | undefined,\n options: RunThreeDSBrowserFlowOptions,\n): Promise<ThreeDSBrowserFlowResult> => {\n if (!nextAction) return { status: \"no_action\" };\n\n if (isThreeDSChallengeAction(nextAction)) {\n const mounted = mountThreeDSBrowserForm(nextAction, options);\n mounted.submit();\n return { status: \"challenge_submitted\", action: nextAction, mounted };\n }\n\n if (!isThreeDSMethodAction(nextAction)) return { status: \"no_action\" };\n const completeThreeDSMethod = options.completeThreeDSMethod;\n if (!completeThreeDSMethod) {\n throw new Error(\"completeThreeDSMethod is required for 3DS Method actions\");\n }\n\n const mounted = mountThreeDSBrowserForm(nextAction, options);\n try {\n mounted.submit();\n const methodResult = await waitForMethodFrame(\n mounted,\n options.methodTimeoutMs ?? 10_000,\n options.signal,\n );\n const indicator = options.methodCompletionIndicator ?? (methodResult === \"loaded\" ? \"Y\" : \"N\");\n const response = await completeThreeDSMethod(\n buildThreeDSMethodCompletion(nextAction, indicator),\n nextAction,\n );\n const followUpAction = getThreeDSAction(response.next_action);\n if (followUpAction && isThreeDSChallengeAction(followUpAction)) {\n const challengeMounted = mountThreeDSBrowserForm(followUpAction, options);\n challengeMounted.submit();\n return {\n status: \"challenge_submitted\",\n action: followUpAction,\n response,\n mounted: challengeMounted,\n methodResult,\n };\n }\n return { status: \"method_completed\", response, methodResult };\n } finally {\n mounted.remove();\n }\n};\n\nconst htmlEscape = (value: string): string =>\n value\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&#39;\");\n\nexport const buildThreeDSAutoSubmitHtml = (nextAction: PaymentNextAction): string => {\n const form = buildThreeDSBrowserForm(nextAction);\n assertHTTPSActionURL(form.action);\n const target = form.target === \"hidden_iframe\" ? \"arcpay-three-ds-method\" : \"_self\";\n const inputs = form.fields\n .map(\n (field) =>\n `<input type=\"hidden\" name=\"${htmlEscape(field.name)}\" value=\"${htmlEscape(field.value)}\">`,\n )\n .join(\"\");\n const iframe =\n form.target === \"hidden_iframe\"\n ? '<iframe name=\"arcpay-three-ds-method\" title=\"3-D Secure method\" hidden></iframe>'\n : \"\";\n return `<!doctype html><html><head><meta charset=\"utf-8\"></head><body>${iframe}<form method=\"POST\" action=\"${htmlEscape(form.action)}\" target=\"${target}\">${inputs}</form><script>document.forms[0].submit();</script></body></html>`;\n};\n","export { ArcPay } from \"./core/arcpay\";\nexport type { ArcPayInstance, ArcPayLoadOptions } from \"./core/arcpay\";\nexport {\n ArcPayError,\n isValidationError,\n isAuthenticationError,\n isAuthorizationError,\n isStateError,\n isRateLimitError,\n isApiError,\n isNetworkError,\n isChallengeAborted,\n} from \"./core/errors\";\nexport type { ArcPayErrorType } from \"./core/errors\";\nexport type { Environment } from \"./core/env\";\nexport type { TokenizeResult } from \"./tokenize/tokenize\";\nexport type { CardScheme } from \"./tokenize/scheme\";\nexport {\n buildThreeDSAutoSubmitHtml,\n buildThreeDSBrowserForm,\n buildThreeDSBrowserStep,\n buildThreeDSMethodCompletion,\n collectBrowserInfo,\n getThreeDSAction,\n isThreeDSChallengeAction,\n isThreeDSMethodAction,\n mountThreeDSBrowserForm,\n runThreeDSBrowserFlow,\n} from \"./three-ds\";\nexport type {\n BrowserFormField,\n BrowserInfo,\n BrowserPostForm,\n MountedThreeDSForm,\n RunThreeDSBrowserFlowOptions,\n ThreeDSAction,\n ThreeDSBrowserStep,\n ThreeDSBrowserFlowResult,\n ThreeDSMountOptions,\n} from \"./three-ds\";\nexport const SDK_VERSION = \"0.1.25\";\n\nexport type { FieldType } from \"./elements/postmessage\";\nexport type { ElementOptions, ElementEvent } from \"./elements/element\";\nexport { Elements } from \"./elements/elements\";\nexport type { ElementsOptions } from \"./elements/elements\";\nexport type {\n HostedFieldsAppearance,\n HostedFieldsAppearanceRule,\n HostedFieldsAppearanceVariables,\n HostedFieldsTheme,\n} from \"./elements/style\";\n"]}
@@ -110,27 +110,68 @@ var parseIncoming = (event, expectedOrigin) => {
110
110
  };
111
111
 
112
112
  // src/elements/style.ts
113
- var FORBIDDEN_PROPERTIES = /* @__PURE__ */ new Set([
114
- "position",
115
- "transform",
116
- "pointer-events",
117
- "pointerevents",
118
- "z-index",
119
- "zindex",
120
- "top",
121
- "left",
122
- "right",
123
- "bottom",
124
- "inset"
113
+ var ALLOWED_PROPERTIES = /* @__PURE__ */ new Set([
114
+ "--arcpay-placeholder-color",
115
+ "background-color",
116
+ "caret-color",
117
+ "color",
118
+ "font-family",
119
+ "font-size",
120
+ "font-style",
121
+ "font-weight",
122
+ "letter-spacing",
123
+ "line-height",
124
+ "opacity",
125
+ "text-align",
126
+ "text-decoration",
127
+ "text-transform"
125
128
  ]);
129
+ var ARCPAY_THEME = {
130
+ base: {
131
+ "font-family": 'Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',
132
+ "font-size": "16px",
133
+ "line-height": "24px",
134
+ color: "#111827",
135
+ "--arcpay-placeholder-color": "#9ca3af",
136
+ "caret-color": "#111827"
137
+ },
138
+ focus: {
139
+ color: "#111827"
140
+ },
141
+ invalid: {
142
+ color: "#dc2626"
143
+ },
144
+ complete: {
145
+ color: "#111827"
146
+ },
147
+ empty: {
148
+ color: "#111827"
149
+ }
150
+ };
151
+ var mergeBlock = (target, source) => {
152
+ if (!target && !source) return void 0;
153
+ return { ...target != null ? target : {}, ...source != null ? source : {} };
154
+ };
155
+ var setIfPresent = (block, key, value) => {
156
+ if (value !== void 0) block[key] = value;
157
+ };
158
+ var assertKnownTheme = (theme) => {
159
+ if (theme === void 0 || theme === "none" || theme === "arcpay") return;
160
+ throw new ArcPayError({
161
+ type: "validation_error",
162
+ code: "invalid_hosted_fields_theme",
163
+ message: `Unsupported Hosted Fields appearance theme: ${String(theme)}`,
164
+ retryable: false
165
+ });
166
+ };
126
167
  var sanitizeBlock = (block) => {
127
168
  const out = {};
128
169
  for (const [key, value] of Object.entries(block)) {
129
170
  const normalizedKey = key.toLowerCase();
130
- if (FORBIDDEN_PROPERTIES.has(normalizedKey)) {
171
+ if (!ALLOWED_PROPERTIES.has(normalizedKey)) {
131
172
  continue;
132
173
  }
133
- out[key] = value;
174
+ out[normalizedKey] = value;
134
175
  }
135
176
  return out;
136
177
  };
@@ -138,8 +179,56 @@ var sanitizeStyle = (style) => {
138
179
  const result = { base: sanitizeBlock(style.base) };
139
180
  if (style.invalid !== void 0) result.invalid = sanitizeBlock(style.invalid);
140
181
  if (style.focus !== void 0) result.focus = sanitizeBlock(style.focus);
182
+ if (style.complete !== void 0) result.complete = sanitizeBlock(style.complete);
183
+ if (style.empty !== void 0) result.empty = sanitizeBlock(style.empty);
141
184
  return result;
142
185
  };
186
+ var buildStyleFromAppearance = (appearance) => {
187
+ var _a;
188
+ assertKnownTheme(appearance == null ? void 0 : appearance.theme);
189
+ const themeStyle = (appearance == null ? void 0 : appearance.theme) === "arcpay" ? ARCPAY_THEME : { base: {} };
190
+ const variableStyle = { base: {} };
191
+ const variables = appearance == null ? void 0 : appearance.variables;
192
+ if (variables) {
193
+ setIfPresent(variableStyle.base, "font-family", variables.fontFamily);
194
+ setIfPresent(variableStyle.base, "font-size", variables.fontSize);
195
+ setIfPresent(variableStyle.base, "font-weight", variables.fontWeight);
196
+ setIfPresent(variableStyle.base, "font-style", variables.fontStyle);
197
+ setIfPresent(variableStyle.base, "line-height", variables.lineHeight);
198
+ setIfPresent(variableStyle.base, "letter-spacing", variables.letterSpacing);
199
+ setIfPresent(variableStyle.base, "text-align", variables.textAlign);
200
+ setIfPresent(variableStyle.base, "color", variables.colorText);
201
+ setIfPresent(variableStyle.base, "--arcpay-placeholder-color", variables.colorPlaceholder);
202
+ setIfPresent(variableStyle.base, "background-color", variables.colorBackground);
203
+ setIfPresent(variableStyle.base, "caret-color", variables.caretColor);
204
+ if (variables.colorDanger !== void 0) {
205
+ variableStyle.invalid = { color: variables.colorDanger };
206
+ }
207
+ if (variables.colorSuccess !== void 0) {
208
+ variableStyle.complete = { color: variables.colorSuccess };
209
+ }
210
+ }
211
+ const rules = appearance == null ? void 0 : appearance.rules;
212
+ const combined = {
213
+ base: {
214
+ ...themeStyle.base,
215
+ ...variableStyle.base,
216
+ ...(_a = rules == null ? void 0 : rules.base) != null ? _a : {}
217
+ }
218
+ };
219
+ const focus = mergeBlock(mergeBlock(themeStyle.focus, variableStyle.focus), rules == null ? void 0 : rules.focus);
220
+ const invalid = mergeBlock(mergeBlock(themeStyle.invalid, variableStyle.invalid), rules == null ? void 0 : rules.invalid);
221
+ const complete = mergeBlock(
222
+ mergeBlock(themeStyle.complete, variableStyle.complete),
223
+ rules == null ? void 0 : rules.complete
224
+ );
225
+ const empty = mergeBlock(mergeBlock(themeStyle.empty, variableStyle.empty), rules == null ? void 0 : rules.empty);
226
+ if (focus !== void 0) combined.focus = focus;
227
+ if (invalid !== void 0) combined.invalid = invalid;
228
+ if (complete !== void 0) combined.complete = complete;
229
+ if (empty !== void 0) combined.empty = empty;
230
+ return sanitizeStyle(combined);
231
+ };
143
232
 
144
233
  // src/elements/element.ts
145
234
  var FIELD_TITLES = {
@@ -215,8 +304,11 @@ var Element = class {
215
304
  handleMessage(data) {
216
305
  if (data.type === "arcpay:ready") {
217
306
  this.status = "ready";
218
- if (this.options.style) {
219
- this.send({ type: "arcpay:style", payload: sanitizeStyle(this.options.style) });
307
+ if (this.options.appearance) {
308
+ this.send({
309
+ type: "arcpay:style",
310
+ payload: buildStyleFromAppearance(this.options.appearance)
311
+ });
220
312
  }
221
313
  if (this.options.placeholder) {
222
314
  this.send({
@@ -233,14 +325,19 @@ var Element = class {
233
325
  this.emit({
234
326
  type: "change",
235
327
  isValid: data.isValid,
328
+ isEmpty: data.isEmpty,
329
+ isComplete: data.isComplete,
236
330
  brand: data.brand,
237
331
  lastFour: data.lastFour
238
332
  });
239
333
  }
240
334
  }
241
335
  update(options) {
242
- if (options.style) {
243
- this.send({ type: "arcpay:style", payload: sanitizeStyle(options.style) });
336
+ if (options.appearance) {
337
+ this.send({
338
+ type: "arcpay:style",
339
+ payload: buildStyleFromAppearance(options.appearance)
340
+ });
244
341
  }
245
342
  if (options.placeholder) {
246
343
  this.send({
@@ -327,8 +424,10 @@ var Elements = class {
327
424
  this.publishableKey = opts.publishableKey;
328
425
  this.iframeBase = (_a = opts.iframeBase) != null ? _a : DEFAULT_IFRAME_BASE;
329
426
  this.channelId = createChannelId();
427
+ this.appearance = opts.appearance;
330
428
  }
331
429
  create(field, options = {}) {
430
+ var _a;
332
431
  if (this.elementMap.has(field)) {
333
432
  throw new ArcPayError({
334
433
  type: "validation_error",
@@ -342,7 +441,14 @@ var Elements = class {
342
441
  publishableKey: this.publishableKey,
343
442
  channelId: this.channelId
344
443
  };
345
- const element = new Element(field, options, ctx);
444
+ const element = new Element(
445
+ field,
446
+ {
447
+ ...options,
448
+ appearance: (_a = options.appearance) != null ? _a : this.appearance
449
+ },
450
+ ctx
451
+ );
346
452
  this.elementMap.set(field, element);
347
453
  return element;
348
454
  }
@@ -448,7 +554,7 @@ var buildInstance = (publishableKey) => {
448
554
  return {
449
555
  publishableKey,
450
556
  environment: detectEnvironment(publishableKey),
451
- elements: () => new Elements({ publishableKey })
557
+ elements: (opts = {}) => new Elements({ publishableKey, ...opts })
452
558
  };
453
559
  };
454
560
  function load(publishableKey) {
@@ -504,7 +610,7 @@ var useArcPay = () => {
504
610
  };
505
611
 
506
612
  // src/react/index.ts
507
- var REACT_WRAPPER_VERSION = "0.1.23";
613
+ var REACT_WRAPPER_VERSION = "0.1.25";
508
614
 
509
615
  exports.ArcPayContext = ArcPayContext;
510
616
  exports.ArcPayProvider = ArcPayProvider;