@supertokens-plugins/rownd-nodejs 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -44,6 +44,26 @@ SuperTokens.init({
44
44
  });
45
45
  ```
46
46
 
47
+ ### Disabling Rownd User Migration
48
+
49
+ After migration is complete, disable Rownd user and session migration to run
50
+ the compatibility endpoints without Rownd credentials:
51
+
52
+ ```typescript
53
+ RowndMigrationPlugin.init({
54
+ disableRowndUserMigration: true,
55
+ });
56
+ ```
57
+
58
+ This prevents the Rownd API client and the `/plugin/rownd/migrate` and
59
+ `/plugin/migrate-session` routes from being initialized. Other compatibility
60
+ endpoints remain enabled. Passwordless and email-verification links continue to
61
+ use the Rownd Hub with an internal dummy app key when `rowndAppKey` is omitted.
62
+ The plugin logs a warning during initialization while migration is disabled.
63
+
64
+ Without `disableRowndUserMigration: true`, both `rowndAppKey` and
65
+ `rowndAppSecret` are required.
66
+
47
67
  ### Session Claim Fields
48
68
 
49
69
  Schema fields can be copied into the SuperTokens access-token payload by setting `include_in_session_claims: true`. Use `session_claim_name` when the claim name should differ from the Rownd data field name.
package/dist/index.d.mts CHANGED
@@ -670,8 +670,14 @@ type RowndSubBrandConfigInput = RowndAppConfigInput & {
670
670
  };
671
671
  };
672
672
  interface RowndPluginConfig {
673
- rowndAppKey: string;
674
- rowndAppSecret: string;
673
+ rowndAppKey?: string;
674
+ rowndAppSecret?: string;
675
+ /**
676
+ * Disables Rownd user and session migration. This must be enabled when
677
+ * rowndAppKey or rowndAppSecret is omitted.
678
+ * @default false
679
+ */
680
+ disableRowndUserMigration?: boolean;
675
681
  enableDebugLogs?: boolean;
676
682
  clientDomains?: RowndClientDomains;
677
683
  crossDeviceConfirmationBypass?: {
@@ -756,7 +762,8 @@ interface MigrationResponse {
756
762
  }
757
763
  interface RowndPluginNormalisedConfig {
758
764
  rowndAppKey: string;
759
- rowndAppSecret: string;
765
+ rowndAppSecret?: string;
766
+ disableRowndUserMigration: boolean;
760
767
  enableDebugLogs?: boolean;
761
768
  clientDomains?: RowndClientDomains;
762
769
  crossDeviceConfirmationBypass?: {
@@ -861,7 +868,7 @@ type CreateMagicLinkWithConfirmationBypassInput = {
861
868
  };
862
869
  declare function createMagicLinkWithConfirmationBypass(input: CreateMagicLinkWithConfirmationBypassInput): Promise<string>;
863
870
 
864
- declare function setRowndClient(client: IRowndClient): void;
871
+ declare function setRowndClient(client: IRowndClient | undefined): void;
865
872
  declare function getRowndClient(): IRowndClient;
866
873
 
867
874
  declare const _default: {
package/dist/index.d.ts CHANGED
@@ -670,8 +670,14 @@ type RowndSubBrandConfigInput = RowndAppConfigInput & {
670
670
  };
671
671
  };
672
672
  interface RowndPluginConfig {
673
- rowndAppKey: string;
674
- rowndAppSecret: string;
673
+ rowndAppKey?: string;
674
+ rowndAppSecret?: string;
675
+ /**
676
+ * Disables Rownd user and session migration. This must be enabled when
677
+ * rowndAppKey or rowndAppSecret is omitted.
678
+ * @default false
679
+ */
680
+ disableRowndUserMigration?: boolean;
675
681
  enableDebugLogs?: boolean;
676
682
  clientDomains?: RowndClientDomains;
677
683
  crossDeviceConfirmationBypass?: {
@@ -756,7 +762,8 @@ interface MigrationResponse {
756
762
  }
757
763
  interface RowndPluginNormalisedConfig {
758
764
  rowndAppKey: string;
759
- rowndAppSecret: string;
765
+ rowndAppSecret?: string;
766
+ disableRowndUserMigration: boolean;
760
767
  enableDebugLogs?: boolean;
761
768
  clientDomains?: RowndClientDomains;
762
769
  crossDeviceConfirmationBypass?: {
@@ -861,7 +868,7 @@ type CreateMagicLinkWithConfirmationBypassInput = {
861
868
  };
862
869
  declare function createMagicLinkWithConfirmationBypass(input: CreateMagicLinkWithConfirmationBypassInput): Promise<string>;
863
870
 
864
- declare function setRowndClient(client: IRowndClient): void;
871
+ declare function setRowndClient(client: IRowndClient | undefined): void;
865
872
  declare function getRowndClient(): IRowndClient;
866
873
 
867
874
  declare const _default: {
package/dist/index.js CHANGED
@@ -2889,6 +2889,7 @@ function validateWritableFields(fields) {
2889
2889
  }
2890
2890
 
2891
2891
  // src/plugin.ts
2892
+ var DISABLED_MIGRATION_ROWND_APP_KEY = "migration-disabled";
2892
2893
  var verifyRowndUserSessionOptions = {
2893
2894
  sessionRequired: true,
2894
2895
  overrideGlobalClaimValidators: (validators) => validators.filter((validator) => {
@@ -2897,10 +2898,10 @@ var verifyRowndUserSessionOptions = {
2897
2898
  };
2898
2899
  var init = createPluginInitFunction(
2899
2900
  (pluginConfig2) => {
2900
- const rowndClient2 = (0, import_node.createInstance)({
2901
+ const rowndClient2 = !pluginConfig2.disableRowndUserMigration && pluginConfig2.rowndAppSecret ? (0, import_node.createInstance)({
2901
2902
  app_key: pluginConfig2.rowndAppKey,
2902
2903
  app_secret: pluginConfig2.rowndAppSecret
2903
- });
2904
+ }) : void 0;
2904
2905
  const telemetryClient = createClient(pluginConfig2.telemetry);
2905
2906
  let hubBootstrapParams;
2906
2907
  const addHubBootstrapParams = (input, linkKey, targetPath) => {
@@ -2940,6 +2941,11 @@ var init = createPluginInitFunction(
2940
2941
  id: PLUGIN_ID,
2941
2942
  compatibleSDKVersions: PLUGIN_SDK_VERSION,
2942
2943
  init: async () => {
2944
+ if (pluginConfig2.disableRowndUserMigration) {
2945
+ console.warn(
2946
+ "RowndMigrationPlugin: Rownd user and session migration is disabled."
2947
+ );
2948
+ }
2943
2949
  if (!import_supertokens_node4.default.isRecipeInitialized("session")) {
2944
2950
  console.warn(
2945
2951
  "RowndMigrationPlugin: Session recipe is not initialized. Session migration will fail."
@@ -2983,11 +2989,11 @@ var init = createPluginInitFunction(
2983
2989
  method: "post",
2984
2990
  handler: withRequestHandler(handleGuestLogin(routeHandlerDeps))
2985
2991
  },
2986
- {
2992
+ ...!pluginConfig2.disableRowndUserMigration ? [{
2987
2993
  path: `${apiBasePath}${HANDLE_BASE_PATH}/migrate`,
2988
2994
  method: "post",
2989
2995
  handler: withRequestHandler(handleMigrate(routeHandlerDeps))
2990
- },
2996
+ }] : [],
2991
2997
  {
2992
2998
  path: `${apiBasePath}/plugin/passwordless-cross-device-confirmation/validate`,
2993
2999
  method: "post",
@@ -2995,11 +3001,11 @@ var init = createPluginInitFunction(
2995
3001
  handleValidatePasswordlessConfirmationBypass(routeHandlerDeps)
2996
3002
  )
2997
3003
  },
2998
- {
3004
+ ...!pluginConfig2.disableRowndUserMigration ? [{
2999
3005
  path: `${apiBasePath}/plugin/migrate-session`,
3000
3006
  method: "post",
3001
3007
  handler: withRequestHandler(handleMigrate(routeHandlerDeps))
3002
- },
3008
+ }] : [],
3003
3009
  {
3004
3010
  path: `${apiBasePath}${HANDLE_BASE_PATH}/signout`,
3005
3011
  method: "post",
@@ -3379,9 +3385,14 @@ var init = createPluginInitFunction(
3379
3385
  },
3380
3386
  () => ({}),
3381
3387
  (config2) => {
3382
- if (!config2?.rowndAppKey || !config2?.rowndAppSecret) {
3388
+ if (config2?.disableRowndUserMigration !== void 0 && typeof config2.disableRowndUserMigration !== "boolean") {
3389
+ throw new Error(
3390
+ "disableRowndUserMigration must be a boolean in plugin config"
3391
+ );
3392
+ }
3393
+ if (!config2?.disableRowndUserMigration && (!config2?.rowndAppKey || !config2?.rowndAppSecret)) {
3383
3394
  throw new Error(
3384
- "Missing rowndAppKey or rowndAppSecret in plugin config"
3395
+ "Missing rowndAppKey or rowndAppSecret in plugin config. Set disableRowndUserMigration to true to disable migration."
3385
3396
  );
3386
3397
  }
3387
3398
  if (config2.telemetry?.provider === "axiom") {
@@ -3402,8 +3413,9 @@ var init = createPluginInitFunction(
3402
3413
  validateClientDomainUrl(key, value);
3403
3414
  }
3404
3415
  return {
3405
- rowndAppKey: config2.rowndAppKey,
3416
+ rowndAppKey: config2.rowndAppKey ?? DISABLED_MIGRATION_ROWND_APP_KEY,
3406
3417
  rowndAppSecret: config2.rowndAppSecret,
3418
+ disableRowndUserMigration: config2.disableRowndUserMigration === true,
3407
3419
  enableDebugLogs: config2.enableDebugLogs,
3408
3420
  clientDomains: config2.clientDomains,
3409
3421
  crossDeviceConfirmationBypass: config2.crossDeviceConfirmationBypass,
package/dist/index.mjs CHANGED
@@ -2866,6 +2866,7 @@ function validateWritableFields(fields) {
2866
2866
  }
2867
2867
 
2868
2868
  // src/plugin.ts
2869
+ var DISABLED_MIGRATION_ROWND_APP_KEY = "migration-disabled";
2869
2870
  var verifyRowndUserSessionOptions = {
2870
2871
  sessionRequired: true,
2871
2872
  overrideGlobalClaimValidators: (validators) => validators.filter((validator) => {
@@ -2874,10 +2875,10 @@ var verifyRowndUserSessionOptions = {
2874
2875
  };
2875
2876
  var init = createPluginInitFunction(
2876
2877
  (pluginConfig2) => {
2877
- const rowndClient2 = createInstance({
2878
+ const rowndClient2 = !pluginConfig2.disableRowndUserMigration && pluginConfig2.rowndAppSecret ? createInstance({
2878
2879
  app_key: pluginConfig2.rowndAppKey,
2879
2880
  app_secret: pluginConfig2.rowndAppSecret
2880
- });
2881
+ }) : void 0;
2881
2882
  const telemetryClient = createClient(pluginConfig2.telemetry);
2882
2883
  let hubBootstrapParams;
2883
2884
  const addHubBootstrapParams = (input, linkKey, targetPath) => {
@@ -2917,6 +2918,11 @@ var init = createPluginInitFunction(
2917
2918
  id: PLUGIN_ID,
2918
2919
  compatibleSDKVersions: PLUGIN_SDK_VERSION,
2919
2920
  init: async () => {
2921
+ if (pluginConfig2.disableRowndUserMigration) {
2922
+ console.warn(
2923
+ "RowndMigrationPlugin: Rownd user and session migration is disabled."
2924
+ );
2925
+ }
2920
2926
  if (!supertokens.isRecipeInitialized("session")) {
2921
2927
  console.warn(
2922
2928
  "RowndMigrationPlugin: Session recipe is not initialized. Session migration will fail."
@@ -2960,11 +2966,11 @@ var init = createPluginInitFunction(
2960
2966
  method: "post",
2961
2967
  handler: withRequestHandler(handleGuestLogin(routeHandlerDeps))
2962
2968
  },
2963
- {
2969
+ ...!pluginConfig2.disableRowndUserMigration ? [{
2964
2970
  path: `${apiBasePath}${HANDLE_BASE_PATH}/migrate`,
2965
2971
  method: "post",
2966
2972
  handler: withRequestHandler(handleMigrate(routeHandlerDeps))
2967
- },
2973
+ }] : [],
2968
2974
  {
2969
2975
  path: `${apiBasePath}/plugin/passwordless-cross-device-confirmation/validate`,
2970
2976
  method: "post",
@@ -2972,11 +2978,11 @@ var init = createPluginInitFunction(
2972
2978
  handleValidatePasswordlessConfirmationBypass(routeHandlerDeps)
2973
2979
  )
2974
2980
  },
2975
- {
2981
+ ...!pluginConfig2.disableRowndUserMigration ? [{
2976
2982
  path: `${apiBasePath}/plugin/migrate-session`,
2977
2983
  method: "post",
2978
2984
  handler: withRequestHandler(handleMigrate(routeHandlerDeps))
2979
- },
2985
+ }] : [],
2980
2986
  {
2981
2987
  path: `${apiBasePath}${HANDLE_BASE_PATH}/signout`,
2982
2988
  method: "post",
@@ -3356,9 +3362,14 @@ var init = createPluginInitFunction(
3356
3362
  },
3357
3363
  () => ({}),
3358
3364
  (config2) => {
3359
- if (!config2?.rowndAppKey || !config2?.rowndAppSecret) {
3365
+ if (config2?.disableRowndUserMigration !== void 0 && typeof config2.disableRowndUserMigration !== "boolean") {
3366
+ throw new Error(
3367
+ "disableRowndUserMigration must be a boolean in plugin config"
3368
+ );
3369
+ }
3370
+ if (!config2?.disableRowndUserMigration && (!config2?.rowndAppKey || !config2?.rowndAppSecret)) {
3360
3371
  throw new Error(
3361
- "Missing rowndAppKey or rowndAppSecret in plugin config"
3372
+ "Missing rowndAppKey or rowndAppSecret in plugin config. Set disableRowndUserMigration to true to disable migration."
3362
3373
  );
3363
3374
  }
3364
3375
  if (config2.telemetry?.provider === "axiom") {
@@ -3379,8 +3390,9 @@ var init = createPluginInitFunction(
3379
3390
  validateClientDomainUrl(key, value);
3380
3391
  }
3381
3392
  return {
3382
- rowndAppKey: config2.rowndAppKey,
3393
+ rowndAppKey: config2.rowndAppKey ?? DISABLED_MIGRATION_ROWND_APP_KEY,
3383
3394
  rowndAppSecret: config2.rowndAppSecret,
3395
+ disableRowndUserMigration: config2.disableRowndUserMigration === true,
3384
3396
  enableDebugLogs: config2.enableDebugLogs,
3385
3397
  clientDomains: config2.clientDomains,
3386
3398
  crossDeviceConfirmationBypass: config2.crossDeviceConfirmationBypass,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supertokens-plugins/rownd-nodejs",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Rownd User Migration Plugin for SuperTokens",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",