@hugoalh/github-sodium 3.0.1 → 3.1.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 +1 -1
- package/README.md +6 -16
- package/{lib → dist}/github-sodium-sealer.d.ts +11 -3
- package/dist/github-sodium-sealer.d.ts.map +1 -0
- package/dist/github-sodium-sealer.js +56 -0
- package/{lib → dist}/main.d.ts +5 -5
- package/dist/main.d.ts.map +1 -0
- package/{lib → dist}/main.js +3 -6
- package/{lib → dist}/seal.d.ts +2 -1
- package/dist/seal.d.ts.map +1 -0
- package/{lib → dist}/seal.js +2 -1
- package/package.json +12 -10
- package/lib/github-sodium-sealer.d.ts.map +0 -1
- package/lib/github-sodium-sealer.js +0 -32
- package/lib/main.d.ts.map +0 -1
- package/lib/seal.d.ts.map +0 -1
package/LICENSE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# MIT License
|
|
2
2
|
|
|
3
|
-
Copyright © 2020\~
|
|
3
|
+
Copyright © 2020\~2023 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
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
[`GitHubSodium.NodeJS`](https://github.com/hugoalh-studio/github-sodium-nodejs)
|
|
4
4
|
|
|
5
|
-

|
|
6
5
|

|
|
7
6
|
[](https://github.com/hugoalh-studio/github-sodium-nodejs/stargazers)
|
|
8
7
|
[](https://github.com/hugoalh-studio/github-sodium-nodejs/graphs/contributors)
|
|
@@ -38,9 +37,9 @@ npm install @hugoalh/github-sodium
|
|
|
38
37
|
|
|
39
38
|
```js
|
|
40
39
|
/* Either */
|
|
41
|
-
import
|
|
42
|
-
import githubSodium from "@hugoalh/github-sodium";//
|
|
43
|
-
import
|
|
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
|
|
44
43
|
```
|
|
45
44
|
|
|
46
45
|
### API
|
|
@@ -48,24 +47,15 @@ import { ... } from "@hugoalh/github-sodium";// Part / Tree-shake
|
|
|
48
47
|
#### Class
|
|
49
48
|
|
|
50
49
|
<ul>
|
|
51
|
-
<li><code>GitHubSodiumSealer</code></li>
|
|
52
|
-
<ul>
|
|
53
|
-
<li>
|
|
54
|
-
|
|
55
|
-
```ts
|
|
56
|
-
@constructor(publicKey: string): GitHubSodiumSealer
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
</li>
|
|
60
50
|
<li>
|
|
61
51
|
|
|
62
52
|
```ts
|
|
63
|
-
|
|
53
|
+
new GitHubSodiumSealer(publicKey: string): GitHubSodiumSealer;
|
|
54
|
+
.encrypt(value: string): string;
|
|
64
55
|
```
|
|
65
56
|
|
|
66
57
|
</li>
|
|
67
58
|
</ul>
|
|
68
|
-
</ul>
|
|
69
59
|
|
|
70
60
|
#### Function
|
|
71
61
|
|
|
@@ -73,7 +63,7 @@ encrypt(value: string): string
|
|
|
73
63
|
<li>
|
|
74
64
|
|
|
75
65
|
```ts
|
|
76
|
-
seal(publicKey: string, value: string): string
|
|
66
|
+
seal(publicKey: string, value: string): string;
|
|
77
67
|
```
|
|
78
68
|
|
|
79
69
|
</li>
|
|
@@ -1,20 +1,28 @@
|
|
|
1
|
-
export default GitHubSodiumSealer;
|
|
2
1
|
/**
|
|
3
2
|
* @class GitHubSodiumSealer
|
|
4
3
|
* @description Encrypt value to GitHub secret value.
|
|
5
4
|
*/
|
|
6
5
|
declare class GitHubSodiumSealer {
|
|
6
|
+
#private;
|
|
7
7
|
/**
|
|
8
8
|
* @constructor
|
|
9
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.
|
|
10
10
|
*/
|
|
11
11
|
constructor(publicKey: string);
|
|
12
12
|
/**
|
|
13
|
-
* @method
|
|
13
|
+
* @method encrypt
|
|
14
14
|
* @param {string} value Value that need to encrypt as secret value.
|
|
15
15
|
* @returns {string} An encrypted GitHub secret value.
|
|
16
16
|
*/
|
|
17
17
|
encrypt(value: string): string;
|
|
18
|
-
|
|
18
|
+
/**
|
|
19
|
+
* @static seal
|
|
20
|
+
* @description Encrypt value to GitHub secret value.
|
|
21
|
+
* @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
|
+
* @param {string} value Value that need to encrypt as secret value.
|
|
23
|
+
* @returns {string} An encrypted GitHub secret value.
|
|
24
|
+
*/
|
|
25
|
+
static seal(publicKey: string, value: string): string;
|
|
19
26
|
}
|
|
27
|
+
export default GitHubSodiumSealer;
|
|
20
28
|
//# sourceMappingURL=github-sodium-sealer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-sodium-sealer.d.ts","sourceRoot":"","sources":["../src/github-sodium-sealer.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,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
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_publicKeyStorage;
|
|
13
|
+
import { StringItemFilter } from "@hugoalh/advanced-determine";
|
|
14
|
+
import libsodium from "libsodium-wrappers";
|
|
15
|
+
await libsodium.ready;
|
|
16
|
+
const stringFilter = new StringItemFilter();
|
|
17
|
+
/**
|
|
18
|
+
* @class GitHubSodiumSealer
|
|
19
|
+
* @description Encrypt value to GitHub secret value.
|
|
20
|
+
*/
|
|
21
|
+
class GitHubSodiumSealer {
|
|
22
|
+
/**
|
|
23
|
+
* @constructor
|
|
24
|
+
* @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
|
+
*/
|
|
26
|
+
constructor(publicKey) {
|
|
27
|
+
_GitHubSodiumSealer_publicKeyStorage.set(this, void 0);
|
|
28
|
+
if (!stringFilter.test(publicKey)) {
|
|
29
|
+
throw new TypeError(`Argument \`publicKey\` must be type of string (non-empty)!`);
|
|
30
|
+
}
|
|
31
|
+
__classPrivateFieldSet(this, _GitHubSodiumSealer_publicKeyStorage, Buffer.from(publicKey, "base64"), "f");
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @method encrypt
|
|
35
|
+
* @param {string} value Value that need to encrypt as secret value.
|
|
36
|
+
* @returns {string} An encrypted GitHub secret value.
|
|
37
|
+
*/
|
|
38
|
+
encrypt(value) {
|
|
39
|
+
if (!stringFilter.test(value)) {
|
|
40
|
+
throw new TypeError(`Argument \`value\` must be type of string (non-empty)!`);
|
|
41
|
+
}
|
|
42
|
+
return Buffer.from(libsodium.crypto_box_seal(Buffer.from(value), __classPrivateFieldGet(this, _GitHubSodiumSealer_publicKeyStorage, "f"))).toString("base64");
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* @static seal
|
|
46
|
+
* @description Encrypt value to GitHub secret value.
|
|
47
|
+
* @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
|
+
* @param {string} value Value that need to encrypt as secret value.
|
|
49
|
+
* @returns {string} An encrypted GitHub secret value.
|
|
50
|
+
*/
|
|
51
|
+
static seal(publicKey, value) {
|
|
52
|
+
return new this(publicKey).encrypt(value);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
_GitHubSodiumSealer_publicKeyStorage = new WeakMap();
|
|
56
|
+
export default GitHubSodiumSealer;
|
package/{lib → dist}/main.d.ts
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
declare namespace _default {
|
|
2
|
-
export { GitHubSodiumSealer };
|
|
3
|
-
export { seal };
|
|
4
|
-
}
|
|
5
|
-
export default _default;
|
|
6
1
|
import GitHubSodiumSealer from "./github-sodium-sealer.js";
|
|
7
2
|
import seal from "./seal.js";
|
|
8
3
|
export { GitHubSodiumSealer, seal };
|
|
4
|
+
declare const _default: {
|
|
5
|
+
GitHubSodiumSealer: typeof GitHubSodiumSealer;
|
|
6
|
+
seal: typeof seal;
|
|
7
|
+
};
|
|
8
|
+
export default _default;
|
|
9
9
|
//# sourceMappingURL=main.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,MAAM,2BAA2B,CAAC;AAC3D,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACN,kBAAkB,EAClB,IAAI,EACJ,CAAC;;;;;AACF,wBAGE"}
|
package/{lib → dist}/main.js
RENAMED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import GitHubSodiumSealer from "./github-sodium-sealer.js";
|
|
2
2
|
import seal from "./seal.js";
|
|
3
|
-
export {
|
|
4
|
-
GitHubSodiumSealer,
|
|
5
|
-
seal
|
|
6
|
-
};
|
|
3
|
+
export { GitHubSodiumSealer, seal };
|
|
7
4
|
export default {
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
GitHubSodiumSealer,
|
|
6
|
+
seal
|
|
10
7
|
};
|
package/{lib → dist}/seal.d.ts
RENAMED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export default seal;
|
|
2
1
|
/**
|
|
3
2
|
* @function seal
|
|
3
|
+
* @description Encrypt value to GitHub secret value.
|
|
4
4
|
* @param {string} publicKey Organization's or repository's public key, which need for encrypt value to secret value before create or update a secret.
|
|
5
5
|
* @param {string} value Value that need to encrypt as secret value.
|
|
6
6
|
* @returns {string} An encrypted GitHub secret value.
|
|
7
7
|
*/
|
|
8
8
|
declare function seal(publicKey: string, value: string): string;
|
|
9
|
+
export default seal;
|
|
9
10
|
//# sourceMappingURL=seal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seal.d.ts","sourceRoot":"","sources":["../src/seal.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AACH,iBAAS,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAEtD;AACD,eAAe,IAAI,CAAC"}
|
package/{lib → dist}/seal.js
RENAMED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import GitHubSodiumSealer from "./github-sodium-sealer.js";
|
|
2
2
|
/**
|
|
3
3
|
* @function seal
|
|
4
|
+
* @description Encrypt value to GitHub secret value.
|
|
4
5
|
* @param {string} publicKey Organization's or repository's public key, which need for encrypt value to secret value before create or update a secret.
|
|
5
6
|
* @param {string} value Value that need to encrypt as secret value.
|
|
6
7
|
* @returns {string} An encrypted GitHub secret value.
|
|
7
8
|
*/
|
|
8
9
|
function seal(publicKey, value) {
|
|
9
|
-
|
|
10
|
+
return new GitHubSodiumSealer(publicKey).encrypt(value);
|
|
10
11
|
}
|
|
11
12
|
export default seal;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hugoalh/github-sodium",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "A module to provide an easier sodium for GitHub secrets.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"github",
|
|
@@ -13,25 +13,27 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"author": "hugoalh",
|
|
15
15
|
"type": "module",
|
|
16
|
-
"main": "./
|
|
16
|
+
"main": "./dist/main.js",
|
|
17
17
|
"exports": {
|
|
18
|
-
"import": "./
|
|
18
|
+
"import": "./dist/main.js"
|
|
19
19
|
},
|
|
20
|
-
"types": "./
|
|
20
|
+
"types": "./dist/main.d.ts",
|
|
21
21
|
"repository": {
|
|
22
22
|
"type": "git",
|
|
23
23
|
"url": "git+https://github.com/hugoalh-studio/github-sodium-nodejs.git"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@hugoalh/advanced-determine": "^
|
|
27
|
-
"libsodium-wrappers": "^0.7.
|
|
26
|
+
"@hugoalh/advanced-determine": "^10.2.1",
|
|
27
|
+
"libsodium-wrappers": "^0.7.11"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/libsodium-wrappers": "^0.7.10",
|
|
31
|
-
"@types/node": "^18.
|
|
32
|
-
"eslint": "^
|
|
33
|
-
"eslint
|
|
34
|
-
"
|
|
31
|
+
"@types/node": "^18.15.0",
|
|
32
|
+
"@typescript-eslint/eslint-plugin": "^5.54.1",
|
|
33
|
+
"@typescript-eslint/parser": "^5.54.1",
|
|
34
|
+
"eslint": "^8.36.0",
|
|
35
|
+
"eslint-plugin-only-warn": "^1.1.0",
|
|
36
|
+
"typescript": "^4.9.5"
|
|
35
37
|
},
|
|
36
38
|
"engines": {
|
|
37
39
|
"node": "^12.20.0 || ^14.15.0 || >=16.13.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"github-sodium-sealer.d.ts","sourceRoot":"","sources":["github-sodium-sealer.js"],"names":[],"mappings":";AAGA;;;GAGG;AACH;IAEC;;;OAGG;IACH,uBAFW,MAAM,EAOhB;IACD;;;;OAIG;IACH,eAHW,MAAM,GACJ,MAAM,CAOlB;;CACD"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { isString as adIsString } from "@hugoalh/advanced-determine";
|
|
2
|
-
import libsodium from "libsodium-wrappers";
|
|
3
|
-
await libsodium.ready;
|
|
4
|
-
/**
|
|
5
|
-
* @class GitHubSodiumSealer
|
|
6
|
-
* @description Encrypt value to GitHub secret value.
|
|
7
|
-
*/
|
|
8
|
-
class GitHubSodiumSealer {
|
|
9
|
-
#publicKeyStorage;
|
|
10
|
-
/**
|
|
11
|
-
* @constructor
|
|
12
|
-
* @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
|
-
*/
|
|
14
|
-
constructor(publicKey) {
|
|
15
|
-
if (!adIsString(publicKey, { empty: false })) {
|
|
16
|
-
throw new TypeError(`Argument \`publicKey\` must be type of string (non-empty)!`);
|
|
17
|
-
}
|
|
18
|
-
this.#publicKeyStorage = Buffer.from(publicKey, "base64");
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* @method
|
|
22
|
-
* @param {string} value Value that need to encrypt as secret value.
|
|
23
|
-
* @returns {string} An encrypted GitHub secret value.
|
|
24
|
-
*/
|
|
25
|
-
encrypt(value) {
|
|
26
|
-
if (!adIsString(value, { empty: false })) {
|
|
27
|
-
throw new TypeError(`Argument \`value\` must be type of string (non-empty)!`);
|
|
28
|
-
}
|
|
29
|
-
return Buffer.from(libsodium.crypto_box_seal(Buffer.from(value), this.#publicKeyStorage)).toString("base64");
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
export default GitHubSodiumSealer;
|
package/lib/main.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["main.js"],"names":[],"mappings":""}
|
package/lib/seal.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"seal.d.ts","sourceRoot":"","sources":["seal.js"],"names":[],"mappings":";AACA;;;;;GAKG;AACH,iCAJW,MAAM,SACN,MAAM,GACJ,MAAM,CAIlB"}
|