pinata 0.1.9 → 0.1.10
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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +46 -39
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46 -39
- package/dist/index.mjs.map +1 -1
- package/package.json +44 -50
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/utils/custom-errors.ts","../src/core/authentication/testAuthentication.ts","../src/core/pinning/file.ts","../src/core/pinning/fileArray.ts","../src/core/pinning/base64.ts","../src/core/pinning/url.ts","../src/core/pinning/json.ts","../src/core/pinning/cid.ts","../src/core/pinning/unpin.ts","../src/core/data/listFiles.ts","../src/core/data/updateMetadata.ts","../src/utils/gateway-tools.ts","../src/core/gateway/getCid.ts","../src/core/gateway/convertIPFSUrl.ts","../src/core/data/pinJobs.ts","../src/core/data/pinnedFileUsage.ts","../src/core/data/totalStorageUsage.ts","../src/core/keys/createKey.ts","../src/core/keys/listKeys.ts","../src/core/keys/revokeKeys.ts","../src/core/groups/createGroup.ts","../src/core/groups/listGroups.ts","../src/core/groups/getGroup.ts","../src/core/groups/addToGroup.ts","../src/core/groups/updateGroup.ts","../src/core/groups/removeFromGroup.ts","../src/core/groups/deleteGroup.ts","../src/core/signatures/addSignature.ts","../src/core/signatures/getSignature.ts","../src/core/signatures/removeSignature.ts","../src/core/pinataSDK.ts"],"sourcesContent":["export * from \"./core/pinataSDK\";\nexport * from \"./core/types\";\n","export class PinataError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic statusCode?: number,\n\t\tpublic details?: any,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"PinataError\";\n\t}\n}\n\nexport class NetworkError extends PinataError {\n\tconstructor(message: string, statusCode?: number, details?: any) {\n\t\tsuper(message, statusCode, details);\n\t\tthis.name = \"NetworkError\";\n\t}\n}\n\nexport class AuthenticationError extends PinataError {\n\tconstructor(message: string, statusCode?: number, details?: any) {\n\t\tsuper(message, statusCode, details);\n\t\tthis.name = \"AuthenticationError\";\n\t}\n}\n\nexport class ValidationError extends PinataError {\n\tconstructor(message: string, details?: any) {\n\t\tsuper(message, undefined, details);\n\t\tthis.name = \"ValidationError\";\n\t}\n}\n","/**\n * Tests the authentication of the current Pinata configuration.\n *\n * This function sends a request to the Pinata API to verify if the provided\n * authentication credentials (JWT) are valid and working correctly.\n *\n * @async\n * @function testAuthentication\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @returns {Promise<AuthTestResponse>} A promise that resolves to an object containing a message about the authentication status.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the authentication process.\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const auth = await pinata.testAuthentication()\n */\n\nimport type { PinataConfig, AuthTestResponse } from \"../types\";\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const testAuthentication = async (config: PinataConfig | undefined) => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst headers: Record<string, string> = {\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/testAuthentication\";\n\n\ttry {\n\t\tconst request = await fetch(\n\t\t\t\"https://api.pinata.cloud/data/testAuthentication\",\n\t\t\t{\n\t\t\t\tmethod: \"GET\",\n\t\t\t\theaders: headers,\n\t\t\t},\n\t\t);\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: AuthTestResponse = await request.json();\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(\n\t\t\t\t`Error processing authentication: ${error.message}`,\n\t\t\t);\n\t\t}\n\t\tthrow new PinataError(\n\t\t\t\"An unknown error occurred while testing authentication\",\n\t\t);\n\t}\n};\n","/**\n * Uploads a file to IPFS via Pinata.\n *\n * This function allows you to upload a single file to IPFS and pin it to Pinata.\n * It's useful for adding individual files to your Pinata account and IPFS network.\n *\n * @async\n * @function uploadFile\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {File} file - The file object to be uploaded.\n * @param {UploadOptions} [options] - Optional parameters for the upload.\n * @param {PinataMetadata} [options.metadata] - Metadata for the uploaded file.\n * @param {string} [options.metadata.name] - Custom name for the file (defaults to the original filename if not provided).\n * @param {Record<string, string | number>} [options.metadata.keyValues] - Custom key-value pairs for the file metadata.\n * @param {string} [options.keys] - Custom JWT to use for this specific upload.\n * @param {string} [options.groupId] - ID of the group to add the uploaded file to.\n * @param {0 | 1} [options.cidVersion] - Version of CID to use (0 or 1).\n * @returns {Promise<PinResponse>} A promise that resolves to an object containing the IPFS hash and other upload details.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the upload process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const file = new File([\"hello world!\"], \"hello.txt\", { type: \"text/plain\" })\n * const upload = await pinata.upload.file(file)\n */\n\nimport type { PinataConfig, PinResponse, UploadOptions } from \"../types\";\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const uploadFile = async (\n\tconfig: PinataConfig | undefined,\n\tfile: File,\n\toptions?: UploadOptions,\n) => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst jwt: string = options?.keys || config.pinataJwt;\n\n\tconst data = new FormData();\n\tdata.append(\"file\", file, file.name);\n\n\tdata.append(\n\t\t\"pinataOptions\",\n\t\tJSON.stringify({\n\t\t\tcidVersion: options?.cidVersion,\n\t\t\tgroupId: options?.groupId,\n\t\t}),\n\t);\n\n\tdata.append(\n\t\t\"pinataMetadata\",\n\t\tJSON.stringify({\n\t\t\tname: options?.metadata ? options.metadata.name : file.name,\n\t\t\tkeyvalues: options?.metadata?.keyValues,\n\t\t}),\n\t);\n\n\tconst headers: Record<string, string> = {\n\t\tAuthorization: `Bearer ${jwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/file\";\n\n\ttry {\n\t\tconst request = await fetch(\n\t\t\t\"https://api.pinata.cloud/pinning/pinFileToIPFS\",\n\t\t\t{\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: headers,\n\t\t\t\tbody: data,\n\t\t\t},\n\t\t);\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\t\tconst res: PinResponse = await request.json();\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error uploading file: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\"An unknown error occurred while uploading the file\");\n\t}\n};\n","/**\n * Uploads multiple files to IPFS via Pinata as a single directory.\n *\n * This function allows you to upload multiple files to IPFS and pin them to Pinata\n * as a single directory. It's useful for adding collections of related files or\n * entire directories to your Pinata account and IPFS network.\n *\n * @async\n * @function uploadFileArray\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {File[]} files - An array of File objects to be uploaded.\n * @param {UploadOptions} [options] - Optional parameters for the upload.\n * @param {PinataMetadata} [options.metadata] - Metadata for the uploaded directory.\n * @param {string} [options.metadata.name] - Name for the directory (defaults to \"folder_from_sdk\" if not provided).\n * @param {Record<string, string | number>} [options.metadata.keyValues] - Custom key-value pairs for the directory metadata.\n * @param {string} [options.keys] - Custom JWT to use for this specific upload.\n * @param {string} [options.groupId] - ID of the group to add the uploaded directory to.\n * @param {0 | 1} [options.cidVersion] - Version of CID to use (0 or 1).\n * @returns {Promise<PinResponse>} A promise that resolves to an object containing the IPFS hash and other upload details.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the upload process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const file1 = new File([\"hello world!\"], \"hello.txt\", { type: \"text/plain\" })\n * const file2 = new File([\"hello world again!\"], \"hello2.txt\", { type: \"text/plain\" })\n * const upload = await pinata.upload.fileArray([file1, file2])\n */\n\nimport type { PinataConfig, PinResponse, UploadOptions } from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const uploadFileArray = async (\n\tconfig: PinataConfig | undefined,\n\tfiles: File[],\n\toptions?: UploadOptions,\n) => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst jwt: string = options?.keys || config?.pinataJwt;\n\n\tconst folder = options?.metadata?.name ?? \"folder_from_sdk\";\n\tconst data = new FormData();\n\n\tfor (const file of Array.from(files)) {\n\t\tdata.append(\"file\", file, `${folder}/${file.name}`);\n\t}\n\n\tdata.append(\n\t\t\"pinataMetadata\",\n\t\tJSON.stringify({\n\t\t\tname: folder,\n\t\t\tkeyvalues: options?.metadata?.keyValues,\n\t\t}),\n\t);\n\n\tdata.append(\n\t\t\"pinataOptions\",\n\t\tJSON.stringify({\n\t\t\tcidVersion: options?.cidVersion,\n\t\t\tgroupId: options?.groupId,\n\t\t}),\n\t);\n\n\tconst headers: Record<string, string> = {\n\t\tAuthorization: `Bearer ${jwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/fileArray\";\n\n\ttry {\n\t\tconst request = await fetch(\n\t\t\t\"https://api.pinata.cloud/pinning/pinFileToIPFS\",\n\t\t\t{\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: headers,\n\t\t\t\tbody: data,\n\t\t\t},\n\t\t);\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: PinResponse = await request.json();\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing fileArray: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\n\t\t\t\"An unknown error occurred while uploading an array of files\",\n\t\t);\n\t}\n};\n","/**\n * Uploads a base64-encoded string to IPFS via Pinata.\n *\n * This function allows you to upload content to IPFS that is encoded as a base64 string.\n * It's particularly useful for uploading binary data or files that have been converted to base64.\n *\n * @async\n * @function uploadBase64\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {string} base64String - The base64-encoded string to be uploaded.\n * @param {UploadOptions} [options] - Optional parameters for the upload.\n * @param {PinataMetadata} [options.metadata] - Metadata for the uploaded file.\n * @param {string} [options.metadata.name] - Name for the uploaded file (default is \"base64 string\").\n * @param {Record<string, string | number>} [options.metadata.keyvalues] - Custom key-value pairs for the file metadata.\n * @param {string} [options.keys] - Custom JWT to use for this specific upload.\n * @param {string} [options.groupId] - ID of the group to add the uploaded file to.\n * @param {0 | 1} [options.cidVersion] - Version of CID to use (0 or 1).\n * @returns {Promise<PinResponse>} A promise that resolves to an object containing the IPFS hash and other upload details.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the upload process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const upload = await pinata.upload.base64(\"SGVsbG8gV29ybGQh\")\n */\n\nimport type { PinataConfig, PinResponse, UploadOptions } from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const uploadBase64 = async (\n\tconfig: PinataConfig | undefined,\n\tbase64String: string,\n\toptions?: UploadOptions,\n) => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst jwt: string = options?.keys || config?.pinataJwt;\n\n\tconst name = options?.metadata?.name\n\t\t? options?.metadata?.name\n\t\t: \"base64 string\";\n\n\tconst buffer = Buffer.from(base64String, \"base64\");\n\n\tconst blob = new Blob([buffer]);\n\n\tconst data = new FormData();\n\n\tdata.append(\"file\", blob, name);\n\n\tdata.append(\n\t\t\"pinataOptions\",\n\t\tJSON.stringify({\n\t\t\tcidVersion: options?.cidVersion,\n\t\t\tgroupId: options?.groupId,\n\t\t}),\n\t);\n\n\tdata.append(\n\t\t\"pinataMetadata\",\n\t\tJSON.stringify({\n\t\t\tname: name,\n\t\t\tkeyvalues: options?.metadata?.keyValues,\n\t\t}),\n\t);\n\n\tconst headers: Record<string, string> = {\n\t\tAuthorization: `Bearer ${jwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/base64\";\n\n\ttry {\n\t\tconst request = await fetch(\n\t\t\t\"https://api.pinata.cloud/pinning/pinFileToIPFS\",\n\t\t\t{\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: headers,\n\t\t\t\tbody: data,\n\t\t\t},\n\t\t);\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: PinResponse = await request.json();\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing base64: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\n\t\t\t\"An unknown error occurred while trying to upload base64\",\n\t\t);\n\t}\n};\n","/**\n * Uploads content from a URL to IPFS via Pinata.\n *\n * This function allows you to upload content from a specified URL to IPFS and pin it to Pinata.\n * It's useful for adding remote content to your Pinata account and IPFS network without\n * first downloading it locally.\n *\n * @async\n * @function uploadUrl\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {string} url - The URL of the content to be uploaded.\n * @param {UploadOptions} [options] - Optional parameters for the upload.\n * @param {PinataMetadata} [options.metadata] - Metadata for the uploaded content.\n * @param {string} [options.metadata.name] - Custom name for the content (defaults to \"url_upload\" if not provided).\n * @param {Record<string, string | number>} [options.metadata.keyValues] - Custom key-value pairs for the content metadata.\n * @param {string} [options.keys] - Custom JWT to use for this specific upload.\n * @param {string} [options.groupId] - ID of the group to add the uploaded content to.\n * @param {0 | 1} [options.cidVersion] - Version of CID to use (0 or 1).\n * @returns {Promise<PinResponse>} A promise that resolves to an object containing the IPFS hash and other upload details.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request or URL fetch.\n * @throws {PinataError} For any other errors that occur during the upload process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const upload = await pinata.upload.url(\"https://i.imgur.com/u4mGk5b.gif\")\n */\n\nimport type { PinataConfig, PinResponse, UploadOptions } from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const uploadUrl = async (\n\tconfig: PinataConfig | undefined,\n\turl: string,\n\toptions?: UploadOptions,\n) => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst jwt: string = options?.keys || config?.pinataJwt;\n\tconst data = new FormData();\n\n\tconst stream = await fetch(url);\n\n\tif (!stream.ok) {\n\t\tconst errorData = await stream.json();\n\t\tthrow new NetworkError(\n\t\t\t`HTTP error! status: ${stream.status}`,\n\t\t\tstream.status,\n\t\t\terrorData,\n\t\t);\n\t}\n\n\tconst arrayBuffer = await stream.arrayBuffer();\n\n\tconst blob = new Blob([arrayBuffer]);\n\n\tconst name = options?.metadata?.name ?? \"url_upload\";\n\n\tconst file = new File([blob], name);\n\n\tdata.append(\"file\", file, name);\n\n\tdata.append(\n\t\t\"pinataOptions\",\n\t\tJSON.stringify({\n\t\t\tcidVersion: options?.cidVersion,\n\t\t\tgroupId: options?.groupId,\n\t\t}),\n\t);\n\n\tdata.append(\n\t\t\"pinataMetadata\",\n\t\tJSON.stringify({\n\t\t\tname: name,\n\t\t\tkeyvalues: options?.metadata?.keyValues,\n\t\t}),\n\t);\n\n\tconst headers: Record<string, string> = {\n\t\tAuthorization: `Bearer ${jwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/url\";\n\n\ttry {\n\t\tconst request = await fetch(\n\t\t\t\"https://api.pinata.cloud/pinning/pinFileToIPFS\",\n\t\t\t{\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: headers,\n\t\t\t\tbody: data,\n\t\t\t},\n\t\t);\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: PinResponse = await request.json();\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing url: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\"An unknown error occurred while uploading by url\");\n\t}\n};\n","/**\n * Uploads JSON data to IPFS via Pinata.\n *\n * This function allows you to upload JSON data directly to IPFS and pin it to Pinata.\n * It's useful for adding structured data, configurations, or any JSON-serializable content\n * to your Pinata account and IPFS network.\n *\n * @async\n * @function uploadJson\n * @template T\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {T} jsonData - The JSON data to be uploaded. Must be a valid JavaScript object that can be JSON-stringified.\n * @param {UploadOptions} [options] - Optional parameters for the upload.\n * @param {PinataMetadata} [options.metadata] - Metadata for the uploaded JSON.\n * @param {string} [options.metadata.name] - Custom name for the JSON content (defaults to \"json\" if not provided).\n * @param {Record<string, string | number>} [options.metadata.keyValues] - Custom key-value pairs for the JSON metadata.\n * @param {string} [options.keys] - Custom JWT to use for this specific upload.\n * @param {string} [options.groupId] - ID of the group to add the uploaded JSON to.\n * @param {0 | 1} [options.cidVersion] - Version of CID to use (0 or 1).\n * @returns {Promise<PinResponse>} A promise that resolves to an object containing the IPFS hash and other upload details.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the upload process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const upload = await pinata.upload.json({\n * name: \"Pinnie NFT\",\n * description: \"A Pinnie NFT from Pinata\",\n * image: \"ipfs://bafkreih5aznjvttude6c3wbvqeebb6rlx5wkbzyppv7garjiubll2ceym4\"\n * })\n */\n\nimport type {\n\tPinataConfig,\n\tPinResponse,\n\tUploadOptions,\n\tJsonBody,\n} from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const uploadJson = async <T extends JsonBody>(\n\tconfig: PinataConfig | undefined,\n\tjsonData: T,\n\toptions?: UploadOptions,\n) => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst jwt: string = options?.keys || config?.pinataJwt;\n\n\tconst data = JSON.stringify({\n\t\tpinataContent: jsonData,\n\t\tpinataOptions: {\n\t\t\tcidVersion: options?.cidVersion,\n\t\t\tgroupId: options?.groupId,\n\t\t},\n\t\tpinataMetadata: {\n\t\t\tname: options?.metadata ? options.metadata.name : \"json\",\n\t\t\tkeyvalues: options?.metadata?.keyValues,\n\t\t},\n\t});\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${jwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/json\";\n\n\ttry {\n\t\tconst request = await fetch(\n\t\t\t\"https://api.pinata.cloud/pinning/pinJSONToIPFS\",\n\t\t\t{\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: headers,\n\t\t\t\tbody: data,\n\t\t\t},\n\t\t);\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: PinResponse = await request.json();\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing json: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\"An unknown error occurred while uploading json\");\n\t}\n};\n","/**\n * Pins an existing file on IPFS to Pinata using its Content Identifier (CID).\n *\n * This function allows you to add an existing IPFS file to your Pinata account\n * by providing its CID. It's useful for ensuring long-term storage and\n * availability of content that's already on IPFS.\n *\n * @async\n * @function uploadCid\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {string} cid - The Content Identifier (CID) of the IPFS file to pin.\n * @param {UploadCIDOptions} [options] - Optional parameters for the upload.\n * @param {PinataMetadata} [options.metadata] - Metadata for the pinned file.\n * @param {string} [options.metadata.name] - Name for the pinned file (defaults to the CID if not provided).\n * @param {Record<string, string | number>} [options.metadata.keyValues] - Custom key-value pairs for the file metadata.\n * @param {string[]} [options.peerAddresses] - Array of peer addresses to contact for pinning.\n * @param {string} [options.keys] - Custom JWT to use for this specific upload.\n * @param {string} [options.groupId] - ID of the group to add the pinned file to.\n * @returns {Promise<PinByCIDResponse>} A promise that resolves to an object containing details about the pinning job.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the pinning process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const pin = await pinata.upload.cid(\"QmVLwvmGehsrNEvhcCnnsw5RQNseohgEkFNN1848zNzdng\")\n */\n\nimport type {\n\tPinataConfig,\n\tPinByCIDResponse,\n\tUploadCIDOptions,\n} from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const uploadCid = async (\n\tconfig: PinataConfig | undefined,\n\tcid: string,\n\toptions?: UploadCIDOptions,\n) => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst jwt: string = options?.keys || config?.pinataJwt;\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${jwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/cid\";\n\n\tconst data = JSON.stringify({\n\t\thashToPin: cid,\n\t\tpinataMetadata: {\n\t\t\tname: options?.metadata ? options?.metadata?.name : cid,\n\t\t\tkeyvalues: options?.metadata?.keyValues,\n\t\t},\n\t\tpinataOptions: {\n\t\t\thostNodes: options?.peerAddresses ? options.peerAddresses : \"\",\n\t\t\tgroupId: options?.groupId,\n\t\t},\n\t});\n\n\ttry {\n\t\tconst request = await fetch(\"https://api.pinata.cloud/pinning/pinByHash\", {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: headers,\n\t\t\tbody: data,\n\t\t});\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: PinByCIDResponse = await request.json();\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing cid: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\"An unknown error occurred while pinning by CID\");\n\t}\n};\n","/**\n * Unpins multiple files from Pinata and IPFS.\n *\n * This function allows you to remove pins for multiple files from your Pinata account.\n * Unpinning a file means that Pinata will no longer guarantee its availability on IPFS,\n * although the content may still be available if pinned by other IPFS nodes.\n *\n * @async\n * @function unpinFile\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {string[]} files - An array of IPFS hashes (CIDs) of the files to unpin.\n * @returns {Promise<UnpinResponse[]>} A promise that resolves to an array of objects, each containing the status of the unpin operation for each file.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the unpinning process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const unpin = await pinata.unpin([\n * \"bafkreih5aznjvttude6c3wbvqeebb6rlx5wkbzyppv7garjiubll2ceym4\"\n * ])\n */\n\nimport type { PinataConfig, UnpinResponse } from \"../types\";\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nconst wait = (milliseconds: number): Promise<void> => {\n\treturn new Promise((resolve) => {\n\t\tsetTimeout(resolve, milliseconds);\n\t});\n};\n\nexport const unpinFile = async (\n\tconfig: PinataConfig | undefined,\n\tfiles: string[],\n): Promise<UnpinResponse[]> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst responses: UnpinResponse[] = [];\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/unpin\";\n\n\tfor (const hash of files) {\n\t\ttry {\n\t\t\tconst response = await fetch(\n\t\t\t\t`https://api.pinata.cloud/pinning/unpin/${hash}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: \"DELETE\",\n\t\t\t\t\theaders: headers,\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tawait wait(300);\n\n\t\t\tif (!response.ok) {\n\t\t\t\tconst errorData = await response.json();\n\t\t\t\tif (response.status === 401) {\n\t\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\t\tresponse.status,\n\t\t\t\t\t\terrorData,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tthrow new NetworkError(\n\t\t\t\t\t`HTTP error! status: ${response.status}`,\n\t\t\t\t\tresponse.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst result = await response.text();\n\t\t\tresponses.push({\n\t\t\t\thash: hash,\n\t\t\t\tstatus: result,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tlet errorMessage: string;\n\n\t\t\tif (error instanceof PinataError) {\n\t\t\t\terrorMessage = error.message;\n\t\t\t} else if (error instanceof Error) {\n\t\t\t\terrorMessage = `Error unpinning file ${hash}: ${error.message}`;\n\t\t\t} else {\n\t\t\t\terrorMessage = `An unknown error occurred while unpinning file ${hash}`;\n\t\t\t}\n\n\t\t\tresponses.push({\n\t\t\t\thash: hash,\n\t\t\t\tstatus: errorMessage,\n\t\t\t});\n\t\t}\n\t}\n\treturn responses;\n};\n","/**\n * Lists files pinned to Pinata based on the provided configuration and options.\n *\n * This function fetches a list of pinned files from the Pinata API, allowing for\n * various filtering and pagination options.\n *\n * @async\n * @function listFiles\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {PinListQuery} [options] - Optional query parameters to filter and paginate the results.\n * @param {string} [options.cid] - Filter by the CID of the file.\n * @param {string} [options.pinStart] - Filter by the start date of pinning (ISO 8601 format).\n * @param {string} [options.pinEnd] - Filter by the end date of pinning (ISO 8601 format).\n * @param {number} [options.pinSizeMin] - Filter by minimum pin size in bytes.\n * @param {number} [options.pinSizeMax] - Filter by maximum pin size in bytes.\n * @param {number} [options.pageLimit] - Number of items to return per page.\n * @param {number} [options.pageOffset] - Number of items to skip (for pagination).\n * @param {string} [options.name] - Filter by the name of the file.\n * @param {string} [options.key] - Metadata key to filter by (used with value and operator).\n * @param {string | number} [options.value] - Metadata value to filter by (used with key and operator).\n * @param {string} [options.operator] - Comparison operator for metadata filtering.\n * @param {string} [options.groupId] - Filter by group ID.\n * @returns {Promise<PinListItem[]>} A promise that resolves to an array of PinListItem objects.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the file listing process.\n *//**\n * Lists files pinned to Pinata based on the provided configuration and options.\n *\n * This function fetches a list of pinned files from the Pinata API, allowing for\n * various filtering and pagination options.\n *\n * @async\n * @function listFiles\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {PinListQuery} [options] - Optional query parameters to filter and paginate the results.\n * @param {string} [options.cid] - Filter by the CID of the file.\n * @param {string} [options.pinStart] - Filter by the start date of pinning (ISO 8601 format).\n * @param {string} [options.pinEnd] - Filter by the end date of pinning (ISO 8601 format).\n * @param {number} [options.pinSizeMin] - Filter by minimum pin size in bytes.\n * @param {number} [options.pinSizeMax] - Filter by maximum pin size in bytes.\n * @param {number} [options.pageLimit] - Number of items to return per page.\n * @param {number} [options.pageOffset] - Number of items to skip (for pagination).\n * @param {string} [options.name] - Filter by the name of the file.\n * @param {string} [options.key] - Metadata key to filter by (used with value and operator).\n * @param {string | number} [options.value] - Metadata value to filter by (used with key and operator).\n * @param {string} [options.operator] - Comparison operator for metadata filtering.\n * @param {string} [options.groupId] - Filter by group ID.\n * @returns {Promise<PinListItem[]>} A promise that resolves to an array of PinListItem objects.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the file listing process.\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const files = await pinata.listFiles().name(\"pinnie\")\n */\n\nimport type {\n\tPinListItem,\n\tPinListQuery,\n\tPinListResponse,\n\tPinataConfig,\n} from \"../types\";\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const listFiles = async (\n\tconfig: PinataConfig | undefined,\n\toptions?: PinListQuery,\n): Promise<PinListItem[]> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst params = new URLSearchParams({\n\t\tincludesCount: \"false\",\n\t});\n\n\tif (options) {\n\t\tconst {\n\t\t\tcid,\n\t\t\tpinStart,\n\t\t\tpinEnd,\n\t\t\tpinSizeMin,\n\t\t\tpinSizeMax,\n\t\t\tpageLimit,\n\t\t\tpageOffset,\n\t\t\tname,\n\t\t\tkey,\n\t\t\tvalue,\n\t\t\toperator,\n\t\t\tgroupId,\n\t\t} = options;\n\n\t\tif (cid) params.append(\"cid\", cid);\n\t\tif (pinStart) params.append(\"pinStart\", pinStart);\n\t\tif (pinEnd) params.append(\"pinEnd\", pinEnd);\n\t\tif (pinSizeMin) params.append(\"pinSizeMin\", pinSizeMin.toString());\n\t\tif (pinSizeMax) params.append(\"pinSizeMax\", pinSizeMax.toString());\n\t\tif (pageLimit) params.append(\"pageLimit\", pageLimit.toString());\n\t\tif (pageOffset) params.append(\"pageOffset\", pageOffset.toString());\n\t\tif (groupId) params.append(\"groupId\", groupId);\n\t\tif (name) params.append(\"metadata[name]\", name);\n\t\tif (key && value) {\n\t\t\tconst keyValueParam = JSON.stringify({\n\t\t\t\t[key]: { value, op: operator || \"eq\" },\n\t\t\t});\n\t\t\tparams.append(\"metadata[keyvalues]\", keyValueParam);\n\t\t}\n\t}\n\n\tconst url = `https://api.pinata.cloud/data/pinList?status=pinned&${params.toString()}`;\n\n\ttry {\n\t\tconst headers: Record<string, string> = {\n\t\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t\t};\n\n\t\tif (config.customHeaders) {\n\t\t\tObject.assign(headers, config.customHeaders);\n\t\t}\n\n\t\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\t\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/listFiles\";\n\n\t\tconst request = await fetch(url, {\n\t\t\tmethod: \"GET\",\n\t\t\theaders: headers,\n\t\t});\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: PinListResponse = await request.json();\n\t\treturn res.rows;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing list files: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\"An unknown error occurred while listing files\");\n\t}\n};\n","/**\n * Updates the metadata for a pinned file on Pinata.\n *\n * This function allows you to modify the name and/or key-value pairs associated\n * with a file that has already been pinned to Pinata. This is useful for\n * organizing and categorizing your pinned content.\n *\n * @async\n * @function updateMetadata\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {PinataMetadataUpdate} options - The options for updating the metadata.\n * @param {string} options.cid - The Content Identifier (CID) of the pinned file to update.\n * @param {string} [options.name] - The new name to assign to the pinned file (optional).\n * @param {Record<string, string | number>} [options.keyValues] - Key-value pairs to associate with the pinned file (optional).\n * @returns {Promise<string>} A promise that resolves to a string confirming the update.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the metadata update process.\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const update = await pinata.updateMedatadata({\n * cid: \"bafkreih5aznjvttude6c3wbvqeebb6rlx5wkbzyppv7garjiubll2ceym4\",\n * name: \"Pinnie V2\",\n * keyValues: {\n * whimsey: 200\n * }\n * })\n */\n\nimport type { PinataConfig, PinataMetadataUpdate } from \"../types\";\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const updateMetadata = async (\n\tconfig: PinataConfig | undefined,\n\toptions: PinataMetadataUpdate,\n): Promise<string> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\tconst data = {\n\t\tipfsPinHash: options.cid,\n\t\tname: options.name,\n\t\tkeyvalues: options.keyValues,\n\t};\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/updateMetadata\";\n\n\ttry {\n\t\tconst request = await fetch(\n\t\t\t\"https://api.pinata.cloud/pinning/hashMetadata\",\n\t\t\t{\n\t\t\t\tmethod: \"PUT\",\n\t\t\t\theaders: headers,\n\t\t\t\tbody: JSON.stringify(data),\n\t\t\t},\n\t\t);\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: string = await request.text();\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(\n\t\t\t\t`Error processing updateMetadata: ${error.message}`,\n\t\t\t);\n\t\t}\n\t\tthrow new PinataError(\"An unknown error occurred while updating metadata\");\n\t}\n};\n","import * as isIPFS from \"is-ipfs\";\n\nfunction containsCID(input: string) {\n\tif (typeof input !== \"string\") {\n\t\tthrow new Error(\"Input is not a string\");\n\t}\n\n\t// Helper function to check if a string starts with a CID\n\tconst startsWithCID = (str: string) => {\n\t\tconst parts = str.split(\"/\");\n\t\treturn isIPFS.cid(parts[0]) ? parts[0] : null;\n\t};\n\n\t// Check if the input itself is a CID or starts with a CID\n\tconst directCID = startsWithCID(input);\n\tif (directCID) {\n\t\treturn {\n\t\t\tcontainsCid: true,\n\t\t\tcid: directCID,\n\t\t};\n\t}\n\n\tlet url: URL;\n\ttry {\n\t\t// Try to parse the input as a URL\n\t\turl = new URL(input);\n\t} catch (error) {\n\t\t// If parsing fails, treat the input as a potential path-like string\n\t\tconst parts = input.split(/\\/|\\?/);\n\t\tfor (const part of parts) {\n\t\t\tconst cid = startsWithCID(part);\n\t\t\tif (cid) {\n\t\t\t\treturn {\n\t\t\t\t\tcontainsCid: true,\n\t\t\t\t\tcid: cid,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\tcontainsCid: false,\n\t\t\tcid: null,\n\t\t};\n\t}\n\n\t// Check for CID in subdomain\n\tconst subdomains = url.hostname.split(\".\");\n\tfor (const subdomain of subdomains) {\n\t\tif (isIPFS.cid(subdomain)) {\n\t\t\treturn {\n\t\t\t\tcontainsCid: true,\n\t\t\t\tcid: subdomain,\n\t\t\t};\n\t\t}\n\t}\n\n\t// Check for CID in path\n\tconst pathParts = url.pathname.split(\"/\");\n\tfor (const part of pathParts) {\n\t\tconst cid = startsWithCID(part);\n\t\tif (cid) {\n\t\t\treturn {\n\t\t\t\tcontainsCid: true,\n\t\t\t\tcid: cid,\n\t\t\t};\n\t\t}\n\t}\n\n\treturn {\n\t\tcontainsCid: false,\n\t\tcid: null,\n\t};\n}\n\nexport function convertToDesiredGateway(\n\tsourceUrl: string,\n\tdesiredGatewayPrefix: string | undefined,\n) {\n\tconst results = containsCID(sourceUrl);\n\n\tif (results.containsCid !== true) {\n\t\tthrow new Error(\"url does not contain CID\");\n\t}\n\n\tif (!sourceUrl.startsWith(\"https\") && !sourceUrl.startsWith(\"ipfs://\")) {\n\t\treturn `${desiredGatewayPrefix}/ipfs/${sourceUrl}`;\n\t}\n\n\tconst urlObj = new URL(sourceUrl);\n\tconst path = urlObj.pathname + urlObj.search + urlObj.hash;\n\n\t//case 1 - the ipfs://cid path\n\tif (sourceUrl.startsWith(`ipfs://${results.cid}`)) {\n\t\treturn `${desiredGatewayPrefix}/ipfs/${results.cid}${path}`;\n\t}\n\n\t//case 2 - the /ipfs/cid path (this should cover ipfs://ipfs/cid as well)\n\tif (sourceUrl.includes(`/ipfs/${results.cid}`)) {\n\t\treturn `${desiredGatewayPrefix}${path}`;\n\t}\n\n\t//case 3 - the /ipns/cid path\n\tif (sourceUrl.includes(`/ipns/${results.cid}`)) {\n\t\treturn `${desiredGatewayPrefix}${path}`;\n\t}\n\n\t//case 4 - the CID is in the subdomain\n\tif (urlObj.hostname.includes(results.cid!)) {\n\t\treturn `${desiredGatewayPrefix}/ipfs/${results.cid}${path}`;\n\t}\n\n\t//this is the fallback if no supported patterns are provided\n\tthrow new Error(\n\t\t\"unsupported URL pattern, please submit a github issue with the URL utilized\",\n\t);\n}\n","/**\n * Retrieves the content of a file from IPFS using its Content Identifier (CID).\n *\n * This function fetches the content associated with a given CID from the specified\n * Pinata gateway. It can handle various content types and returns the data along\n * with the content type information.\n *\n * @async\n * @function getCid\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT and gateway information.\n * @param {string} cid - The Content Identifier (CID) of the file to retrieve.\n * @returns {Promise<GetCIDResponse>} A promise that resolves to an object containing the file data and content type.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the retrieval process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const upload = await pinata.gateways.get(\"QmVLwvmGehsrNEvhcCnnsw5RQNseohgEkFNN1848zNzdng\"* )\n *\n */\n\nimport { convertToDesiredGateway } from \"../../utils/gateway-tools\";\nimport type { GetCIDResponse, PinataConfig } from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const getCid = async (\n\tconfig: PinataConfig | undefined,\n\tcid: string,\n): Promise<GetCIDResponse> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tlet data: JSON | string | Blob;\n\tlet newUrl: string;\n\n\tnewUrl = convertToDesiredGateway(cid, config?.pinataGateway);\n\n\tif (config?.pinataGatewayKey) {\n\t\tnewUrl = `${newUrl}?pinataGatewayToken=${config?.pinataGatewayKey}`;\n\t}\n\n\ttry {\n\t\tconst request = await fetch(newUrl, {\n\t\t\tmethod: \"GET\",\n\t\t\theaders: {\n\t\t\t\tSource: \"sdk/getCid\",\n\t\t\t},\n\t\t});\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst contentType: string | null = request.headers.get(\"content-type\");\n\n\t\tif (contentType?.includes(\"application/json\")) {\n\t\t\tdata = await request.json();\n\t\t} else if (contentType?.includes(\"text/\")) {\n\t\t\tdata = await request.text();\n\t\t} else {\n\t\t\tdata = await request.blob();\n\t\t}\n\n\t\tconst res: GetCIDResponse = {\n\t\t\tdata: data,\n\t\t\tcontentType: contentType,\n\t\t};\n\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing getCid: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\n\t\t\t\"An unknown error occurred while getting CID contents\",\n\t\t);\n\t}\n};\n","/**\n * Converts an IPFS URL to a desired gateway URL.\n *\n * This function takes an IPFS URL and converts it to use a specified gateway.\n * If a Pinata Gateway Key is provided in the configuration, it will be appended\n * to the URL as a query parameter.\n *\n * @function convertIPFSUrl\n * @param {PinataConfig | undefined} config - The Pinata configuration object.\n * @param {string} config.pinataGateway - The desired gateway URL to use.\n * @param {string} [config.pinataGatewayKey] - Optional Pinata Gateway Key for authenticated access.\n * @param {string} url - The original IPFS URL to convert.\n * @returns {string} The converted URL using the specified gateway.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const url = pinata.gateways.convert(\n * \"ipfs://QmVLwvmGehsrNEvhcCnnsw5RQNseohgEkFNN1848zNzdng\"\n * );\n */\n\nimport { convertToDesiredGateway } from \"../../utils/gateway-tools\";\nimport type { PinataConfig } from \"../types\";\n\nexport const convertIPFSUrl = (\n\tconfig: PinataConfig | undefined,\n\turl: string,\n): string => {\n\tlet newUrl: string;\n\tnewUrl = convertToDesiredGateway(url, config?.pinataGateway);\n\tif (config?.pinataGatewayKey) {\n\t\t`${newUrl}?pinataGatewayToken=${config?.pinataGatewayKey}`;\n\t}\n\treturn newUrl;\n};\n","/**\n * Retrieves information about pin jobs from the Pinata API.\n *\n * This function fetches a list of pin jobs based on the provided configuration and options.\n * Pin jobs represent the status of pinning operations in progress or completed.\n *\n * @async\n * @function pinJobs\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {PinJobQuery} [options] - Optional query parameters to filter and paginate the results.\n * @param {string} [options.ipfs_pin_hash] - Filter by the IPFS hash (CID) of the content being pinned.\n * @param {('prechecking'|'retrieving'|'expired'|'over_free_limit'|'over_max_size'|'invalid_object'|'bad_host_node')} [options.status] - Filter by the status of the pin job.\n * @param {('ASC'|'DSC')} [options.sort] - Sort order for the results (ascending or descending).\n * @param {number} [options.limit] - Number of items to return per page.\n * @param {number} [options.offset] - Number of items to skip (for pagination).\n * @returns {Promise<PinJobItem[]>} A promise that resolves to an array of PinJobItem objects.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the pin jobs retrieval process.\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n * const jobs = await pinata.pinJobs().status(\"prechecking\")\n */\n\nimport type {\n\tPinJobItem,\n\tPinJobQuery,\n\tPinJobResponse,\n\tPinataConfig,\n} from \"../types\";\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const pinJobs = async (\n\tconfig: PinataConfig | undefined,\n\toptions?: PinJobQuery,\n): Promise<PinJobItem[]> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst params = new URLSearchParams({\n\t\tincludesCount: \"false\",\n\t});\n\n\tif (options) {\n\t\tconst { ipfs_pin_hash: cid, status, sort, limit, offset } = options;\n\n\t\tif (cid) params.append(\"ipfs_pin_hash\", cid.toString());\n\t\tif (status) params.append(\"status\", status.toString());\n\t\tif (sort) params.append(\"sort\", sort.toString());\n\t\tif (limit) params.append(\"limit\", limit.toString());\n\t\tif (offset) params.append(\"offset\", offset.toString());\n\t}\n\n\tconst url = `https://api.pinata.cloud/pinning/pinJobs?${params.toString()}`;\n\n\tconst headers: Record<string, string> = {\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/pinJobs\";\n\n\ttry {\n\t\tconst request = await fetch(url, {\n\t\t\tmethod: \"GET\",\n\t\t\theaders: headers,\n\t\t});\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\t\tconst res: PinJobResponse = await request.json();\n\t\treturn res.rows;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing pinJobs: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\"An unknown error occurred while listing pin jobs\");\n\t}\n};\n","/**\n * Retrieves the total count of files pinned to Pinata for the authenticated user.\n *\n * This function makes a request to the Pinata API to fetch the total number of files\n * that the user has pinned to their account. This can be useful for monitoring\n * account usage and managing pinned content.\n *\n * @async\n * @function pinnedFileCount\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @returns {Promise<number>} A promise that resolves to the total number of pinned files.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the retrieval process.\n *\n * @example\n * const config = { pinataJwt: 'your-jwt-token' };\n * try {\n * const count = await pinnedFileCount(config);\n * console.log(`Total pinned files: ${count}`);\n * } catch (error) {\n * console.error('Error getting pinned file count:', error);\n * }\n */\n\nimport type { PinataConfig, UserPinnedDataResponse } from \"../types\";\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const pinnedFileCount = async (\n\tconfig: PinataConfig | undefined,\n): Promise<number> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst url = \"https://api.pinata.cloud/data/userPinnedDataTotal\";\n\n\tconst headers: Record<string, string> = {\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/pinnedFileUsage\";\n\n\ttry {\n\t\tconst request = await fetch(url, {\n\t\t\tmethod: \"GET\",\n\t\t\theaders: headers,\n\t\t});\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\t\tconst res: UserPinnedDataResponse = await request.json();\n\t\treturn res.pin_count;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(\n\t\t\t\t`Error processing pinnedFileUsage: ${error.message}`,\n\t\t\t);\n\t\t}\n\t\tthrow new PinataError(\n\t\t\t\"An unknown error occurred while getting pinned file usage\",\n\t\t);\n\t}\n};\n","/**\n * Retrieves the total storage usage in bytes for all files pinned to Pinata by the authenticated user.\n *\n * This function makes a request to the Pinata API to fetch the total storage size\n * of all files that the user has pinned to their account. This can be useful for\n * monitoring account usage, managing storage limits, and planning for capacity.\n *\n * @async\n * @function totalStorageUsage\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @returns {Promise<number>} A promise that resolves to the total storage usage in bytes.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the retrieval process.\n *\n * @example\n * const config = { pinataJwt: 'your-jwt-token' };\n * try {\n * const totalBytes = await totalStorageUsage(config);\n * console.log(`Total storage usage: ${totalBytes} bytes`);\n * console.log(`Total storage usage: ${totalBytes / (1024 * 1024)} MB`);\n * } catch (error) {\n * console.error('Error getting total storage usage:', error);\n * }\n */\n\nimport type { PinataConfig, UserPinnedDataResponse } from \"../types\";\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const totalStorageUsage = async (\n\tconfig: PinataConfig | undefined,\n): Promise<number> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst url = \"https://api.pinata.cloud/data/userPinnedDataTotal\";\n\n\tconst headers: Record<string, string> = {\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/totalStorageUsage\";\n\n\ttry {\n\t\tconst request = await fetch(url, {\n\t\t\tmethod: \"GET\",\n\t\t\theaders: headers,\n\t\t});\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\t\tconst res: UserPinnedDataResponse = await request.json();\n\t\treturn res.pin_size_total;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(\n\t\t\t\t`Error processing totalStorageUsage: ${error.message}`,\n\t\t\t);\n\t\t}\n\t\tthrow new PinataError(\n\t\t\t\"An unknown error occurred while getting total storage usage\",\n\t\t);\n\t}\n};\n","/**\n * Creates a new API key for Pinata services.\n *\n * This function allows you to generate a new API key with specific permissions\n * for use with Pinata's IPFS pinning services. It's useful for creating keys\n * with limited access or for specific applications.\n *\n * @async\n * @function createKey\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {KeyOptions} options - The options for creating a new API key.\n * @param {string} options.keyName - The name to assign to the new API key.\n * @param {KeyPermissions} options.permissions - The permissions to assign to the new key.\n * @param {number} [options.maxUses] - Optional. The maximum number of times the key can be used.\n * @returns {Promise<KeyResponse>} A promise that resolves to an object containing the new API key details.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the key creation process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const key = await pinata.keys.create({\n * keyName: \"user 1\",\n * permissions: {\n * admin: true,\n * },\n * maxUses: 1,\n * });\n */\n\nimport type { PinataConfig, KeyOptions, KeyResponse } from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const createKey = async (\n\tconfig: PinataConfig | undefined,\n\toptions: KeyOptions,\n): Promise<KeyResponse> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/createKey\";\n\n\tconst data = JSON.stringify(options);\n\n\ttry {\n\t\tconst request = await fetch(\"https://api.pinata.cloud/v3/pinata/keys\", {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: headers,\n\t\t\tbody: data,\n\t\t});\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: KeyResponse = await request.json();\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing createKey: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\"An unknown error occurred while creating API key\");\n\t}\n};\n","/**\n * Retrieves a list of API keys associated with the Pinata account.\n *\n * This function allows you to fetch and optionally filter the API keys linked to your Pinata account.\n * It's useful for managing your API keys, checking their status, or auditing key usage.\n *\n * @async\n * @function listKeys\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {KeyListQuery} [options] - Optional query parameters to filter the list of keys.\n * @param {number} [options.offset] - The number of items to skip before starting to collect the result set.\n * @param {boolean} [options.revoked] - If true, includes revoked keys in the results.\n * @param {boolean} [options.limitedUse] - If true, only returns keys with usage limits.\n * @param {boolean} [options.exhausted] - If true, only returns keys that have reached their usage limit.\n * @param {string} [options.name] - Filters keys by name (partial match).\n * @returns {Promise<KeyListItem[]>} A promise that resolves to an array of key objects matching the query.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the key listing process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const keys = await pinata.keys\n * .list()\n * .name(\"Admin\")\n * .revoked(false)\n */\n\nimport type {\n\tKeyListItem,\n\tKeyListQuery,\n\tKeyListResponse,\n\tPinataConfig,\n} from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const listKeys = async (\n\tconfig: PinataConfig | undefined,\n\toptions?: KeyListQuery,\n): Promise<KeyListItem[]> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/listKeys\";\n\n\tconst params = new URLSearchParams();\n\n\tif (options) {\n\t\tconst { offset, name, revoked, limitedUse, exhausted } = options;\n\n\t\tif (offset) params.append(\"offset\", offset.toString());\n\t\tif (revoked !== undefined) params.append(\"revoked\", revoked.toString());\n\t\tif (limitedUse !== undefined)\n\t\t\tparams.append(\"limitedUse\", limitedUse.toString());\n\t\tif (exhausted !== undefined)\n\t\t\tparams.append(\"exhausted\", exhausted.toString());\n\t\tif (name) params.append(\"name\", name);\n\t}\n\n\tconst url = `https://api.pinata.cloud/v3/pinata/keys?${params.toString()}`;\n\n\ttry {\n\t\tconst request = await fetch(url, {\n\t\t\tmethod: \"GET\",\n\t\t\theaders: headers,\n\t\t});\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: KeyListResponse = await request.json();\n\t\treturn res.keys;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing listKeys: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\"An unknown error occurred while listing API keys\");\n\t}\n};\n","/**\n * Revokes multiple API keys from the Pinata account.\n *\n * This function allows you to revoke (invalidate) multiple API keys at once.\n * It's useful for security purposes, such as when keys may have been compromised\n * or are no longer needed.\n *\n * @async\n * @function revokeKeys\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {string[]} keys - An array of API key strings to be revoked.\n * @returns {Promise<RevokeKeyResponse[]>} A promise that resolves to an array of objects,\n * each containing the status of the revocation attempt for each key.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the key revocation process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const revoke = await pinata.keys.revoke([\n * \"94566af5e63833e260be\"\n * ]);\n */\n\nimport type { PinataConfig, RevokeKeyResponse } from \"../types\";\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nconst wait = (milliseconds: number): Promise<void> => {\n\treturn new Promise((resolve) => {\n\t\tsetTimeout(resolve, milliseconds);\n\t});\n};\n\nexport const revokeKeys = async (\n\tconfig: PinataConfig | undefined,\n\tkeys: string[],\n): Promise<RevokeKeyResponse[]> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/revokeKeys\";\n\n\tconst responses: RevokeKeyResponse[] = [];\n\n\tfor (const key of keys) {\n\t\ttry {\n\t\t\tconst request = await fetch(\n\t\t\t\t`https://api.pinata.cloud/v3/pinata/keys/${key}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: \"PUT\",\n\t\t\t\t\theaders: headers,\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tawait wait(300);\n\n\t\t\tif (!request.ok) {\n\t\t\t\tconst errorData = await request.json();\n\t\t\t\tif (request.status === 401) {\n\t\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\t\trequest.status,\n\t\t\t\t\t\terrorData,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tthrow new NetworkError(\n\t\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst result: string = await request.json();\n\t\t\tresponses.push({\n\t\t\t\tkey: key,\n\t\t\t\tstatus: result,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tlet errorMessage: string;\n\n\t\t\tif (error instanceof PinataError) {\n\t\t\t\terrorMessage = error.message;\n\t\t\t} else if (error instanceof Error) {\n\t\t\t\terrorMessage = `Error revoking key ${key}: ${error.message}`;\n\t\t\t} else {\n\t\t\t\terrorMessage = `An unknown error occurred while revoking key ${key}`;\n\t\t\t}\n\n\t\t\tresponses.push({\n\t\t\t\tkey: key,\n\t\t\t\tstatus: errorMessage,\n\t\t\t});\n\t\t}\n\t}\n\n\treturn responses;\n};\n","/**\n * Creates a new group in Pinata for organizing pinned content.\n *\n * This function allows you to create a new group in your Pinata account.\n * Groups can be used to organize and manage your pinned content more effectively.\n *\n * @async\n * @function createGroup\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {GroupOptions} options - The options for creating a new group.\n * @param {string} options.name - The name of the group to be created.\n * @returns {Promise<GroupResponseItem>} A promise that resolves to an object containing details of the created group.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the group creation process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const group = await pinata.groups.create({\n *\tname: \"My New Group\",\n * });\n */\n\nimport type { PinataConfig, GroupOptions, GroupResponseItem } from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const createGroup = async (\n\tconfig: PinataConfig | undefined,\n\toptions: GroupOptions,\n): Promise<GroupResponseItem> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst data = JSON.stringify(options);\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/createGroup\";\n\n\ttry {\n\t\tconst request = await fetch(\"https://api.pinata.cloud/groups\", {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: headers,\n\t\t\tbody: data,\n\t\t});\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: GroupResponseItem = await request.json();\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing createGroup: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\"An unknown error occurred while creating a group\");\n\t}\n};\n","/**\n * Retrieves a list of groups from Pinata.\n *\n * This function fetches a list of groups associated with your Pinata account.\n * It supports pagination and filtering by name.\n *\n * @async\n * @function listGroups\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {GroupQueryOptions} [options] - Optional query parameters to filter and paginate the results.\n * @param {number} [options.offset] - The number of items to skip before starting to collect the result set.\n * @param {string} [options.nameContains] - Filter groups by name (case-insensitive partial match).\n * @param {number} [options.limit] - The numbers of items to return.\n * @returns {Promise<GroupResponseItem[]>} A promise that resolves to an array of group objects.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the group listing process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const groups = await pinata.groups\n * .list()\n * .name(\"Greetings\");\n */\n\nimport type {\n\tPinataConfig,\n\tGroupResponseItem,\n\tGroupQueryOptions,\n} from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const listGroups = async (\n\tconfig: PinataConfig | undefined,\n\toptions?: GroupQueryOptions,\n): Promise<GroupResponseItem[]> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/listGroups\";\n\n\tconst params = new URLSearchParams();\n\n\tif (options) {\n\t\tconst { offset, nameContains, limit } = options;\n\n\t\tif (offset) params.append(\"offset\", offset.toString());\n\t\tif (nameContains !== undefined)\n\t\t\tparams.append(\"nameContains\", nameContains.toString());\n\t\tif (limit !== undefined) params.append(\"limit\", limit.toString());\n\t}\n\n\tconst url = `https://api.pinata.cloud/groups?${params.toString()}`;\n\n\ttry {\n\t\tconst request = await fetch(url, {\n\t\t\tmethod: \"GET\",\n\t\t\theaders: headers,\n\t\t});\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: GroupResponseItem[] = await request.json();\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing listGroups: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\"An unknown error occurred while listing groups\");\n\t}\n};\n","/**\n * Retrieves information about a specific group from Pinata.\n *\n * This function fetches details about a group in your Pinata account using its ID.\n * It provides information such as the group's name, creation date, and last update time.\n *\n * @async\n * @function getGroup\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {GetGroupOptions} options - The options for retrieving a group.\n * @param {string} options.groupId - The ID of the group to retrieve.\n * @returns {Promise<GroupResponseItem>} A promise that resolves to an object containing the group's details.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the group retrieval process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const groups = await pinata.groups.get({\n *\tgroupId: \"3778c10d-452e-4def-8299-ee6bc548bdb0\",\n * });\n */\n\nimport type {\n\tPinataConfig,\n\tGroupResponseItem,\n\tGetGroupOptions,\n} from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const getGroup = async (\n\tconfig: PinataConfig | undefined,\n\toptions: GetGroupOptions,\n): Promise<GroupResponseItem> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/getGroup\";\n\n\ttry {\n\t\tconst request = await fetch(\n\t\t\t`https://api.pinata.cloud/groups/${options.groupId}`,\n\t\t\t{\n\t\t\t\tmethod: \"GET\",\n\t\t\t\theaders: headers,\n\t\t\t},\n\t\t);\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: GroupResponseItem = await request.json();\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing getGroup: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\n\t\t\t\"An unknown error occurred while getting info for a group\",\n\t\t);\n\t}\n};\n","/**\n * Adds one or more CIDs (Content Identifiers) to a specified Pinata group.\n *\n * This function allows you to associate multiple CIDs with a group in Pinata,\n * which can be useful for organizing and managing your pinned content.\n *\n * @async\n * @function addToGroup\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {GroupCIDOptions} options - The options for adding CIDs to a group.\n * @param {string} options.groupId - The ID of the group to add the CIDs to.\n * @param {string[]} options.cids - An array of CIDs to add to the group.\n * @returns {Promise<string>} A promise that resolves to a string confirming the addition.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const group = await pinata.groups.addCids({\n * \tgroupId: \"3778c10d-452e-4def-8299-ee6bc548bdb0\",\n * \tcids: [\"QmVLwvmGehsrNEvhcCnnsw5RQNseohgEkFNN1848zNzdng\"],\n * });\n */\nimport type { GroupCIDOptions, PinataConfig } from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const addToGroup = async (\n\tconfig: PinataConfig | undefined,\n\toptions: GroupCIDOptions,\n): Promise<string> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst data = JSON.stringify({\n\t\tcids: options.cids,\n\t});\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/addToGroup\";\n\n\ttry {\n\t\tconst request = await fetch(\n\t\t\t`https://api.pinata.cloud/groups/${options.groupId}/cids`,\n\t\t\t{\n\t\t\t\tmethod: \"PUT\",\n\t\t\t\theaders: headers,\n\t\t\t\tbody: data,\n\t\t\t},\n\t\t);\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: string = await request.text();\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing addToGroup: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\n\t\t\t\"An unknown error occurred while adding CIDs to group\",\n\t\t);\n\t}\n};\n","/**\n * Updates the information of a specified group in Pinata.\n *\n * This function allows you to modify the name of an existing group in your Pinata account.\n * It's useful for renaming groups to better organize your pinned content.\n *\n * @async\n * @function updateGroup\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {UpdateGroupOptions} options - The options for updating a group.\n * @param {string} options.groupId - The ID of the group to be updated.\n * @param {string} options.name - The new name for the group.\n * @returns {Promise<GroupResponseItem>} A promise that resolves to an object containing the updated group's details.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the group update process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const groups = await pinata.groups.update({\n *\tgroupId: \"3778c10d-452e-4def-8299-ee6bc548bdb0\",\n *\tname: \"My New Group 2\"\n * });\n */\n\nimport type {\n\tPinataConfig,\n\tGroupResponseItem,\n\tUpdateGroupOptions,\n} from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const updateGroup = async (\n\tconfig: PinataConfig | undefined,\n\toptions: UpdateGroupOptions,\n): Promise<GroupResponseItem> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst data = JSON.stringify({\n\t\tname: options.name,\n\t});\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/updateGroup\";\n\n\ttry {\n\t\tconst request = await fetch(\n\t\t\t`https://api.pinata.cloud/groups/${options.groupId}`,\n\t\t\t{\n\t\t\t\tmethod: \"PUT\",\n\t\t\t\theaders: headers,\n\t\t\t\tbody: data,\n\t\t\t},\n\t\t);\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: GroupResponseItem = await request.json();\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing updateGroup: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\"An unknown error occurred while updating group\");\n\t}\n};\n","/**\n * Removes one or more CIDs (Content Identifiers) from a specified Pinata group.\n *\n * This function allows you to disassociate multiple CIDs from a group in Pinata.\n * It's useful for managing the content within your groups without deleting the actual files.\n *\n * @async\n * @function removeFromGroup\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {GroupCIDOptions} options - The options for removing CIDs from a group.\n * @param {string} options.groupId - The ID of the group to remove the CIDs from.\n * @param {string[]} options.cids - An array of CIDs to remove from the group.\n * @returns {Promise<string>} A promise that resolves to a string confirming the removal.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the process.\n *\n * @example\n *import { PinataSDK } from \"pinata\";\n *\n *const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n *});\n *\n *const group = await pinata.groups.removeCids({\n *\tgroupId: \"3778c10d-452e-4def-8299-ee6bc548bdb0\",\n *\tcids: [\"QmVLwvmGehsrNEvhcCnnsw5RQNseohgEkFNN1848zNzdng\"],\n *});\n */\n\nimport type { GroupCIDOptions, PinataConfig } from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const removeFromGroup = async (\n\tconfig: PinataConfig | undefined,\n\toptions: GroupCIDOptions,\n): Promise<string> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/removeFromGroup\";\n\n\tconst data = JSON.stringify({\n\t\tcids: options.cids,\n\t});\n\n\ttry {\n\t\tconst request = await fetch(\n\t\t\t`https://api.pinata.cloud/groups/${options.groupId}/cids`,\n\t\t\t{\n\t\t\t\tmethod: \"DELETE\",\n\t\t\t\theaders: headers,\n\t\t\t\tbody: data,\n\t\t\t},\n\t\t);\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: string = await request.text();\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(\n\t\t\t\t`Error processing removeFromGroup: ${error.message}`,\n\t\t\t);\n\t\t}\n\t\tthrow new PinataError(\n\t\t\t\"An unknown error occurred while removing CIDs from a group\",\n\t\t);\n\t}\n};\n","/**\n * Deletes a specified group from Pinata.\n *\n * This function allows you to remove a group from your Pinata account.\n * Note that deleting a group does not delete the files within the group,\n * it only removes the group association.\n *\n * @async\n * @function deleteGroup\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {GetGroupOptions} options - The options for deleting a group.\n * @param {string} options.groupId - The ID of the group to be deleted.\n * @returns {Promise<string>} A promise that resolves to a string confirming the deletion.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the group deletion process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const groups = await pinata.groups.delete({\n *\tgroupId: \"3778c10d-452e-4def-8299-ee6bc548bdb0\",\n * });\n */\n\nimport type { GetGroupOptions, PinataConfig } from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const deleteGroup = async (\n\tconfig: PinataConfig | undefined,\n\toptions: GetGroupOptions,\n): Promise<string> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/deleteGroup\";\n\n\ttry {\n\t\tconst request = await fetch(\n\t\t\t`https://api.pinata.cloud/groups/${options.groupId}`,\n\t\t\t{\n\t\t\t\tmethod: \"DELETE\",\n\t\t\t\theaders: headers,\n\t\t\t},\n\t\t);\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: string = await request.text();\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing deleteGroup: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\"An unknown error occurred while deleting a group\");\n\t}\n};\n","/**\n * Adds a signature to a specific Content Identifier (CID) on Pinata.\n *\n * This function allows you to add a cryptographic signature to a file identified by its CID.\n * It's useful for verifying ownership or authenticity of content stored on IPFS via Pinata.\n *\n * @async\n * @function addSignature\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {SignatureOptions} options - Options for adding the signature.\n * @param {string} options.cid - The Content Identifier (CID) of the file to be signed.\n * @param {string} options.signature - The cryptographic signature to be added.\n * @returns {Promise<SignatureResponse>} A promise that resolves to an object containing the signature details.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {PinataError} If the user is unauthorized to sign the file or if the file already has a signature.\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the signature addition process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const signature = await pinata.signatures.add({\n *\tcid: \"QmXGeVy9dVwfuFJmvbzz8y4dYK1TdxXbDGzwbNuyZ5xXSU\",\n *\tsignature: \"0x1ba6c2a8412dc9b0be37b013ea5bddd97251dab4d435cc9c4c7bcf331d4017ca2de07485ad6a15ce60d3700cee802787bc7ede0c112c7843f702bb1e71b750911b\"\n * })\n */\n\nimport type {\n\tSignatureOptions,\n\tPinataConfig,\n\tSignatureResponse,\n} from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const addSignature = async (\n\tconfig: PinataConfig | undefined,\n\toptions: SignatureOptions,\n): Promise<SignatureResponse> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst data = JSON.stringify({\n\t\tsignature: options.signature,\n\t});\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/addSignature\";\n\n\ttry {\n\t\tconst request = await fetch(\n\t\t\t`https://api.pinata.cloud/v3/ipfs/signature/${options.cid}`,\n\t\t\t{\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: headers,\n\t\t\t\tbody: data,\n\t\t\t},\n\t\t);\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (request.status === 403) {\n\t\t\t\tthrow new PinataError(\n\t\t\t\t\t\"Unauthorized signing, you must be the original owner of the file and it must not have a signature\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res = await request.json();\n\t\treturn res.data;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing addSignature: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\n\t\t\t\"An unknown error occurred while adding signature to CID\",\n\t\t);\n\t}\n};\n","/**\n * Retrieves the signature associated with a specific Content Identifier (CID) from Pinata.\n *\n * This function allows you to fetch the cryptographic signature associated with a file\n * identified by its CID. It's useful for verifying the authenticity or ownership of\n * content stored on IPFS via Pinata.\n *\n * @async\n * @function getSignature\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {string} cid - The Content Identifier (CID) of the file whose signature is to be retrieved.\n * @returns {Promise<SignatureResponse>} A promise that resolves to an object containing the signature details.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the signature retrieval process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const signature = await pinata.signatures.get(\"QmXGeVy9dVwfuFJmvbzz8y4dYK1TdxXbDGzwbNuyZ5xXSU\"\n )\n */\n\nimport type { PinataConfig, SignatureResponse } from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const getSignature = async (\n\tconfig: PinataConfig | undefined,\n\tcid: string,\n): Promise<SignatureResponse> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/getSignature\";\n\n\ttry {\n\t\tconst request = await fetch(\n\t\t\t`https://api.pinata.cloud/v3/ipfs/signature/${cid}`,\n\t\t\t{\n\t\t\t\tmethod: \"GET\",\n\t\t\t\theaders: headers,\n\t\t\t},\n\t\t);\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res = await request.json();\n\t\treturn res.data;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing getSignature: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\n\t\t\t\"An unknown error occurred while fetching signature for CID\",\n\t\t);\n\t}\n};\n","/**\n * Removes the signature associated with a specific Content Identifier (CID) from Pinata.\n *\n * This function allows you to delete the cryptographic signature associated with a file\n * identified by its CID. It's useful for managing ownership claims or updating the\n * authenticity status of content stored on IPFS via Pinata.\n *\n * @async\n * @function removeSignature\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {string} cid - The Content Identifier (CID) of the file whose signature is to be removed.\n * @returns {Promise<string>} A promise that resolves to \"OK\" if the signature was successfully removed.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the signature removal process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const signature = await pinata.signatures.delete(\"QmXGeVy9dVwfuFJmvbzz8y4dYK1TdxXbDGzwbNuyZ5xXSU\"\n )\n */\n\nimport type { PinataConfig } from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const removeSignature = async (\n\tconfig: PinataConfig | undefined,\n\tcid: string,\n): Promise<string> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/removeSignature\";\n\n\ttry {\n\t\tconst request = await fetch(\n\t\t\t`https://api.pinata.cloud/v3/ipfs/signature/${cid}`,\n\t\t\t{\n\t\t\t\tmethod: \"DELETE\",\n\t\t\t\theaders: headers,\n\t\t\t},\n\t\t);\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\t\treturn \"OK\";\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing addSignature: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\n\t\t\t\"An unknown error occurred while adding signature to CID\",\n\t\t);\n\t}\n};\n","import type {\n\tFileObject,\n\tPinByCIDResponse,\n\tPinListItem,\n\tPinListQuery,\n\tPinResponse,\n\tPinataConfig,\n\tPinataMetadata,\n\tPinataMetadataUpdate,\n\tUploadCIDOptions,\n\tUploadOptions,\n\tGetCIDResponse,\n\tPinJobQuery,\n\tPinJobItem,\n\tKeyOptions,\n\tKeyResponse,\n\tKeyListQuery,\n\tKeyListItem,\n\tGroupOptions,\n\tGroupResponseItem,\n\tUpdateGroupOptions,\n\tGroupCIDOptions,\n\tGroupQueryOptions,\n\tGetGroupOptions,\n\tAuthTestResponse,\n\tUnpinResponse,\n\tRevokeKeyResponse,\n\tSignatureOptions,\n\tSignatureResponse,\n} from \"./types\";\nimport { testAuthentication } from \"./authentication/testAuthentication\";\nimport { uploadFile } from \"./pinning/file\";\nimport { uploadFileArray } from \"./pinning/fileArray\";\nimport { uploadBase64 } from \"./pinning/base64\";\nimport { uploadUrl } from \"./pinning/url\";\nimport { uploadJson } from \"./pinning/json\";\nimport { uploadCid } from \"./pinning/cid\";\nimport { unpinFile } from \"./pinning/unpin\";\nimport { listFiles } from \"./data/listFiles\";\nimport { updateMetadata } from \"./data/updateMetadata\";\nimport { getCid } from \"./gateway/getCid\";\nimport { convertIPFSUrl } from \"./gateway/convertIPFSUrl\";\nimport { pinJobs } from \"./data/pinJobs\";\nimport { pinnedFileCount } from \"./data/pinnedFileUsage\";\nimport { totalStorageUsage } from \"./data/totalStorageUsage\";\nimport { createKey } from \"./keys/createKey\";\nimport { listKeys } from \"./keys/listKeys\";\nimport { revokeKeys } from \"./keys/revokeKeys\";\nimport { createGroup } from \"./groups/createGroup\";\nimport { listGroups } from \"./groups/listGroups\";\nimport { getGroup } from \"./groups/getGroup\";\nimport { addToGroup } from \"./groups/addToGroup\";\nimport { updateGroup } from \"./groups/updateGroup\";\nimport { removeFromGroup } from \"./groups/removeFromGroup\";\nimport { deleteGroup } from \"./groups/deleteGroup\";\nimport { addSignature } from \"./signatures/addSignature\";\nimport { getSignature } from \"./signatures/getSignature\";\nimport { removeSignature } from \"./signatures/removeSignature\";\n\nconst formatConfig = (config: PinataConfig | undefined) => {\n\tlet gateway = config?.pinataGateway;\n\tif (config && gateway) {\n\t\tif (gateway && !gateway.startsWith(\"https://\")) {\n\t\t\tgateway = `https://${gateway}`;\n\t\t}\n\t\tconfig.pinataGateway = gateway;\n\t}\n\treturn config;\n};\n\nexport class PinataSDK {\n\tconfig: PinataConfig | undefined;\n\tupload: Upload;\n\tgateways: Gateways;\n\tusage: Usage;\n\tkeys: Keys;\n\tgroups: Groups;\n\tsignatures: Signatures;\n\n\tconstructor(config?: PinataConfig) {\n\t\tthis.config = formatConfig(config);\n\t\tthis.upload = new Upload(this.config);\n\t\tthis.gateways = new Gateways(this.config);\n\t\tthis.usage = new Usage(this.config);\n\t\tthis.keys = new Keys(this.config);\n\t\tthis.groups = new Groups(this.config);\n\t\tthis.signatures = new Signatures(this.config);\n\t}\n\n\ttestAuthentication(): Promise<AuthTestResponse> {\n\t\treturn testAuthentication(this.config);\n\t}\n\n\tunpin(files: string[]): Promise<UnpinResponse[]> {\n\t\treturn unpinFile(this.config, files);\n\t}\n\n\tlistFiles(): FilterFiles {\n\t\treturn new FilterFiles(this.config);\n\t}\n\n\tupdateMetadata(options: PinataMetadataUpdate): Promise<string> {\n\t\treturn updateMetadata(this.config, options);\n\t}\n\n\tpinJobs(): FilterPinJobs {\n\t\treturn new FilterPinJobs(this.config);\n\t}\n}\n\nclass UploadBuilder<T> {\n\tprivate config: PinataConfig | undefined;\n\tprivate uploadFunction: (\n\t\tconfig: PinataConfig | undefined,\n\t\t...args: any[]\n\t) => Promise<T>;\n\tprivate args: any[];\n\tprivate metadata: PinataMetadata | undefined;\n\tprivate keys: string | undefined;\n\tprivate peerAddresses: string[] | undefined;\n\tprivate version: 0 | 1 | undefined;\n\tprivate groupId: string | undefined;\n\n\tconstructor(\n\t\tconfig: PinataConfig | undefined,\n\t\tuploadFunction: (\n\t\t\tconfig: PinataConfig | undefined,\n\t\t\t...args: any[]\n\t\t) => Promise<T>,\n\t\t...args: any[]\n\t) {\n\t\tthis.config = config;\n\t\tthis.uploadFunction = uploadFunction;\n\t\tthis.args = args;\n\t\tthis.version = 1;\n\t}\n\n\taddMetadata(metadata: PinataMetadata): UploadBuilder<T> {\n\t\tthis.metadata = metadata;\n\t\treturn this;\n\t}\n\n\tkey(jwt: string): UploadBuilder<T> {\n\t\tthis.keys = jwt;\n\t\treturn this;\n\t}\n\n\tcidVersion(v: 0 | 1): UploadBuilder<T> {\n\t\tthis.version = v;\n\t\treturn this;\n\t}\n\n\tgroup(groupId: string): UploadBuilder<T> {\n\t\tthis.groupId = groupId;\n\t\treturn this;\n\t}\n\n\tpeerAddress(peerAddresses: string[]): UploadBuilder<T> {\n\t\tthis.peerAddresses = peerAddresses;\n\t\treturn this;\n\t}\n\n\tthen<TResult1 = T, TResult2 = never>(\n\t\tonfulfilled?:\n\t\t\t| ((value: T) => TResult1 | PromiseLike<TResult1>)\n\t\t\t| null\n\t\t\t| undefined,\n\t\tonrejected?:\n\t\t\t| ((reason: any) => TResult2 | PromiseLike<TResult2>)\n\t\t\t| null\n\t\t\t| undefined,\n\t): Promise<TResult1 | TResult2> {\n\t\tconst options: UploadOptions = this.args[this.args.length - 1] || {};\n\t\tif (this.metadata) {\n\t\t\toptions.metadata = this.metadata;\n\t\t}\n\t\tif (this.keys) {\n\t\t\toptions.keys = this.keys;\n\t\t}\n\t\tif (this.groupId) {\n\t\t\toptions.groupId = this.groupId;\n\t\t}\n\t\tif (this.version) {\n\t\t\toptions.cidVersion = this.version;\n\t\t}\n\t\tif (this.peerAddresses && \"peerAddresses\" in options) {\n\t\t\toptions.peerAddresses = this.peerAddresses;\n\t\t}\n\t\tthis.args[this.args.length - 1] = options;\n\t\treturn this.uploadFunction(this.config, ...this.args).then(\n\t\t\tonfulfilled,\n\t\t\tonrejected,\n\t\t);\n\t}\n}\n\nclass Upload {\n\tconfig: PinataConfig | undefined;\n\n\tconstructor(config?: PinataConfig) {\n\t\tthis.config = formatConfig(config);\n\t}\n\n\tfile(file: FileObject, options?: UploadOptions): UploadBuilder<PinResponse> {\n\t\treturn new UploadBuilder(this.config, uploadFile, file, options);\n\t}\n\n\tfileArray(\n\t\tfiles: FileObject[],\n\t\toptions?: UploadOptions,\n\t): UploadBuilder<PinResponse> {\n\t\treturn new UploadBuilder(this.config, uploadFileArray, files, options);\n\t}\n\n\tbase64(\n\t\tbase64String: string,\n\t\toptions?: UploadOptions,\n\t): UploadBuilder<PinResponse> {\n\t\treturn new UploadBuilder(this.config, uploadBase64, base64String, options);\n\t}\n\n\turl(url: string, options?: UploadOptions): UploadBuilder<PinResponse> {\n\t\treturn new UploadBuilder(this.config, uploadUrl, url, options);\n\t}\n\n\tjson(data: object, options?: UploadOptions): UploadBuilder<PinResponse> {\n\t\treturn new UploadBuilder(this.config, uploadJson, data, options);\n\t}\n\n\tcid(\n\t\tcid: string,\n\t\toptions?: UploadCIDOptions,\n\t): UploadBuilder<PinByCIDResponse> {\n\t\treturn new UploadBuilder(this.config, uploadCid, cid, options);\n\t}\n}\n\nclass FilterFiles {\n\tprivate config: PinataConfig | undefined;\n\tprivate query: PinListQuery = {};\n\t// rate limit vars\n\tprivate requestCount = 0;\n\tprivate lastRequestTime = 0;\n\tprivate readonly MAX_REQUESTS_PER_MINUTE = 30;\n\tprivate readonly MINUTE_IN_MS = 60000;\n\n\tconstructor(config: PinataConfig | undefined) {\n\t\tthis.config = config;\n\t}\n\n\tcid(cid: string): FilterFiles {\n\t\tthis.query.cid = cid;\n\t\treturn this;\n\t}\n\n\tpinStart(date: string): FilterFiles {\n\t\tthis.query.pinStart = date;\n\t\treturn this;\n\t}\n\n\tpinEnd(date: string): FilterFiles {\n\t\tthis.query.pinEnd = date;\n\t\treturn this;\n\t}\n\n\tpinSizeMin(size: number): FilterFiles {\n\t\tthis.query.pinSizeMin = size;\n\t\treturn this;\n\t}\n\n\tpinSizeMax(size: number): FilterFiles {\n\t\tthis.query.pinSizeMax = size;\n\t\treturn this;\n\t}\n\n\tpageLimit(limit: number): FilterFiles {\n\t\tthis.query.pageLimit = limit;\n\t\treturn this;\n\t}\n\n\tpageOffset(offset: number): FilterFiles {\n\t\tthis.query.pageOffset = offset;\n\t\treturn this;\n\t}\n\n\tname(name: string): FilterFiles {\n\t\tthis.query.name = name;\n\t\treturn this;\n\t}\n\n\tgroup(groupId: string): FilterFiles {\n\t\tthis.query.groupId = groupId;\n\t\treturn this;\n\t}\n\n\tkeyValue(\n\t\tkey: string,\n\t\tvalue: string | number,\n\t\toperator?: PinListQuery[\"operator\"],\n\t): FilterFiles {\n\t\tthis.query.key = key;\n\t\tthis.query.value = value;\n\t\tif (operator) {\n\t\t\tthis.query.operator = operator;\n\t\t}\n\t\treturn this;\n\t}\n\n\tthen(onfulfilled?: ((value: PinListItem[]) => any) | null): Promise<any> {\n\t\treturn listFiles(this.config, this.query).then(onfulfilled);\n\t}\n\n\t// rate limit, hopefully temporary?\n\tprivate async rateLimit(): Promise<void> {\n\t\tthis.requestCount++;\n\t\tconst now = Date.now();\n\t\tif (this.requestCount >= this.MAX_REQUESTS_PER_MINUTE) {\n\t\t\tconst timePassedSinceLastRequest = now - this.lastRequestTime;\n\t\t\tif (timePassedSinceLastRequest < this.MINUTE_IN_MS) {\n\t\t\t\tconst delayTime = this.MINUTE_IN_MS - timePassedSinceLastRequest;\n\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, delayTime));\n\t\t\t}\n\t\t\tthis.requestCount = 0;\n\t\t}\n\t\tthis.lastRequestTime = Date.now();\n\t}\n\n\tasync *[Symbol.asyncIterator](): AsyncGenerator<PinListItem, void, unknown> {\n\t\tlet hasMore = true;\n\t\tlet offset = 0;\n\t\tconst limit = this.query.pageLimit || 10;\n\n\t\twhile (hasMore) {\n\t\t\tawait this.rateLimit(); // applying rate limit\n\t\t\tthis.query.pageOffset = offset;\n\t\t\tthis.query.pageLimit = limit;\n\n\t\t\tconst items = await listFiles(this.config, this.query);\n\n\t\t\tfor (const item of items) {\n\t\t\t\tyield item;\n\t\t\t}\n\n\t\t\tif (items.length === 0) {\n\t\t\t\thasMore = false;\n\t\t\t} else {\n\t\t\t\toffset += items.length;\n\t\t\t}\n\t\t}\n\t}\n\n\tasync all(): Promise<PinListItem[]> {\n\t\tconst allItems: PinListItem[] = [];\n\t\tfor await (const item of this) {\n\t\t\tallItems.push(item);\n\t\t}\n\t\treturn allItems;\n\t}\n}\n\nclass Gateways {\n\tconfig: PinataConfig | undefined;\n\n\tconstructor(config?: PinataConfig) {\n\t\tthis.config = formatConfig(config);\n\t}\n\n\tget(cid: string): Promise<GetCIDResponse> {\n\t\treturn getCid(this.config, cid);\n\t}\n\n\tconvert(url: string): string {\n\t\treturn convertIPFSUrl(this.config, url);\n\t}\n}\n\nclass FilterPinJobs {\n\tprivate config: PinataConfig | undefined;\n\tprivate query: PinJobQuery = {};\n\t// rate limit vars\n\tprivate requestCount = 0;\n\tprivate lastRequestTime = 0;\n\tprivate readonly MAX_REQUESTS_PER_MINUTE = 30;\n\tprivate readonly MINUTE_IN_MS = 60000;\n\n\tconstructor(config: PinataConfig | undefined) {\n\t\tthis.config = config;\n\t}\n\n\tcid(cid: string): FilterPinJobs {\n\t\tthis.query.ipfs_pin_hash = cid;\n\t\treturn this;\n\t}\n\n\tstatus(\n\t\tstatus:\n\t\t\t| \"prechecking\"\n\t\t\t| \"retrieving\"\n\t\t\t| \"expired\"\n\t\t\t| \"over_free_limit\"\n\t\t\t| \"over_max_size\"\n\t\t\t| \"invalid_object\"\n\t\t\t| \"bad_host_node\",\n\t): FilterPinJobs {\n\t\tthis.query.status = status;\n\t\treturn this;\n\t}\n\n\tpageLimit(limit: number): FilterPinJobs {\n\t\tthis.query.limit = limit;\n\t\treturn this;\n\t}\n\n\tpageOffset(offset: number): FilterPinJobs {\n\t\tthis.query.offset = offset;\n\t\treturn this;\n\t}\n\n\tsort(sort: \"ASC\" | \"DSC\"): FilterPinJobs {\n\t\tthis.query.sort = sort;\n\t\treturn this;\n\t}\n\n\tthen(onfulfilled?: ((value: PinJobItem[]) => any) | null): Promise<any> {\n\t\treturn pinJobs(this.config, this.query).then(onfulfilled);\n\t}\n\n\t// rate limit, hopefully temporary?\n\tprivate async rateLimit(): Promise<void> {\n\t\tthis.requestCount++;\n\t\tconst now = Date.now();\n\t\tif (this.requestCount >= this.MAX_REQUESTS_PER_MINUTE) {\n\t\t\tconst timePassedSinceLastRequest = now - this.lastRequestTime;\n\t\t\tif (timePassedSinceLastRequest < this.MINUTE_IN_MS) {\n\t\t\t\tconst delayTime = this.MINUTE_IN_MS - timePassedSinceLastRequest;\n\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, delayTime));\n\t\t\t}\n\t\t\tthis.requestCount = 0;\n\t\t}\n\t\tthis.lastRequestTime = Date.now();\n\t}\n\n\tasync *[Symbol.asyncIterator](): AsyncGenerator<PinJobItem, void, unknown> {\n\t\tlet hasMore = true;\n\t\tlet offset = 0;\n\t\tconst limit = this.query.limit || 10;\n\n\t\twhile (hasMore) {\n\t\t\tawait this.rateLimit(); // applying rate limit\n\t\t\tthis.query.offset = offset;\n\t\t\tthis.query.limit = limit;\n\n\t\t\tconst items = await pinJobs(this.config, this.query);\n\n\t\t\tfor (const item of items) {\n\t\t\t\tyield item;\n\t\t\t}\n\n\t\t\tif (items.length === 0) {\n\t\t\t\thasMore = false;\n\t\t\t} else {\n\t\t\t\toffset += items.length;\n\t\t\t}\n\t\t}\n\t}\n\n\tasync all(): Promise<PinJobItem[]> {\n\t\tconst allItems: PinJobItem[] = [];\n\t\tfor await (const item of this) {\n\t\t\tallItems.push(item);\n\t\t}\n\t\treturn allItems;\n\t}\n}\n\nclass Usage {\n\tconfig: PinataConfig | undefined;\n\n\tconstructor(config?: PinataConfig) {\n\t\tthis.config = formatConfig(config);\n\t}\n\n\tpinnedFileCount(): Promise<number> {\n\t\treturn pinnedFileCount(this.config);\n\t}\n\n\ttotalStorageSize(): Promise<number> {\n\t\treturn totalStorageUsage(this.config);\n\t}\n}\n\nclass Keys {\n\tconfig: PinataConfig | undefined;\n\n\tconstructor(config?: PinataConfig) {\n\t\tthis.config = formatConfig(config);\n\t}\n\n\tcreate(options: KeyOptions): Promise<KeyResponse> {\n\t\treturn createKey(this.config, options);\n\t}\n\n\tlist(): FilterKeys {\n\t\treturn new FilterKeys(this.config);\n\t}\n\n\trevoke(keys: string[]): Promise<RevokeKeyResponse[]> {\n\t\treturn revokeKeys(this.config, keys);\n\t}\n}\n\nclass FilterKeys {\n\tprivate config: PinataConfig | undefined;\n\tprivate query: KeyListQuery = {};\n\t// rate limit vars\n\tprivate requestCount = 0;\n\tprivate lastRequestTime = 0;\n\tprivate readonly MAX_REQUESTS_PER_MINUTE = 30;\n\tprivate readonly MINUTE_IN_MS = 60000;\n\n\tconstructor(config: PinataConfig | undefined) {\n\t\tthis.config = config;\n\t}\n\n\toffset(offset: number): FilterKeys {\n\t\tthis.query.offset = offset;\n\t\treturn this;\n\t}\n\n\trevoked(revoked: boolean): FilterKeys {\n\t\tthis.query.revoked = revoked;\n\t\treturn this;\n\t}\n\n\tlimitedUse(limitedUse: boolean): FilterKeys {\n\t\tthis.query.limitedUse = limitedUse;\n\t\treturn this;\n\t}\n\n\texhausted(exhausted: boolean): FilterKeys {\n\t\tthis.query.exhausted = exhausted;\n\t\treturn this;\n\t}\n\n\tname(name: string): FilterKeys {\n\t\tthis.query.name = name;\n\t\treturn this;\n\t}\n\n\tthen(onfulfilled?: ((value: KeyListItem[]) => any) | null): Promise<any> {\n\t\treturn listKeys(this.config, this.query).then(onfulfilled);\n\t}\n\n\t// rate limit, hopefully temporary?\n\tprivate async rateLimit(): Promise<void> {\n\t\tthis.requestCount++;\n\t\tconst now = Date.now();\n\t\tif (this.requestCount >= this.MAX_REQUESTS_PER_MINUTE) {\n\t\t\tconst timePassedSinceLastRequest = now - this.lastRequestTime;\n\t\t\tif (timePassedSinceLastRequest < this.MINUTE_IN_MS) {\n\t\t\t\tconst delayTime = this.MINUTE_IN_MS - timePassedSinceLastRequest;\n\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, delayTime));\n\t\t\t}\n\t\t\tthis.requestCount = 0;\n\t\t}\n\t\tthis.lastRequestTime = Date.now();\n\t}\n\n\tasync *[Symbol.asyncIterator](): AsyncGenerator<KeyListItem, void, unknown> {\n\t\tlet hasMore = true;\n\t\tlet offset = 0;\n\n\t\twhile (hasMore) {\n\t\t\tawait this.rateLimit(); // applying rate limit\n\t\t\tthis.query.offset = offset;\n\n\t\t\tconst items = await listKeys(this.config, this.query);\n\n\t\t\tfor (const item of items) {\n\t\t\t\tyield item;\n\t\t\t}\n\n\t\t\tif (items.length === 0) {\n\t\t\t\thasMore = false;\n\t\t\t} else {\n\t\t\t\toffset += items.length;\n\t\t\t}\n\t\t}\n\t}\n\n\tasync all(): Promise<KeyListItem[]> {\n\t\tconst allItems: KeyListItem[] = [];\n\t\tfor await (const item of this) {\n\t\t\tallItems.push(item);\n\t\t}\n\t\treturn allItems;\n\t}\n}\n\nclass Groups {\n\tconfig: PinataConfig | undefined;\n\n\tconstructor(config?: PinataConfig) {\n\t\tthis.config = formatConfig(config);\n\t}\n\n\tcreate(options: GroupOptions): Promise<GroupResponseItem> {\n\t\treturn createGroup(this.config, options);\n\t}\n\n\tlist(): FilterGroups {\n\t\treturn new FilterGroups(this.config);\n\t}\n\n\tget(options: GetGroupOptions): Promise<GroupResponseItem> {\n\t\treturn getGroup(this.config, options);\n\t}\n\n\taddCids(options: GroupCIDOptions): Promise<string> {\n\t\treturn addToGroup(this.config, options);\n\t}\n\n\tremoveCids(options: GroupCIDOptions): Promise<string> {\n\t\treturn removeFromGroup(this.config, options);\n\t}\n\n\tupdate(options: UpdateGroupOptions): Promise<GroupResponseItem> {\n\t\treturn updateGroup(this.config, options);\n\t}\n\n\tdelete(options: GetGroupOptions): Promise<string> {\n\t\treturn deleteGroup(this.config, options);\n\t}\n}\n\nclass FilterGroups {\n\tprivate config: PinataConfig | undefined;\n\tprivate query: GroupQueryOptions = {};\n\t// rate limit vars\n\tprivate requestCount = 0;\n\tprivate lastRequestTime = 0;\n\tprivate readonly MAX_REQUESTS_PER_MINUTE = 30;\n\tprivate readonly MINUTE_IN_MS = 60000;\n\n\tconstructor(config: PinataConfig | undefined) {\n\t\tthis.config = config;\n\t}\n\n\toffset(offset: number): FilterGroups {\n\t\tthis.query.offset = offset;\n\t\treturn this;\n\t}\n\n\tname(nameContains: string): FilterGroups {\n\t\tthis.query.nameContains = nameContains;\n\t\treturn this;\n\t}\n\n\tlimit(limit: number): FilterGroups {\n\t\tthis.query.limit = limit;\n\t\treturn this;\n\t}\n\n\tthen(\n\t\tonfulfilled?: ((value: GroupResponseItem[]) => any) | null,\n\t): Promise<any> {\n\t\treturn listGroups(this.config, this.query).then(onfulfilled);\n\t}\n\n\t// rate limit, hopefully temporary?\n\tprivate async rateLimit(): Promise<void> {\n\t\tthis.requestCount++;\n\t\tconst now = Date.now();\n\t\tif (this.requestCount >= this.MAX_REQUESTS_PER_MINUTE) {\n\t\t\tconst timePassedSinceLastRequest = now - this.lastRequestTime;\n\t\t\tif (timePassedSinceLastRequest < this.MINUTE_IN_MS) {\n\t\t\t\tconst delayTime = this.MINUTE_IN_MS - timePassedSinceLastRequest;\n\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, delayTime));\n\t\t\t}\n\t\t\tthis.requestCount = 0;\n\t\t}\n\t\tthis.lastRequestTime = Date.now();\n\t}\n\n\tasync *[Symbol.asyncIterator](): AsyncGenerator<\n\t\tGroupResponseItem,\n\t\tvoid,\n\t\tunknown\n\t> {\n\t\tlet hasMore = true;\n\t\tlet offset = 0;\n\n\t\twhile (hasMore) {\n\t\t\tawait this.rateLimit(); // applying rate limit\n\t\t\tthis.query.offset = offset;\n\n\t\t\tconst items = await listGroups(this.config, this.query);\n\n\t\t\tfor (const item of items) {\n\t\t\t\tyield item;\n\t\t\t}\n\n\t\t\tif (items.length === 0) {\n\t\t\t\thasMore = false;\n\t\t\t} else {\n\t\t\t\toffset += items.length;\n\t\t\t}\n\t\t}\n\t}\n\n\tasync all(): Promise<GroupResponseItem[]> {\n\t\tconst allItems: GroupResponseItem[] = [];\n\t\tfor await (const item of this) {\n\t\t\tallItems.push(item);\n\t\t}\n\t\treturn allItems;\n\t}\n}\n\nclass Signatures {\n\tconfig: PinataConfig | undefined;\n\n\tconstructor(config?: PinataConfig) {\n\t\tthis.config = formatConfig(config);\n\t}\n\n\tadd(options: SignatureOptions): Promise<SignatureResponse> {\n\t\treturn addSignature(this.config, options);\n\t}\n\n\tget(cid: string): Promise<SignatureResponse> {\n\t\treturn getSignature(this.config, cid);\n\t}\n\n\tdelete(cid: string): Promise<string> {\n\t\treturn removeSignature(this.config, cid);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,cAAN,cAA0B,MAAM;AAAA,EACtC,YACC,SACO,YACA,SACN;AACD,UAAM,OAAO;AAHN;AACA;AAGP,SAAK,OAAO;AAAA,EACb;AACD;AAEO,IAAM,eAAN,cAA2B,YAAY;AAAA,EAC7C,YAAY,SAAiB,YAAqB,SAAe;AAChE,UAAM,SAAS,YAAY,OAAO;AAClC,SAAK,OAAO;AAAA,EACb;AACD;AAEO,IAAM,sBAAN,cAAkC,YAAY;AAAA,EACpD,YAAY,SAAiB,YAAqB,SAAe;AAChE,UAAM,SAAS,YAAY,OAAO;AAClC,SAAK,OAAO;AAAA,EACb;AACD;AAEO,IAAM,kBAAN,cAA8B,YAAY;AAAA,EAChD,YAAY,SAAiB,SAAe;AAC3C,UAAM,SAAS,QAAW,OAAO;AACjC,SAAK,OAAO;AAAA,EACb;AACD;;;ACGO,IAAM,qBAAqB,OAAO,WAAqC;AAC7E,MAAI,CAAC,UAAU,C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AACA,SAAK,kBAAkB,KAAK,IAAI;AAAA,EACjC;AAAA,EAEA,QAAQ,OAAO,aAAa,IAI1B;AACD,QAAI,UAAU;AACd,QAAI,SAAS;AAEb,WAAO,SAAS;AACf,YAAM,KAAK,UAAU;AACrB,WAAK,MAAM,SAAS;AAEpB,YAAM,QAAQ,MAAM,WAAW,KAAK,QAAQ,KAAK,KAAK;AAEtD,iBAAW,QAAQ,OAAO;AACzB,cAAM;AAAA,MACP;AAEA,UAAI,MAAM,WAAW,GAAG;AACvB,kBAAU;AAAA,MACX,OAAO;AACN,kBAAU,MAAM;AAAA,MACjB;AAAA,IACD;AAAA,EACD;AAAA,EAEA,MAAM,MAAoC;AACzC,UAAM,WAAgC,CAAC;AACvC,qBAAiB,QAAQ,MAAM;AAC9B,eAAS,KAAK,IAAI;AAAA,IACnB;AACA,WAAO;AAAA,EACR;AACD;AAEA,IAAM,aAAN,MAAiB;AAAA,EAGhB,YAAY,QAAuB;AAClC,SAAK,SAAS,aAAa,MAAM;AAAA,EAClC;AAAA,EAEA,IAAI,SAAuD;AAC1D,WAAO,aAAa,KAAK,QAAQ,OAAO;AAAA,EACzC;AAAA,EAEA,IAAIA,MAAyC;AAC5C,WAAO,aAAa,KAAK,QAAQA,IAAG;AAAA,EACrC;AAAA,EAEA,OAAOA,MAA8B;AACpC,WAAO,gBAAgB,KAAK,QAAQA,IAAG;AAAA,EACxC;AACD;","names":["cid","cid","cid","cid","cid","wait","cid","cid","cid"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/utils/custom-errors.ts","../src/core/authentication/testAuthentication.ts","../src/core/pinning/file.ts","../src/core/pinning/fileArray.ts","../src/core/pinning/base64.ts","../src/core/pinning/url.ts","../src/core/pinning/json.ts","../src/core/pinning/cid.ts","../src/core/pinning/unpin.ts","../src/core/data/listFiles.ts","../src/core/data/updateMetadata.ts","../src/utils/gateway-tools.ts","../src/core/gateway/getCid.ts","../src/core/gateway/convertIPFSUrl.ts","../src/core/data/pinJobs.ts","../src/core/data/pinnedFileUsage.ts","../src/core/data/totalStorageUsage.ts","../src/core/keys/createKey.ts","../src/core/keys/listKeys.ts","../src/core/keys/revokeKeys.ts","../src/core/groups/createGroup.ts","../src/core/groups/listGroups.ts","../src/core/groups/getGroup.ts","../src/core/groups/addToGroup.ts","../src/core/groups/updateGroup.ts","../src/core/groups/removeFromGroup.ts","../src/core/groups/deleteGroup.ts","../src/core/signatures/addSignature.ts","../src/core/signatures/getSignature.ts","../src/core/signatures/removeSignature.ts","../src/core/pinataSDK.ts"],"sourcesContent":["export * from \"./core/pinataSDK\";\nexport * from \"./core/types\";\n","export class PinataError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic statusCode?: number,\n\t\tpublic details?: any,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"PinataError\";\n\t}\n}\n\nexport class NetworkError extends PinataError {\n\tconstructor(message: string, statusCode?: number, details?: any) {\n\t\tsuper(message, statusCode, details);\n\t\tthis.name = \"NetworkError\";\n\t}\n}\n\nexport class AuthenticationError extends PinataError {\n\tconstructor(message: string, statusCode?: number, details?: any) {\n\t\tsuper(message, statusCode, details);\n\t\tthis.name = \"AuthenticationError\";\n\t}\n}\n\nexport class ValidationError extends PinataError {\n\tconstructor(message: string, details?: any) {\n\t\tsuper(message, undefined, details);\n\t\tthis.name = \"ValidationError\";\n\t}\n}\n","/**\n * Tests the authentication of the current Pinata configuration.\n *\n * This function sends a request to the Pinata API to verify if the provided\n * authentication credentials (JWT) are valid and working correctly.\n *\n * @async\n * @function testAuthentication\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @returns {Promise<AuthTestResponse>} A promise that resolves to an object containing a message about the authentication status.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the authentication process.\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const auth = await pinata.testAuthentication()\n */\n\nimport type { PinataConfig, AuthTestResponse } from \"../types\";\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const testAuthentication = async (config: PinataConfig | undefined) => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst headers: Record<string, string> = {\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/testAuthentication\";\n\n\ttry {\n\t\tconst request = await fetch(\n\t\t\t\"https://api.pinata.cloud/data/testAuthentication\",\n\t\t\t{\n\t\t\t\tmethod: \"GET\",\n\t\t\t\theaders: headers,\n\t\t\t},\n\t\t);\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: AuthTestResponse = await request.json();\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(\n\t\t\t\t`Error processing authentication: ${error.message}`,\n\t\t\t);\n\t\t}\n\t\tthrow new PinataError(\n\t\t\t\"An unknown error occurred while testing authentication\",\n\t\t);\n\t}\n};\n","/**\n * Uploads a file to IPFS via Pinata.\n *\n * This function allows you to upload a single file to IPFS and pin it to Pinata.\n * It's useful for adding individual files to your Pinata account and IPFS network.\n *\n * @async\n * @function uploadFile\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {File} file - The file object to be uploaded.\n * @param {UploadOptions} [options] - Optional parameters for the upload.\n * @param {PinataMetadata} [options.metadata] - Metadata for the uploaded file.\n * @param {string} [options.metadata.name] - Custom name for the file (defaults to the original filename if not provided).\n * @param {Record<string, string | number>} [options.metadata.keyValues] - Custom key-value pairs for the file metadata.\n * @param {string} [options.keys] - Custom JWT to use for this specific upload.\n * @param {string} [options.groupId] - ID of the group to add the uploaded file to.\n * @param {0 | 1} [options.cidVersion] - Version of CID to use (0 or 1).\n * @returns {Promise<PinResponse>} A promise that resolves to an object containing the IPFS hash and other upload details.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the upload process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const file = new File([\"hello world!\"], \"hello.txt\", { type: \"text/plain\" })\n * const upload = await pinata.upload.file(file)\n */\n\nimport type { PinataConfig, PinResponse, UploadOptions } from \"../types\";\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const uploadFile = async (\n\tconfig: PinataConfig | undefined,\n\tfile: File,\n\toptions?: UploadOptions,\n) => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst jwt: string = options?.keys || config.pinataJwt;\n\n\tconst data = new FormData();\n\tdata.append(\"file\", file, file.name);\n\n\tdata.append(\n\t\t\"pinataOptions\",\n\t\tJSON.stringify({\n\t\t\tcidVersion: options?.cidVersion,\n\t\t\tgroupId: options?.groupId,\n\t\t}),\n\t);\n\n\tdata.append(\n\t\t\"pinataMetadata\",\n\t\tJSON.stringify({\n\t\t\tname: options?.metadata ? options.metadata.name : file.name,\n\t\t\tkeyvalues: options?.metadata?.keyValues,\n\t\t}),\n\t);\n\n\tconst headers: Record<string, string> = {\n\t\tAuthorization: `Bearer ${jwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/file\";\n\n\ttry {\n\t\tconst request = await fetch(\n\t\t\t\"https://api.pinata.cloud/pinning/pinFileToIPFS\",\n\t\t\t{\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: headers,\n\t\t\t\tbody: data,\n\t\t\t},\n\t\t);\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\t\tconst res: PinResponse = await request.json();\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error uploading file: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\"An unknown error occurred while uploading the file\");\n\t}\n};\n","/**\n * Uploads multiple files to IPFS via Pinata as a single directory.\n *\n * This function allows you to upload multiple files to IPFS and pin them to Pinata\n * as a single directory. It's useful for adding collections of related files or\n * entire directories to your Pinata account and IPFS network.\n *\n * @async\n * @function uploadFileArray\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {File[]} files - An array of File objects to be uploaded.\n * @param {UploadOptions} [options] - Optional parameters for the upload.\n * @param {PinataMetadata} [options.metadata] - Metadata for the uploaded directory.\n * @param {string} [options.metadata.name] - Name for the directory (defaults to \"folder_from_sdk\" if not provided).\n * @param {Record<string, string | number>} [options.metadata.keyValues] - Custom key-value pairs for the directory metadata.\n * @param {string} [options.keys] - Custom JWT to use for this specific upload.\n * @param {string} [options.groupId] - ID of the group to add the uploaded directory to.\n * @param {0 | 1} [options.cidVersion] - Version of CID to use (0 or 1).\n * @returns {Promise<PinResponse>} A promise that resolves to an object containing the IPFS hash and other upload details.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the upload process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const file1 = new File([\"hello world!\"], \"hello.txt\", { type: \"text/plain\" })\n * const file2 = new File([\"hello world again!\"], \"hello2.txt\", { type: \"text/plain\" })\n * const upload = await pinata.upload.fileArray([file1, file2])\n */\n\nimport type { PinataConfig, PinResponse, UploadOptions } from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const uploadFileArray = async (\n\tconfig: PinataConfig | undefined,\n\tfiles: File[],\n\toptions?: UploadOptions,\n) => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst jwt: string = options?.keys || config?.pinataJwt;\n\n\tconst folder = options?.metadata?.name ?? \"folder_from_sdk\";\n\tconst data = new FormData();\n\n\tfor (const file of Array.from(files)) {\n\t\tdata.append(\"file\", file, `${folder}/${file.name}`);\n\t}\n\n\tdata.append(\n\t\t\"pinataMetadata\",\n\t\tJSON.stringify({\n\t\t\tname: folder,\n\t\t\tkeyvalues: options?.metadata?.keyValues,\n\t\t}),\n\t);\n\n\tdata.append(\n\t\t\"pinataOptions\",\n\t\tJSON.stringify({\n\t\t\tcidVersion: options?.cidVersion,\n\t\t\tgroupId: options?.groupId,\n\t\t}),\n\t);\n\n\tconst headers: Record<string, string> = {\n\t\tAuthorization: `Bearer ${jwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/fileArray\";\n\n\ttry {\n\t\tconst request = await fetch(\n\t\t\t\"https://api.pinata.cloud/pinning/pinFileToIPFS\",\n\t\t\t{\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: headers,\n\t\t\t\tbody: data,\n\t\t\t},\n\t\t);\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: PinResponse = await request.json();\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing fileArray: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\n\t\t\t\"An unknown error occurred while uploading an array of files\",\n\t\t);\n\t}\n};\n","/**\n * Uploads a base64-encoded string to IPFS via Pinata.\n *\n * This function allows you to upload content to IPFS that is encoded as a base64 string.\n * It's particularly useful for uploading binary data or files that have been converted to base64.\n *\n * @async\n * @function uploadBase64\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {string} base64String - The base64-encoded string to be uploaded.\n * @param {UploadOptions} [options] - Optional parameters for the upload.\n * @param {PinataMetadata} [options.metadata] - Metadata for the uploaded file.\n * @param {string} [options.metadata.name] - Name for the uploaded file (default is \"base64 string\").\n * @param {Record<string, string | number>} [options.metadata.keyvalues] - Custom key-value pairs for the file metadata.\n * @param {string} [options.keys] - Custom JWT to use for this specific upload.\n * @param {string} [options.groupId] - ID of the group to add the uploaded file to.\n * @param {0 | 1} [options.cidVersion] - Version of CID to use (0 or 1).\n * @returns {Promise<PinResponse>} A promise that resolves to an object containing the IPFS hash and other upload details.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the upload process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const upload = await pinata.upload.base64(\"SGVsbG8gV29ybGQh\")\n */\n\nimport type { PinataConfig, PinResponse, UploadOptions } from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const uploadBase64 = async (\n\tconfig: PinataConfig | undefined,\n\tbase64String: string,\n\toptions?: UploadOptions,\n) => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst jwt: string = options?.keys || config?.pinataJwt;\n\n\tconst name = options?.metadata?.name\n\t\t? options?.metadata?.name\n\t\t: \"base64 string\";\n\n\tconst buffer = Buffer.from(base64String, \"base64\");\n\n\tconst blob = new Blob([buffer]);\n\n\tconst data = new FormData();\n\n\tdata.append(\"file\", blob, name);\n\n\tdata.append(\n\t\t\"pinataOptions\",\n\t\tJSON.stringify({\n\t\t\tcidVersion: options?.cidVersion,\n\t\t\tgroupId: options?.groupId,\n\t\t}),\n\t);\n\n\tdata.append(\n\t\t\"pinataMetadata\",\n\t\tJSON.stringify({\n\t\t\tname: name,\n\t\t\tkeyvalues: options?.metadata?.keyValues,\n\t\t}),\n\t);\n\n\tconst headers: Record<string, string> = {\n\t\tAuthorization: `Bearer ${jwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/base64\";\n\n\ttry {\n\t\tconst request = await fetch(\n\t\t\t\"https://api.pinata.cloud/pinning/pinFileToIPFS\",\n\t\t\t{\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: headers,\n\t\t\t\tbody: data,\n\t\t\t},\n\t\t);\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: PinResponse = await request.json();\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing base64: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\n\t\t\t\"An unknown error occurred while trying to upload base64\",\n\t\t);\n\t}\n};\n","/**\n * Uploads content from a URL to IPFS via Pinata.\n *\n * This function allows you to upload content from a specified URL to IPFS and pin it to Pinata.\n * It's useful for adding remote content to your Pinata account and IPFS network without\n * first downloading it locally.\n *\n * @async\n * @function uploadUrl\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {string} url - The URL of the content to be uploaded.\n * @param {UploadOptions} [options] - Optional parameters for the upload.\n * @param {PinataMetadata} [options.metadata] - Metadata for the uploaded content.\n * @param {string} [options.metadata.name] - Custom name for the content (defaults to \"url_upload\" if not provided).\n * @param {Record<string, string | number>} [options.metadata.keyValues] - Custom key-value pairs for the content metadata.\n * @param {string} [options.keys] - Custom JWT to use for this specific upload.\n * @param {string} [options.groupId] - ID of the group to add the uploaded content to.\n * @param {0 | 1} [options.cidVersion] - Version of CID to use (0 or 1).\n * @returns {Promise<PinResponse>} A promise that resolves to an object containing the IPFS hash and other upload details.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request or URL fetch.\n * @throws {PinataError} For any other errors that occur during the upload process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const upload = await pinata.upload.url(\"https://i.imgur.com/u4mGk5b.gif\")\n */\n\nimport type { PinataConfig, PinResponse, UploadOptions } from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const uploadUrl = async (\n\tconfig: PinataConfig | undefined,\n\turl: string,\n\toptions?: UploadOptions,\n) => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst jwt: string = options?.keys || config?.pinataJwt;\n\tconst data = new FormData();\n\n\tconst stream = await fetch(url);\n\n\tif (!stream.ok) {\n\t\tconst errorData = await stream.json();\n\t\tthrow new NetworkError(\n\t\t\t`HTTP error! status: ${stream.status}`,\n\t\t\tstream.status,\n\t\t\terrorData,\n\t\t);\n\t}\n\n\tconst arrayBuffer = await stream.arrayBuffer();\n\n\tconst blob = new Blob([arrayBuffer]);\n\n\tconst name = options?.metadata?.name ?? \"url_upload\";\n\n\tconst file = new File([blob], name);\n\n\tdata.append(\"file\", file, name);\n\n\tdata.append(\n\t\t\"pinataOptions\",\n\t\tJSON.stringify({\n\t\t\tcidVersion: options?.cidVersion,\n\t\t\tgroupId: options?.groupId,\n\t\t}),\n\t);\n\n\tdata.append(\n\t\t\"pinataMetadata\",\n\t\tJSON.stringify({\n\t\t\tname: name,\n\t\t\tkeyvalues: options?.metadata?.keyValues,\n\t\t}),\n\t);\n\n\tconst headers: Record<string, string> = {\n\t\tAuthorization: `Bearer ${jwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/url\";\n\n\ttry {\n\t\tconst request = await fetch(\n\t\t\t\"https://api.pinata.cloud/pinning/pinFileToIPFS\",\n\t\t\t{\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: headers,\n\t\t\t\tbody: data,\n\t\t\t},\n\t\t);\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: PinResponse = await request.json();\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing url: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\"An unknown error occurred while uploading by url\");\n\t}\n};\n","/**\n * Uploads JSON data to IPFS via Pinata.\n *\n * This function allows you to upload JSON data directly to IPFS and pin it to Pinata.\n * It's useful for adding structured data, configurations, or any JSON-serializable content\n * to your Pinata account and IPFS network.\n *\n * @async\n * @function uploadJson\n * @template T\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {T} jsonData - The JSON data to be uploaded. Must be a valid JavaScript object that can be JSON-stringified.\n * @param {UploadOptions} [options] - Optional parameters for the upload.\n * @param {PinataMetadata} [options.metadata] - Metadata for the uploaded JSON.\n * @param {string} [options.metadata.name] - Custom name for the JSON content (defaults to \"json\" if not provided).\n * @param {Record<string, string | number>} [options.metadata.keyValues] - Custom key-value pairs for the JSON metadata.\n * @param {string} [options.keys] - Custom JWT to use for this specific upload.\n * @param {string} [options.groupId] - ID of the group to add the uploaded JSON to.\n * @param {0 | 1} [options.cidVersion] - Version of CID to use (0 or 1).\n * @returns {Promise<PinResponse>} A promise that resolves to an object containing the IPFS hash and other upload details.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the upload process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const upload = await pinata.upload.json({\n * name: \"Pinnie NFT\",\n * description: \"A Pinnie NFT from Pinata\",\n * image: \"ipfs://bafkreih5aznjvttude6c3wbvqeebb6rlx5wkbzyppv7garjiubll2ceym4\"\n * })\n */\n\nimport type {\n\tPinataConfig,\n\tPinResponse,\n\tUploadOptions,\n\tJsonBody,\n} from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const uploadJson = async <T extends JsonBody>(\n\tconfig: PinataConfig | undefined,\n\tjsonData: T,\n\toptions?: UploadOptions,\n) => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst jwt: string = options?.keys || config?.pinataJwt;\n\n\tconst data = JSON.stringify({\n\t\tpinataContent: jsonData,\n\t\tpinataOptions: {\n\t\t\tcidVersion: options?.cidVersion,\n\t\t\tgroupId: options?.groupId,\n\t\t},\n\t\tpinataMetadata: {\n\t\t\tname: options?.metadata ? options.metadata.name : \"json\",\n\t\t\tkeyvalues: options?.metadata?.keyValues,\n\t\t},\n\t});\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${jwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/json\";\n\n\ttry {\n\t\tconst request = await fetch(\n\t\t\t\"https://api.pinata.cloud/pinning/pinJSONToIPFS\",\n\t\t\t{\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: headers,\n\t\t\t\tbody: data,\n\t\t\t},\n\t\t);\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: PinResponse = await request.json();\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing json: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\"An unknown error occurred while uploading json\");\n\t}\n};\n","/**\n * Pins an existing file on IPFS to Pinata using its Content Identifier (CID).\n *\n * This function allows you to add an existing IPFS file to your Pinata account\n * by providing its CID. It's useful for ensuring long-term storage and\n * availability of content that's already on IPFS.\n *\n * @async\n * @function uploadCid\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {string} cid - The Content Identifier (CID) of the IPFS file to pin.\n * @param {UploadCIDOptions} [options] - Optional parameters for the upload.\n * @param {PinataMetadata} [options.metadata] - Metadata for the pinned file.\n * @param {string} [options.metadata.name] - Name for the pinned file (defaults to the CID if not provided).\n * @param {Record<string, string | number>} [options.metadata.keyValues] - Custom key-value pairs for the file metadata.\n * @param {string[]} [options.peerAddresses] - Array of peer addresses to contact for pinning.\n * @param {string} [options.keys] - Custom JWT to use for this specific upload.\n * @param {string} [options.groupId] - ID of the group to add the pinned file to.\n * @returns {Promise<PinByCIDResponse>} A promise that resolves to an object containing details about the pinning job.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the pinning process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const pin = await pinata.upload.cid(\"QmVLwvmGehsrNEvhcCnnsw5RQNseohgEkFNN1848zNzdng\")\n */\n\nimport type {\n\tPinataConfig,\n\tPinByCIDResponse,\n\tUploadCIDOptions,\n} from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const uploadCid = async (\n\tconfig: PinataConfig | undefined,\n\tcid: string,\n\toptions?: UploadCIDOptions,\n) => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst jwt: string = options?.keys || config?.pinataJwt;\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${jwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/cid\";\n\n\tconst data = JSON.stringify({\n\t\thashToPin: cid,\n\t\tpinataMetadata: {\n\t\t\tname: options?.metadata ? options?.metadata?.name : cid,\n\t\t\tkeyvalues: options?.metadata?.keyValues,\n\t\t},\n\t\tpinataOptions: {\n\t\t\thostNodes: options?.peerAddresses ? options.peerAddresses : \"\",\n\t\t\tgroupId: options?.groupId,\n\t\t},\n\t});\n\n\ttry {\n\t\tconst request = await fetch(\"https://api.pinata.cloud/pinning/pinByHash\", {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: headers,\n\t\t\tbody: data,\n\t\t});\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: PinByCIDResponse = await request.json();\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing cid: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\"An unknown error occurred while pinning by CID\");\n\t}\n};\n","/**\n * Unpins multiple files from Pinata and IPFS.\n *\n * This function allows you to remove pins for multiple files from your Pinata account.\n * Unpinning a file means that Pinata will no longer guarantee its availability on IPFS,\n * although the content may still be available if pinned by other IPFS nodes.\n *\n * @async\n * @function unpinFile\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {string[]} files - An array of IPFS hashes (CIDs) of the files to unpin.\n * @returns {Promise<UnpinResponse[]>} A promise that resolves to an array of objects, each containing the status of the unpin operation for each file.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the unpinning process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const unpin = await pinata.unpin([\n * \"bafkreih5aznjvttude6c3wbvqeebb6rlx5wkbzyppv7garjiubll2ceym4\"\n * ])\n */\n\nimport type { PinataConfig, UnpinResponse } from \"../types\";\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nconst wait = (milliseconds: number): Promise<void> => {\n\treturn new Promise((resolve) => {\n\t\tsetTimeout(resolve, milliseconds);\n\t});\n};\n\nexport const unpinFile = async (\n\tconfig: PinataConfig | undefined,\n\tfiles: string[],\n): Promise<UnpinResponse[]> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst responses: UnpinResponse[] = [];\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/unpin\";\n\n\tfor (const hash of files) {\n\t\ttry {\n\t\t\tconst response = await fetch(\n\t\t\t\t`https://api.pinata.cloud/pinning/unpin/${hash}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: \"DELETE\",\n\t\t\t\t\theaders: headers,\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tawait wait(300);\n\n\t\t\tif (!response.ok) {\n\t\t\t\tconst errorData = await response.json();\n\t\t\t\tif (response.status === 401) {\n\t\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\t\tresponse.status,\n\t\t\t\t\t\terrorData,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tthrow new NetworkError(\n\t\t\t\t\t`HTTP error! status: ${response.status}`,\n\t\t\t\t\tresponse.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst result = await response.text();\n\t\t\tresponses.push({\n\t\t\t\thash: hash,\n\t\t\t\tstatus: result,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tlet errorMessage: string;\n\n\t\t\tif (error instanceof PinataError) {\n\t\t\t\terrorMessage = error.message;\n\t\t\t} else if (error instanceof Error) {\n\t\t\t\terrorMessage = `Error unpinning file ${hash}: ${error.message}`;\n\t\t\t} else {\n\t\t\t\terrorMessage = `An unknown error occurred while unpinning file ${hash}`;\n\t\t\t}\n\n\t\t\tresponses.push({\n\t\t\t\thash: hash,\n\t\t\t\tstatus: errorMessage,\n\t\t\t});\n\t\t}\n\t}\n\treturn responses;\n};\n","/**\n * Lists files pinned to Pinata based on the provided configuration and options.\n *\n * This function fetches a list of pinned files from the Pinata API, allowing for\n * various filtering and pagination options.\n *\n * @async\n * @function listFiles\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {PinListQuery} [options] - Optional query parameters to filter and paginate the results.\n * @param {string} [options.cid] - Filter by the CID of the file.\n * @param {string} [options.pinStart] - Filter by the start date of pinning (ISO 8601 format).\n * @param {string} [options.pinEnd] - Filter by the end date of pinning (ISO 8601 format).\n * @param {number} [options.pinSizeMin] - Filter by minimum pin size in bytes.\n * @param {number} [options.pinSizeMax] - Filter by maximum pin size in bytes.\n * @param {number} [options.pageLimit] - Number of items to return per page.\n * @param {number} [options.pageOffset] - Number of items to skip (for pagination).\n * @param {string} [options.name] - Filter by the name of the file.\n * @param {string} [options.key] - Metadata key to filter by (used with value and operator).\n * @param {string | number} [options.value] - Metadata value to filter by (used with key and operator).\n * @param {string} [options.operator] - Comparison operator for metadata filtering.\n * @param {string} [options.groupId] - Filter by group ID.\n * @returns {Promise<PinListItem[]>} A promise that resolves to an array of PinListItem objects.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the file listing process.\n *//**\n * Lists files pinned to Pinata based on the provided configuration and options.\n *\n * This function fetches a list of pinned files from the Pinata API, allowing for\n * various filtering and pagination options.\n *\n * @async\n * @function listFiles\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {PinListQuery} [options] - Optional query parameters to filter and paginate the results.\n * @param {string} [options.cid] - Filter by the CID of the file.\n * @param {string} [options.pinStart] - Filter by the start date of pinning (ISO 8601 format).\n * @param {string} [options.pinEnd] - Filter by the end date of pinning (ISO 8601 format).\n * @param {number} [options.pinSizeMin] - Filter by minimum pin size in bytes.\n * @param {number} [options.pinSizeMax] - Filter by maximum pin size in bytes.\n * @param {number} [options.pageLimit] - Number of items to return per page.\n * @param {number} [options.pageOffset] - Number of items to skip (for pagination).\n * @param {string} [options.name] - Filter by the name of the file.\n * @param {string} [options.key] - Metadata key to filter by (used with value and operator).\n * @param {string | number} [options.value] - Metadata value to filter by (used with key and operator).\n * @param {string} [options.operator] - Comparison operator for metadata filtering.\n * @param {string} [options.groupId] - Filter by group ID.\n * @returns {Promise<PinListItem[]>} A promise that resolves to an array of PinListItem objects.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the file listing process.\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const files = await pinata.listFiles().name(\"pinnie\")\n */\n\nimport type {\n\tPinListItem,\n\tPinListQuery,\n\tPinListResponse,\n\tPinataConfig,\n} from \"../types\";\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const listFiles = async (\n\tconfig: PinataConfig | undefined,\n\toptions?: PinListQuery,\n): Promise<PinListItem[]> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst params = new URLSearchParams({\n\t\tincludesCount: \"false\",\n\t});\n\n\tif (options) {\n\t\tconst {\n\t\t\tcid,\n\t\t\tpinStart,\n\t\t\tpinEnd,\n\t\t\tpinSizeMin,\n\t\t\tpinSizeMax,\n\t\t\tpageLimit,\n\t\t\tpageOffset,\n\t\t\tname,\n\t\t\tkey,\n\t\t\tvalue,\n\t\t\toperator,\n\t\t\tgroupId,\n\t\t} = options;\n\n\t\tif (cid) params.append(\"cid\", cid);\n\t\tif (pinStart) params.append(\"pinStart\", pinStart);\n\t\tif (pinEnd) params.append(\"pinEnd\", pinEnd);\n\t\tif (pinSizeMin) params.append(\"pinSizeMin\", pinSizeMin.toString());\n\t\tif (pinSizeMax) params.append(\"pinSizeMax\", pinSizeMax.toString());\n\t\tif (pageLimit) params.append(\"pageLimit\", pageLimit.toString());\n\t\tif (pageOffset) params.append(\"pageOffset\", pageOffset.toString());\n\t\tif (groupId) params.append(\"groupId\", groupId);\n\t\tif (name) params.append(\"metadata[name]\", name);\n\t\tif (key && value) {\n\t\t\tconst keyValueParam = JSON.stringify({\n\t\t\t\t[key]: { value, op: operator || \"eq\" },\n\t\t\t});\n\t\t\tparams.append(\"metadata[keyvalues]\", keyValueParam);\n\t\t}\n\t}\n\n\tconst url = `https://api.pinata.cloud/data/pinList?status=pinned&${params.toString()}`;\n\n\ttry {\n\t\tconst headers: Record<string, string> = {\n\t\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t\t};\n\n\t\tif (config.customHeaders) {\n\t\t\tObject.assign(headers, config.customHeaders);\n\t\t}\n\n\t\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\t\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/listFiles\";\n\n\t\tconst request = await fetch(url, {\n\t\t\tmethod: \"GET\",\n\t\t\theaders: headers,\n\t\t});\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: PinListResponse = await request.json();\n\t\treturn res.rows;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing list files: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\"An unknown error occurred while listing files\");\n\t}\n};\n","/**\n * Updates the metadata for a pinned file on Pinata.\n *\n * This function allows you to modify the name and/or key-value pairs associated\n * with a file that has already been pinned to Pinata. This is useful for\n * organizing and categorizing your pinned content.\n *\n * @async\n * @function updateMetadata\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {PinataMetadataUpdate} options - The options for updating the metadata.\n * @param {string} options.cid - The Content Identifier (CID) of the pinned file to update.\n * @param {string} [options.name] - The new name to assign to the pinned file (optional).\n * @param {Record<string, string | number>} [options.keyValues] - Key-value pairs to associate with the pinned file (optional).\n * @returns {Promise<string>} A promise that resolves to a string confirming the update.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the metadata update process.\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const update = await pinata.updateMedatadata({\n * cid: \"bafkreih5aznjvttude6c3wbvqeebb6rlx5wkbzyppv7garjiubll2ceym4\",\n * name: \"Pinnie V2\",\n * keyValues: {\n * whimsey: 200\n * }\n * })\n */\n\nimport type { PinataConfig, PinataMetadataUpdate } from \"../types\";\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const updateMetadata = async (\n\tconfig: PinataConfig | undefined,\n\toptions: PinataMetadataUpdate,\n): Promise<string> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\tconst data = {\n\t\tipfsPinHash: options.cid,\n\t\tname: options.name,\n\t\tkeyvalues: options.keyValues,\n\t};\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/updateMetadata\";\n\n\ttry {\n\t\tconst request = await fetch(\n\t\t\t\"https://api.pinata.cloud/pinning/hashMetadata\",\n\t\t\t{\n\t\t\t\tmethod: \"PUT\",\n\t\t\t\theaders: headers,\n\t\t\t\tbody: JSON.stringify(data),\n\t\t\t},\n\t\t);\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: string = await request.text();\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(\n\t\t\t\t`Error processing updateMetadata: ${error.message}`,\n\t\t\t);\n\t\t}\n\t\tthrow new PinataError(\"An unknown error occurred while updating metadata\");\n\t}\n};\n","import type * as IsIPFS from \"is-ipfs\";\n\nlet isIPFSModule: typeof IsIPFS;\n\nasync function getIsIPFS() {\n\tif (!isIPFSModule) {\n\t\tisIPFSModule = await import(\"is-ipfs\");\n\t}\n\treturn isIPFSModule;\n}\n\nasync function containsCID(input: string) {\n\tif (typeof input !== \"string\") {\n\t\tthrow new Error(\"Input is not a string\");\n\t}\n\n\tconst isIPFS = await getIsIPFS();\n\n\t// Helper function to check if a string starts with a CID\n\tconst startsWithCID = (str: string) => {\n\t\tconst parts = str.split(\"/\");\n\t\treturn isIPFS.cid(parts[0]) ? parts[0] : null;\n\t};\n\n\t// Check if the input itself is a CID or starts with a CID\n\tconst directCID = startsWithCID(input);\n\tif (directCID) {\n\t\treturn {\n\t\t\tcontainsCid: true,\n\t\t\tcid: directCID,\n\t\t};\n\t}\n\n\tlet url: URL;\n\ttry {\n\t\t// Try to parse the input as a URL\n\t\turl = new URL(input);\n\t} catch (error) {\n\t\t// If parsing fails, treat the input as a potential path-like string\n\t\tconst parts = input.split(/\\/|\\?/);\n\t\tfor (const part of parts) {\n\t\t\tconst cid = startsWithCID(part);\n\t\t\tif (cid) {\n\t\t\t\treturn {\n\t\t\t\t\tcontainsCid: true,\n\t\t\t\t\tcid: cid,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\tcontainsCid: false,\n\t\t\tcid: null,\n\t\t};\n\t}\n\n\t// Check for CID in subdomain\n\tconst subdomains = url.hostname.split(\".\");\n\tfor (const subdomain of subdomains) {\n\t\tif (isIPFS.cid(subdomain)) {\n\t\t\treturn {\n\t\t\t\tcontainsCid: true,\n\t\t\t\tcid: subdomain,\n\t\t\t};\n\t\t}\n\t}\n\n\t// Check for CID in path\n\tconst pathParts = url.pathname.split(\"/\");\n\tfor (const part of pathParts) {\n\t\tconst cid = startsWithCID(part);\n\t\tif (cid) {\n\t\t\treturn {\n\t\t\t\tcontainsCid: true,\n\t\t\t\tcid: cid,\n\t\t\t};\n\t\t}\n\t}\n\n\treturn {\n\t\tcontainsCid: false,\n\t\tcid: null,\n\t};\n}\n\nexport async function convertToDesiredGateway(\n\tsourceUrl: string,\n\tdesiredGatewayPrefix: string | undefined,\n) {\n\tconst results = await containsCID(sourceUrl);\n\n\tif (results.containsCid !== true) {\n\t\tthrow new Error(\"url does not contain CID\");\n\t}\n\n\tif (!sourceUrl.startsWith(\"https\") && !sourceUrl.startsWith(\"ipfs://\")) {\n\t\treturn `${desiredGatewayPrefix}/ipfs/${sourceUrl}`;\n\t}\n\n\tconst urlObj = new URL(sourceUrl);\n\tconst path = urlObj.pathname + urlObj.search + urlObj.hash;\n\n\t//case 1 - the ipfs://cid path\n\tif (sourceUrl.startsWith(`ipfs://${results.cid}`)) {\n\t\treturn `${desiredGatewayPrefix}/ipfs/${results.cid}${path}`;\n\t}\n\n\t//case 2 - the /ipfs/cid path (this should cover ipfs://ipfs/cid as well)\n\tif (sourceUrl.includes(`/ipfs/${results.cid}`)) {\n\t\treturn `${desiredGatewayPrefix}${path}`;\n\t}\n\n\t//case 3 - the /ipns/cid path\n\tif (sourceUrl.includes(`/ipns/${results.cid}`)) {\n\t\treturn `${desiredGatewayPrefix}${path}`;\n\t}\n\n\t//case 4 - the CID is in the subdomain\n\tif (urlObj.hostname.includes(results.cid!)) {\n\t\treturn `${desiredGatewayPrefix}/ipfs/${results.cid}${path}`;\n\t}\n\n\t//this is the fallback if no supported patterns are provided\n\tthrow new Error(\n\t\t\"unsupported URL pattern, please submit a github issue with the URL utilized\",\n\t);\n}\n","/**\n * Retrieves the content of a file from IPFS using its Content Identifier (CID).\n *\n * This function fetches the content associated with a given CID from the specified\n * Pinata gateway. It can handle various content types and returns the data along\n * with the content type information.\n *\n * @async\n * @function getCid\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT and gateway information.\n * @param {string} cid - The Content Identifier (CID) of the file to retrieve.\n * @returns {Promise<GetCIDResponse>} A promise that resolves to an object containing the file data and content type.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the retrieval process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const upload = await pinata.gateways.get(\"QmVLwvmGehsrNEvhcCnnsw5RQNseohgEkFNN1848zNzdng\"* )\n *\n */\n\nimport { convertToDesiredGateway } from \"../../utils/gateway-tools\";\nimport type { GetCIDResponse, PinataConfig } from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const getCid = async (\n\tconfig: PinataConfig | undefined,\n\tcid: string,\n): Promise<GetCIDResponse> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tlet data: JSON | string | Blob;\n\tlet newUrl: string;\n\n\tnewUrl = await convertToDesiredGateway(cid, config?.pinataGateway);\n\n\tif (config?.pinataGatewayKey) {\n\t\tnewUrl = `${newUrl}?pinataGatewayToken=${config?.pinataGatewayKey}`;\n\t}\n\n\ttry {\n\t\tconst request = await fetch(newUrl, {\n\t\t\tmethod: \"GET\",\n\t\t\theaders: {\n\t\t\t\tSource: \"sdk/getCid\",\n\t\t\t},\n\t\t});\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst contentType: string | null = request.headers.get(\"content-type\");\n\n\t\tif (contentType?.includes(\"application/json\")) {\n\t\t\tdata = await request.json();\n\t\t} else if (contentType?.includes(\"text/\")) {\n\t\t\tdata = await request.text();\n\t\t} else {\n\t\t\tdata = await request.blob();\n\t\t}\n\n\t\tconst res: GetCIDResponse = {\n\t\t\tdata: data,\n\t\t\tcontentType: contentType,\n\t\t};\n\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing getCid: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\n\t\t\t\"An unknown error occurred while getting CID contents\",\n\t\t);\n\t}\n};\n","/**\n * Converts an IPFS URL to a desired gateway URL.\n *\n * This function takes an IPFS URL and converts it to use a specified gateway.\n * If a Pinata Gateway Key is provided in the configuration, it will be appended\n * to the URL as a query parameter.\n *\n * @function convertIPFSUrl\n * @param {PinataConfig | undefined} config - The Pinata configuration object.\n * @param {string} config.pinataGateway - The desired gateway URL to use.\n * @param {string} [config.pinataGatewayKey] - Optional Pinata Gateway Key for authenticated access.\n * @param {string} url - The original IPFS URL to convert.\n * @returns {Promise<string>} The converted URL using the specified gateway.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const url = await pinata.gateways.convert(\n * \"ipfs://QmVLwvmGehsrNEvhcCnnsw5RQNseohgEkFNN1848zNzdng\"\n * );\n */\n\nimport { convertToDesiredGateway } from \"../../utils/gateway-tools\";\nimport type { PinataConfig } from \"../types\";\n\nexport const convertIPFSUrl = async (\n\tconfig: PinataConfig | undefined,\n\turl: string,\n): Promise<string> => {\n\tlet newUrl: string;\n\tnewUrl = await convertToDesiredGateway(url, config?.pinataGateway);\n\tif (config?.pinataGatewayKey) {\n\t\t`${newUrl}?pinataGatewayToken=${config?.pinataGatewayKey}`;\n\t}\n\treturn newUrl;\n};\n","/**\n * Retrieves information about pin jobs from the Pinata API.\n *\n * This function fetches a list of pin jobs based on the provided configuration and options.\n * Pin jobs represent the status of pinning operations in progress or completed.\n *\n * @async\n * @function pinJobs\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {PinJobQuery} [options] - Optional query parameters to filter and paginate the results.\n * @param {string} [options.ipfs_pin_hash] - Filter by the IPFS hash (CID) of the content being pinned.\n * @param {('prechecking'|'retrieving'|'expired'|'over_free_limit'|'over_max_size'|'invalid_object'|'bad_host_node')} [options.status] - Filter by the status of the pin job.\n * @param {('ASC'|'DSC')} [options.sort] - Sort order for the results (ascending or descending).\n * @param {number} [options.limit] - Number of items to return per page.\n * @param {number} [options.offset] - Number of items to skip (for pagination).\n * @returns {Promise<PinJobItem[]>} A promise that resolves to an array of PinJobItem objects.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the pin jobs retrieval process.\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n * const jobs = await pinata.pinJobs().status(\"prechecking\")\n */\n\nimport type {\n\tPinJobItem,\n\tPinJobQuery,\n\tPinJobResponse,\n\tPinataConfig,\n} from \"../types\";\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const pinJobs = async (\n\tconfig: PinataConfig | undefined,\n\toptions?: PinJobQuery,\n): Promise<PinJobItem[]> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst params = new URLSearchParams({\n\t\tincludesCount: \"false\",\n\t});\n\n\tif (options) {\n\t\tconst { ipfs_pin_hash: cid, status, sort, limit, offset } = options;\n\n\t\tif (cid) params.append(\"ipfs_pin_hash\", cid.toString());\n\t\tif (status) params.append(\"status\", status.toString());\n\t\tif (sort) params.append(\"sort\", sort.toString());\n\t\tif (limit) params.append(\"limit\", limit.toString());\n\t\tif (offset) params.append(\"offset\", offset.toString());\n\t}\n\n\tconst url = `https://api.pinata.cloud/pinning/pinJobs?${params.toString()}`;\n\n\tconst headers: Record<string, string> = {\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/pinJobs\";\n\n\ttry {\n\t\tconst request = await fetch(url, {\n\t\t\tmethod: \"GET\",\n\t\t\theaders: headers,\n\t\t});\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\t\tconst res: PinJobResponse = await request.json();\n\t\treturn res.rows;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing pinJobs: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\"An unknown error occurred while listing pin jobs\");\n\t}\n};\n","/**\n * Retrieves the total count of files pinned to Pinata for the authenticated user.\n *\n * This function makes a request to the Pinata API to fetch the total number of files\n * that the user has pinned to their account. This can be useful for monitoring\n * account usage and managing pinned content.\n *\n * @async\n * @function pinnedFileCount\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @returns {Promise<number>} A promise that resolves to the total number of pinned files.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the retrieval process.\n *\n * @example\n * const config = { pinataJwt: 'your-jwt-token' };\n * try {\n * const count = await pinnedFileCount(config);\n * console.log(`Total pinned files: ${count}`);\n * } catch (error) {\n * console.error('Error getting pinned file count:', error);\n * }\n */\n\nimport type { PinataConfig, UserPinnedDataResponse } from \"../types\";\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const pinnedFileCount = async (\n\tconfig: PinataConfig | undefined,\n): Promise<number> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst url = \"https://api.pinata.cloud/data/userPinnedDataTotal\";\n\n\tconst headers: Record<string, string> = {\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/pinnedFileUsage\";\n\n\ttry {\n\t\tconst request = await fetch(url, {\n\t\t\tmethod: \"GET\",\n\t\t\theaders: headers,\n\t\t});\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\t\tconst res: UserPinnedDataResponse = await request.json();\n\t\treturn res.pin_count;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(\n\t\t\t\t`Error processing pinnedFileUsage: ${error.message}`,\n\t\t\t);\n\t\t}\n\t\tthrow new PinataError(\n\t\t\t\"An unknown error occurred while getting pinned file usage\",\n\t\t);\n\t}\n};\n","/**\n * Retrieves the total storage usage in bytes for all files pinned to Pinata by the authenticated user.\n *\n * This function makes a request to the Pinata API to fetch the total storage size\n * of all files that the user has pinned to their account. This can be useful for\n * monitoring account usage, managing storage limits, and planning for capacity.\n *\n * @async\n * @function totalStorageUsage\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @returns {Promise<number>} A promise that resolves to the total storage usage in bytes.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the retrieval process.\n *\n * @example\n * const config = { pinataJwt: 'your-jwt-token' };\n * try {\n * const totalBytes = await totalStorageUsage(config);\n * console.log(`Total storage usage: ${totalBytes} bytes`);\n * console.log(`Total storage usage: ${totalBytes / (1024 * 1024)} MB`);\n * } catch (error) {\n * console.error('Error getting total storage usage:', error);\n * }\n */\n\nimport type { PinataConfig, UserPinnedDataResponse } from \"../types\";\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const totalStorageUsage = async (\n\tconfig: PinataConfig | undefined,\n): Promise<number> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst url = \"https://api.pinata.cloud/data/userPinnedDataTotal\";\n\n\tconst headers: Record<string, string> = {\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/totalStorageUsage\";\n\n\ttry {\n\t\tconst request = await fetch(url, {\n\t\t\tmethod: \"GET\",\n\t\t\theaders: headers,\n\t\t});\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\t\tconst res: UserPinnedDataResponse = await request.json();\n\t\treturn res.pin_size_total;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(\n\t\t\t\t`Error processing totalStorageUsage: ${error.message}`,\n\t\t\t);\n\t\t}\n\t\tthrow new PinataError(\n\t\t\t\"An unknown error occurred while getting total storage usage\",\n\t\t);\n\t}\n};\n","/**\n * Creates a new API key for Pinata services.\n *\n * This function allows you to generate a new API key with specific permissions\n * for use with Pinata's IPFS pinning services. It's useful for creating keys\n * with limited access or for specific applications.\n *\n * @async\n * @function createKey\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {KeyOptions} options - The options for creating a new API key.\n * @param {string} options.keyName - The name to assign to the new API key.\n * @param {KeyPermissions} options.permissions - The permissions to assign to the new key.\n * @param {number} [options.maxUses] - Optional. The maximum number of times the key can be used.\n * @returns {Promise<KeyResponse>} A promise that resolves to an object containing the new API key details.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the key creation process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const key = await pinata.keys.create({\n * keyName: \"user 1\",\n * permissions: {\n * admin: true,\n * },\n * maxUses: 1,\n * });\n */\n\nimport type { PinataConfig, KeyOptions, KeyResponse } from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const createKey = async (\n\tconfig: PinataConfig | undefined,\n\toptions: KeyOptions,\n): Promise<KeyResponse> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/createKey\";\n\n\tconst data = JSON.stringify(options);\n\n\ttry {\n\t\tconst request = await fetch(\"https://api.pinata.cloud/v3/pinata/keys\", {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: headers,\n\t\t\tbody: data,\n\t\t});\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: KeyResponse = await request.json();\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing createKey: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\"An unknown error occurred while creating API key\");\n\t}\n};\n","/**\n * Retrieves a list of API keys associated with the Pinata account.\n *\n * This function allows you to fetch and optionally filter the API keys linked to your Pinata account.\n * It's useful for managing your API keys, checking their status, or auditing key usage.\n *\n * @async\n * @function listKeys\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {KeyListQuery} [options] - Optional query parameters to filter the list of keys.\n * @param {number} [options.offset] - The number of items to skip before starting to collect the result set.\n * @param {boolean} [options.revoked] - If true, includes revoked keys in the results.\n * @param {boolean} [options.limitedUse] - If true, only returns keys with usage limits.\n * @param {boolean} [options.exhausted] - If true, only returns keys that have reached their usage limit.\n * @param {string} [options.name] - Filters keys by name (partial match).\n * @returns {Promise<KeyListItem[]>} A promise that resolves to an array of key objects matching the query.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the key listing process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const keys = await pinata.keys\n * .list()\n * .name(\"Admin\")\n * .revoked(false)\n */\n\nimport type {\n\tKeyListItem,\n\tKeyListQuery,\n\tKeyListResponse,\n\tPinataConfig,\n} from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const listKeys = async (\n\tconfig: PinataConfig | undefined,\n\toptions?: KeyListQuery,\n): Promise<KeyListItem[]> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/listKeys\";\n\n\tconst params = new URLSearchParams();\n\n\tif (options) {\n\t\tconst { offset, name, revoked, limitedUse, exhausted } = options;\n\n\t\tif (offset) params.append(\"offset\", offset.toString());\n\t\tif (revoked !== undefined) params.append(\"revoked\", revoked.toString());\n\t\tif (limitedUse !== undefined)\n\t\t\tparams.append(\"limitedUse\", limitedUse.toString());\n\t\tif (exhausted !== undefined)\n\t\t\tparams.append(\"exhausted\", exhausted.toString());\n\t\tif (name) params.append(\"name\", name);\n\t}\n\n\tconst url = `https://api.pinata.cloud/v3/pinata/keys?${params.toString()}`;\n\n\ttry {\n\t\tconst request = await fetch(url, {\n\t\t\tmethod: \"GET\",\n\t\t\theaders: headers,\n\t\t});\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: KeyListResponse = await request.json();\n\t\treturn res.keys;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing listKeys: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\"An unknown error occurred while listing API keys\");\n\t}\n};\n","/**\n * Revokes multiple API keys from the Pinata account.\n *\n * This function allows you to revoke (invalidate) multiple API keys at once.\n * It's useful for security purposes, such as when keys may have been compromised\n * or are no longer needed.\n *\n * @async\n * @function revokeKeys\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {string[]} keys - An array of API key strings to be revoked.\n * @returns {Promise<RevokeKeyResponse[]>} A promise that resolves to an array of objects,\n * each containing the status of the revocation attempt for each key.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the key revocation process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const revoke = await pinata.keys.revoke([\n * \"94566af5e63833e260be\"\n * ]);\n */\n\nimport type { PinataConfig, RevokeKeyResponse } from \"../types\";\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nconst wait = (milliseconds: number): Promise<void> => {\n\treturn new Promise((resolve) => {\n\t\tsetTimeout(resolve, milliseconds);\n\t});\n};\n\nexport const revokeKeys = async (\n\tconfig: PinataConfig | undefined,\n\tkeys: string[],\n): Promise<RevokeKeyResponse[]> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/revokeKeys\";\n\n\tconst responses: RevokeKeyResponse[] = [];\n\n\tfor (const key of keys) {\n\t\ttry {\n\t\t\tconst request = await fetch(\n\t\t\t\t`https://api.pinata.cloud/v3/pinata/keys/${key}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: \"PUT\",\n\t\t\t\t\theaders: headers,\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tawait wait(300);\n\n\t\t\tif (!request.ok) {\n\t\t\t\tconst errorData = await request.json();\n\t\t\t\tif (request.status === 401) {\n\t\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\t\trequest.status,\n\t\t\t\t\t\terrorData,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tthrow new NetworkError(\n\t\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst result: string = await request.json();\n\t\t\tresponses.push({\n\t\t\t\tkey: key,\n\t\t\t\tstatus: result,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tlet errorMessage: string;\n\n\t\t\tif (error instanceof PinataError) {\n\t\t\t\terrorMessage = error.message;\n\t\t\t} else if (error instanceof Error) {\n\t\t\t\terrorMessage = `Error revoking key ${key}: ${error.message}`;\n\t\t\t} else {\n\t\t\t\terrorMessage = `An unknown error occurred while revoking key ${key}`;\n\t\t\t}\n\n\t\t\tresponses.push({\n\t\t\t\tkey: key,\n\t\t\t\tstatus: errorMessage,\n\t\t\t});\n\t\t}\n\t}\n\n\treturn responses;\n};\n","/**\n * Creates a new group in Pinata for organizing pinned content.\n *\n * This function allows you to create a new group in your Pinata account.\n * Groups can be used to organize and manage your pinned content more effectively.\n *\n * @async\n * @function createGroup\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {GroupOptions} options - The options for creating a new group.\n * @param {string} options.name - The name of the group to be created.\n * @returns {Promise<GroupResponseItem>} A promise that resolves to an object containing details of the created group.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the group creation process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const group = await pinata.groups.create({\n *\tname: \"My New Group\",\n * });\n */\n\nimport type { PinataConfig, GroupOptions, GroupResponseItem } from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const createGroup = async (\n\tconfig: PinataConfig | undefined,\n\toptions: GroupOptions,\n): Promise<GroupResponseItem> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst data = JSON.stringify(options);\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/createGroup\";\n\n\ttry {\n\t\tconst request = await fetch(\"https://api.pinata.cloud/groups\", {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: headers,\n\t\t\tbody: data,\n\t\t});\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: GroupResponseItem = await request.json();\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing createGroup: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\"An unknown error occurred while creating a group\");\n\t}\n};\n","/**\n * Retrieves a list of groups from Pinata.\n *\n * This function fetches a list of groups associated with your Pinata account.\n * It supports pagination and filtering by name.\n *\n * @async\n * @function listGroups\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {GroupQueryOptions} [options] - Optional query parameters to filter and paginate the results.\n * @param {number} [options.offset] - The number of items to skip before starting to collect the result set.\n * @param {string} [options.nameContains] - Filter groups by name (case-insensitive partial match).\n * @param {number} [options.limit] - The numbers of items to return.\n * @returns {Promise<GroupResponseItem[]>} A promise that resolves to an array of group objects.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the group listing process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const groups = await pinata.groups\n * .list()\n * .name(\"Greetings\");\n */\n\nimport type {\n\tPinataConfig,\n\tGroupResponseItem,\n\tGroupQueryOptions,\n} from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const listGroups = async (\n\tconfig: PinataConfig | undefined,\n\toptions?: GroupQueryOptions,\n): Promise<GroupResponseItem[]> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/listGroups\";\n\n\tconst params = new URLSearchParams();\n\n\tif (options) {\n\t\tconst { offset, nameContains, limit } = options;\n\n\t\tif (offset) params.append(\"offset\", offset.toString());\n\t\tif (nameContains !== undefined)\n\t\t\tparams.append(\"nameContains\", nameContains.toString());\n\t\tif (limit !== undefined) params.append(\"limit\", limit.toString());\n\t}\n\n\tconst url = `https://api.pinata.cloud/groups?${params.toString()}`;\n\n\ttry {\n\t\tconst request = await fetch(url, {\n\t\t\tmethod: \"GET\",\n\t\t\theaders: headers,\n\t\t});\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: GroupResponseItem[] = await request.json();\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing listGroups: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\"An unknown error occurred while listing groups\");\n\t}\n};\n","/**\n * Retrieves information about a specific group from Pinata.\n *\n * This function fetches details about a group in your Pinata account using its ID.\n * It provides information such as the group's name, creation date, and last update time.\n *\n * @async\n * @function getGroup\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {GetGroupOptions} options - The options for retrieving a group.\n * @param {string} options.groupId - The ID of the group to retrieve.\n * @returns {Promise<GroupResponseItem>} A promise that resolves to an object containing the group's details.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the group retrieval process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const groups = await pinata.groups.get({\n *\tgroupId: \"3778c10d-452e-4def-8299-ee6bc548bdb0\",\n * });\n */\n\nimport type {\n\tPinataConfig,\n\tGroupResponseItem,\n\tGetGroupOptions,\n} from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const getGroup = async (\n\tconfig: PinataConfig | undefined,\n\toptions: GetGroupOptions,\n): Promise<GroupResponseItem> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/getGroup\";\n\n\ttry {\n\t\tconst request = await fetch(\n\t\t\t`https://api.pinata.cloud/groups/${options.groupId}`,\n\t\t\t{\n\t\t\t\tmethod: \"GET\",\n\t\t\t\theaders: headers,\n\t\t\t},\n\t\t);\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: GroupResponseItem = await request.json();\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing getGroup: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\n\t\t\t\"An unknown error occurred while getting info for a group\",\n\t\t);\n\t}\n};\n","/**\n * Adds one or more CIDs (Content Identifiers) to a specified Pinata group.\n *\n * This function allows you to associate multiple CIDs with a group in Pinata,\n * which can be useful for organizing and managing your pinned content.\n *\n * @async\n * @function addToGroup\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {GroupCIDOptions} options - The options for adding CIDs to a group.\n * @param {string} options.groupId - The ID of the group to add the CIDs to.\n * @param {string[]} options.cids - An array of CIDs to add to the group.\n * @returns {Promise<string>} A promise that resolves to a string confirming the addition.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const group = await pinata.groups.addCids({\n * \tgroupId: \"3778c10d-452e-4def-8299-ee6bc548bdb0\",\n * \tcids: [\"QmVLwvmGehsrNEvhcCnnsw5RQNseohgEkFNN1848zNzdng\"],\n * });\n */\nimport type { GroupCIDOptions, PinataConfig } from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const addToGroup = async (\n\tconfig: PinataConfig | undefined,\n\toptions: GroupCIDOptions,\n): Promise<string> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst data = JSON.stringify({\n\t\tcids: options.cids,\n\t});\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/addToGroup\";\n\n\ttry {\n\t\tconst request = await fetch(\n\t\t\t`https://api.pinata.cloud/groups/${options.groupId}/cids`,\n\t\t\t{\n\t\t\t\tmethod: \"PUT\",\n\t\t\t\theaders: headers,\n\t\t\t\tbody: data,\n\t\t\t},\n\t\t);\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: string = await request.text();\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing addToGroup: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\n\t\t\t\"An unknown error occurred while adding CIDs to group\",\n\t\t);\n\t}\n};\n","/**\n * Updates the information of a specified group in Pinata.\n *\n * This function allows you to modify the name of an existing group in your Pinata account.\n * It's useful for renaming groups to better organize your pinned content.\n *\n * @async\n * @function updateGroup\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {UpdateGroupOptions} options - The options for updating a group.\n * @param {string} options.groupId - The ID of the group to be updated.\n * @param {string} options.name - The new name for the group.\n * @returns {Promise<GroupResponseItem>} A promise that resolves to an object containing the updated group's details.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the group update process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const groups = await pinata.groups.update({\n *\tgroupId: \"3778c10d-452e-4def-8299-ee6bc548bdb0\",\n *\tname: \"My New Group 2\"\n * });\n */\n\nimport type {\n\tPinataConfig,\n\tGroupResponseItem,\n\tUpdateGroupOptions,\n} from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const updateGroup = async (\n\tconfig: PinataConfig | undefined,\n\toptions: UpdateGroupOptions,\n): Promise<GroupResponseItem> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst data = JSON.stringify({\n\t\tname: options.name,\n\t});\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/updateGroup\";\n\n\ttry {\n\t\tconst request = await fetch(\n\t\t\t`https://api.pinata.cloud/groups/${options.groupId}`,\n\t\t\t{\n\t\t\t\tmethod: \"PUT\",\n\t\t\t\theaders: headers,\n\t\t\t\tbody: data,\n\t\t\t},\n\t\t);\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: GroupResponseItem = await request.json();\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing updateGroup: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\"An unknown error occurred while updating group\");\n\t}\n};\n","/**\n * Removes one or more CIDs (Content Identifiers) from a specified Pinata group.\n *\n * This function allows you to disassociate multiple CIDs from a group in Pinata.\n * It's useful for managing the content within your groups without deleting the actual files.\n *\n * @async\n * @function removeFromGroup\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {GroupCIDOptions} options - The options for removing CIDs from a group.\n * @param {string} options.groupId - The ID of the group to remove the CIDs from.\n * @param {string[]} options.cids - An array of CIDs to remove from the group.\n * @returns {Promise<string>} A promise that resolves to a string confirming the removal.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the process.\n *\n * @example\n *import { PinataSDK } from \"pinata\";\n *\n *const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n *});\n *\n *const group = await pinata.groups.removeCids({\n *\tgroupId: \"3778c10d-452e-4def-8299-ee6bc548bdb0\",\n *\tcids: [\"QmVLwvmGehsrNEvhcCnnsw5RQNseohgEkFNN1848zNzdng\"],\n *});\n */\n\nimport type { GroupCIDOptions, PinataConfig } from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const removeFromGroup = async (\n\tconfig: PinataConfig | undefined,\n\toptions: GroupCIDOptions,\n): Promise<string> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/removeFromGroup\";\n\n\tconst data = JSON.stringify({\n\t\tcids: options.cids,\n\t});\n\n\ttry {\n\t\tconst request = await fetch(\n\t\t\t`https://api.pinata.cloud/groups/${options.groupId}/cids`,\n\t\t\t{\n\t\t\t\tmethod: \"DELETE\",\n\t\t\t\theaders: headers,\n\t\t\t\tbody: data,\n\t\t\t},\n\t\t);\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: string = await request.text();\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(\n\t\t\t\t`Error processing removeFromGroup: ${error.message}`,\n\t\t\t);\n\t\t}\n\t\tthrow new PinataError(\n\t\t\t\"An unknown error occurred while removing CIDs from a group\",\n\t\t);\n\t}\n};\n","/**\n * Deletes a specified group from Pinata.\n *\n * This function allows you to remove a group from your Pinata account.\n * Note that deleting a group does not delete the files within the group,\n * it only removes the group association.\n *\n * @async\n * @function deleteGroup\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {GetGroupOptions} options - The options for deleting a group.\n * @param {string} options.groupId - The ID of the group to be deleted.\n * @returns {Promise<string>} A promise that resolves to a string confirming the deletion.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the group deletion process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const groups = await pinata.groups.delete({\n *\tgroupId: \"3778c10d-452e-4def-8299-ee6bc548bdb0\",\n * });\n */\n\nimport type { GetGroupOptions, PinataConfig } from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const deleteGroup = async (\n\tconfig: PinataConfig | undefined,\n\toptions: GetGroupOptions,\n): Promise<string> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/deleteGroup\";\n\n\ttry {\n\t\tconst request = await fetch(\n\t\t\t`https://api.pinata.cloud/groups/${options.groupId}`,\n\t\t\t{\n\t\t\t\tmethod: \"DELETE\",\n\t\t\t\theaders: headers,\n\t\t\t},\n\t\t);\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res: string = await request.text();\n\t\treturn res;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing deleteGroup: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\"An unknown error occurred while deleting a group\");\n\t}\n};\n","/**\n * Adds a signature to a specific Content Identifier (CID) on Pinata.\n *\n * This function allows you to add a cryptographic signature to a file identified by its CID.\n * It's useful for verifying ownership or authenticity of content stored on IPFS via Pinata.\n *\n * @async\n * @function addSignature\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {SignatureOptions} options - Options for adding the signature.\n * @param {string} options.cid - The Content Identifier (CID) of the file to be signed.\n * @param {string} options.signature - The cryptographic signature to be added.\n * @returns {Promise<SignatureResponse>} A promise that resolves to an object containing the signature details.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {PinataError} If the user is unauthorized to sign the file or if the file already has a signature.\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the signature addition process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const signature = await pinata.signatures.add({\n *\tcid: \"QmXGeVy9dVwfuFJmvbzz8y4dYK1TdxXbDGzwbNuyZ5xXSU\",\n *\tsignature: \"0x1ba6c2a8412dc9b0be37b013ea5bddd97251dab4d435cc9c4c7bcf331d4017ca2de07485ad6a15ce60d3700cee802787bc7ede0c112c7843f702bb1e71b750911b\"\n * })\n */\n\nimport type {\n\tSignatureOptions,\n\tPinataConfig,\n\tSignatureResponse,\n} from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const addSignature = async (\n\tconfig: PinataConfig | undefined,\n\toptions: SignatureOptions,\n): Promise<SignatureResponse> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst data = JSON.stringify({\n\t\tsignature: options.signature,\n\t});\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/addSignature\";\n\n\ttry {\n\t\tconst request = await fetch(\n\t\t\t`https://api.pinata.cloud/v3/ipfs/signature/${options.cid}`,\n\t\t\t{\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: headers,\n\t\t\t\tbody: data,\n\t\t\t},\n\t\t);\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (request.status === 403) {\n\t\t\t\tthrow new PinataError(\n\t\t\t\t\t\"Unauthorized signing, you must be the original owner of the file and it must not have a signature\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res = await request.json();\n\t\treturn res.data;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing addSignature: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\n\t\t\t\"An unknown error occurred while adding signature to CID\",\n\t\t);\n\t}\n};\n","/**\n * Retrieves the signature associated with a specific Content Identifier (CID) from Pinata.\n *\n * This function allows you to fetch the cryptographic signature associated with a file\n * identified by its CID. It's useful for verifying the authenticity or ownership of\n * content stored on IPFS via Pinata.\n *\n * @async\n * @function getSignature\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {string} cid - The Content Identifier (CID) of the file whose signature is to be retrieved.\n * @returns {Promise<SignatureResponse>} A promise that resolves to an object containing the signature details.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the signature retrieval process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const signature = await pinata.signatures.get(\"QmXGeVy9dVwfuFJmvbzz8y4dYK1TdxXbDGzwbNuyZ5xXSU\"\n )\n */\n\nimport type { PinataConfig, SignatureResponse } from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const getSignature = async (\n\tconfig: PinataConfig | undefined,\n\tcid: string,\n): Promise<SignatureResponse> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/getSignature\";\n\n\ttry {\n\t\tconst request = await fetch(\n\t\t\t`https://api.pinata.cloud/v3/ipfs/signature/${cid}`,\n\t\t\t{\n\t\t\t\tmethod: \"GET\",\n\t\t\t\theaders: headers,\n\t\t\t},\n\t\t);\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\n\t\tconst res = await request.json();\n\t\treturn res.data;\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing getSignature: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\n\t\t\t\"An unknown error occurred while fetching signature for CID\",\n\t\t);\n\t}\n};\n","/**\n * Removes the signature associated with a specific Content Identifier (CID) from Pinata.\n *\n * This function allows you to delete the cryptographic signature associated with a file\n * identified by its CID. It's useful for managing ownership claims or updating the\n * authenticity status of content stored on IPFS via Pinata.\n *\n * @async\n * @function removeSignature\n * @param {PinataConfig | undefined} config - The Pinata configuration object containing the JWT.\n * @param {string} cid - The Content Identifier (CID) of the file whose signature is to be removed.\n * @returns {Promise<string>} A promise that resolves to \"OK\" if the signature was successfully removed.\n * @throws {ValidationError} If the Pinata configuration or JWT is missing.\n * @throws {AuthenticationError} If the authentication fails (e.g., invalid JWT).\n * @throws {NetworkError} If there's a network-related error during the API request.\n * @throws {PinataError} For any other errors that occur during the signature removal process.\n *\n * @example\n * import { PinataSDK } from \"pinata\";\n *\n * const pinata = new PinataSDK({\n * pinataJwt: process.env.PINATA_JWT!,\n * pinataGateway: \"example-gateway.mypinata.cloud\",\n * });\n *\n * const signature = await pinata.signatures.delete(\"QmXGeVy9dVwfuFJmvbzz8y4dYK1TdxXbDGzwbNuyZ5xXSU\"\n )\n */\n\nimport type { PinataConfig } from \"../types\";\n\nimport {\n\tPinataError,\n\tNetworkError,\n\tAuthenticationError,\n\tValidationError,\n} from \"../../utils/custom-errors\";\n\nexport const removeSignature = async (\n\tconfig: PinataConfig | undefined,\n\tcid: string,\n): Promise<string> => {\n\tif (!config || !config.pinataJwt) {\n\t\tthrow new ValidationError(\"Pinata configuration or JWT is missing\");\n\t}\n\n\tconst headers: Record<string, string> = {\n\t\t\"Content-Type\": \"application/json\",\n\t\tAuthorization: `Bearer ${config?.pinataJwt}`,\n\t};\n\n\tif (config.customHeaders) {\n\t\tObject.assign(headers, config.customHeaders);\n\t}\n\n\t// biome-ignore lint/complexity/useLiteralKeys: non-issue\n\theaders[\"Source\"] = headers[\"Source\"] || \"sdk/removeSignature\";\n\n\ttry {\n\t\tconst request = await fetch(\n\t\t\t`https://api.pinata.cloud/v3/ipfs/signature/${cid}`,\n\t\t\t{\n\t\t\t\tmethod: \"DELETE\",\n\t\t\t\theaders: headers,\n\t\t\t},\n\t\t);\n\n\t\tif (!request.ok) {\n\t\t\tconst errorData = await request.json();\n\t\t\tif (request.status === 401) {\n\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\"Authentication failed\",\n\t\t\t\t\trequest.status,\n\t\t\t\t\terrorData,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NetworkError(\n\t\t\t\t`HTTP error! status: ${request.status}`,\n\t\t\t\trequest.status,\n\t\t\t\terrorData,\n\t\t\t);\n\t\t}\n\t\treturn \"OK\";\n\t} catch (error) {\n\t\tif (error instanceof PinataError) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (error instanceof Error) {\n\t\t\tthrow new PinataError(`Error processing addSignature: ${error.message}`);\n\t\t}\n\t\tthrow new PinataError(\n\t\t\t\"An unknown error occurred while adding signature to CID\",\n\t\t);\n\t}\n};\n","import type {\n\tFileObject,\n\tPinByCIDResponse,\n\tPinListItem,\n\tPinListQuery,\n\tPinResponse,\n\tPinataConfig,\n\tPinataMetadata,\n\tPinataMetadataUpdate,\n\tUploadCIDOptions,\n\tUploadOptions,\n\tGetCIDResponse,\n\tPinJobQuery,\n\tPinJobItem,\n\tKeyOptions,\n\tKeyResponse,\n\tKeyListQuery,\n\tKeyListItem,\n\tGroupOptions,\n\tGroupResponseItem,\n\tUpdateGroupOptions,\n\tGroupCIDOptions,\n\tGroupQueryOptions,\n\tGetGroupOptions,\n\tAuthTestResponse,\n\tUnpinResponse,\n\tRevokeKeyResponse,\n\tSignatureOptions,\n\tSignatureResponse,\n} from \"./types\";\nimport { testAuthentication } from \"./authentication/testAuthentication\";\nimport { uploadFile } from \"./pinning/file\";\nimport { uploadFileArray } from \"./pinning/fileArray\";\nimport { uploadBase64 } from \"./pinning/base64\";\nimport { uploadUrl } from \"./pinning/url\";\nimport { uploadJson } from \"./pinning/json\";\nimport { uploadCid } from \"./pinning/cid\";\nimport { unpinFile } from \"./pinning/unpin\";\nimport { listFiles } from \"./data/listFiles\";\nimport { updateMetadata } from \"./data/updateMetadata\";\nimport { getCid } from \"./gateway/getCid\";\nimport { convertIPFSUrl } from \"./gateway/convertIPFSUrl\";\nimport { pinJobs } from \"./data/pinJobs\";\nimport { pinnedFileCount } from \"./data/pinnedFileUsage\";\nimport { totalStorageUsage } from \"./data/totalStorageUsage\";\nimport { createKey } from \"./keys/createKey\";\nimport { listKeys } from \"./keys/listKeys\";\nimport { revokeKeys } from \"./keys/revokeKeys\";\nimport { createGroup } from \"./groups/createGroup\";\nimport { listGroups } from \"./groups/listGroups\";\nimport { getGroup } from \"./groups/getGroup\";\nimport { addToGroup } from \"./groups/addToGroup\";\nimport { updateGroup } from \"./groups/updateGroup\";\nimport { removeFromGroup } from \"./groups/removeFromGroup\";\nimport { deleteGroup } from \"./groups/deleteGroup\";\nimport { addSignature } from \"./signatures/addSignature\";\nimport { getSignature } from \"./signatures/getSignature\";\nimport { removeSignature } from \"./signatures/removeSignature\";\n\nconst formatConfig = (config: PinataConfig | undefined) => {\n\tlet gateway = config?.pinataGateway;\n\tif (config && gateway) {\n\t\tif (gateway && !gateway.startsWith(\"https://\")) {\n\t\t\tgateway = `https://${gateway}`;\n\t\t}\n\t\tconfig.pinataGateway = gateway;\n\t}\n\treturn config;\n};\n\nexport class PinataSDK {\n\tconfig: PinataConfig | undefined;\n\tupload: Upload;\n\tgateways: Gateways;\n\tusage: Usage;\n\tkeys: Keys;\n\tgroups: Groups;\n\tsignatures: Signatures;\n\n\tconstructor(config?: PinataConfig) {\n\t\tthis.config = formatConfig(config);\n\t\tthis.upload = new Upload(this.config);\n\t\tthis.gateways = new Gateways(this.config);\n\t\tthis.usage = new Usage(this.config);\n\t\tthis.keys = new Keys(this.config);\n\t\tthis.groups = new Groups(this.config);\n\t\tthis.signatures = new Signatures(this.config);\n\t}\n\n\ttestAuthentication(): Promise<AuthTestResponse> {\n\t\treturn testAuthentication(this.config);\n\t}\n\n\tunpin(files: string[]): Promise<UnpinResponse[]> {\n\t\treturn unpinFile(this.config, files);\n\t}\n\n\tlistFiles(): FilterFiles {\n\t\treturn new FilterFiles(this.config);\n\t}\n\n\tupdateMetadata(options: PinataMetadataUpdate): Promise<string> {\n\t\treturn updateMetadata(this.config, options);\n\t}\n\n\tpinJobs(): FilterPinJobs {\n\t\treturn new FilterPinJobs(this.config);\n\t}\n}\n\nclass UploadBuilder<T> {\n\tprivate config: PinataConfig | undefined;\n\tprivate uploadFunction: (\n\t\tconfig: PinataConfig | undefined,\n\t\t...args: any[]\n\t) => Promise<T>;\n\tprivate args: any[];\n\tprivate metadata: PinataMetadata | undefined;\n\tprivate keys: string | undefined;\n\tprivate peerAddresses: string[] | undefined;\n\tprivate version: 0 | 1 | undefined;\n\tprivate groupId: string | undefined;\n\n\tconstructor(\n\t\tconfig: PinataConfig | undefined,\n\t\tuploadFunction: (\n\t\t\tconfig: PinataConfig | undefined,\n\t\t\t...args: any[]\n\t\t) => Promise<T>,\n\t\t...args: any[]\n\t) {\n\t\tthis.config = config;\n\t\tthis.uploadFunction = uploadFunction;\n\t\tthis.args = args;\n\t\tthis.version = 1;\n\t}\n\n\taddMetadata(metadata: PinataMetadata): UploadBuilder<T> {\n\t\tthis.metadata = metadata;\n\t\treturn this;\n\t}\n\n\tkey(jwt: string): UploadBuilder<T> {\n\t\tthis.keys = jwt;\n\t\treturn this;\n\t}\n\n\tcidVersion(v: 0 | 1): UploadBuilder<T> {\n\t\tthis.version = v;\n\t\treturn this;\n\t}\n\n\tgroup(groupId: string): UploadBuilder<T> {\n\t\tthis.groupId = groupId;\n\t\treturn this;\n\t}\n\n\tpeerAddress(peerAddresses: string[]): UploadBuilder<T> {\n\t\tthis.peerAddresses = peerAddresses;\n\t\treturn this;\n\t}\n\n\tthen<TResult1 = T, TResult2 = never>(\n\t\tonfulfilled?:\n\t\t\t| ((value: T) => TResult1 | PromiseLike<TResult1>)\n\t\t\t| null\n\t\t\t| undefined,\n\t\tonrejected?:\n\t\t\t| ((reason: any) => TResult2 | PromiseLike<TResult2>)\n\t\t\t| null\n\t\t\t| undefined,\n\t): Promise<TResult1 | TResult2> {\n\t\tconst options: UploadOptions = this.args[this.args.length - 1] || {};\n\t\tif (this.metadata) {\n\t\t\toptions.metadata = this.metadata;\n\t\t}\n\t\tif (this.keys) {\n\t\t\toptions.keys = this.keys;\n\t\t}\n\t\tif (this.groupId) {\n\t\t\toptions.groupId = this.groupId;\n\t\t}\n\t\tif (this.version) {\n\t\t\toptions.cidVersion = this.version;\n\t\t}\n\t\tif (this.peerAddresses && \"peerAddresses\" in options) {\n\t\t\toptions.peerAddresses = this.peerAddresses;\n\t\t}\n\t\tthis.args[this.args.length - 1] = options;\n\t\treturn this.uploadFunction(this.config, ...this.args).then(\n\t\t\tonfulfilled,\n\t\t\tonrejected,\n\t\t);\n\t}\n}\n\nclass Upload {\n\tconfig: PinataConfig | undefined;\n\n\tconstructor(config?: PinataConfig) {\n\t\tthis.config = formatConfig(config);\n\t}\n\n\tfile(file: FileObject, options?: UploadOptions): UploadBuilder<PinResponse> {\n\t\treturn new UploadBuilder(this.config, uploadFile, file, options);\n\t}\n\n\tfileArray(\n\t\tfiles: FileObject[],\n\t\toptions?: UploadOptions,\n\t): UploadBuilder<PinResponse> {\n\t\treturn new UploadBuilder(this.config, uploadFileArray, files, options);\n\t}\n\n\tbase64(\n\t\tbase64String: string,\n\t\toptions?: UploadOptions,\n\t): UploadBuilder<PinResponse> {\n\t\treturn new UploadBuilder(this.config, uploadBase64, base64String, options);\n\t}\n\n\turl(url: string, options?: UploadOptions): UploadBuilder<PinResponse> {\n\t\treturn new UploadBuilder(this.config, uploadUrl, url, options);\n\t}\n\n\tjson(data: object, options?: UploadOptions): UploadBuilder<PinResponse> {\n\t\treturn new UploadBuilder(this.config, uploadJson, data, options);\n\t}\n\n\tcid(\n\t\tcid: string,\n\t\toptions?: UploadCIDOptions,\n\t): UploadBuilder<PinByCIDResponse> {\n\t\treturn new UploadBuilder(this.config, uploadCid, cid, options);\n\t}\n}\n\nclass FilterFiles {\n\tprivate config: PinataConfig | undefined;\n\tprivate query: PinListQuery = {};\n\t// rate limit vars\n\tprivate requestCount = 0;\n\tprivate lastRequestTime = 0;\n\tprivate readonly MAX_REQUESTS_PER_MINUTE = 30;\n\tprivate readonly MINUTE_IN_MS = 60000;\n\n\tconstructor(config: PinataConfig | undefined) {\n\t\tthis.config = config;\n\t}\n\n\tcid(cid: string): FilterFiles {\n\t\tthis.query.cid = cid;\n\t\treturn this;\n\t}\n\n\tpinStart(date: string): FilterFiles {\n\t\tthis.query.pinStart = date;\n\t\treturn this;\n\t}\n\n\tpinEnd(date: string): FilterFiles {\n\t\tthis.query.pinEnd = date;\n\t\treturn this;\n\t}\n\n\tpinSizeMin(size: number): FilterFiles {\n\t\tthis.query.pinSizeMin = size;\n\t\treturn this;\n\t}\n\n\tpinSizeMax(size: number): FilterFiles {\n\t\tthis.query.pinSizeMax = size;\n\t\treturn this;\n\t}\n\n\tpageLimit(limit: number): FilterFiles {\n\t\tthis.query.pageLimit = limit;\n\t\treturn this;\n\t}\n\n\tpageOffset(offset: number): FilterFiles {\n\t\tthis.query.pageOffset = offset;\n\t\treturn this;\n\t}\n\n\tname(name: string): FilterFiles {\n\t\tthis.query.name = name;\n\t\treturn this;\n\t}\n\n\tgroup(groupId: string): FilterFiles {\n\t\tthis.query.groupId = groupId;\n\t\treturn this;\n\t}\n\n\tkeyValue(\n\t\tkey: string,\n\t\tvalue: string | number,\n\t\toperator?: PinListQuery[\"operator\"],\n\t): FilterFiles {\n\t\tthis.query.key = key;\n\t\tthis.query.value = value;\n\t\tif (operator) {\n\t\t\tthis.query.operator = operator;\n\t\t}\n\t\treturn this;\n\t}\n\n\tthen(onfulfilled?: ((value: PinListItem[]) => any) | null): Promise<any> {\n\t\treturn listFiles(this.config, this.query).then(onfulfilled);\n\t}\n\n\t// rate limit, hopefully temporary?\n\tprivate async rateLimit(): Promise<void> {\n\t\tthis.requestCount++;\n\t\tconst now = Date.now();\n\t\tif (this.requestCount >= this.MAX_REQUESTS_PER_MINUTE) {\n\t\t\tconst timePassedSinceLastRequest = now - this.lastRequestTime;\n\t\t\tif (timePassedSinceLastRequest < this.MINUTE_IN_MS) {\n\t\t\t\tconst delayTime = this.MINUTE_IN_MS - timePassedSinceLastRequest;\n\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, delayTime));\n\t\t\t}\n\t\t\tthis.requestCount = 0;\n\t\t}\n\t\tthis.lastRequestTime = Date.now();\n\t}\n\n\tasync *[Symbol.asyncIterator](): AsyncGenerator<PinListItem, void, unknown> {\n\t\tlet hasMore = true;\n\t\tlet offset = 0;\n\t\tconst limit = this.query.pageLimit || 10;\n\n\t\twhile (hasMore) {\n\t\t\tawait this.rateLimit(); // applying rate limit\n\t\t\tthis.query.pageOffset = offset;\n\t\t\tthis.query.pageLimit = limit;\n\n\t\t\tconst items = await listFiles(this.config, this.query);\n\n\t\t\tfor (const item of items) {\n\t\t\t\tyield item;\n\t\t\t}\n\n\t\t\tif (items.length === 0) {\n\t\t\t\thasMore = false;\n\t\t\t} else {\n\t\t\t\toffset += items.length;\n\t\t\t}\n\t\t}\n\t}\n\n\tasync all(): Promise<PinListItem[]> {\n\t\tconst allItems: PinListItem[] = [];\n\t\tfor await (const item of this) {\n\t\t\tallItems.push(item);\n\t\t}\n\t\treturn allItems;\n\t}\n}\n\nclass Gateways {\n\tconfig: PinataConfig | undefined;\n\n\tconstructor(config?: PinataConfig) {\n\t\tthis.config = formatConfig(config);\n\t}\n\n\tget(cid: string): Promise<GetCIDResponse> {\n\t\treturn getCid(this.config, cid);\n\t}\n\n\tconvert(url: string): Promise<string> {\n\t\treturn convertIPFSUrl(this.config, url);\n\t}\n}\n\nclass FilterPinJobs {\n\tprivate config: PinataConfig | undefined;\n\tprivate query: PinJobQuery = {};\n\t// rate limit vars\n\tprivate requestCount = 0;\n\tprivate lastRequestTime = 0;\n\tprivate readonly MAX_REQUESTS_PER_MINUTE = 30;\n\tprivate readonly MINUTE_IN_MS = 60000;\n\n\tconstructor(config: PinataConfig | undefined) {\n\t\tthis.config = config;\n\t}\n\n\tcid(cid: string): FilterPinJobs {\n\t\tthis.query.ipfs_pin_hash = cid;\n\t\treturn this;\n\t}\n\n\tstatus(\n\t\tstatus:\n\t\t\t| \"prechecking\"\n\t\t\t| \"retrieving\"\n\t\t\t| \"expired\"\n\t\t\t| \"over_free_limit\"\n\t\t\t| \"over_max_size\"\n\t\t\t| \"invalid_object\"\n\t\t\t| \"bad_host_node\",\n\t): FilterPinJobs {\n\t\tthis.query.status = status;\n\t\treturn this;\n\t}\n\n\tpageLimit(limit: number): FilterPinJobs {\n\t\tthis.query.limit = limit;\n\t\treturn this;\n\t}\n\n\tpageOffset(offset: number): FilterPinJobs {\n\t\tthis.query.offset = offset;\n\t\treturn this;\n\t}\n\n\tsort(sort: \"ASC\" | \"DSC\"): FilterPinJobs {\n\t\tthis.query.sort = sort;\n\t\treturn this;\n\t}\n\n\tthen(onfulfilled?: ((value: PinJobItem[]) => any) | null): Promise<any> {\n\t\treturn pinJobs(this.config, this.query).then(onfulfilled);\n\t}\n\n\t// rate limit, hopefully temporary?\n\tprivate async rateLimit(): Promise<void> {\n\t\tthis.requestCount++;\n\t\tconst now = Date.now();\n\t\tif (this.requestCount >= this.MAX_REQUESTS_PER_MINUTE) {\n\t\t\tconst timePassedSinceLastRequest = now - this.lastRequestTime;\n\t\t\tif (timePassedSinceLastRequest < this.MINUTE_IN_MS) {\n\t\t\t\tconst delayTime = this.MINUTE_IN_MS - timePassedSinceLastRequest;\n\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, delayTime));\n\t\t\t}\n\t\t\tthis.requestCount = 0;\n\t\t}\n\t\tthis.lastRequestTime = Date.now();\n\t}\n\n\tasync *[Symbol.asyncIterator](): AsyncGenerator<PinJobItem, void, unknown> {\n\t\tlet hasMore = true;\n\t\tlet offset = 0;\n\t\tconst limit = this.query.limit || 10;\n\n\t\twhile (hasMore) {\n\t\t\tawait this.rateLimit(); // applying rate limit\n\t\t\tthis.query.offset = offset;\n\t\t\tthis.query.limit = limit;\n\n\t\t\tconst items = await pinJobs(this.config, this.query);\n\n\t\t\tfor (const item of items) {\n\t\t\t\tyield item;\n\t\t\t}\n\n\t\t\tif (items.length === 0) {\n\t\t\t\thasMore = false;\n\t\t\t} else {\n\t\t\t\toffset += items.length;\n\t\t\t}\n\t\t}\n\t}\n\n\tasync all(): Promise<PinJobItem[]> {\n\t\tconst allItems: PinJobItem[] = [];\n\t\tfor await (const item of this) {\n\t\t\tallItems.push(item);\n\t\t}\n\t\treturn allItems;\n\t}\n}\n\nclass Usage {\n\tconfig: PinataConfig | undefined;\n\n\tconstructor(config?: PinataConfig) {\n\t\tthis.config = formatConfig(config);\n\t}\n\n\tpinnedFileCount(): Promise<number> {\n\t\treturn pinnedFileCount(this.config);\n\t}\n\n\ttotalStorageSize(): Promise<number> {\n\t\treturn totalStorageUsage(this.config);\n\t}\n}\n\nclass Keys {\n\tconfig: PinataConfig | undefined;\n\n\tconstructor(config?: PinataConfig) {\n\t\tthis.config = formatConfig(config);\n\t}\n\n\tcreate(options: KeyOptions): Promise<KeyResponse> {\n\t\treturn createKey(this.config, options);\n\t}\n\n\tlist(): FilterKeys {\n\t\treturn new FilterKeys(this.config);\n\t}\n\n\trevoke(keys: string[]): Promise<RevokeKeyResponse[]> {\n\t\treturn revokeKeys(this.config, keys);\n\t}\n}\n\nclass FilterKeys {\n\tprivate config: PinataConfig | undefined;\n\tprivate query: KeyListQuery = {};\n\t// rate limit vars\n\tprivate requestCount = 0;\n\tprivate lastRequestTime = 0;\n\tprivate readonly MAX_REQUESTS_PER_MINUTE = 30;\n\tprivate readonly MINUTE_IN_MS = 60000;\n\n\tconstructor(config: PinataConfig | undefined) {\n\t\tthis.config = config;\n\t}\n\n\toffset(offset: number): FilterKeys {\n\t\tthis.query.offset = offset;\n\t\treturn this;\n\t}\n\n\trevoked(revoked: boolean): FilterKeys {\n\t\tthis.query.revoked = revoked;\n\t\treturn this;\n\t}\n\n\tlimitedUse(limitedUse: boolean): FilterKeys {\n\t\tthis.query.limitedUse = limitedUse;\n\t\treturn this;\n\t}\n\n\texhausted(exhausted: boolean): FilterKeys {\n\t\tthis.query.exhausted = exhausted;\n\t\treturn this;\n\t}\n\n\tname(name: string): FilterKeys {\n\t\tthis.query.name = name;\n\t\treturn this;\n\t}\n\n\tthen(onfulfilled?: ((value: KeyListItem[]) => any) | null): Promise<any> {\n\t\treturn listKeys(this.config, this.query).then(onfulfilled);\n\t}\n\n\t// rate limit, hopefully temporary?\n\tprivate async rateLimit(): Promise<void> {\n\t\tthis.requestCount++;\n\t\tconst now = Date.now();\n\t\tif (this.requestCount >= this.MAX_REQUESTS_PER_MINUTE) {\n\t\t\tconst timePassedSinceLastRequest = now - this.lastRequestTime;\n\t\t\tif (timePassedSinceLastRequest < this.MINUTE_IN_MS) {\n\t\t\t\tconst delayTime = this.MINUTE_IN_MS - timePassedSinceLastRequest;\n\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, delayTime));\n\t\t\t}\n\t\t\tthis.requestCount = 0;\n\t\t}\n\t\tthis.lastRequestTime = Date.now();\n\t}\n\n\tasync *[Symbol.asyncIterator](): AsyncGenerator<KeyListItem, void, unknown> {\n\t\tlet hasMore = true;\n\t\tlet offset = 0;\n\n\t\twhile (hasMore) {\n\t\t\tawait this.rateLimit(); // applying rate limit\n\t\t\tthis.query.offset = offset;\n\n\t\t\tconst items = await listKeys(this.config, this.query);\n\n\t\t\tfor (const item of items) {\n\t\t\t\tyield item;\n\t\t\t}\n\n\t\t\tif (items.length === 0) {\n\t\t\t\thasMore = false;\n\t\t\t} else {\n\t\t\t\toffset += items.length;\n\t\t\t}\n\t\t}\n\t}\n\n\tasync all(): Promise<KeyListItem[]> {\n\t\tconst allItems: KeyListItem[] = [];\n\t\tfor await (const item of this) {\n\t\t\tallItems.push(item);\n\t\t}\n\t\treturn allItems;\n\t}\n}\n\nclass Groups {\n\tconfig: PinataConfig | undefined;\n\n\tconstructor(config?: PinataConfig) {\n\t\tthis.config = formatConfig(config);\n\t}\n\n\tcreate(options: GroupOptions): Promise<GroupResponseItem> {\n\t\treturn createGroup(this.config, options);\n\t}\n\n\tlist(): FilterGroups {\n\t\treturn new FilterGroups(this.config);\n\t}\n\n\tget(options: GetGroupOptions): Promise<GroupResponseItem> {\n\t\treturn getGroup(this.config, options);\n\t}\n\n\taddCids(options: GroupCIDOptions): Promise<string> {\n\t\treturn addToGroup(this.config, options);\n\t}\n\n\tremoveCids(options: GroupCIDOptions): Promise<string> {\n\t\treturn removeFromGroup(this.config, options);\n\t}\n\n\tupdate(options: UpdateGroupOptions): Promise<GroupResponseItem> {\n\t\treturn updateGroup(this.config, options);\n\t}\n\n\tdelete(options: GetGroupOptions): Promise<string> {\n\t\treturn deleteGroup(this.config, options);\n\t}\n}\n\nclass FilterGroups {\n\tprivate config: PinataConfig | undefined;\n\tprivate query: GroupQueryOptions = {};\n\t// rate limit vars\n\tprivate requestCount = 0;\n\tprivate lastRequestTime = 0;\n\tprivate readonly MAX_REQUESTS_PER_MINUTE = 30;\n\tprivate readonly MINUTE_IN_MS = 60000;\n\n\tconstructor(config: PinataConfig | undefined) {\n\t\tthis.config = config;\n\t}\n\n\toffset(offset: number): FilterGroups {\n\t\tthis.query.offset = offset;\n\t\treturn this;\n\t}\n\n\tname(nameContains: string): FilterGroups {\n\t\tthis.query.nameContains = nameContains;\n\t\treturn this;\n\t}\n\n\tlimit(limit: number): FilterGroups {\n\t\tthis.query.limit = limit;\n\t\treturn this;\n\t}\n\n\tthen(\n\t\tonfulfilled?: ((value: GroupResponseItem[]) => any) | null,\n\t): Promise<any> {\n\t\treturn listGroups(this.config, this.query).then(onfulfilled);\n\t}\n\n\t// rate limit, hopefully temporary?\n\tprivate async rateLimit(): Promise<void> {\n\t\tthis.requestCount++;\n\t\tconst now = Date.now();\n\t\tif (this.requestCount >= this.MAX_REQUESTS_PER_MINUTE) {\n\t\t\tconst timePassedSinceLastRequest = now - this.lastRequestTime;\n\t\t\tif (timePassedSinceLastRequest < this.MINUTE_IN_MS) {\n\t\t\t\tconst delayTime = this.MINUTE_IN_MS - timePassedSinceLastRequest;\n\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, delayTime));\n\t\t\t}\n\t\t\tthis.requestCount = 0;\n\t\t}\n\t\tthis.lastRequestTime = Date.now();\n\t}\n\n\tasync *[Symbol.asyncIterator](): AsyncGenerator<\n\t\tGroupResponseItem,\n\t\tvoid,\n\t\tunknown\n\t> {\n\t\tlet hasMore = true;\n\t\tlet offset = 0;\n\n\t\twhile (hasMore) {\n\t\t\tawait this.rateLimit(); // applying rate limit\n\t\t\tthis.query.offset = offset;\n\n\t\t\tconst items = await listGroups(this.config, this.query);\n\n\t\t\tfor (const item of items) {\n\t\t\t\tyield item;\n\t\t\t}\n\n\t\t\tif (items.length === 0) {\n\t\t\t\thasMore = false;\n\t\t\t} else {\n\t\t\t\toffset += items.length;\n\t\t\t}\n\t\t}\n\t}\n\n\tasync all(): Promise<GroupResponseItem[]> {\n\t\tconst allItems: GroupResponseItem[] = [];\n\t\tfor await (const item of this) {\n\t\t\tallItems.push(item);\n\t\t}\n\t\treturn allItems;\n\t}\n}\n\nclass Signatures {\n\tconfig: PinataConfig | undefined;\n\n\tconstructor(config?: PinataConfig) {\n\t\tthis.config = formatConfig(config);\n\t}\n\n\tadd(options: SignatureOptions): Promise<SignatureResponse> {\n\t\treturn addSignature(this.config, options);\n\t}\n\n\tget(cid: string): Promise<SignatureResponse> {\n\t\treturn getSignature(this.config, cid);\n\t}\n\n\tdelete(cid: string): Promise<string> {\n\t\treturn removeSignature(this.config, cid);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,cAAN,cAA0B,MAAM;AAAA,EACtC,YACC,SACO,YACA,SACN;AACD,UAAM,OAAO;AAHN;AACA;AAGP,SAAK,OAAO;AAAA,EACb;AACD;AAEO,IAAM,eAAN,cAA2B,YAAY;AAAA,EAC7C,YAAY,SAAiB,YAAqB,SAAe;AAChE,UAAM,SAAS,YAAY,OAAO;AAClC,SAAK,OAAO;AAAA,EACb;AACD;AAEO,IAAM,sBAAN,cAAkC,YAAY;AAAA,EACpD,YAAY,SAAiB,YAAqB,SAAe;AAChE,UAAM,SAAS,YAAY,OAAO;AAClC,SAAK,OAAO;AAAA,EACb;AACD;AAEO,IAAM,kBAAN,cAA8B,YAAY;AAAA,EAChD,YAAY,SAAiB,SAAe;AAC3C,UAAM,SAAS,QAAW,OAAO;AACjC,SAAK,OAAO;AAAA,EACb;AACD;;;ACGO,IAAM,qBAAqB,OAAO,WAAqC;AAC7E,MAAI,CAAC,UAAU,CAAC,OAAO,WAAW;AACjC,UAAM,IAAI,gBAAgB,wCAAwC;AAAA,EACnE;AAEA,QAAM,UAAkC;AAAA,IACvC,eAAe,UAAU,QAAQ,SAAS;AAAA,EAC3C;AAEA,MAAI,OAAO,eAAe;AACzB,WAAO,OAAO,SAAS,OAAO,aAAa;AAAA,EAC5C;AAGA,UAAQ,QAAQ,IAAI,QAAQ,QAAQ,KAAK;AAEzC,MAAI;AACH,UAAM,UAAU,MAAM;AAAA,MACrB;AAAA,MACA;AAAA,QACC,QAAQ;AAAA,QACR;AAAA,MACD;AAAA,IACD;AACA,QAAI,CAAC,QAAQ,IAAI;AAChB,YAAM,YAAY,MAAM,QAA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