@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/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 2026 McSherry Labs
|
|
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,42 @@
|
|
|
1
|
+
# @mcsherrylabs/evolver-client
|
|
2
|
+
|
|
3
|
+
Isomorphic (browser + Node) client SDK for an Evolver node. The single, shared
|
|
4
|
+
implementation of the off-node wire/crypto/transport layer — consumed by the
|
|
5
|
+
`tools/explorer` browser app and the `examples/group-chat` CLI, replacing the two
|
|
6
|
+
hand-rolled, drifted copies that previously lived in each.
|
|
7
|
+
|
|
8
|
+
## What's in here (and what isn't)
|
|
9
|
+
|
|
10
|
+
This is a **headless SDK** — no UI, no storage, no platform assumptions.
|
|
11
|
+
|
|
12
|
+
- **`wire`** — proto3 encoder primitives (default-omitting, per proto3 canonical).
|
|
13
|
+
- **`bodies`** — tx-body builders for the identity / groups / owners ledgers + opaque channel payloads.
|
|
14
|
+
- **`envelope`** — `SignedTx`/`TxAuth` encoding and the **one** signing recipe
|
|
15
|
+
(`signingDigest` / `buildSignedTx`), byte-identical to the server's
|
|
16
|
+
`AuthBodySignable` (062/085). This is the only place txs are signed.
|
|
17
|
+
- **`identity`** — `CreateIdentity` body with proof-of-possession.
|
|
18
|
+
- **`crypto/auth`** — on-chain BLS12-381-G1 + Ed25519 keys (who *sent* a tx).
|
|
19
|
+
- **`crypto/group`** — app messaging crypto: AES-256-GCM + X25519 ECIES key-wrap
|
|
20
|
+
(who *can read* a message). Async (Web Crypto for AES-GCM).
|
|
21
|
+
- **`api`** — `NodeClient`: `submitTx`, `getIdentity`, `pullChannel`/`drainChannel`.
|
|
22
|
+
Injectable `fetch` + `baseUrl`.
|
|
23
|
+
|
|
24
|
+
Apps keep their own **storage** (IndexedDB in `tools/explorer`, filesystem in the CLI),
|
|
25
|
+
**UI**, and **config** — they inject a `Signer` and call the SDK.
|
|
26
|
+
|
|
27
|
+
## Dependencies
|
|
28
|
+
|
|
29
|
+
Only `@noble/curves` + `@noble/hashes` (pure JS). AES-GCM, HKDF salt RNG, base64
|
|
30
|
+
and HTTP use Web Crypto / `fetch` / `atob`, which exist in both browsers and
|
|
31
|
+
Node 16+. No `node:crypto`, no `Buffer`, no DOM-only or Node-only APIs.
|
|
32
|
+
|
|
33
|
+
## Verify
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm run typecheck -w @mcsherrylabs/evolver-client
|
|
37
|
+
node --import tsx npm-libs/client/test/conformance.ts
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The conformance test asserts the signing digest equals an independent
|
|
41
|
+
reimplementation of `AuthBodySignable.scala` — the durable guard against the
|
|
42
|
+
wire layer drifting from the server again.
|
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import type { SubmitResult, PullResp, Delivery, NodeKey } from "./types.js";
|
|
2
|
+
import { type Identity } from "./identity.js";
|
|
3
|
+
/** Outcome of a faucet identity claim (102). `exists` = already on-chain (idempotent rerun). */
|
|
4
|
+
export type ClaimResult = {
|
|
5
|
+
kind: "committed";
|
|
6
|
+
blockHeight: number;
|
|
7
|
+
} | {
|
|
8
|
+
kind: "exists";
|
|
9
|
+
} | {
|
|
10
|
+
kind: "failed";
|
|
11
|
+
error: string;
|
|
12
|
+
message: string;
|
|
13
|
+
};
|
|
14
|
+
export interface NodeClientOpts {
|
|
15
|
+
baseUrl?: string;
|
|
16
|
+
/** Origin of the node's loopback content endpoint (139); defaults to baseUrl. */
|
|
17
|
+
contentBaseUrl?: string;
|
|
18
|
+
fetch?: typeof fetch;
|
|
19
|
+
}
|
|
20
|
+
export declare class NodeClient {
|
|
21
|
+
private readonly baseUrl;
|
|
22
|
+
private readonly contentBaseUrl;
|
|
23
|
+
private readonly fetchImpl;
|
|
24
|
+
constructor(opts?: NodeClientOpts);
|
|
25
|
+
private url;
|
|
26
|
+
private contentUrl;
|
|
27
|
+
/** POST raw SignedTx protobuf bytes to /api/tx/submit. Never throws. */
|
|
28
|
+
submitTx(signedTx: Uint8Array): Promise<SubmitResult>;
|
|
29
|
+
/**
|
|
30
|
+
* POST a sender-auth-only body-form SignedTx to /api/channel/submit-da (098):
|
|
31
|
+
* the gateway node collects the channel's DA attestations over the overlay,
|
|
32
|
+
* assembles the fully-attested tx, and submits it. Use this for DA-enforced
|
|
33
|
+
* channels — the client does NOT collect attestations or build DA_ATTEST auths
|
|
34
|
+
* itself. Returns the commit outcome (or a `da_unavailable` failure if the DA
|
|
35
|
+
* group couldn't be mustered in time). Safe for non-DA channels too (the
|
|
36
|
+
* gateway submits immediately). Never throws.
|
|
37
|
+
*/
|
|
38
|
+
submitTxWithDa(signedTx: Uint8Array): Promise<SubmitResult>;
|
|
39
|
+
/**
|
|
40
|
+
* Faucet identity claim (102): register `id` on-chain via the node-sponsored
|
|
41
|
+
* POST /api/identity/{prepare,create} — no funded sender and no admin key needed
|
|
42
|
+
* (the node sponsors 5000 credits). The PoP digest is recomputed LOCALLY and the
|
|
43
|
+
* claim aborts on mismatch, so the keys never sign server-chosen bytes. A 200
|
|
44
|
+
* means the sponsored CreateIdentity COMMITTED (the node commit-waits); an
|
|
45
|
+
* already-on-chain identity reports `exists`. Never throws.
|
|
46
|
+
*/
|
|
47
|
+
claimIdentity(id: Identity): Promise<ClaimResult>;
|
|
48
|
+
/** GET /api/identity/:nodeId → { nodeId, balance }, or null if not yet on-chain. */
|
|
49
|
+
getIdentity(nodeId: string): Promise<{
|
|
50
|
+
nodeId: string;
|
|
51
|
+
balance: number;
|
|
52
|
+
} | null>;
|
|
53
|
+
/** Latest committed round (chain tip), via the explorer blocks list (orderDesc). 0 if none. */
|
|
54
|
+
currentRound(): Promise<number>;
|
|
55
|
+
/** Members of a group, from the on-chain group_members (/api/explorer/groups/:g/members). */
|
|
56
|
+
getGroupMembers(group: string): Promise<string[]>;
|
|
57
|
+
/**
|
|
58
|
+
* Principal name search (`/api/explorer/search`) — the read behind a recipient picker.
|
|
59
|
+
*
|
|
60
|
+
* THREE node-side facts shape every caller, and they are the reason this wrapper does not
|
|
61
|
+
* pretend to be more than a transport (all three are issue #64):
|
|
62
|
+
*
|
|
63
|
+
* 1. a query shorter than 2 characters is REFUSED (400 `invalid_query`), so a caller that
|
|
64
|
+
* wants to filter on one keystroke cannot use this route at all;
|
|
65
|
+
* 2. the route applies NO result limit — `node_id LIKE '%q%'` with no LIMIT — so the caller
|
|
66
|
+
* must bound what it keeps, and unescaped wildcards in `q` match aggressively;
|
|
67
|
+
* 3. the rows come back UNORDERED and de-duplicated by `(nodeId, type)` only, so a name that
|
|
68
|
+
* is both an identity and a current committee member arrives TWICE.
|
|
69
|
+
*
|
|
70
|
+
* Returns the rows as given. Ranking, bounding and de-duplication belong to the caller until
|
|
71
|
+
* #64 lands.
|
|
72
|
+
*/
|
|
73
|
+
searchPrincipals(q: string): Promise<Array<{
|
|
74
|
+
type: string;
|
|
75
|
+
nodeId: string;
|
|
76
|
+
summary: string;
|
|
77
|
+
}>>;
|
|
78
|
+
/**
|
|
79
|
+
* Recent committed transactions, newest first, decoded to their core view
|
|
80
|
+
* (`/api/explorer/transactions`).
|
|
81
|
+
*
|
|
82
|
+
* Used to resolve a submit whose outcome is unknown: a transaction id is a digest of the
|
|
83
|
+
* transaction's own fields, so it can be looked up rather than resubmitted. `limit` is capped
|
|
84
|
+
* at 200 by the node, and deep paging is expensive — each request re-walks committed blocks
|
|
85
|
+
* from the tip, decoding payloads, so treat this as a live tail and not a history API.
|
|
86
|
+
*/
|
|
87
|
+
recentTransactions(limit?: number, offset?: number): Promise<Array<{
|
|
88
|
+
txId: string;
|
|
89
|
+
roundNum: number;
|
|
90
|
+
ledgerId: string;
|
|
91
|
+
txType: string;
|
|
92
|
+
sender: string;
|
|
93
|
+
details: Array<{
|
|
94
|
+
label: string;
|
|
95
|
+
value: string;
|
|
96
|
+
}>;
|
|
97
|
+
}>>;
|
|
98
|
+
/** All on-chain identity keys (paginated). Filter by nodeId/keyType/label client-side. */
|
|
99
|
+
getKeys(limit?: number, offset?: number): Promise<NodeKey[]>;
|
|
100
|
+
/** Publish raw bytes to this node's loopback content cache (139): POST /content -> 201 {key,size}. Throws on non-201.
|
|
101
|
+
*
|
|
102
|
+
* `opts.authorizedPrincipals` (142): principal names (identity or group) granted READ
|
|
103
|
+
* on the peer route, sent as `X-Evolver-Authorized-Principal` (comma-joined — the
|
|
104
|
+
* server splits; names can never contain a comma). Each name is resolved at POST
|
|
105
|
+
* time: unknown ⇒ HTTP 400 and nothing is stored. The grant set persists as the
|
|
106
|
+
* `.acl` sidecar on EVERY key of the object (blob, or manifest + all chunks).
|
|
107
|
+
* Omitted or an explicit empty array ⇒ an OPEN publish; a non-empty array whose
|
|
108
|
+
* entries are all blank throws locally (restriction was intended — never publish
|
|
109
|
+
* open by accident). */
|
|
110
|
+
postContent(bytes: Uint8Array, opts?: {
|
|
111
|
+
authorizedPrincipals?: string[];
|
|
112
|
+
}): Promise<{
|
|
113
|
+
key: string;
|
|
114
|
+
size: number;
|
|
115
|
+
}>;
|
|
116
|
+
/** Streaming publish (143): `size` is REQUIRED (it becomes Content-Length, which
|
|
117
|
+
* drives the node's up-front free-disk guard — every real caller knows the
|
|
118
|
+
* plaintext/ciphertext size). Grant semantics are identical to postContent. Throws
|
|
119
|
+
* on non-201 with the server's status + JSON (507 insufficient-storage, 413 too
|
|
120
|
+
* large, 400 unknown-principal).
|
|
121
|
+
*
|
|
122
|
+
* ON NODE the request goes through `node:http`/`node:https`, NOT fetch: undici does
|
|
123
|
+
* not apply backpressure to a ReadableStream request body — it drains the body into
|
|
124
|
+
* memory (measured RSS growth 0.89–0.93× of the body, vs flat via node:http), which
|
|
125
|
+
* FR-006 forbids. Browsers keep the fetch path (they never stream a body to a node). */
|
|
126
|
+
postContentStream(body: ReadableStream<Uint8Array>, opts: {
|
|
127
|
+
size: number;
|
|
128
|
+
authorizedPrincipals?: string[];
|
|
129
|
+
}): Promise<{
|
|
130
|
+
key: string;
|
|
131
|
+
size: number;
|
|
132
|
+
}>;
|
|
133
|
+
private postContentCore;
|
|
134
|
+
private postViaFetch;
|
|
135
|
+
/** Fetch bytes by content-cache key (139): GET /content/{key}. Returns null on 404 (no holder reachable). */
|
|
136
|
+
getContent(key: string): Promise<Uint8Array | null>;
|
|
137
|
+
/** Streaming fetch (143): null on 404; `size` from Content-Length (the node always
|
|
138
|
+
* sets it). CALLER CONTRACT: the transfer is complete iff the stream yields exactly
|
|
139
|
+
* `size` bytes — the node signals a mid-serve failure (e.g. chunk verification) by
|
|
140
|
+
* ABORTING the connection, so a short read errors the stream and ALL output must be
|
|
141
|
+
* discarded. `range` maps to a single HTTP Range (both bounds inclusive). No total
|
|
142
|
+
* deadline is applied: Node's fetch enforces a 300 s INACTIVITY (bodyTimeout) guard
|
|
143
|
+
* between chunks, which is the FR-016 semantic. */
|
|
144
|
+
getContentStream(key: string, opts?: {
|
|
145
|
+
range?: {
|
|
146
|
+
from: number;
|
|
147
|
+
toInclusive: number;
|
|
148
|
+
};
|
|
149
|
+
}): Promise<{
|
|
150
|
+
stream: ReadableStream<Uint8Array>;
|
|
151
|
+
size: number;
|
|
152
|
+
} | null>;
|
|
153
|
+
/** GET /api/channel/next?round&index — one poll of the ordered channel stream. */
|
|
154
|
+
pullChannel(round: number, index: number): Promise<PullResp>;
|
|
155
|
+
/**
|
|
156
|
+
* Drive the channel cursor forward, invoking onDeliver per ordered message.
|
|
157
|
+
* Returns when `max` deliveries seen or after `idleStops` consecutive
|
|
158
|
+
* not-ready / body-pending polls.
|
|
159
|
+
*/
|
|
160
|
+
drainChannel(start: {
|
|
161
|
+
round: number;
|
|
162
|
+
index: number;
|
|
163
|
+
}, onDeliver: (d: Delivery) => void | Promise<void>, opts?: {
|
|
164
|
+
max?: number;
|
|
165
|
+
idleStops?: number;
|
|
166
|
+
pollMs?: number;
|
|
167
|
+
}): Promise<{
|
|
168
|
+
round: number;
|
|
169
|
+
index: number;
|
|
170
|
+
}>;
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAiB,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC3F,OAAO,EAAqB,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAIjE,gGAAgG;AAChG,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAevD,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iFAAiF;IACjF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AA8GD,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAA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