@twin.org/blob-storage-connector-ipfs 0.0.3-next.6 → 0.0.3-next.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # TWIN Blob Storage Connector IPFS
2
2
 
3
- Blob Storage connector implementation using [IPFS](https://ipfs.tech/).
3
+ This package integrates blob workflows with [IPFS](https://ipfs.tech/) for decentralised, content-addressed storage and retrieval. It supports distributed scenarios where immutable content addressing is important.
4
4
 
5
5
  ## Installation
6
6
 
@@ -8,18 +8,12 @@ Blob Storage connector implementation using [IPFS](https://ipfs.tech/).
8
8
  npm install @twin.org/blob-storage-connector-ipfs
9
9
  ```
10
10
 
11
- ## Testing
11
+ ## Docker
12
12
 
13
- The tests developed are functional tests and need an instance of IPFS up and running. To run IPFS locally:
13
+ To perform testing of this component it may be necessary to launch a local instance to communicate with.
14
14
 
15
15
  ```shell
16
- docker run -p 4001:4001 -p 4001:4001/udp -p 8080:8080 -p 5001:5001 --name twin-blob-ipfs --hostname ipfs -d ipfs/kubo:latest
17
- ```
18
-
19
- Afterwards you can run the tests as follows:
20
-
21
- ```shell
22
- npm run test
16
+ docker run -d --name twin-blob-storage-ipfs -p 4001:4001 -p 4001:4001/udp -p 8080:8080 -p 5001:5001 ipfs/kubo:latest
23
17
  ```
24
18
 
25
19
  ## Examples
@@ -1,4 +1,4 @@
1
- import { GeneralError, Guards, Is, StringHelper, Urn } from "@twin.org/core";
1
+ import { GeneralError, Guards, HealthStatus, Is, StringHelper, Urn } from "@twin.org/core";
2
2
  import { HeaderHelper, HeaderTypes, MimeTypes } from "@twin.org/web";
3
3
  /**
4
4
  * Class for performing blob storage operations on IPFS.
@@ -42,6 +42,40 @@ export class IpfsBlobStorageConnector {
42
42
  className() {
43
43
  return IpfsBlobStorageConnector.CLASS_NAME;
44
44
  }
45
+ /**
46
+ * Returns the health status of the component.
47
+ * @returns The health status of the component.
48
+ */
49
+ async health() {
50
+ try {
51
+ const fetchOptions = {
52
+ method: "POST",
53
+ headers: {
54
+ accept: MimeTypes.Json
55
+ }
56
+ };
57
+ this.addSecurity(fetchOptions);
58
+ const response = await fetch(`${this._config.apiUrl}/version`, fetchOptions);
59
+ if (response.ok) {
60
+ return [
61
+ {
62
+ source: IpfsBlobStorageConnector.CLASS_NAME,
63
+ status: HealthStatus.Ok,
64
+ description: "healthDescription"
65
+ }
66
+ ];
67
+ }
68
+ }
69
+ catch { }
70
+ return [
71
+ {
72
+ source: IpfsBlobStorageConnector.CLASS_NAME,
73
+ status: HealthStatus.Error,
74
+ description: "healthDescription",
75
+ message: "healthCheckFailed"
76
+ }
77
+ ];
78
+ }
45
79
  /**
46
80
  * Set the blob.
47
81
  * @param blob The data for the blob.
@@ -1 +1 @@
1
- {"version":3,"file":"ipfsBlobStorageConnector.js","sourceRoot":"","sources":["../../src/ipfsBlobStorageConnector.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAE7E,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAIrE;;;GAGG;AACH,MAAM,OAAO,wBAAwB;IACpC;;OAEG;IACI,MAAM,CAAU,SAAS,GAAW,MAAM,CAAC;IAElD;;OAEG;IACI,MAAM,CAAU,UAAU,8BAA8C;IAE/E;;;OAGG;IACc,OAAO,CAAkC;IAE1D;;;OAGG;IACc,oBAAoB,CAAY;IAEjD;;;OAGG;IACH,YAAY,OAAoD;QAC/D,MAAM,CAAC,MAAM,CAAC,wBAAwB,CAAC,UAAU,aAAmB,OAAO,CAAC,CAAC;QAC7E,MAAM,CAAC,MAAM,CACZ,wBAAwB,CAAC,UAAU,oBAEnC,OAAO,CAAC,MAAM,CACd,CAAC;QACF,MAAM,CAAC,WAAW,CACjB,wBAAwB,CAAC,UAAU,2BAEnC,OAAO,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.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IBlobStorageConnector } from \"@twin.org/blob-storage-models\";\nimport { GeneralError, Guards, Is, StringHelper, Urn } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { HeaderHelper, HeaderTypes, MimeTypes } from \"@twin.org/web\";\nimport type { IIpfsBlobStorageConnectorConfig } from \"./models/IIpfsBlobStorageConnectorConfig.js\";\nimport type { IIpfsBlobStorageConnectorConstructorOptions } from \"./models/IIpfsBlobStorageConnectorConstructorOptions.js\";\n\n/**\n * Class for performing blob storage operations on IPFS.\n * See https://docs.ipfs.tech/reference/kubo/rpc/ for more information.\n */\nexport class IpfsBlobStorageConnector implements IBlobStorageConnector {\n\t/**\n\t * The namespace for the items.\n\t */\n\tpublic static readonly NAMESPACE: string = \"ipfs\";\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IpfsBlobStorageConnector>();\n\n\t/**\n\t * The configuration for the connector.\n\t * @internal\n\t */\n\tprivate readonly _config: IIpfsBlobStorageConnectorConfig;\n\n\t/**\n\t * The keys to use from the context ids to create partitions.\n\t * @internal\n\t */\n\tprivate readonly _partitionContextIds?: string[];\n\n\t/**\n\t * Create a new instance of IpfsBlobStorageConnector.\n\t * @param options The options for the connector.\n\t */\n\tconstructor(options: IIpfsBlobStorageConnectorConstructorOptions) {\n\t\tGuards.object(IpfsBlobStorageConnector.CLASS_NAME, nameof(options), options);\n\t\tGuards.object<IIpfsBlobStorageConnectorConfig>(\n\t\t\tIpfsBlobStorageConnector.CLASS_NAME,\n\t\t\tnameof(options.config),\n\t\t\toptions.config\n\t\t);\n\t\tGuards.stringValue(\n\t\t\tIpfsBlobStorageConnector.CLASS_NAME,\n\t\t\tnameof(options.config.apiUrl),\n\t\t\toptions.config.apiUrl\n\t\t);\n\n\t\tthis._config = options.config;\n\t\tthis._partitionContextIds = options.partitionContextIds;\n\t\tthis._config.apiUrl = StringHelper.trimTrailingSlashes(this._config.apiUrl);\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 IpfsBlobStorageConnector.CLASS_NAME;\n\t}\n\n\t/**\n\t * Set the blob.\n\t * @param blob The data for the blob.\n\t * @returns The id of the stored blob in urn format.\n\t */\n\tpublic async set(blob: Uint8Array): Promise<string> {\n\t\tGuards.uint8Array(IpfsBlobStorageConnector.CLASS_NAME, nameof(blob), blob);\n\n\t\ttry {\n\t\t\tconst formBlob = new Blob([new Uint8Array(blob)], { type: MimeTypes.OctetStream });\n\t\t\tconst formData = new FormData();\n\t\t\tformData.append(\"file\", formBlob);\n\n\t\t\tconst fetchOptions: RequestInit = {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tbody: formData,\n\t\t\t\theaders: {\n\t\t\t\t\t[HeaderTypes.Accept]: MimeTypes.Json,\n\t\t\t\t\t[HeaderTypes.ContentDisposition]: \"form-data\"\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tthis.addSecurity(fetchOptions);\n\n\t\t\tconst response = await fetch(`${this._config.apiUrl}/add?pin=true`, fetchOptions);\n\n\t\t\tif (response.ok) {\n\t\t\t\tconst result = (await response.json()) as {\n\t\t\t\t\tName: string;\n\t\t\t\t\tHash: string;\n\t\t\t\t\tSize: string;\n\t\t\t\t};\n\n\t\t\t\treturn `blob:${new Urn(IpfsBlobStorageConnector.NAMESPACE, result.Hash).toString()}`;\n\t\t\t}\n\n\t\t\tconst error = await response.json();\n\t\t\tthrow new GeneralError(IpfsBlobStorageConnector.CLASS_NAME, \"fetchFail\", error);\n\t\t} catch (err) {\n\t\t\tthrow new GeneralError(IpfsBlobStorageConnector.CLASS_NAME, \"setBlobFailed\", undefined, err);\n\t\t}\n\t}\n\n\t/**\n\t * Get the blob.\n\t * @param id The id of the blob to get in urn format.\n\t * @returns The data for the blob if it can be found or undefined.\n\t */\n\tpublic async get(id: string): Promise<Uint8Array | undefined> {\n\t\tUrn.guard(IpfsBlobStorageConnector.CLASS_NAME, nameof(id), id);\n\t\tconst urnParsed = Urn.fromValidString(id);\n\n\t\tif (urnParsed.namespaceMethod() !== IpfsBlobStorageConnector.NAMESPACE) {\n\t\t\tthrow new GeneralError(IpfsBlobStorageConnector.CLASS_NAME, \"namespaceMismatch\", {\n\t\t\t\tnamespace: IpfsBlobStorageConnector.NAMESPACE,\n\t\t\t\tid\n\t\t\t});\n\t\t}\n\n\t\ttry {\n\t\t\tconst fetchOptions: RequestInit = {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: {\n\t\t\t\t\taccept: MimeTypes.Json\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tthis.addSecurity(fetchOptions);\n\n\t\t\tconst responseStat = await fetch(\n\t\t\t\t`${this._config.apiUrl}/block/stat?arg=${urnParsed.namespaceSpecific(1)}&local=true`,\n\t\t\t\tfetchOptions\n\t\t\t);\n\n\t\t\tif (!responseStat.ok) {\n\t\t\t\tconst resp = await responseStat.json();\n\t\t\t\tif (\n\t\t\t\t\tIs.object<{ Message: string }>(resp) &&\n\t\t\t\t\tIs.stringValue(resp.Message) &&\n\t\t\t\t\tresp.Message.includes(\"not found\")\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst response = await fetch(\n\t\t\t\t`${this._config.apiUrl}/cat?arg=${urnParsed.namespaceSpecific(1)}`,\n\t\t\t\tfetchOptions\n\t\t\t);\n\n\t\t\tif (response.ok) {\n\t\t\t\tconst result = await response.arrayBuffer();\n\t\t\t\treturn new Uint8Array(result);\n\t\t\t}\n\n\t\t\tconst error = await response.json();\n\t\t\tthrow new GeneralError(IpfsBlobStorageConnector.CLASS_NAME, \"fetchFail\", error);\n\t\t} catch (err) {\n\t\t\tthrow new GeneralError(IpfsBlobStorageConnector.CLASS_NAME, \"getBlobFailed\", undefined, err);\n\t\t}\n\t}\n\n\t/**\n\t * Remove the blob.\n\t * @param id The id of the blob to remove in urn format.\n\t * @returns True if the blob was found.\n\t */\n\tpublic async remove(id: string): Promise<boolean> {\n\t\tUrn.guard(IpfsBlobStorageConnector.CLASS_NAME, nameof(id), id);\n\t\tconst urnParsed = Urn.fromValidString(id);\n\n\t\tif (urnParsed.namespaceMethod() !== IpfsBlobStorageConnector.NAMESPACE) {\n\t\t\tthrow new GeneralError(IpfsBlobStorageConnector.CLASS_NAME, \"namespaceMismatch\", {\n\t\t\t\tnamespace: IpfsBlobStorageConnector.NAMESPACE,\n\t\t\t\tid\n\t\t\t});\n\t\t}\n\n\t\ttry {\n\t\t\tconst fetchOptions: RequestInit = {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: {\n\t\t\t\t\taccept: MimeTypes.Json\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tthis.addSecurity(fetchOptions);\n\n\t\t\tconst response = await fetch(\n\t\t\t\t`${this._config.apiUrl}/pin/rm?arg=${urnParsed.namespaceSpecific(1)}`,\n\t\t\t\tfetchOptions\n\t\t\t);\n\n\t\t\tif (response.ok) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tconst error = await response.json();\n\t\t\tthrow new GeneralError(IpfsBlobStorageConnector.CLASS_NAME, \"fetchFail\", error);\n\t\t} catch (err) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIpfsBlobStorageConnector.CLASS_NAME,\n\t\t\t\t\"removeBlobFailed\",\n\t\t\t\tundefined,\n\t\t\t\terr\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Add the security to the request.\n\t * @param requestInit The request options.\n\t * @internal\n\t */\n\tprivate addSecurity(requestInit: RequestInit): void {\n\t\tif (Is.stringValue(this._config.bearerToken)) {\n\t\t\trequestInit.headers = {\n\t\t\t\t...requestInit.headers,\n\t\t\t\t[HeaderTypes.Authorization]: HeaderHelper.createBearer(this._config.bearerToken)\n\t\t\t};\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"ipfsBlobStorageConnector.js","sourceRoot":"","sources":["../../src/ipfsBlob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ACrB,GAAG,WAAW,CAAC,OAAO;gBACtB,CAAC,WAAW,CAAC,aAAa,CAAC,EAAE,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;aAChF,CAAC;QACH,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IBlobStorageConnector } from \"@twin.org/blob-storage-models\";\nimport {\n\tGeneralError,\n\tGuards,\n\tHealthStatus,\n\tIs,\n\tStringHelper,\n\tUrn,\n\ttype IHealth\n} from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { HeaderHelper, HeaderTypes, MimeTypes } from \"@twin.org/web\";\nimport type { IIpfsBlobStorageConnectorConfig } from \"./models/IIpfsBlobStorageConnectorConfig.js\";\nimport type { IIpfsBlobStorageConnectorConstructorOptions } from \"./models/IIpfsBlobStorageConnectorConstructorOptions.js\";\n\n/**\n * Class for performing blob storage operations on IPFS.\n * See https://docs.ipfs.tech/reference/kubo/rpc/ for more information.\n */\nexport class IpfsBlobStorageConnector implements IBlobStorageConnector {\n\t/**\n\t * The namespace for the items.\n\t */\n\tpublic static readonly NAMESPACE: string = \"ipfs\";\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IpfsBlobStorageConnector>();\n\n\t/**\n\t * The configuration for the connector.\n\t * @internal\n\t */\n\tprivate readonly _config: IIpfsBlobStorageConnectorConfig;\n\n\t/**\n\t * The keys to use from the context ids to create partitions.\n\t * @internal\n\t */\n\tprivate readonly _partitionContextIds?: string[];\n\n\t/**\n\t * Create a new instance of IpfsBlobStorageConnector.\n\t * @param options The options for the connector.\n\t */\n\tconstructor(options: IIpfsBlobStorageConnectorConstructorOptions) {\n\t\tGuards.object(IpfsBlobStorageConnector.CLASS_NAME, nameof(options), options);\n\t\tGuards.object<IIpfsBlobStorageConnectorConfig>(\n\t\t\tIpfsBlobStorageConnector.CLASS_NAME,\n\t\t\tnameof(options.config),\n\t\t\toptions.config\n\t\t);\n\t\tGuards.stringValue(\n\t\t\tIpfsBlobStorageConnector.CLASS_NAME,\n\t\t\tnameof(options.config.apiUrl),\n\t\t\toptions.config.apiUrl\n\t\t);\n\n\t\tthis._config = options.config;\n\t\tthis._partitionContextIds = options.partitionContextIds;\n\t\tthis._config.apiUrl = StringHelper.trimTrailingSlashes(this._config.apiUrl);\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 IpfsBlobStorageConnector.CLASS_NAME;\n\t}\n\n\t/**\n\t * Returns the health status of the component.\n\t * @returns The health status of the component.\n\t */\n\tpublic async health(): Promise<IHealth[]> {\n\t\ttry {\n\t\t\tconst fetchOptions: RequestInit = {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: {\n\t\t\t\t\taccept: MimeTypes.Json\n\t\t\t\t}\n\t\t\t};\n\t\t\tthis.addSecurity(fetchOptions);\n\t\t\tconst response = await fetch(`${this._config.apiUrl}/version`, fetchOptions);\n\t\t\tif (response.ok) {\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\tsource: IpfsBlobStorageConnector.CLASS_NAME,\n\t\t\t\t\t\tstatus: HealthStatus.Ok,\n\t\t\t\t\t\tdescription: \"healthDescription\"\n\t\t\t\t\t}\n\t\t\t\t];\n\t\t\t}\n\t\t} catch {}\n\t\treturn [\n\t\t\t{\n\t\t\t\tsource: IpfsBlobStorageConnector.CLASS_NAME,\n\t\t\t\tstatus: HealthStatus.Error,\n\t\t\t\tdescription: \"healthDescription\",\n\t\t\t\tmessage: \"healthCheckFailed\"\n\t\t\t}\n\t\t];\n\t}\n\n\t/**\n\t * Set the blob.\n\t * @param blob The data for the blob.\n\t * @returns The id of the stored blob in urn format.\n\t */\n\tpublic async set(blob: Uint8Array): Promise<string> {\n\t\tGuards.uint8Array(IpfsBlobStorageConnector.CLASS_NAME, nameof(blob), blob);\n\n\t\ttry {\n\t\t\tconst formBlob = new Blob([new Uint8Array(blob)], { type: MimeTypes.OctetStream });\n\t\t\tconst formData = new FormData();\n\t\t\tformData.append(\"file\", formBlob);\n\n\t\t\tconst fetchOptions: RequestInit = {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tbody: formData,\n\t\t\t\theaders: {\n\t\t\t\t\t[HeaderTypes.Accept]: MimeTypes.Json,\n\t\t\t\t\t[HeaderTypes.ContentDisposition]: \"form-data\"\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tthis.addSecurity(fetchOptions);\n\n\t\t\tconst response = await fetch(`${this._config.apiUrl}/add?pin=true`, fetchOptions);\n\n\t\t\tif (response.ok) {\n\t\t\t\tconst result = (await response.json()) as {\n\t\t\t\t\tName: string;\n\t\t\t\t\tHash: string;\n\t\t\t\t\tSize: string;\n\t\t\t\t};\n\n\t\t\t\treturn `blob:${new Urn(IpfsBlobStorageConnector.NAMESPACE, result.Hash).toString()}`;\n\t\t\t}\n\n\t\t\tconst error = await response.json();\n\t\t\tthrow new GeneralError(IpfsBlobStorageConnector.CLASS_NAME, \"fetchFail\", error);\n\t\t} catch (err) {\n\t\t\tthrow new GeneralError(IpfsBlobStorageConnector.CLASS_NAME, \"setBlobFailed\", undefined, err);\n\t\t}\n\t}\n\n\t/**\n\t * Get the blob.\n\t * @param id The id of the blob to get in urn format.\n\t * @returns The data for the blob if it can be found or undefined.\n\t */\n\tpublic async get(id: string): Promise<Uint8Array | undefined> {\n\t\tUrn.guard(IpfsBlobStorageConnector.CLASS_NAME, nameof(id), id);\n\t\tconst urnParsed = Urn.fromValidString(id);\n\n\t\tif (urnParsed.namespaceMethod() !== IpfsBlobStorageConnector.NAMESPACE) {\n\t\t\tthrow new GeneralError(IpfsBlobStorageConnector.CLASS_NAME, \"namespaceMismatch\", {\n\t\t\t\tnamespace: IpfsBlobStorageConnector.NAMESPACE,\n\t\t\t\tid\n\t\t\t});\n\t\t}\n\n\t\ttry {\n\t\t\tconst fetchOptions: RequestInit = {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: {\n\t\t\t\t\taccept: MimeTypes.Json\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tthis.addSecurity(fetchOptions);\n\n\t\t\tconst responseStat = await fetch(\n\t\t\t\t`${this._config.apiUrl}/block/stat?arg=${urnParsed.namespaceSpecific(1)}&local=true`,\n\t\t\t\tfetchOptions\n\t\t\t);\n\n\t\t\tif (!responseStat.ok) {\n\t\t\t\tconst resp = await responseStat.json();\n\t\t\t\tif (\n\t\t\t\t\tIs.object<{ Message: string }>(resp) &&\n\t\t\t\t\tIs.stringValue(resp.Message) &&\n\t\t\t\t\tresp.Message.includes(\"not found\")\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst response = await fetch(\n\t\t\t\t`${this._config.apiUrl}/cat?arg=${urnParsed.namespaceSpecific(1)}`,\n\t\t\t\tfetchOptions\n\t\t\t);\n\n\t\t\tif (response.ok) {\n\t\t\t\tconst result = await response.arrayBuffer();\n\t\t\t\treturn new Uint8Array(result);\n\t\t\t}\n\n\t\t\tconst error = await response.json();\n\t\t\tthrow new GeneralError(IpfsBlobStorageConnector.CLASS_NAME, \"fetchFail\", error);\n\t\t} catch (err) {\n\t\t\tthrow new GeneralError(IpfsBlobStorageConnector.CLASS_NAME, \"getBlobFailed\", undefined, err);\n\t\t}\n\t}\n\n\t/**\n\t * Remove the blob.\n\t * @param id The id of the blob to remove in urn format.\n\t * @returns True if the blob was found.\n\t */\n\tpublic async remove(id: string): Promise<boolean> {\n\t\tUrn.guard(IpfsBlobStorageConnector.CLASS_NAME, nameof(id), id);\n\t\tconst urnParsed = Urn.fromValidString(id);\n\n\t\tif (urnParsed.namespaceMethod() !== IpfsBlobStorageConnector.NAMESPACE) {\n\t\t\tthrow new GeneralError(IpfsBlobStorageConnector.CLASS_NAME, \"namespaceMismatch\", {\n\t\t\t\tnamespace: IpfsBlobStorageConnector.NAMESPACE,\n\t\t\t\tid\n\t\t\t});\n\t\t}\n\n\t\ttry {\n\t\t\tconst fetchOptions: RequestInit = {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: {\n\t\t\t\t\taccept: MimeTypes.Json\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tthis.addSecurity(fetchOptions);\n\n\t\t\tconst response = await fetch(\n\t\t\t\t`${this._config.apiUrl}/pin/rm?arg=${urnParsed.namespaceSpecific(1)}`,\n\t\t\t\tfetchOptions\n\t\t\t);\n\n\t\t\tif (response.ok) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tconst error = await response.json();\n\t\t\tthrow new GeneralError(IpfsBlobStorageConnector.CLASS_NAME, \"fetchFail\", error);\n\t\t} catch (err) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tIpfsBlobStorageConnector.CLASS_NAME,\n\t\t\t\t\"removeBlobFailed\",\n\t\t\t\tundefined,\n\t\t\t\terr\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Add the security to the request.\n\t * @param requestInit The request options.\n\t * @internal\n\t */\n\tprivate addSecurity(requestInit: RequestInit): void {\n\t\tif (Is.stringValue(this._config.bearerToken)) {\n\t\t\trequestInit.headers = {\n\t\t\t\t...requestInit.headers,\n\t\t\t\t[HeaderTypes.Authorization]: HeaderHelper.createBearer(this._config.bearerToken)\n\t\t\t};\n\t\t}\n\t}\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  import type { IBlobStorageConnector } from "@twin.org/blob-storage-models";
2
+ import { type IHealth } from "@twin.org/core";
2
3
  import type { IIpfsBlobStorageConnectorConstructorOptions } from "./models/IIpfsBlobStorageConnectorConstructorOptions.js";
3
4
  /**
4
5
  * Class for performing blob storage operations on IPFS.
@@ -23,6 +24,11 @@ export declare class IpfsBlobStorageConnector implements IBlobStorageConnector {
23
24
  * @returns The class name of the component.
24
25
  */
25
26
  className(): string;
27
+ /**
28
+ * Returns the health status of the component.
29
+ * @returns The health status of the component.
30
+ */
31
+ health(): Promise<IHealth[]>;
26
32
  /**
27
33
  * Set the blob.
28
34
  * @param blob The data for the blob.
package/docs/changelog.md CHANGED
@@ -1,6 +1,34 @@
1
- # @twin.org/blob-storage-connector-ipfs - Changelog
1
+ # Changelog
2
2
 
3
- ## [0.0.3-next.6](https://github.com/twinfoundation/blob-storage/compare/blob-storage-connector-ipfs-v0.0.3-next.5...blob-storage-connector-ipfs-v0.0.3-next.6) (2026-02-09)
3
+ ## [0.0.3-next.8](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-ipfs-v0.0.3-next.7...blob-storage-connector-ipfs-v0.0.3-next.8) (2026-05-07)
4
+
5
+
6
+ ### Features
7
+
8
+ * health checks ([#44](https://github.com/iotaledger/twin-blob-storage/issues/44)) ([4a4041c](https://github.com/iotaledger/twin-blob-storage/commit/4a4041c19b68c40ed1aba6d1cdb4318ac4208b7d))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/blob-storage-models bumped from 0.0.3-next.7 to 0.0.3-next.8
16
+
17
+ ## [0.0.3-next.7](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-ipfs-v0.0.3-next.6...blob-storage-connector-ipfs-v0.0.3-next.7) (2026-02-25)
18
+
19
+
20
+ ### Miscellaneous Chores
21
+
22
+ * **blob-storage-connector-ipfs:** Synchronize repo versions
23
+
24
+
25
+ ### Dependencies
26
+
27
+ * The following workspace dependencies were updated
28
+ * dependencies
29
+ * @twin.org/blob-storage-models bumped from 0.0.3-next.6 to 0.0.3-next.7
30
+
31
+ ## [0.0.3-next.6](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-ipfs-v0.0.3-next.5...blob-storage-connector-ipfs-v0.0.3-next.6) (2026-02-09)
4
32
 
5
33
 
6
34
  ### Miscellaneous Chores
@@ -14,7 +42,7 @@
14
42
  * dependencies
15
43
  * @twin.org/blob-storage-models bumped from 0.0.3-next.5 to 0.0.3-next.6
16
44
 
17
- ## [0.0.3-next.5](https://github.com/twinfoundation/blob-storage/compare/blob-storage-connector-ipfs-v0.0.3-next.4...blob-storage-connector-ipfs-v0.0.3-next.5) (2026-01-26)
45
+ ## [0.0.3-next.5](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-ipfs-v0.0.3-next.4...blob-storage-connector-ipfs-v0.0.3-next.5) (2026-01-26)
18
46
 
19
47
 
20
48
  ### Miscellaneous Chores
@@ -28,7 +56,7 @@
28
56
  * dependencies
29
57
  * @twin.org/blob-storage-models bumped from 0.0.3-next.4 to 0.0.3-next.5
30
58
 
31
- ## [0.0.3-next.4](https://github.com/twinfoundation/blob-storage/compare/blob-storage-connector-ipfs-v0.0.3-next.3...blob-storage-connector-ipfs-v0.0.3-next.4) (2026-01-23)
59
+ ## [0.0.3-next.4](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-ipfs-v0.0.3-next.3...blob-storage-connector-ipfs-v0.0.3-next.4) (2026-01-23)
32
60
 
33
61
 
34
62
  ### Miscellaneous Chores
@@ -42,7 +70,7 @@
42
70
  * dependencies
43
71
  * @twin.org/blob-storage-models bumped from 0.0.3-next.3 to 0.0.3-next.4
44
72
 
45
- ## [0.0.3-next.3](https://github.com/twinfoundation/blob-storage/compare/blob-storage-connector-ipfs-v0.0.3-next.2...blob-storage-connector-ipfs-v0.0.3-next.3) (2026-01-21)
73
+ ## [0.0.3-next.3](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-ipfs-v0.0.3-next.2...blob-storage-connector-ipfs-v0.0.3-next.3) (2026-01-21)
46
74
 
47
75
 
48
76
  ### Miscellaneous Chores
@@ -56,13 +84,13 @@
56
84
  * dependencies
57
85
  * @twin.org/blob-storage-models bumped from 0.0.3-next.2 to 0.0.3-next.3
58
86
 
59
- ## [0.0.3-next.2](https://github.com/twinfoundation/blob-storage/compare/blob-storage-connector-ipfs-v0.0.3-next.1...blob-storage-connector-ipfs-v0.0.3-next.2) (2026-01-14)
87
+ ## [0.0.3-next.2](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-ipfs-v0.0.3-next.1...blob-storage-connector-ipfs-v0.0.3-next.2) (2026-01-14)
60
88
 
61
89
 
62
90
  ### Bug Fixes
63
91
 
64
- * missing dependency ([868717b](https://github.com/twinfoundation/blob-storage/commit/868717b9d352af916c32df4d4f942d3bd8769c95))
65
- * missing dependency ([9b7ec26](https://github.com/twinfoundation/blob-storage/commit/9b7ec2694468e75b4d3357b623e5031def82c920))
92
+ * missing dependency ([868717b](https://github.com/iotaledger/twin-blob-storage/commit/868717b9d352af916c32df4d4f942d3bd8769c95))
93
+ * missing dependency ([9b7ec26](https://github.com/iotaledger/twin-blob-storage/commit/9b7ec2694468e75b4d3357b623e5031def82c920))
66
94
 
67
95
 
68
96
  ### Dependencies
@@ -71,19 +99,19 @@
71
99
  * dependencies
72
100
  * @twin.org/blob-storage-models bumped from 0.0.3-next.1 to 0.0.3-next.2
73
101
 
74
- ## [0.0.3-next.1](https://github.com/twinfoundation/blob-storage/compare/blob-storage-connector-ipfs-v0.0.3-next.0...blob-storage-connector-ipfs-v0.0.3-next.1) (2025-11-11)
102
+ ## [0.0.3-next.1](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-ipfs-v0.0.3-next.0...blob-storage-connector-ipfs-v0.0.3-next.1) (2025-11-11)
75
103
 
76
104
 
77
105
  ### Features
78
106
 
79
- * add context id features ([#30](https://github.com/twinfoundation/blob-storage/issues/30)) ([fbf1c92](https://github.com/twinfoundation/blob-storage/commit/fbf1c9276424c841ef5ef3f4de8469ab3fba7e9c))
80
- * add validate-locales ([f20fcec](https://github.com/twinfoundation/blob-storage/commit/f20fceced91e39a0c9edb770b2e43ce944c92f3c))
81
- * eslint migration to flat config ([e4239dd](https://github.com/twinfoundation/blob-storage/commit/e4239dd1c721955cff7f0357255d2bba15319972))
82
- * update dependencies ([56f0094](https://github.com/twinfoundation/blob-storage/commit/56f0094b68d8bd22864cd899ac1b61d95540f719))
83
- * update framework core ([ff339fe](https://github.com/twinfoundation/blob-storage/commit/ff339fe7e3f09ddff429907834bdf43617e9c05e))
84
- * use new createBearer method ([f87c550](https://github.com/twinfoundation/blob-storage/commit/f87c5502fe3b5fee81257d7500f5d4500ea5ed28))
85
- * use new createBearer method ([a965801](https://github.com/twinfoundation/blob-storage/commit/a96580160315c363fc0f06a1615cc92d4339a5e4))
86
- * use shared store mechanism ([#12](https://github.com/twinfoundation/blob-storage/issues/12)) ([cae8110](https://github.com/twinfoundation/blob-storage/commit/cae8110681847a1ac4fcac968b8196694e49c320))
107
+ * add context id features ([#30](https://github.com/iotaledger/twin-blob-storage/issues/30)) ([fbf1c92](https://github.com/iotaledger/twin-blob-storage/commit/fbf1c9276424c841ef5ef3f4de8469ab3fba7e9c))
108
+ * add validate-locales ([f20fcec](https://github.com/iotaledger/twin-blob-storage/commit/f20fceced91e39a0c9edb770b2e43ce944c92f3c))
109
+ * eslint migration to flat config ([e4239dd](https://github.com/iotaledger/twin-blob-storage/commit/e4239dd1c721955cff7f0357255d2bba15319972))
110
+ * update dependencies ([56f0094](https://github.com/iotaledger/twin-blob-storage/commit/56f0094b68d8bd22864cd899ac1b61d95540f719))
111
+ * update framework core ([ff339fe](https://github.com/iotaledger/twin-blob-storage/commit/ff339fe7e3f09ddff429907834bdf43617e9c05e))
112
+ * use new createBearer method ([f87c550](https://github.com/iotaledger/twin-blob-storage/commit/f87c5502fe3b5fee81257d7500f5d4500ea5ed28))
113
+ * use new createBearer method ([a965801](https://github.com/iotaledger/twin-blob-storage/commit/a96580160315c363fc0f06a1615cc92d4339a5e4))
114
+ * use shared store mechanism ([#12](https://github.com/iotaledger/twin-blob-storage/issues/12)) ([cae8110](https://github.com/iotaledger/twin-blob-storage/commit/cae8110681847a1ac4fcac968b8196694e49c320))
87
115
 
88
116
 
89
117
  ### Dependencies
@@ -92,12 +120,12 @@
92
120
  * dependencies
93
121
  * @twin.org/blob-storage-models bumped from 0.0.3-next.0 to 0.0.3-next.1
94
122
 
95
- ## [0.0.2-next.5](https://github.com/twinfoundation/blob-storage/compare/blob-storage-connector-ipfs-v0.0.2-next.4...blob-storage-connector-ipfs-v0.0.2-next.5) (2025-10-09)
123
+ ## [0.0.2-next.5](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-ipfs-v0.0.2-next.4...blob-storage-connector-ipfs-v0.0.2-next.5) (2025-10-09)
96
124
 
97
125
 
98
126
  ### Features
99
127
 
100
- * add validate-locales ([f20fcec](https://github.com/twinfoundation/blob-storage/commit/f20fceced91e39a0c9edb770b2e43ce944c92f3c))
128
+ * add validate-locales ([f20fcec](https://github.com/iotaledger/twin-blob-storage/commit/f20fceced91e39a0c9edb770b2e43ce944c92f3c))
101
129
 
102
130
 
103
131
  ### Dependencies
@@ -106,13 +134,13 @@
106
134
  * dependencies
107
135
  * @twin.org/blob-storage-models bumped from 0.0.2-next.4 to 0.0.2-next.5
108
136
 
109
- ## [0.0.2-next.4](https://github.com/twinfoundation/blob-storage/compare/blob-storage-connector-ipfs-v0.0.2-next.3...blob-storage-connector-ipfs-v0.0.2-next.4) (2025-10-02)
137
+ ## [0.0.2-next.4](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-ipfs-v0.0.2-next.3...blob-storage-connector-ipfs-v0.0.2-next.4) (2025-10-02)
110
138
 
111
139
 
112
140
  ### Features
113
141
 
114
- * use new createBearer method ([f87c550](https://github.com/twinfoundation/blob-storage/commit/f87c5502fe3b5fee81257d7500f5d4500ea5ed28))
115
- * use new createBearer method ([a965801](https://github.com/twinfoundation/blob-storage/commit/a96580160315c363fc0f06a1615cc92d4339a5e4))
142
+ * use new createBearer method ([f87c550](https://github.com/iotaledger/twin-blob-storage/commit/f87c5502fe3b5fee81257d7500f5d4500ea5ed28))
143
+ * use new createBearer method ([a965801](https://github.com/iotaledger/twin-blob-storage/commit/a96580160315c363fc0f06a1615cc92d4339a5e4))
116
144
 
117
145
 
118
146
  ### Dependencies
@@ -121,12 +149,12 @@
121
149
  * dependencies
122
150
  * @twin.org/blob-storage-models bumped from 0.0.2-next.3 to 0.0.2-next.4
123
151
 
124
- ## [0.0.2-next.3](https://github.com/twinfoundation/blob-storage/compare/blob-storage-connector-ipfs-v0.0.2-next.2...blob-storage-connector-ipfs-v0.0.2-next.3) (2025-08-29)
152
+ ## [0.0.2-next.3](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-ipfs-v0.0.2-next.2...blob-storage-connector-ipfs-v0.0.2-next.3) (2025-08-29)
125
153
 
126
154
 
127
155
  ### Features
128
156
 
129
- * eslint migration to flat config ([e4239dd](https://github.com/twinfoundation/blob-storage/commit/e4239dd1c721955cff7f0357255d2bba15319972))
157
+ * eslint migration to flat config ([e4239dd](https://github.com/iotaledger/twin-blob-storage/commit/e4239dd1c721955cff7f0357255d2bba15319972))
130
158
 
131
159
 
132
160
  ### Dependencies
@@ -135,12 +163,12 @@
135
163
  * dependencies
136
164
  * @twin.org/blob-storage-models bumped from 0.0.2-next.2 to 0.0.2-next.3
137
165
 
138
- ## [0.0.2-next.2](https://github.com/twinfoundation/blob-storage/compare/blob-storage-connector-ipfs-v0.0.2-next.1...blob-storage-connector-ipfs-v0.0.2-next.2) (2025-08-20)
166
+ ## [0.0.2-next.2](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-ipfs-v0.0.2-next.1...blob-storage-connector-ipfs-v0.0.2-next.2) (2025-08-20)
139
167
 
140
168
 
141
169
  ### Features
142
170
 
143
- * update framework core ([ff339fe](https://github.com/twinfoundation/blob-storage/commit/ff339fe7e3f09ddff429907834bdf43617e9c05e))
171
+ * update framework core ([ff339fe](https://github.com/iotaledger/twin-blob-storage/commit/ff339fe7e3f09ddff429907834bdf43617e9c05e))
144
172
 
145
173
 
146
174
  ### Dependencies
@@ -149,13 +177,13 @@
149
177
  * dependencies
150
178
  * @twin.org/blob-storage-models bumped from 0.0.2-next.1 to 0.0.2-next.2
151
179
 
152
- ## [0.0.2-next.1](https://github.com/twinfoundation/blob-storage/compare/blob-storage-connector-ipfs-v0.0.2-next.0...blob-storage-connector-ipfs-v0.0.2-next.1) (2025-07-24)
180
+ ## [0.0.2-next.1](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-ipfs-v0.0.2-next.0...blob-storage-connector-ipfs-v0.0.2-next.1) (2025-07-24)
153
181
 
154
182
 
155
183
  ### Features
156
184
 
157
- * update dependencies ([56f0094](https://github.com/twinfoundation/blob-storage/commit/56f0094b68d8bd22864cd899ac1b61d95540f719))
158
- * use shared store mechanism ([#12](https://github.com/twinfoundation/blob-storage/issues/12)) ([cae8110](https://github.com/twinfoundation/blob-storage/commit/cae8110681847a1ac4fcac968b8196694e49c320))
185
+ * update dependencies ([56f0094](https://github.com/iotaledger/twin-blob-storage/commit/56f0094b68d8bd22864cd899ac1b61d95540f719))
186
+ * use shared store mechanism ([#12](https://github.com/iotaledger/twin-blob-storage/issues/12)) ([cae8110](https://github.com/iotaledger/twin-blob-storage/commit/cae8110681847a1ac4fcac968b8196694e49c320))
159
187
 
160
188
 
161
189
  ### Dependencies
@@ -169,7 +197,7 @@
169
197
 
170
198
  ### Features
171
199
 
172
- * release to production ([eacfe75](https://github.com/twinfoundation/blob-storage/commit/eacfe754a0dcd9243d9e13d86422327d0a605164))
200
+ * release to production ([eacfe75](https://github.com/iotaledger/twin-blob-storage/commit/eacfe754a0dcd9243d9e13d86422327d0a605164))
173
201
 
174
202
 
175
203
  ### Dependencies
@@ -178,7 +206,7 @@
178
206
  * dependencies
179
207
  * @twin.org/blob-storage-models bumped from ^0.0.0 to ^0.0.1
180
208
 
181
- ## [0.0.1-next.37](https://github.com/twinfoundation/blob-storage/compare/blob-storage-connector-ipfs-v0.0.1-next.36...blob-storage-connector-ipfs-v0.0.1-next.37) (2025-06-20)
209
+ ## [0.0.1-next.37](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-ipfs-v0.0.1-next.36...blob-storage-connector-ipfs-v0.0.1-next.37) (2025-06-20)
182
210
 
183
211
 
184
212
  ### Miscellaneous Chores
@@ -192,7 +220,7 @@
192
220
  * dependencies
193
221
  * @twin.org/blob-storage-models bumped from 0.0.1-next.36 to 0.0.1-next.37
194
222
 
195
- ## [0.0.1-next.36](https://github.com/twinfoundation/blob-storage/compare/blob-storage-connector-ipfs-v0.0.1-next.35...blob-storage-connector-ipfs-v0.0.1-next.36) (2025-06-19)
223
+ ## [0.0.1-next.36](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-ipfs-v0.0.1-next.35...blob-storage-connector-ipfs-v0.0.1-next.36) (2025-06-19)
196
224
 
197
225
 
198
226
  ### Miscellaneous Chores
@@ -206,7 +234,7 @@
206
234
  * dependencies
207
235
  * @twin.org/blob-storage-models bumped from 0.0.1-next.35 to 0.0.1-next.36
208
236
 
209
- ## [0.0.1-next.35](https://github.com/twinfoundation/blob-storage/compare/blob-storage-connector-ipfs-v0.0.1-next.34...blob-storage-connector-ipfs-v0.0.1-next.35) (2025-06-17)
237
+ ## [0.0.1-next.35](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-ipfs-v0.0.1-next.34...blob-storage-connector-ipfs-v0.0.1-next.35) (2025-06-17)
210
238
 
211
239
 
212
240
  ### Miscellaneous Chores
@@ -220,12 +248,12 @@
220
248
  * dependencies
221
249
  * @twin.org/blob-storage-models bumped from 0.0.1-next.34 to 0.0.1-next.35
222
250
 
223
- ## [0.0.1-next.34](https://github.com/twinfoundation/blob-storage/compare/blob-storage-connector-ipfs-v0.0.1-next.33...blob-storage-connector-ipfs-v0.0.1-next.34) (2025-06-12)
251
+ ## [0.0.1-next.34](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-ipfs-v0.0.1-next.33...blob-storage-connector-ipfs-v0.0.1-next.34) (2025-06-12)
224
252
 
225
253
 
226
254
  ### Features
227
255
 
228
- * update dependencies ([56f0094](https://github.com/twinfoundation/blob-storage/commit/56f0094b68d8bd22864cd899ac1b61d95540f719))
256
+ * update dependencies ([56f0094](https://github.com/iotaledger/twin-blob-storage/commit/56f0094b68d8bd22864cd899ac1b61d95540f719))
229
257
 
230
258
 
231
259
  ### Dependencies
@@ -234,7 +262,7 @@
234
262
  * dependencies
235
263
  * @twin.org/blob-storage-models bumped from 0.0.1-next.33 to 0.0.1-next.34
236
264
 
237
- ## [0.0.1-next.33](https://github.com/twinfoundation/blob-storage/compare/blob-storage-connector-ipfs-v0.0.1-next.32...blob-storage-connector-ipfs-v0.0.1-next.33) (2025-06-03)
265
+ ## [0.0.1-next.33](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-ipfs-v0.0.1-next.32...blob-storage-connector-ipfs-v0.0.1-next.33) (2025-06-03)
238
266
 
239
267
 
240
268
  ### Miscellaneous Chores
@@ -248,7 +276,7 @@
248
276
  * dependencies
249
277
  * @twin.org/blob-storage-models bumped from 0.0.1-next.32 to 0.0.1-next.33
250
278
 
251
- ## [0.0.1-next.32](https://github.com/twinfoundation/blob-storage/compare/blob-storage-connector-ipfs-v0.0.1-next.31...blob-storage-connector-ipfs-v0.0.1-next.32) (2025-05-28)
279
+ ## [0.0.1-next.32](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-ipfs-v0.0.1-next.31...blob-storage-connector-ipfs-v0.0.1-next.32) (2025-05-28)
252
280
 
253
281
 
254
282
  ### Miscellaneous Chores
@@ -262,7 +290,7 @@
262
290
  * dependencies
263
291
  * @twin.org/blob-storage-models bumped from 0.0.1-next.31 to 0.0.1-next.32
264
292
 
265
- ## [0.0.1-next.31](https://github.com/twinfoundation/blob-storage/compare/blob-storage-connector-ipfs-v0.0.1-next.30...blob-storage-connector-ipfs-v0.0.1-next.31) (2025-05-08)
293
+ ## [0.0.1-next.31](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-ipfs-v0.0.1-next.30...blob-storage-connector-ipfs-v0.0.1-next.31) (2025-05-08)
266
294
 
267
295
 
268
296
  ### Miscellaneous Chores
@@ -276,12 +304,12 @@
276
304
  * dependencies
277
305
  * @twin.org/blob-storage-models bumped from 0.0.1-next.30 to 0.0.1-next.31
278
306
 
279
- ## [0.0.1-next.30](https://github.com/twinfoundation/blob-storage/compare/blob-storage-connector-ipfs-v0.0.1-next.29...blob-storage-connector-ipfs-v0.0.1-next.30) (2025-04-17)
307
+ ## [0.0.1-next.30](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-ipfs-v0.0.1-next.29...blob-storage-connector-ipfs-v0.0.1-next.30) (2025-04-17)
280
308
 
281
309
 
282
310
  ### Features
283
311
 
284
- * use shared store mechanism ([#12](https://github.com/twinfoundation/blob-storage/issues/12)) ([cae8110](https://github.com/twinfoundation/blob-storage/commit/cae8110681847a1ac4fcac968b8196694e49c320))
312
+ * use shared store mechanism ([#12](https://github.com/iotaledger/twin-blob-storage/issues/12)) ([cae8110](https://github.com/iotaledger/twin-blob-storage/commit/cae8110681847a1ac4fcac968b8196694e49c320))
285
313
 
286
314
 
287
315
  ### Dependencies
@@ -290,7 +318,7 @@
290
318
  * dependencies
291
319
  * @twin.org/blob-storage-models bumped from 0.0.1-next.29 to 0.0.1-next.30
292
320
 
293
- ## [0.0.1-next.29](https://github.com/twinfoundation/blob-storage/compare/blob-storage-connector-ipfs-v0.0.1-next.28...blob-storage-connector-ipfs-v0.0.1-next.29) (2025-03-28)
321
+ ## [0.0.1-next.29](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-ipfs-v0.0.1-next.28...blob-storage-connector-ipfs-v0.0.1-next.29) (2025-03-28)
294
322
 
295
323
 
296
324
  ### Miscellaneous Chores
package/docs/examples.md CHANGED
@@ -1 +1,39 @@
1
- # @twin.org/blob-storage-connector-ipfs - Examples
1
+ # IPFS Connector Examples
2
+
3
+ Use these snippets to pin content, read it back by identifier, and remove it when it is no longer required.
4
+
5
+ ## IpfsBlobStorageConnector
6
+
7
+ ```typescript
8
+ import { IpfsBlobStorageConnector } from '@twin.org/blob-storage-connector-ipfs';
9
+
10
+ const connector = new IpfsBlobStorageConnector({
11
+ config: {
12
+ apiUrl: 'http://127.0.0.1:5001/api/v0',
13
+ bearerToken: 'dev-access-token'
14
+ }
15
+ });
16
+
17
+ console.log(connector.className()); // IpfsBlobStorageConnector
18
+ ```
19
+
20
+ ```typescript
21
+ import { Converter } from '@twin.org/core';
22
+ import { IpfsBlobStorageConnector } from '@twin.org/blob-storage-connector-ipfs';
23
+
24
+ const connector = new IpfsBlobStorageConnector({
25
+ config: {
26
+ apiUrl: 'http://127.0.0.1:5001/api/v0'
27
+ }
28
+ });
29
+
30
+ const blobData = Converter.utf8ToBytes('IPFS payload');
31
+ const blobId = await connector.set(blobData);
32
+ console.log(blobId); // blob:urn:blob:ipfs:...
33
+
34
+ const storedBlob = await connector.get(blobId);
35
+ console.log(storedBlob?.length); // 12
36
+
37
+ const removed = await connector.remove(blobId);
38
+ console.log(removed); // true
39
+ ```
@@ -29,7 +29,7 @@ The options for the connector.
29
29
 
30
30
  ## Properties
31
31
 
32
- ### NAMESPACE
32
+ ### NAMESPACE {#namespace}
33
33
 
34
34
  > `readonly` `static` **NAMESPACE**: `string` = `"ipfs"`
35
35
 
@@ -37,7 +37,7 @@ The namespace for the items.
37
37
 
38
38
  ***
39
39
 
40
- ### CLASS\_NAME
40
+ ### CLASS\_NAME {#class_name}
41
41
 
42
42
  > `readonly` `static` **CLASS\_NAME**: `string`
43
43
 
@@ -45,7 +45,7 @@ Runtime name for the class.
45
45
 
46
46
  ## Methods
47
47
 
48
- ### className()
48
+ ### className() {#classname}
49
49
 
50
50
  > **className**(): `string`
51
51
 
@@ -63,7 +63,25 @@ The class name of the component.
63
63
 
64
64
  ***
65
65
 
66
- ### set()
66
+ ### health() {#health}
67
+
68
+ > **health**(): `Promise`\<`IHealth`[]\>
69
+
70
+ Returns the health status of the component.
71
+
72
+ #### Returns
73
+
74
+ `Promise`\<`IHealth`[]\>
75
+
76
+ The health status of the component.
77
+
78
+ #### Implementation of
79
+
80
+ `IBlobStorageConnector.health`
81
+
82
+ ***
83
+
84
+ ### set() {#set}
67
85
 
68
86
  > **set**(`blob`): `Promise`\<`string`\>
69
87
 
@@ -89,7 +107,7 @@ The id of the stored blob in urn format.
89
107
 
90
108
  ***
91
109
 
92
- ### get()
110
+ ### get() {#get}
93
111
 
94
112
  > **get**(`id`): `Promise`\<`Uint8Array`\<`ArrayBufferLike`\> \| `undefined`\>
95
113
 
@@ -115,7 +133,7 @@ The data for the blob if it can be found or undefined.
115
133
 
116
134
  ***
117
135
 
118
- ### remove()
136
+ ### remove() {#remove}
119
137
 
120
138
  > **remove**(`id`): `Promise`\<`boolean`\>
121
139
 
@@ -4,7 +4,7 @@ Configuration for the IPFS Blob Storage Connector.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### apiUrl
7
+ ### apiUrl {#apiurl}
8
8
 
9
9
  > **apiUrl**: `string`
10
10
 
@@ -12,8 +12,8 @@ The url for API calls.
12
12
 
13
13
  ***
14
14
 
15
- ### bearerToken?
15
+ ### bearerToken? {#bearertoken}
16
16
 
17
- > `optional` **bearerToken**: `string`
17
+ > `optional` **bearerToken?**: `string`
18
18
 
19
19
  The bearer token for authentication to the API.
@@ -4,15 +4,15 @@ Options for the IPFS Blob Storage Connector constructor.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### partitionContextIds?
7
+ ### partitionContextIds? {#partitioncontextids}
8
8
 
9
- > `optional` **partitionContextIds**: `string`[]
9
+ > `optional` **partitionContextIds?**: `string`[]
10
10
 
11
11
  The keys to use from the context ids to create partitions.
12
12
 
13
13
  ***
14
14
 
15
- ### config
15
+ ### config {#config}
16
16
 
17
17
  > **config**: [`IIpfsBlobStorageConnectorConfig`](IIpfsBlobStorageConnectorConfig.md)
18
18
 
package/locales/en.json CHANGED
@@ -1,4 +1,10 @@
1
1
  {
2
+ "health": {
3
+ "ipfsBlobStorageConnector": {
4
+ "healthDescription": "IPFS blob storage connector is healthy",
5
+ "healthCheckFailed": "Failed to connect to IPFS node"
6
+ }
7
+ },
2
8
  "error": {
3
9
  "ipfsBlobStorageConnector": {
4
10
  "namespaceMismatch": "The namespace in the urn \"{id}\" does not match the namespace of the blob storage \"{namespace}\"",
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@twin.org/blob-storage-connector-ipfs",
3
- "version": "0.0.3-next.6",
4
- "description": "Blob Storage connector implementation using IPFS",
3
+ "version": "0.0.3-next.8",
4
+ "description": "Stores and retrieves blobs through IPFS for content-addressed and distributed workflows.",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "git+https://github.com/twinfoundation/blob-storage.git",
7
+ "url": "git+https://github.com/iotaledger/blob-storage.git",
8
8
  "directory": "packages/blob-storage-connector-ipfs"
9
9
  },
10
10
  "author": "martyn.janes@iota.org",
@@ -14,7 +14,7 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/blob-storage-models": "0.0.3-next.6",
17
+ "@twin.org/blob-storage-models": "0.0.3-next.8",
18
18
  "@twin.org/core": "next",
19
19
  "@twin.org/crypto": "next",
20
20
  "@twin.org/nameof": "next",
@@ -52,7 +52,7 @@
52
52
  "integration"
53
53
  ],
54
54
  "bugs": {
55
- "url": "git+https://github.com/twinfoundation/blob-storage/issues"
55
+ "url": "git+https://github.com/iotaledger/blob-storage/issues"
56
56
  },
57
57
  "homepage": "https://twindev.org"
58
58
  }