@thavguard/arc-pay 0.1.23 → 0.1.24

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":["ArcPayError","init","isValidationError","isAuthenticationError","isAuthorizationError","isStateError","isRateLimitError","isApiError","isNetworkError","isChallengeAborted","detectEnvironment","publishableKey","validatePublishableKey","key","BANNER_ATTR","showSandboxBanner","bar","text","dismiss","ARCPAY_TYPE_PREFIX","isArcpayMessage","data","postToIframe","iframe","message","targetOrigin","parseIncoming","event","expectedOrigin","FORBIDDEN_PROPERTIES","sanitizeBlock","block","out","value","normalizedKey","sanitizeStyle","style","result","FIELD_TITLES","Element","field","options","context","target","container","_a","hello","listeners","callback","_b","listener","DEFAULT_IFRAME_BASE","createChannelId","Elements","opts","ctx","element","paymentId","idempotencyKey","cardNumber","cardExpiry","cardCvv","iframeOrigin","cardIframeWindow","resolve","reject","timer","onMessage","el","cache","buildInstance","load","err","existing","promise","resetForTests","ArcPay","supportedColorDepths","normalizeColorDepth","resolveWindowSize","width","collectBrowserInfo","acceptHeader","getThreeDSAction","nextAction","isThreeDSMethodAction","isThreeDSChallengeAction","buildThreeDSBrowserForm","assertHTTPSActionURL","action","parsed","e","buildThreeDSBrowserStep","buildThreeDSMethodCompletion","completionIndicator","requireDocument","explicitDocument","defaultSubmitter","form","mountThreeDSBrowserForm","doc","formDescriptor","input","waitForMethodFrame","mounted","timeoutMs","signal","settled","cleanup","onLoad","onAbort","settle","runThreeDSBrowserFlow","completeThreeDSMethod","methodResult","indicator","response","followUpAction","challengeMounted","htmlEscape","buildThreeDSAutoSubmitHtml","inputs","SDK_VERSION"],"mappings":"2CAsBO,IAA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IAAA,CAAM,QAAQ,CAAA,CACtB,OAAA,CAAQ,IAAA,CAAM,OAAO,CAAA,CAEbuF,CAAAA,CAA8BpC,CAAAA,EAA0C,CACnF,IAAMc,EAAOX,CAAAA,CAAwBH,CAAU,CAAA,CAC/CI,CAAAA,CAAqBU,CAAAA,CAAK,MAAM,CAAA,CAChC,IAAMvD,EAASuD,CAAAA,CAAK,MAAA,GAAW,eAAA,CAAkB,wBAAA,CAA2B,OAAA,CACtEuB,CAAAA,CAASvB,CAAAA,CAAK,MAAA,CACjB,IACE1D,CAAAA,EACC,CAAA,2BAAA,EAA8B+E,CAAAA,CAAW/E,CAAAA,CAAM,IAAI,CAAC,CAAA,SAAA,EAAY+E,CAAAA,CAAW/E,CAAAA,CAAM,KAAK,CAAC,CAAA,EAAA,CAC3F,CAAA,CACC,IAAA,CAAK,EAAE,CAAA,CAKV,OAAO,CAAA,8DAAA,EAHL0D,CAAAA,CAAK,MAAA,GAAW,eAAA,CACZ,kFAAA,CACA,EACwE,CAAA,4BAAA,EAA+BqB,CAAAA,CAAWrB,EAAK,MAAM,CAAC,CAAA,UAAA,EAAavD,CAAM,CAAA,EAAA,EAAK8E,CAAM,CAAA,iEAAA,CACpK,MCxSaC,EAAAA,CAAc","file":"arcpay.global.js","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/core/arcpay.ts","../../src/three-ds/actions.ts","../../src/index.ts"],"names":["ArcPayError","init","isValidationError","isAuthenticationError","isAuthorizationError","isStateError","isRateLimitError","isApiError","isNetworkError","isChallengeAborted","detectEnvironment","publishableKey","validatePublishableKey","key","BANNER_ATTR","showSandboxBanner","bar","text","dismiss","ARCPAY_TYPE_PREFIX","isArcpayMessage","data","postToIframe","iframe","message","targetOrigin","parseIncoming","event","expectedOrigin","ALLOWED_PROPERTIES","ARCPAY_THEME","mergeBlock","target","source","setIfPresent","block","value","sanitizeBlock","out","normalizedKey","sanitizeStyle","style","result","buildStyleFromAppearance","appearance","_a","themeStyle","variableStyle","variables","rules","combined","focus","invalid","complete","empty","FIELD_TITLES","Element","field","options","context","container","hello","listeners","callback","_b","listener","DEFAULT_IFRAME_BASE","createChannelId","Elements","opts","ctx","element","paymentId","idempotencyKey","cardNumber","cardExpiry","cardCvv","iframeOrigin","cardIframeWindow","resolve","reject","timer","onMessage","el","cache","buildInstance","load","err","existing","promise","resetForTests","ArcPay","supportedColorDepths","normalizeColorDepth","resolveWindowSize","width","collectBrowserInfo","acceptHeader","getThreeDSAction","nextAction","isThreeDSMethodAction","isThreeDSChallengeAction","buildThreeDSBrowserForm","assertHTTPSActionURL","action","parsed","e","buildThreeDSBrowserStep","buildThreeDSMethodCompletion","completionIndicator","requireDocument","explicitDocument","defaultSubmitter","form","mountThreeDSBrowserForm","doc","formDescriptor","input","waitForMethodFrame","mounted","timeoutMs","signal","settled","cleanup","onLoad","onAbort","settle","runThreeDSBrowserFlow","completeThreeDSMethod","methodResult","indicator","response","followUpAction","challengeMounted","htmlEscape","buildThreeDSAutoSubmitHtml","inputs","SDK_VERSION"],"mappings":"2CAsBO,IAAMA,EAAN,cAA0B,KAAM,CASrC,WAAA,CAAYC,EAAuB,CACjC,KAAA,CAAMA,CAAAA,CAAK,OAAO,EAClB,IAAA,CAAK,IAAA,CAAO,aAAA,CACZ,IAAA,CAAK,KAAOA,CAAAA,CAAK,IAAA,CACjB,IAAA,CAAK,IAAA,CAAOA,EAAK,IAAA,CACjB,IAAA,CAAK,KAAA,CAAQA,CAAAA,CAAK,MAClB,IAAA,CAAK,SAAA,CAAYA,CAAAA,CAAK,SAAA,CACtB,KAAK,WAAA,CAAcA,CAAAA,CAAK,WAAA,CACxB,IAAA,CAAK,UAAYA,CAAAA,CAAK,SAAA,CACtB,IAAA,CAAK,SAAA,CAAYA,EAAK,UACxB,CACF,CAAA,CAEaC,CAAAA,CAAqB,GAChC,CAAA,YAAaF,CAAAA,EAAe,CAAA,CAAE,IAAA,GAAS,mBAGlC,IAAMG,CAAAA,CAAyB,CAAA,EACpC,CAAA,YAAaH,GAAe,CAAA,CAAE,IAAA,GAAS,sBAAA,CAC5BI,CAAAA,CAAwB,GACnC,CAAA,YAAaJ,CAAAA,EAAe,CAAA,CAAE,IAAA,GAAS,sBAC5B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KV,OAAO,CAAA,8DAAA,EAHLwD,EAAK,MAAA,GAAW,eAAA,CACZ,kFAAA,CACA,EACwE,+BAA+BqB,CAAAA,CAAWrB,CAAAA,CAAK,MAAM,CAAC,aAAajF,CAAM,CAAA,EAAA,EAAKwG,CAAM,CAAA,iEAAA,CACpK,MCxSaC,EAAAA,CAAc","file":"arcpay.global.js","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\";\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 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 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.24\";\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"]}
package/dist/index.cjs CHANGED
@@ -95,27 +95,59 @@ var parseIncoming = (event, expectedOrigin) => {
95
95
  };
96
96
 
97
97
  // src/elements/style.ts
98
- var FORBIDDEN_PROPERTIES = /* @__PURE__ */ new Set([
99
- "position",
100
- "transform",
101
- "pointer-events",
102
- "pointerevents",
103
- "z-index",
104
- "zindex",
105
- "top",
106
- "left",
107
- "right",
108
- "bottom",
109
- "inset"
98
+ var ALLOWED_PROPERTIES = /* @__PURE__ */ new Set([
99
+ "--arcpay-placeholder-color",
100
+ "background-color",
101
+ "caret-color",
102
+ "color",
103
+ "font-family",
104
+ "font-size",
105
+ "font-style",
106
+ "font-weight",
107
+ "letter-spacing",
108
+ "line-height",
109
+ "opacity",
110
+ "text-align",
111
+ "text-decoration",
112
+ "text-transform"
110
113
  ]);
114
+ var ARCPAY_THEME = {
115
+ base: {
116
+ "font-family": 'Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',
117
+ "font-size": "16px",
118
+ "line-height": "24px",
119
+ color: "#111827",
120
+ "--arcpay-placeholder-color": "#9ca3af",
121
+ "caret-color": "#111827"
122
+ },
123
+ focus: {
124
+ color: "#111827"
125
+ },
126
+ invalid: {
127
+ color: "#dc2626"
128
+ },
129
+ complete: {
130
+ color: "#111827"
131
+ },
132
+ empty: {
133
+ color: "#111827"
134
+ }
135
+ };
136
+ var mergeBlock = (target, source) => {
137
+ if (!target && !source) return void 0;
138
+ return { ...target != null ? target : {}, ...source != null ? source : {} };
139
+ };
140
+ var setIfPresent = (block, key, value) => {
141
+ if (value !== void 0) block[key] = value;
142
+ };
111
143
  var sanitizeBlock = (block) => {
112
144
  const out = {};
113
145
  for (const [key, value] of Object.entries(block)) {
114
146
  const normalizedKey = key.toLowerCase();
115
- if (FORBIDDEN_PROPERTIES.has(normalizedKey)) {
147
+ if (!ALLOWED_PROPERTIES.has(normalizedKey)) {
116
148
  continue;
117
149
  }
118
- out[key] = value;
150
+ out[normalizedKey] = value;
119
151
  }
120
152
  return out;
121
153
  };
@@ -123,8 +155,55 @@ var sanitizeStyle = (style) => {
123
155
  const result = { base: sanitizeBlock(style.base) };
124
156
  if (style.invalid !== void 0) result.invalid = sanitizeBlock(style.invalid);
125
157
  if (style.focus !== void 0) result.focus = sanitizeBlock(style.focus);
158
+ if (style.complete !== void 0) result.complete = sanitizeBlock(style.complete);
159
+ if (style.empty !== void 0) result.empty = sanitizeBlock(style.empty);
126
160
  return result;
127
161
  };
162
+ var buildStyleFromAppearance = (appearance) => {
163
+ var _a;
164
+ const themeStyle = (appearance == null ? void 0 : appearance.theme) === "arcpay" ? ARCPAY_THEME : { base: {} };
165
+ const variableStyle = { base: {} };
166
+ const variables = appearance == null ? void 0 : appearance.variables;
167
+ if (variables) {
168
+ setIfPresent(variableStyle.base, "font-family", variables.fontFamily);
169
+ setIfPresent(variableStyle.base, "font-size", variables.fontSize);
170
+ setIfPresent(variableStyle.base, "font-weight", variables.fontWeight);
171
+ setIfPresent(variableStyle.base, "font-style", variables.fontStyle);
172
+ setIfPresent(variableStyle.base, "line-height", variables.lineHeight);
173
+ setIfPresent(variableStyle.base, "letter-spacing", variables.letterSpacing);
174
+ setIfPresent(variableStyle.base, "text-align", variables.textAlign);
175
+ setIfPresent(variableStyle.base, "color", variables.colorText);
176
+ setIfPresent(variableStyle.base, "--arcpay-placeholder-color", variables.colorPlaceholder);
177
+ setIfPresent(variableStyle.base, "background-color", variables.colorBackground);
178
+ setIfPresent(variableStyle.base, "caret-color", variables.caretColor);
179
+ if (variables.colorDanger !== void 0) {
180
+ variableStyle.invalid = { color: variables.colorDanger };
181
+ }
182
+ if (variables.colorSuccess !== void 0) {
183
+ variableStyle.complete = { color: variables.colorSuccess };
184
+ }
185
+ }
186
+ const rules = appearance == null ? void 0 : appearance.rules;
187
+ const combined = {
188
+ base: {
189
+ ...themeStyle.base,
190
+ ...variableStyle.base,
191
+ ...(_a = rules == null ? void 0 : rules.base) != null ? _a : {}
192
+ }
193
+ };
194
+ const focus = mergeBlock(mergeBlock(themeStyle.focus, variableStyle.focus), rules == null ? void 0 : rules.focus);
195
+ const invalid = mergeBlock(mergeBlock(themeStyle.invalid, variableStyle.invalid), rules == null ? void 0 : rules.invalid);
196
+ const complete = mergeBlock(
197
+ mergeBlock(themeStyle.complete, variableStyle.complete),
198
+ rules == null ? void 0 : rules.complete
199
+ );
200
+ const empty = mergeBlock(mergeBlock(themeStyle.empty, variableStyle.empty), rules == null ? void 0 : rules.empty);
201
+ if (focus !== void 0) combined.focus = focus;
202
+ if (invalid !== void 0) combined.invalid = invalid;
203
+ if (complete !== void 0) combined.complete = complete;
204
+ if (empty !== void 0) combined.empty = empty;
205
+ return sanitizeStyle(combined);
206
+ };
128
207
 
129
208
  // src/elements/element.ts
130
209
  var FIELD_TITLES = {
@@ -200,8 +279,11 @@ var Element = class {
200
279
  handleMessage(data) {
201
280
  if (data.type === "arcpay:ready") {
202
281
  this.status = "ready";
203
- if (this.options.style) {
204
- this.send({ type: "arcpay:style", payload: sanitizeStyle(this.options.style) });
282
+ if (this.options.appearance) {
283
+ this.send({
284
+ type: "arcpay:style",
285
+ payload: buildStyleFromAppearance(this.options.appearance)
286
+ });
205
287
  }
206
288
  if (this.options.placeholder) {
207
289
  this.send({
@@ -218,14 +300,19 @@ var Element = class {
218
300
  this.emit({
219
301
  type: "change",
220
302
  isValid: data.isValid,
303
+ isEmpty: data.isEmpty,
304
+ isComplete: data.isComplete,
221
305
  brand: data.brand,
222
306
  lastFour: data.lastFour
223
307
  });
224
308
  }
225
309
  }
226
310
  update(options) {
227
- if (options.style) {
228
- this.send({ type: "arcpay:style", payload: sanitizeStyle(options.style) });
311
+ if (options.appearance) {
312
+ this.send({
313
+ type: "arcpay:style",
314
+ payload: buildStyleFromAppearance(options.appearance)
315
+ });
229
316
  }
230
317
  if (options.placeholder) {
231
318
  this.send({
@@ -312,8 +399,10 @@ var Elements = class {
312
399
  this.publishableKey = opts.publishableKey;
313
400
  this.iframeBase = (_a = opts.iframeBase) != null ? _a : DEFAULT_IFRAME_BASE;
314
401
  this.channelId = createChannelId();
402
+ this.appearance = opts.appearance;
315
403
  }
316
404
  create(field, options = {}) {
405
+ var _a;
317
406
  if (this.elementMap.has(field)) {
318
407
  throw new ArcPayError({
319
408
  type: "validation_error",
@@ -327,7 +416,14 @@ var Elements = class {
327
416
  publishableKey: this.publishableKey,
328
417
  channelId: this.channelId
329
418
  };
330
- const element = new Element(field, options, ctx);
419
+ const element = new Element(
420
+ field,
421
+ {
422
+ ...options,
423
+ appearance: (_a = options.appearance) != null ? _a : this.appearance
424
+ },
425
+ ctx
426
+ );
331
427
  this.elementMap.set(field, element);
332
428
  return element;
333
429
  }
@@ -433,7 +529,7 @@ var buildInstance = (publishableKey) => {
433
529
  return {
434
530
  publishableKey,
435
531
  environment: detectEnvironment(publishableKey),
436
- elements: () => new Elements({ publishableKey })
532
+ elements: (opts = {}) => new Elements({ publishableKey, ...opts })
437
533
  };
438
534
  };
439
535
  function load(publishableKey) {
@@ -669,7 +765,7 @@ var buildThreeDSAutoSubmitHtml = (nextAction) => {
669
765
  };
670
766
 
671
767
  // src/index.ts
672
- var SDK_VERSION = "0.1.23";
768
+ var SDK_VERSION = "0.1.24";
673
769
 
674
770
  exports.ArcPay = ArcPay;
675
771
  exports.ArcPayError = ArcPayError;