@hugoalh/github-sodium 3.1.0 → 3.1.2

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,7 @@
1
1
  # GitHub Sodium (NodeJS)
2
2
 
3
- [`GitHubSodium.NodeJS`](https://github.com/hugoalh-studio/github-sodium-nodejs)
4
-
5
3
  ![License](https://img.shields.io/static/v1?label=License&message=MIT&style=flat-square "License")
4
+ [![GitHub Repository](https://img.shields.io/badge/Repository-181717?logo=github&logoColor=ffffff&style=flat-square "GitHub Repository")](https://github.com/hugoalh-studio/github-sodium-nodejs)
6
5
  [![GitHub Stars](https://img.shields.io/github/stars/hugoalh-studio/github-sodium-nodejs?label=Stars&logo=github&logoColor=ffffff&style=flat-square "GitHub Stars")](https://github.com/hugoalh-studio/github-sodium-nodejs/stargazers)
7
6
  [![GitHub Contributors](https://img.shields.io/github/contributors/hugoalh-studio/github-sodium-nodejs?label=Contributors&logo=github&logoColor=ffffff&style=flat-square "GitHub Contributors")](https://github.com/hugoalh-studio/github-sodium-nodejs/graphs/contributors)
8
7
  [![GitHub Issues](https://img.shields.io/github/issues-raw/hugoalh-studio/github-sodium-nodejs?label=Issues&logo=github&logoColor=ffffff&style=flat-square "GitHub Issues")](https://github.com/hugoalh-studio/github-sodium-nodejs/issues)
@@ -25,16 +24,12 @@ This project is based on `libsodium.js` ([GitHub](https://github.com/jedisct1/li
25
24
 
26
25
  ### Getting Started
27
26
 
28
- #### Install
29
-
30
- - NodeJS ^ v12.20.0 || ^ v14.15.0 || >= v16.13.0
27
+ - NodeJS ^ v12.20.0 \|\| ^ v14.15.0 \|\| >= v16.13.0
31
28
 
32
29
  ```sh
33
30
  npm install @hugoalh/github-sodium
34
31
  ```
35
32
 
36
- #### Use
37
-
38
33
  ```js
39
34
  /* Either */
40
35
  import { ... } from "@hugoalh/github-sodium";// Named Import
@@ -46,28 +41,16 @@ import githubSodium from "@hugoalh/github-sodium";// Default Import
46
41
 
47
42
  #### Class
48
43
 
49
- <ul>
50
- <li>
51
-
52
- ```ts
53
- new GitHubSodiumSealer(publicKey: string): GitHubSodiumSealer;
54
- .encrypt(value: string): string;
55
- ```
56
-
57
- </li>
58
- </ul>
44
+ - ```ts
45
+ new GitHubSodiumSealer(publicKey: string): GitHubSodiumSealer;
46
+ .encrypt(value: string): string;
47
+ ```
59
48
 
60
49
  #### Function
61
50
 
62
- <ul>
63
- <li>
64
-
65
- ```ts
66
- seal(publicKey: string, value: string): string;
67
- ```
68
-
69
- </li>
70
- </ul>
51
+ - ```ts
52
+ seal(publicKey: string, value: string): string;
53
+ ```
71
54
 
72
55
  ### Example
73
56
 
package/dist/main.d.ts CHANGED
@@ -1,5 +1,37 @@
1
- import GitHubSodiumSealer from "./github-sodium-sealer.js";
2
- import seal from "./seal.js";
1
+ /**
2
+ * @class GitHubSodiumSealer
3
+ * @description Encrypt value to GitHub secret value.
4
+ */
5
+ declare class GitHubSodiumSealer {
6
+ #private;
7
+ /**
8
+ * @constructor
9
+ * @param {string} publicKey Organization's or repository's public key, which need for encrypt value to secret value before create or update a secret.
10
+ */
11
+ constructor(publicKey: string);
12
+ /**
13
+ * @method encrypt
14
+ * @param {string} value Value that need to encrypt as secret value.
15
+ * @returns {string} An encrypted GitHub secret value.
16
+ */
17
+ encrypt(value: string): string;
18
+ /**
19
+ * @static seal
20
+ * @description Encrypt value to GitHub secret value.
21
+ * @param {string} publicKey Organization's or repository's public key, which need for encrypt value to secret value before create or update a secret.
22
+ * @param {string} value Value that need to encrypt as secret value.
23
+ * @returns {string} An encrypted GitHub secret value.
24
+ */
25
+ static seal(publicKey: string, value: string): string;
26
+ }
27
+ /**
28
+ * @function seal
29
+ * @description Encrypt value to GitHub secret value.
30
+ * @param {string} publicKey Organization's or repository's public key, which need for encrypt value to secret value before create or update a secret.
31
+ * @param {string} value Value that need to encrypt as secret value.
32
+ * @returns {string} An encrypted GitHub secret value.
33
+ */
34
+ declare function seal(publicKey: string, value: string): string;
3
35
  export { GitHubSodiumSealer, seal };
4
36
  declare const _default: {
5
37
  GitHubSodiumSealer: typeof GitHubSodiumSealer;
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,MAAM,2BAA2B,CAAC;AAC3D,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACN,kBAAkB,EAClB,IAAI,EACJ,CAAC;;;;;AACF,wBAGE"}
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,cAAM,kBAAkB;;IAEvB;;;OAGG;gBACS,SAAS,EAAE,MAAM;IAS7B;;;;OAIG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAS9B;;;;;;OAMG;IACH,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;CAGrD;AACD;;;;;;GAMG;AACH,iBAAS,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAEtD;AACD,OAAO,EACN,kBAAkB,EAClB,IAAI,EACJ,CAAC;;;;;AACF,wBAGE"}
package/dist/main.js CHANGED
@@ -1,5 +1,72 @@
1
- import GitHubSodiumSealer from "./github-sodium-sealer.js";
2
- import seal from "./seal.js";
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _GitHubSodiumSealer_publicKeyBuffer;
13
+ import libsodium from "libsodium-wrappers";
14
+ await libsodium.ready;
15
+ /**
16
+ * @class GitHubSodiumSealer
17
+ * @description Encrypt value to GitHub secret value.
18
+ */
19
+ class GitHubSodiumSealer {
20
+ /**
21
+ * @constructor
22
+ * @param {string} publicKey Organization's or repository's public key, which need for encrypt value to secret value before create or update a secret.
23
+ */
24
+ constructor(publicKey) {
25
+ _GitHubSodiumSealer_publicKeyBuffer.set(this, void 0);
26
+ if (typeof publicKey !== "string") {
27
+ throw new TypeError(`Argument \`publicKey\` must be type of string!`);
28
+ }
29
+ if (!(publicKey.length > 0)) {
30
+ throw new Error(`Argument \`publicKey\` must be a string which is non-empty!`);
31
+ }
32
+ __classPrivateFieldSet(this, _GitHubSodiumSealer_publicKeyBuffer, Buffer.from(publicKey, "base64"), "f");
33
+ }
34
+ /**
35
+ * @method encrypt
36
+ * @param {string} value Value that need to encrypt as secret value.
37
+ * @returns {string} An encrypted GitHub secret value.
38
+ */
39
+ encrypt(value) {
40
+ if (typeof value !== "string") {
41
+ throw new TypeError(`Argument \`value\` must be type of string!`);
42
+ }
43
+ if (!(value.length > 0)) {
44
+ throw new Error(`Argument \`value\` must be a string which is non-empty!`);
45
+ }
46
+ return Buffer.from(libsodium.crypto_box_seal(Buffer.from(value), __classPrivateFieldGet(this, _GitHubSodiumSealer_publicKeyBuffer, "f"))).toString("base64");
47
+ }
48
+ /**
49
+ * @static seal
50
+ * @description Encrypt value to GitHub secret value.
51
+ * @param {string} publicKey Organization's or repository's public key, which need for encrypt value to secret value before create or update a secret.
52
+ * @param {string} value Value that need to encrypt as secret value.
53
+ * @returns {string} An encrypted GitHub secret value.
54
+ */
55
+ static seal(publicKey, value) {
56
+ return new this(publicKey).encrypt(value);
57
+ }
58
+ }
59
+ _GitHubSodiumSealer_publicKeyBuffer = new WeakMap();
60
+ /**
61
+ * @function seal
62
+ * @description Encrypt value to GitHub secret value.
63
+ * @param {string} publicKey Organization's or repository's public key, which need for encrypt value to secret value before create or update a secret.
64
+ * @param {string} value Value that need to encrypt as secret value.
65
+ * @returns {string} An encrypted GitHub secret value.
66
+ */
67
+ function seal(publicKey, value) {
68
+ return new GitHubSodiumSealer(publicKey).encrypt(value);
69
+ }
3
70
  export { GitHubSodiumSealer, seal };
4
71
  export default {
5
72
  GitHubSodiumSealer,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hugoalh/github-sodium",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
4
4
  "description": "A module to provide an easier sodium for GitHub secrets.",
5
5
  "keywords": [
6
6
  "github",
@@ -23,17 +23,16 @@
23
23
  "url": "git+https://github.com/hugoalh-studio/github-sodium-nodejs.git"
24
24
  },
25
25
  "dependencies": {
26
- "@hugoalh/advanced-determine": "^10.2.1",
27
26
  "libsodium-wrappers": "^0.7.11"
28
27
  },
29
28
  "devDependencies": {
30
29
  "@types/libsodium-wrappers": "^0.7.10",
31
- "@types/node": "^18.15.0",
32
- "@typescript-eslint/eslint-plugin": "^5.54.1",
33
- "@typescript-eslint/parser": "^5.54.1",
34
- "eslint": "^8.36.0",
30
+ "@types/node": "^18.15.11",
31
+ "@typescript-eslint/eslint-plugin": "^5.59.0",
32
+ "@typescript-eslint/parser": "^5.59.0",
33
+ "eslint": "^8.38.0",
35
34
  "eslint-plugin-only-warn": "^1.1.0",
36
- "typescript": "^4.9.5"
35
+ "typescript": "^5.0.4"
37
36
  },
38
37
  "engines": {
39
38
  "node": "^12.20.0 || ^14.15.0 || >=16.13.0"
@@ -1,28 +0,0 @@
1
- /**
2
- * @class GitHubSodiumSealer
3
- * @description Encrypt value to GitHub secret value.
4
- */
5
- declare class GitHubSodiumSealer {
6
- #private;
7
- /**
8
- * @constructor
9
- * @param {string} publicKey Organization's or repository's public key, which need for encrypt value to secret value before create or update a secret.
10
- */
11
- constructor(publicKey: string);
12
- /**
13
- * @method encrypt
14
- * @param {string} value Value that need to encrypt as secret value.
15
- * @returns {string} An encrypted GitHub secret value.
16
- */
17
- encrypt(value: string): string;
18
- /**
19
- * @static seal
20
- * @description Encrypt value to GitHub secret value.
21
- * @param {string} publicKey Organization's or repository's public key, which need for encrypt value to secret value before create or update a secret.
22
- * @param {string} value Value that need to encrypt as secret value.
23
- * @returns {string} An encrypted GitHub secret value.
24
- */
25
- static seal(publicKey: string, value: string): string;
26
- }
27
- export default GitHubSodiumSealer;
28
- //# sourceMappingURL=github-sodium-sealer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"github-sodium-sealer.d.ts","sourceRoot":"","sources":["../src/github-sodium-sealer.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,cAAM,kBAAkB;;IAEvB;;;OAGG;gBACS,SAAS,EAAE,MAAM;IAM7B;;;;OAIG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAM9B;;;;;;OAMG;IACH,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;CAGrD;AACD,eAAe,kBAAkB,CAAC"}
@@ -1,56 +0,0 @@
1
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
- if (kind === "m") throw new TypeError("Private method is not writable");
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
- };
7
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
- };
12
- var _GitHubSodiumSealer_publicKeyStorage;
13
- import { StringItemFilter } from "@hugoalh/advanced-determine";
14
- import libsodium from "libsodium-wrappers";
15
- await libsodium.ready;
16
- const stringFilter = new StringItemFilter();
17
- /**
18
- * @class GitHubSodiumSealer
19
- * @description Encrypt value to GitHub secret value.
20
- */
21
- class GitHubSodiumSealer {
22
- /**
23
- * @constructor
24
- * @param {string} publicKey Organization's or repository's public key, which need for encrypt value to secret value before create or update a secret.
25
- */
26
- constructor(publicKey) {
27
- _GitHubSodiumSealer_publicKeyStorage.set(this, void 0);
28
- if (!stringFilter.test(publicKey)) {
29
- throw new TypeError(`Argument \`publicKey\` must be type of string (non-empty)!`);
30
- }
31
- __classPrivateFieldSet(this, _GitHubSodiumSealer_publicKeyStorage, Buffer.from(publicKey, "base64"), "f");
32
- }
33
- /**
34
- * @method encrypt
35
- * @param {string} value Value that need to encrypt as secret value.
36
- * @returns {string} An encrypted GitHub secret value.
37
- */
38
- encrypt(value) {
39
- if (!stringFilter.test(value)) {
40
- throw new TypeError(`Argument \`value\` must be type of string (non-empty)!`);
41
- }
42
- return Buffer.from(libsodium.crypto_box_seal(Buffer.from(value), __classPrivateFieldGet(this, _GitHubSodiumSealer_publicKeyStorage, "f"))).toString("base64");
43
- }
44
- /**
45
- * @static seal
46
- * @description Encrypt value to GitHub secret value.
47
- * @param {string} publicKey Organization's or repository's public key, which need for encrypt value to secret value before create or update a secret.
48
- * @param {string} value Value that need to encrypt as secret value.
49
- * @returns {string} An encrypted GitHub secret value.
50
- */
51
- static seal(publicKey, value) {
52
- return new this(publicKey).encrypt(value);
53
- }
54
- }
55
- _GitHubSodiumSealer_publicKeyStorage = new WeakMap();
56
- export default GitHubSodiumSealer;
package/dist/seal.d.ts DELETED
@@ -1,10 +0,0 @@
1
- /**
2
- * @function seal
3
- * @description Encrypt value to GitHub secret value.
4
- * @param {string} publicKey Organization's or repository's public key, which need for encrypt value to secret value before create or update a secret.
5
- * @param {string} value Value that need to encrypt as secret value.
6
- * @returns {string} An encrypted GitHub secret value.
7
- */
8
- declare function seal(publicKey: string, value: string): string;
9
- export default seal;
10
- //# sourceMappingURL=seal.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"seal.d.ts","sourceRoot":"","sources":["../src/seal.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AACH,iBAAS,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAEtD;AACD,eAAe,IAAI,CAAC"}
package/dist/seal.js DELETED
@@ -1,12 +0,0 @@
1
- import GitHubSodiumSealer from "./github-sodium-sealer.js";
2
- /**
3
- * @function seal
4
- * @description Encrypt value to GitHub secret value.
5
- * @param {string} publicKey Organization's or repository's public key, which need for encrypt value to secret value before create or update a secret.
6
- * @param {string} value Value that need to encrypt as secret value.
7
- * @returns {string} An encrypted GitHub secret value.
8
- */
9
- function seal(publicKey, value) {
10
- return new GitHubSodiumSealer(publicKey).encrypt(value);
11
- }
12
- export default seal;