@thehonestmachine/oath-core 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 +202 -0
- package/README.md +9 -0
- package/dist/bytes.d.ts +7 -0
- package/dist/bytes.d.ts.map +1 -0
- package/dist/bytes.js +46 -0
- package/dist/bytes.js.map +1 -0
- package/dist/ed25519.d.ts +11 -0
- package/dist/ed25519.d.ts.map +1 -0
- package/dist/ed25519.js +37 -0
- package/dist/ed25519.js.map +1 -0
- package/dist/entry.d.ts +27 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +183 -0
- package/dist/entry.js.map +1 -0
- package/dist/errors.d.ts +5 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +5 -0
- package/dist/errors.js.map +1 -0
- package/dist/hash.d.ts +3 -0
- package/dist/hash.d.ts.map +1 -0
- package/dist/hash.js +9 -0
- package/dist/hash.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/jcs.d.ts +19 -0
- package/dist/jcs.d.ts.map +1 -0
- package/dist/jcs.js +63 -0
- package/dist/jcs.js.map +1 -0
- package/dist/merkle.d.ts +35 -0
- package/dist/merkle.d.ts.map +1 -0
- package/dist/merkle.js +177 -0
- package/dist/merkle.js.map +1 -0
- package/dist/oath.d.ts +34 -0
- package/dist/oath.d.ts.map +1 -0
- package/dist/oath.js +128 -0
- package/dist/oath.js.map +1 -0
- package/dist/sth.d.ts +16 -0
- package/dist/sth.d.ts.map +1 -0
- package/dist/sth.js +95 -0
- package/dist/sth.js.map +1 -0
- package/dist/types.d.ts +90 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/validate.d.ts +17 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +65 -0
- package/dist/validate.js.map +1 -0
- package/package.json +55 -0
- package/src/bytes.ts +46 -0
- package/src/ed25519.ts +40 -0
- package/src/entry.ts +208 -0
- package/src/errors.ts +4 -0
- package/src/hash.ts +10 -0
- package/src/index.ts +82 -0
- package/src/jcs.ts +60 -0
- package/src/merkle.ts +184 -0
- package/src/oath.ts +148 -0
- package/src/sth.ts +126 -0
- package/src/types.ts +108 -0
- package/src/validate.ts +81 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# @thehonestmachine/oath-core
|
|
2
|
+
|
|
3
|
+
The [OATH protocol](https://oath.sh/spec), no I/O: RFC 8785 canonicalization,
|
|
4
|
+
SHA-256 / Ed25519 (pure TS via @noble), the RFC-6962-style Merkle log with
|
|
5
|
+
inclusion and consistency proofs, and validation/signing/hashing for oath
|
|
6
|
+
documents, entries, signed tree heads, and receipts.
|
|
7
|
+
|
|
8
|
+
100% test coverage, enforced. The test suite reproduces the spec's
|
|
9
|
+
Appendix B vectors byte for byte. Apache-2.0.
|
package/dist/bytes.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function utf8Bytes(s: string): Uint8Array;
|
|
2
|
+
export declare function bytesToHex(bytes: Uint8Array): string;
|
|
3
|
+
/** Strict per spec §1.2: lowercase hex only, even length. */
|
|
4
|
+
export declare function hexToBytes(hex: string): Uint8Array;
|
|
5
|
+
export declare function bytesEqual(a: Uint8Array, b: Uint8Array): boolean;
|
|
6
|
+
export declare function concatBytes(...arrays: Uint8Array[]): Uint8Array;
|
|
7
|
+
//# sourceMappingURL=bytes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytes.d.ts","sourceRoot":"","sources":["../src/bytes.ts"],"names":[],"mappings":"AAGA,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,UAAU,CAE/C;AAID,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAMpD;AAED,6DAA6D;AAC7D,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAQlD;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,OAAO,CAKhE;AAED,wBAAgB,WAAW,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,GAAG,UAAU,CAU/D"}
|
package/dist/bytes.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { utf8ToBytes } from '@noble/hashes/utils';
|
|
2
|
+
import { ProtocolError } from './errors.js';
|
|
3
|
+
export function utf8Bytes(s) {
|
|
4
|
+
return utf8ToBytes(s);
|
|
5
|
+
}
|
|
6
|
+
const HEX_CHARS = '0123456789abcdef';
|
|
7
|
+
export function bytesToHex(bytes) {
|
|
8
|
+
let out = '';
|
|
9
|
+
for (const b of bytes) {
|
|
10
|
+
out += HEX_CHARS[b >> 4] + HEX_CHARS[b & 0x0f];
|
|
11
|
+
}
|
|
12
|
+
return out;
|
|
13
|
+
}
|
|
14
|
+
/** Strict per spec §1.2: lowercase hex only, even length. */
|
|
15
|
+
export function hexToBytes(hex) {
|
|
16
|
+
if (hex.length % 2 !== 0)
|
|
17
|
+
throw new ProtocolError('hex string has odd length');
|
|
18
|
+
if (!/^[0-9a-f]*$/.test(hex))
|
|
19
|
+
throw new ProtocolError('hex string must be lowercase 0-9a-f');
|
|
20
|
+
const out = new Uint8Array(hex.length / 2);
|
|
21
|
+
for (let i = 0; i < out.length; i++) {
|
|
22
|
+
out[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
|
|
23
|
+
}
|
|
24
|
+
return out;
|
|
25
|
+
}
|
|
26
|
+
export function bytesEqual(a, b) {
|
|
27
|
+
if (a.length !== b.length)
|
|
28
|
+
return false;
|
|
29
|
+
let diff = 0;
|
|
30
|
+
for (let i = 0; i < a.length; i++)
|
|
31
|
+
diff |= a[i] ^ b[i];
|
|
32
|
+
return diff === 0;
|
|
33
|
+
}
|
|
34
|
+
export function concatBytes(...arrays) {
|
|
35
|
+
let total = 0;
|
|
36
|
+
for (const a of arrays)
|
|
37
|
+
total += a.length;
|
|
38
|
+
const out = new Uint8Array(total);
|
|
39
|
+
let offset = 0;
|
|
40
|
+
for (const a of arrays) {
|
|
41
|
+
out.set(a, offset);
|
|
42
|
+
offset += a.length;
|
|
43
|
+
}
|
|
44
|
+
return out;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=bytes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytes.js","sourceRoot":"","sources":["../src/bytes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,UAAU,SAAS,CAAC,CAAS;IACjC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC;AACxB,CAAC;AAED,MAAM,SAAS,GAAG,kBAAkB,CAAC;AAErC,MAAM,UAAU,UAAU,CAAC,KAAiB;IAC1C,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,GAAG,IAAI,SAAS,CAAC,CAAC,IAAI,CAAC,CAAE,GAAG,SAAS,CAAC,CAAC,GAAG,IAAI,CAAE,CAAC;IACnD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,UAAU,CAAC,GAAW;IAC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f,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QACnB,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC;IACrB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Derive the public key (hex) from a 32-byte private seed (hex). */
|
|
2
|
+
export declare function edPublicKey(seedHex: string): string;
|
|
3
|
+
/** Sign a message with a 32-byte private seed; returns the 64-byte signature as hex. */
|
|
4
|
+
export declare function edSign(message: Uint8Array, seedHex: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* Verify an Ed25519 signature. Returns false (never throws) for signatures
|
|
7
|
+
* that fail, including structurally invalid curve points — every verifier
|
|
8
|
+
* must reach the same answer on the same bytes.
|
|
9
|
+
*/
|
|
10
|
+
export declare function edVerify(signatureHex: string, message: Uint8Array, pubkeyHex: string): boolean;
|
|
11
|
+
//# sourceMappingURL=ed25519.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ed25519.d.ts","sourceRoot":"","sources":["../src/ed25519.ts"],"names":[],"mappings":"AAgBA,qEAAqE;AACrE,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,wFAAwF;AACxF,wBAAgB,MAAM,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAQ9F"}
|
package/dist/ed25519.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as ed from '@noble/ed25519';
|
|
2
|
+
import { sha512 } from '@noble/hashes/sha512';
|
|
3
|
+
import { ProtocolError } from './errors.js';
|
|
4
|
+
import { bytesToHex, hexToBytes } from './bytes.js';
|
|
5
|
+
// @noble/ed25519 v2 needs a synchronous SHA-512 wired in for the sync API.
|
|
6
|
+
ed.etc.sha512Sync = (...messages) => sha512(ed.etc.concatBytes(...messages));
|
|
7
|
+
function keyBytes(hex, byteLength, label) {
|
|
8
|
+
const bytes = hexToBytes(hex);
|
|
9
|
+
if (bytes.length !== byteLength) {
|
|
10
|
+
throw new ProtocolError(`${label} must be ${byteLength} bytes of lowercase hex`);
|
|
11
|
+
}
|
|
12
|
+
return bytes;
|
|
13
|
+
}
|
|
14
|
+
/** Derive the public key (hex) from a 32-byte private seed (hex). */
|
|
15
|
+
export function edPublicKey(seedHex) {
|
|
16
|
+
return bytesToHex(ed.getPublicKey(keyBytes(seedHex, 32, 'private key seed')));
|
|
17
|
+
}
|
|
18
|
+
/** Sign a message with a 32-byte private seed; returns the 64-byte signature as hex. */
|
|
19
|
+
export function edSign(message, seedHex) {
|
|
20
|
+
return bytesToHex(ed.sign(message, keyBytes(seedHex, 32, 'private key seed')));
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Verify an Ed25519 signature. Returns false (never throws) for signatures
|
|
24
|
+
* that fail, including structurally invalid curve points — every verifier
|
|
25
|
+
* must reach the same answer on the same bytes.
|
|
26
|
+
*/
|
|
27
|
+
export function edVerify(signatureHex, message, pubkeyHex) {
|
|
28
|
+
const signature = keyBytes(signatureHex, 64, 'signature');
|
|
29
|
+
const pubkey = keyBytes(pubkeyHex, 32, 'public key');
|
|
30
|
+
try {
|
|
31
|
+
return ed.verify(signature, message, pubkey);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=ed25519.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ed25519.js","sourceRoot":"","sources":["../src/ed25519.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;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AY,CAAC,CAAC;IACrD,IAAI,CAAC;QACH,OAAO,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAC/C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
package/dist/entry.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Entry, OathDoc, UnsignedEntry } from './types.js';
|
|
2
|
+
/** Action types reserved by the spec (§3.4). */
|
|
3
|
+
export declare const RESERVED_ACTION_TYPES: readonly ["oath.swear", "oath.amend"];
|
|
4
|
+
/** Validate a complete signed entry (SPEC.md §3). Structural only. */
|
|
5
|
+
export declare function assertValidEntry(value: unknown): asserts value is Entry;
|
|
6
|
+
/** Validate an entry that has not been signed yet. */
|
|
7
|
+
export declare function assertValidUnsignedEntry(value: unknown): asserts value is UnsignedEntry;
|
|
8
|
+
/** Canonical bytes of the entry without its signature — the signing input. */
|
|
9
|
+
export declare function entrySigningInput(entry: UnsignedEntry | Entry): Uint8Array;
|
|
10
|
+
/** The leaf bytes (SPEC.md §3.2): canonical bytes of the complete signed entry. */
|
|
11
|
+
export declare function leafBytesOf(entry: Entry): Uint8Array;
|
|
12
|
+
/** The entry's Merkle leaf hash as hex: SHA-256(0x00 || leaf bytes). */
|
|
13
|
+
export declare function entryLeafHash(entry: Entry): string;
|
|
14
|
+
export declare function signEntry(unsigned: UnsignedEntry, seedHex: string): Entry;
|
|
15
|
+
export declare function verifyEntrySignature(entry: Entry, pubkeyHex: string): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Cross-check an entry against the oath version it cites (SPEC.md §3, §7):
|
|
18
|
+
* agent and version match, any cited law exists, and the signature verifies
|
|
19
|
+
* against the oath's key.
|
|
20
|
+
*/
|
|
21
|
+
export declare function assertEntryUnderOath(entry: Entry, oath: OathDoc): void;
|
|
22
|
+
/**
|
|
23
|
+
* Promptness (SPEC.md §8.2): the entry was authored within the oath's
|
|
24
|
+
* max_latency_seconds (default 300) of the action occurring.
|
|
25
|
+
*/
|
|
26
|
+
export declare function isPrompt(entry: Entry, maxLatencySeconds?: number): boolean;
|
|
27
|
+
//# sourceMappingURL=entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAiBhE,gDAAgD;AAChD,eAAO,MAAM,qBAAqB,uCAAwC,CAAC;AAoG3E,sEAAsE;AACtE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,KAAK,CAEvE;AAED,sDAAsD;AACtD,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,aAAa,CAEvF;AAED,8EAA8E;AAC9E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa,GAAG,KAAK,GAAG,UAAU,CAI1E;AAED,mFAAmF;AACnF,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,UAAU,CAGpD;AAED,wEAAwE;AACxE,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAElD;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,GAAG,KAAK,CAIzE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAG7E;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CActE;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,KAAK,EACZ,iBAAiB,GAAE,MAAoC,GACtD,OAAO,CAOT"}
|
package/dist/entry.js
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { ProtocolError } from './errors.js';
|
|
2
|
+
import { canonicalBytes } from './jcs.js';
|
|
3
|
+
import { leafHash } from './merkle.js';
|
|
4
|
+
import { bytesToHex } from './bytes.js';
|
|
5
|
+
import { edSign, edVerify } from './ed25519.js';
|
|
6
|
+
import { DEFAULT_MAX_LATENCY_SECONDS, SPEC_VERSION } from './oath.js';
|
|
7
|
+
import { assertKeys, assertPlainObject, isHandle, isHex, isNonEmptyString, isPositiveInteger, isTimestamp, } from './validate.js';
|
|
8
|
+
const REQUIRED = [
|
|
9
|
+
'spec_version',
|
|
10
|
+
'agent',
|
|
11
|
+
'oath_version',
|
|
12
|
+
'action',
|
|
13
|
+
'verdict',
|
|
14
|
+
'law_cited',
|
|
15
|
+
'adjudication',
|
|
16
|
+
'timestamp',
|
|
17
|
+
];
|
|
18
|
+
const OPTIONAL = ['confession'];
|
|
19
|
+
/** Dotted lowercase identifier (SPEC.md §3.1), e.g. "cycle.publish". */
|
|
20
|
+
const ACTION_TYPE_RE = /^[a-z0-9-]+(\.[a-z0-9-]+)*$/;
|
|
21
|
+
/** Action types reserved by the spec (§3.4). */
|
|
22
|
+
export const RESERVED_ACTION_TYPES = ['oath.swear', 'oath.amend'];
|
|
23
|
+
function validateAction(value) {
|
|
24
|
+
const action = assertPlainObject(value, 'entry action');
|
|
25
|
+
assertKeys(action, 'entry action', ['type', 'summary', 'content_hash', 'occurred_at'], []);
|
|
26
|
+
const type = action['type'];
|
|
27
|
+
if (!isNonEmptyString(type) || !ACTION_TYPE_RE.test(type)) {
|
|
28
|
+
throw new ProtocolError('action type must be a dotted lowercase identifier');
|
|
29
|
+
}
|
|
30
|
+
if (!isNonEmptyString(action['summary'])) {
|
|
31
|
+
throw new ProtocolError('action summary must be a non-empty string');
|
|
32
|
+
}
|
|
33
|
+
if (action['content_hash'] !== null && !isHex(action['content_hash'], 32)) {
|
|
34
|
+
throw new ProtocolError('action content_hash must be 32 bytes of lowercase hex or null');
|
|
35
|
+
}
|
|
36
|
+
if (!isTimestamp(action['occurred_at'])) {
|
|
37
|
+
throw new ProtocolError('action occurred_at must be an RFC 3339 UTC timestamp');
|
|
38
|
+
}
|
|
39
|
+
if (type.startsWith('oath.')) {
|
|
40
|
+
if (!RESERVED_ACTION_TYPES.includes(type)) {
|
|
41
|
+
throw new ProtocolError('action types beginning "oath." are reserved by the spec');
|
|
42
|
+
}
|
|
43
|
+
if (action['content_hash'] === null) {
|
|
44
|
+
throw new ProtocolError(`${type} entries must carry the oath hash in content_hash`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function validateAdjudication(value) {
|
|
49
|
+
const adjudication = assertPlainObject(value, 'entry adjudication');
|
|
50
|
+
const mode = adjudication['mode'];
|
|
51
|
+
if (mode === 'machine') {
|
|
52
|
+
assertKeys(adjudication, 'machine adjudication', ['mode', 'check'], ['check_version']);
|
|
53
|
+
if (!isNonEmptyString(adjudication['check'])) {
|
|
54
|
+
throw new ProtocolError('machine adjudication check must be a non-empty string');
|
|
55
|
+
}
|
|
56
|
+
if ('check_version' in adjudication && !isNonEmptyString(adjudication['check_version'])) {
|
|
57
|
+
throw new ProtocolError('machine adjudication check_version must be a non-empty string');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else if (mode === 'model') {
|
|
61
|
+
assertKeys(adjudication, 'model adjudication', ['mode', 'model', 'prompt_hash', 'inputs_hash'], []);
|
|
62
|
+
if (!isNonEmptyString(adjudication['model'])) {
|
|
63
|
+
throw new ProtocolError('model adjudication model must be a non-empty string');
|
|
64
|
+
}
|
|
65
|
+
if (!isHex(adjudication['prompt_hash'], 32)) {
|
|
66
|
+
throw new ProtocolError('model adjudication prompt_hash must be 32 bytes of lowercase hex');
|
|
67
|
+
}
|
|
68
|
+
if (!isHex(adjudication['inputs_hash'], 32)) {
|
|
69
|
+
throw new ProtocolError('model adjudication inputs_hash must be 32 bytes of lowercase hex');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
throw new ProtocolError('adjudication mode must be "machine" or "model"');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function validateEntryShape(value, requireSignature) {
|
|
77
|
+
const entry = assertPlainObject(value, 'entry');
|
|
78
|
+
const required = requireSignature ? [...REQUIRED, 'signature'] : REQUIRED;
|
|
79
|
+
const optional = requireSignature ? OPTIONAL : [...OPTIONAL, 'signature'];
|
|
80
|
+
assertKeys(entry, 'entry', required, optional);
|
|
81
|
+
if (entry['spec_version'] !== SPEC_VERSION) {
|
|
82
|
+
throw new ProtocolError(`entry spec_version must be "${SPEC_VERSION}"`);
|
|
83
|
+
}
|
|
84
|
+
if (!isHandle(entry['agent']))
|
|
85
|
+
throw new ProtocolError('entry agent must be a valid handle');
|
|
86
|
+
if (!isPositiveInteger(entry['oath_version'])) {
|
|
87
|
+
throw new ProtocolError('entry oath_version must be an integer >= 1');
|
|
88
|
+
}
|
|
89
|
+
validateAction(entry['action']);
|
|
90
|
+
const verdict = entry['verdict'];
|
|
91
|
+
if (verdict !== 'compliant' && verdict !== 'violation' && verdict !== 'uncertain') {
|
|
92
|
+
throw new ProtocolError('verdict must be "compliant", "violation", or "uncertain"');
|
|
93
|
+
}
|
|
94
|
+
const lawCited = entry['law_cited'];
|
|
95
|
+
if (lawCited !== null && !isPositiveInteger(lawCited)) {
|
|
96
|
+
throw new ProtocolError('law_cited must be a law number or null');
|
|
97
|
+
}
|
|
98
|
+
if (verdict === 'violation' && lawCited === null) {
|
|
99
|
+
throw new ProtocolError('a violation must cite the violated law (SPEC.md §3.3)');
|
|
100
|
+
}
|
|
101
|
+
if ('confession' in entry) {
|
|
102
|
+
const confession = assertPlainObject(entry['confession'], 'confession');
|
|
103
|
+
assertKeys(confession, 'confession', ['note'], []);
|
|
104
|
+
if (!isNonEmptyString(confession['note'])) {
|
|
105
|
+
throw new ProtocolError('confession note must be a non-empty string');
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
else if (verdict !== 'compliant') {
|
|
109
|
+
throw new ProtocolError(`a ${verdict} verdict requires a confession (SPEC.md §3.3)`);
|
|
110
|
+
}
|
|
111
|
+
validateAdjudication(entry['adjudication']);
|
|
112
|
+
if (!isTimestamp(entry['timestamp'])) {
|
|
113
|
+
throw new ProtocolError('entry timestamp must be an RFC 3339 UTC timestamp');
|
|
114
|
+
}
|
|
115
|
+
if (requireSignature && !isHex(entry['signature'], 64)) {
|
|
116
|
+
throw new ProtocolError('entry signature must be 64 bytes of lowercase hex');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/** Validate a complete signed entry (SPEC.md §3). Structural only. */
|
|
120
|
+
export function assertValidEntry(value) {
|
|
121
|
+
validateEntryShape(value, true);
|
|
122
|
+
}
|
|
123
|
+
/** Validate an entry that has not been signed yet. */
|
|
124
|
+
export function assertValidUnsignedEntry(value) {
|
|
125
|
+
validateEntryShape(value, false);
|
|
126
|
+
}
|
|
127
|
+
/** Canonical bytes of the entry without its signature — the signing input. */
|
|
128
|
+
export function entrySigningInput(entry) {
|
|
129
|
+
const { signature: _signature, ...unsigned } = entry;
|
|
130
|
+
assertValidUnsignedEntry(unsigned);
|
|
131
|
+
return canonicalBytes(unsigned);
|
|
132
|
+
}
|
|
133
|
+
/** The leaf bytes (SPEC.md §3.2): canonical bytes of the complete signed entry. */
|
|
134
|
+
export function leafBytesOf(entry) {
|
|
135
|
+
assertValidEntry(entry);
|
|
136
|
+
return canonicalBytes(entry);
|
|
137
|
+
}
|
|
138
|
+
/** The entry's Merkle leaf hash as hex: SHA-256(0x00 || leaf bytes). */
|
|
139
|
+
export function entryLeafHash(entry) {
|
|
140
|
+
return bytesToHex(leafHash(leafBytesOf(entry)));
|
|
141
|
+
}
|
|
142
|
+
export function signEntry(unsigned, seedHex) {
|
|
143
|
+
assertValidUnsignedEntry(unsigned);
|
|
144
|
+
const signature = edSign(canonicalBytes(unsigned), seedHex);
|
|
145
|
+
return { ...unsigned, signature };
|
|
146
|
+
}
|
|
147
|
+
export function verifyEntrySignature(entry, pubkeyHex) {
|
|
148
|
+
assertValidEntry(entry);
|
|
149
|
+
return edVerify(entry.signature, entrySigningInput(entry), pubkeyHex);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Cross-check an entry against the oath version it cites (SPEC.md §3, §7):
|
|
153
|
+
* agent and version match, any cited law exists, and the signature verifies
|
|
154
|
+
* against the oath's key.
|
|
155
|
+
*/
|
|
156
|
+
export function assertEntryUnderOath(entry, oath) {
|
|
157
|
+
assertValidEntry(entry);
|
|
158
|
+
if (entry.agent !== oath.agent) {
|
|
159
|
+
throw new ProtocolError('entry agent does not match the oath');
|
|
160
|
+
}
|
|
161
|
+
if (entry.oath_version !== oath.version) {
|
|
162
|
+
throw new ProtocolError('entry oath_version does not match the oath');
|
|
163
|
+
}
|
|
164
|
+
if (entry.law_cited !== null && entry.law_cited > oath.laws.length) {
|
|
165
|
+
throw new ProtocolError(`entry cites law ${entry.law_cited}, but the oath has ${oath.laws.length} laws`);
|
|
166
|
+
}
|
|
167
|
+
if (!verifyEntrySignature(entry, oath.pubkey)) {
|
|
168
|
+
throw new ProtocolError("entry signature does not verify against the oath's key");
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Promptness (SPEC.md §8.2): the entry was authored within the oath's
|
|
173
|
+
* max_latency_seconds (default 300) of the action occurring.
|
|
174
|
+
*/
|
|
175
|
+
export function isPrompt(entry, maxLatencySeconds = DEFAULT_MAX_LATENCY_SECONDS) {
|
|
176
|
+
assertValidEntry(entry);
|
|
177
|
+
if (!isPositiveInteger(maxLatencySeconds)) {
|
|
178
|
+
throw new ProtocolError('maxLatencySeconds must be an integer >= 1');
|
|
179
|
+
}
|
|
180
|
+
const delta = Date.parse(entry.timestamp) - Date.parse(entry.action.occurred_at);
|
|
181
|
+
return delta <= maxLatencySeconds * 1000;
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=entry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K,CAAC,SAAS,sBAAsB,IAAI,CAAC,IAAI,CAAC,MAAM,OAAO,CAAC,CAAC;IAC3G,CAAC;IACD,IAAI,CAAC,oBAAoB,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,aAAa,CAAC,wDAAwD,CAAC,CAAC;IACpF,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ,CACtB,KAAY,EACZ,oBAA4B,2BAA2B;IAEvD,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACxB,IAAI,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,aAAa,CAAC,2CAA2C,CAAC,CAAC;IACvE,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACjF,OAAO,KAAK,IAAI,iBAAiB,GAAG,IAAI,CAAC;AAC3C,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,qBAAa,aAAc,SAAQ,KAAK;IAC7B,IAAI,SAAmB;CACjC"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,MAAM,OAAO,aAAc,SAAQ,KAAK;IAC7B,IAAI,GAAG,eAAe,CAAC;CACjC"}
|
package/dist/hash.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../src/hash.ts"],"names":[],"mappings":"AAGA,wBAAgB,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAEpD;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAEnD"}
|
package/dist/hash.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { sha256 as nobleSha256 } from '@noble/hashes/sha256';
|
|
2
|
+
import { bytesToHex } from './bytes.js';
|
|
3
|
+
export function sha256(bytes) {
|
|
4
|
+
return nobleSha256(bytes);
|
|
5
|
+
}
|
|
6
|
+
export function sha256Hex(bytes) {
|
|
7
|
+
return bytesToHex(nobleSha256(bytes));
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=hash.js.map
|
package/dist/hash.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../src/hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,UAAU,MAAM,CAAC,KAAiB;IACtC,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,KAAiB;IACzC,OAAO,UAAU,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;AACxC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { ProtocolError } from './errors.js';
|
|
2
|
+
export { bytesToHex, hexToBytes, bytesEqual, concatBytes, utf8Bytes } from './bytes.js';
|
|
3
|
+
export { sha256, sha256Hex } from './hash.js';
|
|
4
|
+
export { canonicalize, canonicalBytes } from './jcs.js';
|
|
5
|
+
export { HANDLE_RE, isHandle, isTimestamp, isHex, isPositiveInteger, isNonNegativeInteger, isNonEmptyString, assertPlainObject, assertKeys, } from './validate.js';
|
|
6
|
+
export { edPublicKey, edSign, edVerify } from './ed25519.js';
|
|
7
|
+
export { EMPTY_ROOT, leafHash, nodeHash, rootFromLeafHashes, inclusionPath, consistencyPath, verifyInclusion, verifyConsistency, } from './merkle.js';
|
|
8
|
+
export { SPEC_VERSION, DEFAULT_MAX_LATENCY_SECONDS, assertValidOathDoc, assertValidUnsignedOathDoc, oathSigningInput, oathHash, signOathDoc, verifyOathSignature, assertValidAmendment, } from './oath.js';
|
|
9
|
+
export { RESERVED_ACTION_TYPES, assertValidEntry, assertValidUnsignedEntry, entrySigningInput, leafBytesOf, entryLeafHash, signEntry, verifyEntrySignature, assertEntryUnderOath, isPrompt, } from './entry.js';
|
|
10
|
+
export { assertValidSth, assertValidUnsignedSth, sthSigningInput, signSth, verifySthSignature, assertValidReceipt, assertValidUnsignedReceipt, receiptSigningInput, signReceipt, verifyReceiptSignature, } from './sth.js';
|
|
11
|
+
export type { Verdict, LawMode, Law, OathCommitments, UnsignedOathDoc, OathDoc, Action, MachineAdjudication, ModelAdjudication, Adjudication, Confession, UnsignedEntry, Entry, UnsignedTreeHead, SignedTreeHead, UnsignedReceipt, Receipt, InclusionProof, ConsistencyProof, } from './types.js';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACxF,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EACL,SAAS,EACT,QAAQ,EACR,WAAW,EACX,KAAK,EACL,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,GACX,MAAM,eAAe,CAAC;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