@thirdweb-dev/storage
Advanced tools
Comparing version
import { GatewayUrls } from "../types"; | ||
/** | ||
* @internal | ||
* @param url | ||
* @param url - the url to check | ||
* @returns | ||
@@ -6,0 +6,0 @@ */ |
@@ -6,2 +6,3 @@ 'use strict'; | ||
var CIDTool = require('cid-tool'); | ||
var crypto = require('@thirdweb-dev/crypto'); | ||
var FormData = require('form-data'); | ||
@@ -31,3 +32,3 @@ var uuid = require('uuid'); | ||
* @internal | ||
* @param url | ||
* @param url - the url to check | ||
* @returns | ||
@@ -126,6 +127,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); | ||
@@ -149,3 +147,3 @@ return url.replace("{clientId}", derivedClientId); | ||
function convertCidToV1(cid) { | ||
let normalized = ''; | ||
let normalized; | ||
try { | ||
@@ -280,3 +278,9 @@ const hash = cid.split("/")[0]; | ||
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; | ||
} | ||
} | ||
@@ -387,14 +391,8 @@ | ||
name: "@thirdweb-dev/storage", | ||
version: "2.0.0", | ||
version: "2.0.5", | ||
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" | ||
@@ -410,3 +408,3 @@ }, | ||
format: "prettier --write 'src/**/*'", | ||
lint: "eslint src/", | ||
lint: "eslint src/ && bunx publint --strict --level warning", | ||
fix: "eslint src/ --fix", | ||
@@ -426,7 +424,3 @@ "generate-docs": "api-extractor run --local && api-documenter markdown -i ./temp -o ./docs", | ||
preconstruct: { | ||
exports: { | ||
envConditions: [ | ||
"browser" | ||
] | ||
} | ||
exports: true | ||
}, | ||
@@ -450,2 +444,3 @@ devDependencies: { | ||
"eslint-config-thirdweb": "workspace:*", | ||
"eslint-plugin-tsdoc": "^0.2.16", | ||
esm: "^3.2.25", | ||
@@ -460,3 +455,7 @@ mocha: "^10.2.0", | ||
"form-data": "^4.0.0", | ||
uuid: "^9.0.1" | ||
uuid: "^9.0.1", | ||
"@thirdweb-dev/crypto": "workspace:*" | ||
}, | ||
engines: { | ||
node: ">=18" | ||
} | ||
@@ -463,0 +462,0 @@ }; |
@@ -6,2 +6,3 @@ 'use strict'; | ||
var CIDTool = require('cid-tool'); | ||
var crypto = require('@thirdweb-dev/crypto'); | ||
var FormData = require('form-data'); | ||
@@ -31,3 +32,3 @@ var uuid = require('uuid'); | ||
* @internal | ||
* @param url | ||
* @param url - the url to check | ||
* @returns | ||
@@ -126,6 +127,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); | ||
@@ -149,3 +147,3 @@ return url.replace("{clientId}", derivedClientId); | ||
function convertCidToV1(cid) { | ||
let normalized = ''; | ||
let normalized; | ||
try { | ||
@@ -280,3 +278,9 @@ const hash = cid.split("/")[0]; | ||
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; | ||
} | ||
} | ||
@@ -387,14 +391,8 @@ | ||
name: "@thirdweb-dev/storage", | ||
version: "2.0.0", | ||
version: "2.0.5", | ||
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" | ||
@@ -410,3 +408,3 @@ }, | ||
format: "prettier --write 'src/**/*'", | ||
lint: "eslint src/", | ||
lint: "eslint src/ && bunx publint --strict --level warning", | ||
fix: "eslint src/ --fix", | ||
@@ -426,7 +424,3 @@ "generate-docs": "api-extractor run --local && api-documenter markdown -i ./temp -o ./docs", | ||
preconstruct: { | ||
exports: { | ||
envConditions: [ | ||
"browser" | ||
] | ||
} | ||
exports: true | ||
}, | ||
@@ -450,2 +444,3 @@ devDependencies: { | ||
"eslint-config-thirdweb": "workspace:*", | ||
"eslint-plugin-tsdoc": "^0.2.16", | ||
esm: "^3.2.25", | ||
@@ -460,3 +455,7 @@ mocha: "^10.2.0", | ||
"form-data": "^4.0.0", | ||
uuid: "^9.0.1" | ||
uuid: "^9.0.1", | ||
"@thirdweb-dev/crypto": "workspace:*" | ||
}, | ||
engines: { | ||
node: ">=18" | ||
} | ||
@@ -463,0 +462,0 @@ }; |
import CIDTool from 'cid-tool'; | ||
import { sha256HexSync } from '@thirdweb-dev/crypto'; | ||
import FormData from 'form-data'; | ||
@@ -21,3 +22,3 @@ import { v4 } from 'uuid'; | ||
* @internal | ||
* @param url | ||
* @param url - the url to check | ||
* @returns | ||
@@ -116,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); | ||
@@ -139,3 +137,3 @@ return url.replace("{clientId}", derivedClientId); | ||
function convertCidToV1(cid) { | ||
let normalized = ''; | ||
let normalized; | ||
try { | ||
@@ -270,3 +268,9 @@ const hash = cid.split("/")[0]; | ||
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 +381,8 @@ | ||
name: "@thirdweb-dev/storage", | ||
version: "2.0.0", | ||
version: "2.0.5", | ||
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 +398,3 @@ }, | ||
format: "prettier --write 'src/**/*'", | ||
lint: "eslint src/", | ||
lint: "eslint src/ && bunx publint --strict --level warning", | ||
fix: "eslint src/ --fix", | ||
@@ -416,7 +414,3 @@ "generate-docs": "api-extractor run --local && api-documenter markdown -i ./temp -o ./docs", | ||
preconstruct: { | ||
exports: { | ||
envConditions: [ | ||
"browser" | ||
] | ||
} | ||
exports: true | ||
}, | ||
@@ -440,2 +434,3 @@ devDependencies: { | ||
"eslint-config-thirdweb": "workspace:*", | ||
"eslint-plugin-tsdoc": "^0.2.16", | ||
esm: "^3.2.25", | ||
@@ -450,3 +445,7 @@ mocha: "^10.2.0", | ||
"form-data": "^4.0.0", | ||
uuid: "^9.0.1" | ||
uuid: "^9.0.1", | ||
"@thirdweb-dev/crypto": "workspace:*" | ||
}, | ||
engines: { | ||
node: ">=18" | ||
} | ||
@@ -453,0 +452,0 @@ }; |
{ | ||
"name": "@thirdweb-dev/storage", | ||
"version": "0.0.0-dev-83c6394-20231114191948", | ||
"version": "0.0.0-dev-86d7fa8-20231130112651", | ||
"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 | ||
}, | ||
@@ -51,2 +41,3 @@ "devDependencies": { | ||
"eslint-config-thirdweb": "^0.1.6", | ||
"eslint-plugin-tsdoc": "^0.2.16", | ||
"esm": "^3.2.25", | ||
@@ -61,7 +52,11 @@ "mocha": "^10.2.0", | ||
"form-data": "^4.0.0", | ||
"uuid": "^9.0.1" | ||
"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", | ||
@@ -68,0 +63,0 @@ "generate-docs": "api-extractor run --local && api-documenter markdown -i ./temp -o ./docs", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
8
-20%6
-25%163942
-19.35%4
33.33%22
4.76%43
-2.27%3843
-22%+ Added
+ Added
+ Added
+ Added