pinata 1.4.1 → 1.6.0
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/dist/index.d.mts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +162 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +162 -24
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
type PinataConfig = {
|
|
2
|
-
pinataJwt
|
|
2
|
+
pinataJwt?: string;
|
|
3
3
|
pinataGateway?: string;
|
|
4
4
|
pinataGatewayKey?: string;
|
|
5
5
|
customHeaders?: Record<string, string>;
|
|
@@ -30,10 +30,12 @@ type FileObject = {
|
|
|
30
30
|
type JsonBody = Record<string, unknown>;
|
|
31
31
|
type PinataMetadata = {
|
|
32
32
|
name?: string;
|
|
33
|
+
keyvalues?: Record<string, string>;
|
|
33
34
|
};
|
|
34
35
|
type UpdateFileOptions = {
|
|
35
36
|
id: string;
|
|
36
37
|
name?: string;
|
|
38
|
+
keyvalues?: Record<string, string>;
|
|
37
39
|
};
|
|
38
40
|
type UploadOptions = {
|
|
39
41
|
metadata?: PinataMetadata;
|
|
@@ -51,6 +53,7 @@ type FileListItem = {
|
|
|
51
53
|
size: number;
|
|
52
54
|
number_of_files: number;
|
|
53
55
|
mime_type: string;
|
|
56
|
+
keyvalues: Record<string, string>;
|
|
54
57
|
group_id: string | null;
|
|
55
58
|
created_at: string;
|
|
56
59
|
};
|
|
@@ -61,9 +64,11 @@ type FileListResponse = {
|
|
|
61
64
|
type FileListQuery = {
|
|
62
65
|
name?: string;
|
|
63
66
|
group?: string;
|
|
67
|
+
noGroup?: boolean;
|
|
64
68
|
mimeType?: string;
|
|
65
69
|
cid?: string;
|
|
66
70
|
cidPending?: boolean;
|
|
71
|
+
metadata?: Record<string, string>;
|
|
67
72
|
order?: "ASC" | "DESC";
|
|
68
73
|
limit?: number;
|
|
69
74
|
pageToken?: string;
|
|
@@ -294,6 +299,7 @@ declare class PinataSDK {
|
|
|
294
299
|
groups: Groups;
|
|
295
300
|
constructor(config?: PinataConfig);
|
|
296
301
|
setNewHeaders(headers: Record<string, string>): void;
|
|
302
|
+
setNewJwt(jwt: string): void;
|
|
297
303
|
testAuthentication(): Promise<AuthTestResponse>;
|
|
298
304
|
}
|
|
299
305
|
declare class Files {
|
|
@@ -341,6 +347,8 @@ declare class FilterFiles {
|
|
|
341
347
|
order(order: "ASC" | "DESC"): FilterFiles;
|
|
342
348
|
limit(limit: number): FilterFiles;
|
|
343
349
|
cidPending(cidPending: boolean): FilterFiles;
|
|
350
|
+
metadata(keyvalues: Record<string, string>): FilterFiles;
|
|
351
|
+
noGroup(noGroup: boolean): FilterFiles;
|
|
344
352
|
pageToken(pageToken: string): FilterFiles;
|
|
345
353
|
then(onfulfilled?: ((value: FileListResponse) => any) | null): Promise<any>;
|
|
346
354
|
private fetchPage;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
type PinataConfig = {
|
|
2
|
-
pinataJwt
|
|
2
|
+
pinataJwt?: string;
|
|
3
3
|
pinataGateway?: string;
|
|
4
4
|
pinataGatewayKey?: string;
|
|
5
5
|
customHeaders?: Record<string, string>;
|
|
@@ -30,10 +30,12 @@ type FileObject = {
|
|
|
30
30
|
type JsonBody = Record<string, unknown>;
|
|
31
31
|
type PinataMetadata = {
|
|
32
32
|
name?: string;
|
|
33
|
+
keyvalues?: Record<string, string>;
|
|
33
34
|
};
|
|
34
35
|
type UpdateFileOptions = {
|
|
35
36
|
id: string;
|
|
36
37
|
name?: string;
|
|
38
|
+
keyvalues?: Record<string, string>;
|
|
37
39
|
};
|
|
38
40
|
type UploadOptions = {
|
|
39
41
|
metadata?: PinataMetadata;
|
|
@@ -51,6 +53,7 @@ type FileListItem = {
|
|
|
51
53
|
size: number;
|
|
52
54
|
number_of_files: number;
|
|
53
55
|
mime_type: string;
|
|
56
|
+
keyvalues: Record<string, string>;
|
|
54
57
|
group_id: string | null;
|
|
55
58
|
created_at: string;
|
|
56
59
|
};
|
|
@@ -61,9 +64,11 @@ type FileListResponse = {
|
|
|
61
64
|
type FileListQuery = {
|
|
62
65
|
name?: string;
|
|
63
66
|
group?: string;
|
|
67
|
+
noGroup?: boolean;
|
|
64
68
|
mimeType?: string;
|
|
65
69
|
cid?: string;
|
|
66
70
|
cidPending?: boolean;
|
|
71
|
+
metadata?: Record<string, string>;
|
|
67
72
|
order?: "ASC" | "DESC";
|
|
68
73
|
limit?: number;
|
|
69
74
|
pageToken?: string;
|
|
@@ -294,6 +299,7 @@ declare class PinataSDK {
|
|
|
294
299
|
groups: Groups;
|
|
295
300
|
constructor(config?: PinataConfig);
|
|
296
301
|
setNewHeaders(headers: Record<string, string>): void;
|
|
302
|
+
setNewJwt(jwt: string): void;
|
|
297
303
|
testAuthentication(): Promise<AuthTestResponse>;
|
|
298
304
|
}
|
|
299
305
|
declare class Files {
|
|
@@ -341,6 +347,8 @@ declare class FilterFiles {
|
|
|
341
347
|
order(order: "ASC" | "DESC"): FilterFiles;
|
|
342
348
|
limit(limit: number): FilterFiles;
|
|
343
349
|
cidPending(cidPending: boolean): FilterFiles;
|
|
350
|
+
metadata(keyvalues: Record<string, string>): FilterFiles;
|
|
351
|
+
noGroup(noGroup: boolean): FilterFiles;
|
|
344
352
|
pageToken(pageToken: string): FilterFiles;
|
|
345
353
|
then(onfulfilled?: ((value: FileListResponse) => any) | null): Promise<any>;
|
|
346
354
|
private fetchPage;
|
package/dist/index.js
CHANGED
|
@@ -63,7 +63,10 @@ var testAuthentication = async (config) => {
|
|
|
63
63
|
endpoint = config.endpointUrl;
|
|
64
64
|
}
|
|
65
65
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
66
|
-
headers = {
|
|
66
|
+
headers = {
|
|
67
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
68
|
+
...config.customHeaders
|
|
69
|
+
};
|
|
67
70
|
} else {
|
|
68
71
|
headers = {
|
|
69
72
|
Authorization: `Bearer ${config.pinataJwt}`,
|
|
@@ -119,9 +122,15 @@ var uploadFile = async (config, file, options) => {
|
|
|
119
122
|
if (options?.groupId) {
|
|
120
123
|
data.append("group_id", options.groupId);
|
|
121
124
|
}
|
|
125
|
+
if (options?.metadata?.keyvalues) {
|
|
126
|
+
data.append("keyvalues", JSON.stringify(options.metadata.keyvalues));
|
|
127
|
+
}
|
|
122
128
|
let headers;
|
|
123
129
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
124
|
-
headers = {
|
|
130
|
+
headers = {
|
|
131
|
+
Authorization: `Bearer ${jwt}`,
|
|
132
|
+
...config.customHeaders
|
|
133
|
+
};
|
|
125
134
|
} else {
|
|
126
135
|
headers = {
|
|
127
136
|
Authorization: `Bearer ${jwt}`,
|
|
@@ -182,9 +191,15 @@ var uploadBase64 = async (config, base64String, options) => {
|
|
|
182
191
|
if (options?.groupId) {
|
|
183
192
|
data.append("group_id", options.groupId);
|
|
184
193
|
}
|
|
194
|
+
if (options?.metadata?.keyvalues) {
|
|
195
|
+
data.append("keyvalues", JSON.stringify(options.metadata.keyvalues));
|
|
196
|
+
}
|
|
185
197
|
let headers;
|
|
186
198
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
187
|
-
headers = {
|
|
199
|
+
headers = {
|
|
200
|
+
Authorization: `Bearer ${jwt}`,
|
|
201
|
+
...config.customHeaders
|
|
202
|
+
};
|
|
188
203
|
} else {
|
|
189
204
|
headers = {
|
|
190
205
|
Authorization: `Bearer ${jwt}`,
|
|
@@ -257,9 +272,15 @@ var uploadUrl = async (config, url, options) => {
|
|
|
257
272
|
if (options?.groupId) {
|
|
258
273
|
data.append("group_id", options.groupId);
|
|
259
274
|
}
|
|
275
|
+
if (options?.metadata?.keyvalues) {
|
|
276
|
+
data.append("keyvalues", JSON.stringify(options.metadata.keyvalues));
|
|
277
|
+
}
|
|
260
278
|
let headers;
|
|
261
279
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
262
|
-
headers = {
|
|
280
|
+
headers = {
|
|
281
|
+
Authorization: `Bearer ${jwt}`,
|
|
282
|
+
...config.customHeaders
|
|
283
|
+
};
|
|
263
284
|
} else {
|
|
264
285
|
headers = {
|
|
265
286
|
Authorization: `Bearer ${jwt}`,
|
|
@@ -320,9 +341,15 @@ var uploadJson = async (config, jsonData, options) => {
|
|
|
320
341
|
if (options?.groupId) {
|
|
321
342
|
data.append("group_id", options.groupId);
|
|
322
343
|
}
|
|
344
|
+
if (options?.metadata?.keyvalues) {
|
|
345
|
+
data.append("keyvalues", JSON.stringify(options.metadata.keyvalues));
|
|
346
|
+
}
|
|
323
347
|
let headers;
|
|
324
348
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
325
|
-
headers = {
|
|
349
|
+
headers = {
|
|
350
|
+
Authorization: `Bearer ${jwt}`,
|
|
351
|
+
...config.customHeaders
|
|
352
|
+
};
|
|
326
353
|
} else {
|
|
327
354
|
headers = {
|
|
328
355
|
Authorization: `Bearer ${jwt}`,
|
|
@@ -381,7 +408,10 @@ var deleteFile = async (config, files) => {
|
|
|
381
408
|
const responses = [];
|
|
382
409
|
let headers;
|
|
383
410
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
384
|
-
headers = {
|
|
411
|
+
headers = {
|
|
412
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
413
|
+
...config.customHeaders
|
|
414
|
+
};
|
|
385
415
|
} else {
|
|
386
416
|
headers = {
|
|
387
417
|
Authorization: `Bearer ${config.pinataJwt}`,
|
|
@@ -443,7 +473,18 @@ var listFiles = async (config, options) => {
|
|
|
443
473
|
}
|
|
444
474
|
const params = new URLSearchParams();
|
|
445
475
|
if (options) {
|
|
446
|
-
const {
|
|
476
|
+
const {
|
|
477
|
+
name,
|
|
478
|
+
group,
|
|
479
|
+
cid,
|
|
480
|
+
order,
|
|
481
|
+
limit,
|
|
482
|
+
mimeType,
|
|
483
|
+
pageToken,
|
|
484
|
+
cidPending,
|
|
485
|
+
metadata,
|
|
486
|
+
noGroup
|
|
487
|
+
} = options;
|
|
447
488
|
if (limit)
|
|
448
489
|
params.append("limit", limit.toString());
|
|
449
490
|
if (name)
|
|
@@ -460,6 +501,13 @@ var listFiles = async (config, options) => {
|
|
|
460
501
|
params.append("pageToken", pageToken);
|
|
461
502
|
if (cidPending)
|
|
462
503
|
params.append("cidPending", "true");
|
|
504
|
+
if (noGroup)
|
|
505
|
+
params.append("group", "null");
|
|
506
|
+
if (metadata && typeof metadata === "object") {
|
|
507
|
+
Object.entries(metadata).forEach(([key, value]) => {
|
|
508
|
+
params.append(`metadata[${key}]`, value.toString());
|
|
509
|
+
});
|
|
510
|
+
}
|
|
463
511
|
}
|
|
464
512
|
let endpoint = "https://api.pinata.cloud/v3";
|
|
465
513
|
if (config.endpointUrl) {
|
|
@@ -469,7 +517,10 @@ var listFiles = async (config, options) => {
|
|
|
469
517
|
try {
|
|
470
518
|
let headers;
|
|
471
519
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
472
|
-
headers = {
|
|
520
|
+
headers = {
|
|
521
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
522
|
+
...config.customHeaders
|
|
523
|
+
};
|
|
473
524
|
} else {
|
|
474
525
|
headers = {
|
|
475
526
|
Authorization: `Bearer ${config.pinataJwt}`,
|
|
@@ -514,12 +565,26 @@ var updateFile = async (config, options) => {
|
|
|
514
565
|
if (!config) {
|
|
515
566
|
throw new ValidationError("Pinata configuration is missing");
|
|
516
567
|
}
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
568
|
+
if (!options.name && (!options.keyvalues || Object.keys(options.keyvalues).length === 0)) {
|
|
569
|
+
throw new ValidationError(
|
|
570
|
+
"At least one of 'name' or 'keyvalues' must be provided"
|
|
571
|
+
);
|
|
572
|
+
}
|
|
573
|
+
const data = {};
|
|
574
|
+
if (options.name !== void 0) {
|
|
575
|
+
data.name = options.name;
|
|
576
|
+
}
|
|
577
|
+
if (options.keyvalues && Object.keys(options.keyvalues).length > 0) {
|
|
578
|
+
data.keyvalues = options.keyvalues;
|
|
579
|
+
}
|
|
580
|
+
const body = JSON.stringify(data);
|
|
520
581
|
let headers;
|
|
521
582
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
522
|
-
headers = {
|
|
583
|
+
headers = {
|
|
584
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
585
|
+
"Content-Type": "application/json",
|
|
586
|
+
...config.customHeaders
|
|
587
|
+
};
|
|
523
588
|
} else {
|
|
524
589
|
headers = {
|
|
525
590
|
Authorization: `Bearer ${config.pinataJwt}`,
|
|
@@ -535,7 +600,7 @@ var updateFile = async (config, options) => {
|
|
|
535
600
|
const request = await fetch(`${endpoint}/files/${options.id}`, {
|
|
536
601
|
method: "PUT",
|
|
537
602
|
headers,
|
|
538
|
-
body
|
|
603
|
+
body
|
|
539
604
|
});
|
|
540
605
|
if (!request.ok) {
|
|
541
606
|
const errorData = await request.text();
|
|
@@ -615,7 +680,11 @@ var getCid = async (config, cid, options) => {
|
|
|
615
680
|
}
|
|
616
681
|
let headers;
|
|
617
682
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
618
|
-
headers = {
|
|
683
|
+
headers = {
|
|
684
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
685
|
+
"Content-Type": "application/json",
|
|
686
|
+
...config.customHeaders
|
|
687
|
+
};
|
|
619
688
|
} else {
|
|
620
689
|
headers = {
|
|
621
690
|
"Content-Type": "application/json",
|
|
@@ -679,7 +748,11 @@ var createKey = async (config, options) => {
|
|
|
679
748
|
}
|
|
680
749
|
let headers;
|
|
681
750
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
682
|
-
headers = {
|
|
751
|
+
headers = {
|
|
752
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
753
|
+
"Content-Type": "application/json",
|
|
754
|
+
...config.customHeaders
|
|
755
|
+
};
|
|
683
756
|
} else {
|
|
684
757
|
headers = {
|
|
685
758
|
Authorization: `Bearer ${config.pinataJwt}`,
|
|
@@ -733,7 +806,11 @@ var listKeys = async (config, options) => {
|
|
|
733
806
|
}
|
|
734
807
|
let headers;
|
|
735
808
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
736
|
-
headers = {
|
|
809
|
+
headers = {
|
|
810
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
811
|
+
"Content-Type": "application/json",
|
|
812
|
+
...config.customHeaders
|
|
813
|
+
};
|
|
737
814
|
} else {
|
|
738
815
|
headers = {
|
|
739
816
|
Authorization: `Bearer ${config.pinataJwt}`,
|
|
@@ -807,6 +884,11 @@ var revokeKeys = async (config, keys) => {
|
|
|
807
884
|
}
|
|
808
885
|
let headers;
|
|
809
886
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
887
|
+
headers = {
|
|
888
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
889
|
+
"Content-Type": "application/json",
|
|
890
|
+
...config.customHeaders
|
|
891
|
+
};
|
|
810
892
|
headers = { ...config.customHeaders };
|
|
811
893
|
} else {
|
|
812
894
|
headers = {
|
|
@@ -876,7 +958,11 @@ var createGroup = async (config, options) => {
|
|
|
876
958
|
});
|
|
877
959
|
let headers;
|
|
878
960
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
879
|
-
headers = {
|
|
961
|
+
headers = {
|
|
962
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
963
|
+
"Content-Type": "application/json",
|
|
964
|
+
...config.customHeaders
|
|
965
|
+
};
|
|
880
966
|
} else {
|
|
881
967
|
headers = {
|
|
882
968
|
Authorization: `Bearer ${config.pinataJwt}`,
|
|
@@ -930,7 +1016,11 @@ var listGroups = async (config, options) => {
|
|
|
930
1016
|
}
|
|
931
1017
|
let headers;
|
|
932
1018
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
933
|
-
headers = {
|
|
1019
|
+
headers = {
|
|
1020
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
1021
|
+
"Content-Type": "application/json",
|
|
1022
|
+
...config.customHeaders
|
|
1023
|
+
};
|
|
934
1024
|
} else {
|
|
935
1025
|
headers = {
|
|
936
1026
|
Authorization: `Bearer ${config.pinataJwt}`,
|
|
@@ -998,7 +1088,11 @@ var getGroup = async (config, options) => {
|
|
|
998
1088
|
}
|
|
999
1089
|
let headers;
|
|
1000
1090
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
1001
|
-
headers = {
|
|
1091
|
+
headers = {
|
|
1092
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
1093
|
+
"Content-Type": "application/json",
|
|
1094
|
+
...config.customHeaders
|
|
1095
|
+
};
|
|
1002
1096
|
} else {
|
|
1003
1097
|
headers = {
|
|
1004
1098
|
Authorization: `Bearer ${config.pinataJwt}`,
|
|
@@ -1057,7 +1151,11 @@ var updateGroup = async (config, options) => {
|
|
|
1057
1151
|
});
|
|
1058
1152
|
let headers;
|
|
1059
1153
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
1060
|
-
headers = {
|
|
1154
|
+
headers = {
|
|
1155
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
1156
|
+
"Content-Type": "application/json",
|
|
1157
|
+
...config.customHeaders
|
|
1158
|
+
};
|
|
1061
1159
|
} else {
|
|
1062
1160
|
headers = {
|
|
1063
1161
|
Authorization: `Bearer ${config.pinataJwt}`,
|
|
@@ -1111,6 +1209,11 @@ var deleteGroup = async (config, options) => {
|
|
|
1111
1209
|
}
|
|
1112
1210
|
let headers;
|
|
1113
1211
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
1212
|
+
headers = {
|
|
1213
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
1214
|
+
"Content-Type": "application/json",
|
|
1215
|
+
...config.customHeaders
|
|
1216
|
+
};
|
|
1114
1217
|
headers = { ...config.customHeaders };
|
|
1115
1218
|
} else {
|
|
1116
1219
|
headers = {
|
|
@@ -1166,7 +1269,11 @@ var swapCid = async (config, options) => {
|
|
|
1166
1269
|
});
|
|
1167
1270
|
let headers;
|
|
1168
1271
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
1169
|
-
headers = {
|
|
1272
|
+
headers = {
|
|
1273
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
1274
|
+
"Content-Type": "application/json",
|
|
1275
|
+
...config.customHeaders
|
|
1276
|
+
};
|
|
1170
1277
|
} else {
|
|
1171
1278
|
headers = {
|
|
1172
1279
|
Authorization: `Bearer ${config.pinataJwt}`,
|
|
@@ -1234,7 +1341,11 @@ var swapHistory = async (config, options) => {
|
|
|
1234
1341
|
}
|
|
1235
1342
|
let headers;
|
|
1236
1343
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
1237
|
-
headers = {
|
|
1344
|
+
headers = {
|
|
1345
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
1346
|
+
"Content-Type": "application/json",
|
|
1347
|
+
...config.customHeaders
|
|
1348
|
+
};
|
|
1238
1349
|
} else {
|
|
1239
1350
|
headers = {
|
|
1240
1351
|
Authorization: `Bearer ${config.pinataJwt}`,
|
|
@@ -1299,7 +1410,11 @@ var deleteSwap = async (config, cid) => {
|
|
|
1299
1410
|
}
|
|
1300
1411
|
let headers;
|
|
1301
1412
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
1302
|
-
headers = {
|
|
1413
|
+
headers = {
|
|
1414
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
1415
|
+
"Content-Type": "application/json",
|
|
1416
|
+
...config.customHeaders
|
|
1417
|
+
};
|
|
1303
1418
|
} else {
|
|
1304
1419
|
headers = {
|
|
1305
1420
|
Authorization: `Bearer ${config.pinataJwt}`,
|
|
@@ -1411,7 +1526,11 @@ var createSignedURL = async (config, options, imgOpts) => {
|
|
|
1411
1526
|
}
|
|
1412
1527
|
let headers;
|
|
1413
1528
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
1414
|
-
headers = {
|
|
1529
|
+
headers = {
|
|
1530
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
1531
|
+
"Content-Type": "application/json",
|
|
1532
|
+
...config.customHeaders
|
|
1533
|
+
};
|
|
1415
1534
|
} else {
|
|
1416
1535
|
headers = {
|
|
1417
1536
|
"Content-Type": "application/json",
|
|
@@ -1487,6 +1606,17 @@ var PinataSDK = class {
|
|
|
1487
1606
|
this.keys.updateConfig(this.config);
|
|
1488
1607
|
this.groups.updateConfig(this.config);
|
|
1489
1608
|
}
|
|
1609
|
+
setNewJwt(jwt) {
|
|
1610
|
+
if (!this.config) {
|
|
1611
|
+
this.config = { pinataJwt: "" };
|
|
1612
|
+
}
|
|
1613
|
+
this.config.pinataJwt = jwt;
|
|
1614
|
+
this.files.updateConfig(this.config);
|
|
1615
|
+
this.upload.updateConfig(this.config);
|
|
1616
|
+
this.gateways.updateConfig(this.config);
|
|
1617
|
+
this.keys.updateConfig(this.config);
|
|
1618
|
+
this.groups.updateConfig(this.config);
|
|
1619
|
+
}
|
|
1490
1620
|
testAuthentication() {
|
|
1491
1621
|
return testAuthentication(this.config);
|
|
1492
1622
|
}
|
|
@@ -1621,6 +1751,14 @@ var FilterFiles = class {
|
|
|
1621
1751
|
this.query.cidPending = cidPending;
|
|
1622
1752
|
return this;
|
|
1623
1753
|
}
|
|
1754
|
+
metadata(keyvalues) {
|
|
1755
|
+
this.query.metadata = keyvalues;
|
|
1756
|
+
return this;
|
|
1757
|
+
}
|
|
1758
|
+
noGroup(noGroup) {
|
|
1759
|
+
this.query.noGroup = noGroup;
|
|
1760
|
+
return this;
|
|
1761
|
+
}
|
|
1624
1762
|
pageToken(pageToken) {
|
|
1625
1763
|
this.query.pageToken = pageToken;
|
|
1626
1764
|
return this;
|