@aws-amplify/react-native 0.0.0-changesets-preid-f620002-20260129130740

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 (149) hide show
  1. package/AmplifyRTNCore.podspec +41 -0
  2. package/README.md +3 -0
  3. package/android/build.gradle +103 -0
  4. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  5. package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  6. package/android/gradle.properties +5 -0
  7. package/android/gradlew +234 -0
  8. package/android/gradlew.bat +89 -0
  9. package/android/src/hasPackageName/AndroidManifest.xml +4 -0
  10. package/android/src/main/AndroidManifest.xml +3 -0
  11. package/android/src/main/kotlin/com/amazonaws/amplify/rtncore/AmplifyRTNCoreModule.kt +43 -0
  12. package/android/src/main/kotlin/com/amazonaws/amplify/rtncore/AmplifyRTNCorePackage.kt +17 -0
  13. package/android/src/main/kotlin/com/amazonaws/amplify/rtncore/BigInteger.kt +65 -0
  14. package/dist/cjs/apis/computeModPow.js +10 -0
  15. package/dist/cjs/apis/computeModPow.js.map +1 -0
  16. package/dist/cjs/apis/computeS.js +10 -0
  17. package/dist/cjs/apis/computeS.js.map +1 -0
  18. package/dist/cjs/apis/getDeviceName.js +10 -0
  19. package/dist/cjs/apis/getDeviceName.js.map +1 -0
  20. package/dist/cjs/apis/getIsNativeError.js +13 -0
  21. package/dist/cjs/apis/getIsNativeError.js.map +1 -0
  22. package/dist/cjs/apis/getOperatingSystem.js +10 -0
  23. package/dist/cjs/apis/getOperatingSystem.js.map +1 -0
  24. package/dist/cjs/apis/index.js +17 -0
  25. package/dist/cjs/apis/index.js.map +1 -0
  26. package/dist/cjs/index.js +24 -0
  27. package/dist/cjs/index.js.map +1 -0
  28. package/dist/cjs/moduleLoaders/index.js +27 -0
  29. package/dist/cjs/moduleLoaders/index.js.map +1 -0
  30. package/dist/cjs/moduleLoaders/loadAmplifyPushNotification.js +26 -0
  31. package/dist/cjs/moduleLoaders/loadAmplifyPushNotification.js.map +1 -0
  32. package/dist/cjs/moduleLoaders/loadAmplifyRtnPasskeys.js +26 -0
  33. package/dist/cjs/moduleLoaders/loadAmplifyRtnPasskeys.js.map +1 -0
  34. package/dist/cjs/moduleLoaders/loadAmplifyWebBrowser.js +26 -0
  35. package/dist/cjs/moduleLoaders/loadAmplifyWebBrowser.js.map +1 -0
  36. package/dist/cjs/moduleLoaders/loadAppState.js +10 -0
  37. package/dist/cjs/moduleLoaders/loadAppState.js.map +1 -0
  38. package/dist/cjs/moduleLoaders/loadAsyncStorage.js +27 -0
  39. package/dist/cjs/moduleLoaders/loadAsyncStorage.js.map +1 -0
  40. package/dist/cjs/moduleLoaders/loadBase64.js +10 -0
  41. package/dist/cjs/moduleLoaders/loadBase64.js.map +1 -0
  42. package/dist/cjs/moduleLoaders/loadBuffer.js +10 -0
  43. package/dist/cjs/moduleLoaders/loadBuffer.js.map +1 -0
  44. package/dist/cjs/moduleLoaders/loadGetRandomValues.js +22 -0
  45. package/dist/cjs/moduleLoaders/loadGetRandomValues.js.map +1 -0
  46. package/dist/cjs/moduleLoaders/loadNetInfo.js +27 -0
  47. package/dist/cjs/moduleLoaders/loadNetInfo.js.map +1 -0
  48. package/dist/cjs/moduleLoaders/loadUrlPolyfill.js +22 -0
  49. package/dist/cjs/moduleLoaders/loadUrlPolyfill.js.map +1 -0
  50. package/dist/cjs/nativeModule.js +19 -0
  51. package/dist/cjs/nativeModule.js.map +1 -0
  52. package/dist/cjs/types.js +6 -0
  53. package/dist/cjs/types.js.map +1 -0
  54. package/dist/esm/apis/computeModPow.d.ts +2 -0
  55. package/dist/esm/apis/computeModPow.mjs +8 -0
  56. package/dist/esm/apis/computeModPow.mjs.map +1 -0
  57. package/dist/esm/apis/computeS.d.ts +2 -0
  58. package/dist/esm/apis/computeS.mjs +8 -0
  59. package/dist/esm/apis/computeS.mjs.map +1 -0
  60. package/dist/esm/apis/getDeviceName.d.ts +2 -0
  61. package/dist/esm/apis/getDeviceName.mjs +8 -0
  62. package/dist/esm/apis/getDeviceName.mjs.map +1 -0
  63. package/dist/esm/apis/getIsNativeError.d.ts +9 -0
  64. package/dist/esm/apis/getIsNativeError.mjs +10 -0
  65. package/dist/esm/apis/getIsNativeError.mjs.map +1 -0
  66. package/dist/esm/apis/getOperatingSystem.d.ts +1 -0
  67. package/dist/esm/apis/getOperatingSystem.mjs +8 -0
  68. package/dist/esm/apis/getOperatingSystem.mjs.map +1 -0
  69. package/dist/esm/apis/index.d.ts +5 -0
  70. package/dist/esm/apis/index.mjs +6 -0
  71. package/dist/esm/apis/index.mjs.map +1 -0
  72. package/dist/esm/index.d.ts +2 -0
  73. package/dist/esm/index.mjs +16 -0
  74. package/dist/esm/index.mjs.map +1 -0
  75. package/dist/esm/moduleLoaders/index.d.ts +10 -0
  76. package/dist/esm/moduleLoaders/index.mjs +11 -0
  77. package/dist/esm/moduleLoaders/index.mjs.map +1 -0
  78. package/dist/esm/moduleLoaders/loadAmplifyPushNotification.d.ts +21 -0
  79. package/dist/esm/moduleLoaders/loadAmplifyPushNotification.mjs +23 -0
  80. package/dist/esm/moduleLoaders/loadAmplifyPushNotification.mjs.map +1 -0
  81. package/dist/esm/moduleLoaders/loadAmplifyRtnPasskeys.d.ts +1 -0
  82. package/dist/esm/moduleLoaders/loadAmplifyRtnPasskeys.mjs +23 -0
  83. package/dist/esm/moduleLoaders/loadAmplifyRtnPasskeys.mjs.map +1 -0
  84. package/dist/esm/moduleLoaders/loadAmplifyWebBrowser.d.ts +3 -0
  85. package/dist/esm/moduleLoaders/loadAmplifyWebBrowser.mjs +23 -0
  86. package/dist/esm/moduleLoaders/loadAmplifyWebBrowser.mjs.map +1 -0
  87. package/dist/esm/moduleLoaders/loadAppState.d.ts +1 -0
  88. package/dist/esm/moduleLoaders/loadAppState.mjs +8 -0
  89. package/dist/esm/moduleLoaders/loadAppState.mjs.map +1 -0
  90. package/dist/esm/moduleLoaders/loadAsyncStorage.d.ts +2 -0
  91. package/dist/esm/moduleLoaders/loadAsyncStorage.mjs +24 -0
  92. package/dist/esm/moduleLoaders/loadAsyncStorage.mjs.map +1 -0
  93. package/dist/esm/moduleLoaders/loadBase64.d.ts +5 -0
  94. package/dist/esm/moduleLoaders/loadBase64.mjs +8 -0
  95. package/dist/esm/moduleLoaders/loadBase64.mjs.map +1 -0
  96. package/dist/esm/moduleLoaders/loadBuffer.d.ts +21 -0
  97. package/dist/esm/moduleLoaders/loadBuffer.mjs +8 -0
  98. package/dist/esm/moduleLoaders/loadBuffer.mjs.map +1 -0
  99. package/dist/esm/moduleLoaders/loadGetRandomValues.d.ts +1 -0
  100. package/dist/esm/moduleLoaders/loadGetRandomValues.mjs +19 -0
  101. package/dist/esm/moduleLoaders/loadGetRandomValues.mjs.map +1 -0
  102. package/dist/esm/moduleLoaders/loadNetInfo.d.ts +4 -0
  103. package/dist/esm/moduleLoaders/loadNetInfo.mjs +24 -0
  104. package/dist/esm/moduleLoaders/loadNetInfo.mjs.map +1 -0
  105. package/dist/esm/moduleLoaders/loadUrlPolyfill.d.ts +1 -0
  106. package/dist/esm/moduleLoaders/loadUrlPolyfill.mjs +19 -0
  107. package/dist/esm/moduleLoaders/loadUrlPolyfill.mjs.map +1 -0
  108. package/dist/esm/nativeModule.d.ts +2 -0
  109. package/dist/esm/nativeModule.mjs +18 -0
  110. package/dist/esm/nativeModule.mjs.map +1 -0
  111. package/dist/esm/types.d.ts +16 -0
  112. package/dist/esm/types.mjs +2 -0
  113. package/dist/esm/types.mjs.map +1 -0
  114. package/ios/AmplifyRTNCore-Bridging-Header.h +5 -0
  115. package/ios/AmplifyRTNCore.mm +24 -0
  116. package/ios/AmplifyRTNCore.swift +45 -0
  117. package/ios/AmplifyRTNCore.xcodeproj/project.pbxproj +283 -0
  118. package/ios/AmplifyRTNCore.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
  119. package/ios/BigInteger.swift +78 -0
  120. package/ios/JKBigInteger/JKBigDecimal.h +40 -0
  121. package/ios/JKBigInteger/JKBigDecimal.m +224 -0
  122. package/ios/JKBigInteger/JKBigInteger.h +58 -0
  123. package/ios/JKBigInteger/JKBigInteger.m +419 -0
  124. package/ios/JKBigInteger/LICENSE.txt +18 -0
  125. package/ios/JKBigInteger/LibTomMath/tommath.c +6925 -0
  126. package/ios/JKBigInteger/LibTomMath/tommath.h +584 -0
  127. package/ios/JKBigInteger/LibTomMath/tommath_class.h +999 -0
  128. package/ios/JKBigInteger/LibTomMath/tommath_superclass.h +76 -0
  129. package/package.json +73 -0
  130. package/src/apis/computeModPow.ts +8 -0
  131. package/src/apis/computeS.ts +8 -0
  132. package/src/apis/getDeviceName.ts +8 -0
  133. package/src/apis/getIsNativeError.ts +18 -0
  134. package/src/apis/getOperatingSystem.ts +6 -0
  135. package/src/apis/index.ts +8 -0
  136. package/src/index.ts +22 -0
  137. package/src/moduleLoaders/index.ts +13 -0
  138. package/src/moduleLoaders/loadAmplifyPushNotification.ts +28 -0
  139. package/src/moduleLoaders/loadAmplifyRtnPasskeys.ts +28 -0
  140. package/src/moduleLoaders/loadAmplifyWebBrowser.ts +28 -0
  141. package/src/moduleLoaders/loadAppState.ts +6 -0
  142. package/src/moduleLoaders/loadAsyncStorage.ts +29 -0
  143. package/src/moduleLoaders/loadBase64.ts +6 -0
  144. package/src/moduleLoaders/loadBuffer.ts +6 -0
  145. package/src/moduleLoaders/loadGetRandomValues.ts +19 -0
  146. package/src/moduleLoaders/loadNetInfo.ts +31 -0
  147. package/src/moduleLoaders/loadUrlPolyfill.ts +19 -0
  148. package/src/nativeModule.ts +23 -0
  149. package/src/types.ts +21 -0
@@ -0,0 +1,76 @@
1
+ /* super class file for PK algos */
2
+
3
+ /* default ... include all MPI */
4
+ #define LTM_ALL
5
+
6
+ /* RSA only (does not support DH/DSA/ECC) */
7
+ /* #define SC_RSA_1 */
8
+
9
+ /* For reference.... On an Athlon64 optimizing for speed...
10
+
11
+ LTM's mpi.o with all functions [striped] is 142KiB in size.
12
+
13
+ */
14
+
15
+ /* Works for RSA only, mpi.o is 68KiB */
16
+ #ifdef SC_RSA_1
17
+ #define BN_MP_SHRINK_C
18
+ #define BN_MP_LCM_C
19
+ #define BN_MP_PRIME_RANDOM_EX_C
20
+ #define BN_MP_INVMOD_C
21
+ #define BN_MP_GCD_C
22
+ #define BN_MP_MOD_C
23
+ #define BN_MP_MULMOD_C
24
+ #define BN_MP_ADDMOD_C
25
+ #define BN_MP_EXPTMOD_C
26
+ #define BN_MP_SET_INT_C
27
+ #define BN_MP_INIT_MULTI_C
28
+ #define BN_MP_CLEAR_MULTI_C
29
+ #define BN_MP_UNSIGNED_BIN_SIZE_C
30
+ #define BN_MP_TO_UNSIGNED_BIN_C
31
+ #define BN_MP_MOD_D_C
32
+ #define BN_MP_PRIME_RABIN_MILLER_TRIALS_C
33
+ #define BN_REVERSE_C
34
+ #define BN_PRIME_TAB_C
35
+
36
+ /* other modifiers */
37
+ #define BN_MP_DIV_SMALL /* Slower division, not critical */
38
+
39
+ /* here we are on the last pass so we turn things off. The functions classes are still there
40
+ * but we remove them specifically from the build. This also invokes tweaks in functions
41
+ * like removing support for even moduli, etc...
42
+ */
43
+ #ifdef LTM_LAST
44
+ #undef BN_MP_TOOM_MUL_C
45
+ #undef BN_MP_TOOM_SQR_C
46
+ #undef BN_MP_KARATSUBA_MUL_C
47
+ #undef BN_MP_KARATSUBA_SQR_C
48
+ #undef BN_MP_REDUCE_C
49
+ #undef BN_MP_REDUCE_SETUP_C
50
+ #undef BN_MP_DR_IS_MODULUS_C
51
+ #undef BN_MP_DR_SETUP_C
52
+ #undef BN_MP_DR_REDUCE_C
53
+ #undef BN_MP_REDUCE_IS_2K_C
54
+ #undef BN_MP_REDUCE_2K_SETUP_C
55
+ #undef BN_MP_REDUCE_2K_C
56
+ #undef BN_S_MP_EXPTMOD_C
57
+ #undef BN_MP_DIV_3_C
58
+ #undef BN_S_MP_MUL_HIGH_DIGS_C
59
+ #undef BN_FAST_S_MP_MUL_HIGH_DIGS_C
60
+ #undef BN_FAST_MP_INVMOD_C
61
+
62
+ /* To safely undefine these you have to make sure your RSA key won't exceed the Comba threshold
63
+ * which is roughly 255 digits [7140 bits for 32-bit machines, 15300 bits for 64-bit machines]
64
+ * which means roughly speaking you can handle upto 2536-bit RSA keys with these defined without
65
+ * trouble.
66
+ */
67
+ #undef BN_S_MP_MUL_DIGS_C
68
+ #undef BN_S_MP_SQR_C
69
+ #undef BN_MP_MONTGOMERY_REDUCE_C
70
+ #endif
71
+
72
+ #endif
73
+
74
+ /* $Source$ */
75
+ /* $Revision: 0.36 $ */
76
+ /* $Date: 2005-08-01 16:37:28 +0000 $ */
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@aws-amplify/react-native",
3
+ "version": "0.0.0-changesets-preid-f620002-20260129130740",
4
+ "description": "React Native core module for aws-amplify",
5
+ "main": "./dist/cjs/index.js",
6
+ "module": "./dist/esm/index.mjs",
7
+ "react-native": "./dist/cjs/index.js",
8
+ "typings": "./dist/esm/index.d.ts",
9
+ "sideEffects": false,
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "scripts": {
14
+ "prepare:ios": "cd example && npx pod-install",
15
+ "prepare:android": "echo 'no-op'",
16
+ "test": "jest",
17
+ "test:ios": "echo 'no-op'",
18
+ "test:android": "cd ./example/android && ./gradlew test -i",
19
+ "build-with-test": "npm run clean && npm test && tsc",
20
+ "build:esm-cjs": "rollup --forceExit -c rollup.config.mjs",
21
+ "build:watch": "npm run build:esm-cjs -- --watch",
22
+ "build": "npm run clean && npm run build:esm-cjs",
23
+ "clean": "rimraf lib-esm lib dist",
24
+ "format": "echo \"Not implemented\"",
25
+ "lint": "eslint '**/*.{ts,tsx}' && npm run ts-coverage",
26
+ "lint:fix": "eslint '**/*.{ts,tsx}' --fix",
27
+ "ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 88.21"
28
+ },
29
+ "dependencies": {
30
+ "base-64": "^1.0.0",
31
+ "buffer": "^6.0.3",
32
+ "react-native-url-polyfill": "^3.0.0"
33
+ },
34
+ "peerDependencies": {
35
+ "@aws-amplify/rtn-passkeys": "0.0.0-changesets-preid-f620002-20260129130740",
36
+ "react-native": ">=0.70",
37
+ "react-native-get-random-values": ">=1.8.0"
38
+ },
39
+ "peerDependenciesMeta": {
40
+ "@aws-amplify/rtn-passkeys": {
41
+ "optional": true
42
+ }
43
+ },
44
+ "devDependencies": {
45
+ "@aws-amplify/rtn-passkeys": "0.0.0-changesets-preid-f620002-20260129130740",
46
+ "@aws-amplify/rtn-push-notification": "0.0.0-changesets-preid-f620002-20260129130740",
47
+ "@aws-amplify/rtn-web-browser": "0.0.0-changesets-preid-f620002-20260129130740",
48
+ "@react-native-async-storage/async-storage": "^1.17.12",
49
+ "@react-native-community/netinfo": "4.7.0",
50
+ "@types/base-64": "1.0.0",
51
+ "react-native": "0.72.17",
52
+ "react-native-get-random-values": "1.9.0"
53
+ },
54
+ "repository": {
55
+ "type": "git",
56
+ "url": "https://github.com/aws-amplify/amplify-js.git"
57
+ },
58
+ "author": "Amazon Web Services",
59
+ "license": "Apache-2.0",
60
+ "bugs": {
61
+ "url": "https://github.com/aws-amplify/amplify-js/issues"
62
+ },
63
+ "homepage": "https://docs.amplify.aws/",
64
+ "files": [
65
+ "Amplify*.podspec",
66
+ "android",
67
+ "ios",
68
+ "dist/cjs",
69
+ "dist/esm",
70
+ "src"
71
+ ],
72
+ "source": "src/index"
73
+ }
@@ -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,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 getDeviceName: RTNCore['getDeviceName'] = () =>
8
+ nativeModule.getDeviceName();
@@ -0,0 +1,18 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ interface NativeError extends Error {
5
+ code: string;
6
+ domain?: string;
7
+ userInfo?: Record<string, unknown>;
8
+ nativeStackIOS?: never[];
9
+ nativeStackAndroid?: Record<string, unknown>[];
10
+ }
11
+
12
+ export const getIsNativeError = (err: unknown): err is NativeError => {
13
+ return (
14
+ err instanceof Error &&
15
+ 'code' in err &&
16
+ ('nativeStackIOS' in err || 'nativeStackAndroid' in err)
17
+ );
18
+ };
@@ -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 { Platform } from 'react-native';
5
+
6
+ export const getOperatingSystem = () => Platform.OS;
@@ -0,0 +1,8 @@
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';
6
+ export { getOperatingSystem } from './getOperatingSystem';
7
+ export { getDeviceName } from './getDeviceName';
8
+ export { getIsNativeError } from './getIsNativeError';
package/src/index.ts ADDED
@@ -0,0 +1,22 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export {
5
+ computeModPow,
6
+ computeS,
7
+ getOperatingSystem,
8
+ getDeviceName,
9
+ getIsNativeError,
10
+ } from './apis';
11
+ export {
12
+ loadAmplifyRtnPasskeys,
13
+ loadAmplifyPushNotification,
14
+ loadAmplifyWebBrowser,
15
+ loadAsyncStorage,
16
+ loadNetInfo,
17
+ loadBuffer,
18
+ loadUrlPolyfill,
19
+ loadGetRandomValues,
20
+ loadBase64,
21
+ loadAppState,
22
+ } from './moduleLoaders';
@@ -0,0 +1,13 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export { loadAmplifyRtnPasskeys } from './loadAmplifyRtnPasskeys';
5
+ export { loadAmplifyPushNotification } from './loadAmplifyPushNotification';
6
+ export { loadAmplifyWebBrowser } from './loadAmplifyWebBrowser';
7
+ export { loadAsyncStorage } from './loadAsyncStorage';
8
+ export { loadNetInfo } from './loadNetInfo';
9
+ export { loadBuffer } from './loadBuffer';
10
+ export { loadUrlPolyfill } from './loadUrlPolyfill';
11
+ export { loadGetRandomValues } from './loadGetRandomValues';
12
+ export { loadBase64 } from './loadBase64';
13
+ export { loadAppState } from './loadAppState';
@@ -0,0 +1,28 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { PushNotificationModule } from '@aws-amplify/rtn-push-notification';
5
+
6
+ export const loadAmplifyPushNotification = () => {
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('@aws-amplify/rtn-push-notification')?.module;
11
+ if (module) {
12
+ return module as PushNotificationModule;
13
+ }
14
+
15
+ throw new Error(
16
+ 'Ensure `@aws-amplify/rtn-push-notification` is installed and linked.',
17
+ );
18
+ } catch (e) {
19
+ // The error parsing logic cannot be extracted with metro as the `require`
20
+ // would be confused when there is a `import` in the same file importing
21
+ // another module and that causes an error
22
+ const message = (e as Error).message.replace(
23
+ /undefined/g,
24
+ '@aws-amplify/rtn-push-notification',
25
+ );
26
+ throw new Error(message);
27
+ }
28
+ };
@@ -0,0 +1,28 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { AmplifyRtnPasskeysModule } from '@aws-amplify/rtn-passkeys';
5
+
6
+ export const loadAmplifyRtnPasskeys = () => {
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('@aws-amplify/rtn-passkeys')?.module;
11
+ if (module) {
12
+ return module as AmplifyRtnPasskeysModule;
13
+ }
14
+
15
+ throw new Error(
16
+ 'Ensure `@aws-amplify/rtn-passkeys` is installed and linked.',
17
+ );
18
+ } catch (e) {
19
+ // The error parsing logic cannot be extracted with metro as the `require`
20
+ // would be confused when there is a `import` in the same file importing
21
+ // another module and that causes an error
22
+ const message = (e as Error).message.replace(
23
+ /undefined/g,
24
+ '@aws-amplify/rtn-passkeys',
25
+ );
26
+ throw new Error(message);
27
+ }
28
+ };
@@ -0,0 +1,28 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { WebBrowserModule } from '@aws-amplify/rtn-web-browser';
5
+
6
+ export const loadAmplifyWebBrowser = () => {
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('@aws-amplify/rtn-web-browser')?.module;
11
+ if (module) {
12
+ return module as WebBrowserModule;
13
+ }
14
+
15
+ throw new Error(
16
+ 'Ensure `@aws-amplify/rtn-web-browser` is installed and linked.',
17
+ );
18
+ } catch (e) {
19
+ // The error parsing logic cannot be extracted with metro as the `require`
20
+ // would be confused when there is a `import` in the same file importing
21
+ // another module and that causes an error
22
+ const message = (e as Error).message.replace(
23
+ /undefined/g,
24
+ '@aws-amplify/rtn-web-browser',
25
+ );
26
+ throw new Error(message);
27
+ }
28
+ };
@@ -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 { AppState } from 'react-native';
5
+
6
+ export const loadAppState = () => AppState;
@@ -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 extracted with metro as the `require`
21
+ // would be confused when there is a `import` in the same file importing
22
+ // another module and that causes an 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-get-random-values',
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-url-polyfill',
16
+ );
17
+ throw new Error(message);
18
+ }
19
+ };
@@ -0,0 +1,23 @@
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
+
6
+ import { RTNCore } from './types';
7
+
8
+ const LINKING_ERROR =
9
+ `The package '@aws-amplify/react-native' doesn't seem to be linked. Make sure: \n\n` +
10
+ Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
11
+ '- You rebuilt the app after installing the package\n' +
12
+ '- You are not using Expo Go\n';
13
+
14
+ export const nativeModule: RTNCore = NativeModules.AmplifyRTNCore
15
+ ? NativeModules.AmplifyRTNCore
16
+ : new Proxy(
17
+ {},
18
+ {
19
+ get() {
20
+ throw new Error(LINKING_ERROR);
21
+ },
22
+ },
23
+ );
package/src/types.ts ADDED
@@ -0,0 +1,21 @@
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
+
20
+ getDeviceName(): Promise<string>;
21
+ }