@hugoalh/github-sodium 3.1.2 → 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 CHANGED
@@ -1,60 +1,73 @@
1
1
  # GitHub Sodium (NodeJS)
2
2
 
3
- ![License](https://img.shields.io/static/v1?label=License&message=MIT&style=flat-square "License")
4
- [![GitHub Repository](https://img.shields.io/badge/Repository-181717?logo=github&logoColor=ffffff&style=flat-square "GitHub Repository")](https://github.com/hugoalh-studio/github-sodium-nodejs)
5
- [![GitHub Stars](https://img.shields.io/github/stars/hugoalh-studio/github-sodium-nodejs?label=Stars&logo=github&logoColor=ffffff&style=flat-square "GitHub Stars")](https://github.com/hugoalh-studio/github-sodium-nodejs/stargazers)
6
- [![GitHub Contributors](https://img.shields.io/github/contributors/hugoalh-studio/github-sodium-nodejs?label=Contributors&logo=github&logoColor=ffffff&style=flat-square "GitHub Contributors")](https://github.com/hugoalh-studio/github-sodium-nodejs/graphs/contributors)
7
- [![GitHub Issues](https://img.shields.io/github/issues-raw/hugoalh-studio/github-sodium-nodejs?label=Issues&logo=github&logoColor=ffffff&style=flat-square "GitHub Issues")](https://github.com/hugoalh-studio/github-sodium-nodejs/issues)
8
- [![GitHub Pull Requests](https://img.shields.io/github/issues-pr-raw/hugoalh-studio/github-sodium-nodejs?label=Pull%20Requests&logo=github&logoColor=ffffff&style=flat-square "GitHub Pull Requests")](https://github.com/hugoalh-studio/github-sodium-nodejs/pulls)
9
- [![GitHub Discussions](https://img.shields.io/github/discussions/hugoalh-studio/github-sodium-nodejs?label=Discussions&logo=github&logoColor=ffffff&style=flat-square "GitHub Discussions")](https://github.com/hugoalh-studio/github-sodium-nodejs/discussions)
3
+ [⚖️ MIT](./LICENSE.md)
10
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)
11
5
 
12
- | **Releases** | **Latest** (![GitHub Latest Release Date](https://img.shields.io/github/release-date/hugoalh-studio/github-sodium-nodejs?label=&style=flat-square "GitHub Latest Release Date")) | **Pre** (![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")) |
13
- |:-:|:-:|:-:|
14
- | [![GitHub](https://img.shields.io/badge/GitHub-181717?logo=github&logoColor=ffffff&style=flat-square "GitHub")](https://github.com/hugoalh-studio/github-sodium-nodejs/releases) ![GitHub Total Downloads](https://img.shields.io/github/downloads/hugoalh-studio/github-sodium-nodejs/total?label=&style=flat-square "GitHub Total Downloads") | ![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 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") |
15
- | [![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 Total Downloads](https://img.shields.io/npm/dt/@hugoalh/github-sodium?label=&style=flat-square "NPM Total Downloads") | ![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") |
16
-
17
- ## 📝 Description
6
+ | | **Heat** | **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 Stars](https://img.shields.io/github/stars/hugoalh-studio/github-sodium-nodejs?label=&logoColor=ffffff&style=flat-square "GitHub Stars")](https://github.com/hugoalh-studio/github-sodium-nodejs/stargazers) \| ![GitHub Total Downloads](https://img.shields.io/github/downloads/hugoalh-studio/github-sodium-nodejs/total?label=&style=flat-square "GitHub Total Downloads") | ![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 Total Downloads](https://img.shields.io/npm/dt/@hugoalh/github-sodium?label=&style=flat-square "NPM Total Downloads") | ![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") |
18
10
 
19
11
  A NodeJS module to provide an easier sodium for GitHub secrets.
20
12
 
21
- 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.
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.
22
14
 
23
- ## 📚 Documentation
15
+ ## 🔰 Begin
24
16
 
25
- ### Getting Started
17
+ ### Bun
26
18
 
27
- - NodeJS ^ v12.20.0 \|\| ^ v14.15.0 \|\| >= v16.13.0
19
+ > **🧪 Experimental:** Bun is still under development.
28
20
 
29
- ```sh
30
- npm install @hugoalh/github-sodium
31
- ```
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
+ ```
32
32
 
33
- ```js
34
- /* Either */
35
- import { ... } from "@hugoalh/github-sodium";// Named Import
36
- import * as githubSodium from "@hugoalh/github-sodium";// Namespace Import
37
- import githubSodium from "@hugoalh/github-sodium";// Default Import
38
- ```
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.
39
34
 
40
- ### API
35
+ ### NodeJS
41
36
 
42
- #### Class
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
+ ```
43
48
 
44
- - ```ts
45
- new GitHubSodiumSealer(publicKey: string): GitHubSodiumSealer;
46
- .encrypt(value: string): string;
47
- ```
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.
48
50
 
49
- #### Function
51
+ ## 🧩 API
50
52
 
51
53
  - ```ts
52
- seal(publicKey: string, value: string): string;
54
+ class GitHubSodiumSealer {
55
+ constructor(publicKey: string): GitHubSodiumSealer;
56
+ encrypt(value: string): string;
57
+ static seal(publicKey: string, value: string): string;
58
+ }
59
+ ```
60
+ - ```ts
61
+ function seal(publicKey: string, value: string): string;
53
62
  ```
54
63
 
55
- ### Example
64
+ > **ℹ️ Notice:** Documentation is included inside the script file.
65
+
66
+ ## ✍️ Example
56
67
 
57
- ```js
58
- new GitHubSodiumSealer("base64-encoded-public-key").encrypt("plain-text-secret");
59
- //=> "+ZYvJDZMHUfBkJdyq5Zm9SKqeuBQ4sj+6sfjlH4CgG0="
60
- ```
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
- * @class GitHubSodiumSealer
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
- * @method encrypt
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
- * @static seal
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
- * @function seal
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
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,cAAM,kBAAkB;;IAEvB;;;OAGG;gBACS,SAAS,EAAE,MAAM;IAS7B;;;;OAIG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAS9B;;;;;;OAMG;IACH,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;CAGrD;AACD;;;;;;GAMG;AACH,iBAAS,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAEtD;AACD,OAAO,EACN,kBAAkB,EAClB,IAAI,EACJ,CAAC;;;;;AACF,wBAGE"}
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
@@ -13,41 +13,32 @@ var _GitHubSodiumSealer_publicKeyBuffer;
13
13
  import libsodium from "libsodium-wrappers";
14
14
  await libsodium.ready;
15
15
  /**
16
- * @class GitHubSodiumSealer
17
- * @description Encrypt value to GitHub secret value.
16
+ * GitHub sodium sealer for encrypt value to GitHub secret value.
18
17
  */
19
- class GitHubSodiumSealer {
18
+ export class GitHubSodiumSealer {
20
19
  /**
21
- * @constructor
22
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.
23
21
  */
24
22
  constructor(publicKey) {
25
23
  _GitHubSodiumSealer_publicKeyBuffer.set(this, void 0);
26
- if (typeof publicKey !== "string") {
27
- throw new TypeError(`Argument \`publicKey\` must be type of string!`);
28
- }
29
24
  if (!(publicKey.length > 0)) {
30
- throw new Error(`Argument \`publicKey\` must be a string which is non-empty!`);
25
+ throw new SyntaxError(`Argument \`publicKey\` is not a string which is non-empty!`);
31
26
  }
32
27
  __classPrivateFieldSet(this, _GitHubSodiumSealer_publicKeyBuffer, Buffer.from(publicKey, "base64"), "f");
33
28
  }
34
29
  /**
35
- * @method encrypt
30
+ * Encrypt value to GitHub secret value.
36
31
  * @param {string} value Value that need to encrypt as secret value.
37
32
  * @returns {string} An encrypted GitHub secret value.
38
33
  */
39
34
  encrypt(value) {
40
- if (typeof value !== "string") {
41
- throw new TypeError(`Argument \`value\` must be type of string!`);
42
- }
43
35
  if (!(value.length > 0)) {
44
- throw new Error(`Argument \`value\` must be a string which is non-empty!`);
36
+ throw new SyntaxError(`Argument \`value\` is not a string which is non-empty!`);
45
37
  }
46
38
  return Buffer.from(libsodium.crypto_box_seal(Buffer.from(value), __classPrivateFieldGet(this, _GitHubSodiumSealer_publicKeyBuffer, "f"))).toString("base64");
47
39
  }
48
40
  /**
49
- * @static seal
50
- * @description Encrypt value to GitHub secret value.
41
+ * Encrypt value to GitHub secret value.
51
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.
52
43
  * @param {string} value Value that need to encrypt as secret value.
53
44
  * @returns {string} An encrypted GitHub secret value.
@@ -57,18 +48,13 @@ class GitHubSodiumSealer {
57
48
  }
58
49
  }
59
50
  _GitHubSodiumSealer_publicKeyBuffer = new WeakMap();
51
+ export default GitHubSodiumSealer;
60
52
  /**
61
- * @function seal
62
- * @description Encrypt value to GitHub secret value.
53
+ * Encrypt value to GitHub secret value.
63
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.
64
55
  * @param {string} value Value that need to encrypt as secret value.
65
56
  * @returns {string} An encrypted GitHub secret value.
66
57
  */
67
- function seal(publicKey, value) {
58
+ export function seal(publicKey, value) {
68
59
  return new GitHubSodiumSealer(publicKey).encrypt(value);
69
60
  }
70
- export { GitHubSodiumSealer, seal };
71
- export default {
72
- GitHubSodiumSealer,
73
- seal
74
- };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hugoalh/github-sodium",
3
- "version": "3.1.2",
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,19 +23,22 @@
23
23
  "url": "git+https://github.com/hugoalh-studio/github-sodium-nodejs.git"
24
24
  },
25
25
  "dependencies": {
26
- "libsodium-wrappers": "^0.7.11"
26
+ "libsodium-wrappers": "^0.7.13"
27
27
  },
28
28
  "devDependencies": {
29
- "@types/libsodium-wrappers": "^0.7.10",
30
- "@types/node": "^18.15.11",
31
- "@typescript-eslint/eslint-plugin": "^5.59.0",
32
- "@typescript-eslint/parser": "^5.59.0",
33
- "eslint": "^8.38.0",
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",
34
34
  "eslint-plugin-only-warn": "^1.1.0",
35
- "typescript": "^5.0.4"
35
+ "typescript": "^5.2.2"
36
36
  },
37
37
  "engines": {
38
38
  "node": "^12.20.0 || ^14.15.0 || >=16.13.0"
39
39
  },
40
- "private": false
40
+ "private": false,
41
+ "publishConfig": {
42
+ "access": "public"
43
+ }
41
44
  }