From 8b8b75d1080781710c53fa0bccaea78731808e5f Mon Sep 17 00:00:00 2001 From: Aiden Petersen Date: Wed, 17 Aug 2022 14:53:31 +1200 Subject: [PATCH 1/2] remove gradle 7 incompatible code --- android/build.gradle | 93 +++++++------------------------------------- 1 file changed, 15 insertions(+), 78 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index e21cdf0..4e725c3 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -5,18 +5,18 @@ buildscript { if (project == rootProject) { repositories { google() + mavenCentral() jcenter() } dependencies { //noinspection GradleDependency - classpath("com.android.tools.build:gradle:3.5.2") + classpath("com.android.tools.build:gradle:3.5.3") } } } apply plugin: 'com.android.library' -apply plugin: 'maven' def safeExtGet(prop, fallback) { rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback @@ -43,87 +43,24 @@ android { } repositories { - google() + mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - // Matches the RN Hello World template - // https://github.com/facebook/react-native/blob/1e8f3b11027fe0a7514b4fc97d0798d3c64bc895/local-cli/templates/HelloWorld/android/build.gradle#L21 - url "$projectDir/../node_modules/react-native/android" + url("$rootDir/../node_modules/react-native/android") } - mavenCentral() -} - -dependencies { - implementation 'com.facebook.react:react-native:+' -} - -def configureReactNativePom(def pom) { - def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text) - - pom.project { - name packageJson.title - artifactId packageJson.name - version = packageJson.version - group = "net.rhogan.rnsecurerandom" - description packageJson.description - url packageJson.repository.baseUrl - - licenses { - license { - name packageJson.license - url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename - distribution 'repo' - } - } - - developers { - developer { - id packageJson.author.url - name packageJson.author.name + google() + mavenCentral { + // We don't want to fetch react-native from Maven Central as there are + // older versions over there. + content { + excludeGroup "com.facebook.react" } } - } + jcenter() } -afterEvaluate { project -> - - task androidJavadoc(type: Javadoc) { - source = android.sourceSets.main.java.srcDirs - classpath += files(android.bootClasspath) - classpath += files(project.getConfigurations().getByName('compile').asList()) - include '**/*.java' - } - - task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) { - classifier = 'javadoc' - from androidJavadoc.destinationDir - } - - task androidSourcesJar(type: Jar) { - classifier = 'sources' - from android.sourceSets.main.java.srcDirs - include '**/*.java' - } - - android.libraryVariants.all { variant -> - def name = variant.name.capitalize() - task "jar${name}"(type: Jar, dependsOn: variant.javaCompile) { - from variant.javaCompile.destinationDir - } - } - - artifacts { - archives androidSourcesJar - archives androidJavadocJar - } - - task installArchives(type: Upload) { - configuration = configurations.archives - repositories.mavenDeployer { - // Deploy to react-native-event-bridge/maven, ready to publish to npm - repository url: "file://${projectDir}/../android/maven" - - configureReactNativePom pom - } - } +dependencies { + //noinspection GradleDynamicVersion + implementation "com.facebook.react:react-native:+" // From node_modules } + From c67852b49c354b7b9e300fb70b422f274672f0e4 Mon Sep 17 00:00:00 2001 From: Aiden Petersen Date: Wed, 17 Aug 2022 14:54:24 +1200 Subject: [PATCH 2/2] Update example app to RN 0.69.4 --- RNSecureRandomExample/.bundle/config | 2 + RNSecureRandomExample/.eslintrc.js | 4 + RNSecureRandomExample/.flowconfig | 73 +- RNSecureRandomExample/.gitattributes | 1 - RNSecureRandomExample/.gitignore | 15 +- RNSecureRandomExample/.prettierrc.js | 7 + RNSecureRandomExample/.ruby-version | 1 + RNSecureRandomExample/App.js | 48 +- RNSecureRandomExample/Gemfile | 6 + RNSecureRandomExample/__tests__/App-test.js | 14 - .../android/app/{BUCK => _BUCK} | 0 .../android/app/build.gradle | 196 +- .../android/app/debug.keystore | Bin 0 -> 2257 bytes .../android/app/proguard-rules.pro | 7 - .../android/app/src/debug/AndroidManifest.xml | 7 +- .../ReactNativeFlipper.java | 73 + .../android/app/src/main/AndroidManifest.xml | 8 +- .../rnsecurerandomexample/MainActivity.java | 45 +- .../MainApplication.java | 90 +- .../MainApplicationReactNativeHost.java | 116 + .../components/MainComponentsRegistry.java | 36 + ...ApplicationTurboModuleManagerDelegate.java | 48 + .../android/app/src/main/jni/Android.mk | 48 + .../jni/MainApplicationModuleProvider.cpp | 24 + .../main/jni/MainApplicationModuleProvider.h | 16 + ...nApplicationTurboModuleManagerDelegate.cpp | 45 + ...ainApplicationTurboModuleManagerDelegate.h | 38 + .../src/main/jni/MainComponentsRegistry.cpp | 61 + .../app/src/main/jni/MainComponentsRegistry.h | 32 + .../android/app/src/main/jni/OnLoad.cpp | 11 + .../res/drawable/rn_edit_text_material.xml | 36 + .../app/src/main/res/values/styles.xml | 3 +- RNSecureRandomExample/android/build.gradle | 44 +- .../android/gradle.properties | 26 +- .../android/gradle/wrapper/gradle-wrapper.jar | Bin 54329 -> 59536 bytes .../gradle/wrapper/gradle-wrapper.properties | 2 +- RNSecureRandomExample/android/gradlew | 282 +- RNSecureRandomExample/android/gradlew.bat | 173 +- RNSecureRandomExample/android/keystores/BUCK | 8 - .../keystores/debug.keystore.properties | 4 - RNSecureRandomExample/android/settings.gradle | 12 +- RNSecureRandomExample/babel.config.js | 16 +- RNSecureRandomExample/ios/Podfile | 35 + RNSecureRandomExample/ios/Podfile.lock | 557 ++ .../ios/RNSecureRandomExample-tvOS/Info.plist | 54 - .../Info.plist | 24 - .../project.pbxproj | 1322 +--- .../RNSecureRandomExample-tvOS.xcscheme | 129 - .../xcschemes/RNSecureRandomExample.xcscheme | 45 +- .../contents.xcworkspacedata | 10 + .../ios/RNSecureRandomExample/AppDelegate.h | 7 - .../ios/RNSecureRandomExample/AppDelegate.m | 42 - .../ios/RNSecureRandomExample/AppDelegate.mm | 133 + .../Base.lproj/LaunchScreen.xib | 42 - .../AppIcon.appiconset/Contents.json | 45 +- .../ios/RNSecureRandomExample/Info.plist | 27 +- .../LaunchScreen.storyboard | 47 + .../ios/RNSecureRandomExample/main.m | 10 +- .../RNSecureRandomExampleTests.m | 40 +- RNSecureRandomExample/ios/_xcode.env | 11 + RNSecureRandomExample/metro.config.js | 32 +- RNSecureRandomExample/package.json | 30 +- RNSecureRandomExample/yarn.lock | 6240 ----------------- 63 files changed, 2442 insertions(+), 8118 deletions(-) create mode 100644 RNSecureRandomExample/.bundle/config create mode 100644 RNSecureRandomExample/.eslintrc.js delete mode 100644 RNSecureRandomExample/.gitattributes create mode 100644 RNSecureRandomExample/.prettierrc.js create mode 100644 RNSecureRandomExample/.ruby-version create mode 100644 RNSecureRandomExample/Gemfile delete mode 100644 RNSecureRandomExample/__tests__/App-test.js rename RNSecureRandomExample/android/app/{BUCK => _BUCK} (100%) create mode 100644 RNSecureRandomExample/android/app/debug.keystore create mode 100644 RNSecureRandomExample/android/app/src/debug/java/com/rnsecurerandomexample/ReactNativeFlipper.java create mode 100644 RNSecureRandomExample/android/app/src/main/java/com/rnsecurerandomexample/newarchitecture/MainApplicationReactNativeHost.java create mode 100644 RNSecureRandomExample/android/app/src/main/java/com/rnsecurerandomexample/newarchitecture/components/MainComponentsRegistry.java create mode 100644 RNSecureRandomExample/android/app/src/main/java/com/rnsecurerandomexample/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java create mode 100644 RNSecureRandomExample/android/app/src/main/jni/Android.mk create mode 100644 RNSecureRandomExample/android/app/src/main/jni/MainApplicationModuleProvider.cpp create mode 100644 RNSecureRandomExample/android/app/src/main/jni/MainApplicationModuleProvider.h create mode 100644 RNSecureRandomExample/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.cpp create mode 100644 RNSecureRandomExample/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h create mode 100644 RNSecureRandomExample/android/app/src/main/jni/MainComponentsRegistry.cpp create mode 100644 RNSecureRandomExample/android/app/src/main/jni/MainComponentsRegistry.h create mode 100644 RNSecureRandomExample/android/app/src/main/jni/OnLoad.cpp create mode 100644 RNSecureRandomExample/android/app/src/main/res/drawable/rn_edit_text_material.xml delete mode 100644 RNSecureRandomExample/android/keystores/BUCK delete mode 100644 RNSecureRandomExample/android/keystores/debug.keystore.properties create mode 100644 RNSecureRandomExample/ios/Podfile create mode 100644 RNSecureRandomExample/ios/Podfile.lock delete mode 100644 RNSecureRandomExample/ios/RNSecureRandomExample-tvOS/Info.plist delete mode 100644 RNSecureRandomExample/ios/RNSecureRandomExample-tvOSTests/Info.plist delete mode 100644 RNSecureRandomExample/ios/RNSecureRandomExample.xcodeproj/xcshareddata/xcschemes/RNSecureRandomExample-tvOS.xcscheme create mode 100644 RNSecureRandomExample/ios/RNSecureRandomExample.xcworkspace/contents.xcworkspacedata delete mode 100644 RNSecureRandomExample/ios/RNSecureRandomExample/AppDelegate.m create mode 100644 RNSecureRandomExample/ios/RNSecureRandomExample/AppDelegate.mm delete mode 100644 RNSecureRandomExample/ios/RNSecureRandomExample/Base.lproj/LaunchScreen.xib create mode 100644 RNSecureRandomExample/ios/RNSecureRandomExample/LaunchScreen.storyboard create mode 100644 RNSecureRandomExample/ios/_xcode.env delete mode 100644 RNSecureRandomExample/yarn.lock diff --git a/RNSecureRandomExample/.bundle/config b/RNSecureRandomExample/.bundle/config new file mode 100644 index 0000000..848943b --- /dev/null +++ b/RNSecureRandomExample/.bundle/config @@ -0,0 +1,2 @@ +BUNDLE_PATH: "vendor/bundle" +BUNDLE_FORCE_RUBY_PLATFORM: 1 diff --git a/RNSecureRandomExample/.eslintrc.js b/RNSecureRandomExample/.eslintrc.js new file mode 100644 index 0000000..40c6dcd --- /dev/null +++ b/RNSecureRandomExample/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + root: true, + extends: '@react-native-community', +}; diff --git a/RNSecureRandomExample/.flowconfig b/RNSecureRandomExample/.flowconfig index 47d80d9..74f3a75 100644 --- a/RNSecureRandomExample/.flowconfig +++ b/RNSecureRandomExample/.flowconfig @@ -5,65 +5,62 @@ ; Ignore "BUCK" generated dirs /\.buckd/ -; Ignore unexpected extra "@providesModule" -.*/node_modules/.*/node_modules/fbjs/.* +; Ignore polyfills +node_modules/react-native/Libraries/polyfills/.* -; Ignore duplicate module providers -; For RN Apps installed via npm, "Libraries" folder is inside -; "node_modules/react-native" but in the source repo it is in the root -.*/Libraries/react-native/React.js +; Flow doesn't support platforms +.*/Libraries/Utilities/LoadingView.js -; Ignore polyfills -.*/Libraries/polyfills/.* +.*/node_modules/resolve/test/resolver/malformed_package_json/package\.json$ -; Ignore metro -.*/node_modules/metro/.* +[untyped] +.*/node_modules/@react-native-community/cli/.*/.* [include] [libs] -node_modules/react-native/Libraries/react-native/react-native-interface.js +node_modules/react-native/interface.js node_modules/react-native/flow/ [options] emoji=true -esproposal.optional_chaining=enable -esproposal.nullish_coalescing=enable - -module.system=haste -module.system.haste.use_name_reducers=true -# get basename -module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1' -# strip .js or .js.flow suffix -module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1' -# strip .ios suffix -module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1' -module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1' -module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1' -module.system.haste.paths.blacklist=.*/__tests__/.* -module.system.haste.paths.blacklist=.*/__mocks__/.* -module.system.haste.paths.blacklist=/node_modules/react-native/Libraries/Animated/src/polyfills/.* -module.system.haste.paths.whitelist=/node_modules/react-native/Libraries/.* - -munge_underscores=true +exact_by_default=true -module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub' +format.bracket_spacing=false module.file_ext=.js -module.file_ext=.jsx module.file_ext=.json -module.file_ext=.native.js +module.file_ext=.ios.js + +munge_underscores=true + +module.name_mapper='^react-native/\(.*\)$' -> '/node_modules/react-native/\1' +module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '/node_modules/react-native/Libraries/Image/RelativeImageStub' suppress_type=$FlowIssue suppress_type=$FlowFixMe suppress_type=$FlowFixMeProps suppress_type=$FlowFixMeState -suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) -suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ -suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy -suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError +[lints] +sketchy-null-number=warn +sketchy-null-mixed=warn +sketchy-number=warn +untyped-type-import=warn +nonstrict-import=warn +deprecated-type=warn +unsafe-getters-setters=warn +unnecessary-invariant=warn + +[strict] +deprecated-type +nonstrict-import +sketchy-null +unclear-type +unsafe-getters-setters +untyped-import +untyped-type-import [version] -^0.92.0 +^0.176.3 diff --git a/RNSecureRandomExample/.gitattributes b/RNSecureRandomExample/.gitattributes deleted file mode 100644 index d42ff18..0000000 --- a/RNSecureRandomExample/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -*.pbxproj -text diff --git a/RNSecureRandomExample/.gitignore b/RNSecureRandomExample/.gitignore index 5d64756..344481b 100644 --- a/RNSecureRandomExample/.gitignore +++ b/RNSecureRandomExample/.gitignore @@ -20,7 +20,7 @@ DerivedData *.hmap *.ipa *.xcuserstate -project.xcworkspace +ios/.xcode.env.local # Android/IntelliJ # @@ -29,6 +29,7 @@ build/ .gradle local.properties *.iml +*.hprof # node.js # @@ -40,6 +41,7 @@ yarn-error.log buck-out/ \.buckd/ *.keystore +!debug.keystore # fastlane # @@ -48,9 +50,14 @@ buck-out/ # For more information about the recommended setup visit: # https://docs.fastlane.tools/best-practices/source-control/ -*/fastlane/report.xml -*/fastlane/Preview.html -*/fastlane/screenshots +**/fastlane/report.xml +**/fastlane/Preview.html +**/fastlane/screenshots +**/fastlane/test_output # Bundle artifact *.jsbundle + +# Ruby / CocoaPods +/ios/Pods/ +/vendor/bundle/ diff --git a/RNSecureRandomExample/.prettierrc.js b/RNSecureRandomExample/.prettierrc.js new file mode 100644 index 0000000..2b54074 --- /dev/null +++ b/RNSecureRandomExample/.prettierrc.js @@ -0,0 +1,7 @@ +module.exports = { + arrowParens: 'avoid', + bracketSameLine: true, + bracketSpacing: false, + singleQuote: true, + trailingComma: 'all', +}; diff --git a/RNSecureRandomExample/.ruby-version b/RNSecureRandomExample/.ruby-version new file mode 100644 index 0000000..a603bb5 --- /dev/null +++ b/RNSecureRandomExample/.ruby-version @@ -0,0 +1 @@ +2.7.5 diff --git a/RNSecureRandomExample/App.js b/RNSecureRandomExample/App.js index ce8edc0..9ade9fc 100644 --- a/RNSecureRandomExample/App.js +++ b/RNSecureRandomExample/App.js @@ -1,45 +1,33 @@ /** * Sample React Native App * https://github.com/facebook/react-native - * - * @format - * @flow */ -import React, {Component} from 'react'; -import {Button, Platform, StyleSheet, Text, View} from 'react-native'; -import {generateSecureRandom} from 'react-native-securerandom'; +import React, { useState, useCallback } from 'react'; +import { + Button, + StyleSheet, + Text, + View, +} from 'react-native'; -const instructions = Platform.select({ - ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu', - android: - 'Double tap R on your keyboard to reload,\n' + - 'Shake or press menu button for dev menu', -}); +import { generateSecureRandom } from 'react-native-securerandom'; -type Props = {}; -type State = { - randomBytes?: Uint8Array -}; -export default class App extends Component { - state = {}; +const App = () => { + const [randomBytes, setRandomBytes] = useState(); - async moreRandom() { - const randomBytes = await generateSecureRandom(8); - this.setState({ randomBytes }); - } + const moreRandom = useCallback(() => { + generateSecureRandom(5).then(setRandomBytes); + }, []) - render() { - const { randomBytes } = this.state; - return ( + return ( { randomBytes ? {[...randomBytes].map(b => b.toString(16)).join(',')} : Press the button for something random } -