{"_id":"@araviel/nftst-metaplex-auth","name":"@araviel/nftst-metaplex-auth","dist-tags":{"latest":"1.2.0"},"versions":{"1.2.0":{"name":"@araviel/nftst-metaplex-auth","version":"1.2.0","description":"A client library for nft.storage designed for metaplex NFT uploads","main":"./dist/index.cjs","publishConfig":{"access":"public"},"type":"module","exports":{".":{"browser":"./dist/index.browser.js","import":"./dist/src/index.js","require":"./dist/index.cjs"}},"browser":{"./src/platform.js":"./src/platform.browser.js"},"types":"./dist/src/index.d.ts","scripts":{"build":"npm run clean && npm run build:all","clean":"rimraf ./dist","typecheck":"tsc","build:all":"npm run typecheck && npm run build:cjs && npm run build:browser","build:cjs":"mkdirp ./dist && esbuild ./src/index.ts --bundle --format=cjs --platform=node  --target=es2018 --outfile=./dist/index.cjs","build:esm":"mkdirp ./dist && esbuild ./src/index.ts --bundle --format=esm --platform=node --target=es2018 --outfile=./dist/index.esm.js","build:browser":"mkdirp ./dist && esbuild ./src/index.ts --bundle --format=esm --target=es2018 --outfile=./dist/index.browser.js --external:stream/web","build:cli":"mkdirp ./dist && esbuild ./src/cli.ts --bundle --format=cjs --platform=node --target=es2018 --outfile=./dist/cli.cjs","prepublishOnly":"npm run build","typedoc":"typedoc","prepare":"husky install"},"lint-staged":{"**/*":"prettier --write --ignore-unknown"},"keywords":["nft","nft.storage","metaplex","ipfs","filecoin","safecoin"],"author":{"name":"yusef@protocol.ai"},"license":"ISC","dependencies":{"@dashkite/tweetnacl":"^1.0.3","@ipld/dag-pb":"^2.1.16","@safecoin/web3.js":"^1.29.4","@web-std/fetch":"^2.1.2","@web-std/file":"^1.1.4","ajv":"^8.8.1","files-from-path":"^0.2.1","ipfs-car":"^0.6.2","ipfs-unixfs":"^6.0.6","multiformats":"^9.6.2","nft.storage":"^5.2.5","p-retry":"^5.0.0","path-browserify":"^1.0.1","streaming-iterables":"^6.0.0","ts-command-line-args":"^2.2.0","varint":"^6.0.0"},"devDependencies":{"@ipld/car":"^3.2.0","@ssttevee/multipart-parser":"^0.1.9","@types/chai":"^4.2.22","@types/chai-as-promised":"^7.1.5","@types/mocha":"^9.0.0","@types/node":"^16.11.8","@types/path-browserify":"^1.0.0","@types/varint":"^6.0.0","chai":"^4.3.4","chai-as-promised":"^7.1.1","esbuild":"^0.13.12","husky":"^7.0.4","lint-staged":"^12.0.3","mkdirp":"^1.0.4","mocha":"^9.1.3","prettier":"2.4.1","rimraf":"^3.0.2","ts-node":"^10.4.0","typedoc":"^0.22.10","typedoc-plugin-missing-exports":"^0.22.6","typescript":"^4.4.4"},"gitHead":"fe02f38d0b1843bdad58eca6948819d58f495610","_id":"@araviel/nftst-metaplex-auth@1.2.0","_nodeVersion":"16.13.1","_npmVersion":"8.1.2","dist":{"integrity":"sha512-hIVFXAn3ZKZ9Iq937aRjyyYG+axlN0FmEdbeb4h25nRKuCtIkFX1Q7hWfgRGeVgymsPYaMpDl7pASFwTULfezw==","shasum":"598eff016c1616f1ee7f30abed3e1a051b801714","tarball":"https://registry.npmjs.org/@araviel/nftst-metaplex-auth/-/nftst-metaplex-auth-1.2.0.tgz","fileCount":79,"unpackedSize":2100310,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCBdpmfRVVKMNR+darjjGW9MmTPZcvjwJfkb/kK7SJhNwIgGJ1oK9BKtMDYauH1thcX9TIYpY8DuEInySWcHXjWQ7Y="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJicdqcACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp81A//YyThaJssBrXyAsC16jKqbIVqxFeY1+ZdLj6dTdkKBE0d8/mU\r\nmZxFYf0neuU+zY8vk/dGVu4zX/UMhiarLOE5N9ke2kFbd/DRfnaAzjXVSqU3\r\nVJfFbJG/nD4tLqeSR+gGYaKAoSkxu21CbBDPSti64bYVa7TTNCO4Nk5Zn3/1\r\n0BKBqAgQXSGHl5w4EwYXpmRO3y41I2A394osiHwyB/yuy2Xupil4M0yGCymD\r\nOkGsXJ23gYhMasPFTN7eR2uMd3qbOjRemO6yDrdV9sj1fTZNriCiCC2EMaoP\r\nHoOS06TV6PefL7yzH1hMGvJIx3jemO4BBk+nbgN/eyZXEl/BEujL28ejwStM\r\nHU572w7EQkgB4ZlKUAgJpsH0/Z84SryVvwWFPt65z06d1ItqnNx2cn0+s75S\r\nJWS0l7RMU1d3r+6w6lKpkAhdnf/6kV1OWkznLmnBsviqx6g+NbXrbp+P4ujU\r\n39cwXf/zzzNmtfX1rJTKCqErS/yqhjYYlPiofz3UzbLHXum4g0qUg6ps4q7e\r\nadLoj3/9jX8lOAKX0Sp8AiR/h87q+K+Bog/B82/YJFnjALc6VoRqYkwfJmNh\r\n0aOKrZtRILQCKyHN1UvLad5X5Qewu7noCKlR9aMKoBHuWtihgaYQ/OOqe0w7\r\nwVpCxOr+x/58Vd3G/Sruno5uwx78E6dmVAM=\r\n=xoFu\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"araviel","email":"contact@araviel.io"},"directories":{},"maintainers":[{"name":"araviel","email":"contact@araviel.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nftst-metaplex-auth_1.2.0_1651628699964_0.1683221324034918"},"_hasShrinkwrap":false}},"time":{"created":"2022-05-04T01:44:59.918Z","1.2.0":"2022-05-04T01:45:00.192Z","modified":"2022-05-04T01:45:00.300Z"},"maintainers":[{"name":"araviel","email":"contact@araviel.io"}],"description":"A client library for nft.storage designed for metaplex NFT uploads","keywords":["nft","nft.storage","metaplex","ipfs","filecoin","safecoin"],"author":{"name":"yusef@protocol.ai"},"license":"ISC","readme":"# metaplex-auth\n\nThis repo contains a client library for uploading data to [NFT.Storage](https://nft.storage) using a signature from a solana private key to authenticate the request.\n\nSee [SPEC.md](https://github.com/nftstorage/metaplex-auth/blob/main/SPEC.md) for details about the authentication scheme.\n\n## Install\n\n```\nnpm install @nftstorage/metaplex-auth\n```\n\nor\n\n```\nyarn add @nftstorage/metaplex-auth\n```\n\n## Usage\n\nThis package is primarily intended to be used as a library in your JavaScript or TypeScript project.\n\nAPI reference docs can be found at https://nftstorage.github.io/metaplex-auth/\n\n### Creating a client\n\nThe main entry point into the API is the [NFTStorageMetaplexor class](https://nftstorage.github.io/metaplex-auth/classes/NFTStorageMetaplexor.html), which provides methods for uploading files to NFT.Storage.\n\nTo create an `NFTStorageMetaplexor`, you'll need either a Solana private signing key or a `signMessage` function that can return a valid Ed25519 signature for a Solana account (for example, from a [wallet adapter](https://github.com/solana-labs/wallet-adapter)).\n\nThe methods for creating an `NFTStorageMetaplexor` also require a `mintingAgent` string.\n\nThe `mintingAgent` should identify the tool or platform used to prepare the upload.\n\nProjects using this library are free to choose their own value for this tag, however you should avoid changing the name over time, unless the project itself changes names (for example, due to a community fork or re-branding).\n\nFor personal projects or individuals creating tools that are not affiliated with a public platform, please set the value to a URL for your code repository. If your code is not yet public, please create a repository containing a description of the project and links to its public-facing interface.\n\nExamples of suitable values:\n\n- `\"metaplex/candy-machine-cli\"`\n- `\"metaplex/js-sdk\"`\n- `\"magiceden/mint-authority\"`\n- `\"https://github.com/samuelvanderwaal/metaboss\"`\n\nYou may also optionally pass an `agentVersion` string, to differentiate between different versions of your project.\n\n#### With secret key\n\nThe [`NFTStorageMetaplexor.withSecretKey` static method](https://nftstorage.github.io/metaplex-auth/classes/NFTStorageMetaplexor.html#withSecretKey) accepts a `Uint8Array` containing a secret Ed25519 signing key.\n\nIt also optionally accepts an options object that can be used to set some metadata about the request. Most importantly, you should set the `solanaCluster` option to the cluster you intend to mint on. If not provided, it will default to `devnet`.\n\n```js\nimport { NFTStorageMetaplexor } from '@nftstorage/metaplex-auth'\n\nconst key = loadKeyFromSomewhere()\nconst client = NFTStorageMetaplexor.withSecretKey(key, {\n  solanaCluster: 'mainnet-beta',\n  mintingAgent: 'my-awesome-tool',\n})\n```\n\n#### With wallet adapter\n\nIf you're using a [wallet adapter](https://github.com/solana-labs/wallet-adapter) that supports the `signMessage` function, you can use it with the [`NFTStorageMetaplexor.withSigner` static method](https://nftstorage.github.io/metaplex-auth/classes/NFTStorageMetaplexor.html#withSigner) by passing in the `signMessage` function and the public key.\n\n```js\nimport { NFTStorageMetaplexor } from '@nftstorage/metaplex-auth'\nimport { useWallet } from '@solana/wallet-adapter-react'\n\nconst MyComponent = () => {\n  const { publicKey, signMessage } = useWallet()\n  const client = NFTStorageMetaplexor.withSigner(signMessage, publicKey, {\n    solanaCluster: 'mainnet-beta',\n    mintingAgent: 'my-awesome-tool',\n  })\n}\n```\n\n### Uploading Metaplex NFTs\n\nTo assist with uploading Metaplex NFTs, this package includes support for loading [Metaplex NFT metadata](https://docs.metaplex.com/nft-standard) and uploading files that are referenced within.\n\nThe `storeNFT` methods will validate the metadata using a JSON schema to catch any formatting errors before upload.\n\n**Please note** that the schema validation code has not been widely tested yet on real-world NFT data and may be too restrictive. If you believe that it is rejecting valid metadata, please [open an issue](https://github.com/nftstorage/metaplex-auth/issues/new).\n\nIf you're using node.js, you can use the [NFTStorageMetaplexor.storeNFTFromFilesystem method](https://nftstorage.github.io/metaplex-auth/classes/NFTStorageMetaplexor.html#storeNFTFromFilesystem) to load NFT data from disk and upload it in one operation.\n\n```js\nasync function uploadNFT(pathToMetadataJson) {\n  const key = loadKeyFromSomewhere()\n  const client = NFTStorageMetaplexor.withSecretKey(key)\n\n  const result = await client.storeNFTFromFilesystem(pathToMetadataJson)\n}\n```\n\nIf you're running in a browser, you'll need to use the [`prepareMetaplexNFT` function](https://nftstorage.github.io/metaplex-auth/modules.html#prepareMetaplexNFT), which accepts metadata as a JS object and takes `File` objects containing image and other asset data. The resulting [`PackagedNFT` object](https://nftstorage.github.io/metaplex-auth/interfaces/PackagedNFT.html) can be passed into the [storePreparedNFT method](https://nftstorage.github.io/metaplex-auth/classes/NFTStorageMetaplexor.html#storePreparedNFT).\n\n#### File references\n\nThe `prepareMetaplexNFT` and `storeNFTFromFilesystem` methods will upload the `image`, `animation_url` and any files contained in `properties.files` if they contain valid file references.\n\nIn the case of `prepareMetaplexNFT`, the provided `imageFile` parameter will be uploaded, along with any `additionalAssetFiles`. The `image` field in the metadata will be replaced with an HTTP gateway URL to the uploaded image. Likewise, if the `animation_url` field contains the name of one of the `additionalAssetFiles`, the field will be replaced with a gateway URL.\n\nAll entries in `properties.files` will likewise be replaced with IPFS links if the `uri` field contains the filename of any of the uploaded files. Each uploaded file will contain _two_ entries in the final metadata: one containing an HTTP gateway URL with the `cdn` flag set to `true`, and one location-independent `ipfs://` URI with `cdn` set to `false`. This should allow clients to fetch content over HTTP while still preserving a location-independent link that doesn't depend on a single gateway.\n\nWhen using `storeNFTFromFilesystem` on node.js, the same rules apply, however you don't need to pass in `File` objects for each asset. Instead, you can set the `image` field (and optionally, `animation_url`) to a file path relative to the metadata JSON file, and the image data will be loaded from disk. Likewise, any entries in `properties.files` whose `uri` contains a valid file path will be uploaded, and the entry will be replaced with two IPFS links as with `prepareMetaplexNFT`.\n\n### Uploading files\n\nYou can upload arbitrary files using the [storeDirectory method](https://nftstorage.github.io/metaplex-auth/classes/NFTStorageMetaplexor.html#storeDirectory). It accepts an `Iterable` of `File` objects and bundles them into an IPFS directory listing, returning the root CID of the stored directory.\n\n```js\nasync function uploadFiles(files) {\n  const key = loadKeyFromSomewhere()\n  const client = NFTStorageMetaplexor.withSecretKey(key)\n\n  const cid = await client.storeDirectory(files)\n  console.log(\n    `Stored ${files.length} file(s). Check them out at https://${cid}.ipfs.nftstorage.link`\n  )\n}\n```\n\nNote that the returned CID links to a directory object containing the files. If you want to link to individual files within the directory, you must append the filename to the result:\n\n```js\nasync function uploadFiles(files) {\n  const key = loadKeyFromSomewhere()\n  const client = NFTStorageMetaplexor.withSecretKey(key)\n\n  const cid = await client.storeDirectory(files)\n\n  // make HTTP gateway links using the nftstorage.link gateway\n  const gatewayBaseUrl = new URL(`https://${cid}.ipfs.nftstorage.link`)\n  const gatewayLinks = files.map((f) => new URL(f.name, gatewayBaseUrl))\n\n  // make gateway-agnostic IPFS uris:\n  const uriBase = new URL(`ipfs://${cid}`)\n  const ipfsURIs = files.map((f) => new URL(f.name, uriBase))\n}\n```\n\n### Uploading CAR files\n\nUnder the hood, all the upload methods encode data into IPFS Content Archives (CARs) before uploading.\n\nIf you already have CAR-formatted data, you can upload it with the [storeCar method](https://nftstorage.github.io/metaplex-auth/classes/NFTStorageMetaplexor.html#storeCar).\n\nThis may be useful if you have already imported your data into IPFS, or if you want to have more control over the object graph, for example, because you want to use [IPLD](https://ipld.io) to store structured data.\n\nThe `storeCar` method accepts a `CarReader` from the [@ipld/car package](https://github.com/ipld/js-car).\n","readmeFilename":"README.md"}