@twin.org/blob-storage-connector-ipfs 0.0.2-next.4 → 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.
package/dist/cjs/index.cjs
CHANGED
|
@@ -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(
|
|
30
|
-
core.Guards.object(
|
|
31
|
-
core.Guards.stringValue(
|
|
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(
|
|
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(
|
|
61
|
+
throw new core.GeneralError(IpfsBlobStorageConnector.CLASS_NAME, "fetchFail", error);
|
|
62
62
|
}
|
|
63
63
|
catch (err) {
|
|
64
|
-
throw new core.GeneralError(
|
|
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(
|
|
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(
|
|
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(
|
|
95
|
+
throw new core.GeneralError(IpfsBlobStorageConnector.CLASS_NAME, "fetchFail", error);
|
|
96
96
|
}
|
|
97
97
|
catch (err) {
|
|
98
|
-
throw new core.GeneralError(
|
|
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(
|
|
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(
|
|
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(
|
|
128
|
+
throw new core.GeneralError(IpfsBlobStorageConnector.CLASS_NAME, "fetchFail", error);
|
|
129
129
|
}
|
|
130
130
|
catch (err) {
|
|
131
|
-
throw new core.GeneralError(
|
|
131
|
+
throw new core.GeneralError(IpfsBlobStorageConnector.CLASS_NAME, "removeBlobFailed", undefined, err);
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
/**
|
package/dist/esm/index.mjs
CHANGED
|
@@ -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(
|
|
28
|
-
Guards.object(
|
|
29
|
-
Guards.stringValue(
|
|
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(
|
|
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(
|
|
59
|
+
throw new GeneralError(IpfsBlobStorageConnector.CLASS_NAME, "fetchFail", error);
|
|
60
60
|
}
|
|
61
61
|
catch (err) {
|
|
62
|
-
throw new GeneralError(
|
|
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(
|
|
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(
|
|
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(
|
|
93
|
+
throw new GeneralError(IpfsBlobStorageConnector.CLASS_NAME, "fetchFail", error);
|
|
94
94
|
}
|
|
95
95
|
catch (err) {
|
|
96
|
-
throw new GeneralError(
|
|
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(
|
|
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(
|
|
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(
|
|
126
|
+
throw new GeneralError(IpfsBlobStorageConnector.CLASS_NAME, "fetchFail", error);
|
|
127
127
|
}
|
|
128
128
|
catch (err) {
|
|
129
|
-
throw new GeneralError(
|
|
129
|
+
throw new GeneralError(IpfsBlobStorageConnector.CLASS_NAME, "removeBlobFailed", undefined, err);
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
/**
|
|
@@ -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,19 @@
|
|
|
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
|
+
|
|
3
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)
|
|
4
18
|
|
|
5
19
|
|
|
@@ -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
|
+
"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.
|
|
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",
|
|
@@ -52,5 +52,9 @@
|
|
|
52
52
|
"connector",
|
|
53
53
|
"adapter",
|
|
54
54
|
"integration"
|
|
55
|
-
]
|
|
55
|
+
],
|
|
56
|
+
"bugs": {
|
|
57
|
+
"url": "git+https://github.com/twinfoundation/blob-storage/issues"
|
|
58
|
+
},
|
|
59
|
+
"homepage": "https://twindev.org"
|
|
56
60
|
}
|