@arcadiasystems/morse-sdk 0.1.4 → 0.2.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 +79 -0
- package/README.md +14 -2
- package/dist/codecs.d.ts +7 -1
- package/dist/codecs.d.ts.map +1 -1
- package/dist/codecs.js +12 -0
- package/dist/codecs.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +3 -1
- package/dist/config.js.map +1 -1
- package/dist/errors.d.ts +2 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.format.js +2 -0
- package/dist/errors.format.js.map +1 -1
- package/dist/errors.js +44 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/ops/allowlist.d.ts +79 -0
- package/dist/ops/allowlist.d.ts.map +1 -0
- package/dist/ops/allowlist.js +122 -0
- package/dist/ops/allowlist.js.map +1 -0
- package/dist/ops/file-from-bytes.d.ts +84 -0
- package/dist/ops/file-from-bytes.d.ts.map +1 -0
- package/dist/ops/file-from-bytes.js +133 -0
- package/dist/ops/file-from-bytes.js.map +1 -0
- package/dist/ops/file.d.ts +88 -0
- package/dist/ops/file.d.ts.map +1 -0
- package/dist/ops/file.js +142 -0
- package/dist/ops/file.js.map +1 -0
- package/dist/ops/index.d.ts +3 -0
- package/dist/ops/index.d.ts.map +1 -1
- package/dist/ops/index.js +3 -0
- package/dist/ops/index.js.map +1 -1
- package/dist/ptb/allowlist.d.ts +65 -0
- package/dist/ptb/allowlist.d.ts.map +1 -0
- package/dist/ptb/allowlist.js +75 -0
- package/dist/ptb/allowlist.js.map +1 -0
- package/dist/ptb/file.d.ts +58 -0
- package/dist/ptb/file.d.ts.map +1 -0
- package/dist/ptb/file.js +108 -0
- package/dist/ptb/file.js.map +1 -0
- package/dist/read/files-reader.d.ts +59 -0
- package/dist/read/files-reader.d.ts.map +1 -0
- package/dist/read/files-reader.js +247 -0
- package/dist/read/files-reader.js.map +1 -0
- package/dist/read/index.d.ts +1 -0
- package/dist/read/index.d.ts.map +1 -1
- package/dist/read/index.js +1 -0
- package/dist/read/index.js.map +1 -1
- package/dist/seal/adapter.d.ts +22 -1
- package/dist/seal/adapter.d.ts.map +1 -1
- package/dist/seal/allowlist-identity.d.ts +36 -0
- package/dist/seal/allowlist-identity.d.ts.map +1 -0
- package/dist/seal/allowlist-identity.js +81 -0
- package/dist/seal/allowlist-identity.js.map +1 -0
- package/dist/seal/default-adapter.d.ts +16 -1
- package/dist/seal/default-adapter.d.ts.map +1 -1
- package/dist/seal/default-adapter.js +56 -1
- package/dist/seal/default-adapter.js.map +1 -1
- package/dist/seal/index.d.ts +2 -1
- package/dist/seal/index.d.ts.map +1 -1
- package/dist/seal/index.js +1 -0
- package/dist/seal/index.js.map +1 -1
- package/dist/types.d.ts +40 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -1
- package/dist/wallets/keypair-adapter.d.ts.map +1 -1
- package/dist/wallets/keypair-adapter.js +2 -0
- package/dist/wallets/keypair-adapter.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* High-level allowlist ops: build a PTB, sign and execute via the wallet
|
|
3
|
+
* adapter, parse the receipt into a typed result.
|
|
4
|
+
*/
|
|
5
|
+
import { Transaction, } from "@mysten/sui/transactions";
|
|
6
|
+
import { toAllowlistCapId, toAllowlistId } from "../codecs.js";
|
|
7
|
+
import { ValidationError } from "../errors.js";
|
|
8
|
+
import { buildAddMember, buildDeleteAllowlist, buildNewAllowlist, buildRemoveMember, buildShareAllowlist, buildTransferAllowlistCap, } from "../ptb/allowlist.js";
|
|
9
|
+
import { findCreatedId } from "./internal.js";
|
|
10
|
+
const MAX_ALLOWLIST_NAME_LENGTH = 256;
|
|
11
|
+
/**
|
|
12
|
+
* Create an allowlist, share it, and transfer the admin Cap to `adapter.address`
|
|
13
|
+
* in one atomic PTB. The caller can immediately use the returned `capId`
|
|
14
|
+
* for member ops.
|
|
15
|
+
*
|
|
16
|
+
* @throws {ValidationError} If `name` is empty or exceeds 256 chars.
|
|
17
|
+
* @throws {ContractAbortError} On Move abort.
|
|
18
|
+
* @throws {TransportError} On RPC, network, or response-parsing failure.
|
|
19
|
+
*/
|
|
20
|
+
export async function createAllowlist(adapter, config, args) {
|
|
21
|
+
validateAllowlistName(args.name);
|
|
22
|
+
const tx = new Transaction();
|
|
23
|
+
const created = buildNewAllowlist(tx, {
|
|
24
|
+
packageId: config.packageId,
|
|
25
|
+
name: args.name,
|
|
26
|
+
});
|
|
27
|
+
const allowlistArg = created[0];
|
|
28
|
+
const capArg = created[1];
|
|
29
|
+
buildShareAllowlist(tx, {
|
|
30
|
+
packageId: config.packageId,
|
|
31
|
+
allowlist: allowlistArg,
|
|
32
|
+
});
|
|
33
|
+
buildTransferAllowlistCap(tx, {
|
|
34
|
+
packageId: config.packageId,
|
|
35
|
+
cap: capArg,
|
|
36
|
+
recipient: adapter.address,
|
|
37
|
+
});
|
|
38
|
+
const receipt = await adapter.signAndExecuteTransaction(tx, args.signal);
|
|
39
|
+
// Sui types are identified by the package id where the type was DEFINED.
|
|
40
|
+
// allowlist::Allowlist was introduced in the v2 upgrade, so its type
|
|
41
|
+
// identity is rooted at config.packageId (v2 published-at), not at
|
|
42
|
+
// originalPackageId (v1 genesis, used by publication / collection / entry).
|
|
43
|
+
const typePrefix = config.packageId;
|
|
44
|
+
return {
|
|
45
|
+
digest: receipt.digest,
|
|
46
|
+
gasUsedMist: receipt.gasUsedMist,
|
|
47
|
+
allowlistId: toAllowlistId(findCreatedId(receipt, `${typePrefix}::allowlist::Allowlist`)),
|
|
48
|
+
capId: toAllowlistCapId(findCreatedId(receipt, `${typePrefix}::allowlist::Cap`)),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Add an address to the allowlist. Idempotent: adding an existing member
|
|
53
|
+
* aborts with `EMemberAlreadyPresent`.
|
|
54
|
+
*
|
|
55
|
+
* @throws {ContractAbortError} On Move abort (wrong cap, duplicate member).
|
|
56
|
+
* @throws {TransportError} On RPC, network, or response-parsing failure.
|
|
57
|
+
*/
|
|
58
|
+
export async function addMember(adapter, config, args) {
|
|
59
|
+
const tx = new Transaction();
|
|
60
|
+
buildAddMember(tx, {
|
|
61
|
+
packageId: config.packageId,
|
|
62
|
+
allowlistId: args.allowlistId,
|
|
63
|
+
capId: args.capId,
|
|
64
|
+
member: args.member,
|
|
65
|
+
});
|
|
66
|
+
const receipt = await adapter.signAndExecuteTransaction(tx, args.signal);
|
|
67
|
+
return { digest: receipt.digest, gasUsedMist: receipt.gasUsedMist };
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Remove an address from the allowlist. Aborts with `EMemberNotPresent` if
|
|
71
|
+
* the address is not a member.
|
|
72
|
+
*/
|
|
73
|
+
export async function removeMember(adapter, config, args) {
|
|
74
|
+
const tx = new Transaction();
|
|
75
|
+
buildRemoveMember(tx, {
|
|
76
|
+
packageId: config.packageId,
|
|
77
|
+
allowlistId: args.allowlistId,
|
|
78
|
+
capId: args.capId,
|
|
79
|
+
member: args.member,
|
|
80
|
+
});
|
|
81
|
+
const receipt = await adapter.signAndExecuteTransaction(tx, args.signal);
|
|
82
|
+
return { digest: receipt.digest, gasUsedMist: receipt.gasUsedMist };
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Transfer the admin Cap to a new address. The new holder gains full admin
|
|
86
|
+
* rights; the previous holder loses them.
|
|
87
|
+
*/
|
|
88
|
+
export async function transferAllowlistCap(adapter, config, args) {
|
|
89
|
+
const tx = new Transaction();
|
|
90
|
+
buildTransferAllowlistCap(tx, {
|
|
91
|
+
packageId: config.packageId,
|
|
92
|
+
cap: args.capId,
|
|
93
|
+
recipient: args.recipient,
|
|
94
|
+
});
|
|
95
|
+
const receipt = await adapter.signAndExecuteTransaction(tx, args.signal);
|
|
96
|
+
return { digest: receipt.digest, gasUsedMist: receipt.gasUsedMist };
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Delete an allowlist. Any `EncryptedFile` still referencing this allowlist
|
|
100
|
+
* becomes unusable for decryption (`seal_approve` dry-run will fail with
|
|
101
|
+
* `ESealInvalidId` because the allowlist object no longer exists). Delete
|
|
102
|
+
* dependent files first or migrate them before deleting the allowlist.
|
|
103
|
+
*/
|
|
104
|
+
export async function deleteAllowlist(adapter, config, args) {
|
|
105
|
+
const tx = new Transaction();
|
|
106
|
+
buildDeleteAllowlist(tx, {
|
|
107
|
+
packageId: config.packageId,
|
|
108
|
+
allowlistId: args.allowlistId,
|
|
109
|
+
capId: args.capId,
|
|
110
|
+
});
|
|
111
|
+
const receipt = await adapter.signAndExecuteTransaction(tx, args.signal);
|
|
112
|
+
return { digest: receipt.digest, gasUsedMist: receipt.gasUsedMist };
|
|
113
|
+
}
|
|
114
|
+
function validateAllowlistName(name) {
|
|
115
|
+
if (name.length === 0) {
|
|
116
|
+
throw new ValidationError("Allowlist name cannot be empty", "name");
|
|
117
|
+
}
|
|
118
|
+
if (name.length > MAX_ALLOWLIST_NAME_LENGTH) {
|
|
119
|
+
throw new ValidationError(`Allowlist name exceeds ${MAX_ALLOWLIST_NAME_LENGTH} chars`, "name");
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=allowlist.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"allowlist.js","sourceRoot":"","sources":["../../src/ops/allowlist.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,WAAW,GAEX,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EACN,cAAc,EACd,oBAAoB,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C7C,MAAM,IAAI,eAAe,CACxB,0BAA0B,yBAAyB,QAAQ,EAC3D,MAAM,CACN,CAAC;IACH,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* High-level "upload + register" flows for the file module. Combines Walrus
|
|
3
|
+
* upload with on-chain metadata registration in a single PTB so the user
|
|
4
|
+
* sees one signing popup for the storage step plus one for the on-chain
|
|
5
|
+
* write (rather than three separate popups).
|
|
6
|
+
*
|
|
7
|
+
* Mirrors `entry-from-bytes.ts`'s shape but targets `file::new_encrypted_file`
|
|
8
|
+
* / `file::new_public_file` instead of `add_entry_to_collection`.
|
|
9
|
+
*/
|
|
10
|
+
import type { MorsePackageConfig } from "../config.js";
|
|
11
|
+
import type { SealAdapter } from "../seal/adapter.js";
|
|
12
|
+
import type { AllowlistId, BlobObjectId, EncryptedFileId, SealId, WalrusBlobId } from "../types.js";
|
|
13
|
+
import type { WalletAdapter } from "../wallets/adapter.js";
|
|
14
|
+
import type { UploadBlobOptions, WalrusFlowCapable, WalrusWriteAdapter } from "../walrus/adapter.js";
|
|
15
|
+
export type FileUploadProgressEvent = {
|
|
16
|
+
readonly phase: "encrypting";
|
|
17
|
+
} | {
|
|
18
|
+
readonly phase: "uploading";
|
|
19
|
+
} | {
|
|
20
|
+
readonly phase: "submitting";
|
|
21
|
+
} | {
|
|
22
|
+
readonly phase: "complete";
|
|
23
|
+
};
|
|
24
|
+
export type FileUploadProgressCallback = (event: FileUploadProgressEvent) => void;
|
|
25
|
+
export interface UploadFileResult {
|
|
26
|
+
readonly digest: string;
|
|
27
|
+
readonly gasUsedMist: bigint;
|
|
28
|
+
readonly fileId: EncryptedFileId;
|
|
29
|
+
readonly blobId: WalrusBlobId;
|
|
30
|
+
readonly blobObjectId: BlobObjectId;
|
|
31
|
+
}
|
|
32
|
+
export interface UploadEncryptedFileFromBytesArgs {
|
|
33
|
+
readonly walrus: WalrusWriteAdapter & WalrusFlowCapable;
|
|
34
|
+
readonly seal: SealAdapter;
|
|
35
|
+
readonly allowlistId: AllowlistId;
|
|
36
|
+
/** Caller-supplied Seal identity. Must derive from `buildAllowlistSealId(allowlistId, nonce)`. */
|
|
37
|
+
readonly sealId: SealId;
|
|
38
|
+
readonly plaintext: Uint8Array;
|
|
39
|
+
readonly name: string;
|
|
40
|
+
readonly contentType: string;
|
|
41
|
+
readonly upload: UploadBlobOptions;
|
|
42
|
+
readonly signal?: AbortSignal;
|
|
43
|
+
readonly onProgress?: FileUploadProgressCallback;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Encrypt `plaintext` via Seal under the allowlist's identity, upload the
|
|
47
|
+
* ciphertext to Walrus, and register an `EncryptedFile` metadata record in
|
|
48
|
+
* one combined transaction. Two wallet popups: register_blob, then
|
|
49
|
+
* certify_blob + new_encrypted_file + share_file.
|
|
50
|
+
*
|
|
51
|
+
* The caller supplies `sealId` rather than having the flow construct it,
|
|
52
|
+
* so the decryption side can use the same identity bytes without an
|
|
53
|
+
* implicit shared-secret round-trip. Build via:
|
|
54
|
+
*
|
|
55
|
+
* const nonce = crypto.getRandomValues(new Uint8Array(16));
|
|
56
|
+
* const sealId = buildAllowlistSealId(allowlistId, nonce);
|
|
57
|
+
*
|
|
58
|
+
* Reuse the same nonce-derived sealId when decrypting (consumers can
|
|
59
|
+
* recover it by reading the encrypted ciphertext header — Seal stores the
|
|
60
|
+
* identity in the ciphertext envelope).
|
|
61
|
+
*
|
|
62
|
+
* @throws {SealError} If encryption fails (no popup yet).
|
|
63
|
+
* @throws {UncertifiedBlobError} If the combined popup fails after upload
|
|
64
|
+
* succeeded. The blob is on Walrus but uncertified; retry the full flow.
|
|
65
|
+
* @throws {ContractAbortError} On Move abort during simulation.
|
|
66
|
+
* @throws {TransportError} On RPC, network, or pre-upload failure.
|
|
67
|
+
*/
|
|
68
|
+
export declare function uploadEncryptedFileFromBytes(adapter: WalletAdapter, config: MorsePackageConfig, args: UploadEncryptedFileFromBytesArgs): Promise<UploadFileResult>;
|
|
69
|
+
export interface UploadPublicFileFromBytesArgs {
|
|
70
|
+
readonly walrus: WalrusWriteAdapter & WalrusFlowCapable;
|
|
71
|
+
readonly bytes: Uint8Array;
|
|
72
|
+
readonly name: string;
|
|
73
|
+
readonly contentType: string;
|
|
74
|
+
readonly upload: UploadBlobOptions;
|
|
75
|
+
readonly signal?: AbortSignal;
|
|
76
|
+
readonly onProgress?: FileUploadProgressCallback;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Upload `bytes` to Walrus unencrypted and register a public `EncryptedFile`
|
|
80
|
+
* metadata record (`encrypted: false`, `allowlistId: null`) in one combined
|
|
81
|
+
* transaction. Two wallet popups; no Seal involvement.
|
|
82
|
+
*/
|
|
83
|
+
export declare function uploadPublicFileFromBytes(adapter: WalletAdapter, config: MorsePackageConfig, args: UploadPublicFileFromBytesArgs): Promise<UploadFileResult>;
|
|
84
|
+
//# sourceMappingURL=file-from-bytes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-from-bytes.d.ts","sourceRoot":"","sources":["../../src/ops/file-from-bytes.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAOvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EACX,WAAW,EACX,YAAY,EACZ,eAAe,EACf,MAAM,EACN,YAAY,EACZ,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EACX,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,MAAM,sBAAsB,CAAC;AAI9B,MAAM,MAAM,uBAAuB,GAChC;IAAE,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAA;CAAE,GAChC;IAAE,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAA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AAC;IACxD,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,UAAU,CAAC,EAAE,0BAA0B,CAAC;CACjD;AAED;;;;GAIG;AACH,wBAAsB,yBAAyB,CAC9C,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,kBAAkB,EAC1B,IAAI,EAAE,6BAA6B,GACjC,OAAO,CAAC,gBAAgB,CAAC,CA2C3B"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* High-level "upload + register" flows for the file module. Combines Walrus
|
|
3
|
+
* upload with on-chain metadata registration in a single PTB so the user
|
|
4
|
+
* sees one signing popup for the storage step plus one for the on-chain
|
|
5
|
+
* write (rather than three separate popups).
|
|
6
|
+
*
|
|
7
|
+
* Mirrors `entry-from-bytes.ts`'s shape but targets `file::new_encrypted_file`
|
|
8
|
+
* / `file::new_public_file` instead of `add_entry_to_collection`.
|
|
9
|
+
*/
|
|
10
|
+
import { toEncryptedFileId } from "../codecs.js";
|
|
11
|
+
import { TransportError, UncertifiedBlobError } from "../errors.js";
|
|
12
|
+
import { buildNewEncryptedFile, buildNewPublicFile, buildShareFile, } from "../ptb/file.js";
|
|
13
|
+
import { isWalrusFlowCapable } from "../walrus/adapter.js";
|
|
14
|
+
import { findCreatedId } from "./internal.js";
|
|
15
|
+
/**
|
|
16
|
+
* Encrypt `plaintext` via Seal under the allowlist's identity, upload the
|
|
17
|
+
* ciphertext to Walrus, and register an `EncryptedFile` metadata record in
|
|
18
|
+
* one combined transaction. Two wallet popups: register_blob, then
|
|
19
|
+
* certify_blob + new_encrypted_file + share_file.
|
|
20
|
+
*
|
|
21
|
+
* The caller supplies `sealId` rather than having the flow construct it,
|
|
22
|
+
* so the decryption side can use the same identity bytes without an
|
|
23
|
+
* implicit shared-secret round-trip. Build via:
|
|
24
|
+
*
|
|
25
|
+
* const nonce = crypto.getRandomValues(new Uint8Array(16));
|
|
26
|
+
* const sealId = buildAllowlistSealId(allowlistId, nonce);
|
|
27
|
+
*
|
|
28
|
+
* Reuse the same nonce-derived sealId when decrypting (consumers can
|
|
29
|
+
* recover it by reading the encrypted ciphertext header — Seal stores the
|
|
30
|
+
* identity in the ciphertext envelope).
|
|
31
|
+
*
|
|
32
|
+
* @throws {SealError} If encryption fails (no popup yet).
|
|
33
|
+
* @throws {UncertifiedBlobError} If the combined popup fails after upload
|
|
34
|
+
* succeeded. The blob is on Walrus but uncertified; retry the full flow.
|
|
35
|
+
* @throws {ContractAbortError} On Move abort during simulation.
|
|
36
|
+
* @throws {TransportError} On RPC, network, or pre-upload failure.
|
|
37
|
+
*/
|
|
38
|
+
export async function uploadEncryptedFileFromBytes(adapter, config, args) {
|
|
39
|
+
assertFlowCapable(args.walrus);
|
|
40
|
+
args.onProgress?.({ phase: "encrypting" });
|
|
41
|
+
const { ciphertext } = await args.seal.encrypt(args.plaintext, {
|
|
42
|
+
sealId: args.sealId,
|
|
43
|
+
});
|
|
44
|
+
args.onProgress?.({ phase: "uploading" });
|
|
45
|
+
const upload = await args.walrus.startBlobUpload(ciphertext, args.upload);
|
|
46
|
+
try {
|
|
47
|
+
const tx = upload.certifyTransaction;
|
|
48
|
+
const created = buildNewEncryptedFile(tx, {
|
|
49
|
+
packageId: config.packageId,
|
|
50
|
+
blobId: upload.blobId,
|
|
51
|
+
blobObjectId: upload.blobObjectId,
|
|
52
|
+
name: args.name,
|
|
53
|
+
contentType: args.contentType,
|
|
54
|
+
size: BigInt(args.plaintext.length),
|
|
55
|
+
allowlistId: args.allowlistId,
|
|
56
|
+
});
|
|
57
|
+
buildShareFile(tx, {
|
|
58
|
+
packageId: config.packageId,
|
|
59
|
+
file: created,
|
|
60
|
+
});
|
|
61
|
+
args.onProgress?.({ phase: "submitting" });
|
|
62
|
+
const receipt = await adapter.signAndExecuteTransaction(tx, args.signal);
|
|
63
|
+
// See ops/allowlist.ts: file::EncryptedFile was introduced in v2.
|
|
64
|
+
const typePrefix = config.packageId;
|
|
65
|
+
const fileId = toEncryptedFileId(findCreatedId(receipt, `${typePrefix}::file::EncryptedFile`));
|
|
66
|
+
args.onProgress?.({ phase: "complete" });
|
|
67
|
+
return {
|
|
68
|
+
digest: receipt.digest,
|
|
69
|
+
gasUsedMist: receipt.gasUsedMist,
|
|
70
|
+
fileId,
|
|
71
|
+
blobId: upload.blobId,
|
|
72
|
+
blobObjectId: upload.blobObjectId,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
catch (cause) {
|
|
76
|
+
if (cause instanceof UncertifiedBlobError)
|
|
77
|
+
throw cause;
|
|
78
|
+
throw new UncertifiedBlobError(upload.blobObjectId, upload.blobId, {
|
|
79
|
+
cause,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Upload `bytes` to Walrus unencrypted and register a public `EncryptedFile`
|
|
85
|
+
* metadata record (`encrypted: false`, `allowlistId: null`) in one combined
|
|
86
|
+
* transaction. Two wallet popups; no Seal involvement.
|
|
87
|
+
*/
|
|
88
|
+
export async function uploadPublicFileFromBytes(adapter, config, args) {
|
|
89
|
+
assertFlowCapable(args.walrus);
|
|
90
|
+
args.onProgress?.({ phase: "uploading" });
|
|
91
|
+
const upload = await args.walrus.startBlobUpload(args.bytes, args.upload);
|
|
92
|
+
try {
|
|
93
|
+
const tx = upload.certifyTransaction;
|
|
94
|
+
const created = buildNewPublicFile(tx, {
|
|
95
|
+
packageId: config.packageId,
|
|
96
|
+
blobId: upload.blobId,
|
|
97
|
+
blobObjectId: upload.blobObjectId,
|
|
98
|
+
name: args.name,
|
|
99
|
+
contentType: args.contentType,
|
|
100
|
+
size: BigInt(args.bytes.length),
|
|
101
|
+
});
|
|
102
|
+
buildShareFile(tx, {
|
|
103
|
+
packageId: config.packageId,
|
|
104
|
+
file: created,
|
|
105
|
+
});
|
|
106
|
+
args.onProgress?.({ phase: "submitting" });
|
|
107
|
+
const receipt = await adapter.signAndExecuteTransaction(tx, args.signal);
|
|
108
|
+
// See ops/allowlist.ts: file::EncryptedFile was introduced in v2.
|
|
109
|
+
const typePrefix = config.packageId;
|
|
110
|
+
const fileId = toEncryptedFileId(findCreatedId(receipt, `${typePrefix}::file::EncryptedFile`));
|
|
111
|
+
args.onProgress?.({ phase: "complete" });
|
|
112
|
+
return {
|
|
113
|
+
digest: receipt.digest,
|
|
114
|
+
gasUsedMist: receipt.gasUsedMist,
|
|
115
|
+
fileId,
|
|
116
|
+
blobId: upload.blobId,
|
|
117
|
+
blobObjectId: upload.blobObjectId,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
catch (cause) {
|
|
121
|
+
if (cause instanceof UncertifiedBlobError)
|
|
122
|
+
throw cause;
|
|
123
|
+
throw new UncertifiedBlobError(upload.blobObjectId, upload.blobId, {
|
|
124
|
+
cause,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function assertFlowCapable(walrus) {
|
|
129
|
+
if (!isWalrusFlowCapable(walrus)) {
|
|
130
|
+
throw new TransportError("uploadEncryptedFileFromBytes / uploadPublicFileFromBytes require a WalrusWriteAdapter that implements WalrusFlowCapable (i.e. exposes startBlobUpload). The default DefaultWalrusWriteAdapter does. Custom adapters that do not implement the capability should compose walrus.uploadBlob + create_*_file (3 popups) instead.", { operation: "sdk.uploadFileFromBytes" });
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=file-from-bytes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-from-bytes.js","sourceRoot":"","sources":["../../src/ops/file-from-bytes.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAE,iBAAiB,EA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K,EAAE,CAAC;QAChB,IAAI,KAAK,YAAY,oBAAoB;YAAE,MAAM,KAAK,CAAC;QACvD,MAAM,IAAI,oBAAoB,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE;YAClE,KAAK;SACL,CAAC,CAAC;IACJ,CAAC;AACF,CAAC;AAED,SAAS,iBAAiB,CACzB,MAA0B;IAE1B,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,cAAc,CACvB,+TAA+T,EAC/T,EAAE,SAAS,EAAE,yBAAyB,EAAE,CACxC,CAAC;IACH,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* High-level file ops: build a PTB, sign and execute via the wallet adapter,
|
|
3
|
+
* parse the receipt into a typed result.
|
|
4
|
+
*
|
|
5
|
+
* Encrypted-file creation here registers the metadata record assuming the
|
|
6
|
+
* encrypted bytes are already on Walrus. The all-in-one upload+register
|
|
7
|
+
* flow is `uploadEncryptedFileFromBytes` in `file-from-bytes.ts`.
|
|
8
|
+
*/
|
|
9
|
+
import type { MorsePackageConfig } from "../config.js";
|
|
10
|
+
import type { AllowlistId, BlobObjectId, EncryptedFileId, SuiAddress, WalrusBlobId } from "../types.js";
|
|
11
|
+
import type { WalletAdapter } from "../wallets/adapter.js";
|
|
12
|
+
export interface CreateEncryptedFileArgs {
|
|
13
|
+
readonly allowlistId: AllowlistId;
|
|
14
|
+
readonly blobId: WalrusBlobId;
|
|
15
|
+
readonly blobObjectId?: BlobObjectId;
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly contentType: string;
|
|
18
|
+
readonly size: bigint;
|
|
19
|
+
readonly signal?: AbortSignal;
|
|
20
|
+
}
|
|
21
|
+
export interface CreateFileResult {
|
|
22
|
+
readonly digest: string;
|
|
23
|
+
readonly gasUsedMist: bigint;
|
|
24
|
+
readonly fileId: EncryptedFileId;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Register on-chain metadata for an encrypted file already uploaded to Walrus.
|
|
28
|
+
* The bytes at `blobId` MUST be Seal-encrypted under an identity built from
|
|
29
|
+
* `allowlistId` (see `buildAllowlistSealId`); otherwise consumers will fail
|
|
30
|
+
* to decrypt. The SDK does not verify this binding.
|
|
31
|
+
*
|
|
32
|
+
* @throws {ValidationError} If `name` or `contentType` is empty or exceeds length limits.
|
|
33
|
+
* @throws {ContractAbortError} On Move abort (e.g. empty blob_id).
|
|
34
|
+
* @throws {TransportError} On RPC, network, or response-parsing failure.
|
|
35
|
+
*/
|
|
36
|
+
export declare function createEncryptedFile(adapter: WalletAdapter, config: MorsePackageConfig, args: CreateEncryptedFileArgs): Promise<CreateFileResult>;
|
|
37
|
+
export interface CreatePublicFileArgs {
|
|
38
|
+
readonly blobId: WalrusBlobId;
|
|
39
|
+
readonly blobObjectId?: BlobObjectId;
|
|
40
|
+
readonly name: string;
|
|
41
|
+
readonly contentType: string;
|
|
42
|
+
readonly size: bigint;
|
|
43
|
+
readonly signal?: AbortSignal;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Register on-chain metadata for an unencrypted file. The bytes at `blobId`
|
|
47
|
+
* are publicly readable via the Walrus aggregator.
|
|
48
|
+
*/
|
|
49
|
+
export declare function createPublicFile(adapter: WalletAdapter, config: MorsePackageConfig, args: CreatePublicFileArgs): Promise<CreateFileResult>;
|
|
50
|
+
export interface UpdateFileMetadataArgs {
|
|
51
|
+
readonly fileId: EncryptedFileId;
|
|
52
|
+
readonly name: string;
|
|
53
|
+
readonly contentType: string;
|
|
54
|
+
readonly signal?: AbortSignal;
|
|
55
|
+
}
|
|
56
|
+
export interface FileOpResult {
|
|
57
|
+
readonly digest: string;
|
|
58
|
+
readonly gasUsedMist: bigint;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Update the file's `name` and `content_type`. Other fields are immutable
|
|
62
|
+
* post-creation; create a new file record to swap the blob or change the
|
|
63
|
+
* allowlist. Owner only (sender must equal `file.owner` on-chain).
|
|
64
|
+
*/
|
|
65
|
+
export declare function updateFileMetadata(adapter: WalletAdapter, config: MorsePackageConfig, args: UpdateFileMetadataArgs): Promise<FileOpResult>;
|
|
66
|
+
export interface TransferFileOwnershipArgs {
|
|
67
|
+
readonly fileId: EncryptedFileId;
|
|
68
|
+
readonly newOwner: SuiAddress;
|
|
69
|
+
readonly signal?: AbortSignal;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Transfer the metadata-mutation right to a new address. Decryption access
|
|
73
|
+
* is governed separately by the file's allowlist; the new owner must be
|
|
74
|
+
* added to that allowlist (and the previous owner removed, if desired) by
|
|
75
|
+
* the Cap holder. The two operations can be composed in one PTB by the
|
|
76
|
+
* caller if both rights need to move together.
|
|
77
|
+
*/
|
|
78
|
+
export declare function transferFileOwnership(adapter: WalletAdapter, config: MorsePackageConfig, args: TransferFileOwnershipArgs): Promise<FileOpResult>;
|
|
79
|
+
export interface DeleteFileArgs {
|
|
80
|
+
readonly fileId: EncryptedFileId;
|
|
81
|
+
readonly signal?: AbortSignal;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Delete the on-chain metadata record. Does NOT delete the Walrus blob;
|
|
85
|
+
* that follows the Walrus lease lifecycle independently.
|
|
86
|
+
*/
|
|
87
|
+
export declare function deleteFile(adapter: WalletAdapter, config: MorsePackageConfig, args: DeleteFileArgs): Promise<FileOpResult>;
|
|
88
|
+
//# sourceMappingURL=file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/ops/file.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAQH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAUvD,OAAO,KAAK,EACX,WAAW,EACX,YAAY,EACZ,eAAe,EACf,UAAU,EACV,YAAY,EACZ,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK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,eAAe,CAAC;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC9B;AAED,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC7B;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CACvC,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,kBAAkB,EAC1B,IAAI,EAAE,sBAAsB,GAC1B,OAAO,CAAC,YAAY,CAAC,CAYvB;AAED,MAAM,WAAW,yBAAyB;IACzC,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC9B;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CAC1C,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,kBAAkB,EAC1B,IAAI,EAAE,yBAAyB,GAC7B,OAAO,CAAC,YAAY,CAAC,CASvB;AAED,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC9B;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAC/B,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,kBAAkB,EAC1B,IAAI,EAAE,cAAc,GAClB,OAAO,CAAC,YAAY,CAAC,CAQvB"}
|
package/dist/ops/file.js
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* High-level file ops: build a PTB, sign and execute via the wallet adapter,
|
|
3
|
+
* parse the receipt into a typed result.
|
|
4
|
+
*
|
|
5
|
+
* Encrypted-file creation here registers the metadata record assuming the
|
|
6
|
+
* encrypted bytes are already on Walrus. The all-in-one upload+register
|
|
7
|
+
* flow is `uploadEncryptedFileFromBytes` in `file-from-bytes.ts`.
|
|
8
|
+
*/
|
|
9
|
+
import { Transaction, } from "@mysten/sui/transactions";
|
|
10
|
+
import { toEncryptedFileId } from "../codecs.js";
|
|
11
|
+
import { ValidationError } from "../errors.js";
|
|
12
|
+
import { buildDeleteFile, buildNewEncryptedFile, buildNewPublicFile, buildShareFile, buildTransferFileOwnership, buildUpdateFileMetadata, } from "../ptb/file.js";
|
|
13
|
+
import { findCreatedId } from "./internal.js";
|
|
14
|
+
const MAX_FILE_NAME_LENGTH = 256;
|
|
15
|
+
const MAX_CONTENT_TYPE_LENGTH = 255;
|
|
16
|
+
/**
|
|
17
|
+
* Register on-chain metadata for an encrypted file already uploaded to Walrus.
|
|
18
|
+
* The bytes at `blobId` MUST be Seal-encrypted under an identity built from
|
|
19
|
+
* `allowlistId` (see `buildAllowlistSealId`); otherwise consumers will fail
|
|
20
|
+
* to decrypt. The SDK does not verify this binding.
|
|
21
|
+
*
|
|
22
|
+
* @throws {ValidationError} If `name` or `contentType` is empty or exceeds length limits.
|
|
23
|
+
* @throws {ContractAbortError} On Move abort (e.g. empty blob_id).
|
|
24
|
+
* @throws {TransportError} On RPC, network, or response-parsing failure.
|
|
25
|
+
*/
|
|
26
|
+
export async function createEncryptedFile(adapter, config, args) {
|
|
27
|
+
validateFileFields(args.name, args.contentType);
|
|
28
|
+
const tx = new Transaction();
|
|
29
|
+
const created = buildNewEncryptedFile(tx, {
|
|
30
|
+
packageId: config.packageId,
|
|
31
|
+
blobId: args.blobId,
|
|
32
|
+
...(args.blobObjectId === undefined
|
|
33
|
+
? {}
|
|
34
|
+
: { blobObjectId: args.blobObjectId }),
|
|
35
|
+
name: args.name,
|
|
36
|
+
contentType: args.contentType,
|
|
37
|
+
size: args.size,
|
|
38
|
+
allowlistId: args.allowlistId,
|
|
39
|
+
});
|
|
40
|
+
const fileArg = created;
|
|
41
|
+
buildShareFile(tx, { packageId: config.packageId, file: fileArg });
|
|
42
|
+
const receipt = await adapter.signAndExecuteTransaction(tx, args.signal);
|
|
43
|
+
// See ops/allowlist.ts: file::EncryptedFile was introduced in v2; type
|
|
44
|
+
// identity is rooted at config.packageId, not originalPackageId.
|
|
45
|
+
const typePrefix = config.packageId;
|
|
46
|
+
return {
|
|
47
|
+
digest: receipt.digest,
|
|
48
|
+
gasUsedMist: receipt.gasUsedMist,
|
|
49
|
+
fileId: toEncryptedFileId(findCreatedId(receipt, `${typePrefix}::file::EncryptedFile`)),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Register on-chain metadata for an unencrypted file. The bytes at `blobId`
|
|
54
|
+
* are publicly readable via the Walrus aggregator.
|
|
55
|
+
*/
|
|
56
|
+
export async function createPublicFile(adapter, config, args) {
|
|
57
|
+
validateFileFields(args.name, args.contentType);
|
|
58
|
+
const tx = new Transaction();
|
|
59
|
+
const created = buildNewPublicFile(tx, {
|
|
60
|
+
packageId: config.packageId,
|
|
61
|
+
blobId: args.blobId,
|
|
62
|
+
...(args.blobObjectId === undefined
|
|
63
|
+
? {}
|
|
64
|
+
: { blobObjectId: args.blobObjectId }),
|
|
65
|
+
name: args.name,
|
|
66
|
+
contentType: args.contentType,
|
|
67
|
+
size: args.size,
|
|
68
|
+
});
|
|
69
|
+
const fileArg = created;
|
|
70
|
+
buildShareFile(tx, { packageId: config.packageId, file: fileArg });
|
|
71
|
+
const receipt = await adapter.signAndExecuteTransaction(tx, args.signal);
|
|
72
|
+
// See ops/allowlist.ts: file::EncryptedFile was introduced in v2; type
|
|
73
|
+
// identity is rooted at config.packageId, not originalPackageId.
|
|
74
|
+
const typePrefix = config.packageId;
|
|
75
|
+
return {
|
|
76
|
+
digest: receipt.digest,
|
|
77
|
+
gasUsedMist: receipt.gasUsedMist,
|
|
78
|
+
fileId: toEncryptedFileId(findCreatedId(receipt, `${typePrefix}::file::EncryptedFile`)),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Update the file's `name` and `content_type`. Other fields are immutable
|
|
83
|
+
* post-creation; create a new file record to swap the blob or change the
|
|
84
|
+
* allowlist. Owner only (sender must equal `file.owner` on-chain).
|
|
85
|
+
*/
|
|
86
|
+
export async function updateFileMetadata(adapter, config, args) {
|
|
87
|
+
validateFileFields(args.name, args.contentType);
|
|
88
|
+
const tx = new Transaction();
|
|
89
|
+
buildUpdateFileMetadata(tx, {
|
|
90
|
+
packageId: config.packageId,
|
|
91
|
+
fileId: args.fileId,
|
|
92
|
+
name: args.name,
|
|
93
|
+
contentType: args.contentType,
|
|
94
|
+
});
|
|
95
|
+
const receipt = await adapter.signAndExecuteTransaction(tx, args.signal);
|
|
96
|
+
return { digest: receipt.digest, gasUsedMist: receipt.gasUsedMist };
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Transfer the metadata-mutation right to a new address. Decryption access
|
|
100
|
+
* is governed separately by the file's allowlist; the new owner must be
|
|
101
|
+
* added to that allowlist (and the previous owner removed, if desired) by
|
|
102
|
+
* the Cap holder. The two operations can be composed in one PTB by the
|
|
103
|
+
* caller if both rights need to move together.
|
|
104
|
+
*/
|
|
105
|
+
export async function transferFileOwnership(adapter, config, args) {
|
|
106
|
+
const tx = new Transaction();
|
|
107
|
+
buildTransferFileOwnership(tx, {
|
|
108
|
+
packageId: config.packageId,
|
|
109
|
+
fileId: args.fileId,
|
|
110
|
+
newOwner: args.newOwner,
|
|
111
|
+
});
|
|
112
|
+
const receipt = await adapter.signAndExecuteTransaction(tx, args.signal);
|
|
113
|
+
return { digest: receipt.digest, gasUsedMist: receipt.gasUsedMist };
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Delete the on-chain metadata record. Does NOT delete the Walrus blob;
|
|
117
|
+
* that follows the Walrus lease lifecycle independently.
|
|
118
|
+
*/
|
|
119
|
+
export async function deleteFile(adapter, config, args) {
|
|
120
|
+
const tx = new Transaction();
|
|
121
|
+
buildDeleteFile(tx, {
|
|
122
|
+
packageId: config.packageId,
|
|
123
|
+
fileId: args.fileId,
|
|
124
|
+
});
|
|
125
|
+
const receipt = await adapter.signAndExecuteTransaction(tx, args.signal);
|
|
126
|
+
return { digest: receipt.digest, gasUsedMist: receipt.gasUsedMist };
|
|
127
|
+
}
|
|
128
|
+
function validateFileFields(name, contentType) {
|
|
129
|
+
if (name.length === 0) {
|
|
130
|
+
throw new ValidationError("File name cannot be empty", "name");
|
|
131
|
+
}
|
|
132
|
+
if (name.length > MAX_FILE_NAME_LENGTH) {
|
|
133
|
+
throw new ValidationError(`File name exceeds ${MAX_FILE_NAME_LENGTH} chars`, "name");
|
|
134
|
+
}
|
|
135
|
+
if (contentType.length === 0) {
|
|
136
|
+
throw new ValidationError("Content type cannot be empty", "contentType");
|
|
137
|
+
}
|
|
138
|
+
if (contentType.length > MAX_CONTENT_TYPE_LENGTH) {
|
|
139
|
+
throw new ValidationError(`Content type exceeds ${MAX_CONTENT_TYPE_LENGTH} chars`, "contentType");
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.js","sourceRoot":"","sources":["../../src/ops/file.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACN,WAAW,GAEX,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EACN,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACd,0BAA0B,EAC1B,uBAAuB,GACvB,MAAM,gBAAgB,CAAC;AASxB,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACjC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAkBpC;;;;;;;;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,GAAG,MAAM,OAAO,CAAC,yBAAyB,CAAC,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACzE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC;AACrE,CAAC;AAED,SAAS,kBAAkB,CAAC,IAAY,EAAE,WAAmB;IAC5D,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,eAAe,CAAC,2BAA2B,EAAE,MAAM,CAAC,CAAC;IAChE,CAAC;IACD,IAAI,IAAI,CAAC,MAAM,GAAG,oBAAoB,EAAE,CAAC;QACxC,MAAM,IAAI,eAAe,CACxB,qBAAqB,oBAAoB,QAAQ,EACjD,MAAM,CACN,CAAC;IACH,CAAC;IACD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,eAAe,CAAC,8BAA8B,EAAE,aAAa,CAAC,CAAC;IAC1E,CAAC;IACD,IAAI,WAAW,CAAC,MAAM,GAAG,uBAAuB,EAAE,CAAC;QAClD,MAAM,IAAI,eAAe,CACxB,wBAAwB,uBAAuB,QAAQ,EACvD,aAAa,CACb,CAAC;IACH,CAAC;AACF,CAAC"}
|
package/dist/ops/index.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Public barrel for the high-level ops layer.
|
|
3
3
|
*/
|
|
4
|
+
export { type AddMemberArgs, type AllowlistOpResult, addMember, type CreateAllowlistArgs, type CreateAllowlistResult, createAllowlist, type DeleteAllowlistArgs, deleteAllowlist, type RemoveMemberArgs, removeMember, type TransferAllowlistCapArgs, transferAllowlistCap, } from "./allowlist.js";
|
|
4
5
|
export { type DestroyPublisherCapArgs, type DestroyPublisherCapResult, destroyPublisherCap, type IssuePublisherCapArgs, type IssuePublisherCapResult, issuePublisherCap, type RevokePublisherCapArgs, type RevokePublisherCapResult, revokePublisherCap, type TransferPublisherCapArgs, type TransferPublisherCapResult, transferPublisherCap, } from "./cap.js";
|
|
5
6
|
export { type CreateCollectionArgs, type CreateCollectionResult, createCollection, type DeleteCollectionArgs, type DeleteCollectionResult, deleteCollection, } from "./collection.js";
|
|
6
7
|
export { type AddEncryptedEntryArgs, type AddEntryArgs, type AddEntryResult, type AppendDraftRevisionArgs, type AppendEncryptedDraftRevisionArgs, addEncryptedEntry, addEntry, appendDraftRevision, appendEncryptedDraftRevision, type DeleteEntryArgs, type DeleteEntryResult, deleteEntry, type PublishDirectArgs, type PublishFromDraftArgs, publishDirect, publishFromDraft, type RevisionAppendResult, } from "./entry.js";
|
|
7
8
|
export { type AddEncryptedEntryFromBytesArgs, type AddEntryFromBytesArgs, type AddEntryFromBytesResult, addEncryptedEntryFromBytes, addEntryFromBytes, type ProgressCallback, type ProgressEvent, } from "./entry-from-bytes.js";
|
|
9
|
+
export { type CreateEncryptedFileArgs, type CreateFileResult, type CreatePublicFileArgs, createEncryptedFile, createPublicFile, type DeleteFileArgs, deleteFile, type FileOpResult, type TransferFileOwnershipArgs, transferFileOwnership, type UpdateFileMetadataArgs, updateFileMetadata, } from "./file.js";
|
|
10
|
+
export { type FileUploadProgressCallback, type FileUploadProgressEvent, type UploadEncryptedFileFromBytesArgs, type UploadFileResult, type UploadPublicFileFromBytesArgs, uploadEncryptedFileFromBytes, uploadPublicFileFromBytes, } from "./file-from-bytes.js";
|
|
8
11
|
export { type CreatePublicationArgs, type CreatePublicationResult, createPublication, type DeletePublicationArgs, type DeletePublicationResult, deletePublication, type PublicationConfig, type TransferOwnershipArgs, type TransferOwnershipResult, transferOwnership, } from "./publication.js";
|
|
9
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/ops/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ops/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACN,KAAK,uBAAu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,EAChB,KAAK,cAAc,EACnB,UAAU,EACV,KAAK,YAAY,EACjB,KAAK,yBAAyB,EAC9B,qBAAqB,EACrB,KAAK,sBAAsB,EAC3B,kBAAkB,GAClB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,KAAK,gCAAgC,EACrC,KAAK,gBAAgB,EACrB,KAAK,6BAA6B,EAClC,4BAA4B,EAC5B,yBAAyB,GACzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACN,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,iBAAiB,EACjB,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,iBAAiB,EACjB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,iBAAiB,GACjB,MAAM,kBAAkB,CAAC"}
|
package/dist/ops/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Public barrel for the high-level ops layer.
|
|
3
3
|
*/
|
|
4
|
+
export { addMember, createAllowlist, deleteAllowlist, removeMember, transferAllowlistCap, } from "./allowlist.js";
|
|
4
5
|
export { destroyPublisherCap, issuePublisherCap, revokePublisherCap, transferPublisherCap, } from "./cap.js";
|
|
5
6
|
export { createCollection, deleteCollection, } from "./collection.js";
|
|
6
7
|
export { addEncryptedEntry, addEntry, appendDraftRevision, appendEncryptedDraftRevision, deleteEntry, publishDirect, publishFromDraft, } from "./entry.js";
|
|
7
8
|
export { addEncryptedEntryFromBytes, addEntryFromBytes, } from "./entry-from-bytes.js";
|
|
9
|
+
export { createEncryptedFile, createPublicFile, deleteFile, transferFileOwnership, updateFileMetadata, } from "./file.js";
|
|
10
|
+
export { uploadEncryptedFileFromBytes, uploadPublicFileFromBytes, } from "./file-from-bytes.js";
|
|
8
11
|
export { createPublication, deletePublication, transferOwnership, } from "./publication.js";
|
|
9
12
|
//# sourceMappingURL=index.js.map
|