@hugoalh/github-sodium 3.1.1 → 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 +50 -42
- package/dist/main.d.ts +7 -16
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +11 -21
- package/package.json +12 -10
package/README.md
CHANGED
|
@@ -1,65 +1,73 @@
|
|
|
1
1
|
# GitHub Sodium (NodeJS)
|
|
2
2
|
|
|
3
|
-
[
|
|
4
|
-
|
|
5
|
-

|
|
6
|
-
[](https://github.com/hugoalh-studio/github-sodium-nodejs/stargazers)
|
|
7
|
-
[](https://github.com/hugoalh-studio/github-sodium-nodejs/graphs/contributors)
|
|
8
|
-
[](https://github.com/hugoalh-studio/github-sodium-nodejs/issues)
|
|
9
|
-
[](https://github.com/hugoalh-studio/github-sodium-nodejs/pulls)
|
|
10
|
-
[](https://github.com/hugoalh-studio/github-sodium-nodejs/discussions)
|
|
3
|
+
[⚖️ MIT](./LICENSE.md)
|
|
11
4
|
[](https://www.codefactor.io/repository/github/hugoalh-studio/github-sodium-nodejs)
|
|
12
5
|
|
|
13
|
-
| **
|
|
14
|
-
|
|
15
|
-
| [](https://github.com/hugoalh-studio/github-sodium-nodejs/
|
|
16
|
-
| [](https://www.npmjs.com/package/@hugoalh/github-sodium)  |  |  |
|
|
17
|
-
|
|
18
|
-
## 📝 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) |  |  |  |
|
|
19
10
|
|
|
20
11
|
A NodeJS module to provide an easier sodium for GitHub secrets.
|
|
21
12
|
|
|
22
|
-
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.
|
|
23
14
|
|
|
24
|
-
##
|
|
15
|
+
## 🔰 Begin
|
|
25
16
|
|
|
26
|
-
###
|
|
17
|
+
### Bun
|
|
27
18
|
|
|
28
|
-
|
|
19
|
+
> **🧪 Experimental:** Bun is still under development.
|
|
29
20
|
|
|
30
|
-
-
|
|
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
|
+
```
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
npm install @hugoalh/github-sodium
|
|
34
|
-
```
|
|
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.
|
|
35
34
|
|
|
36
|
-
|
|
35
|
+
### NodeJS
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
```
|
|
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
|
+
```
|
|
44
48
|
|
|
45
|
-
|
|
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.
|
|
46
50
|
|
|
47
|
-
|
|
51
|
+
## 🧩 API
|
|
48
52
|
|
|
49
53
|
- ```ts
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
class GitHubSodiumSealer {
|
|
55
|
+
constructor(publicKey: string): GitHubSodiumSealer;
|
|
56
|
+
encrypt(value: string): string;
|
|
57
|
+
static seal(publicKey: string, value: string): string;
|
|
58
|
+
}
|
|
52
59
|
```
|
|
53
|
-
|
|
54
|
-
#### Function
|
|
55
|
-
|
|
56
60
|
- ```ts
|
|
57
|
-
seal(publicKey: string, value: string): string;
|
|
61
|
+
function seal(publicKey: string, value: string): string;
|
|
58
62
|
```
|
|
59
63
|
|
|
60
|
-
|
|
64
|
+
> **ℹ️ Notice:** Documentation is included inside the script file.
|
|
61
65
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
## ✍️ Example
|
|
67
|
+
|
|
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":"
|
|
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
|
@@ -10,40 +10,35 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
12
|
var _GitHubSodiumSealer_publicKeyBuffer;
|
|
13
|
-
import { StringItemFilter } from "@hugoalh/advanced-determine";
|
|
14
13
|
import libsodium from "libsodium-wrappers";
|
|
15
14
|
await libsodium.ready;
|
|
16
|
-
const stringFilter = new StringItemFilter();
|
|
17
15
|
/**
|
|
18
|
-
*
|
|
19
|
-
* @description Encrypt value to GitHub secret value.
|
|
16
|
+
* GitHub sodium sealer for encrypt value to GitHub secret value.
|
|
20
17
|
*/
|
|
21
|
-
class GitHubSodiumSealer {
|
|
18
|
+
export class GitHubSodiumSealer {
|
|
22
19
|
/**
|
|
23
|
-
* @constructor
|
|
24
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.
|
|
25
21
|
*/
|
|
26
22
|
constructor(publicKey) {
|
|
27
23
|
_GitHubSodiumSealer_publicKeyBuffer.set(this, void 0);
|
|
28
|
-
if (!
|
|
29
|
-
throw new
|
|
24
|
+
if (!(publicKey.length > 0)) {
|
|
25
|
+
throw new SyntaxError(`Argument \`publicKey\` is not a string which is non-empty!`);
|
|
30
26
|
}
|
|
31
27
|
__classPrivateFieldSet(this, _GitHubSodiumSealer_publicKeyBuffer, Buffer.from(publicKey, "base64"), "f");
|
|
32
28
|
}
|
|
33
29
|
/**
|
|
34
|
-
*
|
|
30
|
+
* Encrypt value to GitHub secret value.
|
|
35
31
|
* @param {string} value Value that need to encrypt as secret value.
|
|
36
32
|
* @returns {string} An encrypted GitHub secret value.
|
|
37
33
|
*/
|
|
38
34
|
encrypt(value) {
|
|
39
|
-
if (!
|
|
40
|
-
throw new
|
|
35
|
+
if (!(value.length > 0)) {
|
|
36
|
+
throw new SyntaxError(`Argument \`value\` is not a string which is non-empty!`);
|
|
41
37
|
}
|
|
42
38
|
return Buffer.from(libsodium.crypto_box_seal(Buffer.from(value), __classPrivateFieldGet(this, _GitHubSodiumSealer_publicKeyBuffer, "f"))).toString("base64");
|
|
43
39
|
}
|
|
44
40
|
/**
|
|
45
|
-
*
|
|
46
|
-
* @description Encrypt value to GitHub secret value.
|
|
41
|
+
* Encrypt value to GitHub secret value.
|
|
47
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.
|
|
48
43
|
* @param {string} value Value that need to encrypt as secret value.
|
|
49
44
|
* @returns {string} An encrypted GitHub secret value.
|
|
@@ -53,18 +48,13 @@ class GitHubSodiumSealer {
|
|
|
53
48
|
}
|
|
54
49
|
}
|
|
55
50
|
_GitHubSodiumSealer_publicKeyBuffer = new WeakMap();
|
|
51
|
+
export default GitHubSodiumSealer;
|
|
56
52
|
/**
|
|
57
|
-
*
|
|
58
|
-
* @description Encrypt value to GitHub secret value.
|
|
53
|
+
* Encrypt value to GitHub secret value.
|
|
59
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.
|
|
60
55
|
* @param {string} value Value that need to encrypt as secret value.
|
|
61
56
|
* @returns {string} An encrypted GitHub secret value.
|
|
62
57
|
*/
|
|
63
|
-
function seal(publicKey, value) {
|
|
58
|
+
export function seal(publicKey, value) {
|
|
64
59
|
return new GitHubSodiumSealer(publicKey).encrypt(value);
|
|
65
60
|
}
|
|
66
|
-
export { GitHubSodiumSealer, seal };
|
|
67
|
-
export default {
|
|
68
|
-
GitHubSodiumSealer,
|
|
69
|
-
seal
|
|
70
|
-
};
|
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,20 +23,22 @@
|
|
|
23
23
|
"url": "git+https://github.com/hugoalh-studio/github-sodium-nodejs.git"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"
|
|
27
|
-
"libsodium-wrappers": "^0.7.11"
|
|
26
|
+
"libsodium-wrappers": "^0.7.13"
|
|
28
27
|
},
|
|
29
28
|
"devDependencies": {
|
|
30
|
-
"@types/libsodium-wrappers": "^0.7.
|
|
31
|
-
"@types/node": "^
|
|
32
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
33
|
-
"@typescript-eslint/parser": "^
|
|
34
|
-
"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",
|
|
35
34
|
"eslint-plugin-only-warn": "^1.1.0",
|
|
36
|
-
"typescript": "^5.
|
|
35
|
+
"typescript": "^5.2.2"
|
|
37
36
|
},
|
|
38
37
|
"engines": {
|
|
39
38
|
"node": "^12.20.0 || ^14.15.0 || >=16.13.0"
|
|
40
39
|
},
|
|
41
|
-
"private": false
|
|
40
|
+
"private": false,
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
}
|
|
42
44
|
}
|