Reveal Card Details

Display an issued card's PAN, expiry, CVV and PIN inside Wirex-served iframes without the values reaching your page.

Before You Start

Read the following guides before proceeding:

GuideWhy
Web SDKIsolation model and package map
SDK SetupClient id (partner id), environments, installation, CSP
Card DetailsConfirmation methods and action-token rules
Card IssuanceHow the card id is produced

Overview

@wirexapp/card-reveal-web displays an issued card's sensitive details — full PAN, expiry, CVV and PIN —
inside Wirex-served iframes. The frame fetches the values directly from the Wirex API and renders them in
place. Copy-to-clipboard runs inside the frame. Your page mounts the element and receives status events; it
never receives the values.

The element calls the same endpoints documented in Card Details:

Requested rowEndpoint the frame calls
number, expiryPOST /api/v1/cards/{cardId}/details
cvvPOST /api/v1/cards/{cardId}/cvv
pinPOST /api/v1/cards/{cardId}/pin
cardholderNone — rendered from the cardholderName you pass

Prerequisite: Mint an Action Token

Reveal requires a one-shot action_token on top of the user token. Mint it through the confirmation flow —
authenticated with the same user token — immediately before mounting the element.

const nonce = Math.floor(Date.now() / 1000);
const message = `By signing this I confirm that I am executing action GetCardDetails at ${nonce}`;
const messageSignature = await wallet.signMessage(message);

const { action_token: actionToken } = await fetch(
  `${baseUrl}/api/v1/confirmation/signature/verify`,
  {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${accessToken}`,
      'X-User-Wallet': userEoaAddress,
      'X-Chain-Id': chainId,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ action_type: 'GetCardDetails', message_signature: messageSignature, nonce })
  }
).then(response => response.json());
PropertyValue
Validity5 minutes
ScopeGetCardDetails — one token covers the PAN, CVV and PIN endpoints of one reveal
UsageMint a fresh token each time the user opens the details view

SMS OTP confirmation produces the same token under the field name token. Both methods are documented in
Card Details.


Mount the Element

import { createCardReveal } from '@wirexapp/card-reveal-web';

const reveal = createCardReveal(
  { environment: 'uat', clientId: 'a4f6c1e2-9b03-4d77-8a51-2f0c6b8e4d19' },
  {
    cardId: '64120850-73a1-4df5-a074-d463258c9deb',
    actionToken,
    fetchDetails: true,
    fetchCvv: true,
    fields: ['cardholder', 'number', 'expiry', 'cvv'],
    cardholderName: 'ALEX GREY',
    auth: {
      getBearerToken: () => session.getAccessToken(),
      userEmail: user.email,
      userWallet: user.walletAddress,
    },
    onStateChange: ({ status, errorMessage }) => {
      if (status === 'error') showToast(errorMessage);
    },
    onCopied: ({ field }) => analytics.track('card_detail_copied', { field }),
  },
);

await reveal.mount(document.querySelector('#card-details'));

// When the user closes the details view:
reveal.destroy();

Configuration

FieldTypeRequiredDescription
cardIdstringYesIssued card to reveal
actionTokenstringYesStep-up token from confirmation, valid for 5 minutes
fetchDetailsbooleanYesRequests the number and expiry rows. Ignored when fields is set
fetchCvvbooleanYesRequests the cvv row. Ignored when fields is set
fieldsarrayNoExact rows to render, in order: cardholder, number, expiry, cvv, pin. Drives which endpoints the frame calls
cardholderNamestringNoRendered as a plain, non-sensitive row
auth.getBearerToken() => Promise<string>YesReturns a fresh user token
auth.userEmailstringNoSent as X-User-Email. A cross-origin frame cannot read your session
auth.userWalletstringNoSent as X-User-Wallet
appearanceobjectNoWhitelisted styling tokens — see Appearance and Localization
stringsobjectNoTranslated labels — see Strings Keys
onStateChange(state) => voidNo{ status, errorMessage? }
onCopied(event) => voidNo{ field } — which row the user copied. The value never leaves the frame
copybutton | text | row | noneNoCopy control. Default button. See Copy Behavior
copyByFieldobjectNoPer-row copy override: { pin: 'none' }. Accepts button, row, none
showLabelsbooleanNoDefault true. false renders no label element; the label becomes the value's accessible name
rowStyleplain | boxedNoDefault plain. boxed draws each row as a pill from the box tokens
layoutcolumn | rowNoDefault column (stacked). row places the fields side by side, equal widths
maskedboolean | objectNoRows that mount masked: true for all, or { cvv: true, pin: true }. Default nothing masked. See Masking
maskTogglebutton | text | row | noneNoIn-frame show/hide control on every sensitive row. Default none
maskToggleByFieldobjectNoPer-row maskToggle override
maskAfternumber | objectNoMilliseconds after which a shown row re-masks. A number for every row, or { pin: 10000 }. Default never
onMaskedChange(event) => voidNo{ masked, field?, reason } — the masked state the frame applied
onRevealRequested(event) => voidNo{ field }. When passed, the toggle does not reveal; it asks your page, and you reveal with setMasked()

fetchDetails and fetchCvv are required by the TypeScript config type even when fields is set. When
fields is present it decides the rows; the two flags are not read. Omitting fields renders
cardholder, then number and expiry when fetchDetails is true, then cvv when fetchCvv is
true — the pin row is reachable only through fields.

The chain identifier and the API base URL are the frame service's own configuration. Neither is a config
field, so your page cannot point a reveal request at another host.

Identity Headers

auth.userEmail and auth.userWallet are sent as X-User-Email and X-User-Wallet. A
user token carries the user id, wallet address and
email in its own claims, so the API resolves the cardholder from the token and does not read these headers.

Setting both is safe with a user token and rejected with an S2S token, which reads exactly one identity
header and returns ErrorInvalidField (field: user_identifier) when given more. This is one more
reason the bearer must be a user token. See
User Identity Headers.


Layout Options

By default the frame stacks rows as label and value with an icon copy button. Four options make one frame
match layouts that otherwise take several frames and host-drawn chrome:

OptionEffect
showLabels: falseValues only. The row is exactly as tall as its value (add the spacingUnit: '0px' token for a flush row). With copy: 'button' the row is floored at the icon's hit target (copyIconSize + 12px)
copy: 'row' or 'none'The whole row copies, or nothing does — no icon width reserved
rowStyle: 'boxed'Each row is a pill drawn inside the frame from colorBackground, colorBorder, borderRadius, borderWidth and controlMinHeight, with 16px horizontal padding, spacingUnit vertical padding and fieldGap between pills
layout: 'row'Fields side by side, equal widths, fieldGap apart

The wordSpacing appearance token spreads the card number's four-digit groups apart, as card artwork does.

A card-artwork layout — number on one line, expiry and CVV side by side — is two frames:

const shared = {
  cardId, actionToken, auth, appearance,
  fetchDetails: true, fetchCvv: true,
  showLabels: false, copy: 'row', rowStyle: 'boxed',
};

createCardReveal(sdk, { ...shared, fields: ['number'] });
createCardReveal(sdk, { ...shared, fields: ['expiry', 'cvv'], layout: 'row' });

Group rows into one frame where you can. number and expiry share one
POST /api/v1/cards/{cardId}/details call. fields: ['expiry', 'cvv'] in one row frame calls it once;
two single-field frames call it twice with the same action token.

Layouts are frame-wide. A mixed arrangement — one field full-width above a row of others — is two frames.
Unknown fields entries are dropped.


Masking

Each sensitive row — number, expiry, CVV, PIN — can be hidden and shown in place, without a second
step-up. The state is per row and lives in the frame. The user changes it through an in-frame control you
opt into; your page changes it through setMasked().

// Self-contained: CVV and PIN start hidden, every sensitive row has an eye.
const reveal = createCardReveal(sdk, {
  ...config,
  masked: { cvv: true, pin: true },
  maskToggle: 'button',
  maskAfter: { pin: 10000 },
  onMaskedChange: ({ masked, field, reason }) => analytics.track('card_masked', { field, reason }),
});

// Host-driven: your own button, no in-frame control.
const reveal = createCardReveal(sdk, { ...config, masked: true });
showButton.onclick = () => reveal.setMasked(false);        // every row
hideCvvButton.onclick = () => reveal.setMasked({ cvv: true }); // one row, the rest untouched

// Gated: the eye only asks; reveal after your own check.
const reveal = createCardReveal(sdk, {
  ...config,
  masked: true,
  maskToggle: 'button',
  onRevealRequested: async ({ field }) => {
    if (await biometrics.verify()) reveal.setMasked({ [field]: false });
  },
});
RuleDetail
FetchValues are fetched once, at mount, under the actionToken. Masking and unmasking never refetch and never need a new token
RenderingThe value text is replaced in the frame's DOM, not overlaid: card number •••• •••• •••• 1111 (last four stay), expiry ••/••, CVV and PIN one glyph per character. The glyph is the first character of the maskedPlaceholder string
LayoutThe masked text has as many characters as the value, so the row keeps its height and the iframe does not resize
CardholderNever masked and never listed in onMaskedChange
CopyThe copy control stays and copies the real value. Masking is a display aid against shoulder-surfing and screen sharing, not an access control. Use copy: 'none' or copyByField when a field must not be copyable
Toggle with copy: 'row'The row's single click copies, so that row gets no toggle
GateWith onRevealRequested, the toggle only asks and the row stays masked until you call setMasked({ [field]: false }). Hiding is never gated
TimermaskAfter counts from the moment the value is visible and reports reason: 'timeout'
Older framesA frame deployment that predates masking ignores masked and shows the values; it never sends onMaskedChange — that is how you detect it

Masking does not replace short-lived mounting. Mount the element only when the user asked to see the
card. PCI SSC guidance says a full PAN should not stay on screen indefinitely; enforce your re-mask
policy with maskAfter, or with your own timer and setMasked(true).

onMaskedChange payload:

FieldDescription
maskedMap of every rendered maskable row to a boolean — { number: true, expiry: true, cvv: false }
fieldThe row that changed, for user and timeout
reasoninit, user, host or timeout

Object.values(masked).every(Boolean) means every row is hidden.


Element State

onStateChange: ({ status, errorMessage }) => {
  // status: 'loading' | 'ready' | 'error'
}
StatusMeaning
loadingThe frame verified its init and started fetching. Nothing renders yet
readyAt least one requested row loaded
errorEvery requested fetch failed. errorMessage is safe to display

A partial failure reports ready, not error. Rows whose fetch failed render an em dash while the
rows that succeeded render their values. The error banner and the error status appear only when nothing
loaded at all.

Causes of error: an expired actionToken (older than 5 minutes), an unknown card id, a card status that does not
permit the operation, or a backend failure. The action_token error reasons are listed in
Card Details.


Copy Behavior

Copy writes to the clipboard from inside the frame in every mode. Your page receives no clipboard content and
no event payload containing values — onCopied carries the field name and nothing else. The reveal iframe is
the only frame in the SDK granted clipboard-write; the collect frames are granted no permissions at all.

copyControl
button (default)Icon button beside each value; a checkmark for 2 seconds after copying
textText button from the copy string; shows copied for 2 seconds
rowThe whole row is a real button (click, Enter, Space); the copied state shows on the value and is announced to assistive technology
noneNo copy control. The value stays selectable text

copyByField overrides the mode per row — { cvv: 'none', pin: 'none' } keeps the icon everywhere but on
the CVV and PIN. An invalid entry leaves that row on copy.


Strings Keys

KeyDefault
cardholderLabelCardholder
cardNumberLabelCard Number
expiryLabelExpiry date
cvvLabelCVV/CVC
pinLabelPIN
copyCopy
copiedCopied
showShow — the mask toggle's text (maskToggle: 'text') and accessible name while masked
hideHide — the same while shown
maskedPlaceholder• — the glyph drawn for each hidden character (first character of the string)
loadErrorFailed to load card details

Lifecycle

  • Mount the element when the user asks to see the details; call destroy() when the view closes.
  • setMasked() is the only option that changes after mount. Every other option is read at mount.
  • Elements are single-use. Re-opening the view requires a new element and a fresh actionToken.
  • mount() rejects when the frame document cannot load or refuses to initialize. See
    Events and Error Handling.

Your Responsibilities

  • Keep the reveal element short-lived. It exists for the duration of a user-initiated details view.
  • Mint the action_token immediately before mounting. A token minted earlier in a flow expires 5 minutes
    after issue.
  • Do not proxy POST /api/v1/cards/{cardId}/details, /cvv or /pin through your own backend. Proxying
    cardholder data is permitted only when that backend is itself PCI DSS compliant, which the SDK exists to
    avoid.

Exports

ExportReturns
createCardReveal(sdk, config){ mount(container), setMasked(boolean | { [field]: boolean }), destroy() }

Did this page help you?