{"_id":"get-nonce","_rev":"409561","name":"get-nonce","description":"returns nonce","dist-tags":{"latest":"1.0.1"},"maintainers":[{"name":"kashey","email":""}],"time":{"modified":"2021-08-04T05:03:13.000Z","created":"2020-04-16T07:21:59.524Z","1.0.1":"2020-04-17T05:10:02.775Z","1.0.0":"2020-04-16T07:21:59.524Z"},"users":{},"author":{"name":"Anton Korzunov","email":"thekashey@gmail.com"},"repository":{"type":"git","url":"git+ssh://git@github.com/theKashey/get-nonce.git"},"versions":{"1.0.1":{"name":"get-nonce","version":"1.0.1","description":"returns nonce","main":"dist/es5/index.js","types":"dist/es5/index.d.ts","sideEffects":false,"repository":{"type":"git","url":"git+ssh://git@github.com/theKashey/get-nonce.git"},"homepage":"https://github.com/theKashey/get-nonce","author":{"name":"Anton Korzunov","email":"thekashey@gmail.com"},"license":"MIT","keywords":["webpack","nonce","__webpack_nonce__"],"devDependencies":{"@theuiteam/lib-builder":"^0.0.10","@size-limit/preset-small-lib":"^2.1.6"},"module":"dist/es2015/index.js","engines":{"node":">=6"},"scripts":{"dev":"lib-builder dev","test":"jest","test:ci":"jest --runInBand --coverage","build":"lib-builder build && yarn size:report","release":"yarn build && yarn test","size":"npx size-limit","size:report":"npx size-limit --json > .size.json","lint":"lib-builder lint","format":"lib-builder format","update":"lib-builder update","docz:dev":"docz dev","docz:build":"docz build","prepublish":"yarn build && yarn changelog","changelog":"conventional-changelog -p angular -i CHANGELOG.md -s","changelog:rewrite":"conventional-changelog -p angular -i CHANGELOG.md -s -r 0"},"husky":{"hooks":{"pre-commit":"lint-staged"}},"lint-staged":{"*.{ts,tsx}":["prettier --write","tslint --fix","git add"],"*.{js,css,json,md}":["prettier --write","git add"]},"prettier":{"printWidth":120,"trailingComma":"es5","tabWidth":2,"semi":true,"singleQuote":true},"gitHead":"fe602104915e8a18049dc96dfecbc10a96c03068","bugs":{"url":"https://github.com/theKashey/get-nonce/issues"},"_id":"get-nonce@1.0.1","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"shasum":"fdf3f0278073820d2ce9426c18f07481b1e0cdf3","size":2677,"noattachment":false,"key":"/get-nonce/-/get-nonce-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/get-nonce/download/get-nonce-1.0.1.tgz"},"maintainers":[{"name":"kashey","email":""}],"_npmUser":{"name":"kashey","email":"thekashey@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/get-nonce_1.0.1_1587100202601_0.5724882883753502"},"_hasShrinkwrap":false,"publish_time":1587100202775,"_cnpm_publish_time":1587100202775},"1.0.0":{"name":"get-nonce","version":"1.0.0","description":"returns nonce","main":"dist/es5/index.js","types":"dist/es5/index.d.ts","sideEffects":false,"repository":{"type":"git","url":"git+ssh://git@github.com/theKashey/get-nonce.git"},"homepage":"https://github.com/theKashey/get-nonce","author":{"name":"Anton Korzunov","email":"thekashey@gmail.com"},"license":"MIT","keywords":["webpack","nonce","__webpack_nonce__"],"devDependencies":{"@theuiteam/lib-builder":"^0.0.10","@size-limit/preset-small-lib":"^2.1.6"},"module":"dist/es2015/index.js","engines":{"node":">=10"},"scripts":{"dev":"lib-builder dev","test":"jest","test:ci":"jest --runInBand --coverage","build":"lib-builder build && yarn size:report","release":"yarn build && yarn test","size":"npx size-limit","size:report":"npx size-limit --json > .size.json","lint":"lib-builder lint","format":"lib-builder format","update":"lib-builder update","docz:dev":"docz dev","docz:build":"docz build","prepublish":"yarn build && yarn changelog","changelog":"conventional-changelog -p angular -i CHANGELOG.md -s","changelog:rewrite":"conventional-changelog -p angular -i CHANGELOG.md -s -r 0"},"husky":{"hooks":{"pre-commit":"lint-staged"}},"lint-staged":{"*.{ts,tsx}":["prettier --write","tslint --fix","git add"],"*.{js,css,json,md}":["prettier --write","git add"]},"prettier":{"printWidth":120,"trailingComma":"es5","tabWidth":2,"semi":true,"singleQuote":true},"gitHead":"c77143eb3c1fe170b1c851e5edb7ce1cf4a8dfc5","bugs":{"url":"https://github.com/theKashey/get-nonce/issues"},"_id":"get-nonce@1.0.0","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"shasum":"ac4439ffe3cb7577e69e86c25fda687f09889b0b","size":2446,"noattachment":false,"key":"/get-nonce/-/get-nonce-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/get-nonce/download/get-nonce-1.0.0.tgz"},"maintainers":[{"name":"kashey","email":""}],"_npmUser":{"name":"kashey","email":"thekashey@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/get-nonce_1.0.0_1587021719374_0.7491662280215585"},"_hasShrinkwrap":false,"publish_time":1587021719524,"_cnpm_publish_time":1587021719524}},"readme":"# get-nonce\n\njust returns a **nonce** (number used once). No batteries included in those 46 bytes of this library.\n\n---\n\n- ✅ build in `webpack` support via `__webpack_nonce__`\n\n# API\n\n- `getNonce(): string|undefined` - returns the current `nonce`\n- `setNonce(newValue)` - set's nonce value\n\n## Why?\n\nWhy we need a library to access `__webpack_nonce__`? Abstractions!\n\n\"I\", as a library author, don't want to \"predict\" the platform \"you\" going to use.\n\"I\", as well, want an easier way to test and control `nonce` value.\n\nLike - `nonce` is supported out of the box only by webpack, what you are going to do?\n\nThis is why this \"man-in-the-middle\" was created.\nYep, think about `left-pad` :)\n\n## Webpack\n\n> https://webpack.js.org/guides/csp/\n\nTo activate the feature set a **webpack_nonce** variable needs to be included in your entry script.\n\n```\n__webpack_nonce__ = uuid(); // for example\n```\n\nWithout `webpack` `__webpack_nonce__` is actually just a global variable,\nwhich makes it actually bundler independent,\nhowever \"other bundlers\" are able to replicate it only setting it as a global variable\n(as here in tests) which violates a \"secure\" nature of `nonce`.\n\n`get-nonce` is not global.\n\n## Used in\n\n- `react-style-singleton` <- `react-remove-scroll` <- `react-focus-on`\n\n## Inspiration\n\n- [this issue](https://github.com/theKashey/react-remove-scroll/issues/21)\n- [styled-components](https://github.com/styled-components/styled-components/blob/147b0e9a1f10786551b13fd27452fcd5c678d5e0/packages/styled-components/src/utils/nonce.js)\n\n# Licence\n\nMIT\n","_attachments":{},"homepage":"https://github.com/theKashey/get-nonce","bugs":{"url":"https://github.com/theKashey/get-nonce/issues"},"license":"MIT"}