@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.
Files changed (50) hide show
  1. package/README.md +21 -5
  2. package/lib/pinata-sdk.js +305 -155
  3. package/lib/pinata-sdk.min.js +5 -5
  4. package/package.json +1 -1
  5. package/src/commands/data/getFilesByCount/getFilesByCount.js +2 -5
  6. package/src/commands/data/pinList/pinList.js +4 -11
  7. package/src/commands/data/testAuthentication.js +4 -11
  8. package/src/commands/data/userPinnedDataTotal.js +4 -11
  9. package/src/commands/pinning/hashMetadata.js +4 -11
  10. package/src/commands/pinning/hashPinPolicy.js +4 -10
  11. package/src/commands/pinning/pinByHash.js +4 -11
  12. package/src/commands/pinning/pinFileToIPFS.js +5 -16
  13. package/src/commands/pinning/pinFromFS.js +6 -23
  14. package/src/commands/pinning/pinJSONToIPFS.js +4 -10
  15. package/src/commands/pinning/pinJobs/pinJobs.js +4 -10
  16. package/src/commands/pinning/unpin.js +4 -11
  17. package/src/commands/pinning/userPinPolicy.js +4 -10
  18. package/src/constants.js +3 -0
  19. package/src/index.js +60 -15
  20. package/src/util/validators.js +88 -12
  21. package/test/commands/data/getFilesByCount/getFilesByCount.test.js +17 -21
  22. package/test/commands/data/pinList/pinList.test.js +20 -15
  23. package/test/commands/data/testAuthentication.test.js +17 -13
  24. package/test/commands/data/userPinnedDataTotal.test.js +3 -3
  25. package/test/commands/pinning/hashMetadata.test.js +7 -7
  26. package/test/commands/pinning/hashPinPolicy.test.js +6 -6
  27. package/test/commands/pinning/pinByHash.test.js +4 -4
  28. package/test/commands/pinning/pinFileToIPFS.test.js +5 -5
  29. package/test/commands/pinning/pinFromFS.js +3 -3
  30. package/test/commands/pinning/pinJSONToIPFS.test.js +4 -4
  31. package/test/commands/pinning/pinJobs/pinJobs.test.js +3 -3
  32. package/test/commands/pinning/unpin.test.js +5 -5
  33. package/test/commands/pinning/userPinPolicy.test.js +51 -22
  34. package/test/util/validators.test.js +114 -72
  35. package/types/commands/data/getFilesByCount/getFilesByCount.d.ts +1 -1
  36. package/types/commands/data/pinList/pinList.d.ts +1 -1
  37. package/types/commands/data/testAuthentication.d.ts +1 -1
  38. package/types/commands/data/userPinnedDataTotal.d.ts +1 -1
  39. package/types/commands/pinning/hashMetadata.d.ts +1 -1
  40. package/types/commands/pinning/hashPinPolicy.d.ts +1 -1
  41. package/types/commands/pinning/pinByHash.d.ts +1 -1
  42. package/types/commands/pinning/pinFileToIPFS.d.ts +1 -1
  43. package/types/commands/pinning/pinFromFS.d.ts +1 -1
  44. package/types/commands/pinning/pinJSONToIPFS.d.ts +1 -1
  45. package/types/commands/pinning/pinJobs/pinJobs.d.ts +1 -1
  46. package/types/commands/pinning/unpin.d.ts +1 -1
  47. package/types/commands/pinning/userPinPolicy.d.ts +1 -1
  48. package/types/constants.d.ts +1 -0
  49. package/types/index.d.ts +9 -174
  50. package/types/util/validators.d.ts +34 -0
package/README.md CHANGED
@@ -14,12 +14,28 @@ npm install --save @pinata/sdk
14
14
  ```
15
15
 
16
16
  ## Setup
17
- To start, simply require the Pinata SDK and set up an instance with your Pinata API Keys. Don't know what your keys are? Check out your [Account Page](https://pinata.cloud/account).
17
+ To start, simply require the Pinata SDK and set up an instance with your Pinata API Keys or your JWT key. Don't know what your keys are? Check out your [Account Page](https://pinata.cloud/account).
18
+ In the example below we provided with 3 ways to call the pinata SDK.
19
+
18
20
  ```javascript
21
+ // Use the api keys by providing the strings directly
19
22
  const pinataSDK = require('@pinata/sdk');
20
23
  const pinata = pinataSDK('yourPinataApiKey', 'yourPinataSecretApiKey');
21
24
  ```
22
25
 
26
+ ```javascript
27
+ // Use the api keys by specifying your api key and api secret
28
+ const pinataSDK = require('@pinata/sdk');
29
+ const pinata = pinataSDK({ pinataApiKey: 'yourPinataApiKey', pinataSecretApiKey: 'yourPinataSecretApiKey' });
30
+
31
+ ```
32
+
33
+ ```javascript
34
+ // Use the JWT key
35
+ const pinataSDK = require('@pinata/sdk');
36
+ const pinata = pinataSDK({ pinataJWTKey: 'yourPinataJWTKey'});
37
+ ```
38
+
23
39
  Quickly test that you can connect to the API with the following call:
24
40
  ```javascript
25
41
  pinata.testAuthentication().then((result) => {
@@ -191,13 +207,13 @@ pinata.pinFileToIPFS(readableStreamForFile, options).then((result) => {
191
207
  });
192
208
  ```
193
209
 
194
- <a name="pinFromFs-anchor"></a>
210
+ <a name="pinFromFS-anchor"></a>
195
211
  ### `pinFromFS`
196
212
  Read from a location on your local file system and recursively pin the contents to IPFS (node.js only).
197
213
 
198
214
  Both individual files, as well as directories can be read from.
199
215
 
200
- ##### `pinata.pinFromFs(sourcePath, options)`
216
+ ##### `pinata.pinFromFS(sourcePath, options)`
201
217
  ##### Params
202
218
  * `sourcePath` - The location on your local filesystem that should be read from.
203
219
  * `options` (optional): A JSON object that can contain the following keyvalues:
@@ -468,7 +484,7 @@ Our libraries support auto-pagination. This feature easily handles fetching larg
468
484
  To use the auto-pagination feature in Node 10+, simply iterate over a "list" call with the parameters you need in a for await loop.
469
485
 
470
486
  <a name="getFilesByCount-anchor"></a>
471
- ### `getFilesByCount-anchor`
487
+ ### `getFilesByCount`
472
488
  This method support auto-pagination. This feature easily handles fetching large lists of pin records for your Pinata account without having to manually paginate results and perform subsequent requests. To use the auto-pagination feature in Node 10+.
473
489
 
474
490
  ##### `pinata.getFilesByCount(filters, count)`
@@ -537,7 +553,7 @@ Filter explanations:
537
553
  date_pinned: (This is the timestamp for when this content was pinned - represented in ISO 8601 format),
538
554
  date_unpinned: (This is the timestamp for when this content was unpinned (if null, then you still have the content pinned on Pinata),
539
555
  metadata: {
540
- name: (this will be the name of the file originally upuloaded, or the custom name you set),
556
+ name: (this will be the name of the file originally uploaded, or the custom name you set),
541
557
  keyvalues: {
542
558
  exampleCustomKey: "exampleCustomValue",
543
559
  exampleCustomKey2: "exampleCustomValue2",