@kynesyslabs/demosdk 1.6.2 → 1.6.4
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/abstraction/Identities.d.ts +2 -0
- package/build/abstraction/Identities.js +6 -1
- package/build/abstraction/Identities.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.js +2 -1
- package/build/index.js.map +1 -1
- package/build/l2ps/L2PS.d.ts +9 -5
- package/build/l2ps/L2PS.js +39 -12
- package/build/l2ps/L2PS.js.map +1 -1
- package/build/l2ps/L2PSMessagingSystem.d.ts +8 -0
- package/build/l2ps/L2PSMessagingSystem.js +3 -0
- package/build/l2ps/L2PSMessagingSystem.js.map +1 -0
- package/build/l2ps/index.d.ts +3 -1
- package/build/l2ps/index.js +4 -2
- package/build/l2ps/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export interface InferFromWritePayload {
|
|
2
|
+
method: "identity_assign_from_write";
|
|
2
3
|
demos_identity: {
|
|
3
4
|
address: string;
|
|
4
5
|
signedData: string;
|
|
@@ -13,6 +14,7 @@ export interface InferFromWritePayload {
|
|
|
13
14
|
};
|
|
14
15
|
}
|
|
15
16
|
export interface InferFromSignaturePayload {
|
|
17
|
+
method: "identity_assign_from_signature";
|
|
16
18
|
demos_identity: {
|
|
17
19
|
address: string;
|
|
18
20
|
signedData: string;
|
|
@@ -8,7 +8,12 @@ class Identities {
|
|
|
8
8
|
async inferIdentity(payload) {
|
|
9
9
|
const basePayload = {
|
|
10
10
|
method: "gcr_routine",
|
|
11
|
-
params: [
|
|
11
|
+
params: [
|
|
12
|
+
{
|
|
13
|
+
method: payload.method,
|
|
14
|
+
params: [payload],
|
|
15
|
+
},
|
|
16
|
+
],
|
|
12
17
|
};
|
|
13
18
|
// TODO Implement the RPC call
|
|
14
19
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Identities.js","sourceRoot":"","sources":["../../../src/abstraction/Identities.ts"],"names":[],"mappings":";AAAA,4CAA4C;AAC5C,8EAA8E;;
|
|
1
|
+
{"version":3,"file":"Identities.js","sourceRoot":"","sources":["../../../src/abstraction/Identities.ts"],"names":[],"mappings":";AAAA,4CAA4C;AAC5C,8EAA8E;;AAoC9E,MAAqB,UAAU;IAC3B,gBAAe,CAAC;IAEhB,gEAAgE;IAChE,KAAK,CAAC,aAAa,CACf,OAA0D;QAE1D,MAAM,WAAW,GAAG;YAChB,MAAM,EAAE,aAAa;YACrB,MAAM,EAAE;gBACJ;oBACI,MAAM,EAAE,OAAO,CAAC,MAAM;oBACtB,MAAM,EAAE,CAAC,OAAO,CAAC;iBACpB;aACJ;SACJ,CAAA;QACD,8BAA8B;QAC9B,OAAO,KAAK,CAAA;IAChB,CAAC;CACJ;AAnBD,6BAmBC"}
|
package/build/index.d.ts
CHANGED
|
@@ -5,5 +5,6 @@ export * as xmlocalsdk from "./multichain/localsdk";
|
|
|
5
5
|
export * as xmwebsdk from "./multichain/websdk";
|
|
6
6
|
export * as wallet from "./wallet";
|
|
7
7
|
export * as demoswork from "./demoswork";
|
|
8
|
+
export * as l2ps from "./l2ps";
|
|
8
9
|
export * as websdk from './websdk';
|
|
9
10
|
export * as abstraction from './abstraction';
|
package/build/index.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.abstraction = exports.websdk = exports.demoswork = exports.wallet = exports.xmwebsdk = exports.xmlocalsdk = exports.utils = exports.encryption = exports.types = void 0;
|
|
36
|
+
exports.abstraction = exports.websdk = exports.l2ps = exports.demoswork = exports.wallet = exports.xmwebsdk = exports.xmlocalsdk = exports.utils = exports.encryption = exports.types = void 0;
|
|
37
37
|
// Common types and constants
|
|
38
38
|
exports.types = __importStar(require("./types"));
|
|
39
39
|
// Basic cryptographic and data manipulation functions
|
|
@@ -44,6 +44,7 @@ exports.xmlocalsdk = __importStar(require("./multichain/localsdk"));
|
|
|
44
44
|
exports.xmwebsdk = __importStar(require("./multichain/websdk"));
|
|
45
45
|
exports.wallet = __importStar(require("./wallet"));
|
|
46
46
|
exports.demoswork = __importStar(require("./demoswork"));
|
|
47
|
+
exports.l2ps = __importStar(require("./l2ps"));
|
|
47
48
|
exports.websdk = __importStar(require("./websdk"));
|
|
48
49
|
exports.abstraction = __importStar(require("./abstraction"));
|
|
49
50
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA6B;AAC7B,iDAAgC;AAChC,sDAAsD;AACtD,2DAA0C;AAC1C,iDAAgC;AAChC,gCAAgC;AAChC,oEAAmD;AACnD,gEAA+C;AAC/C,mDAAkC;AAClC,yDAAwC;AAExC,mDAAkC;AAClC,6DAA4C"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA6B;AAC7B,iDAAgC;AAChC,sDAAsD;AACtD,2DAA0C;AAC1C,iDAAgC;AAChC,gCAAgC;AAChC,oEAAmD;AACnD,gEAA+C;AAC/C,mDAAkC;AAClC,yDAAwC;AAExC,+CAA8B;AAE9B,mDAAkC;AAClC,6DAA4C"}
|
package/build/l2ps/L2PS.d.ts
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
import * as forge from "node-forge";
|
|
2
2
|
import { EncryptedTransaction } from '../types/blockchain/encryptedTransaction';
|
|
3
3
|
import { Transaction } from '../types';
|
|
4
|
+
import { Message, MessageMap } from "./L2PSMessagingSystem";
|
|
4
5
|
export default class L2PS {
|
|
5
6
|
encryptionKey: forge.pki.rsa.PublicKey;
|
|
6
7
|
uid: forge.pki.rsa.PublicKey;
|
|
7
8
|
pam: string;
|
|
8
9
|
decryptionKey: forge.pki.rsa.PrivateKey;
|
|
9
|
-
|
|
10
|
+
participatingNodes: Map<string, string>;
|
|
10
11
|
encryptedTransactions: Map<string, EncryptedTransaction>;
|
|
11
|
-
constructor();
|
|
12
|
-
|
|
12
|
+
constructor(privateKey?: forge.pki.rsa.PrivateKey);
|
|
13
|
+
getParticipatingNodes(): Promise<Map<string, string>>;
|
|
13
14
|
getEncryptedTransactions(blockNumber: number): Promise<EncryptedTransaction[]>;
|
|
14
15
|
getEncryptedTransaction(eHash: string): Promise<EncryptedTransaction>;
|
|
15
16
|
private encryptTx;
|
|
16
17
|
private decryptTx;
|
|
17
|
-
getTx(eHash: string): Transaction
|
|
18
|
-
registerTx(tx: Transaction):
|
|
18
|
+
getTx(eHash: string): Promise<Transaction>;
|
|
19
|
+
registerTx(tx: Transaction): Promise<string>;
|
|
20
|
+
sendMessage(address: string, message: string): Promise<string>;
|
|
21
|
+
retrieveMessages(address: string): Promise<MessageMap>;
|
|
22
|
+
retrieveSingleMessage(address: string, messageId: string): Promise<Message>;
|
|
19
23
|
}
|
package/build/l2ps/L2PS.js
CHANGED
|
@@ -38,24 +38,33 @@ const forge = __importStar(require("node-forge"));
|
|
|
38
38
|
const encryption_1 = require("../encryption");
|
|
39
39
|
const websdk_1 = require("../websdk");
|
|
40
40
|
class L2PS {
|
|
41
|
-
constructor() {
|
|
41
|
+
constructor(privateKey) {
|
|
42
42
|
// This will be retrieved from the db (blocks)
|
|
43
|
-
this.
|
|
43
|
+
this.participatingNodes = new Map(); // ? Map<publicKey, connectionstring (as in Peer)>
|
|
44
44
|
// Transactions that belong to the L2PS (hash -> transaction)
|
|
45
45
|
this.encryptedTransactions = new Map();
|
|
46
|
-
let
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
let keyPair;
|
|
47
|
+
if (!privateKey) {
|
|
48
|
+
keyPair = forge.pki.rsa.generateKeyPair({ bits: 2048, e: 0x10001 });
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
// Obtaining the public key from the private key
|
|
52
|
+
keyPair.privateKey = privateKey;
|
|
53
|
+
// REVIEW Is this the correct way to set the public key?
|
|
54
|
+
keyPair.publicKey = forge.pki.rsa.setPublicKey(privateKey.n, privateKey.e);
|
|
55
|
+
}
|
|
56
|
+
this.encryptionKey = keyPair.publicKey;
|
|
57
|
+
this.uid = keyPair.publicKey;
|
|
49
58
|
this.pam = forge.pki.publicKeyToRSAPublicKeyPem(this.uid);
|
|
50
|
-
this.decryptionKey =
|
|
59
|
+
this.decryptionKey = keyPair.privateKey;
|
|
51
60
|
}
|
|
52
61
|
// SECTION L2PS methods
|
|
53
|
-
async
|
|
62
|
+
async getParticipatingNodes() {
|
|
54
63
|
var lastBlockResponse = await websdk_1.demos.nodeCall("getLastBlock", {});
|
|
55
64
|
var lastBlock = lastBlockResponse.response;
|
|
56
65
|
// REVIEW Is toString() the correct way to convert the public key to string?
|
|
57
|
-
this.
|
|
58
|
-
return this.
|
|
66
|
+
this.participatingNodes = lastBlock.content.l2ps_partecipating_nodes[this.uid.toString()];
|
|
67
|
+
return this.participatingNodes;
|
|
59
68
|
}
|
|
60
69
|
// ! TODO Add a method to set the partecipating nodes
|
|
61
70
|
// The above method should be authorized through an encrypted message: if decryption succeeds, then the node is authorized to enter in the partecipating nodes
|
|
@@ -94,16 +103,34 @@ class L2PS {
|
|
|
94
103
|
}
|
|
95
104
|
// SECTION Retrieval methods
|
|
96
105
|
// Retrieve a transaction from the L2PS
|
|
97
|
-
getTx(eHash) {
|
|
98
|
-
let eTx = this.encryptedTransactions.get(eHash);
|
|
106
|
+
async getTx(eHash) {
|
|
107
|
+
let eTx = await this.encryptedTransactions.get(eHash);
|
|
99
108
|
let tx = this.decryptTx(eTx);
|
|
100
109
|
return tx;
|
|
101
110
|
}
|
|
102
111
|
// SECTION Registration methods
|
|
103
112
|
// Register a transaction in the L2PS
|
|
104
|
-
registerTx(tx) {
|
|
113
|
+
async registerTx(tx) {
|
|
105
114
|
let eTx = this.encryptTx(tx);
|
|
106
115
|
this.encryptedTransactions.set(eTx.encryptedHash, eTx);
|
|
116
|
+
// TODO Add the transaction to the L2PS remotely
|
|
117
|
+
return eTx.encryptedHash;
|
|
118
|
+
}
|
|
119
|
+
// SECTION Messaging methods
|
|
120
|
+
// Send a message to a specific address
|
|
121
|
+
async sendMessage(address, message) {
|
|
122
|
+
// TODO Implement the method
|
|
123
|
+
return "";
|
|
124
|
+
}
|
|
125
|
+
// Retrieve all messages sent to a specific address
|
|
126
|
+
async retrieveMessages(address) {
|
|
127
|
+
// TODO Implement the method
|
|
128
|
+
return new Map();
|
|
129
|
+
}
|
|
130
|
+
// Retrieve a single message from a specific address specified by its messageId
|
|
131
|
+
async retrieveSingleMessage(address, messageId) {
|
|
132
|
+
// TODO Implement the method
|
|
133
|
+
return null;
|
|
107
134
|
}
|
|
108
135
|
}
|
|
109
136
|
exports.default = L2PS;
|
package/build/l2ps/L2PS.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"L2PS.js","sourceRoot":"","sources":["../../../src/l2ps/L2PS.ts"],"names":[],"mappings":";AAAA,sCAAsC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtC,kDAAmC;AAInC,6CAAuC;AACvC,qCAAiC;
|
|
1
|
+
{"version":3,"file":"L2PS.js","sourceRoot":"","sources":["../../../src/l2ps/L2PS.ts"],"names":[],"mappings":";AAAA,sCAAsC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtC,kDAAmC;AAInC,6CAAuC;AACvC,qCAAiC;AAGjC,MAAqB,IAAI;IAarB,YAAY,UAAqC;QAPjD,8CAA8C;QAC9C,uBAAkB,GAAwB,IAAI,GAAG,EAAE,CAAA,CAAC,kDAAkD;QAEtG,6DAA6D;QAC7D,0BAAqB,GAAsC,IAAI,GAAG,EAAE,CAAA;QAI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D,IAAI,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;QAC5B,OAAO,EAAE,CAAA;IACb,CAAC;IAED,+BAA+B;IAE/B,qCAAqC;IACrC,KAAK,CAAC,UAAU,CAAC,EAAe;QAC5B,IAAI,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;QAC5B,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,GAAG,CAAC,aAAa,EAAE,GAAG,CAAC,CAAA;QACtD,gDAAgD;QAChD,OAAO,GAAG,CAAC,aAAa,CAAA;IAC5B,CAAC;IAED,4BAA4B;IAE5B,uCAAuC;IACvC,KAAK,CAAC,WAAW,CAAC,OAAe,EAAE,OAAe;QAC9C,4BAA4B;QAC5B,OAAO,EAAE,CAAA;IACb,CAAC;IAED,mDAAmD;IACnD,KAAK,CAAC,gBAAgB,CAAC,OAAe;QAClC,4BAA4B;QAC5B,OAAO,IAAI,GAAG,EAAE,CAAA;IACpB,CAAC;IAED,+EAA+E;IAC/E,KAAK,CAAC,qBAAqB,CAAC,OAAe,EAAE,SAAiB;QAC1D,4BAA4B;QAC5B,OAAO,IAAI,CAAA;IACf,CAAC;CAEJ;AAzHD,uBAyHC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"L2PSMessagingSystem.js","sourceRoot":"","sources":["../../../src/l2ps/L2PSMessagingSystem.ts"],"names":[],"mappings":""}
|
package/build/l2ps/index.d.ts
CHANGED
package/build/l2ps/index.js
CHANGED
|
@@ -3,7 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.l2ps = void 0;
|
|
7
7
|
const L2PS_1 = __importDefault(require("./L2PS"));
|
|
8
|
-
exports.
|
|
8
|
+
exports.l2ps = {
|
|
9
|
+
L2PS: L2PS_1.default,
|
|
10
|
+
};
|
|
9
11
|
//# sourceMappingURL=index.js.map
|
package/build/l2ps/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/l2ps/index.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/l2ps/index.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAEb,QAAA,IAAI,GAAG;IAChB,IAAI,EAAJ,cAAI;CACP,CAAA"}
|