@xyo-network/xl1-rest-block-publisher 2.0.12
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 +165 -0
- package/README.md +120 -0
- package/dist/node/RestBlockPublisher.d.ts +56 -0
- package/dist/node/RestBlockPublisher.d.ts.map +1 -0
- package/dist/node/encoding.d.ts +16 -0
- package/dist/node/encoding.d.ts.map +1 -0
- package/dist/node/index.d.ts +3 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.mjs +191 -0
- package/dist/node/index.mjs.map +7 -0
- package/package.json +113 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
package/README.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
[![logo][]](https://xyo.network)
|
|
2
|
+
|
|
3
|
+
# @xyo-network/xl1-rest-block-publisher
|
|
4
|
+
|
|
5
|
+
[![npm-badge][]][npm-link]
|
|
6
|
+
[![license-badge][]][license-link]
|
|
7
|
+
|
|
8
|
+
> Publishes a finalized XL1 chain as the static REST file layout that `RestBlockViewer` reads — pre-compressed, immutable, CDN-friendly.
|
|
9
|
+
|
|
10
|
+
## About
|
|
11
|
+
|
|
12
|
+
Finalized blocks and completed steps never change, so the chain can be materialized once as static files on S3-compatible object storage (e.g. Cloudflare R2) and served forever over plain HTTP. `RestBlockPublisher` writes that layout from any source `BlockViewer`:
|
|
13
|
+
|
|
14
|
+
```text
|
|
15
|
+
/chain/head.json ← written last on every sync (must-revalidate)
|
|
16
|
+
/block/number/<n>.json ← immutable
|
|
17
|
+
/block/hash/<hash>.json ← immutable, same content
|
|
18
|
+
/blocks/step/<level>/<index>.json ← immutable, completed steps only
|
|
19
|
+
/payload/<hash>.json ← immutable
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Bodies are pre-compressed at write time (brotli by default, gzip or none configurable) and stored with the matching `Content-Encoding` plus `application/json`, so HTTP clients decompress transparently — keys keep their `.json` extension. Immutable files get `Cache-Control: public, max-age=31536000, immutable`; the head pointer gets `must-revalidate`.
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { S3Client } from '@aws-sdk/client-s3'
|
|
26
|
+
import { RestBlockPublisher } from '@xyo-network/xl1-rest-block-publisher'
|
|
27
|
+
|
|
28
|
+
const client = new S3Client({
|
|
29
|
+
region: 'auto',
|
|
30
|
+
endpoint: `https://${accountId}.r2.cloudflarestorage.com`,
|
|
31
|
+
credentials: { accessKeyId, secretAccessKey },
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const publisher = await RestBlockPublisher.create({ bucket: 'chain', client, source: blockViewer })
|
|
35
|
+
const range = await publisher.sync() // publishes everything new, head last; null when up to date
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`sync()` resumes from the published head pointer, so the same call serves both initial backfill and incremental tailing. Publishing is idempotent — deterministic keys, immutable content — so re-running after a crash is always safe. The path builders come from [`@xyo-network/xl1-rest-block-viewer`](https://www.npmjs.com/package/@xyo-network/xl1-rest-block-viewer), so reader and writer share one layout contract.
|
|
39
|
+
|
|
40
|
+
## Install
|
|
41
|
+
|
|
42
|
+
Using npm:
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
npm i --save @xyo-network/xl1-rest-block-publisher
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Using yarn:
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
yarn add @xyo-network/xl1-rest-block-publisher
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Using pnpm:
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
pnpm add @xyo-network/xl1-rest-block-publisher
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Using bun:
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
bun add @xyo-network/xl1-rest-block-publisher
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
> Node-only (uses `node:zlib`). Bring your own `@aws-sdk/client-s3` client.
|
|
67
|
+
|
|
68
|
+
## What's Inside
|
|
69
|
+
|
|
70
|
+
- **`RestBlockPublisher`** — `sync()` (cursor-resumed publish, head written last), `publishBlock`, `publishStep`/`publishStepsCompletedBy` (completed steps only), `publishHead`, `publishedHead`.
|
|
71
|
+
- **`encodeBody`/`decodeBody`** — brotli/gzip/none body codecs used for storage and read-back.
|
|
72
|
+
|
|
73
|
+
## Building Locally
|
|
74
|
+
|
|
75
|
+
```sh
|
|
76
|
+
xy build @xyo-network/xl1-rest-block-publisher
|
|
77
|
+
xy test @xyo-network/xl1-rest-block-publisher
|
|
78
|
+
xy lint @xyo-network/xl1-rest-block-publisher
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Maintainers
|
|
82
|
+
|
|
83
|
+
<table>
|
|
84
|
+
<tr>
|
|
85
|
+
<td align="center" valign="top" width="120">
|
|
86
|
+
<a href="https://github.com/arietrouw">
|
|
87
|
+
<img src="https://github.com/arietrouw.png" width="80" height="80" alt="Arie Trouw" /><br />
|
|
88
|
+
<sub><b>Arie Trouw</b></sub>
|
|
89
|
+
</a>
|
|
90
|
+
<br />
|
|
91
|
+
<a href="https://arietrouw.com">arietrouw.com</a>
|
|
92
|
+
</td>
|
|
93
|
+
<td align="center" valign="top" width="120">
|
|
94
|
+
<a href="https://github.com/jonesmac">
|
|
95
|
+
<img src="https://github.com/jonesmac.png" width="80" height="80" alt="Matt Jones" /><br />
|
|
96
|
+
<sub><b>Matt Jones</b></sub>
|
|
97
|
+
</a>
|
|
98
|
+
</td>
|
|
99
|
+
<td align="center" valign="top" width="120">
|
|
100
|
+
<a href="https://github.com/JoelBCarter">
|
|
101
|
+
<img src="https://github.com/JoelBCarter.png" width="80" height="80" alt="Joel Carter" /><br />
|
|
102
|
+
<sub><b>Joel Carter</b></sub>
|
|
103
|
+
</a>
|
|
104
|
+
</td>
|
|
105
|
+
</tr>
|
|
106
|
+
</table>
|
|
107
|
+
|
|
108
|
+
## License
|
|
109
|
+
|
|
110
|
+
See the [LICENSE](./LICENSE) file (LGPL-3.0-only).
|
|
111
|
+
|
|
112
|
+
## Credits
|
|
113
|
+
|
|
114
|
+
[Made with 🔥 and ❄️ by XYO Foundation](https://xyo.network)
|
|
115
|
+
|
|
116
|
+
[npm-badge]: https://img.shields.io/npm/v/@xyo-network/xl1-rest-block-publisher.svg
|
|
117
|
+
[npm-link]: https://www.npmjs.com/package/@xyo-network/xl1-rest-block-publisher
|
|
118
|
+
[license-badge]: https://img.shields.io/npm/l/@xyo-network/xl1-rest-block-publisher.svg
|
|
119
|
+
[license-link]: ./LICENSE
|
|
120
|
+
[logo]: https://cdn.xy.company/img/brand/XYO_full_colored.png
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { S3Client } from '@aws-sdk/client-s3';
|
|
2
|
+
import type { CreatableParams } from '@xylabs/sdk-js';
|
|
3
|
+
import { AbstractCreatable } from '@xylabs/sdk-js';
|
|
4
|
+
import type { BlockViewer, SignedHydratedBlockWithHashMeta, XL1BlockNumber, XL1BlockRange } from '@xyo-network/xl1-protocol-lib';
|
|
5
|
+
import type { RestContentEncoding } from './encoding.ts';
|
|
6
|
+
/** Parameters for RestBlockPublisher. */
|
|
7
|
+
export interface RestBlockPublisherParams extends CreatableParams {
|
|
8
|
+
bucket: string;
|
|
9
|
+
/** S3-compatible client pointed at the target endpoint (e.g. Cloudflare R2). */
|
|
10
|
+
client: S3Client;
|
|
11
|
+
/** Maximum concurrent block publishes during sync. */
|
|
12
|
+
concurrency?: number;
|
|
13
|
+
/** Storage/wire encoding for published files. Defaults to 'br' (brotli). */
|
|
14
|
+
contentEncoding?: RestContentEncoding;
|
|
15
|
+
/** Optional key prefix, allowing the layout to live in a shared bucket. */
|
|
16
|
+
prefix?: string;
|
|
17
|
+
/** The viewer to publish from (only finalized chains should be published). */
|
|
18
|
+
source: BlockViewer;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Publishes a chain as the static REST file layout that `RestBlockViewer` reads
|
|
22
|
+
* (see `paths.ts` in @xyo-network/xl1-rest-block-viewer).
|
|
23
|
+
*
|
|
24
|
+
* Publishing is idempotent: keys are deterministic and contents immutable, so re-publishing
|
|
25
|
+
* any range is safe. `sync()` writes the head pointer last — readers never see a head that
|
|
26
|
+
* references files that do not exist yet — and uses the published head as its resume cursor.
|
|
27
|
+
*/
|
|
28
|
+
export declare class RestBlockPublisher extends AbstractCreatable<RestBlockPublisherParams> {
|
|
29
|
+
get bucket(): string;
|
|
30
|
+
get client(): S3Client;
|
|
31
|
+
get concurrency(): number;
|
|
32
|
+
get contentEncoding(): RestContentEncoding;
|
|
33
|
+
get prefix(): string;
|
|
34
|
+
get source(): BlockViewer;
|
|
35
|
+
/** Publishes one block at its by-number and by-hash paths, plus its payload files. */
|
|
36
|
+
publishBlock(blockNumber: XL1BlockNumber): Promise<SignedHydratedBlockWithHashMeta | null>;
|
|
37
|
+
/** Publishes the current source head to the mutable head pointer. */
|
|
38
|
+
publishHead(): Promise<SignedHydratedBlockWithHashMeta>;
|
|
39
|
+
/**
|
|
40
|
+
* Publishes one completed step's blocks as a BlocksStepSummary file (blocks oldest-first).
|
|
41
|
+
* Asserts the step is complete — partial tail steps are never published.
|
|
42
|
+
*/
|
|
43
|
+
publishStep(stepLevel: number, stepIndex: number): Promise<void>;
|
|
44
|
+
/** Publishes every step (at every level) completed by the given block. */
|
|
45
|
+
publishStepsCompletedBy(blockNumber: XL1BlockNumber): Promise<void>;
|
|
46
|
+
/** Reads the published head pointer back from the bucket, or undefined if absent. */
|
|
47
|
+
publishedHead(): Promise<SignedHydratedBlockWithHashMeta | undefined>;
|
|
48
|
+
/**
|
|
49
|
+
* Publishes everything from the published head (exclusive) to the source head (inclusive),
|
|
50
|
+
* then the completed steps in that range, then the head pointer last. Returns the published
|
|
51
|
+
* range, or null when already up to date.
|
|
52
|
+
*/
|
|
53
|
+
sync(): Promise<XL1BlockRange | null>;
|
|
54
|
+
private putJson;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=RestBlockPublisher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RestBlockPublisher.d.ts","sourceRoot":"","sources":["../../src/RestBlockPublisher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAElD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,C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BAA+B,GAAG,SAAS,CAAC;IAa3E;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;YAmB7B,OAAO;CAWtB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Wire/storage encoding for published files. */
|
|
2
|
+
export type RestContentEncoding = 'br' | 'gzip' | 'none';
|
|
3
|
+
/** An encoded file body plus the HTTP Content-Encoding it should be served with. */
|
|
4
|
+
export interface EncodedBody {
|
|
5
|
+
body: Uint8Array;
|
|
6
|
+
contentEncoding?: 'br' | 'gzip';
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Encodes a JSON string for storage. Bodies are pre-compressed at write time and stored
|
|
10
|
+
* with the matching Content-Encoding so HTTP clients decompress transparently — keys keep
|
|
11
|
+
* their .json extension and Content-Type stays application/json.
|
|
12
|
+
*/
|
|
13
|
+
export declare function encodeBody(json: string, encoding: RestContentEncoding): EncodedBody;
|
|
14
|
+
/** Decodes a stored body back to its JSON string using the object's Content-Encoding. */
|
|
15
|
+
export declare function decodeBody(body: Uint8Array, contentEncoding?: string): string;
|
|
16
|
+
//# sourceMappingURL=encoding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../../src/encoding.ts"],"names":[],"mappings":"AAEA,iDAAiD;AACjD,MAAM,MAAM,mBAAmB,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,CAAA;AAExD,oFAAoF;AACpF,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,UAAU,CAAA;IAChB,eAAe,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;CAChC;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,mBAAmB,GAAG,WAAW,CAYnF;AAED,yFAAyF;AACzF,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,CAY7E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,yBAAyB,CAAA"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
+
if (decorator = decorators[i])
|
|
7
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
+
if (kind && result) __defProp(target, key, result);
|
|
9
|
+
return result;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// src/encoding.ts
|
|
13
|
+
import ZLIB from "node:zlib";
|
|
14
|
+
function encodeBody(json, encoding) {
|
|
15
|
+
switch (encoding) {
|
|
16
|
+
case "br": {
|
|
17
|
+
return { body: ZLIB.brotliCompressSync(json), contentEncoding: "br" };
|
|
18
|
+
}
|
|
19
|
+
case "gzip": {
|
|
20
|
+
return { body: ZLIB.gzipSync(json), contentEncoding: "gzip" };
|
|
21
|
+
}
|
|
22
|
+
case "none": {
|
|
23
|
+
return { body: new TextEncoder().encode(json) };
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function decodeBody(body, contentEncoding) {
|
|
28
|
+
switch (contentEncoding) {
|
|
29
|
+
case "br": {
|
|
30
|
+
return ZLIB.brotliDecompressSync(body).toString("utf8");
|
|
31
|
+
}
|
|
32
|
+
case "gzip": {
|
|
33
|
+
return ZLIB.gunzipSync(body).toString("utf8");
|
|
34
|
+
}
|
|
35
|
+
default: {
|
|
36
|
+
return new TextDecoder().decode(body);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// src/RestBlockPublisher.ts
|
|
42
|
+
import { GetObjectCommand, PutObjectCommand } from "@aws-sdk/client-s3";
|
|
43
|
+
import {
|
|
44
|
+
AbstractCreatable,
|
|
45
|
+
assertEx,
|
|
46
|
+
creatable,
|
|
47
|
+
isNull
|
|
48
|
+
} from "@xylabs/sdk-js";
|
|
49
|
+
import {
|
|
50
|
+
asSignedHydratedBlockWithHashMeta,
|
|
51
|
+
asXL1BlockNumber,
|
|
52
|
+
StepSizes
|
|
53
|
+
} from "@xyo-network/xl1-protocol-lib";
|
|
54
|
+
import { blocksMaxStep, BlocksStepSummarySchema } from "@xyo-network/xl1-protocol-sdk";
|
|
55
|
+
import {
|
|
56
|
+
blockHashPath,
|
|
57
|
+
blockNumberPath,
|
|
58
|
+
blocksStepPath,
|
|
59
|
+
headPath,
|
|
60
|
+
payloadPath
|
|
61
|
+
} from "@xyo-network/xl1-rest-block-viewer";
|
|
62
|
+
import { Semaphore } from "async-mutex";
|
|
63
|
+
var IMMUTABLE_CACHE_CONTROL = "public, max-age=31536000, immutable";
|
|
64
|
+
var HEAD_CACHE_CONTROL = "public, max-age=0, must-revalidate";
|
|
65
|
+
var RestBlockPublisher = class extends AbstractCreatable {
|
|
66
|
+
get bucket() {
|
|
67
|
+
return assertEx(this.params.bucket, () => "No bucket specified");
|
|
68
|
+
}
|
|
69
|
+
get client() {
|
|
70
|
+
return assertEx(this.params.client, () => "No client specified");
|
|
71
|
+
}
|
|
72
|
+
get concurrency() {
|
|
73
|
+
return this.params.concurrency ?? 8;
|
|
74
|
+
}
|
|
75
|
+
get contentEncoding() {
|
|
76
|
+
return this.params.contentEncoding ?? "br";
|
|
77
|
+
}
|
|
78
|
+
get prefix() {
|
|
79
|
+
return this.params.prefix ?? "";
|
|
80
|
+
}
|
|
81
|
+
get source() {
|
|
82
|
+
return assertEx(this.params.source, () => "No source specified");
|
|
83
|
+
}
|
|
84
|
+
/** Publishes one block at its by-number and by-hash paths, plus its payload files. */
|
|
85
|
+
async publishBlock(blockNumber) {
|
|
86
|
+
const block = await this.source.blockByNumber(blockNumber);
|
|
87
|
+
if (isNull(block)) return null;
|
|
88
|
+
const json = JSON.stringify(block);
|
|
89
|
+
await this.putJson(blockNumberPath(block[0].block), json, IMMUTABLE_CACHE_CONTROL);
|
|
90
|
+
await this.putJson(blockHashPath(block[0]._hash), json, IMMUTABLE_CACHE_CONTROL);
|
|
91
|
+
for (const payload of block[1]) {
|
|
92
|
+
await this.putJson(payloadPath(payload._hash), JSON.stringify(payload), IMMUTABLE_CACHE_CONTROL);
|
|
93
|
+
}
|
|
94
|
+
return block;
|
|
95
|
+
}
|
|
96
|
+
/** Publishes the current source head to the mutable head pointer. */
|
|
97
|
+
async publishHead() {
|
|
98
|
+
const head = await this.source.currentBlock();
|
|
99
|
+
await this.putJson(headPath(), JSON.stringify(head), HEAD_CACHE_CONTROL);
|
|
100
|
+
return head;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Publishes one completed step's blocks as a BlocksStepSummary file (blocks oldest-first).
|
|
104
|
+
* Asserts the step is complete — partial tail steps are never published.
|
|
105
|
+
*/
|
|
106
|
+
async publishStep(stepLevel, stepIndex) {
|
|
107
|
+
const size = StepSizes[stepLevel];
|
|
108
|
+
assertEx(stepLevel <= blocksMaxStep, () => `publishStep does not support step levels above ${blocksMaxStep} (requested ${stepLevel})`);
|
|
109
|
+
const lastBlockNumber = (stepIndex + 1) * size - 1;
|
|
110
|
+
const headNumber = await this.source.currentBlockNumber();
|
|
111
|
+
assertEx(lastBlockNumber <= headNumber, () => `Step ${stepLevel}/${stepIndex} is not complete (head ${headNumber})`);
|
|
112
|
+
const newestFirst = await this.source.blocksByStep(stepLevel, stepIndex);
|
|
113
|
+
const blocks = newestFirst.toReversed();
|
|
114
|
+
const summary = {
|
|
115
|
+
schema: BlocksStepSummarySchema,
|
|
116
|
+
hash: assertEx(blocks.at(-1), () => `No blocks for step ${stepLevel}/${stepIndex}`)[0]._hash,
|
|
117
|
+
stepSize: size,
|
|
118
|
+
blocks
|
|
119
|
+
};
|
|
120
|
+
await this.putJson(blocksStepPath(stepLevel, stepIndex), JSON.stringify(summary), IMMUTABLE_CACHE_CONTROL);
|
|
121
|
+
}
|
|
122
|
+
/** Publishes every step (at every level) completed by the given block. */
|
|
123
|
+
async publishStepsCompletedBy(blockNumber) {
|
|
124
|
+
for (let stepLevel = 0; stepLevel <= blocksMaxStep; stepLevel++) {
|
|
125
|
+
const size = StepSizes[stepLevel];
|
|
126
|
+
if ((blockNumber + 1) % size === 0) {
|
|
127
|
+
await this.publishStep(stepLevel, (blockNumber + 1) / size - 1);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/** Reads the published head pointer back from the bucket, or undefined if absent. */
|
|
132
|
+
async publishedHead() {
|
|
133
|
+
try {
|
|
134
|
+
const response = await this.client.send(new GetObjectCommand({ Bucket: this.bucket, Key: `${this.prefix}${headPath()}` }));
|
|
135
|
+
const body = await response.Body?.transformToByteArray();
|
|
136
|
+
if (body === void 0) return void 0;
|
|
137
|
+
const parsed = JSON.parse(decodeBody(body, response.ContentEncoding));
|
|
138
|
+
return asSignedHydratedBlockWithHashMeta(parsed, true);
|
|
139
|
+
} catch (error) {
|
|
140
|
+
if (isNotFoundError(error)) return void 0;
|
|
141
|
+
throw error;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Publishes everything from the published head (exclusive) to the source head (inclusive),
|
|
146
|
+
* then the completed steps in that range, then the head pointer last. Returns the published
|
|
147
|
+
* range, or null when already up to date.
|
|
148
|
+
*/
|
|
149
|
+
async sync() {
|
|
150
|
+
const sourceHead = await this.source.currentBlock();
|
|
151
|
+
const published = await this.publishedHead();
|
|
152
|
+
const start = published === void 0 ? 0 : published[0].block + 1;
|
|
153
|
+
const end = sourceHead[0].block;
|
|
154
|
+
if (start > end) return null;
|
|
155
|
+
const semaphore = new Semaphore(this.concurrency);
|
|
156
|
+
const numbers = Array.from({ length: end - start + 1 }, (_, i) => asXL1BlockNumber(start + i, true));
|
|
157
|
+
await Promise.all(numbers.map((blockNumber) => semaphore.runExclusive(async () => {
|
|
158
|
+
assertEx(await this.publishBlock(blockNumber), () => `Block not found in source [${blockNumber}]`);
|
|
159
|
+
})));
|
|
160
|
+
for (const blockNumber of numbers) {
|
|
161
|
+
await this.publishStepsCompletedBy(blockNumber);
|
|
162
|
+
}
|
|
163
|
+
await this.publishHead();
|
|
164
|
+
return [asXL1BlockNumber(start, true), end];
|
|
165
|
+
}
|
|
166
|
+
async putJson(path, json, cacheControl) {
|
|
167
|
+
const { body, contentEncoding } = encodeBody(json, this.contentEncoding);
|
|
168
|
+
await this.client.send(new PutObjectCommand({
|
|
169
|
+
Bucket: this.bucket,
|
|
170
|
+
Key: `${this.prefix}${path}`,
|
|
171
|
+
Body: body,
|
|
172
|
+
CacheControl: cacheControl,
|
|
173
|
+
ContentEncoding: contentEncoding,
|
|
174
|
+
ContentType: "application/json"
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
RestBlockPublisher = __decorateClass([
|
|
179
|
+
creatable()
|
|
180
|
+
], RestBlockPublisher);
|
|
181
|
+
var isNotFoundError = (error) => {
|
|
182
|
+
if (typeof error !== "object" || error === null) return false;
|
|
183
|
+
const { name, $metadata } = error;
|
|
184
|
+
return name === "NoSuchKey" || name === "NotFound" || $metadata?.httpStatusCode === 404;
|
|
185
|
+
};
|
|
186
|
+
export {
|
|
187
|
+
RestBlockPublisher,
|
|
188
|
+
decodeBody,
|
|
189
|
+
encodeBody
|
|
190
|
+
};
|
|
191
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/encoding.ts", "../../src/RestBlockPublisher.ts"],
|
|
4
|
+
"sourcesContent": ["import ZLIB from 'node:zlib'\n\n/** Wire/storage encoding for published files. */\nexport type RestContentEncoding = 'br' | 'gzip' | 'none'\n\n/** An encoded file body plus the HTTP Content-Encoding it should be served with. */\nexport interface EncodedBody {\n body: Uint8Array\n contentEncoding?: 'br' | 'gzip'\n}\n\n/**\n * Encodes a JSON string for storage. Bodies are pre-compressed at write time and stored\n * with the matching Content-Encoding so HTTP clients decompress transparently \u2014 keys keep\n * their .json extension and Content-Type stays application/json.\n */\nexport function encodeBody(json: string, encoding: RestContentEncoding): EncodedBody {\n switch (encoding) {\n case 'br': {\n return { body: ZLIB.brotliCompressSync(json), contentEncoding: 'br' }\n }\n case 'gzip': {\n return { body: ZLIB.gzipSync(json), contentEncoding: 'gzip' }\n }\n case 'none': {\n return { body: new TextEncoder().encode(json) }\n }\n }\n}\n\n/** Decodes a stored body back to its JSON string using the object's Content-Encoding. */\nexport function decodeBody(body: Uint8Array, contentEncoding?: string): string {\n switch (contentEncoding) {\n case 'br': {\n return ZLIB.brotliDecompressSync(body).toString('utf8')\n }\n case 'gzip': {\n return ZLIB.gunzipSync(body).toString('utf8')\n }\n default: {\n return new TextDecoder().decode(body)\n }\n }\n}\n", "import type { S3Client } from '@aws-sdk/client-s3'\nimport { GetObjectCommand, PutObjectCommand } from '@aws-sdk/client-s3'\nimport type { CreatableParams } from '@xylabs/sdk-js'\nimport {\n AbstractCreatable, assertEx, creatable, isNull,\n} from '@xylabs/sdk-js'\nimport type {\n BlockViewer, SignedHydratedBlockWithHashMeta, XL1BlockNumber, XL1BlockRange,\n} from '@xyo-network/xl1-protocol-lib'\nimport {\n asSignedHydratedBlockWithHashMeta, asXL1BlockNumber, StepSizes,\n} from '@xyo-network/xl1-protocol-lib'\nimport type { BlocksStepSummary } from '@xyo-network/xl1-protocol-sdk'\nimport { blocksMaxStep, BlocksStepSummarySchema } from '@xyo-network/xl1-protocol-sdk'\nimport {\n blockHashPath, blockNumberPath, blocksStepPath, headPath, payloadPath,\n} from '@xyo-network/xl1-rest-block-viewer'\nimport { Semaphore } from 'async-mutex'\n\nimport type { RestContentEncoding } from './encoding.ts'\nimport { decodeBody, encodeBody } from './encoding.ts'\n\n/** Parameters for RestBlockPublisher. */\nexport interface RestBlockPublisherParams extends CreatableParams {\n bucket: string\n /** S3-compatible client pointed at the target endpoint (e.g. Cloudflare R2). */\n client: S3Client\n /** Maximum concurrent block publishes during sync. */\n concurrency?: number\n /** Storage/wire encoding for published files. Defaults to 'br' (brotli). */\n contentEncoding?: RestContentEncoding\n /** Optional key prefix, allowing the layout to live in a shared bucket. */\n prefix?: string\n /** The viewer to publish from (only finalized chains should be published). */\n source: BlockViewer\n}\n\n/** Everything except the head pointer is immutable once written. */\nconst IMMUTABLE_CACHE_CONTROL = 'public, max-age=31536000, immutable'\n/** The head pointer is rewritten as the chain advances. */\nconst HEAD_CACHE_CONTROL = 'public, max-age=0, must-revalidate'\n\n/**\n * Publishes a chain as the static REST file layout that `RestBlockViewer` reads\n * (see `paths.ts` in @xyo-network/xl1-rest-block-viewer).\n *\n * Publishing is idempotent: keys are deterministic and contents immutable, so re-publishing\n * any range is safe. `sync()` writes the head pointer last \u2014 readers never see a head that\n * references files that do not exist yet \u2014 and uses the published head as its resume cursor.\n */\n@creatable()\nexport class RestBlockPublisher extends AbstractCreatable<RestBlockPublisherParams> {\n get bucket(): string {\n return assertEx(this.params.bucket, () => 'No bucket specified')\n }\n\n get client(): S3Client {\n return assertEx(this.params.client, () => 'No client specified')\n }\n\n get concurrency(): number {\n return this.params.concurrency ?? 8\n }\n\n get contentEncoding(): RestContentEncoding {\n return this.params.contentEncoding ?? 'br'\n }\n\n get prefix(): string {\n return this.params.prefix ?? ''\n }\n\n get source(): BlockViewer {\n return assertEx(this.params.source, () => 'No source specified')\n }\n\n /** Publishes one block at its by-number and by-hash paths, plus its payload files. */\n async publishBlock(blockNumber: XL1BlockNumber): Promise<SignedHydratedBlockWithHashMeta | null> {\n const block = await this.source.blockByNumber(blockNumber)\n if (isNull(block)) return null\n const json = JSON.stringify(block)\n await this.putJson(blockNumberPath(block[0].block), json, IMMUTABLE_CACHE_CONTROL)\n await this.putJson(blockHashPath(block[0]._hash), json, IMMUTABLE_CACHE_CONTROL)\n for (const payload of block[1]) {\n await this.putJson(payloadPath(payload._hash), JSON.stringify(payload), IMMUTABLE_CACHE_CONTROL)\n }\n return block\n }\n\n /** Publishes the current source head to the mutable head pointer. */\n async publishHead(): Promise<SignedHydratedBlockWithHashMeta> {\n const head = await this.source.currentBlock()\n await this.putJson(headPath(), JSON.stringify(head), HEAD_CACHE_CONTROL)\n return head\n }\n\n /**\n * Publishes one completed step's blocks as a BlocksStepSummary file (blocks oldest-first).\n * Asserts the step is complete \u2014 partial tail steps are never published.\n */\n async publishStep(stepLevel: number, stepIndex: number): Promise<void> {\n const size = StepSizes[stepLevel]\n assertEx(stepLevel <= blocksMaxStep, () => `publishStep does not support step levels above ${blocksMaxStep} (requested ${stepLevel})`)\n const lastBlockNumber = (stepIndex + 1) * size - 1\n const headNumber = await this.source.currentBlockNumber()\n assertEx(lastBlockNumber <= headNumber, () => `Step ${stepLevel}/${stepIndex} is not complete (head ${headNumber})`)\n const newestFirst = await this.source.blocksByStep(stepLevel, stepIndex)\n const blocks = newestFirst.toReversed()\n const summary: BlocksStepSummary = {\n schema: BlocksStepSummarySchema,\n hash: assertEx(blocks.at(-1), () => `No blocks for step ${stepLevel}/${stepIndex}`)[0]._hash,\n stepSize: size,\n blocks,\n }\n await this.putJson(blocksStepPath(stepLevel, stepIndex), JSON.stringify(summary), IMMUTABLE_CACHE_CONTROL)\n }\n\n /** Publishes every step (at every level) completed by the given block. */\n async publishStepsCompletedBy(blockNumber: XL1BlockNumber): Promise<void> {\n for (let stepLevel = 0; stepLevel <= blocksMaxStep; stepLevel++) {\n const size = StepSizes[stepLevel]\n if ((blockNumber + 1) % size === 0) {\n await this.publishStep(stepLevel, (blockNumber + 1) / size - 1)\n }\n }\n }\n\n /** Reads the published head pointer back from the bucket, or undefined if absent. */\n async publishedHead(): Promise<SignedHydratedBlockWithHashMeta | undefined> {\n try {\n const response = await this.client.send(new GetObjectCommand({ Bucket: this.bucket, Key: `${this.prefix}${headPath()}` }))\n const body = await response.Body?.transformToByteArray()\n if (body === undefined) return undefined\n const parsed: unknown = JSON.parse(decodeBody(body, response.ContentEncoding))\n return asSignedHydratedBlockWithHashMeta(parsed, true)\n } catch (error) {\n if (isNotFoundError(error)) return undefined\n throw error\n }\n }\n\n /**\n * Publishes everything from the published head (exclusive) to the source head (inclusive),\n * then the completed steps in that range, then the head pointer last. Returns the published\n * range, or null when already up to date.\n */\n async sync(): Promise<XL1BlockRange | null> {\n const sourceHead = await this.source.currentBlock()\n const published = await this.publishedHead()\n const start = published === undefined ? 0 : published[0].block + 1\n const end = sourceHead[0].block\n if (start > end) return null\n\n const semaphore = new Semaphore(this.concurrency)\n const numbers = Array.from({ length: end - start + 1 }, (_, i) => asXL1BlockNumber(start + i, true))\n await Promise.all(numbers.map(blockNumber => semaphore.runExclusive(async () => {\n assertEx(await this.publishBlock(blockNumber), () => `Block not found in source [${blockNumber}]`)\n })))\n for (const blockNumber of numbers) {\n await this.publishStepsCompletedBy(blockNumber)\n }\n await this.publishHead()\n return [asXL1BlockNumber(start, true), end]\n }\n\n private async putJson(path: string, json: string, cacheControl: string): Promise<void> {\n const { body, contentEncoding } = encodeBody(json, this.contentEncoding)\n await this.client.send(new PutObjectCommand({\n Bucket: this.bucket,\n Key: `${this.prefix}${path}`,\n Body: body,\n CacheControl: cacheControl,\n ContentEncoding: contentEncoding,\n ContentType: 'application/json',\n }))\n }\n}\n\nconst isNotFoundError = (error: unknown): boolean => {\n if (typeof error !== 'object' || error === null) return false\n const { name, $metadata } = error as { $metadata?: { httpStatusCode?: number }; name?: string }\n return name === 'NoSuchKey' || name === 'NotFound' || $metadata?.httpStatusCode === 404\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;AAAA,OAAO,UAAU;AAgBV,SAAS,WAAW,MAAc,UAA4C;AACnF,UAAQ,UAA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-rest-block-publisher",
|
|
4
|
+
"version": "2.0.12",
|
|
5
|
+
"description": "XYO Layer One static REST chain layout publisher",
|
|
6
|
+
"homepage": "https://xylabs.com",
|
|
7
|
+
"bugs": {
|
|
8
|
+
"url": "https://github.com/XYOracleNetwork/xl1-protocol/issues",
|
|
9
|
+
"email": "support@xylabs.com"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/XYOracleNetwork/xl1-protocol.git"
|
|
14
|
+
},
|
|
15
|
+
"license": "LGPL-3.0-only",
|
|
16
|
+
"author": {
|
|
17
|
+
"name": "XY Labs Development Team",
|
|
18
|
+
"email": "support@xylabs.com",
|
|
19
|
+
"url": "https://xylabs.com"
|
|
20
|
+
},
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"type": "module",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/node/index.d.ts",
|
|
26
|
+
"default": "./dist/node/index.mjs"
|
|
27
|
+
},
|
|
28
|
+
"./package.json": "./package.json"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"!**/*.bench.*",
|
|
33
|
+
"!**/*.spec.*",
|
|
34
|
+
"!**/*.test.*",
|
|
35
|
+
"README.md"
|
|
36
|
+
],
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@xyo-network/xl1-protocol-sdk": "~2.0.12",
|
|
39
|
+
"@xyo-network/xl1-protocol-lib": "~2.0.12",
|
|
40
|
+
"@xyo-network/xl1-rest-block-viewer": "~2.0.12"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@aws-sdk/client-s3": "^3.700.0",
|
|
44
|
+
"@bitauth/libauth": "~3.0",
|
|
45
|
+
"@metamask/providers": "^22.1",
|
|
46
|
+
"@noble/post-quantum": "~0.6.1",
|
|
47
|
+
"@opentelemetry/api": "^1.9",
|
|
48
|
+
"@opentelemetry/sdk-trace-base": "^2.7",
|
|
49
|
+
"@scure/base": "~2.2",
|
|
50
|
+
"@scure/bip39": "~2.2",
|
|
51
|
+
"@xylabs/geo": "^6.0",
|
|
52
|
+
"@xylabs/sdk-js": "^6.0.10",
|
|
53
|
+
"@xylabs/threads": "~6.0",
|
|
54
|
+
"@xylabs/toolchain": "~8.1.19",
|
|
55
|
+
"@xylabs/tsconfig": "~8.1.19",
|
|
56
|
+
"@xyo-network/address": "^6.0",
|
|
57
|
+
"@xyo-network/sdk-js": "^6.0",
|
|
58
|
+
"@xyo-network/sdk-protocol-js": "~6.0",
|
|
59
|
+
"ajv": "^8.20",
|
|
60
|
+
"async-mutex": "^0.5.0",
|
|
61
|
+
"bn.js": "^5.2",
|
|
62
|
+
"buffer": "^6.0",
|
|
63
|
+
"cosmiconfig": "^9.0",
|
|
64
|
+
"debug": "~4.4",
|
|
65
|
+
"eslint": "^10.4.1",
|
|
66
|
+
"ethers": "^6.16",
|
|
67
|
+
"hash-wasm": "~4.12",
|
|
68
|
+
"idb": "^8.0",
|
|
69
|
+
"lru-cache": "^11.3",
|
|
70
|
+
"observable-fns": "~0.6",
|
|
71
|
+
"typescript": "~6.0.3",
|
|
72
|
+
"vite": "^6.0.0 || ^7.0.0 || ^8.0.0",
|
|
73
|
+
"vitest": "~4.1.8",
|
|
74
|
+
"webextension-polyfill": "^0.12",
|
|
75
|
+
"zod": "~4.4"
|
|
76
|
+
},
|
|
77
|
+
"peerDependencies": {
|
|
78
|
+
"@aws-sdk/client-s3": "^3.700",
|
|
79
|
+
"@bitauth/libauth": "~3.0",
|
|
80
|
+
"@metamask/providers": "^22.1",
|
|
81
|
+
"@noble/post-quantum": "~0.6.1",
|
|
82
|
+
"@opentelemetry/api": "^1.9",
|
|
83
|
+
"@opentelemetry/sdk-trace-base": "^2.7",
|
|
84
|
+
"@scure/base": "~2.2",
|
|
85
|
+
"@scure/bip39": "~2.2",
|
|
86
|
+
"@xylabs/geo": "^6.0",
|
|
87
|
+
"@xylabs/sdk-js": "^6.0",
|
|
88
|
+
"@xylabs/threads": "~6.0",
|
|
89
|
+
"@xyo-network/address": "^6.0",
|
|
90
|
+
"@xyo-network/sdk-js": "^6.0",
|
|
91
|
+
"@xyo-network/sdk-protocol-js": "~6.0",
|
|
92
|
+
"ajv": "^8.20",
|
|
93
|
+
"async-mutex": "^0.5",
|
|
94
|
+
"bn.js": "^5.2",
|
|
95
|
+
"buffer": "^6.0",
|
|
96
|
+
"cosmiconfig": "^9.0",
|
|
97
|
+
"debug": "~4.4",
|
|
98
|
+
"ethers": "^6.16",
|
|
99
|
+
"hash-wasm": "~4.12",
|
|
100
|
+
"idb": "^8.0",
|
|
101
|
+
"lru-cache": "^11.3",
|
|
102
|
+
"observable-fns": "~0.6",
|
|
103
|
+
"webextension-polyfill": "^0.12",
|
|
104
|
+
"zod": "~4.4"
|
|
105
|
+
},
|
|
106
|
+
"engines": {
|
|
107
|
+
"node": ">=22.3"
|
|
108
|
+
},
|
|
109
|
+
"engineStrict": true,
|
|
110
|
+
"publishConfig": {
|
|
111
|
+
"access": "public"
|
|
112
|
+
}
|
|
113
|
+
}
|