@storacha/clawracha 0.3.9 ā 0.3.11
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/dist/handlers/remote.d.ts +1 -5
- package/dist/handlers/remote.d.ts.map +1 -1
- package/dist/handlers/remote.js +3 -11
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +6 -2
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +7 -7
- package/package.json +1 -1
|
@@ -8,14 +8,10 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { CID } from "multiformats/cid";
|
|
10
10
|
import type { BlockFetcher, ValueView } from "@storacha/ucn/pail/api";
|
|
11
|
-
import type { DecryptionConfig, EncryptedClient } from "@storacha/encrypt-upload-client/types";
|
|
12
|
-
import type { Signer } from "@ucanto/interface";
|
|
13
11
|
export declare function applyRemoteChanges(changedPaths: string[], entries: Map<string, CID>, workspace: string, options?: {
|
|
14
12
|
gateway?: string;
|
|
15
13
|
blocks?: BlockFetcher;
|
|
16
14
|
current?: ValueView;
|
|
17
|
-
|
|
18
|
-
decryptionConfig?: DecryptionConfig;
|
|
19
|
-
agent?: Signer;
|
|
15
|
+
decrypt?: (cid: CID) => Promise<Uint8Array>;
|
|
20
16
|
}): Promise<void>;
|
|
21
17
|
//# sourceMappingURL=remote.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../../src/handlers/remote.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../../src/handlers/remote.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AA+BtE,wBAAsB,kBAAkB,CACtC,YAAY,EAAE,MAAM,EAAE,EACtB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,EACzB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE;IACR,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;CAC7C,GACA,OAAO,CAAC,IAAI,CAAC,CA6Cf"}
|
package/dist/handlers/remote.js
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
import * as fs from "node:fs/promises";
|
|
10
10
|
import * as path from "node:path";
|
|
11
11
|
import * as mdsync from "../mdsync/index.js";
|
|
12
|
-
import { makeDecryptFn } from "../utils/crypto.js";
|
|
13
12
|
const DEFAULT_GATEWAY = "https://storacha.link";
|
|
14
13
|
const isMarkdown = (filePath) => filePath.endsWith(".md");
|
|
15
14
|
/** Drain a ReadableStream into a single Uint8Array. */
|
|
@@ -33,7 +32,6 @@ async function drainStream(stream) {
|
|
|
33
32
|
}
|
|
34
33
|
export async function applyRemoteChanges(changedPaths, entries, workspace, options) {
|
|
35
34
|
const gateway = options?.gateway ?? DEFAULT_GATEWAY;
|
|
36
|
-
const isEncrypted = !!(options?.encryptedClient && options?.decryptionConfig);
|
|
37
35
|
for (const relativePath of changedPaths) {
|
|
38
36
|
const cid = entries.get(relativePath);
|
|
39
37
|
const fullPath = path.join(workspace, relativePath);
|
|
@@ -52,20 +50,14 @@ export async function applyRemoteChanges(changedPaths, entries, workspace, optio
|
|
|
52
50
|
options?.current) {
|
|
53
51
|
// Markdown: resolve via mdsync CRDT merge.
|
|
54
52
|
// For single-device, unencrypted blocks are stored locally.
|
|
55
|
-
|
|
56
|
-
const decrypt = isEncrypted
|
|
57
|
-
? makeDecryptFn(options.encryptedClient, options.decryptionConfig, options.agent)
|
|
58
|
-
: undefined;
|
|
59
|
-
const content = await mdsync.get(options.blocks, options.current, relativePath, decrypt);
|
|
53
|
+
const content = await mdsync.get(options.blocks, options.current, relativePath, options.decrypt);
|
|
60
54
|
if (content != null) {
|
|
61
55
|
await fs.mkdir(path.dirname(fullPath), { recursive: true });
|
|
62
56
|
await fs.writeFile(fullPath, content);
|
|
63
57
|
}
|
|
64
58
|
}
|
|
65
|
-
else if (
|
|
66
|
-
|
|
67
|
-
const { stream } = await options.encryptedClient.retrieveAndDecryptFile(cid, options.decryptionConfig);
|
|
68
|
-
const bytes = await drainStream(stream);
|
|
59
|
+
else if (options?.decrypt) {
|
|
60
|
+
const bytes = await options.decrypt(cid);
|
|
69
61
|
await fs.mkdir(path.dirname(fullPath), { recursive: true });
|
|
70
62
|
await fs.writeFile(fullPath, bytes);
|
|
71
63
|
}
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EACV,iBAAiB,EAGlB,MAAM,qBAAqB,CAAC;AA6B7B,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,GAAG,EAAE,iBAAiB,QAglBpD"}
|
package/dist/plugin.js
CHANGED
|
@@ -12,6 +12,10 @@ import { SyncEngine } from "./sync.js";
|
|
|
12
12
|
import { resolveAgentWorkspace, getAgentIds } from "./utils/workspace.js";
|
|
13
13
|
import * as z from "zod";
|
|
14
14
|
import { loadDeviceConfig, startWorkspaceSync, doInit, doSetup, doJoin, doGrant, } from "./commands.js";
|
|
15
|
+
import { CID } from "multiformats/basics";
|
|
16
|
+
import { CAR } from "@ucanto/core";
|
|
17
|
+
import { identity } from "multiformats/hashes/identity";
|
|
18
|
+
import { base64 } from "multiformats/bases/base64";
|
|
15
19
|
const activeSyncers = new Map();
|
|
16
20
|
// --- Config helpers ---
|
|
17
21
|
const UpdateParams = z.object({
|
|
@@ -289,9 +293,9 @@ export default function plugin(api) {
|
|
|
289
293
|
console.log(`\nš„ Delegation bundle written to ${opts.output}`);
|
|
290
294
|
}
|
|
291
295
|
else {
|
|
292
|
-
const
|
|
296
|
+
const idCid = CID.createV1(CAR.code, identity.digest(bundleBytes));
|
|
293
297
|
console.log(`\nš„ Delegation bundle for ${targetDID}:\n`);
|
|
294
|
-
console.log(base64);
|
|
298
|
+
console.log(idCid.toString(base64));
|
|
295
299
|
}
|
|
296
300
|
console.log("\nThe target device should run:");
|
|
297
301
|
console.log(` openclaw clawracha join <bundle> --agent <id>`);
|
package/dist/sync.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EAEV,YAAY,EACb,MAAM,kBAAkB,CAAC;AAS1B,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EAEV,YAAY,EACb,MAAM,kBAAkB,CAAC;AAS1B,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA6BxE,qBAAa,UAAU;IACrB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,KAAK,CAAiD;IAC9D,OAAO,CAAC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BAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;YAM5B,WAAW;CAK1B"}
|
package/dist/sync.js
CHANGED
|
@@ -19,7 +19,7 @@ import { makeTempCar } from "./utils/tempcar.js";
|
|
|
19
19
|
import { createStorachaClient } from "./utils/client.js";
|
|
20
20
|
import { decodeDelegation, encodeDelegation } from "./utils/delegation.js";
|
|
21
21
|
import { extract } from "@storacha/client/delegation";
|
|
22
|
-
import { makeEncryptionConfig, makeDecryptionConfig, getEncryptedClient, delegatePlanningDelegationToKMS, } from "./utils/crypto.js";
|
|
22
|
+
import { makeEncryptionConfig, makeDecryptionConfig, getEncryptedClient, delegatePlanningDelegationToKMS, makeDecryptFn, } from "./utils/crypto.js";
|
|
23
23
|
export class SyncEngine {
|
|
24
24
|
workspace;
|
|
25
25
|
blocks;
|
|
@@ -186,9 +186,9 @@ export class SyncEngine {
|
|
|
186
186
|
await applyRemoteChanges(remoteChanges, afterEntries, this.workspace, {
|
|
187
187
|
blocks: this.blocks,
|
|
188
188
|
current: this.current ?? undefined,
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
189
|
+
decrypt: this.decryptionConfig && this.encryptedClient
|
|
190
|
+
? makeDecryptFn(this.encryptedClient, this.decryptionConfig, name.agent)
|
|
191
|
+
: undefined,
|
|
192
192
|
});
|
|
193
193
|
}
|
|
194
194
|
this.lastSync = Date.now();
|
|
@@ -269,9 +269,9 @@ export class SyncEngine {
|
|
|
269
269
|
await applyRemoteChanges(allPaths, entries, this.workspace, {
|
|
270
270
|
blocks: this.blocks,
|
|
271
271
|
current: this.current ?? undefined,
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
272
|
+
decrypt: this.decryptionConfig && this.encryptedClient
|
|
273
|
+
? makeDecryptFn(this.encryptedClient, this.decryptionConfig, name.agent)
|
|
274
|
+
: undefined,
|
|
275
275
|
});
|
|
276
276
|
}
|
|
277
277
|
this.lastSync = Date.now();
|