@kynesyslabs/demosdk 1.1.8 → 1.2.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.
Files changed (109) hide show
  1. package/build/encryption/PQC/index.d.ts +0 -1
  2. package/build/encryption/zK/primer.js +1 -1
  3. package/build/encryption/zK/primer.js.map +1 -1
  4. package/build/index.d.ts +6 -7
  5. package/build/index.js +1 -2
  6. package/build/index.js.map +1 -1
  7. package/build/multichain/core/evm.js +1 -0
  8. package/build/multichain/core/evm.js.map +1 -1
  9. package/build/multichain/core/ibc.js +0 -2
  10. package/build/multichain/core/ibc.js.map +1 -1
  11. package/build/multichain/core/index.d.ts +1 -0
  12. package/build/multichain/core/index.js +3 -1
  13. package/build/multichain/core/index.js.map +1 -1
  14. package/build/multichain/core/near.d.ts +47 -0
  15. package/build/multichain/core/near.js +154 -0
  16. package/build/multichain/core/near.js.map +1 -0
  17. package/build/multichain/core/solana.d.ts +0 -1
  18. package/build/multichain/core/ton.d.ts +0 -1
  19. package/build/multichain/core/types/defaultChain.d.ts +1 -1
  20. package/build/multichain/core/utils.js +1 -2
  21. package/build/multichain/core/utils.js.map +1 -1
  22. package/build/multichain/core/xrp.js +2 -2
  23. package/build/multichain/core/xrp.js.map +1 -1
  24. package/build/multichain/localsdk/index.d.ts +1 -0
  25. package/build/multichain/localsdk/index.js +3 -1
  26. package/build/multichain/localsdk/index.js.map +1 -1
  27. package/build/multichain/localsdk/near.d.ts +7 -0
  28. package/build/multichain/localsdk/near.js +34 -0
  29. package/build/multichain/localsdk/near.js.map +1 -0
  30. package/build/multichain/localsdk/ton.d.ts +0 -1
  31. package/build/multichain/websdk/near.d.ts +1 -0
  32. package/build/multichain/websdk/near.js +7 -0
  33. package/build/multichain/websdk/near.js.map +1 -0
  34. package/build/multichain/websdk/solana.d.ts +0 -1
  35. package/build/multichain/websdk/solana.js +2 -2
  36. package/build/multichain/websdk/solana.js.map +1 -1
  37. package/build/types/communication/demosWork.d.ts +14 -1
  38. package/build/utils/dataManipulation.js +5 -6
  39. package/build/utils/dataManipulation.js.map +1 -1
  40. package/build/utils/getRemoteIP.js +1 -1
  41. package/build/utils/getRemoteIP.js.map +1 -1
  42. package/build/websdk/DemosWebAuth.d.ts +3 -3
  43. package/build/websdk/Web2Transactions.js +1 -2
  44. package/build/websdk/Web2Transactions.js.map +1 -1
  45. package/build/websdk/XMTransactions.js +2 -2
  46. package/build/websdk/XMTransactions.js.map +1 -1
  47. package/build/websdk/demos.d.ts +3 -3
  48. package/build/websdk/rsa.d.ts +2 -2
  49. package/build/websdk/types/KeyPair.d.ts +0 -1
  50. package/build/websdk/utils/bufferizer.js +1 -2
  51. package/build/websdk/utils/bufferizer.js.map +1 -1
  52. package/build/websdk/utils/forge_converter.js +2 -3
  53. package/build/websdk/utils/forge_converter.js.map +1 -1
  54. package/build/websdk/utils/required.js +2 -3
  55. package/build/websdk/utils/required.js.map +1 -1
  56. package/build/websdk/utils/sha256.js +1 -2
  57. package/build/websdk/utils/sha256.js.map +1 -1
  58. package/package.json +5 -8
  59. package/build/demoswork/executor/conditionalExecutor.d.ts +0 -3
  60. package/build/demoswork/executor/conditionalExecutor.js +0 -30
  61. package/build/demoswork/executor/conditionalExecutor.js.map +0 -1
  62. package/build/demoswork/executor/index.d.ts +0 -2
  63. package/build/demoswork/executor/index.js +0 -26
  64. package/build/demoswork/executor/index.js.map +0 -1
  65. package/build/demoswork/executor/stepexecutor.d.ts +0 -18
  66. package/build/demoswork/executor/stepexecutor.js +0 -53
  67. package/build/demoswork/executor/stepexecutor.js.map +0 -1
  68. package/build/demoswork/index.d.ts +0 -4
  69. package/build/demoswork/index.js +0 -15
  70. package/build/demoswork/index.js.map +0 -1
  71. package/build/demoswork/operations/conditional.d.ts +0 -18
  72. package/build/demoswork/operations/conditional.js +0 -90
  73. package/build/demoswork/operations/conditional.js.map +0 -1
  74. package/build/demoswork/operations/index.d.ts +0 -10
  75. package/build/demoswork/operations/index.js +0 -22
  76. package/build/demoswork/operations/index.js.map +0 -1
  77. package/build/demoswork/utils.d.ts +0 -30
  78. package/build/demoswork/utils.js +0 -72
  79. package/build/demoswork/utils.js.map +0 -1
  80. package/build/demoswork/validator/index.d.ts +0 -7
  81. package/build/demoswork/validator/index.js +0 -13
  82. package/build/demoswork/validator/index.js.map +0 -1
  83. package/build/demoswork/validator/steps.validator.d.ts +0 -8
  84. package/build/demoswork/validator/steps.validator.js +0 -52
  85. package/build/demoswork/validator/steps.validator.js.map +0 -1
  86. package/build/demoswork/work.d.ts +0 -12
  87. package/build/demoswork/work.js +0 -56
  88. package/build/demoswork/work.js.map +0 -1
  89. package/build/demoswork/workstep.d.ts +0 -63
  90. package/build/demoswork/workstep.js +0 -93
  91. package/build/demoswork/workstep.js.map +0 -1
  92. package/build/types/demoswork/index.d.ts +0 -14
  93. package/build/types/demoswork/index.js +0 -3
  94. package/build/types/demoswork/index.js.map +0 -1
  95. package/build/types/demoswork/operations.d.ts +0 -10
  96. package/build/types/demoswork/operations.js +0 -3
  97. package/build/types/demoswork/operations.js.map +0 -1
  98. package/build/types/demoswork/steps.d.ts +0 -54
  99. package/build/types/demoswork/steps.js +0 -18
  100. package/build/types/demoswork/steps.js.map +0 -1
  101. package/build/types/demoswork/types.d.ts +0 -4
  102. package/build/types/demoswork/types.js +0 -8
  103. package/build/types/demoswork/types.js.map +0 -1
  104. package/build/types/demoswork/web2.d.ts +0 -4
  105. package/build/types/demoswork/web2.js +0 -3
  106. package/build/types/demoswork/web2.js.map +0 -1
  107. package/build/utils/pprint.d.ts +0 -5
  108. package/build/utils/pprint.js +0 -15
  109. package/build/utils/pprint.js.map +0 -1
@@ -1,90 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Conditional = void 0;
4
- const _1 = require(".");
5
- class Conditional extends _1.Operation {
6
- // INFO: A condition can be a boolean (pre-computed) or a condition object (to be computed on runtime)
7
- // REVIEW: if the condition is a boolean false, then it will never be executed. So, can we omit it from the script?
8
- constructor(script, condition) {
9
- super(script);
10
- this.operationScript.operationType = "conditional";
11
- if (typeof condition === "object") {
12
- console.log("inside conditional", condition);
13
- this.addStep(condition.step);
14
- }
15
- this.operationScript = {
16
- ...this.operationScript,
17
- conditions: [],
18
- };
19
- this.appendCondition(condition);
20
- this.writeToScript();
21
- }
22
- appendCondition(condition) {
23
- // INFO: If the condition is a boolean, create a value only condition
24
- if (typeof condition === "boolean") {
25
- return this.operationScript.conditions.push({
26
- operator: null,
27
- key: null,
28
- value: condition,
29
- stepUID: null,
30
- do: null,
31
- });
32
- }
33
- // INFO: If the condition is an object, create a condition object
34
- return this.operationScript.conditions.push({
35
- operator: condition.operator,
36
- key: condition.key,
37
- value: condition.value,
38
- stepUID: condition.step.workUID,
39
- do: {
40
- type: "step",
41
- uid: null,
42
- },
43
- });
44
- }
45
- writeToScript() {
46
- this.script.operations[this.operationScript.operationUID] =
47
- this.operationScript;
48
- this.script.operationOrder.add(this.operationScript.operationUID);
49
- // TODO: Remove all step outputs
50
- }
51
- then(step) {
52
- this.addStep(step);
53
- const op_length = this.operationScript.conditions.length;
54
- this.operationScript.conditions[op_length - 1].do = {
55
- type: "step",
56
- uid: step.workUID,
57
- };
58
- this.writeToScript();
59
- return {
60
- elif: this.elif.bind(this),
61
- else: this.else.bind(this),
62
- };
63
- }
64
- elif(condition) {
65
- if (typeof condition === "object") {
66
- console.log("inside conditional", condition);
67
- this.addStep(condition.step);
68
- }
69
- this.appendCondition(condition);
70
- return {
71
- then: this.then.bind(this),
72
- };
73
- }
74
- else(step) {
75
- this.addStep(step);
76
- this.operationScript.conditions.push({
77
- operator: null,
78
- key: null,
79
- value: null,
80
- stepUID: null,
81
- do: {
82
- type: "step",
83
- uid: step.workUID,
84
- },
85
- });
86
- this.writeToScript();
87
- }
88
- }
89
- exports.Conditional = Conditional;
90
- //# sourceMappingURL=conditional.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"conditional.js","sourceRoot":"","sources":["../../../../src/demoswork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CAAC;YACjC,QAAQ,EAAE,IAAI;YACd,GAAG,EAAE,IAAI;YACT,KAAK,EAAE,IAAI;YACX,OAAO,EAAE,IAAI;YACb,EAAE,EAAE;gBACA,IAAI,EAAE,MAAM;gBACZ,GAAG,EAAE,IAAI,CAAC,OAAO;aACpB;SACJ,CAAC,CAAA;QAEF,IAAI,CAAC,aAAa,EAAE,CAAA;IACxB,CAAC;CACJ;AApGD,kCAoGC"}
@@ -1,10 +0,0 @@
1
- import { DemoScript } from "../../types/demoswork";
2
- import { OperationScript } from "../../types/demoswork/operations";
3
- import { WorkStep } from "../workstep";
4
- export declare class Operation {
5
- script: DemoScript;
6
- operationScript: OperationScript;
7
- constructor(script: DemoScript);
8
- addStep(step: WorkStep): void;
9
- execute(): void;
10
- }
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Operation = void 0;
4
- const utils_1 = require("../utils");
5
- class Operation {
6
- constructor(script) {
7
- this.operationScript = {
8
- operationUID: "",
9
- operationType: "",
10
- };
11
- this.script = script;
12
- this.operationScript.operationUID = (0, utils_1.getNewUID)();
13
- }
14
- addStep(step) {
15
- this.script.steps[step.workUID] = step;
16
- }
17
- execute() {
18
- throw new Error("Method not implemented.");
19
- }
20
- }
21
- exports.Operation = Operation;
22
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/demoswork/operations/index.ts"],"names":[],"mappings":";;;AAGA,oCAAoC;AAGpC,MAAa,SAAS;IAOlB,YAAY,MAAkB;QAL9B,oBAAe,GAAoB;YAC/B,YAAY,EAAE,EAAE;YAChB,aAAa,EAAiB,EAAE;SACnC,CAAA;QAGG,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,eAAe,CAAC,YAAY,GAAG,IAAA,iBAAS,GAAE,CAAA;IACnD,CAAC;IAED,OAAO,CAAC,IAAc;QAClB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAA;IAC1C,CAAC;IAED,OAAO;QACH,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAC9C,CAAC;CACJ;AAnBD,8BAmBC"}
@@ -1,30 +0,0 @@
1
- import { operators } from "../types/demoswork/types";
2
- import { stepKeys } from "../types/demoswork/steps";
3
- import { WorkStep } from "./workstep";
4
- export declare function getNewUID(): any;
5
- export declare function equalTo(step: WorkStep, key: stepKeys, value: any): {
6
- step: WorkStep;
7
- operator: operators;
8
- key: "output.result" | "output.hash";
9
- value: any;
10
- };
11
- /**
12
- * Get the value of a property given a path in an object.
13
- * The path should be a string of property names separated by dots.
14
- *
15
- * @param obj The object to traverse
16
- * @param path The path of the property to get
17
- * @returns The value of the property at the path
18
- *
19
- * @example getValue(myObject, "nested.property")
20
- */
21
- export declare function getValue(obj: Object, path: string): Object;
22
- /**
23
- * Compare two values using the specified operator
24
- *
25
- * @param a First value
26
- * @param b Second value
27
- * @param operator Comparison operator
28
- * @returns The result of the comparison (boolean)
29
- */
30
- export declare function compare(a: any, b: any, operator: string, validate_only?: boolean): boolean;
@@ -1,72 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compare = exports.getValue = exports.equalTo = exports.getNewUID = void 0;
4
- const uuid_1 = require("uuid");
5
- function getNewUID() {
6
- return (0, uuid_1.v4)();
7
- }
8
- exports.getNewUID = getNewUID;
9
- function equalTo(step, key, value) {
10
- return {
11
- step,
12
- operator: "==",
13
- key,
14
- value,
15
- };
16
- }
17
- exports.equalTo = equalTo;
18
- /**
19
- * Get the value of a property given a path in an object.
20
- * The path should be a string of property names separated by dots.
21
- *
22
- * @param obj The object to traverse
23
- * @param path The path of the property to get
24
- * @returns The value of the property at the path
25
- *
26
- * @example getValue(myObject, "nested.property")
27
- */
28
- function getValue(obj, path) {
29
- // Split the path string into an array of property names
30
- const properties = path.split(".");
31
- // Traverse the object using the property names
32
- let value = obj;
33
- for (const prop of properties) {
34
- if (value && typeof value === "object") {
35
- value = value[prop];
36
- }
37
- else {
38
- return undefined; // Return undefined if the property doesn't exist
39
- }
40
- }
41
- return value;
42
- }
43
- exports.getValue = getValue;
44
- /**
45
- * Compare two values using the specified operator
46
- *
47
- * @param a First value
48
- * @param b Second value
49
- * @param operator Comparison operator
50
- * @returns The result of the comparison (boolean)
51
- */
52
- function compare(a, b, operator, validate_only = false) {
53
- const operations = {
54
- ">": (a, b) => a > b,
55
- ">=": (a, b) => a >= b,
56
- "<": (a, b) => a < b,
57
- "<=": (a, b) => a <= b,
58
- "==": (a, b) => a == b,
59
- "===": (a, b) => a === b,
60
- "!=": (a, b) => a != b,
61
- "!==": (a, b) => a !== b,
62
- };
63
- if (!operations.hasOwnProperty(operator)) {
64
- throw new Error("Invalid operator:" + operator);
65
- }
66
- if (validate_only) {
67
- return true;
68
- }
69
- return operations[operator](a, b);
70
- }
71
- exports.compare = compare;
72
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/demoswork/utils.ts"],"names":[],"mappings":";;;AAAA,+BAAmC;AAMnC,SAAgB,SAAS;IACrB,OAAO,IAAA,SAAM,GAAE,CAAA;AACnB,CAAC;AAFD,8BAEC;AAED,SAAgB,OAAO,CAAC,IAAc,EAAE,GAAa,EAAE,KAAU;IAC7D,OAAO;QACH,IAAI;QACJ,QAAQ,EAAa,IAAI;QACzB,GAAG;QACH,KAAK;KACR,CAAA;AACL,CAAC;AAPD,0BAOC;AAED;;;;;;;;;GASG;AACH,SAAgB,QAAQ,CAAC,GAAW,EAAE,IAAY;IAC9C,wDAAwD;IACxD,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAElC,+CAA+C;IAC/C,IAAI,KAAK,GAAG,GAAG,CAAA;IAEf,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;Q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AQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AACrC,CAAC;AA1BD,0BA0BC"}
@@ -1,7 +0,0 @@
1
- import { DemoScript } from "../../types/demoswork";
2
- /**
3
- * Validates a work script. Checks for common errors.
4
- *
5
- * @param work The work script to validate
6
- */
7
- export default function (script: DemoScript): void;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const steps_validator_1 = require("./steps.validator");
4
- /**
5
- * Validates a work script. Checks for common errors.
6
- *
7
- * @param work The work script to validate
8
- */
9
- function default_1(script) {
10
- (0, steps_validator_1.noUnusedSteps)(script);
11
- }
12
- exports.default = default_1;
13
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/demoswork/validator/index.ts"],"names":[],"mappings":";;AACA,uDAAkD;AAElD;;;;GAIG;AACH,mBAAyB,MAAkB;IACvC,IAAA,+BAAa,EAAC,MAAM,CAAC,CAAA;AACzB,CAAC;AAFD,4BAEC"}
@@ -1,8 +0,0 @@
1
- import { DemoScript } from "../../types/demoswork";
2
- /**
3
- * Assert that all steps in the script are consumed by operations
4
- *
5
- * @param script The work script to validate
6
- * @returns true if all steps are used, false otherwise
7
- */
8
- export declare function noUnusedSteps(script: DemoScript): void;
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.noUnusedSteps = void 0;
4
- function getConditionalScriptSteps(script) {
5
- let steps = new Set();
6
- // INFO: Loop through all conditions and add the step to the set
7
- script.conditions.forEach(condition => {
8
- if (condition.stepUID) {
9
- steps.add(condition.stepUID);
10
- }
11
- steps.add(condition.do.uid);
12
- });
13
- return steps;
14
- }
15
- function collectAllSteps(script) {
16
- let steps = new Set();
17
- Object.keys(script.operations).forEach(opUID => {
18
- let operation = script.operations[opUID];
19
- switch (operation.operationType) {
20
- case "conditional":
21
- let conditonalSteps = getConditionalScriptSteps(operation);
22
- let scriptSteps = new Set(Object.keys(script.steps));
23
- // INFO: Assert that all steps in the conditional
24
- // script are included in the final script
25
- let diff = new Set(Array.from(conditonalSteps).filter(x => !scriptSteps.has(x)));
26
- if (diff.size > 0) {
27
- throw new Error(`Steps ${[...diff]} not included in final script`);
28
- }
29
- steps = new Set([...steps, ...conditonalSteps]);
30
- break;
31
- }
32
- });
33
- return steps;
34
- }
35
- /**
36
- * Assert that all steps in the script are consumed by operations
37
- *
38
- * @param script The work script to validate
39
- * @returns true if all steps are used, false otherwise
40
- */
41
- function noUnusedSteps(script) {
42
- // NOTES: Collect all steps in the script
43
- // and compare them to the script steps
44
- let steps = collectAllSteps(script);
45
- let scriptSteps = new Set(Object.keys(script.steps));
46
- let diff = new Set(Array.from(scriptSteps).filter(x => !steps.has(x)));
47
- if (diff.size > 0) {
48
- throw new Error(`Steps ${[...diff]} not used in script`);
49
- }
50
- }
51
- exports.noUnusedSteps = noUnusedSteps;
52
- //# sourceMappingURL=steps.validator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"steps.validator.js","sourceRoot":"","sources":["../../../../src/demoswork/validator/steps.validator.ts"],"names":[],"mappings":";;;AAGA,SAAS,yBAAyB,CAAC,MAAyB;IACxD,IAAI,KAAK,GAAG,IAAI,GAAG,EAAU,CAAA;IAE7B,gEAAgE;IAChE,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;QAClC,IAAI,SAAS,CAAC,OAAO,EAAC,CAAC;YACnB,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;QAChC,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,CAAC,CAAA;IAC/B,CAAC,CAAC,CAAA;IAEF,OAAO,KAAK,CAAA;AAChB,CAAC;AAED,SAAS,eAAe,CAAC,MAAkB;IACvC,IAAI,KAAK,GAAG,IAAI,GAAG,EAAU,CAAA;IAE7B,MAAM,CAAC,IAA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C,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAEtE,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,qBAAqB,CAAC,CAAA;IAC5D,CAAC;AACL,CAAC;AAXD,sCAWC"}
@@ -1,12 +0,0 @@
1
- import { DemoScript } from "../types/demoswork";
2
- import { Condition } from "../types/demoswork/steps";
3
- import { Conditional } from "./operations/conditional";
4
- export declare class DemosWork {
5
- script: DemoScript;
6
- results: Record<string, any>;
7
- if(condition: boolean | Condition): Conditional;
8
- validate(script: DemoScript): void;
9
- fromJSON(script: DemoScript): this;
10
- execute(): Promise<Record<string, any>>;
11
- toJSON(): DemoScript;
12
- }
@@ -1,56 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.DemosWork = void 0;
7
- const pprint_1 = __importDefault(require("../utils/pprint"));
8
- const executor_1 = __importDefault(require("./executor"));
9
- const conditional_1 = require("./operations/conditional");
10
- const validator_1 = __importDefault(require("./validator"));
11
- class DemosWork {
12
- constructor() {
13
- this.script = {
14
- operationOrder: new Set(),
15
- operations: {},
16
- steps: {},
17
- };
18
- // INFO: Step results indexed by stepUID
19
- this.results = {};
20
- }
21
- if(condition) {
22
- return new conditional_1.Conditional(this.script, condition);
23
- }
24
- validate(script) {
25
- (0, validator_1.default)(script);
26
- }
27
- fromJSON(script) {
28
- let newscript = script;
29
- (0, pprint_1.default)(newscript.operationOrder);
30
- newscript.operationOrder = new Set(script.operationOrder);
31
- this.script = script;
32
- return this;
33
- }
34
- async execute() {
35
- return await (0, executor_1.default)(this);
36
- }
37
- toJSON() {
38
- let script = this.script;
39
- // @ts-expect-error
40
- // convert set to array
41
- script.operationOrder = [...script.operationOrder];
42
- // remove all step outputs
43
- for (const stepUID in script.steps) {
44
- delete script.steps[stepUID].output;
45
- delete script.steps[stepUID].workUID;
46
- }
47
- // remove all operation uids
48
- for (const opUID in script.operations) {
49
- delete script.operations[opUID].operationUID;
50
- }
51
- this.validate(script);
52
- return script;
53
- }
54
- }
55
- exports.DemosWork = DemosWork;
56
- //# sourceMappingURL=work.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"work.js","sourceRoot":"","sources":["../../../src/demoswork/work.ts"],"names":[],"mappings":";;;;;;AAEA,4DAAmC;AACnC,0DAAsC;AACtC,0DAAsD;AACtD,4DAAqC;AAErC,MAAa,SAAS;IAAtB;QACI,WAAM,GAAe;YACjB,cAAc,EAAE,IAAI,GAAG,EAAU;YACjC,UAAU,EAAE,EAAE;YACd,KAAK,EAAE,EAAE;SACZ,CAAA;QACD,wCAAwC;QACxC,YAAO,GAAwB,EAAE,CAAA;IA2CrC,CAAC;IAzCG,EAAE,CAAC,SAA8B;QAC7B,OAAO,IAAI,yBAAW,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IAClD,CAAC;IAED,QAAQ,CAAC,MAAkB;QACvB,IAAA,mBAAW,EAAC,MAAM,CAAC,CAAA;IACvB,CAAC;IAED,QAAQ,CAAC,MAAkB;QACvB,IAAI,SAAS,GAAG,MAAM,CAAA;QACtB,IAAA,gBAAM,EAAC,SAAS,CAAC,cAAc,CAAC,CAAA;QAChC,SAAS,CAAC,cAAc,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC,CAAA;QAEzD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,OAAO,IAAI,CAAA;IACf,CAAC;IAED,KAAK,CAAC,OAAO;QACT,OAAO,MAAM,IAAA,kBAAa,EAAC,IAAI,CAAC,CAAA;IACpC,CAAC;IAED,MAAM;QACF,IAAI,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;QACxB,mBAAmB;QACnB,uBAAuB;QACvB,MAAM,CAAC,cAAc,GAAG,CAAC,GAAG,MAAM,CAAC,cAAc,CAAC,CAAA;QAElD,0BAA0B;QAC1B,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YACjC,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,CAAA;YACnC,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,OAAO,CAAA;QACxC,CAAC;QAED,4BAA4B;QAC5B,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YACpC,OAAO,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,YAAY,CAAA;QAChD,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;QACrB,OAAO,MAAM,CAAA;IACjB,CAAC;CACJ;AAlDD,8BAkDC"}
@@ -1,63 +0,0 @@
1
- import forge from "node-forge";
2
- import { IWeb2Request, XMScript } from "../types";
3
- import { DataTypes } from "../types/demoswork/types";
4
- import { WorkStepInput } from "../types/demoswork/steps";
5
- export declare class WorkStep {
6
- type: string;
7
- workUID: string;
8
- content: WorkStepInput;
9
- output: any;
10
- description: string;
11
- signature: forge.pki.ed25519.BinaryBuffer;
12
- constructor(payload: WorkStepInput);
13
- get hash(): string;
14
- /**
15
- * Sign a work step using a private key
16
- *
17
- * @param privateKey The private key
18
- * @returns The signature
19
- */
20
- sign(privateKey: forge.pki.ed25519.BinaryBuffer | any): forge.pki.ed25519.NativeBuffer;
21
- execute(): void;
22
- }
23
- export declare class Web2WorkStep extends WorkStep {
24
- type: string;
25
- output: {
26
- statusCode: {
27
- type: DataTypes;
28
- src: {
29
- stepUID: string;
30
- key: string;
31
- };
32
- };
33
- payload: {
34
- type: DataTypes;
35
- src: {
36
- stepUID: string;
37
- key: string;
38
- };
39
- };
40
- };
41
- constructor(payload: IWeb2Request);
42
- }
43
- export declare class XmWorkStep extends WorkStep {
44
- type: string;
45
- output: {
46
- result: {
47
- type: DataTypes;
48
- src: {
49
- stepUID: string;
50
- key: string;
51
- };
52
- };
53
- hash: {
54
- type: DataTypes;
55
- src: {
56
- stepUID: string;
57
- key: string;
58
- };
59
- };
60
- };
61
- constructor(payload: XMScript);
62
- }
63
- export declare function prepareXMStep(xm_payload: XMScript): XmWorkStep;
@@ -1,93 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.prepareXMStep = exports.XmWorkStep = exports.Web2WorkStep = exports.WorkStep = void 0;
7
- const node_forge_1 = __importDefault(require("node-forge"));
8
- const utils_1 = require("./utils");
9
- const encryption_1 = require("../encryption");
10
- const dataManipulation_1 = require("../utils/dataManipulation");
11
- const types_1 = require("../types/demoswork/types");
12
- class WorkStep {
13
- constructor(payload) {
14
- this.content = payload;
15
- this.workUID = (0, utils_1.getNewUID)();
16
- }
17
- get hash() {
18
- return encryption_1.Hashing.sha256(JSON.stringify(this));
19
- }
20
- /**
21
- * Sign a work step using a private key
22
- *
23
- * @param privateKey The private key
24
- * @returns The signature
25
- */
26
- sign(privateKey) {
27
- if (privateKey.type == "string") {
28
- console.log("[HexToForge] Deriving a buffer from privateKey...");
29
- privateKey = (0, dataManipulation_1.HexToForge)(privateKey);
30
- }
31
- this.signature = node_forge_1.default.pki.ed25519.sign({
32
- message: this.hash,
33
- encoding: "utf8",
34
- privateKey,
35
- });
36
- return this.signature;
37
- }
38
- execute() {
39
- // INFO: Send payload or execute web2 request here
40
- }
41
- }
42
- exports.WorkStep = WorkStep;
43
- class Web2WorkStep extends WorkStep {
44
- constructor(payload) {
45
- super(payload);
46
- this.type = "web2";
47
- this.output = {
48
- statusCode: {
49
- type: types_1.DataTypes.internal,
50
- src: {
51
- stepUID: this.workUID,
52
- key: "output.statusCode",
53
- },
54
- },
55
- payload: {
56
- type: types_1.DataTypes.internal,
57
- src: {
58
- stepUID: this.workUID,
59
- key: "output.payload",
60
- },
61
- },
62
- };
63
- }
64
- }
65
- exports.Web2WorkStep = Web2WorkStep;
66
- class XmWorkStep extends WorkStep {
67
- constructor(payload) {
68
- super(payload);
69
- this.type = "xm";
70
- this.output = {
71
- result: {
72
- type: types_1.DataTypes.internal,
73
- src: {
74
- stepUID: this.workUID,
75
- key: "output.result",
76
- },
77
- },
78
- hash: {
79
- type: types_1.DataTypes.internal,
80
- src: {
81
- stepUID: this.workUID,
82
- key: "output.hash",
83
- },
84
- },
85
- };
86
- }
87
- }
88
- exports.XmWorkStep = XmWorkStep;
89
- function prepareXMStep(xm_payload) {
90
- return new XmWorkStep(xm_payload);
91
- }
92
- exports.prepareXMStep = prepareXMStep;
93
- //# sourceMappingURL=workstep.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workstep.js","sourceRoot":"","sources":["../../../src/demoswork/workstep.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA8B;AAE9B,mCAAmC;AACnC,6CAAsC;AACtC,+DAAqD;AAGrD,mDAAmD;AAGnD,MAAa,QAAQ;IAQjB,YAAY,OAAsB;QAC9B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,OAAO,GAAG,IAAA,iBAAS,GAAE,CAAA;IAC9B,CAAC;IAED,IAAI,IAAI;QACJ,OAAO,oBAAO,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;IAC/C,CAAC;IAED;;;;;OAKG;IACH,IAAI,CAAC,UAAgD;QACjD,IAAI,UAAU,CAAC,IAAI,IAAI,QAAQ,EAAE,CAAC;YAC9B,OAAO,CAAC,GAAG,CAAC,mDAAmD,CAAC,CAAA;YAChE,UAAU,GAAG,IAAA,6BAAU,EAAC,UAAU,CAAC,CAAA;QACvC,CAAC;QAED,IAAI,CAAC,SAAS,GAAG,oBAAK,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC;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AU,CAAC,CAAA;AACrC,CAAC;AAFD,sCAEC"}
@@ -1,14 +0,0 @@
1
- import { WorkStep } from "../../demoswork/workstep";
2
- import { AnyOperation } from "./operations";
3
- /**
4
- * The final shape of the work script
5
- */
6
- export interface DemoScript {
7
- operationOrder: Set<string>;
8
- operations: {
9
- [key: string]: AnyOperation;
10
- };
11
- steps: {
12
- [key: string]: WorkStep;
13
- };
14
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/types/demoswork/index.ts"],"names":[],"mappings":""}
@@ -1,10 +0,0 @@
1
- import { Conditional } from "./steps";
2
- export type OperationType = "conditional" | "loop" | "operation" | "function";
3
- export interface OperationScript {
4
- operationUID: string;
5
- operationType: OperationType;
6
- }
7
- export interface ConditionalScript extends OperationScript {
8
- conditions: Conditional[];
9
- }
10
- export type AnyOperation = ConditionalScript;
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=operations.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"operations.js","sourceRoot":"","sources":["../../../../src/types/demoswork/operations.ts"],"names":[],"mappings":""}