Skip to content

Commit 9e80104

Browse files
committed
improve typing and pass corect data
1 parent 17889d0 commit 9e80104

20 files changed

+73
-42
lines changed

bundle/emailpassword.c1a0d79af26440b51d51.js renamed to bundle/emailpassword.a02453698f220fcc2e22.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/emailverification.a79e33acc7eb395196ea.js renamed to bundle/emailverification.973a61ed0c7510512ad4.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/multifactorauth.db3d09794dfe21df5191.js renamed to bundle/multifactorauth.f5236f3283286391ac9c.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/multitenancy.d9410cf4157295294a4f.js renamed to bundle/multitenancy.f33de57d2ddfd4489ccf.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/oauth2provider.282dfd69f753c1da542f.js renamed to bundle/oauth2provider.f2637d1feca4602e9733.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/passwordless.f371962da255a66c4acf.js renamed to bundle/passwordless.5fc7d9ddb50f606f3518.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/session.2740b8f1fe8cd6052828.js renamed to bundle/session.3d6b8b354cc44167debb.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/supertokens.260bad1a50289c4111db.js renamed to bundle/supertokens.ebbf17f6ef1bb498b7f6.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/thirdparty.b73554ac6a5053bf704d.js renamed to bundle/thirdparty.b675ae5720a25f1223af.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/totp.8798e985f5feb60ba2e0.js renamed to bundle/totp.8aa91159442add552896.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/userroles.d780c52d1442012774ef.js renamed to bundle/userroles.d7b43b845bc9e038e668.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/build/index.d.ts

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

lib/build/supertokens.js

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

lib/build/types.d.ts

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

lib/build/utils.d.ts

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

lib/build/utils.js

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

lib/ts/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import SuperTokens from "./supertokens";
1616
import { SuperTokensConfig } from "./types";
1717

18+
export type { SuperTokensConfig, SuperTokensPublicConfig, SuperTokensPlugin, SuperTokensPublicPlugin } from "./types";
19+
1820
export default class SuperTokensAPIWrapper {
1921
static init(config: SuperTokensConfig): void {
2022
SuperTokens.init(config);

lib/ts/supertokens.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@
1515

1616
import RecipeModule from "./recipe/recipeModule";
1717
import { NormalisedAppInfo, SuperTokensConfig, SuperTokensPlugin, SuperTokensPublicPlugin } from "./types";
18-
import { checkForSSRErrorAndAppendIfNeeded, getPublicPlugin, isTest, normaliseInputAppInfoOrThrowError } from "./utils";
18+
import {
19+
checkForSSRErrorAndAppendIfNeeded,
20+
getPublicConfig,
21+
getPublicPlugin,
22+
isTest,
23+
normaliseInputAppInfoOrThrowError,
24+
} from "./utils";
1925
import { CookieHandlerReference } from "./cookieHandler";
2026
import { WindowHandlerReference } from "./windowHandler";
2127
import { PostSuperTokensInitCallbacks } from "./postSuperTokensInitCallbacks";
@@ -58,7 +64,11 @@ export default class SuperTokens {
5864
}
5965
}
6066
if (plugin.dependencies) {
61-
const result = plugin.dependencies(finalPluginList, package_version);
67+
const result = plugin.dependencies(
68+
getPublicConfig(config),
69+
finalPluginList.map(getPublicPlugin),
70+
package_version
71+
);
6272
if (result.status === "ERROR") {
6373
throw new Error(result.message);
6474
}
@@ -75,7 +85,7 @@ export default class SuperTokens {
7585
for (let pluginIndex = 0; pluginIndex < this.pluginList.length; pluginIndex += 1) {
7686
const pluginConfig = finalPluginList[pluginIndex].config;
7787
if (pluginConfig) {
78-
config = { ...config, ...pluginConfig(config) };
88+
config = { ...config, ...pluginConfig(getPublicConfig(config)) };
7989
}
8090

8191
const pluginInit = finalPluginList[pluginIndex].init;

lib/ts/types.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -227,24 +227,23 @@ export type SuperTokensPlugin = {
227227
version?: string;
228228
compatibleWebJSSDKVersions?: string | string[]; // match the syntax of the engines field in package.json
229229
dependencies?: (
230-
pluginsAbove: Pick<SuperTokensPlugin, "id" | "version" | "exports">[],
230+
config: SuperTokensPublicConfig,
231+
pluginsAbove: SuperTokensPublicPlugin[],
231232
sdkVersion: string
232233
) => { status: "OK"; pluginsToAdd?: SuperTokensPlugin[] } | { status: "ERROR"; message: string };
233234
overrideMap?: {
234235
[recipeId in keyof AllRecipeConfigs]?: RecipePluginOverride<recipeId> & {
235236
recipeInitRequired?: boolean | ((sdkVersion: string) => boolean);
236237
};
237238
};
238-
init?: (
239-
config: Omit<SuperTokensConfig, "recipeList">,
240-
plugins: SuperTokensPlugin[],
241-
sdkVersion: string
242-
) => void | Promise<void>;
239+
init?: (config: SuperTokensPublicConfig, plugins: SuperTokensPublicPlugin[], sdkVersion: string) => void;
243240
exports?: Record<string, any>;
244-
config?: (config: Omit<SuperTokensConfig, "recipeList">) => Omit<SuperTokensConfig, "recipeList"> | undefined;
241+
config?: (config: SuperTokensPublicConfig) => SuperTokensPublicConfig | undefined;
245242
};
246243

247244
export type SuperTokensPublicPlugin = Pick<
248245
SuperTokensPlugin,
249246
"id" | "version" | "exports" | "compatibleWebJSSDKVersions"
250247
> & { initialized: boolean };
248+
249+
export type SuperTokensPublicConfig = Omit<SuperTokensConfig, "experimental" | "recipeList">;

lib/ts/utils.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ import {
2020
AllRecipeConfigs,
2121
AppInfoUserInput,
2222
NormalisedAppInfo,
23+
SuperTokensConfig,
2324
SuperTokensPlugin,
25+
SuperTokensPublicConfig,
2426
SuperTokensPublicPlugin,
2527
User,
2628
} from "./types";
@@ -220,12 +222,12 @@ export function applyPlugins<T extends keyof AllRecipeConfigs>(
220222
config: AllRecipeConfigs[T] | undefined,
221223
plugins: NonNullable<SuperTokensPlugin["overrideMap"]>[]
222224
): AllRecipeConfigs[T] {
223-
config = config ?? ({} as AllRecipeConfigs[T]);
224-
let functionLayers = [config.override?.functions];
225+
let _config = { ...(config ?? ({} as AllRecipeConfigs[T])) };
226+
let functionLayers = [_config.override?.functions];
225227
for (const plugin of plugins) {
226228
const overrides = plugin[recipeId];
227229
if (overrides) {
228-
config = overrides.config ? overrides.config(config) : config;
230+
_config = { ...(overrides.config ? overrides.config(_config) : _config) };
229231
if (overrides.functions !== undefined) {
230232
functionLayers.push(overrides.functions as any);
231233
}
@@ -234,8 +236,8 @@ export function applyPlugins<T extends keyof AllRecipeConfigs>(
234236
functionLayers = functionLayers.reverse().filter((layer) => layer !== undefined);
235237

236238
if (functionLayers.length > 0) {
237-
config.override = {
238-
...config.override,
239+
_config.override = {
240+
..._config.override,
239241
functions: (oI: any, builder: OverrideableBuilder<any>) => {
240242
for (const layer of functionLayers) {
241243
builder.override(layer as any);
@@ -244,7 +246,8 @@ export function applyPlugins<T extends keyof AllRecipeConfigs>(
244246
},
245247
};
246248
}
247-
return config;
249+
250+
return _config;
248251
}
249252

250253
export function getPublicPlugin(plugin: SuperTokensPlugin): SuperTokensPublicPlugin {
@@ -256,3 +259,8 @@ export function getPublicPlugin(plugin: SuperTokensPlugin): SuperTokensPublicPlu
256259
compatibleWebJSSDKVersions: plugin.compatibleWebJSSDKVersions,
257260
};
258261
}
262+
263+
export function getPublicConfig(config: SuperTokensConfig): SuperTokensPublicConfig {
264+
// const { experimental, recipeList, ...publicConfig } = config;
265+
return config;
266+
}

0 commit comments

Comments
 (0)