@hugoalh/github-sodium 5.0.2 → 5.1.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/LICENSE.md +1 -1
- package/README.md +58 -62
- package/mod.d.ts +70 -0
- package/mod.d.ts.map +1 -0
- package/mod.js +114 -0
- package/package.json +21 -32
- package/dist/main.d.ts +0 -33
- package/dist/main.d.ts.map +0 -1
- package/dist/main.js +0 -48
package/LICENSE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# MIT License
|
|
2
2
|
|
|
3
|
-
Copyright © 2020\~2024 hugoalh
|
|
3
|
+
Copyright © 2020\~2024 hugoalh
|
|
4
4
|
|
|
5
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
|
|
package/README.md
CHANGED
|
@@ -1,88 +1,84 @@
|
|
|
1
|
-
# GitHub Sodium (
|
|
1
|
+
# GitHub Sodium (ES)
|
|
2
2
|
|
|
3
3
|
[**⚖️** MIT](./LICENSE.md)
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
[](https://github.com/hugoalh/github-sodium-es)
|
|
6
|
+
[](https://jsr.io/@hugoalh/github-sodium)
|
|
7
|
+
[](https://www.npmjs.com/package/@hugoalh/github-sodium)
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
An ES (JavaScript & TypeScript) module to provide an easier and simplified method for encrypt GitHub secrets, based on the NPM package [`libsodium.js`](https://www.npmjs.com/package/libsodium-wrappers).
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
## 🔰 Begin
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
### 🎯 Targets
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
| | **Remote** | **JSR** | **NPM** |
|
|
16
|
+
|:--|:--|:--|:--|
|
|
17
|
+
| **[Bun](https://bun.sh/)** >= v1.1.0 | ❌ | ❓ | ✔️ |
|
|
18
|
+
| **[Cloudflare Workers](https://workers.cloudflare.com/)** | ❌ | ❓ | ✔️ |
|
|
19
|
+
| **[Deno](https://deno.land/)** >= v1.42.0 | ✔️ | ✔️ | ✔️ |
|
|
20
|
+
| **[NodeJS](https://nodejs.org/)** >= v16.13.0 | ❌ | ❓ | ✔️ |
|
|
16
21
|
|
|
17
|
-
|
|
18
|
-
-
|
|
19
|
-
- Deno >= v1.34.0
|
|
20
|
-
> **🛡️ Require Permission**
|
|
21
|
-
>
|
|
22
|
-
> *N/A*
|
|
23
|
-
- NodeJS >= v16.13.0
|
|
22
|
+
> [!NOTE]
|
|
23
|
+
> - It is possible to use this module in other methods/ways which not listed in here, however those methods/ways are not officially supported, and should beware maybe cause security issues.
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
### #️⃣ Resources Identifier
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
- **Remote - GitHub Raw:**
|
|
28
|
+
```
|
|
29
|
+
https://raw.githubusercontent.com/hugoalh/github-sodium-es/{Tag}/mod.ts
|
|
30
|
+
```
|
|
31
|
+
- **JSR:**
|
|
32
|
+
```
|
|
33
|
+
[jsr:]@hugoalh/github-sodium[@{Tag}]
|
|
34
|
+
```
|
|
35
|
+
- **NPM:**
|
|
36
|
+
```
|
|
37
|
+
[npm:]@hugoalh/github-sodium[@{Tag}]
|
|
38
|
+
```
|
|
28
39
|
|
|
29
|
-
>
|
|
40
|
+
> [!NOTE]
|
|
41
|
+
> - For usage of remote resources, it is recommended to import the entire module with the main path `mod.ts`, however it is also able to import part of the module with sub path if available, but do not import if:
|
|
30
42
|
>
|
|
31
|
-
>
|
|
32
|
-
>
|
|
33
|
-
|
|
34
|
-
1. Install via console/shell/terminal:
|
|
35
|
-
- Via NPM
|
|
36
|
-
```sh
|
|
37
|
-
npm install @hugoalh/github-sodium[@<Tag>]
|
|
38
|
-
```
|
|
39
|
-
- Via PNPM
|
|
40
|
-
```sh
|
|
41
|
-
pnpm add @hugoalh/github-sodium[@<Tag>]
|
|
42
|
-
```
|
|
43
|
-
- Via Yarn
|
|
44
|
-
```sh
|
|
45
|
-
yarn add @hugoalh/github-sodium[@<Tag>]
|
|
46
|
-
```
|
|
47
|
-
2. Import at the script (`<ScriptName>.js`):
|
|
48
|
-
```js
|
|
49
|
-
import ... from "@hugoalh/github-sodium";
|
|
50
|
-
```
|
|
51
|
-
> **ℹ️ Note**
|
|
52
|
-
>
|
|
53
|
-
> Although it is recommended to import the entire module, it is also able to import part of the module with sub path if available, please visit [file `package.json`](./package.json) property `exports` for available sub paths.
|
|
54
|
-
|
|
55
|
-
### Via NPM Specifier
|
|
56
|
-
|
|
57
|
-
> **🎯 Supported Target**
|
|
43
|
+
> - it's path has an underscore prefix (e.g.: `_foo.ts`, `_util/bar.ts`), or
|
|
44
|
+
> - it is a benchmark or test file (e.g.: `foo.bench.ts`, `foo.test.ts`), or
|
|
45
|
+
> - it's symbol has an underscore prefix (e.g.: `_bar`, `_foo`).
|
|
58
46
|
>
|
|
59
|
-
>
|
|
60
|
-
> -
|
|
47
|
+
> These elements are not considered part of the public API, thus no stability is guaranteed for them.
|
|
48
|
+
> - For usage of JSR or NPM resources, it is recommended to import the entire module with the main entrypoint, however it is also able to import part of the module with sub entrypoint if available, please visit the [file `jsr.jsonc`](./jsr.jsonc) property `exports` for available sub entrypoints.
|
|
49
|
+
> - It is recommended to use this module with tag for immutability.
|
|
50
|
+
|
|
51
|
+
### 🛡️ Require Runtime Permissions
|
|
61
52
|
|
|
62
|
-
|
|
63
|
-
```js
|
|
64
|
-
import ... from "npm:@hugoalh/github-sodium[@<Tag>]";
|
|
65
|
-
```
|
|
66
|
-
> **ℹ️ Note**
|
|
67
|
-
>
|
|
68
|
-
> Although it is recommended to import the entire module, it is also able to import part of the module with sub path if available, please visit [file `package.json`](./package.json) property `exports` for available sub paths.
|
|
53
|
+
*This module does not require any runtime permission.*
|
|
69
54
|
|
|
70
|
-
## 🧩
|
|
55
|
+
## 🧩 APIs (Excerpt)
|
|
71
56
|
|
|
72
57
|
- ```ts
|
|
73
58
|
class GitHubSodiumSealer {
|
|
74
|
-
constructor(publicKey: string)
|
|
59
|
+
constructor(publicKey: string, keyID?: string);
|
|
75
60
|
encrypt(value: string): string;
|
|
76
|
-
|
|
61
|
+
encryptToRequestBody(value: string): GitHubRESTSetPublicKeyRequestBody;
|
|
62
|
+
getKeyID(): string | undefined;
|
|
63
|
+
get keyID(): string | undefined;
|
|
64
|
+
static fromJSON(input: JSONObject): GitHubSodiumSealer;
|
|
65
|
+
static async fromResponse(input: Response): Promise<GitHubSodiumSealer>;
|
|
77
66
|
}
|
|
78
67
|
```
|
|
79
68
|
- ```ts
|
|
80
|
-
|
|
69
|
+
interface GitHubRESTSetPublicKeyRequestBody {
|
|
70
|
+
encrypted_value: string;
|
|
71
|
+
key_id: string;
|
|
72
|
+
}
|
|
81
73
|
```
|
|
82
74
|
|
|
83
|
-
|
|
75
|
+
> [!NOTE]
|
|
76
|
+
> - For the full or prettier documentation, can visit via:
|
|
77
|
+
> - [Deno CLI `deno doc`](https://docs.deno.com/runtime/reference/cli/documentation_generator/)
|
|
78
|
+
> - [JSR](https://jsr.io/@hugoalh/github-sodium)
|
|
84
79
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
80
|
+
## ✍️ Examples
|
|
81
|
+
|
|
82
|
+
- ```ts
|
|
83
|
+
new GitHubSodiumSealer("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234").encrypt("plain-text-secret");
|
|
88
84
|
```
|
package/mod.d.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type JSONObject } from "@hugoalh/is-json";
|
|
2
|
+
export interface GitHubRESTSetPublicKeyRequestBody {
|
|
3
|
+
encrypted_value: string;
|
|
4
|
+
key_id: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* GitHub sodium sealer for encrypt value to the GitHub secret value.
|
|
8
|
+
*/
|
|
9
|
+
export declare class GitHubSodiumSealer {
|
|
10
|
+
#private;
|
|
11
|
+
get [Symbol.toStringTag](): string;
|
|
12
|
+
/**
|
|
13
|
+
* Initialize the GitHub sodium sealer.
|
|
14
|
+
* @param {string} publicKey Public key, which get from the GitHub organization or repository, need for encrypt value to the GitHub secret value before create or update the GitHub secret.
|
|
15
|
+
* @param {string} [keyID] ID of the key, which get from the GitHub organization or repository, need for create or update the GitHub secret. This parameter is optional if no need to output as part of the {@linkcode Request} body.
|
|
16
|
+
*/
|
|
17
|
+
constructor(publicKey: string, keyID?: string);
|
|
18
|
+
/**
|
|
19
|
+
* Encrypt value to the GitHub secret value.
|
|
20
|
+
* @param {string} value Value that need to encrypt as the GitHub secret value.
|
|
21
|
+
* @returns {string} An encrypted GitHub secret value.
|
|
22
|
+
*/
|
|
23
|
+
encrypt(value: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Encrypt value to the GitHub secret value, and output as part of the {@linkcode Request} body for create or update GitHub secret via the GitHub REST API.
|
|
26
|
+
* @param {string} value Value that need to encrypt as the GitHub secret value.
|
|
27
|
+
* @returns {GitHubRESTSetPublicKeyRequestBody} Part of the {@linkcode Request} body for create or update GitHub secret via the GitHub REST API.
|
|
28
|
+
*/
|
|
29
|
+
encryptToRequestBody(value: string): GitHubRESTSetPublicKeyRequestBody;
|
|
30
|
+
/**
|
|
31
|
+
* Get the ID of the key.
|
|
32
|
+
* @returns {string | undefined} ID of the key.
|
|
33
|
+
*/
|
|
34
|
+
getKeyID(): string | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Get the ID of the key.
|
|
37
|
+
* @returns {string | undefined} ID of the key.
|
|
38
|
+
*/
|
|
39
|
+
get keyID(): string | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Initialize the GitHub sodium sealer with the {@linkcode Response} JSON body from get GitHub secret public key via the GitHub REST API.
|
|
42
|
+
* @param {JSONObject} input {@linkcode Response} JSON body.
|
|
43
|
+
* @returns {GitHubSodiumSealer} GitHub sodium sealer.
|
|
44
|
+
*/
|
|
45
|
+
static fromJSON(input: JSONObject): GitHubSodiumSealer;
|
|
46
|
+
/**
|
|
47
|
+
* Initialize the GitHub sodium sealer with the {@linkcode Response} from get GitHub secret public key via the GitHub REST API.
|
|
48
|
+
* @param {Response} input {@linkcode Response}.
|
|
49
|
+
* @returns {Promise<GitHubSodiumSealer>} GitHub sodium sealer.
|
|
50
|
+
*/
|
|
51
|
+
static fromResponse(input: Response): Promise<GitHubSodiumSealer>;
|
|
52
|
+
/**
|
|
53
|
+
* Encrypt value to the GitHub secret value.
|
|
54
|
+
* @param {string} publicKey Public key, which get from the GitHub organization or repository, need for encrypt value to the GitHub secret value before create or update the GitHub secret.
|
|
55
|
+
* @param {string} value Value that need to encrypt as the GitHub secret value.
|
|
56
|
+
* @returns {string} An encrypted GitHub secret value.
|
|
57
|
+
* @deprecated Migrate to `new GitHubSodiumSealer(publicKey).encrypt(value)`.
|
|
58
|
+
*/
|
|
59
|
+
static seal(publicKey: string, value: string): string;
|
|
60
|
+
}
|
|
61
|
+
export default GitHubSodiumSealer;
|
|
62
|
+
/**
|
|
63
|
+
* Encrypt value to the GitHub secret value.
|
|
64
|
+
* @param {string} publicKey Public key, which get from the GitHub organization or repository, need for encrypt value to the GitHub secret value before create or update the GitHub secret.
|
|
65
|
+
* @param {string} value Value that need to encrypt as the GitHub secret value.
|
|
66
|
+
* @returns {string} An encrypted GitHub secret value.
|
|
67
|
+
* @deprecated Migrate to `new GitHubSodiumSealer(publicKey).encrypt(value)`.
|
|
68
|
+
*/
|
|
69
|
+
export declare function seal(publicKey: string, value: string): string;
|
|
70
|
+
//# sourceMappingURL=mod.d.ts.map
|
package/mod.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAEA,OAAO,EAEN,KAAK,UAAU,EACf,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,iCAAiC;IACjD,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;CACf;AACD;;GAEG;AACH,qBAAa,kBAAkB;;IAC9B,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAEjC;IAGD;;;;OAIG;gBACS,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;IAa7C;;;;OAIG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAM9B;;;;OAIG;IACH,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,iCAAiC;IAStE;;;OAGG;IACH,QAAQ,IAAI,MAAM,GAAG,SAAS;IAG9B;;;OAGG;IACH,IAAI,KAAK,IAAI,MAAM,GAAG,SAAS,CAE9B;IACD;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,kBAAkB;IAStD;;;;OAIG;WACU,YAAY,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAOvE;;;;;;OAMG;IACH,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;CAGrD;AACD,eAAe,kBAAkB,CAAC;AAClC;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7D"}
|
package/mod.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
import libsodium from "libsodium-wrappers";
|
|
3
|
+
import { isJSONObject } from "@hugoalh/is-json";
|
|
4
|
+
await libsodium.ready;
|
|
5
|
+
/**
|
|
6
|
+
* GitHub sodium sealer for encrypt value to the GitHub secret value.
|
|
7
|
+
*/
|
|
8
|
+
export class GitHubSodiumSealer {
|
|
9
|
+
get [Symbol.toStringTag]() {
|
|
10
|
+
return "GitHubSodiumSealer";
|
|
11
|
+
}
|
|
12
|
+
#keyID;
|
|
13
|
+
#publicKey;
|
|
14
|
+
/**
|
|
15
|
+
* Initialize the GitHub sodium sealer.
|
|
16
|
+
* @param {string} publicKey Public key, which get from the GitHub organization or repository, need for encrypt value to the GitHub secret value before create or update the GitHub secret.
|
|
17
|
+
* @param {string} [keyID] ID of the key, which get from the GitHub organization or repository, need for create or update the GitHub secret. This parameter is optional if no need to output as part of the {@linkcode Request} body.
|
|
18
|
+
*/
|
|
19
|
+
constructor(publicKey, keyID) {
|
|
20
|
+
if (!(typeof keyID === "undefined" ||
|
|
21
|
+
(typeof keyID === "string" && keyID.length > 0))) {
|
|
22
|
+
throw new TypeError(`Parameter \`keyID\` is not \`undefined\`, or a string which is non empty!`);
|
|
23
|
+
}
|
|
24
|
+
if (!(publicKey.length > 0)) {
|
|
25
|
+
throw new SyntaxError(`Parameter \`publicKey\` is not a string which is non empty!`);
|
|
26
|
+
}
|
|
27
|
+
this.#keyID = keyID;
|
|
28
|
+
this.#publicKey = Buffer.from(publicKey, "base64");
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Encrypt value to the GitHub secret value.
|
|
32
|
+
* @param {string} value Value that need to encrypt as the GitHub secret value.
|
|
33
|
+
* @returns {string} An encrypted GitHub secret value.
|
|
34
|
+
*/
|
|
35
|
+
encrypt(value) {
|
|
36
|
+
if (!(value.length > 0)) {
|
|
37
|
+
throw new SyntaxError(`Parameter \`value\` is not a string which is non empty!`);
|
|
38
|
+
}
|
|
39
|
+
return Buffer.from(libsodium.crypto_box_seal(Buffer.from(value), this.#publicKey)).toString("base64");
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Encrypt value to the GitHub secret value, and output as part of the {@linkcode Request} body for create or update GitHub secret via the GitHub REST API.
|
|
43
|
+
* @param {string} value Value that need to encrypt as the GitHub secret value.
|
|
44
|
+
* @returns {GitHubRESTSetPublicKeyRequestBody} Part of the {@linkcode Request} body for create or update GitHub secret via the GitHub REST API.
|
|
45
|
+
*/
|
|
46
|
+
encryptToRequestBody(value) {
|
|
47
|
+
if (this.#keyID !== "string") {
|
|
48
|
+
throw new Error(`Key ID was not defined at the initialize stage!`);
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
encrypted_value: this.encrypt(value),
|
|
52
|
+
key_id: this.#keyID
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get the ID of the key.
|
|
57
|
+
* @returns {string | undefined} ID of the key.
|
|
58
|
+
*/
|
|
59
|
+
getKeyID() {
|
|
60
|
+
return this.#keyID;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get the ID of the key.
|
|
64
|
+
* @returns {string | undefined} ID of the key.
|
|
65
|
+
*/
|
|
66
|
+
get keyID() {
|
|
67
|
+
return this.#keyID;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Initialize the GitHub sodium sealer with the {@linkcode Response} JSON body from get GitHub secret public key via the GitHub REST API.
|
|
71
|
+
* @param {JSONObject} input {@linkcode Response} JSON body.
|
|
72
|
+
* @returns {GitHubSodiumSealer} GitHub sodium sealer.
|
|
73
|
+
*/
|
|
74
|
+
static fromJSON(input) {
|
|
75
|
+
if (typeof input.key !== "string" ||
|
|
76
|
+
typeof input.key_id !== "string") {
|
|
77
|
+
throw new Error(`Parameter \`input\` is not a valid response JSON body!`);
|
|
78
|
+
}
|
|
79
|
+
return new this(input.key, input.key_id);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Initialize the GitHub sodium sealer with the {@linkcode Response} from get GitHub secret public key via the GitHub REST API.
|
|
83
|
+
* @param {Response} input {@linkcode Response}.
|
|
84
|
+
* @returns {Promise<GitHubSodiumSealer>} GitHub sodium sealer.
|
|
85
|
+
*/
|
|
86
|
+
static async fromResponse(input) {
|
|
87
|
+
const responsePayload = await input.clone().json();
|
|
88
|
+
if (!isJSONObject(responsePayload)) {
|
|
89
|
+
throw new Error(`Parameter \`input\` is not a valid response!`);
|
|
90
|
+
}
|
|
91
|
+
return GitHubSodiumSealer.fromJSON(responsePayload);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Encrypt value to the GitHub secret value.
|
|
95
|
+
* @param {string} publicKey Public key, which get from the GitHub organization or repository, need for encrypt value to the GitHub secret value before create or update the GitHub secret.
|
|
96
|
+
* @param {string} value Value that need to encrypt as the GitHub secret value.
|
|
97
|
+
* @returns {string} An encrypted GitHub secret value.
|
|
98
|
+
* @deprecated Migrate to `new GitHubSodiumSealer(publicKey).encrypt(value)`.
|
|
99
|
+
*/
|
|
100
|
+
static seal(publicKey, value) {
|
|
101
|
+
return new this(publicKey).encrypt(value);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
export default GitHubSodiumSealer;
|
|
105
|
+
/**
|
|
106
|
+
* Encrypt value to the GitHub secret value.
|
|
107
|
+
* @param {string} publicKey Public key, which get from the GitHub organization or repository, need for encrypt value to the GitHub secret value before create or update the GitHub secret.
|
|
108
|
+
* @param {string} value Value that need to encrypt as the GitHub secret value.
|
|
109
|
+
* @returns {string} An encrypted GitHub secret value.
|
|
110
|
+
* @deprecated Migrate to `new GitHubSodiumSealer(publicKey).encrypt(value)`.
|
|
111
|
+
*/
|
|
112
|
+
export function seal(publicKey, value) {
|
|
113
|
+
return new GitHubSodiumSealer(publicKey).encrypt(value);
|
|
114
|
+
}
|
package/package.json
CHANGED
|
@@ -1,52 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hugoalh/github-sodium",
|
|
3
|
-
"version": "5.0
|
|
4
|
-
"description": "A module to provide an easier
|
|
3
|
+
"version": "5.1.0",
|
|
4
|
+
"description": "A module to provide an easier and simplified method for encrypt GitHub secrets.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"github",
|
|
7
7
|
"sodium"
|
|
8
8
|
],
|
|
9
|
-
"homepage": "https://github.com/hugoalh
|
|
9
|
+
"homepage": "https://github.com/hugoalh/github-sodium-es#readme",
|
|
10
10
|
"bugs": {
|
|
11
|
-
"url": "https://github.com/hugoalh
|
|
11
|
+
"url": "https://github.com/hugoalh/github-sodium-es/issues"
|
|
12
12
|
},
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"author": "hugoalh",
|
|
15
|
-
"files": [
|
|
16
|
-
"asset/**",
|
|
17
|
-
"bin/**",
|
|
18
|
-
"dist/**",
|
|
19
|
-
"lib/**",
|
|
20
|
-
"LICENSE*.md",
|
|
21
|
-
"package.json",
|
|
22
|
-
"README*.md"
|
|
23
|
-
],
|
|
24
15
|
"type": "module",
|
|
25
|
-
"main": "./
|
|
16
|
+
"main": "./mod.js",
|
|
17
|
+
"module": "./mod.js",
|
|
26
18
|
"exports": {
|
|
27
|
-
"
|
|
28
|
-
|
|
19
|
+
".": {
|
|
20
|
+
"import": {
|
|
21
|
+
"types": "./mod.d.ts",
|
|
22
|
+
"default": "./mod.js"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
29
25
|
},
|
|
30
|
-
"types": "./
|
|
26
|
+
"types": "./mod.d.ts",
|
|
31
27
|
"repository": {
|
|
32
28
|
"type": "git",
|
|
33
|
-
"url": "git+https://github.com/hugoalh
|
|
34
|
-
},
|
|
35
|
-
"scripts": {
|
|
36
|
-
"build": "tsc"
|
|
29
|
+
"url": "git+https://github.com/hugoalh/github-sodium-es.git"
|
|
37
30
|
},
|
|
31
|
+
"scripts": {},
|
|
38
32
|
"dependencies": {
|
|
39
|
-
"
|
|
33
|
+
"@hugoalh/is-json": "^1.0.4",
|
|
34
|
+
"libsodium-wrappers": "^0.7.15"
|
|
40
35
|
},
|
|
41
36
|
"devDependencies": {
|
|
42
|
-
"@
|
|
43
|
-
"@types/libsodium-wrappers": "^0.7.13",
|
|
44
|
-
"@types/node": "^20.12.2",
|
|
45
|
-
"@typescript-eslint/eslint-plugin": "^7.4.0",
|
|
46
|
-
"@typescript-eslint/parser": "^7.4.0",
|
|
47
|
-
"eslint": "^8.57.0",
|
|
48
|
-
"eslint-plugin-only-warn": "^1.1.0",
|
|
49
|
-
"typescript": "^5.4.3"
|
|
37
|
+
"@types/node": "^20.9.0"
|
|
50
38
|
},
|
|
51
39
|
"engines": {
|
|
52
40
|
"node": ">=16.13.0"
|
|
@@ -54,5 +42,6 @@
|
|
|
54
42
|
"private": false,
|
|
55
43
|
"publishConfig": {
|
|
56
44
|
"access": "public"
|
|
57
|
-
}
|
|
58
|
-
|
|
45
|
+
},
|
|
46
|
+
"_generatedBy": "dnt@dev"
|
|
47
|
+
}
|
package/dist/main.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GitHub sodium sealer for encrypt value to GitHub secret value.
|
|
3
|
-
*/
|
|
4
|
-
export declare class GitHubSodiumSealer {
|
|
5
|
-
#private;
|
|
6
|
-
/**
|
|
7
|
-
* Initialize GitHub sodium sealer.
|
|
8
|
-
* @param {string} publicKey Organization's or repository's public key, which need for encrypt value to secret value before create or update a secret.
|
|
9
|
-
*/
|
|
10
|
-
constructor(publicKey: string);
|
|
11
|
-
/**
|
|
12
|
-
* Encrypt value to GitHub secret value.
|
|
13
|
-
* @param {string} value Value that need to encrypt as secret value.
|
|
14
|
-
* @returns {string} An encrypted GitHub secret value.
|
|
15
|
-
*/
|
|
16
|
-
encrypt(value: string): string;
|
|
17
|
-
/**
|
|
18
|
-
* Encrypt value to GitHub secret value.
|
|
19
|
-
* @param {string} publicKey Organization's or repository's public key, which need for encrypt value to secret value before create or update a secret.
|
|
20
|
-
* @param {string} value Value that need to encrypt as secret value.
|
|
21
|
-
* @returns {string} An encrypted GitHub secret value.
|
|
22
|
-
*/
|
|
23
|
-
static seal(publicKey: string, value: string): string;
|
|
24
|
-
}
|
|
25
|
-
export default GitHubSodiumSealer;
|
|
26
|
-
/**
|
|
27
|
-
* Encrypt value to GitHub secret value.
|
|
28
|
-
* @param {string} publicKey Organization's or repository's public key, which need for encrypt value to secret value before create or update a secret.
|
|
29
|
-
* @param {string} value Value that need to encrypt as secret value.
|
|
30
|
-
* @returns {string} An encrypted GitHub secret value.
|
|
31
|
-
*/
|
|
32
|
-
export declare function seal(publicKey: string, value: string): string;
|
|
33
|
-
//# sourceMappingURL=main.d.ts.map
|
package/dist/main.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,qBAAa,kBAAkB;;IAE9B;;;OAGG;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
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import libsodium from "libsodium-wrappers";
|
|
2
|
-
await libsodium.ready;
|
|
3
|
-
/**
|
|
4
|
-
* GitHub sodium sealer for encrypt value to GitHub secret value.
|
|
5
|
-
*/
|
|
6
|
-
export class GitHubSodiumSealer {
|
|
7
|
-
#publicKeyBuffer;
|
|
8
|
-
/**
|
|
9
|
-
* Initialize GitHub sodium sealer.
|
|
10
|
-
* @param {string} publicKey Organization's or repository's public key, which need for encrypt value to secret value before create or update a secret.
|
|
11
|
-
*/
|
|
12
|
-
constructor(publicKey) {
|
|
13
|
-
if (!(publicKey.length > 0)) {
|
|
14
|
-
throw new SyntaxError(`Argument \`publicKey\` is not a string which is non-empty!`);
|
|
15
|
-
}
|
|
16
|
-
this.#publicKeyBuffer = Buffer.from(publicKey, "base64");
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Encrypt value to GitHub secret value.
|
|
20
|
-
* @param {string} value Value that need to encrypt as secret value.
|
|
21
|
-
* @returns {string} An encrypted GitHub secret value.
|
|
22
|
-
*/
|
|
23
|
-
encrypt(value) {
|
|
24
|
-
if (!(value.length > 0)) {
|
|
25
|
-
throw new SyntaxError(`Argument \`value\` is not a string which is non-empty!`);
|
|
26
|
-
}
|
|
27
|
-
return Buffer.from(libsodium.crypto_box_seal(Buffer.from(value), this.#publicKeyBuffer)).toString("base64");
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Encrypt value to GitHub secret value.
|
|
31
|
-
* @param {string} publicKey Organization's or repository's public key, which need for encrypt value to secret value before create or update a secret.
|
|
32
|
-
* @param {string} value Value that need to encrypt as secret value.
|
|
33
|
-
* @returns {string} An encrypted GitHub secret value.
|
|
34
|
-
*/
|
|
35
|
-
static seal(publicKey, value) {
|
|
36
|
-
return new this(publicKey).encrypt(value);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
export default GitHubSodiumSealer;
|
|
40
|
-
/**
|
|
41
|
-
* Encrypt value to GitHub secret value.
|
|
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.
|
|
43
|
-
* @param {string} value Value that need to encrypt as secret value.
|
|
44
|
-
* @returns {string} An encrypted GitHub secret value.
|
|
45
|
-
*/
|
|
46
|
-
export function seal(publicKey, value) {
|
|
47
|
-
return new GitHubSodiumSealer(publicKey).encrypt(value);
|
|
48
|
-
}
|