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

@thirdweb-dev/storage

Package Overview
Dependencies
Maintainers
10
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.2.7 to 0.2.8-dev-065c0ba

6

dist/declarations/src/core/ipfs-storage.d.ts
import { IStorage } from "../interfaces/IStorage";
import { IStorageUpload, UploadResult } from "../interfaces/IStorageUpload";
import { FileOrBuffer, JsonObject } from "../types";
import { FileOrBuffer, JsonObject, StorageOptions } from "../types";
import { UploadProgressEvent } from "../types/events";

@@ -18,4 +18,6 @@ /**

private uploader;
constructor(gatewayUrl?: string, uploader?: IStorageUpload);
private options;
constructor(gatewayUrl?: string, uploader?: IStorageUpload, options?: StorageOptions);
private getNextPublicGateway;
private getBaseUri;
/**

@@ -22,0 +24,0 @@ * Upload a file to IPFS and return the hash

@@ -17,3 +17,3 @@ /// <reference types="node" />

*/
export declare function replaceFilePropertiesWithHashes(object: Record<string, any>, cids: string[]): Record<string, any>;
export declare function replaceFilePropertiesWithHashes(object: Record<string, any>, cids: string[], scheme: string): Record<string, any>;
/**

@@ -20,0 +20,0 @@ * Replaces all ipfs:// hashes (or any other scheme) with gateway url

@@ -5,4 +5,5 @@ export * from "./interfaces/IStorage";

export * from "./core/remote-storage";
export * from "./uploaders/pinata-uploader";
export * from "./types/index";
export { isBufferInstance, isFileInstance } from "./helpers/storage";
//# sourceMappingURL=index.d.ts.map

@@ -17,3 +17,6 @@ /// <reference types="node" />

export declare type FileBufferOrString = z.output<typeof FileBufferOrStringSchema>;
export declare type StorageOptions = {
appendGatewayUrl: boolean;
};
export {};
//# sourceMappingURL=index.d.ts.map

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

function replaceFilePropertiesWithHashes(object, cids) {
function replaceFilePropertiesWithHashes(object, cids, scheme) {
const keys = Object.keys(object);

@@ -77,3 +77,3 @@

if (typeof val === "object" && !isFile) {
replaceFilePropertiesWithHashes(val, cids);
replaceFilePropertiesWithHashes(val, cids, scheme);
continue;

@@ -86,3 +86,3 @@ }

object[keys[key]] = "ipfs://".concat(cids.splice(0, 1)[0]);
object[keys[key]] = "".concat(scheme).concat(cids.splice(0, 1)[0]);
}

@@ -396,2 +396,3 @@

let uploader = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new PinataUploader();
let options = arguments.length > 2 ? arguments[2] : undefined;

@@ -404,4 +405,7 @@ _defineProperty(this, "gatewayUrl", void 0);

_defineProperty(this, "options", void 0);
this.gatewayUrl = "".concat(gatewayUrl.replace(/\/$/, ""), "/");
this.uploader = uploader;
this.options = options;
}

@@ -419,2 +423,12 @@

}
getBaseUri() {
var _this$options;
if ((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.appendGatewayUrl) {
return this.gatewayUrl;
} else {
return "ipfs://";
}
}
/**

@@ -438,3 +452,3 @@ * Upload a file to IPFS and return the hash

} = await this.uploader.uploadBatchWithCid([data], 0, contractAddress, signerAddress, options);
const baseUri = "ipfs://".concat(cid, "/");
const baseUri = "".concat(this.getBaseUri()).concat(cid, "/");
return "".concat(baseUri).concat(fileNames[0]);

@@ -456,3 +470,3 @@ }

} = await this.uploader.uploadBatchWithCid(files, fileStartNumber, contractAddress, signerAddress, options);
const baseUri = "ipfs://".concat(cid, "/");
const baseUri = "".concat(this.getBaseUri()).concat(cid, "/");
const uris = fileNames.map(filename => "".concat(baseUri).concat(filename));

@@ -506,3 +520,3 @@ return {

} = await this.uploader.uploadBatchWithCid(metadataToUpload, fileStartNumber, contractAddress, signerAddress);
const baseUri = "ipfs://".concat(cid, "/");
const baseUri = "".concat(this.getBaseUri()).concat(cid, "/");
const uris = fileNames.map(filename => "".concat(baseUri).concat(filename));

@@ -562,3 +576,3 @@ return {

// replace all active gateway url links with their raw ipfs hash
const sanitizedMetadatas = replaceGatewayUrlWithHash(metadatas, "ipfs://", this.gatewayUrl); // extract any binary file to upload
const sanitizedMetadatas = replaceGatewayUrlWithHash(metadatas, this.getBaseUri(), this.gatewayUrl); // extract any binary file to upload

@@ -583,3 +597,3 @@ const filesToUpload = sanitizedMetadatas.flatMap(m => this.buildFilePropertiesMap(m, [])); // if no binary files to upload, return the metadata

return replaceFilePropertiesWithHashes(sanitizedMetadatas, cids);
return replaceFilePropertiesWithHashes(sanitizedMetadatas, cids, this.getBaseUri());
}

@@ -765,2 +779,3 @@ /**

exports.IpfsStorage = IpfsStorage;
exports.PinataUploader = PinataUploader;
exports.RemoteStorage = RemoteStorage;

@@ -767,0 +782,0 @@ exports.isBrowser = isBrowser;

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

function replaceFilePropertiesWithHashes(object, cids) {
function replaceFilePropertiesWithHashes(object, cids, scheme) {
const keys = Object.keys(object);

@@ -77,3 +77,3 @@

if (typeof val === "object" && !isFile) {
replaceFilePropertiesWithHashes(val, cids);
replaceFilePropertiesWithHashes(val, cids, scheme);
continue;

@@ -86,3 +86,3 @@ }

object[keys[key]] = "ipfs://".concat(cids.splice(0, 1)[0]);
object[keys[key]] = "".concat(scheme).concat(cids.splice(0, 1)[0]);
}

@@ -396,2 +396,3 @@

let uploader = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new PinataUploader();
let options = arguments.length > 2 ? arguments[2] : undefined;

@@ -404,4 +405,7 @@ _defineProperty(this, "gatewayUrl", void 0);

_defineProperty(this, "options", void 0);
this.gatewayUrl = "".concat(gatewayUrl.replace(/\/$/, ""), "/");
this.uploader = uploader;
this.options = options;
}

@@ -419,2 +423,12 @@

}
getBaseUri() {
var _this$options;
if ((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.appendGatewayUrl) {
return this.gatewayUrl;
} else {
return "ipfs://";
}
}
/**

@@ -438,3 +452,3 @@ * Upload a file to IPFS and return the hash

} = await this.uploader.uploadBatchWithCid([data], 0, contractAddress, signerAddress, options);
const baseUri = "ipfs://".concat(cid, "/");
const baseUri = "".concat(this.getBaseUri()).concat(cid, "/");
return "".concat(baseUri).concat(fileNames[0]);

@@ -456,3 +470,3 @@ }

} = await this.uploader.uploadBatchWithCid(files, fileStartNumber, contractAddress, signerAddress, options);
const baseUri = "ipfs://".concat(cid, "/");
const baseUri = "".concat(this.getBaseUri()).concat(cid, "/");
const uris = fileNames.map(filename => "".concat(baseUri).concat(filename));

@@ -506,3 +520,3 @@ return {

} = await this.uploader.uploadBatchWithCid(metadataToUpload, fileStartNumber, contractAddress, signerAddress);
const baseUri = "ipfs://".concat(cid, "/");
const baseUri = "".concat(this.getBaseUri()).concat(cid, "/");
const uris = fileNames.map(filename => "".concat(baseUri).concat(filename));

@@ -562,3 +576,3 @@ return {

// replace all active gateway url links with their raw ipfs hash
const sanitizedMetadatas = replaceGatewayUrlWithHash(metadatas, "ipfs://", this.gatewayUrl); // extract any binary file to upload
const sanitizedMetadatas = replaceGatewayUrlWithHash(metadatas, this.getBaseUri(), this.gatewayUrl); // extract any binary file to upload

@@ -583,3 +597,3 @@ const filesToUpload = sanitizedMetadatas.flatMap(m => this.buildFilePropertiesMap(m, [])); // if no binary files to upload, return the metadata

return replaceFilePropertiesWithHashes(sanitizedMetadatas, cids);
return replaceFilePropertiesWithHashes(sanitizedMetadatas, cids, this.getBaseUri());
}

@@ -765,2 +779,3 @@ /**

exports.IpfsStorage = IpfsStorage;
exports.PinataUploader = PinataUploader;
exports.RemoteStorage = RemoteStorage;

@@ -767,0 +782,0 @@ exports.isBrowser = isBrowser;

@@ -59,3 +59,3 @@ import fetch from 'cross-fetch';

function replaceFilePropertiesWithHashes(object, cids) {
function replaceFilePropertiesWithHashes(object, cids, scheme) {
const keys = Object.keys(object);

@@ -68,3 +68,3 @@

if (typeof val === "object" && !isFile) {
replaceFilePropertiesWithHashes(val, cids);
replaceFilePropertiesWithHashes(val, cids, scheme);
continue;

@@ -77,3 +77,3 @@ }

object[keys[key]] = "ipfs://".concat(cids.splice(0, 1)[0]);
object[keys[key]] = "".concat(scheme).concat(cids.splice(0, 1)[0]);
}

@@ -387,2 +387,3 @@

let uploader = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new PinataUploader();
let options = arguments.length > 2 ? arguments[2] : undefined;

@@ -395,4 +396,7 @@ _defineProperty(this, "gatewayUrl", void 0);

_defineProperty(this, "options", void 0);
this.gatewayUrl = "".concat(gatewayUrl.replace(/\/$/, ""), "/");
this.uploader = uploader;
this.options = options;
}

@@ -410,2 +414,12 @@

}
getBaseUri() {
var _this$options;
if ((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.appendGatewayUrl) {
return this.gatewayUrl;
} else {
return "ipfs://";
}
}
/**

@@ -429,3 +443,3 @@ * Upload a file to IPFS and return the hash

} = await this.uploader.uploadBatchWithCid([data], 0, contractAddress, signerAddress, options);
const baseUri = "ipfs://".concat(cid, "/");
const baseUri = "".concat(this.getBaseUri()).concat(cid, "/");
return "".concat(baseUri).concat(fileNames[0]);

@@ -447,3 +461,3 @@ }

} = await this.uploader.uploadBatchWithCid(files, fileStartNumber, contractAddress, signerAddress, options);
const baseUri = "ipfs://".concat(cid, "/");
const baseUri = "".concat(this.getBaseUri()).concat(cid, "/");
const uris = fileNames.map(filename => "".concat(baseUri).concat(filename));

@@ -497,3 +511,3 @@ return {

} = await this.uploader.uploadBatchWithCid(metadataToUpload, fileStartNumber, contractAddress, signerAddress);
const baseUri = "ipfs://".concat(cid, "/");
const baseUri = "".concat(this.getBaseUri()).concat(cid, "/");
const uris = fileNames.map(filename => "".concat(baseUri).concat(filename));

@@ -553,3 +567,3 @@ return {

// replace all active gateway url links with their raw ipfs hash
const sanitizedMetadatas = replaceGatewayUrlWithHash(metadatas, "ipfs://", this.gatewayUrl); // extract any binary file to upload
const sanitizedMetadatas = replaceGatewayUrlWithHash(metadatas, this.getBaseUri(), this.gatewayUrl); // extract any binary file to upload

@@ -574,3 +588,3 @@ const filesToUpload = sanitizedMetadatas.flatMap(m => this.buildFilePropertiesMap(m, [])); // if no binary files to upload, return the metadata

return replaceFilePropertiesWithHashes(sanitizedMetadatas, cids);
return replaceFilePropertiesWithHashes(sanitizedMetadatas, cids, this.getBaseUri());
}

@@ -754,2 +768,2 @@ /**

export { FileBufferOrStringSchema, IpfsStorage, RemoteStorage, isBrowser, isBufferInstance, isFileInstance };
export { FileBufferOrStringSchema, IpfsStorage, PinataUploader, RemoteStorage, isBrowser, isBufferInstance, isFileInstance };
{
"name": "@thirdweb-dev/storage",
"version": "0.2.7",
"version": "0.2.8-dev-065c0ba",
"main": "dist/thirdweb-dev-storage.cjs.js",

@@ -37,2 +37,2 @@ "module": "dist/thirdweb-dev-storage.esm.js",

}
}
}

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