UNPKG

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