@mcsherrylabs/evolver-client 0.8.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 +42 -0
- package/dist/api.d.ts +172 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +508 -0
- package/dist/api.js.map +1 -0
- package/dist/bodies.d.ts +86 -0
- package/dist/bodies.d.ts.map +1 -0
- package/dist/bodies.js +145 -0
- package/dist/bodies.js.map +1 -0
- package/dist/crypto/auth.d.ts +25 -0
- package/dist/crypto/auth.d.ts.map +1 -0
- package/dist/crypto/auth.js +71 -0
- package/dist/crypto/auth.js.map +1 -0
- package/dist/crypto/canonical.d.ts +21 -0
- package/dist/crypto/canonical.d.ts.map +1 -0
- package/dist/crypto/canonical.js +68 -0
- package/dist/crypto/canonical.js.map +1 -0
- package/dist/crypto/group.d.ts +29 -0
- package/dist/crypto/group.d.ts.map +1 -0
- package/dist/crypto/group.js +107 -0
- package/dist/crypto/group.js.map +1 -0
- package/dist/crypto/hash.d.ts +7 -0
- package/dist/crypto/hash.d.ts.map +1 -0
- package/dist/crypto/hash.js +34 -0
- package/dist/crypto/hash.js.map +1 -0
- package/dist/crypto/stream.d.ts +27 -0
- package/dist/crypto/stream.d.ts.map +1 -0
- package/dist/crypto/stream.js +186 -0
- package/dist/crypto/stream.js.map +1 -0
- package/dist/envelope.d.ts +28 -0
- package/dist/envelope.d.ts.map +1 -0
- package/dist/envelope.js +68 -0
- package/dist/envelope.js.map +1 -0
- package/dist/generated/codecs.d.ts +145 -0
- package/dist/generated/codecs.d.ts.map +1 -0
- package/dist/generated/codecs.js +240 -0
- package/dist/generated/codecs.js.map +1 -0
- package/dist/identity.d.ts +17 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +52 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/signers.d.ts +52 -0
- package/dist/signers.d.ts.map +1 -0
- package/dist/signers.js +75 -0
- package/dist/signers.js.map +1 -0
- package/dist/types.d.ts +103 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +44 -0
- package/dist/types.js.map +1 -0
- package/dist/wire.d.ts +13 -0
- package/dist/wire.d.ts.map +1 -0
- package/dist/wire.js +71 -0
- package/dist/wire.js.map +1 -0
- package/package.json +41 -0
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
// ⚠️ GENERATED FILE — DO NOT EDIT. Regenerate with `sbt-evolver generateSignables`.
|
|
2
|
+
//
|
|
3
|
+
// 149 — one description per signed message, and this is its TypeScript interpreter. The
|
|
4
|
+
// source is `Codecs.all` in the Scala tree; this file is emitted from the schema that
|
|
5
|
+
// `SchemaExport` derives from it, so the node and the SDK cannot disagree about a format
|
|
6
|
+
// without one of them failing to build.
|
|
7
|
+
//
|
|
8
|
+
// Hand-editing this file is caught by `GeneratedSourcesSpec`, which regenerates and diffs.
|
|
9
|
+
// If a digest here is wrong, the description is wrong: fix
|
|
10
|
+
// `src/main/scala/ce/evolver/signable/` (or wherever the description lives) and regenerate.
|
|
11
|
+
//
|
|
12
|
+
// ⚠️ WHAT THE CALLER STILL DECIDES. A `oneOf` field's BRANCH CONDITION is not in the
|
|
13
|
+
// description — `Branch.select` is a Scala function, so no schema can carry it and no
|
|
14
|
+
// generator can emit it. The caller therefore says WHICH fold applies and supplies the
|
|
15
|
+
// pre-image; the generated code applies it. That is strictly more than the hand-written
|
|
16
|
+
// SDK did (it took an already-folded slot and computed `sha256` at the call site), and it
|
|
17
|
+
// is the honest boundary of what generation can reach.
|
|
18
|
+
import { dst, lpString, lengthPrefixed, int32BE, int64BE, count, encoded } from "../crypto/canonical.js";
|
|
19
|
+
import { sha256 } from "../crypto/hash.js";
|
|
20
|
+
function foldBytes(c) {
|
|
21
|
+
switch (c.fold) {
|
|
22
|
+
case "sha256Of": return sha256(c.bytes);
|
|
23
|
+
case "verbatim": return c.bytes;
|
|
24
|
+
case "empty": return new Uint8Array(0);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** A fixed-width slot, written BARE. The width is checked because that is the whole
|
|
28
|
+
* justification for omitting the prefix: a short value runs into the next field and the
|
|
29
|
+
* encoding stops being injective. */
|
|
30
|
+
function fixedWidth(field, b, width) {
|
|
31
|
+
if (b.length !== width) {
|
|
32
|
+
throw new Error(`field '${field}': expected ${width} bytes, got ${b.length}. An unprefixed field of ` +
|
|
33
|
+
`the wrong width runs into the next one and the encoding stops being injective.`);
|
|
34
|
+
}
|
|
35
|
+
return b;
|
|
36
|
+
}
|
|
37
|
+
/** `ce.evolver/153/tx-auth/v2` — digest. */
|
|
38
|
+
export function authBody(f) {
|
|
39
|
+
return sha256(encoded(dst("ce.evolver/153/tx-auth/v2"), lpString(f.ledgerId), lpString(f.senderNodeId), int64BE(f.ttlRound), int64BE(f.maxToll), lengthPrefixed(foldBytes(f.bodySlot))));
|
|
40
|
+
}
|
|
41
|
+
/** `ce.evolver/148/auths-digest/v1` — digest. */
|
|
42
|
+
export function authsDigest(f) {
|
|
43
|
+
return sha256(encoded(dst("ce.evolver/148/auths-digest/v1"), count(f.auths.length), ...f.auths.flatMap((e) => [lpString(e.nodeId), lpString(e.keyType), lpString(e.keyLabel), int32BE(e.purpose), lengthPrefixed(e.signature)])));
|
|
44
|
+
}
|
|
45
|
+
/** `ce.evolver/148/vote/v1` — material (signed as-is, NOT hashed). */
|
|
46
|
+
export function vote(f) {
|
|
47
|
+
return encoded(dst("ce.evolver/148/vote/v1"), int32BE(f.roundNum), fixedWidth("blockId", f.blockId, 32));
|
|
48
|
+
}
|
|
49
|
+
/** `ce.evolver/148/new-view/v1` — material (signed as-is, NOT hashed). */
|
|
50
|
+
export function newView(f) {
|
|
51
|
+
return encoded(dst("ce.evolver/148/new-view/v1"), int32BE(f.roundNum), fixedWidth("highQcBlockId", f.highQcBlockId, 32), int32BE(f.highQcRoundNum));
|
|
52
|
+
}
|
|
53
|
+
/** `ce.evolver/145/p2p-msg/v1` — digest. */
|
|
54
|
+
export function p2pSignable(f) {
|
|
55
|
+
return sha256(encoded(dst("ce.evolver/145/p2p-msg/v1"), lpString(f.sender), lpString(f.keyType), lpString(f.keyLabel), lpString(f.recipient), lpString(f.channel), int64BE(f.timestamp), lengthPrefixed(f.nonce), fixedWidth("payload", sha256(f.payload), 32)));
|
|
56
|
+
}
|
|
57
|
+
/** `ce.evolver/148/pop-create-identity/v1` — digest. */
|
|
58
|
+
export function popCreateIdentity(f) {
|
|
59
|
+
return sha256(encoded(dst("ce.evolver/148/pop-create-identity/v1"), lpString(f.nodeId), int64BE(f.initialCredit), count(f.keys.length), ...f.keys.flatMap((e) => [lpString(e.keyType), lengthPrefixed(e.publicKey), lpString(e.keyLabel)])));
|
|
60
|
+
}
|
|
61
|
+
/** `ce.evolver/148/pop-add-key/v1` — digest. */
|
|
62
|
+
export function popAddKey(f) {
|
|
63
|
+
return sha256(encoded(dst("ce.evolver/148/pop-add-key/v1"), lengthPrefixed(f.publicKey), lpString(f.keyType), lpString(f.keyLabel)));
|
|
64
|
+
}
|
|
65
|
+
/** `ce.evolver/148/pop-replace-key/v1` — digest. */
|
|
66
|
+
export function popReplaceKey(f) {
|
|
67
|
+
return sha256(encoded(dst("ce.evolver/148/pop-replace-key/v1"), lengthPrefixed(f.publicKey), lpString(f.keyType), lpString(f.keyLabel)));
|
|
68
|
+
}
|
|
69
|
+
/** `ce.evolver/149/proposal-id-admission/v1` — digest. */
|
|
70
|
+
export function proposalIdAdmission(f) {
|
|
71
|
+
return sha256(encoded(dst("ce.evolver/149/proposal-id-admission/v1"), lpString(f.candidateNodeId), int32BE(f.startBlockHeight), lpString(f.proposerNodeId), int32BE(f.donatedStake)));
|
|
72
|
+
}
|
|
73
|
+
/** `ce.evolver/149/proposal-id-removal/v1` — digest. */
|
|
74
|
+
export function proposalIdRemoval(f) {
|
|
75
|
+
return sha256(encoded(dst("ce.evolver/149/proposal-id-removal/v1"), lpString(f.targetNodeId), int32BE(f.removalBlockHeight), lpString(f.proposerNodeId)));
|
|
76
|
+
}
|
|
77
|
+
/** `ce.evolver/148/block-id/v1` — digest. */
|
|
78
|
+
export function blockId(f) {
|
|
79
|
+
return sha256(encoded(dst("ce.evolver/148/block-id/v1"), int32BE(f.roundNum), fixedWidth("parentId", f.parentId, 32), fixedWidth("merkleRoot", f.merkleRoot, 32), lengthPrefixed(f.parentQcSigners)));
|
|
80
|
+
}
|
|
81
|
+
/** `ce.evolver/149/list-tx-id/v1` — digest. */
|
|
82
|
+
export function listTxId(f) {
|
|
83
|
+
return sha256(encoded(dst("ce.evolver/149/list-tx-id/v1"), count(f.txIds.length), ...f.txIds.flatMap((e) => [fixedWidth("txIds.txId", e.txId, 32)])));
|
|
84
|
+
}
|
|
85
|
+
/** `ce.evolver/149/list-context/v1` — digest. */
|
|
86
|
+
export function listContext(f) {
|
|
87
|
+
return sha256(encoded(dst("ce.evolver/149/list-context/v1"), fixedWidth("listTxId", f.listTxId, 32), fixedWidth("txId", f.txId, 32)));
|
|
88
|
+
}
|
|
89
|
+
export const CODECS = [
|
|
90
|
+
{
|
|
91
|
+
name: "auth-body",
|
|
92
|
+
tag: "ce.evolver/153/tx-auth/v2",
|
|
93
|
+
output: "digest",
|
|
94
|
+
fields: [
|
|
95
|
+
{ name: "ledgerId", kind: "string", derivation: "direct" },
|
|
96
|
+
{ name: "senderNodeId", kind: "string", derivation: "direct" },
|
|
97
|
+
{ name: "ttlRound", kind: "int64", derivation: "direct" },
|
|
98
|
+
{ name: "maxToll", kind: "int64", derivation: "direct" },
|
|
99
|
+
{ name: "bodySlot", kind: "bytes", derivation: { oneOf: ["sha256Of", "verbatim", "empty"] } },
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: "auths-digest",
|
|
104
|
+
tag: "ce.evolver/148/auths-digest/v1",
|
|
105
|
+
output: "digest",
|
|
106
|
+
fields: [
|
|
107
|
+
{ name: "auths", kind: "list(string,string,string,int32,bytes)", elements: [{ name: "nodeId", kind: "string" }, { name: "keyType", kind: "string" }, { name: "keyLabel", kind: "string" }, { name: "purpose", kind: "int32" }, { name: "signature", kind: "bytes" }], derivation: "direct" },
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: "vote",
|
|
112
|
+
tag: "ce.evolver/148/vote/v1",
|
|
113
|
+
output: "material",
|
|
114
|
+
fields: [
|
|
115
|
+
{ name: "roundNum", kind: "int32", derivation: "direct" },
|
|
116
|
+
{ name: "blockId", kind: "fixed(32)", derivation: "direct" },
|
|
117
|
+
],
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: "new-view",
|
|
121
|
+
tag: "ce.evolver/148/new-view/v1",
|
|
122
|
+
output: "material",
|
|
123
|
+
fields: [
|
|
124
|
+
{ name: "roundNum", kind: "int32", derivation: "direct" },
|
|
125
|
+
{ name: "highQcBlockId", kind: "fixed(32)", derivation: "direct" },
|
|
126
|
+
{ name: "highQcRoundNum", kind: "int32", derivation: "direct" },
|
|
127
|
+
],
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: "p2p-signable",
|
|
131
|
+
tag: "ce.evolver/145/p2p-msg/v1",
|
|
132
|
+
output: "digest",
|
|
133
|
+
fields: [
|
|
134
|
+
{ name: "sender", kind: "string", derivation: "direct" },
|
|
135
|
+
{ name: "keyType", kind: "string", derivation: "direct" },
|
|
136
|
+
{ name: "keyLabel", kind: "string", derivation: "direct" },
|
|
137
|
+
{ name: "recipient", kind: "string", derivation: "direct" },
|
|
138
|
+
{ name: "channel", kind: "string", derivation: "direct" },
|
|
139
|
+
{ name: "timestamp", kind: "int64", derivation: "direct" },
|
|
140
|
+
{ name: "nonce", kind: "bytes", derivation: "direct" },
|
|
141
|
+
{ name: "payload", kind: "fixed(32)", derivation: "sha256Of" },
|
|
142
|
+
],
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
name: "pop-create-identity",
|
|
146
|
+
tag: "ce.evolver/148/pop-create-identity/v1",
|
|
147
|
+
output: "digest",
|
|
148
|
+
fields: [
|
|
149
|
+
{ name: "nodeId", kind: "string", derivation: "direct" },
|
|
150
|
+
{ name: "initialCredit", kind: "int64", derivation: "direct" },
|
|
151
|
+
{ name: "keys", kind: "list(string,bytes,string)", elements: [{ name: "keyType", kind: "string" }, { name: "publicKey", kind: "bytes" }, { name: "keyLabel", kind: "string" }], derivation: "direct" },
|
|
152
|
+
],
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: "pop-add-key",
|
|
156
|
+
tag: "ce.evolver/148/pop-add-key/v1",
|
|
157
|
+
output: "digest",
|
|
158
|
+
fields: [
|
|
159
|
+
{ name: "publicKey", kind: "bytes", derivation: "direct" },
|
|
160
|
+
{ name: "keyType", kind: "string", derivation: "direct" },
|
|
161
|
+
{ name: "keyLabel", kind: "string", derivation: "direct" },
|
|
162
|
+
],
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
name: "pop-replace-key",
|
|
166
|
+
tag: "ce.evolver/148/pop-replace-key/v1",
|
|
167
|
+
output: "digest",
|
|
168
|
+
fields: [
|
|
169
|
+
{ name: "publicKey", kind: "bytes", derivation: "direct" },
|
|
170
|
+
{ name: "keyType", kind: "string", derivation: "direct" },
|
|
171
|
+
{ name: "keyLabel", kind: "string", derivation: "direct" },
|
|
172
|
+
],
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
name: "proposal-id-admission",
|
|
176
|
+
tag: "ce.evolver/149/proposal-id-admission/v1",
|
|
177
|
+
output: "digest",
|
|
178
|
+
fields: [
|
|
179
|
+
{ name: "candidateNodeId", kind: "string", derivation: "direct" },
|
|
180
|
+
{ name: "startBlockHeight", kind: "int32", derivation: "direct" },
|
|
181
|
+
{ name: "proposerNodeId", kind: "string", derivation: "direct" },
|
|
182
|
+
{ name: "donatedStake", kind: "int32", derivation: "direct" },
|
|
183
|
+
],
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
name: "proposal-id-removal",
|
|
187
|
+
tag: "ce.evolver/149/proposal-id-removal/v1",
|
|
188
|
+
output: "digest",
|
|
189
|
+
fields: [
|
|
190
|
+
{ name: "targetNodeId", kind: "string", derivation: "direct" },
|
|
191
|
+
{ name: "removalBlockHeight", kind: "int32", derivation: "direct" },
|
|
192
|
+
{ name: "proposerNodeId", kind: "string", derivation: "direct" },
|
|
193
|
+
],
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
name: "block-id",
|
|
197
|
+
tag: "ce.evolver/148/block-id/v1",
|
|
198
|
+
output: "digest",
|
|
199
|
+
fields: [
|
|
200
|
+
{ name: "roundNum", kind: "int32", derivation: "direct" },
|
|
201
|
+
{ name: "parentId", kind: "fixed(32)", derivation: "direct" },
|
|
202
|
+
{ name: "merkleRoot", kind: "fixed(32)", derivation: "direct" },
|
|
203
|
+
{ name: "parentQcSigners", kind: "bytes", derivation: "direct" },
|
|
204
|
+
],
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
name: "list-tx-id",
|
|
208
|
+
tag: "ce.evolver/149/list-tx-id/v1",
|
|
209
|
+
output: "digest",
|
|
210
|
+
fields: [
|
|
211
|
+
{ name: "txIds", kind: "list(fixed(32))", elements: [{ name: "txId", kind: "fixed(32)" }], derivation: "direct" },
|
|
212
|
+
],
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
name: "list-context",
|
|
216
|
+
tag: "ce.evolver/149/list-context/v1",
|
|
217
|
+
output: "digest",
|
|
218
|
+
fields: [
|
|
219
|
+
{ name: "listTxId", kind: "fixed(32)", derivation: "direct" },
|
|
220
|
+
{ name: "txId", kind: "fixed(32)", derivation: "direct" },
|
|
221
|
+
],
|
|
222
|
+
},
|
|
223
|
+
];
|
|
224
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
225
|
+
export const ENCODERS = {
|
|
226
|
+
"auth-body": (row) => authBody(row),
|
|
227
|
+
"auths-digest": (row) => authsDigest(row),
|
|
228
|
+
"vote": (row) => vote(row),
|
|
229
|
+
"new-view": (row) => newView(row),
|
|
230
|
+
"p2p-signable": (row) => p2pSignable(row),
|
|
231
|
+
"pop-create-identity": (row) => popCreateIdentity(row),
|
|
232
|
+
"pop-add-key": (row) => popAddKey(row),
|
|
233
|
+
"pop-replace-key": (row) => popReplaceKey(row),
|
|
234
|
+
"proposal-id-admission": (row) => proposalIdAdmission(row),
|
|
235
|
+
"proposal-id-removal": (row) => proposalIdRemoval(row),
|
|
236
|
+
"block-id": (row) => blockId(row),
|
|
237
|
+
"list-tx-id": (row) => listTxId(row),
|
|
238
|
+
"list-context": (row) => listContext(row),
|
|
239
|
+
};
|
|
240
|
+
//# sourceMappingURL=codecs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codecs.js","sourceRoot":"","sources":["../../src/generated/codecs.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,EAAE;AACF,wFAAwF;AACxF,sFAAsF;AACtF,yFAAyF;AACzF,wCAAwC;AACxC,EAAE;AACF,2FAA2F;AAC3F,2DAA2D;AAC3D,4FAA4F;AAC5F,EAAE;AACF,qFAAqF;AACrF,sFAAsF;AACtF,uFAAuF;AACvF,wFAAwF;AACxF,0FAA0F;AAC1F,uDAAuD;AAEvD,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACzG,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAqB3C,SAAS,SAAS,CAAC,CAAa;IAC9B,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;QACf,KAAK,UAAU,CAAC,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACxC,KAAK,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC;QAChC,KAAK,OAAO,CAAC,CAAI,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AAC;IAClD,cAAc,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,WAAW,CAAC,GAAwB,CAAC;IAC9D,qBAAqB,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,iBAAiB,CAAC,GAA8B,CAAC;IACjF,aAAa,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,CAAC,GAAsB,CAAC;IACzD,iBAAiB,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,aAAa,CAAC,GAA0B,CAAC;IACrE,uBAAuB,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,mBAAmB,CAAC,GAAgC,CAAC;IACvF,qBAAqB,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,iBAAiB,CAAC,GAA8B,CAAC;IACjF,UAAU,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,GAAoB,CAAC;IAClD,YAAY,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAqB,CAAC;IACtD,cAAc,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,WAAW,CAAC,GAAwB,CAAC;CAC/D,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type BlsKeypair, type EdKeypair } from "./crypto/auth.js";
|
|
2
|
+
export interface Identity {
|
|
3
|
+
nodeId: string;
|
|
4
|
+
bls: BlsKeypair;
|
|
5
|
+
ed: EdKeypair;
|
|
6
|
+
}
|
|
7
|
+
export declare function newIdentity(nodeId: string): Identity;
|
|
8
|
+
/** Sponsored initial credit of a faucet claim — MUST mirror the node's
|
|
9
|
+
* IdentityApiHandler (5000): it is part of the PoP digest recomputed locally. */
|
|
10
|
+
export declare const FAUCET_SPONSORED_CREDIT = 5000;
|
|
11
|
+
/** PoP digest of the faucet-sponsored CreateIdentity for `id` — the exact bytes the
|
|
12
|
+
* node's /api/identity/prepare returns as tx_hash_hex. Recomputing it locally lets
|
|
13
|
+
* the claimer refuse to PoP-sign server-chosen bytes. */
|
|
14
|
+
export declare function faucetClaimDigest(id: Identity): Uint8Array;
|
|
15
|
+
/** CreateIdentity tx_body for `id`, with PoP signed by `id`'s own keys. */
|
|
16
|
+
export declare function createIdentityBodyFor(id: Identity, initialCredit: number | bigint): Uint8Array;
|
|
17
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAUA,OAAO,EAA+C,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGhH,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,UAAU,CAAC;IAChB,EAAE,EAAE,SAAS,CAAC;CACf;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,CAEpD;AAED;kFACkF;AAClF,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAE5C;;0DAE0D;AAC1D,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,QAAQ,GAAG,UAAU,CAa1D;AAED,2EAA2E;AAC3E,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,CAgB9F"}
|
package/dist/identity.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Identity creation: fresh identities with on-chain auth keys + proof-of-possession.
|
|
2
|
+
//
|
|
3
|
+
// Each identity gets two mandatory auth keys (BLS12-381-G1 + Ed25519, both empty
|
|
4
|
+
// label). PoP: every new key signs the SAME message — the `pop-create-identity` digest, whose
|
|
5
|
+
// description deliberately excludes `pop_signature` so no key's proof is inside the thing the
|
|
6
|
+
// others are proving. (It was "SHA-256 of the serialized body" until 148; this header said so
|
|
7
|
+
// until 149.)
|
|
8
|
+
import { createIdentityInner, createIdentityBody } from "./bodies.js";
|
|
9
|
+
import { popCreateIdentity } from "./generated/codecs.js";
|
|
10
|
+
import { genBls, genEd, blsSign, edSign, edPubToSpki } from "./crypto/auth.js";
|
|
11
|
+
export function newIdentity(nodeId) {
|
|
12
|
+
return { nodeId, bls: genBls(), ed: genEd() };
|
|
13
|
+
}
|
|
14
|
+
/** Sponsored initial credit of a faucet claim — MUST mirror the node's
|
|
15
|
+
* IdentityApiHandler (5000): it is part of the PoP digest recomputed locally. */
|
|
16
|
+
export const FAUCET_SPONSORED_CREDIT = 5000;
|
|
17
|
+
/** PoP digest of the faucet-sponsored CreateIdentity for `id` — the exact bytes the
|
|
18
|
+
* node's /api/identity/prepare returns as tx_hash_hex. Recomputing it locally lets
|
|
19
|
+
* the claimer refuse to PoP-sign server-chosen bytes. */
|
|
20
|
+
export function faucetClaimDigest(id) {
|
|
21
|
+
const keysNoPoP = [
|
|
22
|
+
{ keyType: "BLS12-381-G1", publicKey: id.bls.pub, keyLabel: "" },
|
|
23
|
+
{ keyType: "Ed25519", publicKey: edPubToSpki(id.ed.pub), keyLabel: "" },
|
|
24
|
+
];
|
|
25
|
+
// 148 — canonical PoP encoding, matching the node. This value is recomputed locally and
|
|
26
|
+
// compared against the server's tx_hash before signing, so a mismatch REFUSES rather than
|
|
27
|
+
// signs bytes we cannot reproduce.
|
|
28
|
+
return popCreateIdentity({
|
|
29
|
+
nodeId: id.nodeId,
|
|
30
|
+
initialCredit: BigInt(FAUCET_SPONSORED_CREDIT),
|
|
31
|
+
keys: keysNoPoP,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/** CreateIdentity tx_body for `id`, with PoP signed by `id`'s own keys. */
|
|
35
|
+
export function createIdentityBodyFor(id, initialCredit) {
|
|
36
|
+
const keysNoPoP = [
|
|
37
|
+
{ keyType: "BLS12-381-G1", publicKey: id.bls.pub, keyLabel: "" }, // raw 48-byte G1
|
|
38
|
+
{ keyType: "Ed25519", publicKey: edPubToSpki(id.ed.pub), keyLabel: "" }, // X.509 SPKI
|
|
39
|
+
];
|
|
40
|
+
// Every new key signs this ONE message; no pop_signature is inside it.
|
|
41
|
+
const popHash = popCreateIdentity({
|
|
42
|
+
nodeId: id.nodeId,
|
|
43
|
+
initialCredit: BigInt(initialCredit),
|
|
44
|
+
keys: keysNoPoP,
|
|
45
|
+
});
|
|
46
|
+
const keysWithPoP = [
|
|
47
|
+
{ ...keysNoPoP[0], popSig: blsSign(popHash, id.bls.priv) }, // 96-byte G2
|
|
48
|
+
{ ...keysNoPoP[1], popSig: edSign(popHash, id.ed.priv) }, // 64-byte ed25519
|
|
49
|
+
];
|
|
50
|
+
return createIdentityBody(createIdentityInner(id.nodeId, initialCredit, keysWithPoP, true));
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,EAAE;AACF,iFAAiF;AACjF,8FAA8F;AAC9F,8FAA8F;AAC9F,8FAA8F;AAC9F,cAAc;AAEd,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAmC,MAAM,kBAAkB,CAAC;AAShH,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC;AAChD,CAAC;AAED;kFACkF;AAClF,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAE5C;;0DAE0D;AAC1D,MAAM,UAAU,iBAAiB,CAAC,EAAY;IAC5C,MAAM,SAAS,GAAe;QAC5B,EAAE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,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AkB,CAAC,mBAAmB,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC;AAC9F,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from "./types.js";
|
|
2
|
+
export * from "./wire.js";
|
|
3
|
+
export * from "./crypto/hash.js";
|
|
4
|
+
export * from "./crypto/auth.js";
|
|
5
|
+
export * from "./crypto/group.js";
|
|
6
|
+
export * from "./crypto/stream.js";
|
|
7
|
+
export * from "./generated/codecs.js";
|
|
8
|
+
export * from "./envelope.js";
|
|
9
|
+
export * from "./bodies.js";
|
|
10
|
+
export * from "./identity.js";
|
|
11
|
+
export * from "./signers.js";
|
|
12
|
+
export * from "./api.js";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AAInC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// @mcsherrylabs/evolver-client — isomorphic client SDK for an Evolver node.
|
|
2
|
+
export * from "./types.js";
|
|
3
|
+
export * from "./wire.js";
|
|
4
|
+
export * from "./crypto/hash.js";
|
|
5
|
+
export * from "./crypto/auth.js";
|
|
6
|
+
export * from "./crypto/group.js";
|
|
7
|
+
export * from "./crypto/stream.js";
|
|
8
|
+
// 149 — the generated encoders: one per described message, emitted from the node's own
|
|
9
|
+
// descriptions. Exported before ./envelope and ./bodies because those two now COMPOSE these
|
|
10
|
+
// rather than restating them.
|
|
11
|
+
export * from "./generated/codecs.js";
|
|
12
|
+
export * from "./envelope.js";
|
|
13
|
+
export * from "./bodies.js";
|
|
14
|
+
export * from "./identity.js";
|
|
15
|
+
export * from "./signers.js";
|
|
16
|
+
export * from "./api.js";
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAE5E,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,uFAAuF;AACvF,4FAA4F;AAC5F,8BAA8B;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type P2pSignableFields } from "./generated/codecs.js";
|
|
2
|
+
import type { Signer } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* The default BLS auth key ("BLS12-381-G1", ""). `nodeId` "" means the auth
|
|
5
|
+
* resolves to the tx sender; pass an explicit nodeId for a co-signer.
|
|
6
|
+
*/
|
|
7
|
+
export declare function blsDefaultSigner(blsPriv: Uint8Array, nodeId?: string): Signer;
|
|
8
|
+
/**
|
|
9
|
+
* 147 — the default Ed25519 auth key (`"Ed25519"`, `""`), closing over the private half so
|
|
10
|
+
* no caller holds it.
|
|
11
|
+
*
|
|
12
|
+
* Why Ed25519 and not BLS for the peer-to-peer path: verification is cheaper, there is
|
|
13
|
+
* nothing to aggregate in a point-to-point message, and it keeps the consensus BLS key off
|
|
14
|
+
* an application surface entirely. It is also the key an identity's `create-identity`
|
|
15
|
+
* already registers on-chain, so a user's p2p messages are attributable with no extra
|
|
16
|
+
* enrolment.
|
|
17
|
+
*/
|
|
18
|
+
export declare function edDefaultSigner(edPriv: Uint8Array, nodeId?: string): Signer;
|
|
19
|
+
/** The fields a peer-to-peer signature covers. One object, so the digest and the body it
|
|
20
|
+
* travels in can never disagree about what was signed. */
|
|
21
|
+
export type P2PMessageFields = P2pSignableFields;
|
|
22
|
+
/** Exactly what the node's relay route (`POST /api/p2p/send`) reads: flat, all strings. */
|
|
23
|
+
export interface P2PRelayBody extends Record<string, string> {
|
|
24
|
+
sender: string;
|
|
25
|
+
keyType: string;
|
|
26
|
+
keyLabel: string;
|
|
27
|
+
recipient: string;
|
|
28
|
+
channel: string;
|
|
29
|
+
timestamp: string;
|
|
30
|
+
nonce: string;
|
|
31
|
+
payload: string;
|
|
32
|
+
signature: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* 147 — build the relay body for one peer-to-peer message: compute the material with the
|
|
36
|
+
* GENERATED encoder, sign it through the handle, and lay the fields out the way the node
|
|
37
|
+
* parses them.
|
|
38
|
+
*
|
|
39
|
+
* ⚠️ This function contains **no byte encoding of its own**, and must not gain any. The
|
|
40
|
+
* digest comes from `p2pSignable()` in `generated/codecs.ts`, emitted from the node's own
|
|
41
|
+
* description of this message — so "byte-identical to the node" is structural rather than
|
|
42
|
+
* something asserted after the fact. A hand-rolled second encoder here is exactly the
|
|
43
|
+
* failure 149 exists to prevent (the TypeScript half of PoP drifted from the Scala half for
|
|
44
|
+
* a whole release while `npm test` stayed green), and the discipline gate refuses it:
|
|
45
|
+
* *no hand-written encoder shadows a generated one*.
|
|
46
|
+
*
|
|
47
|
+
* `timestamp` crosses as a DECIMAL STRING and is held as `bigint` (Constitution VIII):
|
|
48
|
+
* epoch millis is a large integer, and a float round-trip would corrupt the one field whose
|
|
49
|
+
* corruption is invisible until the far end silently refuses the signature.
|
|
50
|
+
*/
|
|
51
|
+
export declare function p2pRelayBody(signer: Signer, fields: P2PMessageFields): P2PRelayBody;
|
|
52
|
+
//# sourceMappingURL=signers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signers.d.ts","sourceRoot":"","sources":["../src/signers.ts"],"names":[],"mappings":"AAIA,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAK,GAAG,MAAM,CAOzE;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,SAAK,GAAG,MAAM,CAOvE;AAED;2DAC2D;AAC3D,MAAM,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAEjD,2FAA2F;AAC3F,MAAM,WAAW,YAAa,SAAQ,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAC1D,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAClD,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IACnC,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;CACtE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,GAAG,YAAY,CAanF"}
|
package/dist/signers.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// Signer constructors. A Signer turns the 32-byte signing digest into one TxAuth.
|
|
2
|
+
import { blsSign, edSign } from "./crypto/auth.js";
|
|
3
|
+
import { bytesToHex } from "./crypto/hash.js";
|
|
4
|
+
import { p2pSignable } from "./generated/codecs.js";
|
|
5
|
+
/**
|
|
6
|
+
* The default BLS auth key ("BLS12-381-G1", ""). `nodeId` "" means the auth
|
|
7
|
+
* resolves to the tx sender; pass an explicit nodeId for a co-signer.
|
|
8
|
+
*/
|
|
9
|
+
export function blsDefaultSigner(blsPriv, nodeId = "") {
|
|
10
|
+
return {
|
|
11
|
+
keyType: "BLS12-381-G1",
|
|
12
|
+
keyLabel: "",
|
|
13
|
+
nodeId,
|
|
14
|
+
sign: (digest) => blsSign(digest, blsPriv),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 147 — the default Ed25519 auth key (`"Ed25519"`, `""`), closing over the private half so
|
|
19
|
+
* no caller holds it.
|
|
20
|
+
*
|
|
21
|
+
* Why Ed25519 and not BLS for the peer-to-peer path: verification is cheaper, there is
|
|
22
|
+
* nothing to aggregate in a point-to-point message, and it keeps the consensus BLS key off
|
|
23
|
+
* an application surface entirely. It is also the key an identity's `create-identity`
|
|
24
|
+
* already registers on-chain, so a user's p2p messages are attributable with no extra
|
|
25
|
+
* enrolment.
|
|
26
|
+
*/
|
|
27
|
+
export function edDefaultSigner(edPriv, nodeId = "") {
|
|
28
|
+
return {
|
|
29
|
+
keyType: "Ed25519",
|
|
30
|
+
keyLabel: "",
|
|
31
|
+
nodeId,
|
|
32
|
+
sign: (digest) => edSign(digest, edPriv),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 147 — build the relay body for one peer-to-peer message: compute the material with the
|
|
37
|
+
* GENERATED encoder, sign it through the handle, and lay the fields out the way the node
|
|
38
|
+
* parses them.
|
|
39
|
+
*
|
|
40
|
+
* ⚠️ This function contains **no byte encoding of its own**, and must not gain any. The
|
|
41
|
+
* digest comes from `p2pSignable()` in `generated/codecs.ts`, emitted from the node's own
|
|
42
|
+
* description of this message — so "byte-identical to the node" is structural rather than
|
|
43
|
+
* something asserted after the fact. A hand-rolled second encoder here is exactly the
|
|
44
|
+
* failure 149 exists to prevent (the TypeScript half of PoP drifted from the Scala half for
|
|
45
|
+
* a whole release while `npm test` stayed green), and the discipline gate refuses it:
|
|
46
|
+
* *no hand-written encoder shadows a generated one*.
|
|
47
|
+
*
|
|
48
|
+
* `timestamp` crosses as a DECIMAL STRING and is held as `bigint` (Constitution VIII):
|
|
49
|
+
* epoch millis is a large integer, and a float round-trip would corrupt the one field whose
|
|
50
|
+
* corruption is invisible until the far end silently refuses the signature.
|
|
51
|
+
*/
|
|
52
|
+
export function p2pRelayBody(signer, fields) {
|
|
53
|
+
const signature = signer.sign(p2pSignable(fields));
|
|
54
|
+
return {
|
|
55
|
+
sender: fields.sender,
|
|
56
|
+
keyType: fields.keyType,
|
|
57
|
+
keyLabel: fields.keyLabel,
|
|
58
|
+
recipient: fields.recipient,
|
|
59
|
+
channel: fields.channel,
|
|
60
|
+
timestamp: fields.timestamp.toString(10),
|
|
61
|
+
nonce: bytesToHex(fields.nonce),
|
|
62
|
+
payload: bytesToBase64(fields.payload),
|
|
63
|
+
signature: bytesToHex(signature),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/** `btoa`, not `Buffer` — this package is isomorphic and `api.ts` already decodes with
|
|
67
|
+
* `atob` for the same reason. A `Buffer` here would work in every test and fail in a
|
|
68
|
+
* browser, which is the worst available outcome. */
|
|
69
|
+
function bytesToBase64(bytes) {
|
|
70
|
+
let bin = "";
|
|
71
|
+
for (let i = 0; i < bytes.length; i++)
|
|
72
|
+
bin += String.fromCharCode(bytes[i]);
|
|
73
|
+
return btoa(bin);
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=signers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signers.js","sourceRoot":"","sources":["../src/signers.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAElF,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB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AAED;;qDAEqD;AACrD,SAAS,aAAa,CAAC,KAAiB;IACtC,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE;QAAE,GAAG,IAAI,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5E,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AACnB,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/** A key that signs the 32-byte tx signing digest, producing one TxAuth. */
|
|
2
|
+
export interface Signer {
|
|
3
|
+
keyType: string;
|
|
4
|
+
keyLabel: string;
|
|
5
|
+
/** "" ⇒ resolves to sender_node_id; set ⇒ a co-signer identity. */
|
|
6
|
+
nodeId: string;
|
|
7
|
+
sign(digest: Uint8Array): Uint8Array;
|
|
8
|
+
}
|
|
9
|
+
/** A produced TxAuth entry (TxAuth: 1 key_type | 2 key_label | 3 signature | 4 node_id). */
|
|
10
|
+
export interface Auth {
|
|
11
|
+
keyType: string;
|
|
12
|
+
keyLabel: string;
|
|
13
|
+
signature: Uint8Array;
|
|
14
|
+
nodeId: string;
|
|
15
|
+
}
|
|
16
|
+
/** One key in a CreateIdentityTxBody (KeyEntryWithPoP). */
|
|
17
|
+
export interface KeyEntry {
|
|
18
|
+
keyType: string;
|
|
19
|
+
publicKey: Uint8Array;
|
|
20
|
+
keyLabel: string;
|
|
21
|
+
popSig?: Uint8Array;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Every machine-readable refusal code a node can put in a submit response, in ONE
|
|
25
|
+
* declaration — the runtime list and the type are the same statement, so they cannot
|
|
26
|
+
* drift apart (the type is derived from the array, not written beside it).
|
|
27
|
+
*
|
|
28
|
+
* The authority is the node: `SubmitResponder.mapRejection` maps each
|
|
29
|
+
* `SubmitRejectReason` to one of these strings, and `ChannelSubmitDaHandler` adds
|
|
30
|
+
* `da_unavailable`. `src/dev/transfer-checks.ts` reads that Scala file and fails if it
|
|
31
|
+
* emits a code this list does not carry.
|
|
32
|
+
*
|
|
33
|
+
* ⚠️ Before 154 this list held SIX of them, so `insufficient_balance`,
|
|
34
|
+
* `invalid_identity_body`, `duplicate`, `ttl_expired`, `unknown_key` and the rest were
|
|
35
|
+
* all reported to callers as `internal` — found by driving a real refusal on a rig,
|
|
36
|
+
* where a 400 `invalid_identity_body` arrived as `{"reason":"internal"}`.
|
|
37
|
+
*/
|
|
38
|
+
export declare const FAILURE_REASONS: readonly ["malformed_signed_tx", "unknown_ledger_id", "node_not_ready", "queue_full", "duplicate", "invalid_signature", "insufficient_balance", "invalid_identity_body", "invalid_group_body", "invalid_owners_body", "invalid_list_body", "rejected", "confirmation_timeout", "ttl_expired", "ttl_too_far", "unknown_key", "unauthorized", "toll_ceiling_too_low", "insufficient_da", "too_many_auths", "da_unavailable", "internal"];
|
|
39
|
+
export type FailureReason = (typeof FAILURE_REASONS)[number];
|
|
40
|
+
export interface Committed {
|
|
41
|
+
kind: "committed";
|
|
42
|
+
txIdHex: string;
|
|
43
|
+
}
|
|
44
|
+
export interface Failed {
|
|
45
|
+
kind: "failed";
|
|
46
|
+
reason: FailureReason;
|
|
47
|
+
message: string;
|
|
48
|
+
}
|
|
49
|
+
export interface Timeout {
|
|
50
|
+
kind: "timeout";
|
|
51
|
+
txIdHex: string;
|
|
52
|
+
}
|
|
53
|
+
export type SubmitResult = Committed | Failed | Timeout;
|
|
54
|
+
export interface NodeKey {
|
|
55
|
+
nodeId: string;
|
|
56
|
+
keyType: string;
|
|
57
|
+
label: string;
|
|
58
|
+
publicKeyHex: string;
|
|
59
|
+
}
|
|
60
|
+
export interface PullResp {
|
|
61
|
+
httpStatus: number;
|
|
62
|
+
status: string;
|
|
63
|
+
round?: string;
|
|
64
|
+
index?: string;
|
|
65
|
+
txId?: string;
|
|
66
|
+
ledgerId?: string;
|
|
67
|
+
sender?: string;
|
|
68
|
+
ttlRound?: string;
|
|
69
|
+
body?: string;
|
|
70
|
+
tip?: string;
|
|
71
|
+
message?: string;
|
|
72
|
+
}
|
|
73
|
+
export interface Delivery {
|
|
74
|
+
round: number;
|
|
75
|
+
index: number;
|
|
76
|
+
txId: string;
|
|
77
|
+
ledgerId: string;
|
|
78
|
+
sender: string;
|
|
79
|
+
body: Uint8Array;
|
|
80
|
+
}
|
|
81
|
+
export interface WrappedKey {
|
|
82
|
+
ephPub: Uint8Array;
|
|
83
|
+
blob: Uint8Array;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* A handle that recovers a group key from a wrap addressed to ONE member — peer to
|
|
87
|
+
* [[Signer]], for key agreement instead of signature.
|
|
88
|
+
*
|
|
89
|
+
* It exists for the same reason Signer does: the private half stays inside the
|
|
90
|
+
* implementation. Callers pass wraps in and get group keys out, and never see a scalar.
|
|
91
|
+
* It is not a Signer because it produces no signature; the operation is ECDH.
|
|
92
|
+
*
|
|
93
|
+
* Build one with `edGroupKeyUnwrapper` (an Ed25519 identity key, what every member uses
|
|
94
|
+
* today) or `x25519GroupKeyUnwrapper` (a native X25519 key). A future remote/phone-held
|
|
95
|
+
* implementation slots in here — see issue #53, and note that today's mobile signer
|
|
96
|
+
* offers signing but no ECDH, so that is a service-side change, not just a new class.
|
|
97
|
+
*/
|
|
98
|
+
export interface GroupKeyUnwrapper {
|
|
99
|
+
/** Diagnostic: which key this unwraps with, and how it was obtained. */
|
|
100
|
+
keyType: string;
|
|
101
|
+
unwrap(w: WrappedKey): Promise<Uint8Array>;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,4EAA4E;AAC5E,MAAM,WAAW,MAAM;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,mEA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