@aloma.io/integration-sdk 3.0.1-6 → 3.0.1-7
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/build/cli.mjs +17 -1
- package/package.json +1 -1
- package/src/cli.mts +24 -1
package/build/cli.mjs
CHANGED
@@ -3,10 +3,13 @@ import { Command } from "commander";
|
|
3
3
|
import fs from "node:fs";
|
4
4
|
import { fileURLToPath } from "node:url";
|
5
5
|
import path from "node:path";
|
6
|
+
import JWE from './internal/util/jwe/index.cjs';
|
7
|
+
console.log(JWE);
|
6
8
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
7
9
|
const files = [
|
8
10
|
{ name: "index.mts", dir: "src/controller" },
|
9
11
|
{ name: "index.mts", dir: "src" },
|
12
|
+
{ name: ".gitignore", dir: "" },
|
10
13
|
{ name: "package.json", dir: "" },
|
11
14
|
{ name: "Containerfile", dir: "" },
|
12
15
|
{ name: "entrypoint.sh", dir: "" },
|
@@ -31,6 +34,18 @@ const extract = ({ target, name, connectorId }) => {
|
|
31
34
|
content.connectorId = connectorId;
|
32
35
|
fs.writeFileSync(`${target}/package.json`, JSON.stringify(content, null, 2));
|
33
36
|
};
|
37
|
+
const generateKeys = async ({ target }) => {
|
38
|
+
const jwe = new JWE({});
|
39
|
+
await jwe.newPair();
|
40
|
+
const priv = await jwe.exportPrivateAsBase64();
|
41
|
+
const pub = await jwe.exportPublicAsBase64();
|
42
|
+
const content = `REGISTRATION_KEY=
|
43
|
+
PRIVATE_KEY=${priv}
|
44
|
+
PUBLIC_KEY=${pub}
|
45
|
+
`;
|
46
|
+
console.log(content);
|
47
|
+
fs.writeFileSync(`${target}/.env`, content);
|
48
|
+
};
|
34
49
|
const program = new Command();
|
35
50
|
program
|
36
51
|
.name("npx @aloma.io/integration-sdk")
|
@@ -42,12 +57,13 @@ program
|
|
42
57
|
.description("Create a new connector project")
|
43
58
|
.argument("<name>", "name of the project")
|
44
59
|
.requiredOption("--connector-id <id>", "id of the connector")
|
45
|
-
.action((name, options) => {
|
60
|
+
.action(async (name, options) => {
|
46
61
|
name = name.replace(/[\/\.]/gi, "");
|
47
62
|
if (!name)
|
48
63
|
throw new Error("name is empty");
|
49
64
|
const target = `${process.cwd()}/${name}`;
|
50
65
|
fs.mkdirSync(target);
|
51
66
|
extract({ ...options, target, name });
|
67
|
+
await generateKeys({ target });
|
52
68
|
});
|
53
69
|
program.parse();
|
package/package.json
CHANGED
package/src/cli.mts
CHANGED
@@ -4,12 +4,16 @@ import { Command } from "commander";
|
|
4
4
|
import fs from "node:fs";
|
5
5
|
import { fileURLToPath } from "node:url";
|
6
6
|
import path from "node:path";
|
7
|
+
import JWE from './internal/util/jwe/index.cjs'
|
8
|
+
|
9
|
+
console.log(JWE)
|
7
10
|
|
8
11
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
9
12
|
|
10
13
|
const files = [
|
11
14
|
{ name: "index.mts", dir: "src/controller" },
|
12
15
|
{ name: "index.mts", dir: "src" },
|
16
|
+
{ name: ".gitignore", dir: "" },
|
13
17
|
{ name: "package.json", dir: "" },
|
14
18
|
{ name: "Containerfile", dir: "" },
|
15
19
|
{ name: "entrypoint.sh", dir: "" },
|
@@ -44,6 +48,24 @@ const extract = ({ target, name, connectorId }) => {
|
|
44
48
|
fs.writeFileSync(`${target}/package.json`, JSON.stringify(content, null, 2));
|
45
49
|
};
|
46
50
|
|
51
|
+
const generateKeys = async ({target}) =>
|
52
|
+
{
|
53
|
+
const jwe = new JWE({});
|
54
|
+
await jwe.newPair();
|
55
|
+
|
56
|
+
const priv = await jwe.exportPrivateAsBase64();
|
57
|
+
const pub = await jwe.exportPublicAsBase64();
|
58
|
+
|
59
|
+
const content = `REGISTRATION_KEY=
|
60
|
+
PRIVATE_KEY=${priv}
|
61
|
+
PUBLIC_KEY=${pub}
|
62
|
+
`;
|
63
|
+
|
64
|
+
console.log(content);
|
65
|
+
|
66
|
+
fs.writeFileSync(`${target}/.env`, content);
|
67
|
+
};
|
68
|
+
|
47
69
|
const program = new Command();
|
48
70
|
|
49
71
|
program
|
@@ -57,7 +79,7 @@ program
|
|
57
79
|
.description("Create a new connector project")
|
58
80
|
.argument("<name>", "name of the project")
|
59
81
|
.requiredOption("--connector-id <id>", "id of the connector")
|
60
|
-
.action((name, options) => {
|
82
|
+
.action(async (name, options) => {
|
61
83
|
name = name.replace(/[\/\.]/gi, "");
|
62
84
|
if (!name) throw new Error("name is empty");
|
63
85
|
|
@@ -66,6 +88,7 @@ program
|
|
66
88
|
fs.mkdirSync(target);
|
67
89
|
|
68
90
|
extract({ ...options, target, name });
|
91
|
+
await generateKeys({target});
|
69
92
|
});
|
70
93
|
|
71
94
|
program.parse();
|