{"version":3,"file":"lib.cjs","sources":["../../src/lib.js"],"sourcesContent":["/**\n * A client library for the https://filebase.storage/ service. It provides a convenient\n * interface for working with the [Raw HTTP API](https://filebase.storage/#api-docs)\n * from a web browser or [Node.js](https://nodejs.org/) and comes bundled with\n * TS for out-of-the box type inference and better IntelliSense.\n *\n * @example\n * ```js\n * import { FilebaseClient, File, Blob } from \"filebase.storage\"\n * const client = new FilebaseClient({ token: API_TOKEN })\n *\n * const cid = await client.storeBlob(new Blob(['hello world']))\n * ```\n * @module\n */\n\nimport { pack } from 'ipfs-car/pack'\nimport { CID } from 'multiformats/cid'\nimport * as Token from './token.js'\nimport { File, Blob, FormData, Blockstore } from './platform.js'\nimport { toGatewayURL } from './gateway.js'\nimport { BlockstoreCarReader } from './bs-car-reader.js'\nimport pipe from 'it-pipe'\nimport { Upload } from \"@aws-sdk/lib-storage\";\nimport { S3Client, HeadObjectCommand, DeleteObjectCommand } from \"@aws-sdk/client-s3\";\nimport stream from 'stream'\n\nconst MAX_STORE_RETRIES = 5\nconst MAX_CONCURRENT_UPLOADS = 4\nconst DEFAULT_ENDPOINT = 'https://s3.filebase.com'\n\n/**\n * @typedef {import('./lib/interface.js').Service} Service\n * @typedef {import('./lib/interface.js').CIDString} CIDString\n * @typedef {import('./lib/interface.js').Deal} Deal\n * @typedef {import('./lib/interface.js').FileObject} FileObject\n * @typedef {import('./lib/interface.js').FilesSource} FilesSource\n * @typedef {import('./lib/interface.js').Pin} Pin\n * @typedef {import('./lib/interface.js').CarReader} CarReader\n * @typedef {import('./lib/interface.js').S3ClientConfig} S3ClientConfig\n * @typedef {import('ipfs-car/blockstore').Blockstore} BlockstoreI\n * @typedef {import('./lib/interface.js').RateLimiter} RateLimiter\n */\n\n/**\n * @template {import('./lib/interface.js').TokenInput} T\n * @typedef {import('./lib/interface.js').Token<T>} TokenType\n */\n\n/**\n * Parses Authentication Token\n *\n * @param {string | string[]} tokenToParse\n * @returns {import('./lib/interface.js').ParseTokenResult}\n */\nfunction parseToken(tokenToParse) {\n  if (Array.isArray(tokenToParse)) {\n    if (typeof tokenToParse[2] === \"undefined\") {\n      throw new Error(`No Bucket Found`);\n    }\n    return {\n      credentials: tokenToParse,\n      bucket: tokenToParse[2]\n    }\n  }\n\n  const tokenBuffer = Buffer.from(tokenToParse, 'base64')\n  const token = tokenBuffer.toString('ascii').split(':')\n  const bucket = token[2]\n\n  if (typeof token === \"undefined\" || !Array.isArray(token)) {\n    throw new Error(`Token Not Found`)\n  }\n\n  if (typeof token[0] !== \"string\") {\n    throw new Error(`Invalid Access Key`)\n  }\n\n  if (typeof token[1] !== \"string\") {\n    throw new Error(`Invalid Secret Key`)\n  }\n\n  if (typeof bucket === \"undefined\") {\n    throw new Error(`No Bucket Found`);\n  }\n\n  return {\n    credentials: token,\n    bucket: bucket\n  }\n}\n\n/**\n */\nclass FilebaseClient {\n  /**\n   * Constructs a client bound to the given `options.token` and\n   * `options.endpoint`.\n   *\n   * @example\n   * ```js\n   * import { FilebaseClient, File, Blob } from \"filebase.storage\"\n   * const client = new FilebaseClient({ token: API_TOKEN })\n   *\n   * const cid = await client.storeBlob(new Blob(['hello world']))\n   * ```\n   * Optionally you could pass an alternative API endpoint (e.g. for testing)\n   * @example\n   * ```js\n   * import { FilebaseClient } from \"filebase.storage\"\n   * const client = new FilebaseClient({\n   *   token: API_TOKEN\n   *   endpoint: new URL('http://localhost:8080/')\n   * })\n   * ```\n   *\n   * @param {{token: string, endpoint?: string, s3config?: S3ClientConfig, bucket?: string}} options\n   */\n  constructor({\n    endpoint = DEFAULT_ENDPOINT,\n    token,\n    s3config,\n    bucket\n  }) {\n    this.endpoint = endpoint\n\n    if (typeof token === \"undefined\" && s3config) {\n      this.s3config = s3config\n      if (typeof this.s3config.credentials === \"undefined\") {\n        throw new Error(`Must pass credentials`)\n      }\n    } else {\n      const parsedToken = parseToken(token)\n      this.token = parsedToken.credentials\n      this.bucket = bucket || parsedToken.bucket\n\n      this.s3config = {\n        credentials: {\n          accessKeyId: this.token[0] || \"\",\n          secretAccessKey: this.token[1] || \"\"\n        },\n        endpoint: endpoint,\n        maxAttempts: MAX_STORE_RETRIES,\n        region: \"us-east-1\",\n        forcePathStyle: true,\n      }\n    }\n  }\n\n  /**\n   * Stores a single file and returns its CID.\n   *\n   * @param {Service} service\n   * @param {Blob} blob\n   * @param {string | null} objectName\n   * @returns {Promise<CIDString>}\n   */\n  static async storeBlob(service, blob, objectName = null) {\n    const blockstore = new Blockstore()\n\n    try {\n      const { cid, car } = await FilebaseClient.encodeBlob(blob, { blockstore })\n      await FilebaseClient.storeCar(service, car, objectName || cid.toString())\n\n      return cid.toString();\n    } finally {\n      await blockstore.close()\n    }\n  }\n\n  /**\n   * Stores a CAR file and returns its root CID.\n   *\n   * @param {Service} service\n   * @param {AsyncIterable<Uint8Array>} car\n   * @param {string} objectName\n   * @param {import('./lib/interface.js').CarStorerOptions} [options]\n   * @returns {Promise<CIDString>}\n   */\n  static async storeCar(\n    { endpoint, token, s3config, bucket },\n    car,\n    objectName ,\n    { onStoredChunk, onComplete, maxRetries} = {}\n  ) {\n    const selectedEndpoint = endpoint || DEFAULT_ENDPOINT;\n\n    if (typeof s3config === \"undefined\" && typeof token !== \"undefined\") {\n      const parsedToken = await parseToken(token)\n      this.token = parsedToken.credentials\n      this.bucket = bucket || parsedToken.bucket\n\n      s3config = {\n        credentials: {\n          accessKeyId: this.token[0] || \"\",\n          secretAccessKey: this.token[1] || \"\"\n        },\n        endpoint: selectedEndpoint,\n        maxAttempts: maxRetries || MAX_STORE_RETRIES,\n        region: \"us-east-1\",\n        forcePathStyle: true,\n      }\n    } else {\n      this.bucket = bucket\n    }\n\n    if (typeof s3config === \"undefined\") {\n      throw new Error(`s3config not defined`)\n    }\n\n    const s3client = new S3Client(s3config);\n\n    // Convert to an S3 upload of the full car\n    const readableStream = stream.Readable.from(car)\n    onComplete && readableStream.on('finish', onComplete)\n    const parallelUploads3 = new Upload({\n      client: s3client,\n      params: {\n        Bucket: this.bucket,\n        Key: objectName,\n        Body: readableStream,\n        Metadata: {\n          import: 'car'\n        },\n      },\n      queueSize: MAX_CONCURRENT_UPLOADS,\n      partSize: 1024 * 1024 * 105,\n      leavePartsOnError: false, // optional manually handle dropped parts\n    });\n\n    let storedBytes = 0.01\n    let progressBytes = storedBytes\n    parallelUploads3.on(\"httpUploadProgress\", (progress) => {\n      if (typeof progress.loaded !== \"number\") {\n        throw new Error(`Expected Number for Loaded Progress`);\n      }\n      progressBytes = progress.loaded - storedBytes;\n      storedBytes = progress.loaded;\n      onStoredChunk && onStoredChunk(progressBytes)\n    });\n\n    await parallelUploads3.done();\n\n    const headCommand = new HeadObjectCommand({\n      Bucket: this.bucket,\n      Key: objectName,\n    })\n    const carHeader = await s3client.send(headCommand);\n\n    if (typeof carHeader.Metadata === \"undefined\" || typeof carHeader.Metadata['cid'] === \"undefined\") {\n      throw new Error(`No CID Returned from Remote`)\n    }\n\n    return carHeader.Metadata['cid'];\n  }\n\n  /**\n   * Stores a directory of files and returns a CID. Provided files **MUST**\n   * be within the same directory, otherwise error is raised e.g. `foo/bar.png`,\n   * `foo/bla/baz.json` is ok but `foo/bar.png`, `bla/baz.json` is not.\n   *\n   * @param {Service} service\n   * @param {FilesSource} filesSource\n   * @param {string | null} objectName\n   * @returns {Promise<CIDString>}\n   */\n  static async storeDirectory(service, filesSource, objectName = null) {\n    const blockstore = new Blockstore()\n    let cidString\n    try {\n      const { cid, car } = await FilebaseClient.encodeDirectory(filesSource, {\n        blockstore,\n      })\n      cidString = cid.toString()\n      await FilebaseClient.storeCar(service, car, objectName || cid.toString())\n    } finally {\n      await blockstore.close()\n    }\n\n    return cidString\n  }\n\n  /**\n   * Stores the given token and all resources it references (in the form of a\n   * File or a Blob) along with a metadata JSON as specificed in ERC-1155. The\n   * `token.image` must be either a `File` or a `Blob` instance, which will be\n   * stored and the corresponding content address URL will be saved in the\n   * metadata JSON file under `image` field.\n   *\n   * If `token.properties` contains properties with `File` or `Blob` values,\n   * those also get stored and their URLs will be saved in the metadata JSON\n   * file in their place.\n   *\n   * Note: URLs for `File` objects will retain file names e.g. in case of\n   * `new File([bytes], 'cat.png', { type: 'image/png' })` will be transformed\n   * into a URL that looks like `ipfs://bafy...hash/image/cat.png`. For `Blob`\n   * objects, the URL will not have a file name name or mime type, instead it\n   * will be transformed into a URL that looks like\n   * `ipfs://bafy...hash/image/blob`.\n   *\n   * @template {import('./lib/interface.js').TokenInput} T\n   * @param {Service} service\n   * @param {T} metadata\n   * @param {string | null} objectName\n   * @returns {Promise<TokenType<T>>}\n   */\n  static async store(service, metadata, objectName = null) {\n    const { token, car, cid } = await FilebaseClient.encodeNFT(metadata)\n    await FilebaseClient.storeCar(service, car, objectName || cid.toString())\n    return token\n  }\n\n  /**\n   * Returns current status of the stored NFT by its CID. Note the NFT must\n   * have previously been stored by this account.\n   *\n   * @param {Service} service\n   * @param {string} cid\n   * @param {string | null} objectName\n   * @returns {Promise<import('./lib/interface.js').StatusResult>}\n   */\n  static async status(\n    { endpoint, token, s3config, bucket },\n    cid,\n    objectName\n  ) {\n    const selectedEndpoint = endpoint || DEFAULT_ENDPOINT;\n\n    if (typeof s3config === \"undefined\" && typeof token !== \"undefined\") {\n      const parsedToken = parseToken(token)\n      this.token = parsedToken.credentials\n      this.bucket = bucket || parsedToken.bucket\n\n      s3config = {\n        credentials: {\n          accessKeyId: this.token[0] || \"\",\n          secretAccessKey: this.token[1] || \"\"\n        },\n        endpoint: selectedEndpoint,\n        maxAttempts: MAX_STORE_RETRIES,\n        region: \"us-east-1\",\n        forcePathStyle: true,\n      }\n    } else {\n      this.bucket = bucket\n    }\n\n    if (typeof s3config === \"undefined\") {\n      throw new Error(`s3config not defined`)\n    }\n\n    const s3client = new S3Client(s3config);\n\n    const headCommand = new HeadObjectCommand({\n      Bucket: this.bucket,\n      Key: objectName || cid,\n    })\n    const carHeader = await s3client.send(headCommand);\n\n    if (typeof carHeader.Metadata === \"undefined\" || typeof carHeader.Metadata['cid'] === \"undefined\") {\n      throw new Error(`No CID Returned from Remote`)\n    }\n\n    if (typeof carHeader['ContentLength'] !== \"number\") {\n      throw new Error(`Invalid Content Length`)\n    }\n\n    const displayDate = carHeader.LastModified;\n\n    if (typeof displayDate === \"undefined\") {\n      throw new Error('Invalid Date')\n    }\n\n    return {\n      cid: carHeader.Metadata['cid'],\n      size: carHeader['ContentLength'],\n      deals: [],\n      pin: {\n        cid: carHeader.Metadata['cid'],\n        name: carHeader.Metadata['cid'],\n        status: 'pinned',\n        created: displayDate,\n      },\n      created: displayDate,\n    }\n  }\n\n\n  /**\n   * Removes stored content by its CID from this account. Please note that\n   * even if content is removed from the service other nodes that have\n   * replicated it might still continue providing it.\n   *\n   * @param {Service} service\n   * @param {string} cid\n   * @param {string | null} objectName\n   * @returns {Promise<void>}\n   */\n  static async delete(\n    { endpoint, token, s3config, bucket },\n    cid,\n    objectName = null\n  ) {\n    const selectedEndpoint = endpoint || DEFAULT_ENDPOINT\n\n    if (typeof s3config === \"undefined\" && typeof token !== \"undefined\") {\n      const parsedToken = parseToken(token)\n      this.token = parsedToken.credentials\n      this.bucket = bucket || parsedToken.bucket\n\n      s3config = {\n        credentials: {\n          accessKeyId: this.token[0] || \"\",\n          secretAccessKey: this.token[1] || \"\"\n        },\n        endpoint: selectedEndpoint,\n        region: \"us-east-1\",\n        forcePathStyle: true,\n      }\n    } else {\n      this.bucket = bucket;\n    }\n\n    if (typeof s3config === \"undefined\") {\n      throw new Error(`s3config not defined`)\n    }\n\n    const s3client = new S3Client(s3config);\n\n    const deleteCommand = new DeleteObjectCommand({\n      Bucket: this.bucket,\n      Key: objectName || cid,\n    })\n\n    await s3client.send(deleteCommand);\n  }\n\n  /**\n   * Encodes the given token and all resources it references (in the form of a\n   * File or a Blob) along with a metadata JSON as specificed in ERC-1155 to a\n   * CAR file. The `token.image` must be either a `File` or a `Blob` instance,\n   * which will be stored and the corresponding content address URL will be\n   * saved in the metadata JSON file under `image` field.\n   *\n   * If `token.properties` contains properties with `File` or `Blob` values,\n   * those also get stored and their URLs will be saved in the metadata JSON\n   * file in their place.\n   *\n   * Note: URLs for `File` objects will retain file names e.g. in case of\n   * `new File([bytes], 'cat.png', { type: 'image/png' })` will be transformed\n   * into a URL that looks like `ipfs://bafy...hash/image/cat.png`. For `Blob`\n   * objects, the URL will not have a file name name or mime type, instead it\n   * will be transformed into a URL that looks like\n   * `ipfs://bafy...hash/image/blob`.\n   *\n   * @example\n   * ```js\n   * const { token, car } = await FilebaseClient.encodeNFT({\n   *   name: 'filebase.storage store test',\n   *   description: 'Test ERC-1155 compatible metadata.',\n   *   image: new File(['<DATA>'], 'pinpie.jpg', { type: 'image/jpg' }),\n   *   properties: {\n   *     custom: 'Custom data can appear here, files are auto uploaded.',\n   *     file: new File(['<DATA>'], 'README.md', { type: 'text/plain' }),\n   *   }\n   * })\n   *\n   * console.log('IPFS URL for the metadata:', token.url)\n   * console.log('metadata.json contents:\\n', token.data)\n   * console.log('metadata.json with IPFS gateway URLs:\\n', token.embed())\n   *\n   * // Now store the CAR file on filebase.storage\n   * await client.storeCar(car)\n   * ```\n   *\n   * @template {import('./lib/interface.js').TokenInput} T\n   * @param {T} input\n   * @returns {Promise<{ cid: CID, token: TokenType<T>, car: AsyncIterable<Uint8Array> }>}\n   */\n  static async encodeNFT(input) {\n    validateERC1155(input)\n    return Token.Token.encode(input)\n  }\n\n  /**\n   * Encodes a single file to a CAR file and also returns its root CID.\n   *\n   * @example\n   * ```js\n   * const content = new Blob(['hello world'])\n   * const { cid, car } = await FilebaseClient.encodeBlob(content)\n   *\n   * // Root CID of the file\n   * console.log(cid.toString())\n   *\n   * // Now store the CAR file on filebase.storage\n   * await client.storeCar(car)\n   * ```\n   *\n   * @param {Blob} blob\n   * @param {object} [options]\n   * @param {BlockstoreI} [options.blockstore]\n   * @returns {Promise<{ cid: CID, car: AsyncIterable<Uint8Array> }>}\n   */\n  static async encodeBlob(blob, { blockstore } = {}) {\n    if (blob.size === 0) {\n      throw new Error('Content size is 0, make sure to provide some content')\n    }\n    return packCar([toImportCandidate('blob', blob)], {\n      blockstore,\n      wrapWithDirectory: false,\n    })\n  }\n\n  /**\n   * Encodes a directory of files to a CAR file and also returns the root CID.\n   * Provided files **MUST** be within the same directory, otherwise error is\n   * raised e.g. `foo/bar.png`, `foo/bla/baz.json` is ok but `foo/bar.png`,\n   * `bla/baz.json` is not.\n   *\n   * @example\n   * ```js\n   * const { cid, car } = await FilebaseClient.encodeDirectory([\n   *   new File(['hello world'], 'hello.txt'),\n   *   new File([JSON.stringify({'from': 'incognito'}, null, 2)], 'metadata.json')\n   * ])\n   *\n   * // Root CID of the directory\n   * console.log(cid.toString())\n   *\n   * // Now store the CAR file on filebase.storage\n   * await client.storeCar(car)\n   * ```\n   *\n   * @param {FilesSource} files\n   * @param {object} [options]\n   * @param {BlockstoreI} [options.blockstore]\n   * @returns {Promise<{ cid: CID, car: AsyncIterable<Uint8Array> }>}\n   */\n  static async encodeDirectory(files, { blockstore } = {}) {\n    let size = 0\n    const input = pipe(files, async function* (files) {\n      for await (const file of files) {\n        yield toImportCandidate(file.name, file)\n        size += file.size\n      }\n    })\n    const packed = await packCar(input, {\n      blockstore,\n      wrapWithDirectory: true,\n    })\n    if (size === 0) {\n      throw new Error(\n        'Total size of files should exceed 0, make sure to provide some content'\n      )\n    }\n    return packed\n  }\n\n  /**\n   * Stores a single file and returns the corresponding Content Identifier (CID).\n   * Takes a [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob)\n   * or a [File](https://developer.mozilla.org/en-US/docs/Web/API/File). Note\n   * that no file name or file metadata is retained.\n   *\n   * @example\n   * ```js\n   * const content = new Blob(['hello world'])\n   * const cid = await client.storeBlob(content)\n   * cid //> 'zdj7Wn9FQAURCP6MbwcWuzi7u65kAsXCdjNTkhbJcoaXBusq9'\n   * ```\n   *\n   * @param {Blob} blob\n   * @param {string | null} objectName\n   */\n  storeBlob(blob, objectName = null) {\n    return FilebaseClient.storeBlob(this, blob, objectName)\n  }\n\n  /**\n   * Stores files encoded as a single [Content Addressed Archive\n   * (CAR)](https://github.com/ipld/specs/blob/master/block-layer/content-addressable-archives.md).\n   *\n   * Takes a [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob)\n   * or a [File](https://developer.mozilla.org/en-US/docs/Web/API/File).\n   *\n   * Returns the corresponding Content Identifier (CID).\n   *\n   * See the [`ipfs-car` docs](https://www.npmjs.com/package/ipfs-car) for more\n   * details on packing a CAR file.\n   *\n   * @example\n   * ```js\n   * import { pack } from 'ipfs-car/pack'\n   * import { CarReader } from '@ipld/car'\n   * const { out, root } = await pack({\n   *  input: fs.createReadStream('pinpie.pdf')\n   * })\n   * const expectedCid = root.toString()\n   * const carReader = await CarReader.fromIterable(out)\n   * const cid = await storage.storeCar(carReader)\n   * console.assert(cid === expectedCid)\n   * ```\n   *\n   * @example\n   * ```\n   * import { packToBlob } from 'ipfs-car/pack/blob'\n   * const data = 'Hello world'\n   * const { root, car } = await packToBlob({ input: [new TextEncoder().encode(data)] })\n   * const expectedCid = root.toString()\n   * const cid = await client.storeCar(car)\n   * console.assert(cid === expectedCid)\n   * ```\n   * @param {AsyncIterable<Uint8Array>} car\n   * @param {string} objectName\n   * @param {import('./lib/interface.js').CarStorerOptions} [options]\n   */\n  storeCar(car, objectName, options) {\n    return FilebaseClient.storeCar(this, car, objectName, options)\n  }\n\n  /**\n   * Stores a directory of files and returns a CID for the directory.\n   *\n   * @example\n   * ```js\n   * const cid = await client.storeDirectory([\n   *   new File(['hello world'], 'hello.txt'),\n   *   new File([JSON.stringify({'from': 'incognito'}, null, 2)], 'metadata.json')\n   * ])\n   * cid //>\n   * ```\n   *\n   * Argument can be a [FileList](https://developer.mozilla.org/en-US/docs/Web/API/FileList)\n   * instance as well, in which case directory structure will be retained.\n   *\n   * @param {FilesSource} files\n   * @param {string | null} objectName\n   */\n  storeDirectory(files, objectName = null) {\n    return FilebaseClient.storeDirectory(this, files, objectName)\n  }\n\n  /**\n   * Returns current status of the stored NFT by its CID. Note the NFT must\n   * have previously been stored by this account.\n   *\n   * @example\n   * ```js\n   * const status = await client.status('zdj7Wn9FQAURCP6MbwcWuzi7u65kAsXCdjNTkhbJcoaXBusq9')\n   * ```\n   *\n   * @param {string} cid\n   * @param {string | null} objectName\n   */\n  status(cid, objectName = null) {\n    return FilebaseClient.status(this, cid, objectName)\n  }\n\n  /**\n   * Removes stored content by its CID from the service.\n   *\n   * > Please note that even if content is removed from the service other nodes\n   * that have replicated it might still continue providing it.\n   *\n   * @example\n   * ```js\n   * await client.delete('zdj7Wn9FQAURCP6MbwcWuzi7u65kAsXCdjNTkhbJcoaXBusq9')\n   * ```\n   *\n   * @param {string} cid\n   * @param {string | null} objectName\n   */\n  delete(cid, objectName = null) {\n    return FilebaseClient.delete(this, cid, objectName)\n  }\n\n  /**\n   * Stores the given token and all resources it references (in the form of a\n   * File or a Blob) along with a metadata JSON as specificed in\n   * [ERC-1155](https://eips.ethereum.org/EIPS/eip-1155#metadata). The\n   * `token.image` must be either a `File` or a `Blob` instance, which will be\n   * stored and the corresponding content address URL will be saved in the\n   * metadata JSON file under `image` field.\n   *\n   * If `token.properties` contains properties with `File` or `Blob` values,\n   * those also get stored and their URLs will be saved in the metadata JSON\n   * file in their place.\n   *\n   * Note: URLs for `File` objects will retain file names e.g. in case of\n   * `new File([bytes], 'cat.png', { type: 'image/png' })` will be transformed\n   * into a URL that looks like `ipfs://bafy...hash/image/cat.png`. For `Blob`\n   * objects, the URL will not have a file name name or mime type, instead it\n   * will be transformed into a URL that looks like\n   * `ipfs://bafy...hash/image/blob`.\n   *\n   * @example\n   * ```js\n   * const metadata = await client.store({\n   *   name: 'filebase.storage store test',\n   *   description: 'Test ERC-1155 compatible metadata.',\n   *   image: new File(['<DATA>'], 'pinpie.jpg', { type: 'image/jpg' }),\n   *   properties: {\n   *     custom: 'Custom data can appear here, files are auto uploaded.',\n   *     file: new File(['<DATA>'], 'README.md', { type: 'text/plain' }),\n   *   }\n   * })\n   *\n   * console.log('IPFS URL for the metadata:', metadata.url)\n   * console.log('metadata.json contents:\\n', metadata.data)\n   * console.log('metadata.json with IPFS gateway URLs:\\n', metadata.embed())\n   * ```\n   *\n   * @template {import('./lib/interface.js').TokenInput} T\n   * @param {T} token\n   * @param {string | null} objectName\n   */\n  store(token, objectName = null) {\n    return FilebaseClient.store(this, token, objectName)\n  }\n}\n\n/**\n * Cast an iterable to an asyncIterable\n * @template T\n * @param {Iterable<T>} iterable\n * @returns {AsyncIterable<T>}\n */\nexport function toAsyncIterable(iterable) {\n  return (async function* () {\n    for (const item of iterable) {\n      yield item\n    }\n  })()\n}\n\n/**\n * @template {import('./lib/interface.js').TokenInput} T\n * @param {T} metadata\n */\nconst validateERC1155 = ({ name, description, image, decimals }) => {\n  // Just validate that expected fields are present\n  if (typeof name !== 'string') {\n    throw new TypeError(\n      'string property `name` identifying the asset is required'\n    )\n  }\n  if (typeof description !== 'string') {\n    throw new TypeError(\n      'string property `description` describing asset is required'\n    )\n  }\n  if (!(image instanceof Blob)) {\n    throw new TypeError('property `image` must be a Blob or File object')\n  } else if (!image.type.startsWith('image/')) {\n    console.warn(`According to ERC721 Metadata JSON Schema 'image' must have 'image/*' mime type.\n\nFor better interoperability we would highly recommend storing content with different mime type under 'properties' namespace e.g. \\`properties: { video: file }\\` and using 'image' field for storing a preview image for it instead.\n\nFor more context please see ERC-721 specification https://eips.ethereum.org/EIPS/eip-721`)\n  }\n\n  if (typeof decimals !== 'undefined' && typeof decimals !== 'number') {\n    throw new TypeError('property `decimals` must be an integer value')\n  }\n}\n\n/**\n * @param {import('ipfs-car/pack').ImportCandidateStream|Array<{ path: string, content: import('./platform.js').ReadableStream }>} input\n * @param {object} [options]\n * @param {BlockstoreI} [options.blockstore]\n * @param {boolean} [options.wrapWithDirectory]\n */\nconst packCar = async (input, { blockstore, wrapWithDirectory } = {}) => {\n  /* c8 ignore next 1 */\n  blockstore = blockstore || new Blockstore()\n  const { root: cid, out } = await pack({ input, blockstore, wrapWithDirectory, rawLeaves: false, cidVersion: 0 })\n  const car = new BlockstoreCarReader(1, [cid], blockstore)\n  return { cid, carReader: car, car: out }\n}\n\n/**\n * Convert the passed blob to an \"import candidate\" - an object suitable for\n * passing to the ipfs-unixfs-importer. Note: content is an accessor so that\n * the stream is created only when needed.\n *\n * @param {string} path\n * @param {Pick<Blob, 'stream'>|{ stream: () => AsyncIterable<Uint8Array> }} blob\n * @returns {import('ipfs-core-types/src/utils.js').ImportCandidate}\n */\nfunction toImportCandidate(path, blob) {\n  /** @type {AsyncIterable<Uint8Array>} */\n  let stream\n  return {\n    path,\n    get content() {\n      stream = stream || blob.stream()\n      return stream\n    },\n  }\n}\n\nexport { FilebaseClient, File, Blob, FormData, toGatewayURL, Token }\n"],"names":["Blockstore","S3Client","stream","Upload","HeadObjectCommand","DeleteObjectCommand","Token.Token","pipe","Blob","pack","BlockstoreCarReader"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAYA;AACA,MAAM,iBAAiB,GAAG,EAAC;AAC3B,MAAM,sBAAsB,GAAG,EAAC;AAChC,MAAM,gBAAgB,GAAG,0BAAyB;AAClD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,UAAU,CAAC,YAAY,EAAE;AAClC,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE;AACnC,IAAI,IAAI,OAAO,YAAY,CAAC,CAAC,CAAC,KAAK,WAAW,EAAE;AAChD,MAAM,MAAM,IAAI,KAAK,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC;AACzC,KAAK;AACL,IAAI,OAAO;AACX,MAAM,WAAW,EAAE,YAAY;AAC/B,MAAM,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;AAC7B,KAAK;AACL,GAAG;AACH;AAC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;AACA;AACA;AACA;AACA;AACA,EAAE,QAAQ,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE;AACrC,IAAI,OAAO,cAAc,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,CAAC;AAClE,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,EAAE;AAC3C,IAAI,OAAO,cAAc,CAAC,cAAc,CAAC,IAAI,EAAE,KAAK,EAAE,UAAU,CAAC;AACjE,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,MAAM,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI,EAAE;AACjC,IAAI,OAAO,cAAc,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,UAAU,CAAC;AACvD,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,MAAM,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI,EAAE;AACjC,IAAI,OAAO,cAAc,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,UAAU,CAAC;AACvD,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,EAAE;AAClC,IAAI,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,UAAU,CAAC;AACxD,GAAG;AACH,CAAC;AACD;AACA;AACA;A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