@hugoalh/github-sodium 2.0.3 → 3.0.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 +2 -10
- package/lib/github-sodium-sealer.d.ts +1 -1
- package/lib/github-sodium-sealer.d.ts.map +1 -1
- package/lib/github-sodium-sealer.js +7 -6
- package/lib/main.d.ts +7 -2
- package/lib/main.js +7 -3
- package/lib/seal.d.ts +1 -1
- package/lib/seal.js +2 -2
- package/package.json +6 -8
- package/lib/github-sodium-sealer.d.mts +0 -20
- package/lib/github-sodium-sealer.d.mts.map +0 -1
- package/lib/github-sodium-sealer.mjs +0 -32
- package/lib/main.d.mts +0 -9
- package/lib/main.d.mts.map +0 -1
- package/lib/main.mjs +0 -10
- package/lib/seal.d.mts +0 -9
- package/lib/seal.d.mts.map +0 -1
- package/lib/seal.mjs +0 -11
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
A NodeJS module to provide an easier sodium for GitHub secrets.
|
|
22
22
|
|
|
23
|
-
This project is based on `libsodium.js` ([GitHub](https://github.com/jedisct1/libsodium.js))([NPM](https://www.npmjs.com/package/libsodium))
|
|
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.
|
|
24
24
|
|
|
25
25
|
## 📚 Documentation
|
|
26
26
|
|
|
@@ -28,7 +28,7 @@ This project is based on `libsodium.js` ([GitHub](https://github.com/jedisct1/li
|
|
|
28
28
|
|
|
29
29
|
#### Install
|
|
30
30
|
|
|
31
|
-
- NodeJS >=
|
|
31
|
+
- NodeJS ^ v12.20.0 || ^ v14.15.0 || >= v16.13.0
|
|
32
32
|
|
|
33
33
|
```sh
|
|
34
34
|
npm install @hugoalh/github-sodium
|
|
@@ -36,14 +36,6 @@ npm install @hugoalh/github-sodium
|
|
|
36
36
|
|
|
37
37
|
#### Use
|
|
38
38
|
|
|
39
|
-
##### CommonJS
|
|
40
|
-
|
|
41
|
-
```js
|
|
42
|
-
const githubSodium = require("@hugoalh/github-sodium");
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
##### ModuleJS
|
|
46
|
-
|
|
47
39
|
```js
|
|
48
40
|
/* Either */
|
|
49
41
|
import * as githubSodium from "@hugoalh/github-sodium";// All
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-sodium-sealer.d.ts","sourceRoot":"","sources":["github-sodium-sealer.js"],"names":[],"mappings":";
|
|
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
|
-
|
|
2
|
-
|
|
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,7 +12,7 @@ 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 (!
|
|
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");
|
|
@@ -22,10 +23,10 @@ class GitHubSodiumSealer {
|
|
|
22
23
|
* @returns {string} An encrypted GitHub secret value.
|
|
23
24
|
*/
|
|
24
25
|
encrypt(value) {
|
|
25
|
-
if (!
|
|
26
|
+
if (!adIsString(value, { empty: false })) {
|
|
26
27
|
throw new TypeError(`Argument \`value\` must be type of string (non-empty)!`);
|
|
27
28
|
}
|
|
28
|
-
return Buffer.from(
|
|
29
|
+
return Buffer.from(libsodium.crypto_box_seal(Buffer.from(value), this.#publicKeyStorage)).toString("base64");
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
|
-
|
|
32
|
+
export default GitHubSodiumSealer;
|
package/lib/main.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
package/lib/seal.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
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.
|
|
@@ -8,4 +8,4 @@ const GitHubSodiumSealer = require("./github-sodium-sealer.js");
|
|
|
8
8
|
function seal(publicKey, value) {
|
|
9
9
|
return new GitHubSodiumSealer(publicKey).encrypt(value);
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
export default seal;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hugoalh/github-sodium",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "A module to provide an easier sodium for GitHub
|
|
3
|
+
"version": "3.0.1",
|
|
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.
|
|
19
|
-
"require": "./lib/main.js"
|
|
18
|
+
"import": "./lib/main.js"
|
|
20
19
|
},
|
|
21
20
|
"types": "./lib/main.d.ts",
|
|
22
21
|
"repository": {
|
|
@@ -25,8 +24,7 @@
|
|
|
25
24
|
},
|
|
26
25
|
"dependencies": {
|
|
27
26
|
"@hugoalh/advanced-determine": "^7.2.0",
|
|
28
|
-
"libsodium-wrappers": "^0.7.10"
|
|
29
|
-
"tweetsodium": "0.0.5"
|
|
27
|
+
"libsodium-wrappers": "^0.7.10"
|
|
30
28
|
},
|
|
31
29
|
"devDependencies": {
|
|
32
30
|
"@types/libsodium-wrappers": "^0.7.10",
|
|
@@ -36,7 +34,7 @@
|
|
|
36
34
|
"typescript": "^4.8.4"
|
|
37
35
|
},
|
|
38
36
|
"engines": {
|
|
39
|
-
"node": ">=
|
|
37
|
+
"node": "^12.20.0 || ^14.15.0 || >=16.13.0"
|
|
40
38
|
},
|
|
41
39
|
"private": false
|
|
42
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
|
package/lib/main.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.mts","sourceRoot":"","sources":["main.mjs"],"names":[],"mappings":""}
|
package/lib/main.mjs
DELETED
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
|
package/lib/seal.d.mts.map
DELETED
|
@@ -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;
|