From ab750e37075bfc0d4c9237307b59d8b6e3b4135b Mon Sep 17 00:00:00 2001 From: Greg Soucy Date: Mon, 18 May 2026 11:55:43 -0400 Subject: [PATCH] Fix SDK receipt typing with canonical proof envelope --- src/receipt.ts | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/receipt.ts b/src/receipt.ts index 3326500..d804811 100644 --- a/src/receipt.ts +++ b/src/receipt.ts @@ -21,7 +21,22 @@ export interface ReceiptInput { }; } -export type Receipt = CommandLayerReceipt; +export interface CanonicalProofEnvelope { + canonicalization: "json.sorted_keys.v1"; + hash: { + alg: "SHA-256"; + value: string; + }; + signature: { + alg: "Ed25519"; + value: string; + kid: string; + }; +} + +export type Receipt = ReceiptInput & { + proof: CanonicalProofEnvelope; +}; export function canonicalPayloadFromReceiptInput(receipt: ReceiptInput) { return { @@ -39,11 +54,16 @@ export function canonicalPayloadFromReceiptInput(receipt: ReceiptInput) { export async function createReceipt(params: { keyId: string; privateKeyPem: string; - canonicalization: string; + canonicalization: "json.sorted_keys.v1"; input: ReceiptInput; }): Promise { - return signCommandLayerReceipt(params.input, { - privateKeyPem: params.privateKeyPem, - kid: params.keyId, - }); + const signed = signCommandLayerReceipt( + params.input as unknown as CommandLayerReceipt, + { + privateKeyPem: params.privateKeyPem, + kid: params.keyId, + }, + ); + + return signed as unknown as Receipt; }