@twin.org/blob-storage-connector-ipfs 0.0.1-next.3 → 0.0.1-next.31
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 +1 -1
- package/dist/cjs/index.cjs +12 -7
- package/dist/esm/index.mjs +12 -7
- package/dist/types/index.d.ts +1 -0
- package/dist/types/ipfsBlobStorageConnector.d.ts +2 -5
- package/dist/types/models/IIpfsBlobStorageConnectorConstructorOptions.d.ts +10 -0
- package/docs/changelog.md +43 -1
- package/docs/reference/classes/IpfsBlobStorageConnector.md +17 -13
- package/docs/reference/index.md +1 -0
- package/docs/reference/interfaces/IIpfsBlobStorageConnectorConstructorOptions.md +11 -0
- package/locales/en.json +4 -2
- package/package.json +5 -33
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ npm install @twin.org/blob-storage-connector-ipfs
|
|
|
13
13
|
The tests developed are functional tests and need an instance of IPFS up and running. To run IPFS locally:
|
|
14
14
|
|
|
15
15
|
```shell
|
|
16
|
-
docker run -p 4001:4001 -p 4001:4001/udp -p 8080:8080 -p 5001:5001 --name ipfs --hostname ipfs -d ipfs/kubo:latest
|
|
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
17
|
```
|
|
18
18
|
|
|
19
19
|
Afterwards you can run the tests as follows:
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -24,7 +24,6 @@ class IpfsBlobStorageConnector {
|
|
|
24
24
|
/**
|
|
25
25
|
* Create a new instance of IpfsBlobStorageConnector.
|
|
26
26
|
* @param options The options for the connector.
|
|
27
|
-
* @param options.config The configuration for the connector.
|
|
28
27
|
*/
|
|
29
28
|
constructor(options) {
|
|
30
29
|
core.Guards.object(this.CLASS_NAME, "options", options);
|
|
@@ -58,9 +57,8 @@ class IpfsBlobStorageConnector {
|
|
|
58
57
|
const result = (await response.json());
|
|
59
58
|
return `blob:${new core.Urn(IpfsBlobStorageConnector.NAMESPACE, result.Hash).toString()}`;
|
|
60
59
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
});
|
|
60
|
+
const error = await response.json();
|
|
61
|
+
throw new core.GeneralError(this.CLASS_NAME, "fetchFail", error);
|
|
64
62
|
}
|
|
65
63
|
catch (err) {
|
|
66
64
|
throw new core.GeneralError(this.CLASS_NAME, "setBlobFailed", undefined, err);
|
|
@@ -93,8 +91,12 @@ class IpfsBlobStorageConnector {
|
|
|
93
91
|
const result = await response.arrayBuffer();
|
|
94
92
|
return new Uint8Array(result);
|
|
95
93
|
}
|
|
94
|
+
const error = await response.json();
|
|
95
|
+
throw new core.GeneralError(this.CLASS_NAME, "fetchFail", error);
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
throw new core.GeneralError(this.CLASS_NAME, "getBlobFailed", undefined, err);
|
|
96
99
|
}
|
|
97
|
-
catch { }
|
|
98
100
|
}
|
|
99
101
|
/**
|
|
100
102
|
* Remove the blob.
|
|
@@ -122,9 +124,12 @@ class IpfsBlobStorageConnector {
|
|
|
122
124
|
if (response.ok) {
|
|
123
125
|
return true;
|
|
124
126
|
}
|
|
127
|
+
const error = await response.json();
|
|
128
|
+
throw new core.GeneralError(this.CLASS_NAME, "fetchFail", error);
|
|
129
|
+
}
|
|
130
|
+
catch (err) {
|
|
131
|
+
throw new core.GeneralError(this.CLASS_NAME, "removeBlobFailed", undefined, err);
|
|
125
132
|
}
|
|
126
|
-
catch { }
|
|
127
|
-
return false;
|
|
128
133
|
}
|
|
129
134
|
/**
|
|
130
135
|
* Add the security to the request.
|
package/dist/esm/index.mjs
CHANGED
|
@@ -22,7 +22,6 @@ class IpfsBlobStorageConnector {
|
|
|
22
22
|
/**
|
|
23
23
|
* Create a new instance of IpfsBlobStorageConnector.
|
|
24
24
|
* @param options The options for the connector.
|
|
25
|
-
* @param options.config The configuration for the connector.
|
|
26
25
|
*/
|
|
27
26
|
constructor(options) {
|
|
28
27
|
Guards.object(this.CLASS_NAME, "options", options);
|
|
@@ -56,9 +55,8 @@ class IpfsBlobStorageConnector {
|
|
|
56
55
|
const result = (await response.json());
|
|
57
56
|
return `blob:${new Urn(IpfsBlobStorageConnector.NAMESPACE, result.Hash).toString()}`;
|
|
58
57
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
});
|
|
58
|
+
const error = await response.json();
|
|
59
|
+
throw new GeneralError(this.CLASS_NAME, "fetchFail", error);
|
|
62
60
|
}
|
|
63
61
|
catch (err) {
|
|
64
62
|
throw new GeneralError(this.CLASS_NAME, "setBlobFailed", undefined, err);
|
|
@@ -91,8 +89,12 @@ class IpfsBlobStorageConnector {
|
|
|
91
89
|
const result = await response.arrayBuffer();
|
|
92
90
|
return new Uint8Array(result);
|
|
93
91
|
}
|
|
92
|
+
const error = await response.json();
|
|
93
|
+
throw new GeneralError(this.CLASS_NAME, "fetchFail", error);
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
throw new GeneralError(this.CLASS_NAME, "getBlobFailed", undefined, err);
|
|
94
97
|
}
|
|
95
|
-
catch { }
|
|
96
98
|
}
|
|
97
99
|
/**
|
|
98
100
|
* Remove the blob.
|
|
@@ -120,9 +122,12 @@ class IpfsBlobStorageConnector {
|
|
|
120
122
|
if (response.ok) {
|
|
121
123
|
return true;
|
|
122
124
|
}
|
|
125
|
+
const error = await response.json();
|
|
126
|
+
throw new GeneralError(this.CLASS_NAME, "fetchFail", error);
|
|
127
|
+
}
|
|
128
|
+
catch (err) {
|
|
129
|
+
throw new GeneralError(this.CLASS_NAME, "removeBlobFailed", undefined, err);
|
|
123
130
|
}
|
|
124
|
-
catch { }
|
|
125
|
-
return false;
|
|
126
131
|
}
|
|
127
132
|
/**
|
|
128
133
|
* Add the security to the request.
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IBlobStorageConnector } from "@twin.org/blob-storage-models";
|
|
2
|
-
import type {
|
|
2
|
+
import type { IIpfsBlobStorageConnectorConstructorOptions } from "./models/IIpfsBlobStorageConnectorConstructorOptions";
|
|
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.
|
|
@@ -16,11 +16,8 @@ export declare class IpfsBlobStorageConnector implements IBlobStorageConnector {
|
|
|
16
16
|
/**
|
|
17
17
|
* Create a new instance of IpfsBlobStorageConnector.
|
|
18
18
|
* @param options The options for the connector.
|
|
19
|
-
* @param options.config The configuration for the connector.
|
|
20
19
|
*/
|
|
21
|
-
constructor(options:
|
|
22
|
-
config: IIpfsBlobStorageConnectorConfig;
|
|
23
|
-
});
|
|
20
|
+
constructor(options: IIpfsBlobStorageConnectorConstructorOptions);
|
|
24
21
|
/**
|
|
25
22
|
* Set the blob.
|
|
26
23
|
* @param blob The data for the blob.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IIpfsBlobStorageConnectorConfig } from "./IIpfsBlobStorageConnectorConfig";
|
|
2
|
+
/**
|
|
3
|
+
* Options for the IPFS Blob Storage Connector constructor.
|
|
4
|
+
*/
|
|
5
|
+
export interface IIpfsBlobStorageConnectorConstructorOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The configuration for the connector.
|
|
8
|
+
*/
|
|
9
|
+
config: IIpfsBlobStorageConnectorConfig;
|
|
10
|
+
}
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# @twin.org/blob-storage-connector-ipfs - Changelog
|
|
2
2
|
|
|
3
|
-
## v0.0.1-next.
|
|
3
|
+
## [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)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Miscellaneous Chores
|
|
7
|
+
|
|
8
|
+
* **blob-storage-connector-ipfs:** Synchronize repo versions
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/blob-storage-models bumped from 0.0.1-next.30 to 0.0.1-next.31
|
|
16
|
+
|
|
17
|
+
## [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)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* use shared store mechanism ([#12](https://github.com/twinfoundation/blob-storage/issues/12)) ([cae8110](https://github.com/twinfoundation/blob-storage/commit/cae8110681847a1ac4fcac968b8196694e49c320))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Dependencies
|
|
26
|
+
|
|
27
|
+
* The following workspace dependencies were updated
|
|
28
|
+
* dependencies
|
|
29
|
+
* @twin.org/blob-storage-models bumped from 0.0.1-next.29 to 0.0.1-next.30
|
|
30
|
+
|
|
31
|
+
## [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)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Miscellaneous Chores
|
|
35
|
+
|
|
36
|
+
* **blob-storage-connector-ipfs:** Synchronize repo versions
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Dependencies
|
|
40
|
+
|
|
41
|
+
* The following workspace dependencies were updated
|
|
42
|
+
* dependencies
|
|
43
|
+
* @twin.org/blob-storage-models bumped from 0.0.1-next.28 to 0.0.1-next.29
|
|
44
|
+
|
|
45
|
+
## v0.0.1-next.28
|
|
4
46
|
|
|
5
47
|
- Initial Release
|
|
@@ -9,25 +9,23 @@ See https://docs.ipfs.tech/reference/kubo/rpc/ for more information.
|
|
|
9
9
|
|
|
10
10
|
## Constructors
|
|
11
11
|
|
|
12
|
-
###
|
|
12
|
+
### Constructor
|
|
13
13
|
|
|
14
|
-
> **new IpfsBlobStorageConnector**(`options`):
|
|
14
|
+
> **new IpfsBlobStorageConnector**(`options`): `IpfsBlobStorageConnector`
|
|
15
15
|
|
|
16
16
|
Create a new instance of IpfsBlobStorageConnector.
|
|
17
17
|
|
|
18
18
|
#### Parameters
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
##### options
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
• **options.config**: [`IIpfsBlobStorageConnectorConfig`](../interfaces/IIpfsBlobStorageConnectorConfig.md)
|
|
22
|
+
[`IIpfsBlobStorageConnectorConstructorOptions`](../interfaces/IIpfsBlobStorageConnectorConstructorOptions.md)
|
|
25
23
|
|
|
26
|
-
The
|
|
24
|
+
The options for the connector.
|
|
27
25
|
|
|
28
26
|
#### Returns
|
|
29
27
|
|
|
30
|
-
|
|
28
|
+
`IpfsBlobStorageConnector`
|
|
31
29
|
|
|
32
30
|
## Properties
|
|
33
31
|
|
|
@@ -59,7 +57,9 @@ Set the blob.
|
|
|
59
57
|
|
|
60
58
|
#### Parameters
|
|
61
59
|
|
|
62
|
-
|
|
60
|
+
##### blob
|
|
61
|
+
|
|
62
|
+
`Uint8Array`
|
|
63
63
|
|
|
64
64
|
The data for the blob.
|
|
65
65
|
|
|
@@ -77,19 +77,21 @@ The id of the stored blob in urn format.
|
|
|
77
77
|
|
|
78
78
|
### get()
|
|
79
79
|
|
|
80
|
-
> **get**(`id`): `Promise`\<`undefined` \| `Uint8Array
|
|
80
|
+
> **get**(`id`): `Promise`\<`undefined` \| `Uint8Array`\<`ArrayBufferLike`\>\>
|
|
81
81
|
|
|
82
82
|
Get the blob.
|
|
83
83
|
|
|
84
84
|
#### Parameters
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
##### id
|
|
87
|
+
|
|
88
|
+
`string`
|
|
87
89
|
|
|
88
90
|
The id of the blob to get in urn format.
|
|
89
91
|
|
|
90
92
|
#### Returns
|
|
91
93
|
|
|
92
|
-
`Promise`\<`undefined` \| `Uint8Array
|
|
94
|
+
`Promise`\<`undefined` \| `Uint8Array`\<`ArrayBufferLike`\>\>
|
|
93
95
|
|
|
94
96
|
The data for the blob if it can be found or undefined.
|
|
95
97
|
|
|
@@ -107,7 +109,9 @@ Remove the blob.
|
|
|
107
109
|
|
|
108
110
|
#### Parameters
|
|
109
111
|
|
|
110
|
-
|
|
112
|
+
##### id
|
|
113
|
+
|
|
114
|
+
`string`
|
|
111
115
|
|
|
112
116
|
The id of the blob to remove in urn format.
|
|
113
117
|
|
package/docs/reference/index.md
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Interface: IIpfsBlobStorageConnectorConstructorOptions
|
|
2
|
+
|
|
3
|
+
Options for the IPFS Blob Storage Connector constructor.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### config
|
|
8
|
+
|
|
9
|
+
> **config**: [`IIpfsBlobStorageConnectorConfig`](IIpfsBlobStorageConnectorConfig.md)
|
|
10
|
+
|
|
11
|
+
The configuration for the connector.
|
package/locales/en.json
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
"error": {
|
|
3
3
|
"ipfsBlobStorageConnector": {
|
|
4
4
|
"namespaceMismatch": "The namespace in the urn \"{id}\" does not match the namespace of the blob storage \"{namespace}\"",
|
|
5
|
-
"fetchFail": "Failure during IPFS
|
|
6
|
-
"setBlobFailed": "Failed to store blob in IPFS"
|
|
5
|
+
"fetchFail": "Failure during IPFS request",
|
|
6
|
+
"setBlobFailed": "Failed to store blob in IPFS",
|
|
7
|
+
"getBlobFailed": "Failed to get blob from IPFS",
|
|
8
|
+
"removeBlobFailed": "Failed to remove blob from IPFS"
|
|
7
9
|
}
|
|
8
10
|
}
|
|
9
11
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/blob-storage-connector-ipfs",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.31",
|
|
4
4
|
"description": "Blob Storage connector implementation using IPFS",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -13,51 +13,23 @@
|
|
|
13
13
|
"engines": {
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
|
-
"scripts": {
|
|
17
|
-
"clean": "rimraf dist coverage docs/reference",
|
|
18
|
-
"build": "tspc",
|
|
19
|
-
"test": "vitest --run --config ./vitest.config.ts --no-cache",
|
|
20
|
-
"coverage": "vitest --run --coverage --config ./vitest.config.ts --no-cache",
|
|
21
|
-
"bundle:esm": "rollup --config rollup.config.mjs --environment MODULE:esm",
|
|
22
|
-
"bundle:cjs": "rollup --config rollup.config.mjs --environment MODULE:cjs",
|
|
23
|
-
"bundle": "npm run bundle:esm && npm run bundle:cjs",
|
|
24
|
-
"docs:clean": "rimraf docs/reference",
|
|
25
|
-
"docs:generate": "typedoc",
|
|
26
|
-
"docs": "npm run docs:clean && npm run docs:generate",
|
|
27
|
-
"dist": "npm run clean && npm run build && npm run test && npm run bundle && npm run docs"
|
|
28
|
-
},
|
|
29
16
|
"dependencies": {
|
|
30
|
-
"@twin.org/blob-storage-models": "0.0.1-next.
|
|
17
|
+
"@twin.org/blob-storage-models": "0.0.1-next.31",
|
|
31
18
|
"@twin.org/core": "next",
|
|
32
19
|
"@twin.org/crypto": "next",
|
|
33
20
|
"@twin.org/nameof": "next",
|
|
34
21
|
"@twin.org/web": "next"
|
|
35
22
|
},
|
|
36
|
-
"devDependencies": {
|
|
37
|
-
"@twin.org/nameof-transformer": "next",
|
|
38
|
-
"@vitest/coverage-v8": "2.1.1",
|
|
39
|
-
"copyfiles": "2.4.1",
|
|
40
|
-
"dotenv": "16.4.5",
|
|
41
|
-
"rimraf": "6.0.1",
|
|
42
|
-
"rollup": "4.22.0",
|
|
43
|
-
"rollup-plugin-copy": "3.5.0",
|
|
44
|
-
"rollup-plugin-typescript2": "0.36.0",
|
|
45
|
-
"ts-patch": "3.2.1",
|
|
46
|
-
"typedoc": "0.26.7",
|
|
47
|
-
"typedoc-plugin-markdown": "4.2.7",
|
|
48
|
-
"typescript": "5.6.2",
|
|
49
|
-
"vitest": "2.1.1"
|
|
50
|
-
},
|
|
51
23
|
"main": "./dist/cjs/index.cjs",
|
|
52
24
|
"module": "./dist/esm/index.mjs",
|
|
53
25
|
"types": "./dist/types/index.d.ts",
|
|
54
26
|
"exports": {
|
|
55
27
|
".": {
|
|
28
|
+
"types": "./dist/types/index.d.ts",
|
|
56
29
|
"require": "./dist/cjs/index.cjs",
|
|
57
|
-
"import": "./dist/esm/index.mjs"
|
|
58
|
-
"types": "./dist/types/index.d.ts"
|
|
30
|
+
"import": "./dist/esm/index.mjs"
|
|
59
31
|
},
|
|
60
|
-
"./locales": "./locales"
|
|
32
|
+
"./locales/*.json": "./locales/*.json"
|
|
61
33
|
},
|
|
62
34
|
"files": [
|
|
63
35
|
"dist/cjs",
|