@hugoalh/github-sodium 3.1.2 → 5.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/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MIT License
2
2
 
3
- Copyright © 2020\~2023 hugoalh Studio
3
+ Copyright © 2020\~2024 hugoalh Studio
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
6
 
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")) |
6
+ | | **Release - Latest** | **Release - Pre** |
13
7
  |:-:|:-:|:-:|
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
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") |
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:** >= 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
@@ -1,53 +1,32 @@
1
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
- if (kind === "m") throw new TypeError("Private method is not writable");
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
- };
7
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
- };
12
- var _GitHubSodiumSealer_publicKeyBuffer;
13
1
  import libsodium from "libsodium-wrappers";
14
2
  await libsodium.ready;
15
3
  /**
16
- * @class GitHubSodiumSealer
17
- * @description Encrypt value to GitHub secret value.
4
+ * GitHub sodium sealer for encrypt value to GitHub secret value.
18
5
  */
19
- class GitHubSodiumSealer {
6
+ export class GitHubSodiumSealer {
7
+ #publicKeyBuffer;
20
8
  /**
21
- * @constructor
22
9
  * @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
10
  */
24
11
  constructor(publicKey) {
25
- _GitHubSodiumSealer_publicKeyBuffer.set(this, void 0);
26
- if (typeof publicKey !== "string") {
27
- throw new TypeError(`Argument \`publicKey\` must be type of string!`);
28
- }
29
12
  if (!(publicKey.length > 0)) {
30
- throw new Error(`Argument \`publicKey\` must be a string which is non-empty!`);
13
+ throw new SyntaxError(`Argument \`publicKey\` is not a string which is non-empty!`);
31
14
  }
32
- __classPrivateFieldSet(this, _GitHubSodiumSealer_publicKeyBuffer, Buffer.from(publicKey, "base64"), "f");
15
+ this.#publicKeyBuffer = Buffer.from(publicKey, "base64");
33
16
  }
34
17
  /**
35
- * @method encrypt
18
+ * Encrypt value to GitHub secret value.
36
19
  * @param {string} value Value that need to encrypt as secret value.
37
20
  * @returns {string} An encrypted GitHub secret value.
38
21
  */
39
22
  encrypt(value) {
40
- if (typeof value !== "string") {
41
- throw new TypeError(`Argument \`value\` must be type of string!`);
42
- }
43
23
  if (!(value.length > 0)) {
44
- throw new Error(`Argument \`value\` must be a string which is non-empty!`);
24
+ throw new SyntaxError(`Argument \`value\` is not a string which is non-empty!`);
45
25
  }
46
- return Buffer.from(libsodium.crypto_box_seal(Buffer.from(value), __classPrivateFieldGet(this, _GitHubSodiumSealer_publicKeyBuffer, "f"))).toString("base64");
26
+ return Buffer.from(libsodium.crypto_box_seal(Buffer.from(value), this.#publicKeyBuffer)).toString("base64");
47
27
  }
48
28
  /**
49
- * @static seal
50
- * @description Encrypt value to GitHub secret value.
29
+ * Encrypt value to GitHub secret value.
51
30
  * @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
31
  * @param {string} value Value that need to encrypt as secret value.
53
32
  * @returns {string} An encrypted GitHub secret value.
@@ -56,19 +35,13 @@ class GitHubSodiumSealer {
56
35
  return new this(publicKey).encrypt(value);
57
36
  }
58
37
  }
59
- _GitHubSodiumSealer_publicKeyBuffer = new WeakMap();
38
+ export default GitHubSodiumSealer;
60
39
  /**
61
- * @function seal
62
- * @description Encrypt value to GitHub secret value.
40
+ * Encrypt value to GitHub secret value.
63
41
  * @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
42
  * @param {string} value Value that need to encrypt as secret value.
65
43
  * @returns {string} An encrypted GitHub secret value.
66
44
  */
67
- function seal(publicKey, value) {
45
+ export function seal(publicKey, value) {
68
46
  return new GitHubSodiumSealer(publicKey).encrypt(value);
69
47
  }
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": "5.0.0",
4
4
  "description": "A module to provide an easier sodium for GitHub secrets.",
5
5
  "keywords": [
6
6
  "github",
@@ -23,19 +23,23 @@
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
+ "@stylistic/eslint-plugin": "^1.5.3",
30
+ "@types/libsodium-wrappers": "^0.7.13",
31
+ "@types/node": "^20.11.0",
32
+ "@typescript-eslint/eslint-plugin": "^6.18.1",
33
+ "@typescript-eslint/parser": "^6.18.1",
34
+ "eslint": "^8.56.0",
34
35
  "eslint-plugin-only-warn": "^1.1.0",
35
- "typescript": "^5.0.4"
36
+ "typescript": "^5.3.3"
36
37
  },
37
38
  "engines": {
38
- "node": "^12.20.0 || ^14.15.0 || >=16.13.0"
39
+ "node": ">=16.13.0"
39
40
  },
40
- "private": false
41
+ "private": false,
42
+ "publishConfig": {
43
+ "access": "public"
44
+ }
41
45
  }