{"_id":"@lukeed/csprng","_rev":"2966174","name":"@lukeed/csprng","description":"An alias package for `crypto.randomBytes` in Node.js and/or browsers","dist-tags":{"latest":"1.1.0"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"time":{"modified":"2023-05-08T06:32:05.000Z","created":"2020-10-27T20:05:36.108Z","1.1.0":"2023-03-31T19:54:10.527Z","1.0.1":"2021-11-22T04:40:50.489Z","1.0.0":"2020-10-27T20:05:36.108Z"},"users":{},"author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"https://lukeed.com"},"repository":{"type":"git","url":"git+https://github.com/lukeed/csprng.git"},"versions":{"1.1.0":{"version":"1.1.0","name":"@lukeed/csprng","repository":{"type":"git","url":"git+https://github.com/lukeed/csprng.git"},"description":"An alias package for `crypto.randomBytes` in Node.js and/or browsers","unpkg":"browser/index.min.js","browser":"browser/index.mjs","module":"node/index.mjs","main":"node/index.js","types":"index.d.ts","license":"MIT","author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"https://lukeed.com"},"exports":{".":{"browser":{"types":"./browser/index.d.ts","import":"./browser/index.mjs","require":"./browser/index.js"},"types":"./node/index.d.ts","import":"./node/index.mjs","require":"./node/index.js"},"./node":{"types":"./node/index.d.ts","import":"./node/index.mjs","require":"./node/index.js"},"./browser":{"types":"./browser/index.d.ts","import":"./browser/index.mjs","require":"./browser/index.js"},"./package.json":"./package.json"},"engines":{"node":">=8"},"scripts":{"build":"bundt","test":"uvu -r esm test"},"modes":{"browser":"src/browser.js","node":"src/node.js"},"keywords":["crypto","browser","isomorphic","getRandomValues","randomFill","random","csprng"],"devDependencies":{"bundt":"1.1.1","esm":"3.2.25","uvu":"0.5.2"},"publishConfig":{"access":"public"},"gitHead":"686b7dd9c2ee235faf98da2aaa9fcbe0315175b2","bugs":{"url":"https://github.com/lukeed/csprng/issues"},"homepage":"https://github.com/lukeed/csprng#readme","_id":"@lukeed/csprng@1.1.0","_nodeVersion":"18.12.1","_npmVersion":"8.19.2","dist":{"shasum":"1e3e4bd05c1cc7a0b2ddbd8a03f39f6e4b5e6cfe","size":2741,"noattachment":false,"key":"/@lukeed/csprng/-/@lukeed/csprng-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@lukeed/csprng/download/@lukeed/csprng-1.1.0.tgz"},"_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"directories":{},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/csprng_1.1.0_1680292450362_0.17851502573509692"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-03-31T19:54:10.527Z","publish_time":1680292450527,"_cnpm_publish_time":1680292450527},"1.0.1":{"version":"1.0.1","name":"@lukeed/csprng","repository":{"type":"git","url":"git+https://github.com/lukeed/csprng.git"},"description":"An alias package for `crypto.randomBytes` in Node.js and/or browsers","unpkg":"browser/index.min.js","browser":"browser/index.mjs","module":"node/index.mjs","main":"node/index.js","types":"index.d.ts","license":"MIT","author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"https://lukeed.com"},"exports":{".":{"browser":{"import":"./browser/index.mjs","require":"./browser/index.js"},"import":"./node/index.mjs","require":"./node/index.js"},"./node":{"import":"./node/index.mjs","require":"./node/index.js"},"./browser":{"import":"./browser/index.mjs","require":"./browser/index.js"},"./package.json":"./package.json"},"engines":{"node":">=8"},"scripts":{"build":"bundt","test":"uvu -r esm test"},"modes":{"browser":"src/browser.js","node":"src/node.js"},"keywords":["crypto","browser","isomorphic","getRandomValues","randomFill","random","csprng"],"devDependencies":{"bundt":"1.1.1","esm":"3.2.25","uvu":"0.5.2"},"publishConfig":{"access":"public"},"gitHead":"1a63cf8d207ab9ee99c8e25663593d72262cd79d","bugs":{"url":"https://github.com/lukeed/csprng/issues"},"homepage":"https://github.com/lukeed/csprng#readme","_id":"@lukeed/csprng@1.0.1","_nodeVersion":"16.13.0","_npmVersion":"8.1.0","dist":{"shasum":"625e93a0edb2c830e3c52ce2d67b9d53377c6a66","size":2721,"noattachment":false,"key":"/@lukeed/csprng/-/@lukeed/csprng-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/@lukeed/csprng/download/@lukeed/csprng-1.0.1.tgz"},"_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"directories":{},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/csprng_1.0.1_1637556050346_0.12969226903005704"},"_hasShrinkwrap":false,"publish_time":1637556050489,"_cnpm_publish_time":1637556050489},"1.0.0":{"version":"1.0.0","name":"@lukeed/csprng","repository":{"type":"git","url":"git+https://github.com/lukeed/csprng.git"},"description":"An alias package for `crypto.randomBytes` in Node.js and/or browsers","unpkg":"browser/index.min.js","browser":"browser/index.mjs","module":"node/index.mjs","main":"node/index.js","types":"index.d.ts","license":"MIT","author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"https://lukeed.com"},"exports":{".":{"import":"./node/index.mjs","browser":"./browser/index.mjs","require":"./node/index.js"},"./node":{"import":"./node/index.mjs","require":"./node/index.js"},"./browser":{"import":"./browser/index.mjs","require":"./browser/index.js"},"./package.json":"./package.json"},"engines":{"node":">=8"},"scripts":{"build":"bundt","test":"uvu -r esm test"},"modes":{"browser":"src/browser.js","node":"src/node.js"},"keywords":["crypto","browser","isomorphic","getRandomValues","randomFill","random","csprng"],"devDependencies":{"bundt":"1.1.1","esm":"3.2.25","uvu":"0.3.4"},"publishConfig":{"access":"public"},"gitHead":"ea3400f5dab50e4f1aa7e6fada951fb45f36179e","bugs":{"url":"https://github.com/lukeed/csprng/issues"},"homepage":"https://github.com/lukeed/csprng#readme","_id":"@lukeed/csprng@1.0.0","_nodeVersion":"12.18.4","_npmVersion":"6.14.6","dist":{"shasum":"733a122382749d27e2e46ec38f8c71c9d53a9636","size":2762,"noattachment":false,"key":"/@lukeed/csprng/-/@lukeed/csprng-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@lukeed/csprng/download/@lukeed/csprng-1.0.0.tgz"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/csprng_1.0.0_1603829135942_0.31539898140734124"},"_hasShrinkwrap":false,"publish_time":1603829136108,"_cnpm_publish_time":1603829136108}},"readme":"# @lukeed/csprng ![CI](https://github.com/lukeed/csprng/workflows/CI/badge.svg) [![codecov](https://badgen.now.sh/codecov/c/github/lukeed/csprng)](https://codecov.io/gh/lukeed/csprng)\n\n> A tiny (~90B) isomorphic wrapper for `crypto.randomBytes` in Node.js and browsers.\n\n***Why?***\n\nThis package allows you/dependents to import a cryptographically secure generator (CSPRNG) _without_ worrying about (aka, checking the runtime environment for) the different `crypto` implementations. Instead, by extracting a `random` function into a third-party/external package, one can rely on bundlers and/or module resolution to load the correct implementation for the desired environment.\n\nIn other words, one can include the browser-specific implementation when bundling for the browser, completely ignoring the Node.js code – or vice versa.\n\nBy default, this module is set up to work with Rollup, webpack, and Node's native ESM _and_ CommonJS path resolutions.\n\n## Install\n\n```\n$ npm install --save @lukeed/csprng\n```\n\n\n## Usage\n\n***General Usage***\n\n```js\n// Rely on bundlers/environment detection\nimport { random } from '@lukeed/csprng';\n\nconst array = random(12);\n// browser => Uint8Array(12) [...]\n// Node.js => <Buffer ...>\n```\n\n***Specific Environment***\n\n```js\n// Choose the \"browser\" implementation explicitly.\n//=> ! NOTE ! Will break in Node.js environments!\nimport { random } from '@lukeed/csprng/browser';\n\nconst array = random(1024);\n//=> Uint8Array(1024) [...]\n\n// ---\n\n// Choose the \"node\" implementation explicitly.\n//=> ! NOTE ! Will break in browser environments!\nimport { random } from '@lukeed/csprng/node';\n\nconst array = random(1024);\n//=> <Buffer ...>\n```\n\n\n## API\n\n### random(length)\nReturns: `Buffer` or `Uint8Array`\n\nReturns a typed array of given `length`.\n\n\n#### length\nType: `Number`\n\nThe desired length of your output TypedArray.\n\n\n## Related\n\n- [uid](https://github.com/lukeed/uid) - A tiny (134B) and fast utility to randomize unique IDs of fixed length\n- [@lukeed/uuid](https://github.com/lukeed/uuid) - A tiny (230B), fast, and cryptographically secure UUID (V4) generator for Node and the browser\n\n\n## License\n\nMIT © [Luke Edwards](https://lukeed.com)\n","_attachments":{},"homepage":"https://github.com/lukeed/csprng#readme","bugs":{"url":"https://github.com/lukeed/csprng/issues"},"license":"MIT"}