@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
package/dist/types.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Shared types for the Evolver client SDK.
|
|
2
|
+
// ── Submit results (POST /api/tx/submit) ─────────────────────────────────────
|
|
3
|
+
/**
|
|
4
|
+
* Every machine-readable refusal code a node can put in a submit response, in ONE
|
|
5
|
+
* declaration — the runtime list and the type are the same statement, so they cannot
|
|
6
|
+
* drift apart (the type is derived from the array, not written beside it).
|
|
7
|
+
*
|
|
8
|
+
* The authority is the node: `SubmitResponder.mapRejection` maps each
|
|
9
|
+
* `SubmitRejectReason` to one of these strings, and `ChannelSubmitDaHandler` adds
|
|
10
|
+
* `da_unavailable`. `src/dev/transfer-checks.ts` reads that Scala file and fails if it
|
|
11
|
+
* emits a code this list does not carry.
|
|
12
|
+
*
|
|
13
|
+
* ⚠️ Before 154 this list held SIX of them, so `insufficient_balance`,
|
|
14
|
+
* `invalid_identity_body`, `duplicate`, `ttl_expired`, `unknown_key` and the rest were
|
|
15
|
+
* all reported to callers as `internal` — found by driving a real refusal on a rig,
|
|
16
|
+
* where a 400 `invalid_identity_body` arrived as `{"reason":"internal"}`.
|
|
17
|
+
*/
|
|
18
|
+
export const FAILURE_REASONS = [
|
|
19
|
+
"malformed_signed_tx",
|
|
20
|
+
"unknown_ledger_id",
|
|
21
|
+
"node_not_ready",
|
|
22
|
+
"queue_full",
|
|
23
|
+
"duplicate",
|
|
24
|
+
"invalid_signature",
|
|
25
|
+
"insufficient_balance",
|
|
26
|
+
"invalid_identity_body",
|
|
27
|
+
"invalid_group_body",
|
|
28
|
+
"invalid_owners_body",
|
|
29
|
+
"invalid_list_body",
|
|
30
|
+
"rejected",
|
|
31
|
+
"confirmation_timeout",
|
|
32
|
+
"ttl_expired",
|
|
33
|
+
"ttl_too_far",
|
|
34
|
+
"unknown_key",
|
|
35
|
+
"unauthorized",
|
|
36
|
+
"toll_ceiling_too_low", // 153 — the channel's committed toll exceeds the sender's signed max_toll
|
|
37
|
+
"insufficient_da",
|
|
38
|
+
"too_many_auths",
|
|
39
|
+
"da_unavailable",
|
|
40
|
+
// client-side only: the node never sends this. Set when the response could not be
|
|
41
|
+
// read at all (transport failure, unparseable JSON, unrecognised shape).
|
|
42
|
+
"internal",
|
|
43
|
+
];
|
|
44
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,2CAA2C;AA2B3C,gFAAgF;AAEhF;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,qBAAqB;IACrB,mBAAmB;IACnB,gBAAgB;IAChB,YAAY;IACZ,WAAW;IACX,mBAAmB;IACnB,sBAAsB;IACtB,uBAAuB;IACvB,oBAAoB;IACpB,qBAAqB;IACrB,mBAAmB;IACnB,UAAU;IACV,sBAAsB;IACtB,aAAa;IACb,aAAa;IACb,aAAa;IACb,cAAc;IACd,sBAAsB,EAAG,0EAA0E;IACnG,iBAAiB;IACjB,gBAAgB;IAChB,gBAAgB;IAChB,kFAAkF;IAClF,yEAAyE;IACzE,UAAU;CACF,CAAC"}
|
package/dist/wire.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** length-delimited string; omitted when empty (proto3 default). */
|
|
2
|
+
export declare function fString(field: number, s: string): number[];
|
|
3
|
+
/** length-delimited bytes; omitted when empty (proto3 default). */
|
|
4
|
+
export declare function fBytes(field: number, b: Uint8Array): number[];
|
|
5
|
+
/** an explicitly-present sub-message (always emitted, even if inner is empty). */
|
|
6
|
+
export declare function fMessage(field: number, inner: Uint8Array): number[];
|
|
7
|
+
/** non-negative varint scalar (uint64/int64); omitted when 0 (proto3 default). */
|
|
8
|
+
export declare function fVarint(field: number, n: number | bigint): number[];
|
|
9
|
+
/** bool; omitted when false (proto3 default). */
|
|
10
|
+
export declare function fBool(field: number, v: boolean): number[];
|
|
11
|
+
/** Concatenate partial encodings into the final byte string. */
|
|
12
|
+
export declare function concat(...parts: number[][]): Uint8Array;
|
|
13
|
+
//# sourceMappingURL=wire.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../src/wire.ts"],"names":[],"mappings":"AA8BA,oEAAoE;AACpE,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAI1D;AAED,mEAAmE;AACnE,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,GAAG,MAAM,EAAE,CAG7D;AAED,kFAAkF;AAClF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,EAAE,CAEnE;AAED,kFAAkF;AAClF,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAGnE;AAED,iDAAiD;AACjD,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAGzD;AAED,gEAAgE;AAChE,wBAAgB,MAAM,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,EAAE,GAAG,UAAU,CAUvD"}
|
package/dist/wire.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// proto3 wire-format primitives.
|
|
2
|
+
//
|
|
3
|
+
// proto3 semantics: default-valued scalar fields (0 / "" / empty bytes / false)
|
|
4
|
+
// are OMITTED on the wire. This matters for the proof-of-possession recipe (a
|
|
5
|
+
// body re-encoded with pop_signature omitted) and for byte-exact digests.
|
|
6
|
+
//
|
|
7
|
+
// Encode only — the client never parses proto; the server does that. Field
|
|
8
|
+
// numbers mirror src/main/protobuf/evolver/**; this codec is the single place
|
|
9
|
+
// the wire contract is reproduced.
|
|
10
|
+
const WIRE_VARINT = 0;
|
|
11
|
+
const WIRE_LEN = 2;
|
|
12
|
+
function varint(n) {
|
|
13
|
+
let v = typeof n === "bigint" ? n : BigInt(n);
|
|
14
|
+
if (v < 0n)
|
|
15
|
+
throw new Error("varint: negative value");
|
|
16
|
+
const out = [];
|
|
17
|
+
do {
|
|
18
|
+
let b = Number(v & 0x7fn);
|
|
19
|
+
v >>= 7n;
|
|
20
|
+
if (v > 0n)
|
|
21
|
+
b |= 0x80;
|
|
22
|
+
out.push(b);
|
|
23
|
+
} while (v > 0n);
|
|
24
|
+
return out;
|
|
25
|
+
}
|
|
26
|
+
function tag(field, wire) {
|
|
27
|
+
return varint((field << 3) | wire);
|
|
28
|
+
}
|
|
29
|
+
/** length-delimited string; omitted when empty (proto3 default). */
|
|
30
|
+
export function fString(field, s) {
|
|
31
|
+
if (s.length === 0)
|
|
32
|
+
return [];
|
|
33
|
+
const bytes = new TextEncoder().encode(s);
|
|
34
|
+
return [...tag(field, WIRE_LEN), ...varint(bytes.length), ...bytes];
|
|
35
|
+
}
|
|
36
|
+
/** length-delimited bytes; omitted when empty (proto3 default). */
|
|
37
|
+
export function fBytes(field, b) {
|
|
38
|
+
if (b.length === 0)
|
|
39
|
+
return [];
|
|
40
|
+
return [...tag(field, WIRE_LEN), ...varint(b.length), ...Array.from(b)];
|
|
41
|
+
}
|
|
42
|
+
/** an explicitly-present sub-message (always emitted, even if inner is empty). */
|
|
43
|
+
export function fMessage(field, inner) {
|
|
44
|
+
return [...tag(field, WIRE_LEN), ...varint(inner.length), ...Array.from(inner)];
|
|
45
|
+
}
|
|
46
|
+
/** non-negative varint scalar (uint64/int64); omitted when 0 (proto3 default). */
|
|
47
|
+
export function fVarint(field, n) {
|
|
48
|
+
if ((typeof n === "bigint" ? n : BigInt(n)) === 0n)
|
|
49
|
+
return [];
|
|
50
|
+
return [...tag(field, WIRE_VARINT), ...varint(n)];
|
|
51
|
+
}
|
|
52
|
+
/** bool; omitted when false (proto3 default). */
|
|
53
|
+
export function fBool(field, v) {
|
|
54
|
+
if (!v)
|
|
55
|
+
return [];
|
|
56
|
+
return [...tag(field, WIRE_VARINT), 1];
|
|
57
|
+
}
|
|
58
|
+
/** Concatenate partial encodings into the final byte string. */
|
|
59
|
+
export function concat(...parts) {
|
|
60
|
+
let len = 0;
|
|
61
|
+
for (const p of parts)
|
|
62
|
+
len += p.length;
|
|
63
|
+
const out = new Uint8Array(len);
|
|
64
|
+
let i = 0;
|
|
65
|
+
for (const p of parts) {
|
|
66
|
+
out.set(p, i);
|
|
67
|
+
i += p.length;
|
|
68
|
+
}
|
|
69
|
+
return out;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=wire.js.map
|
package/dist/wire.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wire.js","sourceRoot":"","sources":["../src/wire.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,EAAE;AACF,gFAAgF;AAChF,8EAA8E;AAC9E,0EAA0E;AAC1E,EAAE;AACF,2EAA2E;AAC3E,8EAA8E;AAC9E,mCAAmC;AAEnC,MAAM,WAAW,GAAG,CAAC,CAAC;AACtB,MAAM,QAAQ,GAAG,CAAC,CAAC;AAEnB,SAAS,MAAM,CAAC,CAAkB;IAChC,IAAI,CAAC,GAAG,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC9C,IAAI,CAAC,GAAG,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC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rylabs/evolver-client",
|
|
3
|
+
"version": "0.8.0",
|
|
4
|
+
"description": "Client SDK for an Evolver node: proto3 wire codec, transaction signing (AuthBodySignable), on-chain + group crypto, and the node HTTP API.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"default": "./dist/index.js"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc -p tsconfig.build.json",
|
|
14
|
+
"clean": "rm -rf dist",
|
|
15
|
+
"prepare": "npm run build",
|
|
16
|
+
"typecheck": "tsc --noEmit"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@noble/curves": "1.9.7",
|
|
20
|
+
"@noble/hashes": "1.8.0"
|
|
21
|
+
},
|
|
22
|
+
"license": "Apache-2.0",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://gitlab.com/openstar/evolver.git",
|
|
26
|
+
"directory": "npm-libs/client"
|
|
27
|
+
},
|
|
28
|
+
"main": "./dist/index.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"README.md"
|
|
33
|
+
],
|
|
34
|
+
"sideEffects": false,
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=20"
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
}
|
|
41
|
+
}
|