@twin.org/synchronised-storage-rest-client 0.0.1-next.3 → 0.0.1-next.5

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.
@@ -26,17 +26,33 @@ class SynchronisedStorageClient extends apiCore.BaseRestClient {
26
26
  super(SynchronisedStorageClient._CLASS_NAME, config, "synchronised-storage");
27
27
  }
28
28
  /**
29
- * Synchronise a complete set of changes, assumes this is a trusted node.
30
- * @param changeSetStorageId The id of the change set to synchronise in blob storage.
31
- * @returns Nothing.
29
+ * Get the decryption key for the synchronised storage.
30
+ * This is used to decrypt the data stored in the synchronised storage.
31
+ * @param nodeIdentity The identity of the node requesting the decryption key.
32
+ * @param proof The proof of the request so we know the request is from the specified node.
33
+ * @returns The decryption key.
32
34
  */
33
- async syncChangeSet(changeSetStorageId) {
34
- core.Guards.string(this.CLASS_NAME, "changeSetStorageId", changeSetStorageId);
35
- await this.fetch("/", "GET", {
36
- query: {
37
- changeSetStorageId
35
+ async getDecryptionKey(nodeIdentity, proof) {
36
+ core.Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
37
+ core.Guards.object(this.CLASS_NAME, "proof", proof);
38
+ const response = await this.fetch("/decryption-key", "POST", {
39
+ body: {
40
+ nodeIdentity,
41
+ proof
38
42
  }
39
43
  });
44
+ return response.body.decryptionKey;
45
+ }
46
+ /**
47
+ * Synchronise a set of changes from an untrusted node, assumes this is a trusted node.
48
+ * @param syncChangeSet The change set to synchronise.
49
+ * @returns Nothing.
50
+ */
51
+ async syncChangeSet(syncChangeSet) {
52
+ core.Guards.object(this.CLASS_NAME, "syncChangeSet", syncChangeSet);
53
+ await this.fetch("/sync-changeset", "POST", {
54
+ body: syncChangeSet
55
+ });
40
56
  }
41
57
  }
42
58
 
@@ -24,17 +24,33 @@ class SynchronisedStorageClient extends BaseRestClient {
24
24
  super(SynchronisedStorageClient._CLASS_NAME, config, "synchronised-storage");
25
25
  }
26
26
  /**
27
- * Synchronise a complete set of changes, assumes this is a trusted node.
28
- * @param changeSetStorageId The id of the change set to synchronise in blob storage.
29
- * @returns Nothing.
27
+ * Get the decryption key for the synchronised storage.
28
+ * This is used to decrypt the data stored in the synchronised storage.
29
+ * @param nodeIdentity The identity of the node requesting the decryption key.
30
+ * @param proof The proof of the request so we know the request is from the specified node.
31
+ * @returns The decryption key.
30
32
  */
31
- async syncChangeSet(changeSetStorageId) {
32
- Guards.string(this.CLASS_NAME, "changeSetStorageId", changeSetStorageId);
33
- await this.fetch("/", "GET", {
34
- query: {
35
- changeSetStorageId
33
+ async getDecryptionKey(nodeIdentity, proof) {
34
+ Guards.stringValue(this.CLASS_NAME, "nodeIdentity", nodeIdentity);
35
+ Guards.object(this.CLASS_NAME, "proof", proof);
36
+ const response = await this.fetch("/decryption-key", "POST", {
37
+ body: {
38
+ nodeIdentity,
39
+ proof
36
40
  }
37
41
  });
42
+ return response.body.decryptionKey;
43
+ }
44
+ /**
45
+ * Synchronise a set of changes from an untrusted node, assumes this is a trusted node.
46
+ * @param syncChangeSet The change set to synchronise.
47
+ * @returns Nothing.
48
+ */
49
+ async syncChangeSet(syncChangeSet) {
50
+ Guards.object(this.CLASS_NAME, "syncChangeSet", syncChangeSet);
51
+ await this.fetch("/sync-changeset", "POST", {
52
+ body: syncChangeSet
53
+ });
38
54
  }
39
55
  }
40
56
 
@@ -1,6 +1,7 @@
1
1
  import { BaseRestClient } from "@twin.org/api-core";
2
2
  import type { IBaseRestClientConfig } from "@twin.org/api-models";
3
- import type { ISynchronisedStorageComponent } from "@twin.org/synchronised-storage-models";
3
+ import type { IProof } from "@twin.org/standards-w3c-did";
4
+ import type { ISyncChangeSet, ISynchronisedStorageComponent } from "@twin.org/synchronised-storage-models";
4
5
  /**
5
6
  * Client for performing synchronised storage through to REST endpoints.
6
7
  */
@@ -15,9 +16,17 @@ export declare class SynchronisedStorageClient extends BaseRestClient implements
15
16
  */
16
17
  constructor(config: IBaseRestClientConfig);
17
18
  /**
18
- * Synchronise a complete set of changes, assumes this is a trusted node.
19
- * @param changeSetStorageId The id of the change set to synchronise in blob storage.
19
+ * Get the decryption key for the synchronised storage.
20
+ * This is used to decrypt the data stored in the synchronised storage.
21
+ * @param nodeIdentity The identity of the node requesting the decryption key.
22
+ * @param proof The proof of the request so we know the request is from the specified node.
23
+ * @returns The decryption key.
24
+ */
25
+ getDecryptionKey(nodeIdentity: string, proof: IProof): Promise<string>;
26
+ /**
27
+ * Synchronise a set of changes from an untrusted node, assumes this is a trusted node.
28
+ * @param syncChangeSet The change set to synchronise.
20
29
  * @returns Nothing.
21
30
  */
22
- syncChangeSet(changeSetStorageId: string): Promise<void>;
31
+ syncChangeSet(syncChangeSet: ISyncChangeSet): Promise<void>;
23
32
  }
package/docs/changelog.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.1-next.5](https://github.com/twinfoundation/synchronised-storage/compare/synchronised-storage-rest-client-v0.0.1-next.4...synchronised-storage-rest-client-v0.0.1-next.5) (2025-08-11)
4
+
5
+
6
+ ### Miscellaneous Chores
7
+
8
+ * **synchronised-storage-rest-client:** Synchronize repo versions
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/synchronised-storage-models bumped from 0.0.1-next.4 to 0.0.1-next.5
16
+
17
+ ## [0.0.1-next.4](https://github.com/twinfoundation/synchronised-storage/compare/synchronised-storage-rest-client-v0.0.1-next.3...synchronised-storage-rest-client-v0.0.1-next.4) (2025-08-08)
18
+
19
+
20
+ ### Features
21
+
22
+ * blob storage connector instead of component ([#7](https://github.com/twinfoundation/synchronised-storage/issues/7)) ([ea27241](https://github.com/twinfoundation/synchronised-storage/commit/ea27241cf0810b52ab7a6be7346809d127b7109a))
23
+
24
+
25
+ ### Dependencies
26
+
27
+ * The following workspace dependencies were updated
28
+ * dependencies
29
+ * @twin.org/synchronised-storage-models bumped from 0.0.1-next.3 to 0.0.1-next.4
30
+
3
31
  ## [0.0.1-next.3](https://github.com/twinfoundation/synchronised-storage/compare/synchronised-storage-rest-client-v0.0.1-next.2...synchronised-storage-rest-client-v0.0.1-next.3) (2025-07-25)
4
32
 
5
33
 
@@ -48,19 +48,52 @@ Runtime name for the class.
48
48
 
49
49
  ## Methods
50
50
 
51
- ### syncChangeSet()
51
+ ### getDecryptionKey()
52
52
 
53
- > **syncChangeSet**(`changeSetStorageId`): `Promise`\<`void`\>
53
+ > **getDecryptionKey**(`nodeIdentity`, `proof`): `Promise`\<`string`\>
54
54
 
55
- Synchronise a complete set of changes, assumes this is a trusted node.
55
+ Get the decryption key for the synchronised storage.
56
+ This is used to decrypt the data stored in the synchronised storage.
56
57
 
57
58
  #### Parameters
58
59
 
59
- ##### changeSetStorageId
60
+ ##### nodeIdentity
60
61
 
61
62
  `string`
62
63
 
63
- The id of the change set to synchronise in blob storage.
64
+ The identity of the node requesting the decryption key.
65
+
66
+ ##### proof
67
+
68
+ `IProof`
69
+
70
+ The proof of the request so we know the request is from the specified node.
71
+
72
+ #### Returns
73
+
74
+ `Promise`\<`string`\>
75
+
76
+ The decryption key.
77
+
78
+ #### Implementation of
79
+
80
+ `ISynchronisedStorageComponent.getDecryptionKey`
81
+
82
+ ***
83
+
84
+ ### syncChangeSet()
85
+
86
+ > **syncChangeSet**(`syncChangeSet`): `Promise`\<`void`\>
87
+
88
+ Synchronise a set of changes from an untrusted node, assumes this is a trusted node.
89
+
90
+ #### Parameters
91
+
92
+ ##### syncChangeSet
93
+
94
+ `ISyncChangeSet`
95
+
96
+ The change set to synchronise.
64
97
 
65
98
  #### Returns
66
99
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/synchronised-storage-rest-client",
3
- "version": "0.0.1-next.3",
3
+ "version": "0.0.1-next.5",
4
4
  "description": "Synchronised storage contract implementation which can connect to REST endpoints",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,7 +19,8 @@
19
19
  "@twin.org/core": "next",
20
20
  "@twin.org/entity": "next",
21
21
  "@twin.org/nameof": "next",
22
- "@twin.org/synchronised-storage-models": "0.0.1-next.3"
22
+ "@twin.org/standards-w3c-did": "next",
23
+ "@twin.org/synchronised-storage-models": "0.0.1-next.5"
23
24
  },
24
25
  "main": "./dist/cjs/index.cjs",
25
26
  "module": "./dist/esm/index.mjs",