@myfield/sdk 0.9.2 → 0.9.3
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 +7 -0
- package/README.md +30 -9
- package/dist/index.js +467 -366
- package/package.json +15 -8
- package/types/index.d.ts +395 -137
- package/docs/API.md +0 -298
- package/docs/BUCKET-SPEC.md +0 -173
- package/src/auth/authorization.ts +0 -254
- package/src/auth/flow.ts +0 -93
- package/src/auth/identifiers.ts +0 -46
- package/src/auth/index.ts +0 -17
- package/src/auth/instance.ts +0 -395
- package/src/auth/keys.ts +0 -73
- package/src/auth/proof.ts +0 -26
- package/src/auth/session.ts +0 -16
- package/src/auth/store.ts +0 -90
- package/src/auth/types.ts +0 -47
- package/src/bucket/binary.ts +0 -253
- package/src/bucket/client.ts +0 -426
- package/src/bucket/crypto.ts +0 -58
- package/src/bucket/format.ts +0 -324
- package/src/bucket/index.ts +0 -40
- package/src/bucket/keys.ts +0 -104
- package/src/bucket/store.ts +0 -190
- package/src/bucket/transport.ts +0 -249
- package/src/errors.ts +0 -40
- package/src/facade.ts +0 -698
- package/src/index.ts +0 -29
- package/src/internal/encoding.ts +0 -95
- package/src/remote/bucket.ts +0 -180
- package/src/remote/client.ts +0 -38
- package/src/remote/connection.ts +0 -529
- package/src/remote/feed.ts +0 -80
- package/src/remote/http.ts +0 -78
- package/src/remote/session.ts +0 -31
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myfield/sdk",
|
|
3
|
-
"version": "0.9.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.9.3",
|
|
4
|
+
"description": "MyField SDK for third-party web apps: local-first object storage, end-to-end-encrypted sync, and internal MyField authorization.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "OPENTECH AI PTE. LTD.",
|
|
7
7
|
"homepage": "https://github.com/myfield-one/sdk",
|
|
@@ -25,10 +25,8 @@
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
|
-
"dist/",
|
|
29
|
-
"src/",
|
|
28
|
+
"dist/index.js",
|
|
30
29
|
"types/",
|
|
31
|
-
"docs/",
|
|
32
30
|
"README.md",
|
|
33
31
|
"LICENSE",
|
|
34
32
|
"CHANGELOG.md"
|
|
@@ -44,17 +42,26 @@
|
|
|
44
42
|
],
|
|
45
43
|
"sideEffects": false,
|
|
46
44
|
"scripts": {
|
|
47
|
-
"build": "
|
|
45
|
+
"build": "npm run build:js && node scripts/api.mjs --build",
|
|
48
46
|
"prepack": "npm run build",
|
|
49
47
|
"test": "node --experimental-strip-types --test test/*.test.mjs",
|
|
50
48
|
"verify:remote": "node scripts/verify-remote.mjs",
|
|
51
49
|
"typecheck": "tsc --noEmit",
|
|
52
|
-
"typecheck:api": "
|
|
50
|
+
"typecheck:api": "node scripts/verify-docs.mjs && tsc -p tsconfig.consumer.json",
|
|
51
|
+
"build:js": "esbuild src/index.ts --bundle --format=esm --platform=browser --target=es2022 --outfile=dist/index.js",
|
|
52
|
+
"api:update": "node scripts/api.mjs --update",
|
|
53
|
+
"api:check": "node scripts/api.mjs",
|
|
54
|
+
"test:package": "node scripts/verify-package.mjs",
|
|
55
|
+
"test:docs": "node scripts/verify-docs.mjs",
|
|
56
|
+
"test:tooling": "node --test test/api-generation.test.mjs"
|
|
53
57
|
},
|
|
54
58
|
"devDependencies": {
|
|
55
59
|
"@types/node": "^25.5.2",
|
|
56
60
|
"esbuild": "^0.28.1",
|
|
57
61
|
"fake-indexeddb": "6.2.4",
|
|
58
|
-
"typescript": "5.5.4"
|
|
62
|
+
"typescript": "5.5.4",
|
|
63
|
+
"@microsoft/api-extractor": "7.59.4",
|
|
64
|
+
"typedoc": "0.28.20",
|
|
65
|
+
"typedoc-plugin-markdown": "4.14.1"
|
|
59
66
|
}
|
|
60
67
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,154 +1,412 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export type
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
1
|
+
/** Binary input supported by Local field values.
|
|
2
|
+
* @public
|
|
3
|
+
*/
|
|
4
|
+
export declare type BinaryInput = Blob | ArrayBuffer | Uint8Array;
|
|
5
|
+
|
|
6
|
+
/** Optional binary metadata stored inside encrypted Local payloads.
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export declare type BinaryOptions = {
|
|
10
|
+
mimeType?: string;
|
|
11
|
+
name?: string;
|
|
12
|
+
lastModified?: number;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/** Local-first object storage. Network synchronization requires a connection.
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export declare type Bucket = {
|
|
19
|
+
/** The local resource label; the granted remote bucket ID may differ. */
|
|
20
|
+
readonly id: string;
|
|
21
|
+
/** Current connection state. */
|
|
22
|
+
readonly state: BucketState;
|
|
23
|
+
/** Wraps a binary field without uploading it. */
|
|
24
|
+
binary(input: BinaryInput | BucketBinaryValue, options?: BinaryOptions): BucketBinaryValue;
|
|
25
|
+
/** @deprecated No-op kept for compatibility; operations initialize storage lazily. */
|
|
26
|
+
ready(): Promise<void>;
|
|
27
|
+
/** Replaces known local fields; concurrent unknown remote fields remain mergeable. */
|
|
28
|
+
put(objectId: string, object: Record<string, unknown>): Promise<void>;
|
|
29
|
+
/** Reads local data, returning null for absent or deleted objects. */
|
|
30
|
+
get(objectId: string): Promise<Record<string, unknown> | null>;
|
|
31
|
+
/** Updates top-level fields; undefined deletes a field. */
|
|
32
|
+
update(objectId: string, fields: Record<string, unknown>): Promise<void>;
|
|
33
|
+
/** Creates a local deletion and schedules synchronization when connected. */
|
|
34
|
+
delete(objectId: string): Promise<void>;
|
|
35
|
+
/** Lists known local objects newest first; does not query the cloud. */
|
|
36
|
+
list(options?: {
|
|
37
|
+
prefix?: string;
|
|
38
|
+
includeDeleted?: boolean;
|
|
39
|
+
}): Promise<ListEntry[]>;
|
|
40
|
+
/** Restores saved authorization without prompting. Load local data first. */
|
|
41
|
+
resume(): Promise<BucketState>;
|
|
42
|
+
/** Connects from a user gesture; authorization failures report disconnected state. */
|
|
43
|
+
connect(options?: ConnectOptions): Promise<BucketState>;
|
|
44
|
+
/** Drops authorization and connection while retaining local objects and identity keys. */
|
|
45
|
+
disconnect(): Promise<void>;
|
|
46
|
+
/** Runs one Local sync pass; rejects when disconnected. */
|
|
47
|
+
sync(): Promise<void>;
|
|
48
|
+
/** Enables or disables automatic Local sync; an active pass may finish. */
|
|
49
|
+
setAutoSync(enabled: boolean): void;
|
|
50
|
+
/** Subscribes to state or local changes; returns an unsubscribe function. */
|
|
51
|
+
on(event: "state", handler: (state: BucketState, detail?: string) => void): () => void;
|
|
52
|
+
/** Subscribes to state or local changes; returns an unsubscribe function. */
|
|
53
|
+
on(event: "change", handler: (objectId: string) => void): () => void;
|
|
54
|
+
/** Stops this bucket runtime and releases listeners and sync resources. */
|
|
55
|
+
dispose(): void;
|
|
56
|
+
/* Excluded from this release type: __bindTestTransport */
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/** A binary field handle. Read bytes explicitly through its asynchronous methods.
|
|
60
|
+
* @public
|
|
61
|
+
*/
|
|
62
|
+
export declare type BucketBinaryValue = {
|
|
63
|
+
readonly kind: "binary";
|
|
64
|
+
readonly size: number;
|
|
65
|
+
readonly mimeType?: string;
|
|
66
|
+
readonly name?: string;
|
|
67
|
+
readonly lastModified?: number;
|
|
68
|
+
blob(): Promise<Blob>;
|
|
69
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/** An issued bucket authorization and the bucket key wrapped for its target device.
|
|
73
|
+
* @public
|
|
74
|
+
*/
|
|
75
|
+
export declare type BucketGrant = {
|
|
76
|
+
v: 1;
|
|
77
|
+
grantRecordId: string;
|
|
78
|
+
mfid: string;
|
|
79
|
+
resourceId: string;
|
|
80
|
+
instanceId: string;
|
|
81
|
+
issuedAt: string;
|
|
82
|
+
keyId: string;
|
|
83
|
+
capabilities: ("read" | "write")[];
|
|
84
|
+
envelope: {
|
|
85
|
+
kind: "bucket-key";
|
|
86
|
+
bucketId: string;
|
|
87
|
+
keyId: string;
|
|
88
|
+
targetInstanceId: string;
|
|
89
|
+
targetWrappingPublicJwk: JsonWebKey;
|
|
90
|
+
ephemeralPublicJwk: JsonWebKey;
|
|
91
|
+
wrapAlg: "ECDH-HKDF-SHA-256/AES-GCM-256";
|
|
92
|
+
salt: string;
|
|
93
|
+
iv: string;
|
|
94
|
+
aad: string;
|
|
95
|
+
ciphertext: string;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/** Current object heads and the starting cursor for feed catch-up.
|
|
100
|
+
* @public
|
|
101
|
+
*/
|
|
102
|
+
export declare type BucketIndex = {
|
|
103
|
+
bucketId: string;
|
|
104
|
+
objects: FeedHint[];
|
|
105
|
+
feedCursor: string | null;
|
|
106
|
+
hasMoreFeed: boolean;
|
|
107
|
+
[field: string]: unknown;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
/** The granted non-extractable AES-GCM key and remote bucket identity for app encryption.
|
|
111
|
+
* @public
|
|
112
|
+
*/
|
|
113
|
+
export declare type BucketKey = {
|
|
114
|
+
bucketId: string;
|
|
115
|
+
keyId: string;
|
|
116
|
+
cryptoKey: CryptoKey;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/** Connection state shared with the associated resource.
|
|
120
|
+
* @public
|
|
121
|
+
*/
|
|
122
|
+
export declare type BucketState = "disconnected" | "connecting" | "connected";
|
|
123
|
+
|
|
124
|
+
declare type BucketTransportLike = {
|
|
125
|
+
pullHead(wireObjectId: string): Promise<TransportHeadResult>;
|
|
126
|
+
pullPayload(wireObjectId: string, versionId: string): Promise<TransportPayloadResult>;
|
|
127
|
+
push(wireObjectId: string, plaintext: Uint8Array, expectedHeadVersionId: string | null): Promise<TransportPushResult>;
|
|
128
|
+
listHeads?(): Promise<Map<string, string>>;
|
|
73
129
|
};
|
|
74
130
|
|
|
131
|
+
/** Machine-readable SDK failure with optional HTTP and retry diagnostics.
|
|
132
|
+
* @public
|
|
133
|
+
*/
|
|
134
|
+
export declare class ClientError extends Error {
|
|
135
|
+
readonly code: string;
|
|
136
|
+
readonly status?: number;
|
|
137
|
+
readonly requestId?: string;
|
|
138
|
+
readonly retryable: boolean;
|
|
139
|
+
readonly retryAfterMs?: number;
|
|
140
|
+
readonly maxBytes?: number;
|
|
141
|
+
constructor(code: string, message: string, options?: ClientErrorOptions);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** HTTP diagnostics, retry information, payload limit and original cause.
|
|
145
|
+
* @public
|
|
146
|
+
*/
|
|
147
|
+
export declare type ClientErrorOptions = {
|
|
148
|
+
status?: number;
|
|
149
|
+
requestId?: string;
|
|
150
|
+
retryable?: boolean;
|
|
151
|
+
retryAfterMs?: number;
|
|
152
|
+
maxBytes?: number;
|
|
153
|
+
cause?: unknown;
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
/** App-encrypted bytes and metadata submitted against an expected remote head.
|
|
157
|
+
* @public
|
|
158
|
+
*/
|
|
159
|
+
export declare type CommitInput = {
|
|
160
|
+
meta: VersionMeta;
|
|
161
|
+
/** App-encrypted payload; never submit private plaintext. */
|
|
162
|
+
payload: Blob | Uint8Array;
|
|
163
|
+
/** Last observed head, or null to create an object. */
|
|
164
|
+
expectedHeadVersionId: string | null;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
/** A successful commit or a CAS rejection; other failures throw ClientError.
|
|
168
|
+
* @public
|
|
169
|
+
*/
|
|
170
|
+
export declare type CommitResult = {
|
|
171
|
+
ok: true;
|
|
172
|
+
} | {
|
|
173
|
+
ok: false;
|
|
174
|
+
reason: "version-mismatch" | "conflict";
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
/** Automatic Local synchronization settings; defaults to enabled.
|
|
178
|
+
* @public
|
|
179
|
+
*/
|
|
180
|
+
export declare type ConnectOptions = {
|
|
181
|
+
/** Enable automatic Local sync after connecting; defaults to true. */
|
|
182
|
+
autoSync?: boolean;
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
/** Creates a local Instance with an explicit application ID. No network I/O.
|
|
186
|
+
* @public
|
|
187
|
+
*/
|
|
75
188
|
export declare function createInstance(appId: string): Instance;
|
|
189
|
+
|
|
190
|
+
/** Creates a local Instance; appId defaults to the browser hostname.
|
|
191
|
+
* @public
|
|
192
|
+
*/
|
|
76
193
|
export declare function createInstance(options?: CreateInstanceOptions): Instance;
|
|
77
194
|
|
|
195
|
+
/** Local persistence scope and authorization page settings. Creating an Instance does not connect.
|
|
196
|
+
* @public
|
|
197
|
+
*/
|
|
198
|
+
export declare type CreateInstanceOptions = {
|
|
199
|
+
/** Existing local storage scope; defaults to explicit appId, otherwise "default". */
|
|
200
|
+
namespace?: string;
|
|
201
|
+
/** IndexedDB by default; memory is useful for tests and ephemeral clients. */
|
|
202
|
+
storage?: "indexeddb" | "memory";
|
|
203
|
+
/** Stable lowercase domain-form application ID; defaults to the browser hostname. */
|
|
204
|
+
appId?: string;
|
|
205
|
+
/** Absolute HTTP(S) Auth page URL without credentials, query or fragment. */
|
|
206
|
+
authUrl?: string;
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
/** The current committed version, with optional newest-first ancestry evidence.
|
|
210
|
+
* @public
|
|
211
|
+
*/
|
|
212
|
+
export declare type CurrentVersion = {
|
|
213
|
+
versionId: string;
|
|
214
|
+
headVersionMeta: VersionMeta;
|
|
215
|
+
history?: string[] | null;
|
|
216
|
+
[field: string]: unknown;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
/** An object/version notification that prompts feed catch-up, not an object payload.
|
|
220
|
+
* @public
|
|
221
|
+
*/
|
|
222
|
+
export declare type FeedHint = {
|
|
223
|
+
objectId: string;
|
|
224
|
+
versionId: string;
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
/** One page of changes. Continue from cursor while hasMore is true.
|
|
228
|
+
* @public
|
|
229
|
+
*/
|
|
230
|
+
export declare type FeedPage = {
|
|
231
|
+
entries: FeedHint[];
|
|
232
|
+
cursor: string;
|
|
233
|
+
hasMore: boolean;
|
|
234
|
+
[field: string]: unknown;
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
/** Application identity, authorization and access to Local and Remote buckets.
|
|
238
|
+
* @public
|
|
239
|
+
*/
|
|
240
|
+
export declare type Instance = {
|
|
241
|
+
/** Local persistence namespace; never sent as the remote bucket ID. */
|
|
242
|
+
readonly namespace: string;
|
|
243
|
+
/** Remote access for the default bucket; the app owns encryption and local storage. */
|
|
244
|
+
readonly remote: {
|
|
245
|
+
getBucket(): RemoteBucket;
|
|
246
|
+
};
|
|
247
|
+
/** Current connection state. */
|
|
248
|
+
readonly state: BucketState;
|
|
249
|
+
/** Returns the cached default Local bucket identified by appId. */
|
|
250
|
+
getBucket(): Bucket;
|
|
251
|
+
/** Reads the saved instance identity, or null when absent. */
|
|
252
|
+
getKey(): Promise<InstanceKey | null>;
|
|
253
|
+
/** Creates an identity when disconnected; rejects if a key already exists. */
|
|
254
|
+
createKey(): Promise<InstanceKey>;
|
|
255
|
+
/** Saves a device identity while disconnected. A matching grant for the default bucket may be imported with it. Use resume() to verify access with the server. */
|
|
256
|
+
importKey(key: InstanceKey, options?: {
|
|
257
|
+
bucketGrant: BucketGrant;
|
|
258
|
+
apiUrl: string;
|
|
259
|
+
}): Promise<void>;
|
|
260
|
+
/** Removes the identity and dependent authorization when disconnected. */
|
|
261
|
+
removeKey(): Promise<void>;
|
|
262
|
+
/** Restores saved authorization without prompting. Load local data first. */
|
|
263
|
+
resume(options?: {
|
|
264
|
+
autoSync?: boolean;
|
|
265
|
+
}): Promise<BucketState>;
|
|
266
|
+
/** Connects from a user gesture; authorization failures report disconnected state. */
|
|
267
|
+
connect(options?: {
|
|
268
|
+
autoSync?: boolean;
|
|
269
|
+
}): Promise<BucketState>;
|
|
270
|
+
/** Drops authorization and connection while retaining local objects and identity keys. */
|
|
271
|
+
disconnect(): Promise<void>;
|
|
272
|
+
/** Subscribes to connection state and error notifications; returns an unsubscribe function. */
|
|
273
|
+
on(event: "state", handler: (state: BucketState, error?: ClientError) => void): () => void;
|
|
274
|
+
/** Gets a Local handle for another stable resource label; creation is local-only. */
|
|
275
|
+
createBucket(options: {
|
|
276
|
+
id: string;
|
|
277
|
+
}): Bucket;
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
/** Persisted instance identity with public JWKs and non-extractable private CryptoKeys.
|
|
281
|
+
* @public
|
|
282
|
+
*/
|
|
283
|
+
export declare type InstanceKey = {
|
|
284
|
+
instanceId: string;
|
|
285
|
+
signingPublicJwk: JsonWebKey;
|
|
286
|
+
signingPrivateKey: CryptoKey;
|
|
287
|
+
wrappingPublicJwk: JsonWebKey;
|
|
288
|
+
wrappingPrivateKey: CryptoKey;
|
|
289
|
+
createdAt: string;
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
/** Known local object ID and UTC ISO update time; deleted entries are opt-in.
|
|
293
|
+
* @public
|
|
294
|
+
*/
|
|
295
|
+
export declare type ListEntry = {
|
|
296
|
+
id: string;
|
|
297
|
+
updatedAt: string;
|
|
298
|
+
deleted?: true;
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
/** A Local sync operation requires an active connection.
|
|
302
|
+
* @public
|
|
303
|
+
*/
|
|
78
304
|
export declare class NotConnectedError extends Error {
|
|
79
|
-
|
|
305
|
+
constructor();
|
|
80
306
|
}
|
|
81
307
|
|
|
308
|
+
/** Version metadata and its payload. Consume or cancel Response bodies.
|
|
309
|
+
* @public
|
|
310
|
+
*/
|
|
311
|
+
export declare type ObjectVersion<TPayload = Response> = {
|
|
312
|
+
meta: VersionMeta;
|
|
313
|
+
payload: TPayload;
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
/** The Local sync transport is unavailable.
|
|
317
|
+
* @public
|
|
318
|
+
*/
|
|
82
319
|
export declare class OfflineError extends Error {
|
|
83
|
-
|
|
320
|
+
constructor();
|
|
84
321
|
}
|
|
85
322
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
getPayload(objectId: string, versionId: string, options?: RequestOptions): Promise<Response>;
|
|
121
|
-
commit(input: CommitInput, options?: RequestOptions): Promise<CommitResult>;
|
|
122
|
-
listVersions(objectId: string, versionId: string, options?: PageOptions): Promise<VersionHistory>;
|
|
123
|
-
getIndex(options?: RequestOptions): Promise<BucketIndex>;
|
|
124
|
-
listFeed(options?: PageOptions): Promise<FeedPage>;
|
|
125
|
-
watchFeed(options?: RequestOptions): Promise<AsyncGenerator<FeedHint>>;
|
|
323
|
+
/** Opaque pagination cursor, optional positive page limit and cancellation.
|
|
324
|
+
* @public
|
|
325
|
+
*/
|
|
326
|
+
export declare type PageOptions = RequestOptions & {
|
|
327
|
+
cursor?: string | null;
|
|
328
|
+
limit?: number;
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
/** Storage-independent Remote operations. The application owns payload encryption, merge and recovery.
|
|
332
|
+
* @public
|
|
333
|
+
*/
|
|
334
|
+
export declare interface RemoteBucket {
|
|
335
|
+
/** Returns the granted key handle without a request. Use your own AAD and retain keyId. */
|
|
336
|
+
getBucketKey(options?: RequestOptions): Promise<BucketKey>;
|
|
337
|
+
/** Reads the current head, or null when absent. knownVersionId requests ancestry evidence. */
|
|
338
|
+
getCurrent(objectId: string, options?: RequestOptions & {
|
|
339
|
+
knownVersionId?: string | null;
|
|
340
|
+
}): Promise<CurrentVersion | null>;
|
|
341
|
+
/** Reads metadata and a payload Response; consume or cancel its body. */
|
|
342
|
+
getVersion(objectId: string, versionId: string, options?: RequestOptions): Promise<ObjectVersion>;
|
|
343
|
+
/** Reads metadata for one committed version; missing versions throw. */
|
|
344
|
+
getVersionMeta(objectId: string, versionId: string, options?: RequestOptions): Promise<VersionMeta>;
|
|
345
|
+
/** Returns the encrypted payload Response; consume or cancel its body. */
|
|
346
|
+
getPayload(objectId: string, versionId: string, options?: RequestOptions): Promise<Response>;
|
|
347
|
+
/** Submits encrypted bytes with CAS. Preserve IDs and bytes after uncertain failures. */
|
|
348
|
+
commit(input: CommitInput, options?: RequestOptions): Promise<CommitResult>;
|
|
349
|
+
/** Reads committed-version history anchored at one object/version; follow nextCursor. */
|
|
350
|
+
listVersions(objectId: string, versionId: string, options?: PageOptions): Promise<VersionHistory>;
|
|
351
|
+
/** Reads the current heads snapshot and its feed catch-up cursor. */
|
|
352
|
+
getIndex(options?: RequestOptions): Promise<BucketIndex>;
|
|
353
|
+
/** Reads a feed page; continue from cursor while hasMore is true. */
|
|
354
|
+
listFeed(options?: PageOptions): Promise<FeedPage>;
|
|
355
|
+
/** Resolves when the change feed is ready. Abort or close the stream to stop. */
|
|
356
|
+
watchFeed(options?: RequestOptions): Promise<AsyncGenerator<FeedHint>>;
|
|
126
357
|
}
|
|
127
358
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
maxBytes?: number;
|
|
134
|
-
cause?: unknown;
|
|
359
|
+
/** Cancellation for a Remote operation; requests are not automatically retried.
|
|
360
|
+
* @public
|
|
361
|
+
*/
|
|
362
|
+
export declare type RequestOptions = {
|
|
363
|
+
signal?: AbortSignal;
|
|
135
364
|
};
|
|
136
365
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
readonly maxBytes?: number;
|
|
144
|
-
constructor(code: string, message: string, options?: ClientErrorOptions);
|
|
145
|
-
}
|
|
366
|
+
declare type TransportHeadResult = {
|
|
367
|
+
found: false;
|
|
368
|
+
} | {
|
|
369
|
+
found: true;
|
|
370
|
+
versionId: string;
|
|
371
|
+
};
|
|
146
372
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
wrappingPrivateKey: CryptoKey;
|
|
153
|
-
createdAt: string;
|
|
373
|
+
declare type TransportPayloadResult = {
|
|
374
|
+
found: false;
|
|
375
|
+
} | {
|
|
376
|
+
found: true;
|
|
377
|
+
plaintext: Uint8Array;
|
|
154
378
|
};
|
|
379
|
+
|
|
380
|
+
declare type TransportPushResult = {
|
|
381
|
+
ok: true;
|
|
382
|
+
versionId: string;
|
|
383
|
+
} | {
|
|
384
|
+
ok: false;
|
|
385
|
+
conflict: true;
|
|
386
|
+
remoteVersionId: string | null;
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
/** Committed-version metadata with ancestry and an opaque continuation cursor.
|
|
390
|
+
* @public
|
|
391
|
+
*/
|
|
392
|
+
export declare type VersionHistory = VersionMeta & {
|
|
393
|
+
history: string[];
|
|
394
|
+
nextCursor: string | null;
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
/** Transport metadata. Application plaintext and private metadata must remain encrypted.
|
|
398
|
+
* @public
|
|
399
|
+
*/
|
|
400
|
+
export declare type VersionMeta = {
|
|
401
|
+
/** App-supplied Remote object ID; Remote does not apply Local ID blinding. */
|
|
402
|
+
objectId: string;
|
|
403
|
+
/** Fixed version identity; reuse it with the same bytes after an uncertain outcome. */
|
|
404
|
+
versionId: string;
|
|
405
|
+
/** Direct parents; include the expected CAS head for an update. */
|
|
406
|
+
parentVersionIds: string[];
|
|
407
|
+
/** SHA-256 of the submitted ciphertext bytes when supplied. */
|
|
408
|
+
payloadHash?: string;
|
|
409
|
+
[field: string]: unknown;
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
export { }
|