Workbench memory
Signing keyempty
Macaroonempty
Challengeempty
Credentialempty
Validate L402Verify signature, preimage, and caveats
idle
Use from Workbench
Signing key source: not in Workbench
typescriptcurrent input code - reflects form fields
import { L402, Identifier, InMemoryRootKeyStore, validUntilSatisfier } from "@boltwall/l402";
function hexToBytes(hex: string): Uint8Array {
const bytes = new Uint8Array(hex.length / 2);
for (let i = 0; i < bytes.length; i++) {
bytes[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
}
return bytes;
}
const macaroon = "<base64 macaroon>";
const workbenchSigningKey = "<Workbench signing key>";
const preimage = "<64-char hex preimage>";
const { tokenId } = Identifier.fromMacaroon(macaroon);
const store = new InMemoryRootKeyStore();
await store.put(tokenId, hexToBytes(workbenchSigningKey));
const token = new L402({ macaroons: [macaroon], paymentPreimage: preimage });
const result = await token.verify({
rootKeyStore: store,
satisfiers: [validUntilSatisfier()],
context: { now: new Date() },
});
// -> { ok: true } or { ok: false, reason: "..." }
L402 Playground