@hugoalh/github-sodium 3.1.2 → 4.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 +52 -39
- package/dist/main.d.ts +7 -16
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +9 -23
- package/package.json +12 -9
package/README.md
CHANGED
|
@@ -1,60 +1,73 @@
|
|
|
1
1
|
# GitHub Sodium (NodeJS)
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
[](https://github.com/hugoalh-studio/github-sodium-nodejs)
|
|
5
|
-
[](https://github.com/hugoalh-studio/github-sodium-nodejs/stargazers)
|
|
6
|
-
[](https://github.com/hugoalh-studio/github-sodium-nodejs/graphs/contributors)
|
|
7
|
-
[](https://github.com/hugoalh-studio/github-sodium-nodejs/issues)
|
|
8
|
-
[](https://github.com/hugoalh-studio/github-sodium-nodejs/pulls)
|
|
9
|
-
[](https://github.com/hugoalh-studio/github-sodium-nodejs/discussions)
|
|
3
|
+
[⚖️ MIT](./LICENSE.md)
|
|
10
4
|
[](https://www.codefactor.io/repository/github/hugoalh-studio/github-sodium-nodejs)
|
|
11
5
|
|
|
12
|
-
| **
|
|
13
|
-
|
|
14
|
-
| [](https://github.com/hugoalh-studio/github-sodium-nodejs/
|
|
15
|
-
| [](https://www.npmjs.com/package/@hugoalh/github-sodium)  |  |  |
|
|
16
|
-
|
|
17
|
-
## 📝 Description
|
|
6
|
+
| | **Heat** | **Release - Latest** | **Release - Pre** |
|
|
7
|
+
|:-:|:-:|:-:|:-:|
|
|
8
|
+
| [](https://github.com/hugoalh-studio/github-sodium-nodejs) | [](https://github.com/hugoalh-studio/github-sodium-nodejs/stargazers) \|  |  () |  () |
|
|
9
|
+
| [](https://www.npmjs.com/package/@hugoalh/github-sodium) |  |  |  |
|
|
18
10
|
|
|
19
11
|
A NodeJS module to provide an easier sodium for GitHub secrets.
|
|
20
12
|
|
|
21
|
-
This project is based on
|
|
13
|
+
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.
|
|
22
14
|
|
|
23
|
-
##
|
|
15
|
+
## 🔰 Begin
|
|
24
16
|
|
|
25
|
-
###
|
|
17
|
+
### Bun
|
|
26
18
|
|
|
27
|
-
|
|
19
|
+
> **🧪 Experimental:** Bun is still under development.
|
|
28
20
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
- **Target Version:** ^ v1.0.0, &:
|
|
22
|
+
- TypeScript >= v5.1.0 *\[Development\]*
|
|
23
|
+
- **Require Permission:** *N/A*
|
|
24
|
+
- **Domain/Registry:**
|
|
25
|
+
- [NPM](https://www.npmjs.com/package/@hugoalh/github-sodium)
|
|
26
|
+
```sh
|
|
27
|
+
bun add @hugoalh/github-sodium[@<Tag>]
|
|
28
|
+
```
|
|
29
|
+
```js
|
|
30
|
+
import ... from "@hugoalh/github-sodium[@<Tag>]";
|
|
31
|
+
```
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
/* Either */
|
|
35
|
-
import { ... } from "@hugoalh/github-sodium";// Named Import
|
|
36
|
-
import * as githubSodium from "@hugoalh/github-sodium";// Namespace Import
|
|
37
|
-
import githubSodium from "@hugoalh/github-sodium";// Default Import
|
|
38
|
-
```
|
|
33
|
+
> **ℹ️ Notice:** It is also able to import part of the module with sub path if available, see [file `package.json`](./package.json) property `exports` for available sub paths.
|
|
39
34
|
|
|
40
|
-
###
|
|
35
|
+
### NodeJS
|
|
41
36
|
|
|
42
|
-
|
|
37
|
+
- **Target Version:** ^ v12.20.0 \|\| ^ v14.15.0 \|\| >= v16.13.0, &:
|
|
38
|
+
- TypeScript >= v5.1.0 *\[Development\]*
|
|
39
|
+
- **Require Permission:** *N/A*
|
|
40
|
+
- **Domain/Registry:**
|
|
41
|
+
- [NPM](https://www.npmjs.com/package/@hugoalh/github-sodium)
|
|
42
|
+
```sh
|
|
43
|
+
npm install @hugoalh/github-sodium[@<Tag>]
|
|
44
|
+
```
|
|
45
|
+
```js
|
|
46
|
+
import ... from "@hugoalh/github-sodium";
|
|
47
|
+
```
|
|
43
48
|
|
|
44
|
-
|
|
45
|
-
new GitHubSodiumSealer(publicKey: string): GitHubSodiumSealer;
|
|
46
|
-
.encrypt(value: string): string;
|
|
47
|
-
```
|
|
49
|
+
> **ℹ️ Notice:** It is also able to import part of the module with sub path if available, see [file `package.json`](./package.json) property `exports` for available sub paths.
|
|
48
50
|
|
|
49
|
-
|
|
51
|
+
## 🧩 API
|
|
50
52
|
|
|
51
53
|
- ```ts
|
|
52
|
-
|
|
54
|
+
class GitHubSodiumSealer {
|
|
55
|
+
constructor(publicKey: string): GitHubSodiumSealer;
|
|
56
|
+
encrypt(value: string): string;
|
|
57
|
+
static seal(publicKey: string, value: string): string;
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
- ```ts
|
|
61
|
+
function seal(publicKey: string, value: string): string;
|
|
53
62
|
```
|
|
54
63
|
|
|
55
|
-
|
|
64
|
+
> **ℹ️ Notice:** Documentation is included inside the script file.
|
|
65
|
+
|
|
66
|
+
## ✍️ Example
|
|
56
67
|
|
|
57
|
-
```js
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
68
|
+
- ```js
|
|
69
|
+
import { GitHubSodiumSealer } from "@hugoalh/github-sodium";
|
|
70
|
+
|
|
71
|
+
new GitHubSodiumSealer("base64-encoded-public-key").encrypt("plain-text-secret");
|
|
72
|
+
//=> "+ZYvJDZMHUfBkJdyq5Zm9SKqeuBQ4sj+6sfjlH4CgG0="
|
|
73
|
+
```
|
package/dist/main.d.ts
CHANGED
|
@@ -1,41 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @description Encrypt value to GitHub secret value.
|
|
2
|
+
* GitHub sodium sealer for encrypt value to GitHub secret value.
|
|
4
3
|
*/
|
|
5
|
-
declare class GitHubSodiumSealer {
|
|
4
|
+
export declare class GitHubSodiumSealer {
|
|
6
5
|
#private;
|
|
7
6
|
/**
|
|
8
|
-
* @constructor
|
|
9
7
|
* @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
8
|
*/
|
|
11
9
|
constructor(publicKey: string);
|
|
12
10
|
/**
|
|
13
|
-
*
|
|
11
|
+
* Encrypt value to GitHub secret value.
|
|
14
12
|
* @param {string} value Value that need to encrypt as secret value.
|
|
15
13
|
* @returns {string} An encrypted GitHub secret value.
|
|
16
14
|
*/
|
|
17
15
|
encrypt(value: string): string;
|
|
18
16
|
/**
|
|
19
|
-
*
|
|
20
|
-
* @description Encrypt value to GitHub secret value.
|
|
17
|
+
* Encrypt value to GitHub secret value.
|
|
21
18
|
* @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
19
|
* @param {string} value Value that need to encrypt as secret value.
|
|
23
20
|
* @returns {string} An encrypted GitHub secret value.
|
|
24
21
|
*/
|
|
25
22
|
static seal(publicKey: string, value: string): string;
|
|
26
23
|
}
|
|
24
|
+
export default GitHubSodiumSealer;
|
|
27
25
|
/**
|
|
28
|
-
*
|
|
29
|
-
* @description Encrypt value to GitHub secret value.
|
|
26
|
+
* Encrypt value to GitHub secret value.
|
|
30
27
|
* @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
28
|
* @param {string} value Value that need to encrypt as secret value.
|
|
32
29
|
* @returns {string} An encrypted GitHub secret value.
|
|
33
30
|
*/
|
|
34
|
-
declare function seal(publicKey: string, value: string): string;
|
|
35
|
-
export { GitHubSodiumSealer, seal };
|
|
36
|
-
declare const _default: {
|
|
37
|
-
GitHubSodiumSealer: typeof GitHubSodiumSealer;
|
|
38
|
-
seal: typeof seal;
|
|
39
|
-
};
|
|
40
|
-
export default _default;
|
|
31
|
+
export declare function seal(publicKey: string, value: string): string;
|
|
41
32
|
//# sourceMappingURL=main.d.ts.map
|
package/dist/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,qBAAa,kBAAkB;;IAE9B;;OAEG;gBACS,SAAS,EAAE,MAAM;IAM7B;;;;OAIG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAM9B;;;;;OAKG;IACH,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;CAGrD;AACD,eAAe,kBAAkB,CAAC;AAClC;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7D"}
|
package/dist/main.js
CHANGED
|
@@ -13,41 +13,32 @@ var _GitHubSodiumSealer_publicKeyBuffer;
|
|
|
13
13
|
import libsodium from "libsodium-wrappers";
|
|
14
14
|
await libsodium.ready;
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
17
|
-
* @description Encrypt value to GitHub secret value.
|
|
16
|
+
* GitHub sodium sealer for encrypt value to GitHub secret value.
|
|
18
17
|
*/
|
|
19
|
-
class GitHubSodiumSealer {
|
|
18
|
+
export class GitHubSodiumSealer {
|
|
20
19
|
/**
|
|
21
|
-
* @constructor
|
|
22
20
|
* @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
21
|
*/
|
|
24
22
|
constructor(publicKey) {
|
|
25
23
|
_GitHubSodiumSealer_publicKeyBuffer.set(this, void 0);
|
|
26
|
-
if (typeof publicKey !== "string") {
|
|
27
|
-
throw new TypeError(`Argument \`publicKey\` must be type of string!`);
|
|
28
|
-
}
|
|
29
24
|
if (!(publicKey.length > 0)) {
|
|
30
|
-
throw new
|
|
25
|
+
throw new SyntaxError(`Argument \`publicKey\` is not a string which is non-empty!`);
|
|
31
26
|
}
|
|
32
27
|
__classPrivateFieldSet(this, _GitHubSodiumSealer_publicKeyBuffer, Buffer.from(publicKey, "base64"), "f");
|
|
33
28
|
}
|
|
34
29
|
/**
|
|
35
|
-
*
|
|
30
|
+
* Encrypt value to GitHub secret value.
|
|
36
31
|
* @param {string} value Value that need to encrypt as secret value.
|
|
37
32
|
* @returns {string} An encrypted GitHub secret value.
|
|
38
33
|
*/
|
|
39
34
|
encrypt(value) {
|
|
40
|
-
if (typeof value !== "string") {
|
|
41
|
-
throw new TypeError(`Argument \`value\` must be type of string!`);
|
|
42
|
-
}
|
|
43
35
|
if (!(value.length > 0)) {
|
|
44
|
-
throw new
|
|
36
|
+
throw new SyntaxError(`Argument \`value\` is not a string which is non-empty!`);
|
|
45
37
|
}
|
|
46
38
|
return Buffer.from(libsodium.crypto_box_seal(Buffer.from(value), __classPrivateFieldGet(this, _GitHubSodiumSealer_publicKeyBuffer, "f"))).toString("base64");
|
|
47
39
|
}
|
|
48
40
|
/**
|
|
49
|
-
*
|
|
50
|
-
* @description Encrypt value to GitHub secret value.
|
|
41
|
+
* Encrypt value to GitHub secret value.
|
|
51
42
|
* @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
43
|
* @param {string} value Value that need to encrypt as secret value.
|
|
53
44
|
* @returns {string} An encrypted GitHub secret value.
|
|
@@ -57,18 +48,13 @@ class GitHubSodiumSealer {
|
|
|
57
48
|
}
|
|
58
49
|
}
|
|
59
50
|
_GitHubSodiumSealer_publicKeyBuffer = new WeakMap();
|
|
51
|
+
export default GitHubSodiumSealer;
|
|
60
52
|
/**
|
|
61
|
-
*
|
|
62
|
-
* @description Encrypt value to GitHub secret value.
|
|
53
|
+
* Encrypt value to GitHub secret value.
|
|
63
54
|
* @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
55
|
* @param {string} value Value that need to encrypt as secret value.
|
|
65
56
|
* @returns {string} An encrypted GitHub secret value.
|
|
66
57
|
*/
|
|
67
|
-
function seal(publicKey, value) {
|
|
58
|
+
export function seal(publicKey, value) {
|
|
68
59
|
return new GitHubSodiumSealer(publicKey).encrypt(value);
|
|
69
60
|
}
|
|
70
|
-
export { GitHubSodiumSealer, seal };
|
|
71
|
-
export default {
|
|
72
|
-
GitHubSodiumSealer,
|
|
73
|
-
seal
|
|
74
|
-
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hugoalh/github-sodium",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "A module to provide an easier sodium for GitHub secrets.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"github",
|
|
@@ -23,19 +23,22 @@
|
|
|
23
23
|
"url": "git+https://github.com/hugoalh-studio/github-sodium-nodejs.git"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"libsodium-wrappers": "^0.7.
|
|
26
|
+
"libsodium-wrappers": "^0.7.13"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@types/libsodium-wrappers": "^0.7.
|
|
30
|
-
"@types/node": "^
|
|
31
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
32
|
-
"@typescript-eslint/parser": "^
|
|
33
|
-
"eslint": "^8.
|
|
29
|
+
"@types/libsodium-wrappers": "^0.7.11",
|
|
30
|
+
"@types/node": "^20.8.4",
|
|
31
|
+
"@typescript-eslint/eslint-plugin": "^6.7.5",
|
|
32
|
+
"@typescript-eslint/parser": "^6.7.5",
|
|
33
|
+
"eslint": "^8.51.0",
|
|
34
34
|
"eslint-plugin-only-warn": "^1.1.0",
|
|
35
|
-
"typescript": "^5.
|
|
35
|
+
"typescript": "^5.2.2"
|
|
36
36
|
},
|
|
37
37
|
"engines": {
|
|
38
38
|
"node": "^12.20.0 || ^14.15.0 || >=16.13.0"
|
|
39
39
|
},
|
|
40
|
-
"private": false
|
|
40
|
+
"private": false,
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
}
|
|
41
44
|
}
|