@pinata/sdk 1.2.0 → 1.2.1
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 +21 -5
- package/lib/pinata-sdk.js +305 -155
- package/lib/pinata-sdk.min.js +5 -5
- package/package.json +1 -1
- package/src/commands/data/getFilesByCount/getFilesByCount.js +2 -5
- package/src/commands/data/pinList/pinList.js +4 -11
- package/src/commands/data/testAuthentication.js +4 -11
- package/src/commands/data/userPinnedDataTotal.js +4 -11
- package/src/commands/pinning/hashMetadata.js +4 -11
- package/src/commands/pinning/hashPinPolicy.js +4 -10
- package/src/commands/pinning/pinByHash.js +4 -11
- package/src/commands/pinning/pinFileToIPFS.js +5 -16
- package/src/commands/pinning/pinFromFS.js +6 -23
- package/src/commands/pinning/pinJSONToIPFS.js +4 -10
- package/src/commands/pinning/pinJobs/pinJobs.js +4 -10
- package/src/commands/pinning/unpin.js +4 -11
- package/src/commands/pinning/userPinPolicy.js +4 -10
- package/src/constants.js +3 -0
- package/src/index.js +60 -15
- package/src/util/validators.js +88 -12
- package/test/commands/data/getFilesByCount/getFilesByCount.test.js +17 -21
- package/test/commands/data/pinList/pinList.test.js +20 -15
- package/test/commands/data/testAuthentication.test.js +17 -13
- package/test/commands/data/userPinnedDataTotal.test.js +3 -3
- package/test/commands/pinning/hashMetadata.test.js +7 -7
- package/test/commands/pinning/hashPinPolicy.test.js +6 -6
- package/test/commands/pinning/pinByHash.test.js +4 -4
- package/test/commands/pinning/pinFileToIPFS.test.js +5 -5
- package/test/commands/pinning/pinFromFS.js +3 -3
- package/test/commands/pinning/pinJSONToIPFS.test.js +4 -4
- package/test/commands/pinning/pinJobs/pinJobs.test.js +3 -3
- package/test/commands/pinning/unpin.test.js +5 -5
- package/test/commands/pinning/userPinPolicy.test.js +51 -22
- package/test/util/validators.test.js +114 -72
- package/types/commands/data/getFilesByCount/getFilesByCount.d.ts +1 -1
- package/types/commands/data/pinList/pinList.d.ts +1 -1
- package/types/commands/data/testAuthentication.d.ts +1 -1
- package/types/commands/data/userPinnedDataTotal.d.ts +1 -1
- package/types/commands/pinning/hashMetadata.d.ts +1 -1
- package/types/commands/pinning/hashPinPolicy.d.ts +1 -1
- package/types/commands/pinning/pinByHash.d.ts +1 -1
- package/types/commands/pinning/pinFileToIPFS.d.ts +1 -1
- package/types/commands/pinning/pinFromFS.d.ts +1 -1
- package/types/commands/pinning/pinJSONToIPFS.d.ts +1 -1
- package/types/commands/pinning/pinJobs/pinJobs.d.ts +1 -1
- package/types/commands/pinning/unpin.d.ts +1 -1
- package/types/commands/pinning/userPinPolicy.d.ts +1 -1
- package/types/constants.d.ts +1 -0
- package/types/index.d.ts +9 -174
- package/types/util/validators.d.ts +34 -0
|
@@ -9,7 +9,7 @@ test('Result other than 200 status is returned', () => {
|
|
|
9
9
|
};
|
|
10
10
|
axios.get.mockResolvedValue(badStatus);
|
|
11
11
|
expect.assertions(1);
|
|
12
|
-
expect(pinJobs('test', 'test')).rejects.toEqual(Error(`unknown server response while attempting to retrieve pin jobs: ${badStatus}`));
|
|
12
|
+
expect(pinJobs({ pinataApiKey: 'test', pinataSecretApiKey: 'test' })).rejects.toEqual(Error(`unknown server response while attempting to retrieve pin jobs: ${badStatus}`));
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
test('200 status is returned', () => {
|
|
@@ -19,11 +19,11 @@ test('200 status is returned', () => {
|
|
|
19
19
|
};
|
|
20
20
|
axios.get.mockResolvedValue(goodStatus);
|
|
21
21
|
expect.assertions(1);
|
|
22
|
-
expect(pinJobs('test', 'test')).resolves.toEqual(goodStatus.data);
|
|
22
|
+
expect(pinJobs({ pinataApiKey: 'test', pinataSecretApiKey: 'test' })).resolves.toEqual(goodStatus.data);
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
test('Rejection handled', () => {
|
|
26
26
|
axios.get.mockRejectedValue('test error');
|
|
27
27
|
expect.assertions(1);
|
|
28
|
-
expect(pinJobs('test', 'test')).rejects.toEqual('test error');
|
|
28
|
+
expect(pinJobs({ pinataApiKey: 'test', pinataSecretApiKey: 'test' })).rejects.toEqual('test error');
|
|
29
29
|
});
|
|
@@ -9,13 +9,13 @@ const goodHashToUnpin = 'Qma6e8dovfLyiG2UUfdkSHNPAySzrWLX9qVXb44v1muqcp';
|
|
|
9
9
|
|
|
10
10
|
test('No hashToUnpin value is provided should error', () => {
|
|
11
11
|
expect(() => {
|
|
12
|
-
unpin('test', 'test');
|
|
12
|
+
unpin({ pinataApiKey: 'test', pinataSecretApiKey: 'test' });
|
|
13
13
|
}).toThrow('hashToUnpin value is required for removing a pin from Pinata');
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
test('Invalid hashToUnpin value is provided', () => {
|
|
17
17
|
expect(() => {
|
|
18
|
-
unpin('test', 'test', badHashToUnpin);
|
|
18
|
+
unpin({ pinataApiKey: 'test', pinataSecretApiKey: 'test' }, badHashToUnpin);
|
|
19
19
|
}).toThrow(`${badHashToUnpin} is an invalid IPFS CID`);
|
|
20
20
|
});
|
|
21
21
|
|
|
@@ -26,7 +26,7 @@ test('200 status is returned', () => {
|
|
|
26
26
|
};
|
|
27
27
|
axios.delete.mockResolvedValue(goodStatus);
|
|
28
28
|
expect.assertions(1);
|
|
29
|
-
expect(unpin('test', 'test', goodHashToUnpin)).resolves.toEqual(goodStatus.data);
|
|
29
|
+
expect(unpin({ pinataApiKey: 'test', pinataSecretApiKey: 'test' }, goodHashToUnpin)).resolves.toEqual(goodStatus.data);
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
test('Result other than 200 status is returned', () => {
|
|
@@ -35,13 +35,13 @@ test('Result other than 200 status is returned', () => {
|
|
|
35
35
|
};
|
|
36
36
|
axios.delete.mockResolvedValue(badStatus);
|
|
37
37
|
expect.assertions(1);
|
|
38
|
-
expect(unpin('test', 'test', goodHashToUnpin)).rejects.toEqual(Error(`unknown server response while removing pin from IPFS: ${badStatus}`));
|
|
38
|
+
expect(unpin({ pinataApiKey: 'test', pinataSecretApiKey: 'test' }, goodHashToUnpin)).rejects.toEqual(Error(`unknown server response while removing pin from IPFS: ${badStatus}`));
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
test('Rejection handled', () => {
|
|
42
42
|
axios.delete.mockRejectedValue('test error');
|
|
43
43
|
expect.assertions(1);
|
|
44
|
-
expect(unpin('test', 'test', goodHashToUnpin)).rejects.toEqual('test error');
|
|
44
|
+
expect(unpin({ pinataApiKey: 'test', pinataSecretApiKey: 'test' }, goodHashToUnpin)).rejects.toEqual('test error');
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
|
|
@@ -1,51 +1,80 @@
|
|
|
1
|
-
import axios from
|
|
2
|
-
import userPinPolicy from
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import userPinPolicy from "../../../src/commands/pinning/userPinPolicy";
|
|
3
3
|
|
|
4
|
-
jest.mock(
|
|
4
|
+
jest.mock("axios");
|
|
5
5
|
|
|
6
6
|
//common values
|
|
7
7
|
const newPinPolicy = {
|
|
8
8
|
regions: [
|
|
9
9
|
{
|
|
10
|
-
id:
|
|
11
|
-
desiredReplicationCount: 2
|
|
10
|
+
id: "FRA1",
|
|
11
|
+
desiredReplicationCount: 2,
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
|
-
id:
|
|
15
|
-
desiredReplicationCount: 2
|
|
16
|
-
}
|
|
17
|
-
]
|
|
14
|
+
id: "NYC1",
|
|
15
|
+
desiredReplicationCount: 2,
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
test(
|
|
20
|
+
test("No newPinPolicy value provided should error", () => {
|
|
21
21
|
expect(() => {
|
|
22
|
-
userPinPolicy(
|
|
22
|
+
userPinPolicy({
|
|
23
|
+
pinataApiKey: "test",
|
|
24
|
+
pinataSecretApiKey: "test",
|
|
25
|
+
});
|
|
23
26
|
}).toThrow();
|
|
24
27
|
});
|
|
25
28
|
|
|
26
|
-
test(
|
|
29
|
+
test("200 status is returned", () => {
|
|
27
30
|
const goodStatus = {
|
|
28
31
|
status: 200,
|
|
29
|
-
data:
|
|
32
|
+
data: "testData",
|
|
30
33
|
};
|
|
31
34
|
axios.put.mockResolvedValue(goodStatus);
|
|
32
35
|
expect.assertions(1);
|
|
33
|
-
expect(
|
|
36
|
+
expect(
|
|
37
|
+
userPinPolicy(
|
|
38
|
+
{
|
|
39
|
+
pinataApiKey: "test",
|
|
40
|
+
pinataSecretApiKey: "test",
|
|
41
|
+
},
|
|
42
|
+
newPinPolicy
|
|
43
|
+
)
|
|
44
|
+
).resolves.toEqual(goodStatus.data);
|
|
34
45
|
});
|
|
35
46
|
|
|
36
|
-
test(
|
|
47
|
+
test("Result other than 200 status is returned", () => {
|
|
37
48
|
const badStatus = {
|
|
38
|
-
status: 700
|
|
49
|
+
status: 700,
|
|
39
50
|
};
|
|
40
51
|
axios.put.mockResolvedValue(badStatus);
|
|
41
52
|
expect.assertions(1);
|
|
42
|
-
expect(
|
|
53
|
+
expect(
|
|
54
|
+
userPinPolicy(
|
|
55
|
+
{
|
|
56
|
+
pinataApiKey: "test",
|
|
57
|
+
pinataSecretApiKey: "test",
|
|
58
|
+
},
|
|
59
|
+
newPinPolicy
|
|
60
|
+
)
|
|
61
|
+
).rejects.toEqual(
|
|
62
|
+
Error(
|
|
63
|
+
`unknown server response while changing pin policy for user: ${badStatus}`
|
|
64
|
+
)
|
|
65
|
+
);
|
|
43
66
|
});
|
|
44
67
|
|
|
45
|
-
test(
|
|
46
|
-
axios.put.mockRejectedValue(
|
|
68
|
+
test("Rejection handled", () => {
|
|
69
|
+
axios.put.mockRejectedValue("test error");
|
|
47
70
|
expect.assertions(1);
|
|
48
|
-
expect(
|
|
71
|
+
expect(
|
|
72
|
+
userPinPolicy(
|
|
73
|
+
{
|
|
74
|
+
pinataApiKey: "test",
|
|
75
|
+
pinataSecretApiKey: "test",
|
|
76
|
+
},
|
|
77
|
+
newPinPolicy
|
|
78
|
+
)
|
|
79
|
+
).rejects.toEqual("test error");
|
|
49
80
|
});
|
|
50
|
-
|
|
51
|
-
|
|
@@ -1,61 +1,98 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
validateApiKeys,
|
|
3
|
+
createConfigForAxiosHeaders,
|
|
4
|
+
validateHostNodes,
|
|
5
|
+
validateMetadata,
|
|
6
|
+
validatePinPolicyStructure,
|
|
7
|
+
validatePinataOptions,
|
|
8
|
+
} from "../../src/util/validators";
|
|
9
|
+
import { ERROR_NO_CREDENTIALS_PROVIDED } from "../../src/constants";
|
|
2
10
|
|
|
3
|
-
describe(
|
|
4
|
-
test(
|
|
5
|
-
expect(() => {
|
|
6
|
-
validateApiKeys(
|
|
7
|
-
}).toThrow(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
describe("validateApiKeys function testing", () => {
|
|
12
|
+
test("check to throw if either pinataApiKey or pinataSecretApiKey are not provided", () => {
|
|
13
|
+
expect(() => {
|
|
14
|
+
validateApiKeys("", "test");
|
|
15
|
+
}).toThrow(
|
|
16
|
+
"No pinataApiKey provided! Please provide your pinata api key as an argument when you start this script"
|
|
17
|
+
);
|
|
18
|
+
expect(() => {
|
|
19
|
+
validateApiKeys("test", "");
|
|
20
|
+
}).toThrow(
|
|
21
|
+
"No pinataSecretApiKey provided! Please provide your pinata secret api key as an argument when you start this script"
|
|
22
|
+
);
|
|
11
23
|
});
|
|
12
24
|
});
|
|
13
25
|
|
|
14
|
-
describe(
|
|
15
|
-
|
|
26
|
+
describe("createConfigForAxiosHeaders function testing", () => {
|
|
27
|
+
expect(() => {
|
|
28
|
+
createConfigForAxiosHeaders({});
|
|
29
|
+
}).toThrow(ERROR_NO_CREDENTIALS_PROVIDED);
|
|
30
|
+
|
|
31
|
+
expect(() => {
|
|
32
|
+
createConfigForAxiosHeaders({ pinataApiKey: "some api key" });
|
|
33
|
+
}).toThrow(ERROR_NO_CREDENTIALS_PROVIDED);
|
|
34
|
+
|
|
35
|
+
expect(() => {
|
|
36
|
+
createConfigForAxiosHeaders({ pinataSecretApiKey: "some api secret" });
|
|
37
|
+
}).toThrow(ERROR_NO_CREDENTIALS_PROVIDED);
|
|
38
|
+
|
|
39
|
+
expect(
|
|
40
|
+
createConfigForAxiosHeaders({
|
|
41
|
+
pinataApiKey: "some api key",
|
|
42
|
+
pinataSecretApiKey: "some api secret",
|
|
43
|
+
})
|
|
44
|
+
).toEqual({
|
|
45
|
+
withCredentials: true,
|
|
46
|
+
headers: {
|
|
47
|
+
pinata_api_key: "some api key",
|
|
48
|
+
pinata_secret_api_key: "some api secret",
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
describe("validateHostNodes function testing", () => {
|
|
53
|
+
test("host_nodes is not an array", () => {
|
|
16
54
|
const hostNodes = {
|
|
17
|
-
test:
|
|
55
|
+
test: "test",
|
|
18
56
|
};
|
|
19
57
|
expect(() => {
|
|
20
58
|
validateHostNodes(hostNodes);
|
|
21
|
-
}).toThrow(
|
|
59
|
+
}).toThrow("host_nodes value must be an array");
|
|
22
60
|
});
|
|
23
61
|
|
|
24
|
-
test(
|
|
25
|
-
const validHost =
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
invalidHost
|
|
30
|
-
];
|
|
62
|
+
test("invalid host_node entry", () => {
|
|
63
|
+
const validHost =
|
|
64
|
+
"/ip4/127.0.0.1/tcp/1234/ws/ipfs/QmUjNmr8TgJCn1Ao7DvMy4cjoZU15b9bwSCBLE3vwXiwgj";
|
|
65
|
+
const invalidHost = "invalid host";
|
|
66
|
+
const hostNodes = [validHost, invalidHost];
|
|
31
67
|
expect(() => {
|
|
32
68
|
validateHostNodes(hostNodes);
|
|
33
|
-
}).toThrow(
|
|
69
|
+
}).toThrow(
|
|
70
|
+
`host_node array entry: ${invalidHost} is not a valid peer multiaddr`
|
|
71
|
+
);
|
|
34
72
|
});
|
|
35
73
|
});
|
|
36
74
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
test('name is not a string', () => {
|
|
75
|
+
describe("validateMetadata function testing", () => {
|
|
76
|
+
test("name is not a string", () => {
|
|
40
77
|
const badName = {
|
|
41
|
-
test:
|
|
78
|
+
test: "testing",
|
|
42
79
|
};
|
|
43
80
|
expect(() => {
|
|
44
81
|
validateMetadata({
|
|
45
|
-
name: badName
|
|
82
|
+
name: badName,
|
|
46
83
|
});
|
|
47
|
-
}).toThrow(
|
|
84
|
+
}).toThrow("metadata name must be of type string");
|
|
48
85
|
});
|
|
49
|
-
test(
|
|
50
|
-
const badKeyValues =
|
|
86
|
+
test("keyvalues is not an object", () => {
|
|
87
|
+
const badKeyValues = "testing";
|
|
51
88
|
expect(() => {
|
|
52
89
|
validateMetadata({
|
|
53
|
-
keyvalues: badKeyValues
|
|
90
|
+
keyvalues: badKeyValues,
|
|
54
91
|
});
|
|
55
|
-
}).toThrow(
|
|
92
|
+
}).toThrow("metatadata keyvalues must be an object");
|
|
56
93
|
});
|
|
57
94
|
|
|
58
|
-
test(
|
|
95
|
+
test("more than 10 keyvalues was provided", () => {
|
|
59
96
|
const tooManyKeyValues = {
|
|
60
97
|
one: 1,
|
|
61
98
|
two: 2,
|
|
@@ -67,19 +104,21 @@ describe('validateMetadata function testing', () => {
|
|
|
67
104
|
eight: 8,
|
|
68
105
|
nine: 9,
|
|
69
106
|
ten: 10,
|
|
70
|
-
eleven: 11
|
|
107
|
+
eleven: 11,
|
|
71
108
|
};
|
|
72
109
|
expect(() => {
|
|
73
110
|
validateMetadata({
|
|
74
|
-
keyvalues: tooManyKeyValues
|
|
111
|
+
keyvalues: tooManyKeyValues,
|
|
75
112
|
});
|
|
76
|
-
}).toThrow(
|
|
113
|
+
}).toThrow(
|
|
114
|
+
"No more than 10 keyvalues can be provided for metadata entries"
|
|
115
|
+
);
|
|
77
116
|
});
|
|
78
|
-
test(
|
|
117
|
+
test("Throws error on an object being passed in as a value for a keyvalue", () => {
|
|
79
118
|
const invalidValue = {
|
|
80
119
|
one: 1,
|
|
81
120
|
two: {
|
|
82
|
-
test:
|
|
121
|
+
test: "test",
|
|
83
122
|
},
|
|
84
123
|
three: 3,
|
|
85
124
|
four: 4,
|
|
@@ -89,15 +128,17 @@ describe('validateMetadata function testing', () => {
|
|
|
89
128
|
eight: 8,
|
|
90
129
|
nine: 9,
|
|
91
130
|
ten: 10,
|
|
92
|
-
eleven: 11
|
|
131
|
+
eleven: 11,
|
|
93
132
|
};
|
|
94
133
|
expect(() => {
|
|
95
134
|
validateMetadata({
|
|
96
|
-
keyvalues: invalidValue
|
|
135
|
+
keyvalues: invalidValue,
|
|
97
136
|
});
|
|
98
|
-
}).toThrow(
|
|
137
|
+
}).toThrow(
|
|
138
|
+
"Metadata keyvalue values must be strings, booleans, or numbers"
|
|
139
|
+
);
|
|
99
140
|
});
|
|
100
|
-
test(
|
|
141
|
+
test("Does not throw an error if metadata is valid", () => {
|
|
101
142
|
const invalidValue = {
|
|
102
143
|
one: 1,
|
|
103
144
|
two: 2,
|
|
@@ -108,85 +149,86 @@ describe('validateMetadata function testing', () => {
|
|
|
108
149
|
seven: 7,
|
|
109
150
|
eight: 8,
|
|
110
151
|
nine: 9,
|
|
111
|
-
ten: 10
|
|
152
|
+
ten: 10,
|
|
112
153
|
};
|
|
113
154
|
expect(() => {
|
|
114
155
|
validateMetadata({
|
|
115
|
-
keyvalues: invalidValue
|
|
156
|
+
keyvalues: invalidValue,
|
|
116
157
|
});
|
|
117
158
|
}).not.toThrow();
|
|
118
159
|
});
|
|
119
160
|
});
|
|
120
161
|
|
|
121
|
-
describe(
|
|
122
|
-
test(
|
|
162
|
+
describe("validatePinPolicyStructure function testing", () => {
|
|
163
|
+
test("No Policy Provided", () => {
|
|
123
164
|
expect(() => {
|
|
124
165
|
validatePinPolicyStructure();
|
|
125
166
|
}).toThrow("No pin policy provided");
|
|
126
167
|
});
|
|
127
|
-
test(
|
|
168
|
+
test("No Regions Provided", () => {
|
|
128
169
|
expect(() => {
|
|
129
170
|
validatePinPolicyStructure({
|
|
130
|
-
test:
|
|
171
|
+
test: "test",
|
|
131
172
|
});
|
|
132
173
|
}).toThrow("No regions provided in pin policy");
|
|
133
174
|
});
|
|
134
|
-
test(
|
|
175
|
+
test("region id is not a string", () => {
|
|
135
176
|
expect(() => {
|
|
136
177
|
validatePinPolicyStructure({
|
|
137
178
|
regions: [
|
|
138
179
|
{
|
|
139
|
-
id:
|
|
140
|
-
desiredReplicationCount: 1
|
|
180
|
+
id: "goodRegionId",
|
|
181
|
+
desiredReplicationCount: 1,
|
|
141
182
|
},
|
|
142
183
|
{
|
|
143
184
|
id: 0,
|
|
144
|
-
desiredReplicationCount: 1
|
|
145
|
-
}
|
|
146
|
-
]
|
|
185
|
+
desiredReplicationCount: 1,
|
|
186
|
+
},
|
|
187
|
+
],
|
|
147
188
|
});
|
|
148
189
|
}).toThrow("region id must be a string");
|
|
149
190
|
});
|
|
150
|
-
test(
|
|
191
|
+
test("desiredReplicationCount is not an integer", () => {
|
|
151
192
|
expect(() => {
|
|
152
193
|
validatePinPolicyStructure({
|
|
153
194
|
regions: [
|
|
154
195
|
{
|
|
155
|
-
id:
|
|
156
|
-
desiredReplicationCount: 1
|
|
196
|
+
id: "goodRegionId",
|
|
197
|
+
desiredReplicationCount: 1,
|
|
157
198
|
},
|
|
158
199
|
{
|
|
159
|
-
id:
|
|
160
|
-
desiredReplicationCount:
|
|
161
|
-
}
|
|
162
|
-
]
|
|
200
|
+
id: "goodRegionId2",
|
|
201
|
+
desiredReplicationCount: "string that should fail",
|
|
202
|
+
},
|
|
203
|
+
],
|
|
163
204
|
});
|
|
164
205
|
}).toThrow("desiredReplicationCount must be an integer");
|
|
165
206
|
});
|
|
166
207
|
});
|
|
167
208
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
test('options is not an object', () => {
|
|
209
|
+
describe("validatePinataOptions function testing", () => {
|
|
210
|
+
test("options is not an object", () => {
|
|
171
211
|
expect(() => {
|
|
172
|
-
validatePinataOptions(
|
|
173
|
-
}).toThrow(
|
|
212
|
+
validatePinataOptions("test");
|
|
213
|
+
}).toThrow("options must be an object");
|
|
174
214
|
});
|
|
175
|
-
test(
|
|
215
|
+
test("cidVersion is not a 0 or 1", () => {
|
|
176
216
|
const badVersion = {
|
|
177
|
-
test:
|
|
217
|
+
test: "testing",
|
|
178
218
|
};
|
|
179
219
|
expect(() => {
|
|
180
220
|
validatePinataOptions({
|
|
181
|
-
cidVersion: badVersion
|
|
221
|
+
cidVersion: badVersion,
|
|
182
222
|
});
|
|
183
|
-
}).toThrow(
|
|
223
|
+
}).toThrow("unsupported or invalid cidVersion");
|
|
184
224
|
});
|
|
185
|
-
test(
|
|
225
|
+
test("wrapWithDirectory is not true or false", () => {
|
|
186
226
|
expect(() => {
|
|
187
227
|
validatePinataOptions({
|
|
188
|
-
wrapWithDirectory:
|
|
228
|
+
wrapWithDirectory: "test",
|
|
189
229
|
});
|
|
190
|
-
}).toThrow(
|
|
230
|
+
}).toThrow(
|
|
231
|
+
"wrapWithDirectory must be a boolean value of true or false"
|
|
232
|
+
);
|
|
191
233
|
});
|
|
192
234
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export default function getFilesByCount(
|
|
1
|
+
export default function getFilesByCount(config: any, filters?: {}, maxCount?: number): {
|
|
2
2
|
[Symbol.asyncIterator]: () => {
|
|
3
3
|
next(): Promise<{
|
|
4
4
|
value: any;
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
* @param {*} metadata
|
|
7
7
|
* @returns {Promise<unknown>}
|
|
8
8
|
*/
|
|
9
|
-
export default function hashMetadata(
|
|
9
|
+
export default function hashMetadata(config: any, ipfsPinHash: any, metadata: any): Promise<unknown>;
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
* @param {*} newPinPolicy
|
|
7
7
|
* @returns {Promise<unknown>}
|
|
8
8
|
*/
|
|
9
|
-
export default function hashPinPolicy(
|
|
9
|
+
export default function hashPinPolicy(config: any, ipfsPinHash: any, newPinPolicy: any): Promise<unknown>;
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
* @param {*} options
|
|
7
7
|
* @returns {Promise<unknown>}
|
|
8
8
|
*/
|
|
9
|
-
export default function pinByHash(
|
|
9
|
+
export default function pinByHash(config: any, hashToPin: any, options: any): Promise<unknown>;
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
* @param {*} options
|
|
7
7
|
* @returns {Promise<unknown>}
|
|
8
8
|
*/
|
|
9
|
-
export default function pinFileToIPFS(
|
|
9
|
+
export default function pinFileToIPFS(config: any, readStream: any, options: any): Promise<unknown>;
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
* @param {*} options
|
|
7
7
|
* @returns {Promise<unknown>}
|
|
8
8
|
*/
|
|
9
|
-
export default function pinFromFS(
|
|
9
|
+
export default function pinFromFS(config: any, sourcePath: string, options: any): Promise<unknown>;
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
* @param {*} options
|
|
7
7
|
* @returns {Promise<unknown>}
|
|
8
8
|
*/
|
|
9
|
-
export default function pinJSONToIPFS(
|
|
9
|
+
export default function pinJSONToIPFS(config: any, body: any, options: any): Promise<unknown>;
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* @param {string} hashToUnpin
|
|
6
6
|
* @returns {Promise<unknown>}
|
|
7
7
|
*/
|
|
8
|
-
export default function unpin(
|
|
8
|
+
export default function unpin(config: any, hashToUnpin: string): Promise<unknown>;
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* @param {*} newPinPolicy
|
|
6
6
|
* @returns {Promise<unknown>}
|
|
7
7
|
*/
|
|
8
|
-
export default function userPinPolicy(
|
|
8
|
+
export default function userPinPolicy(config: any, newPinPolicy: any): Promise<unknown>;
|
package/types/constants.d.ts
CHANGED