pinata 2.0.1 → 2.1.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/README.md +13 -13
- package/dist/index.d.mts +13 -5
- package/dist/index.d.ts +13 -5
- package/dist/index.js +92 -38
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +91 -38
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,9 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
The new all-in-one Pinata SDK
|
|
6
6
|
|
|
7
|
-
> [!IMPORTANT]
|
|
8
|
-
> The `v1.*.*` release is a breaking change and does not support IPFS. Please use the [`pinata-web3`](https://github.com/PinataCloud/pinata-web3) SDK.
|
|
9
|
-
|
|
10
7
|
## Quickstart
|
|
11
8
|
|
|
12
9
|
[View the full documentation here](https://docs.pinata.cloud/sdk-beta/getting-started)
|
|
@@ -45,7 +42,7 @@ const pinata = new PinataSDK({
|
|
|
45
42
|
async function main() {
|
|
46
43
|
try {
|
|
47
44
|
const file = new File(["hello"], "Testing.txt", { type: "text/plain" });
|
|
48
|
-
const upload = await pinata.upload.file(file);
|
|
45
|
+
const upload = await pinata.upload.public.file(file);
|
|
49
46
|
console.log(upload);
|
|
50
47
|
} catch (error) {
|
|
51
48
|
console.log(error);
|
|
@@ -59,14 +56,17 @@ This will return an object like the following:
|
|
|
59
56
|
|
|
60
57
|
```typescript
|
|
61
58
|
{
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
59
|
+
id: "0195a5c4-242f-7c01-bee8-f34a9e8e804b",
|
|
60
|
+
user_id: "87ef31fe-519b-4ffe-90d9-987771247827",
|
|
61
|
+
group_id: null,
|
|
62
|
+
name: "hello.txt",
|
|
63
|
+
cid: "bafkreid7qoywk77r7rj3slobqfekdvs57qwuwh5d2z3sqsw52iabe3mqne",
|
|
64
|
+
created_at: "2025-03-17T20:20:50.057Z",
|
|
65
|
+
size: 12,
|
|
66
|
+
number_of_files: 1,
|
|
67
|
+
mime_type: "text/plain",
|
|
68
|
+
vectorized: false,
|
|
69
|
+
network: "public",
|
|
70
70
|
}
|
|
71
71
|
```
|
|
72
72
|
|
|
@@ -84,7 +84,7 @@ const pinata = new PinataSDK({
|
|
|
84
84
|
|
|
85
85
|
async function main() {
|
|
86
86
|
try {
|
|
87
|
-
const data = await pinata.gateways.get("bafkreibm6jg3ux5qumhcn2b3flc3tyu6dmlb4xa7u5bf44yegnrjhc4yeq");
|
|
87
|
+
const data = await pinata.gateways.public.get("bafkreibm6jg3ux5qumhcn2b3flc3tyu6dmlb4xa7u5bf44yegnrjhc4yeq");
|
|
88
88
|
console.log(data)
|
|
89
89
|
} catch (error) {
|
|
90
90
|
console.log(error);
|
package/dist/index.d.mts
CHANGED
|
@@ -102,8 +102,8 @@ type FileListQuery = {
|
|
|
102
102
|
};
|
|
103
103
|
type PinQueueQuery = {
|
|
104
104
|
sort?: "ASC" | "DSC";
|
|
105
|
-
status?: "prechecking" | "retrieving" | "expired" | "over_free_limit" | "over_max_size" | "invalid_object" | "bad_host_node";
|
|
106
|
-
|
|
105
|
+
status?: "prechecking" | "retrieving" | "expired" | "backfilled" | "over_free_limit" | "over_max_size" | "invalid_object" | "bad_host_node";
|
|
106
|
+
cid?: string;
|
|
107
107
|
limit?: number;
|
|
108
108
|
pageToken?: string;
|
|
109
109
|
};
|
|
@@ -325,6 +325,7 @@ type UploadOptions = {
|
|
|
325
325
|
groupId?: string;
|
|
326
326
|
vectorize?: boolean;
|
|
327
327
|
url?: string;
|
|
328
|
+
peerAddresses?: string[];
|
|
328
329
|
};
|
|
329
330
|
type SignedUploadUrlOptions = {
|
|
330
331
|
date?: number;
|
|
@@ -343,8 +344,12 @@ type UploadCIDOptions = {
|
|
|
343
344
|
type PinByCIDResponse = {
|
|
344
345
|
id: string;
|
|
345
346
|
cid: string;
|
|
346
|
-
|
|
347
|
+
date_queued: string;
|
|
347
348
|
name: string;
|
|
349
|
+
status: string;
|
|
350
|
+
keyvalues: Record<string, any> | null;
|
|
351
|
+
host_nodes: string[] | null;
|
|
352
|
+
group_id: string | null;
|
|
348
353
|
};
|
|
349
354
|
|
|
350
355
|
declare const analyticsDateInterval: (config: PinataConfig | undefined, options?: TimeIntervalAnalyticsQuery) => Promise<TimeIntervalAnalyticsResponse>;
|
|
@@ -377,6 +382,8 @@ declare const vectorizeQuery: (config: PinataConfig | undefined, options: Vector
|
|
|
377
382
|
|
|
378
383
|
declare const queue: (config: PinataConfig | undefined, options?: PinQueueQuery) => Promise<PinQueueResponse>;
|
|
379
384
|
|
|
385
|
+
declare const deletePinRequest: (config: PinataConfig | undefined, id: string) => Promise<string>;
|
|
386
|
+
|
|
380
387
|
declare const getCid: (config: PinataConfig | undefined, cid: string, gatewayType?: "ipfs" | "files", options?: OptimizeImageOptions) => Promise<GetCIDResponse>;
|
|
381
388
|
|
|
382
389
|
declare const convertIPFSUrl: (config: PinataConfig | undefined, url: string, gatewayPrefix?: string) => Promise<string>;
|
|
@@ -634,7 +641,7 @@ declare class FilterQueue {
|
|
|
634
641
|
private readonly MINUTE_IN_MS;
|
|
635
642
|
constructor(config: PinataConfig | undefined);
|
|
636
643
|
cid(cid: string): FilterQueue;
|
|
637
|
-
status(status: "prechecking" | "retrieving" | "expired" | "over_free_limit" | "over_max_size" | "invalid_object" | "bad_host_node"): FilterQueue;
|
|
644
|
+
status(status: "prechecking" | "retrieving" | "expired" | "backfilled" | "over_free_limit" | "over_max_size" | "invalid_object" | "bad_host_node"): FilterQueue;
|
|
638
645
|
pageLimit(limit: number): FilterQueue;
|
|
639
646
|
pageToken(pageToken: string): FilterQueue;
|
|
640
647
|
private fetchPage;
|
|
@@ -656,6 +663,7 @@ declare class PublicFiles {
|
|
|
656
663
|
getSwapHistory(options: SwapHistoryOptions): Promise<SwapCidResponse[]>;
|
|
657
664
|
deleteSwap(cid: string): Promise<string>;
|
|
658
665
|
queue(): FilterQueue;
|
|
666
|
+
deletePinRequest(requestId: string): Promise<string>;
|
|
659
667
|
}
|
|
660
668
|
|
|
661
669
|
declare class PrivateFiles {
|
|
@@ -792,4 +800,4 @@ declare function getFileIdFromUrl(url: string): string;
|
|
|
792
800
|
|
|
793
801
|
declare const formatConfig: (config: PinataConfig | undefined) => PinataConfig | undefined;
|
|
794
802
|
|
|
795
|
-
export { type AccessLinkOptions, type AnalyticsQuery, AuthenticationError, type ContainsCIDResponse, type ContentType, type DataEndponts, type DeleteResponse, type Endpoints, type FileListItem, type FileListQuery, type FileListResponse, type FileObject, type GetCIDResponse, type GetGroupOptions, type GroupCIDOptions, type GroupListResponse, type GroupOptions, type GroupQueryOptions, type GroupResponseItem, type JsonBody, type KeyListItem, type KeyListQuery, type KeyListResponse, type KeyOptions, type KeyPermissions, type KeyResponse, NetworkError, type OptimizeImageOptions, type PinByCIDResponse, type PinQueueItem, type PinQueueQuery, type PinQueueResponse, type PinataConfig, PinataError, type PinataMetadata, PinataSDK, type PinningEndpoints, type RevokeKeyResponse, type SignatureOptions, type SignatureResponse, type SignedUploadUrlOptions, type SwapCidOptions, type SwapCidResponse, type SwapHistoryOptions, type TimeIntervalAnalyticsQuery, type TimeIntervalAnalyticsResponse, type TimePeriodItem, type TopAnalyticsItem, type TopAnalyticsQuery, type TopAnalyticsResponse, type UpdateFileOptions, type UpdateGroupFilesResponse, type UpdateGroupOptions, type UploadCIDOptions, type UploadOptions, type UploadResponse, type UserPinnedDataResponse, ValidationError, type VectorQueryMatch, type VectorizeFileResponse, type VectorizeQuery, type VectorizeQueryResponse, addToGroup, analyticsDateInterval, analyticsTopUsage, containsCID, convertIPFSUrl, convertToDesiredGateway, createAccessLink, createGroup, createKey, createSignedUploadURL, deleteFile, deleteFileVectors, deleteGroup, deleteSwap, formatConfig, getCid, getFileIdFromUrl, getGroup, listFiles, listGroups, listKeys, pinnedFileCount, queue, removeFromGroup, revokeKeys, swapCid, swapHistory, testAuthentication, totalStorageUsage, updateFile, updateGroup, uploadBase64, uploadCid, uploadFile, uploadFileArray, uploadJson, uploadUrl, vectorizeFile, vectorizeQuery };
|
|
803
|
+
export { type AccessLinkOptions, type AnalyticsQuery, AuthenticationError, type ContainsCIDResponse, type ContentType, type DataEndponts, type DeleteResponse, type Endpoints, type FileListItem, type FileListQuery, type FileListResponse, type FileObject, type GetCIDResponse, type GetGroupOptions, type GroupCIDOptions, type GroupListResponse, type GroupOptions, type GroupQueryOptions, type GroupResponseItem, type JsonBody, type KeyListItem, type KeyListQuery, type KeyListResponse, type KeyOptions, type KeyPermissions, type KeyResponse, NetworkError, type OptimizeImageOptions, type PinByCIDResponse, type PinQueueItem, type PinQueueQuery, type PinQueueResponse, type PinataConfig, PinataError, type PinataMetadata, PinataSDK, type PinningEndpoints, type RevokeKeyResponse, type SignatureOptions, type SignatureResponse, type SignedUploadUrlOptions, type SwapCidOptions, type SwapCidResponse, type SwapHistoryOptions, type TimeIntervalAnalyticsQuery, type TimeIntervalAnalyticsResponse, type TimePeriodItem, type TopAnalyticsItem, type TopAnalyticsQuery, type TopAnalyticsResponse, type UpdateFileOptions, type UpdateGroupFilesResponse, type UpdateGroupOptions, type UploadCIDOptions, type UploadOptions, type UploadResponse, type UserPinnedDataResponse, ValidationError, type VectorQueryMatch, type VectorizeFileResponse, type VectorizeQuery, type VectorizeQueryResponse, addToGroup, analyticsDateInterval, analyticsTopUsage, containsCID, convertIPFSUrl, convertToDesiredGateway, createAccessLink, createGroup, createKey, createSignedUploadURL, deleteFile, deleteFileVectors, deleteGroup, deletePinRequest, deleteSwap, formatConfig, getCid, getFileIdFromUrl, getGroup, listFiles, listGroups, listKeys, pinnedFileCount, queue, removeFromGroup, revokeKeys, swapCid, swapHistory, testAuthentication, totalStorageUsage, updateFile, updateGroup, uploadBase64, uploadCid, uploadFile, uploadFileArray, uploadJson, uploadUrl, vectorizeFile, vectorizeQuery };
|
package/dist/index.d.ts
CHANGED
|
@@ -102,8 +102,8 @@ type FileListQuery = {
|
|
|
102
102
|
};
|
|
103
103
|
type PinQueueQuery = {
|
|
104
104
|
sort?: "ASC" | "DSC";
|
|
105
|
-
status?: "prechecking" | "retrieving" | "expired" | "over_free_limit" | "over_max_size" | "invalid_object" | "bad_host_node";
|
|
106
|
-
|
|
105
|
+
status?: "prechecking" | "retrieving" | "expired" | "backfilled" | "over_free_limit" | "over_max_size" | "invalid_object" | "bad_host_node";
|
|
106
|
+
cid?: string;
|
|
107
107
|
limit?: number;
|
|
108
108
|
pageToken?: string;
|
|
109
109
|
};
|
|
@@ -325,6 +325,7 @@ type UploadOptions = {
|
|
|
325
325
|
groupId?: string;
|
|
326
326
|
vectorize?: boolean;
|
|
327
327
|
url?: string;
|
|
328
|
+
peerAddresses?: string[];
|
|
328
329
|
};
|
|
329
330
|
type SignedUploadUrlOptions = {
|
|
330
331
|
date?: number;
|
|
@@ -343,8 +344,12 @@ type UploadCIDOptions = {
|
|
|
343
344
|
type PinByCIDResponse = {
|
|
344
345
|
id: string;
|
|
345
346
|
cid: string;
|
|
346
|
-
|
|
347
|
+
date_queued: string;
|
|
347
348
|
name: string;
|
|
349
|
+
status: string;
|
|
350
|
+
keyvalues: Record<string, any> | null;
|
|
351
|
+
host_nodes: string[] | null;
|
|
352
|
+
group_id: string | null;
|
|
348
353
|
};
|
|
349
354
|
|
|
350
355
|
declare const analyticsDateInterval: (config: PinataConfig | undefined, options?: TimeIntervalAnalyticsQuery) => Promise<TimeIntervalAnalyticsResponse>;
|
|
@@ -377,6 +382,8 @@ declare const vectorizeQuery: (config: PinataConfig | undefined, options: Vector
|
|
|
377
382
|
|
|
378
383
|
declare const queue: (config: PinataConfig | undefined, options?: PinQueueQuery) => Promise<PinQueueResponse>;
|
|
379
384
|
|
|
385
|
+
declare const deletePinRequest: (config: PinataConfig | undefined, id: string) => Promise<string>;
|
|
386
|
+
|
|
380
387
|
declare const getCid: (config: PinataConfig | undefined, cid: string, gatewayType?: "ipfs" | "files", options?: OptimizeImageOptions) => Promise<GetCIDResponse>;
|
|
381
388
|
|
|
382
389
|
declare const convertIPFSUrl: (config: PinataConfig | undefined, url: string, gatewayPrefix?: string) => Promise<string>;
|
|
@@ -634,7 +641,7 @@ declare class FilterQueue {
|
|
|
634
641
|
private readonly MINUTE_IN_MS;
|
|
635
642
|
constructor(config: PinataConfig | undefined);
|
|
636
643
|
cid(cid: string): FilterQueue;
|
|
637
|
-
status(status: "prechecking" | "retrieving" | "expired" | "over_free_limit" | "over_max_size" | "invalid_object" | "bad_host_node"): FilterQueue;
|
|
644
|
+
status(status: "prechecking" | "retrieving" | "expired" | "backfilled" | "over_free_limit" | "over_max_size" | "invalid_object" | "bad_host_node"): FilterQueue;
|
|
638
645
|
pageLimit(limit: number): FilterQueue;
|
|
639
646
|
pageToken(pageToken: string): FilterQueue;
|
|
640
647
|
private fetchPage;
|
|
@@ -656,6 +663,7 @@ declare class PublicFiles {
|
|
|
656
663
|
getSwapHistory(options: SwapHistoryOptions): Promise<SwapCidResponse[]>;
|
|
657
664
|
deleteSwap(cid: string): Promise<string>;
|
|
658
665
|
queue(): FilterQueue;
|
|
666
|
+
deletePinRequest(requestId: string): Promise<string>;
|
|
659
667
|
}
|
|
660
668
|
|
|
661
669
|
declare class PrivateFiles {
|
|
@@ -792,4 +800,4 @@ declare function getFileIdFromUrl(url: string): string;
|
|
|
792
800
|
|
|
793
801
|
declare const formatConfig: (config: PinataConfig | undefined) => PinataConfig | undefined;
|
|
794
802
|
|
|
795
|
-
export { type AccessLinkOptions, type AnalyticsQuery, AuthenticationError, type ContainsCIDResponse, type ContentType, type DataEndponts, type DeleteResponse, type Endpoints, type FileListItem, type FileListQuery, type FileListResponse, type FileObject, type GetCIDResponse, type GetGroupOptions, type GroupCIDOptions, type GroupListResponse, type GroupOptions, type GroupQueryOptions, type GroupResponseItem, type JsonBody, type KeyListItem, type KeyListQuery, type KeyListResponse, type KeyOptions, type KeyPermissions, type KeyResponse, NetworkError, type OptimizeImageOptions, type PinByCIDResponse, type PinQueueItem, type PinQueueQuery, type PinQueueResponse, type PinataConfig, PinataError, type PinataMetadata, PinataSDK, type PinningEndpoints, type RevokeKeyResponse, type SignatureOptions, type SignatureResponse, type SignedUploadUrlOptions, type SwapCidOptions, type SwapCidResponse, type SwapHistoryOptions, type TimeIntervalAnalyticsQuery, type TimeIntervalAnalyticsResponse, type TimePeriodItem, type TopAnalyticsItem, type TopAnalyticsQuery, type TopAnalyticsResponse, type UpdateFileOptions, type UpdateGroupFilesResponse, type UpdateGroupOptions, type UploadCIDOptions, type UploadOptions, type UploadResponse, type UserPinnedDataResponse, ValidationError, type VectorQueryMatch, type VectorizeFileResponse, type VectorizeQuery, type VectorizeQueryResponse, addToGroup, analyticsDateInterval, analyticsTopUsage, containsCID, convertIPFSUrl, convertToDesiredGateway, createAccessLink, createGroup, createKey, createSignedUploadURL, deleteFile, deleteFileVectors, deleteGroup, deleteSwap, formatConfig, getCid, getFileIdFromUrl, getGroup, listFiles, listGroups, listKeys, pinnedFileCount, queue, removeFromGroup, revokeKeys, swapCid, swapHistory, testAuthentication, totalStorageUsage, updateFile, updateGroup, uploadBase64, uploadCid, uploadFile, uploadFileArray, uploadJson, uploadUrl, vectorizeFile, vectorizeQuery };
|
|
803
|
+
export { type AccessLinkOptions, type AnalyticsQuery, AuthenticationError, type ContainsCIDResponse, type ContentType, type DataEndponts, type DeleteResponse, type Endpoints, type FileListItem, type FileListQuery, type FileListResponse, type FileObject, type GetCIDResponse, type GetGroupOptions, type GroupCIDOptions, type GroupListResponse, type GroupOptions, type GroupQueryOptions, type GroupResponseItem, type JsonBody, type KeyListItem, type KeyListQuery, type KeyListResponse, type KeyOptions, type KeyPermissions, type KeyResponse, NetworkError, type OptimizeImageOptions, type PinByCIDResponse, type PinQueueItem, type PinQueueQuery, type PinQueueResponse, type PinataConfig, PinataError, type PinataMetadata, PinataSDK, type PinningEndpoints, type RevokeKeyResponse, type SignatureOptions, type SignatureResponse, type SignedUploadUrlOptions, type SwapCidOptions, type SwapCidResponse, type SwapHistoryOptions, type TimeIntervalAnalyticsQuery, type TimeIntervalAnalyticsResponse, type TimePeriodItem, type TopAnalyticsItem, type TopAnalyticsQuery, type TopAnalyticsResponse, type UpdateFileOptions, type UpdateGroupFilesResponse, type UpdateGroupOptions, type UploadCIDOptions, type UploadOptions, type UploadResponse, type UserPinnedDataResponse, ValidationError, type VectorQueryMatch, type VectorizeFileResponse, type VectorizeQuery, type VectorizeQueryResponse, addToGroup, analyticsDateInterval, analyticsTopUsage, containsCID, convertIPFSUrl, convertToDesiredGateway, createAccessLink, createGroup, createKey, createSignedUploadURL, deleteFile, deleteFileVectors, deleteGroup, deletePinRequest, deleteSwap, formatConfig, getCid, getFileIdFromUrl, getGroup, listFiles, listGroups, listKeys, pinnedFileCount, queue, removeFromGroup, revokeKeys, swapCid, swapHistory, testAuthentication, totalStorageUsage, updateFile, updateGroup, uploadBase64, uploadCid, uploadFile, uploadFileArray, uploadJson, uploadUrl, vectorizeFile, vectorizeQuery };
|
package/dist/index.js
CHANGED
|
@@ -38,6 +38,7 @@ __export(src_exports, {
|
|
|
38
38
|
deleteFile: () => deleteFile,
|
|
39
39
|
deleteFileVectors: () => deleteFileVectors,
|
|
40
40
|
deleteGroup: () => deleteGroup,
|
|
41
|
+
deletePinRequest: () => deletePinRequest,
|
|
41
42
|
deleteSwap: () => deleteSwap,
|
|
42
43
|
formatConfig: () => formatConfig,
|
|
43
44
|
getCid: () => getCid,
|
|
@@ -1212,7 +1213,7 @@ var vectorizeQuery = async (config, options) => {
|
|
|
1212
1213
|
throw new PinataError(`No files returned in query to fetch`);
|
|
1213
1214
|
}
|
|
1214
1215
|
const cid = resData.matches[0].cid;
|
|
1215
|
-
const fileRes = await getCid(config, cid,
|
|
1216
|
+
const fileRes = await getCid(config, cid, "files");
|
|
1216
1217
|
return fileRes;
|
|
1217
1218
|
}
|
|
1218
1219
|
return resData;
|
|
@@ -1238,21 +1239,23 @@ var queue = async (config, options) => {
|
|
|
1238
1239
|
includesCount: "false"
|
|
1239
1240
|
});
|
|
1240
1241
|
if (options) {
|
|
1241
|
-
const {
|
|
1242
|
+
const { cid, status, sort, limit, pageToken } = options;
|
|
1242
1243
|
if (cid)
|
|
1243
|
-
params.append("
|
|
1244
|
+
params.append("cid", cid.toString());
|
|
1244
1245
|
if (status)
|
|
1245
1246
|
params.append("status", status.toString());
|
|
1246
1247
|
if (sort)
|
|
1247
1248
|
params.append("sort", sort.toString());
|
|
1248
1249
|
if (limit)
|
|
1249
1250
|
params.append("limit", limit.toString());
|
|
1251
|
+
if (pageToken)
|
|
1252
|
+
params.append("pageToken", pageToken.toString());
|
|
1250
1253
|
}
|
|
1251
|
-
let endpoint = "https://api.pinata.cloud";
|
|
1254
|
+
let endpoint = "https://api.pinata.cloud/v3";
|
|
1252
1255
|
if (config.endpointUrl) {
|
|
1253
1256
|
endpoint = config.endpointUrl;
|
|
1254
1257
|
}
|
|
1255
|
-
const url = `${endpoint}/
|
|
1258
|
+
const url = `${endpoint}/files/public/pin_by_cid?${params.toString()}`;
|
|
1256
1259
|
let headers;
|
|
1257
1260
|
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
1258
1261
|
headers = {
|
|
@@ -1294,15 +1297,7 @@ var queue = async (config, options) => {
|
|
|
1294
1297
|
});
|
|
1295
1298
|
}
|
|
1296
1299
|
const res = await request.json();
|
|
1297
|
-
const resData =
|
|
1298
|
-
rows: res.rows.map((row) => ({
|
|
1299
|
-
...row,
|
|
1300
|
-
cid: row.ipfs_pin_hash,
|
|
1301
|
-
ipfs_pin_hash: void 0
|
|
1302
|
-
})),
|
|
1303
|
-
next_page_token: ""
|
|
1304
|
-
// Assuming API returns this
|
|
1305
|
-
};
|
|
1300
|
+
const resData = res.data;
|
|
1306
1301
|
return resData;
|
|
1307
1302
|
} catch (error) {
|
|
1308
1303
|
if (error instanceof PinataError) {
|
|
@@ -1315,6 +1310,69 @@ var queue = async (config, options) => {
|
|
|
1315
1310
|
}
|
|
1316
1311
|
};
|
|
1317
1312
|
|
|
1313
|
+
// src/core/functions/files/deletePinRequest.ts
|
|
1314
|
+
var deletePinRequest = async (config, id) => {
|
|
1315
|
+
if (!config) {
|
|
1316
|
+
throw new ValidationError("Pinata configuration is missing");
|
|
1317
|
+
}
|
|
1318
|
+
let headers;
|
|
1319
|
+
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
1320
|
+
headers = {
|
|
1321
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
1322
|
+
...config.customHeaders
|
|
1323
|
+
};
|
|
1324
|
+
} else {
|
|
1325
|
+
headers = {
|
|
1326
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
1327
|
+
Source: "sdk/deletePinRequest"
|
|
1328
|
+
};
|
|
1329
|
+
}
|
|
1330
|
+
let endpoint = "https://api.pinata.cloud/v3";
|
|
1331
|
+
if (config.endpointUrl) {
|
|
1332
|
+
endpoint = config.endpointUrl;
|
|
1333
|
+
}
|
|
1334
|
+
try {
|
|
1335
|
+
const response = await fetch(`${endpoint}/files/public/pin_by_cid/${id}`, {
|
|
1336
|
+
method: "DELETE",
|
|
1337
|
+
headers
|
|
1338
|
+
});
|
|
1339
|
+
if (!response.ok) {
|
|
1340
|
+
const errorData = await response.text();
|
|
1341
|
+
if (response.status === 401) {
|
|
1342
|
+
throw new AuthenticationError(
|
|
1343
|
+
`Authentication failed: ${errorData}`,
|
|
1344
|
+
response.status,
|
|
1345
|
+
{
|
|
1346
|
+
error: errorData,
|
|
1347
|
+
code: "HTTP_ERROR",
|
|
1348
|
+
metadata: {
|
|
1349
|
+
requestUrl: response.url
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
);
|
|
1353
|
+
}
|
|
1354
|
+
throw new NetworkError(`HTTP error`, response.status, {
|
|
1355
|
+
error: errorData,
|
|
1356
|
+
code: "HTTP_ERROR",
|
|
1357
|
+
metadata: {
|
|
1358
|
+
requestUrl: response.url
|
|
1359
|
+
}
|
|
1360
|
+
});
|
|
1361
|
+
}
|
|
1362
|
+
return "OK";
|
|
1363
|
+
} catch (error) {
|
|
1364
|
+
if (error instanceof PinataError) {
|
|
1365
|
+
throw error;
|
|
1366
|
+
}
|
|
1367
|
+
if (error instanceof Error) {
|
|
1368
|
+
throw new PinataError(`Error deleting pin by request: ${error.message}`);
|
|
1369
|
+
}
|
|
1370
|
+
throw new PinataError(
|
|
1371
|
+
"An unknown error occurred while deleting pin by CID request"
|
|
1372
|
+
);
|
|
1373
|
+
}
|
|
1374
|
+
};
|
|
1375
|
+
|
|
1318
1376
|
// src/core/functions/gateway/getCid.ts
|
|
1319
1377
|
var getCid = async (config, cid, gatewayType, options) => {
|
|
1320
1378
|
if (!config) {
|
|
@@ -1550,12 +1608,12 @@ async function convertToDesiredGateway(sourceUrl, desiredGatewayPrefix) {
|
|
|
1550
1608
|
throw new Error("url does not contain CID");
|
|
1551
1609
|
}
|
|
1552
1610
|
if (!sourceUrl.startsWith("https") && !sourceUrl.startsWith("ipfs://")) {
|
|
1553
|
-
return `${desiredGatewayPrefix}/
|
|
1611
|
+
return `${desiredGatewayPrefix}/ipfs/${sourceUrl}`;
|
|
1554
1612
|
}
|
|
1555
1613
|
const urlObj = new URL(sourceUrl);
|
|
1556
1614
|
const path = urlObj.pathname + urlObj.search + urlObj.hash;
|
|
1557
1615
|
if (sourceUrl.startsWith(`ipfs://${results.cid}`)) {
|
|
1558
|
-
return `${desiredGatewayPrefix}/
|
|
1616
|
+
return `${desiredGatewayPrefix}/ipfs/${results.cid}${path}`;
|
|
1559
1617
|
}
|
|
1560
1618
|
if (sourceUrl.includes(`/ipfs/${results.cid}`)) {
|
|
1561
1619
|
return `${desiredGatewayPrefix}${path}`;
|
|
@@ -1564,7 +1622,7 @@ async function convertToDesiredGateway(sourceUrl, desiredGatewayPrefix) {
|
|
|
1564
1622
|
return `${desiredGatewayPrefix}${path}`;
|
|
1565
1623
|
}
|
|
1566
1624
|
if (urlObj.hostname.includes(results.cid)) {
|
|
1567
|
-
return `${desiredGatewayPrefix}/
|
|
1625
|
+
return `${desiredGatewayPrefix}/ipfs/${results.cid}${path}`;
|
|
1568
1626
|
}
|
|
1569
1627
|
throw new Error(
|
|
1570
1628
|
"unsupported URL pattern, please submit a github issue with the URL utilized"
|
|
@@ -3406,23 +3464,20 @@ var uploadCid = async (config, cid, options) => {
|
|
|
3406
3464
|
Source: "sdk/cid"
|
|
3407
3465
|
};
|
|
3408
3466
|
}
|
|
3409
|
-
const
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
}
|
|
3419
|
-
});
|
|
3420
|
-
let endpoint = "https://api.pinata.cloud";
|
|
3467
|
+
const requestBody = {
|
|
3468
|
+
cid,
|
|
3469
|
+
name: options?.metadata ? options?.metadata?.name : cid,
|
|
3470
|
+
keyvalues: options?.metadata?.keyvalues,
|
|
3471
|
+
group_id: options?.groupId,
|
|
3472
|
+
host_nodes: options?.peerAddresses
|
|
3473
|
+
};
|
|
3474
|
+
const data = JSON.stringify(requestBody);
|
|
3475
|
+
let endpoint = "https://api.pinata.cloud/v3";
|
|
3421
3476
|
if (config.endpointUrl) {
|
|
3422
3477
|
endpoint = config.endpointUrl;
|
|
3423
3478
|
}
|
|
3424
3479
|
try {
|
|
3425
|
-
const request = await fetch(`${endpoint}/
|
|
3480
|
+
const request = await fetch(`${endpoint}/files/public/pin_by_cid`, {
|
|
3426
3481
|
method: "POST",
|
|
3427
3482
|
headers,
|
|
3428
3483
|
body: data
|
|
@@ -3451,12 +3506,7 @@ var uploadCid = async (config, cid, options) => {
|
|
|
3451
3506
|
});
|
|
3452
3507
|
}
|
|
3453
3508
|
const res = await request.json();
|
|
3454
|
-
const resData =
|
|
3455
|
-
id: res.id,
|
|
3456
|
-
cid: res.ipfsHash,
|
|
3457
|
-
name: res.name,
|
|
3458
|
-
status: res.status
|
|
3459
|
-
};
|
|
3509
|
+
const resData = res.data;
|
|
3460
3510
|
return resData;
|
|
3461
3511
|
} catch (error) {
|
|
3462
3512
|
if (error instanceof PinataError) {
|
|
@@ -4204,7 +4254,7 @@ var FilterQueue = class {
|
|
|
4204
4254
|
this.config = config;
|
|
4205
4255
|
}
|
|
4206
4256
|
cid(cid) {
|
|
4207
|
-
this.query.
|
|
4257
|
+
this.query.cid = cid;
|
|
4208
4258
|
return this;
|
|
4209
4259
|
}
|
|
4210
4260
|
status(status) {
|
|
@@ -4297,6 +4347,9 @@ var PublicFiles = class {
|
|
|
4297
4347
|
queue() {
|
|
4298
4348
|
return new FilterQueue(this.config);
|
|
4299
4349
|
}
|
|
4350
|
+
deletePinRequest(requestId) {
|
|
4351
|
+
return deletePinRequest(this.config, requestId);
|
|
4352
|
+
}
|
|
4300
4353
|
};
|
|
4301
4354
|
|
|
4302
4355
|
// src/core/classes/files/PrivateFiles.ts
|
|
@@ -4412,7 +4465,7 @@ var UploadBuilder = class {
|
|
|
4412
4465
|
if (this.uploadUrl) {
|
|
4413
4466
|
options.url = this.uploadUrl;
|
|
4414
4467
|
}
|
|
4415
|
-
if (this.peerAddresses
|
|
4468
|
+
if (this.peerAddresses) {
|
|
4416
4469
|
options.peerAddresses = this.peerAddresses;
|
|
4417
4470
|
}
|
|
4418
4471
|
this.args[this.args.length - 1] = options;
|
|
@@ -4859,6 +4912,7 @@ var PinataSDK = class {
|
|
|
4859
4912
|
deleteFile,
|
|
4860
4913
|
deleteFileVectors,
|
|
4861
4914
|
deleteGroup,
|
|
4915
|
+
deletePinRequest,
|
|
4862
4916
|
deleteSwap,
|
|
4863
4917
|
formatConfig,
|
|
4864
4918
|
getCid,
|