ucpiauthx 1.0.2

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.

Potentially problematic release.


This version of ucpiauthx might be problematic. Click here for more details.

Files changed (4) hide show
  1. package/README.md +3 -0
  2. package/abi.json +495 -0
  3. package/index.js +69 -0
  4. package/package.json +15 -0
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # authx
2
+ # xauth
3
+ # xauth
package/abi.json ADDED
@@ -0,0 +1,495 @@
1
+
2
+ [
3
+ {
4
+ "inputs": [
5
+ {
6
+ "internalType": "string",
7
+ "name": "organisation",
8
+ "type": "string"
9
+ },
10
+ {
11
+ "internalType": "bool",
12
+ "name": "_vote",
13
+ "type": "bool"
14
+ }
15
+ ],
16
+ "name": "addnode",
17
+ "outputs": [],
18
+ "stateMutability": "nonpayable",
19
+ "type": "function"
20
+ },
21
+ {
22
+ "inputs": [
23
+ {
24
+ "internalType": "bytes32",
25
+ "name": "jwthash",
26
+ "type": "bytes32"
27
+ }
28
+ ],
29
+ "name": "authrlogin",
30
+ "outputs": [],
31
+ "stateMutability": "nonpayable",
32
+ "type": "function"
33
+ },
34
+ {
35
+ "inputs": [
36
+ {
37
+ "internalType": "bytes32",
38
+ "name": "jwthash",
39
+ "type": "bytes32"
40
+ },
41
+ {
42
+ "internalType": "bytes32",
43
+ "name": "whois",
44
+ "type": "bytes32"
45
+ },
46
+ {
47
+ "internalType": "bytes[]",
48
+ "name": "_verifysigno",
49
+ "type": "bytes[]"
50
+ },
51
+ {
52
+ "internalType": "bytes[]",
53
+ "name": "_whoissigno",
54
+ "type": "bytes[]"
55
+ },
56
+ {
57
+ "internalType": "bytes[]",
58
+ "name": "addo",
59
+ "type": "bytes[]"
60
+ }
61
+ ],
62
+ "name": "authrsign",
63
+ "outputs": [],
64
+ "stateMutability": "nonpayable",
65
+ "type": "function"
66
+ },
67
+ {
68
+ "inputs": [
69
+ {
70
+ "internalType": "string",
71
+ "name": "org",
72
+ "type": "string"
73
+ },
74
+ {
75
+ "internalType": "string",
76
+ "name": "noderpc",
77
+ "type": "string"
78
+ }
79
+ ],
80
+ "stateMutability": "nonpayable",
81
+ "type": "constructor"
82
+ },
83
+ {
84
+ "anonymous": false,
85
+ "inputs": [
86
+ {
87
+ "indexed": false,
88
+ "internalType": "address",
89
+ "name": "nodeaddress",
90
+ "type": "address"
91
+ },
92
+ {
93
+ "indexed": false,
94
+ "internalType": "string",
95
+ "name": "organisation",
96
+ "type": "string"
97
+ }
98
+ ],
99
+ "name": "Nodeadd",
100
+ "type": "event"
101
+ },
102
+ {
103
+ "inputs": [
104
+ {
105
+ "internalType": "string",
106
+ "name": "organisation",
107
+ "type": "string"
108
+ },
109
+ {
110
+ "internalType": "string",
111
+ "name": "noderpc",
112
+ "type": "string"
113
+ }
114
+ ],
115
+ "name": "nodeaddreq",
116
+ "outputs": [],
117
+ "stateMutability": "nonpayable",
118
+ "type": "function"
119
+ },
120
+ {
121
+ "inputs": [
122
+ {
123
+ "internalType": "bytes32",
124
+ "name": "",
125
+ "type": "bytes32"
126
+ }
127
+ ],
128
+ "name": "addidhash",
129
+ "outputs": [
130
+ {
131
+ "internalType": "bytes32",
132
+ "name": "",
133
+ "type": "bytes32"
134
+ }
135
+ ],
136
+ "stateMutability": "view",
137
+ "type": "function"
138
+ },
139
+ {
140
+ "inputs": [
141
+ {
142
+ "internalType": "address",
143
+ "name": "",
144
+ "type": "address"
145
+ }
146
+ ],
147
+ "name": "addjhash",
148
+ "outputs": [
149
+ {
150
+ "internalType": "bytes32",
151
+ "name": "",
152
+ "type": "bytes32"
153
+ }
154
+ ],
155
+ "stateMutability": "view",
156
+ "type": "function"
157
+ },
158
+ {
159
+ "inputs": [],
160
+ "name": "genesisnode",
161
+ "outputs": [
162
+ {
163
+ "internalType": "string",
164
+ "name": "",
165
+ "type": "string"
166
+ }
167
+ ],
168
+ "stateMutability": "view",
169
+ "type": "function"
170
+ },
171
+ {
172
+ "inputs": [
173
+ {
174
+ "internalType": "string",
175
+ "name": "",
176
+ "type": "string"
177
+ }
178
+ ],
179
+ "name": "ifvoted",
180
+ "outputs": [
181
+ {
182
+ "internalType": "bool",
183
+ "name": "",
184
+ "type": "bool"
185
+ }
186
+ ],
187
+ "stateMutability": "view",
188
+ "type": "function"
189
+ },
190
+ {
191
+ "inputs": [
192
+ {
193
+ "internalType": "bytes32",
194
+ "name": "",
195
+ "type": "bytes32"
196
+ }
197
+ ],
198
+ "name": "jhashadd",
199
+ "outputs": [
200
+ {
201
+ "internalType": "address",
202
+ "name": "",
203
+ "type": "address"
204
+ }
205
+ ],
206
+ "stateMutability": "view",
207
+ "type": "function"
208
+ },
209
+ {
210
+ "inputs": [
211
+ {
212
+ "internalType": "uint8",
213
+ "name": "i",
214
+ "type": "uint8"
215
+ }
216
+ ],
217
+ "name": "nodeatindex",
218
+ "outputs": [
219
+ {
220
+ "internalType": "string",
221
+ "name": "",
222
+ "type": "string"
223
+ }
224
+ ],
225
+ "stateMutability": "view",
226
+ "type": "function"
227
+ },
228
+ {
229
+ "inputs": [],
230
+ "name": "nodecount",
231
+ "outputs": [
232
+ {
233
+ "internalType": "uint256",
234
+ "name": "",
235
+ "type": "uint256"
236
+ }
237
+ ],
238
+ "stateMutability": "view",
239
+ "type": "function"
240
+ },
241
+ {
242
+ "inputs": [
243
+ {
244
+ "internalType": "string",
245
+ "name": "",
246
+ "type": "string"
247
+ }
248
+ ],
249
+ "name": "nodereplacer",
250
+ "outputs": [
251
+ {
252
+ "internalType": "bool",
253
+ "name": "",
254
+ "type": "bool"
255
+ }
256
+ ],
257
+ "stateMutability": "view",
258
+ "type": "function"
259
+ },
260
+ {
261
+ "inputs": [
262
+ {
263
+ "internalType": "uint256",
264
+ "name": "",
265
+ "type": "uint256"
266
+ }
267
+ ],
268
+ "name": "nodes",
269
+ "outputs": [
270
+ {
271
+ "internalType": "address",
272
+ "name": "nodeaddress",
273
+ "type": "address"
274
+ },
275
+ {
276
+ "internalType": "string",
277
+ "name": "organisation",
278
+ "type": "string"
279
+ },
280
+ {
281
+ "internalType": "string",
282
+ "name": "noderpc",
283
+ "type": "string"
284
+ }
285
+ ],
286
+ "stateMutability": "view",
287
+ "type": "function"
288
+ },
289
+ {
290
+ "inputs": [
291
+ {
292
+ "internalType": "string",
293
+ "name": "",
294
+ "type": "string"
295
+ }
296
+ ],
297
+ "name": "nodevote",
298
+ "outputs": [
299
+ {
300
+ "internalType": "uint256",
301
+ "name": "yesvote",
302
+ "type": "uint256"
303
+ },
304
+ {
305
+ "internalType": "uint256",
306
+ "name": "novote",
307
+ "type": "uint256"
308
+ }
309
+ ],
310
+ "stateMutability": "view",
311
+ "type": "function"
312
+ },
313
+ {
314
+ "inputs": [
315
+ {
316
+ "internalType": "string",
317
+ "name": "organisation",
318
+ "type": "string"
319
+ }
320
+ ],
321
+ "name": "op",
322
+ "outputs": [
323
+ {
324
+ "internalType": "uint256",
325
+ "name": "",
326
+ "type": "uint256"
327
+ }
328
+ ],
329
+ "stateMutability": "view",
330
+ "type": "function"
331
+ },
332
+ {
333
+ "inputs": [
334
+ {
335
+ "internalType": "string",
336
+ "name": "",
337
+ "type": "string"
338
+ }
339
+ ],
340
+ "name": "prenodeaddress",
341
+ "outputs": [
342
+ {
343
+ "internalType": "address",
344
+ "name": "",
345
+ "type": "address"
346
+ }
347
+ ],
348
+ "stateMutability": "view",
349
+ "type": "function"
350
+ },
351
+ {
352
+ "inputs": [
353
+ {
354
+ "internalType": "string",
355
+ "name": "",
356
+ "type": "string"
357
+ }
358
+ ],
359
+ "name": "prenoderpc",
360
+ "outputs": [
361
+ {
362
+ "internalType": "string",
363
+ "name": "",
364
+ "type": "string"
365
+ }
366
+ ],
367
+ "stateMutability": "view",
368
+ "type": "function"
369
+ },
370
+ {
371
+ "inputs": [
372
+ {
373
+ "internalType": "bytes32",
374
+ "name": "_ethSignedMessageHash",
375
+ "type": "bytes32"
376
+ },
377
+ {
378
+ "internalType": "bytes",
379
+ "name": "_signature",
380
+ "type": "bytes"
381
+ }
382
+ ],
383
+ "name": "recoverSigner",
384
+ "outputs": [
385
+ {
386
+ "internalType": "address",
387
+ "name": "",
388
+ "type": "address"
389
+ }
390
+ ],
391
+ "stateMutability": "pure",
392
+ "type": "function"
393
+ },
394
+ {
395
+ "inputs": [
396
+ {
397
+ "internalType": "address",
398
+ "name": "",
399
+ "type": "address"
400
+ }
401
+ ],
402
+ "name": "reversenodemap",
403
+ "outputs": [
404
+ {
405
+ "internalType": "string",
406
+ "name": "",
407
+ "type": "string"
408
+ }
409
+ ],
410
+ "stateMutability": "view",
411
+ "type": "function"
412
+ },
413
+ {
414
+ "inputs": [
415
+ {
416
+ "internalType": "bytes",
417
+ "name": "sig",
418
+ "type": "bytes"
419
+ }
420
+ ],
421
+ "name": "splitSignature",
422
+ "outputs": [
423
+ {
424
+ "internalType": "bytes32",
425
+ "name": "r",
426
+ "type": "bytes32"
427
+ },
428
+ {
429
+ "internalType": "bytes32",
430
+ "name": "s",
431
+ "type": "bytes32"
432
+ },
433
+ {
434
+ "internalType": "uint8",
435
+ "name": "v",
436
+ "type": "uint8"
437
+ }
438
+ ],
439
+ "stateMutability": "pure",
440
+ "type": "function"
441
+ },
442
+ {
443
+ "inputs": [
444
+ {
445
+ "internalType": "bytes[]",
446
+ "name": "_signo",
447
+ "type": "bytes[]"
448
+ }
449
+ ],
450
+ "name": "tmp",
451
+ "outputs": [
452
+ {
453
+ "internalType": "uint256",
454
+ "name": "",
455
+ "type": "uint256"
456
+ }
457
+ ],
458
+ "stateMutability": "pure",
459
+ "type": "function"
460
+ },
461
+ {
462
+ "inputs": [
463
+ {
464
+ "internalType": "bytes32",
465
+ "name": "_hashedMessage",
466
+ "type": "bytes32"
467
+ },
468
+ {
469
+ "internalType": "uint8",
470
+ "name": "_v",
471
+ "type": "uint8"
472
+ },
473
+ {
474
+ "internalType": "bytes32",
475
+ "name": "_r",
476
+ "type": "bytes32"
477
+ },
478
+ {
479
+ "internalType": "bytes32",
480
+ "name": "_s",
481
+ "type": "bytes32"
482
+ }
483
+ ],
484
+ "name": "VerifyMessage",
485
+ "outputs": [
486
+ {
487
+ "internalType": "address",
488
+ "name": "",
489
+ "type": "address"
490
+ }
491
+ ],
492
+ "stateMutability": "pure",
493
+ "type": "function"
494
+ }
495
+ ]
package/index.js ADDED
@@ -0,0 +1,69 @@
1
+ const Web3=require("web3");
2
+ const abi=require("./abi.json");
3
+ const web3 = new Web3('https://api.s0.ps.hmny.io');
4
+ const axios=require("axios");
5
+ const contract_address="0xdC092Ea4D6e83B303ff731ACdC6f4Bf3764Fb803";
6
+ const contract = new web3.eth.Contract(abi, contract_address);
7
+ async function nodecount(){
8
+ var v;
9
+ await contract.methods
10
+ .nodecount()
11
+ .call()
12
+ .then((c)=>{
13
+ v=c;
14
+ });
15
+ return v;
16
+ }
17
+ async function nodenameat(x){
18
+ var naam;
19
+ var nodecoun=await nodecount();
20
+ contract.methods
21
+ .nodeatindex(x)
22
+ .call()
23
+ .then((c)=>{
24
+ naam=c;
25
+ });
26
+ return naam;
27
+ }
28
+ async function noderpc(index){
29
+ var rc;
30
+ await contract.methods
31
+ .nodes(index)
32
+ .call()
33
+ .then((c)=>{
34
+ rc=c[2];
35
+ });
36
+ return rc;
37
+ }
38
+
39
+ async function allnoderpc(){
40
+ var no=await nodecount();
41
+ //console.log(no);
42
+ for(var x=0;x<no;x++){
43
+ var rpc=await noderpc(x);
44
+ console.log(rpc);
45
+ }
46
+ }
47
+
48
+ async function login(aud,jwt){
49
+ var no=await nodecount();
50
+ let rpcurl=[];
51
+ let jwtsign=[];
52
+ var fl;
53
+ for(var x=0;x<no;x++){
54
+ var rpc=await noderpc(x);
55
+ rpcurl.push(rpc+"/verify?jwt="+jwt+"&aud="+aud);
56
+ }
57
+ axios.all(rpcurl.map((endpoint) => axios.get(endpoint))).then(
58
+ (data) =>{
59
+ //console.log(data[0]);
60
+ var fullres=data.split("$");
61
+ jwtsign.push(fullres[0]);
62
+ whoissign.push(whoissign[0]);
63
+
64
+ }
65
+ );
66
+ return jwtsign[0];
67
+ }
68
+ login();
69
+ module.exports={nodecount,nodenameat,noderpc,allnoderpc,login}
package/package.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "ucpiauthx",
3
+ "version": "1.0.2",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "author": "Pranjal Maurya",
10
+ "license": "ISC",
11
+ "dependencies": {
12
+ "axios": "^1.1.2",
13
+ "web3": "^1.8.0"
14
+ }
15
+ }