@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 CHANGED
@@ -1,22 +1,20 @@
1
- # GitHub Sodium (JavaScript)
1
+ # GitHub Sodium (ES)
2
2
 
3
3
  [**⚖️** MIT](./LICENSE.md)
4
4
 
5
- **🗂️**
6
- [![GitHub: hugoalh-studio/github-sodium-js](https://img.shields.io/badge/hugoalh--studio/github--sodium--js-181717?logo=github&logoColor=ffffff&style=flat "GitHub: hugoalh-studio/github-sodium-js")](https://github.com/hugoalh-studio/github-sodium-js)
7
- [![NPM: @hugoalh/github-sodium](https://img.shields.io/badge/@hugoalh/github--sodium-CB3837?logo=npm&logoColor=ffffff&style=flat "NPM: @hugoalh/github-sodium")](https://www.npmjs.com/package/@hugoalh/github-sodium)
5
+ [![GitHub: hugoalh-studio/github-sodium-es](https://img.shields.io/github/v/release/hugoalh-studio/github-sodium-es?label=hugoalh-studio/github-sodium-es&labelColor=181717&logo=github&logoColor=ffffff&sort=semver&style=flat "GitHub: hugoalh-studio/github-sodium-es")](https://github.com/hugoalh-studio/github-sodium-es)
6
+ [![JSR: @hugoalh/github-sodium](https://img.shields.io/jsr/v/@hugoalh/github-sodium?label=JSR%20@hugoalh/github-sodium&labelColor=F7DF1E&logoColor=000000&style=flat "JSR: @hugoalh/github-sodium")](https://jsr.io/@hugoalh/github-sodium)
7
+ [![NPM: @hugoalh/github-sodium](https://img.shields.io/npm/v/@hugoalh/github-sodium?label=@hugoalh/github-sodium&labelColor=CB3837&logo=npm&logoColor=ffffff&style=flat "NPM: @hugoalh/github-sodium")](https://www.npmjs.com/package/@hugoalh/github-sodium)
8
8
 
9
- **🆙** ![Latest Release Version](https://img.shields.io/github/release/hugoalh-studio/github-sodium-js?sort=semver&color=2187C0&label=&style=flat "Latest Release Version") (![Latest Release Date](https://img.shields.io/github/release-date/hugoalh-studio/github-sodium-js?color=2187C0&label=&style=flat "Latest Release Date"))
9
+ An ES (JavaScript & TypeScript) module to provide an easier sodium for GitHub secrets.
10
10
 
11
- A JavaScript module to provide an easier sodium for GitHub secrets.
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 Installation
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 console/shell/terminal:
35
- - Via NPM
83
+ 1. Install via:
84
+ - NPM
36
85
  ```sh
37
- npm install @hugoalh/github-sodium[@<Tag>]
86
+ npm install @hugoalh/github-sodium[@${Tag}]
38
87
  ```
39
- - Via PNPM
88
+ - PNPM
40
89
  ```sh
41
- pnpm add @hugoalh/github-sodium[@<Tag>]
90
+ pnpm add @hugoalh/github-sodium[@${Tag}]
42
91
  ```
43
- - Via Yarn
92
+ - Yarn
44
93
  ```sh
45
- yarn add @hugoalh/github-sodium[@<Tag>]
94
+ yarn add @hugoalh/github-sodium[@${Tag}]
46
95
  ```
47
- 2. Import at the script (`<ScriptName>.js`):
48
- ```js
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
- ### Via NPM Specifier
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 (`<ScriptName>.js`):
63
- ```js
64
- import ... from "npm:@hugoalh/github-sodium[@<Tag>]";
113
+ 1. Import at the script:
114
+ ```ts
115
+ import ... from "npm:@hugoalh/github-sodium[@${Tag}]";
65
116
  ```
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.
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
- - ```js
86
- new GitHubSodiumSealer("base64-encoded-public-key").encrypt("plain-text-secret");
87
- //=> "+ZYvJDZMHUfBkJdyq5Zm9SKqeuBQ4sj+6sfjlH4CgG0="
161
+ - ```ts
162
+ new GitHubSodiumSealer("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234").encrypt("plain-text-secret");
88
163
  ```
@@ -30,4 +30,4 @@ export default GitHubSodiumSealer;
30
30
  * @returns {string} An encrypted GitHub secret value.
31
31
  */
32
32
  export declare function seal(publicKey: string, value: string): string;
33
- //# sourceMappingURL=main.d.ts.map
33
+ //# sourceMappingURL=mod.d.ts.map
@@ -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"}
@@ -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
- #publicKeyBuffer;
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.#publicKeyBuffer = Buffer.from(publicKey, "base64");
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.#publicKeyBuffer)).toString("base64");
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.2",
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-js#readme",
9
+ "homepage": "https://github.com/hugoalh-studio/github-sodium-es#readme",
10
10
  "bugs": {
11
- "url": "https://github.com/hugoalh-studio/github-sodium-js/issues"
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/main.js",
25
+ "main": "./dist/mod.js",
26
26
  "exports": {
27
- "types": "./dist/main.d.ts",
28
- "import": "./dist/main.js"
27
+ "types": "./dist/mod.d.ts",
28
+ "import": "./dist/mod.js"
29
29
  },
30
- "types": "./dist/main.d.ts",
30
+ "types": "./dist/mod.d.ts",
31
31
  "repository": {
32
32
  "type": "git",
33
- "url": "git+https://github.com/hugoalh-studio/github-sodium-js.git"
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
- "@stylistic/eslint-plugin": "^1.7.0",
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"
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"
@@ -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"}