knowitwhenyouseeit 1.0.1 → 2.6.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 CHANGED
@@ -1,8 +1,8 @@
1
- # [knowitwhenyouseeit](//zemnmez.github.io/knowitwhenyouseeit)
1
+ # knowitwhenyouseeit
2
2
 
3
3
  > provides functions to render client-side data but only if it matches a secure digest
4
4
 
5
- [![NPM](https://img.shields.io/npm/v/knowitwhenyouseeit.svg)](https://www.npmjs.com/package/knowitwhenyouseeit) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
5
+ [![NPM](https://img.shields.io/npm/v/knowitwhenyouseeit.svg)](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 whitelisted from 'knowitwhenyouseeit'
16
+ import allowlisted from 'knowitwhenyouseeit'
17
17
 
18
- const getMessage = whitelisted(
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,59 +1,27 @@
1
1
  {
2
+ "$schema": "https://json.schemastore.org/package.json",
2
3
  "name": "knowitwhenyouseeit",
3
- "version": "1.0.1",
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": "zemnmez/knowitwhenyouseeit",
8
- "main": "dist/index.js",
9
- "module": "dist/index.es.js",
10
- "jsnext:main": "dist/index.es.js",
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
- "scripts": {
16
- "test": "cross-env CI=1 react-scripts test --env=jsdom",
17
- "test:watch": "react-scripts test --env=jsdom",
18
- "build": "rollup -c",
19
- "start": "rollup -c -w",
20
- "prepare": "yarn run build",
21
- "predeploy": "cd example && yarn install && yarn run build",
22
- "deploy": "gh-pages -d example/build"
16
+ "version": "v2.6.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"
23
22
  },
24
23
  "devDependencies": {
25
- "@svgr/rollup": "^2.4.1",
26
- "babel-core": "^6.26.3",
27
- "babel-eslint": "^8.2.5",
28
- "babel-plugin-external-helpers": "^6.22.0",
29
- "babel-preset-env": "^1.7.0",
30
- "babel-preset-react": "^6.24.1",
31
- "babel-preset-stage-0": "^6.24.1",
32
- "cross-env": "^5.1.4",
33
- "eslint": "^5.0.1",
34
- "eslint-config-standard": "^11.0.0",
35
- "eslint-config-standard-react": "^6.0.0",
36
- "eslint-plugin-import": "^2.13.0",
37
- "eslint-plugin-node": "^7.0.1",
38
- "eslint-plugin-promise": "^4.0.0",
39
- "eslint-plugin-react": "^7.10.0",
40
- "eslint-plugin-standard": "^3.1.0",
41
- "gh-pages": "^2.0.1",
42
- "react": "^16.4.1",
43
- "react-dom": "^16.4.1",
44
- "react-scripts": "^1.1.4",
45
- "rollup": "^0.64.1",
46
- "rollup-plugin-babel": "^3.0.7",
47
- "rollup-plugin-commonjs": "^9.1.3",
48
- "rollup-plugin-node-resolve": "^3.3.0",
49
- "rollup-plugin-peer-deps-external": "^2.2.0",
50
- "rollup-plugin-postcss": "^1.6.2",
51
- "rollup-plugin-url": "^1.4.0"
52
- },
53
- "files": [
54
- "dist"
55
- ],
56
- "dependencies": {
57
- "bcryptjs": "^2.4.3"
24
+ "@types/bcryptjs": "^2.4.2",
25
+ "@types/node": "^18.7.11"
58
26
  }
59
- }
27
+ }