Skip to content

Commit

Permalink
fix: making sure async errors hit error boundaries + smaller test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
porcellus committed Dec 4, 2023
1 parent 9040500 commit ddc73be
Show file tree
Hide file tree
Showing 46 changed files with 721 additions and 454 deletions.
58 changes: 1 addition & 57 deletions examples/for-tests/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,63 +208,7 @@ window.resetTOTP = () => {
};
let recipeList = [
TOTP.init({
override: {
functions: (oI) => ({
...oI,
listDevices: async () => ({ devices: totpDevices, status: "OK" }),
removeDevice: async ({ deviceName }) => {
return { status: "OK", didDeviceExist: removeTOTPDevice(deviceName) };
},
createDevice: async ({ deviceName }) => {
deviceName = deviceName ?? `totp-${Date.now()}`;
addTOTPDevice(deviceName);
return {
status: "OK",
deviceName: deviceName,
issuerName: "st",
qrCodeString: deviceName,
secret: `secret-${deviceName}`,
};
},
verifyCode: async ({ totp }) => {
const dev = totpDevices.find((d) => d.deviceName.endsWith(totp) && d.verified);
if (dev) {
await fetch("http://localhost:8082/completeFactor", {
method: "POST",
body: JSON.stringify({ id: "totp" }),
headers: new Headers([["Content-Type", "application/json"]]),
});
return { status: "OK" };
}

if (++tryCount > 3) {
return { status: "LIMIT_REACHED_ERROR", retryAfterMs: 30000 };
}
return { status: "INVALID_TOTP_ERROR" };
},
verifyDevice: async ({ deviceName, totp }) => {
const dev = totpDevices.find((d) => d.deviceName === deviceName);
if (!dev) {
return { status: "UNKNOWN_DEVICE_ERROR" };
}
if (deviceName.endsWith(totp)) {
const wasAlreadyVerified = dev.verified;
verifyTOTPDevice(deviceName);
await fetch("http://localhost:8082/completeFactor", {
method: "POST",
body: JSON.stringify({ id: "totp" }),
headers: new Headers([["Content-Type", "application/json"]]),
});
return { status: "OK", wasAlreadyVerified };
}

if (++tryCount > 3) {
return { status: "LIMIT_REACHED_ERROR", retryAfterMs: 30000 };
}
return { status: "INVALID_TOTP_ERROR" };
},
}),
},
override: {},
}),
MultiFactorAuth.init({
firstFactors: testContext.firstFactors,
Expand Down
27 changes: 15 additions & 12 deletions lib/build/authRecipe-shared2.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 29 additions & 24 deletions lib/build/emailpassword-shared7.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion lib/build/emailpassword-shared9.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions lib/build/emailverificationprebuiltui.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions lib/build/genericComponentOverrideContext.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions lib/build/multifactorauth-shared.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ddc73be

Please sign in to comment.