@bolyra/receipts 0.11.1 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/NOTICE +121 -0
- package/README.md +115 -0
- package/dist/approval.d.ts +251 -0
- package/dist/approval.js +1173 -0
- package/dist/chain.d.ts +3 -0
- package/dist/chain.js +0 -5
- package/dist/index.d.ts +2 -0
- package/dist/index.js +12 -1
- package/dist/sign.d.ts +7 -0
- package/dist/sign.js +3 -0
- package/dist/types.d.ts +7 -2
- package/package.json +3 -4
- package/src/approval.ts +1410 -0
- package/src/chain.ts +10 -1
- package/src/index.ts +39 -0
- package/src/sign.ts +41 -2
- package/src/types.ts +7 -2
package/dist/chain.d.ts
CHANGED
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
* (enterprise-configurable), not part of this library.
|
|
37
37
|
*/
|
|
38
38
|
import type { ReceiptPayload, ReceiptSignerConfig, SignedReceipt } from './types';
|
|
39
|
+
import type { ApprovalReceiptPayload, ExecutionReceiptPayload } from './approval';
|
|
39
40
|
/** Sentinel prevReceiptHash for the first receipt in a log: 32 zero bytes. */
|
|
40
41
|
export declare const GENESIS_PREV_RECEIPT_HASH: string;
|
|
41
42
|
/**
|
|
@@ -44,6 +45,8 @@ export declare const GENESIS_PREV_RECEIPT_HASH: string;
|
|
|
44
45
|
* signature.payloadHash) and `receiptHash` itself (to avoid self-reference).
|
|
45
46
|
*/
|
|
46
47
|
export declare function computeReceiptHash(receipt: SignedReceipt): string;
|
|
48
|
+
export declare function computeReceiptHash(receipt: SignedReceipt<ApprovalReceiptPayload | ExecutionReceiptPayload>): string;
|
|
49
|
+
export declare function computeReceiptHash(receipt: SignedReceipt): string;
|
|
47
50
|
/**
|
|
48
51
|
* Stateful writer-side chain: assigns { seq, prevReceiptHash } to each payload
|
|
49
52
|
* before signing and attaches the resulting receiptHash to the envelope.
|
package/dist/chain.js
CHANGED
|
@@ -46,11 +46,6 @@ const canonical_1 = require("./canonical");
|
|
|
46
46
|
const sign_1 = require("./sign");
|
|
47
47
|
/** Sentinel prevReceiptHash for the first receipt in a log: 32 zero bytes. */
|
|
48
48
|
exports.GENESIS_PREV_RECEIPT_HASH = '0x' + '0'.repeat(64);
|
|
49
|
-
/**
|
|
50
|
-
* Canonical hash of a signed receipt: keccak256 over
|
|
51
|
-
* canonicalize({ payload, signature }). Excludes `id` (derivable from
|
|
52
|
-
* signature.payloadHash) and `receiptHash` itself (to avoid self-reference).
|
|
53
|
-
*/
|
|
54
49
|
function computeReceiptHash(receipt) {
|
|
55
50
|
const canonical = (0, canonical_1.canonicalize)({ payload: receipt.payload, signature: receipt.signature });
|
|
56
51
|
return '0x' + (0, utils_1.bytesToHex)((0, sha3_1.keccak_256)(new TextEncoder().encode(canonical)));
|
package/dist/index.d.ts
CHANGED
|
@@ -7,3 +7,5 @@ export type { ReceiptPayload, ReceiptChainFields, SignedReceipt, ReceiptSignerCo
|
|
|
7
7
|
export { INSTANCE_BINDING_DST, INSTANCE_REF_PREFIX, computeInstanceRef, validateInstancePreimage, verifyInstanceBinding, } from './instance';
|
|
8
8
|
export type { InstancePreimage, ReceiptInstanceFields, InstanceBindingCode, InstanceBindingResult, PreimageValidation, } from './instance';
|
|
9
9
|
export { parseSignerDiscovery, acceptedSigners, SignerDiscoveryError, type SignerDiscoveryDocument, type DiscoveredSigner, } from './signer-discovery';
|
|
10
|
+
export { ARGUMENTS_DIGEST_DST, ARGUMENTS_MAX_BYTES, ARGUMENTS_MAX_DEPTH, LINK_VERIFICATION_STATEMENT, ApprovedExecutionError, computeArgumentsDigest, createApprovalReceipt, executeApproved, validateArgumentsJson, verifyApprovalExecutionLink, } from './approval';
|
|
11
|
+
export type { ApprovalAssertion, ApprovalBinding, ApprovalContext, ApprovalDecision, ApprovalReceiptInput, ApprovalReceiptPayload, ApprovalValidity, ApprovedExecution, ArgumentsValidation, BlockedExecution, BlockedExecutionCode, ConsumeClaim, ConsumeFn, DispatchFn, ExecuteApprovedParams, ExecutionFields, ExecutionReceiptPayload, JsonObject, JsonPrimitive, JsonValue, LinkCheck, LinkCheckId, LinkVerificationResult, ReturnedExecution, VerifyLinkParams, } from './approval';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SignerDiscoveryError = exports.acceptedSigners = exports.parseSignerDiscovery = exports.verifyInstanceBinding = exports.validateInstancePreimage = exports.computeInstanceRef = exports.INSTANCE_REF_PREFIX = exports.INSTANCE_BINDING_DST = exports.verifyReceiptChain = exports.computeReceiptHash = exports.ReceiptChain = exports.GENESIS_PREV_RECEIPT_HASH = exports.hashPayload = exports.verifyReceipt = exports.signReceipt = exports.createCommerceReceipt = exports.createAuthReceipt = exports.canonicalize = void 0;
|
|
3
|
+
exports.verifyApprovalExecutionLink = exports.validateArgumentsJson = exports.executeApproved = exports.createApprovalReceipt = exports.computeArgumentsDigest = exports.ApprovedExecutionError = exports.LINK_VERIFICATION_STATEMENT = exports.ARGUMENTS_MAX_DEPTH = exports.ARGUMENTS_MAX_BYTES = exports.ARGUMENTS_DIGEST_DST = exports.SignerDiscoveryError = exports.acceptedSigners = exports.parseSignerDiscovery = exports.verifyInstanceBinding = exports.validateInstancePreimage = exports.computeInstanceRef = exports.INSTANCE_REF_PREFIX = exports.INSTANCE_BINDING_DST = exports.verifyReceiptChain = exports.computeReceiptHash = exports.ReceiptChain = exports.GENESIS_PREV_RECEIPT_HASH = exports.hashPayload = exports.verifyReceipt = exports.signReceipt = exports.createCommerceReceipt = exports.createAuthReceipt = exports.canonicalize = void 0;
|
|
4
4
|
var canonical_1 = require("./canonical");
|
|
5
5
|
Object.defineProperty(exports, "canonicalize", { enumerable: true, get: function () { return canonical_1.canonicalize; } });
|
|
6
6
|
var receipt_1 = require("./receipt");
|
|
@@ -25,3 +25,14 @@ var signer_discovery_1 = require("./signer-discovery");
|
|
|
25
25
|
Object.defineProperty(exports, "parseSignerDiscovery", { enumerable: true, get: function () { return signer_discovery_1.parseSignerDiscovery; } });
|
|
26
26
|
Object.defineProperty(exports, "acceptedSigners", { enumerable: true, get: function () { return signer_discovery_1.acceptedSigners; } });
|
|
27
27
|
Object.defineProperty(exports, "SignerDiscoveryError", { enumerable: true, get: function () { return signer_discovery_1.SignerDiscoveryError; } });
|
|
28
|
+
var approval_1 = require("./approval");
|
|
29
|
+
Object.defineProperty(exports, "ARGUMENTS_DIGEST_DST", { enumerable: true, get: function () { return approval_1.ARGUMENTS_DIGEST_DST; } });
|
|
30
|
+
Object.defineProperty(exports, "ARGUMENTS_MAX_BYTES", { enumerable: true, get: function () { return approval_1.ARGUMENTS_MAX_BYTES; } });
|
|
31
|
+
Object.defineProperty(exports, "ARGUMENTS_MAX_DEPTH", { enumerable: true, get: function () { return approval_1.ARGUMENTS_MAX_DEPTH; } });
|
|
32
|
+
Object.defineProperty(exports, "LINK_VERIFICATION_STATEMENT", { enumerable: true, get: function () { return approval_1.LINK_VERIFICATION_STATEMENT; } });
|
|
33
|
+
Object.defineProperty(exports, "ApprovedExecutionError", { enumerable: true, get: function () { return approval_1.ApprovedExecutionError; } });
|
|
34
|
+
Object.defineProperty(exports, "computeArgumentsDigest", { enumerable: true, get: function () { return approval_1.computeArgumentsDigest; } });
|
|
35
|
+
Object.defineProperty(exports, "createApprovalReceipt", { enumerable: true, get: function () { return approval_1.createApprovalReceipt; } });
|
|
36
|
+
Object.defineProperty(exports, "executeApproved", { enumerable: true, get: function () { return approval_1.executeApproved; } });
|
|
37
|
+
Object.defineProperty(exports, "validateArgumentsJson", { enumerable: true, get: function () { return approval_1.validateArgumentsJson; } });
|
|
38
|
+
Object.defineProperty(exports, "verifyApprovalExecutionLink", { enumerable: true, get: function () { return approval_1.verifyApprovalExecutionLink; } });
|
package/dist/sign.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import type { ReceiptPayload, ReceiptSignerConfig, SignedReceipt } from './types';
|
|
2
|
+
import type { ApprovalReceiptPayload, ExecutionReceiptPayload } from './approval';
|
|
2
3
|
export declare function hashPayload(payload: ReceiptPayload): string;
|
|
4
|
+
export declare function hashPayload(payload: ApprovalReceiptPayload | ExecutionReceiptPayload): string;
|
|
5
|
+
export declare function hashPayload(payload: ReceiptPayload): string;
|
|
6
|
+
export declare function signReceipt(payload: ReceiptPayload, config: ReceiptSignerConfig): SignedReceipt;
|
|
7
|
+
export declare function signReceipt<T extends ApprovalReceiptPayload | ExecutionReceiptPayload>(payload: T, config: ReceiptSignerConfig): SignedReceipt<T>;
|
|
3
8
|
export declare function signReceipt(payload: ReceiptPayload, config: ReceiptSignerConfig): SignedReceipt;
|
|
4
9
|
export declare function verifyReceipt(receipt: SignedReceipt, expectedSigner?: string): boolean;
|
|
10
|
+
export declare function verifyReceipt(receipt: SignedReceipt<ApprovalReceiptPayload | ExecutionReceiptPayload>, expectedSigner?: string): boolean;
|
|
11
|
+
export declare function verifyReceipt(receipt: SignedReceipt, expectedSigner?: string): boolean;
|
package/dist/sign.js
CHANGED
|
@@ -42,6 +42,9 @@ const sha256_1 = require("@noble/hashes/sha256");
|
|
|
42
42
|
const sha3_1 = require("@noble/hashes/sha3");
|
|
43
43
|
const utils_1 = require("@noble/hashes/utils");
|
|
44
44
|
const canonical_1 = require("./canonical");
|
|
45
|
+
// Each legacy signature appears FIRST (call resolution) and again LAST:
|
|
46
|
+
// conditional types such as ReturnType<typeof signReceipt> read the last
|
|
47
|
+
// overload, and existing code relies on that resolving to the legacy shape.
|
|
45
48
|
// @noble/secp256k1 v2 requires hmacSha256Sync to be set for synchronous signing.
|
|
46
49
|
secp256k1.etc.hmacSha256Sync = (k, ...m) => {
|
|
47
50
|
const h = hmac_1.hmac.create(sha256_1.sha256, k);
|
package/dist/types.d.ts
CHANGED
|
@@ -66,10 +66,15 @@ export interface ReceiptPayload {
|
|
|
66
66
|
/** Present only on hash-chained receipts (written via ReceiptChain). */
|
|
67
67
|
chain?: ReceiptChainFields;
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Signed envelope. Generic over the payload so the approval-binding module can
|
|
71
|
+
* sign its own payload kinds; the default keeps every legacy call site typed
|
|
72
|
+
* exactly as before (`SignedReceipt` === `SignedReceipt<ReceiptPayload>`).
|
|
73
|
+
*/
|
|
74
|
+
export interface SignedReceipt<T = ReceiptPayload> {
|
|
70
75
|
/** First 16 hex chars of payloadHash. */
|
|
71
76
|
id: string;
|
|
72
|
-
payload:
|
|
77
|
+
payload: T;
|
|
73
78
|
signature: {
|
|
74
79
|
alg: 'ES256K';
|
|
75
80
|
keyId: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bolyra/receipts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"description": "Signed auth receipts for Bolyra ZKP verification decisions — canonical JSON, secp256k1 sign/verify, EVM-compatible r||s||v signatures.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"build": "tsc",
|
|
12
12
|
"prepare": "tsc",
|
|
13
13
|
"test": "jest",
|
|
14
|
-
"typecheck": "tsc --noEmit"
|
|
14
|
+
"typecheck": "tsc --noEmit && tsc -p tsconfig.test.json"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@noble/secp256k1": "^2.2.0",
|
|
@@ -36,8 +36,7 @@
|
|
|
36
36
|
"url": "https://github.com/bolyra/bolyra"
|
|
37
37
|
},
|
|
38
38
|
"publishConfig": {
|
|
39
|
-
"access": "public"
|
|
40
|
-
"tag": "release-0.11"
|
|
39
|
+
"access": "public"
|
|
41
40
|
},
|
|
42
41
|
"keywords": [
|
|
43
42
|
"bolyra",
|