@pinata/sdk 1.1.23 → 1.1.26
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 +2 -108
- package/lib/pinata-sdk.js +6 -183
- package/lib/pinata-sdk.min.js +5 -5
- package/package.json +1 -1
- package/src/commands/pinning/pinFileToIPFS.js +3 -3
- package/src/index.js +0 -25
- package/test/commands/pinning/pinFileToIPFS.test.js +16 -3
- package/types/index.d.ts +0 -31
package/README.md
CHANGED
|
@@ -36,7 +36,6 @@ Once you've set up your instance, using the Pinata SDK is easy. Simply call your
|
|
|
36
36
|
|
|
37
37
|
* Pinning
|
|
38
38
|
* [hashMetadata](#hashMetadata-anchor)
|
|
39
|
-
* [hashPinPolicy](#hashPinPolicy-anchor)
|
|
40
39
|
* [pinByHash](#pinByHash-anchor)
|
|
41
40
|
* [pinFileToIPFS](#pinFileToIPFS-anchor)
|
|
42
41
|
* [pinFromFS](#pinFromFS-anchor)
|
|
@@ -102,46 +101,6 @@ pinata.hashMetadata('yourHashHere', metadata).then((result) => {
|
|
|
102
101
|
});
|
|
103
102
|
```
|
|
104
103
|
|
|
105
|
-
|
|
106
|
-
<a name="hashPinPolicy-anchor"></a>
|
|
107
|
-
### `hashPinPolicy`
|
|
108
|
-
Allows the user to change the pin policy for an individual piece of content.
|
|
109
|
-
Changes made via this endpoint only affect the content for the hash passed in. They do not affect a user's account level pin policy.
|
|
110
|
-
|
|
111
|
-
To read more about pin policies, please check out the [Regions and Replications Documentation](https://pinata.cloud/documentation#RegionsAndReplications).
|
|
112
|
-
|
|
113
|
-
##### `pinata.hashPinPolicy(ipfsPinHash, newPinPolicy)`
|
|
114
|
-
##### Params
|
|
115
|
-
* `ipfsPinHash` - A string for a valid IPFS Hash that you have pinned on Pinata.
|
|
116
|
-
* `newPinPolicy` A JSON object with a new [Pin Policy](#pinPolicies-anchor) for the hash.
|
|
117
|
-
|
|
118
|
-
#### Response
|
|
119
|
-
If the operation is successful, you will receive back an "OK" REST 200 status.
|
|
120
|
-
|
|
121
|
-
##### Example Code
|
|
122
|
-
```javascript
|
|
123
|
-
const newPinPolicy = {
|
|
124
|
-
regions: [
|
|
125
|
-
{
|
|
126
|
-
id: 'FRA1',
|
|
127
|
-
desiredReplicationCount: 2
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
id: 'NYC1',
|
|
131
|
-
desiredReplicationCount: 2
|
|
132
|
-
}
|
|
133
|
-
]
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
pinata.hashPinPolicy('yourHashHere', newPinPolicy).then((result) => {
|
|
137
|
-
//handle results here
|
|
138
|
-
console.log(result);
|
|
139
|
-
}).catch((err) => {
|
|
140
|
-
//handle error here
|
|
141
|
-
console.log(err);
|
|
142
|
-
});
|
|
143
|
-
```
|
|
144
|
-
|
|
145
104
|
<a name="pinByHash-anchor"></a>
|
|
146
105
|
### `pinByHash`
|
|
147
106
|
Adds a hash to Pinata's pin queue to be pinned asynchronously. For the synchronous version of this operation see: [pinHashToIPFS](#pinHashToIPFS-anchor)
|
|
@@ -153,7 +112,6 @@ Adds a hash to Pinata's pin queue to be pinned asynchronously. For the synchrono
|
|
|
153
112
|
* `pinataMetadata` (optional): A JSON object with [optional metadata](#metadata-anchor) for the hash being pinned
|
|
154
113
|
* `pinataOptions`
|
|
155
114
|
* `hostNodes` (optional): An array of [multiaddresses for nodes](#hostNode-anchor) that are currently hosting the content to be pinned
|
|
156
|
-
* `customPinPolicy` A JSON object with a new [Pin Policy](#pinPolicies-anchor) for the hash.
|
|
157
115
|
#### Response
|
|
158
116
|
```
|
|
159
117
|
{
|
|
@@ -177,19 +135,7 @@ const options = {
|
|
|
177
135
|
hostNodes: [
|
|
178
136
|
'/ip4/hostNode1ExternalIP/tcp/4001/ipfs/hostNode1PeerId',
|
|
179
137
|
'/ip4/hostNode2ExternalIP/tcp/4001/ipfs/hostNode2PeerId'
|
|
180
|
-
]
|
|
181
|
-
customPinPolicy: {
|
|
182
|
-
regions: [
|
|
183
|
-
{
|
|
184
|
-
id: 'FRA1',
|
|
185
|
-
desiredReplicationCount: 1
|
|
186
|
-
},
|
|
187
|
-
{
|
|
188
|
-
id: 'NYC1',
|
|
189
|
-
desiredReplicationCount: 2
|
|
190
|
-
}
|
|
191
|
-
]
|
|
192
|
-
}
|
|
138
|
+
]
|
|
193
139
|
}
|
|
194
140
|
};
|
|
195
141
|
pinata.pinByHash('yourHashHere', options).then((result) => {
|
|
@@ -414,45 +360,6 @@ pinata.unpin(hashToUnpin).then((result) => {
|
|
|
414
360
|
});
|
|
415
361
|
```
|
|
416
362
|
|
|
417
|
-
<a name="userPinPolicy-anchor"></a>
|
|
418
|
-
### `userPinPolicy`
|
|
419
|
-
This allows the sender to change the pin policy their account.
|
|
420
|
-
|
|
421
|
-
Following a successful call of this endpoint, the new pin policy provided will be utilized for every new piece of content pinned to IPFS via Pinata.
|
|
422
|
-
|
|
423
|
-
To read more about pin policies, please check out the [Regions and Replications Documentation](https://pinata.cloud/documentation#RegionsAndReplications).
|
|
424
|
-
|
|
425
|
-
##### `pinata.userPinPolicy(newPinPolicy)`
|
|
426
|
-
##### Params
|
|
427
|
-
* `newPinPolicy` A JSON object with a new [Pin Policy](#pinPolicies-anchor) for the hash.
|
|
428
|
-
|
|
429
|
-
#### Response
|
|
430
|
-
If the operation is successful, you will receive back an "OK" REST 200 status.
|
|
431
|
-
|
|
432
|
-
##### Example Code
|
|
433
|
-
```javascript
|
|
434
|
-
const newPinPolicy = {
|
|
435
|
-
regions: [
|
|
436
|
-
{
|
|
437
|
-
id: 'FRA1',
|
|
438
|
-
desiredReplicationCount: 2
|
|
439
|
-
},
|
|
440
|
-
{
|
|
441
|
-
id: 'NYC1',
|
|
442
|
-
desiredReplicationCount: 2
|
|
443
|
-
}
|
|
444
|
-
]
|
|
445
|
-
}
|
|
446
|
-
};
|
|
447
|
-
pinata.userPinPolicy(newPinPolicy).then((result) => {
|
|
448
|
-
//handle results here
|
|
449
|
-
console.log(result);
|
|
450
|
-
}).catch((err) => {
|
|
451
|
-
//handle error here
|
|
452
|
-
console.log(err);
|
|
453
|
-
});
|
|
454
|
-
```
|
|
455
|
-
|
|
456
363
|
<a name="testAuthentication-anchor"></a>
|
|
457
364
|
### `testAuthentication`
|
|
458
365
|
Tests that you can authenticate with Pinata correctly
|
|
@@ -724,26 +631,13 @@ The options object can consist of the following values:
|
|
|
724
631
|
* wrapWithDirectory (optional) - Tells IPFS to wrap your content in a directory to preserve the content's original name. See [this blog post](https://flyingzumwalt.gitbooks.io/decentralized-web-primer/content/files-on-ipfs/lessons/wrap-directories-around-content.html) for more details on what this does. Valid options are:
|
|
725
632
|
* `true`
|
|
726
633
|
* `false`
|
|
727
|
-
* customPinPolicy (optional) - a custom [Pin Policy](#pinPolicies-anchor) for the piece of content being pinned. Providing a custom pin policy as part of a request means that the content being pinned will be replicated differently from the user's default pin policy found under the [Account](https://pinata.cloud/account) page.
|
|
728
634
|
|
|
729
635
|
|
|
730
636
|
##### Example pinataOptions object
|
|
731
637
|
```
|
|
732
638
|
{
|
|
733
639
|
cidVersion: 1,
|
|
734
|
-
wrapWithDirectory: true
|
|
735
|
-
customPinPolicy: {
|
|
736
|
-
regions: [
|
|
737
|
-
{
|
|
738
|
-
id: 'FRA1',
|
|
739
|
-
desiredReplicationCount: 2
|
|
740
|
-
},
|
|
741
|
-
{
|
|
742
|
-
id: 'NYC1',
|
|
743
|
-
desiredReplicationCount: 2
|
|
744
|
-
}
|
|
745
|
-
]
|
|
746
|
-
}
|
|
640
|
+
wrapWithDirectory: true
|
|
747
641
|
}
|
|
748
642
|
```
|
|
749
643
|
|