π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Pass as a query param instead
Manav Rathi9ff8469a548c
diff --git a/web/apps/accounts/src/services/passkey.ts b/web/apps/accounts/src/services/passkey.tsindex c3e67754eb..132a4d5f8d 100644--- a/web/apps/accounts/src/services/passkey.ts+++ b/web/apps/accounts/src/services/passkey.ts@@ -566,8 +566,9 @@ export const passkeyAuthenticationSuccessRedirectURL = async (twoFactorAuthorizationResponse: TwoFactorAuthorizationResponse,) => {const encodedResponse = await toB64URLSafeNoPaddingString(- JSON.stringify({ ...twoFactorAuthorizationResponse, passkeySessionID }),+ JSON.stringify(twoFactorAuthorizationResponse),);+ redirectURL.searchParams.set("passkeySessionID", passkeySessionID);redirectURL.searchParams.set("response", encodedResponse);return redirectURL;};diff --git a/web/packages/accounts/pages/passkeys/finish.tsx b/web/packages/accounts/pages/passkeys/finish.tsxindex abbc328f9c..2b1a8b8e61 100644--- a/web/packages/accounts/pages/passkeys/finish.tsx+++ b/web/packages/accounts/pages/passkeys/finish.tsx@@ -23,12 +23,15 @@ const Page: React.FC<PageProps> = () => {useEffect(() => {// Extract response from query paramsconst searchParams = new URLSearchParams(window.location.search);+ const passkeySessionID = searchParams.get("passkeySessionID");const response = searchParams.get("response");- if (!response) return;+ if (!passkeySessionID || !response) return;- saveCredentialsAndNavigateTo(response).then((slug: string) => {- router.push(slug);- });+ saveCredentialsAndNavigateTo(passkeySessionID, response).then(+ (slug: string) => {+ router.push(slug);+ },+ );}, []);return (@@ -45,35 +48,22 @@ export default Page;* and save them to local storage for use by subsequent steps (or normal* functioning) of the app.*- * @param response The string that is passed as the response query parameter to+ * @param passkeySessionID The string that is passed as the "passkeySessionID"+ * query parameter to us.+ *+ * @param response The string that is passed as the "response" query parameter to* us (we're the final "finish" page in the passkey flow).** @returns the slug that we should navigate to now.*/-const saveCredentialsAndNavigateTo = async (response: string) => {- // Decode response string (inverse of the steps we perform in- // `passkeyAuthenticationSuccessRedirectURL`).- const decodedResponse = JSON.parse(- await fromB64URLSafeNoPaddingString(response),- );-- // Only one of `encryptedToken` or `token` will be present depending on the- // account's lifetime:- //- // - The plaintext "token" will be passed during fresh signups, where we- // don't yet have keys to encrypt it, the account itself is being created- // as we go through this flow.- //- // - The encrypted `encryptedToken` will be present otherwise (i.e. if the- // user is signing into an existing account).- const { passkeySessionID, keyAttributes, encryptedToken, token, id } =- decodedResponse;-+const saveCredentialsAndNavigateTo = async (+ passkeySessionID: string,+ response: string,+) => {const inflightPasskeySessionID = nullToUndefined(sessionStorage.getItem("inflightPasskeySessionID"),);if (- !passkeySessionID ||!inflightPasskeySessionID ||passkeySessionID != inflightPasskeySessionID) {@@ -88,6 +78,23 @@ const saveCredentialsAndNavigateTo = async (response: string) => {sessionStorage.removeItem("inflightPasskeySessionID");+ // Decode response string (inverse of the steps we perform in+ // `passkeyAuthenticationSuccessRedirectURL`).+ const decodedResponse = JSON.parse(+ await fromB64URLSafeNoPaddingString(response),+ );++ // Only one of `encryptedToken` or `token` will be present depending on the+ // account's lifetime:+ //+ // - The plaintext "token" will be passed during fresh signups, where we+ // don't yet have keys to encrypt it, the account itself is being created+ // as we go through this flow.+ //+ // - The encrypted `encryptedToken` will be present otherwise (i.e. if the+ // user is signing into an existing account).+ const { keyAttributes, encryptedToken, token, id } = decodedResponse;+setData(LS_KEYS.USER, {...getData(LS_KEYS.USER),token,