From 591605e58f23509c4faf754a670f9abbdb62437b Mon Sep 17 00:00:00 2001 From: Truong Nhat Quang Date: Tue, 10 Dec 2024 17:44:07 +0700 Subject: [PATCH] fix: remove redundancy function --- packages/waypoint/web/delegation-auth.ts | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/packages/waypoint/web/delegation-auth.ts b/packages/waypoint/web/delegation-auth.ts index 9551f96..73f5871 100644 --- a/packages/waypoint/web/delegation-auth.ts +++ b/packages/waypoint/web/delegation-auth.ts @@ -82,19 +82,10 @@ export const delegationAuthorize = async ( } as DelegationAuthorizeData } -const parseClientShard = async () => { - const url = new URL(window.location.href) - - const method = url.searchParams.get("method") - if (method !== "auth") { - throw "parseRedirectUrl: invalid method" - } - - const type = url.searchParams.get("type") - if (type !== "success") { - throw "parseRedirectUrl: authorization failed" - } +export const parseRedirectUrlWithShard = async () => { + const authData = parseRedirectUrlForAuthData() + const url = new URL(window.location.href) const encryptedShard = url.searchParams.get("wallet_key") if (!encryptedShard) { @@ -111,14 +102,6 @@ const parseClientShard = async () => { const builtPrivateKey = await buildPrivateKey(privateKey) const clientShard = await decryptClientShard(encryptedShard, builtPrivateKey) - return { - clientShard, - } -} - -export const parseRedirectUrlWithShard = async () => { - const authData = parseRedirectUrlForAuthData() - const { clientShard } = await parseClientShard() return { ...authData, clientShard,