@hugoalh/github-sodium 1.1.2 → 1.1.6

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.
@@ -0,0 +1,10 @@
1
+ export default githubSodium;
2
+ /**
3
+ * @function githubSodium
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
+ declare function githubSodium(publicKey: string, value: string): string;
10
+ //# sourceMappingURL=main.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.mts","sourceRoot":"","sources":["../lib/main.mjs"],"names":[],"mappings":";AACA;;;;;;GAMG;AACH,yCAJW,MAAM,SACN,MAAM,GACJ,MAAM,CAgBlB"}
@@ -0,0 +1,10 @@
1
+ export = githubSodium;
2
+ /**
3
+ * @function githubSodium
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
+ declare function githubSodium(publicKey: string, value: string): string;
10
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../lib/main.js"],"names":[],"mappings":";AACA;;;;;;GAMG;AACH,yCAJW,MAAM,SACN,MAAM,GACJ,MAAM,CAgBlB"}
package/LICENSE.md CHANGED
@@ -2,21 +2,26 @@
2
2
 
3
3
  © 2020 hugoalh Studio
4
4
 
5
- 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:
5
+ 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:
6
6
 
7
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the software.
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
8
 
9
- 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.
9
+ 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.
10
10
 
11
11
  ---
12
12
 
13
- *This is a short and simple list that mostly concluded this license about the permission(s), condition(s), and limitation(s); The license content section shall prevail.*
13
+ *This is a short and simple list that mostly concluded this license about the permissions 🟢, conditions 🔵, and limitations 🔴, this license content section shall prevail.*
14
14
 
15
- | | |
16
- |:-:|:--|
17
- | ✔ | Commercial Use |
18
- | ✔ | Distribution |
19
- | ✔ | Modification |
20
- | ✔ | Private Use |
21
- | ❌ | Liability |
22
- | ❌ | Warranty |
15
+ - Commercial Use 🟢
16
+ - Distribution 🟢
17
+ - Modification 🟢
18
+ - Patent Use
19
+ - Private Use 🟢
20
+ - Disclose Source
21
+ - License & Copyright Notice 🔵
22
+ - Network Use Is Distribution
23
+ - Same License
24
+ - State Changes
25
+ - Liability 🔴
26
+ - Trademark Use
27
+ - Warranty 🔴
package/README.md CHANGED
@@ -1,7 +1,6 @@
1
- # GitHub Sodium (NodeJS Edition)
2
-
3
- [`GitHubSodium.NodeJS`](https://github.com/hugoalh-studio/github-sodium-nodejs) - A NodeJS module to provide an easier sodium for GitHub secret.
1
+ # GitHub Sodium (NodeJS)
4
2
 
3
+ [`GitHubSodium.NodeJS`](https://github.com/hugoalh-studio/github-sodium-nodejs)
5
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)
6
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)
7
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)
@@ -14,51 +13,53 @@
14
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)
15
14
  [![License](https://img.shields.io/static/v1?label=License&message=MIT&color=brightgreen&style=flat-square)](./LICENSE.md)
16
15
 
17
- | **Release** | **Latest** | **Pre** |
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)) |
18
17
  |:-:|:-:|:-:|
19
- | [**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 Release Date](https://img.shields.io/github/release-date/hugoalh-studio/github-sodium-nodejs?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) (![GitHub Latest Pre-Release Date](https://img.shields.io/github/release-date-pre/hugoalh-studio/github-sodium-nodejs?label=%20&style=flat-square)) |
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) |
20
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) |
21
20
 
22
21
  ## 📝 Description
23
22
 
24
- This project is based on "tweetsodium" ([GitHub](https://github.com/github/tweetsodium))([NPM](https://www.npmjs.com/package/tweetsodium)) with optimization for GitHub secret.
23
+ A NodeJS module to provide an easier sodium for GitHub secret.
24
+
25
+ This project is based on TweetSodium ([GitHub](https://github.com/github/tweetsodium))([NPM](https://www.npmjs.com/package/tweetsodium)) with optimization for GitHub secret.
25
26
 
26
27
  ## 📚 Documentation
27
28
 
28
29
  ### Getting Started
29
30
 
30
- NodeJS (>= v14.15.0) & NPM (>= v6.14.8):
31
+ #### Install
32
+
33
+ NodeJS (>= v14.15.0) + NPM (>= v6.14.8):
31
34
 
32
35
  ```sh
33
36
  npm install @hugoalh/github-sodium
34
37
  ```
35
38
 
36
- ### API
37
-
38
- #### `(publicKey, value)`
39
-
40
- ##### Description
41
-
42
- Encrypt value to GitHub secret value.
43
-
44
- ##### Argument
45
-
46
- ###### `publicKey`
39
+ #### Use In CommonJS
47
40
 
48
- `<string>` Organization's or repository's public key, which need for encrypt value to secret value before create or update a secret.
41
+ ```js
42
+ const githubSodium = require("@hugoalh/github-sodium");
43
+ ```
49
44
 
50
- ###### `value`
45
+ #### Use In ModuleJS
51
46
 
52
- `<string>` Value that need to encrypt as secret value.
47
+ ```js
48
+ import githubSodium from "@hugoalh/github-sodium";
49
+ ```
53
50
 
54
- ##### Return
51
+ ### API
55
52
 
56
- `<string>` A encrypted GitHub secret value.
53
+ ```ts
54
+ githubSodium(// Encrypt value to GitHub secret value.
55
+ publicKey: string,// Organization's or repository's public key, which need for encrypt value to secret value before create or update a secret.
56
+ value: string// Value that need to encrypt as secret value.
57
+ ): string// An encrypted GitHub secret value.
58
+ ```
57
59
 
58
60
  ### Example
59
61
 
60
62
  ```js
61
- const githubSodium = require("@hugoalh/github-sodium");
62
-
63
- console.log(githubSodium("awpojpwojqmrmklmklmkljicvjifjogjotrj", "my-secret"));// spjerpawakmsfnklasklfnkljljkasjkdlazsdjfljslejifklejrlkmslkfmklpmqhnoubdpsdofipskpdokfepkasdpoaiwopejkqmatyn
63
+ githubSodium("base64-encoded-public-key", "plain-text-secret");
64
+ //=> "+ZYvJDZMHUfBkJdyq5Zm9SKqeuBQ4sj+6sfjlH4CgG0="
64
65
  ```
package/lib/main.js CHANGED
@@ -4,14 +4,20 @@ const sodium = require("tweetsodium");
4
4
  * @description Encrypt value to GitHub secret value.
5
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
6
  * @param {string} value Value that need to encrypt as secret value.
7
- * @returns {string} A encrypted GitHub secret value.
7
+ * @returns {string} An encrypted GitHub secret value.
8
8
  */
9
9
  function githubSodium(publicKey, value) {
10
- if (typeof publicKey !== "string" || publicKey.length === 0) {
11
- throw new TypeError(`Argument "publicKey" must be type of string (non-nullable)!`);
10
+ if (
11
+ typeof publicKey !== "string" ||
12
+ publicKey.length === 0
13
+ ) {
14
+ throw new TypeError(`Argument \`publicKey\` must be type of string (non-empty)!`);
12
15
  };
13
- if (typeof value !== "string" || value.length === 0) {
14
- throw new TypeError(`Argument "value" must be type of string (non-nullable)!`);
16
+ if (
17
+ typeof value !== "string" ||
18
+ value.length === 0
19
+ ) {
20
+ throw new TypeError(`Argument \`value\` must be type of string (non-empty)!`);
15
21
  };
16
22
  return Buffer.from(sodium.seal(Buffer.from(value), Buffer.from(publicKey, "base64"))).toString("base64");
17
23
  };
package/lib/main.mjs CHANGED
@@ -4,14 +4,20 @@ import * as sodium from "tweetsodium";
4
4
  * @description Encrypt value to GitHub secret value.
5
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
6
  * @param {string} value Value that need to encrypt as secret value.
7
- * @returns {string} A encrypted GitHub secret value.
7
+ * @returns {string} An encrypted GitHub secret value.
8
8
  */
9
9
  function githubSodium(publicKey, value) {
10
- if (typeof publicKey !== "string" || publicKey.length === 0) {
11
- throw new TypeError(`Argument "publicKey" must be type of string (non-nullable)!`);
10
+ if (
11
+ typeof publicKey !== "string" ||
12
+ publicKey.length === 0
13
+ ) {
14
+ throw new TypeError(`Argument \`publicKey\` must be type of string (non-empty)!`);
12
15
  };
13
- if (typeof value !== "string" || value.length === 0) {
14
- throw new TypeError(`Argument "value" must be type of string (non-nullable)!`);
16
+ if (
17
+ typeof value !== "string" ||
18
+ value.length === 0
19
+ ) {
20
+ throw new TypeError(`Argument \`value\` must be type of string (non-empty)!`);
15
21
  };
16
22
  return Buffer.from(sodium.seal(Buffer.from(value), Buffer.from(publicKey, "base64"))).toString("base64");
17
23
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hugoalh/github-sodium",
3
- "version": "1.1.2",
3
+ "version": "1.1.6",
4
4
  "description": "A module to provide an easier sodium for GitHub secret.",
5
5
  "keywords": [
6
6
  "github",
@@ -13,10 +13,12 @@
13
13
  "license": "MIT",
14
14
  "author": "hugoalh",
15
15
  "main": "./lib/main.js",
16
+ "module": "./lib/main.mjs",
16
17
  "exports": {
17
18
  "import": "./lib/main.mjs",
18
19
  "require": "./lib/main.js"
19
20
  },
21
+ "types": "./@types/main.d.ts",
20
22
  "repository": {
21
23
  "type": "git",
22
24
  "url": "git+https://github.com/hugoalh-studio/github-sodium-nodejs.git"