Skip to content

Commit 0770646

Browse files
authored
Speed up the onboarding process by parallelizing calls (#2691)
* move the recoveryWizard and commitMetadata below the fetchDelegation * run formatting
1 parent edb4233 commit 0770646

File tree

1 file changed

+11
-10
lines changed
  • src/frontend/src/flows/authorize

1 file changed

+11
-10
lines changed

src/frontend/src/flows/authorize/index.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -210,20 +210,10 @@ const authenticate = async (
210210
autoSelectionIdentity: autoSelectionIdentity,
211211
});
212212

213-
// Here, if the user is returning & doesn't have any recovery device, we prompt them to add
214-
// one. The exact flow depends on the device they use.
215-
// XXX: Must happen before auth protocol is done, otherwise the authenticating dapp
216-
// may have already closed the II window
217-
if (!authSuccess.newAnchor) {
218-
await recoveryWizard(authSuccess.userNumber, authSuccess.connection);
219-
}
220-
221213
// at this point, derivationOrigin is either validated or undefined
222214
const derivationOrigin =
223215
authContext.authRequest.derivationOrigin ?? authContext.requestOrigin;
224216

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

233+
// Here, if the user is returning & doesn't have any recovery device, we prompt them to add
234+
// one. The exact flow depends on the device they use.
235+
// XXX: Must happen before auth protocol is done, otherwise the authenticating dapp
236+
// may have already closed the II window
237+
if (!authSuccess.newAnchor) {
238+
await recoveryWizard(authSuccess.userNumber, authSuccess.connection);
239+
}
240+
241+
// Ignore the response of committing the metadata because it's not crucial.
242+
void authSuccess.connection.commitMetadata();
243+
243244
const [userKey, parsed_signed_delegation] = result;
244245

245246
const userPublicKey = Uint8Array.from(userKey);

0 commit comments

Comments
 (0)