From 99a8a0e0f2762bb380fe59696515538a672cde84 Mon Sep 17 00:00:00 2001 From: Danh Date: Mon, 16 Oct 2023 18:07:03 +0700 Subject: [PATCH] test --- package.json | 2 +- src/pages/Oauth/AuthForm/EmailLoginForm.tsx | 10 +++++++++- src/pages/Oauth/Login.tsx | 1 + src/react-app-env.d.ts | 1 + yarn.lock | 8 ++++---- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 33bb5edb8a..121056c4a9 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@blocto/web3-react-connector": "^1.0.0", "@coinbase/wallet-sdk": "^3.0.4", "@esbuild-plugins/node-globals-polyfill": "^0.2.3", - "@kybernetwork/oauth2": "1.0.1-rc.4", + "@kybernetwork/oauth2": "1.0.1-rc.5", "@kyberswap/krystal-walletconnect-v2": "0.0.1", "@kyberswap/ks-sdk-classic": "^1.0.3", "@kyberswap/ks-sdk-core": "1.0.11", diff --git a/src/pages/Oauth/AuthForm/EmailLoginForm.tsx b/src/pages/Oauth/AuthForm/EmailLoginForm.tsx index 96e6e2c1f4..67d24ae463 100644 --- a/src/pages/Oauth/AuthForm/EmailLoginForm.tsx +++ b/src/pages/Oauth/AuthForm/EmailLoginForm.tsx @@ -42,7 +42,15 @@ const EmailLoginForm = ({ flowStatus }: { flowStatus: FlowStatus }) => { const qs = useParsedQueryString<{ flow: string }>() const onSendCode = async ({ email }: { email: string }) => { - return KyberOauth2.oauthUi.sendVerifyCode({ email, flow: qs.flow + '' }) + return KyberOauth2.oauthUi.sendVerifyCode( + { email, flow: qs.flow + '' }, + { + withCredentials: true, + headers: { + 'X-CSRF-Token': window.csrf, + }, + }, + ) } return ( diff --git a/src/pages/Oauth/Login.tsx b/src/pages/Oauth/Login.tsx index 5fe619d49c..eb111c74ae 100644 --- a/src/pages/Oauth/Login.tsx +++ b/src/pages/Oauth/Login.tsx @@ -66,6 +66,7 @@ export function Login() { const connectingWallet = useRef(false) + window.csrf = authFormConfig?.ui?.nodes?.find(e => e.attributes.name === 'csrf_token')?.attributes?.value ?? '' const signInWithEth = useCallback(async () => { try { const siweConfig = authFormConfig?.oauth_client?.metadata?.siwe_config diff --git a/src/react-app-env.d.ts b/src/react-app-env.d.ts index 9b5b595417..08a0d893b0 100644 --- a/src/react-app-env.d.ts +++ b/src/react-app-env.d.ts @@ -46,6 +46,7 @@ interface Window { solana?: any recaptchaOptions?: any zESettings?: any + csrf: string // todo } declare module 'content-hash' { diff --git a/yarn.lock b/yarn.lock index ec3f0b9fed..10f0f17b30 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2257,10 +2257,10 @@ bs58 "^5.0.0" uuid "^8.3.2" -"@kybernetwork/oauth2@1.0.1-rc.4": - version "1.0.1-rc.4" - resolved "https://npm.pkg.github.com/download/@kybernetwork/oauth2/1.0.1-rc.4/954d9fd7699ac79bcce1a91a5159e451b98d3ed9#954d9fd7699ac79bcce1a91a5159e451b98d3ed9" - integrity sha512-word23WbqARrHIAR/JStAvSdmupQZC07k8xCU2VidRjeT2nhLxvi+4j/FLBKwzLvgObvBHnqDCqbr9D434qjXQ== +"@kybernetwork/oauth2@1.0.1-rc.5": + version "1.0.1-rc.5" + resolved "https://npm.pkg.github.com/download/@kybernetwork/oauth2/1.0.1-rc.5/9a727733fbe5a48ea2a6d4bbb49e87dc62fd95c7#9a727733fbe5a48ea2a6d4bbb49e87dc62fd95c7" + integrity sha512-jukcpMG++loxTEDOs9fhuKyGCiasO8AhSsLPpNKxQ0j5L9T050YEvcZz7rn1V89FM+J9IKL7i+mLRPUz9KxShg== dependencies: axios "1.2.1" client-oauth2 "^4.3.3"