@twin.org/blob-storage-connector-ipfs 0.0.3-next.7 → 0.0.3-next.9

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,5 +1,5 @@
1
- import { GeneralError, Guards, Is, StringHelper, Urn } from "@twin.org/core";
2
- import { HeaderHelper, HeaderTypes, MimeTypes } from "@twin.org/web";
1
+ import { GeneralError, Guards, HealthStatus, Is, StringHelper, Urn } from "@twin.org/core";
2
+ import { HeaderHelper, HeaderTypes, HttpMethod, MimeTypes } from "@twin.org/web";
3
3
  /**
4
4
  * Class for performing blob storage operations on IPFS.
5
5
  * See https://docs.ipfs.tech/reference/kubo/rpc/ for more information.
@@ -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: HttpMethod.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.
@@ -54,7 +88,7 @@ export class IpfsBlobStorageConnector {
54
88
  const formData = new FormData();
55
89
  formData.append("file", formBlob);
56
90
  const fetchOptions = {
57
- method: "POST",
91
+ method: HttpMethod.POST,
58
92
  body: formData,
59
93
  headers: {
60
94
  [HeaderTypes.Accept]: MimeTypes.Json,
@@ -90,7 +124,7 @@ export class IpfsBlobStorageConnector {
90
124
  }
91
125
  try {
92
126
  const fetchOptions = {
93
- method: "POST",
127
+ method: HttpMethod.POST,
94
128
  headers: {
95
129
  accept: MimeTypes.Json
96
130
  }
@@ -133,7 +167,7 @@ export class IpfsBlobStorageConnector {
133
167
  }
134
168
  try {
135
169
  const fetchOptions = {
136
- method: "POST",
170
+ method: HttpMethod.POST,
137
171
  headers: {
138
172
  accept: MimeTypes.Json
139
173
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ipfsBlobStorageConnector.js","sourceRoot":"","sources":["../../src/ipfsBlobStorageConnector.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,EAA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,MAAM,IAAI,YAAY,CAAC,wBAAwB,CAAC,UAAU,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;QACjF,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,MAAM,IAAI,YAAY,CACrB,wBAAwB,CAAC,UAAU,EACnC,kBAAkB,EAClB,SAAS,EACT,GAAG,CACH,CAAC;QACH,CAAC;IACF,CAAC;IAED;;;;OAIG;IACK,WAAW,CAAC,WAAwB;QAC3C,IAAI,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;YAC9C,WAAW,CAAC,OAAO,GAAG;gBACrB,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 { 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/ipfsBlobStorageConnector.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,EAAE,EACF,YAAY,EACZ,GAAG,EAEH,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAIjF;;;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,MAA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CAC3B,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,eAAe,SAAS,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,EACrE,YAAY,CACZ,CAAC;YAEF,IAAI,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,OAAO,IAAI,CAAC;YACb,CAAC;YAED,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACpC,MAAM,IAAI,YAAY,CAAC,wBAAwB,CAAC,UAAU,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;QACjF,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,MAAM,IAAI,YAAY,CACrB,wBAAwB,CAAC,UAAU,EACnC,kBAAkB,EAClB,SAAS,EACT,GAAG,CACH,CAAC;QACH,CAAC;IACF,CAAC;IAED;;;;OAIG;IACK,WAAW,CAAC,WAAwB;QAC3C,IAAI,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;YAC9C,WAAW,CAAC,OAAO,GAAG;gBACrB,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, HttpMethod, 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: HttpMethod.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: HttpMethod.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: HttpMethod.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: HttpMethod.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,49 @@
1
- # @twin.org/blob-storage-connector-ipfs - Changelog
1
+ # Changelog
2
2
 
3
- ## [0.0.3-next.7](https://github.com/twinfoundation/blob-storage/compare/blob-storage-connector-ipfs-v0.0.3-next.6...blob-storage-connector-ipfs-v0.0.3-next.7) (2026-02-25)
3
+ ## [0.0.3-next.9](https://github.com/iotaledger/twin-blob-storage/compare/blob-storage-connector-ipfs-v0.0.3-next.8...blob-storage-connector-ipfs-v0.0.3-next.9) (2026-05-07)
4
+
5
+
6
+ ### Features
7
+
8
+ * add context id features ([#30](https://github.com/iotaledger/twin-blob-storage/issues/30)) ([fbf1c92](https://github.com/iotaledger/twin-blob-storage/commit/fbf1c9276424c841ef5ef3f4de8469ab3fba7e9c))
9
+ * add validate-locales ([f20fcec](https://github.com/iotaledger/twin-blob-storage/commit/f20fceced91e39a0c9edb770b2e43ce944c92f3c))
10
+ * eslint migration to flat config ([e4239dd](https://github.com/iotaledger/twin-blob-storage/commit/e4239dd1c721955cff7f0357255d2bba15319972))
11
+ * health checks ([#44](https://github.com/iotaledger/twin-blob-storage/issues/44)) ([4a4041c](https://github.com/iotaledger/twin-blob-storage/commit/4a4041c19b68c40ed1aba6d1cdb4318ac4208b7d))
12
+ * update dependencies ([56f0094](https://github.com/iotaledger/twin-blob-storage/commit/56f0094b68d8bd22864cd899ac1b61d95540f719))
13
+ * update framework core ([ff339fe](https://github.com/iotaledger/twin-blob-storage/commit/ff339fe7e3f09ddff429907834bdf43617e9c05e))
14
+ * update health fetch ([6c86b51](https://github.com/iotaledger/twin-blob-storage/commit/6c86b51c2a034f680ccf290514dcb47e2ef91057))
15
+ * use new createBearer method ([f87c550](https://github.com/iotaledger/twin-blob-storage/commit/f87c5502fe3b5fee81257d7500f5d4500ea5ed28))
16
+ * use new createBearer method ([a965801](https://github.com/iotaledger/twin-blob-storage/commit/a96580160315c363fc0f06a1615cc92d4339a5e4))
17
+ * use shared store mechanism ([#12](https://github.com/iotaledger/twin-blob-storage/issues/12)) ([cae8110](https://github.com/iotaledger/twin-blob-storage/commit/cae8110681847a1ac4fcac968b8196694e49c320))
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * missing dependency ([868717b](https://github.com/iotaledger/twin-blob-storage/commit/868717b9d352af916c32df4d4f942d3bd8769c95))
23
+ * missing dependency ([9b7ec26](https://github.com/iotaledger/twin-blob-storage/commit/9b7ec2694468e75b4d3357b623e5031def82c920))
24
+
25
+
26
+ ### Dependencies
27
+
28
+ * The following workspace dependencies were updated
29
+ * dependencies
30
+ * @twin.org/blob-storage-models bumped from 0.0.3-next.8 to 0.0.3-next.9
31
+
32
+ ## [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)
33
+
34
+
35
+ ### Features
36
+
37
+ * health checks ([#44](https://github.com/iotaledger/twin-blob-storage/issues/44)) ([4a4041c](https://github.com/iotaledger/twin-blob-storage/commit/4a4041c19b68c40ed1aba6d1cdb4318ac4208b7d))
38
+
39
+
40
+ ### Dependencies
41
+
42
+ * The following workspace dependencies were updated
43
+ * dependencies
44
+ * @twin.org/blob-storage-models bumped from 0.0.3-next.7 to 0.0.3-next.8
45
+
46
+ ## [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)
4
47
 
5
48
 
6
49
  ### Miscellaneous Chores
@@ -14,7 +57,7 @@
14
57
  * dependencies
15
58
  * @twin.org/blob-storage-models bumped from 0.0.3-next.6 to 0.0.3-next.7
16
59
 
17
- ## [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)
60
+ ## [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)
18
61
 
19
62
 
20
63
  ### Miscellaneous Chores
@@ -28,7 +71,7 @@
28
71
  * dependencies
29
72
  * @twin.org/blob-storage-models bumped from 0.0.3-next.5 to 0.0.3-next.6
30
73
 
31
- ## [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)
74
+ ## [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)
32
75
 
33
76
 
34
77
  ### Miscellaneous Chores
@@ -42,7 +85,7 @@
42
85
  * dependencies
43
86
  * @twin.org/blob-storage-models bumped from 0.0.3-next.4 to 0.0.3-next.5
44
87
 
45
- ## [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)
88
+ ## [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)
46
89
 
47
90
 
48
91
  ### Miscellaneous Chores
@@ -56,7 +99,7 @@
56
99
  * dependencies
57
100
  * @twin.org/blob-storage-models bumped from 0.0.3-next.3 to 0.0.3-next.4
58
101
 
59
- ## [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)
102
+ ## [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)
60
103
 
61
104
 
62
105
  ### Miscellaneous Chores
@@ -70,13 +113,13 @@
70
113
  * dependencies
71
114
  * @twin.org/blob-storage-models bumped from 0.0.3-next.2 to 0.0.3-next.3
72
115
 
73
- ## [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)
116
+ ## [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)
74
117
 
75
118
 
76
119
  ### Bug Fixes
77
120
 
78
- * missing dependency ([868717b](https://github.com/twinfoundation/blob-storage/commit/868717b9d352af916c32df4d4f942d3bd8769c95))
79
- * missing dependency ([9b7ec26](https://github.com/twinfoundation/blob-storage/commit/9b7ec2694468e75b4d3357b623e5031def82c920))
121
+ * missing dependency ([868717b](https://github.com/iotaledger/twin-blob-storage/commit/868717b9d352af916c32df4d4f942d3bd8769c95))
122
+ * missing dependency ([9b7ec26](https://github.com/iotaledger/twin-blob-storage/commit/9b7ec2694468e75b4d3357b623e5031def82c920))
80
123
 
81
124
 
82
125
  ### Dependencies
@@ -85,19 +128,19 @@
85
128
  * dependencies
86
129
  * @twin.org/blob-storage-models bumped from 0.0.3-next.1 to 0.0.3-next.2
87
130
 
88
- ## [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)
131
+ ## [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)
89
132
 
90
133
 
91
134
  ### Features
92
135
 
93
- * add context id features ([#30](https://github.com/twinfoundation/blob-storage/issues/30)) ([fbf1c92](https://github.com/twinfoundation/blob-storage/commit/fbf1c9276424c841ef5ef3f4de8469ab3fba7e9c))
94
- * add validate-locales ([f20fcec](https://github.com/twinfoundation/blob-storage/commit/f20fceced91e39a0c9edb770b2e43ce944c92f3c))
95
- * eslint migration to flat config ([e4239dd](https://github.com/twinfoundation/blob-storage/commit/e4239dd1c721955cff7f0357255d2bba15319972))
96
- * update dependencies ([56f0094](https://github.com/twinfoundation/blob-storage/commit/56f0094b68d8bd22864cd899ac1b61d95540f719))
97
- * update framework core ([ff339fe](https://github.com/twinfoundation/blob-storage/commit/ff339fe7e3f09ddff429907834bdf43617e9c05e))
98
- * use new createBearer method ([f87c550](https://github.com/twinfoundation/blob-storage/commit/f87c5502fe3b5fee81257d7500f5d4500ea5ed28))
99
- * use new createBearer method ([a965801](https://github.com/twinfoundation/blob-storage/commit/a96580160315c363fc0f06a1615cc92d4339a5e4))
100
- * use shared store mechanism ([#12](https://github.com/twinfoundation/blob-storage/issues/12)) ([cae8110](https://github.com/twinfoundation/blob-storage/commit/cae8110681847a1ac4fcac968b8196694e49c320))
136
+ * add context id features ([#30](https://github.com/iotaledger/twin-blob-storage/issues/30)) ([fbf1c92](https://github.com/iotaledger/twin-blob-storage/commit/fbf1c9276424c841ef5ef3f4de8469ab3fba7e9c))
137
+ * add validate-locales ([f20fcec](https://github.com/iotaledger/twin-blob-storage/commit/f20fceced91e39a0c9edb770b2e43ce944c92f3c))
138
+ * eslint migration to flat config ([e4239dd](https://github.com/iotaledger/twin-blob-storage/commit/e4239dd1c721955cff7f0357255d2bba15319972))
139
+ * update dependencies ([56f0094](https://github.com/iotaledger/twin-blob-storage/commit/56f0094b68d8bd22864cd899ac1b61d95540f719))
140
+ * update framework core ([ff339fe](https://github.com/iotaledger/twin-blob-storage/commit/ff339fe7e3f09ddff429907834bdf43617e9c05e))
141
+ * use new createBearer method ([f87c550](https://github.com/iotaledger/twin-blob-storage/commit/f87c5502fe3b5fee81257d7500f5d4500ea5ed28))
142
+ * use new createBearer method ([a965801](https://github.com/iotaledger/twin-blob-storage/commit/a96580160315c363fc0f06a1615cc92d4339a5e4))
143
+ * use shared store mechanism ([#12](https://github.com/iotaledger/twin-blob-storage/issues/12)) ([cae8110](https://github.com/iotaledger/twin-blob-storage/commit/cae8110681847a1ac4fcac968b8196694e49c320))
101
144
 
102
145
 
103
146
  ### Dependencies
@@ -106,12 +149,12 @@
106
149
  * dependencies
107
150
  * @twin.org/blob-storage-models bumped from 0.0.3-next.0 to 0.0.3-next.1
108
151
 
109
- ## [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)
152
+ ## [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)
110
153
 
111
154
 
112
155
  ### Features
113
156
 
114
- * add validate-locales ([f20fcec](https://github.com/twinfoundation/blob-storage/commit/f20fceced91e39a0c9edb770b2e43ce944c92f3c))
157
+ * add validate-locales ([f20fcec](https://github.com/iotaledger/twin-blob-storage/commit/f20fceced91e39a0c9edb770b2e43ce944c92f3c))
115
158
 
116
159
 
117
160
  ### Dependencies
@@ -120,13 +163,13 @@
120
163
  * dependencies
121
164
  * @twin.org/blob-storage-models bumped from 0.0.2-next.4 to 0.0.2-next.5
122
165
 
123
- ## [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)
166
+ ## [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)
124
167
 
125
168
 
126
169
  ### Features
127
170
 
128
- * use new createBearer method ([f87c550](https://github.com/twinfoundation/blob-storage/commit/f87c5502fe3b5fee81257d7500f5d4500ea5ed28))
129
- * use new createBearer method ([a965801](https://github.com/twinfoundation/blob-storage/commit/a96580160315c363fc0f06a1615cc92d4339a5e4))
171
+ * use new createBearer method ([f87c550](https://github.com/iotaledger/twin-blob-storage/commit/f87c5502fe3b5fee81257d7500f5d4500ea5ed28))
172
+ * use new createBearer method ([a965801](https://github.com/iotaledger/twin-blob-storage/commit/a96580160315c363fc0f06a1615cc92d4339a5e4))
130
173
 
131
174
 
132
175
  ### Dependencies
@@ -135,12 +178,12 @@
135
178
  * dependencies
136
179
  * @twin.org/blob-storage-models bumped from 0.0.2-next.3 to 0.0.2-next.4
137
180
 
138
- ## [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)
181
+ ## [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)
139
182
 
140
183
 
141
184
  ### Features
142
185
 
143
- * eslint migration to flat config ([e4239dd](https://github.com/twinfoundation/blob-storage/commit/e4239dd1c721955cff7f0357255d2bba15319972))
186
+ * eslint migration to flat config ([e4239dd](https://github.com/iotaledger/twin-blob-storage/commit/e4239dd1c721955cff7f0357255d2bba15319972))
144
187
 
145
188
 
146
189
  ### Dependencies
@@ -149,12 +192,12 @@
149
192
  * dependencies
150
193
  * @twin.org/blob-storage-models bumped from 0.0.2-next.2 to 0.0.2-next.3
151
194
 
152
- ## [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)
195
+ ## [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)
153
196
 
154
197
 
155
198
  ### Features
156
199
 
157
- * update framework core ([ff339fe](https://github.com/twinfoundation/blob-storage/commit/ff339fe7e3f09ddff429907834bdf43617e9c05e))
200
+ * update framework core ([ff339fe](https://github.com/iotaledger/twin-blob-storage/commit/ff339fe7e3f09ddff429907834bdf43617e9c05e))
158
201
 
159
202
 
160
203
  ### Dependencies
@@ -163,13 +206,13 @@
163
206
  * dependencies
164
207
  * @twin.org/blob-storage-models bumped from 0.0.2-next.1 to 0.0.2-next.2
165
208
 
166
- ## [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)
209
+ ## [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)
167
210
 
168
211
 
169
212
  ### Features
170
213
 
171
- * update dependencies ([56f0094](https://github.com/twinfoundation/blob-storage/commit/56f0094b68d8bd22864cd899ac1b61d95540f719))
172
- * use shared store mechanism ([#12](https://github.com/twinfoundation/blob-storage/issues/12)) ([cae8110](https://github.com/twinfoundation/blob-storage/commit/cae8110681847a1ac4fcac968b8196694e49c320))
214
+ * update dependencies ([56f0094](https://github.com/iotaledger/twin-blob-storage/commit/56f0094b68d8bd22864cd899ac1b61d95540f719))
215
+ * use shared store mechanism ([#12](https://github.com/iotaledger/twin-blob-storage/issues/12)) ([cae8110](https://github.com/iotaledger/twin-blob-storage/commit/cae8110681847a1ac4fcac968b8196694e49c320))
173
216
 
174
217
 
175
218
  ### Dependencies
@@ -183,7 +226,7 @@
183
226
 
184
227
  ### Features
185
228
 
186
- * release to production ([eacfe75](https://github.com/twinfoundation/blob-storage/commit/eacfe754a0dcd9243d9e13d86422327d0a605164))
229
+ * release to production ([eacfe75](https://github.com/iotaledger/twin-blob-storage/commit/eacfe754a0dcd9243d9e13d86422327d0a605164))
187
230
 
188
231
 
189
232
  ### Dependencies
@@ -192,7 +235,7 @@
192
235
  * dependencies
193
236
  * @twin.org/blob-storage-models bumped from ^0.0.0 to ^0.0.1
194
237
 
195
- ## [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)
238
+ ## [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)
196
239
 
197
240
 
198
241
  ### Miscellaneous Chores
@@ -206,7 +249,7 @@
206
249
  * dependencies
207
250
  * @twin.org/blob-storage-models bumped from 0.0.1-next.36 to 0.0.1-next.37
208
251
 
209
- ## [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)
252
+ ## [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)
210
253
 
211
254
 
212
255
  ### Miscellaneous Chores
@@ -220,7 +263,7 @@
220
263
  * dependencies
221
264
  * @twin.org/blob-storage-models bumped from 0.0.1-next.35 to 0.0.1-next.36
222
265
 
223
- ## [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)
266
+ ## [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)
224
267
 
225
268
 
226
269
  ### Miscellaneous Chores
@@ -234,12 +277,12 @@
234
277
  * dependencies
235
278
  * @twin.org/blob-storage-models bumped from 0.0.1-next.34 to 0.0.1-next.35
236
279
 
237
- ## [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)
280
+ ## [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)
238
281
 
239
282
 
240
283
  ### Features
241
284
 
242
- * update dependencies ([56f0094](https://github.com/twinfoundation/blob-storage/commit/56f0094b68d8bd22864cd899ac1b61d95540f719))
285
+ * update dependencies ([56f0094](https://github.com/iotaledger/twin-blob-storage/commit/56f0094b68d8bd22864cd899ac1b61d95540f719))
243
286
 
244
287
 
245
288
  ### Dependencies
@@ -248,7 +291,7 @@
248
291
  * dependencies
249
292
  * @twin.org/blob-storage-models bumped from 0.0.1-next.33 to 0.0.1-next.34
250
293
 
251
- ## [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)
294
+ ## [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)
252
295
 
253
296
 
254
297
  ### Miscellaneous Chores
@@ -262,7 +305,7 @@
262
305
  * dependencies
263
306
  * @twin.org/blob-storage-models bumped from 0.0.1-next.32 to 0.0.1-next.33
264
307
 
265
- ## [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)
308
+ ## [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)
266
309
 
267
310
 
268
311
  ### Miscellaneous Chores
@@ -276,7 +319,7 @@
276
319
  * dependencies
277
320
  * @twin.org/blob-storage-models bumped from 0.0.1-next.31 to 0.0.1-next.32
278
321
 
279
- ## [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)
322
+ ## [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)
280
323
 
281
324
 
282
325
  ### Miscellaneous Chores
@@ -290,12 +333,12 @@
290
333
  * dependencies
291
334
  * @twin.org/blob-storage-models bumped from 0.0.1-next.30 to 0.0.1-next.31
292
335
 
293
- ## [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)
336
+ ## [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)
294
337
 
295
338
 
296
339
  ### Features
297
340
 
298
- * use shared store mechanism ([#12](https://github.com/twinfoundation/blob-storage/issues/12)) ([cae8110](https://github.com/twinfoundation/blob-storage/commit/cae8110681847a1ac4fcac968b8196694e49c320))
341
+ * use shared store mechanism ([#12](https://github.com/iotaledger/twin-blob-storage/issues/12)) ([cae8110](https://github.com/iotaledger/twin-blob-storage/commit/cae8110681847a1ac4fcac968b8196694e49c320))
299
342
 
300
343
 
301
344
  ### Dependencies
@@ -304,7 +347,7 @@
304
347
  * dependencies
305
348
  * @twin.org/blob-storage-models bumped from 0.0.1-next.29 to 0.0.1-next.30
306
349
 
307
- ## [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)
350
+ ## [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)
308
351
 
309
352
 
310
353
  ### 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.7",
4
- "description": "Blob Storage connector implementation using IPFS",
3
+ "version": "0.0.3-next.9",
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.7",
17
+ "@twin.org/blob-storage-models": "0.0.3-next.9",
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
  }