Skip to content

Commit f3dadbb

Browse files
authored
feat: recursive plugin dependency resolution (#1005)
## Summary of change - Makes plugin dependency resolution recursive - Flips plugin resolution order - Moves plugin code to new file - Adds tests - Fixes issue with plugin config override allowing modification of non-public properties - Adds support for ts-mocha ## Related issues ## Test Plan (Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Bonus points for screenshots and videos!) ## Documentation changes (If relevant, please create a PR in our [docs repo](https://github.com/supertokens/docs), or create a checklist here highlighting the necessary changes) ## Checklist for important updates - [ ] Changelog has been updated - [ ] `coreDriverInterfaceSupported.json` file has been updated (if needed) - Along with the associated array in `lib/ts/version.ts` - [ ] `frontendDriverInterfaceSupported.json` file has been updated (if needed) - [ ] Changes to the version if needed - In `package.json` - In `package-lock.json` - In `lib/ts/version.ts` - [ ] Had run `npm run build-pretty` - [ ] Had installed and ran the pre-commit hook - [ ] If new thirdparty provider is added, - [ ] update switch statement in `recipe/thirdparty/providers/configUtils.ts` file, `createProvider` function. - [ ] add an icon on the user management dashboard. - [ ] Issue this PR against the latest non released version branch. - To know which one it is, run find the latest released tag (`git tag`) in the format `vX.Y.Z`, and then find the latest branch (`git branch --all`) whose `X.Y` is greater than the latest released tag. - If no such branch exists, then create one from the latest released branch. - [ ] If have added a new web framework, update the `add-ts-no-check.js` file to include that - [ ] If added a new recipe / api interface, then make sure that the implementation of it uses NON arrow functions only (like `someFunc: function () {..}`). - [ ] If added a new recipe, then make sure to expose it inside the recipe folder present in the root of this repo. We also need to expose its types. - [ ] If added a new entry point, then make sure that it is importable by adding it to the `exports` in `package.json` ## Remaining TODOs for this PR - [ ] Item1 - [ ] Item2
2 parents d27248d + 8f70674 commit f3dadbb

File tree

55 files changed

+1653
-452
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1653
-452
lines changed

.mocharc.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
spec: test/**/*.test.js
1+
spec: test/**/*.test.*
2+
extension: [ts, js]
23
exit: true
34
slow: 10000
45
timeout: 20000

lib/build/index.js

Lines changed: 14 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/build/plugins.d.ts

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/build/plugins.js

Lines changed: 156 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/build/recipe/accountlinking/recipe.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const processState_1 = require("../../processState");
3030
const logger_1 = require("../../logger");
3131
const recipe_1 = __importDefault(require("../emailverification/recipe"));
3232
const utils_2 = require("../../utils");
33+
const plugins_1 = require("../../plugins");
3334
class Recipe extends recipeModule_1.default {
3435
constructor(recipeId, appInfo, config, _recipes, _ingredients) {
3536
super(recipeId, appInfo);
@@ -595,7 +596,7 @@ class Recipe extends recipeModule_1.default {
595596
Recipe.instance = new Recipe(
596597
Recipe.RECIPE_ID,
597598
appInfo,
598-
(0, utils_2.applyPlugins)(
599+
(0, plugins_1.applyPlugins)(
599600
Recipe.RECIPE_ID,
600601
config,
601602
plugins !== null && plugins !== void 0 ? plugins : []

lib/build/recipe/dashboard/api/multitenancy/getThirdPartyConfig.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,16 @@ async function getThirdPartyConfig(_, tenantId, options, userContext) {
130130
authorizationEndpoint: undefined,
131131
tokenEndpoint: undefined,
132132
userInfoEndpoint: undefined,
133-
clients: ((_c = staticProviders[0].config.clients) !== null && _c !== void 0 ? _c : []).map(
134-
(client) =>
135-
Object.assign(Object.assign({}, client), {
136-
additionalConfig: Object.assign(
137-
Object.assign({}, client.additionalConfig),
138-
additionalConfig
139-
),
140-
})
133+
clients: ((_c = staticProviders[0].config.clients) !== null && _c !== void 0
134+
? _c
135+
: []
136+
).map((client) =>
137+
Object.assign(Object.assign({}, client), {
138+
additionalConfig: Object.assign(
139+
Object.assign({}, client.additionalConfig),
140+
additionalConfig
141+
),
142+
})
141143
),
142144
}),
143145
});

lib/build/recipe/dashboard/recipe.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ const updateTenantSecondaryFactor_1 = __importDefault(require("./api/multitenanc
6969
const updateTenantCoreConfig_1 = __importDefault(require("./api/multitenancy/updateTenantCoreConfig"));
7070
const getThirdPartyConfig_1 = __importDefault(require("./api/multitenancy/getThirdPartyConfig"));
7171
const utils_2 = require("../../utils");
72+
const plugins_1 = require("../../plugins");
7273
class Recipe extends recipeModule_1.default {
7374
constructor(recipeId, appInfo, isInServerlessEnv, config) {
7475
super(recipeId, appInfo);
@@ -603,7 +604,7 @@ class Recipe extends recipeModule_1.default {
603604
Recipe.RECIPE_ID,
604605
appInfo,
605606
isInServerlessEnv,
606-
(0, utils_2.applyPlugins)(
607+
(0, plugins_1.applyPlugins)(
607608
Recipe.RECIPE_ID,
608609
config,
609610
plugins !== null && plugins !== void 0 ? plugins : []

lib/build/recipe/emailpassword/index.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,17 @@ class Wrapper {
112112
});
113113
}
114114
static updateEmailOrPassword(input) {
115-
return recipe_1.default.getInstanceOrThrowError().recipeInterfaceImpl.updateEmailOrPassword(
116-
Object.assign(Object.assign({}, input), {
117-
userContext: (0, utils_2.getUserContext)(input.userContext),
118-
tenantIdForPasswordPolicy:
119-
input.tenantIdForPasswordPolicy === undefined
120-
? constants_1.DEFAULT_TENANT_ID
121-
: input.tenantIdForPasswordPolicy,
122-
})
123-
);
115+
return recipe_1.default
116+
.getInstanceOrThrowError()
117+
.recipeInterfaceImpl.updateEmailOrPassword(
118+
Object.assign(Object.assign({}, input), {
119+
userContext: (0, utils_2.getUserContext)(input.userContext),
120+
tenantIdForPasswordPolicy:
121+
input.tenantIdForPasswordPolicy === undefined
122+
? constants_1.DEFAULT_TENANT_ID
123+
: input.tenantIdForPasswordPolicy,
124+
})
125+
);
124126
}
125127
static async createResetPasswordLink(tenantId, userId, email, userContext) {
126128
const ctx = (0, utils_2.getUserContext)(userContext);

lib/build/recipe/emailpassword/recipe.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const signin_1 = __importDefault(require("./api/signin"));
2929
const generatePasswordResetToken_1 = __importDefault(require("./api/generatePasswordResetToken"));
3030
const passwordReset_1 = __importDefault(require("./api/passwordReset"));
3131
const utils_2 = require("../../utils");
32+
const plugins_1 = require("../../plugins");
3233
const emailExists_1 = __importDefault(require("./api/emailExists"));
3334
const recipeImplementation_1 = __importDefault(require("./recipeImplementation"));
3435
const implementation_1 = __importDefault(require("./api/implementation"));
@@ -285,7 +286,7 @@ class Recipe extends recipeModule_1.default {
285286
Recipe.RECIPE_ID,
286287
appInfo,
287288
isInServerlessEnv,
288-
(0, utils_2.applyPlugins)(
289+
(0, plugins_1.applyPlugins)(
289290
Recipe.RECIPE_ID,
290291
config,
291292
plugins !== null && plugins !== void 0 ? plugins : []

lib/build/recipe/emailverification/recipe.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const session_1 = __importDefault(require("../session"));
3939
const __1 = require("../..");
4040
const logger_1 = require("../../logger");
4141
const utils_2 = require("../../utils");
42+
const plugins_1 = require("../../plugins");
4243
class Recipe extends recipeModule_1.default {
4344
constructor(recipeId, appInfo, isInServerlessEnv, config, ingredients) {
4445
super(recipeId, appInfo);
@@ -295,7 +296,7 @@ class Recipe extends recipeModule_1.default {
295296
Recipe.RECIPE_ID,
296297
appInfo,
297298
isInServerlessEnv,
298-
(0, utils_2.applyPlugins)(
299+
(0, plugins_1.applyPlugins)(
299300
Recipe.RECIPE_ID,
300301
config,
301302
plugins !== null && plugins !== void 0 ? plugins : []

0 commit comments

Comments
 (0)