diff --git a/lib/build/supertokens.js b/lib/build/supertokens.js index 72c86c096..7da5fa01d 100644 --- a/lib/build/supertokens.js +++ b/lib/build/supertokens.js @@ -32,7 +32,7 @@ const version_1 = require("./version"); const recipe_1 = __importDefault(require("./recipe/session/recipe")); class SuperTokens { constructor(config) { - var _a, _b, _c, _d, _e; + var _a, _b, _c, _d, _e, _f; this.handleAPI = async (matchedRecipe, id, tenantId, request, response, path, method, userContext) => { return await matchedRecipe.handleAPIRequest(id, tenantId, request, response, path, method, userContext); }; @@ -351,7 +351,10 @@ class SuperTokens { } return userContext._default.request; }; - const inputPluginList = (_a = config.plugins) !== null && _a !== void 0 ? _a : []; + const inputPluginList = + (_b = (_a = config.experimental) === null || _a === void 0 ? void 0 : _a.plugins) !== null && _b !== void 0 + ? _b + : []; this.pluginRouteHandlers = []; const finalPluginList = []; for (const plugin of inputPluginList) { @@ -396,9 +399,9 @@ class SuperTokens { this.appInfo = (0, utils_1.normaliseInputAppInfoOrThrowError)(config.appInfo); this.supertokens = config.supertokens; querier_1.Querier.init( - (_b = config.supertokens) === null || _b === void 0 + (_c = config.supertokens) === null || _c === void 0 ? void 0 - : _b.connectionURI + : _c.connectionURI .split(";") .filter((h) => h !== "") .map((h) => { @@ -407,9 +410,9 @@ class SuperTokens { basePath: new normalisedURLPath_1.default(h.trim()), }; }), - (_c = config.supertokens) === null || _c === void 0 ? void 0 : _c.apiKey, - (_d = config.supertokens) === null || _d === void 0 ? void 0 : _d.networkInterceptor, - (_e = config.supertokens) === null || _e === void 0 ? void 0 : _e.disableCoreCallCache + (_d = config.supertokens) === null || _d === void 0 ? void 0 : _d.apiKey, + (_e = config.supertokens) === null || _e === void 0 ? void 0 : _e.networkInterceptor, + (_f = config.supertokens) === null || _f === void 0 ? void 0 : _f.disableCoreCallCache ); if (config.recipeList === undefined || config.recipeList.length === 0) { throw new Error("Please provide at least one recipe to the supertokens.init function call"); diff --git a/lib/build/types.d.ts b/lib/build/types.d.ts index 025ff9c61..adb2916b6 100644 --- a/lib/build/types.d.ts +++ b/lib/build/types.d.ts @@ -129,7 +129,18 @@ export type TypeInput = { telemetry?: boolean; isInServerlessEnv?: boolean; debug?: boolean; - plugins?: SuperTokensPlugin[]; + /** + * + * Our experimental features are not yet stable and are subject to change. In practical terms, this means that their interface is subject to change without a major version update. + * They are also not tested as much as our "normal" features. + * + * If you want to use these features, or if you have any feedback please let us know at: + * https://supertokens.com/discord + * + */ + experimental?: { + plugins?: SuperTokensPlugin[]; + }; }; export type NetworkInterceptor = (request: HttpRequest, userContext: UserContext) => HttpRequest; export interface HttpRequest { diff --git a/lib/build/version.d.ts b/lib/build/version.d.ts index b4ea16c58..7dd8c3ed5 100644 --- a/lib/build/version.d.ts +++ b/lib/build/version.d.ts @@ -1,4 +1,4 @@ // @ts-nocheck -export declare const version = "21.1.0"; +export declare const version = "21.1.0-canary-plugins.0"; export declare const cdiSupported: string[]; export declare const dashboardVersion = "0.13"; diff --git a/lib/build/version.js b/lib/build/version.js index 2d83d58ed..899d9f720 100644 --- a/lib/build/version.js +++ b/lib/build/version.js @@ -15,7 +15,7 @@ exports.dashboardVersion = exports.cdiSupported = exports.version = void 0; * License for the specific language governing permissions and limitations * under the License. */ -exports.version = "21.1.0"; +exports.version = "21.1.0-canary-plugins.0"; exports.cdiSupported = ["5.2"]; // Note: The actual script import for dashboard uses v{DASHBOARD_VERSION} exports.dashboardVersion = "0.13"; diff --git a/lib/ts/supertokens.ts b/lib/ts/supertokens.ts index 0cde5d019..ec04bc55c 100644 --- a/lib/ts/supertokens.ts +++ b/lib/ts/supertokens.ts @@ -63,7 +63,7 @@ export default class SuperTokens { telemetryEnabled: boolean; constructor(config: TypeInput) { - const inputPluginList = config.plugins ?? []; + const inputPluginList = config.experimental?.plugins ?? []; this.pluginRouteHandlers = []; const finalPluginList: SuperTokensPlugin[] = []; for (const plugin of inputPluginList) { diff --git a/lib/ts/types.ts b/lib/ts/types.ts index 4bcda3c7c..1d1006bb5 100644 --- a/lib/ts/types.ts +++ b/lib/ts/types.ts @@ -145,7 +145,18 @@ export type TypeInput = { telemetry?: boolean; isInServerlessEnv?: boolean; debug?: boolean; - plugins?: SuperTokensPlugin[]; + /** + * + * Our experimental features are not yet stable and are subject to change. In practical terms, this means that their interface is subject to change without a major version update. + * They are also not tested as much as our "normal" features. + * + * If you want to use these features, or if you have any feedback please let us know at: + * https://supertokens.com/discord + * + */ + experimental?: { + plugins?: SuperTokensPlugin[]; + }; }; export type NetworkInterceptor = (request: HttpRequest, userContext: UserContext) => HttpRequest; diff --git a/lib/ts/version.ts b/lib/ts/version.ts index 7c52a9640..820f3a6ba 100644 --- a/lib/ts/version.ts +++ b/lib/ts/version.ts @@ -12,7 +12,7 @@ * License for the specific language governing permissions and limitations * under the License. */ -export const version = "21.1.0"; +export const version = "21.1.0-canary-plugins.0"; export const cdiSupported = ["5.2"]; diff --git a/package-lock.json b/package-lock.json index 4bde62250..6c2eea9fd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "supertokens-node", - "version": "21.1.0", + "version": "21.1.0-canary-plugins.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "supertokens-node", - "version": "21.1.0", + "version": "21.1.0-canary-plugins.0", "license": "Apache-2.0", "dependencies": { "buffer": "^6.0.3", diff --git a/package.json b/package.json index a5282ea2c..240ecf190 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "supertokens-node", - "version": "21.1.0", + "version": "21.1.0-canary-plugins.0", "description": "NodeJS driver for SuperTokens core", "main": "index.js", "scripts": { diff --git a/test/with-typescript/index.ts b/test/with-typescript/index.ts index e2e67ec2d..01818c860 100644 --- a/test/with-typescript/index.ts +++ b/test/with-typescript/index.ts @@ -2369,59 +2369,61 @@ const customPlugin = createPluginInitFunction<{ log: (input: any) => void }, { p Supertokens.init({ appInfo, recipeList: [OpenId.init()], - plugins: [ - { - id: "asdf", - compatibleSDKVersions: "1.2.3", - overrideMap: { - emailpassword: { - functions: (oI) => ({ - ...oI, - signIn: (input) => { - return oI.signIn(input); - }, - }), - apis: (apis) => ({ - ...apis, - signInPOST: (input) => { - return apis.signInPOST!(input); - }, - }), + experimental: { + plugins: [ + { + id: "asdf", + compatibleSDKVersions: "1.2.3", + overrideMap: { + emailpassword: { + functions: (oI) => ({ + ...oI, + signIn: (input) => { + return oI.signIn(input); + }, + }), + apis: (apis) => ({ + ...apis, + signInPOST: (input) => { + return apis.signInPOST!(input); + }, + }), + }, + passwordless: { + functions: (oI) => ({ + ...oI, + checkCode: (input) => { + return oI.checkCode(input); + }, + }), + }, }, - passwordless: { - functions: (oI) => ({ - ...oI, - checkCode: (input) => { - return oI.checkCode(input); + routeHandlers: [ + { + method: "get", + path: "/asdf", + verifySessionOptions: {}, + handler: async (req, res, userContext) => { + return { + status: 200, + body: {}, + }; }, - }), - }, + }, + ], }, - routeHandlers: [ - { - method: "get", - path: "/asdf", - verifySessionOptions: {}, - handler: async (req, res, userContext) => { - return { - status: 200, - body: {}, - }; + customPlugin({ + prefix: "asdf", + override: (oI) => ({ + ...oI, + log: (input: any) => { + console.log(`in log override - before oI.log`); + const res = oI.log(input); + console.log(`in log override - after oI.log`); + return res; }, - }, - ], - }, - customPlugin({ - prefix: "asdf", - override: (oI) => ({ - ...oI, - log: (input: any) => { - console.log(`in log override - before oI.log`); - const res = oI.log(input); - console.log(`in log override - after oI.log`); - return res; - }, + }), }), - }), - ], + ], + }, });