@hugoalh/github-sodium 3.1.1 → 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,65 +1,73 @@
1
1
  # GitHub Sodium (NodeJS)
2
2
 
3
- [`GitHubSodium.NodeJS`](https://github.com/hugoalh-studio/github-sodium-nodejs)
4
-
5
- ![License](https://img.shields.io/static/v1?label=License&message=MIT&style=flat-square "License")
6
- [![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)
7
- [![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)
8
- [![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)
9
- [![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)
10
- [![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)
11
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)
12
5
 
13
- | **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")) |
14
- |:-:|:-:|:-:|
15
- | [![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") |
16
- | [![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") |
17
-
18
- ## 📝 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") |
19
10
 
20
11
  A NodeJS module to provide an easier sodium for GitHub secrets.
21
12
 
22
- 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.
23
14
 
24
- ## 📚 Documentation
15
+ ## 🔰 Begin
25
16
 
26
- ### Getting Started
17
+ ### Bun
27
18
 
28
- #### Install
19
+ > **🧪 Experimental:** Bun is still under development.
29
20
 
30
- - NodeJS ^ v12.20.0 || ^ v14.15.0 || >= v16.13.0
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
+ ```
31
32
 
32
- ```sh
33
- npm install @hugoalh/github-sodium
34
- ```
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.
35
34
 
36
- #### Use
35
+ ### NodeJS
37
36
 
38
- ```js
39
- /* Either */
40
- import { ... } from "@hugoalh/github-sodium";// Named Import
41
- import * as githubSodium from "@hugoalh/github-sodium";// Namespace Import
42
- import githubSodium from "@hugoalh/github-sodium";// Default Import
43
- ```
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
+ ```
44
48
 
45
- ### API
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.
46
50
 
47
- #### Class
51
+ ## 🧩 API
48
52
 
49
53
  - ```ts
50
- new GitHubSodiumSealer(publicKey: string): GitHubSodiumSealer;
51
- .encrypt(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
+ }
52
59
  ```
53
-
54
- #### Function
55
-
56
60
  - ```ts
57
- seal(publicKey: string, value: string): string;
61
+ function seal(publicKey: string, value: string): string;
58
62
  ```
59
63
 
60
- ### Example
64
+ > **ℹ️ Notice:** Documentation is included inside the script file.
61
65
 
62
- ```js
63
- new GitHubSodiumSealer("base64-encoded-public-key").encrypt("plain-text-secret");
64
- //=> "+ZYvJDZMHUfBkJdyq5Zm9SKqeuBQ4sj+6sfjlH4CgG0="
65
- ```
66
+ ## ✍️ Example
67
+
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":"AAIA;;;GAGG;AACH,cAAM,kBAAkB;;IAEvB;;;OAGG;gBACS,SAAS,EAAE,MAAM;IAM7B;;;;OAIG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAM9B;;;;;;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
@@ -10,40 +10,35 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
12
  var _GitHubSodiumSealer_publicKeyBuffer;
13
- import { StringItemFilter } from "@hugoalh/advanced-determine";
14
13
  import libsodium from "libsodium-wrappers";
15
14
  await libsodium.ready;
16
- const stringFilter = new StringItemFilter();
17
15
  /**
18
- * @class GitHubSodiumSealer
19
- * @description Encrypt value to GitHub secret value.
16
+ * GitHub sodium sealer for encrypt value to GitHub secret value.
20
17
  */
21
- class GitHubSodiumSealer {
18
+ export class GitHubSodiumSealer {
22
19
  /**
23
- * @constructor
24
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.
25
21
  */
26
22
  constructor(publicKey) {
27
23
  _GitHubSodiumSealer_publicKeyBuffer.set(this, void 0);
28
- if (!stringFilter.test(publicKey)) {
29
- throw new TypeError(`Argument \`publicKey\` must be type of string (non-empty)!`);
24
+ if (!(publicKey.length > 0)) {
25
+ throw new SyntaxError(`Argument \`publicKey\` is not a string which is non-empty!`);
30
26
  }
31
27
  __classPrivateFieldSet(this, _GitHubSodiumSealer_publicKeyBuffer, Buffer.from(publicKey, "base64"), "f");
32
28
  }
33
29
  /**
34
- * @method encrypt
30
+ * Encrypt value to GitHub secret value.
35
31
  * @param {string} value Value that need to encrypt as secret value.
36
32
  * @returns {string} An encrypted GitHub secret value.
37
33
  */
38
34
  encrypt(value) {
39
- if (!stringFilter.test(value)) {
40
- throw new TypeError(`Argument \`value\` must be type of string (non-empty)!`);
35
+ if (!(value.length > 0)) {
36
+ throw new SyntaxError(`Argument \`value\` is not a string which is non-empty!`);
41
37
  }
42
38
  return Buffer.from(libsodium.crypto_box_seal(Buffer.from(value), __classPrivateFieldGet(this, _GitHubSodiumSealer_publicKeyBuffer, "f"))).toString("base64");
43
39
  }
44
40
  /**
45
- * @static seal
46
- * @description Encrypt value to GitHub secret value.
41
+ * Encrypt value to GitHub secret value.
47
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.
48
43
  * @param {string} value Value that need to encrypt as secret value.
49
44
  * @returns {string} An encrypted GitHub secret value.
@@ -53,18 +48,13 @@ class GitHubSodiumSealer {
53
48
  }
54
49
  }
55
50
  _GitHubSodiumSealer_publicKeyBuffer = new WeakMap();
51
+ export default GitHubSodiumSealer;
56
52
  /**
57
- * @function seal
58
- * @description Encrypt value to GitHub secret value.
53
+ * Encrypt value to GitHub secret value.
59
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.
60
55
  * @param {string} value Value that need to encrypt as secret value.
61
56
  * @returns {string} An encrypted GitHub secret value.
62
57
  */
63
- function seal(publicKey, value) {
58
+ export function seal(publicKey, value) {
64
59
  return new GitHubSodiumSealer(publicKey).encrypt(value);
65
60
  }
66
- export { GitHubSodiumSealer, seal };
67
- export default {
68
- GitHubSodiumSealer,
69
- seal
70
- };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hugoalh/github-sodium",
3
- "version": "3.1.1",
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,20 +23,22 @@
23
23
  "url": "git+https://github.com/hugoalh-studio/github-sodium-nodejs.git"
24
24
  },
25
25
  "dependencies": {
26
- "@hugoalh/advanced-determine": "^10.3.0",
27
- "libsodium-wrappers": "^0.7.11"
26
+ "libsodium-wrappers": "^0.7.13"
28
27
  },
29
28
  "devDependencies": {
30
- "@types/libsodium-wrappers": "^0.7.10",
31
- "@types/node": "^18.15.11",
32
- "@typescript-eslint/eslint-plugin": "^5.57.1",
33
- "@typescript-eslint/parser": "^5.57.1",
34
- "eslint": "^8.37.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",
35
34
  "eslint-plugin-only-warn": "^1.1.0",
36
- "typescript": "^5.0.3"
35
+ "typescript": "^5.2.2"
37
36
  },
38
37
  "engines": {
39
38
  "node": "^12.20.0 || ^14.15.0 || >=16.13.0"
40
39
  },
41
- "private": false
40
+ "private": false,
41
+ "publishConfig": {
42
+ "access": "public"
43
+ }
42
44
  }