Skip to content

Commit

Permalink
feat: mark plugins as experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
porcellus committed Feb 12, 2025
1 parent e699f38 commit 9fb6f3f
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 66 deletions.
17 changes: 10 additions & 7 deletions lib/build/supertokens.js

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

13 changes: 12 additions & 1 deletion lib/build/types.d.ts

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

2 changes: 1 addition & 1 deletion lib/build/version.d.ts

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

2 changes: 1 addition & 1 deletion lib/build/version.js

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

2 changes: 1 addition & 1 deletion lib/ts/supertokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
13 changes: 12 additions & 1 deletion lib/ts/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/ts/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"];

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
102 changes: 52 additions & 50 deletions test/with-typescript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
}),
}),
}),
],
],
},
});

0 comments on commit 9fb6f3f

Please sign in to comment.