@arcadiasystems/morse-sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/LICENSE +21 -0
- package/README.md +404 -0
- package/dist/clients.d.ts +12 -0
- package/dist/clients.d.ts.map +1 -0
- package/dist/clients.js +6 -0
- package/dist/clients.js.map +1 -0
- package/dist/codecs.d.ts +45 -0
- package/dist/codecs.d.ts.map +1 -0
- package/dist/codecs.js +132 -0
- package/dist/codecs.js.map +1 -0
- package/dist/compatibility.d.ts +22 -0
- package/dist/compatibility.d.ts.map +1 -0
- package/dist/compatibility.js +22 -0
- package/dist/compatibility.js.map +1 -0
- package/dist/config.d.ts +92 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +85 -0
- package/dist/config.js.map +1 -0
- package/dist/errors.d.ts +101 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +214 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/ops/cap.d.ts +79 -0
- package/dist/ops/cap.d.ts.map +1 -0
- package/dist/ops/cap.js +104 -0
- package/dist/ops/cap.js.map +1 -0
- package/dist/ops/collection.d.ts +50 -0
- package/dist/ops/collection.d.ts.map +1 -0
- package/dist/ops/collection.js +55 -0
- package/dist/ops/collection.js.map +1 -0
- package/dist/ops/entry-from-bytes.d.ts +129 -0
- package/dist/ops/entry-from-bytes.d.ts.map +1 -0
- package/dist/ops/entry-from-bytes.js +137 -0
- package/dist/ops/entry-from-bytes.js.map +1 -0
- package/dist/ops/entry.d.ts +173 -0
- package/dist/ops/entry.d.ts.map +1 -0
- package/dist/ops/entry.js +235 -0
- package/dist/ops/entry.js.map +1 -0
- package/dist/ops/index.d.ts +9 -0
- package/dist/ops/index.d.ts.map +1 -0
- package/dist/ops/index.js +9 -0
- package/dist/ops/index.js.map +1 -0
- package/dist/ops/internal.d.ts +21 -0
- package/dist/ops/internal.d.ts.map +1 -0
- package/dist/ops/internal.js +42 -0
- package/dist/ops/internal.js.map +1 -0
- package/dist/ops/publication.d.ts +74 -0
- package/dist/ops/publication.d.ts.map +1 -0
- package/dist/ops/publication.js +123 -0
- package/dist/ops/publication.js.map +1 -0
- package/dist/ptb/cap.d.ts +36 -0
- package/dist/ptb/cap.d.ts.map +1 -0
- package/dist/ptb/cap.js +44 -0
- package/dist/ptb/cap.js.map +1 -0
- package/dist/ptb/collection.d.ts +27 -0
- package/dist/ptb/collection.d.ts.map +1 -0
- package/dist/ptb/collection.js +33 -0
- package/dist/ptb/collection.js.map +1 -0
- package/dist/ptb/entry.d.ts +104 -0
- package/dist/ptb/entry.d.ts.map +1 -0
- package/dist/ptb/entry.js +155 -0
- package/dist/ptb/entry.js.map +1 -0
- package/dist/ptb/index.d.ts +9 -0
- package/dist/ptb/index.d.ts.map +1 -0
- package/dist/ptb/index.js +9 -0
- package/dist/ptb/index.js.map +1 -0
- package/dist/ptb/internal.d.ts +11 -0
- package/dist/ptb/internal.d.ts.map +1 -0
- package/dist/ptb/internal.js +12 -0
- package/dist/ptb/internal.js.map +1 -0
- package/dist/ptb/publication.d.ts +51 -0
- package/dist/ptb/publication.d.ts.map +1 -0
- package/dist/ptb/publication.js +61 -0
- package/dist/ptb/publication.js.map +1 -0
- package/dist/read/entry-bcs.d.ts +47 -0
- package/dist/read/entry-bcs.d.ts.map +1 -0
- package/dist/read/entry-bcs.js +36 -0
- package/dist/read/entry-bcs.js.map +1 -0
- package/dist/read/index.d.ts +5 -0
- package/dist/read/index.d.ts.map +1 -0
- package/dist/read/index.js +5 -0
- package/dist/read/index.js.map +1 -0
- package/dist/read/reader.d.ts +148 -0
- package/dist/read/reader.d.ts.map +1 -0
- package/dist/read/reader.js +403 -0
- package/dist/read/reader.js.map +1 -0
- package/dist/seal/adapter.d.ts +56 -0
- package/dist/seal/adapter.d.ts.map +1 -0
- package/dist/seal/adapter.js +7 -0
- package/dist/seal/adapter.js.map +1 -0
- package/dist/seal/default-adapter.d.ts +90 -0
- package/dist/seal/default-adapter.d.ts.map +1 -0
- package/dist/seal/default-adapter.js +187 -0
- package/dist/seal/default-adapter.js.map +1 -0
- package/dist/seal/identity.d.ts +31 -0
- package/dist/seal/identity.d.ts.map +1 -0
- package/dist/seal/identity.js +79 -0
- package/dist/seal/identity.js.map +1 -0
- package/dist/seal/index.d.ts +8 -0
- package/dist/seal/index.d.ts.map +1 -0
- package/dist/seal/index.js +7 -0
- package/dist/seal/index.js.map +1 -0
- package/dist/types.d.ts +160 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +33 -0
- package/dist/types.js.map +1 -0
- package/dist/wallets/adapter.d.ts +34 -0
- package/dist/wallets/adapter.d.ts.map +1 -0
- package/dist/wallets/adapter.js +6 -0
- package/dist/wallets/adapter.js.map +1 -0
- package/dist/wallets/index.d.ts +7 -0
- package/dist/wallets/index.d.ts.map +1 -0
- package/dist/wallets/index.js +6 -0
- package/dist/wallets/index.js.map +1 -0
- package/dist/wallets/keypair-adapter.d.ts +31 -0
- package/dist/wallets/keypair-adapter.d.ts.map +1 -0
- package/dist/wallets/keypair-adapter.js +210 -0
- package/dist/wallets/keypair-adapter.js.map +1 -0
- package/dist/wallets/wallet-standard-signer.d.ts +118 -0
- package/dist/wallets/wallet-standard-signer.d.ts.map +1 -0
- package/dist/wallets/wallet-standard-signer.js +207 -0
- package/dist/wallets/wallet-standard-signer.js.map +1 -0
- package/dist/walrus/adapter.d.ts +91 -0
- package/dist/walrus/adapter.d.ts.map +1 -0
- package/dist/walrus/adapter.js +11 -0
- package/dist/walrus/adapter.js.map +1 -0
- package/dist/walrus/default-adapter.d.ts +104 -0
- package/dist/walrus/default-adapter.d.ts.map +1 -0
- package/dist/walrus/default-adapter.js +146 -0
- package/dist/walrus/default-adapter.js.map +1 -0
- package/dist/walrus/default-read-adapter.d.ts +89 -0
- package/dist/walrus/default-read-adapter.d.ts.map +1 -0
- package/dist/walrus/default-read-adapter.js +81 -0
- package/dist/walrus/default-read-adapter.js.map +1 -0
- package/dist/walrus/http-aggregator-read-adapter.d.ts +107 -0
- package/dist/walrus/http-aggregator-read-adapter.d.ts.map +1 -0
- package/dist/walrus/http-aggregator-read-adapter.js +174 -0
- package/dist/walrus/http-aggregator-read-adapter.js.map +1 -0
- package/dist/walrus/http-publisher-write-adapter.d.ts +97 -0
- package/dist/walrus/http-publisher-write-adapter.d.ts.map +1 -0
- package/dist/walrus/http-publisher-write-adapter.js +249 -0
- package/dist/walrus/http-publisher-write-adapter.js.map +1 -0
- package/dist/walrus/index.d.ts +11 -0
- package/dist/walrus/index.d.ts.map +1 -0
- package/dist/walrus/index.js +11 -0
- package/dist/walrus/index.js.map +1 -0
- package/dist/walrus/quilt-patch-id.d.ts +34 -0
- package/dist/walrus/quilt-patch-id.d.ts.map +1 -0
- package/dist/walrus/quilt-patch-id.js +103 -0
- package/dist/walrus/quilt-patch-id.js.map +1 -0
- package/package.json +72 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read-side counterpart to `DefaultWalrusWriteAdapter`. Wraps
|
|
3
|
+
* `@mysten/walrus`'s read APIs (`readBlob`, `getBlobObject`, `getFiles`)
|
|
4
|
+
* behind an interface symmetric to the write adapter.
|
|
5
|
+
*
|
|
6
|
+
* Without this, browser dapps that need to fetch raw blob bytes (most
|
|
7
|
+
* commonly: encrypted-entry decryption flows that read ciphertext from
|
|
8
|
+
* Walrus before passing it to `seal.decrypt`) end up instantiating
|
|
9
|
+
* `WalrusClient` directly, defeating the adapter pattern.
|
|
10
|
+
*/
|
|
11
|
+
import { type WalrusClientConfig, type WalrusFile } from "@mysten/walrus";
|
|
12
|
+
import type { BlobObjectId, BlobRef, QuiltPatchId, WalrusBlobId } from "../types.js";
|
|
13
|
+
/** Optional knobs threaded through every read. */
|
|
14
|
+
export interface WalrusReadOptions {
|
|
15
|
+
readonly signal?: AbortSignal;
|
|
16
|
+
}
|
|
17
|
+
/** Read-only Walrus client, symmetric to `WalrusWriteAdapter`. */
|
|
18
|
+
export interface WalrusReadAdapter {
|
|
19
|
+
/**
|
|
20
|
+
* Read by Walrus content-addressed blob id (the 43-char URL-safe-base64
|
|
21
|
+
* identifier returned by `uploadBlob` / `uploadQuilt`). Cheapest path
|
|
22
|
+
* when you already have the content id from an upload result.
|
|
23
|
+
*/
|
|
24
|
+
readBlob(blobId: WalrusBlobId, options?: WalrusReadOptions): Promise<Uint8Array>;
|
|
25
|
+
/**
|
|
26
|
+
* Read by Sui object id of the on-chain `Blob` object. Resolves the
|
|
27
|
+
* object to its `blob_id` first, then reads. Use this when you have
|
|
28
|
+
* `Revision.blobRef.blobObjectId` from `reader.getEntry(...)` and need
|
|
29
|
+
* the bytes back (e.g. for decryption).
|
|
30
|
+
*
|
|
31
|
+
* `options.signal` cancels the underlying blob fetch but not the
|
|
32
|
+
* preceding `getBlobObject` resolution; @mysten/walrus does not accept
|
|
33
|
+
* a signal on the resolution call. Cancelling between resolve and read
|
|
34
|
+
* lets the bytes-fetch abort.
|
|
35
|
+
*/
|
|
36
|
+
readBlobByObjectId(blobObjectId: BlobObjectId, options?: WalrusReadOptions): Promise<Uint8Array>;
|
|
37
|
+
/**
|
|
38
|
+
* Read a single quilt patch by its 37-byte branded id. Use this when
|
|
39
|
+
* `BlobRef.kind === "quilt"`.
|
|
40
|
+
*
|
|
41
|
+
* `options.signal` is accepted for API symmetry with the other reads
|
|
42
|
+
* but is not forwarded: @mysten/walrus's `getFiles` and the resulting
|
|
43
|
+
* `WalrusFile.bytes()` do not accept signals at this version. Long-
|
|
44
|
+
* running quilt-patch fetches cannot currently be cancelled.
|
|
45
|
+
*/
|
|
46
|
+
readQuiltPatch(patchId: QuiltPatchId, options?: WalrusReadOptions): Promise<Uint8Array>;
|
|
47
|
+
/**
|
|
48
|
+
* Convenience: dispatch on the `BlobRef` discriminant and read the
|
|
49
|
+
* corresponding payload. Lets consumers do
|
|
50
|
+
* `await reader.readBlobRef(revision.blobRef)` without switching on
|
|
51
|
+
* `kind` themselves.
|
|
52
|
+
*/
|
|
53
|
+
readBlobRef(blobRef: BlobRef, options?: WalrusReadOptions): Promise<Uint8Array>;
|
|
54
|
+
}
|
|
55
|
+
/** Narrow structural slice of `WalrusClient` actually used by the read adapter. */
|
|
56
|
+
interface WalrusReadClient {
|
|
57
|
+
readBlob(args: {
|
|
58
|
+
blobId: string;
|
|
59
|
+
signal?: AbortSignal;
|
|
60
|
+
}): Promise<Uint8Array>;
|
|
61
|
+
getBlobObject(blobObjectId: string): Promise<{
|
|
62
|
+
id: string;
|
|
63
|
+
blob_id: string;
|
|
64
|
+
}>;
|
|
65
|
+
getFiles(args: {
|
|
66
|
+
ids: string[];
|
|
67
|
+
}): Promise<WalrusFile[]>;
|
|
68
|
+
}
|
|
69
|
+
interface DefaultWalrusReadAdapterOptions {
|
|
70
|
+
readonly client: WalrusReadClient;
|
|
71
|
+
}
|
|
72
|
+
/** Convenience options for `DefaultWalrusReadAdapter.fromConfig`. */
|
|
73
|
+
export type WalrusReadAdapterConfig = WalrusClientConfig;
|
|
74
|
+
/** `WalrusReadAdapter` backed by `@mysten/walrus`'s `WalrusClient`. */
|
|
75
|
+
export declare class DefaultWalrusReadAdapter implements WalrusReadAdapter {
|
|
76
|
+
private readonly client;
|
|
77
|
+
constructor(options: DefaultWalrusReadAdapterOptions);
|
|
78
|
+
/**
|
|
79
|
+
* Build an adapter from a `WalrusClientConfig`. Equivalent to
|
|
80
|
+
* constructing the `WalrusClient` yourself and passing it in.
|
|
81
|
+
*/
|
|
82
|
+
static fromConfig(config: WalrusReadAdapterConfig): DefaultWalrusReadAdapter;
|
|
83
|
+
readBlob(blobId: WalrusBlobId, options?: WalrusReadOptions): Promise<Uint8Array>;
|
|
84
|
+
readBlobByObjectId(blobObjectId: BlobObjectId, options?: WalrusReadOptions): Promise<Uint8Array>;
|
|
85
|
+
readQuiltPatch(patchId: QuiltPatchId, _options?: WalrusReadOptions): Promise<Uint8Array>;
|
|
86
|
+
readBlobRef(blobRef: BlobRef, options?: WalrusReadOptions): Promise<Uint8Array>;
|
|
87
|
+
}
|
|
88
|
+
export {};
|
|
89
|
+
//# sourceMappingURL=default-read-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-read-adapter.d.ts","sourceRoot":"","sources":["../../src/walrus/default-read-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAGN,KAAK,kBAAkB,EACvB,KAAK,UAAU,EAEf,MAAM,gBAAgB,CAAC;AAGxB,OAAO,KAAK,EACX,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,MAAM,aAAa,CAAC;AAGrB,kDAAkD;AAClD,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC9B;AAED,kEAAkE;AAClE,MAAM,WAAW,iBAAiB;IACjC;;;;OAIG;IACH,QAAQ,CACP,MAAM,EAAE,YAAY,EACpB,OAAO,CAAC,EAAE,iBAAiB,GACzB,OAAO,CAAC,UAAU,CAAC,CAAC;IAEvB;;;;;;;;;;OAUG;IACH,kBAAkB,CACjB,YAAY,EAAE,YAAY,EAC1B,OAAO,CAAC,EAAE,iBAAiB,GACzB,OAAO,CAAC,UAAU,CAAC,CAAC;IAEvB;;;;;;;;OAQG;IACH,cAAc,CACb,OAAO,EAAE,YAAY,EACrB,OAAO,CAAC,EAAE,iBAAiB,GACzB,OAAO,CAAC,UAAU,CAAC,CAAC;IAEvB;;;;;OAKG;IACH,WAAW,CACV,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,iBAAiB,GACzB,OAAO,CAAC,UAAU,CAAC,CAAC;CACvB;AAED,mFAAmF;AACnF,UAAU,gBAAgB;IACzB,QAAQ,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAC9E,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC;QAC5C,EAAE,EAAE,MAAM,CAAC;QACX,OAAO,EAAE,MAAM,CAAC;KAChB,CAAC,CAAC;IACH,QAAQ,CAAC,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;CACzD;AAED,UAAU,+BAA+B;IACxC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;CAClC;AAED,qEAAqE;AACrE,MAAM,MAAM,uBAAuB,GAAG,kBAAkB,CAAC;AAEzD,uEAAuE;AACvE,qBAAa,wBAAyB,YAAW,iBAAiB;IACjE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmB;gBAE9B,OAAO,EAAE,+BAA+B;IAIpD;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,uBAAuB,GAAG,wBAAwB;IAMtE,QAAQ,CACb,MAAM,EAAE,YAAY,EACpB,OAAO,GAAE,iBAAsB,GAC7B,OAAO,CAAC,UAAU,CAAC;IAShB,kBAAkB,CACvB,YAAY,EAAE,YAAY,EAC1B,OAAO,GAAE,iBAAsB,GAC7B,OAAO,CAAC,UAAU,CAAC;IAYhB,cAAc,CACnB,OAAO,EAAE,YAAY,EACrB,QAAQ,GAAE,iBAAsB,GAC9B,OAAO,CAAC,UAAU,CAAC;IAchB,WAAW,CAChB,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE,iBAAsB,GAC7B,OAAO,CAAC,UAAU,CAAC;CAMtB"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read-side counterpart to `DefaultWalrusWriteAdapter`. Wraps
|
|
3
|
+
* `@mysten/walrus`'s read APIs (`readBlob`, `getBlobObject`, `getFiles`)
|
|
4
|
+
* behind an interface symmetric to the write adapter.
|
|
5
|
+
*
|
|
6
|
+
* Without this, browser dapps that need to fetch raw blob bytes (most
|
|
7
|
+
* commonly: encrypted-entry decryption flows that read ciphertext from
|
|
8
|
+
* Walrus before passing it to `seal.decrypt`) end up instantiating
|
|
9
|
+
* `WalrusClient` directly, defeating the adapter pattern.
|
|
10
|
+
*/
|
|
11
|
+
import { NoBlobMetadataReceivedError, WalrusClient, NotFoundError as WalrusNotFoundError, } from "@mysten/walrus";
|
|
12
|
+
import { NotFoundError, TransportError } from "../errors.js";
|
|
13
|
+
import { quiltPatchIdToString } from "./quilt-patch-id.js";
|
|
14
|
+
/** `WalrusReadAdapter` backed by `@mysten/walrus`'s `WalrusClient`. */
|
|
15
|
+
export class DefaultWalrusReadAdapter {
|
|
16
|
+
client;
|
|
17
|
+
constructor(options) {
|
|
18
|
+
this.client = options.client;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Build an adapter from a `WalrusClientConfig`. Equivalent to
|
|
22
|
+
* constructing the `WalrusClient` yourself and passing it in.
|
|
23
|
+
*/
|
|
24
|
+
static fromConfig(config) {
|
|
25
|
+
return new DefaultWalrusReadAdapter({
|
|
26
|
+
client: new WalrusClient(config),
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
async readBlob(blobId, options = {}) {
|
|
30
|
+
return runWalrusCall(() => this.client.readBlob({
|
|
31
|
+
blobId,
|
|
32
|
+
...(options.signal === undefined ? {} : { signal: options.signal }),
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
async readBlobByObjectId(blobObjectId, options = {}) {
|
|
36
|
+
const blob = await runWalrusCall(() => this.client.getBlobObject(blobObjectId));
|
|
37
|
+
return runWalrusCall(() => this.client.readBlob({
|
|
38
|
+
blobId: blob.blob_id,
|
|
39
|
+
...(options.signal === undefined ? {} : { signal: options.signal }),
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
async readQuiltPatch(patchId, _options = {}) {
|
|
43
|
+
const id = quiltPatchIdToString(patchId);
|
|
44
|
+
const files = await runWalrusCall(() => this.client.getFiles({ ids: [id] }));
|
|
45
|
+
const file = files[0];
|
|
46
|
+
if (!file) {
|
|
47
|
+
throw new TransportError(`Walrus getFiles returned no entry for quilt patch ${id}`);
|
|
48
|
+
}
|
|
49
|
+
return runWalrusCall(() => file.bytes());
|
|
50
|
+
}
|
|
51
|
+
async readBlobRef(blobRef, options = {}) {
|
|
52
|
+
if (blobRef.kind === "blob") {
|
|
53
|
+
return this.readBlobByObjectId(blobRef.blobObjectId, options);
|
|
54
|
+
}
|
|
55
|
+
return this.readQuiltPatch(blobRef.patchId, options);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async function runWalrusCall(call) {
|
|
59
|
+
try {
|
|
60
|
+
return await call();
|
|
61
|
+
}
|
|
62
|
+
catch (cause) {
|
|
63
|
+
if (cause instanceof TransportError || cause instanceof NotFoundError) {
|
|
64
|
+
throw cause;
|
|
65
|
+
}
|
|
66
|
+
if (cause instanceof WalrusNotFoundError ||
|
|
67
|
+
cause instanceof NoBlobMetadataReceivedError) {
|
|
68
|
+
throw new NotFoundError("blob", `Walrus blob: ${cause.message}`, {
|
|
69
|
+
cause,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
throw new TransportError(walrusErrorMessage(cause), { cause });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function walrusErrorMessage(cause) {
|
|
76
|
+
if (cause instanceof Error) {
|
|
77
|
+
return `Walrus read failed: ${cause.message}`;
|
|
78
|
+
}
|
|
79
|
+
return "Walrus read failed";
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=default-read-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-read-adapter.js","sourceRoot":"","sources":["../../src/walrus/default-read-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACN,2BAA2B,EAC3B,YAAY,EAGZ,aAAa,IAAI,mBAAmB,GACpC,MAAM,g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CAAC;QACD,MAAM,IAAI,cAAc,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAChE,CAAC;AACF,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAc;IACzC,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC5B,OAAO,uBAAuB,KAAK,CAAC,OAAO,EAAE,CAAC;IAC/C,CAAC;IACD,OAAO,oBAAoB,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `WalrusReadAdapter` that fetches blob bytes from a Walrus aggregator HTTP
|
|
3
|
+
* service instead of fanning out to ~30 storage nodes via `WalrusClient`.
|
|
4
|
+
*
|
|
5
|
+
* Why this exists: browser reads through `DefaultWalrusReadAdapter` hit the
|
|
6
|
+
* direct-protocol path, which fans out to every storage node in the
|
|
7
|
+
* committee. On testnet a subset of those nodes do not ship CORS headers,
|
|
8
|
+
* so browser fetches frequently fail with `NoBlobMetadataReceivedError`
|
|
9
|
+
* even when the blob is healthy. CLI smokes against the same blob succeed
|
|
10
|
+
* because the CLI does not enforce CORS. The aggregator HTTP service is a
|
|
11
|
+
* Walrus-operator-run wrapper that internally does the shard math and
|
|
12
|
+
* exposes a single CORS-friendly endpoint.
|
|
13
|
+
*
|
|
14
|
+
* Trust model: the aggregator returns whatever bytes it serves. The
|
|
15
|
+
* trustless guarantee of fanout-and-reconstruct is replaced with trust in
|
|
16
|
+
* the operator. Most consumers running a known Mysten / Nami / community
|
|
17
|
+
* aggregator are fine with this; consumers who need stronger guarantees
|
|
18
|
+
* should keep `DefaultWalrusReadAdapter`. A future `verifyContentHash`
|
|
19
|
+
* option is planned for v0.2.0 to recompute the blobId from returned bytes
|
|
20
|
+
* and assert it matches.
|
|
21
|
+
*
|
|
22
|
+
* On-chain Sui object lookups (resolving `blobObjectId` to its `blob_id`)
|
|
23
|
+
* still go through the supplied `ObjectReader` (gRPC). The HTTP path only
|
|
24
|
+
* substitutes the bytes-fetch step.
|
|
25
|
+
*/
|
|
26
|
+
import type { ObjectReader } from "../clients.js";
|
|
27
|
+
import type { NetworkConfig } from "../config.js";
|
|
28
|
+
import type { BlobObjectId, BlobRef, QuiltPatchId, WalrusBlobId } from "../types.js";
|
|
29
|
+
import type { WalrusReadAdapter, WalrusReadOptions } from "./default-read-adapter.js";
|
|
30
|
+
/** Minimal `fetch` shape the adapter calls; `globalThis.fetch` satisfies it. */
|
|
31
|
+
type FetchLike = (input: string, init?: {
|
|
32
|
+
signal?: AbortSignal;
|
|
33
|
+
headers?: HeadersInit;
|
|
34
|
+
}) => Promise<{
|
|
35
|
+
ok: boolean;
|
|
36
|
+
status: number;
|
|
37
|
+
statusText: string;
|
|
38
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
39
|
+
}>;
|
|
40
|
+
/**
|
|
41
|
+
* Optional integrity check on blob bytes received from the aggregator. The
|
|
42
|
+
* callback is invoked with the bytes and the expected `blobId` after every
|
|
43
|
+
* successful blob fetch (`readBlob` and `readBlobByObjectId`). It must
|
|
44
|
+
* throw on a mismatch; the adapter rewraps the throw as a `TransportError`
|
|
45
|
+
* so consumers narrow on the SDK's error taxonomy.
|
|
46
|
+
*
|
|
47
|
+
* Why a callback: Walrus's `blobId` is derived from the encoded blob (Reed-
|
|
48
|
+
* Solomon slivers, root hash), not a simple `blake2b256(bytes)`. Computing
|
|
49
|
+
* the canonical blobId from raw bytes requires `WalrusClient.computeBlobMetadata`
|
|
50
|
+
* with the committee's `numShards`. The SDK keeps this as a callback rather
|
|
51
|
+
* than a built-in option to avoid coupling the lightweight HTTP adapter to
|
|
52
|
+
* a `WalrusClient` instance and its `numShards` lookup.
|
|
53
|
+
*
|
|
54
|
+
* Quilt patches are not verified: `readQuiltPatch` returns a sub-range of
|
|
55
|
+
* a parent blob, and per-patch hashes are not part of the canonical
|
|
56
|
+
* patch-id derivation at this version of Walrus.
|
|
57
|
+
*/
|
|
58
|
+
export type WalrusBlobIntegrityCheck = (bytes: Uint8Array, expectedBlobId: WalrusBlobId) => Promise<void>;
|
|
59
|
+
/** Construction options for `HttpAggregatorReadAdapter`. */
|
|
60
|
+
export interface HttpAggregatorReadAdapterOptions {
|
|
61
|
+
/** Aggregator base URL, e.g. `"https://aggregator.walrus-testnet.walrus.space"`. No trailing slash. */
|
|
62
|
+
readonly aggregatorUrl: string;
|
|
63
|
+
/** Sui RPC client used to resolve `blobObjectId` to `blob_id` for `readBlobByObjectId`. */
|
|
64
|
+
readonly suiClient: ObjectReader;
|
|
65
|
+
/** Optional per-request HTTP headers (auth tokens, custom origin labels). */
|
|
66
|
+
readonly headers?: HeadersInit;
|
|
67
|
+
/** Override `fetch` for testing; defaults to `globalThis.fetch`. */
|
|
68
|
+
readonly fetch?: FetchLike;
|
|
69
|
+
/**
|
|
70
|
+
* Optional trust-but-verify callback. When supplied, blob fetches verify
|
|
71
|
+
* the returned bytes match the expected `blobId` before resolving. Wire
|
|
72
|
+
* this to `WalrusClient.computeBlobMetadata({ bytes, numShards }).blobId`
|
|
73
|
+
* if you want the canonical Walrus derivation; or implement a custom
|
|
74
|
+
* application-level check.
|
|
75
|
+
*/
|
|
76
|
+
readonly verifyBlobIntegrity?: WalrusBlobIntegrityCheck;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* `WalrusReadAdapter` backed by a Walrus aggregator HTTP service.
|
|
80
|
+
* Substitutes one CORS-friendly server for the direct-protocol fanout that
|
|
81
|
+
* misbehaves on testnet from browsers. Trade trustless reads for operator
|
|
82
|
+
* trust; pick `DefaultWalrusReadAdapter` if you need the former.
|
|
83
|
+
*/
|
|
84
|
+
export declare class HttpAggregatorReadAdapter implements WalrusReadAdapter {
|
|
85
|
+
#private;
|
|
86
|
+
constructor(options: HttpAggregatorReadAdapterOptions);
|
|
87
|
+
/** Mirror `DefaultWalrusReadAdapter.fromConfig` for symmetry. */
|
|
88
|
+
static fromConfig(options: HttpAggregatorReadAdapterOptions): HttpAggregatorReadAdapter;
|
|
89
|
+
/**
|
|
90
|
+
* Construct against `morseConfig.walrusEndpoints.aggregator` (the canonical
|
|
91
|
+
* Mysten-run aggregator for the network). Pass `verifyBlobIntegrity` or
|
|
92
|
+
* `headers` here if you want them; everything else is inferred.
|
|
93
|
+
*
|
|
94
|
+
* @throws {ConfigurationError} If the network has no canonical aggregator
|
|
95
|
+
* URL (e.g. mainnet pre-freeze, or a custom-deployment config without
|
|
96
|
+
* `walrusEndpoints.aggregator` supplied).
|
|
97
|
+
*/
|
|
98
|
+
static fromMorseConfig(morseConfig: Pick<NetworkConfig, "walrusEndpoints">, suiClient: ObjectReader, extras?: Pick<HttpAggregatorReadAdapterOptions, "headers" | "fetch" | "verifyBlobIntegrity">): HttpAggregatorReadAdapter;
|
|
99
|
+
readBlob(blobId: WalrusBlobId, options?: WalrusReadOptions): Promise<Uint8Array>;
|
|
100
|
+
readBlobByObjectId(blobObjectId: BlobObjectId, options?: WalrusReadOptions): Promise<Uint8Array>;
|
|
101
|
+
readQuiltPatch(patchId: QuiltPatchId, options?: WalrusReadOptions): Promise<Uint8Array>;
|
|
102
|
+
readBlobRef(blobRef: BlobRef, options?: WalrusReadOptions): Promise<Uint8Array>;
|
|
103
|
+
private fetchBytes;
|
|
104
|
+
private resolveBlobIdFromObject;
|
|
105
|
+
}
|
|
106
|
+
export {};
|
|
107
|
+
//# sourceMappingURL=http-aggregator-read-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-aggregator-read-adapter.d.ts","sourceRoot":"","sources":["../../src/walrus/http-aggregator-read-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAOlD,OAAO,KAAK,EACX,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,MA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ACvB,MAAM,CAAC,EAAE,IAAI,CACZ,gCAAgC,EAChC,SAAS,GAAG,OAAO,GAAG,qBAAqB,CAC3C,GACC,yBAAyB;IAkBtB,QAAQ,CACb,MAAM,EAAE,YAAY,EACpB,OAAO,GAAE,iBAAsB,GAC7B,OAAO,CAAC,UAAU,CAAC;IAgBhB,kBAAkB,CACvB,YAAY,EAAE,YAAY,EAC1B,OAAO,GAAE,iBAAsB,GAC7B,OAAO,CAAC,UAAU,CAAC;IAQhB,cAAc,CACnB,OAAO,EAAE,YAAY,EACrB,OAAO,GAAE,iBAAsB,GAC7B,OAAO,CAAC,UAAU,CAAC;IAMhB,WAAW,CAChB,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE,iBAAsB,GAC7B,OAAO,CAAC,UAAU,CAAC;YAOR,UAAU;YA2CV,uBAAuB;CAmDrC"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `WalrusReadAdapter` that fetches blob bytes from a Walrus aggregator HTTP
|
|
3
|
+
* service instead of fanning out to ~30 storage nodes via `WalrusClient`.
|
|
4
|
+
*
|
|
5
|
+
* Why this exists: browser reads through `DefaultWalrusReadAdapter` hit the
|
|
6
|
+
* direct-protocol path, which fans out to every storage node in the
|
|
7
|
+
* committee. On testnet a subset of those nodes do not ship CORS headers,
|
|
8
|
+
* so browser fetches frequently fail with `NoBlobMetadataReceivedError`
|
|
9
|
+
* even when the blob is healthy. CLI smokes against the same blob succeed
|
|
10
|
+
* because the CLI does not enforce CORS. The aggregator HTTP service is a
|
|
11
|
+
* Walrus-operator-run wrapper that internally does the shard math and
|
|
12
|
+
* exposes a single CORS-friendly endpoint.
|
|
13
|
+
*
|
|
14
|
+
* Trust model: the aggregator returns whatever bytes it serves. The
|
|
15
|
+
* trustless guarantee of fanout-and-reconstruct is replaced with trust in
|
|
16
|
+
* the operator. Most consumers running a known Mysten / Nami / community
|
|
17
|
+
* aggregator are fine with this; consumers who need stronger guarantees
|
|
18
|
+
* should keep `DefaultWalrusReadAdapter`. A future `verifyContentHash`
|
|
19
|
+
* option is planned for v0.2.0 to recompute the blobId from returned bytes
|
|
20
|
+
* and assert it matches.
|
|
21
|
+
*
|
|
22
|
+
* On-chain Sui object lookups (resolving `blobObjectId` to its `blob_id`)
|
|
23
|
+
* still go through the supplied `ObjectReader` (gRPC). The HTTP path only
|
|
24
|
+
* substitutes the bytes-fetch step.
|
|
25
|
+
*/
|
|
26
|
+
import { blobIdFromInt } from "@mysten/walrus";
|
|
27
|
+
import { toWalrusBlobId } from "../codecs.js";
|
|
28
|
+
import { ConfigurationError, NotFoundError, TransportError, ValidationError, } from "../errors.js";
|
|
29
|
+
import { quiltPatchIdToString } from "./quilt-patch-id.js";
|
|
30
|
+
/**
|
|
31
|
+
* `WalrusReadAdapter` backed by a Walrus aggregator HTTP service.
|
|
32
|
+
* Substitutes one CORS-friendly server for the direct-protocol fanout that
|
|
33
|
+
* misbehaves on testnet from browsers. Trade trustless reads for operator
|
|
34
|
+
* trust; pick `DefaultWalrusReadAdapter` if you need the former.
|
|
35
|
+
*/
|
|
36
|
+
export class HttpAggregatorReadAdapter {
|
|
37
|
+
#aggregatorUrl;
|
|
38
|
+
#suiClient;
|
|
39
|
+
#headers;
|
|
40
|
+
#fetch;
|
|
41
|
+
#verifyBlobIntegrity;
|
|
42
|
+
constructor(options) {
|
|
43
|
+
this.#aggregatorUrl = options.aggregatorUrl.replace(/\/+$/, "");
|
|
44
|
+
this.#suiClient = options.suiClient;
|
|
45
|
+
if (options.headers !== undefined)
|
|
46
|
+
this.#headers = options.headers;
|
|
47
|
+
// Browsers enforce that `window.fetch` is called with `window` as its
|
|
48
|
+
// receiver (WebIDL HostObject check); storing `globalThis.fetch` on
|
|
49
|
+
// the instance and calling it as `this.#fetch(...)` later throws
|
|
50
|
+
// `TypeError: Illegal invocation`. Bind to `globalThis` so the call
|
|
51
|
+
// receiver is correct in browsers.
|
|
52
|
+
this.#fetch =
|
|
53
|
+
options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
54
|
+
if (options.verifyBlobIntegrity !== undefined) {
|
|
55
|
+
this.#verifyBlobIntegrity = options.verifyBlobIntegrity;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/** Mirror `DefaultWalrusReadAdapter.fromConfig` for symmetry. */
|
|
59
|
+
static fromConfig(options) {
|
|
60
|
+
return new HttpAggregatorReadAdapter(options);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Construct against `morseConfig.walrusEndpoints.aggregator` (the canonical
|
|
64
|
+
* Mysten-run aggregator for the network). Pass `verifyBlobIntegrity` or
|
|
65
|
+
* `headers` here if you want them; everything else is inferred.
|
|
66
|
+
*
|
|
67
|
+
* @throws {ConfigurationError} If the network has no canonical aggregator
|
|
68
|
+
* URL (e.g. mainnet pre-freeze, or a custom-deployment config without
|
|
69
|
+
* `walrusEndpoints.aggregator` supplied).
|
|
70
|
+
*/
|
|
71
|
+
static fromMorseConfig(morseConfig, suiClient, extras) {
|
|
72
|
+
const url = morseConfig.walrusEndpoints?.aggregator ?? "";
|
|
73
|
+
if (url.length === 0) {
|
|
74
|
+
throw new ConfigurationError("morseConfig.walrusEndpoints.aggregator is empty. Pass an aggregator URL explicitly to HttpAggregatorReadAdapter.fromConfig({ aggregatorUrl, suiClient }), or use a network where the endpoint is pinned (testnet).");
|
|
75
|
+
}
|
|
76
|
+
return new HttpAggregatorReadAdapter({
|
|
77
|
+
aggregatorUrl: url,
|
|
78
|
+
suiClient,
|
|
79
|
+
...(extras?.headers === undefined ? {} : { headers: extras.headers }),
|
|
80
|
+
...(extras?.fetch === undefined ? {} : { fetch: extras.fetch }),
|
|
81
|
+
...(extras?.verifyBlobIntegrity === undefined
|
|
82
|
+
? {}
|
|
83
|
+
: { verifyBlobIntegrity: extras.verifyBlobIntegrity }),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
async readBlob(blobId, options = {}) {
|
|
87
|
+
const url = `${this.#aggregatorUrl}/v1/blobs/${encodeURIComponent(blobId)}`;
|
|
88
|
+
const bytes = await this.fetchBytes(url, "blob", blobId, options.signal);
|
|
89
|
+
if (this.#verifyBlobIntegrity !== undefined) {
|
|
90
|
+
try {
|
|
91
|
+
await this.#verifyBlobIntegrity(bytes, blobId);
|
|
92
|
+
}
|
|
93
|
+
catch (cause) {
|
|
94
|
+
throw new TransportError(`Walrus aggregator returned bytes that fail blob-integrity check for ${blobId}: ${cause instanceof Error ? cause.message : String(cause)}`, { cause });
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return bytes;
|
|
98
|
+
}
|
|
99
|
+
async readBlobByObjectId(blobObjectId, options = {}) {
|
|
100
|
+
const blobId = await this.resolveBlobIdFromObject(blobObjectId, options.signal);
|
|
101
|
+
return this.readBlob(blobId, options);
|
|
102
|
+
}
|
|
103
|
+
async readQuiltPatch(patchId, options = {}) {
|
|
104
|
+
const id = quiltPatchIdToString(patchId);
|
|
105
|
+
const url = `${this.#aggregatorUrl}/v1/blobs/by-quilt-patch-id/${encodeURIComponent(id)}`;
|
|
106
|
+
return this.fetchBytes(url, "quilt patch", id, options.signal);
|
|
107
|
+
}
|
|
108
|
+
async readBlobRef(blobRef, options = {}) {
|
|
109
|
+
if (blobRef.kind === "blob") {
|
|
110
|
+
return this.readBlobByObjectId(blobRef.blobObjectId, options);
|
|
111
|
+
}
|
|
112
|
+
return this.readQuiltPatch(blobRef.patchId, options);
|
|
113
|
+
}
|
|
114
|
+
async fetchBytes(url, kind, identifier, signal) {
|
|
115
|
+
let response;
|
|
116
|
+
try {
|
|
117
|
+
response = await this.#fetch(url, {
|
|
118
|
+
...(signal === undefined ? {} : { signal }),
|
|
119
|
+
...(this.#headers === undefined ? {} : { headers: this.#headers }),
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
catch (cause) {
|
|
123
|
+
throw new TransportError(`Walrus aggregator request failed: ${cause instanceof Error ? cause.message : String(cause)}`, { cause });
|
|
124
|
+
}
|
|
125
|
+
if (response.status === 404) {
|
|
126
|
+
throw new NotFoundError("blob", `Walrus aggregator: ${kind} ${identifier} not found`, { cause: new Error(`HTTP ${response.status} ${response.statusText}`) });
|
|
127
|
+
}
|
|
128
|
+
if (!response.ok) {
|
|
129
|
+
throw new TransportError(`Walrus aggregator returned HTTP ${response.status} ${response.statusText} for ${kind} ${identifier}`);
|
|
130
|
+
}
|
|
131
|
+
try {
|
|
132
|
+
const buffer = await response.arrayBuffer();
|
|
133
|
+
return new Uint8Array(buffer);
|
|
134
|
+
}
|
|
135
|
+
catch (cause) {
|
|
136
|
+
throw new TransportError(`Walrus aggregator response body could not be read: ${cause instanceof Error ? cause.message : String(cause)}`, { cause });
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
async resolveBlobIdFromObject(blobObjectId, signal) {
|
|
140
|
+
let response;
|
|
141
|
+
try {
|
|
142
|
+
response = await this.#suiClient.getObject({
|
|
143
|
+
objectId: blobObjectId,
|
|
144
|
+
include: { json: true },
|
|
145
|
+
...(signal === undefined ? {} : { signal }),
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
catch (cause) {
|
|
149
|
+
throw new TransportError(`Sui getObject failed for blob ${blobObjectId}: ${cause instanceof Error ? cause.message : String(cause)}`, { cause });
|
|
150
|
+
}
|
|
151
|
+
const object = response.object;
|
|
152
|
+
if (object === undefined || object === null) {
|
|
153
|
+
throw new NotFoundError("blob", `Walrus blob object not found on-chain: ${blobObjectId}`);
|
|
154
|
+
}
|
|
155
|
+
const json = object.json;
|
|
156
|
+
if (json === null || typeof json !== "object") {
|
|
157
|
+
throw new ValidationError(`Walrus blob object ${blobObjectId} has no parsed JSON content`, "blob.json");
|
|
158
|
+
}
|
|
159
|
+
const blobIdRaw = json.blob_id;
|
|
160
|
+
if (typeof blobIdRaw !== "string" && typeof blobIdRaw !== "number") {
|
|
161
|
+
throw new ValidationError(`Walrus blob object ${blobObjectId} has no string blob_id field; got ${typeof blobIdRaw}`, "blob.blob_id");
|
|
162
|
+
}
|
|
163
|
+
// Move `u256` BCS-decodes to a decimal string in Sui RPC json mode;
|
|
164
|
+
// `blobIdFromInt` converts it to the URL-safe-base64 form aggregators expect.
|
|
165
|
+
try {
|
|
166
|
+
const asBigInt = BigInt(blobIdRaw);
|
|
167
|
+
return toWalrusBlobId(blobIdFromInt(asBigInt));
|
|
168
|
+
}
|
|
169
|
+
catch (cause) {
|
|
170
|
+
throw new ValidationError(`Walrus blob_id u256 could not be converted to base64: ${cause instanceof Error ? cause.message : String(cause)}`, "blob.blob_id", { cause });
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=http-aggregator-read-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-aggregator-read-adapter.js","sourceRoot":"","sources":["../../src/walrus/http-aggregator-read-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG/C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EACN,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,eAAe,GACf,MAAM,cAAc,CAAC;AAWtB,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAwD3D;;;;;GAKG;AACH,MAAM,OAAO,yBAAyB;IAC5B,cAAc,CAAS;IACvB,UAAU,CAAe;IACzB,QAAQ,CAAe;IACvB,MAAM,CAAY;IAClB,oBAAoB,CAA4B;IAEzD,YAAY,OAAyC;QACpD,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAChE,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC;QACpC,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS;YAAE,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,OAAO,CAA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M,CAAC;QAC/B,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YAC7C,MAAM,IAAI,aAAa,CACtB,MAAM,EACN,0CAA0C,YAAY,EAAE,CACxD,CAAC;QACH,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACzB,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC/C,MAAM,IAAI,eAAe,CACxB,sBAAsB,YAAY,6BAA6B,EAC/D,WAAW,CACX,CAAC;QACH,CAAC;QACD,MAAM,SAAS,GAAI,IAA8B,CAAC,OAAO,CAAC;QAC1D,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;YACpE,MAAM,IAAI,eAAe,CACxB,sBAAsB,YAAY,qCAAqC,OAAO,SAAS,EAAE,EACzF,cAAc,CACd,CAAC;QACH,CAAC;QACD,oEAAoE;QACpE,8EAA8E;QAC9E,IAAI,CAAC;YACJ,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;YACnC,OAAO,cAAc,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;QAChD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,eAAe,CACxB,yDAAyD,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EACjH,cAAc,EACd,EAAE,KAAK,EAAE,CACT,CAAC;QACH,CAAC;IACF,CAAC;CACD"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `WalrusWriteAdapter` that uploads through a Walrus publisher HTTP service
|
|
3
|
+
* instead of fanning out to ~30 storage nodes via `WalrusClient`. The
|
|
4
|
+
* publisher (an operator-run service) pays the WAL storage deposit and
|
|
5
|
+
* handles `register_blob` + `certify_blob` server-side; the consumer's
|
|
6
|
+
* wallet only signs the downstream `add_entry_to_collection` (1 popup).
|
|
7
|
+
*
|
|
8
|
+
* Trade-offs vs `DefaultWalrusWriteAdapter`:
|
|
9
|
+
* - 1 wallet popup vs 2 (the publisher absorbs register + certify).
|
|
10
|
+
* - Operator-paid storage vs consumer-paid storage. Consumers using a
|
|
11
|
+
* paid publisher tier sign whatever auth the publisher requires via
|
|
12
|
+
* the `headers` option.
|
|
13
|
+
* - The publisher returns the blob object owned by `ownerAddress` (via
|
|
14
|
+
* `send_object_to`), which the consumer then references in
|
|
15
|
+
* `addEntry`.
|
|
16
|
+
*
|
|
17
|
+
* NOT compatible with `addEntryFromBytes` / `addEncryptedEntryFromBytes`,
|
|
18
|
+
* which require `WalrusFlowCapable` for the 2-popup combined PTB. The
|
|
19
|
+
* publisher-paid path is naturally a 1-popup path through the standard
|
|
20
|
+
* `uploadBlob` + `addEntry` composition; the from-bytes optimization
|
|
21
|
+
* isn't needed because there's no certify popup to combine.
|
|
22
|
+
*/
|
|
23
|
+
import type { BlobObjectId, SuiAddress, WalrusBlobId } from "../types.js";
|
|
24
|
+
import type { QuiltPatchInput, UploadBlobOptions, UploadBlobResult, UploadQuiltOptions, UploadQuiltResult, WalrusWriteAdapter } from "./adapter.js";
|
|
25
|
+
/** Minimal `fetch` shape the adapter calls; `globalThis.fetch` satisfies it. */
|
|
26
|
+
type FetchLike = (input: string, init?: {
|
|
27
|
+
method?: string;
|
|
28
|
+
body?: BodyInit;
|
|
29
|
+
headers?: HeadersInit;
|
|
30
|
+
signal?: AbortSignal;
|
|
31
|
+
}) => Promise<{
|
|
32
|
+
ok: boolean;
|
|
33
|
+
status: number;
|
|
34
|
+
statusText: string;
|
|
35
|
+
text(): Promise<string>;
|
|
36
|
+
json(): Promise<unknown>;
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* Custom response parser for non-standard publishers. Receives the raw
|
|
40
|
+
* decoded JSON from `PUT /v1/blobs` (or the inner `blobStoreResult` field
|
|
41
|
+
* on the quilt endpoint) and returns the parsed `UploadBlobResult`.
|
|
42
|
+
*
|
|
43
|
+
* Throw `ValidationError` for malformed shapes; throw `TransportError` for
|
|
44
|
+
* content-level publisher errors that the consumer should surface (e.g.
|
|
45
|
+
* `markedInvalid`, `alreadyCertified` without an owned object). Throws
|
|
46
|
+
* propagate verbatim so the consumer's typed errors reach the caller of
|
|
47
|
+
* `uploadBlob` / `uploadQuilt` unchanged.
|
|
48
|
+
*
|
|
49
|
+
* Use this when a fork of the Walrus publisher serves a response shape
|
|
50
|
+
* that the built-in parser does not recognize (the built-in handles
|
|
51
|
+
* Mysten's published binary, which serves camelCase, with a snake_case
|
|
52
|
+
* fallback for the documented schema). Most consumers do not need to set
|
|
53
|
+
* this.
|
|
54
|
+
*/
|
|
55
|
+
export type ParsePublisherResponse = (raw: unknown) => UploadBlobResult | Promise<UploadBlobResult>;
|
|
56
|
+
/** Construction options for `HttpPublisherWriteAdapter`. */
|
|
57
|
+
export interface HttpPublisherWriteAdapterOptions {
|
|
58
|
+
/** Publisher base URL, e.g. `"https://walrus-testnet-publisher.nami.cloud"`. No trailing slash. */
|
|
59
|
+
readonly publisherUrl: string;
|
|
60
|
+
/**
|
|
61
|
+
* Address that will own the resulting Sui blob object. The publisher
|
|
62
|
+
* sends the newly-created `Blob` to this address via `send_object_to`
|
|
63
|
+
* so the consumer's `addEntry` can reference it. Typically the
|
|
64
|
+
* connected wallet's address.
|
|
65
|
+
*/
|
|
66
|
+
readonly ownerAddress: SuiAddress;
|
|
67
|
+
/** Optional per-request HTTP headers (auth tokens, bearer keys, custom origin labels). */
|
|
68
|
+
readonly headers?: HeadersInit;
|
|
69
|
+
/** Override `fetch` for testing; defaults to `globalThis.fetch`. */
|
|
70
|
+
readonly fetch?: FetchLike;
|
|
71
|
+
/**
|
|
72
|
+
* Optional response-shape escape hatch for non-standard publishers. When
|
|
73
|
+
* supplied, replaces the built-in parser. See `ParsePublisherResponse`
|
|
74
|
+
* for the contract. Most consumers should leave this undefined.
|
|
75
|
+
*/
|
|
76
|
+
readonly parseResponse?: ParsePublisherResponse;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* `WalrusWriteAdapter` backed by a Walrus publisher HTTP service. Substitutes
|
|
80
|
+
* an operator-run upload service for the direct-protocol shard fanout.
|
|
81
|
+
* Useful for browser dapps that want a "publisher pays storage" onboarding
|
|
82
|
+
* path (1 wallet popup total) and/or CORS-friendly uploads from environments
|
|
83
|
+
* that block direct storage-node fanout.
|
|
84
|
+
*/
|
|
85
|
+
export declare class HttpPublisherWriteAdapter implements WalrusWriteAdapter {
|
|
86
|
+
#private;
|
|
87
|
+
constructor(options: HttpPublisherWriteAdapterOptions);
|
|
88
|
+
/** Mirror `DefaultWalrusWriteAdapter.fromConfig` for symmetry. */
|
|
89
|
+
static fromConfig(options: HttpPublisherWriteAdapterOptions): HttpPublisherWriteAdapter;
|
|
90
|
+
uploadBlob(data: Uint8Array, options: UploadBlobOptions): Promise<UploadBlobResult>;
|
|
91
|
+
uploadQuilt(patches: readonly QuiltPatchInput[], options: UploadQuiltOptions): Promise<UploadQuiltResult>;
|
|
92
|
+
private buildBlobUrl;
|
|
93
|
+
private buildQuiltUrl;
|
|
94
|
+
private putRequest;
|
|
95
|
+
}
|
|
96
|
+
export type { BlobObjectId, WalrusBlobId };
|
|
97
|
+
//# sourceMappingURL=http-publisher-write-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-publisher-write-adapter.d.ts","sourceRoot":"","sources":["../../src/walrus/http-publisher-write-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,KAAK,EACX,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAElB,iBAAiB,EACjB,kBA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