Initial commit
This commit is contained in:
1
node_modules/get-nonce/CHANGELOG.md
generated
vendored
Normal file
1
node_modules/get-nonce/CHANGELOG.md
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
# 1.0.0 (2020-04-16)
|
||||
21
node_modules/get-nonce/LICENSE
generated
vendored
Normal file
21
node_modules/get-nonce/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 Anton Korzunov
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
54
node_modules/get-nonce/README.md
generated
vendored
Normal file
54
node_modules/get-nonce/README.md
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
# get-nonce
|
||||
|
||||
just returns a **nonce** (number used once). No batteries included in those 46 bytes of this library.
|
||||
|
||||
---
|
||||
|
||||
- ✅ build in `webpack` support via `__webpack_nonce__`
|
||||
|
||||
# API
|
||||
|
||||
- `getNonce(): string|undefined` - returns the current `nonce`
|
||||
- `setNonce(newValue)` - set's nonce value
|
||||
|
||||
## Why?
|
||||
|
||||
Why we need a library to access `__webpack_nonce__`? Abstractions!
|
||||
|
||||
"I", as a library author, don't want to "predict" the platform "you" going to use.
|
||||
"I", as well, want an easier way to test and control `nonce` value.
|
||||
|
||||
Like - `nonce` is supported out of the box only by webpack, what you are going to do?
|
||||
|
||||
This is why this "man-in-the-middle" was created.
|
||||
Yep, think about `left-pad` :)
|
||||
|
||||
## Webpack
|
||||
|
||||
> https://webpack.js.org/guides/csp/
|
||||
|
||||
To activate the feature set a **webpack_nonce** variable needs to be included in your entry script.
|
||||
|
||||
```
|
||||
__webpack_nonce__ = uuid(); // for example
|
||||
```
|
||||
|
||||
Without `webpack` `__webpack_nonce__` is actually just a global variable,
|
||||
which makes it actually bundler independent,
|
||||
however "other bundlers" are able to replicate it only setting it as a global variable
|
||||
(as here in tests) which violates a "secure" nature of `nonce`.
|
||||
|
||||
`get-nonce` is not global.
|
||||
|
||||
## Used in
|
||||
|
||||
- `react-style-singleton` <- `react-remove-scroll` <- `react-focus-on`
|
||||
|
||||
## Inspiration
|
||||
|
||||
- [this issue](https://github.com/theKashey/react-remove-scroll/issues/21)
|
||||
- [styled-components](https://github.com/styled-components/styled-components/blob/147b0e9a1f10786551b13fd27452fcd5c678d5e0/packages/styled-components/src/utils/nonce.js)
|
||||
|
||||
# Licence
|
||||
|
||||
MIT
|
||||
2
node_modules/get-nonce/dist/es2015/index.d.ts
generated
vendored
Normal file
2
node_modules/get-nonce/dist/es2015/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export declare const setNonce: (nonce: string) => void;
|
||||
export declare const getNonce: () => string | undefined;
|
||||
13
node_modules/get-nonce/dist/es2015/index.js
generated
vendored
Normal file
13
node_modules/get-nonce/dist/es2015/index.js
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
var currentNonce;
|
||||
export var setNonce = function (nonce) {
|
||||
currentNonce = nonce;
|
||||
};
|
||||
export var getNonce = function () {
|
||||
if (currentNonce) {
|
||||
return currentNonce;
|
||||
}
|
||||
if (typeof __webpack_nonce__ !== 'undefined') {
|
||||
return __webpack_nonce__;
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
2
node_modules/get-nonce/dist/es5/index.d.ts
generated
vendored
Normal file
2
node_modules/get-nonce/dist/es5/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export declare const setNonce: (nonce: string) => void;
|
||||
export declare const getNonce: () => string | undefined;
|
||||
15
node_modules/get-nonce/dist/es5/index.js
generated
vendored
Normal file
15
node_modules/get-nonce/dist/es5/index.js
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var currentNonce;
|
||||
exports.setNonce = function (nonce) {
|
||||
currentNonce = nonce;
|
||||
};
|
||||
exports.getNonce = function () {
|
||||
if (currentNonce) {
|
||||
return currentNonce;
|
||||
}
|
||||
if (typeof __webpack_nonce__ !== 'undefined') {
|
||||
return __webpack_nonce__;
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
68
node_modules/get-nonce/package.json
generated
vendored
Normal file
68
node_modules/get-nonce/package.json
generated
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
{
|
||||
"name": "get-nonce",
|
||||
"version": "1.0.1",
|
||||
"description": "returns nonce",
|
||||
"main": "dist/es5/index.js",
|
||||
"types": "dist/es5/index.d.ts",
|
||||
"sideEffects": false,
|
||||
"repository": "git@github.com:theKashey/get-nonce.git",
|
||||
"homepage": "https://github.com/theKashey/get-nonce",
|
||||
"author": "Anton Korzunov <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"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user