Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
x402 protocol extensions
# npm npm install @armory-sh/extensions # yarn yarn add @armory-sh/extensions # pnpm pnpm add @armory-sh/extensions # bun bun add @armory-sh/extensions
import { createSIWxHook } from '@armory-sh/extensions'; const hook = createSIWxHook({ domain: 'example.com', statement: 'Sign in to access premium content', expirationSeconds: 3600 });
domain
string
statement
expirationSeconds
number
import { createPaymentIdHook } from '@armory-sh/extensions'; // Auto-generate payment ID const hook = createPaymentIdHook(); // Or specify a custom ID const hook = createPaymentIdHook({ paymentId: 'my-custom-id-123' });
paymentId
import { createCustomHook } from '@armory-sh/extensions'; const customHook = createCustomHook({ key: 'my-extension', handler: async (context) => { // Modify the payment payload if (context.payload) { context.payload.extensions = { ...(context.payload.extensions ?? {}), 'my-extension': { data: 'value' } }; } }, priority: 75 // Higher priority runs first });
import { declareSIWxExtension } from '@armory-sh/extensions'; const extension = declareSIWxExtension({ domain: 'api.example.com', statement: 'Sign in to access this API', network: 'eip155:8453', expirationSeconds: 3600 });
import { declarePaymentIdentifierExtension } from '@armory-sh/extensions'; // Require payment ID from clients const extension = declarePaymentIdentifierExtension({ required: true });
import { declareDiscoveryExtension } from '@armory-sh/extensions'; const extension = declareDiscoveryExtension({ required: true });
import { validateSIWxMessage, parseSIWxHeader } from '@armory-sh/extensions'; const payload = parseSIWxHeader(header); const result = validateSIWxMessage( payload, 'https://api.example.com/resource', { maxAge: 3600 } ); if (result.valid) { console.log('Valid SIWX message'); } else { console.error('Invalid:', result.error); }
import { verifySIWxSignature } from '@armory-sh/extensions'; const result = await verifySIWxSignature(payload, { evmVerifier: async (message, signature, address) => { // Custom signature verification return true; } });
import { generatePaymentId } from '@armory-sh/extensions'; const id = generatePaymentId();
import { extractExtension } from '@armory-sh/extensions'; const siwxData = extractExtension(payload.extensions, 'siwx');
import { SIGN_IN_WITH_X, PAYMENT_IDENTIFIER, BAZAAR, } from '@armory-sh/extensions';
import type { SIWxHookConfig, PaymentIdHookConfig, CustomHookConfig, SIWxExtensionConfig, PaymentIdentifierConfig, BazaarDiscoveryConfig, SIWxPayload, SIWxExtensionInfo, PaymentIdentifierExtensionInfo, BazaarExtensionInfo, Extension, } from '@armory-sh/extensions';
createSIWxHook
createPaymentIdHook
createCustomHook
declareSIWxExtension
declarePaymentIdentifierExtension
declareDiscoveryExtension
validateSIWxMessage
verifySIWxSignature
parseSIWxHeader
encodeSIWxHeader
createSIWxMessage
createSIWxPayload
generatePaymentId
extractExtension
isSIWxExtension
isPaymentIdentifierExtension
isDiscoveryExtension