-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenhance-rn.js
executable file
·50 lines (45 loc) · 1.07 KB
/
enhance-rn.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { NativeModules } from 'react-native';
import * as src from './src';
import BigInteger from './src/BigInteger';
export * from './src';
const { RNAWSCognito } = NativeModules;
BigInteger.prototype.modPow = function nativeModPow(e, m, callback) {
RNAWSCognito.computeModPow(
{
target: this.toString(16),
value: e.toString(16),
modifier: m.toString(16),
},
(err, result) => {
if (err) {
return callback(new Error(err), null);
}
const bigIntResult = new BigInteger(result, 16);
return callback(null, bigIntResult);
}
);
};
src.AuthenticationHelper.prototype.calculateS = function nativeComputeS(
xValue,
serverBValue,
callback
) {
RNAWSCognito.computeS(
{
g: this.g.toString(16),
x: xValue.toString(16),
k: this.k.toString(16),
a: this.smallAValue.toString(16),
b: serverBValue.toString(16),
u: this.UValue.toString(16),
},
(err, result) => {
if (err) {
return callback(new Error(err), null);
}
const bigIntResult = new BigInteger(result, 16);
return callback(null, bigIntResult);
}
);
return undefined;
};