@supertokens-plugins/rownd-nodejs 0.3.0-beta.6 → 0.3.0-beta.8

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.
@@ -37,7 +37,6 @@ __export(setupCoreInstance_exports, {
37
37
  });
38
38
  module.exports = __toCommonJS(setupCoreInstance_exports);
39
39
  var import_zod2 = require("zod");
40
- var import_fs = __toESM(require("fs"));
41
40
 
42
41
  // scripts/scriptUtils.ts
43
42
  var fs = __toESM(require("fs/promises"));
@@ -137,6 +136,38 @@ function formatZodError(error) {
137
136
  (issue) => `${formatIssuePath(issue.path.filter((segment) => typeof segment === "string" || typeof segment === "number"))}: ${issue.message}`
138
137
  ).join("\n");
139
138
  }
139
+ function parseConfig(rawConfig, configDir = SCRIPT_DIR) {
140
+ const parsed = ConfigSchema.parse(rawConfig);
141
+ const checkpointFile = (0, import_node_path.isAbsolute)(parsed.checkpoint.file) ? parsed.checkpoint.file : (0, import_node_path.resolve)(configDir, parsed.checkpoint.file);
142
+ return {
143
+ limit: parsed.limit,
144
+ checkpoint: {
145
+ file: checkpointFile,
146
+ resume: parsed.checkpoint.resume
147
+ },
148
+ retry: parsed.retry,
149
+ rownd: parsed.rownd,
150
+ supertokens: parsed.supertokens,
151
+ thirdPartyProviders: parsed.thirdPartyProviders
152
+ };
153
+ }
154
+ async function loadConfig(configFilePath) {
155
+ const configFile = await fs.readFile(configFilePath, "utf8");
156
+ return parseConfig((0, import_yaml.parse)(configFile), (0, import_node_path.dirname)(configFilePath));
157
+ }
158
+ function parseRequiredConfigArg(args) {
159
+ for (let i = 0; i < args.length; i += 1) {
160
+ const arg = args[i];
161
+ if (arg === "--config" || arg === "-c") {
162
+ const value = args[i + 1];
163
+ if (!value) {
164
+ throw new Error(`Missing value for ${arg}`);
165
+ }
166
+ return (0, import_node_path.resolve)(value);
167
+ }
168
+ }
169
+ throw new Error("Missing required --config <path>");
170
+ }
140
171
  function hasHelpArg(args) {
141
172
  return args.includes("--help") || args.includes("-h");
142
173
  }
@@ -183,7 +214,17 @@ async function provisionSuperTokensInfrastructure(config, oidcClients) {
183
214
  "client_credentials",
184
215
  "implicit"
185
216
  ],
186
- tokenEndpointAuthMethod: "client_secret_post"
217
+ tokenEndpointAuthMethod: oidcClient.config.token_endpoint_auth_method ?? "client_secret_basic",
218
+ audience: [`app:${config.rownd.appId}`],
219
+ metadata: {
220
+ rowndOidcClientId: oidcClient.id,
221
+ rowndAppVariantId: credential.app_variant_id || void 0,
222
+ rowndAllowedScopes: oidcClient.config.allowed_scopes || [],
223
+ rowndApplicationType: oidcClient.config.application_type,
224
+ rowndIsPkceRequired: oidcClient.config.is_pkce_required,
225
+ rowndIsPkceSupported: oidcClient.config.is_pkce_supported,
226
+ rowndDeviceFlowEnabled: oidcClient.config.device_flow_enabled
227
+ }
187
228
  })
188
229
  }
189
230
  );
@@ -204,7 +245,12 @@ var RowndOidcClientSchema = import_zod2.z.object({
204
245
  config: import_zod2.z.object({
205
246
  redirect_uris: import_zod2.z.array(import_zod2.z.string()).optional(),
206
247
  post_logout_uris: import_zod2.z.array(import_zod2.z.string()).optional(),
207
- allowed_scopes: import_zod2.z.array(import_zod2.z.string()).optional()
248
+ allowed_scopes: import_zod2.z.array(import_zod2.z.string()).optional(),
249
+ token_endpoint_auth_method: import_zod2.z.enum(["client_secret_basic", "client_secret_post", "none"]).optional(),
250
+ application_type: import_zod2.z.enum(["web", "native"]).optional(),
251
+ is_pkce_required: import_zod2.z.boolean().optional(),
252
+ is_pkce_supported: import_zod2.z.boolean().optional(),
253
+ device_flow_enabled: import_zod2.z.boolean().optional()
208
254
  }),
209
255
  credentials: import_zod2.z.array(
210
256
  import_zod2.z.object({
@@ -239,25 +285,9 @@ async function runCli() {
239
285
  printHelp();
240
286
  return;
241
287
  }
242
- const config = {
243
- limit: 100,
244
- checkpoint: {
245
- file: "checkpoint.json",
246
- resume: false
247
- },
248
- retry: {
249
- maxAttempts: 3,
250
- initialDelayMs: 1e3
251
- },
252
- rownd: {
253
- appId: "app_cesvgomn94c4mz1j9g16d7tn",
254
- appKey: "key_ic6r0j87b8owmdc2h2nn3xmp",
255
- appSecret: "ras_1d15275403b64c1f25d8705c4d95f9049adcd95b8b5a555e",
256
- pageSize: 100
257
- }
258
- };
288
+ const config = await loadConfig(parseRequiredConfigArg(args));
259
289
  const oidcClients = await fetchRowndOidcClients(config);
260
- import_fs.default.writeFileSync("oidc-clients.json", JSON.stringify(oidcClients, null, 2));
290
+ await provisionSuperTokensInfrastructure(config, oidcClients);
261
291
  console.log("Successfully provisioned SuperTokens infrastructure.");
262
292
  }
263
293
  if (require.main === module) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supertokens-plugins/rownd-nodejs",
3
- "version": "0.3.0-beta.6",
3
+ "version": "0.3.0-beta.8",
4
4
  "description": "Rownd User Migration Plugin for SuperTokens",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",