Skip to main content

Transaction Confirmation

Passkeys can also be used for digitial signed transactions, making them useful in situations like:

  • Financial transactions: Ensures users confirm actions involving transfers or payments, preventing unauthorized activity.
  • Data integrity: Validates any state-changing operation (e.g., updating sensitive records) with user authentication to avoid tampering.
  • Non-repudiation: Provides legal proof of action approval in scenarios like contract signing or agreement approvals.

Prerequisites

Setup SDK

npm i @loginid/websdk3

Import and initialize an instance:

import { LoginIDWebSDK } from "@loginid/websdk3";

const lid = new LoginIDWebSDK({
baseUrl: process.env.LOGINID_BASE_URL,
});

Sign a Transaction Using Transaction Confirmation

Transaction confirmation requires:

  • username and transaction payload
  • nonce (optional)

The transaction payload accepts a string, such as plain text or JSON string.

The nonce is any unique identifier or reference for the transaction payload.

import { LoginIDWebSDK } from "@loginid/websdk3";

const config = {
baseUrl: BASE_URL,
};

const lid = new LoginIDWebSDK(config);

async function handleTransactionConfirmation() {
try {
// The txPayload and nonce can be generated on the backend

const { username } = lid.getSession();
// The nonce value is optional
const options = { nonce: nonce };
const confirmationResult = await lid.confirmTransaction(
username,
txPayload,
options
);

// You can pass the LoginID token to your backend for verification
} catch (error) {
// Handle errors
console.error("Error during transaction confirmation:", error);
}
}

After receiving the confirmTransaction result, send it to your backend to verify the token and transaction details. For more details, see our backend integration section.