{"_id":"@cronoscatsclub/ipfs-gateway-tools","name":"@cronoscatsclub/ipfs-gateway-tools","dist-tags":{"latest":"1.1.0"},"versions":{"1.1.0":{"name":"@cronoscatsclub/ipfs-gateway-tools","version":"1.1.0","description":"Toolkit for working with IPFS Gateways and CIDs","scripts":{"start":"webpack serve","test":"jest --coverage --env=node","prepare":"npm run build","trypublish":"npm publish || true","expose:cmd":"mv -v dist/* ./","build":"webpack --mode=production","prepublishOnly":"webpack --mode=production && npm run expose:cmd"},"repository":{"type":"git","url":"git+https://github.com/cronoscatsclub/ipfs-gateway-tools.git"},"author":{"name":"Matt Ober","email":"matt@pinata.cloud","url":"https://github.com/obo20"},"license":"MIT","bugs":{"url":"https://github.com/cronoscatsclub/ipfs-gateway-tools/issues"},"homepage":"https://github.com/cronoscatsclub/ipfs-gateway-tools","keywords":["ipfs","gateway","pinata"],"devDependencies":{"@babel/cli":"^7.13.16","@babel/core":"^7.13.16","@babel/plugin-proposal-class-properties":"^7.13.0","@babel/polyfill":"^7.12.1","@babel/preset-env":"^7.13.15","babel-eslint":"^10.1.0","babel-loader":"^8.2.2","babel-preset-minify":"^0.5.0","clean-webpack-plugin":"*","css-loader":"^5.2.4","eslint":"^7.24.0","file-loader":"^6.2.0","jest":"^26.6.3","prettier":"^2.2.1","prettier-webpack-plugin":"^1.2.0","style-loader":"^2.0.0","terser-webpack-plugin":"^5.1.1","url-loader":"^4.1.1","webpack":"^5.35.0","webpack-cli":"^4.6.0","webpack-dev-server":"4.0.0-beta.2","webpack-node-externals":"^3.0.0"},"dependencies":{"is-ipfs":"1.0.3"},"main":"babel.config.js","directories":{"test":"tests"},"_id":"@cronoscatsclub/ipfs-gateway-tools@1.1.0","_nodeVersion":"12.22.12","_npmVersion":"6.14.16","dist":{"integrity":"sha512-ewyhix23kpX4iZMUDiQjc+hszNQQqy8e1kchl2SYvITBSFhNrPzgljoj7ZNsFr85cQ77OOyuQlzSF7HHLsFvmw==","shasum":"c932dc75bed0f67ab12dadc0e9d5d86b589e61bd","tarball":"https://registry.npmjs.org/@cronoscatsclub/ipfs-gateway-tools/-/ipfs-gateway-tools-1.1.0.tgz","fileCount":10,"unpackedSize":361275,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCID4w2ZWHcBWLSUzw7lGpSdKIDHTw1lh1WpNA1koBQUW8AiEA1pA2EqDAOVcfMzgykvEGbkaT09s3RUrnFfL2UU5XBqc="}]},"_npmUser":{"name":"cronoscatsclub","email":"cronoscatsclub@gmail.com"},"maintainers":[{"name":"cronoscatsclub","email":"cronoscatsclub@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ipfs-gateway-tools_1.1.0_1700136801804_0.41886560191947075"},"_hasShrinkwrap":false}},"time":{"created":"2023-11-16T12:13:21.725Z","1.1.0":"2023-11-16T12:13:22.017Z","modified":"2023-11-16T12:13:22.311Z"},"maintainers":[{"name":"cronoscatsclub","email":"cronoscatsclub@gmail.com"}],"description":"Toolkit for working with IPFS Gateways and CIDs","homepage":"https://github.com/cronoscatsclub/ipfs-gateway-tools","keywords":["ipfs","gateway","pinata"],"repository":{"type":"git","url":"git+https://github.com/cronoscatsclub/ipfs-gateway-tools.git"},"author":{"name":"Matt Ober","email":"matt@pinata.cloud","url":"https://github.com/obo20"},"bugs":{"url":"https://github.com/cronoscatsclub/ipfs-gateway-tools/issues"},"license":"MIT","readme":"# IPFS Gateway Tools\n\nIPFS Gateway Tools\n\n## Overview\n\nThis toolkit contains helper functions for working with IPFS gateway URLs and transforming them as desired.\n\nThis package comes with a distributions for the browser and for NodeJS. Take care to ensure you are importing or requiring in the right version. \n\n## Installation\n```\nnpm install --save @pinata/ipfs-gateway-tools\n```\n\n## Browser Setup\nTo require this in your project simply include the library at the top of your file like so:\n\n```javascript\nimport IPFSGatewayTools from '@pinata/ipfs-gateway-tools/dist/browser';\nconst gatewayTools = new IPFSGatewayTools();\n```\n\n## NodeJS Setup\n\n```javascript\nconst IPFSGatewayTools = require('@pinata/ipfs-gateway-tools/dist/node');\nconst gatewayTools = new IPFSGatewayTools();\n```\n\n## Usage\nThe IPFS gateway toolkit currently contains the following functions:\n\n* [containsCID](#containsCID-anchor)\n* [convertToDesiredGateway](#convertToDesiredGateway-anchor)\n\n\n<a name=\"containsCID-anchor\"></a>\n### containsCID\n\n\n##### `ipfsGatewayTools.containsCID(url)`\n##### Params\n* `url` - A gateway url that should take one of the following forms:\n   * `ipfs://CID`\n   * `ipfs://ipfs/CID`\n   * `https://example-gateway.com/ipfs/CID`\n   * `https://example-gateway.com/ipfs/CID/exampleFile.json`\n   * `https://example-gateway.com/ipns/CID`\n    \n#### Response\n```\n{\n    containsCid: (Boolean) - True if the url contains a CID,\n    cid: (string) - The CID that the url contains if \"containsCid\" is true\n}\n```\n\n<a name=\"convertToDesiredGateway-anchor\"></a>\n### convertToDesiredGateway\n\n\n##### `ipfsGatewayTools.convertToDesiredGateway(sourceUrl, desiredGatewayPrefix)`\n##### Params\n* `sourceUrl` - A gateway url that should take one of the following forms:\n   * `ipfs://CID`\n   * `ipfs://ipfs/CID`\n   * `https://example-gateway.com/ipfs/CID`\n   * `https://example-gateway.com/ipfs/CID/exampleFile.json`\n   * `https://example-gateway.com/ipns/CID`\n* `desiredGatewayPrefix` - The desired gateway you want to convert your source URL to. A few examples of this would be:\n   * `https://mygateway.mypinata.cloud`\n   * `https://ipfs.io`\n    \n#### Response\nReturns a string that uses the desired source gateway prefix. \n\nExample code:\n```javascript\nconst sourceUrl = 'https://exampleGateway.com/ipfs/bafybeifx7yeb55armcsxwwitkymga5xf53dxiarykms3ygqic223w5sk3m';\nconst desiredGatewayPrefix = 'https://mygateway.mypinata.cloud'\nconst convertedGatewayUrl = ipfsGatewayTools.convertToDesiredGateway(sourceUrl, desiredGatewayPrefix);\n\n//In the example above, the resulting value for convertedGatewayUrl would be: https://mygateway.mypinata.cloud/ipfs/bafybeifx7yeb55armcsxwwitkymga5xf53dxiarykms3ygqic223w5sk3m\n```\n\n## Questions? Issues? Suggestions? \nFeel free to file a github issue or email us at team@pinata.cloud \n\nWe'd love to hear from you!\n","readmeFilename":"README.md"}