Skip to content

Commit

Permalink
Speed up the onboarding process by parallelizing calls (#2691)
Browse files Browse the repository at this point in the history
* move the recoveryWizard and commitMetadata below the fetchDelegation

* run formatting
  • Loading branch information
LXIF authored Nov 14, 2024
1 parent edb4233 commit 0770646
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/frontend/src/flows/authorize/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,20 +210,10 @@ const authenticate = async (
autoSelectionIdentity: autoSelectionIdentity,
});

// Here, if the user is returning & doesn't have any recovery device, we prompt them to add
// one. The exact flow depends on the device they use.
// XXX: Must happen before auth protocol is done, otherwise the authenticating dapp
// may have already closed the II window
if (!authSuccess.newAnchor) {
await recoveryWizard(authSuccess.userNumber, authSuccess.connection);
}

// at this point, derivationOrigin is either validated or undefined
const derivationOrigin =
authContext.authRequest.derivationOrigin ?? authContext.requestOrigin;

// Ignore the response of committing the metadata because it's not crucial.
void authSuccess.connection.commitMetadata();
const result = await withLoader(() =>
fetchDelegation({
connection: authSuccess.connection,
Expand All @@ -240,6 +230,17 @@ const authenticate = async (
};
}

// Here, if the user is returning & doesn't have any recovery device, we prompt them to add
// one. The exact flow depends on the device they use.
// XXX: Must happen before auth protocol is done, otherwise the authenticating dapp
// may have already closed the II window
if (!authSuccess.newAnchor) {
await recoveryWizard(authSuccess.userNumber, authSuccess.connection);
}

// Ignore the response of committing the metadata because it's not crucial.
void authSuccess.connection.commitMetadata();

const [userKey, parsed_signed_delegation] = result;

const userPublicKey = Uint8Array.from(userKey);
Expand Down

0 comments on commit 0770646

Please sign in to comment.