From 88ee87d635f9e8c5baeda35c4cd889ba4967f067 Mon Sep 17 00:00:00 2001 From: rh389 Date: Tue, 4 Jun 2019 01:18:21 +0100 Subject: [PATCH] Add example project --- RNSecureRandomExample/.buckconfig | 6 + RNSecureRandomExample/.flowconfig | 69 + RNSecureRandomExample/.gitattributes | 1 + RNSecureRandomExample/.gitignore | 56 + RNSecureRandomExample/.watchmanconfig | 1 + RNSecureRandomExample/App.js | 51 + RNSecureRandomExample/__tests__/App-test.js | 14 + RNSecureRandomExample/android/app/BUCK | 55 + .../android/app/build.gradle | 152 + .../android/app/build_defs.bzl | 19 + .../android/app/proguard-rules.pro | 17 + .../android/app/src/debug/AndroidManifest.xml | 8 + .../android/app/src/main/AndroidManifest.xml | 26 + .../rnsecurerandomexample/MainActivity.java | 15 + .../MainApplication.java | 47 + .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 3056 bytes .../res/mipmap-hdpi/ic_launcher_round.png | Bin 0 -> 5024 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 2096 bytes .../res/mipmap-mdpi/ic_launcher_round.png | Bin 0 -> 2858 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 4569 bytes .../res/mipmap-xhdpi/ic_launcher_round.png | Bin 0 -> 7098 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 6464 bytes .../res/mipmap-xxhdpi/ic_launcher_round.png | Bin 0 -> 10676 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 9250 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.png | Bin 0 -> 15523 bytes .../app/src/main/res/values/strings.xml | 3 + .../app/src/main/res/values/styles.xml | 8 + RNSecureRandomExample/android/build.gradle | 33 + .../android/gradle.properties | 18 + .../android/gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 54329 bytes .../gradle/wrapper/gradle-wrapper.properties | 5 + RNSecureRandomExample/android/gradlew | 172 + RNSecureRandomExample/android/gradlew.bat | 84 + RNSecureRandomExample/android/keystores/BUCK | 8 + .../keystores/debug.keystore.properties | 4 + RNSecureRandomExample/android/settings.gradle | 5 + RNSecureRandomExample/app.json | 4 + RNSecureRandomExample/babel.config.js | 3 + RNSecureRandomExample/index.js | 9 + .../ios/RNSecureRandomExample-tvOS/Info.plist | 54 + .../Info.plist | 24 + .../project.pbxproj | 1562 +++++ .../RNSecureRandomExample-tvOS.xcscheme | 129 + .../xcschemes/RNSecureRandomExample.xcscheme | 129 + .../ios/RNSecureRandomExample/AppDelegate.h | 15 + .../ios/RNSecureRandomExample/AppDelegate.m | 42 + .../Base.lproj/LaunchScreen.xib | 42 + .../AppIcon.appiconset/Contents.json | 38 + .../Images.xcassets/Contents.json | 6 + .../ios/RNSecureRandomExample/Info.plist | 60 + .../ios/RNSecureRandomExample/main.m | 16 + .../ios/RNSecureRandomExampleTests/Info.plist | 24 + .../RNSecureRandomExampleTests.m | 68 + RNSecureRandomExample/metro.config.js | 17 + RNSecureRandomExample/package.json | 25 + RNSecureRandomExample/yarn.lock | 6235 +++++++++++++++++ 56 files changed, 9379 insertions(+) create mode 100644 RNSecureRandomExample/.buckconfig create mode 100644 RNSecureRandomExample/.flowconfig create mode 100644 RNSecureRandomExample/.gitattributes create mode 100644 RNSecureRandomExample/.gitignore create mode 100644 RNSecureRandomExample/.watchmanconfig create mode 100644 RNSecureRandomExample/App.js create mode 100644 RNSecureRandomExample/__tests__/App-test.js create mode 100644 RNSecureRandomExample/android/app/BUCK create mode 100644 RNSecureRandomExample/android/app/build.gradle create mode 100644 RNSecureRandomExample/android/app/build_defs.bzl create mode 100644 RNSecureRandomExample/android/app/proguard-rules.pro create mode 100644 RNSecureRandomExample/android/app/src/debug/AndroidManifest.xml create mode 100644 RNSecureRandomExample/android/app/src/main/AndroidManifest.xml create mode 100644 RNSecureRandomExample/android/app/src/main/java/com/rnsecurerandomexample/MainActivity.java create mode 100644 RNSecureRandomExample/android/app/src/main/java/com/rnsecurerandomexample/MainApplication.java create mode 100644 RNSecureRandomExample/android/app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 RNSecureRandomExample/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png create mode 100644 RNSecureRandomExample/android/app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 RNSecureRandomExample/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png create mode 100644 RNSecureRandomExample/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 RNSecureRandomExample/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png create mode 100644 RNSecureRandomExample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 RNSecureRandomExample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png create mode 100644 RNSecureRandomExample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 RNSecureRandomExample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png create mode 100644 RNSecureRandomExample/android/app/src/main/res/values/strings.xml create mode 100644 RNSecureRandomExample/android/app/src/main/res/values/styles.xml create mode 100644 RNSecureRandomExample/android/build.gradle create mode 100644 RNSecureRandomExample/android/gradle.properties create mode 100644 RNSecureRandomExample/android/gradle/wrapper/gradle-wrapper.jar create mode 100644 RNSecureRandomExample/android/gradle/wrapper/gradle-wrapper.properties create mode 100755 RNSecureRandomExample/android/gradlew create mode 100644 RNSecureRandomExample/android/gradlew.bat create mode 100644 RNSecureRandomExample/android/keystores/BUCK create mode 100644 RNSecureRandomExample/android/keystores/debug.keystore.properties create mode 100644 RNSecureRandomExample/android/settings.gradle create mode 100644 RNSecureRandomExample/app.json create mode 100644 RNSecureRandomExample/babel.config.js create mode 100644 RNSecureRandomExample/index.js create mode 100644 RNSecureRandomExample/ios/RNSecureRandomExample-tvOS/Info.plist create mode 100644 RNSecureRandomExample/ios/RNSecureRandomExample-tvOSTests/Info.plist create mode 100644 RNSecureRandomExample/ios/RNSecureRandomExample.xcodeproj/project.pbxproj create mode 100644 RNSecureRandomExample/ios/RNSecureRandomExample.xcodeproj/xcshareddata/xcschemes/RNSecureRandomExample-tvOS.xcscheme create mode 100644 RNSecureRandomExample/ios/RNSecureRandomExample.xcodeproj/xcshareddata/xcschemes/RNSecureRandomExample.xcscheme create mode 100644 RNSecureRandomExample/ios/RNSecureRandomExample/AppDelegate.h create mode 100644 RNSecureRandomExample/ios/RNSecureRandomExample/AppDelegate.m create mode 100644 RNSecureRandomExample/ios/RNSecureRandomExample/Base.lproj/LaunchScreen.xib create mode 100644 RNSecureRandomExample/ios/RNSecureRandomExample/Images.xcassets/AppIcon.appiconset/Contents.json create mode 100644 RNSecureRandomExample/ios/RNSecureRandomExample/Images.xcassets/Contents.json create mode 100644 RNSecureRandomExample/ios/RNSecureRandomExample/Info.plist create mode 100644 RNSecureRandomExample/ios/RNSecureRandomExample/main.m create mode 100644 RNSecureRandomExample/ios/RNSecureRandomExampleTests/Info.plist create mode 100644 RNSecureRandomExample/ios/RNSecureRandomExampleTests/RNSecureRandomExampleTests.m create mode 100644 RNSecureRandomExample/metro.config.js create mode 100644 RNSecureRandomExample/package.json create mode 100644 RNSecureRandomExample/yarn.lock diff --git a/RNSecureRandomExample/.buckconfig b/RNSecureRandomExample/.buckconfig new file mode 100644 index 0000000..934256c --- /dev/null +++ b/RNSecureRandomExample/.buckconfig @@ -0,0 +1,6 @@ + +[android] + target = Google Inc.:Google APIs:23 + +[maven_repositories] + central = https://repo1.maven.org/maven2 diff --git a/RNSecureRandomExample/.flowconfig b/RNSecureRandomExample/.flowconfig new file mode 100644 index 0000000..47d80d9 --- /dev/null +++ b/RNSecureRandomExample/.flowconfig @@ -0,0 +1,69 @@ +[ignore] +; We fork some components by platform +.*/*[.]android.js + +; Ignore "BUCK" generated dirs +/\.buckd/ + +; Ignore unexpected extra "@providesModule" +.*/node_modules/.*/node_modules/fbjs/.* + +; 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 + +; Ignore polyfills +.*/Libraries/polyfills/.* + +; Ignore metro +.*/node_modules/metro/.* + +[include] + +[libs] +node_modules/react-native/Libraries/react-native/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 + +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' + +module.file_ext=.js +module.file_ext=.jsx +module.file_ext=.json +module.file_ext=.native.js + +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 + +[version] +^0.92.0 diff --git a/RNSecureRandomExample/.gitattributes b/RNSecureRandomExample/.gitattributes new file mode 100644 index 0000000..d42ff18 --- /dev/null +++ b/RNSecureRandomExample/.gitattributes @@ -0,0 +1 @@ +*.pbxproj -text diff --git a/RNSecureRandomExample/.gitignore b/RNSecureRandomExample/.gitignore new file mode 100644 index 0000000..5d64756 --- /dev/null +++ b/RNSecureRandomExample/.gitignore @@ -0,0 +1,56 @@ +# OSX +# +.DS_Store + +# Xcode +# +build/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata +*.xccheckout +*.moved-aside +DerivedData +*.hmap +*.ipa +*.xcuserstate +project.xcworkspace + +# Android/IntelliJ +# +build/ +.idea +.gradle +local.properties +*.iml + +# node.js +# +node_modules/ +npm-debug.log +yarn-error.log + +# BUCK +buck-out/ +\.buckd/ +*.keystore + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/ + +*/fastlane/report.xml +*/fastlane/Preview.html +*/fastlane/screenshots + +# Bundle artifact +*.jsbundle diff --git a/RNSecureRandomExample/.watchmanconfig b/RNSecureRandomExample/.watchmanconfig new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/RNSecureRandomExample/.watchmanconfig @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/RNSecureRandomExample/App.js b/RNSecureRandomExample/App.js new file mode 100644 index 0000000..ce8edc0 --- /dev/null +++ b/RNSecureRandomExample/App.js @@ -0,0 +1,51 @@ +/** + * 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'; + +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', +}); + +type Props = {}; +type State = { + randomBytes?: Uint8Array +}; +export default class App extends Component { + state = {}; + + async moreRandom() { + const randomBytes = await generateSecureRandom(8); + this.setState({ randomBytes }); + } + + render() { + const { randomBytes } = this.state; + return ( + + { randomBytes ? {[...randomBytes].map(b => b.toString(16)).join(',')} + : Press the button for something random } +