pinata 2.5.4 → 2.5.6
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/LICENSE +0 -0
- package/README.md +1 -1
- package/dist/{gateway-tools-C-tdEyF2.d.mts → gateway-tools-Cx64TJRo.d.mts} +21 -0
- package/dist/{gateway-tools-C-tdEyF2.d.ts → gateway-tools-Cx64TJRo.d.ts} +21 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +89 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +89 -14
- 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 +63 -69
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
@@ -179,7 +179,28 @@ type SignedUploadUrlOptions = {
|
|
|
179
179
|
keyvalues?: Record<string, string>;
|
|
180
180
|
vectorize?: boolean;
|
|
181
181
|
maxFileSize?: number;
|
|
182
|
+
/**
|
|
183
|
+
* Restrict the signed URL to specific MIME types.
|
|
184
|
+
*
|
|
185
|
+
* NOTE: For directory uploads (e.g. `pinata.upload.public.fileArray(...).url(...)`),
|
|
186
|
+
* this array MUST include the synthetic `"directory"` MIME type — otherwise the
|
|
187
|
+
* upload will be rejected with `400 "Presigned URL does not grant permissions to
|
|
188
|
+
* upload detected MIME type: directory"`. Aliases like `application/x-directory` or
|
|
189
|
+
* `inode/directory` are NOT accepted, and a wildcard (`["*"]` / `["*\/*"]`) does not
|
|
190
|
+
* cover it.
|
|
191
|
+
*
|
|
192
|
+
* Example: `mimeTypes: ["directory"]` (or `["directory", "text/plain"]` to also
|
|
193
|
+
* allow plain-text files inside the directory).
|
|
194
|
+
*/
|
|
182
195
|
mimeTypes?: string[];
|
|
196
|
+
/**
|
|
197
|
+
* Mint this signed URL for directory uploads (e.g. `fileArray(...).url(...)`).
|
|
198
|
+
*
|
|
199
|
+
* Adds `"directory"` to `mimeTypes` so the API permits the synthetic directory
|
|
200
|
+
* MIME type. Any other entries in `mimeTypes` are preserved, so you can both
|
|
201
|
+
* allow a directory and constrain the file types inside it.
|
|
202
|
+
*/
|
|
203
|
+
forDirectory?: boolean;
|
|
183
204
|
streamable?: boolean;
|
|
184
205
|
car?: boolean;
|
|
185
206
|
/**
|
|
@@ -179,7 +179,28 @@ type SignedUploadUrlOptions = {
|
|
|
179
179
|
keyvalues?: Record<string, string>;
|
|
180
180
|
vectorize?: boolean;
|
|
181
181
|
maxFileSize?: number;
|
|
182
|
+
/**
|
|
183
|
+
* Restrict the signed URL to specific MIME types.
|
|
184
|
+
*
|
|
185
|
+
* NOTE: For directory uploads (e.g. `pinata.upload.public.fileArray(...).url(...)`),
|
|
186
|
+
* this array MUST include the synthetic `"directory"` MIME type — otherwise the
|
|
187
|
+
* upload will be rejected with `400 "Presigned URL does not grant permissions to
|
|
188
|
+
* upload detected MIME type: directory"`. Aliases like `application/x-directory` or
|
|
189
|
+
* `inode/directory` are NOT accepted, and a wildcard (`["*"]` / `["*\/*"]`) does not
|
|
190
|
+
* cover it.
|
|
191
|
+
*
|
|
192
|
+
* Example: `mimeTypes: ["directory"]` (or `["directory", "text/plain"]` to also
|
|
193
|
+
* allow plain-text files inside the directory).
|
|
194
|
+
*/
|
|
182
195
|
mimeTypes?: string[];
|
|
196
|
+
/**
|
|
197
|
+
* Mint this signed URL for directory uploads (e.g. `fileArray(...).url(...)`).
|
|
198
|
+
*
|
|
199
|
+
* Adds `"directory"` to `mimeTypes` so the API permits the synthetic directory
|
|
200
|
+
* MIME type. Any other entries in `mimeTypes` are preserved, so you can both
|
|
201
|
+
* allow a directory and constrain the file types inside it.
|
|
202
|
+
*/
|
|
203
|
+
forDirectory?: boolean;
|
|
183
204
|
streamable?: boolean;
|
|
184
205
|
car?: boolean;
|
|
185
206
|
/**
|
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, C as CidVersion } from './gateway-tools-
|
|
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-
|
|
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-Cx64TJRo.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-Cx64TJRo.mjs';
|
|
3
3
|
|
|
4
4
|
type PinataConfig = {
|
|
5
5
|
pinataJwt?: string;
|
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, C as CidVersion } from './gateway-tools-
|
|
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-
|
|
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-Cx64TJRo.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-Cx64TJRo.js';
|
|
3
3
|
|
|
4
4
|
type PinataConfig = {
|
|
5
5
|
pinataJwt?: string;
|
package/dist/index.js
CHANGED
|
@@ -2440,8 +2440,12 @@ var createSignedUploadURL = async (config, options, network) => {
|
|
|
2440
2440
|
if (options.maxFileSize) {
|
|
2441
2441
|
payload.max_file_size = options.maxFileSize;
|
|
2442
2442
|
}
|
|
2443
|
-
if (options.mimeTypes) {
|
|
2444
|
-
|
|
2443
|
+
if (options.mimeTypes || options.forDirectory) {
|
|
2444
|
+
const types = new Set(options.mimeTypes ?? []);
|
|
2445
|
+
if (options.forDirectory) {
|
|
2446
|
+
types.add("directory");
|
|
2447
|
+
}
|
|
2448
|
+
payload.allow_mime_types = Array.from(types);
|
|
2445
2449
|
}
|
|
2446
2450
|
let endpoint = "https://uploads.pinata.cloud/v3";
|
|
2447
2451
|
if (config.uploadUrl) {
|
|
@@ -2882,6 +2886,89 @@ var uploadFileArray = async (config, files, network, options) => {
|
|
|
2882
2886
|
}
|
|
2883
2887
|
const jwt = options?.keys || config?.pinataJwt;
|
|
2884
2888
|
const folder = options?.metadata?.name || "folder_from_sdk";
|
|
2889
|
+
let headers;
|
|
2890
|
+
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
2891
|
+
headers = {
|
|
2892
|
+
Authorization: `Bearer ${jwt}`,
|
|
2893
|
+
...config.customHeaders
|
|
2894
|
+
};
|
|
2895
|
+
} else {
|
|
2896
|
+
headers = {
|
|
2897
|
+
Authorization: `Bearer ${jwt}`,
|
|
2898
|
+
Source: "sdk/fileArray"
|
|
2899
|
+
};
|
|
2900
|
+
}
|
|
2901
|
+
if (options?.url) {
|
|
2902
|
+
const data2 = new FormData();
|
|
2903
|
+
for (const file of Array.from(files)) {
|
|
2904
|
+
const path = file.webkitRelativePath || `${folder}/${file.name}`;
|
|
2905
|
+
data2.append("file", file, path);
|
|
2906
|
+
}
|
|
2907
|
+
data2.append("network", network);
|
|
2908
|
+
data2.append("name", folder);
|
|
2909
|
+
if (options.groupId) {
|
|
2910
|
+
data2.append("group_id", options.groupId);
|
|
2911
|
+
}
|
|
2912
|
+
if (options.metadata?.keyvalues) {
|
|
2913
|
+
data2.append("keyvalues", JSON.stringify(options.metadata.keyvalues));
|
|
2914
|
+
}
|
|
2915
|
+
if (options.streamable) {
|
|
2916
|
+
data2.append("streamable", "true");
|
|
2917
|
+
}
|
|
2918
|
+
if (options.car) {
|
|
2919
|
+
data2.append("car", "true");
|
|
2920
|
+
}
|
|
2921
|
+
if (options.cid_version !== void 0) {
|
|
2922
|
+
data2.append("cid_version", options.cid_version.toString());
|
|
2923
|
+
}
|
|
2924
|
+
if (options.expires_at !== void 0) {
|
|
2925
|
+
data2.append("expires_at", options.expires_at.toString());
|
|
2926
|
+
}
|
|
2927
|
+
try {
|
|
2928
|
+
const url = new URL(options.url);
|
|
2929
|
+
const request = await fetch(url.toString(), {
|
|
2930
|
+
method: "POST",
|
|
2931
|
+
headers,
|
|
2932
|
+
body: data2
|
|
2933
|
+
});
|
|
2934
|
+
if (!request.ok) {
|
|
2935
|
+
const errorData = await request.text();
|
|
2936
|
+
if (request.status === 401 || request.status === 403) {
|
|
2937
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
2938
|
+
`Authentication failed: ${errorData}`,
|
|
2939
|
+
request.status,
|
|
2940
|
+
{
|
|
2941
|
+
error: errorData,
|
|
2942
|
+
code: "AUTH_ERROR",
|
|
2943
|
+
metadata: {
|
|
2944
|
+
requestUrl: request.url
|
|
2945
|
+
}
|
|
2946
|
+
}
|
|
2947
|
+
);
|
|
2948
|
+
}
|
|
2949
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
2950
|
+
error: errorData,
|
|
2951
|
+
code: "HTTP_ERROR",
|
|
2952
|
+
metadata: {
|
|
2953
|
+
requestUrl: request.url
|
|
2954
|
+
}
|
|
2955
|
+
});
|
|
2956
|
+
}
|
|
2957
|
+
const res = await request.json();
|
|
2958
|
+
const resData = res.data;
|
|
2959
|
+
return resData;
|
|
2960
|
+
} catch (error) {
|
|
2961
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
2962
|
+
throw error;
|
|
2963
|
+
}
|
|
2964
|
+
if (error instanceof Error) {
|
|
2965
|
+
throw new chunkBK3CLF3Z_js.PinataError(`Error processing fileArray: ${error.message}`);
|
|
2966
|
+
}
|
|
2967
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
2968
|
+
"An unknown error occurred while uploading an array of files"
|
|
2969
|
+
);
|
|
2970
|
+
}
|
|
2971
|
+
}
|
|
2885
2972
|
const data = new FormData();
|
|
2886
2973
|
for (const file of Array.from(files)) {
|
|
2887
2974
|
const path = file.webkitRelativePath || `${folder}/${file.name}`;
|
|
@@ -2901,18 +2988,6 @@ var uploadFileArray = async (config, files, network, options) => {
|
|
|
2901
2988
|
cidVersion: 1
|
|
2902
2989
|
})
|
|
2903
2990
|
);
|
|
2904
|
-
let headers;
|
|
2905
|
-
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
2906
|
-
headers = {
|
|
2907
|
-
Authorization: `Bearer ${jwt}`,
|
|
2908
|
-
...config.customHeaders
|
|
2909
|
-
};
|
|
2910
|
-
} else {
|
|
2911
|
-
headers = {
|
|
2912
|
-
Authorization: `Bearer ${jwt}`,
|
|
2913
|
-
Source: "sdk/fileArray"
|
|
2914
|
-
};
|
|
2915
|
-
}
|
|
2916
2991
|
let endpoint = "https://api.pinata.cloud/pinning/pinFileToIPFS";
|
|
2917
2992
|
if (config.legacyUploadUrl) {
|
|
2918
2993
|
endpoint = config.legacyUploadUrl;
|