@@ -45,6 +45,7 @@ export type ReceiptMetadata = {
4545
4646export type CanonicalReceipt < T = unknown > = {
4747 status : "success" | "error" | string ;
48+ verb ?: string ;
4849 /**
4950 * Legacy / commercial-only metadata.
5051 * Commons v1.1.0 receipts should not rely on or emit this block.
@@ -76,12 +77,17 @@ export type RuntimeMetadata = {
7677 [ k : string ] : unknown ;
7778} ;
7879
80+ export type ReceiptProtocolMetadata = {
81+ verb : string ;
82+ version : string ;
83+ } ;
84+
7985export type CommandResponse < TResult = unknown , TError = unknown > = {
80- receipt : CanonicalReceipt < TResult , TError > ;
86+ receipt : CanonicalReceipt < TResult > ;
8187 runtime_metadata ?: RuntimeMetadata ;
8288} ;
8389
84- export type LegacyBlendedReceipt < TResult = unknown , TError = unknown > = CanonicalReceipt < TResult , TError > & {
90+ export type LegacyBlendedReceipt < TResult = unknown , TError = unknown > = CanonicalReceipt < TResult > & {
8591 trace ?: RuntimeMetadata ;
8692} ;
8793
@@ -295,7 +301,7 @@ function extractReceipt(subject: CanonicalReceipt | CommandResponse | LegacyBlen
295301
296302export function extractReceiptVerb ( subject : CanonicalReceipt | CommandResponse | LegacyBlendedReceipt ) : string | null {
297303 const receipt = extractReceipt ( subject ) ;
298- return isRecord ( receipt . x402 ) && typeof receipt . x402 . verb === "string" ? receipt . x402 . verb : null ;
304+ return getReceiptVerb ( receipt ) ?? "summarize" ;
299305}
300306
301307export function normalizeCommandResponse < T = unknown > ( payload : unknown ) : CommandResponse < T > {
@@ -349,6 +355,7 @@ export async function verifyReceipt(receiptLike: CanonicalReceipt | CommandRespo
349355 const { hash_sha256 : recomputedHash } = recomputeReceiptHashSha256 ( receipt ) ;
350356 const hashMatches = claimedHash === recomputedHash ;
351357 const receiptId = typeof receipt . metadata ?. receipt_id === "string" ? receipt . metadata . receipt_id : null ;
358+ const receiptIdPresent = ! ! receiptId ;
352359 const receiptIdMatches = ! receiptId || ! claimedHash ? true : receiptId === claimedHash ;
353360
354361 let pubkey : Uint8Array | null = null ;
@@ -396,7 +403,7 @@ export async function verifyReceipt(receiptLike: CanonicalReceipt | CommandRespo
396403 } ,
397404 values : {
398405 verb : getReceiptVerb ( receipt ) ,
399- signer_id,
406+ signer_id : signerId ,
400407 alg,
401408 canonical,
402409 claimed_hash : claimedHash ,
0 commit comments