Skip to content

Commit

Permalink
fix: MFA implementation (#743)
Browse files Browse the repository at this point in the history
* fix: type fix and account linking functions

* fix: cdi version update

* fix: more type updates

* fix: tests

* fix: totp recipe

* fix: totp types

* fix: update types

* fix: totp apis

* fix: user identifier info

* fix: recipe tests

* fix: test

* fix: basic mfa impl

* fix: pr comments

* fix: tests

* fix: factors setup from other recipe

* fix: getFactorsSetupForUser impl

* fix: getMFARequirementsForAuth impl

* fix: isAllowedToSetupFactor impl

* fix: addToDefaultRequiredFactorsForUser and getDefaultRequiredFactorsForUser impl

* fix: typo

* fix: build next array

* fix: remove error file

* fix: factorSetupForUser refactor

* fix: next array

* fix: api impl

* fix: typo

* fix: isValidFirstFactorForTenant

* fix: impl

* fix: updated impl

* feat: fix and update mfa imlp to make all e2e tests pass

* fix: adds overwriteSessionDuringSignIn config in session

* fix: error messages in claims

* fix: cleanup

* fix: new errors for sign in up APIs

* fix: add error in totp

* fix: marked MFA TODOs

* fix: new param in createNewSession

* fix: impl cleanup

* fix: remove MFA_ERROR

* fix: cdi version

* fix: test fix

* fix: update/fix mfa impl to match e2e tests

* fix: pr comments

* fix: session user deleted error

* fix: adding cache to getUserById

* fix: get user cache

* caching in querier

* fix: mfa impl

* fix: email selection

* fix: mfa claims

* fix: remove unnecessary file

* fix: pr comment

* fix: PR comments

* fix: session handling

* fix: review comments

* fix: defaultRequiredFactorsForUser is now appwide

* fix: using accountlinking instead of mfa for primary user and link accounts

* fix: overwrite session flag refactor

* fix: race conditions in createOrUpdateSessionForMultifactorAuthAfterFactorCompletion

* fix: race conditions in createOrUpdateSessionForMultifactorAuthAfterFactorCompletion

* fix: recipe functions refactor

* fix: contact support case

* fix: unnecessary file

* fix: test

* refactor: added shouldRefetch + fetchValue building the next array into MFAclaim (#758)

* fix: usercontext type

* fix: test

* fix: test

* feat: add access token payload param to claim.build

* feat: expose addToDefaultRequiredFactorsForUser and remove tenantId param

* fix: remaining TODOs

* fix: auto init tests related to mfa

* fix: recipe function tests

* fix: create new session refactor

* fix: recipe interface refactor

* fix: userContext type fix

* fix: test

* fix: test

* fix: session

* fix: user context and support codes

* fix: type fixes after merge

* fix: test

* fix: pr comments

* fix: pr comment

* fix: test

* fix: available factors

* fix: updated user object

* fix: shouldAttemptAccountLinkingIfAllowed

* fix: missed types and test fixes

* fix: mfa fixes and tests

* fix: more tests

---------

Co-authored-by: Mihaly Lengyel <mihaly@lengyel.tech>
  • Loading branch information
sattvikc and porcellus authored Dec 15, 2023
1 parent 328c28f commit 520a320
Show file tree
Hide file tree
Showing 399 changed files with 8,666 additions and 3,141 deletions.
2 changes: 1 addition & 1 deletion coreDriverInterfaceSupported.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"_comment": "contains a list of core-driver interfaces branch names that this core supports",
"versions": ["4.1"]
"versions": ["5.0"]
}
10 changes: 9 additions & 1 deletion lib/build/framework/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ async function assertFormDataBodyParserHasBeenUsedForExpressLikeRequest(request)
}
exports.assertFormDataBodyParserHasBeenUsedForExpressLikeRequest = assertFormDataBodyParserHasBeenUsedForExpressLikeRequest;
function setHeaderForExpressLikeResponse(res, key, value, allowDuplicateKey) {
var _a;
try {
let existingHeaders = res.getHeaders();
let existingValue = existingHeaders[key.toLowerCase()];
Expand Down Expand Up @@ -238,7 +239,14 @@ function setHeaderForExpressLikeResponse(res, key, value, allowDuplicateKey) {
}
}
} catch (err) {
throw new Error("Error while setting header with key: " + key + " and value: " + value);
throw new Error(
"Error while setting header with key: " +
key +
" and value: " +
value +
"\nError: " +
((_a = err.message) !== null && _a !== void 0 ? _a : err)
);
}
}
exports.setHeaderForExpressLikeResponse = setHeaderForExpressLikeResponse;
Expand Down
30 changes: 18 additions & 12 deletions lib/build/index.d.ts

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

39 changes: 29 additions & 10 deletions lib/build/index.js

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

5 changes: 3 additions & 2 deletions lib/build/ingredients/emaildelivery/services/smtp.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @ts-nocheck
import OverrideableBuilder from "supertokens-js-override";
import { UserContext } from "../../../types";
export interface SMTPServiceConfig {
host: string;
from: {
Expand All @@ -18,13 +19,13 @@ export interface GetContentResult {
toEmail: string;
}
export declare type TypeInputSendRawEmail = GetContentResult & {
userContext: any;
userContext: UserContext;
};
export declare type ServiceInterface<T> = {
sendRawEmail: (input: TypeInputSendRawEmail) => Promise<void>;
getContent: (
input: T & {
userContext: any;
userContext: UserContext;
}
) => Promise<GetContentResult>;
};
Expand Down
3 changes: 2 additions & 1 deletion lib/build/ingredients/emaildelivery/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// @ts-nocheck
import OverrideableBuilder from "supertokens-js-override";
import { UserContext } from "../../types";
export declare type EmailDeliveryInterface<T> = {
sendEmail: (
input: T & {
tenantId: string;
userContext: any;
userContext: UserContext;
}
) => Promise<void>;
};
Expand Down
5 changes: 3 additions & 2 deletions lib/build/ingredients/smsdelivery/services/twilio.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @ts-nocheck
import OverrideableBuilder from "supertokens-js-override";
import { ClientOpts } from "twilio/lib/base/BaseTwilio";
import { UserContext } from "../../../types";
/**
* only one of "from" and "messagingServiceSid" should be passed.
* if both are passed, we should throw error to the user
Expand All @@ -27,7 +28,7 @@ export interface GetContentResult {
toPhoneNumber: string;
}
export declare type TypeInputSendRawSms = GetContentResult & {
userContext: any;
userContext: UserContext;
} & (
| {
from: string;
Expand All @@ -40,7 +41,7 @@ export declare type ServiceInterface<T> = {
sendRawSms: (input: TypeInputSendRawSms) => Promise<void>;
getContent: (
input: T & {
userContext: any;
userContext: UserContext;
}
) => Promise<GetContentResult>;
};
Expand Down
3 changes: 2 additions & 1 deletion lib/build/ingredients/smsdelivery/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// @ts-nocheck
import OverrideableBuilder from "supertokens-js-override";
import { UserContext } from "../../types";
export declare type SmsDeliveryInterface<T> = {
sendSms: (
input: T & {
tenantId: string;
userContext: any;
userContext: UserContext;
}
) => Promise<void>;
};
Expand Down
17 changes: 12 additions & 5 deletions lib/build/querier.d.ts

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

Loading

0 comments on commit 520a320

Please sign in to comment.