Skip to main content

Client Hook

import { createSIWxHook } from '@armory-sh/extensions';

const hook = createSIWxHook({
  domain: 'api.example.com',
  statement: 'Sign in to access protected routes',
  expirationSeconds: 3600
});

Server Declaration

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
});

Validation

import { parseSIWxHeader, validateSIWxMessage, verifySIWxSignature } from '@armory-sh/extensions';

const payload = parseSIWxHeader(header);
const messageResult = validateSIWxMessage(payload, 'https://api.example.com/data');

if (messageResult.valid) {
  const signatureResult = await verifySIWxSignature(payload, {
    evmVerifier: async () => true
  });
}