@arcadiasystems/morse-sdk 0.1.4 → 0.3.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 +118 -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 +11 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +11 -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-events.d.ts +87 -0
- package/dist/read/files-events.d.ts.map +1 -0
- package/dist/read/files-events.js +194 -0
- package/dist/read/files-events.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 +2 -0
- package/dist/read/index.d.ts.map +1 -1
- package/dist/read/index.js +2 -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 +85 -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,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event type constants and pure reconciliation helpers for the file +
|
|
3
|
+
* allowlist modules. Designed for consumers integrating a Sui indexer of
|
|
4
|
+
* their choice: fetch events from your indexer, pass them here, get back a
|
|
5
|
+
* deduplicated `EncryptedFileSummary[]` that reflects the current state.
|
|
6
|
+
*
|
|
7
|
+
* The SDK intentionally does NOT ship an event-fetching client. Sui v2 gRPC
|
|
8
|
+
* has no historical event query method, and the legacy `suix_queryEvents`
|
|
9
|
+
* JSON-RPC endpoint is on Mysten's deprecation track. Picking an indexer
|
|
10
|
+
* (Mysten public, self-hosted, third-party) is a consumer concern; the SDK
|
|
11
|
+
* owns the parsing + reconciliation logic which is the morse-contract-
|
|
12
|
+
* specific part.
|
|
13
|
+
*
|
|
14
|
+
* Pagination, retention, auth, and CORS are entirely the consumer's
|
|
15
|
+
* responsibility; they live with the indexer client, not here.
|
|
16
|
+
*/
|
|
17
|
+
import { ValidationError } from "../errors.js";
|
|
18
|
+
/**
|
|
19
|
+
* Build the fully-qualified event type strings for a given file-events
|
|
20
|
+
* origin package id. The origin id is the package where the event structs
|
|
21
|
+
* were FIRST defined, which is independent of `config.packageId` (the
|
|
22
|
+
* current published-at, which moves on every upgrade).
|
|
23
|
+
*
|
|
24
|
+
* Pass `config.filesEventOriginPackageId` here. The SDK ships the testnet
|
|
25
|
+
* default in `morseConfig`; custom deployments supply their own.
|
|
26
|
+
*
|
|
27
|
+
* @throws {ValidationError} If `packageId` is missing.
|
|
28
|
+
*/
|
|
29
|
+
export function buildFilesEventTypes(packageId) {
|
|
30
|
+
if (!packageId) {
|
|
31
|
+
throw new ValidationError("buildFilesEventTypes: packageId is required (pass config.filesEventOriginPackageId)", "packageId");
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
FileCreated: `${packageId}::file::FileCreated`,
|
|
35
|
+
FileDeleted: `${packageId}::file::FileDeleted`,
|
|
36
|
+
FileMetadataUpdated: `${packageId}::file::FileMetadataUpdated`,
|
|
37
|
+
FileOwnershipTransferred: `${packageId}::file::FileOwnershipTransferred`,
|
|
38
|
+
AllowlistCreated: `${packageId}::allowlist::AllowlistCreated`,
|
|
39
|
+
AllowlistDeleted: `${packageId}::allowlist::AllowlistDeleted`,
|
|
40
|
+
MemberAdded: `${packageId}::allowlist::MemberAdded`,
|
|
41
|
+
MemberRemoved: `${packageId}::allowlist::MemberRemoved`,
|
|
42
|
+
CapTransferred: `${packageId}::allowlist::CapTransferred`,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Reconcile a stream of Sui events into the current set of files owned by
|
|
47
|
+
* `address`. Caller is responsible for fetching events (typically via an
|
|
48
|
+
* indexer); pass all `FileCreated`, `FileOwnershipTransferred`, and
|
|
49
|
+
* `FileDeleted` events from the event types built via `buildFilesEventTypes`.
|
|
50
|
+
*
|
|
51
|
+
* Order-independence: events are sorted internally by `timestampMs` before
|
|
52
|
+
* reconciliation, so passing them in arbitrary order produces the same
|
|
53
|
+
* result. Events with `timestampMs === null` are skipped (unconfirmed).
|
|
54
|
+
*
|
|
55
|
+
* Best-effort: if `FileOwnershipTransferred` references a `file` whose
|
|
56
|
+
* `FileCreated` is missing from the input (e.g. retention pruning), the
|
|
57
|
+
* incoming transfer is dropped silently; there is no way to recover the
|
|
58
|
+
* metadata without the original event. Increase the indexer's event
|
|
59
|
+
* window if completeness is critical.
|
|
60
|
+
*/
|
|
61
|
+
export function reconcileFilesOwnedBy(events, address, eventTypes) {
|
|
62
|
+
const known = new Map();
|
|
63
|
+
const owners = new Map();
|
|
64
|
+
const sorted = sortByTimestamp(events);
|
|
65
|
+
for (const event of sorted) {
|
|
66
|
+
const ts = parseTimestampMs(event.timestampMs);
|
|
67
|
+
if (ts === null)
|
|
68
|
+
continue;
|
|
69
|
+
if (event.type === eventTypes.FileCreated) {
|
|
70
|
+
const payload = event.parsedJson;
|
|
71
|
+
const summary = payloadToSummary(payload, ts);
|
|
72
|
+
known.set(summary.id, summary);
|
|
73
|
+
owners.set(summary.id, summary.owner);
|
|
74
|
+
}
|
|
75
|
+
else if (event.type === eventTypes.FileOwnershipTransferred) {
|
|
76
|
+
const payload = event.parsedJson;
|
|
77
|
+
owners.set(payload.file, payload.new_owner);
|
|
78
|
+
}
|
|
79
|
+
else if (event.type === eventTypes.FileDeleted) {
|
|
80
|
+
const payload = event.parsedJson;
|
|
81
|
+
known.delete(payload.file);
|
|
82
|
+
owners.delete(payload.file);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const out = [];
|
|
86
|
+
for (const [fileId, summary] of known) {
|
|
87
|
+
if (owners.get(fileId) === address) {
|
|
88
|
+
out.push(summary);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return out.sort((a, b) => b.createdAtMs - a.createdAtMs);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Reconcile a stream of events into the current set of files where
|
|
95
|
+
* `address` has decrypt access via allowlist membership. Caller passes
|
|
96
|
+
* `MemberAdded`, `MemberRemoved`, `AllowlistDeleted`, `FileCreated`, and
|
|
97
|
+
* `FileDeleted` events.
|
|
98
|
+
*
|
|
99
|
+
* Same best-effort guarantees as `reconcileFilesOwnedBy`. Files referencing
|
|
100
|
+
* an `AllowlistDeleted` allowlist are dropped (the on-chain `seal_approve`
|
|
101
|
+
* dry-run would fail for them anyway).
|
|
102
|
+
*/
|
|
103
|
+
export function reconcileFilesAccessibleBy(events, address, eventTypes) {
|
|
104
|
+
const memberAllowlists = new Set();
|
|
105
|
+
const deletedAllowlists = new Set();
|
|
106
|
+
const knownFiles = new Map();
|
|
107
|
+
const sorted = sortByTimestamp(events);
|
|
108
|
+
for (const event of sorted) {
|
|
109
|
+
const ts = parseTimestampMs(event.timestampMs);
|
|
110
|
+
if (ts === null)
|
|
111
|
+
continue;
|
|
112
|
+
if (event.type === eventTypes.MemberAdded) {
|
|
113
|
+
const payload = event.parsedJson;
|
|
114
|
+
if (payload.member === address) {
|
|
115
|
+
memberAllowlists.add(payload.allowlist);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
else if (event.type === eventTypes.MemberRemoved) {
|
|
119
|
+
const payload = event.parsedJson;
|
|
120
|
+
if (payload.member === address) {
|
|
121
|
+
memberAllowlists.delete(payload.allowlist);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
else if (event.type === eventTypes.AllowlistDeleted) {
|
|
125
|
+
const payload = event.parsedJson;
|
|
126
|
+
deletedAllowlists.add(payload.allowlist);
|
|
127
|
+
memberAllowlists.delete(payload.allowlist);
|
|
128
|
+
}
|
|
129
|
+
else if (event.type === eventTypes.FileCreated) {
|
|
130
|
+
const payload = event.parsedJson;
|
|
131
|
+
const summary = payloadToSummary(payload, ts);
|
|
132
|
+
knownFiles.set(summary.id, summary);
|
|
133
|
+
}
|
|
134
|
+
else if (event.type === eventTypes.FileDeleted) {
|
|
135
|
+
const payload = event.parsedJson;
|
|
136
|
+
knownFiles.delete(payload.file);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const out = [];
|
|
140
|
+
for (const summary of knownFiles.values()) {
|
|
141
|
+
if (summary.allowlistId === null)
|
|
142
|
+
continue;
|
|
143
|
+
const allowlistKey = summary.allowlistId;
|
|
144
|
+
if (deletedAllowlists.has(allowlistKey))
|
|
145
|
+
continue;
|
|
146
|
+
if (!memberAllowlists.has(allowlistKey))
|
|
147
|
+
continue;
|
|
148
|
+
out.push(summary);
|
|
149
|
+
}
|
|
150
|
+
return out.sort((a, b) => b.createdAtMs - a.createdAtMs);
|
|
151
|
+
}
|
|
152
|
+
// internal
|
|
153
|
+
function sortByTimestamp(events) {
|
|
154
|
+
return [...events].sort((a, b) => {
|
|
155
|
+
const ta = parseTimestampMs(a.timestampMs) ?? Number.POSITIVE_INFINITY;
|
|
156
|
+
const tb = parseTimestampMs(b.timestampMs) ?? Number.POSITIVE_INFINITY;
|
|
157
|
+
return ta - tb;
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
function parseTimestampMs(value) {
|
|
161
|
+
if (value === null || value === undefined)
|
|
162
|
+
return null;
|
|
163
|
+
const num = typeof value === "string" ? Number(value) : value;
|
|
164
|
+
return Number.isFinite(num) ? num : null;
|
|
165
|
+
}
|
|
166
|
+
function payloadToSummary(payload, createdAtMs) {
|
|
167
|
+
return {
|
|
168
|
+
kind: "summary",
|
|
169
|
+
id: payload.file,
|
|
170
|
+
owner: payload.owner,
|
|
171
|
+
name: payload.name,
|
|
172
|
+
contentType: payload.content_type,
|
|
173
|
+
size: typeof payload.size === "string" ? Number(payload.size) : payload.size,
|
|
174
|
+
encrypted: payload.encrypted,
|
|
175
|
+
allowlistId: extractAllowlistId(payload.allowlist_id),
|
|
176
|
+
createdAtMs,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* `Option<ID>` in Move serializes as either a plain string (the address),
|
|
181
|
+
* `null`, or `{ vec: [address] | [] }` depending on the indexer's decoder.
|
|
182
|
+
* Normalize all three to `AllowlistId | null`.
|
|
183
|
+
*/
|
|
184
|
+
function extractAllowlistId(raw) {
|
|
185
|
+
if (raw === null || raw === undefined)
|
|
186
|
+
return null;
|
|
187
|
+
if (typeof raw === "string")
|
|
188
|
+
return raw;
|
|
189
|
+
if (Array.isArray(raw.vec) && raw.vec.length > 0 && raw.vec[0]) {
|
|
190
|
+
return raw.vec[0];
|
|
191
|
+
}
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=files-events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files-events.js","sourceRoot":"","sources":["../../src/read/files-events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAsB/C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAAC,SAAoB;IACxD,IAAI,CAAC,SAAS,EAAE,CAAC;QAChB,MAAM,IAAI,eAAe,CACxB,qFAAqF,EACrF,WAAW,CACX,CAAC;IACH,CAAC;IACD,OAAO;QACN,WAAW,EAAE,GAAG,SAAS,qBAAqB;QAC9C,WAAW,EAAE,GAAG,SAAS,qBAAqB;QAC9C,mBAAmB,EAAE,GAAG,SAAS,6BAA6B;QAC9D,wBAAwB,EAAE,GAAG,SAAS,kCAAkC;QACxE,gBAAgB,EAAE,GAAG,SAAS,+BAA+B;QAC7D,gBAAgB,EAAE,GAAG,SAAS,+BAA+B;QAC7D,WAAW,EAAE,G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,EAAE,OAAO,CAAC,IAAI;QAClB,WAAW,EAAE,OAAO,CAAC,YAAY;QACjC,IAAI,EACH,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI;QACvE,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,WAAW,EAAE,kBAAkB,CAAC,OAAO,CAAC,YAAY,CAAC;QACrD,WAAW;KACX,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,kBAAkB,CAC1B,GAA+C;IAE/C,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACnD,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,GAA6B,CAAC;IAClE,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAChE,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,CAA2B,CAAC;IAC7C,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RPC-backed reader for the allowlist + file modules. EncryptedFile objects
|
|
3
|
+
* are shared (every successful create_*_file flow calls share_file), so
|
|
4
|
+
* "list files owned by an address" is not exposed at the RPC layer — there
|
|
5
|
+
* is no on-chain owner field for `listOwnedObjects` to filter on. Listing
|
|
6
|
+
* accessible files requires event-based indexing; a future indexer-backed
|
|
7
|
+
* implementation will expose it through this same interface.
|
|
8
|
+
*/
|
|
9
|
+
import type { ObjectReader } from "../clients.js";
|
|
10
|
+
import type { Allowlist, AllowlistCap, AllowlistId, EncryptedFile, EncryptedFileId, PackageId, SuiAddress } from "../types.js";
|
|
11
|
+
/** Result of a single page of `listAllowlistCapsOwnedBy`. */
|
|
12
|
+
export interface AllowlistCapListPage {
|
|
13
|
+
readonly results: readonly AllowlistCap[];
|
|
14
|
+
readonly nextCursor: string | null;
|
|
15
|
+
}
|
|
16
|
+
/** Options for paginated list calls in `FilesReader`. */
|
|
17
|
+
export interface FilesListOptions {
|
|
18
|
+
readonly limit?: number;
|
|
19
|
+
readonly cursor?: string;
|
|
20
|
+
readonly signal?: AbortSignal;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Read-only access to the files domain: Allowlist objects, EncryptedFile
|
|
24
|
+
* metadata records, and the AllowlistCaps owned by a given address.
|
|
25
|
+
*
|
|
26
|
+
* Notably absent: there is no `listEncryptedFilesOwnedBy(address)` because
|
|
27
|
+
* EncryptedFile is a shared object with no on-chain owner field; `address`
|
|
28
|
+
* cannot index into anything. List the AllowlistCaps an address holds
|
|
29
|
+
* (admin access), then fetch each cap's `allowlistId` and inspect the
|
|
30
|
+
* allowlist's `members` set, or subscribe to the contract's events.
|
|
31
|
+
*/
|
|
32
|
+
export interface FilesReader {
|
|
33
|
+
getAllowlist(id: AllowlistId, signal?: AbortSignal): Promise<Allowlist>;
|
|
34
|
+
getEncryptedFile(id: EncryptedFileId, signal?: AbortSignal): Promise<EncryptedFile>;
|
|
35
|
+
listAllowlistCapsOwnedBy(address: SuiAddress, options?: FilesListOptions): Promise<AllowlistCapListPage>;
|
|
36
|
+
}
|
|
37
|
+
export declare class RpcFilesReader implements FilesReader {
|
|
38
|
+
private readonly client;
|
|
39
|
+
private readonly typePackageId;
|
|
40
|
+
constructor(client: ObjectReader, typePackageId: PackageId);
|
|
41
|
+
/**
|
|
42
|
+
* Build a reader from a morse package config. Uses `packageId` (the
|
|
43
|
+
* current published-at) for type filters because the allowlist + file
|
|
44
|
+
* modules were introduced in the v2 upgrade — Sui identifies a type by
|
|
45
|
+
* the package id where it was DEFINED, not by the package's genesis
|
|
46
|
+
* original-id. This differs from `RpcPublicationReader`, which uses
|
|
47
|
+
* `originalPackageId` because publication / collection / entry were
|
|
48
|
+
* defined in v1.
|
|
49
|
+
*/
|
|
50
|
+
static fromMorseConfig(config: {
|
|
51
|
+
packageId: PackageId;
|
|
52
|
+
originalPackageId?: PackageId;
|
|
53
|
+
}, client: ObjectReader): RpcFilesReader;
|
|
54
|
+
getAllowlist(id: AllowlistId, signal?: AbortSignal): Promise<Allowlist>;
|
|
55
|
+
getEncryptedFile(id: EncryptedFileId, signal?: AbortSignal): Promise<EncryptedFile>;
|
|
56
|
+
listAllowlistCapsOwnedBy(address: SuiAddress, options?: FilesListOptions): Promise<AllowlistCapListPage>;
|
|
57
|
+
private callClient;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=files-reader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files-reader.d.ts","sourceRoot":"","sources":["../../src/read/files-reader.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAUlD,OAAO,KAAK,EACX,SAAS,EACT,YAAY,EACZ,WAAW,EACX,aAAa,EACb,eAAe,EACf,SAAS,EACT,UAAU,EACV,MAAM,aAAa,CAAC;AAIrB,6DAA6D;AAC7D,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,CAAC;IAC1C,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAED,yDAAyD;AACzD,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC9B;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,WAAW;IAC3B,YAAY,CAAC,EAAE,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IACxE,gBAAgB,CACf,EAAE,EAAE,eAAe,EACnB,MAAM,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,aAAa,CAAC,CAAC;IAC1B,wBAAwB,CACvB,OAAO,EAAE,UAAU,EACnB,OAAO,CAAC,EAAE,gBAAgB,GACxB,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACjC;AAED,qBAAa,cAAe,YAAW,WAAW;IAEhD,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,aAAa;gBADb,MAAM,EAAE,YAAY,EACpB,aAAa,EAAE,SAAS;IAG1C;;;;;;;;OAQG;IACH,MAAM,CAAC,eAAe,CACrB,MAAM,EAAE;QAAE,SAAS,EAAE,SAAS,CAAC;QAAC,iBAAiB,CAAC,EAAE,SAAS,CAAA;KAAE,EAC/D,MAAM,EAAE,YAAY,GAClB,cAAc;IAIX,YAAY,CACjB,EAAE,EAAE,WAAW,EACf,MAAM,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,SAAS,CAAC;IA6Bf,gBAAgB,CACrB,EAAE,EAAE,eAAe,EACnB,MAAM,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,aAAa,CAAC;IA6BnB,wBAAwB,CAC7B,OAAO,EAAE,UAAU,EACnB,OAAO,GAAE,gBAAqB,GAC5B,OAAO,CAAC,oBAAoB,CAAC;YAkBlB,UAAU;CAaxB"}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RPC-backed reader for the allowlist + file modules. EncryptedFile objects
|
|
3
|
+
* are shared (every successful create_*_file flow calls share_file), so
|
|
4
|
+
* "list files owned by an address" is not exposed at the RPC layer — there
|
|
5
|
+
* is no on-chain owner field for `listOwnedObjects` to filter on. Listing
|
|
6
|
+
* accessible files requires event-based indexing; a future indexer-backed
|
|
7
|
+
* implementation will expose it through this same interface.
|
|
8
|
+
*/
|
|
9
|
+
import { toAllowlistCapId, toAllowlistId, toBlobObjectId, toEncryptedFileId, toSuiAddress, toWalrusBlobId, } from "../codecs.js";
|
|
10
|
+
import { NotFoundError, TransportError, ValidationError } from "../errors.js";
|
|
11
|
+
const DEFAULT_PAGE_LIMIT = 50;
|
|
12
|
+
export class RpcFilesReader {
|
|
13
|
+
client;
|
|
14
|
+
typePackageId;
|
|
15
|
+
constructor(client, typePackageId) {
|
|
16
|
+
this.client = client;
|
|
17
|
+
this.typePackageId = typePackageId;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Build a reader from a morse package config. Uses `packageId` (the
|
|
21
|
+
* current published-at) for type filters because the allowlist + file
|
|
22
|
+
* modules were introduced in the v2 upgrade — Sui identifies a type by
|
|
23
|
+
* the package id where it was DEFINED, not by the package's genesis
|
|
24
|
+
* original-id. This differs from `RpcPublicationReader`, which uses
|
|
25
|
+
* `originalPackageId` because publication / collection / entry were
|
|
26
|
+
* defined in v1.
|
|
27
|
+
*/
|
|
28
|
+
static fromMorseConfig(config, client) {
|
|
29
|
+
return new RpcFilesReader(client, config.packageId);
|
|
30
|
+
}
|
|
31
|
+
async getAllowlist(id, signal) {
|
|
32
|
+
const validated = toAllowlistId(id);
|
|
33
|
+
let response;
|
|
34
|
+
try {
|
|
35
|
+
response = await this.callClient("getObject", () => this.client.getObject({
|
|
36
|
+
objectId: validated,
|
|
37
|
+
include: { json: true },
|
|
38
|
+
...(signal === undefined ? {} : { signal }),
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
if (error instanceof TransportError &&
|
|
43
|
+
isObjectNotFoundError(error.cause, validated)) {
|
|
44
|
+
throw new NotFoundError("allowlist", validated, {
|
|
45
|
+
cause: error.cause,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
const object = response.object;
|
|
51
|
+
if (!object) {
|
|
52
|
+
throw new NotFoundError("allowlist", validated);
|
|
53
|
+
}
|
|
54
|
+
return parseAllowlist(object);
|
|
55
|
+
}
|
|
56
|
+
async getEncryptedFile(id, signal) {
|
|
57
|
+
const validated = toEncryptedFileId(id);
|
|
58
|
+
let response;
|
|
59
|
+
try {
|
|
60
|
+
response = await this.callClient("getObject", () => this.client.getObject({
|
|
61
|
+
objectId: validated,
|
|
62
|
+
include: { json: true },
|
|
63
|
+
...(signal === undefined ? {} : { signal }),
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
if (error instanceof TransportError &&
|
|
68
|
+
isObjectNotFoundError(error.cause, validated)) {
|
|
69
|
+
throw new NotFoundError("encrypted-file", validated, {
|
|
70
|
+
cause: error.cause,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
const object = response.object;
|
|
76
|
+
if (!object) {
|
|
77
|
+
throw new NotFoundError("encrypted-file", validated);
|
|
78
|
+
}
|
|
79
|
+
return parseEncryptedFile(object);
|
|
80
|
+
}
|
|
81
|
+
async listAllowlistCapsOwnedBy(address, options = {}) {
|
|
82
|
+
const validated = toSuiAddress(address);
|
|
83
|
+
const { limit = DEFAULT_PAGE_LIMIT, cursor, signal } = options;
|
|
84
|
+
const capType = `${this.typePackageId}::allowlist::Cap`;
|
|
85
|
+
const response = await this.callClient("listOwnedObjects", () => this.client.listOwnedObjects({
|
|
86
|
+
owner: validated,
|
|
87
|
+
type: capType,
|
|
88
|
+
limit,
|
|
89
|
+
cursor: cursor ?? null,
|
|
90
|
+
include: { json: true },
|
|
91
|
+
...(signal === undefined ? {} : { signal }),
|
|
92
|
+
}));
|
|
93
|
+
const results = response.objects.map((object) => parseAllowlistCap(object));
|
|
94
|
+
return { results, nextCursor: response.cursor };
|
|
95
|
+
}
|
|
96
|
+
async callClient(operation, call) {
|
|
97
|
+
try {
|
|
98
|
+
return await call();
|
|
99
|
+
}
|
|
100
|
+
catch (cause) {
|
|
101
|
+
throw new TransportError(`${operation} failed`, {
|
|
102
|
+
cause,
|
|
103
|
+
operation: `sui.${operation}`,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function parseAllowlist(object) {
|
|
109
|
+
const json = object.json;
|
|
110
|
+
if (!json || typeof json !== "object") {
|
|
111
|
+
throw new NotFoundError("allowlist", object.objectId);
|
|
112
|
+
}
|
|
113
|
+
const record = json;
|
|
114
|
+
const name = readString(record, "name", "allowlist.name");
|
|
115
|
+
const members = readMembers(record);
|
|
116
|
+
return {
|
|
117
|
+
id: toAllowlistId(object.objectId),
|
|
118
|
+
name,
|
|
119
|
+
members,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function parseAllowlistCap(object) {
|
|
123
|
+
const json = object.json;
|
|
124
|
+
if (!json || typeof json !== "object") {
|
|
125
|
+
throw new NotFoundError("allowlist", object.objectId);
|
|
126
|
+
}
|
|
127
|
+
const record = json;
|
|
128
|
+
const allowlistIdField = record.allowlist_id;
|
|
129
|
+
if (typeof allowlistIdField !== "string") {
|
|
130
|
+
throw new ValidationError("allowlist::Cap.allowlist_id missing or not a string", "cap.allowlist_id");
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
id: toAllowlistCapId(object.objectId),
|
|
134
|
+
allowlistId: toAllowlistId(allowlistIdField),
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function parseEncryptedFile(object) {
|
|
138
|
+
const json = object.json;
|
|
139
|
+
if (!json || typeof json !== "object") {
|
|
140
|
+
throw new NotFoundError("encrypted-file", object.objectId);
|
|
141
|
+
}
|
|
142
|
+
const record = json;
|
|
143
|
+
const owner = toSuiAddress(readString(record, "owner", "file.owner"));
|
|
144
|
+
// Sui gRPC serializes vector<u8> either as a base64 string (standard JSON
|
|
145
|
+
// representation) or as a number array (older RPC variants). Accept both.
|
|
146
|
+
const blobId = toWalrusBlobId(parseBlobIdField(record.blob_id));
|
|
147
|
+
const blobObjectId = readOptionalString(record, "blob_object_id");
|
|
148
|
+
const name = readString(record, "name", "file.name");
|
|
149
|
+
const contentType = readString(record, "content_type", "file.content_type");
|
|
150
|
+
const size = readSafeIntFromBig(record, "size", "file.size");
|
|
151
|
+
const encrypted = record.encrypted === true;
|
|
152
|
+
const allowlistIdRaw = readOptionalString(record, "allowlist_id");
|
|
153
|
+
const createdAtMs = readSafeIntFromBig(record, "created_at_ms", "file.created_at_ms");
|
|
154
|
+
return {
|
|
155
|
+
id: toEncryptedFileId(object.objectId),
|
|
156
|
+
owner,
|
|
157
|
+
blobId,
|
|
158
|
+
blobObjectId: blobObjectId === null ? null : toBlobObjectId(blobObjectId),
|
|
159
|
+
name,
|
|
160
|
+
contentType,
|
|
161
|
+
size,
|
|
162
|
+
encrypted,
|
|
163
|
+
allowlistId: allowlistIdRaw === null ? null : toAllowlistId(allowlistIdRaw),
|
|
164
|
+
createdAtMs,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function readMembers(record) {
|
|
168
|
+
const raw = record.members;
|
|
169
|
+
if (!raw || typeof raw !== "object") {
|
|
170
|
+
return [];
|
|
171
|
+
}
|
|
172
|
+
const contents = raw.contents;
|
|
173
|
+
if (!Array.isArray(contents)) {
|
|
174
|
+
return [];
|
|
175
|
+
}
|
|
176
|
+
const out = [];
|
|
177
|
+
for (const entry of contents) {
|
|
178
|
+
if (typeof entry === "string") {
|
|
179
|
+
out.push(toSuiAddress(entry));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return out;
|
|
183
|
+
}
|
|
184
|
+
function readString(record, field, errorField) {
|
|
185
|
+
const value = record[field];
|
|
186
|
+
if (typeof value !== "string") {
|
|
187
|
+
throw new ValidationError(`${errorField} missing or not a string`, errorField);
|
|
188
|
+
}
|
|
189
|
+
return value;
|
|
190
|
+
}
|
|
191
|
+
function readOptionalString(record, field) {
|
|
192
|
+
const value = record[field];
|
|
193
|
+
if (value === null || value === undefined) {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
return typeof value === "string" ? value : null;
|
|
197
|
+
}
|
|
198
|
+
function readSafeIntFromBig(record, field, errorField) {
|
|
199
|
+
const value = record[field];
|
|
200
|
+
if (typeof value !== "string" && typeof value !== "number") {
|
|
201
|
+
throw new ValidationError(`${errorField} missing or not a number`, errorField);
|
|
202
|
+
}
|
|
203
|
+
const big = BigInt(value);
|
|
204
|
+
if (big > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
205
|
+
throw new ValidationError(`${errorField} exceeds Number.MAX_SAFE_INTEGER`, errorField);
|
|
206
|
+
}
|
|
207
|
+
return Number(big);
|
|
208
|
+
}
|
|
209
|
+
function bytesArrayToBase64Url(bytes) {
|
|
210
|
+
let binary = "";
|
|
211
|
+
for (const byte of bytes) {
|
|
212
|
+
binary += String.fromCharCode(byte);
|
|
213
|
+
}
|
|
214
|
+
const b64 = btoa(binary);
|
|
215
|
+
return b64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Sui gRPC may serialize `vector<u8>` as:
|
|
219
|
+
* - a base64 string (standard JSON encoding)
|
|
220
|
+
* - a base64URL string (some RPC variants)
|
|
221
|
+
* - an array of numbers (older variants, or when the field is small)
|
|
222
|
+
* Return the URL-safe-base64 form Walrus uses for blob ids regardless of input shape.
|
|
223
|
+
*/
|
|
224
|
+
function parseBlobIdField(raw) {
|
|
225
|
+
if (Array.isArray(raw)) {
|
|
226
|
+
return bytesArrayToBase64Url(raw);
|
|
227
|
+
}
|
|
228
|
+
if (typeof raw !== "string") {
|
|
229
|
+
throw new ValidationError("file.blob_id must be a byte array or base64 string", "file.blob_id");
|
|
230
|
+
}
|
|
231
|
+
// Already URL-safe? Strip padding and return.
|
|
232
|
+
if (/^[A-Za-z0-9_-]+={0,2}$/.test(raw)) {
|
|
233
|
+
return raw.replace(/=+$/g, "");
|
|
234
|
+
}
|
|
235
|
+
// Standard base64 with + and / — convert to URL-safe.
|
|
236
|
+
if (/^[A-Za-z0-9+/]+={0,2}$/.test(raw)) {
|
|
237
|
+
return raw.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
|
|
238
|
+
}
|
|
239
|
+
throw new ValidationError("file.blob_id is not a recognized base64 string", "file.blob_id");
|
|
240
|
+
}
|
|
241
|
+
function isObjectNotFoundError(cause, _objectId) {
|
|
242
|
+
if (!(cause instanceof Error)) {
|
|
243
|
+
return false;
|
|
244
|
+
}
|
|
245
|
+
return /not found|NotFound|object.*not.*exist/i.test(cause.message);
|
|
246
|
+
}
|
|
247
|
+
//# sourceMappingURL=files-reader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files-reader.js","sourceRoot":"","sources":["../../src/read/files-reader.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,EACN,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,cAAc,GACd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAW9E,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAqC9B,MAAM,OAAO,cAAc;IAER;IACA;IAFlB,YACkB,MAAoB,EACpB,aAAwB;QADxB,WAAM,GAAN,MAAM,CAAc;QACpB,kBAAa,GAAb,aAAa,CAAW;IACvC,CAAC;IAEJ;;;;;;;;OAQG;IACH,MAAM,CAAC,eAAe,CACrB,MAA+D,EAC/D,MAAoB;QAEpB,OAAO,IAAI,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,YAAY,CACjB,EAAe,EACf,MAAoB;QAEpB,MAAM,SAAS,GAAG,aAAa,CAAC,EAAE,CAAC,CAAC;QACpC,IAAI,QAAwD,CAAC;QAC7D,IAAI,CAAC;YACJ,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,EA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
* Public barrel for the read layer.
|
|
3
3
|
*/
|
|
4
|
+
export { buildFilesEventTypes, type FilesEventInput, type FilesEventTypes, reconcileFilesAccessibleBy, reconcileFilesOwnedBy, } from "./files-events.js";
|
|
5
|
+
export { type AllowlistCapListPage, type FilesListOptions, type FilesReader, RpcFilesReader, } from "./files-reader.js";
|
|
4
6
|
export { type EntryListPage, type ListEntriesOptions, type ListPublicationsOptions, type ListPublisherCapsOptions, type OwnedPublication, type PublicationListPage, type PublicationReader, type PublisherCapListPage, RpcPublicationReader, type ScanEntriesOptions, } from "./reader.js";
|
|
5
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/read/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/read/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,oBAAoB,EACpB,KAAK,kBAAkB,GACvB,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/read/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACN,oBAAoB,EACpB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,0BAA0B,EAC1B,qBAAqB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACN,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,cAAc,GACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,oBAAoB,EACpB,KAAK,kBAAkB,GACvB,MAAM,aAAa,CAAC"}
|
package/dist/read/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Public barrel for the read layer.
|
|
3
3
|
*/
|
|
4
|
+
export { buildFilesEventTypes, reconcileFilesAccessibleBy, reconcileFilesOwnedBy, } from "./files-events.js";
|
|
5
|
+
export { RpcFilesReader, } from "./files-reader.js";
|
|
4
6
|
export { RpcPublicationReader, } from "./reader.js";
|
|
5
7
|
//# sourceMappingURL=index.js.map
|
package/dist/read/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/read/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EASN,oBAAoB,GAEpB,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/read/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACN,oBAAoB,EAGpB,0BAA0B,EAC1B,qBAAqB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAIN,cAAc,GACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EASN,oBAAoB,GAEpB,MAAM,aAAa,CAAC"}
|
package/dist/seal/adapter.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* (key servers, threshold, package id) is bound at construction time.
|
|
5
5
|
*/
|
|
6
6
|
import type { SessionKey } from "@mysten/seal";
|
|
7
|
-
import type { PublisherCapId, SealId } from "../types.js";
|
|
7
|
+
import type { AllowlistId, PublisherCapId, SealId } from "../types.js";
|
|
8
8
|
export interface SealEncryptOptions {
|
|
9
9
|
readonly sealId: SealId;
|
|
10
10
|
/** Optional additional authenticated data bound into the ciphertext. */
|
|
@@ -22,6 +22,12 @@ export interface SealDecryptOptions {
|
|
|
22
22
|
readonly sealId: SealId;
|
|
23
23
|
readonly publisherCapId: PublisherCapId;
|
|
24
24
|
}
|
|
25
|
+
/** Options for decrypting content gated by the allowlist policy. */
|
|
26
|
+
export interface SealDecryptUnderAllowlistOptions {
|
|
27
|
+
readonly sessionKey: SessionKey;
|
|
28
|
+
readonly sealId: SealId;
|
|
29
|
+
readonly allowlistId: AllowlistId;
|
|
30
|
+
}
|
|
25
31
|
/**
|
|
26
32
|
* Combined Seal adapter. Implementations bundle a `SealClient`, the morse
|
|
27
33
|
* package id (Seal binds it into ciphertext envelopes), and a TSS threshold.
|
|
@@ -52,5 +58,20 @@ export interface SealAdapter {
|
|
|
52
58
|
* @throws {TransportError} On network or PTB build failure.
|
|
53
59
|
*/
|
|
54
60
|
decrypt(ciphertext: Uint8Array, options: SealDecryptOptions): Promise<Uint8Array>;
|
|
61
|
+
/**
|
|
62
|
+
* Decrypt content gated by the allowlist policy. The Seal key servers
|
|
63
|
+
* verify that `sessionKey.getAddress()` is a current member of `allowlistId`
|
|
64
|
+
* by dry-running `allowlist::seal_approve(sealId, allowlist)`; non-members
|
|
65
|
+
* surface as `SealError("no-access")`.
|
|
66
|
+
*
|
|
67
|
+
* Distinct from `decrypt`, which targets the publisher policy. Both can
|
|
68
|
+
* coexist on the same adapter instance since policy targeting is decided
|
|
69
|
+
* by the seal_approve PTB the adapter constructs internally.
|
|
70
|
+
*
|
|
71
|
+
* @throws {SealError} On Seal authorization failure (`no-access`),
|
|
72
|
+
* decryption failure (`decrypt-failed`), session-key expiry, or rate limiting.
|
|
73
|
+
* @throws {TransportError} On network or PTB build failure.
|
|
74
|
+
*/
|
|
75
|
+
decryptUnderAllowlist(ciphertext: Uint8Array, options: SealDecryptUnderAllowlistOptions): Promise<Uint8Array>;
|
|
55
76
|
}
|
|
56
77
|
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/seal/adapter.ts"],"names":[],"mappings":"AAAA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OAaG;IACH,qBAAqB,CACpB,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,gCAAgC,GACvC,OAAO,CAAC,UAAU,CAAC,CAAC;CACvB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seal identity (`SealId`) construction and inspection for the allowlist policy.
|
|
3
|
+
* The Move layer (`allowlist::seal_approve`) enforces the byte format, so both
|
|
4
|
+
* encode and decode here must match the contract byte-for-byte.
|
|
5
|
+
*
|
|
6
|
+
* Layout: `allowlist_id(32) || policy_tag(u8=2) || nonce(>=1)`. Total length
|
|
7
|
+
* must be > 33 bytes (`allowlist::ESealInvalidId` otherwise).
|
|
8
|
+
*
|
|
9
|
+
* Distinct from the publisher policy (`publisher-identity.ts`) by policy tag
|
|
10
|
+
* (allowlist=2, publisher=1) so both can coexist in the same package without
|
|
11
|
+
* identity collisions.
|
|
12
|
+
*/
|
|
13
|
+
import { type AllowlistId, type SealId, SealPolicyTag } from "../types.js";
|
|
14
|
+
/** Structured view of an allowlist Seal identity. */
|
|
15
|
+
export interface AllowlistSealIdParts {
|
|
16
|
+
readonly allowlistId: AllowlistId;
|
|
17
|
+
readonly policyTag: SealPolicyTag;
|
|
18
|
+
readonly nonce: Uint8Array;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Build an allowlist-policy Seal identity. The nonce must be at least 1 byte
|
|
22
|
+
* (the Move contract's `id.length() > 33` invariant); nonces of 16 random
|
|
23
|
+
* bytes are typical.
|
|
24
|
+
*
|
|
25
|
+
* @throws {ValidationError} If `allowlistId` is not a 0x-prefixed 64-char
|
|
26
|
+
* hex string, or `nonce` is shorter than 1 byte.
|
|
27
|
+
*/
|
|
28
|
+
export declare function buildAllowlistSealId(allowlistId: AllowlistId, nonce: Uint8Array): SealId;
|
|
29
|
+
/**
|
|
30
|
+
* Decode the structural fields of an allowlist Seal identity. The brand
|
|
31
|
+
* guarantees the byte layout, so this never throws on a properly-built
|
|
32
|
+
* identity. Throws `ValidationError` if the bytes carry a different policy
|
|
33
|
+
* tag (e.g. publisher) — use `decodePublisherSealId` for those.
|
|
34
|
+
*/
|
|
35
|
+
export declare function decodeAllowlistSealId(id: SealId): AllowlistSealIdParts;
|
|
36
|
+
//# sourceMappingURL=allowlist-identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"allowlist-identity.d.ts","sourceRoot":"","sources":["../../src/seal/allowlist-identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAO3E,qDAAqD;AACrD,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;CAC3B;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CACnC,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,UAAU,GACf,MAAM,CAaR;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,MAAM,GAAG,oBAAoB,CAetE"}
|