@kumologica/sdk 4.0.0-beta5 → 4.0.0-beta7

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.
@@ -0,0 +1,37 @@
1
+ const path = require('path');
2
+
3
+ exports.command = 'request [email]';
4
+ exports.desc = `Requests a kumologica license for the specified email address.`;
5
+
6
+ exports.builder = (yargs) => {
7
+ yargs
8
+ .positional('email', {
9
+ describe: 'The email address to request the license for.',
10
+ type: 'string',
11
+
12
+ demandOption: true // Makes the positional argument required
13
+ });
14
+ };
15
+
16
+ function isValidEmail(email) {
17
+ return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
18
+ }
19
+
20
+ exports.handler = async function (argv) {
21
+
22
+ if(!argv.email || !isValidEmail(argv.email)) {
23
+ console.error('Invalid or missing email address. Please provide a valid email address.');
24
+ process.exit(1);
25
+ }
26
+
27
+ try {
28
+ const tools = require('../../../src/app/lib/utils/tools.min.js');
29
+
30
+ await tools.license.subscribe(argv.email);
31
+ console.log(`Follow the instructions in your email to complete the license request process.`);
32
+
33
+ } catch (e) {
34
+ console.log(`${e.message}`);
35
+ process.exit(1);
36
+ }
37
+ }
@@ -1,10 +1,7 @@
1
1
  const path = require('path');
2
2
 
3
3
  exports.command = 'save [key]';
4
- exports.desc = `Saves kumologica license in local file system.\n
5
-
6
- Documentation:
7
- https://docs.kumologica.com/docs/references/cli/LicenseSave.html`;
4
+ exports.desc = `Saves kumologica license in local file system.`;
8
5
 
9
6
  exports.builder = (yargs) => {
10
7
  yargs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kumologica/sdk",
3
- "version": "4.0.0-beta5",
3
+ "version": "4.0.0-beta7",
4
4
  "productName": "Kumologica Designer",
5
5
  "copyright": "Copyright 2020 Kumologica Pty Ltd, All Rights Reserved.",
6
6
  "author": "Kumologica Pty Ltd <contact@kumologica.com>",
@@ -84,9 +84,9 @@
84
84
  "@aws-sdk/credential-providers": "^3.556.0",
85
85
  "@aws-sdk/lib-dynamodb": "^3.549.0",
86
86
  "@electron/remote": "^2.0.8",
87
- "@kumologica/builder": "4.0.0-beta5",
88
- "@kumologica/devkit": "4.0.0-beta5",
89
- "@kumologica/runtime": "4.0.0-beta5",
87
+ "@kumologica/builder": "4.0.0-beta7",
88
+ "@kumologica/devkit": "4.0.0-beta7",
89
+ "@kumologica/runtime": "4.0.0-beta7",
90
90
  "adm-zip": "0.4.13",
91
91
  "ajv": "8.10.0",
92
92
  "archive-type": "^4.0.0",
@@ -511,7 +511,10 @@ if (s.cwevents && s.cwevents.length > 0) {
511
511
  settings.flowName
512
512
  );
513
513
 
514
- // NEW
514
+ if (!params.environment.some(e => e.key === "KUMOLOGICA_LICENSE")) {
515
+ params.environment.push({ key: "KUMOLOGICA_LICENSE", value: process.env.KUMOLOGICA_LICENSE });
516
+ }
517
+
515
518
  const args = this.mapParams(params);
516
519
  args.region = this.region;
517
520
  args["bucket-name"] = settings.deploymentBucketName;
@@ -519,7 +522,6 @@ if (s.cwevents && s.cwevents.length > 0) {
519
522
  args["flow-file-name"] = projectInfo.projectFlowName;
520
523
  args["zip-file-name"] = settings.zipFileName;
521
524
 
522
- console.log(`args: ${JSON.stringify(args)}`);
523
525
  const scriptFileName = exp("cloudformation", "aws", args);
524
526
 
525
527
  this.log(`Cloudformation script has been created: ${scriptFileName}`);
@@ -562,6 +564,10 @@ if (s.cwevents && s.cwevents.length > 0) {
562
564
  Body: body
563
565
  });
564
566
 
567
+ if (!params.environment.some(e => e.key === "KUMOLOGICA_LICENSE")) {
568
+ params.environment.push({ key: "KUMOLOGICA_LICENSE", value: process.env.KUMOLOGICA_LICENSE });
569
+ }
570
+
565
571
  const args = this.mapParams(params);
566
572
  args.region = this.region;
567
573
  args["bucket-name"] = settings.deploymentBucketName;
@@ -569,7 +575,7 @@ if (s.cwevents && s.cwevents.length > 0) {
569
575
  args["flow-file-name"] = projectInfo.projectFlowName;
570
576
  args["zip-file-name"] = settings.zipFileName;
571
577
  args.skipPrepare = "true"; // no need for cloudformation prepare
572
-
578
+
573
579
  const scriptFileName = exp("cloudformation", "aws", args);
574
580
 
575
581
  const lambdaCfTemplate = this.loadJsonFile(scriptFileName);
@@ -1 +1 @@
1
- var e,o,n,t,r=require("crypto"),i=require("fs"),s=require("path");function l(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function c(){if(!o){o=1;let l="base64";e={subscribe:async function(e){console.log("Requesting developer license for email: "+e);var r=await fetch("https://api.infra.kumologica.com/p/signup?x-api-key=RjibYF3qZb2AzmTrPOnV35LfRV798e3Z87vp4izo",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e})});if(r.ok)return!0;{let e=await r.text();return console.error(`License request failed: ${r.status} `+e),!1}},display:function(e){e?(console.log("-------- License Details ----------"),console.log("Subscriber: "+e.sub),console.log("Email: "+e.email),console.log("License Type: "+e.licenseType),console.log("Issued By: "+e.iss),console.log("Issued At: "+new Date(e.iat).toLocaleString()),console.log("Expiry: "+("perpetual"===e.exp?"Perpetual":new Date(e.exp).toLocaleString())),console.log("-----------------------------------")):console.error("Invalid license data.")},verify:function(e){publicKeyPem=(()=>{var o=Buffer.from("XkI1bxBWOXhHBztkdXIuEXlKLBcSIWstZlEzOEADPyFCCVkUeQNIIxwWDU4QEiEyLHpfOjwHCVNlL3tTFiIvMGkcZCkOBnNgIjtybUckA3x7BRARDElXRxECPlB4OgF4aWIRDQAGLBI2Jns3eTINDkx+XSN9bAAFDHllInIdCEg8SzICC2JJJyl4CGk5JAB/EBQcLW4+dzcuMGxhLglhbHUZF2ZwFQMJEl08cAVfWGd5ADtje34SDUJCHxUlWh83aghXDnJXXwxxCFsUNANhCzJ0MHoiVyEvLlh2OC5gf2UwdGZhDxAvMllUcCgSWl1w",l).toString().split("").reverse().join("");let t="";for(let r=0;r<o.length;r++){let e="34jfd#d-cDFG23@W096ml".charCodeAt(r%21);t+=String.fromCharCode(o.charCodeAt(r)^e)}return Buffer.from(t,l).toString()})();var o=r,[e,t]=e.split(".");if(!e||!t)throw new Error("Invalid license format. License may have been tampered.");var e=Buffer.from(e,"base64url").toString("utf-8"),n=JSON.parse(e),e=Buffer.from(e,"utf-8"),t=Buffer.from(t,l),o=o.createVerify("SHA256");if(o.update(e),o.end(),!o.verify(publicKeyPem,t))throw new Error("Invalid license signature. License may have been tampered.");if(!(n&&n.sub&&n.email&&n.iss&&n.iat))throw new Error("Invalid license data. License may have been tampered.");if(n.exp&&("Perpetual"===n.exp||Date.now()>n.exp))throw new Error("License has expired. Please renew your license, contact Kumologica support at contact@kumologica.com.");return n},save:function(e,r){var o=i,t=s,t=(console.log("saving key to: "+e),t.join(e,"kumologica.license"));try{o.writeFileSync(t,r,"utf-8"),console.log("License saved successfully at: "+t)}catch(e){console.error("Failed to save license: "+e.message)}},read:function(e){var r=i,o=s.join(e,"kumologica.license");try{let e=r.readFileSync(o,"utf-8");return console.log("License read successfully from: "+o),e}catch(e){return null}}}}return e}var a=(()=>{if(t)return n;t=1;var e=c();return n={license:e}})(),u=l(a);module.exports=u;
1
+ var e,o,n,t,r=require("crypto"),s=require("fs"),i=require("path");function l(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function c(){if(!o){o=1;let l="base64";e={subscribe:async function(e){console.log("Requesting license for email: "+e);var r=await fetch("https://api.infra.kumologica.com/p/signup?x-api-key=RjibYF3qZb2AzmTrPOnV35LfRV798e3Z87vp4izo",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e})});if(r.ok)return!0;{let e=await r.text();return console.error(`License request failed: ${r.status} `+e),!1}},display:function(e){e?(console.log("-------- License Details ----------"),console.log("Subscriber: "+e.sub),console.log("Email: "+e.email),console.log("License Type: "+e.licenseType),console.log("Issued For: "+(e.name||e.email)),console.log("Issued By: "+e.iss),console.log("Issued At: "+new Date(e.iat).toLocaleString()),console.log("Expiry: "+("perpetual"===e.exp?"Perpetual":new Date(e.exp).toLocaleString())),console.log("-----------------------------------")):console.error("Invalid license data.")},verify:function(e){publicKeyPem=(()=>{var o=Buffer.from("XkI1bxBWOXhHBztkdXIuEXlKLBcSIWstZlEzOEADPyFCCVkUeQNIIxwWDU4QEiEyLHpfOjwHCVNlL3tTFiIvMGkcZCkOBnNgIjtybUckA3x7BRARDElXRxECPlB4OgF4aWIRDQAGLBI2Jns3eTINDkx+XSN9bAAFDHllInIdCEg8SzICC2JJJyl4CGk5JAB/EBQcLW4+dzcuMGxhLglhbHUZF2ZwFQMJEl08cAVfWGd5ADtje34SDUJCHxUlWh83aghXDnJXXwxxCFsUNANhCzJ0MHoiVyEvLlh2OC5gf2UwdGZhDxAvMllUcCgSWl1w",l).toString().split("").reverse().join("");let t="";for(let r=0;r<o.length;r++){let e="34jfd#d-cDFG23@W096ml".charCodeAt(r%21);t+=String.fromCharCode(o.charCodeAt(r)^e)}return Buffer.from(t,l).toString()})();var o=r,[e,t]=e.split(".");if(!e||!t)throw new Error("Invalid license format. License may have been tampered.");var e=Buffer.from(e,"base64url").toString("utf-8"),n=JSON.parse(e),e=Buffer.from(e,"utf-8"),t=Buffer.from(t,l),o=o.createVerify("SHA256");if(o.update(e),o.end(),!o.verify(publicKeyPem,t))throw new Error("Invalid license signature. License may have been tampered.");if(!(n&&n.sub&&n.email&&n.iss&&n.iat))throw new Error("Invalid license data. License may have been tampered.");if(n.exp&&("Perpetual"===n.exp||Date.now()>n.exp))throw new Error("License has expired. Please renew your license, contact Kumologica support at contact@kumologica.com.");return n},save:function(e,r){var o=s,t=i,t=(console.log("saving key to: "+e),t.join(e,"kumologica.license"));try{o.writeFileSync(t,r,"utf-8"),console.log("License saved successfully at: "+t)}catch(e){console.error("Failed to save license: "+e.message)}},read:function(e){var r=s,o=i.join(e,"kumologica.license");try{let e=r.readFileSync(o,"utf-8");return console.log("License read successfully from: "+o),e}catch(e){return null}}}}return e}var a=(()=>{if(t)return n;t=1;var e=c();return n={license:e}})(),u=l(a);module.exports=u;
@@ -51,19 +51,6 @@ class DesignerServer {
51
51
  return licenseData;
52
52
  }
53
53
 
54
- verifyLicense(licenseData) {
55
-
56
- if (licenseData) {
57
- const lData = tools.license.verify(licenseData);
58
- if (lData) {
59
- tools.license.display(lData);
60
- }
61
- return lData;
62
- } else {
63
- console.error("[ERROR] License data is not available. Please provide a valid license key.");
64
- return null;
65
- }
66
- }
67
54
 
68
55
  async start() {
69
56
  // Check if port passed by parameter is available otherwise allocate a new one
@@ -79,8 +66,6 @@ class DesignerServer {
79
66
  process.exit(1);
80
67
  }
81
68
 
82
- this.verifyLicense(licenseKey);
83
-
84
69
  process.env.KUMOLOGICA_LICENSE = licenseKey;
85
70
 
86
71
  this.config.port = await this.allocatePort(this.config.port);
@@ -91,6 +76,7 @@ class DesignerServer {
91
76
  );
92
77
 
93
78
  await this.flowServer.start();
79
+
94
80
  this.flowServer.log.debug(
95
81
  `Runtime Configuration:${JSON.stringify(this.config, null, 2)}`
96
82
  );