UNPKG

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