@twin.org/synchronised-storage-rest-client 0.0.1-next.9 → 0.0.3-next.10

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # TWIN Synchronised Storage REST Client
1
+ # Synchronised Storage REST Client
2
2
 
3
- Synchronised storage contract implementation which can connect to REST endpoints.
3
+ This package provides a client for calling trusted synchronised storage REST endpoints, including decryption key retrieval and submission of change sets from connected nodes.
4
4
 
5
5
  ## Installation
6
6
 
@@ -0,0 +1,4 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export * from "./synchronisedStorageRestClient.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,oCAAoC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./synchronisedStorageRestClient.js\";\n"]}
@@ -0,0 +1,60 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { BaseRestClient } from "@twin.org/api-core";
4
+ import { Guards } from "@twin.org/core";
5
+ import { HeaderHelper, HeaderTypes } from "@twin.org/web";
6
+ /**
7
+ * Client for performing synchronised storage through to REST endpoints.
8
+ */
9
+ export class SynchronisedStorageRestClient extends BaseRestClient {
10
+ /**
11
+ * Runtime name for the class.
12
+ */
13
+ static CLASS_NAME = "SynchronisedStorageRestClient";
14
+ /**
15
+ * Create a new instance of SynchronisedStorageRestClient.
16
+ * @param config The configuration for the client.
17
+ */
18
+ constructor(config) {
19
+ super(SynchronisedStorageRestClient.CLASS_NAME, config, "synchronised-storage");
20
+ }
21
+ /**
22
+ * Returns the class name of the component.
23
+ * @returns The class name of the component.
24
+ */
25
+ className() {
26
+ return SynchronisedStorageRestClient.CLASS_NAME;
27
+ }
28
+ /**
29
+ * Get the decryption key for the synchronised storage.
30
+ * This is used to decrypt the data stored in the synchronised storage.
31
+ * @param trustPayload Trust payload to verify the requesters identity.
32
+ * @returns The decryption key.
33
+ */
34
+ async getDecryptionKey(trustPayload) {
35
+ Guards.stringValue(SynchronisedStorageRestClient.CLASS_NAME, "trustPayload", trustPayload);
36
+ const response = await this.fetch("/decryption-key", "GET", {
37
+ headers: {
38
+ [HeaderTypes.Authorization]: HeaderHelper.createBearer(trustPayload)
39
+ }
40
+ });
41
+ return response.body.decryptionKey;
42
+ }
43
+ /**
44
+ * Synchronise a set of changes from an untrusted node, assumes this is a trusted node.
45
+ * @param syncChangeSet The change set to synchronise.
46
+ * @param trustPayload Trust payload to verify the requesters identity.
47
+ * @returns Nothing.
48
+ */
49
+ async syncChangeSet(syncChangeSet, trustPayload) {
50
+ Guards.object(SynchronisedStorageRestClient.CLASS_NAME, "syncChangeSet", syncChangeSet);
51
+ Guards.stringValue(SynchronisedStorageRestClient.CLASS_NAME, "trustPayload", trustPayload);
52
+ await this.fetch("/sync-changeset", "POST", {
53
+ headers: {
54
+ [HeaderTypes.Authorization]: HeaderHelper.createBearer(trustPayload)
55
+ },
56
+ body: syncChangeSet
57
+ });
58
+ }
59
+ }
60
+ //# sourceMappingURL=synchronisedStorageRestClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"synchronisedStorageRestClient.js","sourceRoot":"","sources":["../../src/synchronisedStorageRestClient.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AASxC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE1D;;GAEG;AACH,MAAM,OAAO,6BACZ,SAAQ,cAAc;IAGtB;;OAEG;IACI,MAAM,CAAU,UAAU,mCAAmD;IAEpF;;;OAGG;IACH,YAAY,MAA6B;QACxC,KAAK,CAAC,6BAA6B,CAAC,UAAU,EAAE,MAAM,EAAE,sBAAsB,CAAC,CAAC;IACjF,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,6BAA6B,CAAC,UAAU,CAAC;IACjD,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,gBAAgB,CAAC,YAAqB;QAClD,MAAM,CAAC,WAAW,CACjB,6BAA6B,CAAC,UAAU,kBAExC,YAAY,CACZ,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAChC,iBAAiB,EACjB,KAAK,EACL;YACC,OAAO,EAAE;gBACR,CAAC,WAAW,CAAC,aAAa,CAAC,EAAE,YAAY,CAAC,YAAY,CAAC,YAAY,CAAC;aACpE;SACD,CACD,CAAC;QAEF,OAAO,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC;IACpC,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,aAAa,CAAC,aAA6B,EAAE,YAAqB;QAC9E,MAAM,CAAC,MAAM,CACZ,6BAA6B,CAAC,UAAU,mBAExC,aAAa,CACb,CAAC;QAEF,MAAM,CAAC,WAAW,CACjB,6BAA6B,CAAC,UAAU,kBAExC,YAAY,CACZ,CAAC;QAEF,MAAM,IAAI,CAAC,KAAK,CAA4C,iBAAiB,EAAE,MAAM,EAAE;YACtF,OAAO,EAAE;gBACR,CAAC,WAAW,CAAC,aAAa,CAAC,EAAE,YAAY,CAAC,YAAY,CAAC,YAAY,CAAC;aACpE;YACD,IAAI,EAAE,aAAa;SACnB,CAAC,CAAC;IACJ,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseRestClient } from \"@twin.org/api-core\";\nimport type { IBaseRestClientConfig, INoContentResponse } from \"@twin.org/api-models\";\nimport { Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type {\n\tISyncChangeSet,\n\tISyncChangeSetRequest,\n\tISyncDecryptionKeyRequest,\n\tISyncDecryptionKeyResponse,\n\tISynchronisedStorageComponent\n} from \"@twin.org/synchronised-storage-models\";\nimport { HeaderHelper, HeaderTypes } from \"@twin.org/web\";\n\n/**\n * Client for performing synchronised storage through to REST endpoints.\n */\nexport class SynchronisedStorageRestClient\n\textends BaseRestClient\n\timplements ISynchronisedStorageComponent\n{\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<SynchronisedStorageRestClient>();\n\n\t/**\n\t * Create a new instance of SynchronisedStorageRestClient.\n\t * @param config The configuration for the client.\n\t */\n\tconstructor(config: IBaseRestClientConfig) {\n\t\tsuper(SynchronisedStorageRestClient.CLASS_NAME, config, \"synchronised-storage\");\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn SynchronisedStorageRestClient.CLASS_NAME;\n\t}\n\n\t/**\n\t * Get the decryption key for the synchronised storage.\n\t * This is used to decrypt the data stored in the synchronised storage.\n\t * @param trustPayload Trust payload to verify the requesters identity.\n\t * @returns The decryption key.\n\t */\n\tpublic async getDecryptionKey(trustPayload: unknown): Promise<string> {\n\t\tGuards.stringValue(\n\t\t\tSynchronisedStorageRestClient.CLASS_NAME,\n\t\t\tnameof(trustPayload),\n\t\t\ttrustPayload\n\t\t);\n\n\t\tconst response = await this.fetch<ISyncDecryptionKeyRequest, ISyncDecryptionKeyResponse>(\n\t\t\t\"/decryption-key\",\n\t\t\t\"GET\",\n\t\t\t{\n\t\t\t\theaders: {\n\t\t\t\t\t[HeaderTypes.Authorization]: HeaderHelper.createBearer(trustPayload)\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn response.body.decryptionKey;\n\t}\n\n\t/**\n\t * Synchronise a set of changes from an untrusted node, assumes this is a trusted node.\n\t * @param syncChangeSet The change set to synchronise.\n\t * @param trustPayload Trust payload to verify the requesters identity.\n\t * @returns Nothing.\n\t */\n\tpublic async syncChangeSet(syncChangeSet: ISyncChangeSet, trustPayload: unknown): Promise<void> {\n\t\tGuards.object<ISyncChangeSet>(\n\t\t\tSynchronisedStorageRestClient.CLASS_NAME,\n\t\t\tnameof(syncChangeSet),\n\t\t\tsyncChangeSet\n\t\t);\n\n\t\tGuards.stringValue(\n\t\t\tSynchronisedStorageRestClient.CLASS_NAME,\n\t\t\tnameof(trustPayload),\n\t\t\ttrustPayload\n\t\t);\n\n\t\tawait this.fetch<ISyncChangeSetRequest, INoContentResponse>(\"/sync-changeset\", \"POST\", {\n\t\t\theaders: {\n\t\t\t\t[HeaderTypes.Authorization]: HeaderHelper.createBearer(trustPayload)\n\t\t\t},\n\t\t\tbody: syncChangeSet\n\t\t});\n\t}\n}\n"]}
@@ -1 +1 @@
1
- export * from "./synchronisedStorageClient";
1
+ export * from "./synchronisedStorageRestClient.js";
@@ -1,32 +1,36 @@
1
1
  import { BaseRestClient } from "@twin.org/api-core";
2
2
  import type { IBaseRestClientConfig } from "@twin.org/api-models";
3
- import type { IProof } from "@twin.org/standards-w3c-did";
4
3
  import type { ISyncChangeSet, ISynchronisedStorageComponent } from "@twin.org/synchronised-storage-models";
5
4
  /**
6
5
  * Client for performing synchronised storage through to REST endpoints.
7
6
  */
8
- export declare class SynchronisedStorageClient extends BaseRestClient implements ISynchronisedStorageComponent {
7
+ export declare class SynchronisedStorageRestClient extends BaseRestClient implements ISynchronisedStorageComponent {
9
8
  /**
10
9
  * Runtime name for the class.
11
10
  */
12
- readonly CLASS_NAME: string;
11
+ static readonly CLASS_NAME: string;
13
12
  /**
14
- * Create a new instance of SynchronisedStorageClient.
13
+ * Create a new instance of SynchronisedStorageRestClient.
15
14
  * @param config The configuration for the client.
16
15
  */
17
16
  constructor(config: IBaseRestClientConfig);
17
+ /**
18
+ * Returns the class name of the component.
19
+ * @returns The class name of the component.
20
+ */
21
+ className(): string;
18
22
  /**
19
23
  * Get the decryption key for the synchronised storage.
20
24
  * 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.
25
+ * @param trustPayload Trust payload to verify the requesters identity.
23
26
  * @returns The decryption key.
24
27
  */
25
- getDecryptionKey(nodeIdentity: string, proof: IProof): Promise<string>;
28
+ getDecryptionKey(trustPayload: unknown): Promise<string>;
26
29
  /**
27
30
  * Synchronise a set of changes from an untrusted node, assumes this is a trusted node.
28
31
  * @param syncChangeSet The change set to synchronise.
32
+ * @param trustPayload Trust payload to verify the requesters identity.
29
33
  * @returns Nothing.
30
34
  */
31
- syncChangeSet(syncChangeSet: ISyncChangeSet): Promise<void>;
35
+ syncChangeSet(syncChangeSet: ISyncChangeSet, trustPayload: unknown): Promise<void>;
32
36
  }
package/docs/changelog.md CHANGED
@@ -1,5 +1,250 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.3-next.10](https://github.com/twinfoundation/synchronised-storage/compare/synchronised-storage-rest-client-v0.0.3-next.9...synchronised-storage-rest-client-v0.0.3-next.10) (2026-03-20)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * remove redundant code ([19edb23](https://github.com/twinfoundation/synchronised-storage/commit/19edb236f318b9c9454a64259d0ab5098a0c8173))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/synchronised-storage-models bumped from 0.0.3-next.9 to 0.0.3-next.10
16
+
17
+ ## [0.0.3-next.9](https://github.com/twinfoundation/synchronised-storage/compare/synchronised-storage-rest-client-v0.0.3-next.8...synchronised-storage-rest-client-v0.0.3-next.9) (2026-03-04)
18
+
19
+
20
+ ### Miscellaneous Chores
21
+
22
+ * **synchronised-storage-rest-client:** Synchronize repo versions
23
+
24
+
25
+ ### Dependencies
26
+
27
+ * The following workspace dependencies were updated
28
+ * dependencies
29
+ * @twin.org/synchronised-storage-models bumped from 0.0.3-next.8 to 0.0.3-next.9
30
+
31
+ ## [0.0.3-next.8](https://github.com/twinfoundation/synchronised-storage/compare/synchronised-storage-rest-client-v0.0.3-next.7...synchronised-storage-rest-client-v0.0.3-next.8) (2026-02-25)
32
+
33
+
34
+ ### Miscellaneous Chores
35
+
36
+ * **synchronised-storage-rest-client:** Synchronize repo versions
37
+
38
+
39
+ ### Dependencies
40
+
41
+ * The following workspace dependencies were updated
42
+ * dependencies
43
+ * @twin.org/synchronised-storage-models bumped from 0.0.3-next.7 to 0.0.3-next.8
44
+
45
+ ## [0.0.3-next.7](https://github.com/twinfoundation/synchronised-storage/compare/synchronised-storage-rest-client-v0.0.3-next.6...synchronised-storage-rest-client-v0.0.3-next.7) (2026-01-28)
46
+
47
+
48
+ ### Miscellaneous Chores
49
+
50
+ * **synchronised-storage-rest-client:** Synchronize repo versions
51
+
52
+
53
+ ### Dependencies
54
+
55
+ * The following workspace dependencies were updated
56
+ * dependencies
57
+ * @twin.org/synchronised-storage-models bumped from 0.0.3-next.6 to 0.0.3-next.7
58
+
59
+ ## [0.0.3-next.6](https://github.com/twinfoundation/synchronised-storage/compare/synchronised-storage-rest-client-v0.0.3-next.5...synchronised-storage-rest-client-v0.0.3-next.6) (2026-01-22)
60
+
61
+
62
+ ### Miscellaneous Chores
63
+
64
+ * **synchronised-storage-rest-client:** Synchronize repo versions
65
+
66
+
67
+ ### Dependencies
68
+
69
+ * The following workspace dependencies were updated
70
+ * dependencies
71
+ * @twin.org/synchronised-storage-models bumped from 0.0.3-next.5 to 0.0.3-next.6
72
+
73
+ ## [0.0.3-next.5](https://github.com/twinfoundation/synchronised-storage/compare/synchronised-storage-rest-client-v0.0.3-next.4...synchronised-storage-rest-client-v0.0.3-next.5) (2026-01-19)
74
+
75
+
76
+ ### Features
77
+
78
+ * remove unused dependencies ([518c460](https://github.com/twinfoundation/synchronised-storage/commit/518c460d2e5e2b2c487565acb5162a03ddb85eae))
79
+
80
+
81
+ ### Dependencies
82
+
83
+ * The following workspace dependencies were updated
84
+ * dependencies
85
+ * @twin.org/synchronised-storage-models bumped from 0.0.3-next.4 to 0.0.3-next.5
86
+
87
+ ## [0.0.3-next.4](https://github.com/twinfoundation/synchronised-storage/compare/synchronised-storage-rest-client-v0.0.3-next.3...synchronised-storage-rest-client-v0.0.3-next.4) (2026-01-15)
88
+
89
+
90
+ ### Miscellaneous Chores
91
+
92
+ * **synchronised-storage-rest-client:** Synchronize repo versions
93
+
94
+
95
+ ### Dependencies
96
+
97
+ * The following workspace dependencies were updated
98
+ * dependencies
99
+ * @twin.org/synchronised-storage-models bumped from 0.0.3-next.3 to 0.0.3-next.4
100
+
101
+ ## [0.0.3-next.3](https://github.com/twinfoundation/synchronised-storage/compare/synchronised-storage-rest-client-v0.0.3-next.2...synchronised-storage-rest-client-v0.0.3-next.3) (2026-01-12)
102
+
103
+
104
+ ### Features
105
+
106
+ * add trustPayload guards ([cf1622f](https://github.com/twinfoundation/synchronised-storage/commit/cf1622f8b65a4b77032e31ecaa41664499f4c892))
107
+
108
+
109
+ ### Dependencies
110
+
111
+ * The following workspace dependencies were updated
112
+ * dependencies
113
+ * @twin.org/synchronised-storage-models bumped from 0.0.3-next.2 to 0.0.3-next.3
114
+
115
+ ## [0.0.3-next.2](https://github.com/twinfoundation/synchronised-storage/compare/synchronised-storage-rest-client-v0.0.3-next.1...synchronised-storage-rest-client-v0.0.3-next.2) (2025-12-04)
116
+
117
+
118
+ ### Features
119
+
120
+ * use trust component ([424f0d6](https://github.com/twinfoundation/synchronised-storage/commit/424f0d6aaacfdc7700c46fe6c2def23b2eacddc9))
121
+
122
+
123
+ ### Dependencies
124
+
125
+ * The following workspace dependencies were updated
126
+ * dependencies
127
+ * @twin.org/synchronised-storage-models bumped from 0.0.3-next.1 to 0.0.3-next.2
128
+
129
+ ## [0.0.3-next.1](https://github.com/twinfoundation/synchronised-storage/compare/synchronised-storage-rest-client-v0.0.3-next.0...synchronised-storage-rest-client-v0.0.3-next.1) (2025-11-12)
130
+
131
+
132
+ ### Features
133
+
134
+ * add context id features ([#24](https://github.com/twinfoundation/synchronised-storage/issues/24)) ([5266b18](https://github.com/twinfoundation/synchronised-storage/commit/5266b18088317c7dc274a209a79102a6fc88a8e4))
135
+ * add rights management integration ([d003d33](https://github.com/twinfoundation/synchronised-storage/commit/d003d33d2d2b4a4aa1379071eed71a707ebcb4de))
136
+ * add validate-locales ([e3d7b98](https://github.com/twinfoundation/synchronised-storage/commit/e3d7b98839e9ca624855717c8957d572c4e09abf))
137
+ * blob storage connector instead of component ([#7](https://github.com/twinfoundation/synchronised-storage/issues/7)) ([ea27241](https://github.com/twinfoundation/synchronised-storage/commit/ea27241cf0810b52ab7a6be7346809d127b7109a))
138
+ * eslint migration to flat config ([f601c14](https://github.com/twinfoundation/synchronised-storage/commit/f601c14f6adef3290554dc7df6e6b3528aa0dc2b))
139
+ * initial commit ([16949b8](https://github.com/twinfoundation/synchronised-storage/commit/16949b8e5bdb190f053c52af352290e3fd964f9a))
140
+ * update framework core ([99f09cc](https://github.com/twinfoundation/synchronised-storage/commit/99f09cc94cfb9fff6b3a345775eeae2ab3192ed2))
141
+ * update to in built vc auth mechanism ([411a371](https://github.com/twinfoundation/synchronised-storage/commit/411a3716830195ebf54755a1633b05d5c3f96754))
142
+
143
+
144
+ ### Dependencies
145
+
146
+ * The following workspace dependencies were updated
147
+ * dependencies
148
+ * @twin.org/synchronised-storage-models bumped from 0.0.3-next.0 to 0.0.3-next.1
149
+
150
+ ## [0.0.1-next.16](https://github.com/twinfoundation/synchronised-storage/compare/synchronised-storage-rest-client-v0.0.1-next.15...synchronised-storage-rest-client-v0.0.1-next.16) (2025-10-09)
151
+
152
+
153
+ ### Features
154
+
155
+ * add validate-locales ([e3d7b98](https://github.com/twinfoundation/synchronised-storage/commit/e3d7b98839e9ca624855717c8957d572c4e09abf))
156
+
157
+
158
+ ### Dependencies
159
+
160
+ * The following workspace dependencies were updated
161
+ * dependencies
162
+ * @twin.org/synchronised-storage-models bumped from 0.0.1-next.15 to 0.0.1-next.16
163
+
164
+ ## [0.0.1-next.15](https://github.com/twinfoundation/synchronised-storage/compare/synchronised-storage-rest-client-v0.0.1-next.14...synchronised-storage-rest-client-v0.0.1-next.15) (2025-09-23)
165
+
166
+
167
+ ### Features
168
+
169
+ * update to in built vc auth mechanism ([411a371](https://github.com/twinfoundation/synchronised-storage/commit/411a3716830195ebf54755a1633b05d5c3f96754))
170
+
171
+
172
+ ### Dependencies
173
+
174
+ * The following workspace dependencies were updated
175
+ * dependencies
176
+ * @twin.org/synchronised-storage-models bumped from 0.0.1-next.14 to 0.0.1-next.15
177
+
178
+ ## [0.0.1-next.14](https://github.com/twinfoundation/synchronised-storage/compare/synchronised-storage-rest-client-v0.0.1-next.13...synchronised-storage-rest-client-v0.0.1-next.14) (2025-09-22)
179
+
180
+
181
+ ### Features
182
+
183
+ * add rights management integration ([d003d33](https://github.com/twinfoundation/synchronised-storage/commit/d003d33d2d2b4a4aa1379071eed71a707ebcb4de))
184
+
185
+
186
+ ### Dependencies
187
+
188
+ * The following workspace dependencies were updated
189
+ * dependencies
190
+ * @twin.org/synchronised-storage-models bumped from 0.0.1-next.13 to 0.0.1-next.14
191
+
192
+ ## [0.0.1-next.13](https://github.com/twinfoundation/synchronised-storage/compare/synchronised-storage-rest-client-v0.0.1-next.12...synchronised-storage-rest-client-v0.0.1-next.13) (2025-08-29)
193
+
194
+
195
+ ### Features
196
+
197
+ * eslint migration to flat config ([f601c14](https://github.com/twinfoundation/synchronised-storage/commit/f601c14f6adef3290554dc7df6e6b3528aa0dc2b))
198
+
199
+
200
+ ### Dependencies
201
+
202
+ * The following workspace dependencies were updated
203
+ * dependencies
204
+ * @twin.org/synchronised-storage-models bumped from 0.0.1-next.12 to 0.0.1-next.13
205
+
206
+ ## [0.0.1-next.12](https://github.com/twinfoundation/synchronised-storage/compare/synchronised-storage-rest-client-v0.0.1-next.11...synchronised-storage-rest-client-v0.0.1-next.12) (2025-08-21)
207
+
208
+
209
+ ### Features
210
+
211
+ * update framework core ([99f09cc](https://github.com/twinfoundation/synchronised-storage/commit/99f09cc94cfb9fff6b3a345775eeae2ab3192ed2))
212
+
213
+
214
+ ### Dependencies
215
+
216
+ * The following workspace dependencies were updated
217
+ * dependencies
218
+ * @twin.org/synchronised-storage-models bumped from 0.0.1-next.11 to 0.0.1-next.12
219
+
220
+ ## [0.0.1-next.11](https://github.com/twinfoundation/synchronised-storage/compare/synchronised-storage-rest-client-v0.0.1-next.10...synchronised-storage-rest-client-v0.0.1-next.11) (2025-08-15)
221
+
222
+
223
+ ### Miscellaneous Chores
224
+
225
+ * **synchronised-storage-rest-client:** Synchronize repo versions
226
+
227
+
228
+ ### Dependencies
229
+
230
+ * The following workspace dependencies were updated
231
+ * dependencies
232
+ * @twin.org/synchronised-storage-models bumped from 0.0.1-next.10 to 0.0.1-next.11
233
+
234
+ ## [0.0.1-next.10](https://github.com/twinfoundation/synchronised-storage/compare/synchronised-storage-rest-client-v0.0.1-next.9...synchronised-storage-rest-client-v0.0.1-next.10) (2025-08-15)
235
+
236
+
237
+ ### Miscellaneous Chores
238
+
239
+ * **synchronised-storage-rest-client:** Synchronize repo versions
240
+
241
+
242
+ ### Dependencies
243
+
244
+ * The following workspace dependencies were updated
245
+ * dependencies
246
+ * @twin.org/synchronised-storage-models bumped from 0.0.1-next.9 to 0.0.1-next.10
247
+
3
248
  ## [0.0.1-next.9](https://github.com/twinfoundation/synchronised-storage/compare/synchronised-storage-rest-client-v0.0.1-next.8...synchronised-storage-rest-client-v0.0.1-next.9) (2025-08-13)
4
249
 
5
250
 
@@ -126,4 +371,4 @@
126
371
  * dependencies
127
372
  * @twin.org/synchronised-storage-models bumped from 0.0.1-next.0 to 0.0.1-next.1
128
373
 
129
- ## @twin.org/synchronised-storage-rest-client - Changelog
374
+ ## Changelog
package/docs/examples.md CHANGED
@@ -1 +1,56 @@
1
- # @twin.org/synchronised-storage-rest-client - Examples
1
+ # Synchronised Storage REST Client Examples
2
+
3
+ These snippets show how to call trusted synchronisation endpoints from a node or backend process using strongly typed request data.
4
+
5
+ ## SynchronisedStorageRestClient
6
+
7
+ ```typescript
8
+ import { SynchronisedStorageRestClient } from '@twin.org/synchronised-storage-rest-client';
9
+
10
+ const client = new SynchronisedStorageRestClient({
11
+ endpoint: 'https://api.example.net'
12
+ });
13
+
14
+ const className = client.className();
15
+
16
+ console.log(className); // SynchronisedStorageRestClient
17
+ ```
18
+
19
+ ```typescript
20
+ import {
21
+ SynchronisedStorageContexts,
22
+ SynchronisedStorageTypes,
23
+ type ISyncChangeSet
24
+ } from '@twin.org/synchronised-storage-models';
25
+ import { SynchronisedStorageRestClient } from '@twin.org/synchronised-storage-rest-client';
26
+
27
+ const client = new SynchronisedStorageRestClient({
28
+ endpoint: 'https://api.example.net'
29
+ });
30
+
31
+ const trustPayload = 'eyJhbGciOiJFZERTQSJ9.sample-payload.signature';
32
+ const decryptionKey = await client.getDecryptionKey(trustPayload);
33
+
34
+ console.log(decryptionKey.length); // 44
35
+
36
+ const changeSet: ISyncChangeSet = {
37
+ '@context': SynchronisedStorageContexts.Context,
38
+ type: SynchronisedStorageTypes.ChangeSet,
39
+ id: 'changeset-20260310-01',
40
+ storageKey: 'profile',
41
+ dateCreated: '2026-03-10T10:00:00.000Z',
42
+ dateModified: '2026-03-10T10:00:00.000Z',
43
+ nodeIdentity: 'did:iota:node-2',
44
+ changes: [
45
+ {
46
+ operation: 'set',
47
+ id: 'profile-4',
48
+ entity: {
49
+ dateModified: '2026-03-10T10:00:00.000Z'
50
+ }
51
+ }
52
+ ]
53
+ };
54
+
55
+ await client.syncChangeSet(changeSet, trustPayload);
56
+ ```
@@ -1,4 +1,4 @@
1
- # Class: SynchronisedStorageClient
1
+ # Class: SynchronisedStorageRestClient
2
2
 
3
3
  Client for performing synchronised storage through to REST endpoints.
4
4
 
@@ -14,9 +14,9 @@ Client for performing synchronised storage through to REST endpoints.
14
14
 
15
15
  ### Constructor
16
16
 
17
- > **new SynchronisedStorageClient**(`config`): `SynchronisedStorageClient`
17
+ > **new SynchronisedStorageRestClient**(`config`): `SynchronisedStorageRestClient`
18
18
 
19
- Create a new instance of SynchronisedStorageClient.
19
+ Create a new instance of SynchronisedStorageRestClient.
20
20
 
21
21
  #### Parameters
22
22
 
@@ -28,7 +28,7 @@ The configuration for the client.
28
28
 
29
29
  #### Returns
30
30
 
31
- `SynchronisedStorageClient`
31
+ `SynchronisedStorageRestClient`
32
32
 
33
33
  #### Overrides
34
34
 
@@ -36,38 +36,46 @@ The configuration for the client.
36
36
 
37
37
  ## Properties
38
38
 
39
- ### CLASS\_NAME
39
+ ### CLASS\_NAME {#class_name}
40
40
 
41
- > `readonly` **CLASS\_NAME**: `string` = `SynchronisedStorageClient._CLASS_NAME`
41
+ > `readonly` `static` **CLASS\_NAME**: `string`
42
42
 
43
43
  Runtime name for the class.
44
44
 
45
+ ## Methods
46
+
47
+ ### className() {#classname}
48
+
49
+ > **className**(): `string`
50
+
51
+ Returns the class name of the component.
52
+
53
+ #### Returns
54
+
55
+ `string`
56
+
57
+ The class name of the component.
58
+
45
59
  #### Implementation of
46
60
 
47
- `ISynchronisedStorageComponent.CLASS_NAME`
61
+ `ISynchronisedStorageComponent.className`
48
62
 
49
- ## Methods
63
+ ***
50
64
 
51
- ### getDecryptionKey()
65
+ ### getDecryptionKey() {#getdecryptionkey}
52
66
 
53
- > **getDecryptionKey**(`nodeIdentity`, `proof`): `Promise`\<`string`\>
67
+ > **getDecryptionKey**(`trustPayload`): `Promise`\<`string`\>
54
68
 
55
69
  Get the decryption key for the synchronised storage.
56
70
  This is used to decrypt the data stored in the synchronised storage.
57
71
 
58
72
  #### Parameters
59
73
 
60
- ##### nodeIdentity
61
-
62
- `string`
63
-
64
- The identity of the node requesting the decryption key.
74
+ ##### trustPayload
65
75
 
66
- ##### proof
76
+ `unknown`
67
77
 
68
- `IProof`
69
-
70
- The proof of the request so we know the request is from the specified node.
78
+ Trust payload to verify the requesters identity.
71
79
 
72
80
  #### Returns
73
81
 
@@ -81,9 +89,9 @@ The decryption key.
81
89
 
82
90
  ***
83
91
 
84
- ### syncChangeSet()
92
+ ### syncChangeSet() {#syncchangeset}
85
93
 
86
- > **syncChangeSet**(`syncChangeSet`): `Promise`\<`void`\>
94
+ > **syncChangeSet**(`syncChangeSet`, `trustPayload`): `Promise`\<`void`\>
87
95
 
88
96
  Synchronise a set of changes from an untrusted node, assumes this is a trusted node.
89
97
 
@@ -95,6 +103,12 @@ Synchronise a set of changes from an untrusted node, assumes this is a trusted n
95
103
 
96
104
  The change set to synchronise.
97
105
 
106
+ ##### trustPayload
107
+
108
+ `unknown`
109
+
110
+ Trust payload to verify the requesters identity.
111
+
98
112
  #### Returns
99
113
 
100
114
  `Promise`\<`void`\>
@@ -2,4 +2,4 @@
2
2
 
3
3
  ## Classes
4
4
 
5
- - [SynchronisedStorageClient](classes/SynchronisedStorageClient.md)
5
+ - [SynchronisedStorageRestClient](classes/SynchronisedStorageRestClient.md)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@twin.org/synchronised-storage-rest-client",
3
- "version": "0.0.1-next.9",
4
- "description": "Synchronised storage contract implementation which can connect to REST endpoints",
3
+ "version": "0.0.3-next.10",
4
+ "description": "REST client for trusted decryption key retrieval and change set synchronisation.",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/twinfoundation/synchronised-storage.git",
@@ -16,28 +16,39 @@
16
16
  "dependencies": {
17
17
  "@twin.org/api-core": "next",
18
18
  "@twin.org/api-models": "next",
19
+ "@twin.org/context": "next",
19
20
  "@twin.org/core": "next",
20
21
  "@twin.org/entity": "next",
21
22
  "@twin.org/nameof": "next",
22
- "@twin.org/standards-w3c-did": "next",
23
- "@twin.org/synchronised-storage-models": "0.0.1-next.9"
23
+ "@twin.org/synchronised-storage-models": "0.0.3-next.10",
24
+ "@twin.org/web": "next"
24
25
  },
25
- "main": "./dist/cjs/index.cjs",
26
- "module": "./dist/esm/index.mjs",
26
+ "main": "./dist/es/index.js",
27
27
  "types": "./dist/types/index.d.ts",
28
28
  "exports": {
29
29
  ".": {
30
30
  "types": "./dist/types/index.d.ts",
31
- "require": "./dist/cjs/index.cjs",
32
- "import": "./dist/esm/index.mjs"
31
+ "import": "./dist/es/index.js",
32
+ "default": "./dist/es/index.js"
33
33
  },
34
34
  "./locales/*.json": "./locales/*.json"
35
35
  },
36
36
  "files": [
37
- "dist/cjs",
38
- "dist/esm",
37
+ "dist/es",
39
38
  "dist/types",
40
39
  "locales",
41
40
  "docs"
42
- ]
41
+ ],
42
+ "keywords": [
43
+ "twin",
44
+ "trade",
45
+ "iota",
46
+ "framework",
47
+ "blockchain",
48
+ "synchronised-storage"
49
+ ],
50
+ "bugs": {
51
+ "url": "git+https://github.com/twinfoundation/synchronised-storage/issues"
52
+ },
53
+ "homepage": "https://twindev.org"
43
54
  }
@@ -1,59 +0,0 @@
1
- 'use strict';
2
-
3
- var apiCore = require('@twin.org/api-core');
4
- var core = require('@twin.org/core');
5
-
6
- // Copyright 2024 IOTA Stiftung.
7
- // SPDX-License-Identifier: Apache-2.0.
8
- /**
9
- * Client for performing synchronised storage through to REST endpoints.
10
- */
11
- class SynchronisedStorageClient extends apiCore.BaseRestClient {
12
- /**
13
- * Runtime name for the class.
14
- * @internal
15
- */
16
- static _CLASS_NAME = "SynchronisedStorageClient";
17
- /**
18
- * Runtime name for the class.
19
- */
20
- CLASS_NAME = SynchronisedStorageClient._CLASS_NAME;
21
- /**
22
- * Create a new instance of SynchronisedStorageClient.
23
- * @param config The configuration for the client.
24
- */
25
- constructor(config) {
26
- super(SynchronisedStorageClient._CLASS_NAME, config, "synchronised-storage");
27
- }
28
- /**
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.
34
- */
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
42
- }
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
- });
56
- }
57
- }
58
-
59
- exports.SynchronisedStorageClient = SynchronisedStorageClient;
@@ -1,57 +0,0 @@
1
- import { BaseRestClient } from '@twin.org/api-core';
2
- import { Guards } from '@twin.org/core';
3
-
4
- // Copyright 2024 IOTA Stiftung.
5
- // SPDX-License-Identifier: Apache-2.0.
6
- /**
7
- * Client for performing synchronised storage through to REST endpoints.
8
- */
9
- class SynchronisedStorageClient extends BaseRestClient {
10
- /**
11
- * Runtime name for the class.
12
- * @internal
13
- */
14
- static _CLASS_NAME = "SynchronisedStorageClient";
15
- /**
16
- * Runtime name for the class.
17
- */
18
- CLASS_NAME = SynchronisedStorageClient._CLASS_NAME;
19
- /**
20
- * Create a new instance of SynchronisedStorageClient.
21
- * @param config The configuration for the client.
22
- */
23
- constructor(config) {
24
- super(SynchronisedStorageClient._CLASS_NAME, config, "synchronised-storage");
25
- }
26
- /**
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.
32
- */
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
40
- }
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
- });
54
- }
55
- }
56
-
57
- export { SynchronisedStorageClient };