@pinata/sdk 1.1.26 → 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/.babelrc +4 -3
- package/.nvmrc +1 -1
- package/README.md +103 -19
- package/lib/pinata-sdk.js +615 -157
- package/lib/pinata-sdk.min.js +5 -5
- package/package.json +3 -2
- package/src/commands/data/getFilesByCount/getFilesByCount.js +67 -0
- package/src/commands/data/pinList/pinList.js +6 -11
- package/src/commands/data/pinList/queryBuilder.js +4 -0
- 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 +63 -13
- package/src/util/validators.js +88 -12
- package/test/commands/data/getFilesByCount/getFilesByCount.test.js +211 -0
- package/test/commands/data/pinList/pinList.test.js +100 -26
- package/test/commands/data/pinlist-sample-api.js +540 -0
- 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 +12 -0
- package/types/commands/data/pinList/pinList.d.ts +2 -2
- 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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Pin List
|
|
3
3
|
* @param {string} pinataApiKey
|
|
4
4
|
* @param {string} pinataSecretApiKey
|
|
5
|
-
* @param {
|
|
5
|
+
* @param {any} filters
|
|
6
6
|
* @returns {Promise<unknown>}
|
|
7
7
|
*/
|
|
8
|
-
export default function pinList(
|
|
8
|
+
export default function pinList(config: any, filters?: any): Promise<unknown>;
|
|
@@ -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
package/types/index.d.ts
CHANGED
|
@@ -1,182 +1,11 @@
|
|
|
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
|
-
* Pin by hash
|
|
105
|
-
* @callback pinByHash
|
|
106
|
-
* @param {string} hashToPin
|
|
107
|
-
* @param {PinataPinByHashPinOptions} [options]
|
|
108
|
-
* @returns {Promise<PinataPinByHashResponse>}
|
|
109
|
-
*/
|
|
110
|
-
/**
|
|
111
|
-
* Pin file to IPFS
|
|
112
|
-
* @callback pinFileToIPFS
|
|
113
|
-
* @param {ReadStream} readableStream
|
|
114
|
-
* @param {PinataPinOptions} [options]
|
|
115
|
-
* @returns {Promise<PinataPinResponse>}
|
|
116
|
-
*/
|
|
117
|
-
/**
|
|
118
|
-
* Pin from FS
|
|
119
|
-
* @callback pinFromFS
|
|
120
|
-
* @param {string} sourcePath
|
|
121
|
-
* @param {PinataPinOptions} [options]
|
|
122
|
-
* @returns {Promise<PinataPinResponse>}
|
|
123
|
-
*/
|
|
124
|
-
/**
|
|
125
|
-
* Pin Jobs
|
|
126
|
-
* @callback pinJobs
|
|
127
|
-
* @param {PinataPinJobsFilterOptions} [filters]
|
|
128
|
-
* @returns {Promise<PinataPinJobsResponse>}
|
|
129
|
-
*/
|
|
130
|
-
/**
|
|
131
|
-
* Pin JSON to IPFS
|
|
132
|
-
* @callback pinJSONToIPFS
|
|
133
|
-
* @param {Object} body
|
|
134
|
-
* @param {PinataPinOptions} [options]
|
|
135
|
-
* @returns {Promise<PinataPinResponse>}
|
|
136
|
-
*/
|
|
137
|
-
/**
|
|
138
|
-
* Unpin
|
|
139
|
-
* @callback unpin
|
|
140
|
-
* @param {string} hashToUnpin
|
|
141
|
-
* @returns {Promise<any>}
|
|
142
|
-
*/
|
|
143
|
-
/**
|
|
144
|
-
* Test Authentication
|
|
145
|
-
* @callback testAuthentication
|
|
146
|
-
* @returns {Promise<{authenticated: boolean}>}
|
|
147
|
-
*/
|
|
148
|
-
/**
|
|
149
|
-
* Pin List
|
|
150
|
-
* @callback pinList
|
|
151
|
-
* @param {PinataPinListFilterOptions} [filters]
|
|
152
|
-
* @returns {Promise<PinataPinListResponse>}
|
|
153
|
-
*/
|
|
154
|
-
/**
|
|
155
|
-
* User Pinned Data Total
|
|
156
|
-
* @callback userPinnedDataTotal
|
|
157
|
-
* @returns {Promise<number>}
|
|
158
|
-
*/
|
|
159
|
-
/**
|
|
160
|
-
* @typedef PinataClient
|
|
161
|
-
* @property {pinByHash} pinByHash
|
|
162
|
-
* @property {hashMetadata} hashMetadata
|
|
163
|
-
* @property {pinFileToIPFS} pinFileToIPFS
|
|
164
|
-
* @property {pinFromFS} pinFromFS
|
|
165
|
-
* @property {pinJSONToIPFS} pinJSONToIPFS
|
|
166
|
-
* @property {pinJobs} pinJobs
|
|
167
|
-
* @property {unpin} unpin
|
|
168
|
-
* @property {testAuthentication} testAuthentication
|
|
169
|
-
* @property {pinList} pinList
|
|
170
|
-
* @property {userPinnedDataTotal} userPinnedDataTotal
|
|
171
|
-
*/
|
|
172
1
|
/**
|
|
173
2
|
* Pinata Client
|
|
174
3
|
*
|
|
175
|
-
* @param {string} pinataApiKey
|
|
176
|
-
* @param {string} pinataSecretApiKey
|
|
4
|
+
* @param {string | PinataConfig} [pinataApiKey]
|
|
5
|
+
* @param {string} [pinataSecretApiKey]
|
|
177
6
|
* @returns {PinataClient}
|
|
178
7
|
*/
|
|
179
|
-
export default function pinataClient(pinataApiKey
|
|
8
|
+
export default function pinataClient(pinataApiKey?: string | PinataConfig | undefined, pinataSecretApiKey?: string | undefined): PinataClient;
|
|
180
9
|
export type PinataMetadata = Record<string, string | number | null>;
|
|
181
10
|
export type PinataMetadataFilter = {
|
|
182
11
|
name?: string | undefined;
|
|
@@ -307,7 +136,13 @@ export type pinList = (filters?: PinataPinListFilterOptions | undefined) => Prom
|
|
|
307
136
|
* User Pinned Data Total
|
|
308
137
|
*/
|
|
309
138
|
export type userPinnedDataTotal = () => Promise<number>;
|
|
139
|
+
export type PinataConfig = {
|
|
140
|
+
pinataApiKey?: string | undefined;
|
|
141
|
+
pinataSecretApiKey?: string | undefined;
|
|
142
|
+
pinataJWTKey?: string | undefined;
|
|
143
|
+
};
|
|
310
144
|
export type PinataClient = {
|
|
145
|
+
config: PinataConfig;
|
|
311
146
|
pinByHash: pinByHash;
|
|
312
147
|
hashMetadata: hashMetadata;
|
|
313
148
|
pinFileToIPFS: pinFileToIPFS;
|
|
@@ -4,6 +4,40 @@
|
|
|
4
4
|
* @param {string} pinataSecretApiKey
|
|
5
5
|
*/
|
|
6
6
|
export function validateApiKeys(pinataApiKey: string, pinataSecretApiKey: string): void;
|
|
7
|
+
export function createConfigForAxiosHeaders(config: any): {
|
|
8
|
+
withCredentials: boolean;
|
|
9
|
+
headers: {
|
|
10
|
+
pinata_api_key: any;
|
|
11
|
+
pinata_secret_api_key: any;
|
|
12
|
+
Authorization?: undefined;
|
|
13
|
+
};
|
|
14
|
+
} | {
|
|
15
|
+
headers: {
|
|
16
|
+
Authorization: string;
|
|
17
|
+
pinata_api_key?: undefined;
|
|
18
|
+
pinata_secret_api_key?: undefined;
|
|
19
|
+
};
|
|
20
|
+
withCredentials?: undefined;
|
|
21
|
+
};
|
|
22
|
+
export function createConfigForAxiosHeadersWithFormData(config: any, boundaryValue: any): {
|
|
23
|
+
maxContentLength: number;
|
|
24
|
+
maxBodyLength: number;
|
|
25
|
+
withCredentials: boolean;
|
|
26
|
+
headers: {
|
|
27
|
+
pinata_api_key: any;
|
|
28
|
+
pinata_secret_api_key: any;
|
|
29
|
+
Authorization?: undefined;
|
|
30
|
+
};
|
|
31
|
+
} | {
|
|
32
|
+
maxContentLength: number;
|
|
33
|
+
maxBodyLength: number;
|
|
34
|
+
headers: {
|
|
35
|
+
Authorization: string;
|
|
36
|
+
pinata_api_key?: undefined;
|
|
37
|
+
pinata_secret_api_key?: undefined;
|
|
38
|
+
};
|
|
39
|
+
withCredentials?: undefined;
|
|
40
|
+
};
|
|
7
41
|
/**
|
|
8
42
|
* Validate host Nodes
|
|
9
43
|
* @param {*} hostNodes
|