@cedulon/audit 0.1.0
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 +192 -0
- package/README.md +13 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +433 -0
- package/dist/index.js.map +1 -0
- package/package.json +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the
|
|
44
|
+
purposes of this License, Derivative Works shall not include works
|
|
45
|
+
that remain separable from, or merely link (or bind by name) to
|
|
46
|
+
the interfaces of, the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of,
|
|
58
|
+
the Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as
|
|
159
|
+
a result of this License or out of the use or inability to use
|
|
160
|
+
the Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
Copyright 2026 Emekcan Dogru
|
|
181
|
+
|
|
182
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
183
|
+
you may not use this file except in compliance with the License.
|
|
184
|
+
You may obtain a copy of the License at
|
|
185
|
+
|
|
186
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
187
|
+
|
|
188
|
+
Unless required by applicable law or agreed to in writing, software
|
|
189
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
190
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
191
|
+
See the License for the specific language governing permissions and
|
|
192
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# `@cedulon/audit`
|
|
2
|
+
|
|
3
|
+
Compare a rail extract to the receipt chain and checkpoints. A settlement
|
|
4
|
+
without a receipt is a finding.
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
import { audit } from "@cedulon/audit";
|
|
8
|
+
|
|
9
|
+
const report = audit({ receipts, checkpoints, settlements });
|
|
10
|
+
// report.summary is "audit: balanced" or lists findings
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Repository: https://github.com/dogrucanemek-alt/cedulon
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type SignedCheckpoint } from "@cedulon/checkpoint";
|
|
2
|
+
import { type SignedReceipt } from "@cedulon/receipts";
|
|
3
|
+
import { type RailSettlement, type SignedRailExtract } from "@cedulon/x402-adapter";
|
|
4
|
+
export type FindingCode = "settlement-without-receipt" | "receipt-without-settlement" | "receipt-chain-break" | "checkpoint-total-mismatch" | "checkpoint-head-mismatch" | "duplicate-ref" | "settlement-mismatch" | "equivocation" | "window-coverage" | "settled-without-ref" | "unauthenticated-extract" | "extract-key-mismatch" | "extract-scope-mismatch" | "extract-settlement-mismatch" | "malformed-amount" | "countersign-bad" | "ok";
|
|
5
|
+
/**
|
|
6
|
+
* Trust root the verifier supplies out of band. Without it a rail extract only
|
|
7
|
+
* proves internal consistency: any key can sign any body, including its own.
|
|
8
|
+
*/
|
|
9
|
+
export type RailTrustPin = {
|
|
10
|
+
publicKeyPem: string;
|
|
11
|
+
accountId?: string;
|
|
12
|
+
railId?: string;
|
|
13
|
+
windowStartMs?: number;
|
|
14
|
+
windowEndMs?: number;
|
|
15
|
+
};
|
|
16
|
+
export type Finding = {
|
|
17
|
+
code: Exclude<FindingCode, "ok">;
|
|
18
|
+
detail: string;
|
|
19
|
+
id: string;
|
|
20
|
+
severity?: "fail" | "warn";
|
|
21
|
+
};
|
|
22
|
+
export type AuditReport = {
|
|
23
|
+
ok: boolean;
|
|
24
|
+
findings: Finding[];
|
|
25
|
+
warnings: Finding[];
|
|
26
|
+
guarantee: "unconditional" | "conditional";
|
|
27
|
+
summary: string;
|
|
28
|
+
};
|
|
29
|
+
export declare function inCheckpointWindow(timestampMs: number, cp: SignedCheckpoint): boolean;
|
|
30
|
+
export declare function receiptsInWindow(receipts: SignedReceipt[], cp: SignedCheckpoint): SignedReceipt[];
|
|
31
|
+
export declare function findReceiptChainBreak(receipts: SignedReceipt[]): Finding | null;
|
|
32
|
+
export declare function findSettlementMatches(receipts: SignedReceipt[], settlements: RailSettlement[]): Finding[];
|
|
33
|
+
/** @deprecated use findSettlementMatches */
|
|
34
|
+
export declare function findSettlementsWithoutReceipt(receipts: SignedReceipt[], settlements: RailSettlement[]): Finding[];
|
|
35
|
+
/** @deprecated use findSettlementMatches */
|
|
36
|
+
export declare function findReceiptsWithoutSettlement(receipts: SignedReceipt[], settlements: RailSettlement[]): Finding[];
|
|
37
|
+
export declare function findWindowCoverage(receipts: SignedReceipt[], checkpoints: SignedCheckpoint[]): Finding[];
|
|
38
|
+
export declare function findCheckpointTotalMismatches(receipts: SignedReceipt[], checkpoints: SignedCheckpoint[]): Finding[];
|
|
39
|
+
export declare function findEquivocationFinding(checkpoints: SignedCheckpoint[]): Finding | null;
|
|
40
|
+
export declare function audit(input: {
|
|
41
|
+
receipts: SignedReceipt[];
|
|
42
|
+
checkpoints: SignedCheckpoint[];
|
|
43
|
+
settlements?: RailSettlement[];
|
|
44
|
+
extract?: SignedRailExtract;
|
|
45
|
+
trust?: RailTrustPin;
|
|
46
|
+
}): AuditReport;
|
|
47
|
+
export declare function formatAudit(report: AuditReport, receiptCount?: number): string;
|
|
48
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,gBAAgB,EACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAsD,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC3G,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACvB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,WAAW,GACnB,4BAA4B,GAC5B,4BAA4B,GAC5B,qBAAqB,GACrB,2BAA2B,GAC3B,0BAA0B,GAC1B,eAAe,GACf,qBAAqB,GACrB,cAAc,GACd,iBAAiB,GACjB,qBAAqB,GACrB,yBAAyB,GACzB,sBAAsB,GACtB,wBAAwB,GACxB,6BAA6B,GAC7B,kBAAkB,GAClB,iBAAiB,GACjB,IAAI,CAAC;AAET;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,OAAO,CAAC;IACZ,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,QA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/B,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB,GAAG,WAAW,CAoId;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,EAAE,YAAY,SAAI,GAAG,MAAM,CAWzE"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
import { findCheckpointChainBreak, findEquivocation, totalsFromReceipts, verifyCheckpoint, } from "@cedulon/checkpoint";
|
|
2
|
+
import { receiptHash, verifyCounterSignature, verifyReceipt } from "@cedulon/receipts";
|
|
3
|
+
import { verifyRailExtract, } from "@cedulon/x402-adapter";
|
|
4
|
+
function receiptRef(r) {
|
|
5
|
+
return r.claims.x402PaymentRef;
|
|
6
|
+
}
|
|
7
|
+
function isSettled(r) {
|
|
8
|
+
return r.claims.outcome === "settled";
|
|
9
|
+
}
|
|
10
|
+
export function inCheckpointWindow(timestampMs, cp) {
|
|
11
|
+
return timestampMs >= cp.claims.startMs && timestampMs < cp.claims.endMs;
|
|
12
|
+
}
|
|
13
|
+
export function receiptsInWindow(receipts, cp) {
|
|
14
|
+
return receipts.filter((r) => inCheckpointWindow(r.claims.timestampMs, cp));
|
|
15
|
+
}
|
|
16
|
+
export function findReceiptChainBreak(receipts) {
|
|
17
|
+
for (let i = 0; i < receipts.length; i += 1) {
|
|
18
|
+
if (!verifyReceipt(receipts[i])) {
|
|
19
|
+
return {
|
|
20
|
+
code: "receipt-chain-break",
|
|
21
|
+
id: receipts[i].claims.nonce,
|
|
22
|
+
detail: `receipt ${i} signature failed`,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const expected = i === 0 ? null : receiptHash(receipts[i - 1]);
|
|
26
|
+
if (receipts[i].claims.prevReceiptHash !== expected) {
|
|
27
|
+
return {
|
|
28
|
+
code: "receipt-chain-break",
|
|
29
|
+
id: receipts[i].claims.nonce,
|
|
30
|
+
detail: `receipt ${i} prevReceiptHash does not match prior receipt`,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
function pushDuplicateRefs(items, findings) {
|
|
37
|
+
const seen = new Map();
|
|
38
|
+
for (const item of items) {
|
|
39
|
+
seen.set(item.ref, (seen.get(item.ref) ?? 0) + 1);
|
|
40
|
+
}
|
|
41
|
+
const dupes = new Set();
|
|
42
|
+
for (const [ref, n] of seen) {
|
|
43
|
+
if (n > 1) {
|
|
44
|
+
dupes.add(ref);
|
|
45
|
+
findings.push({
|
|
46
|
+
code: "duplicate-ref",
|
|
47
|
+
id: ref,
|
|
48
|
+
detail: `${items.find((x) => x.ref === ref)?.side ?? "item"} ref ${ref} appears ${n} times`,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return dupes;
|
|
53
|
+
}
|
|
54
|
+
export function findSettlementMatches(receipts, settlements) {
|
|
55
|
+
const findings = [];
|
|
56
|
+
const settled = receipts.filter(isSettled);
|
|
57
|
+
for (const r of settled) {
|
|
58
|
+
if (receiptRef(r) === null) {
|
|
59
|
+
findings.push({
|
|
60
|
+
code: "settled-without-ref",
|
|
61
|
+
id: r.claims.nonce,
|
|
62
|
+
detail: `settled receipt nonce=${r.claims.nonce} has null rail ref`,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const receiptItems = settled
|
|
67
|
+
.map((r) => ({ ref: receiptRef(r), id: r.claims.nonce, side: "receipt", receipt: r }))
|
|
68
|
+
.filter((x) => x.ref !== null);
|
|
69
|
+
const settlementItems = settlements.map((s) => ({
|
|
70
|
+
ref: s.ref,
|
|
71
|
+
id: s.ref,
|
|
72
|
+
side: "settlement",
|
|
73
|
+
settlement: s,
|
|
74
|
+
}));
|
|
75
|
+
const dupeReceipt = pushDuplicateRefs(receiptItems, findings);
|
|
76
|
+
const dupeSettlement = pushDuplicateRefs(settlementItems, findings);
|
|
77
|
+
const skip = new Set([...dupeReceipt, ...dupeSettlement]);
|
|
78
|
+
// A ref that repeats is skipped by the ref-keyed match below, so compare the
|
|
79
|
+
// aggregate settled amount against the aggregate receipted amount instead.
|
|
80
|
+
// Otherwise a repeated ref hides the amount that is unaccounted for.
|
|
81
|
+
for (const ref of skip) {
|
|
82
|
+
let malformed = false;
|
|
83
|
+
const add = (into, currency, amount) => {
|
|
84
|
+
let parsed;
|
|
85
|
+
try {
|
|
86
|
+
parsed = BigInt(amount);
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
// An amount the audit cannot read is itself a finding. Throwing here
|
|
90
|
+
// would take down the whole report over one bad row.
|
|
91
|
+
malformed = true;
|
|
92
|
+
findings.push({
|
|
93
|
+
code: "malformed-amount",
|
|
94
|
+
id: ref,
|
|
95
|
+
detail: `ref ${ref} carries the amount ${JSON.stringify(amount)}, which is not an integer`,
|
|
96
|
+
});
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
into.set(currency, (into.get(currency) ?? 0n) + parsed);
|
|
100
|
+
};
|
|
101
|
+
const settledByCurrency = new Map();
|
|
102
|
+
for (const item of settlementItems) {
|
|
103
|
+
if (item.ref !== ref)
|
|
104
|
+
continue;
|
|
105
|
+
add(settledByCurrency, item.settlement.currency, item.settlement.amount);
|
|
106
|
+
}
|
|
107
|
+
const receiptedByCurrency = new Map();
|
|
108
|
+
for (const item of receiptItems) {
|
|
109
|
+
if (item.ref !== ref)
|
|
110
|
+
continue;
|
|
111
|
+
add(receiptedByCurrency, item.receipt.claims.currency, item.receipt.claims.amount);
|
|
112
|
+
}
|
|
113
|
+
if (malformed) {
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
for (const [currency, settled] of settledByCurrency) {
|
|
117
|
+
const receipted = receiptedByCurrency.get(currency) ?? 0n;
|
|
118
|
+
if (settled > receipted) {
|
|
119
|
+
findings.push({
|
|
120
|
+
code: "settlement-without-receipt",
|
|
121
|
+
id: ref,
|
|
122
|
+
detail: `ref ${ref} settled ${settled} ${currency} against ${receipted} ${currency} receipted; ${settled - receipted} ${currency} unaccounted`,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
else if (settled < receipted) {
|
|
126
|
+
findings.push({
|
|
127
|
+
code: "settlement-mismatch",
|
|
128
|
+
id: ref,
|
|
129
|
+
detail: `ref ${ref} settled ${settled} ${currency} against ${receipted} ${currency} receipted`,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const receiptsByRef = new Map();
|
|
135
|
+
for (const item of receiptItems) {
|
|
136
|
+
if (!skip.has(item.ref)) {
|
|
137
|
+
receiptsByRef.set(item.ref, item.receipt);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const settlementsByRef = new Map();
|
|
141
|
+
for (const item of settlementItems) {
|
|
142
|
+
if (!skip.has(item.ref)) {
|
|
143
|
+
settlementsByRef.set(item.ref, item.settlement);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
for (const [ref, s] of settlementsByRef) {
|
|
147
|
+
const r = receiptsByRef.get(ref);
|
|
148
|
+
if (!r) {
|
|
149
|
+
findings.push({
|
|
150
|
+
code: "settlement-without-receipt",
|
|
151
|
+
id: ref,
|
|
152
|
+
detail: `settlement ${s.ref} ${s.amount} ${s.currency} has no spend receipt`,
|
|
153
|
+
});
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
if (r.claims.amount !== s.amount || r.claims.currency !== s.currency) {
|
|
157
|
+
findings.push({
|
|
158
|
+
code: "settlement-mismatch",
|
|
159
|
+
id: ref,
|
|
160
|
+
detail: `settlement ${ref} ${s.amount} ${s.currency} != receipt ${r.claims.amount} ${r.claims.currency}`,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
for (const [ref, r] of receiptsByRef) {
|
|
165
|
+
if (!settlementsByRef.has(ref)) {
|
|
166
|
+
findings.push({
|
|
167
|
+
code: "receipt-without-settlement",
|
|
168
|
+
id: r.claims.nonce,
|
|
169
|
+
detail: `receipt nonce=${r.claims.nonce} ref=${ref} is not on the rail extract`,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return findings;
|
|
174
|
+
}
|
|
175
|
+
/** @deprecated use findSettlementMatches */
|
|
176
|
+
export function findSettlementsWithoutReceipt(receipts, settlements) {
|
|
177
|
+
return findSettlementMatches(receipts, settlements).filter((f) => f.code === "settlement-without-receipt");
|
|
178
|
+
}
|
|
179
|
+
/** @deprecated use findSettlementMatches */
|
|
180
|
+
export function findReceiptsWithoutSettlement(receipts, settlements) {
|
|
181
|
+
return findSettlementMatches(receipts, settlements).filter((f) => f.code === "receipt-without-settlement");
|
|
182
|
+
}
|
|
183
|
+
export function findWindowCoverage(receipts, checkpoints) {
|
|
184
|
+
const findings = [];
|
|
185
|
+
const ordered = [...checkpoints].sort((a, b) => a.claims.epoch - b.claims.epoch);
|
|
186
|
+
for (let i = 1; i < ordered.length; i += 1) {
|
|
187
|
+
const prev = ordered[i - 1];
|
|
188
|
+
const cur = ordered[i];
|
|
189
|
+
if (cur.claims.epoch !== prev.claims.epoch + 1) {
|
|
190
|
+
findings.push({
|
|
191
|
+
code: "window-coverage",
|
|
192
|
+
id: `epoch-${cur.claims.epoch}`,
|
|
193
|
+
detail: `checkpoint epochs must be consecutive; ${prev.claims.epoch} then ${cur.claims.epoch}`,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
if (cur.claims.startMs !== prev.claims.endMs) {
|
|
197
|
+
findings.push({
|
|
198
|
+
code: "window-coverage",
|
|
199
|
+
id: `epoch-${cur.claims.epoch}-adjacent`,
|
|
200
|
+
detail: `checkpoint windows must be adjacent; epoch ${prev.claims.epoch} ends ${prev.claims.endMs} but ${cur.claims.epoch} starts ${cur.claims.startMs}`,
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
for (const r of receipts) {
|
|
205
|
+
const hits = checkpoints.filter((cp) => inCheckpointWindow(r.claims.timestampMs, cp));
|
|
206
|
+
if (hits.length === 0) {
|
|
207
|
+
findings.push({
|
|
208
|
+
code: "window-coverage",
|
|
209
|
+
id: r.claims.nonce,
|
|
210
|
+
detail: `receipt nonce=${r.claims.nonce} ts=${r.claims.timestampMs} is in no checkpoint window`,
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
else if (hits.length > 1) {
|
|
214
|
+
findings.push({
|
|
215
|
+
code: "window-coverage",
|
|
216
|
+
id: r.claims.nonce,
|
|
217
|
+
detail: `receipt nonce=${r.claims.nonce} is in ${hits.length} checkpoint windows`,
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return findings;
|
|
222
|
+
}
|
|
223
|
+
export function findCheckpointTotalMismatches(receipts, checkpoints) {
|
|
224
|
+
const findings = [];
|
|
225
|
+
for (const cp of checkpoints) {
|
|
226
|
+
if (!verifyCheckpoint(cp)) {
|
|
227
|
+
findings.push({
|
|
228
|
+
code: "checkpoint-total-mismatch",
|
|
229
|
+
id: `epoch-${cp.claims.epoch}`,
|
|
230
|
+
detail: `checkpoint epoch ${cp.claims.epoch} signature failed`,
|
|
231
|
+
});
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
const inWindow = receiptsInWindow(receipts, cp);
|
|
235
|
+
const expected = totalsFromReceipts(inWindow);
|
|
236
|
+
if (JSON.stringify(expected) !== JSON.stringify(cp.claims.totals)) {
|
|
237
|
+
findings.push({
|
|
238
|
+
code: "checkpoint-total-mismatch",
|
|
239
|
+
id: `epoch-${cp.claims.epoch}`,
|
|
240
|
+
detail: `checkpoint epoch ${cp.claims.epoch} totals ${JSON.stringify(cp.claims.totals)} != receipts ${JSON.stringify(expected)}`,
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
if (inWindow.length !== cp.claims.receiptCount) {
|
|
244
|
+
findings.push({
|
|
245
|
+
code: "checkpoint-total-mismatch",
|
|
246
|
+
id: `epoch-${cp.claims.epoch}-count`,
|
|
247
|
+
detail: `checkpoint epoch ${cp.claims.epoch} receiptCount ${cp.claims.receiptCount} != ${inWindow.length}`,
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
const expectedHead = inWindow.length === 0 ? null : receiptHash(inWindow[inWindow.length - 1]);
|
|
251
|
+
if (cp.claims.chainHeadHash !== expectedHead) {
|
|
252
|
+
findings.push({
|
|
253
|
+
code: "checkpoint-head-mismatch",
|
|
254
|
+
id: `epoch-${cp.claims.epoch}-head`,
|
|
255
|
+
detail: `checkpoint epoch ${cp.claims.epoch} chainHeadHash ${cp.claims.chainHeadHash} != ${expectedHead}`,
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
const chain = findCheckpointChainBreak(checkpoints);
|
|
260
|
+
if (chain) {
|
|
261
|
+
findings.push({
|
|
262
|
+
code: "checkpoint-total-mismatch",
|
|
263
|
+
id: `checkpoint-chain-${chain.index}`,
|
|
264
|
+
detail: `checkpoint chain ${chain.reason} at ${chain.index}`,
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
return findings;
|
|
268
|
+
}
|
|
269
|
+
export function findEquivocationFinding(checkpoints) {
|
|
270
|
+
const hit = findEquivocation(checkpoints);
|
|
271
|
+
if (!hit) {
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
return {
|
|
275
|
+
code: "equivocation",
|
|
276
|
+
id: `epoch-${hit.epoch}`,
|
|
277
|
+
detail: `epoch ${hit.epoch} has ${hit.hashes.length} distinct checkpoint hashes`,
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
function normalizePem(pem) {
|
|
281
|
+
return pem.replace(/\s+/g, "");
|
|
282
|
+
}
|
|
283
|
+
function settlementKey(s) {
|
|
284
|
+
return [s.ref, s.amount, s.currency, s.timestampMs].join("\u0000");
|
|
285
|
+
}
|
|
286
|
+
function sameSettlements(a, b) {
|
|
287
|
+
if (a.length !== b.length)
|
|
288
|
+
return false;
|
|
289
|
+
const left = a.map(settlementKey).sort();
|
|
290
|
+
const right = b.map(settlementKey).sort();
|
|
291
|
+
return left.every((k, i) => k === right[i]);
|
|
292
|
+
}
|
|
293
|
+
export function audit(input) {
|
|
294
|
+
const findings = [];
|
|
295
|
+
const warnings = [];
|
|
296
|
+
// When an extract is supplied it is the subject of the audit: reconcile the
|
|
297
|
+
// rows it actually carries, never a separate array the caller hands over.
|
|
298
|
+
const reconciled = input.extract ? input.extract.body.settlements : (input.settlements ?? []);
|
|
299
|
+
if (input.extract) {
|
|
300
|
+
if (input.settlements && !sameSettlements(input.settlements, input.extract.body.settlements)) {
|
|
301
|
+
findings.push({
|
|
302
|
+
code: "extract-settlement-mismatch",
|
|
303
|
+
id: "extract",
|
|
304
|
+
detail: `caller supplied ${input.settlements.length} settlement(s) that differ from the ${input.extract.body.settlements.length} in the signed extract; the extract is authoritative`,
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
const signatureVerifies = verifyRailExtract(input.extract);
|
|
308
|
+
if (!input.trust) {
|
|
309
|
+
warnings.push({
|
|
310
|
+
code: "unauthenticated-extract",
|
|
311
|
+
id: "extract",
|
|
312
|
+
detail: signatureVerifies
|
|
313
|
+
? "no verifier-supplied rail key; the signature proves internal consistency, not that the named rail produced the extract, so the completeness guarantee is conditional"
|
|
314
|
+
: "rail extract signature failed and no rail key was pinned; completeness guarantee is conditional",
|
|
315
|
+
severity: "warn",
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
// A pin is the verifier stating what it expects. Once stated, every way of
|
|
320
|
+
// failing to meet it is a finding, including a signature that does not
|
|
321
|
+
// verify at all: checking the pin only on the path where the signature
|
|
322
|
+
// already verified would fail open on the worse input.
|
|
323
|
+
const t = input.trust;
|
|
324
|
+
const body = input.extract.body;
|
|
325
|
+
if (!signatureVerifies) {
|
|
326
|
+
findings.push({
|
|
327
|
+
code: "extract-key-mismatch",
|
|
328
|
+
id: "extract",
|
|
329
|
+
detail: "a rail key was pinned but the extract signature does not verify against the key it carries",
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
else if (normalizePem(input.extract.publicKeyPem) !== normalizePem(t.publicKeyPem)) {
|
|
333
|
+
findings.push({
|
|
334
|
+
code: "extract-key-mismatch",
|
|
335
|
+
id: "extract",
|
|
336
|
+
detail: "rail extract is signed by a key other than the pinned rail key",
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
if (t.accountId !== undefined && body.accountId !== t.accountId) {
|
|
340
|
+
findings.push({
|
|
341
|
+
code: "extract-scope-mismatch",
|
|
342
|
+
id: "extract",
|
|
343
|
+
detail: `rail extract covers account ${body.accountId}, not the expected ${t.accountId}`,
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
if (t.railId !== undefined && body.railId !== t.railId) {
|
|
347
|
+
findings.push({
|
|
348
|
+
code: "extract-scope-mismatch",
|
|
349
|
+
id: "extract",
|
|
350
|
+
detail: `rail extract covers rail ${body.railId}, not the expected ${t.railId}`,
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
if (t.windowStartMs !== undefined && body.windowStartMs > t.windowStartMs) {
|
|
354
|
+
findings.push({
|
|
355
|
+
code: "extract-scope-mismatch",
|
|
356
|
+
id: "extract",
|
|
357
|
+
detail: `rail extract starts at ${body.windowStartMs}, after the expected window start ${t.windowStartMs}`,
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
if (t.windowEndMs !== undefined && body.windowEndMs < t.windowEndMs) {
|
|
361
|
+
findings.push({
|
|
362
|
+
code: "extract-scope-mismatch",
|
|
363
|
+
id: "extract",
|
|
364
|
+
detail: `rail extract ends at ${body.windowEndMs}, before the expected window end ${t.windowEndMs}`,
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
warnings.push({
|
|
371
|
+
code: "unauthenticated-extract",
|
|
372
|
+
id: "extract",
|
|
373
|
+
detail: input.trust
|
|
374
|
+
? "a rail key was pinned but no extract was supplied, so there is nothing to check it against; completeness guarantee is conditional"
|
|
375
|
+
: "rail extract is unsigned; completeness guarantee is conditional",
|
|
376
|
+
severity: "warn",
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
findings.push(...findSettlementMatches(input.receipts, reconciled));
|
|
380
|
+
for (const r of input.receipts) {
|
|
381
|
+
if (!r.counterCoseHex) {
|
|
382
|
+
continue;
|
|
383
|
+
}
|
|
384
|
+
if (!verifyCounterSignature(r)) {
|
|
385
|
+
findings.push({
|
|
386
|
+
code: "countersign-bad",
|
|
387
|
+
id: r.claims.nonce,
|
|
388
|
+
detail: `payee countersignature on nonce=${r.claims.nonce} failed verify`,
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
const chain = findReceiptChainBreak(input.receipts);
|
|
393
|
+
if (chain)
|
|
394
|
+
findings.push(chain);
|
|
395
|
+
findings.push(...findCheckpointTotalMismatches(input.receipts, input.checkpoints));
|
|
396
|
+
findings.push(...findWindowCoverage(input.receipts, input.checkpoints));
|
|
397
|
+
const equiv = findEquivocationFinding(input.checkpoints);
|
|
398
|
+
if (equiv)
|
|
399
|
+
findings.push(equiv);
|
|
400
|
+
const hard = findings.filter((f) => f.severity !== "warn");
|
|
401
|
+
const missing = hard.filter((f) => f.code === "settlement-without-receipt");
|
|
402
|
+
const summary = hard.length === 0
|
|
403
|
+
? "audit: balanced"
|
|
404
|
+
: missing.length > 0
|
|
405
|
+
? `audit: ${missing.length} settlement without receipt → FAIL`
|
|
406
|
+
: `audit: ${hard.length} finding(s) → FAIL`;
|
|
407
|
+
// A finding that says the extract itself cannot be trusted also removes the
|
|
408
|
+
// unconditional claim; otherwise a report could name a key mismatch and still
|
|
409
|
+
// describe its own guarantee as unconditional.
|
|
410
|
+
const doubtedExtract = hard.some((f) => f.code === "extract-key-mismatch" ||
|
|
411
|
+
f.code === "extract-scope-mismatch" ||
|
|
412
|
+
f.code === "extract-settlement-mismatch");
|
|
413
|
+
return {
|
|
414
|
+
ok: hard.length === 0,
|
|
415
|
+
findings: hard,
|
|
416
|
+
warnings,
|
|
417
|
+
guarantee: warnings.length === 0 && !doubtedExtract ? "unconditional" : "conditional",
|
|
418
|
+
summary,
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
export function formatAudit(report, receiptCount = 0) {
|
|
422
|
+
const lines = report.ok
|
|
423
|
+
? [`audit: balanced`, `receipts=${receiptCount}`, "findings=0"]
|
|
424
|
+
: [report.summary, ...report.findings.map((f) => `${f.code}\t${f.id}\t${f.detail}`)];
|
|
425
|
+
// Warnings decide whether the balance means anything, so an operator has to
|
|
426
|
+
// see them on the passing path too, not only in the returned object.
|
|
427
|
+
lines.push(`guarantee=${report.guarantee}`);
|
|
428
|
+
for (const w of report.warnings) {
|
|
429
|
+
lines.push(`warn\t${w.code}\t${w.detail}`);
|
|
430
|
+
}
|
|
431
|
+
return lines.join("\n");
|
|
432
|
+
}
|
|
433
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,GAEjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,aAAa,EAAsB,MAAM,mBAAmB,CAAC;AAC3G,OAAO,EACL,iBAAiB,GAGlB,MAAM,uBAAuB,CAAC;AAgD/B,SAAS,UAAU,CAAC,CAAgB;IAClC,OAAO,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC;AACjC,CAAC;AAED,SAAS,SAAS,CAAC,CAAgB;IACjC,OAAO,CAAC,CAAC,MAAM,CAAC,OAAO,KAAK,SAAS,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,WAAmB,EAAE,EAAoB;IAC1E,OAAO,WAAW,IAAI,EAAE,CAAC,MAAM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AK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACvF,4EAA4E;IAC5E,qEAAqE;IACrE,KAAK,CAAC,IAAI,CAAC,aAAa,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;IAC5C,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QAChC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cedulon/audit",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Reconcile a rail extract against the Cedulon receipt chain.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=20"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/dogrucanemek-alt/cedulon.git",
|
|
13
|
+
"directory": "packages/audit"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/dogrucanemek-alt/cedulon/tree/master/packages/audit",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/dogrucanemek-alt/cedulon/issues"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"cedulon",
|
|
21
|
+
"audit"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsc -p tsconfig.build.json"
|
|
25
|
+
},
|
|
26
|
+
"main": "./dist/index.js",
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"import": "./dist/index.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist",
|
|
36
|
+
"README.md",
|
|
37
|
+
"LICENSE"
|
|
38
|
+
],
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@cedulon/checkpoint": "^0.1.0",
|
|
44
|
+
"@cedulon/receipts": "^0.1.0",
|
|
45
|
+
"@cedulon/x402-adapter": "^0.1.0"
|
|
46
|
+
}
|
|
47
|
+
}
|