@twin.org/verifiable-storage-service 0.0.3-next.9 → 0.9.0-next.1

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.
@@ -1 +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"]}
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 * The default connector namespace to use; falls back to the first registered connector if not provided.\n\t */\n\tdefaultNamespace?: string;\n}\n"]}
@@ -1,4 +1,7 @@
1
1
  import { generateRestRoutesVerifiableStorage, tagsVerifiableStorage } from "./verifiableStorageRoutes.js";
2
+ /**
3
+ * The REST entry points for the verifiable storage service.
4
+ */
2
5
  export const restEntryPoints = [
3
6
  {
4
7
  name: "verifiable",
@@ -1 +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
+ {"version":3,"file":"restEntryPoints.js","sourceRoot":"","sources":["../../src/restEntryPoints.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,mCAAmC,EACnC,qBAAqB,EACrB,MAAM,8BAA8B,CAAC;AAEtC;;GAEG;AACH,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\n/**\n * The REST entry points for the verifiable storage service.\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"]}
@@ -204,7 +204,7 @@ export async function verifiableStorageCreate(httpRequestContext, componentName,
204
204
  };
205
205
  }
206
206
  /**
207
- * UPdate an Verifiable Storage.
207
+ * Update a verifiable storage item.
208
208
  * @param httpRequestContext The request context for the API.
209
209
  * @param componentName The name of the component to use in the routes.
210
210
  * @param request The request.
@@ -225,7 +225,7 @@ export async function verifiableStorageUpdate(httpRequestContext, componentName,
225
225
  };
226
226
  }
227
227
  /**
228
- * Get an Verifiable Storage.
228
+ * Get a verifiable storage item.
229
229
  * @param componentName The name of the component to use in the routes.
230
230
  * @param request The request.
231
231
  * @returns The response object with additional http response properties.
@@ -1 +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;AAE5D;;GAEG;AACH,MAAM,aAAa,GAAG,yBAAyB,CAAC;AAEhD;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAW;IAC5C;QACC,IAAI,EAAE,mBAAmB;QACzB,WAAW,EAAE,8DAA8D;KAC3E;CACD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,mCAAmC,CAClD,aAAqB,EACrB,aAAqB;IAErB,MAAM,WAAW,GAChB;QACC,WAAW,EAAE,yBAAyB;QACtC,OAAO,EAAE,sCAAsC;QAC/C,GAAG,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC,IAAI;QAClC,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,GAAG,aAAa,GAAG;QACzB,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE,EAAE,CAC9C,uBAAuB,CAAC,kBAAkB,EAAE,aAAa,EAAE,OAAO,CAAC;QACpE,WAAW,EAAE;YACZ,IAAI,mCAA2C;YAC/C,QAAQ,EAAE;gBACT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AAY,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"]}
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;AAE5D;;GAEG;AACH,MAAM,aAAa,GAAG,yBAAyB,CAAC;AAEhD;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAW;IAC5C;QACC,IAAI,EAAE,mBAAmB;QACzB,WAAW,EAAE,8DAA8D;KAC3E;CACD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,mCAAmC,CAClD,aAAqB,EACrB,aAAqB;IAErB,MAAM,WAAW,GAChB;QACC,WAAW,EAAE,yBAAyB;QACtC,OAAO,EAAE,sCAAsC;QAC/C,GAAG,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC,IAAI;QAClC,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,GAAG,aAAa,GAAG;QACzB,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE,EAAE,CAC9C,uBAAuB,CAAC,kBAAkB,EAAE,aAAa,EAAE,OAA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AAa,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 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 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 a verifiable storage item.\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"]}
@@ -23,6 +23,7 @@ export class VerifiableStorageService {
23
23
  /**
24
24
  * Create a new instance of VerifiableStorageService.
25
25
  * @param options The options for the service.
26
+ * @throws {GeneralError} If no connectors are registered.
26
27
  */
27
28
  constructor(options) {
28
29
  const names = VerifiableStorageConnectorFactory.names();
@@ -82,12 +83,12 @@ export class VerifiableStorageService {
82
83
  }
83
84
  }
84
85
  /**
85
- * Get an Verifiable Storage.
86
+ * Get a verifiable storage item.
86
87
  * @param id The id of the verifiable storage item to get.
87
88
  * @param options Additional options for getting the verifiable storage item.
88
89
  * @param options.includeData Should the data be included in the response, defaults to true.
89
90
  * @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
+ * @returns The data and receipt for the verifiable storage item.
91
92
  */
92
93
  async get(id, options) {
93
94
  Urn.guard(VerifiableStorageService.CLASS_NAME, "id", id);
@@ -102,9 +103,9 @@ export class VerifiableStorageService {
102
103
  }
103
104
  /**
104
105
  * Remove a verifiable storage item.
105
- * @param id The id of the Verifiable Storage to remove.
106
+ * @param id The id of the verifiable storage item to remove.
106
107
  * @param controller The identity of the controller to access the vault keys.
107
- * @returns Nothing.
108
+ * @returns A promise that resolves when the item has been removed.
108
109
  */
109
110
  async remove(id, controller) {
110
111
  Urn.guard(VerifiableStorageService.CLASS_NAME, "id", id);
@@ -121,6 +122,7 @@ export class VerifiableStorageService {
121
122
  * Get the connector from the uri.
122
123
  * @param id The id of the item in urn format.
123
124
  * @returns The connector.
125
+ * @throws GeneralError If the namespace does not match.
124
126
  * @internal
125
127
  */
126
128
  getConnector(id) {
@@ -1 +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,CAAC,MAAM,CAClB,IAAgB,EAChB,SAAoB,EACpB,OAEC,EACD,SAAkB,EAClB,UAAmB;QAKnB,MAAM,CAAC,UAAU,CAAC,wBAAwB,CAAC,UAAU,UAAgB,IAAI,CAAC,CAAC;QAC3E,MAAM,CAAC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E,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
+ {"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;;;;OAIG;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,C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AC9B,MAAM,KAAK,GAAG,GAAG,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;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 * @throws {GeneralError} If no connectors are registered.\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 a verifiable storage item.\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 and receipt 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 item to remove.\n\t * @param controller The identity of the controller to access the vault keys.\n\t * @returns A promise that resolves when the item has been removed.\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 * @throws GeneralError If the namespace does not match.\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"]}
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export interface IVerifiableStorageServiceConfig {
5
5
  /**
6
- * What is the default connector to use for Verifiable Storage. If not provided the first connector from the factory will be used.
6
+ * The default connector namespace to use; falls back to the first registered connector if not provided.
7
7
  */
8
8
  defaultNamespace?: string;
9
9
  }
@@ -1,2 +1,5 @@
1
1
  import type { IRestRouteEntryPoint } from "@twin.org/api-models";
2
+ /**
3
+ * The REST entry points for the verifiable storage service.
4
+ */
2
5
  export declare const restEntryPoints: IRestRouteEntryPoint[];
@@ -20,7 +20,7 @@ export declare function generateRestRoutesVerifiableStorage(baseRouteName: strin
20
20
  */
21
21
  export declare function verifiableStorageCreate(httpRequestContext: IHttpRequestContext, componentName: string, request: IVerifiableStorageCreateRequest): Promise<IVerifiableStorageCreateResponse>;
22
22
  /**
23
- * UPdate an Verifiable Storage.
23
+ * Update a verifiable storage item.
24
24
  * @param httpRequestContext The request context for the API.
25
25
  * @param componentName The name of the component to use in the routes.
26
26
  * @param request The request.
@@ -28,7 +28,7 @@ export declare function verifiableStorageCreate(httpRequestContext: IHttpRequest
28
28
  */
29
29
  export declare function verifiableStorageUpdate(httpRequestContext: IHttpRequestContext, componentName: string, request: IVerifiableStorageUpdateRequest): Promise<IVerifiableStorageUpdateResponse>;
30
30
  /**
31
- * Get an Verifiable Storage.
31
+ * Get a verifiable storage item.
32
32
  * @param componentName The name of the component to use in the routes.
33
33
  * @param request The request.
34
34
  * @returns The response object with additional http response properties.
@@ -12,6 +12,7 @@ export declare class VerifiableStorageService implements IVerifiableStorageCompo
12
12
  /**
13
13
  * Create a new instance of VerifiableStorageService.
14
14
  * @param options The options for the service.
15
+ * @throws {GeneralError} If no connectors are registered.
15
16
  */
16
17
  constructor(options?: IVerifiableStorageServiceConstructorOptions);
17
18
  /**
@@ -45,12 +46,12 @@ export declare class VerifiableStorageService implements IVerifiableStorageCompo
45
46
  */
46
47
  update(id: string, data?: Uint8Array, allowList?: string[], controller?: string): Promise<IJsonLdNodeObject>;
47
48
  /**
48
- * Get an Verifiable Storage.
49
+ * Get a verifiable storage item.
49
50
  * @param id The id of the verifiable storage item to get.
50
51
  * @param options Additional options for getting the verifiable storage item.
51
52
  * @param options.includeData Should the data be included in the response, defaults to true.
52
53
  * @param options.includeAllowList Should the allow list be included in the response, defaults to true.
53
- * @returns The data for the verifiable storage item.
54
+ * @returns The data and receipt for the verifiable storage item.
54
55
  */
55
56
  get(id: string, options?: {
56
57
  includeData?: boolean;
@@ -61,9 +62,9 @@ export declare class VerifiableStorageService implements IVerifiableStorageCompo
61
62
  }>;
62
63
  /**
63
64
  * Remove a verifiable storage item.
64
- * @param id The id of the Verifiable Storage to remove.
65
+ * @param id The id of the verifiable storage item to remove.
65
66
  * @param controller The identity of the controller to access the vault keys.
66
- * @returns Nothing.
67
+ * @returns A promise that resolves when the item has been removed.
67
68
  */
68
69
  remove(id: string, controller?: string): Promise<void>;
69
70
  }
package/docs/changelog.md CHANGED
@@ -1,5 +1,104 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.9.0-next.1](https://github.com/iotaledger/twin-verifiable-storage/compare/verifiable-storage-service-v0.9.0-next.0...verifiable-storage-service-v0.9.0-next.1) (2026-06-23)
4
+
5
+
6
+ ### Features
7
+
8
+ * add context id features ([#40](https://github.com/iotaledger/twin-verifiable-storage/issues/40)) ([260b96a](https://github.com/iotaledger/twin-verifiable-storage/commit/260b96a8b7d1a26c6c415f2de12e09671ee70220))
9
+ * add support for allowlist ([#17](https://github.com/iotaledger/twin-verifiable-storage/issues/17)) ([9341ea6](https://github.com/iotaledger/twin-verifiable-storage/commit/9341ea6b95dfbf2a5dc70a53e5979d7d0e8b2de6))
10
+ * add validate-locales ([326384f](https://github.com/iotaledger/twin-verifiable-storage/commit/326384fe867604e7cd450460a6a56c6c7bdc8f98))
11
+ * additional fields in IOTA receipt ([f1ddffa](https://github.com/iotaledger/twin-verifiable-storage/commit/f1ddffa82b5d3fafe00bfe2ca938e9c6982e5aca))
12
+ * eslint migration to flat config ([b0a0b85](https://github.com/iotaledger/twin-verifiable-storage/commit/b0a0b8585a77c1e541531d60b432916b9dc0867e))
13
+ * remove unused namespace ([e95b332](https://github.com/iotaledger/twin-verifiable-storage/commit/e95b33251950bb2f04bff0cb643ed8bcdb2897d3))
14
+ * typescript 6 update ([66823cf](https://github.com/iotaledger/twin-verifiable-storage/commit/66823cf7a6522622c889afdc49005d016e8574fe))
15
+ * update allow list name case ([278a787](https://github.com/iotaledger/twin-verifiable-storage/commit/278a787e96864c95438f87adaac6f2fc8b6bebcd))
16
+ * update connector config and tests for gas station ([#25](https://github.com/iotaledger/twin-verifiable-storage/issues/25)) ([e0997ff](https://github.com/iotaledger/twin-verifiable-storage/commit/e0997ffb0f4869dca11f248a9886acdd22c7dcc2))
17
+ * update dependencies ([a16a772](https://github.com/iotaledger/twin-verifiable-storage/commit/a16a77244cb1d312ea5ee74232bcdadd25f2b330))
18
+ * update framework core ([efa612e](https://github.com/iotaledger/twin-verifiable-storage/commit/efa612e54dbe2d8f223f27ff9e315e08a2fed04b))
19
+ * update IOTA verifiable storage connector to use the updated move-to-json cli ([#33](https://github.com/iotaledger/twin-verifiable-storage/issues/33)) ([7c8d0d2](https://github.com/iotaledger/twin-verifiable-storage/commit/7c8d0d2e0418333ab1f897f744326c5c72857932))
20
+ * update schemas ([a44dd16](https://github.com/iotaledger/twin-verifiable-storage/commit/a44dd164d03b799a38786dae655a42b1a5dcf9cc))
21
+ * use new dlt packages with latency fix ([#6](https://github.com/iotaledger/twin-verifiable-storage/issues/6)) ([d81c45b](https://github.com/iotaledger/twin-verifiable-storage/commit/d81c45bce035864a41bbd498815169d7257fbcb8))
22
+ * use shared store mechanism ([#8](https://github.com/iotaledger/twin-verifiable-storage/issues/8)) ([8c8ecb8](https://github.com/iotaledger/twin-verifiable-storage/commit/8c8ecb83d32431952c594ea23d37040991f5b4d3))
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * tests ([e30075e](https://github.com/iotaledger/twin-verifiable-storage/commit/e30075e0100a7eb956d4042b01b40fe3bd9ec62a))
28
+
29
+
30
+ ### Dependencies
31
+
32
+ * The following workspace dependencies were updated
33
+ * dependencies
34
+ * @twin.org/verifiable-storage-models bumped from 0.9.0-next.0 to 0.9.0-next.1
35
+ * devDependencies
36
+ * @twin.org/verifiable-storage-connector-entity-storage bumped from 0.9.0-next.0 to 0.9.0-next.1
37
+
38
+ ## [0.0.3-next.13](https://github.com/iotaledger/twin-verifiable-storage/compare/verifiable-storage-service-v0.0.3-next.12...verifiable-storage-service-v0.0.3-next.13) (2026-06-11)
39
+
40
+
41
+ ### Miscellaneous Chores
42
+
43
+ * **verifiable-storage-service:** Synchronize repo versions
44
+
45
+
46
+ ### Dependencies
47
+
48
+ * The following workspace dependencies were updated
49
+ * dependencies
50
+ * @twin.org/verifiable-storage-models bumped from 0.0.3-next.12 to 0.0.3-next.13
51
+ * devDependencies
52
+ * @twin.org/verifiable-storage-connector-entity-storage bumped from 0.0.3-next.12 to 0.0.3-next.13
53
+
54
+ ## [0.0.3-next.12](https://github.com/iotaledger/twin-verifiable-storage/compare/verifiable-storage-service-v0.0.3-next.11...verifiable-storage-service-v0.0.3-next.12) (2026-05-28)
55
+
56
+
57
+ ### Miscellaneous Chores
58
+
59
+ * **verifiable-storage-service:** Synchronize repo versions
60
+
61
+
62
+ ### Dependencies
63
+
64
+ * The following workspace dependencies were updated
65
+ * dependencies
66
+ * @twin.org/verifiable-storage-models bumped from 0.0.3-next.11 to 0.0.3-next.12
67
+ * devDependencies
68
+ * @twin.org/verifiable-storage-connector-entity-storage bumped from 0.0.3-next.11 to 0.0.3-next.12
69
+
70
+ ## [0.0.3-next.11](https://github.com/iotaledger/twin-verifiable-storage/compare/verifiable-storage-service-v0.0.3-next.10...verifiable-storage-service-v0.0.3-next.11) (2026-05-20)
71
+
72
+
73
+ ### Miscellaneous Chores
74
+
75
+ * **verifiable-storage-service:** Synchronize repo versions
76
+
77
+
78
+ ### Dependencies
79
+
80
+ * The following workspace dependencies were updated
81
+ * dependencies
82
+ * @twin.org/verifiable-storage-models bumped from 0.0.3-next.10 to 0.0.3-next.11
83
+ * devDependencies
84
+ * @twin.org/verifiable-storage-connector-entity-storage bumped from 0.0.3-next.10 to 0.0.3-next.11
85
+
86
+ ## [0.0.3-next.10](https://github.com/iotaledger/twin-verifiable-storage/compare/verifiable-storage-service-v0.0.3-next.9...verifiable-storage-service-v0.0.3-next.10) (2026-05-12)
87
+
88
+
89
+ ### Features
90
+
91
+ * typescript 6 update ([66823cf](https://github.com/iotaledger/twin-verifiable-storage/commit/66823cf7a6522622c889afdc49005d016e8574fe))
92
+
93
+
94
+ ### Dependencies
95
+
96
+ * The following workspace dependencies were updated
97
+ * dependencies
98
+ * @twin.org/verifiable-storage-models bumped from 0.0.3-next.9 to 0.0.3-next.10
99
+ * devDependencies
100
+ * @twin.org/verifiable-storage-connector-entity-storage bumped from 0.0.3-next.9 to 0.0.3-next.10
101
+
3
102
  ## [0.0.3-next.9](https://github.com/iotaledger/twin-verifiable-storage/compare/verifiable-storage-service-v0.0.3-next.8...verifiable-storage-service-v0.0.3-next.9) (2026-05-08)
4
103
 
5
104
 
@@ -481,7 +481,7 @@
481
481
  },
482
482
  "message": {
483
483
  "type": "string",
484
- "description": "The message for the error."
484
+ "description": "The message for the error as an i18n key."
485
485
  },
486
486
  "source": {
487
487
  "type": "string",
@@ -549,7 +549,7 @@
549
549
  "receipt",
550
550
  "id"
551
551
  ],
552
- "description": "The data that was stored."
552
+ "description": "The created verifiable storage item details."
553
553
  },
554
554
  "VerifiableStorageGetRequest": {
555
555
  "type": "object",
@@ -588,7 +588,7 @@
588
588
  "required": [
589
589
  "receipt"
590
590
  ],
591
- "description": "The data that was obtained."
591
+ "description": "The retrieved verifiable storage item contents."
592
592
  },
593
593
  "VerifiableStorageUpdateRequest": {
594
594
  "type": "object",
@@ -26,6 +26,10 @@ The options for the service.
26
26
 
27
27
  `VerifiableStorageService`
28
28
 
29
+ #### Throws
30
+
31
+ If no connectors are registered.
32
+
29
33
  ## Properties
30
34
 
31
35
  ### CLASS\_NAME {#class_name}
@@ -156,7 +160,7 @@ The updated receipt.
156
160
 
157
161
  > **get**(`id`, `options?`): `Promise`\<\{ `data?`: `Uint8Array`\<`ArrayBufferLike`\>; `receipt`: `IJsonLdNodeObject`; \}\>
158
162
 
159
- Get an Verifiable Storage.
163
+ Get a verifiable storage item.
160
164
 
161
165
  #### Parameters
162
166
 
@@ -186,7 +190,7 @@ Should the allow list be included in the response, defaults to true.
186
190
 
187
191
  `Promise`\<\{ `data?`: `Uint8Array`\<`ArrayBufferLike`\>; `receipt`: `IJsonLdNodeObject`; \}\>
188
192
 
189
- The data for the verifiable storage item.
193
+ The data and receipt for the verifiable storage item.
190
194
 
191
195
  #### Implementation of
192
196
 
@@ -206,7 +210,7 @@ Remove a verifiable storage item.
206
210
 
207
211
  `string`
208
212
 
209
- The id of the Verifiable Storage to remove.
213
+ The id of the verifiable storage item to remove.
210
214
 
211
215
  ##### controller?
212
216
 
@@ -218,7 +222,7 @@ The identity of the controller to access the vault keys.
218
222
 
219
223
  `Promise`\<`void`\>
220
224
 
221
- Nothing.
225
+ A promise that resolves when the item has been removed.
222
226
 
223
227
  #### Implementation of
224
228
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  > **verifiableStorageGet**(`componentName`, `request`): `Promise`\<`IVerifiableStorageGetResponse`\>
4
4
 
5
- Get an Verifiable Storage.
5
+ Get a verifiable storage item.
6
6
 
7
7
  ## Parameters
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  > **verifiableStorageUpdate**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`IVerifiableStorageUpdateResponse`\>
4
4
 
5
- UPdate an Verifiable Storage.
5
+ Update a verifiable storage item.
6
6
 
7
7
  ## Parameters
8
8
 
@@ -8,4 +8,4 @@ Configuration for the Verifiable Storage Service.
8
8
 
9
9
  > `optional` **defaultNamespace?**: `string`
10
10
 
11
- What is the default connector to use for Verifiable Storage. If not provided the first connector from the factory will be used.
11
+ The default connector namespace to use; falls back to the first registered connector if not provided.
@@ -1,3 +1,5 @@
1
1
  # Variable: restEntryPoints
2
2
 
3
3
  > `const` **restEntryPoints**: `IRestRouteEntryPoint`[]
4
+
5
+ The REST entry points for the verifiable storage service.
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@twin.org/verifiable-storage-service",
3
- "version": "0.0.3-next.9",
3
+ "version": "0.9.0-next.1",
4
4
  "description": "Service component and REST routes that expose verifiable storage operations",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "git+https://github.com/iotaledger/verifiable-storage.git",
7
+ "url": "git+https://github.com/iotaledger/twin-verifiable-storage.git",
8
8
  "directory": "packages/verifiable-storage-service"
9
9
  },
10
10
  "contributors": [
@@ -17,13 +17,13 @@
17
17
  "node": ">=20.0.0"
18
18
  },
19
19
  "dependencies": {
20
- "@twin.org/api-models": "next",
21
- "@twin.org/context": "next",
22
- "@twin.org/core": "next",
23
- "@twin.org/entity": "next",
24
- "@twin.org/nameof": "next",
25
- "@twin.org/verifiable-storage-models": "0.0.3-next.9",
26
- "@twin.org/web": "next"
20
+ "@twin.org/api-models": "0.9.0-next.1",
21
+ "@twin.org/context": "0.9.0-next.1",
22
+ "@twin.org/core": "0.9.0-next.1",
23
+ "@twin.org/entity": "0.9.0-next.1",
24
+ "@twin.org/nameof": "0.9.0-next.1",
25
+ "@twin.org/verifiable-storage-models": "0.9.0-next.1",
26
+ "@twin.org/web": "0.9.0-next.1"
27
27
  },
28
28
  "main": "./dist/es/index.js",
29
29
  "types": "./dist/types/index.d.ts",
@@ -57,7 +57,7 @@
57
57
  "business-logic"
58
58
  ],
59
59
  "bugs": {
60
- "url": "git+https://github.com/iotaledger/verifiable-storage/issues"
60
+ "url": "git+https://github.com/iotaledger/twin-verifiable-storage/issues"
61
61
  },
62
62
  "homepage": "https://twindev.org"
63
63
  }