@twin.org/blob-storage-connector-ipfs 0.0.2-next.3 → 0.0.2-next.5

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.
@@ -15,7 +15,7 @@ class IpfsBlobStorageConnector {
15
15
  /**
16
16
  * Runtime name for the class.
17
17
  */
18
- CLASS_NAME = "IpfsBlobStorageConnector";
18
+ static CLASS_NAME = "IpfsBlobStorageConnector";
19
19
  /**
20
20
  * The configuration for the connector.
21
21
  * @internal
@@ -26,9 +26,9 @@ class IpfsBlobStorageConnector {
26
26
  * @param options The options for the connector.
27
27
  */
28
28
  constructor(options) {
29
- core.Guards.object(this.CLASS_NAME, "options", options);
30
- core.Guards.object(this.CLASS_NAME, "options.config", options.config);
31
- core.Guards.stringValue(this.CLASS_NAME, "options.config.apiUrl", options.config.apiUrl);
29
+ core.Guards.object(IpfsBlobStorageConnector.CLASS_NAME, "options", options);
30
+ core.Guards.object(IpfsBlobStorageConnector.CLASS_NAME, "options.config", options.config);
31
+ core.Guards.stringValue(IpfsBlobStorageConnector.CLASS_NAME, "options.config.apiUrl", options.config.apiUrl);
32
32
  this._config = options.config;
33
33
  this._config.apiUrl = core.StringHelper.trimTrailingSlashes(this._config.apiUrl);
34
34
  }
@@ -38,7 +38,7 @@ class IpfsBlobStorageConnector {
38
38
  * @returns The id of the stored blob in urn format.
39
39
  */
40
40
  async set(blob) {
41
- core.Guards.uint8Array(this.CLASS_NAME, "blob", blob);
41
+ core.Guards.uint8Array(IpfsBlobStorageConnector.CLASS_NAME, "blob", blob);
42
42
  try {
43
43
  const formBlob = new Blob([new Uint8Array(blob)], { type: web.MimeTypes.OctetStream });
44
44
  const formData = new FormData();
@@ -58,10 +58,10 @@ class IpfsBlobStorageConnector {
58
58
  return `blob:${new core.Urn(IpfsBlobStorageConnector.NAMESPACE, result.Hash).toString()}`;
59
59
  }
60
60
  const error = await response.json();
61
- throw new core.GeneralError(this.CLASS_NAME, "fetchFail", error);
61
+ throw new core.GeneralError(IpfsBlobStorageConnector.CLASS_NAME, "fetchFail", error);
62
62
  }
63
63
  catch (err) {
64
- throw new core.GeneralError(this.CLASS_NAME, "setBlobFailed", undefined, err);
64
+ throw new core.GeneralError(IpfsBlobStorageConnector.CLASS_NAME, "setBlobFailed", undefined, err);
65
65
  }
66
66
  }
67
67
  /**
@@ -70,10 +70,10 @@ class IpfsBlobStorageConnector {
70
70
  * @returns The data for the blob if it can be found or undefined.
71
71
  */
72
72
  async get(id) {
73
- core.Urn.guard(this.CLASS_NAME, "id", id);
73
+ core.Urn.guard(IpfsBlobStorageConnector.CLASS_NAME, "id", id);
74
74
  const urnParsed = core.Urn.fromValidString(id);
75
75
  if (urnParsed.namespaceMethod() !== IpfsBlobStorageConnector.NAMESPACE) {
76
- throw new core.GeneralError(this.CLASS_NAME, "namespaceMismatch", {
76
+ throw new core.GeneralError(IpfsBlobStorageConnector.CLASS_NAME, "namespaceMismatch", {
77
77
  namespace: IpfsBlobStorageConnector.NAMESPACE,
78
78
  id
79
79
  });
@@ -92,10 +92,10 @@ class IpfsBlobStorageConnector {
92
92
  return new Uint8Array(result);
93
93
  }
94
94
  const error = await response.json();
95
- throw new core.GeneralError(this.CLASS_NAME, "fetchFail", error);
95
+ throw new core.GeneralError(IpfsBlobStorageConnector.CLASS_NAME, "fetchFail", error);
96
96
  }
97
97
  catch (err) {
98
- throw new core.GeneralError(this.CLASS_NAME, "getBlobFailed", undefined, err);
98
+ throw new core.GeneralError(IpfsBlobStorageConnector.CLASS_NAME, "getBlobFailed", undefined, err);
99
99
  }
100
100
  }
101
101
  /**
@@ -104,10 +104,10 @@ class IpfsBlobStorageConnector {
104
104
  * @returns True if the blob was found.
105
105
  */
106
106
  async remove(id) {
107
- core.Urn.guard(this.CLASS_NAME, "id", id);
107
+ core.Urn.guard(IpfsBlobStorageConnector.CLASS_NAME, "id", id);
108
108
  const urnParsed = core.Urn.fromValidString(id);
109
109
  if (urnParsed.namespaceMethod() !== IpfsBlobStorageConnector.NAMESPACE) {
110
- throw new core.GeneralError(this.CLASS_NAME, "namespaceMismatch", {
110
+ throw new core.GeneralError(IpfsBlobStorageConnector.CLASS_NAME, "namespaceMismatch", {
111
111
  namespace: IpfsBlobStorageConnector.NAMESPACE,
112
112
  id
113
113
  });
@@ -125,10 +125,10 @@ class IpfsBlobStorageConnector {
125
125
  return true;
126
126
  }
127
127
  const error = await response.json();
128
- throw new core.GeneralError(this.CLASS_NAME, "fetchFail", error);
128
+ throw new core.GeneralError(IpfsBlobStorageConnector.CLASS_NAME, "fetchFail", error);
129
129
  }
130
130
  catch (err) {
131
- throw new core.GeneralError(this.CLASS_NAME, "removeBlobFailed", undefined, err);
131
+ throw new core.GeneralError(IpfsBlobStorageConnector.CLASS_NAME, "removeBlobFailed", undefined, err);
132
132
  }
133
133
  }
134
134
  /**
@@ -140,7 +140,7 @@ class IpfsBlobStorageConnector {
140
140
  if (core.Is.stringValue(this._config.bearerToken)) {
141
141
  requestInit.headers = {
142
142
  ...requestInit.headers,
143
- Authorization: `Bearer ${this._config.bearerToken}`
143
+ [web.HeaderTypes.Authorization]: web.HeaderHelper.createBearer(this._config.bearerToken)
144
144
  };
145
145
  }
146
146
  }
@@ -1,5 +1,5 @@
1
1
  import { Guards, StringHelper, Urn, GeneralError, Is } from '@twin.org/core';
2
- import { MimeTypes, HeaderTypes } from '@twin.org/web';
2
+ import { MimeTypes, HeaderTypes, HeaderHelper } from '@twin.org/web';
3
3
 
4
4
  /**
5
5
  * Class for performing blob storage operations on IPFS.
@@ -13,7 +13,7 @@ class IpfsBlobStorageConnector {
13
13
  /**
14
14
  * Runtime name for the class.
15
15
  */
16
- CLASS_NAME = "IpfsBlobStorageConnector";
16
+ static CLASS_NAME = "IpfsBlobStorageConnector";
17
17
  /**
18
18
  * The configuration for the connector.
19
19
  * @internal
@@ -24,9 +24,9 @@ class IpfsBlobStorageConnector {
24
24
  * @param options The options for the connector.
25
25
  */
26
26
  constructor(options) {
27
- Guards.object(this.CLASS_NAME, "options", options);
28
- Guards.object(this.CLASS_NAME, "options.config", options.config);
29
- Guards.stringValue(this.CLASS_NAME, "options.config.apiUrl", options.config.apiUrl);
27
+ Guards.object(IpfsBlobStorageConnector.CLASS_NAME, "options", options);
28
+ Guards.object(IpfsBlobStorageConnector.CLASS_NAME, "options.config", options.config);
29
+ Guards.stringValue(IpfsBlobStorageConnector.CLASS_NAME, "options.config.apiUrl", options.config.apiUrl);
30
30
  this._config = options.config;
31
31
  this._config.apiUrl = StringHelper.trimTrailingSlashes(this._config.apiUrl);
32
32
  }
@@ -36,7 +36,7 @@ class IpfsBlobStorageConnector {
36
36
  * @returns The id of the stored blob in urn format.
37
37
  */
38
38
  async set(blob) {
39
- Guards.uint8Array(this.CLASS_NAME, "blob", blob);
39
+ Guards.uint8Array(IpfsBlobStorageConnector.CLASS_NAME, "blob", blob);
40
40
  try {
41
41
  const formBlob = new Blob([new Uint8Array(blob)], { type: MimeTypes.OctetStream });
42
42
  const formData = new FormData();
@@ -56,10 +56,10 @@ class IpfsBlobStorageConnector {
56
56
  return `blob:${new Urn(IpfsBlobStorageConnector.NAMESPACE, result.Hash).toString()}`;
57
57
  }
58
58
  const error = await response.json();
59
- throw new GeneralError(this.CLASS_NAME, "fetchFail", error);
59
+ throw new GeneralError(IpfsBlobStorageConnector.CLASS_NAME, "fetchFail", error);
60
60
  }
61
61
  catch (err) {
62
- throw new GeneralError(this.CLASS_NAME, "setBlobFailed", undefined, err);
62
+ throw new GeneralError(IpfsBlobStorageConnector.CLASS_NAME, "setBlobFailed", undefined, err);
63
63
  }
64
64
  }
65
65
  /**
@@ -68,10 +68,10 @@ class IpfsBlobStorageConnector {
68
68
  * @returns The data for the blob if it can be found or undefined.
69
69
  */
70
70
  async get(id) {
71
- Urn.guard(this.CLASS_NAME, "id", id);
71
+ Urn.guard(IpfsBlobStorageConnector.CLASS_NAME, "id", id);
72
72
  const urnParsed = Urn.fromValidString(id);
73
73
  if (urnParsed.namespaceMethod() !== IpfsBlobStorageConnector.NAMESPACE) {
74
- throw new GeneralError(this.CLASS_NAME, "namespaceMismatch", {
74
+ throw new GeneralError(IpfsBlobStorageConnector.CLASS_NAME, "namespaceMismatch", {
75
75
  namespace: IpfsBlobStorageConnector.NAMESPACE,
76
76
  id
77
77
  });
@@ -90,10 +90,10 @@ class IpfsBlobStorageConnector {
90
90
  return new Uint8Array(result);
91
91
  }
92
92
  const error = await response.json();
93
- throw new GeneralError(this.CLASS_NAME, "fetchFail", error);
93
+ throw new GeneralError(IpfsBlobStorageConnector.CLASS_NAME, "fetchFail", error);
94
94
  }
95
95
  catch (err) {
96
- throw new GeneralError(this.CLASS_NAME, "getBlobFailed", undefined, err);
96
+ throw new GeneralError(IpfsBlobStorageConnector.CLASS_NAME, "getBlobFailed", undefined, err);
97
97
  }
98
98
  }
99
99
  /**
@@ -102,10 +102,10 @@ class IpfsBlobStorageConnector {
102
102
  * @returns True if the blob was found.
103
103
  */
104
104
  async remove(id) {
105
- Urn.guard(this.CLASS_NAME, "id", id);
105
+ Urn.guard(IpfsBlobStorageConnector.CLASS_NAME, "id", id);
106
106
  const urnParsed = Urn.fromValidString(id);
107
107
  if (urnParsed.namespaceMethod() !== IpfsBlobStorageConnector.NAMESPACE) {
108
- throw new GeneralError(this.CLASS_NAME, "namespaceMismatch", {
108
+ throw new GeneralError(IpfsBlobStorageConnector.CLASS_NAME, "namespaceMismatch", {
109
109
  namespace: IpfsBlobStorageConnector.NAMESPACE,
110
110
  id
111
111
  });
@@ -123,10 +123,10 @@ class IpfsBlobStorageConnector {
123
123
  return true;
124
124
  }
125
125
  const error = await response.json();
126
- throw new GeneralError(this.CLASS_NAME, "fetchFail", error);
126
+ throw new GeneralError(IpfsBlobStorageConnector.CLASS_NAME, "fetchFail", error);
127
127
  }
128
128
  catch (err) {
129
- throw new GeneralError(this.CLASS_NAME, "removeBlobFailed", undefined, err);
129
+ throw new GeneralError(IpfsBlobStorageConnector.CLASS_NAME, "removeBlobFailed", undefined, err);
130
130
  }
131
131
  }
132
132
  /**
@@ -138,7 +138,7 @@ class IpfsBlobStorageConnector {
138
138
  if (Is.stringValue(this._config.bearerToken)) {
139
139
  requestInit.headers = {
140
140
  ...requestInit.headers,
141
- Authorization: `Bearer ${this._config.bearerToken}`
141
+ [HeaderTypes.Authorization]: HeaderHelper.createBearer(this._config.bearerToken)
142
142
  };
143
143
  }
144
144
  }
@@ -12,7 +12,7 @@ export declare class IpfsBlobStorageConnector implements IBlobStorageConnector {
12
12
  /**
13
13
  * Runtime name for the class.
14
14
  */
15
- readonly CLASS_NAME: string;
15
+ static readonly CLASS_NAME: string;
16
16
  /**
17
17
  * Create a new instance of IpfsBlobStorageConnector.
18
18
  * @param options The options for the connector.
package/docs/changelog.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # @twin.org/blob-storage-connector-ipfs - Changelog
2
2
 
3
+ ## [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)
4
+
5
+
6
+ ### Features
7
+
8
+ * add validate-locales ([f20fcec](https://github.com/twinfoundation/blob-storage/commit/f20fceced91e39a0c9edb770b2e43ce944c92f3c))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/blob-storage-models bumped from 0.0.2-next.4 to 0.0.2-next.5
16
+
17
+ ## [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)
18
+
19
+
20
+ ### Features
21
+
22
+ * use new createBearer method ([f87c550](https://github.com/twinfoundation/blob-storage/commit/f87c5502fe3b5fee81257d7500f5d4500ea5ed28))
23
+ * use new createBearer method ([a965801](https://github.com/twinfoundation/blob-storage/commit/a96580160315c363fc0f06a1615cc92d4339a5e4))
24
+
25
+
26
+ ### Dependencies
27
+
28
+ * The following workspace dependencies were updated
29
+ * dependencies
30
+ * @twin.org/blob-storage-models bumped from 0.0.2-next.3 to 0.0.2-next.4
31
+
3
32
  ## [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)
4
33
 
5
34
 
@@ -39,14 +39,10 @@ The namespace for the items.
39
39
 
40
40
  ### CLASS\_NAME
41
41
 
42
- > `readonly` **CLASS\_NAME**: `string`
42
+ > `readonly` `static` **CLASS\_NAME**: `string`
43
43
 
44
44
  Runtime name for the class.
45
45
 
46
- #### Implementation of
47
-
48
- `IBlobStorageConnector.CLASS_NAME`
49
-
50
46
  ## Methods
51
47
 
52
48
  ### set()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/blob-storage-connector-ipfs",
3
- "version": "0.0.2-next.3",
3
+ "version": "0.0.2-next.5",
4
4
  "description": "Blob Storage connector implementation using IPFS",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,7 +14,7 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/blob-storage-models": "0.0.2-next.3",
17
+ "@twin.org/blob-storage-models": "0.0.2-next.5",
18
18
  "@twin.org/core": "next",
19
19
  "@twin.org/crypto": "next",
20
20
  "@twin.org/nameof": "next",
@@ -37,5 +37,24 @@
37
37
  "dist/types",
38
38
  "locales",
39
39
  "docs"
40
- ]
40
+ ],
41
+ "keywords": [
42
+ "twin",
43
+ "trade",
44
+ "iota",
45
+ "framework",
46
+ "blockchain",
47
+ "blob-storage",
48
+ "blob",
49
+ "storage",
50
+ "files",
51
+ "binary",
52
+ "connector",
53
+ "adapter",
54
+ "integration"
55
+ ],
56
+ "bugs": {
57
+ "url": "git+https://github.com/twinfoundation/blob-storage/issues"
58
+ },
59
+ "homepage": "https://twindev.org"
41
60
  }