{"_id":"@agicash/bc-ur","_rev":"2-02571554ad1f675fbf707b068d20f23b","name":"@agicash/bc-ur","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@agicash/bc-ur","version":"0.1.0","keywords":["bc-ur"],"license":"MIT","_id":"@agicash/bc-ur@0.1.0","maintainers":[{"name":"bobsy","email":"dev@agi.cash"},{"name":"josip_agicash","email":"josip@agi.cash"}],"homepage":"https://github.com/MakePrisms/bc-ur#readme","bugs":{"url":"https://github.com/MakePrisms/bc-ur/issues"},"dist":{"shasum":"41f3fb8990f30ccd096731eb7032c5db4a4e4874","tarball":"https://registry.npmjs.org/@agicash/bc-ur/-/bc-ur-0.1.0.tgz","fileCount":29,"integrity":"sha512-B2Hh7dSqdeVZuMCwdNR0MXUr4fUU5n+gTWd0b0m9HpV6/mAXRMnAfuJbeax/krvHf8A3qMxFLAkTBKcSxUSPuw==","signatures":[{"sig":"MEUCIHAm4lxmg7SMwdMuYfgB4J/5fxISEM+XXvLlsVbiq4s4AiEAuDrzmgRAHakH5/1Zte0D1z4J6CgbZnDQbXvT4lJL4qI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":106236},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","gitHead":"0d6c368c2cc79a7abc37434696ec0974c70d6493","scripts":{"lint":"eslint \"./src/**/*.{ts,tsx}\" --max-warnings=0","test":"vitest","build":"yarn clean && rollup -c","clean":"rm -rf dist","prepublish":"yarn build"},"_npmUser":{"name":"josip_agicash","email":"josip@agi.cash"},"repository":{"url":"git+https://github.com/MakePrisms/bc-ur.git","type":"git"},"_npmVersion":"10.8.2","description":"A JS implementation of the Uniform Resources (UR) specification from Blockchain Commons","directories":{"lib":"src","test":"tests"},"_nodeVersion":"20.18.0","dependencies":{"jsbi":"3.1.5","cborg":"^4.0.9","big.js":"^6.2.2","buffer":"^6.0.3","cbor-sync":"^1.0.4","@noble/hashes":"^1.3.3","@apocentre/alias-sampling":"^0.5.3"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tslib":"^2.8.1","rollup":"^4.29.1","vitest":"^1.3.1","typescript":"^5.7.2","@types/big.js":"^6.2.2","@rollup/plugin-typescript":"^12.1.2"},"_npmOperationalInternal":{"tmp":"tmp/bc-ur_0.1.0_1772318364513_0.04634416663811436","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2026-02-28T22:39:24.381Z","modified":"2026-04-02T00:57:25.308Z","0.1.0":"2026-02-28T22:39:24.666Z"},"bugs":{"url":"https://github.com/MakePrisms/bc-ur/issues"},"license":"MIT","homepage":"https://github.com/MakePrisms/bc-ur#readme","keywords":["bc-ur"],"repository":{"url":"git+https://github.com/MakePrisms/bc-ur.git","type":"git"},"description":"A JS implementation of the Uniform Resources (UR) specification from Blockchain Commons","maintainers":[{"email":"dev@agi.cash","name":"bobsy"},{"email":"josip@agi.cash","name":"josip_agicash"},{"email":"damian@agi.cash","name":"damian-agicash"}],"readme":"# BC-UR\n\nFork from `@gandlaf21/bc-ur` which uses Big.js instead of bignumber.js.\n\n## Installing\n\nTo install, run:\n```bash\nyarn add @agicash/bc-ur\n```\n\n## Quick Start\n\n### Encode a message\n\n```js\nimport {UR, UREncoder} from '@agicash/bc-ur'\n\nconst message = {any: 'property'}\nconst messageBuffer = Buffer.from(JSON.stringify(message))\n\n// First step is to create a UR object from a Buffer\nconst ur = UR.fromBuffer(messageBuffer)\n\n// Then, create the UREncoder object\n\n// The maximum amount of fragments to be generated in total\n// For NGRAVE ZERO support please keep to a maximum fragment size of 200\nconst maxFragmentLength = 200\n\n// The index of the fragment that will be the first to be generated\n// If it's more than the \"maxFragmentLength\", then all the subsequent fragments will only be\n// fountain parts\nconst firstSeqNum = 0\n\n// Create the encoder object\nconst encoder = new UREncoder(ur, maxFragmentLength, firstSeqNum)\n\n// Keep generating new parts, until a condition is met; for example the user exits the page, or clicks \"DONE\"\nwhile(!stop) {\n  // get the next part in the sequence\n  let part = encoder.nextPart()\n\n  // get the part as a string containing the cbor payload and display it with whatever way\n  // the part looks like this:\n  // ur:bytes/1-9/lpadascfadaxcywenbpljkhdcahkadaemejtswhhylkepmykhhtsytsnoyoyaxaedsuttydmmhhpktpmsrjtdkgslpgh\n\n  displayPart(part)\n}\n```\n\n### Decode a message\n\n```js\nimport {URDecoder} from '@agicash/bc-ur'\n\n// Create the decoder object\nconst decoder = new URDecoder()\n\ndo {\n  // Scan the part from a QRCode\n  // the part should look like this:\n  // ur:bytes/1-9/lpadascfadaxcywenbpljkhdcahkadaemejtswhhylkepmykhhtsytsnoyoyaxaedsuttydmmhhpktpmsrjtdkgslpgh\n  const part = scanQRCode()\n\n  // register the new part with the decoder\n  decoder.receivePart(part)\n\n  // check if all the necessary parts have been received to successfully decode the message\n} while (!decoder.isComplete())\n\n// If no error has been found\nif (decoder.isSuccess()) {\n  // Get the UR representation of the message\n  const ur = decoder.resultUR()\n\n  // Decode the CBOR message to a Buffer\n  const decoded = ur.decodeCBOR()\n\n  // get the original message, assuming it was a JSON object\n  const originalMessage = JSON.parse(decoded.toString())\n}\nelse {\n  // log and handle the error\n  const error = decoder.resultError()\n  console.log('Error found while decoding', error)\n  handleError(error)\n}\n\n```\n","readmeFilename":"README.md"}