magiclabs / magic-js

Magic browser/React Native JavaScript SDK is your entry-point to integrating passwordless authentication inside your application.
https://magic.link/docs/api-reference/client-side-sdks/web
Apache License 2.0
457 stars 85 forks source link

Use storage for faster calls to `isLoggedIn` on mobile #689

Closed romin-halltari closed 8 months ago

romin-halltari commented 8 months ago

📦 Pull Request

Significantly improves calls to isLoggedIn by keeping track of it by with the local storage. Check the screen recording for a demo. The code of the demo is on the Magic Lens repo, branch demo/is-logged-in.

✅ Fixed Issues

https://github.com/magiclabs/magic-js/issues/683

🚨 Test instructions

⚠️ Don't forget to add a semver label!

Please only add one label:

https://github.com/magiclabs/magic-js/assets/150072475/76cb13b0-c5be-4efb-a6d4-7fc9edf7c530

📦 Published PR as canary version: Canary Versions
:sparkles: Test out this PR locally via: ```bash npm install @magic-ext/algorand@16.5.0-canary.689.7390316721.0 npm install @magic-ext/aptos@4.5.0-canary.689.7390316721.0 npm install @magic-ext/avalanche@16.5.0-canary.689.7390316721.0 npm install @magic-ext/bitcoin@16.5.0-canary.689.7390316721.0 npm install @magic-ext/conflux@14.5.0-canary.689.7390316721.0 npm install @magic-ext/cosmos@16.5.0-canary.689.7390316721.0 npm install @magic-ext/ed25519@12.5.0-canary.689.7390316721.0 npm install @magic-ext/flow@16.5.0-canary.689.7390316721.0 npm install @magic-ext/gdkms@4.5.0-canary.689.7390316721.0 npm install @magic-ext/harmony@16.5.0-canary.689.7390316721.0 npm install @magic-ext/icon@16.5.0-canary.689.7390316721.0 npm install @magic-ext/near@16.5.0-canary.689.7390316721.0 npm install @magic-ext/oauth@15.6.0-canary.689.7390316721.0 npm install @magic-ext/oidc@4.5.0-canary.689.7390316721.0 npm install @magic-ext/polkadot@16.5.0-canary.689.7390316721.0 npm install @magic-ext/react-native-bare-oauth@18.2.0-canary.689.7390316721.0 npm install @magic-ext/react-native-expo-oauth@18.2.0-canary.689.7390316721.0 npm install @magic-ext/solana@18.4.0-canary.689.7390316721.0 npm install @magic-ext/taquito@13.5.0-canary.689.7390316721.0 npm install @magic-ext/terra@13.5.0-canary.689.7390316721.0 npm install @magic-ext/tezos@16.5.0-canary.689.7390316721.0 npm install @magic-ext/webauthn@15.5.0-canary.689.7390316721.0 npm install @magic-ext/zilliqa@16.5.0-canary.689.7390316721.0 npm install @magic-sdk/commons@17.5.0-canary.689.7390316721.0 npm install @magic-sdk/pnp@15.6.0-canary.689.7390316721.0 npm install @magic-sdk/provider@21.5.0-canary.689.7390316721.0 npm install @magic-sdk/react-native-bare@22.5.0-canary.689.7390316721.0 npm install @magic-sdk/react-native-expo@22.5.0-canary.689.7390316721.0 npm install magic-sdk@21.5.0-canary.689.7390316721.0 # or yarn add @magic-ext/algorand@16.5.0-canary.689.7390316721.0 yarn add @magic-ext/aptos@4.5.0-canary.689.7390316721.0 yarn add @magic-ext/avalanche@16.5.0-canary.689.7390316721.0 yarn add @magic-ext/bitcoin@16.5.0-canary.689.7390316721.0 yarn add @magic-ext/conflux@14.5.0-canary.689.7390316721.0 yarn add @magic-ext/cosmos@16.5.0-canary.689.7390316721.0 yarn add @magic-ext/ed25519@12.5.0-canary.689.7390316721.0 yarn add @magic-ext/flow@16.5.0-canary.689.7390316721.0 yarn add @magic-ext/gdkms@4.5.0-canary.689.7390316721.0 yarn add @magic-ext/harmony@16.5.0-canary.689.7390316721.0 yarn add @magic-ext/icon@16.5.0-canary.689.7390316721.0 yarn add @magic-ext/near@16.5.0-canary.689.7390316721.0 yarn add @magic-ext/oauth@15.6.0-canary.689.7390316721.0 yarn add @magic-ext/oidc@4.5.0-canary.689.7390316721.0 yarn add @magic-ext/polkadot@16.5.0-canary.689.7390316721.0 yarn add @magic-ext/react-native-bare-oauth@18.2.0-canary.689.7390316721.0 yarn add @magic-ext/react-native-expo-oauth@18.2.0-canary.689.7390316721.0 yarn add @magic-ext/solana@18.4.0-canary.689.7390316721.0 yarn add @magic-ext/taquito@13.5.0-canary.689.7390316721.0 yarn add @magic-ext/terra@13.5.0-canary.689.7390316721.0 yarn add @magic-ext/tezos@16.5.0-canary.689.7390316721.0 yarn add @magic-ext/webauthn@15.5.0-canary.689.7390316721.0 yarn add @magic-ext/zilliqa@16.5.0-canary.689.7390316721.0 yarn add @magic-sdk/commons@17.5.0-canary.689.7390316721.0 yarn add @magic-sdk/pnp@15.6.0-canary.689.7390316721.0 yarn add @magic-sdk/provider@21.5.0-canary.689.7390316721.0 yarn add @magic-sdk/react-native-bare@22.5.0-canary.689.7390316721.0 yarn add @magic-sdk/react-native-expo@22.5.0-canary.689.7390316721.0 yarn add magic-sdk@21.5.0-canary.689.7390316721.0 ```
shortcut-integration[bot] commented 8 months ago

This pull request has been linked to Shortcut Story #91336: Look into faster calls to isLoggedIn and other methods that are called on app startup.

Ethella commented 8 months ago

On another note, I think we should always store the value in a JSON format to ensure scalability for the future. But I think it's an overkill for now, as we can always switch to a new key in the storage.

Ariflo commented 8 months ago

:rocket: PR was released in @magic-ext/algorand@16.5.0, @magic-ext/aptos@4.5.0, @magic-ext/avalanche@16.5.0, @magic-ext/bitcoin@16.5.0, @magic-ext/conflux@14.5.0, @magic-ext/cosmos@16.5.0, @magic-ext/ed25519@12.5.0, @magic-ext/flow@16.5.0, @magic-ext/gdkms@4.5.0, @magic-ext/harmony@16.5.0, @magic-ext/icon@16.5.0, @magic-ext/near@16.5.0, @magic-ext/oauth@15.6.0, @magic-ext/oidc@4.5.0, @magic-ext/polkadot@16.5.0, @magic-ext/react-native-bare-oauth@18.2.0, @magic-ext/react-native-expo-oauth@18.2.0, @magic-ext/solana@18.4.0, @magic-ext/taquito@13.5.0, @magic-ext/terra@13.5.0, @magic-ext/tezos@16.5.0, @magic-ext/webauthn@15.5.0, @magic-ext/zilliqa@16.5.0, @magic-sdk/commons@17.5.0, @magic-sdk/pnp@15.6.0, @magic-sdk/provider@21.5.0, @magic-sdk/react-native-bare@22.5.0, @magic-sdk/react-native-expo@22.5.0, magic-sdk@21.5.0 :rocket: