@aloma.io/integration-sdk 3.0.1-6 → 3.0.1-8

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 CHANGED
@@ -3,6 +3,8 @@ 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" },
@@ -30,6 +32,22 @@ const extract = ({ target, name, connectorId }) => {
30
32
  content.name = name;
31
33
  content.connectorId = connectorId;
32
34
  fs.writeFileSync(`${target}/package.json`, JSON.stringify(content, null, 2));
35
+ fs.writeFileSync(`${target}/.gitignore`, `.DS_Store
36
+ node_modules
37
+ build
38
+ .env`);
39
+ };
40
+ const generateKeys = async ({ target }) => {
41
+ const jwe = new JWE({});
42
+ await jwe.newPair();
43
+ const priv = await jwe.exportPrivateAsBase64();
44
+ const pub = await jwe.exportPublicAsBase64();
45
+ const content = `REGISTRATION_KEY=
46
+ PRIVATE_KEY=${priv}
47
+ PUBLIC_KEY=${pub}
48
+ `;
49
+ console.log(content);
50
+ fs.writeFileSync(`${target}/.env`, content);
33
51
  };
34
52
  const program = new Command();
35
53
  program
@@ -42,12 +60,13 @@ program
42
60
  .description("Create a new connector project")
43
61
  .argument("<name>", "name of the project")
44
62
  .requiredOption("--connector-id <id>", "id of the connector")
45
- .action((name, options) => {
63
+ .action(async (name, options) => {
46
64
  name = name.replace(/[\/\.]/gi, "");
47
65
  if (!name)
48
66
  throw new Error("name is empty");
49
67
  const target = `${process.cwd()}/${name}`;
50
68
  fs.mkdirSync(target);
51
69
  extract({ ...options, target, name });
70
+ await generateKeys({ target });
52
71
  });
53
72
  program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aloma.io/integration-sdk",
3
- "version": "3.0.1-6",
3
+ "version": "3.0.1-8",
4
4
  "description": "",
5
5
  "author": "aloma.io",
6
6
  "license": "Apache-2.0",
package/src/cli.mts CHANGED
@@ -4,6 +4,9 @@ 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
 
@@ -42,6 +45,28 @@ const extract = ({ target, name, connectorId }) => {
42
45
  content.connectorId = connectorId;
43
46
 
44
47
  fs.writeFileSync(`${target}/package.json`, JSON.stringify(content, null, 2));
48
+ fs.writeFileSync(`${target}/.gitignore`, `.DS_Store
49
+ node_modules
50
+ build
51
+ .env`);
52
+ };
53
+
54
+ const generateKeys = async ({target}) =>
55
+ {
56
+ const jwe = new JWE({});
57
+ await jwe.newPair();
58
+
59
+ const priv = await jwe.exportPrivateAsBase64();
60
+ const pub = await jwe.exportPublicAsBase64();
61
+
62
+ const content = `REGISTRATION_KEY=
63
+ PRIVATE_KEY=${priv}
64
+ PUBLIC_KEY=${pub}
65
+ `;
66
+
67
+ console.log(content);
68
+
69
+ fs.writeFileSync(`${target}/.env`, content);
45
70
  };
46
71
 
47
72
  const program = new Command();
@@ -57,7 +82,7 @@ program
57
82
  .description("Create a new connector project")
58
83
  .argument("<name>", "name of the project")
59
84
  .requiredOption("--connector-id <id>", "id of the connector")
60
- .action((name, options) => {
85
+ .action(async (name, options) => {
61
86
  name = name.replace(/[\/\.]/gi, "");
62
87
  if (!name) throw new Error("name is empty");
63
88
 
@@ -66,6 +91,7 @@ program
66
91
  fs.mkdirSync(target);
67
92
 
68
93
  extract({ ...options, target, name });
94
+ await generateKeys({target});
69
95
  });
70
96
 
71
97
  program.parse();