React-Native-App | RN 开源之初,写几个小 App 玩玩 | Frontend Framework library
kandi X-RAY | React-Native-App Summary
kandi X-RAY | React-Native-App Summary
RN 开源之初,写几个小 App 玩玩
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of React-Native-App
React-Native-App Key Features
React-Native-App Examples and Code Snippets
Community Discussions
Trending Discussions on React-Native-App
QUESTION
I have a React native front end where I use invertase/react-native-apple-authentication to handle Apple Authentication.
Then I have a NodeJS back end, where I use A-Tokyo/apple-signin-auth to handle Apple authenticated users and let them access routes.
I made this authentication based on this article.
I want the users to be able use the app without logging in again without a time limit.
Therefore I save the identity token, which I get when the user does the first sign up in Async Storage in the front-end. Every time the user tries to access routes the user will be checked if he/she has a identityToken in the Header in my isAuth
middleware in the NodeJS backend for the respective request.
I can see in my logs not sometimes requests get the following error the backend in my isAuth
middleware:
JsonWebTokenError: error in secret or public key callback: input error: Invalid id token public key id at /app/node_modules/jsonwebtoken/verify.js:96:19 at _getIdTokenApplePublicKey (/app/node_modules/apple-signin-auth/lib/index.js:1:5730) at runMicrotasks () at processTicksAndRejections (internal/process/task_queues.js:95:5)
The error is thrown in the apple-signin-auth
library when executing this code:
ANSWER
Answered 2022-Mar-29 at 08:04As far as I understand the workflow, you verify the identity token in the backend only once when the user has authenticated themselves using "Sign in with Apple" on the device.
If verifying the identity token in the backend was successful, you receive a refresh token in the response. You are then supposed to save this refresh token in your backend and verify the refresh token once a day to check if the user is still logged in with Apple. What does that mean? For example a user could revoke access to your app. Or a different user could log in on the Apple device.
By the way, if you verify the refresh token on every request (read multiple times a day), you risk Apple throttling these requests.
Bear in mind that this doesn't free your system from rolling its own session management meaning that your system sends its own session ids back and forth between the backend and front-end. Once a day, you check the refresh token associated with a session to see if the user is still logged in.
Disclaimer: This is how I understood the docs of Sign in with Apple. In other works, I have no experience implementing it. Hope it helps nonetheless.
QUESTION
I have a few concerns with an OpenId Connect strategy that I would like to use and have been unable to find specifics on what the security concerns may be and any glaring issues with it I am overlooking.
Currently, I have an OpenId Connect implementation using Openiddict with Authorization Code flow. For the client, I have a React-Native app using react-native-app-auth.
I see from other questions on SO and from issues posted on the Openiddict repo that the recommended approach to third-party providers (e.g. Google) is: Client -> Auth server -> Google Auth -> Auth server -> Client/Auth server code and token exchange
However, it seems that a better approach from a UX standpoint (when using a SPA or native app) would be to implement something similar to GoogleSignIn on the client and either handle the identity on the server using an IdToken or authorization code from Google. This introduces an issue as the flow previously recommended could not be used as the entire initial challenge and redirect from Auth server to Google Auth has been skipped.
I have seen that this issue is mitigated by not using the authorization code grant and instead implementing a custom assertion grant. This seems to be an alright approach but would require exposing a custom grant and handling the flow differently on the client and server for local and third-party logins.
My proposed solution continues to use the authorization code flow and instead of adding a custom grant type the client could just pass a third-party identifier "Google" and the token or authorization code in the additional parameters of the OIDC authorize request. The authorize endpoint could then detect the provider and token, perform token validation, create a user or principal from it, and create an authorization code to send back to the client for the code/token exchange. This flow would look like the following:
1. Get the id token from the provider Client -> GoogleSignIn -> Client
2. Pass token to auth server and initiate code / token exchange Client -> Auth Server -> Auth server Verify Google IdToken (JWKS, issuer, audience, provider specific validation, etc...) or exchange auth code -> Auth server -> Client/Auth server code and token exchange
One downside to this approach would be the additional hops to verify the token on the server side. If the token was returned from GoogleSignIn, they themselves said that it could be trusted. https://developers.google.com/identity/protocols/oauth2/openid-connect#obtainuserinfo
I see that it is generally recommended to place the auth server between the client and the third-party but in this process the server is still between the client and auth server but only after the initial exchange from the client and third-party.
Questions,
In general am I missing something with this flow?
In this case would it be necessary to verify the token on the server side?
Is there some better way to approach this that I have completely overlooked?
Am I making this too complicated and UX should not be this much of a concern?
Instead of adding the provider and token to the additional parameters would it make more sense to pass it in the body of a post request? I don't see the issue with passing it via query string but that's also part of the reasoning for the authorization code grant from my understanding.
Apologies in advance for anything I have missed or omitted for brevity that should have been included.
Thanks.
...ANSWER
Answered 2022-Feb-14 at 14:27ARCHITECTURE
I'm not sure I understand the UX problem - your existing architecture feels really good. If you want to login directly to Google, just send an acr_values=google
query parameter in the authorization redirect, to bypass any authentication selection screens. The exact value will depend on how Openiddict represents the Google authentication option, and some providers use a non-standard parameter such as idp
. Have a closer look at the OIDC request parameters.
A key OAuth goal is that the Authorization Server (AS) - Openiddict in your case - shields your apps from all of the provider differences and deals with their nuances and vendor specific behaviour. Your apps then also only receive one type of token, and only ever use simple code. As an example, the Curity AS supports all of these options, none of which requires any code in applications.
APPAUTH AND UX
If a user is already signed in then it can, as you say, look unnatural to spin up the system browser and them it is dismissed immediately.
A common option is to show the consent screen or an interstitial page to keep the user informed - and the user clicks one extra button. This can also be useful for getting password autofill to work. My code example and blog post shows how this might look, though of course you can improve on my basic UX.
OFFLINE ACCESS
I find this term misleading, since refresh tokens are most commonly used when the user is there. Are you just asking how to deal with tokens in a mobile client? Aim for behaviour like this:
- Standard messages for API calls with access tokens in an authorization bearer header
- Standard refresh token grant messages to refresh access tokens - eg as in this code
Note also that mobile apps can save tokens to encrypted secure mobile storage that is private to the app. This can improve usability, eg by avoiding logins every time the app is restarted. You should think through scenarios such as stolen devices and token lifetimes though.
QUESTION
I am trying to install React Native Firebase Mlkit to my existing iOS React Native app. My app is already using various Firebase packages (app, auth, firestore, etc.).
I am following the instructions from the guide. I tried both automatic and manual installation. But when I run pod install
, I got this error:
ANSWER
Answered 2022-Feb-02 at 19:231) First off Firebase/MLVisionTextModel
is deprecated (FirebaseMLVisionTextModel has been deprecated in favor of MLKitTextRecognition). You can read the migration guide here (https://developers.google.com/ml-kit/migration)
2) If you ever have errors like was resolved to x.x.x, which depends on Firebase/CoreOnly (= x.x.x)
A lot of times you can fix this by adding this below at the very top of your PodFile to specify what version to use.
QUESTION
i have the Invariant Violation: Native module cannot be null error and the 2nd error down below. I found online the issue might have to do with not having an ios folder in a module directory, i looked in each of the folders in the local system and on github with them all containing the ios folder
...ANSWER
Answered 2022-Jan-20 at 05:12Check the library @react-navigation/drawer
compatibility with IOS and Android respectively , link it manually sometimes autolinking doesn't work. Ensure you are running correct project , clean build and install pod and check it out.
QUESTION
I have a react native app that it worked well until upgrade packages Actually after upgrade packages this permision added (android.permission.QUERY_ALL_PACKAGES) to manifest.please help me
this is first package.json
...ANSWER
Answered 2022-Jan-18 at 18:30It is because of target SDK updated to 30, some features (eg: Speech recognition,TTS) works in from android 11 device only after adding following code in our AndroidManifest.xml
QUESTION
I am experiencing difficulty writing tests for react-native typescript screen using instructions from the URL below https://react-native-async-storage.github.io/async-storage/docs/advanced/jest/
I keep getting the below error
FAIL app/screens/login/login-screen.test.tsx ● Test suite failed to run
...ANSWER
Answered 2021-Dec-06 at 15:23Based on your package.json dependencies you dont have the @react-native-async-storage
dependency, you have @react-native-community/async-storage
, which is the old organisation namespace.
Try doing
QUESTION
I have a login screen in the react-native mobile app. When a user enters the correct Email and password, then I store the jwt token in the react-native app, but not in the webview. After the login screen, I want to show a webview(Dashboard). How to skip the login screen because the user is already authenticated in react-native-app? How to pass the jwt token to webview so that the user does not need authentication again. Click to see code
...ANSWER
Answered 2021-Oct-29 at 19:57You can pass the token with the URL
in the WebView
component with query param:
QUESTION
hellow every one i migrated gitlab-ce into a new instance with new domain name using backup/restore
my problem : when i click a project it gives me "500 Whoops, something went wrong on our end "
i installed the same gitlab-ce version in the new host which is 13.6.2
my gitlab status
...ANSWER
Answered 2021-Oct-28 at 16:29To fix this problem I had to migrate gitlab-secrets.json
from /etc/gitlab
too, because this file contains the database encryption key, CI/CD variables, and variables used for two-factor authentication.
If you fail to restore this encryption key file along with the application data backup, users with two-factor authentication enabled and GitLab Runner lose access to your GitLab server.
QUESTION
When I search the internet for react-native
optimizations / best practices (Especially for FlatLists
which are often greedy), I always find the advice not to use the arrow functions ... }
.
Example 1 : https://reactnative.dev/docs/optimizing-flatlist-configuration#avoid-anonymous-function-on-renderitem :
Move out the renderItem function to the outside of render function, so it won't recreate itself each time render function called. (...)
Example 2 : https://blog.codemagic.io/improve-react-native-app-performance/ :
Avoid Arrow Functions : Arrow functions are a common culprit for wasteful re-renders. Don’t use arrow functions as callbacks in your functions to render views (...)
Example 3 : https://medium.com/wix-engineering/dealing-with-performance-issues-in-react-native-b181d0012cfa :
Arrow functions is another usual suspect for wasteful re-renders. Don’t use arrow functions as callbacks (such as click/tap) in your render functions (...)
I understand that it is recommended not to use arrow function (especially in onPress
button and FlatList
), and to put the components outside of the render if possible.
Good practice example :
...ANSWER
Answered 2021-Oct-18 at 16:47The answer has nothing to do with arrow functions, but rather understanding reference equality why react might decide to rerender a component.
You can use useCallback to wrap your function. This will cause the reference to renderItem to only update when one of your callback dependencies updates.
QUESTION
Issue: This broke with no changes between days. Even though I have metro running npx react-native start
when I run npx react-native run-android
it starts it's own metro server and does not allow me to do "fast refresh" it basically installs the debug build of the app onto the device. I need it to fast refresh for development purposes.
Already tried the steps on issue: Unable to load script from assets index.android.bundle on windows
To test and debug my android build for a react-native project I had an emulator running in one Powershell window, would start a metro server in a second Powershell window using npx react-native start
then run the app in a third powershell window using npx react-native run-android
it would go through the build and install the app, then it would "pass" the app to the react-native metro server then that would install it to the emulator. This would allow me to make changes to the code and "fast refresh" the application in the emulator/phone and logs got outputted to the Metro Server.
Versions (executed at project root folder)
npx react-native --version
: 6.0.0
npx --version
: 7.18.1
Setup:
First Powershell window:
emulator -avd Galaxy_Nexus_Android9 -no-snapshot
Second Powershell window: Make sure abd device is running
...ANSWER
Answered 2021-Sep-17 at 19:15Solution: Run the start metro server and run-android commands on a different port. I suspect McAfee was using the default port 8081.
Open admin CMD/Powershell and run the following:
Reverse the port that the adb device will listen on:
adb reverse tcp:8081 tcp:8090
Start the Metro server on the same port:
npx react-native start --port 8090
Open another admin CMD/Powershell window and run:
Start the android build/run on the same port:
npx react-native run-android --port=8090
The last command should also start the emulator automatically.
If the metro server errors out after you do the run-android command, just run the npx react-native start --port 8090
again in the same window.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install React-Native-App
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page