@kynesyslabs/demosdk 1.0.13 → 1.0.14

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 (62) hide show
  1. package/build/multichain/core/index.d.ts +1 -1
  2. package/build/multichain/core/solana.d.ts +19 -0
  3. package/build/multichain/core/solana.js +119 -0
  4. package/build/multichain/core/solana.js.map +1 -0
  5. package/build/multichain/core/types/defaultChain.d.ts +2 -2
  6. package/build/multichain/core/types/defaultChain.js.map +1 -1
  7. package/build/multichain/core/types/interfaces.d.ts +1 -1
  8. package/build/multichain/localsdk/evm.d.ts +2 -5
  9. package/build/multichain/localsdk/evm.js.map +1 -1
  10. package/build/multichain/localsdk/ibc.d.ts +2 -5
  11. package/build/multichain/localsdk/ibc.js.map +1 -1
  12. package/build/multichain/localsdk/multiversx.d.ts +2 -5
  13. package/build/multichain/localsdk/multiversx.js.map +1 -1
  14. package/build/multichain/localsdk/xrp.d.ts +2 -15
  15. package/build/multichain/localsdk/xrp.js.map +1 -1
  16. package/build/types/blockchain/Transaction.d.ts +2 -2
  17. package/build/types/web2/index.d.ts +8 -1
  18. package/build/types/web2/index.js +9 -0
  19. package/build/types/web2/index.js.map +1 -1
  20. package/build/websdk/DemosTransactions.d.ts +8 -0
  21. package/build/websdk/DemosTransactions.js +100 -0
  22. package/build/websdk/DemosTransactions.js.map +1 -0
  23. package/build/websdk/DemosWebAuth.d.ts +27 -0
  24. package/build/websdk/DemosWebAuth.js +200 -0
  25. package/build/websdk/DemosWebAuth.js.map +1 -0
  26. package/build/websdk/Web2Transactions.d.ts +2 -0
  27. package/build/websdk/Web2Transactions.js +58 -0
  28. package/build/websdk/Web2Transactions.js.map +1 -0
  29. package/build/websdk/XMTransactions.d.ts +69 -0
  30. package/build/websdk/XMTransactions.js +124 -0
  31. package/build/websdk/XMTransactions.js.map +1 -0
  32. package/build/websdk/demos.d.ts +61 -0
  33. package/build/websdk/demos.js +401 -0
  34. package/build/websdk/demos.js.map +1 -0
  35. package/build/websdk/index.d.ts +11 -0
  36. package/build/websdk/index.js +32 -0
  37. package/build/websdk/index.js.map +1 -0
  38. package/build/websdk/rsa.d.ts +19 -0
  39. package/build/websdk/rsa.js +86 -0
  40. package/build/websdk/rsa.js.map +1 -0
  41. package/build/websdk/types/IBuffer.d.ts +4 -0
  42. package/build/websdk/types/IBuffer.js +3 -0
  43. package/build/websdk/types/IBuffer.js.map +1 -0
  44. package/build/websdk/types/KeyPair.d.ts +9 -0
  45. package/build/websdk/types/KeyPair.js +3 -0
  46. package/build/websdk/types/KeyPair.js.map +1 -0
  47. package/build/websdk/utils/bufferizer.d.ts +9 -0
  48. package/build/websdk/utils/bufferizer.js +19 -0
  49. package/build/websdk/utils/bufferizer.js.map +1 -0
  50. package/build/websdk/utils/forge_converter.d.ts +3 -0
  51. package/build/websdk/utils/forge_converter.js +73 -0
  52. package/build/websdk/utils/forge_converter.js.map +1 -0
  53. package/build/websdk/utils/required.d.ts +21 -0
  54. package/build/websdk/utils/required.js +48 -0
  55. package/build/websdk/utils/required.js.map +1 -0
  56. package/build/websdk/utils/sha256.d.ts +4 -0
  57. package/build/websdk/utils/sha256.js +18 -0
  58. package/build/websdk/utils/sha256.js.map +1 -0
  59. package/build/websdk/utils/skeletons.d.ts +37 -0
  60. package/build/websdk/utils/skeletons.js +70 -0
  61. package/build/websdk/utils/skeletons.js.map +1 -0
  62. package/package.json +3 -1
@@ -0,0 +1,401 @@
1
+ "use strict";
2
+ /* INFO
3
+ This library contains all the functions that are used to interact with the demos blockchain.
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || function (mod) {
22
+ if (mod && mod.__esModule) return mod;
23
+ var result = {};
24
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
+ __setModuleDefault(result, mod);
26
+ return result;
27
+ };
28
+ var __importDefault = (this && this.__importDefault) || function (mod) {
29
+ return (mod && mod.__esModule) ? mod : { "default": mod };
30
+ };
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.demos = void 0;
33
+ /* eslint-disable no-unused-vars */
34
+ /* eslint-disable no-undef */
35
+ const buffer_1 = require("buffer/");
36
+ const node_forge_1 = __importDefault(require("node-forge"));
37
+ const socket_io_client_1 = __importDefault(require("socket.io-client"));
38
+ const sha256_1 = require("./utils/sha256");
39
+ const bufferizer_1 = require("./utils/bufferizer");
40
+ const skeletons = __importStar(require("./utils/skeletons"));
41
+ // NOTE Including custom libraries from Demos
42
+ const DemosWebAuth_1 = require("./DemosWebAuth");
43
+ const XMTransactions_1 = require("./XMTransactions");
44
+ const DemosTransactions_1 = require("./DemosTransactions");
45
+ const Web2Transactions_1 = require("./Web2Transactions");
46
+ // TODO Use XMTransactions for the crosschain transactions
47
+ // REVIEW Maybe modularize this behemoth
48
+ exports.demos = {
49
+ // ANCHOR Properties
50
+ socket: null,
51
+ socket_connected: false,
52
+ connectedListener: function (val) { },
53
+ set connected(val) {
54
+ this.socket_connected = val;
55
+ this.connectedListener(val);
56
+ },
57
+ get connected() {
58
+ return this.socket_connected;
59
+ },
60
+ onConnectedChange: function (listener) {
61
+ this.connectedListener = listener;
62
+ },
63
+ identity: null,
64
+ registry: {},
65
+ // SECTION Registry
66
+ replies: {
67
+ // INFO Insert a muid in the reply registry
68
+ waitReply: function (muid) {
69
+ if (!exports.demos.registry[muid]) {
70
+ exports.demos.registry[muid] = null;
71
+ console.log('[DEMOS] Waiting for response for ' + muid);
72
+ console.log(exports.demos.registry);
73
+ }
74
+ },
75
+ // INFO Check if a muid is in the registry
76
+ needReply: function (muid) {
77
+ if (exports.demos.registry[muid] === undefined) {
78
+ return false;
79
+ }
80
+ else {
81
+ return true;
82
+ }
83
+ },
84
+ // INFO Get a reply from a muid
85
+ getReply: function (muid) {
86
+ return exports.demos.registry[muid];
87
+ },
88
+ // NOTE As this method returns a promise, we can use it to asynchronously await for a reply
89
+ checkReply: async function (muid, ms = 10000) {
90
+ let timeout = ms; // 5 seconds
91
+ let reply = exports.demos.replies.getReply(muid);
92
+ while (reply === null && timeout > 0) {
93
+ await new Promise((resolve) => setTimeout(resolve, 100));
94
+ reply = exports.demos.replies.getReply(muid);
95
+ timeout -= 100;
96
+ }
97
+ if (reply === null) {
98
+ reply = JSON.stringify({ error: 'timeout' });
99
+ }
100
+ return reply;
101
+ },
102
+ },
103
+ // !SECTION Registry
104
+ // SECTION Connection and listeners
105
+ connect: function (rpc_url) {
106
+ if (this.socket !== null) {
107
+ console.log('[DEMOS] Already connected');
108
+ return;
109
+ }
110
+ // @ts-ignore
111
+ try {
112
+ exports.demos.socket = (0, socket_io_client_1.default)(rpc_url, {
113
+ extraHeaders: {
114
+ 'Access-Control-Allow-Origin': '*',
115
+ },
116
+ });
117
+ }
118
+ catch (e) {
119
+ this.connected = false;
120
+ console.log(e);
121
+ }
122
+ if (exports.demos.socket === null) {
123
+ throw new Error('Socket is null! Aborting connection');
124
+ }
125
+ // Listeners
126
+ exports.demos.socket.on('connect', function () {
127
+ console.log('[DEMOS] Connected to server', exports.demos.socket.connected);
128
+ exports.demos.connected = exports.demos.socket.connected;
129
+ });
130
+ exports.demos.socket.once('disconnect', function () {
131
+ console.log('[DEMOS] Disconnected from server');
132
+ exports.demos.socket = null;
133
+ exports.demos.connected = false;
134
+ });
135
+ // NOTE Reply to comlink messages
136
+ exports.demos.socket.on('comlink_reply', function (reply) {
137
+ if (!reply.chain.current.currentMessage.bundle.content.message) {
138
+ console.log('[!] [DEMOS] Received a comlink_reply without a message!');
139
+ return;
140
+ }
141
+ const _muid = reply.muid;
142
+ console.log('[DEMOS] Received comlink_reply: ' + _muid);
143
+ if (exports.demos.replies.needReply(_muid)) {
144
+ console.log('[DEMOS] Received an expected reply!');
145
+ exports.demos.registry[_muid] =
146
+ reply.chain.current.currentMessage.bundle.content.message;
147
+ // console.log(reply.chain.current.currentMessage.bundle.content.message)
148
+ }
149
+ else {
150
+ console.log('[DEMOS] Received an unexpected reply!');
151
+ }
152
+ });
153
+ exports.demos.socket.on('connect_error', (err) => {
154
+ exports.demos.connected = exports.demos.socket.connected;
155
+ exports.demos.socket = null;
156
+ console.log(`[DEMOS] connect_error due to ${err.message}`);
157
+ });
158
+ exports.demos.socket.on('connect_failed', (err) => {
159
+ exports.demos.socket.disconnect();
160
+ console.log(`[DEMOS] error due to ${err.message}`);
161
+ });
162
+ // ANCHOR Catch-all (mainly for debug purposes)
163
+ exports.demos.socket.onAny((event, data) => {
164
+ console.log(event);
165
+ console.log(data);
166
+ });
167
+ },
168
+ disconnect: function () {
169
+ exports.demos.socket?.disconnect();
170
+ },
171
+ // !SECTION Connection and listeners
172
+ // INFO MUID generator
173
+ generateMuid: function () {
174
+ const number_1 = Math.random().toString(36).substring(2, 15) +
175
+ Math.random().toString(36).substring(2, 15);
176
+ const number_2 = Math.random().toString(36).substring(2, 15) +
177
+ Math.random().toString(36).substring(2, 15);
178
+ const muid = number_1 + number_2;
179
+ return muid;
180
+ },
181
+ // SECTION NodeCall prototype
182
+ // INFO NodeCalls use the same structure
183
+ nodeCall: async function (message, args = {}) {
184
+ return await exports.demos.call('nodeCall', message, args);
185
+ },
186
+ // TODO, FIXME & REVIEW: Replace call with validate / execute logic
187
+ confirm: async function (transaction) {
188
+ return await exports.demos.call('transaction', '', transaction, 'confirmTx');
189
+ },
190
+ broadcast: async function (validationData) {
191
+ // FIXME Implement validationData type
192
+ return await exports.demos.call('transaction', '', validationData, 'broadcastTx');
193
+ },
194
+ // INFO NodeCalls use the same structure
195
+ call: async function (type, message, data = {}, extra = '', sender = null, receiver = null) {
196
+ /* if (!demos.socket.connected) {
197
+ console.log("[ERROR] We are disconnected")
198
+ return
199
+ } */
200
+ const _muid = exports.demos.generateMuid();
201
+ // TODO Typize both objects below
202
+ const transmission = {
203
+ bundle: {
204
+ content: {
205
+ type: type,
206
+ message: message,
207
+ sender: null,
208
+ receiver: null,
209
+ timestamp: null,
210
+ data: data, // REVIEW Does it works this way or should we pass it as a non-dict argument?
211
+ extra: extra,
212
+ },
213
+ hash: '',
214
+ signature: null,
215
+ },
216
+ };
217
+ const comlink = {
218
+ muid: _muid,
219
+ properties: {
220
+ connection_string: null, // NOTE We don't have a connection_string as we are clients
221
+ require_reply: true,
222
+ is_reply: false,
223
+ },
224
+ chain: {
225
+ current: {
226
+ currentMessage: transmission,
227
+ currentMessageHash: '',
228
+ previousHashes: [], // Keep track of the previous hashes to have full integrity
229
+ },
230
+ comlinkCurrentHash: '', // is the hashed version of .current
231
+ comlinkCurrentHashSignature: null, // is the signature of the hashed version of.current
232
+ },
233
+ };
234
+ // REVIEW Getting our shared identity
235
+ let keys;
236
+ try {
237
+ const id = DemosWebAuth_1.DemosWebAuth.getInstance();
238
+ if (id.keypair === null) {
239
+ throw new Error('No keypair found');
240
+ }
241
+ keys = id.keypair;
242
+ }
243
+ catch (e) {
244
+ console.log('[ERROR LOADING IDENTITY]');
245
+ console.log(e);
246
+ // FIXME and // TODO Eliminate this: generating a random identity for the signature
247
+ const seed = node_forge_1.default.random.getBytesSync(32);
248
+ keys = node_forge_1.default.pki.ed25519.generateKeyPair({ seed });
249
+ // megabudino was here
250
+ }
251
+ const privkey = keys.privateKey;
252
+ const pubKey = keys.publicKey;
253
+ console.log(keys);
254
+ // Signaling our identity
255
+ console.log('Parameters:');
256
+ comlink.chain.current.currentMessage.bundle.content.sender =
257
+ buffer_1.Buffer.from(pubKey);
258
+ // NOTE Manual converting the Uint8Array to a Buffer supported by node.js and forge
259
+ console.log('Buffered key (uint8array):');
260
+ console.log(buffer_1.Buffer.from(pubKey));
261
+ const pubKeyBuffer = (0, bufferizer_1.bufferize)(pubKey);
262
+ console.log('Manual buffering:');
263
+ console.log(pubKeyBuffer);
264
+ comlink.chain.current.currentMessage.bundle.content.sender =
265
+ pubKeyBuffer;
266
+ console.log('Actual sender:');
267
+ console.log(comlink.chain.current.currentMessage.bundle.content.sender);
268
+ // NOTE Doing the cryptography for the transmission object
269
+ const stringifiedTransmissionContent = JSON.stringify(comlink.chain.current.currentMessage.bundle.content);
270
+ console.log('Transmission Content:');
271
+ console.log(comlink.chain.current.currentMessage.bundle.content);
272
+ console.log('Stringified Transmission Content:');
273
+ console.log(stringifiedTransmissionContent);
274
+ const t_hashed = await (0, sha256_1.sha256)(stringifiedTransmissionContent);
275
+ console.log(t_hashed +
276
+ ' is the hashed version of comlink.chain.current.currentMessage.bundle.content');
277
+ comlink.chain.current.currentMessage.bundle.hash = t_hashed;
278
+ comlink.chain.current.currentMessageHash = t_hashed;
279
+ // And signing it
280
+ const t_signature = node_forge_1.default.pki.ed25519.sign({
281
+ message: t_hashed,
282
+ encoding: 'utf8',
283
+ privateKey: privkey,
284
+ });
285
+ console.log(t_signature.toString('utf8') +
286
+ ' is the signature of the hashed version of comlink.chain.current.currentMessage.bundle.content');
287
+ comlink.chain.current.currentMessage.bundle.signature = (0, bufferizer_1.bufferize)(buffer_1.Buffer.from(t_signature)); // REVIEW Changed to Buffer
288
+ // NOTE Also hashing the comlink current property
289
+ const stringifiedMessage = JSON.stringify(comlink.chain.current);
290
+ const hashed = await (0, sha256_1.sha256)(stringifiedMessage);
291
+ console.log(hashed + ' is the hashed version of comlink.chain.current');
292
+ comlink.chain.comlinkCurrentHash = hashed;
293
+ // Signing the hash
294
+ // console.log(keys.publicKey.toHex() + " is the public key of the signing key")
295
+ // console.log(keys.privateKey.toHex() + " is the private key of the signing key")
296
+ const signature = node_forge_1.default.pki.ed25519.sign({
297
+ message: hashed,
298
+ encoding: 'utf8',
299
+ privateKey: privkey,
300
+ });
301
+ console.log(signature.toString('utf8') +
302
+ ' is the signature of the hashed version of comlink.chain.current');
303
+ comlink.chain.comlinkCurrentHashSignature = (0, bufferizer_1.bufferize)(buffer_1.Buffer.from(signature)); // REVIEW Changed to Buffer
304
+ // Stringifying currentMessage
305
+ // comlink.chain.current.currentMessage = JSON.stringify(comlink.chain.current.currentMessage)
306
+ console.log('Sending message ');
307
+ console.log(message);
308
+ console.log(' to server with muid: ' + comlink.muid);
309
+ console.log('Using the following comlink:');
310
+ console.log(comlink);
311
+ // Registering the reply request
312
+ exports.demos.replies.waitReply(_muid);
313
+ console.log(comlink);
314
+ exports.demos.socket.emit('comlink', comlink);
315
+ // Waiting for a reply
316
+ return await exports.demos.replies.checkReply(_muid);
317
+ },
318
+ // !SECTION NodeCall prototype
319
+ // SECTION Predefined calls
320
+ getLastBlockNumber: async function () {
321
+ return await exports.demos.nodeCall('getLastBlockNumber');
322
+ },
323
+ getLastBlockHash: async function () {
324
+ return await exports.demos.nodeCall('getLastBlockHash');
325
+ },
326
+ getBlockByNumber: async function (blockNumber) {
327
+ let block = await exports.demos.nodeCall('getBlockByNumber', {
328
+ blockNumber,
329
+ });
330
+ block = JSON.parse(block);
331
+ console.log(typeof block);
332
+ return block;
333
+ },
334
+ getBlockByHash: async function (blockHash) {
335
+ let block = await exports.demos.nodeCall('getBlockByHash', {
336
+ blockHash,
337
+ });
338
+ block = JSON.parse(block);
339
+ block.content = JSON.parse(block.content);
340
+ console.log(typeof block);
341
+ return block;
342
+ },
343
+ getTxByHash: async function (txHash = 'e25860ec6a7cccff0371091fed3a4c6839b1231ccec8cf2cb36eca3533af8f11') {
344
+ // Defaulting to the genesis tx of course
345
+ let tx = await exports.demos.nodeCall('getTxByHash', {
346
+ hash: txHash,
347
+ });
348
+ tx = JSON.parse(tx);
349
+ console.log(typeof tx);
350
+ return tx;
351
+ },
352
+ getPeerlist: async function () {
353
+ return await exports.demos.nodeCall('getPeerlist');
354
+ },
355
+ getMempool: async function () {
356
+ return await exports.demos.nodeCall('getMempool');
357
+ },
358
+ getPeerIdentity: async function () {
359
+ return await exports.demos.nodeCall('getPeerIdentity');
360
+ },
361
+ getAddressInfo: async function (address) {
362
+ const add = JSON.parse(await exports.demos.nodeCall('getAddressInfo', {
363
+ address,
364
+ }));
365
+ add.native.tx_list = JSON.parse(add.native.tx_list);
366
+ return add;
367
+ },
368
+ // !SECTION Predefined calls
369
+ // SECTION Operation types
370
+ /* NOTE
371
+ * As per the new transaction system, we need to prepare the payload before sending it to the network.
372
+ * This is done by calling the createPayload method of the corresponding transaction type.
373
+ * You will get a Transaction object, signed and ready to be broadcasted using DemosTransactions.broadcast.
374
+ * After broadcasting, you will receive a ValidityData object that needs to be confirmed.
375
+ * This is done by calling the confirm method of DemosTransactions.
376
+ */
377
+ // ANCHOR Web2 Endpoints
378
+ web2: {
379
+ createPayload: Web2Transactions_1.prepareWeb2Payload, // REVIEW It returns a tx that needs to be broadcasted and then confirmed due to the new method
380
+ },
381
+ // ANCHOR Crosschain support endpoints
382
+ xm: {
383
+ // INFO Working with XMTransactions
384
+ createPayload: XMTransactions_1.prepareXMPayload, // REVIEW It returns a tx that needs to be broadcasted and then confirmed due to the new method
385
+ },
386
+ // ANCHOR Supporting txs
387
+ DemosTransactions: DemosTransactions_1.DemosTransactions,
388
+ transactions: DemosTransactions_1.DemosTransactions,
389
+ // !SECTION Operation types
390
+ // INFO DemosWebAuthenticator
391
+ DemosWebAuth: DemosWebAuth_1.DemosWebAuth, // NOTE Modularized to be more elegant
392
+ // INFO Calling demos.skeletons.NAME provides an empty skeleton that can be used for reference while calling other demos functions
393
+ skeletons,
394
+ };
395
+ async function sleep(time) {
396
+ return new Promise((resolve) => setTimeout(resolve, time));
397
+ }
398
+ // Creating a demos class
399
+ // let demos = new Demos()
400
+ // export default demos
401
+ //# sourceMappingURL=demos.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"demos.js","sourceRoot":"","sources":["../../../src/websdk/demos.ts"],"names":[],"mappings":";AAAA;;EAEE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,mCAAmC;AACnC,6BAA6B;AAC7B,oCAAgC;AAChC,4DAA8B;AAC9B,wEAA6C;AAE7C,2CAAuC;AACvC,mDAA8C;AAC9C,6DAA8C;AAE9C,6CAA6C;AAC7C,iDAA6C;AAC7C,qDAAmD;AACnD,2DAAuD;AACvD,yDAAuD;AAKvD,0DAA0D;AAE1D,wCAAwC;AAC3B,QAAA,KAAK,GAAG;IACjB,oBAAoB;IACpB,MAAM,EAAiB,IAAI;IAC3B,gBAAgB,EAAE,KAAK;IACvB,iBAAiB,EAAE,UAAU,GAAQ,IAAG,CAAC;IACzC,IAAI,SAAS,CAAC,GAAG;QACb,IAAI,CAAC,gBAAgB,GAAG,GAAG,CAAA;QAC3B,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAA;IAC/B,CAAC;IACD,IAAI,SAAS;QACT,OAAO,IAAI,CAAC,gBAAgB,CAAA;IAChC,CAAC;IACD,iBAAiB,EAAE,UAAU,QAAa;QACtC,IAAI,CAAC,iBAAiB,GAAG,QAAQ,CAAA;IACrC,CAAC;IACD,QAAQ,EAAE,IAAI;IACd,QAAQ,EAIP,EAAE;IAEH,mBAAmB;IACnB,OAAO,EAAE;QACL,2CAA2C;QAC3C,SAAS,EAAE,UAAU,IAAY;YAC7B,IAAI,CAAC,aAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;gBACxB,aAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;gBAC3B,OAAO,CAAC,GAAG,CAAC,mCAAmC,GAAG,IAAI,CAAC,CAAA;gBACvD,OAAO,CAAC,GAAG,CAAC,aAAK,CAAC,QAAQ,CAAC,CAAA;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AAC,YAAY,CAAC,CAAA;IAC7C,CAAC;IACD,eAAe,EAAE,KAAK;QAClB,OAAO,MAAM,aAAK,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAA;IAClD,CAAC;IAED,cAAc,EAAE,KAAK,WAAW,OAAY;QACxC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAClB,MAAM,aAAK,CAAC,QAAQ,CAAC,gBAAgB,EAAE;YACnC,OAAO;SACV,CAAC,CACL,CAAA;QACD,GAAG,CAAC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QACnD,OAAO,GAAG,CAAA;IACd,CAAC;IACD,4BAA4B;IAE5B,0BAA0B;IAC1B;;;;;;OAMG;IACH,wBAAwB;IACxB,IAAI,EAAE;QACF,aAAa,EAAE,qCAAkB,EAAE,+FAA+F;KACrI;IACD,sCAAsC;IACtC,EAAE,EAAE;QACA,mCAAmC;QACnC,aAAa,EAAE,iCAAgB,EAAE,+FAA+F;KACnI;IAED,wBAAwB;IACxB,iBAAiB,EAAjB,qCAAiB;IACjB,YAAY,EAAE,qCAAiB;IAE/B,2BAA2B;IAE3B,6BAA6B;IAC7B,YAAY,EAAZ,2BAAY,EAAE,sCAAsC;IAEpD,kIAAkI;IAClI,SAAS;CACZ,CAAA;AAED,KAAK,UAAU,KAAK,CAAC,IAAY;IAC7B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAA;AAC9D,CAAC;AAED,yBAAyB;AACzB,0BAA0B;AAC1B,uBAAuB"}
@@ -0,0 +1,11 @@
1
+ export { demos } from './demos';
2
+ export { DemosTransactions } from './DemosTransactions';
3
+ export { RSA } from './rsa';
4
+ export { DemosWebAuth } from './DemosWebAuth';
5
+ export { prepareWeb2Payload } from './Web2Transactions';
6
+ export { XMTransactions, prepareXMPayload } from './XMTransactions';
7
+ export { sha256 } from './utils/sha256';
8
+ export { bufferize } from './utils/bufferizer';
9
+ export { required, _required } from './utils/required';
10
+ export { forgeToString, stringToForge } from './utils/forge_converter';
11
+ export { crosschain_operation, transaction, web2_request } from './utils/skeletons';
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.web2_request = exports.transaction = exports.crosschain_operation = exports.stringToForge = exports.forgeToString = exports._required = exports.required = exports.bufferize = exports.sha256 = exports.prepareXMPayload = exports.XMTransactions = exports.prepareWeb2Payload = exports.DemosWebAuth = exports.RSA = exports.DemosTransactions = exports.demos = void 0;
4
+ var demos_1 = require("./demos");
5
+ Object.defineProperty(exports, "demos", { enumerable: true, get: function () { return demos_1.demos; } });
6
+ var DemosTransactions_1 = require("./DemosTransactions");
7
+ Object.defineProperty(exports, "DemosTransactions", { enumerable: true, get: function () { return DemosTransactions_1.DemosTransactions; } });
8
+ var rsa_1 = require("./rsa");
9
+ Object.defineProperty(exports, "RSA", { enumerable: true, get: function () { return rsa_1.RSA; } });
10
+ var DemosWebAuth_1 = require("./DemosWebAuth");
11
+ Object.defineProperty(exports, "DemosWebAuth", { enumerable: true, get: function () { return DemosWebAuth_1.DemosWebAuth; } });
12
+ var Web2Transactions_1 = require("./Web2Transactions");
13
+ Object.defineProperty(exports, "prepareWeb2Payload", { enumerable: true, get: function () { return Web2Transactions_1.prepareWeb2Payload; } });
14
+ var XMTransactions_1 = require("./XMTransactions");
15
+ Object.defineProperty(exports, "XMTransactions", { enumerable: true, get: function () { return XMTransactions_1.XMTransactions; } });
16
+ Object.defineProperty(exports, "prepareXMPayload", { enumerable: true, get: function () { return XMTransactions_1.prepareXMPayload; } });
17
+ // Utils
18
+ var sha256_1 = require("./utils/sha256");
19
+ Object.defineProperty(exports, "sha256", { enumerable: true, get: function () { return sha256_1.sha256; } });
20
+ var bufferizer_1 = require("./utils/bufferizer");
21
+ Object.defineProperty(exports, "bufferize", { enumerable: true, get: function () { return bufferizer_1.bufferize; } });
22
+ var required_1 = require("./utils/required");
23
+ Object.defineProperty(exports, "required", { enumerable: true, get: function () { return required_1.required; } });
24
+ Object.defineProperty(exports, "_required", { enumerable: true, get: function () { return required_1._required; } });
25
+ var forge_converter_1 = require("./utils/forge_converter");
26
+ Object.defineProperty(exports, "forgeToString", { enumerable: true, get: function () { return forge_converter_1.forgeToString; } });
27
+ Object.defineProperty(exports, "stringToForge", { enumerable: true, get: function () { return forge_converter_1.stringToForge; } });
28
+ var skeletons_1 = require("./utils/skeletons");
29
+ Object.defineProperty(exports, "crosschain_operation", { enumerable: true, get: function () { return skeletons_1.crosschain_operation; } });
30
+ Object.defineProperty(exports, "transaction", { enumerable: true, get: function () { return skeletons_1.transaction; } });
31
+ Object.defineProperty(exports, "web2_request", { enumerable: true, get: function () { return skeletons_1.web2_request; } });
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/websdk/index.ts"],"names":[],"mappings":";;;AAAA,iCAA+B;AAAtB,8FAAA,KAAK,OAAA;AACd,yDAAuD;AAA9C,sHAAA,iBAAiB,OAAA;AAE1B,6BAA2B;AAAlB,0FAAA,GAAG,OAAA;AACZ,+CAA6C;AAApC,4GAAA,YAAY,OAAA;AAErB,uDAAuD;AAA9C,sHAAA,kBAAkB,OAAA;AAC3B,mDAAmE;AAA1D,gHAAA,cAAc,OAAA;AAAE,kHAAA,gBAAgB,OAAA;AAEzC,QAAQ;AACR,yCAAuC;AAA9B,gGAAA,MAAM,OAAA;AACf,iDAA8C;AAArC,uGAAA,SAAS,OAAA;AAClB,6CAAsD;AAA7C,oGAAA,QAAQ,OAAA;AAAE,qGAAA,SAAS,OAAA;AAC5B,2DAAsE;AAA7D,gHAAA,aAAa,OAAA;AAAE,gHAAA,aAAa,OAAA;AACrC,+CAAmF;AAA1E,iHAAA,oBAAoB,OAAA;AAAE,wGAAA,WAAW,OAAA;AAAE,yGAAA,YAAY,OAAA"}
@@ -0,0 +1,19 @@
1
+ import forge from 'node-forge';
2
+ export declare class RSA {
3
+ static _instance: RSA | null;
4
+ keypair: forge.pki.rsa.KeyPair | null;
5
+ stringified_keypair: string;
6
+ constructor();
7
+ static getInstance(): RSA;
8
+ refresh(): void;
9
+ PRNG(seed: any): forge.random.Random;
10
+ seedForger(pre_seed: any): string;
11
+ self_encrypt(message: string): string;
12
+ /**
13
+ * @param {forge.pki.rsa.PublicKey} public_key
14
+ */
15
+ encrypt(public_key: {
16
+ encrypt: (arg0: any) => any;
17
+ }, message: string): string;
18
+ decrypt(message: any): string;
19
+ }
@@ -0,0 +1,86 @@
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.RSA = void 0;
7
+ const node_forge_1 = __importDefault(require("node-forge"));
8
+ const DemosWebAuth_1 = require("./DemosWebAuth");
9
+ const required_1 = require("./utils/required");
10
+ // INFO This class is to be used as part of DemosWebAuthenticator (e.g. DemosWebAuth.getInstance().rsa().refresh())
11
+ class RSA {
12
+ constructor() {
13
+ this.keypair = null;
14
+ this.stringified_keypair = "";
15
+ }
16
+ // INFO Singleton pattern
17
+ static getInstance() {
18
+ if (!RSA._instance) {
19
+ RSA._instance = new RSA();
20
+ }
21
+ return RSA._instance;
22
+ }
23
+ // INFO Generating, if possible, a RSA keypair
24
+ // NOTE Derived from DemosWebAuth keypairs
25
+ refresh() {
26
+ let pre_seed = null;
27
+ if (DemosWebAuth_1.DemosWebAuth.getInstance().stringified_keypair) {
28
+ pre_seed = DemosWebAuth_1.DemosWebAuth.getInstance().stringified_keypair.privateKey;
29
+ }
30
+ else
31
+ throw new Error('RSA Keypair cannot be generated without a proper ECDSA authentication');
32
+ // If we are here, we can proceed and fill DemosWebAuth instance
33
+ const seed = this.seedForger(pre_seed);
34
+ const pseudorandom = this.PRNG(seed);
35
+ this.keypair = node_forge_1.default.pki.rsa.generateKeyPair({ bits: 4096, prng: pseudorandom });
36
+ this.stringified_keypair = JSON.stringify(this.keypair);
37
+ }
38
+ // INFO Generating a pseudo-random from a seed
39
+ PRNG(seed) {
40
+ const prng = node_forge_1.default.random.createInstance();
41
+ prng.seedFileSync = () => seed;
42
+ return prng;
43
+ }
44
+ // INFO Generating a seed in the right format from a string
45
+ seedForger(pre_seed) {
46
+ const md = node_forge_1.default.md.sha256.create();
47
+ md.update(pre_seed);
48
+ return md.digest().toHex();
49
+ }
50
+ // INFO Encrypting a message using the RSA keypair
51
+ self_encrypt(message) {
52
+ if (!(0, required_1.required)(this.keypair)) {
53
+ throw new Error('RSA Keypair cannot be generated without a proper ECDSA keypair');
54
+ }
55
+ if (!(typeof (message) === 'string')) {
56
+ message = JSON.stringify(message);
57
+ }
58
+ const encoded = node_forge_1.default.util.encode64(message);
59
+ const encrypted = this.keypair.publicKey.encrypt(encoded);
60
+ return node_forge_1.default.util.encode64(encrypted);
61
+ }
62
+ /**
63
+ * @param {forge.pki.rsa.PublicKey} public_key
64
+ */
65
+ encrypt(public_key, message) {
66
+ if (!(typeof (message) === 'string')) {
67
+ message = JSON.stringify(message);
68
+ }
69
+ const encoded = node_forge_1.default.util.encode64(message);
70
+ const encrypted = public_key.encrypt(encoded);
71
+ return node_forge_1.default.util.encode64(encrypted);
72
+ }
73
+ // INFO Decrypting a message using the RSA keypair
74
+ decrypt(message) {
75
+ if (!(0, required_1.required)(this.keypair)) {
76
+ throw new Error('RSA Keypair cannot be generated without a proper ECDSA keypair');
77
+ }
78
+ const debased_encrypted = node_forge_1.default.util.decode64(message);
79
+ const raw_decrypted = this.keypair.privateKey.decrypt(debased_encrypted);
80
+ const decrypted = node_forge_1.default.util.decode64(raw_decrypted);
81
+ return decrypted;
82
+ }
83
+ }
84
+ exports.RSA = RSA;
85
+ RSA._instance = null;
86
+ //# sourceMappingURL=rsa.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"r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,CAAA;QAC7C,OAAO,oBAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;IACvC,CAAC;IAED,kDAAkD;IAClD,OAAO,CAAE,OAAY;QACnB,IAAI,CAAC,IAAA,mBAAQ,EAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAA;QACnF,CAAC;QAED,MAAM,iBAAiB,GAAG,oBAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;QACtD,MAAM,aAAa,GAAG,IAAI,CAAC,OAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAA;QACzE,MAAM,SAAS,GAAG,oBAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAA;QACpD,OAAO,SAAS,CAAA;IAClB,CAAC;;AA9EH,kBA+EC;AA9EQ,aAAS,GAAe,IAAI,AAAnB,CAAmB"}
@@ -0,0 +1,4 @@
1
+ export interface IBufferized {
2
+ type: string;
3
+ data: number[];
4
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IBuffer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IBuffer.js","sourceRoot":"","sources":["../../../../src/websdk/types/IBuffer.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ /// <reference types="node" />
2
+ export interface IKeyPair {
3
+ privateKey: Buffer | Uint8Array | null | false;
4
+ publicKey: Buffer | Uint8Array | null | false;
5
+ }
6
+ export interface IStringifiedKeyPair {
7
+ privateKey: string;
8
+ publicKey: string;
9
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=KeyPair.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KeyPair.js","sourceRoot":"","sources":["../../../../src/websdk/types/KeyPair.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import { IBufferized } from '../types/IBuffer';
2
+ /**
3
+ * Converting uint8arrays into node.js-like objects representing a Buffer
4
+ * @date 2/9/2023 - 04:47:48
5
+ *
6
+ * @param {*} uint8array
7
+ * @returns {{ type: string; data: {}; }}
8
+ */
9
+ export declare function bufferize(uint8array: Uint8Array): IBufferized;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.bufferize = void 0;
4
+ /**
5
+ * Converting uint8arrays into node.js-like objects representing a Buffer
6
+ * @date 2/9/2023 - 04:47:48
7
+ *
8
+ * @param {*} uint8array
9
+ * @returns {{ type: string; data: {}; }}
10
+ */
11
+ function bufferize(uint8array) {
12
+ const buffer = { type: 'Buffer', data: [] };
13
+ for (let i = 0; i < uint8array.length; i++) {
14
+ buffer.data.push(uint8array[i]);
15
+ }
16
+ return buffer;
17
+ }
18
+ exports.bufferize = bufferize;
19
+ //# sourceMappingURL=bufferizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bufferizer.js","sourceRoot":"","sources":["../../../../src/websdk/utils/bufferizer.ts"],"names":[],"mappings":";;;AAEA;;;;;;GAMG;AACH,SAAgB,SAAS,CAAC,UAAsB;IAC5C,MAAM,MAAM,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAY,EAAE,EAAE,CAAA;IACrD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACzC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;IACnC,CAAC;IACD,OAAO,MAAM,CAAA;AACjB,CAAC;AAND,8BAMC"}