@pinata/sdk 1.1.22 → 1.1.25
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/lib/pinata-sdk.js +4 -4
- package/lib/pinata-sdk.min.js +2 -2
- package/package.json +2 -2
- package/src/commands/pinning/pinFileToIPFS.js +3 -3
- package/test/commands/pinning/pinFileToIPFS.test.js +16 -3
- package/tsconfig.json +1 -1
- package/types/commands/data/pinList/pinList.d.ts +8 -0
- package/types/commands/data/pinList/queryBuilder.d.ts +7 -0
- package/types/commands/data/testAuthentication.d.ts +7 -0
- package/types/commands/data/userPinnedDataTotal.d.ts +7 -0
- package/types/commands/pinning/hashMetadata.d.ts +9 -0
- package/types/commands/pinning/hashPinPolicy.d.ts +9 -0
- package/types/commands/pinning/pinByHash.d.ts +9 -0
- package/types/commands/pinning/pinFileToIPFS.d.ts +9 -0
- package/types/commands/pinning/pinFromFS.d.ts +9 -0
- package/types/commands/pinning/pinJSONToIPFS.d.ts +9 -0
- package/types/commands/pinning/pinJobs/pinJobs.d.ts +8 -0
- package/types/commands/pinning/pinJobs/queryBuilder.d.ts +7 -0
- package/types/commands/pinning/unpin.d.ts +8 -0
- package/types/commands/pinning/userPinPolicy.d.ts +8 -0
- package/types/constants.d.ts +1 -0
- package/types/index.d.ts +362 -0
- package/types/util/errorResponse.d.ts +1 -0
- package/types/util/validators.d.ts +26 -0
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pinata/sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.25",
|
|
4
4
|
"description": "Official SDK for the Pinata IPFS platform",
|
|
5
5
|
"main": "lib/pinata-sdk.js",
|
|
6
|
-
"types": "
|
|
6
|
+
"types": "types/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "webpack --env dev && webpack --env build && npm run test && tsc",
|
|
9
9
|
"coverage": "jest --coverage",
|
|
@@ -24,8 +24,8 @@ export default function pinFileToIPFS(pinataApiKey, pinataSecretApiKey, readStre
|
|
|
24
24
|
|
|
25
25
|
const endpoint = `${baseUrl}/pinning/pinFileToIPFS`;
|
|
26
26
|
|
|
27
|
-
if (!(readStream instanceof stream.Readable)) {
|
|
28
|
-
reject(new Error('readStream is not a readable stream'));
|
|
27
|
+
if (!(readStream instanceof stream.Readable || readStream instanceof NodeFormData)) {
|
|
28
|
+
reject(new Error('readStream is not a readable stream or form data'));
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
if (options) {
|
|
@@ -41,7 +41,7 @@ export default function pinFileToIPFS(pinataApiKey, pinataSecretApiKey, readStre
|
|
|
41
41
|
|
|
42
42
|
axios.post(
|
|
43
43
|
endpoint,
|
|
44
|
-
data,
|
|
44
|
+
readStream instanceof NodeFormData ? readStream : data,
|
|
45
45
|
{
|
|
46
46
|
withCredentials: true,
|
|
47
47
|
maxContentLength: 'Infinity', //this is needed to prevent axios from erroring out with large files
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import pinFileToIPFS from'../../../src/commands/pinning/pinFileToIPFS';
|
|
3
3
|
import fs from 'fs';
|
|
4
|
+
import NodeFormData from 'form-data';
|
|
4
5
|
jest.mock('axios');
|
|
5
6
|
|
|
6
7
|
//common values
|
|
7
8
|
const nonStream = 'test';
|
|
8
9
|
const validStream = fs.createReadStream('./pinata.png');
|
|
10
|
+
const validFormData = new NodeFormData();
|
|
11
|
+
validFormData.append('file', validStream, {filepath: 'test/filepath'});
|
|
9
12
|
|
|
10
13
|
|
|
11
|
-
test('non-readableStream is passed in', () => {
|
|
12
|
-
expect(pinFileToIPFS('test', 'test', nonStream)).rejects.toEqual(Error('readStream is not a readable stream'));
|
|
14
|
+
test('non-readableStream and non-formData is passed in', () => {
|
|
15
|
+
expect(pinFileToIPFS('test', 'test', nonStream)).rejects.toEqual(Error('readStream is not a readable stream or form data'));
|
|
13
16
|
|
|
14
17
|
return undefined;
|
|
15
18
|
});
|
|
16
19
|
|
|
17
|
-
test('200 status is returned', () => {
|
|
20
|
+
test('200 status is returned with valid stream', () => {
|
|
18
21
|
const goodStatus = {
|
|
19
22
|
status: 200,
|
|
20
23
|
data: 'testData'
|
|
@@ -24,6 +27,16 @@ test('200 status is returned', () => {
|
|
|
24
27
|
expect(pinFileToIPFS('test', 'test', validStream)).resolves.toEqual(goodStatus.data);
|
|
25
28
|
});
|
|
26
29
|
|
|
30
|
+
test('200 status is returned with valid form data', () => {
|
|
31
|
+
const goodStatus = {
|
|
32
|
+
status: 200,
|
|
33
|
+
data: 'testData'
|
|
34
|
+
};
|
|
35
|
+
axios.post.mockResolvedValue(goodStatus);
|
|
36
|
+
expect.assertions(1);
|
|
37
|
+
expect(pinFileToIPFS('test', 'test', validFormData)).resolves.toEqual(goodStatus.data);
|
|
38
|
+
});
|
|
39
|
+
|
|
27
40
|
test('Result other than 200 status is returned', () => {
|
|
28
41
|
const badStatus = {
|
|
29
42
|
status: 700
|
package/tsconfig.json
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pin List
|
|
3
|
+
* @param {string} pinataApiKey
|
|
4
|
+
* @param {string} pinataSecretApiKey
|
|
5
|
+
* @param {string} filters
|
|
6
|
+
* @returns {Promise<unknown>}
|
|
7
|
+
*/
|
|
8
|
+
export default function pinList(pinataApiKey: string, pinataSecretApiKey: string, filters: string): Promise<unknown>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hash Meta Data
|
|
3
|
+
* @param {string} pinataApiKey
|
|
4
|
+
* @param {string} pinataSecretApiKey
|
|
5
|
+
* @param {*} ipfsPinHash
|
|
6
|
+
* @param {*} metadata
|
|
7
|
+
* @returns {Promise<unknown>}
|
|
8
|
+
*/
|
|
9
|
+
export default function hashMetadata(pinataApiKey: string, pinataSecretApiKey: string, ipfsPinHash: any, metadata: any): Promise<unknown>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hash Pin Policy
|
|
3
|
+
* @param {string} pinataApiKey
|
|
4
|
+
* @param {string} pinataSecretApiKey
|
|
5
|
+
* @param {*} ipfsPinHash
|
|
6
|
+
* @param {*} newPinPolicy
|
|
7
|
+
* @returns {Promise<unknown>}
|
|
8
|
+
*/
|
|
9
|
+
export default function hashPinPolicy(pinataApiKey: string, pinataSecretApiKey: string, ipfsPinHash: any, newPinPolicy: any): Promise<unknown>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pin By Hash
|
|
3
|
+
* @param {string} pinataApiKey
|
|
4
|
+
* @param {string} pinataSecretApiKey
|
|
5
|
+
* @param {*} hashToPin
|
|
6
|
+
* @param {*} options
|
|
7
|
+
* @returns {Promise<unknown>}
|
|
8
|
+
*/
|
|
9
|
+
export default function pinByHash(pinataApiKey: string, pinataSecretApiKey: string, hashToPin: any, options: any): Promise<unknown>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pin File to IPFS
|
|
3
|
+
* @param {string} pinataApiKey
|
|
4
|
+
* @param {string} pinataSecretApiKey
|
|
5
|
+
* @param {*} readStream
|
|
6
|
+
* @param {*} options
|
|
7
|
+
* @returns {Promise<unknown>}
|
|
8
|
+
*/
|
|
9
|
+
export default function pinFileToIPFS(pinataApiKey: string, pinataSecretApiKey: string, readStream: any, options: any): Promise<unknown>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PinFromFS
|
|
3
|
+
* @param {string} pinataApiKey
|
|
4
|
+
* @param {string} pinataSecretApiKey
|
|
5
|
+
* @param {string} sourcePath
|
|
6
|
+
* @param {*} options
|
|
7
|
+
* @returns {Promise<unknown>}
|
|
8
|
+
*/
|
|
9
|
+
export default function pinFromFS(pinataApiKey: string, pinataSecretApiKey: string, sourcePath: string, options: any): Promise<unknown>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pin JSON to IPFS
|
|
3
|
+
* @param {string} pinataApiKey
|
|
4
|
+
* @param {string} pinataSecretApiKey
|
|
5
|
+
* @param {*} body
|
|
6
|
+
* @param {*} options
|
|
7
|
+
* @returns {Promise<unknown>}
|
|
8
|
+
*/
|
|
9
|
+
export default function pinJSONToIPFS(pinataApiKey: string, pinataSecretApiKey: string, body: any, options: any): Promise<unknown>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unpin
|
|
3
|
+
* @param {string} pinataApiKey
|
|
4
|
+
* @param {string} pinataSecretApiKey
|
|
5
|
+
* @param {string} hashToUnpin
|
|
6
|
+
* @returns {Promise<unknown>}
|
|
7
|
+
*/
|
|
8
|
+
export default function unpin(pinataApiKey: string, pinataSecretApiKey: string, hashToUnpin: string): Promise<unknown>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User Pin Policy
|
|
3
|
+
* @param {string} pinataApiKey
|
|
4
|
+
* @param {string} pinataSecretApiKey
|
|
5
|
+
* @param {*} newPinPolicy
|
|
6
|
+
* @returns {Promise<unknown>}
|
|
7
|
+
*/
|
|
8
|
+
export default function userPinPolicy(pinataApiKey: string, pinataSecretApiKey: string, newPinPolicy: any): Promise<unknown>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const baseUrl: "https://api.pinata.cloud";
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Record<string, string | number | null>} PinataMetadata
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @typedef PinataMetadataFilter
|
|
6
|
+
* @property {string} [name]
|
|
7
|
+
* @property {Record<string, {value: string, op: string}>} keyvalues
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {{id: string, desiredReplicationCount: number}} PinataPinPolicyItem
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* @typedef PinataPinByHashOptions
|
|
14
|
+
* @property {string[]} [hostNodes]
|
|
15
|
+
* @property {{regions: PinataPinPolicyItem[]}} [customPinPolicy]
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* @typedef PinataPinByHashPinOptions
|
|
19
|
+
* @property {PinataMetadata} [pinataMetadata]
|
|
20
|
+
* @property {PinataPinByHashOptions} [pinataOptions]
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* @typedef PinataOptions
|
|
24
|
+
* @property {0 | 1} [cidVersion]
|
|
25
|
+
* @property {boolean} [wrapWithDirectory]
|
|
26
|
+
* @property {{regions: PinataPinPolicyItem[]}} [customPinPolicy]
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* @typedef PinataPinOptions
|
|
30
|
+
* @property {PinataMetadata} [pinataMetadata]
|
|
31
|
+
* @property {PinataOptions} [pinataOptions]
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* @typedef PinataPinJobsFilterOptions
|
|
35
|
+
* @property {'ASC' | 'DESC'} sort
|
|
36
|
+
* @property {string} [status]
|
|
37
|
+
* @property {string} [ipfs_pin_hash]
|
|
38
|
+
* @property {number} [limit]
|
|
39
|
+
* @property {number} [offset]
|
|
40
|
+
*/
|
|
41
|
+
/**
|
|
42
|
+
* @typedef PinataPinListFilterOptions
|
|
43
|
+
* @property {string} [hashContains]
|
|
44
|
+
* @property {string} [pinStart]
|
|
45
|
+
* @property {string} [pinEnd]
|
|
46
|
+
* @property {string} [unpinStart]
|
|
47
|
+
* @property {string} [unpinEnd]
|
|
48
|
+
* @property {number} [pinSizeMin]
|
|
49
|
+
* @property {number} [pinSizeMax]
|
|
50
|
+
* @property {string} [status]
|
|
51
|
+
* @property {number} [pageLimit]
|
|
52
|
+
* @property {number} [pageOffset]
|
|
53
|
+
* @property {PinataMetadataFilter} [metadata]
|
|
54
|
+
*/
|
|
55
|
+
/**
|
|
56
|
+
* @typedef PinataPinByHashResponse
|
|
57
|
+
* @property {number | string} id
|
|
58
|
+
* @property {string} ipfsHash
|
|
59
|
+
* @property {string} status
|
|
60
|
+
* @property {string} name
|
|
61
|
+
*/
|
|
62
|
+
/**
|
|
63
|
+
* @typedef PinataPinResponse
|
|
64
|
+
* @property {string} IpfsHash
|
|
65
|
+
* @property {number} PinSize
|
|
66
|
+
* @property {string} Timestamp
|
|
67
|
+
*/
|
|
68
|
+
/**
|
|
69
|
+
* @typedef PinataPinJobsResponseRow
|
|
70
|
+
* @property {number | string} id
|
|
71
|
+
* @property {string} ipfs_pin_hash
|
|
72
|
+
* @property {string} date_queued
|
|
73
|
+
* @property {string | undefined | null} name
|
|
74
|
+
* @property {string} status
|
|
75
|
+
*/
|
|
76
|
+
/**
|
|
77
|
+
* @typedef PinataPinJobsResponse
|
|
78
|
+
* @property {number} count
|
|
79
|
+
* @property {PinataPinJobsResponseRow[]} rows
|
|
80
|
+
*/
|
|
81
|
+
/**
|
|
82
|
+
* @typedef PinataPinListResponseRow
|
|
83
|
+
* @property {number | string} id
|
|
84
|
+
* @property {string} ipfs_pin_hash
|
|
85
|
+
* @property {number} size
|
|
86
|
+
* @property {string | number} user_id
|
|
87
|
+
* @property {string} date_pinned
|
|
88
|
+
* @property {string} date_unpinned
|
|
89
|
+
* @property {PinataMetadata} metadata
|
|
90
|
+
*/
|
|
91
|
+
/**
|
|
92
|
+
* @typedef PinataPinListResponse
|
|
93
|
+
* @property {number} count
|
|
94
|
+
* @property {PinataPinListResponseRow[]} rows
|
|
95
|
+
*/
|
|
96
|
+
/**
|
|
97
|
+
* Hash meta data
|
|
98
|
+
* @callback hashMetadata
|
|
99
|
+
* @param {string} ipfsPinHash
|
|
100
|
+
* @param {PinataMetadata} metadata
|
|
101
|
+
* @returns {Promise<any>}
|
|
102
|
+
*/
|
|
103
|
+
/**
|
|
104
|
+
* Hash pin policy
|
|
105
|
+
* @callback hashPinPolicy
|
|
106
|
+
* @param {string} ipfsPinHash
|
|
107
|
+
* @param {{regions: PinataPinPolicyItem[]}} newPinPolicy
|
|
108
|
+
* @returns {Promise<any>}
|
|
109
|
+
*/
|
|
110
|
+
/**
|
|
111
|
+
* Pin by hash
|
|
112
|
+
* @callback pinByHash
|
|
113
|
+
* @param {string} hashToPin
|
|
114
|
+
* @param {PinataPinByHashPinOptions} [options]
|
|
115
|
+
* @returns {Promise<PinataPinByHashResponse>}
|
|
116
|
+
*/
|
|
117
|
+
/**
|
|
118
|
+
* Pin file to IPFS
|
|
119
|
+
* @callback pinFileToIPFS
|
|
120
|
+
* @param {ReadStream} readableStream
|
|
121
|
+
* @param {PinataPinOptions} [options]
|
|
122
|
+
* @returns {Promise<PinataPinResponse>}
|
|
123
|
+
*/
|
|
124
|
+
/**
|
|
125
|
+
* Pin from FS
|
|
126
|
+
* @callback pinFromFS
|
|
127
|
+
* @param {string} sourcePath
|
|
128
|
+
* @param {PinataPinOptions} [options]
|
|
129
|
+
* @returns {Promise<PinataPinResponse>}
|
|
130
|
+
*/
|
|
131
|
+
/**
|
|
132
|
+
* Pin Jobs
|
|
133
|
+
* @callback pinJobs
|
|
134
|
+
* @param {PinataPinJobsFilterOptions} [filters]
|
|
135
|
+
* @returns {Promise<PinataPinJobsResponse>}
|
|
136
|
+
*/
|
|
137
|
+
/**
|
|
138
|
+
* Pin JSON to IPFS
|
|
139
|
+
* @callback pinJSONToIPFS
|
|
140
|
+
* @param {Object} body
|
|
141
|
+
* @param {PinataPinOptions} [options]
|
|
142
|
+
* @returns {Promise<PinataPinResponse>}
|
|
143
|
+
*/
|
|
144
|
+
/**
|
|
145
|
+
* Unpin
|
|
146
|
+
* @callback unpin
|
|
147
|
+
* @param {string} hashToUnpin
|
|
148
|
+
* @returns {Promise<any>}
|
|
149
|
+
*/
|
|
150
|
+
/**
|
|
151
|
+
* User Pin Policy
|
|
152
|
+
* @callback userPinPolicy
|
|
153
|
+
* @param {{regions: PinataPinPolicyItem[]}} newPinPolicy
|
|
154
|
+
* @returns {Promise<any>}
|
|
155
|
+
*/
|
|
156
|
+
/**
|
|
157
|
+
* Test Authentication
|
|
158
|
+
* @callback testAuthentication
|
|
159
|
+
* @returns {Promise<{authenticated: boolean}>}
|
|
160
|
+
*/
|
|
161
|
+
/**
|
|
162
|
+
* Pin List
|
|
163
|
+
* @callback pinList
|
|
164
|
+
* @param {PinataPinListFilterOptions} [filters]
|
|
165
|
+
* @returns {Promise<PinataPinListResponse>}
|
|
166
|
+
*/
|
|
167
|
+
/**
|
|
168
|
+
* User Pinned Data Total
|
|
169
|
+
* @callback userPinnedDataTotal
|
|
170
|
+
* @returns {Promise<number>}
|
|
171
|
+
*/
|
|
172
|
+
/**
|
|
173
|
+
* @typedef PinataClient
|
|
174
|
+
* @property {pinByHash} pinByHash
|
|
175
|
+
* @property {hashMetadata} hashMetadata
|
|
176
|
+
* @property {hashPinPolicy} hashPinPolicy
|
|
177
|
+
* @property {pinFileToIPFS} pinFileToIPFS
|
|
178
|
+
* @property {pinFromFS} pinFromFS
|
|
179
|
+
* @property {pinJSONToIPFS} pinJSONToIPFS
|
|
180
|
+
* @property {pinJobs} pinJobs
|
|
181
|
+
* @property {unpin} unpin
|
|
182
|
+
* @property {userPinPolicy} userPinPolicy
|
|
183
|
+
* @property {testAuthentication} testAuthentication
|
|
184
|
+
* @property {pinList} pinList
|
|
185
|
+
* @property {userPinnedDataTotal} userPinnedDataTotal
|
|
186
|
+
*/
|
|
187
|
+
/**
|
|
188
|
+
* Pinata Client
|
|
189
|
+
*
|
|
190
|
+
* @param {string} pinataApiKey
|
|
191
|
+
* @param {string} pinataSecretApiKey
|
|
192
|
+
* @returns {PinataClient}
|
|
193
|
+
*/
|
|
194
|
+
export default function pinataClient(pinataApiKey: string, pinataSecretApiKey: string): PinataClient;
|
|
195
|
+
export type PinataMetadata = Record<string, string | number | null>;
|
|
196
|
+
export type PinataMetadataFilter = {
|
|
197
|
+
name?: string | undefined;
|
|
198
|
+
keyvalues: Record<string, {
|
|
199
|
+
value: string;
|
|
200
|
+
op: string;
|
|
201
|
+
}>;
|
|
202
|
+
};
|
|
203
|
+
export type PinataPinPolicyItem = {
|
|
204
|
+
id: string;
|
|
205
|
+
desiredReplicationCount: number;
|
|
206
|
+
};
|
|
207
|
+
export type PinataPinByHashOptions = {
|
|
208
|
+
hostNodes?: string[] | undefined;
|
|
209
|
+
customPinPolicy?: {
|
|
210
|
+
regions: PinataPinPolicyItem[];
|
|
211
|
+
} | undefined;
|
|
212
|
+
};
|
|
213
|
+
export type PinataPinByHashPinOptions = {
|
|
214
|
+
pinataMetadata?: Record<string, string | number | null> | undefined;
|
|
215
|
+
pinataOptions?: PinataPinByHashOptions | undefined;
|
|
216
|
+
};
|
|
217
|
+
export type PinataOptions = {
|
|
218
|
+
cidVersion?: 0 | 1 | undefined;
|
|
219
|
+
wrapWithDirectory?: boolean | undefined;
|
|
220
|
+
customPinPolicy?: {
|
|
221
|
+
regions: PinataPinPolicyItem[];
|
|
222
|
+
} | undefined;
|
|
223
|
+
};
|
|
224
|
+
export type PinataPinOptions = {
|
|
225
|
+
pinataMetadata?: Record<string, string | number | null> | undefined;
|
|
226
|
+
pinataOptions?: PinataOptions | undefined;
|
|
227
|
+
};
|
|
228
|
+
export type PinataPinJobsFilterOptions = {
|
|
229
|
+
sort: 'ASC' | 'DESC';
|
|
230
|
+
status?: string | undefined;
|
|
231
|
+
ipfs_pin_hash?: string | undefined;
|
|
232
|
+
limit?: number | undefined;
|
|
233
|
+
offset?: number | undefined;
|
|
234
|
+
};
|
|
235
|
+
export type PinataPinListFilterOptions = {
|
|
236
|
+
hashContains?: string | undefined;
|
|
237
|
+
pinStart?: string | undefined;
|
|
238
|
+
pinEnd?: string | undefined;
|
|
239
|
+
unpinStart?: string | undefined;
|
|
240
|
+
unpinEnd?: string | undefined;
|
|
241
|
+
pinSizeMin?: number | undefined;
|
|
242
|
+
pinSizeMax?: number | undefined;
|
|
243
|
+
status?: string | undefined;
|
|
244
|
+
pageLimit?: number | undefined;
|
|
245
|
+
pageOffset?: number | undefined;
|
|
246
|
+
metadata?: PinataMetadataFilter | undefined;
|
|
247
|
+
};
|
|
248
|
+
export type PinataPinByHashResponse = {
|
|
249
|
+
id: number | string;
|
|
250
|
+
ipfsHash: string;
|
|
251
|
+
status: string;
|
|
252
|
+
name: string;
|
|
253
|
+
};
|
|
254
|
+
export type PinataPinResponse = {
|
|
255
|
+
IpfsHash: string;
|
|
256
|
+
PinSize: number;
|
|
257
|
+
Timestamp: string;
|
|
258
|
+
};
|
|
259
|
+
export type PinataPinJobsResponseRow = {
|
|
260
|
+
id: number | string;
|
|
261
|
+
ipfs_pin_hash: string;
|
|
262
|
+
date_queued: string;
|
|
263
|
+
name: string | undefined | null;
|
|
264
|
+
status: string;
|
|
265
|
+
};
|
|
266
|
+
export type PinataPinJobsResponse = {
|
|
267
|
+
count: number;
|
|
268
|
+
rows: PinataPinJobsResponseRow[];
|
|
269
|
+
};
|
|
270
|
+
export type PinataPinListResponseRow = {
|
|
271
|
+
id: number | string;
|
|
272
|
+
ipfs_pin_hash: string;
|
|
273
|
+
size: number;
|
|
274
|
+
user_id: string | number;
|
|
275
|
+
date_pinned: string;
|
|
276
|
+
date_unpinned: string;
|
|
277
|
+
metadata: PinataMetadata;
|
|
278
|
+
};
|
|
279
|
+
export type PinataPinListResponse = {
|
|
280
|
+
count: number;
|
|
281
|
+
rows: PinataPinListResponseRow[];
|
|
282
|
+
};
|
|
283
|
+
/**
|
|
284
|
+
* Hash meta data
|
|
285
|
+
*/
|
|
286
|
+
export type hashMetadata = (ipfsPinHash: string, metadata: PinataMetadata) => Promise<any>;
|
|
287
|
+
/**
|
|
288
|
+
* Hash pin policy
|
|
289
|
+
*/
|
|
290
|
+
export type hashPinPolicy = (ipfsPinHash: string, newPinPolicy: {
|
|
291
|
+
regions: PinataPinPolicyItem[];
|
|
292
|
+
}) => Promise<any>;
|
|
293
|
+
/**
|
|
294
|
+
* Pin by hash
|
|
295
|
+
*/
|
|
296
|
+
export type pinByHash = (hashToPin: string, options?: PinataPinByHashPinOptions | undefined) => Promise<PinataPinByHashResponse>;
|
|
297
|
+
/**
|
|
298
|
+
* Pin file to IPFS
|
|
299
|
+
*/
|
|
300
|
+
export type pinFileToIPFS = (readableStream: any, options?: PinataPinOptions | undefined) => Promise<PinataPinResponse>;
|
|
301
|
+
/**
|
|
302
|
+
* Pin from FS
|
|
303
|
+
*/
|
|
304
|
+
export type pinFromFS = (sourcePath: string, options?: PinataPinOptions | undefined) => Promise<PinataPinResponse>;
|
|
305
|
+
/**
|
|
306
|
+
* Pin Jobs
|
|
307
|
+
*/
|
|
308
|
+
export type pinJobs = (filters?: PinataPinJobsFilterOptions | undefined) => Promise<PinataPinJobsResponse>;
|
|
309
|
+
/**
|
|
310
|
+
* Pin JSON to IPFS
|
|
311
|
+
*/
|
|
312
|
+
export type pinJSONToIPFS = (body: Object, options?: PinataPinOptions | undefined) => Promise<PinataPinResponse>;
|
|
313
|
+
/**
|
|
314
|
+
* Unpin
|
|
315
|
+
*/
|
|
316
|
+
export type unpin = (hashToUnpin: string) => Promise<any>;
|
|
317
|
+
/**
|
|
318
|
+
* User Pin Policy
|
|
319
|
+
*/
|
|
320
|
+
export type userPinPolicy = (newPinPolicy: {
|
|
321
|
+
regions: PinataPinPolicyItem[];
|
|
322
|
+
}) => Promise<any>;
|
|
323
|
+
/**
|
|
324
|
+
* Test Authentication
|
|
325
|
+
*/
|
|
326
|
+
export type testAuthentication = () => Promise<{
|
|
327
|
+
authenticated: boolean;
|
|
328
|
+
}>;
|
|
329
|
+
/**
|
|
330
|
+
* Pin List
|
|
331
|
+
*/
|
|
332
|
+
export type pinList = (filters?: PinataPinListFilterOptions | undefined) => Promise<PinataPinListResponse>;
|
|
333
|
+
/**
|
|
334
|
+
* User Pinned Data Total
|
|
335
|
+
*/
|
|
336
|
+
export type userPinnedDataTotal = () => Promise<number>;
|
|
337
|
+
export type PinataClient = {
|
|
338
|
+
pinByHash: pinByHash;
|
|
339
|
+
hashMetadata: hashMetadata;
|
|
340
|
+
hashPinPolicy: hashPinPolicy;
|
|
341
|
+
pinFileToIPFS: pinFileToIPFS;
|
|
342
|
+
pinFromFS: pinFromFS;
|
|
343
|
+
pinJSONToIPFS: pinJSONToIPFS;
|
|
344
|
+
pinJobs: pinJobs;
|
|
345
|
+
unpin: unpin;
|
|
346
|
+
userPinPolicy: userPinPolicy;
|
|
347
|
+
testAuthentication: testAuthentication;
|
|
348
|
+
pinList: pinList;
|
|
349
|
+
userPinnedDataTotal: userPinnedDataTotal;
|
|
350
|
+
};
|
|
351
|
+
import pinByHash from "./commands/pinning/pinByHash";
|
|
352
|
+
import hashMetadata from "./commands/pinning/hashMetadata";
|
|
353
|
+
import hashPinPolicy from "./commands/pinning/hashPinPolicy";
|
|
354
|
+
import pinFileToIPFS from "./commands/pinning/pinFileToIPFS";
|
|
355
|
+
import pinFromFS from "./commands/pinning/pinFromFS";
|
|
356
|
+
import pinJSONToIPFS from "./commands/pinning/pinJSONToIPFS";
|
|
357
|
+
import pinJobs from "./commands/pinning/pinJobs/pinJobs";
|
|
358
|
+
import unpin from "./commands/pinning/unpin";
|
|
359
|
+
import userPinPolicy from "./commands/pinning/userPinPolicy";
|
|
360
|
+
import testAuthentication from "./commands/data/testAuthentication";
|
|
361
|
+
import pinList from "./commands/data/pinList/pinList";
|
|
362
|
+
import userPinnedDataTotal from "./commands/data/userPinnedDataTotal";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function handleError(error: any): any;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validate API Keys
|
|
3
|
+
* @param {string} pinataApiKey
|
|
4
|
+
* @param {string} pinataSecretApiKey
|
|
5
|
+
*/
|
|
6
|
+
export function validateApiKeys(pinataApiKey: string, pinataSecretApiKey: string): void;
|
|
7
|
+
/**
|
|
8
|
+
* Validate host Nodes
|
|
9
|
+
* @param {*} hostNodes
|
|
10
|
+
*/
|
|
11
|
+
export function validateHostNodes(hostNodes: any): void;
|
|
12
|
+
/**
|
|
13
|
+
* Validate MetaData
|
|
14
|
+
* @param {*} metadata
|
|
15
|
+
*/
|
|
16
|
+
export function validateMetadata(metadata: any): void;
|
|
17
|
+
/**
|
|
18
|
+
* Validate Pin Policy Structure
|
|
19
|
+
* @param {*} pinPolicy
|
|
20
|
+
*/
|
|
21
|
+
export function validatePinPolicyStructure(pinPolicy: any): void;
|
|
22
|
+
/**
|
|
23
|
+
* Validate Pinata Options
|
|
24
|
+
* @param {*} options
|
|
25
|
+
*/
|
|
26
|
+
export function validatePinataOptions(options: any): void;
|