@hugoalh/github-sodium 5.0.1 → 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,52 +1,147 @@
1
- # GitHub Sodium (NodeJS)
1
+ # GitHub Sodium (ES)
2
+
3
+ [**⚖️** MIT](./LICENSE.md)
4
+
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
+
9
+ An ES (JavaScript & TypeScript) module to provide an easier sodium for GitHub secrets.
10
+
11
+ This project is based on "[libsodium.js](https://github.com/jedisct1/libsodium.js)" with optimization for GitHub secrets.
12
+
13
+ ## 🎯 Target
14
+
15
+ - Bun ^ v1.0.0
16
+ - Cloudflare Workers
17
+ - Deno >= v1.34.0 / >= v1.41.1 (For JSR Only)
18
+ > **🛡️ Require Permission**
19
+ >
20
+ > *N/A*
21
+ - NodeJS >= v16.13.0
22
+
23
+ ## 🔰 Usage
24
+
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
+ ```
2
54
 
3
- [⚖️ MIT](./LICENSE.md)
4
- [![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/hugoalh-studio/github-sodium-nodejs?label=Grade&logo=codefactor&logoColor=ffffff&style=flat-square "CodeFactor Grade")](https://www.codefactor.io/repository/github/hugoalh-studio/github-sodium-nodejs)
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.
5
59
 
6
- | | **Release - Latest** | **Release - Pre** |
7
- |:-:|:-:|:-:|
8
- | [![GitHub](https://img.shields.io/badge/GitHub-181717?logo=github&logoColor=ffffff&style=flat-square "GitHub")](https://github.com/hugoalh-studio/github-sodium-nodejs) | ![GitHub Latest Release Version](https://img.shields.io/github/release/hugoalh-studio/github-sodium-nodejs?sort=semver&label=&style=flat-square "GitHub Latest Release Version") (![GitHub Latest Release Date](https://img.shields.io/github/release-date/hugoalh-studio/github-sodium-nodejs?label=&style=flat-square "GitHub Latest Release Date")) | ![GitHub Latest Pre-Release Version](https://img.shields.io/github/release/hugoalh-studio/github-sodium-nodejs?include_prereleases&sort=semver&label=&style=flat-square "GitHub Latest Pre-Release Version") (![GitHub Latest Pre-Release Date](https://img.shields.io/github/release-date-pre/hugoalh-studio/github-sodium-nodejs?label=&style=flat-square "GitHub Latest Pre-Release Date")) |
9
- | [![NPM](https://img.shields.io/badge/NPM-CB3837?logo=npm&logoColor=ffffff&style=flat-square "NPM")](https://www.npmjs.com/package/@hugoalh/github-sodium) | ![NPM Latest Release Version](https://img.shields.io/npm/v/@hugoalh/github-sodium/latest?label=&style=flat-square "NPM Latest Release Version") | ![NPM Latest Pre-Release Version](https://img.shields.io/npm/v/@hugoalh/github-sodium/pre?label=&style=flat-square "NPM Latest Pre-Release Version") |
60
+ ### Via JSR With Specifier
10
61
 
11
- A NodeJS module to provide an easier sodium for GitHub secrets.
62
+ > **🎯 Supported Target**
63
+ >
64
+ > - Deno
12
65
 
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.
66
+ 1. Import at the script:
67
+ ```ts
68
+ import ... from "jsr:@hugoalh/github-sodium[@${Tag}]";
69
+ ```
14
70
 
15
- ## 🔰 Begin
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`
77
+
78
+ > **🎯 Supported Target**
79
+ >
80
+ > - Cloudflare Workers
81
+ > - NodeJS
82
+
83
+ 1. Install via:
84
+ - NPM
85
+ ```sh
86
+ npm install @hugoalh/github-sodium[@${Tag}]
87
+ ```
88
+ - PNPM
89
+ ```sh
90
+ pnpm add @hugoalh/github-sodium[@${Tag}]
91
+ ```
92
+ - Yarn
93
+ ```sh
94
+ yarn add @hugoalh/github-sodium[@${Tag}]
95
+ ```
96
+ 2. Import at the script:
97
+ ```ts
98
+ import ... from "@hugoalh/github-sodium";
99
+ ```
16
100
 
17
- ### Bun
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.
18
105
 
19
- > **🧪 Experimental:** Bun is still under development.
106
+ ### Via NPM With Specifier
20
107
 
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>]";
108
+ > **🎯 Supported Target**
109
+ >
110
+ > - Bun
111
+ > - Deno
112
+
113
+ 1. Import at the script:
114
+ ```ts
115
+ import ... from "npm:@hugoalh/github-sodium[@${Tag}]";
31
116
  ```
32
117
 
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.
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.
34
122
 
35
- ### NodeJS
123
+ ### Via Remote Import
36
124
 
37
- - **Target Version:** >= 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";
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";
47
133
  ```
48
134
 
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.
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.
50
145
 
51
146
  ## 🧩 API
52
147
 
@@ -61,13 +156,8 @@ This project is based on libsodium.js ([GitHub](https://github.com/jedisct1/libs
61
156
  function seal(publicKey: string, value: string): string;
62
157
  ```
63
158
 
64
- > **ℹ️ Notice:** Documentation is included inside the script file.
65
-
66
159
  ## ✍️ Example
67
160
 
68
- - ```js
69
- import { GitHubSodiumSealer } from "@hugoalh/github-sodium";
70
-
71
- new GitHubSodiumSealer("base64-encoded-public-key").encrypt("plain-text-secret");
72
- //=> "+ZYvJDZMHUfBkJdyq5Zm9SKqeuBQ4sj+6sfjlH4CgG0="
161
+ - ```ts
162
+ new GitHubSodiumSealer("2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234").encrypt("plain-text-secret");
73
163
  ```
@@ -4,6 +4,7 @@
4
4
  export declare class GitHubSodiumSealer {
5
5
  #private;
6
6
  /**
7
+ * Initialize GitHub sodium sealer.
7
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.
8
9
  */
9
10
  constructor(publicKey: string);
@@ -29,4 +30,4 @@ export default GitHubSodiumSealer;
29
30
  * @returns {string} An encrypted GitHub secret value.
30
31
  */
31
32
  export declare function seal(publicKey: string, value: string): string;
32
- //# 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,18 +1,20 @@
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
  /**
10
+ * Initialize GitHub sodium sealer.
9
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.
10
12
  */
11
13
  constructor(publicKey) {
12
14
  if (!(publicKey.length > 0)) {
13
15
  throw new SyntaxError(`Argument \`publicKey\` is not a string which is non-empty!`);
14
16
  }
15
- this.#publicKeyBuffer = Buffer.from(publicKey, "base64");
17
+ this.#publicKey = Buffer.from(publicKey, "base64");
16
18
  }
17
19
  /**
18
20
  * Encrypt value to GitHub secret value.
@@ -23,7 +25,7 @@ export class GitHubSodiumSealer {
23
25
  if (!(value.length > 0)) {
24
26
  throw new SyntaxError(`Argument \`value\` is not a string which is non-empty!`);
25
27
  }
26
- 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");
27
29
  }
28
30
  /**
29
31
  * Encrypt value to GitHub secret value.
package/package.json CHANGED
@@ -1,40 +1,47 @@
1
1
  {
2
2
  "name": "@hugoalh/github-sodium",
3
- "version": "5.0.1",
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-nodejs#readme",
9
+ "homepage": "https://github.com/hugoalh-studio/github-sodium-es#readme",
10
10
  "bugs": {
11
- "url": "https://github.com/hugoalh-studio/github-sodium-nodejs/issues"
11
+ "url": "https://github.com/hugoalh-studio/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
+ ],
15
24
  "type": "module",
16
- "main": "./dist/main.js",
25
+ "main": "./dist/mod.js",
17
26
  "exports": {
18
- "types": "./dist/main.d.ts",
19
- "import": "./dist/main.js"
27
+ "types": "./dist/mod.d.ts",
28
+ "import": "./dist/mod.js"
20
29
  },
21
- "types": "./dist/main.d.ts",
30
+ "types": "./dist/mod.d.ts",
22
31
  "repository": {
23
32
  "type": "git",
24
- "url": "git+https://github.com/hugoalh-studio/github-sodium-nodejs.git"
33
+ "url": "git+https://github.com/hugoalh-studio/github-sodium-es.git"
34
+ },
35
+ "scripts": {
36
+ "build": "tsc"
25
37
  },
26
38
  "dependencies": {
27
- "libsodium-wrappers": "^0.7.13"
39
+ "libsodium-wrappers": "0.7.13"
28
40
  },
29
41
  "devDependencies": {
30
- "@stylistic/eslint-plugin": "^1.5.3",
31
- "@types/libsodium-wrappers": "^0.7.13",
32
- "@types/node": "^20.11.0",
33
- "@typescript-eslint/eslint-plugin": "^6.18.1",
34
- "@typescript-eslint/parser": "^6.18.1",
35
- "eslint": "^8.56.0",
36
- "eslint-plugin-only-warn": "^1.1.0",
37
- "typescript": "^5.3.3"
42
+ "@types/libsodium-wrappers": "0.7.14",
43
+ "@types/node": "20.12.7",
44
+ "typescript": "^5.4.5"
38
45
  },
39
46
  "engines": {
40
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;;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"}