@hugoalh/github-sodium 1.1.4 → 2.0.0-beta.1
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/@types/github-sodium-sealer.d.mts +20 -0
- package/@types/github-sodium-sealer.d.mts.map +1 -0
- package/@types/github-sodium-sealer.d.ts +20 -0
- package/@types/github-sodium-sealer.d.ts.map +1 -0
- package/@types/main.d.mts +13 -0
- package/@types/main.d.mts.map +1 -0
- package/@types/main.d.ts +5 -9
- package/@types/main.d.ts.map +1 -0
- package/@types/seal.d.mts +9 -0
- package/@types/seal.d.mts.map +1 -0
- package/@types/seal.d.ts +9 -0
- package/@types/seal.d.ts.map +1 -0
- package/LICENSE.md +1 -1
- package/README.md +18 -11
- package/lib/github-sodium-sealer.js +31 -0
- package/lib/github-sodium-sealer.mjs +32 -0
- package/lib/main.js +9 -23
- package/lib/main.mjs +16 -23
- package/lib/seal.js +11 -0
- package/lib/seal.mjs +11 -0
- package/package.json +5 -2
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export default GitHubSodiumSealer;
|
|
2
|
+
/**
|
|
3
|
+
* @class GitHubSodiumSealer
|
|
4
|
+
* @description Encrypt value to GitHub secret value.
|
|
5
|
+
*/
|
|
6
|
+
declare class GitHubSodiumSealer {
|
|
7
|
+
/**
|
|
8
|
+
* @constructor
|
|
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
|
+
*/
|
|
11
|
+
constructor(publicKey: string);
|
|
12
|
+
/**
|
|
13
|
+
* @method
|
|
14
|
+
* @param {string} value Value that need to encrypt as secret value.
|
|
15
|
+
* @returns {string} An encrypted GitHub secret value.
|
|
16
|
+
*/
|
|
17
|
+
encrypt(value: string): string;
|
|
18
|
+
#private;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=github-sodium-sealer.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-sodium-sealer.d.mts","sourceRoot":"","sources":["../lib/github-sodium-sealer.mjs"],"names":[],"mappings":";AAGA;;;GAGG;AACH;IAEC;;;OAGG;IACH,uBAFW,MAAM,EAOhB;IACD;;;;OAIG;IACH,eAHW,MAAM,GACJ,MAAM,CAOlB;;CACD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export = GitHubSodiumSealer;
|
|
2
|
+
/**
|
|
3
|
+
* @class GitHubSodiumSealer
|
|
4
|
+
* @description Encrypt value to GitHub secret value.
|
|
5
|
+
*/
|
|
6
|
+
declare class GitHubSodiumSealer {
|
|
7
|
+
/**
|
|
8
|
+
* @constructor
|
|
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
|
+
*/
|
|
11
|
+
constructor(publicKey: string);
|
|
12
|
+
/**
|
|
13
|
+
* @method
|
|
14
|
+
* @param {string} value Value that need to encrypt as secret value.
|
|
15
|
+
* @returns {string} An encrypted GitHub secret value.
|
|
16
|
+
*/
|
|
17
|
+
encrypt(value: string): string;
|
|
18
|
+
#private;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=github-sodium-sealer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-sodium-sealer.d.ts","sourceRoot":"","sources":["../lib/github-sodium-sealer.js"],"names":[],"mappings":";AAEA;;;GAGG;AACH;IAEC;;;OAGG;IACH,uBAFW,MAAM,EAOhB;IACD;;;;OAIG;IACH,eAHW,MAAM,GACJ,MAAM,CAOlB;;CACD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare namespace _default {
|
|
2
|
+
export { GitHubSodiumSealer };
|
|
3
|
+
export { seal };
|
|
4
|
+
export { version as v };
|
|
5
|
+
export { version as ver };
|
|
6
|
+
export { version };
|
|
7
|
+
}
|
|
8
|
+
export default _default;
|
|
9
|
+
import GitHubSodiumSealer from "./github-sodium-sealer.mjs";
|
|
10
|
+
import seal from "./seal.mjs";
|
|
11
|
+
export const version: 1;
|
|
12
|
+
export { GitHubSodiumSealer, seal, version as v, version as ver };
|
|
13
|
+
//# sourceMappingURL=main.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.mts","sourceRoot":"","sources":["../lib/main.mjs"],"names":[],"mappings":";;;;;;;;;;AAEA,wBAAkB"}
|
package/@types/main.d.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* @param {string} value Value that need to encrypt as secret value.
|
|
7
|
-
* @returns {string} An encrypted GitHub secret value.
|
|
8
|
-
*/
|
|
9
|
-
declare function githubSodium(publicKey: string, value: string): string;
|
|
1
|
+
import GitHubSodiumSealer = require("./github-sodium-sealer.js");
|
|
2
|
+
import seal = require("./seal.js");
|
|
3
|
+
export const version: 1;
|
|
4
|
+
export { GitHubSodiumSealer, seal, version as v, version as ver };
|
|
5
|
+
//# sourceMappingURL=main.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../lib/main.js"],"names":[],"mappings":";;AAEA,wBAAkB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export default seal;
|
|
2
|
+
/**
|
|
3
|
+
* @function seal
|
|
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
|
+
* @param {string} value Value that need to encrypt as secret value.
|
|
6
|
+
* @returns {string} An encrypted GitHub secret value.
|
|
7
|
+
*/
|
|
8
|
+
declare function seal(publicKey: string, value: string): string;
|
|
9
|
+
//# sourceMappingURL=seal.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seal.d.mts","sourceRoot":"","sources":["../lib/seal.mjs"],"names":[],"mappings":";AACA;;;;;GAKG;AACH,iCAJW,MAAM,SACN,MAAM,GACJ,MAAM,CAIlB"}
|
package/@types/seal.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export = seal;
|
|
2
|
+
/**
|
|
3
|
+
* @function seal
|
|
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
|
+
* @param {string} value Value that need to encrypt as secret value.
|
|
6
|
+
* @returns {string} An encrypted GitHub secret value.
|
|
7
|
+
*/
|
|
8
|
+
declare function seal(publicKey: string, value: string): string;
|
|
9
|
+
//# sourceMappingURL=seal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seal.d.ts","sourceRoot":"","sources":["../lib/seal.js"],"names":[],"mappings":";AACA;;;;;GAKG;AACH,iCAJW,MAAM,SACN,MAAM,GACJ,MAAM,CAIlB"}
|
package/LICENSE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# MIT License
|
|
2
2
|
|
|
3
|
-
© 2020 hugoalh Studio
|
|
3
|
+
© 2020\~2022 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,4 +1,4 @@
|
|
|
1
|
-
# GitHub Sodium (NodeJS
|
|
1
|
+
# GitHub Sodium (NodeJS)
|
|
2
2
|
|
|
3
3
|
[`GitHubSodium.NodeJS`](https://github.com/hugoalh-studio/github-sodium-nodejs)
|
|
4
4
|
[](https://github.com/hugoalh-studio/github-sodium-nodejs/graphs/contributors)
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
|
|
23
23
|
A NodeJS module to provide an easier sodium for GitHub secret.
|
|
24
24
|
|
|
25
|
-
This project is based on TweetSodium ([GitHub](https://github.com/github/tweetsodium))([NPM](https://www.npmjs.com/package/tweetsodium)) with optimization for GitHub secret.
|
|
25
|
+
This project is based on LibSodiumJS ([GitHub](https://github.com/jedisct1/libsodium.js))([NPM](https://www.npmjs.com/package/libsodium))(for ModuleJS) and TweetSodium ([GitHub](https://github.com/github/tweetsodium))([NPM](https://www.npmjs.com/package/tweetsodium))(for CommonJS) with optimization for GitHub secret.
|
|
26
26
|
|
|
27
27
|
## 📚 Documentation
|
|
28
28
|
|
|
@@ -30,7 +30,8 @@ This project is based on TweetSodium ([GitHub](https://github.com/github/tweetso
|
|
|
30
30
|
|
|
31
31
|
#### Install
|
|
32
32
|
|
|
33
|
-
NodeJS
|
|
33
|
+
- NodeJS >= v14.15.0
|
|
34
|
+
- NPM >= v6.14.8
|
|
34
35
|
|
|
35
36
|
```sh
|
|
36
37
|
npm install @hugoalh/github-sodium
|
|
@@ -45,21 +46,27 @@ const githubSodium = require("@hugoalh/github-sodium");
|
|
|
45
46
|
#### Use In ModuleJS
|
|
46
47
|
|
|
47
48
|
```js
|
|
48
|
-
|
|
49
|
+
/* Either */
|
|
50
|
+
import * as githubSodium from "@hugoalh/github-sodium";// All
|
|
51
|
+
import githubSodium from "@hugoalh/github-sodium";// All (>= v2.0.0)
|
|
52
|
+
import { ... } from "@hugoalh/github-sodium";// Part / Tree-shake
|
|
49
53
|
```
|
|
50
54
|
|
|
51
55
|
### API
|
|
52
56
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
#### Class
|
|
58
|
+
|
|
59
|
+
- `GitHubSodiumSealer`
|
|
60
|
+
- `@constructor(publicKey)`
|
|
61
|
+
- `encrypt(value)`
|
|
62
|
+
|
|
63
|
+
#### Function
|
|
64
|
+
|
|
65
|
+
- `seal(publicKey, value)`
|
|
59
66
|
|
|
60
67
|
### Example
|
|
61
68
|
|
|
62
69
|
```js
|
|
63
|
-
|
|
70
|
+
new GitHubSodiumSealer("base64-encoded-public-key").encrypt("plain-text-secret");
|
|
64
71
|
//=> "+ZYvJDZMHUfBkJdyq5Zm9SKqeuBQ4sj+6sfjlH4CgG0="
|
|
65
72
|
```
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const advancedDetermine = require("@hugoalh/advanced-determine");
|
|
2
|
+
const tweetsodium = require("tweetsodium");
|
|
3
|
+
/**
|
|
4
|
+
* @class GitHubSodiumSealer
|
|
5
|
+
* @description Encrypt value to GitHub secret value.
|
|
6
|
+
*/
|
|
7
|
+
class GitHubSodiumSealer {
|
|
8
|
+
#publicKey;
|
|
9
|
+
/**
|
|
10
|
+
* @constructor
|
|
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.
|
|
12
|
+
*/
|
|
13
|
+
constructor(publicKey) {
|
|
14
|
+
if (!advancedDetermine.isString(publicKey, { empty: false })) {
|
|
15
|
+
throw new TypeError(`Argument \`publicKey\` must be type of string (non-empty)!`);
|
|
16
|
+
};
|
|
17
|
+
this.#publicKey = publicKey;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* @method
|
|
21
|
+
* @param {string} value Value that need to encrypt as secret value.
|
|
22
|
+
* @returns {string} An encrypted GitHub secret value.
|
|
23
|
+
*/
|
|
24
|
+
encrypt(value) {
|
|
25
|
+
if (!advancedDetermine.isString(value, { empty: false })) {
|
|
26
|
+
throw new TypeError(`Argument \`value\` must be type of string (non-empty)!`);
|
|
27
|
+
};
|
|
28
|
+
return Buffer.from(tweetsodium.seal(Buffer.from(value), Buffer.from(this.#publicKey, "base64"))).toString("base64");
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
module.exports = GitHubSodiumSealer;
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
#publicKey;
|
|
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.#publicKey = publicKey;
|
|
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), Buffer.from(this.#publicKey, "base64"))).toString("base64");
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export default GitHubSodiumSealer;
|
package/lib/main.js
CHANGED
|
@@ -1,24 +1,10 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (
|
|
11
|
-
typeof publicKey !== "string" ||
|
|
12
|
-
publicKey.length === 0
|
|
13
|
-
) {
|
|
14
|
-
throw new TypeError(`Argument \`publicKey\` must be type of string (non-nullable)!`);
|
|
15
|
-
};
|
|
16
|
-
if (
|
|
17
|
-
typeof value !== "string" ||
|
|
18
|
-
value.length === 0
|
|
19
|
-
) {
|
|
20
|
-
throw new TypeError(`Argument \`value\` must be type of string (non-nullable)!`);
|
|
21
|
-
};
|
|
22
|
-
return Buffer.from(sodium.seal(Buffer.from(value), Buffer.from(publicKey, "base64"))).toString("base64");
|
|
1
|
+
const GitHubSodiumSealer = require("./github-sodium-sealer.js");
|
|
2
|
+
const seal = require("./seal.js");
|
|
3
|
+
const version = 1;
|
|
4
|
+
module.exports = {
|
|
5
|
+
GitHubSodiumSealer,
|
|
6
|
+
seal,
|
|
7
|
+
v: version,
|
|
8
|
+
ver: version,
|
|
9
|
+
version
|
|
23
10
|
};
|
|
24
|
-
module.exports = githubSodium;
|
package/lib/main.mjs
CHANGED
|
@@ -1,24 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
typeof value !== "string" ||
|
|
18
|
-
value.length === 0
|
|
19
|
-
) {
|
|
20
|
-
throw new TypeError(`Argument \`value\` must be type of string (non-nullable)!`);
|
|
21
|
-
};
|
|
22
|
-
return Buffer.from(sodium.seal(Buffer.from(value), Buffer.from(publicKey, "base64"))).toString("base64");
|
|
1
|
+
import GitHubSodiumSealer from "./github-sodium-sealer.mjs";
|
|
2
|
+
import seal from "./seal.mjs";
|
|
3
|
+
const version = 1;
|
|
4
|
+
export {
|
|
5
|
+
GitHubSodiumSealer,
|
|
6
|
+
seal,
|
|
7
|
+
version as v,
|
|
8
|
+
version as ver,
|
|
9
|
+
version
|
|
10
|
+
};
|
|
11
|
+
export default {
|
|
12
|
+
GitHubSodiumSealer,
|
|
13
|
+
seal,
|
|
14
|
+
v: version,
|
|
15
|
+
ver: version,
|
|
16
|
+
version
|
|
23
17
|
};
|
|
24
|
-
export default githubSodium;
|
package/lib/seal.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const GitHubSodiumSealer = require("./github-sodium-sealer.js");
|
|
2
|
+
/**
|
|
3
|
+
* @function seal
|
|
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
|
+
* @param {string} value Value that need to encrypt as secret value.
|
|
6
|
+
* @returns {string} An encrypted GitHub secret value.
|
|
7
|
+
*/
|
|
8
|
+
function seal(publicKey, value) {
|
|
9
|
+
return new GitHubSodiumSealer(publicKey).encrypt(value);
|
|
10
|
+
};
|
|
11
|
+
module.exports = seal;
|
package/lib/seal.mjs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import GitHubSodiumSealer from "./github-sodium-sealer.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* @function seal
|
|
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
|
+
* @param {string} value Value that need to encrypt as secret value.
|
|
6
|
+
* @returns {string} An encrypted GitHub secret value.
|
|
7
|
+
*/
|
|
8
|
+
function seal(publicKey, value) {
|
|
9
|
+
return new GitHubSodiumSealer(publicKey).encrypt(value);
|
|
10
|
+
};
|
|
11
|
+
export default seal;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hugoalh/github-sodium",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-beta.1",
|
|
4
4
|
"description": "A module to provide an easier sodium for GitHub secret.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"github",
|
|
@@ -24,7 +24,10 @@
|
|
|
24
24
|
"url": "git+https://github.com/hugoalh-studio/github-sodium-nodejs.git"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"
|
|
27
|
+
"@hugoalh/advanced-determine": "^7.0.2",
|
|
28
|
+
"@types/libsodium-wrappers": "^0.7.9",
|
|
29
|
+
"libsodium-wrappers": "^0.7.10",
|
|
30
|
+
"tweetsodium": "^0.0.6"
|
|
28
31
|
},
|
|
29
32
|
"engines": {
|
|
30
33
|
"node": ">= 14.15.0",
|