@aws-amplify/react-native 1.0.1-api-v6-rebase-2023-10-11.3fb8920.0

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 (115) hide show
  1. package/AmplifyRTNCore.podspec +35 -0
  2. package/LICENSE +201 -0
  3. package/android/build.gradle +85 -0
  4. package/android/gradle.properties +4 -0
  5. package/android/src/main/AndroidManifest.xml +4 -0
  6. package/android/src/main/kotlin/com/amazonaws/amplify/rtncore/AmplifyRTNCoreModule.kt +29 -0
  7. package/android/src/main/kotlin/com/amazonaws/amplify/rtncore/AmplifyRTNCorePackage.kt +17 -0
  8. package/android/src/main/kotlin/com/amazonaws/amplify/rtncore/BigInteger.kt +65 -0
  9. package/ios/AmplifyRTNCore-Bridging-Header.h +5 -0
  10. package/ios/AmplifyRTNCore.mm +21 -0
  11. package/ios/AmplifyRTNCore.swift +29 -0
  12. package/ios/AmplifyRTNCore.xcodeproj/project.pbxproj +283 -0
  13. package/ios/AmplifyRTNCore.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
  14. package/ios/BigInteger.swift +78 -0
  15. package/ios/JKBigInteger/JKBigDecimal.h +40 -0
  16. package/ios/JKBigInteger/JKBigDecimal.m +224 -0
  17. package/ios/JKBigInteger/JKBigInteger.h +58 -0
  18. package/ios/JKBigInteger/JKBigInteger.m +419 -0
  19. package/ios/JKBigInteger/LICENSE.txt +18 -0
  20. package/ios/JKBigInteger/LibTomMath/tommath.c +6925 -0
  21. package/ios/JKBigInteger/LibTomMath/tommath.h +584 -0
  22. package/ios/JKBigInteger/LibTomMath/tommath_class.h +999 -0
  23. package/ios/JKBigInteger/LibTomMath/tommath_superclass.h +76 -0
  24. package/lib/apis/computeModPow.d.ts +2 -0
  25. package/lib/apis/computeModPow.js +9 -0
  26. package/lib/apis/computeModPow.js.map +1 -0
  27. package/lib/apis/computeS.d.ts +2 -0
  28. package/lib/apis/computeS.js +9 -0
  29. package/lib/apis/computeS.js.map +1 -0
  30. package/lib/apis/index.d.ts +2 -0
  31. package/lib/apis/index.js +10 -0
  32. package/lib/apis/index.js.map +1 -0
  33. package/lib/index.d.ts +2 -0
  34. package/lib/index.js +16 -0
  35. package/lib/index.js.map +1 -0
  36. package/lib/moduleLoaders/index.d.ts +6 -0
  37. package/lib/moduleLoaders/index.js +18 -0
  38. package/lib/moduleLoaders/index.js.map +1 -0
  39. package/lib/moduleLoaders/loadAsyncStorage.d.ts +2 -0
  40. package/lib/moduleLoaders/loadAsyncStorage.js +26 -0
  41. package/lib/moduleLoaders/loadAsyncStorage.js.map +1 -0
  42. package/lib/moduleLoaders/loadBase64.d.ts +5 -0
  43. package/lib/moduleLoaders/loadBase64.js +9 -0
  44. package/lib/moduleLoaders/loadBase64.js.map +1 -0
  45. package/lib/moduleLoaders/loadBuffer.d.ts +22 -0
  46. package/lib/moduleLoaders/loadBuffer.js +9 -0
  47. package/lib/moduleLoaders/loadBuffer.js.map +1 -0
  48. package/lib/moduleLoaders/loadGetRandomValues.d.ts +1 -0
  49. package/lib/moduleLoaders/loadGetRandomValues.js +21 -0
  50. package/lib/moduleLoaders/loadGetRandomValues.js.map +1 -0
  51. package/lib/moduleLoaders/loadNetInfo.d.ts +4 -0
  52. package/lib/moduleLoaders/loadNetInfo.js +26 -0
  53. package/lib/moduleLoaders/loadNetInfo.js.map +1 -0
  54. package/lib/moduleLoaders/loadUrlPolyfill.d.ts +1 -0
  55. package/lib/moduleLoaders/loadUrlPolyfill.js +21 -0
  56. package/lib/moduleLoaders/loadUrlPolyfill.js.map +1 -0
  57. package/lib/nativeModule.d.ts +2 -0
  58. package/lib/nativeModule.js +18 -0
  59. package/lib/nativeModule.js.map +1 -0
  60. package/lib/types.d.ts +15 -0
  61. package/lib/types.js +5 -0
  62. package/lib/types.js.map +1 -0
  63. package/lib-esm/apis/computeModPow.d.ts +2 -0
  64. package/lib-esm/apis/computeModPow.js +5 -0
  65. package/lib-esm/apis/computeModPow.js.map +1 -0
  66. package/lib-esm/apis/computeS.d.ts +2 -0
  67. package/lib-esm/apis/computeS.js +5 -0
  68. package/lib-esm/apis/computeS.js.map +1 -0
  69. package/lib-esm/apis/index.d.ts +2 -0
  70. package/lib-esm/apis/index.js +5 -0
  71. package/lib-esm/apis/index.js.map +1 -0
  72. package/lib-esm/index.d.ts +2 -0
  73. package/lib-esm/index.js +5 -0
  74. package/lib-esm/index.js.map +1 -0
  75. package/lib-esm/moduleLoaders/index.d.ts +6 -0
  76. package/lib-esm/moduleLoaders/index.js +9 -0
  77. package/lib-esm/moduleLoaders/index.js.map +1 -0
  78. package/lib-esm/moduleLoaders/loadAsyncStorage.d.ts +2 -0
  79. package/lib-esm/moduleLoaders/loadAsyncStorage.js +22 -0
  80. package/lib-esm/moduleLoaders/loadAsyncStorage.js.map +1 -0
  81. package/lib-esm/moduleLoaders/loadBase64.d.ts +5 -0
  82. package/lib-esm/moduleLoaders/loadBase64.js +5 -0
  83. package/lib-esm/moduleLoaders/loadBase64.js.map +1 -0
  84. package/lib-esm/moduleLoaders/loadBuffer.d.ts +22 -0
  85. package/lib-esm/moduleLoaders/loadBuffer.js +5 -0
  86. package/lib-esm/moduleLoaders/loadBuffer.js.map +1 -0
  87. package/lib-esm/moduleLoaders/loadGetRandomValues.d.ts +1 -0
  88. package/lib-esm/moduleLoaders/loadGetRandomValues.js +17 -0
  89. package/lib-esm/moduleLoaders/loadGetRandomValues.js.map +1 -0
  90. package/lib-esm/moduleLoaders/loadNetInfo.d.ts +4 -0
  91. package/lib-esm/moduleLoaders/loadNetInfo.js +22 -0
  92. package/lib-esm/moduleLoaders/loadNetInfo.js.map +1 -0
  93. package/lib-esm/moduleLoaders/loadUrlPolyfill.d.ts +1 -0
  94. package/lib-esm/moduleLoaders/loadUrlPolyfill.js +17 -0
  95. package/lib-esm/moduleLoaders/loadUrlPolyfill.js.map +1 -0
  96. package/lib-esm/nativeModule.d.ts +2 -0
  97. package/lib-esm/nativeModule.js +15 -0
  98. package/lib-esm/nativeModule.js.map +1 -0
  99. package/lib-esm/types.d.ts +15 -0
  100. package/lib-esm/types.js +4 -0
  101. package/lib-esm/types.js.map +1 -0
  102. package/package.json +67 -0
  103. package/src/apis/computeModPow.ts +8 -0
  104. package/src/apis/computeS.ts +8 -0
  105. package/src/apis/index.ts +5 -0
  106. package/src/index.ts +12 -0
  107. package/src/moduleLoaders/index.ts +9 -0
  108. package/src/moduleLoaders/loadAsyncStorage.ts +29 -0
  109. package/src/moduleLoaders/loadBase64.ts +6 -0
  110. package/src/moduleLoaders/loadBuffer.ts +6 -0
  111. package/src/moduleLoaders/loadGetRandomValues.ts +19 -0
  112. package/src/moduleLoaders/loadNetInfo.ts +31 -0
  113. package/src/moduleLoaders/loadUrlPolyfill.ts +19 -0
  114. package/src/nativeModule.ts +22 -0
  115. package/src/types.ts +19 -0
@@ -0,0 +1,17 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export const loadGetRandomValues = () => {
4
+ try {
5
+ // metro bundler requires static string for loading module.
6
+ // See: https://facebook.github.io/metro/docs/configuration/#dynamicdepsinpackages
7
+ require('react-native-get-random-values');
8
+ }
9
+ catch (e) {
10
+ // The error parsing logic cannot be extract as with metro the `require`
11
+ // would be confused when there is a `import` in the same file importing
12
+ // another module and that causes error
13
+ const message = e.message.replace(/undefined/g, '@react-native-community/netinfo');
14
+ throw new Error(message);
15
+ }
16
+ };
17
+ //# sourceMappingURL=loadGetRandomValues.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadGetRandomValues.js","sourceRoot":"","sources":["../../src/moduleLoaders/loadGetRandomValues.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACvC,IAAI;QACH,2DAA2D;QAC3D,kFAAkF;QAClF,OAAO,CAAC,gCAAgC,CAAC,CAAC;KAC1C;IAAC,OAAO,CAAC,EAAE;QACX,wEAAwE;QACxE,wEAAwE;QACxE,uCAAuC;QACvC,MAAM,OAAO,GAAI,CAAW,CAAC,OAAO,CAAC,OAAO,CAC3C,YAAY,EACZ,iCAAiC,CACjC,CAAC;QACF,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;KACzB;AACF,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type NetInfo from '@react-native-community/netinfo';
2
+ type NetInfoModule = typeof NetInfo;
3
+ export declare const loadNetInfo: () => NetInfoModule;
4
+ export {};
@@ -0,0 +1,22 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export const loadNetInfo = () => {
4
+ try {
5
+ // metro bundler requires static string for loading module.
6
+ // See: https://facebook.github.io/metro/docs/configuration/#dynamicdepsinpackages
7
+ const module = require('@react-native-community/netinfo')
8
+ ?.default;
9
+ if (module) {
10
+ return module;
11
+ }
12
+ throw new Error('Ensure `@react-native-community/netinfo` is installed and linked.');
13
+ }
14
+ catch (e) {
15
+ // The error parsing logic cannot be extract as with metro the `require`
16
+ // would be confused when there is a `import` in the same file importing
17
+ // another module and that causes error
18
+ const message = e.message.replace(/undefined/g, '@react-native-community/netinfo');
19
+ throw new Error(message);
20
+ }
21
+ };
22
+ //# sourceMappingURL=loadNetInfo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadNetInfo.js","sourceRoot":"","sources":["../../src/moduleLoaders/loadNetInfo.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAMtC,MAAM,CAAC,MAAM,WAAW,GAAG,GAAkB,EAAE;IAC9C,IAAI;QACH,2DAA2D;QAC3D,kFAAkF;QAClF,MAAM,MAAM,GAAG,OAAO,CAAC,iCAAiC,CAAC;YACxD,EAAE,OAAwB,CAAC;QAC5B,IAAI,MAAM,EAAE;YACX,OAAO,MAAM,CAAC;SACd;QAED,MAAM,IAAI,KAAK,CACd,mEAAmE,CACnE,CAAC;KACF;IAAC,OAAO,CAAC,EAAE;QACX,wEAAwE;QACxE,wEAAwE;QACxE,uCAAuC;QACvC,MAAM,OAAO,GAAI,CAAW,CAAC,OAAO,CAAC,OAAO,CAC3C,YAAY,EACZ,iCAAiC,CACjC,CAAC;QACF,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;KACzB;AACF,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const loadUrlPolyfill: () => void;
@@ -0,0 +1,17 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export const loadUrlPolyfill = () => {
4
+ try {
5
+ // metro bundler requires static string for loading module.
6
+ // See: https://facebook.github.io/metro/docs/configuration/#dynamicdepsinpackages
7
+ require('react-native-url-polyfill/auto');
8
+ }
9
+ catch (e) {
10
+ // The error parsing logic cannot be extract as with metro the `require`
11
+ // would be confused when there is a `import` in the same file importing
12
+ // another module and that causes error
13
+ const message = e.message.replace(/undefined/g, '@react-native-community/netinfo');
14
+ throw new Error(message);
15
+ }
16
+ };
17
+ //# sourceMappingURL=loadUrlPolyfill.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadUrlPolyfill.js","sourceRoot":"","sources":["../../src/moduleLoaders/loadUrlPolyfill.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE;IACnC,IAAI;QACH,2DAA2D;QAC3D,kFAAkF;QAClF,OAAO,CAAC,gCAAgC,CAAC,CAAC;KAC1C;IAAC,OAAO,CAAC,EAAE;QACX,wEAAwE;QACxE,wEAAwE;QACxE,uCAAuC;QACvC,MAAM,OAAO,GAAI,CAAW,CAAC,OAAO,CAAC,OAAO,CAC3C,YAAY,EACZ,iCAAiC,CACjC,CAAC;QACF,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;KACzB;AACF,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { RTNCore } from './types';
2
+ export declare const nativeModule: RTNCore;
@@ -0,0 +1,15 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { NativeModules, Platform } from 'react-native';
4
+ const LINKING_ERROR = `The package '@aws-amplify/react-native' doesn't seem to be linked. Make sure: \n\n` +
5
+ Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
6
+ '- You rebuilt the app after installing the package\n' +
7
+ '- You are not using Expo Go\n';
8
+ export const nativeModule = NativeModules.AmplifyRTNCore
9
+ ? NativeModules.AmplifyRTNCore
10
+ : new Proxy({}, {
11
+ get() {
12
+ throw new Error(LINKING_ERROR);
13
+ },
14
+ });
15
+ //# sourceMappingURL=nativeModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nativeModule.js","sourceRoot":"","sources":["../src/nativeModule.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAGvD,MAAM,aAAa,GAClB,oFAAoF;IACpF,QAAQ,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,gCAAgC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACvE,sDAAsD;IACtD,+BAA+B,CAAC;AAEjC,MAAM,CAAC,MAAM,YAAY,GAAY,aAAa,CAAC,cAAc;IAChE,CAAC,CAAC,aAAa,CAAC,cAAc;IAC9B,CAAC,CAAC,IAAI,KAAK,CACT,EAAE,EACF;QACC,GAAG;YACF,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;QAChC,CAAC;KACD,CACA,CAAC"}
@@ -0,0 +1,15 @@
1
+ export interface RTNCore {
2
+ computeModPow(payload: {
3
+ base: string;
4
+ exponent: string;
5
+ divisor: string;
6
+ }): Promise<string>;
7
+ computeS(payload: {
8
+ g: string;
9
+ x: string;
10
+ k: string;
11
+ a: string;
12
+ b: string;
13
+ u: string;
14
+ }): Promise<string>;
15
+ }
@@ -0,0 +1,4 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export {};
4
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC"}
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@aws-amplify/react-native",
3
+ "version": "1.0.1-api-v6-rebase-2023-10-11.3fb8920.0+3fb8920",
4
+ "description": "React Native core module for aws-amplify",
5
+ "main": "./lib/index.js",
6
+ "module": "./lib-esm/index.js",
7
+ "typings": "./lib-esm/index.d.ts",
8
+ "sideEffects": false,
9
+ "publishConfig": {
10
+ "access": "public"
11
+ },
12
+ "scripts": {
13
+ "test": "tslint 'src/**/*.ts'",
14
+ "test:android": "./android/gradlew test -p ./android",
15
+ "build-with-test": "npm run clean && npm test && tsc",
16
+ "build:cjs": "rimraf lib && tsc -p ./tsconfig.build.json -m commonjs --outDir lib",
17
+ "build:esm": "rimraf lib-esm && tsc -p ./tsconfig.build.json -m esnext --outDir lib-esm",
18
+ "build:cjs:watch": "rimraf lib && tsc -p ./tsconfig.build.json -m commonjs --outDir lib --watch",
19
+ "build:esm:watch": "rimraf lib-esm && tsc -p ./tsconfig.build.json -m esnext --outDir lib-esm --watch",
20
+ "build": "npm run clean && npm run build:esm && npm run build:cjs",
21
+ "clean": "rimraf lib-esm lib dist",
22
+ "format": "echo \"Not implemented\"",
23
+ "lint": "tslint 'src/**/*.ts' && npm run ts-coverage",
24
+ "ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 88.21"
25
+ },
26
+ "dependencies": {
27
+ "base-64": "^1.0.0",
28
+ "buffer": "^6.0.3",
29
+ "react-native-url-polyfill": "^2.0.0"
30
+ },
31
+ "peerDependencies": {
32
+ "react-native": ">=0.70",
33
+ "react-native-get-random-values": ">=1.9.0"
34
+ },
35
+ "devDependencies": {
36
+ "@react-native-async-storage/async-storage": "^1.17.12",
37
+ "@react-native-community/netinfo": "4.7.0",
38
+ "@types/base-64": "1.0.0",
39
+ "@types/react-native": "0.70.0",
40
+ "react-native": "0.70.0",
41
+ "react-native-get-random-values": "1.9.0",
42
+ "typescript": "5.1.6"
43
+ },
44
+ "react-native": {
45
+ "./lib/index": "./lib-esm/index.js"
46
+ },
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "https://github.com/aws-amplify/amplify-js.git"
50
+ },
51
+ "author": "Amazon Web Services",
52
+ "license": "Apache-2.0",
53
+ "bugs": {
54
+ "url": "https://github.com/aws-amplify/amplify-js/issues"
55
+ },
56
+ "homepage": "https://docs.amplify.aws/",
57
+ "files": [
58
+ "Amplify*.podspec",
59
+ "android",
60
+ "ios",
61
+ "lib",
62
+ "lib-esm",
63
+ "src"
64
+ ],
65
+ "source": "src/index",
66
+ "gitHead": "3fb8920eb97bfbeb3cbb46f0ddbe86dcd5b43053"
67
+ }
@@ -0,0 +1,8 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { nativeModule } from '../nativeModule';
5
+ import { RTNCore } from '../types';
6
+
7
+ export const computeModPow: RTNCore['computeModPow'] = payload =>
8
+ nativeModule.computeModPow(payload);
@@ -0,0 +1,8 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { nativeModule } from '../nativeModule';
5
+ import { RTNCore } from '../types';
6
+
7
+ export const computeS: RTNCore['computeS'] = payload =>
8
+ nativeModule.computeS(payload);
@@ -0,0 +1,5 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export { computeModPow } from './computeModPow';
5
+ export { computeS } from './computeS';
package/src/index.ts ADDED
@@ -0,0 +1,12 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export { computeModPow, computeS } from './apis';
5
+ export {
6
+ loadAsyncStorage,
7
+ loadNetInfo,
8
+ loadBuffer,
9
+ loadUrlPolyfill,
10
+ loadGetRandomValues,
11
+ loadBase64,
12
+ } from './moduleLoaders';
@@ -0,0 +1,9 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export { loadAsyncStorage } from './loadAsyncStorage';
5
+ export { loadNetInfo } from './loadNetInfo';
6
+ export { loadBuffer } from './loadBuffer';
7
+ export { loadUrlPolyfill } from './loadUrlPolyfill';
8
+ export { loadGetRandomValues } from './loadGetRandomValues';
9
+ export { loadBase64 } from './loadBase64';
@@ -0,0 +1,29 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { AsyncStorageStatic } from '@react-native-async-storage/async-storage';
5
+
6
+ export const loadAsyncStorage = (): AsyncStorageStatic => {
7
+ try {
8
+ // metro bundler requires static string for loading module.
9
+ // See: https://facebook.github.io/metro/docs/configuration/#dynamicdepsinpackages
10
+ const module = require('@react-native-async-storage/async-storage')
11
+ ?.default as AsyncStorageStatic;
12
+ if (module) {
13
+ return module;
14
+ }
15
+
16
+ throw new Error(
17
+ 'Ensure `@react-native-async-storage/async-storage` is installed and linked.'
18
+ );
19
+ } catch (e) {
20
+ // The error parsing logic cannot be extract as with metro the `require`
21
+ // would be confused when there is a `import` in the same file importing
22
+ // another module and that causes error
23
+ const message = (e as Error).message.replace(
24
+ /undefined/g,
25
+ '@react-native-async-storage/async-storage'
26
+ );
27
+ throw new Error(message);
28
+ }
29
+ };
@@ -0,0 +1,6 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { decode, encode } from 'base-64';
5
+
6
+ export const loadBase64 = () => ({ decode, encode });
@@ -0,0 +1,6 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { Buffer } from 'buffer';
5
+
6
+ export const loadBuffer = () => Buffer;
@@ -0,0 +1,19 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export const loadGetRandomValues = () => {
5
+ try {
6
+ // metro bundler requires static string for loading module.
7
+ // See: https://facebook.github.io/metro/docs/configuration/#dynamicdepsinpackages
8
+ require('react-native-get-random-values');
9
+ } catch (e) {
10
+ // The error parsing logic cannot be extract as with metro the `require`
11
+ // would be confused when there is a `import` in the same file importing
12
+ // another module and that causes error
13
+ const message = (e as Error).message.replace(
14
+ /undefined/g,
15
+ '@react-native-community/netinfo'
16
+ );
17
+ throw new Error(message);
18
+ }
19
+ };
@@ -0,0 +1,31 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type NetInfo from '@react-native-community/netinfo';
5
+
6
+ type NetInfoModule = typeof NetInfo;
7
+
8
+ export const loadNetInfo = (): NetInfoModule => {
9
+ try {
10
+ // metro bundler requires static string for loading module.
11
+ // See: https://facebook.github.io/metro/docs/configuration/#dynamicdepsinpackages
12
+ const module = require('@react-native-community/netinfo')
13
+ ?.default as NetInfoModule;
14
+ if (module) {
15
+ return module;
16
+ }
17
+
18
+ throw new Error(
19
+ 'Ensure `@react-native-community/netinfo` is installed and linked.'
20
+ );
21
+ } catch (e) {
22
+ // The error parsing logic cannot be extract as with metro the `require`
23
+ // would be confused when there is a `import` in the same file importing
24
+ // another module and that causes error
25
+ const message = (e as Error).message.replace(
26
+ /undefined/g,
27
+ '@react-native-community/netinfo'
28
+ );
29
+ throw new Error(message);
30
+ }
31
+ };
@@ -0,0 +1,19 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export const loadUrlPolyfill = () => {
5
+ try {
6
+ // metro bundler requires static string for loading module.
7
+ // See: https://facebook.github.io/metro/docs/configuration/#dynamicdepsinpackages
8
+ require('react-native-url-polyfill/auto');
9
+ } catch (e) {
10
+ // The error parsing logic cannot be extract as with metro the `require`
11
+ // would be confused when there is a `import` in the same file importing
12
+ // another module and that causes error
13
+ const message = (e as Error).message.replace(
14
+ /undefined/g,
15
+ '@react-native-community/netinfo'
16
+ );
17
+ throw new Error(message);
18
+ }
19
+ };
@@ -0,0 +1,22 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { NativeModules, Platform } from 'react-native';
5
+ import { RTNCore } from './types';
6
+
7
+ const LINKING_ERROR =
8
+ `The package '@aws-amplify/react-native' doesn't seem to be linked. Make sure: \n\n` +
9
+ Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
10
+ '- You rebuilt the app after installing the package\n' +
11
+ '- You are not using Expo Go\n';
12
+
13
+ export const nativeModule: RTNCore = NativeModules.AmplifyRTNCore
14
+ ? NativeModules.AmplifyRTNCore
15
+ : new Proxy(
16
+ {},
17
+ {
18
+ get() {
19
+ throw new Error(LINKING_ERROR);
20
+ },
21
+ }
22
+ );
package/src/types.ts ADDED
@@ -0,0 +1,19 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export interface RTNCore {
5
+ computeModPow(payload: {
6
+ base: string;
7
+ exponent: string;
8
+ divisor: string;
9
+ }): Promise<string>;
10
+
11
+ computeS(payload: {
12
+ g: string;
13
+ x: string;
14
+ k: string;
15
+ a: string;
16
+ b: string;
17
+ u: string;
18
+ }): Promise<string>;
19
+ }