From acccfc9d7f461442b639aabc7c44fb5cde0d708e Mon Sep 17 00:00:00 2001 From: shrinathprabhu Date: Wed, 24 Apr 2024 10:53:52 +0530 Subject: [PATCH 1/2] Update passwordless login to otp login --- package-lock.json | 14 +-- package.json | 2 +- src/components/OTPInput.vue | 199 ++++++++++++++++++++++++++++++++++++ src/pages/login.vue | 30 ++++-- 4 files changed, 227 insertions(+), 18 deletions(-) create mode 100644 src/components/OTPInput.vue diff --git a/package-lock.json b/package-lock.json index 5b240fe..c6d1ab1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,7 @@ "name": "send-it", "version": "0.0.0", "dependencies": { - "@arcana/auth": "^1.0.11-beta.1", + "@arcana/auth": "^1.0.10", "@fontsource/caveat": "^5.0.8", "@fontsource/syne": "^5.0.8", "@headlessui/vue": "^1.7.15", @@ -147,9 +147,9 @@ } }, "node_modules/@arcana/auth": { - "version": "1.0.11-beta.1", - "resolved": "https://registry.npmjs.org/@arcana/auth/-/auth-1.0.11-beta.1.tgz", - "integrity": "sha512-WPkk4DpQIOSMpDmSNd3+lKkWKJIj2wmN6Uxudxf4AlQJWRdLDUR8jVv1T3Afhxsn7wRsox58Be0I8K0ERIQIkw==", + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/@arcana/auth/-/auth-1.0.10.tgz", + "integrity": "sha512-8s7awiHTm5Rj3cd0dOnNoLggpVCImjE08lIFKSrQIvy9tqNY1SstTdnwYJIVoHxVL43l72EOWg7YgEZgy3dBaw==", "dependencies": { "@metamask/safe-event-emitter": "^2.0.0", "@solana/web3.js": "^1.87.3", @@ -13340,9 +13340,9 @@ "dev": true }, "@arcana/auth": { - "version": "1.0.11-beta.1", - "resolved": "https://registry.npmjs.org/@arcana/auth/-/auth-1.0.11-beta.1.tgz", - "integrity": "sha512-WPkk4DpQIOSMpDmSNd3+lKkWKJIj2wmN6Uxudxf4AlQJWRdLDUR8jVv1T3Afhxsn7wRsox58Be0I8K0ERIQIkw==", + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/@arcana/auth/-/auth-1.0.10.tgz", + "integrity": "sha512-8s7awiHTm5Rj3cd0dOnNoLggpVCImjE08lIFKSrQIvy9tqNY1SstTdnwYJIVoHxVL43l72EOWg7YgEZgy3dBaw==", "requires": { "@metamask/safe-event-emitter": "^2.0.0", "@solana/web3.js": "^1.87.3", diff --git a/package.json b/package.json index af1aea0..1d35ba1 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "preview": "vite preview" }, "dependencies": { - "@arcana/auth": "^1.0.11-beta.1", + "@arcana/auth": "^1.0.10", "@fontsource/caveat": "^5.0.8", "@fontsource/syne": "^5.0.8", "@headlessui/vue": "^1.7.15", diff --git a/src/components/OTPInput.vue b/src/components/OTPInput.vue new file mode 100644 index 0000000..0c09087 --- /dev/null +++ b/src/components/OTPInput.vue @@ -0,0 +1,199 @@ + + + + + diff --git a/src/pages/login.vue b/src/pages/login.vue index 75be3b2..8339aed 100644 --- a/src/pages/login.vue +++ b/src/pages/login.vue @@ -14,6 +14,7 @@ import useWalletConnect from "@/use/walletconnect"; import type { GetAccountResult, PublicClient } from "@wagmi/core"; import { normaliseEmail } from "@/utils/normalise"; import useOkxWallet from "@/use/okxwallet"; +import OTPInput from "@/components/OTPInput.vue"; const arcanaAuth = useArcanaAuth(); const authStore = useAuthStore(); @@ -24,6 +25,7 @@ const passwordlessEmailId = ref(""); const toast = useToast(); const walletConnect = useWalletConnect(); const okxWallet = useOkxWallet(); +const showOTPInput = ref(false); const query = route.query; const verifier = query.verifier as string; @@ -74,22 +76,24 @@ async function socialLogin(type: string) { async function passwordlessLogin() { try { - loaderStore.showLoader( - `Click on the verification mail sent to ${passwordlessEmailId.value}...` + showOTPInput.value = true; + const authInstance = arcanaAuth.getAuthInstance(); + const loginState = await authInstance.loginWithOTPStart( + normaliseEmail(passwordlessEmailId.value) ); - await arcanaAuth - .getAuthInstance() - .loginWithLink(normaliseEmail(passwordlessEmailId.value)); - authStore.provider = arcanaAuth.getProvider(); - authStore.isLoggedIn = true; - authStore.loggedInWith = ""; + await loginState.begin(); } catch (e: any) { toast.error(e); - } finally { - loaderStore.hideLoader(); + showOTPInput.value = false; } } +async function passwordlessLoginSuccess() { + authStore.provider = arcanaAuth.getProvider(); + authStore.isLoggedIn = true; + authStore.loggedInWith = ""; +} + async function onConnectToWalletConnect() { const accountDetails = walletConnect.getAccount(); const isConnected = accountDetails.isConnected; @@ -290,5 +294,11 @@ async function onConnectToOkxWallet() { + From c3cc30d81170ba95bb1b1ec305ccb00ed7a4dc96 Mon Sep 17 00:00:00 2001 From: shrinathprabhu Date: Wed, 24 Apr 2024 11:03:49 +0530 Subject: [PATCH 2/2] Update arcana auth --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index c6d1ab1..5b240fe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,7 @@ "name": "send-it", "version": "0.0.0", "dependencies": { - "@arcana/auth": "^1.0.10", + "@arcana/auth": "^1.0.11-beta.1", "@fontsource/caveat": "^5.0.8", "@fontsource/syne": "^5.0.8", "@headlessui/vue": "^1.7.15", @@ -147,9 +147,9 @@ } }, "node_modules/@arcana/auth": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/@arcana/auth/-/auth-1.0.10.tgz", - "integrity": "sha512-8s7awiHTm5Rj3cd0dOnNoLggpVCImjE08lIFKSrQIvy9tqNY1SstTdnwYJIVoHxVL43l72EOWg7YgEZgy3dBaw==", + "version": "1.0.11-beta.1", + "resolved": "https://registry.npmjs.org/@arcana/auth/-/auth-1.0.11-beta.1.tgz", + "integrity": "sha512-WPkk4DpQIOSMpDmSNd3+lKkWKJIj2wmN6Uxudxf4AlQJWRdLDUR8jVv1T3Afhxsn7wRsox58Be0I8K0ERIQIkw==", "dependencies": { "@metamask/safe-event-emitter": "^2.0.0", "@solana/web3.js": "^1.87.3", @@ -13340,9 +13340,9 @@ "dev": true }, "@arcana/auth": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/@arcana/auth/-/auth-1.0.10.tgz", - "integrity": "sha512-8s7awiHTm5Rj3cd0dOnNoLggpVCImjE08lIFKSrQIvy9tqNY1SstTdnwYJIVoHxVL43l72EOWg7YgEZgy3dBaw==", + "version": "1.0.11-beta.1", + "resolved": "https://registry.npmjs.org/@arcana/auth/-/auth-1.0.11-beta.1.tgz", + "integrity": "sha512-WPkk4DpQIOSMpDmSNd3+lKkWKJIj2wmN6Uxudxf4AlQJWRdLDUR8jVv1T3Afhxsn7wRsox58Be0I8K0ERIQIkw==", "requires": { "@metamask/safe-event-emitter": "^2.0.0", "@solana/web3.js": "^1.87.3", diff --git a/package.json b/package.json index 1d35ba1..af1aea0 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "preview": "vite preview" }, "dependencies": { - "@arcana/auth": "^1.0.10", + "@arcana/auth": "^1.0.11-beta.1", "@fontsource/caveat": "^5.0.8", "@fontsource/syne": "^5.0.8", "@headlessui/vue": "^1.7.15",