@hugoalh/github-sodium 2.0.1 → 3.0.0

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,28 +1,26 @@
1
1
  # GitHub Sodium (NodeJS)
2
2
 
3
3
  [`GitHubSodium.NodeJS`](https://github.com/hugoalh-studio/github-sodium-nodejs)
4
- [![GitHub Contributors](https://img.shields.io/github/contributors/hugoalh-studio/github-sodium-nodejs?label=Contributors&logo=github&logoColor=ffffff&style=flat-square)](https://github.com/hugoalh-studio/github-sodium-nodejs/graphs/contributors)
5
- [![GitHub Issues](https://img.shields.io/github/issues-raw/hugoalh-studio/github-sodium-nodejs?label=Issues&logo=github&logoColor=ffffff&style=flat-square)](https://github.com/hugoalh-studio/github-sodium-nodejs/issues)
6
- [![GitHub Pull Requests](https://img.shields.io/github/issues-pr-raw/hugoalh-studio/github-sodium-nodejs?label=Pull%20Requests&logo=github&logoColor=ffffff&style=flat-square)](https://github.com/hugoalh-studio/github-sodium-nodejs/pulls)
7
- [![GitHub Discussions](https://img.shields.io/github/discussions/hugoalh-studio/github-sodium-nodejs?label=Discussions&logo=github&logoColor=ffffff&style=flat-square)](https://github.com/hugoalh-studio/github-sodium-nodejs/discussions)
8
- [![GitHub Stars](https://img.shields.io/github/stars/hugoalh-studio/github-sodium-nodejs?label=Stars&logo=github&logoColor=ffffff&style=flat-square)](https://github.com/hugoalh-studio/github-sodium-nodejs/stargazers)
9
- [![GitHub Forks](https://img.shields.io/github/forks/hugoalh-studio/github-sodium-nodejs?label=Forks&logo=github&logoColor=ffffff&style=flat-square)](https://github.com/hugoalh-studio/github-sodium-nodejs/network/members)
10
- ![GitHub Languages](https://img.shields.io/github/languages/count/hugoalh-studio/github-sodium-nodejs?label=Languages&logo=github&logoColor=ffffff&style=flat-square)
11
- [![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/hugoalh-studio/github-sodium-nodejs?label=Grade&logo=codefactor&logoColor=ffffff&style=flat-square)](https://www.codefactor.io/repository/github/hugoalh-studio/github-sodium-nodejs)
12
- [![LGTM Alerts](https://img.shields.io/lgtm/alerts/g/hugoalh-studio/github-sodium-nodejs?label=Alerts&logo=lgtm&logoColor=ffffff&style=flat-square)
13
- ![LGTM Grade](https://img.shields.io/lgtm/grade/javascript/g/hugoalh-studio/github-sodium-nodejs?label=Grade&logo=lgtm&logoColor=ffffff&style=flat-square)](https://lgtm.com/projects/g/hugoalh-studio/github-sodium-nodejs)
14
- [![License](https://img.shields.io/static/v1?label=License&message=MIT&style=flat-square)](./LICENSE.md)
15
-
16
- | **Release** | **Latest** (![GitHub Latest Release Date](https://img.shields.io/github/release-date/hugoalh-studio/github-sodium-nodejs?label=%20&style=flat-square)) | **Pre** (![GitHub Latest Pre-Release Date](https://img.shields.io/github/release-date-pre/hugoalh-studio/github-sodium-nodejs?label=%20&style=flat-square)) |
4
+
5
+ ![NodeJS](https://img.shields.io/badge/NodeJS-339933?logo=nodedotjs&logoColor=ffffff&style=flat-square "NodeJS")
6
+ ![License](https://img.shields.io/static/v1?label=License&message=MIT&style=flat-square "License")
7
+ [![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)
8
+ [![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)
9
+ [![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)
10
+ [![GitHub Pull Requests](https://img.shields.io/github/issues-pr-raw/hugoalh-studio/github-sodium-nodejs?label=Pull%20Requests&logo=github&logoColor=ffffff&style=flat-square "GitHub Pull Requests")](https://github.com/hugoalh-studio/github-sodium-nodejs/pulls)
11
+ [![GitHub Discussions](https://img.shields.io/github/discussions/hugoalh-studio/github-sodium-nodejs?label=Discussions&logo=github&logoColor=ffffff&style=flat-square "GitHub Discussions")](https://github.com/hugoalh-studio/github-sodium-nodejs/discussions)
12
+ [![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/hugoalh-studio/github-sodium-nodejs?label=Grade&logo=codefactor&logoColor=ffffff&style=flat-square "CodeFactor Grade")](https://www.codefactor.io/repository/github/hugoalh-studio/github-sodium-nodejs)
13
+
14
+ | **Releases** | **Latest** (![GitHub Latest Release Date](https://img.shields.io/github/release-date/hugoalh-studio/github-sodium-nodejs?label=&style=flat-square "GitHub Latest Release Date")) | **Pre** (![GitHub Latest Pre-Release Date](https://img.shields.io/github/release-date-pre/hugoalh-studio/github-sodium-nodejs?label=&style=flat-square "GitHub Latest Pre-Release Date")) |
17
15
  |:-:|:-:|:-:|
18
- | [**GitHub**](https://github.com/hugoalh-studio/github-sodium-nodejs/releases) ![GitHub Total Downloads](https://img.shields.io/github/downloads/hugoalh-studio/github-sodium-nodejs/total?label=%20&style=flat-square) | ![GitHub Latest Release Version](https://img.shields.io/github/release/hugoalh-studio/github-sodium-nodejs?sort=semver&label=%20&style=flat-square) | ![GitHub Latest Pre-Release Version](https://img.shields.io/github/release/hugoalh-studio/github-sodium-nodejs?include_prereleases&sort=semver&label=%20&style=flat-square) |
19
- | [**NPM**](https://www.npmjs.com/package/@hugoalh/github-sodium) ![NPM Total Downloads](https://img.shields.io/npm/dt/@hugoalh/github-sodium?label=%20&style=flat-square) | ![NPM Latest Release Version](https://img.shields.io/npm/v/@hugoalh/github-sodium/latest?label=%20&style=flat-square) | ![NPM Latest Pre-Release Version](https://img.shields.io/npm/v/@hugoalh/github-sodium/pre?label=%20&style=flat-square) |
16
+ | [![GitHub](https://img.shields.io/badge/GitHub-181717?logo=github&logoColor=ffffff&style=flat-square "GitHub")](https://github.com/hugoalh-studio/github-sodium-nodejs/releases) ![GitHub Total Downloads](https://img.shields.io/github/downloads/hugoalh-studio/github-sodium-nodejs/total?label=&style=flat-square "GitHub Total Downloads") | ![GitHub Latest Release Version](https://img.shields.io/github/release/hugoalh-studio/github-sodium-nodejs?sort=semver&label=&style=flat-square "GitHub Latest Release Version") | ![GitHub Latest Pre-Release Version](https://img.shields.io/github/release/hugoalh-studio/github-sodium-nodejs?include_prereleases&sort=semver&label=&style=flat-square "GitHub Latest Pre-Release Version") |
17
+ | [![NPM](https://img.shields.io/badge/NPM-CB3837?logo=npm&logoColor=ffffff&style=flat-square "NPM")](https://www.npmjs.com/package/@hugoalh/github-sodium) ![NPM Total Downloads](https://img.shields.io/npm/dt/@hugoalh/github-sodium?label=&style=flat-square "NPM Total Downloads") | ![NPM Latest Release Version](https://img.shields.io/npm/v/@hugoalh/github-sodium/latest?label=&style=flat-square "NPM Latest Release Version") | ![NPM Latest Pre-Release Version](https://img.shields.io/npm/v/@hugoalh/github-sodium/pre?label=&style=flat-square "NPM Latest Pre-Release Version") |
20
18
 
21
19
  ## 📝 Description
22
20
 
23
- A NodeJS module to provide an easier sodium for GitHub secret.
21
+ A NodeJS module to provide an easier sodium for GitHub secrets.
24
22
 
25
- This project is based on `libsodium.js` ([GitHub](https://github.com/jedisct1/libsodium.js))([NPM](https://www.npmjs.com/package/libsodium))(for ModuleJS) and `tweetsodium` ([GitHub](https://github.com/github/tweetsodium))([NPM](https://www.npmjs.com/package/tweetsodium))(for CommonJS) with optimization for GitHub secret.
23
+ This project is based on `libsodium.js` ([GitHub](https://github.com/jedisct1/libsodium.js))([NPM](https://www.npmjs.com/package/libsodium)) with optimization for GitHub secrets.
26
24
 
27
25
  ## 📚 Documentation
28
26
 
@@ -30,20 +28,13 @@ This project is based on `libsodium.js` ([GitHub](https://github.com/jedisct1/li
30
28
 
31
29
  #### Install
32
30
 
33
- - NodeJS >= v14.15.0
34
- - NPM >= v6.14.8
31
+ - NodeJS ^ v12.20.0 || ^ v14.15.0 || >= v16.13.0
35
32
 
36
33
  ```sh
37
34
  npm install @hugoalh/github-sodium
38
35
  ```
39
36
 
40
- #### Use In CommonJS
41
-
42
- ```js
43
- const githubSodium = require("@hugoalh/github-sodium");
44
- ```
45
-
46
- #### Use In ModuleJS
37
+ #### Use
47
38
 
48
39
  ```js
49
40
  /* Either */
@@ -56,13 +47,37 @@ import { ... } from "@hugoalh/github-sodium";// Part / Tree-shake
56
47
 
57
48
  #### Class
58
49
 
59
- - `GitHubSodiumSealer`
60
- - `@constructor(publicKey)`
61
- - `encrypt(value)`
50
+ <ul>
51
+ <li><code>GitHubSodiumSealer</code></li>
52
+ <ul>
53
+ <li>
54
+
55
+ ```ts
56
+ @constructor(publicKey: string): GitHubSodiumSealer
57
+ ```
58
+
59
+ </li>
60
+ <li>
61
+
62
+ ```ts
63
+ encrypt(value: string): string
64
+ ```
65
+
66
+ </li>
67
+ </ul>
68
+ </ul>
62
69
 
63
70
  #### Function
64
71
 
65
- - `seal(publicKey, value)`
72
+ <ul>
73
+ <li>
74
+
75
+ ```ts
76
+ seal(publicKey: string, value: string): string
77
+ ```
78
+
79
+ </li>
80
+ </ul>
66
81
 
67
82
  ### Example
68
83
 
@@ -1,4 +1,4 @@
1
- export = GitHubSodiumSealer;
1
+ export default GitHubSodiumSealer;
2
2
  /**
3
3
  * @class GitHubSodiumSealer
4
4
  * @description Encrypt value to GitHub secret value.
@@ -1 +1 @@
1
- {"version":3,"file":"github-sodium-sealer.d.ts","sourceRoot":"","sources":["github-sodium-sealer.js"],"names":[],"mappings":";AAEA;;;GAGG;AACH;IAEC;;;OAGG;IACH,uBAFW,MAAM,EAOhB;IACD;;;;OAIG;IACH,eAHW,MAAM,GACJ,MAAM,CAOlB;;CACD"}
1
+ {"version":3,"file":"github-sodium-sealer.d.ts","sourceRoot":"","sources":["github-sodium-sealer.js"],"names":[],"mappings":";AAGA;;;GAGG;AACH;IAEC;;;OAGG;IACH,uBAFW,MAAM,EAOhB;IACD;;;;OAIG;IACH,eAHW,MAAM,GACJ,MAAM,CAOlB;;CACD"}
@@ -1,5 +1,6 @@
1
- const advancedDetermine = require("@hugoalh/advanced-determine");
2
- const tweetsodium = require("tweetsodium");
1
+ import { isString as adIsString } from "@hugoalh/advanced-determine";
2
+ import libsodium from "libsodium-wrappers";
3
+ await libsodium.ready;
3
4
  /**
4
5
  * @class GitHubSodiumSealer
5
6
  * @description Encrypt value to GitHub secret value.
@@ -11,21 +12,21 @@ class GitHubSodiumSealer {
11
12
  * @param {string} publicKey Organization's or repository's public key, which need for encrypt value to secret value before create or update a secret.
12
13
  */
13
14
  constructor(publicKey) {
14
- if (!advancedDetermine.isString(publicKey, { empty: false })) {
15
+ if (!adIsString(publicKey, { empty: false })) {
15
16
  throw new TypeError(`Argument \`publicKey\` must be type of string (non-empty)!`);
16
- };
17
+ }
17
18
  this.#publicKeyStorage = Buffer.from(publicKey, "base64");
18
- };
19
+ }
19
20
  /**
20
21
  * @method
21
22
  * @param {string} value Value that need to encrypt as secret value.
22
23
  * @returns {string} An encrypted GitHub secret value.
23
24
  */
24
25
  encrypt(value) {
25
- if (!advancedDetermine.isString(value, { empty: false })) {
26
+ if (!adIsString(value, { empty: false })) {
26
27
  throw new TypeError(`Argument \`value\` must be type of string (non-empty)!`);
27
- };
28
- return Buffer.from(tweetsodium.seal(Buffer.from(value), this.#publicKeyStorage)).toString("base64");
29
- };
30
- };
31
- module.exports = GitHubSodiumSealer;
28
+ }
29
+ return Buffer.from(libsodium.crypto_box_seal(Buffer.from(value), this.#publicKeyStorage)).toString("base64");
30
+ }
31
+ }
32
+ export default GitHubSodiumSealer;
package/lib/main.d.ts CHANGED
@@ -1,4 +1,9 @@
1
- import GitHubSodiumSealer = require("./github-sodium-sealer.js");
2
- import seal = require("./seal.js");
1
+ declare namespace _default {
2
+ export { GitHubSodiumSealer };
3
+ export { seal };
4
+ }
5
+ export default _default;
6
+ import GitHubSodiumSealer from "./github-sodium-sealer.js";
7
+ import seal from "./seal.js";
3
8
  export { GitHubSodiumSealer, seal };
4
9
  //# sourceMappingURL=main.d.ts.map
package/lib/main.js CHANGED
@@ -1,6 +1,10 @@
1
- const GitHubSodiumSealer = require("./github-sodium-sealer.js");
2
- const seal = require("./seal.js");
3
- module.exports = {
1
+ import GitHubSodiumSealer from "./github-sodium-sealer.js";
2
+ import seal from "./seal.js";
3
+ export {
4
+ GitHubSodiumSealer,
5
+ seal
6
+ };
7
+ export default {
4
8
  GitHubSodiumSealer,
5
9
  seal
6
10
  };
package/lib/seal.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export = seal;
1
+ export default seal;
2
2
  /**
3
3
  * @function seal
4
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.
package/lib/seal.js CHANGED
@@ -1,4 +1,4 @@
1
- const GitHubSodiumSealer = require("./github-sodium-sealer.js");
1
+ import GitHubSodiumSealer from "./github-sodium-sealer.js";
2
2
  /**
3
3
  * @function seal
4
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.
@@ -7,5 +7,5 @@ const GitHubSodiumSealer = require("./github-sodium-sealer.js");
7
7
  */
8
8
  function seal(publicKey, value) {
9
9
  return new GitHubSodiumSealer(publicKey).encrypt(value);
10
- };
11
- module.exports = seal;
10
+ }
11
+ export default seal;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hugoalh/github-sodium",
3
- "version": "2.0.1",
4
- "description": "A module to provide an easier sodium for GitHub secret.",
3
+ "version": "3.0.0",
4
+ "description": "A module to provide an easier sodium for GitHub secrets.",
5
5
  "keywords": [
6
6
  "github",
7
7
  "sodium"
@@ -12,11 +12,10 @@
12
12
  },
13
13
  "license": "MIT",
14
14
  "author": "hugoalh",
15
+ "type": "module",
15
16
  "main": "./lib/main.js",
16
- "module": "./lib/main.mjs",
17
17
  "exports": {
18
- "import": "./lib/main.mjs",
19
- "require": "./lib/main.js"
18
+ "import": "./lib/main.js"
20
19
  },
21
20
  "types": "./lib/main.d.ts",
22
21
  "repository": {
@@ -24,16 +23,18 @@
24
23
  "url": "git+https://github.com/hugoalh-studio/github-sodium-nodejs.git"
25
24
  },
26
25
  "dependencies": {
27
- "@hugoalh/advanced-determine": "^7.1.3",
28
- "libsodium-wrappers": "^0.7.10",
29
- "tweetsodium": "^0.0.6"
26
+ "@hugoalh/advanced-determine": "^7.1.4",
27
+ "libsodium-wrappers": "^0.7.10"
30
28
  },
31
29
  "devDependencies": {
32
- "@types/libsodium-wrappers": "^0.7.9"
30
+ "@types/libsodium-wrappers": "^0.7.9",
31
+ "@types/node": "^18.7.18",
32
+ "eslint": "^8.23.1",
33
+ "eslint-plugin-only-warn": "^1.0.3",
34
+ "typescript": "^4.8.3"
33
35
  },
34
36
  "engines": {
35
- "node": ">= 14.15.0",
36
- "npm": ">= 6.14.8"
37
+ "node": "^12.20.0 || ^14.15.0 || >=16.13.0"
37
38
  },
38
39
  "private": false
39
40
  }
@@ -1,20 +0,0 @@
1
- export default GitHubSodiumSealer;
2
- /**
3
- * @class GitHubSodiumSealer
4
- * @description Encrypt value to GitHub secret value.
5
- */
6
- declare class GitHubSodiumSealer {
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
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
- #private;
19
- }
20
- //# sourceMappingURL=github-sodium-sealer.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"github-sodium-sealer.d.mts","sourceRoot":"","sources":["github-sodium-sealer.mjs"],"names":[],"mappings":";AAGA;;;GAGG;AACH;IAEC;;;OAGG;IACH,uBAFW,MAAM,EAOhB;IACD;;;;OAIG;IACH,eAHW,MAAM,GACJ,MAAM,CAOlB;;CACD"}
@@ -1,32 +0,0 @@
1
- import { isString as adIsString } from "@hugoalh/advanced-determine";
2
- import libsodium from "libsodium-wrappers";
3
- await libsodium.ready;
4
- /**
5
- * @class GitHubSodiumSealer
6
- * @description Encrypt value to GitHub secret value.
7
- */
8
- class GitHubSodiumSealer {
9
- #publicKeyStorage;
10
- /**
11
- * @constructor
12
- * @param {string} publicKey Organization's or repository's public key, which need for encrypt value to secret value before create or update a secret.
13
- */
14
- constructor(publicKey) {
15
- if (!adIsString(publicKey, { empty: false })) {
16
- throw new TypeError(`Argument \`publicKey\` must be type of string (non-empty)!`);
17
- };
18
- this.#publicKeyStorage = Buffer.from(publicKey, "base64");
19
- };
20
- /**
21
- * @method
22
- * @param {string} value Value that need to encrypt as secret value.
23
- * @returns {string} An encrypted GitHub secret value.
24
- */
25
- encrypt(value) {
26
- if (!adIsString(value, { empty: false })) {
27
- throw new TypeError(`Argument \`value\` must be type of string (non-empty)!`);
28
- };
29
- return Buffer.from(libsodium.crypto_box_seal(Buffer.from(value), this.#publicKeyStorage)).toString("base64");
30
- };
31
- };
32
- export default GitHubSodiumSealer;
package/lib/main.d.mts DELETED
@@ -1,9 +0,0 @@
1
- declare namespace _default {
2
- export { GitHubSodiumSealer };
3
- export { seal };
4
- }
5
- export default _default;
6
- import GitHubSodiumSealer from "./github-sodium-sealer.mjs";
7
- import seal from "./seal.mjs";
8
- export { GitHubSodiumSealer, seal };
9
- //# sourceMappingURL=main.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"main.d.mts","sourceRoot":"","sources":["main.mjs"],"names":[],"mappings":""}
package/lib/main.mjs DELETED
@@ -1,10 +0,0 @@
1
- import GitHubSodiumSealer from "./github-sodium-sealer.mjs";
2
- import seal from "./seal.mjs";
3
- export {
4
- GitHubSodiumSealer,
5
- seal
6
- };
7
- export default {
8
- GitHubSodiumSealer,
9
- seal
10
- };
package/lib/seal.d.mts DELETED
@@ -1,9 +0,0 @@
1
- export default seal;
2
- /**
3
- * @function seal
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
- //# sourceMappingURL=seal.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"seal.d.mts","sourceRoot":"","sources":["seal.mjs"],"names":[],"mappings":";AACA;;;;;GAKG;AACH,iCAJW,MAAM,SACN,MAAM,GACJ,MAAM,CAIlB"}
package/lib/seal.mjs DELETED
@@ -1,11 +0,0 @@
1
- import GitHubSodiumSealer from "./github-sodium-sealer.mjs";
2
- /**
3
- * @function seal
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
- function seal(publicKey, value) {
9
- return new GitHubSodiumSealer(publicKey).encrypt(value);
10
- };
11
- export default seal;