knowitwhenyouseeit 1.0.0 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/index.d.ts +16 -0
- package/index.js +20 -0
- package/package.json +15 -52
- package/dist/index.es.js +0 -1430
- package/dist/index.es.js.map +0 -1
- package/dist/index.js +0 -1434
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# knowitwhenyouseeit
|
|
2
2
|
|
|
3
3
|
> provides functions to render client-side data but only if it matches a secure digest
|
|
4
4
|
|
|
5
|
-
[](https://www.npmjs.com/package/knowitwhenyouseeit)
|
|
5
|
+
[](https://www.npmjs.com/package/knowitwhenyouseeit)
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -13,9 +13,9 @@ yarn add knowitwhenyouseeit
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
15
|
```jsx
|
|
16
|
-
import
|
|
16
|
+
import allowlisted from 'knowitwhenyouseeit'
|
|
17
17
|
|
|
18
|
-
const getMessage =
|
|
18
|
+
const getMessage = allowllisted(
|
|
19
19
|
"$2y$12$BcuZ0VfUeLLpoLxOC5Xv7eQQK0r95by8YJsECCldKP4ftPr20rpXW", //hello world
|
|
20
20
|
"$2y$12$hxyWxMx.qap70Snn1QKMwuDp/9XgNM7HpwbrGnsPu/j7dyTEWh0M2" //hewwo world
|
|
21
21
|
)
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Allowlist takes a set of bcrypt digests, and returns a function which, when passed an input returns that
|
|
3
|
+
* same input provided it matches one of the bcrypt digests. Otherwise, it returns `false`.
|
|
4
|
+
*
|
|
5
|
+
* This can be used to store some secret in the client without making it implicitly available to anyone who views the source.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* // if our website is https://cool.com, this alerts 'hello world' if loaded as https://cool.com#hello%20world
|
|
9
|
+
* const getMessage = allowlist('$2y$12$hxyWxMx.qap70Snn1QKMwuDp/9XgNM7HpwbrGnsPu/j7dyTEWh0M2');
|
|
10
|
+
* alert(getMessage(decodeURIComponent(window.hash.slice(1))))
|
|
11
|
+
*/
|
|
12
|
+
declare const allowlist: (...bcrypt_digests: string[]) => <S extends string>(input: S) => false | S;
|
|
13
|
+
export { allowlist }
|
|
14
|
+
export default allowlist;
|
|
15
|
+
|
|
16
|
+
export { }
|
package/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.default = exports.allowlist = void 0;
|
|
6
|
+
var _bcryptjs = _interopRequireDefault(require("bcryptjs"));
|
|
7
|
+
function _interopRequireDefault(obj) {
|
|
8
|
+
return obj && obj.__esModule ? obj : {
|
|
9
|
+
default: obj
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
const allowlist = (...bcrypt_digests)=>(input)=>bcrypt_digests.some((digest)=>_bcryptjs.default.compareSync(input, digest)
|
|
13
|
+
) && input
|
|
14
|
+
;
|
|
15
|
+
exports.allowlist = allowlist;
|
|
16
|
+
var _default = allowlist;
|
|
17
|
+
exports.default = _default;
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,64 +1,27 @@
|
|
|
1
1
|
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/package.json",
|
|
2
3
|
"name": "knowitwhenyouseeit",
|
|
3
|
-
"version": "1.0.0",
|
|
4
4
|
"description": "provides functions to render client-side data but only if it matches a secure digest",
|
|
5
5
|
"author": "zemnmez",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"repository":
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/Zemnmez/monorepo.git",
|
|
10
|
+
"directory": "ts/knowitwhenyouseeit"
|
|
11
|
+
},
|
|
11
12
|
"engines": {
|
|
12
13
|
"node": ">=8",
|
|
13
14
|
"npm": ">=5"
|
|
14
15
|
},
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"predeploy": "cd example && yarn install && yarn run build",
|
|
22
|
-
"deploy": "gh-pages -d example/build"
|
|
23
|
-
},
|
|
24
|
-
"peerDependencies": {
|
|
25
|
-
"prop-types": "^15.5.4",
|
|
26
|
-
"react": "^15.0.0 || ^16.0.0",
|
|
27
|
-
"react-dom": "^15.0.0 || ^16.0.0"
|
|
16
|
+
"version": "v2.5.1",
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"bcryptjs": "^2.4.3",
|
|
19
|
+
"react": "18.2.0",
|
|
20
|
+
"react-dom": "^18.2.0",
|
|
21
|
+
"regenerator-runtime": "^0.13.9"
|
|
28
22
|
},
|
|
29
23
|
"devDependencies": {
|
|
30
|
-
"@
|
|
31
|
-
"
|
|
32
|
-
"babel-eslint": "^8.2.5",
|
|
33
|
-
"babel-plugin-external-helpers": "^6.22.0",
|
|
34
|
-
"babel-preset-env": "^1.7.0",
|
|
35
|
-
"babel-preset-react": "^6.24.1",
|
|
36
|
-
"babel-preset-stage-0": "^6.24.1",
|
|
37
|
-
"cross-env": "^5.1.4",
|
|
38
|
-
"eslint": "^5.0.1",
|
|
39
|
-
"eslint-config-standard": "^11.0.0",
|
|
40
|
-
"eslint-config-standard-react": "^6.0.0",
|
|
41
|
-
"eslint-plugin-import": "^2.13.0",
|
|
42
|
-
"eslint-plugin-node": "^7.0.1",
|
|
43
|
-
"eslint-plugin-promise": "^4.0.0",
|
|
44
|
-
"eslint-plugin-react": "^7.10.0",
|
|
45
|
-
"eslint-plugin-standard": "^3.1.0",
|
|
46
|
-
"gh-pages": "^1.2.0",
|
|
47
|
-
"react": "^16.4.1",
|
|
48
|
-
"react-dom": "^16.4.1",
|
|
49
|
-
"react-scripts": "^1.1.4",
|
|
50
|
-
"rollup": "^0.64.1",
|
|
51
|
-
"rollup-plugin-babel": "^3.0.7",
|
|
52
|
-
"rollup-plugin-commonjs": "^9.1.3",
|
|
53
|
-
"rollup-plugin-node-resolve": "^3.3.0",
|
|
54
|
-
"rollup-plugin-peer-deps-external": "^2.2.0",
|
|
55
|
-
"rollup-plugin-postcss": "^1.6.2",
|
|
56
|
-
"rollup-plugin-url": "^1.4.0"
|
|
57
|
-
},
|
|
58
|
-
"files": [
|
|
59
|
-
"dist"
|
|
60
|
-
],
|
|
61
|
-
"dependencies": {
|
|
62
|
-
"bcryptjs": "^2.4.3"
|
|
24
|
+
"@types/bcryptjs": "^2.4.2",
|
|
25
|
+
"@types/node": "^18.7.9"
|
|
63
26
|
}
|
|
64
|
-
}
|
|
27
|
+
}
|