@storacha/clawracha 0.3.7 → 0.3.8
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 +2 -0
- package/dist/handlers/remote.d.ts.map +1 -1
- package/dist/handlers/remote.js +4 -2
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +2 -1
- package/dist/utils/crypto.d.ts +3 -4
- package/dist/utils/crypto.d.ts.map +1 -1
- package/dist/utils/crypto.js +16 -2
- package/package.json +2 -1
|
@@ -9,11 +9,13 @@
|
|
|
9
9
|
import type { CID } from "multiformats/cid";
|
|
10
10
|
import type { BlockFetcher, ValueView } from "@storacha/ucn/pail/api";
|
|
11
11
|
import type { DecryptionConfig, EncryptedClient } from "@storacha/encrypt-upload-client/types";
|
|
12
|
+
import type { Signer } from "@ucanto/interface";
|
|
12
13
|
export declare function applyRemoteChanges(changedPaths: string[], entries: Map<string, CID>, workspace: string, options?: {
|
|
13
14
|
gateway?: string;
|
|
14
15
|
blocks?: BlockFetcher;
|
|
15
16
|
current?: ValueView;
|
|
16
17
|
encryptedClient?: EncryptedClient;
|
|
17
18
|
decryptionConfig?: DecryptionConfig;
|
|
19
|
+
agent?: Signer;
|
|
18
20
|
}): Promise<void>;
|
|
19
21
|
//# 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;AACtE,OAAO,KAAK,
|
|
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;AACtE,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EAChB,MAAM,uCAAuC,CAAC;AAG/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAwBhD,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,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GACA,OAAO,CAAC,IAAI,CAAC,CA2Df"}
|
package/dist/handlers/remote.js
CHANGED
|
@@ -47,12 +47,14 @@ export async function applyRemoteChanges(changedPaths, entries, workspace, optio
|
|
|
47
47
|
throw err;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
else if (isMarkdown(relativePath) &&
|
|
50
|
+
else if (isMarkdown(relativePath) &&
|
|
51
|
+
options?.blocks &&
|
|
52
|
+
options?.current) {
|
|
51
53
|
// Markdown: resolve via mdsync CRDT merge.
|
|
52
54
|
// For single-device, unencrypted blocks are stored locally.
|
|
53
55
|
// TODO: For multi-device private spaces, add decrypt layer to resolveValue.
|
|
54
56
|
const decrypt = isEncrypted
|
|
55
|
-
? makeDecryptFn(options.encryptedClient, options.decryptionConfig)
|
|
57
|
+
? makeDecryptFn(options.encryptedClient, options.decryptionConfig, options.agent)
|
|
56
58
|
: undefined;
|
|
57
59
|
const content = await mdsync.get(options.blocks, options.current, relativePath, decrypt);
|
|
58
60
|
if (content != null) {
|
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;AA4BxE,qBAAa,UAAU;IACrB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,KAAK,CAAiD;IAC9D,OAAO,CAAC,OAAO,CAA0B;IACzC,OAAO,CAAC,UAAU,CAAgB;IAClC,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,QAAQ,CAAoC;IACpD,OAAO,CAAC,gBAAgB,CAAC,CAAmB;IAC5C,OAAO,CAAC,gBAAgB,CAAC,CAAmB;IAC5C,OAAO,CAAC,eAAe,CAAC,CAAkB;gBAE9B,SAAS,EAAE,MAAM;IAK7B;;;OAGG;IACG,IAAI,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,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;AA4BxE,qBAAa,UAAU;IACrB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,KAAK,CAAiD;IAC9D,OAAO,CAAC,OAAO,CAA0B;IACzC,OAAO,CAAC,UAAU,CAAgB;IAClC,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAA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
|
package/dist/sync.js
CHANGED
|
@@ -78,7 +78,7 @@ export class SyncEngine {
|
|
|
78
78
|
throw new Error("Failed to extract upload delegation");
|
|
79
79
|
this.encryptionConfig = makeEncryptionConfig(agent, config.spaceDID, [planDelForKMS, uploadDel]);
|
|
80
80
|
// For decrypt, uploadDelegation covers space/content/decrypt
|
|
81
|
-
this.decryptionConfig = makeDecryptionConfig(config.spaceDID, uploadDel);
|
|
81
|
+
this.decryptionConfig = makeDecryptionConfig(config.spaceDID, uploadDel, [planDelForKMS, uploadDel]);
|
|
82
82
|
this.encryptedClient = await getEncryptedClient(storachaClient);
|
|
83
83
|
}
|
|
84
84
|
try {
|
|
@@ -276,6 +276,7 @@ export class SyncEngine {
|
|
|
276
276
|
current: this.current ?? undefined,
|
|
277
277
|
encryptedClient: this.encryptedClient,
|
|
278
278
|
decryptionConfig: this.decryptionConfig,
|
|
279
|
+
agent: name.agent,
|
|
279
280
|
});
|
|
280
281
|
}
|
|
281
282
|
this.lastSync = Date.now();
|
package/dist/utils/crypto.d.ts
CHANGED
|
@@ -5,14 +5,13 @@
|
|
|
5
5
|
import type { Block } from "multiformats";
|
|
6
6
|
import type { CID } from "multiformats/cid";
|
|
7
7
|
import type { Client } from "@storacha/client";
|
|
8
|
-
import type { Proof } from "@ucanto/interface";
|
|
8
|
+
import type { Proof, Signer } from "@ucanto/interface";
|
|
9
9
|
type SpaceDID = `did:key:${string}`;
|
|
10
10
|
import type { CryptoAdapter, EncryptionConfig, DecryptionConfig, BlobLike, EncryptedClient } from "@storacha/encrypt-upload-client/types";
|
|
11
11
|
import { Delegation } from "@ucanto/interface";
|
|
12
|
-
import { EdSigner } from "@storacha/client/principal/ed25519";
|
|
13
12
|
export declare function getKMSCryptoAdapter(): CryptoAdapter;
|
|
14
13
|
export declare function getEncryptedClient(storachaClient: Client): Promise<EncryptedClient>;
|
|
15
|
-
export declare function delegatePlanningDelegationToKMS(agent:
|
|
14
|
+
export declare function delegatePlanningDelegationToKMS(agent: Signer, planDelegation: Delegation): Promise<Proof>;
|
|
16
15
|
export declare function makeEncryptionConfig(issuer: {
|
|
17
16
|
did: () => `did:key:${string}`;
|
|
18
17
|
}, spaceDID: SpaceDID, proofs: Proof[]): EncryptionConfig;
|
|
@@ -26,6 +25,6 @@ export declare function encryptToBlockStream(file: BlobLike, encryptionConfig: E
|
|
|
26
25
|
* Create a decrypt function for mdsync resolveValue.
|
|
27
26
|
* Fetches encrypted content by CID via EncryptedClient and returns decrypted bytes.
|
|
28
27
|
*/
|
|
29
|
-
export declare function makeDecryptFn(encryptedClient: EncryptedClient, decryptionConfig: DecryptionConfig): (cid: CID) => Promise<Uint8Array>;
|
|
28
|
+
export declare function makeDecryptFn(encryptedClient: EncryptedClient, decryptionConfig: DecryptionConfig, agent: Signer): (cid: CID) => Promise<Uint8Array>;
|
|
30
29
|
export {};
|
|
31
30
|
//# sourceMappingURL=crypto.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../src/utils/crypto.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../src/utils/crypto.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACvD,KAAK,QAAQ,GAAG,WAAW,MAAM,EAAE,CAAC;AACpC,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,QAAQ,EACR,eAAe,EAChB,MAAM,uCAAuC,CAAC;AAO/C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAU/C,wBAAgB,mBAAmB,IAAI,aAAa,CAInD;AAED,wBAAsB,kBAAkB,CACtC,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,eAAe,CAAC,CAM1B;AAED,wBAAsB,+BAA+B,CACnD,KAAK,EAAE,MAAM,EACb,cAAc,EAAE,UAAU,GACzB,OAAO,CAAC,KAAK,CAAC,CAUhB;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE;IAAE,GAAG,EAAE,MAAM,WAAW,MAAM,EAAE,CAAA;CAAE,EAC1C,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,KAAK,EAAE,GACd,gBAAgB,CAMlB;AAED,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,QAAQ,EAClB,iBAAiB,EAAE,KAAK,EACxB,MAAM,CAAC,EAAE,KAAK,EAAE,GACf,gBAAgB,CAMlB;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,QAAQ,EACd,gBAAgB,EAAE,gBAAgB,GACjC,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAIhC;AAuBD;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,eAAe,EAAE,eAAe,EAChC,gBAAgB,EAAE,gBAAgB,EAClC,KAAK,EAAE,MAAM,GACZ,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,UAAU,CAAC,CAkBnC"}
|
package/dist/utils/crypto.js
CHANGED
|
@@ -6,6 +6,7 @@ import { createGenericKMSAdapter } from "@storacha/encrypt-upload-client/factori
|
|
|
6
6
|
import { create as createEncryptedClient } from "@storacha/encrypt-upload-client";
|
|
7
7
|
import { encryptFile, encryptedBlockStream, } from "@storacha/encrypt-upload-client/utils/encrypt";
|
|
8
8
|
import { delegate } from "@ucanto/core";
|
|
9
|
+
import { decrypt } from "@storacha/capabilities/space";
|
|
9
10
|
const KMS_SERVICE_URL = "https://ucan-kms-production.protocol-labs.workers.dev";
|
|
10
11
|
const KMS_SERVICE_DID = "did:key:z6MksQJobJmBfPhjHWgFXVppqM6Fcjc1k7xu4z6xvusVrtKv";
|
|
11
12
|
let cachedAdapter = null;
|
|
@@ -81,9 +82,22 @@ async function drainStream(stream) {
|
|
|
81
82
|
* Create a decrypt function for mdsync resolveValue.
|
|
82
83
|
* Fetches encrypted content by CID via EncryptedClient and returns decrypted bytes.
|
|
83
84
|
*/
|
|
84
|
-
export function makeDecryptFn(encryptedClient, decryptionConfig) {
|
|
85
|
+
export function makeDecryptFn(encryptedClient, decryptionConfig, agent) {
|
|
85
86
|
return async (cid) => {
|
|
86
|
-
const
|
|
87
|
+
const decryptDelegation = await decrypt.delegate({
|
|
88
|
+
issuer: agent,
|
|
89
|
+
audience: agent,
|
|
90
|
+
with: decryptionConfig.spaceDID,
|
|
91
|
+
nb: {
|
|
92
|
+
resource: cid,
|
|
93
|
+
},
|
|
94
|
+
expiration: Math.floor(Date.now() / 1000) + 60 * 15, // 15 minutes
|
|
95
|
+
proofs: [decryptionConfig.decryptDelegation],
|
|
96
|
+
});
|
|
97
|
+
const { stream } = await encryptedClient.retrieveAndDecryptFile(cid, {
|
|
98
|
+
...decryptionConfig,
|
|
99
|
+
decryptDelegation,
|
|
100
|
+
});
|
|
87
101
|
return drainStream(stream);
|
|
88
102
|
};
|
|
89
103
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storacha/clawracha",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8",
|
|
4
4
|
"description": "OpenClaw plugin for Storacha workspace sync via UCN Pail",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@ipld/car": "^5.2.0",
|
|
30
30
|
"@ipld/dag-cbor": "^9.2.5",
|
|
31
|
+
"@storacha/capabilities": "^2.2.0",
|
|
31
32
|
"@storacha/client": "^2.0.4",
|
|
32
33
|
"@storacha/encrypt-upload-client": "1.1.76-rc.1",
|
|
33
34
|
"@storacha/md-merge": "0.9.0",
|