@hugoalh/github-sodium 5.0.2 → 5.0.3
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 +107 -32
- package/dist/{main.d.ts → mod.d.ts} +1 -1
- package/dist/mod.d.ts.map +1 -0
- package/dist/{main.js → mod.js} +4 -3
- package/package.json +11 -16
- package/dist/main.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
# GitHub Sodium (
|
|
1
|
+
# GitHub Sodium (ES)
|
|
2
2
|
|
|
3
3
|
[**⚖️** MIT](./LICENSE.md)
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
[](https://github.com/hugoalh-studio/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 sodium for GitHub secrets.
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
This project is based on [libsodium.js](https://github.com/jedisct1/libsodium.js) with optimization for GitHub secrets.
|
|
11
|
+
This project is based on "[libsodium.js](https://github.com/jedisct1/libsodium.js)" with optimization for GitHub secrets.
|
|
14
12
|
|
|
15
13
|
## 🎯 Target
|
|
16
14
|
|
|
17
15
|
- Bun ^ v1.0.0
|
|
18
16
|
- Cloudflare Workers
|
|
19
|
-
- Deno >= v1.34.0
|
|
17
|
+
- Deno >= v1.34.0 / >= v1.41.1 (For JSR Only)
|
|
20
18
|
> **🛡️ Require Permission**
|
|
21
19
|
>
|
|
22
20
|
> *N/A*
|
|
@@ -24,48 +22,126 @@ This project is based on [libsodium.js](https://github.com/jedisct1/libsodium.js
|
|
|
24
22
|
|
|
25
23
|
## 🔰 Usage
|
|
26
24
|
|
|
27
|
-
### Via
|
|
25
|
+
### Via JSR With `node_modules`
|
|
26
|
+
|
|
27
|
+
> **🎯 Supported Target**
|
|
28
|
+
>
|
|
29
|
+
> - Bun
|
|
30
|
+
> - Cloudflare Workers
|
|
31
|
+
> - NodeJS
|
|
32
|
+
|
|
33
|
+
1. Install via:
|
|
34
|
+
- Bun
|
|
35
|
+
```sh
|
|
36
|
+
bunx jsr add @hugoalh/github-sodium[@${Tag}]
|
|
37
|
+
```
|
|
38
|
+
- NPM
|
|
39
|
+
```sh
|
|
40
|
+
npx jsr add @hugoalh/github-sodium[@${Tag}]
|
|
41
|
+
```
|
|
42
|
+
- PNPM
|
|
43
|
+
```sh
|
|
44
|
+
pnpm dlx jsr add @hugoalh/github-sodium[@${Tag}]
|
|
45
|
+
```
|
|
46
|
+
- Yarn
|
|
47
|
+
```sh
|
|
48
|
+
yarn dlx jsr add @hugoalh/github-sodium[@${Tag}]
|
|
49
|
+
```
|
|
50
|
+
2. Import at the script:
|
|
51
|
+
```ts
|
|
52
|
+
import ... from "@hugoalh/github-sodium";
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
> **ℹ️ Note**
|
|
56
|
+
>
|
|
57
|
+
> - 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 `jsr.jsonc`](./jsr.jsonc) property `exports` for available sub paths.
|
|
58
|
+
> - It is recommended to import the module with tag for immutability.
|
|
59
|
+
|
|
60
|
+
### Via JSR With Specifier
|
|
61
|
+
|
|
62
|
+
> **🎯 Supported Target**
|
|
63
|
+
>
|
|
64
|
+
> - Deno
|
|
65
|
+
|
|
66
|
+
1. Import at the script:
|
|
67
|
+
```ts
|
|
68
|
+
import ... from "jsr:@hugoalh/github-sodium[@${Tag}]";
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
> **ℹ️ Note**
|
|
72
|
+
>
|
|
73
|
+
> - 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 `jsr.jsonc`](./jsr.jsonc) property `exports` for available sub paths.
|
|
74
|
+
> - It is recommended to import the module with tag for immutability.
|
|
75
|
+
|
|
76
|
+
### Via NPM With `node_modules`
|
|
28
77
|
|
|
29
78
|
> **🎯 Supported Target**
|
|
30
79
|
>
|
|
31
80
|
> - Cloudflare Workers
|
|
32
81
|
> - NodeJS
|
|
33
82
|
|
|
34
|
-
1. Install via
|
|
35
|
-
-
|
|
83
|
+
1. Install via:
|
|
84
|
+
- NPM
|
|
36
85
|
```sh
|
|
37
|
-
npm install @hugoalh/github-sodium[
|
|
86
|
+
npm install @hugoalh/github-sodium[@${Tag}]
|
|
38
87
|
```
|
|
39
|
-
-
|
|
88
|
+
- PNPM
|
|
40
89
|
```sh
|
|
41
|
-
pnpm add @hugoalh/github-sodium[
|
|
90
|
+
pnpm add @hugoalh/github-sodium[@${Tag}]
|
|
42
91
|
```
|
|
43
|
-
-
|
|
92
|
+
- Yarn
|
|
44
93
|
```sh
|
|
45
|
-
yarn add @hugoalh/github-sodium[
|
|
94
|
+
yarn add @hugoalh/github-sodium[@${Tag}]
|
|
46
95
|
```
|
|
47
|
-
2. Import at the script
|
|
48
|
-
```
|
|
96
|
+
2. Import at the script:
|
|
97
|
+
```ts
|
|
49
98
|
import ... from "@hugoalh/github-sodium";
|
|
50
99
|
```
|
|
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
100
|
|
|
55
|
-
|
|
101
|
+
> **ℹ️ Note**
|
|
102
|
+
>
|
|
103
|
+
> - 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 `jsr.jsonc`](./jsr.jsonc) property `exports` for available sub paths.
|
|
104
|
+
> - It is recommended to import the module with tag for immutability.
|
|
105
|
+
|
|
106
|
+
### Via NPM With Specifier
|
|
56
107
|
|
|
57
108
|
> **🎯 Supported Target**
|
|
58
109
|
>
|
|
59
110
|
> - Bun
|
|
60
111
|
> - Deno
|
|
61
112
|
|
|
62
|
-
1. Import at the script
|
|
63
|
-
```
|
|
64
|
-
import ... from "npm:@hugoalh/github-sodium[
|
|
113
|
+
1. Import at the script:
|
|
114
|
+
```ts
|
|
115
|
+
import ... from "npm:@hugoalh/github-sodium[@${Tag}]";
|
|
65
116
|
```
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
117
|
+
|
|
118
|
+
> **ℹ️ Note**
|
|
119
|
+
>
|
|
120
|
+
> - 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 `jsr.jsonc`](./jsr.jsonc) property `exports` for available sub paths.
|
|
121
|
+
> - It is recommended to import the module with tag for immutability.
|
|
122
|
+
|
|
123
|
+
### Via Remote Import
|
|
124
|
+
|
|
125
|
+
> **🎯 Supported Target**
|
|
126
|
+
>
|
|
127
|
+
> - Deno
|
|
128
|
+
|
|
129
|
+
1. Import at the script:
|
|
130
|
+
```ts
|
|
131
|
+
/* Via GitHub Raw (Require Tag) */
|
|
132
|
+
import ... from "https://raw.githubusercontent.com/hugoalh-studio/github-sodium-es/${Tag}/mod.ts";
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
> **ℹ️ Note**
|
|
136
|
+
>
|
|
137
|
+
> - Although it is recommended to import the entire module with the main path `mod.ts`, it is also able to import part of the module with sub path if available, but do not import if:
|
|
138
|
+
>
|
|
139
|
+
> - it's file path has an underscore prefix (e.g.: `_foo.ts`, `_util/bar.ts`), or
|
|
140
|
+
> - it is a benchmark or test file (e.g.: `foo.bench.ts`, `foo.test.ts`), or
|
|
141
|
+
> - it's symbol has an underscore prefix (e.g.: `export function _baz() {}`).
|
|
142
|
+
>
|
|
143
|
+
> These elements are not considered part of the public API, thus no stability is guaranteed for them.
|
|
144
|
+
> - Although there have 3rd party services which provide enhanced, equal, or similar methods/ways to remote import the module, beware these services maybe inject unrelated elements and thus affect the security.
|
|
69
145
|
|
|
70
146
|
## 🧩 API
|
|
71
147
|
|
|
@@ -82,7 +158,6 @@ This project is based on [libsodium.js](https://github.com/jedisct1/libsodium.js
|
|
|
82
158
|
|
|
83
159
|
## ✍️ Example
|
|
84
160
|
|
|
85
|
-
- ```
|
|
86
|
-
new GitHubSodiumSealer("
|
|
87
|
-
//=> "+ZYvJDZMHUfBkJdyq5Zm9SKqeuBQ4sj+6sfjlH4CgG0="
|
|
161
|
+
- ```ts
|
|
162
|
+
new GitHubSodiumSealer("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234").encrypt("plain-text-secret");
|
|
88
163
|
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAGA;;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 → mod.js}
RENAMED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
1
2
|
import libsodium from "libsodium-wrappers";
|
|
2
3
|
await libsodium.ready;
|
|
3
4
|
/**
|
|
4
5
|
* GitHub sodium sealer for encrypt value to GitHub secret value.
|
|
5
6
|
*/
|
|
6
7
|
export class GitHubSodiumSealer {
|
|
7
|
-
#
|
|
8
|
+
#publicKey;
|
|
8
9
|
/**
|
|
9
10
|
* Initialize GitHub sodium sealer.
|
|
10
11
|
* @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,7 +14,7 @@ export class GitHubSodiumSealer {
|
|
|
13
14
|
if (!(publicKey.length > 0)) {
|
|
14
15
|
throw new SyntaxError(`Argument \`publicKey\` is not a string which is non-empty!`);
|
|
15
16
|
}
|
|
16
|
-
this.#
|
|
17
|
+
this.#publicKey = Buffer.from(publicKey, "base64");
|
|
17
18
|
}
|
|
18
19
|
/**
|
|
19
20
|
* Encrypt value to GitHub secret value.
|
|
@@ -24,7 +25,7 @@ export class GitHubSodiumSealer {
|
|
|
24
25
|
if (!(value.length > 0)) {
|
|
25
26
|
throw new SyntaxError(`Argument \`value\` is not a string which is non-empty!`);
|
|
26
27
|
}
|
|
27
|
-
return Buffer.from(libsodium.crypto_box_seal(Buffer.from(value), this.#
|
|
28
|
+
return Buffer.from(libsodium.crypto_box_seal(Buffer.from(value), this.#publicKey)).toString("base64");
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
30
31
|
* Encrypt value to GitHub secret value.
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hugoalh/github-sodium",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.3",
|
|
4
4
|
"description": "A module to provide an easier sodium for GitHub secrets.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"github",
|
|
7
7
|
"sodium"
|
|
8
8
|
],
|
|
9
|
-
"homepage": "https://github.com/hugoalh-studio/github-sodium-
|
|
9
|
+
"homepage": "https://github.com/hugoalh-studio/github-sodium-es#readme",
|
|
10
10
|
"bugs": {
|
|
11
|
-
"url": "https://github.com/hugoalh-studio/github-sodium-
|
|
11
|
+
"url": "https://github.com/hugoalh-studio/github-sodium-es/issues"
|
|
12
12
|
},
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"author": "hugoalh",
|
|
@@ -22,15 +22,15 @@
|
|
|
22
22
|
"README*.md"
|
|
23
23
|
],
|
|
24
24
|
"type": "module",
|
|
25
|
-
"main": "./dist/
|
|
25
|
+
"main": "./dist/mod.js",
|
|
26
26
|
"exports": {
|
|
27
|
-
"types": "./dist/
|
|
28
|
-
"import": "./dist/
|
|
27
|
+
"types": "./dist/mod.d.ts",
|
|
28
|
+
"import": "./dist/mod.js"
|
|
29
29
|
},
|
|
30
|
-
"types": "./dist/
|
|
30
|
+
"types": "./dist/mod.d.ts",
|
|
31
31
|
"repository": {
|
|
32
32
|
"type": "git",
|
|
33
|
-
"url": "git+https://github.com/hugoalh-studio/github-sodium-
|
|
33
|
+
"url": "git+https://github.com/hugoalh-studio/github-sodium-es.git"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "tsc"
|
|
@@ -39,14 +39,9 @@
|
|
|
39
39
|
"libsodium-wrappers": "0.7.13"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@
|
|
43
|
-
"@types/
|
|
44
|
-
"
|
|
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"
|
|
42
|
+
"@types/libsodium-wrappers": "0.7.14",
|
|
43
|
+
"@types/node": "20.12.7",
|
|
44
|
+
"typescript": "^5.4.5"
|
|
50
45
|
},
|
|
51
46
|
"engines": {
|
|
52
47
|
"node": ">=16.13.0"
|
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"}
|