@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.
- package/@types/main.d.mts +10 -0
- package/@types/main.d.mts.map +1 -0
- package/@types/main.d.ts +10 -0
- package/@types/main.d.ts.map +1 -0
- package/LICENSE.md +17 -12
- package/README.md +27 -26
- package/lib/main.js +11 -5
- package/lib/main.mjs +11 -5
- package/package.json +3 -1
|
@@ -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"}
|
package/@types/main.d.ts
ADDED
|
@@ -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 "
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
|
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
|
[](https://github.com/hugoalh-studio/github-sodium-nodejs/graphs/contributors)
|
|
6
5
|
[](https://github.com/hugoalh-studio/github-sodium-nodejs/issues)
|
|
7
6
|
[](https://github.com/hugoalh-studio/github-sodium-nodejs/pulls)
|
|
@@ -14,51 +13,53 @@
|
|
|
14
13
|
](https://lgtm.com/projects/g/hugoalh-studio/github-sodium-nodejs)
|
|
15
14
|
[](./LICENSE.md)
|
|
16
15
|
|
|
17
|
-
| **Release** | **Latest** | **Pre** |
|
|
16
|
+
| **Release** | **Latest** () | **Pre** () |
|
|
18
17
|
|:-:|:-:|:-:|
|
|
19
|
-
| [**GitHub**](https://github.com/hugoalh-studio/github-sodium-nodejs/releases)  | 
|
|
18
|
+
| [**GitHub**](https://github.com/hugoalh-studio/github-sodium-nodejs/releases)  |  |  |
|
|
20
19
|
| [**NPM**](https://www.npmjs.com/package/@hugoalh/github-sodium)  |  |  |
|
|
21
20
|
|
|
22
21
|
## 📝 Description
|
|
23
22
|
|
|
24
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
41
|
+
```js
|
|
42
|
+
const githubSodium = require("@hugoalh/github-sodium");
|
|
43
|
+
```
|
|
49
44
|
|
|
50
|
-
|
|
45
|
+
#### Use In ModuleJS
|
|
51
46
|
|
|
52
|
-
|
|
47
|
+
```js
|
|
48
|
+
import githubSodium from "@hugoalh/github-sodium";
|
|
49
|
+
```
|
|
53
50
|
|
|
54
|
-
|
|
51
|
+
### API
|
|
55
52
|
|
|
56
|
-
|
|
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
|
-
|
|
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}
|
|
7
|
+
* @returns {string} An encrypted GitHub secret value.
|
|
8
8
|
*/
|
|
9
9
|
function githubSodium(publicKey, value) {
|
|
10
|
-
if (
|
|
11
|
-
|
|
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 (
|
|
14
|
-
|
|
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}
|
|
7
|
+
* @returns {string} An encrypted GitHub secret value.
|
|
8
8
|
*/
|
|
9
9
|
function githubSodium(publicKey, value) {
|
|
10
|
-
if (
|
|
11
|
-
|
|
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 (
|
|
14
|
-
|
|
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.
|
|
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"
|