pinata 2.5.0 → 2.5.2
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/{gateway-tools-l9hk7kz4.d.mts → gateway-tools-C0QGU-4p.d.mts} +12 -1
- package/dist/{gateway-tools-l9hk7kz4.d.ts → gateway-tools-C0QGU-4p.d.ts} +12 -1
- package/dist/index.d.mts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +48 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -30
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.mts +2 -2
- package/dist/react/index.d.ts +2 -2
- package/package.json +3 -2
|
@@ -133,6 +133,7 @@ type ContainsCIDResponse = {
|
|
|
133
133
|
cid: string | null;
|
|
134
134
|
};
|
|
135
135
|
|
|
136
|
+
type CidVersion = "v0" | "v1";
|
|
136
137
|
type UploadResponse = {
|
|
137
138
|
id: string;
|
|
138
139
|
name: string;
|
|
@@ -156,6 +157,11 @@ type UploadOptions = {
|
|
|
156
157
|
url?: string;
|
|
157
158
|
streamable?: boolean;
|
|
158
159
|
peerAddresses?: string[];
|
|
160
|
+
car?: boolean;
|
|
161
|
+
/**
|
|
162
|
+
* CID version "v1" or "v0" (defaults to v1 if falsy)
|
|
163
|
+
*/
|
|
164
|
+
cid_version?: CidVersion;
|
|
159
165
|
};
|
|
160
166
|
type SignedUploadUrlOptions = {
|
|
161
167
|
date?: number;
|
|
@@ -167,6 +173,11 @@ type SignedUploadUrlOptions = {
|
|
|
167
173
|
maxFileSize?: number;
|
|
168
174
|
mimeTypes?: string[];
|
|
169
175
|
streamable?: boolean;
|
|
176
|
+
car?: boolean;
|
|
177
|
+
/**
|
|
178
|
+
* CID version "v1" or "v0" (defaults to v1 if falsy)
|
|
179
|
+
*/
|
|
180
|
+
cid_version?: CidVersion;
|
|
170
181
|
};
|
|
171
182
|
type UploadCIDOptions = {
|
|
172
183
|
metadata?: PinataMetadata;
|
|
@@ -208,4 +219,4 @@ declare class ValidationError extends PinataError {
|
|
|
208
219
|
declare function containsCID(input: string): Promise<ContainsCIDResponse>;
|
|
209
220
|
declare function convertToDesiredGateway(sourceUrl: string, desiredGatewayPrefix: string | undefined): Promise<string>;
|
|
210
221
|
|
|
211
|
-
export { type AccessLinkOptions as A, type
|
|
222
|
+
export { type AccessLinkOptions as A, type CidVersion as C, type DeleteResponse as D, type FileListQuery as F, type GetCIDResponse as G, type JsonBody as J, NetworkError as N, type OptimizeImageOptions as O, type PinQueueQuery as P, type SwapCidOptions as S, type UpdateFileOptions as U, type VectorizeFileResponse as V, type FileListResponse as a, type SwapCidResponse as b, type SwapHistoryOptions as c, type FileListItem as d, type VectorizeQuery as e, type VectorizeQueryResponse as f, type PinQueueResponse as g, type UploadOptions as h, type UploadResponse as i, type SignedUploadUrlOptions as j, type UploadCIDOptions as k, type PinByCIDResponse as l, type PinQueueItem as m, type FileObject as n, type PinataMetadata as o, type VectorQueryMatch as p, type ContentType as q, type ContainsCIDResponse as r, PinataError as s, AuthenticationError as t, ValidationError as u, containsCID as v, convertToDesiredGateway as w };
|
|
@@ -133,6 +133,7 @@ type ContainsCIDResponse = {
|
|
|
133
133
|
cid: string | null;
|
|
134
134
|
};
|
|
135
135
|
|
|
136
|
+
type CidVersion = "v0" | "v1";
|
|
136
137
|
type UploadResponse = {
|
|
137
138
|
id: string;
|
|
138
139
|
name: string;
|
|
@@ -156,6 +157,11 @@ type UploadOptions = {
|
|
|
156
157
|
url?: string;
|
|
157
158
|
streamable?: boolean;
|
|
158
159
|
peerAddresses?: string[];
|
|
160
|
+
car?: boolean;
|
|
161
|
+
/**
|
|
162
|
+
* CID version "v1" or "v0" (defaults to v1 if falsy)
|
|
163
|
+
*/
|
|
164
|
+
cid_version?: CidVersion;
|
|
159
165
|
};
|
|
160
166
|
type SignedUploadUrlOptions = {
|
|
161
167
|
date?: number;
|
|
@@ -167,6 +173,11 @@ type SignedUploadUrlOptions = {
|
|
|
167
173
|
maxFileSize?: number;
|
|
168
174
|
mimeTypes?: string[];
|
|
169
175
|
streamable?: boolean;
|
|
176
|
+
car?: boolean;
|
|
177
|
+
/**
|
|
178
|
+
* CID version "v1" or "v0" (defaults to v1 if falsy)
|
|
179
|
+
*/
|
|
180
|
+
cid_version?: CidVersion;
|
|
170
181
|
};
|
|
171
182
|
type UploadCIDOptions = {
|
|
172
183
|
metadata?: PinataMetadata;
|
|
@@ -208,4 +219,4 @@ declare class ValidationError extends PinataError {
|
|
|
208
219
|
declare function containsCID(input: string): Promise<ContainsCIDResponse>;
|
|
209
220
|
declare function convertToDesiredGateway(sourceUrl: string, desiredGatewayPrefix: string | undefined): Promise<string>;
|
|
210
221
|
|
|
211
|
-
export { type AccessLinkOptions as A, type
|
|
222
|
+
export { type AccessLinkOptions as A, type CidVersion as C, type DeleteResponse as D, type FileListQuery as F, type GetCIDResponse as G, type JsonBody as J, NetworkError as N, type OptimizeImageOptions as O, type PinQueueQuery as P, type SwapCidOptions as S, type UpdateFileOptions as U, type VectorizeFileResponse as V, type FileListResponse as a, type SwapCidResponse as b, type SwapHistoryOptions as c, type FileListItem as d, type VectorizeQuery as e, type VectorizeQueryResponse as f, type PinQueueResponse as g, type UploadOptions as h, type UploadResponse as i, type SignedUploadUrlOptions as j, type UploadCIDOptions as k, type PinByCIDResponse as l, type PinQueueItem as m, type FileObject as n, type PinataMetadata as o, type VectorQueryMatch as p, type ContentType as q, type ContainsCIDResponse as r, PinataError as s, AuthenticationError as t, ValidationError as u, containsCID as v, convertToDesiredGateway as w };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DeleteResponse, V as VectorizeFileResponse, F as FileListQuery, a as FileListResponse, S as SwapCidOptions, b as SwapCidResponse, c as SwapHistoryOptions, U as UpdateFileOptions, d as FileListItem, e as VectorizeQuery, f as VectorizeQueryResponse, G as GetCIDResponse, P as PinQueueQuery, g as PinQueueResponse, O as OptimizeImageOptions, A as AccessLinkOptions, h as UploadOptions, i as UploadResponse, j as SignedUploadUrlOptions, J as JsonBody, k as UploadCIDOptions, l as PinByCIDResponse, m as PinQueueItem } from './gateway-tools-
|
|
2
|
-
export {
|
|
1
|
+
import { D as DeleteResponse, V as VectorizeFileResponse, F as FileListQuery, a as FileListResponse, S as SwapCidOptions, b as SwapCidResponse, c as SwapHistoryOptions, U as UpdateFileOptions, d as FileListItem, e as VectorizeQuery, f as VectorizeQueryResponse, G as GetCIDResponse, P as PinQueueQuery, g as PinQueueResponse, O as OptimizeImageOptions, A as AccessLinkOptions, h as UploadOptions, i as UploadResponse, j as SignedUploadUrlOptions, J as JsonBody, k as UploadCIDOptions, l as PinByCIDResponse, m as PinQueueItem, C as CidVersion } from './gateway-tools-C0QGU-4p.mjs';
|
|
2
|
+
export { t as AuthenticationError, r as ContainsCIDResponse, q as ContentType, n as FileObject, N as NetworkError, s as PinataError, o as PinataMetadata, u as ValidationError, p as VectorQueryMatch, v as containsCID, w as convertToDesiredGateway } from './gateway-tools-C0QGU-4p.mjs';
|
|
3
3
|
|
|
4
4
|
type PinataConfig = {
|
|
5
5
|
pinataJwt?: string;
|
|
@@ -523,14 +523,18 @@ declare class UploadBuilder<T> {
|
|
|
523
523
|
private uploadUrl;
|
|
524
524
|
private isStreamable;
|
|
525
525
|
private peerAddresses;
|
|
526
|
+
private carFormat;
|
|
527
|
+
private _cidVersion;
|
|
526
528
|
constructor(config: PinataConfig | undefined, uploadFunction: (config: PinataConfig | undefined, ...args: any[]) => Promise<T>, ...args: any[]);
|
|
527
529
|
name(name: string): UploadBuilder<T>;
|
|
528
530
|
keyvalues(keyvalues: Record<string, string>): UploadBuilder<T>;
|
|
529
531
|
key(jwt: string): UploadBuilder<T>;
|
|
530
532
|
vectorize(): UploadBuilder<T>;
|
|
531
533
|
url(url: string): UploadBuilder<T>;
|
|
534
|
+
cidVersion(v: CidVersion): UploadBuilder<T>;
|
|
532
535
|
group(groupId: string): UploadBuilder<T>;
|
|
533
536
|
streamable(): UploadBuilder<T>;
|
|
537
|
+
car(): UploadBuilder<T>;
|
|
534
538
|
peerAddress(peerAddresses: string[]): UploadBuilder<T>;
|
|
535
539
|
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
|
|
536
540
|
}
|
|
@@ -602,4 +606,4 @@ declare function getFileIdFromUrl(url: string): string;
|
|
|
602
606
|
|
|
603
607
|
declare const formatConfig: (config: PinataConfig | undefined) => PinataConfig | undefined;
|
|
604
608
|
|
|
605
|
-
export { AccessLinkOptions, type AnalyticsQuery, type DataEndponts, DeleteResponse, type Endpoints, FileListItem, FileListQuery, FileListResponse, GetCIDResponse, type GetGroupOptions, type GroupCIDOptions, type GroupListResponse, type GroupOptions, type GroupQueryOptions, type GroupResponseItem, JsonBody, type KeyListItem, type KeyListQuery, type KeyListResponse, type KeyOptions, type KeyPermissions, type KeyResponse, OptimizeImageOptions, PinByCIDResponse, PinQueueItem, PinQueueQuery, PinQueueResponse, type PinataConfig, PinataSDK, type PinningEndpoints, type ResourcePermission, type RevokeKeyResponse, type SignatureOptions, type SignatureResponse, SignedUploadUrlOptions, SwapCidOptions, SwapCidResponse, SwapHistoryOptions, type TimeIntervalAnalyticsQuery, type TimeIntervalAnalyticsResponse, type TimePeriodItem, type TopAnalyticsItem, type TopAnalyticsQuery, type TopAnalyticsResponse, UpdateFileOptions, type UpdateGroupFilesResponse, type UpdateGroupOptions, UploadCIDOptions, UploadOptions, UploadResponse, type UserPinnedDataResponse, VectorizeFileResponse, VectorizeQuery, VectorizeQueryResponse, addToGroup, analyticsDateInterval, analyticsTopUsage, convertIPFSUrl, 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 };
|
|
609
|
+
export { AccessLinkOptions, type AnalyticsQuery, CidVersion, type DataEndponts, DeleteResponse, type Endpoints, FileListItem, FileListQuery, FileListResponse, GetCIDResponse, type GetGroupOptions, type GroupCIDOptions, type GroupListResponse, type GroupOptions, type GroupQueryOptions, type GroupResponseItem, JsonBody, type KeyListItem, type KeyListQuery, type KeyListResponse, type KeyOptions, type KeyPermissions, type KeyResponse, OptimizeImageOptions, PinByCIDResponse, PinQueueItem, PinQueueQuery, PinQueueResponse, type PinataConfig, PinataSDK, type PinningEndpoints, type ResourcePermission, type RevokeKeyResponse, type SignatureOptions, type SignatureResponse, SignedUploadUrlOptions, SwapCidOptions, SwapCidResponse, SwapHistoryOptions, type TimeIntervalAnalyticsQuery, type TimeIntervalAnalyticsResponse, type TimePeriodItem, type TopAnalyticsItem, type TopAnalyticsQuery, type TopAnalyticsResponse, UpdateFileOptions, type UpdateGroupFilesResponse, type UpdateGroupOptions, UploadCIDOptions, UploadOptions, UploadResponse, type UserPinnedDataResponse, VectorizeFileResponse, VectorizeQuery, VectorizeQueryResponse, addToGroup, analyticsDateInterval, analyticsTopUsage, convertIPFSUrl, 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
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DeleteResponse, V as VectorizeFileResponse, F as FileListQuery, a as FileListResponse, S as SwapCidOptions, b as SwapCidResponse, c as SwapHistoryOptions, U as UpdateFileOptions, d as FileListItem, e as VectorizeQuery, f as VectorizeQueryResponse, G as GetCIDResponse, P as PinQueueQuery, g as PinQueueResponse, O as OptimizeImageOptions, A as AccessLinkOptions, h as UploadOptions, i as UploadResponse, j as SignedUploadUrlOptions, J as JsonBody, k as UploadCIDOptions, l as PinByCIDResponse, m as PinQueueItem } from './gateway-tools-
|
|
2
|
-
export {
|
|
1
|
+
import { D as DeleteResponse, V as VectorizeFileResponse, F as FileListQuery, a as FileListResponse, S as SwapCidOptions, b as SwapCidResponse, c as SwapHistoryOptions, U as UpdateFileOptions, d as FileListItem, e as VectorizeQuery, f as VectorizeQueryResponse, G as GetCIDResponse, P as PinQueueQuery, g as PinQueueResponse, O as OptimizeImageOptions, A as AccessLinkOptions, h as UploadOptions, i as UploadResponse, j as SignedUploadUrlOptions, J as JsonBody, k as UploadCIDOptions, l as PinByCIDResponse, m as PinQueueItem, C as CidVersion } from './gateway-tools-C0QGU-4p.js';
|
|
2
|
+
export { t as AuthenticationError, r as ContainsCIDResponse, q as ContentType, n as FileObject, N as NetworkError, s as PinataError, o as PinataMetadata, u as ValidationError, p as VectorQueryMatch, v as containsCID, w as convertToDesiredGateway } from './gateway-tools-C0QGU-4p.js';
|
|
3
3
|
|
|
4
4
|
type PinataConfig = {
|
|
5
5
|
pinataJwt?: string;
|
|
@@ -523,14 +523,18 @@ declare class UploadBuilder<T> {
|
|
|
523
523
|
private uploadUrl;
|
|
524
524
|
private isStreamable;
|
|
525
525
|
private peerAddresses;
|
|
526
|
+
private carFormat;
|
|
527
|
+
private _cidVersion;
|
|
526
528
|
constructor(config: PinataConfig | undefined, uploadFunction: (config: PinataConfig | undefined, ...args: any[]) => Promise<T>, ...args: any[]);
|
|
527
529
|
name(name: string): UploadBuilder<T>;
|
|
528
530
|
keyvalues(keyvalues: Record<string, string>): UploadBuilder<T>;
|
|
529
531
|
key(jwt: string): UploadBuilder<T>;
|
|
530
532
|
vectorize(): UploadBuilder<T>;
|
|
531
533
|
url(url: string): UploadBuilder<T>;
|
|
534
|
+
cidVersion(v: CidVersion): UploadBuilder<T>;
|
|
532
535
|
group(groupId: string): UploadBuilder<T>;
|
|
533
536
|
streamable(): UploadBuilder<T>;
|
|
537
|
+
car(): UploadBuilder<T>;
|
|
534
538
|
peerAddress(peerAddresses: string[]): UploadBuilder<T>;
|
|
535
539
|
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
|
|
536
540
|
}
|
|
@@ -602,4 +606,4 @@ declare function getFileIdFromUrl(url: string): string;
|
|
|
602
606
|
|
|
603
607
|
declare const formatConfig: (config: PinataConfig | undefined) => PinataConfig | undefined;
|
|
604
608
|
|
|
605
|
-
export { AccessLinkOptions, type AnalyticsQuery, type DataEndponts, DeleteResponse, type Endpoints, FileListItem, FileListQuery, FileListResponse, GetCIDResponse, type GetGroupOptions, type GroupCIDOptions, type GroupListResponse, type GroupOptions, type GroupQueryOptions, type GroupResponseItem, JsonBody, type KeyListItem, type KeyListQuery, type KeyListResponse, type KeyOptions, type KeyPermissions, type KeyResponse, OptimizeImageOptions, PinByCIDResponse, PinQueueItem, PinQueueQuery, PinQueueResponse, type PinataConfig, PinataSDK, type PinningEndpoints, type ResourcePermission, type RevokeKeyResponse, type SignatureOptions, type SignatureResponse, SignedUploadUrlOptions, SwapCidOptions, SwapCidResponse, SwapHistoryOptions, type TimeIntervalAnalyticsQuery, type TimeIntervalAnalyticsResponse, type TimePeriodItem, type TopAnalyticsItem, type TopAnalyticsQuery, type TopAnalyticsResponse, UpdateFileOptions, type UpdateGroupFilesResponse, type UpdateGroupOptions, UploadCIDOptions, UploadOptions, UploadResponse, type UserPinnedDataResponse, VectorizeFileResponse, VectorizeQuery, VectorizeQueryResponse, addToGroup, analyticsDateInterval, analyticsTopUsage, convertIPFSUrl, 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 };
|
|
609
|
+
export { AccessLinkOptions, type AnalyticsQuery, CidVersion, type DataEndponts, DeleteResponse, type Endpoints, FileListItem, FileListQuery, FileListResponse, GetCIDResponse, type GetGroupOptions, type GroupCIDOptions, type GroupListResponse, type GroupOptions, type GroupQueryOptions, type GroupResponseItem, JsonBody, type KeyListItem, type KeyListQuery, type KeyListResponse, type KeyOptions, type KeyPermissions, type KeyResponse, OptimizeImageOptions, PinByCIDResponse, PinQueueItem, PinQueueQuery, PinQueueResponse, type PinataConfig, PinataSDK, type PinningEndpoints, type ResourcePermission, type RevokeKeyResponse, type SignatureOptions, type SignatureResponse, SignedUploadUrlOptions, SwapCidOptions, SwapCidResponse, SwapHistoryOptions, type TimeIntervalAnalyticsQuery, type TimeIntervalAnalyticsResponse, type TimePeriodItem, type TopAnalyticsItem, type TopAnalyticsQuery, type TopAnalyticsResponse, UpdateFileOptions, type UpdateGroupFilesResponse, type UpdateGroupOptions, UploadCIDOptions, UploadOptions, UploadResponse, type UserPinnedDataResponse, VectorizeFileResponse, VectorizeQuery, VectorizeQueryResponse, addToGroup, analyticsDateInterval, analyticsTopUsage, convertIPFSUrl, 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
|
@@ -2458,9 +2458,8 @@ var createSignedUploadURL = async (config, options, network) => {
|
|
|
2458
2458
|
Source: "sdk/createSignURL"
|
|
2459
2459
|
};
|
|
2460
2460
|
}
|
|
2461
|
-
let retryCount = 0;
|
|
2462
2461
|
const maxRetries = 3;
|
|
2463
|
-
|
|
2462
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
2464
2463
|
try {
|
|
2465
2464
|
const request = await fetch(`${endpoint}/files/sign`, {
|
|
2466
2465
|
method: "POST",
|
|
@@ -2483,21 +2482,13 @@ var createSignedUploadURL = async (config, options, network) => {
|
|
|
2483
2482
|
}
|
|
2484
2483
|
);
|
|
2485
2484
|
}
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
{
|
|
2490
|
-
|
|
2491
|
-
code: "HTTP_ERROR",
|
|
2492
|
-
metadata: {
|
|
2493
|
-
requestUrl: request.url
|
|
2494
|
-
}
|
|
2485
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
2486
|
+
error: errorData,
|
|
2487
|
+
code: "HTTP_ERROR",
|
|
2488
|
+
metadata: {
|
|
2489
|
+
requestUrl: request.url
|
|
2495
2490
|
}
|
|
2496
|
-
);
|
|
2497
|
-
if (request.status >= 400 && request.status < 500 && request.status !== 429) {
|
|
2498
|
-
throw error;
|
|
2499
|
-
}
|
|
2500
|
-
throw error;
|
|
2491
|
+
});
|
|
2501
2492
|
}
|
|
2502
2493
|
const res = await request.json();
|
|
2503
2494
|
return res.data;
|
|
@@ -2508,27 +2499,24 @@ var createSignedUploadURL = async (config, options, network) => {
|
|
|
2508
2499
|
if (error instanceof chunkBK3CLF3Z_js.NetworkError && error.statusCode && error.statusCode >= 400 && error.statusCode < 500 && error.statusCode !== 429) {
|
|
2509
2500
|
throw error;
|
|
2510
2501
|
}
|
|
2511
|
-
|
|
2512
|
-
if (retryCount > maxRetries) {
|
|
2502
|
+
if (attempt === maxRetries) {
|
|
2513
2503
|
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
2514
2504
|
throw error;
|
|
2515
2505
|
}
|
|
2516
2506
|
if (error instanceof Error) {
|
|
2517
2507
|
throw new chunkBK3CLF3Z_js.PinataError(
|
|
2518
|
-
`Error processing createSignedURL
|
|
2508
|
+
`Error processing createSignedURL: ${error.message}`
|
|
2519
2509
|
);
|
|
2520
2510
|
}
|
|
2521
2511
|
throw new chunkBK3CLF3Z_js.PinataError(
|
|
2522
|
-
|
|
2512
|
+
"An unknown error occurred while getting signed url"
|
|
2523
2513
|
);
|
|
2524
2514
|
}
|
|
2525
|
-
const delay = Math.min(1e3 * Math.pow(2,
|
|
2515
|
+
const delay = Math.min(1e3 * Math.pow(2, attempt), 4e3);
|
|
2526
2516
|
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
2527
2517
|
}
|
|
2528
2518
|
}
|
|
2529
|
-
|
|
2530
|
-
new chunkBK3CLF3Z_js.PinataError("Unexpected error: retry loop completed without resolution")
|
|
2531
|
-
);
|
|
2519
|
+
throw new chunkBK3CLF3Z_js.PinataError("An unknown error occurred while getting signed url");
|
|
2532
2520
|
};
|
|
2533
2521
|
|
|
2534
2522
|
// src/core/functions/uploads/file.ts
|
|
@@ -2565,11 +2553,24 @@ var uploadFile = async (config, file, network, options) => {
|
|
|
2565
2553
|
if (options?.streamable) {
|
|
2566
2554
|
metadata += `,streamable ${btoa("true")}`;
|
|
2567
2555
|
}
|
|
2556
|
+
if (options?.car) {
|
|
2557
|
+
metadata += `,car ${btoa("true")}`;
|
|
2558
|
+
}
|
|
2559
|
+
if (options?.cid_version !== void 0) {
|
|
2560
|
+
metadata += `,cid_version ${btoa(options.cid_version)}`;
|
|
2561
|
+
}
|
|
2568
2562
|
let updatedEndpoint = `${endpoint}/files`;
|
|
2569
2563
|
if (options?.url) {
|
|
2570
2564
|
updatedEndpoint = options.url;
|
|
2571
2565
|
}
|
|
2572
|
-
const
|
|
2566
|
+
const requestUrl = new URL(updatedEndpoint);
|
|
2567
|
+
if (options?.cid_version !== void 0) {
|
|
2568
|
+
requestUrl.searchParams.set(
|
|
2569
|
+
"X-Upload-Option-Cid-Version",
|
|
2570
|
+
options.cid_version.toString()
|
|
2571
|
+
);
|
|
2572
|
+
}
|
|
2573
|
+
const urlReq = await fetch(requestUrl.toString(), {
|
|
2573
2574
|
method: "POST",
|
|
2574
2575
|
headers: {
|
|
2575
2576
|
"Upload-Length": `${file.size}`,
|
|
@@ -2728,9 +2729,16 @@ var uploadFile = async (config, file, network, options) => {
|
|
|
2728
2729
|
if (options?.streamable) {
|
|
2729
2730
|
data.append("streamable", "true");
|
|
2730
2731
|
}
|
|
2732
|
+
if (options?.car) {
|
|
2733
|
+
data.append("car", "true");
|
|
2734
|
+
}
|
|
2735
|
+
if (options?.cid_version !== void 0) {
|
|
2736
|
+
data.append("cid_version", options.cid_version.toString());
|
|
2737
|
+
}
|
|
2731
2738
|
if (options?.url) {
|
|
2732
2739
|
try {
|
|
2733
|
-
const
|
|
2740
|
+
const url = new URL(options.url);
|
|
2741
|
+
const request = await fetch(url.toString(), {
|
|
2734
2742
|
method: "POST",
|
|
2735
2743
|
headers,
|
|
2736
2744
|
body: data
|
|
@@ -4250,10 +4258,10 @@ var UploadBuilder = class {
|
|
|
4250
4258
|
this.uploadUrl = url;
|
|
4251
4259
|
return this;
|
|
4252
4260
|
}
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4261
|
+
cidVersion(v) {
|
|
4262
|
+
this._cidVersion = v;
|
|
4263
|
+
return this;
|
|
4264
|
+
}
|
|
4257
4265
|
group(groupId) {
|
|
4258
4266
|
this.groupId = groupId;
|
|
4259
4267
|
return this;
|
|
@@ -4262,6 +4270,10 @@ var UploadBuilder = class {
|
|
|
4262
4270
|
this.isStreamable = true;
|
|
4263
4271
|
return this;
|
|
4264
4272
|
}
|
|
4273
|
+
car() {
|
|
4274
|
+
this.carFormat = true;
|
|
4275
|
+
return this;
|
|
4276
|
+
}
|
|
4265
4277
|
peerAddress(peerAddresses) {
|
|
4266
4278
|
this.peerAddresses = peerAddresses;
|
|
4267
4279
|
return this;
|
|
@@ -4289,6 +4301,12 @@ var UploadBuilder = class {
|
|
|
4289
4301
|
if (this.peerAddresses) {
|
|
4290
4302
|
options.peerAddresses = this.peerAddresses;
|
|
4291
4303
|
}
|
|
4304
|
+
if (this.carFormat) {
|
|
4305
|
+
options.car = this.carFormat;
|
|
4306
|
+
}
|
|
4307
|
+
if (this._cidVersion !== void 0) {
|
|
4308
|
+
options.cid_version = this._cidVersion;
|
|
4309
|
+
}
|
|
4292
4310
|
this.args[this.args.length - 1] = options;
|
|
4293
4311
|
return this.uploadFunction(this.config, ...this.args).then(
|
|
4294
4312
|
onfulfilled,
|