Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@thirdweb-dev/storage

Package Overview
Dependencies
Maintainers
8
Versions
801
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thirdweb-dev/storage - npm Package Compare versions

Comparing version 0.0.0-dev-25f5da4-20230828234008 to 0.0.0-dev-2644666-20231219000747

2

dist/declarations/src/common/urls.d.ts
import { GatewayUrls } from "../types";
/**
* @internal
* @param url
* @param url - the url to check
* @returns

@@ -6,0 +6,0 @@ */

@@ -26,2 +26,3 @@ import { GatewayUrls, IStorageDownloader, IpfsDownloaderOptions, SingleDownloadOptions } from "../../types";

private clientId?;
private defaultTimeout;
constructor(options: IpfsDownloaderOptions);

@@ -28,0 +29,0 @@ download(uri: string, gatewayUrls: GatewayUrls, options?: SingleDownloadOptions, attempts?: number): Promise<Response>;

@@ -89,3 +89,3 @@ import { GatewayUrls, IThirdwebStorage, IpfsUploadBatchOptions, SingleDownloadOptions, ThirdwebStorageOptions, UploadOptions } from "../types";

* @param options - Options to pass through to the storage uploader class
* @returns - The URI of the uploaded data
* @returns The URI of the uploaded data
*

@@ -110,3 +110,3 @@ * @example

* @param options - Options to pass through to the storage uploader class
* @returns - The URIs of the uploaded data
* @returns The URIs of the uploaded data
*

@@ -113,0 +113,0 @@ * @example

@@ -28,2 +28,6 @@ /**

clientId?: string;
/**
* Optional timeout in seconds for the download request, overrides the default timeout
*/
timeoutInSeconds?: number;
};

@@ -30,0 +34,0 @@ export type SingleDownloadOptions = {

@@ -6,3 +6,3 @@ 'use strict';

var CIDTool = require('cid-tool');
var fetch = require('cross-fetch');
var crypto = require('@thirdweb-dev/crypto');
var FormData = require('form-data');

@@ -14,3 +14,2 @@ var uuid = require('uuid');

var CIDTool__default = /*#__PURE__*/_interopDefault(CIDTool);
var fetch__default = /*#__PURE__*/_interopDefault(fetch);
var FormData__default = /*#__PURE__*/_interopDefault(FormData);

@@ -34,3 +33,3 @@

* @internal
* @param url
* @param url - the url to check
* @returns

@@ -129,6 +128,3 @@ */

}
// this is on purpose because we're using the crypto module only in node
// eslint-disable-next-line @typescript-eslint/no-var-requires
const crypto = require("crypto");
const hashedSecretKey = crypto.createHash("sha256").update(secretKey).digest("hex");
const hashedSecretKey = crypto.sha256HexSync(secretKey);
const derivedClientId = hashedSecretKey.slice(0, 32);

@@ -282,3 +278,9 @@ return url.replace("{clientId}", derivedClientId);

const path = uri.replace(scheme, "");
return getGatewayUrlForCid(schemeGatewayUrls[index], path, clientId);
try {
const gatewayUrl = getGatewayUrlForCid(schemeGatewayUrls[index], path, clientId);
return gatewayUrl;
} catch (err) {
console.warn(`The IPFS uri: ${path} is not valid.`);
return undefined;
}
}

@@ -389,14 +391,8 @@

name: "@thirdweb-dev/storage",
version: "1.2.8",
version: "2.0.7",
main: "dist/thirdweb-dev-storage.cjs.js",
module: "dist/thirdweb-dev-storage.esm.js",
browser: {
"./dist/thirdweb-dev-storage.esm.js": "./dist/thirdweb-dev-storage.browser.esm.js"
},
exports: {
".": {
module: {
browser: "./dist/thirdweb-dev-storage.browser.esm.js",
"default": "./dist/thirdweb-dev-storage.esm.js"
},
module: "./dist/thirdweb-dev-storage.esm.js",
"default": "./dist/thirdweb-dev-storage.cjs.js"

@@ -412,3 +408,3 @@ },

format: "prettier --write 'src/**/*'",
lint: "eslint src/",
lint: "eslint src/ && bunx publint --strict --level warning",
fix: "eslint src/ --fix",

@@ -421,3 +417,4 @@ "generate-docs": "api-extractor run --local && api-documenter markdown -i ./temp -o ./docs",

"test:single": "NODE_ENV=test SWC_NODE_PROJECT=./tsconfig.test.json mocha --timeout 30000",
push: "yalc push"
push: "yalc push",
typedoc: "node scripts/typedoc.mjs"
},

@@ -428,7 +425,3 @@ files: [

preconstruct: {
exports: {
envConditions: [
"browser"
]
}
exports: true
},

@@ -446,3 +439,3 @@ devDependencies: {

"@types/mocha": "^10.0.0",
"@types/uuid": "^9.0.2",
"@types/uuid": "^9.0.5",
"@typescript-eslint/eslint-plugin": "^6.2.0",

@@ -453,11 +446,17 @@ "@typescript-eslint/parser": "^6.2.0",

"eslint-config-thirdweb": "workspace:*",
"eslint-plugin-tsdoc": "^0.2.16",
esm: "^3.2.25",
mocha: "^10.2.0",
typescript: "^5.1.6"
rimraf: "^3.0.2",
typescript: "^5.1.6",
"typedoc-gen": "workspace:*"
},
dependencies: {
"cid-tool": "^3.0.0",
"cross-fetch": "^3.1.8",
"form-data": "^4.0.0",
uuid: "^9.0.0"
uuid: "^9.0.1",
"@thirdweb-dev/crypto": "workspace:*"
},
engines: {
node: ">=18"
}

@@ -486,3 +485,3 @@ };

class StorageDownloader {
DEFAULT_TIMEOUT_IN_SECONDS = 30;
DEFAULT_TIMEOUT_IN_SECONDS = 60;
DEFAULT_MAX_RETRIES = 3;

@@ -492,2 +491,3 @@ constructor(options) {

this.clientId = options.clientId;
this.defaultTimeout = options.timeoutInSeconds || this.DEFAULT_TIMEOUT_IN_SECONDS;
}

@@ -500,3 +500,3 @@ async download(uri, gatewayUrls, options) {

// return a 404 response to avoid retrying
return new fetch.Response(JSON.stringify({
return new Response(JSON.stringify({
error: "Not Found"

@@ -516,3 +516,3 @@ }), {

console.error("[FAILED_TO_DOWNLOAD_ERROR] Unable to download from URI - all gateway URLs failed to respond.");
return new fetch.Response(JSON.stringify({
return new Response(JSON.stringify({
error: "Not Found"

@@ -545,9 +545,15 @@ }), {

...headers,
authorization: `Bearer ${globalThis.TW_AUTH_TOKEN}`,
"x-authorize-wallet": 'true'
authorization: `Bearer ${globalThis.TW_AUTH_TOKEN}`
};
}
if (typeof globalThis !== "undefined" && "TW_CLI_AUTH_TOKEN" in globalThis && typeof globalThis.TW_CLI_AUTH_TOKEN === "string") {
headers = {
...headers,
authorization: `Bearer ${globalThis.TW_CLI_AUTH_TOKEN}`
};
headers["x-authorize-wallet"] = "true";
}
headers["x-sdk-version"] = pkg.version;
headers["x-sdk-name"] = pkg.name;
headers["x-sdk-platform"] = bundleId ? "react-native" : isBrowser() ? "browser" : "node";
headers["x-sdk-platform"] = bundleId ? "react-native" : isBrowser() ? window.bridge !== undefined ? "webGL" : "browser" : "node";
}

@@ -559,5 +565,5 @@ if (isTooManyRequests(resolvedUri)) {

const controller = new AbortController();
const timeoutInSeconds = options?.timeoutInSeconds || this.DEFAULT_TIMEOUT_IN_SECONDS;
const timeoutInSeconds = options?.timeoutInSeconds || this.defaultTimeout;
const timeout = setTimeout(() => controller.abort(), timeoutInSeconds * 1000);
const resOrErr = await fetch__default["default"](resolvedUri, {
const resOrErr = await fetch(resolvedUri, {
headers,

@@ -833,7 +839,12 @@ signal: controller.signal

xhr.setRequestHeader("x-sdk-name", pkg.name);
xhr.setRequestHeader("x-sdk-platform", bundleId ? "react-native" : isBrowser() ? "browser" : "node");
xhr.setRequestHeader("x-sdk-platform", bundleId ? "react-native" : isBrowser() ? window.bridge !== undefined ? "webGL" : "browser" : "node");
// if we have a authorization token on global context then add that to the headers
// if we have a authorization token on global context then add that to the headers, this is for the dashboard.
if (typeof globalThis !== "undefined" && "TW_AUTH_TOKEN" in globalThis && typeof globalThis.TW_AUTH_TOKEN === "string") {
xhr.setRequestHeader("authorization", `Bearer ${globalThis.TW_AUTH_TOKEN}`);
}
// CLI auth token
if (typeof globalThis !== "undefined" && "TW_CLI_AUTH_TOKEN" in globalThis && typeof globalThis.TW_CLI_AUTH_TOKEN === "string") {
xhr.setRequestHeader("authorization", `Bearer ${globalThis.TW_CLI_AUTH_TOKEN}`);
xhr.setRequestHeader("x-authorize-wallet", `true`);

@@ -860,8 +871,13 @@ }

// if we have a authorization token on global context then add that to the headers
// if we have a authorization token on global context then add that to the headers, this is for the dashboard.
if (typeof globalThis !== "undefined" && "TW_AUTH_TOKEN" in globalThis && typeof globalThis.TW_AUTH_TOKEN === "string") {
headers["authorization"] = `Bearer ${globalThis.TW_AUTH_TOKEN}`;
}
// CLI auth token
if (typeof globalThis !== "undefined" && "TW_CLI_AUTH_TOKEN" in globalThis && typeof globalThis.TW_CLI_AUTH_TOKEN === "string") {
headers["authorization"] = `Bearer ${globalThis.TW_CLI_AUTH_TOKEN}`;
headers["x-authorize-wallet"] = "true";
}
const res = await fetch__default["default"](`${this.uploadServerUrl}/ipfs/upload`, {
const res = await fetch(`${this.uploadServerUrl}/ipfs/upload`, {
method: "POST",

@@ -878,3 +894,3 @@ headers: {

}
throw new Error("Failed to upload files to IPFS");
throw new Error(`Failed to upload files to IPFS - ${res.status} - ${res.statusText} - ${await res.text()}`);
}

@@ -884,3 +900,3 @@ const body = await res.json();

if (!cid) {
throw new Error("Failed to upload files to IPFS");
throw new Error("Failed to upload files to IPFS - Bad CID");
}

@@ -1004,3 +1020,3 @@ if (options?.uploadWithoutDirectory) {

* @param options - Options to pass through to the storage uploader class
* @returns - The URI of the uploaded data
* @returns The URI of the uploaded data
*

@@ -1029,3 +1045,3 @@ * @example

* @param options - Options to pass through to the storage uploader class
* @returns - The URIs of the uploaded data
* @returns The URIs of the uploaded data
*

@@ -1032,0 +1048,0 @@ * @example

@@ -6,3 +6,3 @@ 'use strict';

var CIDTool = require('cid-tool');
var fetch = require('cross-fetch');
var crypto = require('@thirdweb-dev/crypto');
var FormData = require('form-data');

@@ -14,3 +14,2 @@ var uuid = require('uuid');

var CIDTool__default = /*#__PURE__*/_interopDefault(CIDTool);
var fetch__default = /*#__PURE__*/_interopDefault(fetch);
var FormData__default = /*#__PURE__*/_interopDefault(FormData);

@@ -34,3 +33,3 @@

* @internal
* @param url
* @param url - the url to check
* @returns

@@ -129,6 +128,3 @@ */

}
// this is on purpose because we're using the crypto module only in node
// eslint-disable-next-line @typescript-eslint/no-var-requires
const crypto = require("crypto");
const hashedSecretKey = crypto.createHash("sha256").update(secretKey).digest("hex");
const hashedSecretKey = crypto.sha256HexSync(secretKey);
const derivedClientId = hashedSecretKey.slice(0, 32);

@@ -282,3 +278,9 @@ return url.replace("{clientId}", derivedClientId);

const path = uri.replace(scheme, "");
return getGatewayUrlForCid(schemeGatewayUrls[index], path, clientId);
try {
const gatewayUrl = getGatewayUrlForCid(schemeGatewayUrls[index], path, clientId);
return gatewayUrl;
} catch (err) {
console.warn(`The IPFS uri: ${path} is not valid.`);
return undefined;
}
}

@@ -389,14 +391,8 @@

name: "@thirdweb-dev/storage",
version: "1.2.8",
version: "2.0.7",
main: "dist/thirdweb-dev-storage.cjs.js",
module: "dist/thirdweb-dev-storage.esm.js",
browser: {
"./dist/thirdweb-dev-storage.esm.js": "./dist/thirdweb-dev-storage.browser.esm.js"
},
exports: {
".": {
module: {
browser: "./dist/thirdweb-dev-storage.browser.esm.js",
"default": "./dist/thirdweb-dev-storage.esm.js"
},
module: "./dist/thirdweb-dev-storage.esm.js",
"default": "./dist/thirdweb-dev-storage.cjs.js"

@@ -412,3 +408,3 @@ },

format: "prettier --write 'src/**/*'",
lint: "eslint src/",
lint: "eslint src/ && bunx publint --strict --level warning",
fix: "eslint src/ --fix",

@@ -421,3 +417,4 @@ "generate-docs": "api-extractor run --local && api-documenter markdown -i ./temp -o ./docs",

"test:single": "NODE_ENV=test SWC_NODE_PROJECT=./tsconfig.test.json mocha --timeout 30000",
push: "yalc push"
push: "yalc push",
typedoc: "node scripts/typedoc.mjs"
},

@@ -428,7 +425,3 @@ files: [

preconstruct: {
exports: {
envConditions: [
"browser"
]
}
exports: true
},

@@ -446,3 +439,3 @@ devDependencies: {

"@types/mocha": "^10.0.0",
"@types/uuid": "^9.0.2",
"@types/uuid": "^9.0.5",
"@typescript-eslint/eslint-plugin": "^6.2.0",

@@ -453,11 +446,17 @@ "@typescript-eslint/parser": "^6.2.0",

"eslint-config-thirdweb": "workspace:*",
"eslint-plugin-tsdoc": "^0.2.16",
esm: "^3.2.25",
mocha: "^10.2.0",
typescript: "^5.1.6"
rimraf: "^3.0.2",
typescript: "^5.1.6",
"typedoc-gen": "workspace:*"
},
dependencies: {
"cid-tool": "^3.0.0",
"cross-fetch": "^3.1.8",
"form-data": "^4.0.0",
uuid: "^9.0.0"
uuid: "^9.0.1",
"@thirdweb-dev/crypto": "workspace:*"
},
engines: {
node: ">=18"
}

@@ -486,3 +485,3 @@ };

class StorageDownloader {
DEFAULT_TIMEOUT_IN_SECONDS = 30;
DEFAULT_TIMEOUT_IN_SECONDS = 60;
DEFAULT_MAX_RETRIES = 3;

@@ -492,2 +491,3 @@ constructor(options) {

this.clientId = options.clientId;
this.defaultTimeout = options.timeoutInSeconds || this.DEFAULT_TIMEOUT_IN_SECONDS;
}

@@ -500,3 +500,3 @@ async download(uri, gatewayUrls, options) {

// return a 404 response to avoid retrying
return new fetch.Response(JSON.stringify({
return new Response(JSON.stringify({
error: "Not Found"

@@ -516,3 +516,3 @@ }), {

console.error("[FAILED_TO_DOWNLOAD_ERROR] Unable to download from URI - all gateway URLs failed to respond.");
return new fetch.Response(JSON.stringify({
return new Response(JSON.stringify({
error: "Not Found"

@@ -545,9 +545,15 @@ }), {

...headers,
authorization: `Bearer ${globalThis.TW_AUTH_TOKEN}`,
"x-authorize-wallet": 'true'
authorization: `Bearer ${globalThis.TW_AUTH_TOKEN}`
};
}
if (typeof globalThis !== "undefined" && "TW_CLI_AUTH_TOKEN" in globalThis && typeof globalThis.TW_CLI_AUTH_TOKEN === "string") {
headers = {
...headers,
authorization: `Bearer ${globalThis.TW_CLI_AUTH_TOKEN}`
};
headers["x-authorize-wallet"] = "true";
}
headers["x-sdk-version"] = pkg.version;
headers["x-sdk-name"] = pkg.name;
headers["x-sdk-platform"] = bundleId ? "react-native" : isBrowser() ? "browser" : "node";
headers["x-sdk-platform"] = bundleId ? "react-native" : isBrowser() ? window.bridge !== undefined ? "webGL" : "browser" : "node";
}

@@ -559,5 +565,5 @@ if (isTooManyRequests(resolvedUri)) {

const controller = new AbortController();
const timeoutInSeconds = options?.timeoutInSeconds || this.DEFAULT_TIMEOUT_IN_SECONDS;
const timeoutInSeconds = options?.timeoutInSeconds || this.defaultTimeout;
const timeout = setTimeout(() => controller.abort(), timeoutInSeconds * 1000);
const resOrErr = await fetch__default["default"](resolvedUri, {
const resOrErr = await fetch(resolvedUri, {
headers,

@@ -833,7 +839,12 @@ signal: controller.signal

xhr.setRequestHeader("x-sdk-name", pkg.name);
xhr.setRequestHeader("x-sdk-platform", bundleId ? "react-native" : isBrowser() ? "browser" : "node");
xhr.setRequestHeader("x-sdk-platform", bundleId ? "react-native" : isBrowser() ? window.bridge !== undefined ? "webGL" : "browser" : "node");
// if we have a authorization token on global context then add that to the headers
// if we have a authorization token on global context then add that to the headers, this is for the dashboard.
if (typeof globalThis !== "undefined" && "TW_AUTH_TOKEN" in globalThis && typeof globalThis.TW_AUTH_TOKEN === "string") {
xhr.setRequestHeader("authorization", `Bearer ${globalThis.TW_AUTH_TOKEN}`);
}
// CLI auth token
if (typeof globalThis !== "undefined" && "TW_CLI_AUTH_TOKEN" in globalThis && typeof globalThis.TW_CLI_AUTH_TOKEN === "string") {
xhr.setRequestHeader("authorization", `Bearer ${globalThis.TW_CLI_AUTH_TOKEN}`);
xhr.setRequestHeader("x-authorize-wallet", `true`);

@@ -860,8 +871,13 @@ }

// if we have a authorization token on global context then add that to the headers
// if we have a authorization token on global context then add that to the headers, this is for the dashboard.
if (typeof globalThis !== "undefined" && "TW_AUTH_TOKEN" in globalThis && typeof globalThis.TW_AUTH_TOKEN === "string") {
headers["authorization"] = `Bearer ${globalThis.TW_AUTH_TOKEN}`;
}
// CLI auth token
if (typeof globalThis !== "undefined" && "TW_CLI_AUTH_TOKEN" in globalThis && typeof globalThis.TW_CLI_AUTH_TOKEN === "string") {
headers["authorization"] = `Bearer ${globalThis.TW_CLI_AUTH_TOKEN}`;
headers["x-authorize-wallet"] = "true";
}
const res = await fetch__default["default"](`${this.uploadServerUrl}/ipfs/upload`, {
const res = await fetch(`${this.uploadServerUrl}/ipfs/upload`, {
method: "POST",

@@ -878,3 +894,3 @@ headers: {

}
throw new Error("Failed to upload files to IPFS");
throw new Error(`Failed to upload files to IPFS - ${res.status} - ${res.statusText} - ${await res.text()}`);
}

@@ -884,3 +900,3 @@ const body = await res.json();

if (!cid) {
throw new Error("Failed to upload files to IPFS");
throw new Error("Failed to upload files to IPFS - Bad CID");
}

@@ -1004,3 +1020,3 @@ if (options?.uploadWithoutDirectory) {

* @param options - Options to pass through to the storage uploader class
* @returns - The URI of the uploaded data
* @returns The URI of the uploaded data
*

@@ -1029,3 +1045,3 @@ * @example

* @param options - Options to pass through to the storage uploader class
* @returns - The URIs of the uploaded data
* @returns The URIs of the uploaded data
*

@@ -1032,0 +1048,0 @@ * @example

import CIDTool from 'cid-tool';
import fetch, { Response } from 'cross-fetch';
import { sha256HexSync } from '@thirdweb-dev/crypto';
import FormData from 'form-data';

@@ -22,3 +22,3 @@ import { v4 } from 'uuid';

* @internal
* @param url
* @param url - the url to check
* @returns

@@ -117,6 +117,3 @@ */

}
// this is on purpose because we're using the crypto module only in node
// eslint-disable-next-line @typescript-eslint/no-var-requires
const crypto = require("crypto");
const hashedSecretKey = crypto.createHash("sha256").update(secretKey).digest("hex");
const hashedSecretKey = sha256HexSync(secretKey);
const derivedClientId = hashedSecretKey.slice(0, 32);

@@ -270,3 +267,9 @@ return url.replace("{clientId}", derivedClientId);

const path = uri.replace(scheme, "");
return getGatewayUrlForCid(schemeGatewayUrls[index], path, clientId);
try {
const gatewayUrl = getGatewayUrlForCid(schemeGatewayUrls[index], path, clientId);
return gatewayUrl;
} catch (err) {
console.warn(`The IPFS uri: ${path} is not valid.`);
return undefined;
}
}

@@ -377,14 +380,8 @@

name: "@thirdweb-dev/storage",
version: "1.2.8",
version: "2.0.7",
main: "dist/thirdweb-dev-storage.cjs.js",
module: "dist/thirdweb-dev-storage.esm.js",
browser: {
"./dist/thirdweb-dev-storage.esm.js": "./dist/thirdweb-dev-storage.browser.esm.js"
},
exports: {
".": {
module: {
browser: "./dist/thirdweb-dev-storage.browser.esm.js",
"default": "./dist/thirdweb-dev-storage.esm.js"
},
module: "./dist/thirdweb-dev-storage.esm.js",
"default": "./dist/thirdweb-dev-storage.cjs.js"

@@ -400,3 +397,3 @@ },

format: "prettier --write 'src/**/*'",
lint: "eslint src/",
lint: "eslint src/ && bunx publint --strict --level warning",
fix: "eslint src/ --fix",

@@ -409,3 +406,4 @@ "generate-docs": "api-extractor run --local && api-documenter markdown -i ./temp -o ./docs",

"test:single": "NODE_ENV=test SWC_NODE_PROJECT=./tsconfig.test.json mocha --timeout 30000",
push: "yalc push"
push: "yalc push",
typedoc: "node scripts/typedoc.mjs"
},

@@ -416,7 +414,3 @@ files: [

preconstruct: {
exports: {
envConditions: [
"browser"
]
}
exports: true
},

@@ -434,3 +428,3 @@ devDependencies: {

"@types/mocha": "^10.0.0",
"@types/uuid": "^9.0.2",
"@types/uuid": "^9.0.5",
"@typescript-eslint/eslint-plugin": "^6.2.0",

@@ -441,11 +435,17 @@ "@typescript-eslint/parser": "^6.2.0",

"eslint-config-thirdweb": "workspace:*",
"eslint-plugin-tsdoc": "^0.2.16",
esm: "^3.2.25",
mocha: "^10.2.0",
typescript: "^5.1.6"
rimraf: "^3.0.2",
typescript: "^5.1.6",
"typedoc-gen": "workspace:*"
},
dependencies: {
"cid-tool": "^3.0.0",
"cross-fetch": "^3.1.8",
"form-data": "^4.0.0",
uuid: "^9.0.0"
uuid: "^9.0.1",
"@thirdweb-dev/crypto": "workspace:*"
},
engines: {
node: ">=18"
}

@@ -474,3 +474,3 @@ };

class StorageDownloader {
DEFAULT_TIMEOUT_IN_SECONDS = 30;
DEFAULT_TIMEOUT_IN_SECONDS = 60;
DEFAULT_MAX_RETRIES = 3;

@@ -480,2 +480,3 @@ constructor(options) {

this.clientId = options.clientId;
this.defaultTimeout = options.timeoutInSeconds || this.DEFAULT_TIMEOUT_IN_SECONDS;
}

@@ -531,9 +532,15 @@ async download(uri, gatewayUrls, options) {

...headers,
authorization: `Bearer ${globalThis.TW_AUTH_TOKEN}`,
"x-authorize-wallet": 'true'
authorization: `Bearer ${globalThis.TW_AUTH_TOKEN}`
};
}
if (typeof globalThis !== "undefined" && "TW_CLI_AUTH_TOKEN" in globalThis && typeof globalThis.TW_CLI_AUTH_TOKEN === "string") {
headers = {
...headers,
authorization: `Bearer ${globalThis.TW_CLI_AUTH_TOKEN}`
};
headers["x-authorize-wallet"] = "true";
}
headers["x-sdk-version"] = pkg.version;
headers["x-sdk-name"] = pkg.name;
headers["x-sdk-platform"] = bundleId ? "react-native" : isBrowser() ? "browser" : "node";
headers["x-sdk-platform"] = bundleId ? "react-native" : isBrowser() ? window.bridge !== undefined ? "webGL" : "browser" : "node";
}

@@ -545,3 +552,3 @@ if (isTooManyRequests(resolvedUri)) {

const controller = new AbortController();
const timeoutInSeconds = options?.timeoutInSeconds || this.DEFAULT_TIMEOUT_IN_SECONDS;
const timeoutInSeconds = options?.timeoutInSeconds || this.defaultTimeout;
const timeout = setTimeout(() => controller.abort(), timeoutInSeconds * 1000);

@@ -819,7 +826,12 @@ const resOrErr = await fetch(resolvedUri, {

xhr.setRequestHeader("x-sdk-name", pkg.name);
xhr.setRequestHeader("x-sdk-platform", bundleId ? "react-native" : isBrowser() ? "browser" : "node");
xhr.setRequestHeader("x-sdk-platform", bundleId ? "react-native" : isBrowser() ? window.bridge !== undefined ? "webGL" : "browser" : "node");
// if we have a authorization token on global context then add that to the headers
// if we have a authorization token on global context then add that to the headers, this is for the dashboard.
if (typeof globalThis !== "undefined" && "TW_AUTH_TOKEN" in globalThis && typeof globalThis.TW_AUTH_TOKEN === "string") {
xhr.setRequestHeader("authorization", `Bearer ${globalThis.TW_AUTH_TOKEN}`);
}
// CLI auth token
if (typeof globalThis !== "undefined" && "TW_CLI_AUTH_TOKEN" in globalThis && typeof globalThis.TW_CLI_AUTH_TOKEN === "string") {
xhr.setRequestHeader("authorization", `Bearer ${globalThis.TW_CLI_AUTH_TOKEN}`);
xhr.setRequestHeader("x-authorize-wallet", `true`);

@@ -846,5 +858,10 @@ }

// if we have a authorization token on global context then add that to the headers
// if we have a authorization token on global context then add that to the headers, this is for the dashboard.
if (typeof globalThis !== "undefined" && "TW_AUTH_TOKEN" in globalThis && typeof globalThis.TW_AUTH_TOKEN === "string") {
headers["authorization"] = `Bearer ${globalThis.TW_AUTH_TOKEN}`;
}
// CLI auth token
if (typeof globalThis !== "undefined" && "TW_CLI_AUTH_TOKEN" in globalThis && typeof globalThis.TW_CLI_AUTH_TOKEN === "string") {
headers["authorization"] = `Bearer ${globalThis.TW_CLI_AUTH_TOKEN}`;
headers["x-authorize-wallet"] = "true";

@@ -864,3 +881,3 @@ }

}
throw new Error("Failed to upload files to IPFS");
throw new Error(`Failed to upload files to IPFS - ${res.status} - ${res.statusText} - ${await res.text()}`);
}

@@ -870,3 +887,3 @@ const body = await res.json();

if (!cid) {
throw new Error("Failed to upload files to IPFS");
throw new Error("Failed to upload files to IPFS - Bad CID");
}

@@ -990,3 +1007,3 @@ if (options?.uploadWithoutDirectory) {

* @param options - Options to pass through to the storage uploader class
* @returns - The URI of the uploaded data
* @returns The URI of the uploaded data
*

@@ -1015,3 +1032,3 @@ * @example

* @param options - Options to pass through to the storage uploader class
* @returns - The URIs of the uploaded data
* @returns The URIs of the uploaded data
*

@@ -1018,0 +1035,0 @@ * @example

{
"name": "@thirdweb-dev/storage",
"version": "0.0.0-dev-25f5da4-20230828234008",
"version": "0.0.0-dev-2644666-20231219000747",
"main": "dist/thirdweb-dev-storage.cjs.js",
"module": "dist/thirdweb-dev-storage.esm.js",
"browser": {
"./dist/thirdweb-dev-storage.esm.js": "./dist/thirdweb-dev-storage.browser.esm.js"
},
"exports": {
".": {
"module": {
"browser": "./dist/thirdweb-dev-storage.browser.esm.js",
"default": "./dist/thirdweb-dev-storage.esm.js"
},
"module": "./dist/thirdweb-dev-storage.esm.js",
"default": "./dist/thirdweb-dev-storage.cjs.js"

@@ -27,7 +21,3 @@ },

"preconstruct": {
"exports": {
"envConditions": [
"browser"
]
}
"exports": true
},

@@ -45,3 +35,3 @@ "devDependencies": {

"@types/mocha": "^10.0.0",
"@types/uuid": "^9.0.2",
"@types/uuid": "^9.0.5",
"@typescript-eslint/eslint-plugin": "^6.2.0",

@@ -52,15 +42,21 @@ "@typescript-eslint/parser": "^6.2.0",

"eslint-config-thirdweb": "^0.1.6",
"eslint-plugin-tsdoc": "^0.2.16",
"esm": "^3.2.25",
"mocha": "^10.2.0",
"typescript": "^5.1.6"
"rimraf": "^3.0.2",
"typescript": "^5.1.6",
"typedoc-gen": "^1.0.1"
},
"dependencies": {
"cid-tool": "^3.0.0",
"cross-fetch": "^3.1.8",
"form-data": "^4.0.0",
"uuid": "^9.0.0"
"uuid": "^9.0.1",
"@thirdweb-dev/crypto": "0.2.0"
},
"engines": {
"node": ">=18"
},
"scripts": {
"format": "prettier --write 'src/**/*'",
"lint": "eslint src/",
"lint": "eslint src/ && bunx publint --strict --level warning",
"fix": "eslint src/ --fix",

@@ -73,4 +69,5 @@ "generate-docs": "api-extractor run --local && api-documenter markdown -i ./temp -o ./docs",

"test:single": "NODE_ENV=test SWC_NODE_PROJECT=./tsconfig.test.json mocha --timeout 30000",
"push": "yalc push"
"push": "yalc push",
"typedoc": "node scripts/typedoc.mjs"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc