@pinata/sdk 2.1.0 → 3.0.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 (81) hide show
  1. package/LICENSE +1 -2
  2. package/README.md +59 -694
  3. package/index.d.ts +9 -0
  4. package/index.js +6 -0
  5. package/index.mjs +4 -0
  6. package/legacy.js +15 -0
  7. package/package.json +62 -83
  8. package/react/index.d.ts +1 -0
  9. package/react/index.js +3 -0
  10. package/react/index.mjs +1 -0
  11. package/.babelrc +0 -5
  12. package/.editorconfig +0 -12
  13. package/.eslintrc +0 -173
  14. package/.husky/pre-commit +0 -6
  15. package/.nvmrc +0 -1
  16. package/.travis.yml +0 -5
  17. package/lib/pinata-sdk.js +0 -24526
  18. package/lib/pinata-sdk.min.js +0 -22
  19. package/pinata.png +0 -0
  20. package/src/commands/data/getFilesByCount/getFilesByCount.ts +0 -66
  21. package/src/commands/data/index.ts +0 -4
  22. package/src/commands/data/pinList/pinList.ts +0 -77
  23. package/src/commands/data/pinList/queryBuilder.ts +0 -239
  24. package/src/commands/data/testAuthentication.ts +0 -31
  25. package/src/commands/data/userPinnedDataTotal.ts +0 -24
  26. package/src/commands/pinning/hashMetadata.ts +0 -56
  27. package/src/commands/pinning/index.ts +0 -8
  28. package/src/commands/pinning/pinByHash.ts +0 -65
  29. package/src/commands/pinning/pinFileToIPFS.ts +0 -118
  30. package/src/commands/pinning/pinFromFS.ts +0 -60
  31. package/src/commands/pinning/pinJSONToIPFS.ts +0 -47
  32. package/src/commands/pinning/pinJobs/pinJobs.ts +0 -50
  33. package/src/commands/pinning/pinJobs/queryBuilder.ts +0 -75
  34. package/src/commands/pinning/unpin.ts +0 -32
  35. package/src/constants.ts +0 -4
  36. package/src/index.ts +0 -124
  37. package/src/require-babel-polyfill.ts +0 -5
  38. package/src/third-party/base-path-converter.d.ts +0 -3
  39. package/src/third-party/global.d.ts +0 -9
  40. package/src/third-party/is-ipfs.d.ts +0 -5
  41. package/src/util/errorResponse.ts +0 -10
  42. package/src/util/validators.ts +0 -182
  43. package/test/commands/data/getFilesByCount/getFilesByCount.test.ts +0 -212
  44. package/test/commands/data/pinList/pinList.test.ts +0 -102
  45. package/test/commands/data/pinList/queryBuilder.test.ts +0 -439
  46. package/test/commands/data/pinlist-sample-api.ts +0 -540
  47. package/test/commands/data/testAuthentication.test.ts +0 -34
  48. package/test/commands/data/userPinnedDataTotal.test.ts +0 -29
  49. package/test/commands/pinning/hashMetadata.test.ts +0 -76
  50. package/test/commands/pinning/pinByHash.test.ts +0 -46
  51. package/test/commands/pinning/pinFileToIPFS.test.ts +0 -53
  52. package/test/commands/pinning/pinFromFS.ts +0 -71
  53. package/test/commands/pinning/pinJSONToIPFS.test.ts +0 -42
  54. package/test/commands/pinning/pinJobs/pinJobs.test.ts +0 -29
  55. package/test/commands/pinning/pinJobs/queryBuilder.test.ts +0 -120
  56. package/test/commands/pinning/unpin.test.ts +0 -46
  57. package/test/util/validators.test.ts +0 -234
  58. package/tsconfig.json +0 -23
  59. package/types/commands/data/getFilesByCount/getFilesByCount.d.ts +0 -14
  60. package/types/commands/data/index.d.ts +0 -4
  61. package/types/commands/data/pinList/pinList.d.ts +0 -45
  62. package/types/commands/data/pinList/queryBuilder.d.ts +0 -1
  63. package/types/commands/data/testAuthentication.d.ts +0 -5
  64. package/types/commands/data/userPinnedDataTotal.d.ts +0 -2
  65. package/types/commands/pinning/hashMetadata.d.ts +0 -3
  66. package/types/commands/pinning/hashPinPolicy.d.ts +0 -9
  67. package/types/commands/pinning/index.d.ts +0 -8
  68. package/types/commands/pinning/pinByHash.d.ts +0 -14
  69. package/types/commands/pinning/pinFileToIPFS.d.ts +0 -25
  70. package/types/commands/pinning/pinFromFS.d.ts +0 -4
  71. package/types/commands/pinning/pinJSONToIPFS.d.ts +0 -3
  72. package/types/commands/pinning/pinJobs/pinJobs.d.ts +0 -20
  73. package/types/commands/pinning/pinJobs/queryBuilder.d.ts +0 -1
  74. package/types/commands/pinning/unpin.d.ts +0 -2
  75. package/types/commands/pinning/userPinPolicy.d.ts +0 -8
  76. package/types/constants.d.ts +0 -2
  77. package/types/index.d.ts +0 -39
  78. package/types/require-babel-polyfill.d.ts +0 -2
  79. package/types/util/errorResponse.d.ts +0 -1
  80. package/types/util/validators.d.ts +0 -37
  81. package/webpack.config.js +0 -58
@@ -1,45 +0,0 @@
1
- import { PinataConfig } from '../../..';
2
- export interface PinataPinRegion {
3
- regionId: string;
4
- currentReplicationCount: number;
5
- desiredReplicationCount: number;
6
- }
7
- export interface PinataMetadata {
8
- [key: string]: string | number | null;
9
- }
10
- export interface PinataMetadataFilter {
11
- name?: string | undefined;
12
- keyvalues: {
13
- [key: string]: {
14
- value: string | number | null;
15
- op: string;
16
- };
17
- };
18
- }
19
- export interface PinataPin {
20
- id: string | number;
21
- ipfs_pin_hash: string;
22
- size: number;
23
- user_id: string | number;
24
- date_pinned: string;
25
- date_unpinned: string | null;
26
- metadata: PinataMetadata;
27
- regions: PinataPinRegion[];
28
- }
29
- export declare type PinataPinListFilterOptions = {
30
- hashContains?: string | undefined;
31
- pinStart?: string | undefined;
32
- pinEnd?: string | undefined;
33
- unpinStart?: string | undefined;
34
- unpinEnd?: string | undefined;
35
- pinSizeMin?: number | undefined;
36
- pinSizeMax?: number | undefined;
37
- status?: string | undefined;
38
- pageLimit?: number | undefined;
39
- pageOffset?: number | undefined;
40
- metadata?: PinataMetadataFilter | undefined;
41
- };
42
- export interface PinataPinListResponse {
43
- rows: PinataPin[];
44
- }
45
- export default function pinList(config: PinataConfig, filters?: PinataPinListFilterOptions): Promise<PinataPinListResponse>;
@@ -1 +0,0 @@
1
- export default function queryBuilder(baseUrl: string, filters?: any): string;
@@ -1,5 +0,0 @@
1
- import { PinataConfig } from '../..';
2
- export interface PinataTestAuthenticationResponse {
3
- authenticated: boolean;
4
- }
5
- export default function testAuthentication(config: PinataConfig): Promise<PinataTestAuthenticationResponse>;
@@ -1,2 +0,0 @@
1
- import { PinataConfig } from '../..';
2
- export default function userPinnedDataTotal(config: PinataConfig): Promise<number>;
@@ -1,3 +0,0 @@
1
- import { PinataConfig } from '../..';
2
- import { PinataMetadata } from '../data/pinList/pinList';
3
- export default function hashMetadata(config: PinataConfig, ipfsPinHash: string, metadata: PinataMetadata): Promise<any>;
@@ -1,9 +0,0 @@
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(config: any, ipfsPinHash: any, newPinPolicy: any): Promise<unknown>;
@@ -1,8 +0,0 @@
1
- export * from './pinJobs/pinJobs';
2
- export * from './pinJobs/queryBuilder';
3
- export * from './hashMetadata';
4
- export * from './pinByHash';
5
- export * from './pinFileToIPFS';
6
- export * from './pinFromFS';
7
- export * from './pinJSONToIPFS';
8
- export * from './unpin';
@@ -1,14 +0,0 @@
1
- import { PinataConfig } from '../..';
2
- import { PinataOptions } from './pinFileToIPFS';
3
- import { PinataMetadata } from '../data/pinList/pinList';
4
- export interface PinataPinByHashPinOptions {
5
- pinataMetadata?: PinataMetadata;
6
- pinataOptions?: PinataOptions;
7
- }
8
- export interface PinataPinByHashResponse {
9
- id: number | string;
10
- ipfsHash: string;
11
- status: string;
12
- name: string;
13
- }
14
- export default function pinByHash(config: PinataConfig, hashToPin: string, options: any): Promise<any>;
@@ -1,25 +0,0 @@
1
- import NodeFormData from 'form-data';
2
- import { PinataConfig, PinataMetadata } from '../..';
3
- export interface PinataPinPolicyItem {
4
- id: string;
5
- desiredReplicationCount: number;
6
- }
7
- export interface PinataOptions {
8
- hostNodes?: string[] | undefined;
9
- cidVersion?: 0 | 1;
10
- wrapWithDirectory?: boolean;
11
- customPinPolicy?: {
12
- regions: PinataPinPolicyItem[];
13
- };
14
- }
15
- export interface PinataPinResponse {
16
- IpfsHash: string;
17
- PinSize: number;
18
- Timestamp: string;
19
- }
20
- export interface PinataPinOptions {
21
- pinataMetadata?: PinataMetadata;
22
- pinataOptions?: PinataOptions | undefined;
23
- }
24
- export declare function uploadToIPFS(config: PinataConfig, data: NodeFormData, options?: PinataPinOptions): Promise<PinataPinResponse>;
25
- export default function pinFileToIPFS(config: PinataConfig, readStream: any, options?: PinataPinOptions): Promise<PinataPinResponse>;
@@ -1,4 +0,0 @@
1
- import { PinataConfig } from '../..';
2
- import { PinataPinOptions, PinataPinResponse } from './pinFileToIPFS';
3
- export declare function normalizePath(p: string): string;
4
- export default function pinFromFS(config: PinataConfig, sourcePath: string, options?: PinataPinOptions): Promise<PinataPinResponse>;
@@ -1,3 +0,0 @@
1
- import { PinataConfig } from '../..';
2
- import { PinataPinOptions, PinataPinResponse } from './pinFileToIPFS';
3
- export default function pinJSONToIPFS(config: PinataConfig, body: any, options?: PinataPinOptions): Promise<PinataPinResponse>;
@@ -1,20 +0,0 @@
1
- import { PinataConfig } from '../../..';
2
- export interface PinataPinJobsResponseRow {
3
- id: number | string;
4
- ipfs_pin_hash: string;
5
- date_queued: string;
6
- name: string | undefined | null;
7
- status: string;
8
- }
9
- export interface PinataPinJobsResponse {
10
- count: number;
11
- rows: PinataPinJobsResponseRow[];
12
- }
13
- export interface PinataPinJobsFilterOptions {
14
- sort: 'ASC' | 'DESC';
15
- status?: string | undefined;
16
- ipfs_pin_hash?: string | undefined;
17
- limit?: number | undefined;
18
- offset?: number | undefined;
19
- }
20
- export default function pinJobs(config: PinataConfig, filters?: PinataPinJobsFilterOptions): Promise<PinataPinJobsResponse>;
@@ -1 +0,0 @@
1
- export default function queryBuilder(baseUrl: string, filters?: any): string;
@@ -1,2 +0,0 @@
1
- import { PinataConfig } from '../..';
2
- export default function unpin(config: PinataConfig, hashToUnpin: string): Promise<unknown>;
@@ -1,8 +0,0 @@
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(config: any, newPinPolicy: any): Promise<unknown>;
@@ -1,2 +0,0 @@
1
- export declare const baseUrl = "https://api.pinata.cloud";
2
- export declare const ERROR_NO_CREDENTIALS_PROVIDED = "No credentials provided! Please provide your pinata api key and pinata secret api key or your pinata JWT key as an argument when you start this script";
package/types/index.d.ts DELETED
@@ -1,39 +0,0 @@
1
- import './require-babel-polyfill';
2
- import { PinataPinByHashPinOptions } from './commands/pinning/pinByHash';
3
- import { PinataPinOptions } from './commands/pinning/pinFileToIPFS';
4
- import { PinataPinJobsFilterOptions } from './commands/pinning/pinJobs/pinJobs';
5
- import { PinataMetadata, PinataPinListFilterOptions } from './commands/data/pinList/pinList';
6
- export interface PinataConfig {
7
- pinataApiKey?: string;
8
- pinataSecretApiKey?: string;
9
- pinataJWTKey?: string;
10
- }
11
- declare class PinataClient {
12
- config: PinataConfig;
13
- constructor(pinataApiKey?: string | PinataConfig, pinataSecretApiKey?: string);
14
- pinByHash(hashToPin: string, options?: PinataPinByHashPinOptions): Promise<any>;
15
- hashMetadata(ipfsPinHash: string, metadata: PinataMetadata): Promise<any>;
16
- pinFileToIPFS(readableStream: any, options?: PinataPinOptions): Promise<import("./commands/pinning").PinataPinResponse>;
17
- pinFromFS(sourcePath: string, options?: PinataPinOptions): Promise<import("./commands/pinning").PinataPinResponse>;
18
- pinJSONToIPFS(body: any, options?: PinataPinOptions): Promise<import("./commands/pinning").PinataPinResponse>;
19
- pinJobs(filters?: PinataPinJobsFilterOptions): Promise<import("./commands/pinning").PinataPinJobsResponse>;
20
- unpin(hashToUnpin: string): Promise<unknown>;
21
- pinList(filters: PinataPinListFilterOptions): Promise<import("./commands/data").PinataPinListResponse>;
22
- getFilesByCount(filters: PinataPinListFilterOptions, maxCount?: number): {
23
- [Symbol.asyncIterator]: () => {
24
- next(): Promise<{
25
- value: import("./commands/data").PinataPin;
26
- done: boolean;
27
- }>;
28
- return(): Promise<{
29
- value: number;
30
- done: boolean;
31
- }>;
32
- };
33
- };
34
- testAuthentication(): Promise<import("./commands/data").PinataTestAuthenticationResponse>;
35
- userPinnedDataTotal(): Promise<number>;
36
- }
37
- export * from './commands/data';
38
- export * from './commands/pinning';
39
- export default PinataClient;
@@ -1,2 +0,0 @@
1
- declare const _default: void;
2
- export default _default;
@@ -1 +0,0 @@
1
- export declare const handleError: (error: any) => any;
@@ -1,37 +0,0 @@
1
- import { PinataConfig } from '..';
2
- export interface axiosHeaders {
3
- maxContentLength: number;
4
- maxBodyLength: number;
5
- headers: {
6
- [key: string]: any;
7
- };
8
- withCredentials?: boolean;
9
- }
10
- export declare function validateApiKeys(pinataApiKey?: string, pinataSecretApiKey?: string): void;
11
- export declare function createConfigForAxiosHeaders(config: PinataConfig): {
12
- withCredentials: boolean;
13
- headers: {
14
- pinata_api_key: string;
15
- pinata_secret_api_key: string;
16
- Authorization?: undefined;
17
- };
18
- } | {
19
- headers: {
20
- Authorization: string;
21
- pinata_api_key?: undefined;
22
- pinata_secret_api_key?: undefined;
23
- };
24
- withCredentials?: undefined;
25
- };
26
- export declare function createConfigForAxiosHeadersWithFormData(config: PinataConfig, boundaryValue: string): axiosHeaders;
27
- export declare function validateHostNodes(hostNodes: any): void;
28
- export declare function validateMetadata(metadata: any): void;
29
- export declare function validatePinPolicyStructure(pinPolicy: {
30
- regions: any[];
31
- }): void;
32
- export declare function validatePinataOptions(options: {
33
- cidVersion?: number;
34
- wrapWithDirectory?: boolean;
35
- hostNodes?: any;
36
- customPinPolicy?: any;
37
- }): void;
package/webpack.config.js DELETED
@@ -1,58 +0,0 @@
1
- const webpack = require('webpack');
2
- const path = require('path');
3
-
4
- const libraryName = 'pinata-sdk';
5
-
6
- module.exports = (env) => {
7
- let outputFile, mode;
8
-
9
- if (env === 'build') {
10
- mode = 'production';
11
-
12
- outputFile = libraryName + '.min.js';
13
- } else {
14
- mode = 'development';
15
- outputFile = libraryName + '.js';
16
- }
17
- return {
18
- mode: mode,
19
- entry: [ __dirname + '/src/index.ts'],
20
- devtool: 'inline-source-map',
21
- output: {
22
- path: __dirname + '/lib',
23
- filename: outputFile,
24
- library: libraryName,
25
- libraryTarget: 'umd',
26
- umdNamedDefine: true,
27
- globalObject: "typeof self !== 'undefined' ? self : this"
28
- },
29
- module: {
30
- rules: [
31
- {
32
- test: /\.ts?$/,
33
- loader: 'babel-loader',
34
- exclude: /(node_modules|bower_components)/
35
- },
36
- // {
37
- // test: /\.ts?$/,
38
- // loader: 'eslint-loader',
39
- // exclude: /node_modules/,
40
-
41
- // }
42
- ]
43
- },
44
- target: 'node',
45
- node: {
46
- process: false
47
- },
48
- plugins: [
49
- new webpack.DefinePlugin({
50
- 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
51
- })
52
- ],
53
- resolve: {
54
- modules: [path.resolve('./node_modules'), path.resolve('./src')],
55
- extensions: ['.json', '.js', '.ts']
56
- }
57
- };
58
- };