@twin.org/verifiable-storage-service 0.0.2-next.6 → 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,8 @@
1
1
  # TWIN Verifiable Storage Service
2
2
 
3
- Verifiable Storage contract implementation and REST endpoint definitions.
3
+ This package provides the service layer for verifiable storage, exposing component logic and REST route definitions that can be mounted in API applications. It translates storage operations into a consistent service interface for upstream consumers.
4
+
5
+ The package is useful when you need to host verifiable storage capabilities behind HTTP endpoints while retaining the same contracts used by connectors and clients.
4
6
 
5
7
  ## Installation
6
8
 
@@ -0,0 +1,8 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export * from "./models/IVerifiableStorageServiceConfig.js";
4
+ export * from "./models/IVerifiableStorageServiceConstructorOptions.js";
5
+ export * from "./verifiableStorageRoutes.js";
6
+ export * from "./verifiableStorageService.js";
7
+ export * from "./restEntryPoints.js";
8
+ //# 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,6CAA6C,CAAC;AAC5D,cAAc,yDAAyD,CAAC;AACxE,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sBAAsB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./models/IVerifiableStorageServiceConfig.js\";\nexport * from \"./models/IVerifiableStorageServiceConstructorOptions.js\";\nexport * from \"./verifiableStorageRoutes.js\";\nexport * from \"./verifiableStorageService.js\";\nexport * from \"./restEntryPoints.js\";\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export {};
4
+ //# sourceMappingURL=IVerifiableStorageServiceConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IVerifiableStorageServiceConfig.js","sourceRoot":"","sources":["../../../src/models/IVerifiableStorageServiceConfig.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Configuration for the Verifiable Storage Service.\n */\nexport interface IVerifiableStorageServiceConfig {\n\t/**\n\t * What is the default connector to use for Verifiable Storage. If not provided the first connector from the factory will be used.\n\t */\n\tdefaultNamespace?: string;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IVerifiableStorageServiceConstructorOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IVerifiableStorageServiceConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IVerifiableStorageServiceConstructorOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IVerifiableStorageServiceConfig } from \"./IVerifiableStorageServiceConfig.js\";\n\n/**\n * Options for the Verifiable Storage service constructor.\n */\nexport interface IVerifiableStorageServiceConstructorOptions {\n\t/**\n\t * The configuration for the service.\n\t */\n\tconfig?: IVerifiableStorageServiceConfig;\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import { generateRestRoutesVerifiableStorage, tagsVerifiableStorage } from "./verifiableStorageRoutes.js";
2
+ export const restEntryPoints = [
3
+ {
4
+ name: "verifiable",
5
+ defaultBaseRoute: "verifiable",
6
+ tags: tagsVerifiableStorage,
7
+ generateRoutes: generateRestRoutesVerifiableStorage
8
+ }
9
+ ];
10
+ //# sourceMappingURL=restEntryPoints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restEntryPoints.js","sourceRoot":"","sources":["../../src/restEntryPoints.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,mCAAmC,EACnC,qBAAqB,EACrB,MAAM,8BAA8B,CAAC;AAEtC,MAAM,CAAC,MAAM,eAAe,GAA2B;IACtD;QACC,IAAI,EAAE,YAAY;QAClB,gBAAgB,EAAE,YAAY;QAC9B,IAAI,EAAE,qBAAqB;QAC3B,cAAc,EAAE,mCAAmC;KACnD;CACD,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IRestRouteEntryPoint } from \"@twin.org/api-models\";\nimport {\n\tgenerateRestRoutesVerifiableStorage,\n\ttagsVerifiableStorage\n} from \"./verifiableStorageRoutes.js\";\n\nexport const restEntryPoints: IRestRouteEntryPoint[] = [\n\t{\n\t\tname: \"verifiable\",\n\t\tdefaultBaseRoute: \"verifiable\",\n\t\ttags: tagsVerifiableStorage,\n\t\tgenerateRoutes: generateRestRoutesVerifiableStorage\n\t}\n];\n"]}
@@ -1,7 +1,6 @@
1
- import { Guards, ComponentFactory, Converter, Is, GeneralError, Urn } from '@twin.org/core';
2
- import { HttpStatusCode, HeaderTypes } from '@twin.org/web';
3
- import { VerifiableStorageConnectorFactory } from '@twin.org/verifiable-storage-models';
4
-
1
+ import { ContextIdHelper, ContextIdKeys, ContextIdStore } from "@twin.org/context";
2
+ import { ComponentFactory, Converter, Guards, Is } from "@twin.org/core";
3
+ import { HeaderTypes, HttpStatusCode } from "@twin.org/web";
5
4
  /**
6
5
  * The source used when communicating about these routes.
7
6
  */
@@ -9,7 +8,7 @@ const ROUTES_SOURCE = "verifiableStorageRoutes";
9
8
  /**
10
9
  * The tag to associate with the routes.
11
10
  */
12
- const tagsVerifiableStorage = [
11
+ export const tagsVerifiableStorage = [
13
12
  {
14
13
  name: "VerifiableStorage",
15
14
  description: "Endpoints which are modelled to access a verifiable storage."
@@ -21,7 +20,7 @@ const tagsVerifiableStorage = [
21
20
  * @param componentName The name of the component to use in the routes stored in the ComponentFactory.
22
21
  * @returns The generated routes.
23
22
  */
24
- function generateRestRoutesVerifiableStorage(baseRouteName, componentName) {
23
+ export function generateRestRoutesVerifiableStorage(baseRouteName, componentName) {
25
24
  const createRoute = {
26
25
  operationId: "verifiableStorageCreate",
27
26
  summary: "Create an item in verifiable storage",
@@ -56,7 +55,7 @@ function generateRestRoutesVerifiableStorage(baseRouteName, componentName) {
56
55
  body: {
57
56
  receipt: {
58
57
  "@context": "https://schema.twindev.org/verifiable-storage/",
59
- type: "VerifiableStorageIotaReceipt"
58
+ type: "VerifiableStorageIotaReceipt2026"
60
59
  },
61
60
  id: "verifiable:iota:aW90YS1uZnQ6dHN0OjB4NzYyYjljNDllYTg2OWUwZWJkYTliYmZhNzY5Mzk0NDdhNDI4ZGNmMTc4YzVkMTVhYjQ0N2UyZDRmYmJiNGViMg=="
62
61
  }
@@ -98,7 +97,7 @@ function generateRestRoutesVerifiableStorage(baseRouteName, componentName) {
98
97
  response: {
99
98
  body: {
100
99
  "@context": "https://schema.twindev.org/verifiable-storage/",
101
- type: "VerifiableStorageIotaReceipt"
100
+ type: "VerifiableStorageIotaReceipt2026"
102
101
  }
103
102
  }
104
103
  }
@@ -183,14 +182,16 @@ function generateRestRoutesVerifiableStorage(baseRouteName, componentName) {
183
182
  * @param request The request.
184
183
  * @returns The response object with additional http response properties.
185
184
  */
186
- async function verifiableStorageCreate(httpRequestContext, componentName, request) {
185
+ export async function verifiableStorageCreate(httpRequestContext, componentName, request) {
187
186
  Guards.object(ROUTES_SOURCE, "request", request);
188
187
  Guards.object(ROUTES_SOURCE, "request.body", request.body);
189
188
  Guards.stringBase64(ROUTES_SOURCE, "request.body.data", request.body.data);
189
+ const contextIds = await ContextIdStore.getContextIds();
190
+ ContextIdHelper.guard(contextIds, ContextIdKeys.Organization);
190
191
  const component = ComponentFactory.get(componentName);
191
192
  const result = await component.create(Converter.base64ToBytes(request.body.data), request.body.allowList, {
192
193
  maxAllowListSize: request.body.maxAllowListSize
193
- }, httpRequestContext.userIdentity, request.body.namespace);
194
+ }, request.body.namespace, contextIds[ContextIdKeys.Organization]);
194
195
  return {
195
196
  statusCode: HttpStatusCode.created,
196
197
  headers: {
@@ -209,14 +210,16 @@ async function verifiableStorageCreate(httpRequestContext, componentName, reques
209
210
  * @param request The request.
210
211
  * @returns The response object with additional http response properties.
211
212
  */
212
- async function verifiableStorageUpdate(httpRequestContext, componentName, request) {
213
+ export async function verifiableStorageUpdate(httpRequestContext, componentName, request) {
213
214
  Guards.object(ROUTES_SOURCE, "request", request);
214
215
  Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
215
216
  Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
216
217
  Guards.object(ROUTES_SOURCE, "request.body", request.body);
217
218
  Guards.stringBase64(ROUTES_SOURCE, "request.body.data", request.body.data);
219
+ const contextIds = await ContextIdStore.getContextIds();
220
+ ContextIdHelper.guard(contextIds, ContextIdKeys.Organization);
218
221
  const component = ComponentFactory.get(componentName);
219
- const result = await component.update(request.pathParams.id, Is.stringBase64(request.body.data) ? Converter.base64ToBytes(request.body.data) : undefined, request.body.allowList, httpRequestContext.userIdentity);
222
+ const result = await component.update(request.pathParams.id, Is.stringBase64(request.body.data) ? Converter.base64ToBytes(request.body.data) : undefined, request.body.allowList, contextIds[ContextIdKeys.Organization]);
220
223
  return {
221
224
  body: result
222
225
  };
@@ -227,7 +230,7 @@ async function verifiableStorageUpdate(httpRequestContext, componentName, reques
227
230
  * @param request The request.
228
231
  * @returns The response object with additional http response properties.
229
232
  */
230
- async function verifiableStorageGet(componentName, request) {
233
+ export async function verifiableStorageGet(componentName, request) {
231
234
  Guards.object(ROUTES_SOURCE, "request", request);
232
235
  Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
233
236
  Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
@@ -248,151 +251,16 @@ async function verifiableStorageGet(componentName, request) {
248
251
  * @param request The request.
249
252
  * @returns The response object with additional http response properties.
250
253
  */
251
- async function verifiableStorageRemove(httpRequestContext, componentName, request) {
254
+ export async function verifiableStorageRemove(httpRequestContext, componentName, request) {
252
255
  Guards.object(ROUTES_SOURCE, "request", request);
253
256
  Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
254
257
  Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
258
+ const contextIds = await ContextIdStore.getContextIds();
259
+ ContextIdHelper.guard(contextIds, ContextIdKeys.Organization);
255
260
  const component = ComponentFactory.get(componentName);
256
- await component.remove(request.pathParams.id, httpRequestContext.userIdentity);
261
+ await component.remove(request.pathParams.id, contextIds[ContextIdKeys.Organization]);
257
262
  return {
258
263
  statusCode: HttpStatusCode.noContent
259
264
  };
260
265
  }
261
-
262
- // Copyright 2024 IOTA Stiftung.
263
- // SPDX-License-Identifier: Apache-2.0.
264
- /**
265
- * Service for performing Verifiable Storage operations to a connector.
266
- */
267
- class VerifiableStorageService {
268
- /**
269
- * Runtime name for the class.
270
- */
271
- static CLASS_NAME = "VerifiableStorageService";
272
- /**
273
- * The namespace supported by the verifiableStorage service.
274
- * @internal
275
- */
276
- static _NAMESPACE = "verifiable";
277
- /**
278
- * The default namespace for the connector to use.
279
- * @internal
280
- */
281
- _defaultNamespace;
282
- /**
283
- * Create a new instance of VerifiableStorageService.
284
- * @param options The options for the service.
285
- */
286
- constructor(options) {
287
- const names = VerifiableStorageConnectorFactory.names();
288
- if (names.length === 0) {
289
- throw new GeneralError(VerifiableStorageService.CLASS_NAME, "noConnectors");
290
- }
291
- this._defaultNamespace = options?.config?.defaultNamespace ?? names[0];
292
- }
293
- /**
294
- * Create a verifiable storage item.
295
- * @param data The data for the verifiable storage item.
296
- * @param allowList The list of identities that are allowed to modify the item.
297
- * @param options Additional options for creating the item.
298
- * @param options.maxAllowListSize The maximum size of the allow list.
299
- * @param identity The identity to store the Verifiable Storage operation on.
300
- * @param namespace The namespace to use for the Verifiable Storage.
301
- * @returns The id of the created verifiable storage item.
302
- */
303
- async create(data, allowList, options, identity, namespace) {
304
- Guards.uint8Array(VerifiableStorageService.CLASS_NAME, "data", data);
305
- Guards.stringValue(VerifiableStorageService.CLASS_NAME, "identity", identity);
306
- try {
307
- const connectorNamespace = namespace ?? this._defaultNamespace;
308
- const verifiableStorageConnector = VerifiableStorageConnectorFactory.get(connectorNamespace);
309
- const verifiableStorageResult = await verifiableStorageConnector.create(identity, data, allowList, options);
310
- return verifiableStorageResult;
311
- }
312
- catch (error) {
313
- throw new GeneralError(VerifiableStorageService.CLASS_NAME, "createFailed", undefined, error);
314
- }
315
- }
316
- /**
317
- * Update an item in verifiable storage.
318
- * @param id The id of the item to update.
319
- * @param data The data to store, optional if updating the allow list.
320
- * @param allowList Updated list of identities that are allowed to modify the item.
321
- * @param identity The identity of the user to access the vault keys.
322
- * @returns The updated receipt.
323
- */
324
- async update(id, data, allowList, identity) {
325
- Urn.guard(VerifiableStorageService.CLASS_NAME, "id", id);
326
- Guards.stringValue(VerifiableStorageService.CLASS_NAME, "identity", identity);
327
- try {
328
- const verifiableStorageConnector = this.getConnector(id);
329
- const verifiableStorageResult = await verifiableStorageConnector.update(identity, id, data, allowList);
330
- return verifiableStorageResult;
331
- }
332
- catch (error) {
333
- throw new GeneralError(VerifiableStorageService.CLASS_NAME, "updateFailed", undefined, error);
334
- }
335
- }
336
- /**
337
- * Get an Verifiable Storage.
338
- * @param id The id of the verifiable storage item to get.
339
- * @param options Additional options for getting the verifiable storage item.
340
- * @param options.includeData Should the data be included in the response, defaults to true.
341
- * @param options.includeAllowList Should the allow list be included in the response, defaults to true.
342
- * @returns The data for the verifiable storage item.
343
- */
344
- async get(id, options) {
345
- Urn.guard(VerifiableStorageService.CLASS_NAME, "id", id);
346
- try {
347
- const verifiableStorageConnector = this.getConnector(id);
348
- return verifiableStorageConnector.get(id, options);
349
- }
350
- catch (error) {
351
- throw new GeneralError(VerifiableStorageService.CLASS_NAME, "getFailed", undefined, error);
352
- }
353
- }
354
- /**
355
- * Remove a verifiable storage item.
356
- * @param id The id of the Verifiable Storage to remove.
357
- * @param identity The identity to perform the verifiableStorage operation on.
358
- * @returns Nothing.
359
- */
360
- async remove(id, identity) {
361
- Urn.guard(VerifiableStorageService.CLASS_NAME, "id", id);
362
- Guards.stringValue(VerifiableStorageService.CLASS_NAME, "identity", identity);
363
- try {
364
- const verifiableStorageConnector = this.getConnector(id);
365
- await verifiableStorageConnector.remove(identity, id);
366
- }
367
- catch (error) {
368
- throw new GeneralError(VerifiableStorageService.CLASS_NAME, "removeFailed", undefined, error);
369
- }
370
- }
371
- /**
372
- * Get the connector from the uri.
373
- * @param id The id of the item in urn format.
374
- * @returns The connector.
375
- * @internal
376
- */
377
- getConnector(id) {
378
- const idUri = Urn.fromValidString(id);
379
- if (idUri.namespaceIdentifier() !== VerifiableStorageService._NAMESPACE) {
380
- throw new GeneralError(VerifiableStorageService.CLASS_NAME, "namespaceMismatch", {
381
- namespace: VerifiableStorageService._NAMESPACE,
382
- id
383
- });
384
- }
385
- return VerifiableStorageConnectorFactory.get(idUri.namespaceMethod());
386
- }
387
- }
388
-
389
- const restEntryPoints = [
390
- {
391
- name: "verifiable",
392
- defaultBaseRoute: "verifiable",
393
- tags: tagsVerifiableStorage,
394
- generateRoutes: generateRestRoutesVerifiableStorage
395
- }
396
- ];
397
-
398
- export { VerifiableStorageService, generateRestRoutesVerifiableStorage, restEntryPoints, tagsVerifiableStorage, verifiableStorageCreate, verifiableStorageGet, verifiableStorageRemove, verifiableStorageUpdate };
266
+ //# sourceMappingURL=verifiableStorageRoutes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verifiableStorageRoutes.js","sourceRoot":"","sources":["../../src/verifiableStorageRoutes.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAYzE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AA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,CAAC,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;YACnF,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,SAAS,EAAE,MAAM,CAAC,SAAS;SAC3B;KACD,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC5C,kBAAuC,EACvC,aAAqB,EACrB,OAAwC;IAExC,MAAM,CAAC,MAAM,CAAkC,aAAa,aAAmB,OAAO,CAAC,CAAC;IACxF,MAAM,CAAC,MAAM,CACZ,aAAa,wBAEb,OAAO,CAAC,UAAU,CAClB,CAAC;IACF,MAAM,CAAC,WAAW,CAAC,aAAa,2BAAiC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAExF,MAAM,UAAU,GAAG,MAAM,cAAc,CAAC,aAAa,EAAE,CAAC;IACxD,eAAe,CAAC,KAAK,CAAC,UAAU,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;IAE9D,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAA8B,aAAa,CAAC,CAAC;IACnF,MAAM,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC;IAEtF,OAAO;QACN,UAAU,EAAE,cAAc,CAAC,SAAS;KACpC,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type {\n\tIHttpRequestContext,\n\tINoContentResponse,\n\tIRestRoute,\n\tITag\n} from \"@twin.org/api-models\";\nimport { ContextIdHelper, ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport { ComponentFactory, Converter, Guards, Is } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type {\n\tIVerifiableStorageComponent,\n\tIVerifiableStorageCreateRequest,\n\tIVerifiableStorageCreateResponse,\n\tIVerifiableStorageGetRequest,\n\tIVerifiableStorageGetResponse,\n\tIVerifiableStorageRemoveRequest,\n\tIVerifiableStorageUpdateRequest,\n\tIVerifiableStorageUpdateResponse\n} from \"@twin.org/verifiable-storage-models\";\nimport { HeaderTypes, HttpStatusCode } from \"@twin.org/web\";\n\n/**\n * The source used when communicating about these routes.\n */\nconst ROUTES_SOURCE = \"verifiableStorageRoutes\";\n\n/**\n * The tag to associate with the routes.\n */\nexport const tagsVerifiableStorage: ITag[] = [\n\t{\n\t\tname: \"VerifiableStorage\",\n\t\tdescription: \"Endpoints which are modelled to access a verifiable storage.\"\n\t}\n];\n\n/**\n * The REST routes for VerifiableStorage.\n * @param baseRouteName Prefix to prepend to the paths.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @returns The generated routes.\n */\nexport function generateRestRoutesVerifiableStorage(\n\tbaseRouteName: string,\n\tcomponentName: string\n): IRestRoute[] {\n\tconst createRoute: IRestRoute<IVerifiableStorageCreateRequest, IVerifiableStorageCreateResponse> =\n\t\t{\n\t\t\toperationId: \"verifiableStorageCreate\",\n\t\t\tsummary: \"Create an item in verifiable storage\",\n\t\t\ttag: tagsVerifiableStorage[0].name,\n\t\t\tmethod: \"POST\",\n\t\t\tpath: `${baseRouteName}/`,\n\t\t\thandler: async (httpRequestContext, request) =>\n\t\t\t\tverifiableStorageCreate(httpRequestContext, componentName, request),\n\t\t\trequestType: {\n\t\t\t\ttype: nameof<IVerifiableStorageCreateRequest>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"verifiableStorageCreateRequestExample\",\n\t\t\t\t\t\trequest: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\tdata: \"SGVsbG8gd29ybGQ=\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\tresponseType: [\n\t\t\t\t{\n\t\t\t\t\ttype: nameof<IVerifiableStorageCreateResponse>(),\n\t\t\t\t\texamples: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: \"verifiableStorageCreateResponseExample\",\n\t\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\t\tstatusCode: HttpStatusCode.created,\n\t\t\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\t\t[HeaderTypes.Location]:\n\t\t\t\t\t\t\t\t\t\t\"verifiable:iota:aW90YS1uZnQ6dHN0OjB4NzYyYjljNDllYTg2OWUwZWJkYTliYmZhNzY5Mzk0NDdhNDI4ZGNmMTc4YzVkMTVhYjQ0N2UyZDRmYmJiNGViMg==\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\treceipt: {\n\t\t\t\t\t\t\t\t\t\t\"@context\": \"https://schema.twindev.org/verifiable-storage/\",\n\t\t\t\t\t\t\t\t\t\ttype: \"VerifiableStorageIotaReceipt2026\"\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tid: \"verifiable:iota:aW90YS1uZnQ6dHN0OjB4NzYyYjljNDllYTg2OWUwZWJkYTliYmZhNzY5Mzk0NDdhNDI4ZGNmMTc4YzVkMTVhYjQ0N2UyZDRmYmJiNGViMg==\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t]\n\t\t};\n\n\tconst updateRoute: IRestRoute<IVerifiableStorageUpdateRequest, IVerifiableStorageUpdateResponse> =\n\t\t{\n\t\t\toperationId: \"verifiableStorageUpdate\",\n\t\t\tsummary: \"Update an item in verifiable storage\",\n\t\t\ttag: tagsVerifiableStorage[0].name,\n\t\t\tmethod: \"PUT\",\n\t\t\tpath: `${baseRouteName}/:id`,\n\t\t\thandler: async (httpRequestContext, request) =>\n\t\t\t\tverifiableStorageUpdate(httpRequestContext, componentName, request),\n\t\t\trequestType: {\n\t\t\t\ttype: nameof<IVerifiableStorageUpdateRequest>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"verifiableStorageUpdateRequestExample\",\n\t\t\t\t\t\trequest: {\n\t\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\t\tid: \"verifiable:iota:aW90YS1uZnQ6dHN0OjB4NzYyYjljNDllYTg2OWUwZWJkYTliYmZhNzY5Mzk0NDdhNDI4ZGNmMTc4YzVkMTVhYjQ0N2UyZDRmYmJiNGViMg==\"\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\tdata: \"SGVsbG8gd29ybGQ=\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\tresponseType: [\n\t\t\t\t{\n\t\t\t\t\ttype: nameof<IVerifiableStorageUpdateResponse>(),\n\t\t\t\t\texamples: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tid: \"verifiableStorageUpdateResponseExample\",\n\t\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\t\"@context\": \"https://schema.twindev.org/verifiable-storage/\",\n\t\t\t\t\t\t\t\t\ttype: \"VerifiableStorageIotaReceipt2026\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t]\n\t\t};\n\n\tconst getRoute: IRestRoute<IVerifiableStorageGetRequest, IVerifiableStorageGetResponse> = {\n\t\toperationId: \"verifiableStorageGet\",\n\t\tsummary: \"Get an verifiable storage item\",\n\t\ttag: tagsVerifiableStorage[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/:id`,\n\t\thandler: async (httpRequestContext, request) => verifiableStorageGet(componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IVerifiableStorageGetRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"verifiableStorageGetRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"verifiable:iota:aW90YS1uZnQ6dHN0OjB4NzYyYjljNDllYTg2OWUwZWJkYTliYmZhNzY5Mzk0NDdhNDI4ZGNmMTc4YzVkMTVhYjQ0N2UyZDRmYmJiNGViMg==\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IVerifiableStorageGetResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"verifiableStorageGetResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\tdata: \"SGVsbG8gd29ybGQ=\",\n\t\t\t\t\t\t\t\treceipt: {\n\t\t\t\t\t\t\t\t\t\"@context\": \"https://www.w3.org/ns/activitystreams\",\n\t\t\t\t\t\t\t\t\ttype: \"Create\",\n\t\t\t\t\t\t\t\t\tactor: \"https://example.org/actor\",\n\t\t\t\t\t\t\t\t\tobject: \"https://example.org/object\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\tconst removeRoute: IRestRoute<IVerifiableStorageRemoveRequest, INoContentResponse> = {\n\t\toperationId: \"verifiableStorageRemove\",\n\t\tsummary: \"Remove an item from verifiable storage\",\n\t\ttag: tagsVerifiableStorage[0].name,\n\t\tmethod: \"DELETE\",\n\t\tpath: `${baseRouteName}/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tverifiableStorageRemove(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IVerifiableStorageRemoveRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"verifiableStorageRemoveRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"verifiable:iota:aW90YS1uZnQ6dHN0OjB4NzYyYjljNDllYTg2OWUwZWJkYTliYmZhNzY5Mzk0NDdhNDI4ZGNmMTc4YzVkMTVhYjQ0N2UyZDRmYmJiNGViMg==\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\treturn [createRoute, updateRoute, getRoute, removeRoute];\n}\n\n/**\n * Create a verifiable storage item.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function verifiableStorageCreate(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IVerifiableStorageCreateRequest\n): Promise<IVerifiableStorageCreateResponse> {\n\tGuards.object<IVerifiableStorageCreateRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IVerifiableStorageCreateRequest[\"body\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.body),\n\t\trequest.body\n\t);\n\tGuards.stringBase64(ROUTES_SOURCE, nameof(request.body.data), request.body.data);\n\n\tconst contextIds = await ContextIdStore.getContextIds();\n\tContextIdHelper.guard(contextIds, ContextIdKeys.Organization);\n\n\tconst component = ComponentFactory.get<IVerifiableStorageComponent>(componentName);\n\tconst result = await component.create(\n\t\tConverter.base64ToBytes(request.body.data),\n\t\trequest.body.allowList,\n\t\t{\n\t\t\tmaxAllowListSize: request.body.maxAllowListSize\n\t\t},\n\t\trequest.body.namespace,\n\t\tcontextIds[ContextIdKeys.Organization]\n\t);\n\treturn {\n\t\tstatusCode: HttpStatusCode.created,\n\t\theaders: {\n\t\t\t[HeaderTypes.Location]: result.id\n\t\t},\n\t\tbody: {\n\t\t\treceipt: result.receipt,\n\t\t\tid: result.id\n\t\t}\n\t};\n}\n\n/**\n * UPdate an Verifiable Storage.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function verifiableStorageUpdate(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IVerifiableStorageUpdateRequest\n): Promise<IVerifiableStorageUpdateResponse> {\n\tGuards.object<IVerifiableStorageUpdateRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IVerifiableStorageGetRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\tGuards.object<IVerifiableStorageUpdateRequest[\"body\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.body),\n\t\trequest.body\n\t);\n\tGuards.stringBase64(ROUTES_SOURCE, nameof(request.body.data), request.body.data);\n\n\tconst contextIds = await ContextIdStore.getContextIds();\n\tContextIdHelper.guard(contextIds, ContextIdKeys.Organization);\n\n\tconst component = ComponentFactory.get<IVerifiableStorageComponent>(componentName);\n\tconst result = await component.update(\n\t\trequest.pathParams.id,\n\t\tIs.stringBase64(request.body.data) ? Converter.base64ToBytes(request.body.data) : undefined,\n\t\trequest.body.allowList,\n\t\tcontextIds[ContextIdKeys.Organization]\n\t);\n\treturn {\n\t\tbody: result\n\t};\n}\n\n/**\n * Get an Verifiable Storage.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function verifiableStorageGet(\n\tcomponentName: string,\n\trequest: IVerifiableStorageGetRequest\n): Promise<IVerifiableStorageGetResponse> {\n\tGuards.object<IVerifiableStorageGetRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IVerifiableStorageGetRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\n\tconst component = ComponentFactory.get<IVerifiableStorageComponent>(componentName);\n\tconst result = await component.get(request.pathParams.id, request.body);\n\treturn {\n\t\tbody: {\n\t\t\tdata: Is.uint8Array(result.data) ? Converter.bytesToBase64(result.data) : undefined,\n\t\t\treceipt: result.receipt,\n\t\t\tallowList: result.allowList\n\t\t}\n\t};\n}\n\n/**\n * Remove a verifiable storage item.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function verifiableStorageRemove(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IVerifiableStorageRemoveRequest\n): Promise<INoContentResponse> {\n\tGuards.object<IVerifiableStorageRemoveRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IVerifiableStorageRemoveRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\n\tconst contextIds = await ContextIdStore.getContextIds();\n\tContextIdHelper.guard(contextIds, ContextIdKeys.Organization);\n\n\tconst component = ComponentFactory.get<IVerifiableStorageComponent>(componentName);\n\tawait component.remove(request.pathParams.id, contextIds[ContextIdKeys.Organization]);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n"]}
@@ -0,0 +1,137 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { GeneralError, Guards, Urn } from "@twin.org/core";
4
+ import { VerifiableStorageConnectorFactory } from "@twin.org/verifiable-storage-models";
5
+ /**
6
+ * Service for performing Verifiable Storage operations to a connector.
7
+ */
8
+ export class VerifiableStorageService {
9
+ /**
10
+ * Runtime name for the class.
11
+ */
12
+ static CLASS_NAME = "VerifiableStorageService";
13
+ /**
14
+ * The namespace supported by the verifiableStorage service.
15
+ * @internal
16
+ */
17
+ static _NAMESPACE = "verifiable";
18
+ /**
19
+ * The default namespace for the connector to use.
20
+ * @internal
21
+ */
22
+ _defaultNamespace;
23
+ /**
24
+ * Create a new instance of VerifiableStorageService.
25
+ * @param options The options for the service.
26
+ */
27
+ constructor(options) {
28
+ const names = VerifiableStorageConnectorFactory.names();
29
+ if (names.length === 0) {
30
+ throw new GeneralError(VerifiableStorageService.CLASS_NAME, "noConnectors");
31
+ }
32
+ this._defaultNamespace = options?.config?.defaultNamespace ?? names[0];
33
+ }
34
+ /**
35
+ * Returns the class name of the component.
36
+ * @returns The class name of the component.
37
+ */
38
+ className() {
39
+ return VerifiableStorageService.CLASS_NAME;
40
+ }
41
+ /**
42
+ * Create a verifiable storage item.
43
+ * @param data The data for the verifiable storage item.
44
+ * @param allowList The list of identities that are allowed to modify the item.
45
+ * @param options Additional options for creating the item.
46
+ * @param options.maxAllowListSize The maximum size of the allow list.
47
+ * @param namespace The namespace to use for the connector to use.
48
+ * @param controller The identity of the controller to access the vault keys.
49
+ * @returns The id of the created verifiable storage item.
50
+ */
51
+ async create(data, allowList, options, namespace, controller) {
52
+ Guards.uint8Array(VerifiableStorageService.CLASS_NAME, "data", data);
53
+ Guards.stringValue(VerifiableStorageService.CLASS_NAME, "controller", controller);
54
+ try {
55
+ const connectorNamespace = namespace ?? this._defaultNamespace;
56
+ const verifiableStorageConnector = VerifiableStorageConnectorFactory.get(connectorNamespace);
57
+ const verifiableStorageResult = await verifiableStorageConnector.create(controller, data, allowList, options);
58
+ return verifiableStorageResult;
59
+ }
60
+ catch (error) {
61
+ throw new GeneralError(VerifiableStorageService.CLASS_NAME, "createFailed", undefined, error);
62
+ }
63
+ }
64
+ /**
65
+ * Update an item in verifiable storage.
66
+ * @param id The id of the item to update.
67
+ * @param data The data to store, optional if updating the allow list.
68
+ * @param allowList Updated list of identities that are allowed to modify the item.
69
+ * @param controller The identity of the controller to access the vault keys.
70
+ * @returns The updated receipt.
71
+ */
72
+ async update(id, data, allowList, controller) {
73
+ Urn.guard(VerifiableStorageService.CLASS_NAME, "id", id);
74
+ Guards.stringValue(VerifiableStorageService.CLASS_NAME, "controller", controller);
75
+ try {
76
+ const verifiableStorageConnector = this.getConnector(id);
77
+ const verifiableStorageResult = await verifiableStorageConnector.update(controller, id, data, allowList);
78
+ return verifiableStorageResult;
79
+ }
80
+ catch (error) {
81
+ throw new GeneralError(VerifiableStorageService.CLASS_NAME, "updateFailed", undefined, error);
82
+ }
83
+ }
84
+ /**
85
+ * Get an Verifiable Storage.
86
+ * @param id The id of the verifiable storage item to get.
87
+ * @param options Additional options for getting the verifiable storage item.
88
+ * @param options.includeData Should the data be included in the response, defaults to true.
89
+ * @param options.includeAllowList Should the allow list be included in the response, defaults to true.
90
+ * @returns The data for the verifiable storage item.
91
+ */
92
+ async get(id, options) {
93
+ Urn.guard(VerifiableStorageService.CLASS_NAME, "id", id);
94
+ try {
95
+ const verifiableStorageConnector = this.getConnector(id);
96
+ const result = await verifiableStorageConnector.get(id, options);
97
+ return result;
98
+ }
99
+ catch (error) {
100
+ throw new GeneralError(VerifiableStorageService.CLASS_NAME, "getFailed", undefined, error);
101
+ }
102
+ }
103
+ /**
104
+ * Remove a verifiable storage item.
105
+ * @param id The id of the Verifiable Storage to remove.
106
+ * @param controller The identity of the controller to access the vault keys.
107
+ * @returns Nothing.
108
+ */
109
+ async remove(id, controller) {
110
+ Urn.guard(VerifiableStorageService.CLASS_NAME, "id", id);
111
+ Guards.stringValue(VerifiableStorageService.CLASS_NAME, "controller", controller);
112
+ try {
113
+ const verifiableStorageConnector = this.getConnector(id);
114
+ await verifiableStorageConnector.remove(controller, id);
115
+ }
116
+ catch (error) {
117
+ throw new GeneralError(VerifiableStorageService.CLASS_NAME, "removeFailed", undefined, error);
118
+ }
119
+ }
120
+ /**
121
+ * Get the connector from the uri.
122
+ * @param id The id of the item in urn format.
123
+ * @returns The connector.
124
+ * @internal
125
+ */
126
+ getConnector(id) {
127
+ const idUri = Urn.fromValidString(id);
128
+ if (idUri.namespaceIdentifier() !== VerifiableStorageService._NAMESPACE) {
129
+ throw new GeneralError(VerifiableStorageService.CLASS_NAME, "namespaceMismatch", {
130
+ namespace: VerifiableStorageService._NAMESPACE,
131
+ id
132
+ });
133
+ }
134
+ return VerifiableStorageConnectorFactory.get(idUri.namespaceMethod());
135
+ }
136
+ }
137
+ //# sourceMappingURL=verifiableStorageService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verifiableStorageService.js","sourceRoot":"","sources":["../../src/verifiableStorageService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAG3D,OAAO,EACN,iCAAiC,EAGjC,MAAM,qCAAqC,CAAC;AAG7C;;GAEG;AACH,MAAM,OAAO,wBAAwB;IACpC;;OAEG;IACI,MAAM,CAAU,UAAU,8BAA8C;IAE/E;;;OAGG;IACK,MAAM,CAAU,UAAU,GAAW,YAAY,CAAC;IAE1D;;;OAGG;IACc,iBAAiB,CAAS;IAE3C;;;OAGG;IACH,YAAY,OAAqD;QAChE,MAAM,KAAK,GAAG,iCAAiC,CAAC,KAAK,EAAE,CAAC;QACxD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,YAAY,CAAC,wBAAwB,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;QAC7E,CAAC;QAED,IAAI,CAAC,iBAAiB,GAAG,OAAO,EAAE,MAAM,EAAE,gBAAgB,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;IACxE,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,wBAAwB,CAAC,UAAU,CAAC;IAC5C,CAAC;IAED;;;;;;;;;OASG;IACI,KAAK,CA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C;QAEtC,IAAI,KAAK,CAAC,mBAAmB,EAAE,KAAK,wBAAwB,CAAC,UAAU,EAAE,CAAC;YACzE,MAAM,IAAI,YAAY,CAAC,wBAAwB,CAAC,UAAU,EAAE,mBAAmB,EAAE;gBAChF,SAAS,EAAE,wBAAwB,CAAC,UAAU;gBAC9C,EAAE;aACF,CAAC,CAAC;QACJ,CAAC;QAED,OAAO,iCAAiC,CAAC,GAAG,CAC3C,KAAK,CAAC,eAAe,EAAE,CACvB,CAAC;IACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { GeneralError, Guards, Urn } from \"@twin.org/core\";\nimport type { IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tVerifiableStorageConnectorFactory,\n\ttype IVerifiableStorageComponent,\n\ttype IVerifiableStorageConnector\n} from \"@twin.org/verifiable-storage-models\";\nimport type { IVerifiableStorageServiceConstructorOptions } from \"./models/IVerifiableStorageServiceConstructorOptions.js\";\n\n/**\n * Service for performing Verifiable Storage operations to a connector.\n */\nexport class VerifiableStorageService implements IVerifiableStorageComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<VerifiableStorageService>();\n\n\t/**\n\t * The namespace supported by the verifiableStorage service.\n\t * @internal\n\t */\n\tprivate static readonly _NAMESPACE: string = \"verifiable\";\n\n\t/**\n\t * The default namespace for the connector to use.\n\t * @internal\n\t */\n\tprivate readonly _defaultNamespace: string;\n\n\t/**\n\t * Create a new instance of VerifiableStorageService.\n\t * @param options The options for the service.\n\t */\n\tconstructor(options?: IVerifiableStorageServiceConstructorOptions) {\n\t\tconst names = VerifiableStorageConnectorFactory.names();\n\t\tif (names.length === 0) {\n\t\t\tthrow new GeneralError(VerifiableStorageService.CLASS_NAME, \"noConnectors\");\n\t\t}\n\n\t\tthis._defaultNamespace = options?.config?.defaultNamespace ?? names[0];\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 VerifiableStorageService.CLASS_NAME;\n\t}\n\n\t/**\n\t * Create a verifiable storage item.\n\t * @param data The data for the verifiable storage item.\n\t * @param allowList The list of identities that are allowed to modify the item.\n\t * @param options Additional options for creating the item.\n\t * @param options.maxAllowListSize The maximum size of the allow list.\n\t * @param namespace The namespace to use for the connector to use.\n\t * @param controller The identity of the controller to access the vault keys.\n\t * @returns The id of the created verifiable storage item.\n\t */\n\tpublic async create(\n\t\tdata: Uint8Array,\n\t\tallowList?: string[],\n\t\toptions?: {\n\t\t\tmaxAllowListSize?: number;\n\t\t},\n\t\tnamespace?: string,\n\t\tcontroller?: string\n\t): Promise<{\n\t\tid: string;\n\t\treceipt: IJsonLdNodeObject;\n\t}> {\n\t\tGuards.uint8Array(VerifiableStorageService.CLASS_NAME, nameof(data), data);\n\t\tGuards.stringValue(VerifiableStorageService.CLASS_NAME, nameof(controller), controller);\n\n\t\ttry {\n\t\t\tconst connectorNamespace = namespace ?? this._defaultNamespace;\n\n\t\t\tconst verifiableStorageConnector =\n\t\t\t\tVerifiableStorageConnectorFactory.get<IVerifiableStorageConnector>(connectorNamespace);\n\n\t\t\tconst verifiableStorageResult = await verifiableStorageConnector.create(\n\t\t\t\tcontroller,\n\t\t\t\tdata,\n\t\t\t\tallowList,\n\t\t\t\toptions\n\t\t\t);\n\n\t\t\treturn verifiableStorageResult;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(VerifiableStorageService.CLASS_NAME, \"createFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Update an item in verifiable storage.\n\t * @param id The id of the item to update.\n\t * @param data The data to store, optional if updating the allow list.\n\t * @param allowList Updated list of identities that are allowed to modify the item.\n\t * @param controller The identity of the controller to access the vault keys.\n\t * @returns The updated receipt.\n\t */\n\tpublic async update(\n\t\tid: string,\n\t\tdata?: Uint8Array,\n\t\tallowList?: string[],\n\t\tcontroller?: string\n\t): Promise<IJsonLdNodeObject> {\n\t\tUrn.guard(VerifiableStorageService.CLASS_NAME, nameof(id), id);\n\t\tGuards.stringValue(VerifiableStorageService.CLASS_NAME, nameof(controller), controller);\n\n\t\ttry {\n\t\t\tconst verifiableStorageConnector = this.getConnector(id);\n\t\t\tconst verifiableStorageResult = await verifiableStorageConnector.update(\n\t\t\t\tcontroller,\n\t\t\t\tid,\n\t\t\t\tdata,\n\t\t\t\tallowList\n\t\t\t);\n\n\t\t\treturn verifiableStorageResult;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(VerifiableStorageService.CLASS_NAME, \"updateFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Get an Verifiable Storage.\n\t * @param id The id of the verifiable storage item to get.\n\t * @param options Additional options for getting the verifiable storage item.\n\t * @param options.includeData Should the data be included in the response, defaults to true.\n\t * @param options.includeAllowList Should the allow list be included in the response, defaults to true.\n\t * @returns The data for the verifiable storage item.\n\t */\n\tpublic async get(\n\t\tid: string,\n\t\toptions?: { includeData?: boolean; includeAllowList?: boolean }\n\t): Promise<{\n\t\tdata?: Uint8Array;\n\t\treceipt: IJsonLdNodeObject;\n\t}> {\n\t\tUrn.guard(VerifiableStorageService.CLASS_NAME, nameof(id), id);\n\n\t\ttry {\n\t\t\tconst verifiableStorageConnector = this.getConnector(id);\n\t\t\tconst result = await verifiableStorageConnector.get(id, options);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(VerifiableStorageService.CLASS_NAME, \"getFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Remove a verifiable storage item.\n\t * @param id The id of the Verifiable Storage to remove.\n\t * @param controller The identity of the controller to access the vault keys.\n\t * @returns Nothing.\n\t */\n\tpublic async remove(id: string, controller?: string): Promise<void> {\n\t\tUrn.guard(VerifiableStorageService.CLASS_NAME, nameof(id), id);\n\t\tGuards.stringValue(VerifiableStorageService.CLASS_NAME, nameof(controller), controller);\n\n\t\ttry {\n\t\t\tconst verifiableStorageConnector = this.getConnector(id);\n\t\t\tawait verifiableStorageConnector.remove(controller, id);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(VerifiableStorageService.CLASS_NAME, \"removeFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Get the connector from the uri.\n\t * @param id The id of the item in urn format.\n\t * @returns The connector.\n\t * @internal\n\t */\n\tprivate getConnector(id: string): IVerifiableStorageConnector {\n\t\tconst idUri = Urn.fromValidString(id);\n\n\t\tif (idUri.namespaceIdentifier() !== VerifiableStorageService._NAMESPACE) {\n\t\t\tthrow new GeneralError(VerifiableStorageService.CLASS_NAME, \"namespaceMismatch\", {\n\t\t\t\tnamespace: VerifiableStorageService._NAMESPACE,\n\t\t\t\tid\n\t\t\t});\n\t\t}\n\n\t\treturn VerifiableStorageConnectorFactory.get<IVerifiableStorageConnector>(\n\t\t\tidUri.namespaceMethod()\n\t\t);\n\t}\n}\n"]}
@@ -1,5 +1,5 @@
1
- export * from "./models/IVerifiableStorageServiceConfig";
2
- export * from "./models/IVerifiableStorageServiceConstructorOptions";
3
- export * from "./verifiableStorageRoutes";
4
- export * from "./verifiableStorageService";
5
- export * from "./restEntryPoints";
1
+ export * from "./models/IVerifiableStorageServiceConfig.js";
2
+ export * from "./models/IVerifiableStorageServiceConstructorOptions.js";
3
+ export * from "./verifiableStorageRoutes.js";
4
+ export * from "./verifiableStorageService.js";
5
+ export * from "./restEntryPoints.js";
@@ -1,4 +1,4 @@
1
- import type { IVerifiableStorageServiceConfig } from "./IVerifiableStorageServiceConfig";
1
+ import type { IVerifiableStorageServiceConfig } from "./IVerifiableStorageServiceConfig.js";
2
2
  /**
3
3
  * Options for the Verifiable Storage service constructor.
4
4
  */
@@ -1,6 +1,6 @@
1
1
  import type { IJsonLdNodeObject } from "@twin.org/data-json-ld";
2
2
  import { type IVerifiableStorageComponent } from "@twin.org/verifiable-storage-models";
3
- import type { IVerifiableStorageServiceConstructorOptions } from "./models/IVerifiableStorageServiceConstructorOptions";
3
+ import type { IVerifiableStorageServiceConstructorOptions } from "./models/IVerifiableStorageServiceConstructorOptions.js";
4
4
  /**
5
5
  * Service for performing Verifiable Storage operations to a connector.
6
6
  */
@@ -14,19 +14,24 @@ export declare class VerifiableStorageService implements IVerifiableStorageCompo
14
14
  * @param options The options for the service.
15
15
  */
16
16
  constructor(options?: IVerifiableStorageServiceConstructorOptions);
17
+ /**
18
+ * Returns the class name of the component.
19
+ * @returns The class name of the component.
20
+ */
21
+ className(): string;
17
22
  /**
18
23
  * Create a verifiable storage item.
19
24
  * @param data The data for the verifiable storage item.
20
25
  * @param allowList The list of identities that are allowed to modify the item.
21
26
  * @param options Additional options for creating the item.
22
27
  * @param options.maxAllowListSize The maximum size of the allow list.
23
- * @param identity The identity to store the Verifiable Storage operation on.
24
- * @param namespace The namespace to use for the Verifiable Storage.
28
+ * @param namespace The namespace to use for the connector to use.
29
+ * @param controller The identity of the controller to access the vault keys.
25
30
  * @returns The id of the created verifiable storage item.
26
31
  */
27
32
  create(data: Uint8Array, allowList?: string[], options?: {
28
33
  maxAllowListSize?: number;
29
- }, identity?: string, namespace?: string): Promise<{
34
+ }, namespace?: string, controller?: string): Promise<{
30
35
  id: string;
31
36
  receipt: IJsonLdNodeObject;
32
37
  }>;
@@ -35,10 +40,10 @@ export declare class VerifiableStorageService implements IVerifiableStorageCompo
35
40
  * @param id The id of the item to update.
36
41
  * @param data The data to store, optional if updating the allow list.
37
42
  * @param allowList Updated list of identities that are allowed to modify the item.
38
- * @param identity The identity of the user to access the vault keys.
43
+ * @param controller The identity of the controller to access the vault keys.
39
44
  * @returns The updated receipt.
40
45
  */
41
- update(id: string, data?: Uint8Array, allowList?: string[], identity?: string): Promise<IJsonLdNodeObject>;
46
+ update(id: string, data?: Uint8Array, allowList?: string[], controller?: string): Promise<IJsonLdNodeObject>;
42
47
  /**
43
48
  * Get an Verifiable Storage.
44
49
  * @param id The id of the verifiable storage item to get.
@@ -57,8 +62,8 @@ export declare class VerifiableStorageService implements IVerifiableStorageCompo
57
62
  /**
58
63
  * Remove a verifiable storage item.
59
64
  * @param id The id of the Verifiable Storage to remove.
60
- * @param identity The identity to perform the verifiableStorage operation on.
65
+ * @param controller The identity of the controller to access the vault keys.
61
66
  * @returns Nothing.
62
67
  */
63
- remove(id: string, identity?: string): Promise<void>;
68
+ remove(id: string, controller?: string): Promise<void>;
64
69
  }