@supertokens-plugins/rownd-nodejs 0.3.0-beta.1 → 0.3.0-beta.3
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 +7 -4
- package/dist/bulkMigrate.js +44 -584
- package/dist/index.d.mts +12 -20
- package/dist/index.d.ts +12 -20
- package/dist/index.js +1444 -1455
- package/dist/index.mjs +1441 -1453
- package/package.json +1 -3
package/dist/bulkMigrate.js
CHANGED
|
@@ -6,9 +6,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
10
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
|
-
};
|
|
12
9
|
var __export = (target, all) => {
|
|
13
10
|
for (var name in all)
|
|
14
11
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -31,121 +28,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
31
28
|
));
|
|
32
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
33
30
|
|
|
34
|
-
// ../../node_modules/has-flag/index.js
|
|
35
|
-
var require_has_flag = __commonJS({
|
|
36
|
-
"../../node_modules/has-flag/index.js"(exports2, module2) {
|
|
37
|
-
"use strict";
|
|
38
|
-
module2.exports = (flag, argv = process.argv) => {
|
|
39
|
-
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
40
|
-
const position = argv.indexOf(prefix + flag);
|
|
41
|
-
const terminatorPosition = argv.indexOf("--");
|
|
42
|
-
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
// ../../node_modules/supports-color/index.js
|
|
48
|
-
var require_supports_color = __commonJS({
|
|
49
|
-
"../../node_modules/supports-color/index.js"(exports2, module2) {
|
|
50
|
-
"use strict";
|
|
51
|
-
var os = require("os");
|
|
52
|
-
var tty = require("tty");
|
|
53
|
-
var hasFlag = require_has_flag();
|
|
54
|
-
var { env } = process;
|
|
55
|
-
var forceColor;
|
|
56
|
-
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
57
|
-
forceColor = 0;
|
|
58
|
-
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
59
|
-
forceColor = 1;
|
|
60
|
-
}
|
|
61
|
-
if ("FORCE_COLOR" in env) {
|
|
62
|
-
if (env.FORCE_COLOR === "true") {
|
|
63
|
-
forceColor = 1;
|
|
64
|
-
} else if (env.FORCE_COLOR === "false") {
|
|
65
|
-
forceColor = 0;
|
|
66
|
-
} else {
|
|
67
|
-
forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
function translateLevel(level) {
|
|
71
|
-
if (level === 0) {
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
return {
|
|
75
|
-
level,
|
|
76
|
-
hasBasic: true,
|
|
77
|
-
has256: level >= 2,
|
|
78
|
-
has16m: level >= 3
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
function supportsColor(haveStream, streamIsTTY) {
|
|
82
|
-
if (forceColor === 0) {
|
|
83
|
-
return 0;
|
|
84
|
-
}
|
|
85
|
-
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
86
|
-
return 3;
|
|
87
|
-
}
|
|
88
|
-
if (hasFlag("color=256")) {
|
|
89
|
-
return 2;
|
|
90
|
-
}
|
|
91
|
-
if (haveStream && !streamIsTTY && forceColor === void 0) {
|
|
92
|
-
return 0;
|
|
93
|
-
}
|
|
94
|
-
const min = forceColor || 0;
|
|
95
|
-
if (env.TERM === "dumb") {
|
|
96
|
-
return min;
|
|
97
|
-
}
|
|
98
|
-
if (process.platform === "win32") {
|
|
99
|
-
const osRelease = os.release().split(".");
|
|
100
|
-
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
101
|
-
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
102
|
-
}
|
|
103
|
-
return 1;
|
|
104
|
-
}
|
|
105
|
-
if ("CI" in env) {
|
|
106
|
-
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
|
107
|
-
return 1;
|
|
108
|
-
}
|
|
109
|
-
return min;
|
|
110
|
-
}
|
|
111
|
-
if ("TEAMCITY_VERSION" in env) {
|
|
112
|
-
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
113
|
-
}
|
|
114
|
-
if (env.COLORTERM === "truecolor") {
|
|
115
|
-
return 3;
|
|
116
|
-
}
|
|
117
|
-
if ("TERM_PROGRAM" in env) {
|
|
118
|
-
const version = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
119
|
-
switch (env.TERM_PROGRAM) {
|
|
120
|
-
case "iTerm.app":
|
|
121
|
-
return version >= 3 ? 3 : 2;
|
|
122
|
-
case "Apple_Terminal":
|
|
123
|
-
return 2;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
if (/-256(color)?$/i.test(env.TERM)) {
|
|
127
|
-
return 2;
|
|
128
|
-
}
|
|
129
|
-
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
130
|
-
return 1;
|
|
131
|
-
}
|
|
132
|
-
if ("COLORTERM" in env) {
|
|
133
|
-
return 1;
|
|
134
|
-
}
|
|
135
|
-
return min;
|
|
136
|
-
}
|
|
137
|
-
function getSupportLevel(stream) {
|
|
138
|
-
const level = supportsColor(stream, stream && stream.isTTY);
|
|
139
|
-
return translateLevel(level);
|
|
140
|
-
}
|
|
141
|
-
module2.exports = {
|
|
142
|
-
supportsColor: getSupportLevel,
|
|
143
|
-
stdout: translateLevel(supportsColor(true, tty.isatty(1))),
|
|
144
|
-
stderr: translateLevel(supportsColor(true, tty.isatty(2)))
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
|
|
149
31
|
// scripts/bulkMigrate.ts
|
|
150
32
|
var bulkMigrate_exports = {};
|
|
151
33
|
__export(bulkMigrate_exports, {
|
|
@@ -157,391 +39,24 @@ module.exports = __toCommonJS(bulkMigrate_exports);
|
|
|
157
39
|
var fs2 = __toESM(require("fs/promises"));
|
|
158
40
|
var import_zod2 = require("zod");
|
|
159
41
|
|
|
160
|
-
// src/
|
|
42
|
+
// src/rownd-compatibility.ts
|
|
161
43
|
var import_supertokens_node = __toESM(require("supertokens-node"));
|
|
162
|
-
var import_accountlinking = __toESM(require("supertokens-node/recipe/accountlinking"));
|
|
163
|
-
var import_emailverification = __toESM(require("supertokens-node/recipe/emailverification"));
|
|
164
|
-
var import_passwordless = __toESM(require("supertokens-node/recipe/passwordless"));
|
|
165
|
-
var import_session = __toESM(require("supertokens-node/recipe/session"));
|
|
166
|
-
var import_claims = require("supertokens-node/recipe/session/claims");
|
|
167
|
-
var import_thirdparty = __toESM(require("supertokens-node/recipe/thirdparty"));
|
|
168
|
-
var import_usermetadata2 = __toESM(require("supertokens-node/recipe/usermetadata"));
|
|
169
44
|
|
|
170
45
|
// src/constants.ts
|
|
171
|
-
var PLUGIN_ID = "supertokens-plugin-rownd";
|
|
172
|
-
var PLUGIN_SDK_VERSION = ["23.0.0", "23.0.1", ">=23.0.1"];
|
|
173
46
|
var GUEST_AUTH_METHOD_ID = "guest";
|
|
174
47
|
var ANONYMOUS_AUTH_METHOD_ID = "anonymous";
|
|
175
48
|
|
|
176
|
-
//
|
|
177
|
-
var
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
createDebug.coerce = coerce;
|
|
187
|
-
createDebug.disable = disable;
|
|
188
|
-
createDebug.enable = enable;
|
|
189
|
-
createDebug.enabled = enabled;
|
|
190
|
-
createDebug.humanize = env.humanize;
|
|
191
|
-
createDebug.destroy = destroy;
|
|
192
|
-
Object.keys(env).forEach((key) => {
|
|
193
|
-
createDebug[key] = env[key];
|
|
194
|
-
});
|
|
195
|
-
createDebug.names = [];
|
|
196
|
-
createDebug.skips = [];
|
|
197
|
-
createDebug.formatters = {};
|
|
198
|
-
function selectColor(namespace) {
|
|
199
|
-
let hash = 0;
|
|
200
|
-
for (let i = 0; i < namespace.length; i++) {
|
|
201
|
-
hash = (hash << 5) - hash + namespace.charCodeAt(i);
|
|
202
|
-
hash |= 0;
|
|
203
|
-
}
|
|
204
|
-
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
|
205
|
-
}
|
|
206
|
-
createDebug.selectColor = selectColor;
|
|
207
|
-
function createDebug(namespace) {
|
|
208
|
-
let prevTime;
|
|
209
|
-
let enableOverride = null;
|
|
210
|
-
let namespacesCache;
|
|
211
|
-
let enabledCache;
|
|
212
|
-
function debug(...args) {
|
|
213
|
-
if (!debug.enabled) {
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
const self = debug;
|
|
217
|
-
const curr = Number(/* @__PURE__ */ new Date());
|
|
218
|
-
const ms = curr - (prevTime || curr);
|
|
219
|
-
self.diff = ms;
|
|
220
|
-
self.prev = prevTime;
|
|
221
|
-
self.curr = curr;
|
|
222
|
-
prevTime = curr;
|
|
223
|
-
args[0] = createDebug.coerce(args[0]);
|
|
224
|
-
if (typeof args[0] !== "string") {
|
|
225
|
-
args.unshift("%O");
|
|
226
|
-
}
|
|
227
|
-
let index = 0;
|
|
228
|
-
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
|
229
|
-
if (match === "%%") {
|
|
230
|
-
return "%";
|
|
231
|
-
}
|
|
232
|
-
index++;
|
|
233
|
-
const formatter = createDebug.formatters[format];
|
|
234
|
-
if (typeof formatter === "function") {
|
|
235
|
-
const val = args[index];
|
|
236
|
-
match = formatter.call(self, val);
|
|
237
|
-
args.splice(index, 1);
|
|
238
|
-
index--;
|
|
239
|
-
}
|
|
240
|
-
return match;
|
|
241
|
-
});
|
|
242
|
-
createDebug.formatArgs.call(self, args);
|
|
243
|
-
const logFn = self.log || createDebug.log;
|
|
244
|
-
logFn.apply(self, args);
|
|
245
|
-
}
|
|
246
|
-
debug.namespace = namespace;
|
|
247
|
-
debug.useColors = createDebug.useColors();
|
|
248
|
-
debug.color = createDebug.selectColor(namespace);
|
|
249
|
-
debug.extend = extend;
|
|
250
|
-
debug.destroy = createDebug.destroy;
|
|
251
|
-
Object.defineProperty(debug, "enabled", {
|
|
252
|
-
enumerable: true,
|
|
253
|
-
configurable: false,
|
|
254
|
-
get: () => {
|
|
255
|
-
if (enableOverride !== null) {
|
|
256
|
-
return enableOverride;
|
|
257
|
-
}
|
|
258
|
-
if (namespacesCache !== createDebug.namespaces) {
|
|
259
|
-
namespacesCache = createDebug.namespaces;
|
|
260
|
-
enabledCache = createDebug.enabled(namespace);
|
|
261
|
-
}
|
|
262
|
-
return enabledCache;
|
|
263
|
-
},
|
|
264
|
-
set: (v) => {
|
|
265
|
-
enableOverride = v;
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
if (typeof createDebug.init === "function") {
|
|
269
|
-
createDebug.init(debug);
|
|
270
|
-
}
|
|
271
|
-
return debug;
|
|
272
|
-
}
|
|
273
|
-
function extend(namespace, delimiter) {
|
|
274
|
-
const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
|
|
275
|
-
newDebug.log = this.log;
|
|
276
|
-
return newDebug;
|
|
277
|
-
}
|
|
278
|
-
function enable(namespaces) {
|
|
279
|
-
createDebug.save(namespaces);
|
|
280
|
-
createDebug.namespaces = namespaces;
|
|
281
|
-
createDebug.names = [];
|
|
282
|
-
createDebug.skips = [];
|
|
283
|
-
const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
|
|
284
|
-
for (const ns of split) {
|
|
285
|
-
if (ns[0] === "-") {
|
|
286
|
-
createDebug.skips.push(ns.slice(1));
|
|
287
|
-
} else {
|
|
288
|
-
createDebug.names.push(ns);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
function matchesTemplate(search, template) {
|
|
293
|
-
let searchIndex = 0;
|
|
294
|
-
let templateIndex = 0;
|
|
295
|
-
let starIndex = -1;
|
|
296
|
-
let matchIndex = 0;
|
|
297
|
-
while (searchIndex < search.length) {
|
|
298
|
-
if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
|
|
299
|
-
if (template[templateIndex] === "*") {
|
|
300
|
-
starIndex = templateIndex;
|
|
301
|
-
matchIndex = searchIndex;
|
|
302
|
-
templateIndex++;
|
|
303
|
-
} else {
|
|
304
|
-
searchIndex++;
|
|
305
|
-
templateIndex++;
|
|
306
|
-
}
|
|
307
|
-
} else if (starIndex !== -1) {
|
|
308
|
-
templateIndex = starIndex + 1;
|
|
309
|
-
matchIndex++;
|
|
310
|
-
searchIndex = matchIndex;
|
|
311
|
-
} else {
|
|
312
|
-
return false;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
while (templateIndex < template.length && template[templateIndex] === "*") {
|
|
316
|
-
templateIndex++;
|
|
317
|
-
}
|
|
318
|
-
return templateIndex === template.length;
|
|
319
|
-
}
|
|
320
|
-
function disable() {
|
|
321
|
-
const namespaces = [...createDebug.names, ...createDebug.skips.map((namespace) => "-" + namespace)].join(",");
|
|
322
|
-
createDebug.enable("");
|
|
323
|
-
return namespaces;
|
|
324
|
-
}
|
|
325
|
-
function enabled(name) {
|
|
326
|
-
for (const skip of createDebug.skips) {
|
|
327
|
-
if (matchesTemplate(name, skip)) {
|
|
328
|
-
return false;
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
for (const ns of createDebug.names) {
|
|
332
|
-
if (matchesTemplate(name, ns)) {
|
|
333
|
-
return true;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
return false;
|
|
337
|
-
}
|
|
338
|
-
function coerce(val) {
|
|
339
|
-
if (val instanceof Error) {
|
|
340
|
-
return val.stack || val.message;
|
|
341
|
-
}
|
|
342
|
-
return val;
|
|
343
|
-
}
|
|
344
|
-
function destroy() {
|
|
345
|
-
console.warn(
|
|
346
|
-
"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."
|
|
347
|
-
);
|
|
348
|
-
}
|
|
349
|
-
createDebug.enable(createDebug.load());
|
|
350
|
-
return createDebug;
|
|
351
|
-
}
|
|
352
|
-
var common_default = setup;
|
|
353
|
-
|
|
354
|
-
// ../../shared/nodejs/src/log/logger.ts
|
|
355
|
-
var BASIC_COLORS = [6, 2, 3, 4, 5, 1];
|
|
356
|
-
var EXTENDED_COLORS = [
|
|
357
|
-
20,
|
|
358
|
-
21,
|
|
359
|
-
26,
|
|
360
|
-
27,
|
|
361
|
-
32,
|
|
362
|
-
33,
|
|
363
|
-
38,
|
|
364
|
-
39,
|
|
365
|
-
40,
|
|
366
|
-
41,
|
|
367
|
-
42,
|
|
368
|
-
43,
|
|
369
|
-
44,
|
|
370
|
-
45,
|
|
371
|
-
56,
|
|
372
|
-
57,
|
|
373
|
-
62,
|
|
374
|
-
63,
|
|
375
|
-
68,
|
|
376
|
-
69,
|
|
377
|
-
74,
|
|
378
|
-
75,
|
|
379
|
-
76,
|
|
380
|
-
77,
|
|
381
|
-
78,
|
|
382
|
-
79,
|
|
383
|
-
80,
|
|
384
|
-
81,
|
|
385
|
-
92,
|
|
386
|
-
93,
|
|
387
|
-
98,
|
|
388
|
-
99,
|
|
389
|
-
112,
|
|
390
|
-
113,
|
|
391
|
-
128,
|
|
392
|
-
129,
|
|
393
|
-
134,
|
|
394
|
-
135,
|
|
395
|
-
148,
|
|
396
|
-
149,
|
|
397
|
-
160,
|
|
398
|
-
161,
|
|
399
|
-
162,
|
|
400
|
-
163,
|
|
401
|
-
164,
|
|
402
|
-
165,
|
|
403
|
-
166,
|
|
404
|
-
167,
|
|
405
|
-
168,
|
|
406
|
-
169,
|
|
407
|
-
170,
|
|
408
|
-
171,
|
|
409
|
-
172,
|
|
410
|
-
173,
|
|
411
|
-
178,
|
|
412
|
-
179,
|
|
413
|
-
184,
|
|
414
|
-
185,
|
|
415
|
-
196,
|
|
416
|
-
197,
|
|
417
|
-
198,
|
|
418
|
-
199,
|
|
419
|
-
200,
|
|
420
|
-
201,
|
|
421
|
-
202,
|
|
422
|
-
203,
|
|
423
|
-
204,
|
|
424
|
-
205,
|
|
425
|
-
206,
|
|
426
|
-
207,
|
|
427
|
-
208,
|
|
428
|
-
209,
|
|
429
|
-
214,
|
|
430
|
-
215,
|
|
431
|
-
220,
|
|
432
|
-
221
|
|
433
|
-
];
|
|
434
|
-
function supportsExtendedColors() {
|
|
435
|
-
try {
|
|
436
|
-
const supportsColor = require_supports_color();
|
|
437
|
-
return supportsColor && (supportsColor.stderr || supportsColor).level >= 2;
|
|
438
|
-
} catch {
|
|
439
|
-
return false;
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
function shouldUseColors() {
|
|
443
|
-
return false;
|
|
444
|
-
}
|
|
445
|
-
function formatArgs(args) {
|
|
446
|
-
const { namespace, useColors, color } = this;
|
|
447
|
-
if (useColors) {
|
|
448
|
-
const colorCode = color < 8 ? `3${color}` : `38;5;${color}`;
|
|
449
|
-
const prefix = `\x1B[${colorCode};1m${namespace}\x1B[0m`;
|
|
450
|
-
args[0] = `${prefix} ${args[0]}`.split("\n").join(`
|
|
451
|
-
${prefix} `);
|
|
452
|
-
args.push(`\x1B[${colorCode}m+${humanizeTime(this.diff)}\x1B[0m`);
|
|
453
|
-
} else {
|
|
454
|
-
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
455
|
-
args[0] = `${timestamp} ${namespace} ${args[0]}`;
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
function writeOutput(...args) {
|
|
459
|
-
process.stderr.write(import_util.default.format(...args) + "\n");
|
|
460
|
-
}
|
|
461
|
-
function saveConfig(namespaces) {
|
|
462
|
-
if (namespaces) {
|
|
463
|
-
process.env.DEBUG = namespaces;
|
|
464
|
-
} else {
|
|
465
|
-
delete process.env.DEBUG;
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
function loadConfig() {
|
|
469
|
-
return process.env.DEBUG;
|
|
470
|
-
}
|
|
471
|
-
function humanizeTime(milliseconds) {
|
|
472
|
-
if (milliseconds >= 1e3) {
|
|
473
|
-
const seconds = Math.round(milliseconds / 1e3);
|
|
474
|
-
return `${seconds}s`;
|
|
475
|
-
}
|
|
476
|
-
return `${milliseconds}ms`;
|
|
477
|
-
}
|
|
478
|
-
function createLoggerConfig() {
|
|
479
|
-
const colors = supportsExtendedColors() ? EXTENDED_COLORS : BASIC_COLORS;
|
|
480
|
-
return {
|
|
481
|
-
colors,
|
|
482
|
-
useColors: shouldUseColors,
|
|
483
|
-
formatArgs,
|
|
484
|
-
log: writeOutput,
|
|
485
|
-
save: saveConfig,
|
|
486
|
-
load: loadConfig,
|
|
487
|
-
humanize: humanizeTime
|
|
488
|
-
};
|
|
489
|
-
}
|
|
490
|
-
var config = createLoggerConfig();
|
|
491
|
-
var logger = common_default(config);
|
|
492
|
-
if (logger.formatters) {
|
|
493
|
-
logger.formatters.o = function(value) {
|
|
494
|
-
return import_util.default.inspect(value, { colors: this.useColors, compact: true }).split("\n").map((line) => line.trim()).join(" ");
|
|
495
|
-
};
|
|
496
|
-
logger.formatters.O = function(value) {
|
|
497
|
-
return import_util.default.inspect(value, { colors: this.useColors, compact: false });
|
|
498
|
-
};
|
|
49
|
+
// src/rownd-compatibility.ts
|
|
50
|
+
var IDENTITY_USER_DATA_FIELDS = /* @__PURE__ */ new Set([
|
|
51
|
+
"user_id",
|
|
52
|
+
"email",
|
|
53
|
+
"phone_number",
|
|
54
|
+
"google_id",
|
|
55
|
+
"apple_id"
|
|
56
|
+
]);
|
|
57
|
+
function isIdentityField(field) {
|
|
58
|
+
return IDENTITY_USER_DATA_FIELDS.has(field);
|
|
499
59
|
}
|
|
500
|
-
var logger_default = logger;
|
|
501
|
-
|
|
502
|
-
// ../../shared/nodejs/src/log/index.ts
|
|
503
|
-
var log_default = logger_default;
|
|
504
|
-
|
|
505
|
-
// ../../shared/nodejs/src/logger.ts
|
|
506
|
-
var getFileLocation = () => {
|
|
507
|
-
let errorObject = new Error();
|
|
508
|
-
if (errorObject.stack === void 0) {
|
|
509
|
-
return "N/A";
|
|
510
|
-
}
|
|
511
|
-
let errorStack = errorObject.stack.split("\n");
|
|
512
|
-
for (let i = 1; i < errorStack.length; i++) {
|
|
513
|
-
if (!errorStack[i]?.includes("logger.js")) {
|
|
514
|
-
return errorStack[i]?.match(/(?<=\().+?(?=\))/g);
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
return "N/A";
|
|
518
|
-
};
|
|
519
|
-
var buildLogger = (pluginId, version, { fileLocation = true } = {}) => {
|
|
520
|
-
const namespace = `com.supertokens.plugin.${pluginId}`;
|
|
521
|
-
function logDebugMessage2(message) {
|
|
522
|
-
if (log_default.enabled(namespace)) {
|
|
523
|
-
log_default(namespace)(
|
|
524
|
-
`{t: "${(/* @__PURE__ */ new Date()).toISOString()}", message: "${message}", file: "${fileLocation ? getFileLocation() : "N/A"}" version: "${version}"}`
|
|
525
|
-
);
|
|
526
|
-
console.log();
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
function enableDebugLogs2() {
|
|
530
|
-
log_default.enable(namespace);
|
|
531
|
-
}
|
|
532
|
-
return {
|
|
533
|
-
logDebugMessage: logDebugMessage2,
|
|
534
|
-
enableDebugLogs: enableDebugLogs2
|
|
535
|
-
};
|
|
536
|
-
};
|
|
537
|
-
|
|
538
|
-
// src/logger.ts
|
|
539
|
-
var { logDebugMessage, enableDebugLogs } = buildLogger(
|
|
540
|
-
PLUGIN_ID,
|
|
541
|
-
PLUGIN_SDK_VERSION
|
|
542
|
-
);
|
|
543
|
-
|
|
544
|
-
// src/pluginImplementation.ts
|
|
545
60
|
function mapRowndUserToSuperTokens(rowndUser) {
|
|
546
61
|
const loginMethods = [];
|
|
547
62
|
const rowndUserData = rowndUser.data || {};
|
|
@@ -606,16 +121,6 @@ function mapRowndUserToSuperTokens(rowndUser) {
|
|
|
606
121
|
userMetadata
|
|
607
122
|
};
|
|
608
123
|
}
|
|
609
|
-
var IDENTITY_USER_DATA_FIELDS = /* @__PURE__ */ new Set([
|
|
610
|
-
"user_id",
|
|
611
|
-
"email",
|
|
612
|
-
"phone_number",
|
|
613
|
-
"google_id",
|
|
614
|
-
"apple_id"
|
|
615
|
-
]);
|
|
616
|
-
function isIdentityField(field) {
|
|
617
|
-
return IDENTITY_USER_DATA_FIELDS.has(field);
|
|
618
|
-
}
|
|
619
124
|
function buildRowndUserMetadata(rowndUser) {
|
|
620
125
|
const metadata = {
|
|
621
126
|
...rowndUser.meta || {},
|
|
@@ -628,51 +133,6 @@ function buildRowndUserMetadata(rowndUser) {
|
|
|
628
133
|
}
|
|
629
134
|
return metadata;
|
|
630
135
|
}
|
|
631
|
-
var RowndIsAnonymousClaim = new import_claims.BooleanClaim({
|
|
632
|
-
key: "is_anonymous",
|
|
633
|
-
fetchValue: async (userId) => {
|
|
634
|
-
const user = await import_supertokens_node.default.getUser(userId);
|
|
635
|
-
const effectiveAuthLevel = getEffectiveAuthLevel(user);
|
|
636
|
-
return effectiveAuthLevel === GUEST_AUTH_METHOD_ID;
|
|
637
|
-
}
|
|
638
|
-
});
|
|
639
|
-
function getThirdPartyId(method) {
|
|
640
|
-
return method.thirdPartyId || method.thirdParty?.id;
|
|
641
|
-
}
|
|
642
|
-
function getThirdPartyUserId(method) {
|
|
643
|
-
return method.thirdPartyUserId || method.thirdParty?.userId;
|
|
644
|
-
}
|
|
645
|
-
function getGuestAuthLevel(user) {
|
|
646
|
-
const guestMethod = user?.loginMethods.find(isGuestLoginMethod);
|
|
647
|
-
return guestMethod ? GUEST_AUTH_METHOD_ID : void 0;
|
|
648
|
-
}
|
|
649
|
-
function isGuestLoginMethod(method) {
|
|
650
|
-
const thirdPartyId = getThirdPartyId(method);
|
|
651
|
-
return method.recipeId === "thirdparty" && (thirdPartyId === GUEST_AUTH_METHOD_ID || thirdPartyId === ANONYMOUS_AUTH_METHOD_ID);
|
|
652
|
-
}
|
|
653
|
-
function hasVerifiedRealLoginMethod(user) {
|
|
654
|
-
return !!user?.loginMethods.some((method) => {
|
|
655
|
-
if (isGuestLoginMethod(method)) {
|
|
656
|
-
return false;
|
|
657
|
-
}
|
|
658
|
-
if (method.recipeId === "passwordless") {
|
|
659
|
-
return !!(method.email || method.phoneNumber);
|
|
660
|
-
}
|
|
661
|
-
if (method.recipeId === "thirdparty") {
|
|
662
|
-
return !!getThirdPartyUserId(method) && method.verified === true;
|
|
663
|
-
}
|
|
664
|
-
if (method.recipeId === "emailpassword") {
|
|
665
|
-
return !!method.email && method.verified === true;
|
|
666
|
-
}
|
|
667
|
-
return method.verified === true;
|
|
668
|
-
});
|
|
669
|
-
}
|
|
670
|
-
function getEffectiveAuthLevel(user, originalAuthLevel, verifiedData) {
|
|
671
|
-
if (hasVerifiedRealLoginMethod(user)) {
|
|
672
|
-
return "verified";
|
|
673
|
-
}
|
|
674
|
-
return getGuestAuthLevel(user) || originalAuthLevel || (verifiedData && Object.keys(verifiedData).length > 0 ? "verified" : "unverified");
|
|
675
|
-
}
|
|
676
136
|
|
|
677
137
|
// scripts/scriptUtils.ts
|
|
678
138
|
var fs = __toESM(require("fs/promises"));
|
|
@@ -787,7 +247,7 @@ function parseConfig(rawConfig, configDir = SCRIPT_DIR) {
|
|
|
787
247
|
thirdPartyProviders: parsed.thirdPartyProviders
|
|
788
248
|
};
|
|
789
249
|
}
|
|
790
|
-
async function
|
|
250
|
+
async function loadConfig(configFilePath) {
|
|
791
251
|
const configFile = await fs.readFile(configFilePath, "utf8");
|
|
792
252
|
return parseConfig((0, import_yaml.parse)(configFile), (0, import_node_path.dirname)(configFilePath));
|
|
793
253
|
}
|
|
@@ -823,25 +283,25 @@ function parseRowndUser(parsed) {
|
|
|
823
283
|
};
|
|
824
284
|
return { rowndUser, rowndUserId };
|
|
825
285
|
}
|
|
826
|
-
async function fetchRowndUsersPage(
|
|
286
|
+
async function fetchRowndUsersPage(config, cursor, pageSize) {
|
|
827
287
|
const url = new URL(
|
|
828
|
-
`/applications/${
|
|
288
|
+
`/applications/${config.rownd.appId}/users/data`,
|
|
829
289
|
"https://api.rownd.io"
|
|
830
290
|
);
|
|
831
291
|
if (cursor) {
|
|
832
292
|
url.searchParams.set("after", cursor);
|
|
833
293
|
}
|
|
834
294
|
url.searchParams.set("include_duplicates", "true");
|
|
835
|
-
url.searchParams.set("page_size", String(pageSize ??
|
|
295
|
+
url.searchParams.set("page_size", String(pageSize ?? config.rownd.pageSize));
|
|
836
296
|
const response = await fetchWithRetry({
|
|
837
297
|
url: url.toString(),
|
|
838
298
|
requestInit: {
|
|
839
299
|
headers: {
|
|
840
|
-
"x-rownd-app-key":
|
|
841
|
-
"x-rownd-app-secret":
|
|
300
|
+
"x-rownd-app-key": config.rownd.appKey,
|
|
301
|
+
"x-rownd-app-secret": config.rownd.appSecret
|
|
842
302
|
}
|
|
843
303
|
},
|
|
844
|
-
retryConfig:
|
|
304
|
+
retryConfig: config.retry,
|
|
845
305
|
operation: "Fetching Rownd users"
|
|
846
306
|
});
|
|
847
307
|
if (!response.ok) {
|
|
@@ -950,24 +410,24 @@ async function appendFailedMappings(filePath, failedMappings) {
|
|
|
950
410
|
);
|
|
951
411
|
await fs2.rename(tempFile, filePath);
|
|
952
412
|
}
|
|
953
|
-
async function stageUsersForImport(
|
|
413
|
+
async function stageUsersForImport(config) {
|
|
954
414
|
const headers = {
|
|
955
415
|
"Content-Type": "application/json"
|
|
956
416
|
};
|
|
957
|
-
if (
|
|
958
|
-
headers["api-key"] =
|
|
417
|
+
if (config.supertokens.apiKey) {
|
|
418
|
+
headers["api-key"] = config.supertokens.apiKey;
|
|
959
419
|
}
|
|
960
420
|
const response = await fetchWithRetry({
|
|
961
421
|
url: new URL(
|
|
962
422
|
"/bulk-import/users",
|
|
963
|
-
|
|
423
|
+
config.supertokens.connectionURI
|
|
964
424
|
).toString(),
|
|
965
425
|
requestInit: {
|
|
966
426
|
method: "POST",
|
|
967
427
|
headers,
|
|
968
|
-
body: JSON.stringify({ users:
|
|
428
|
+
body: JSON.stringify({ users: config.users })
|
|
969
429
|
},
|
|
970
|
-
retryConfig:
|
|
430
|
+
retryConfig: config.retry,
|
|
971
431
|
operation: "Importing users into SuperTokens"
|
|
972
432
|
});
|
|
973
433
|
if (!response.ok) {
|
|
@@ -976,42 +436,42 @@ async function stageUsersForImport(config2) {
|
|
|
976
436
|
);
|
|
977
437
|
}
|
|
978
438
|
}
|
|
979
|
-
async function importUsersBatch(
|
|
980
|
-
for (let index = 0; index < users.length; index +=
|
|
981
|
-
const batch = users.slice(index, index +
|
|
439
|
+
async function importUsersBatch(config, users, totalImportedBeforeBatch) {
|
|
440
|
+
for (let index = 0; index < users.length; index += config.supertokens.batchSize) {
|
|
441
|
+
const batch = users.slice(index, index + config.supertokens.batchSize);
|
|
982
442
|
console.log(
|
|
983
|
-
`Importing batch ${Math.floor(totalImportedBeforeBatch /
|
|
443
|
+
`Importing batch ${Math.floor(totalImportedBeforeBatch / config.supertokens.batchSize) + 1} (${batch.length} users)`
|
|
984
444
|
);
|
|
985
445
|
await stageUsersForImport({
|
|
986
446
|
users: batch.map((entry) => entry.user),
|
|
987
|
-
supertokens:
|
|
988
|
-
retry:
|
|
447
|
+
supertokens: config.supertokens,
|
|
448
|
+
retry: config.retry
|
|
989
449
|
});
|
|
990
450
|
}
|
|
991
451
|
}
|
|
992
|
-
async function migrateRowndUsersToSuperTokens(
|
|
993
|
-
const checkpoint =
|
|
994
|
-
const failedMappingsFile = getFailedMappingsFilePath(
|
|
452
|
+
async function migrateRowndUsersToSuperTokens(config) {
|
|
453
|
+
const checkpoint = config.checkpoint.resume ? await loadCheckpoint(config.checkpoint.file) : null;
|
|
454
|
+
const failedMappingsFile = getFailedMappingsFilePath(config.checkpoint.file);
|
|
995
455
|
let cursor = checkpoint?.cursor;
|
|
996
456
|
let totalProcessed = 0;
|
|
997
457
|
let totalImported = checkpoint?.importedCount ?? 0;
|
|
998
458
|
let totalSkipped = 0;
|
|
999
|
-
if (
|
|
459
|
+
if (config.checkpoint.resume) {
|
|
1000
460
|
console.log(
|
|
1001
461
|
checkpoint ? `Resuming migration from cursor ${checkpoint.cursor ?? "<start>"}` : "No checkpoint found. Starting a fresh migration."
|
|
1002
462
|
);
|
|
1003
463
|
}
|
|
1004
|
-
while (totalProcessed <
|
|
1005
|
-
const remaining = Number.isFinite(
|
|
1006
|
-
const requestedPageSize = Number.isFinite(
|
|
464
|
+
while (totalProcessed < config.limit) {
|
|
465
|
+
const remaining = Number.isFinite(config.limit) ? Math.max(config.limit - totalProcessed, 0) : config.rownd.pageSize;
|
|
466
|
+
const requestedPageSize = Number.isFinite(config.limit) ? Math.min(config.rownd.pageSize, remaining) : config.rownd.pageSize;
|
|
1007
467
|
if (requestedPageSize === 0) {
|
|
1008
468
|
break;
|
|
1009
469
|
}
|
|
1010
470
|
console.log(
|
|
1011
|
-
`Fetching page ${Math.floor(totalProcessed /
|
|
471
|
+
`Fetching page ${Math.floor(totalProcessed / config.rownd.pageSize) + 1}`
|
|
1012
472
|
);
|
|
1013
473
|
const pageUsers = await fetchRowndUsersPage(
|
|
1014
|
-
|
|
474
|
+
config,
|
|
1015
475
|
cursor,
|
|
1016
476
|
requestedPageSize
|
|
1017
477
|
);
|
|
@@ -1039,11 +499,11 @@ async function migrateRowndUsersToSuperTokens(config2) {
|
|
|
1039
499
|
}
|
|
1040
500
|
await appendFailedMappings(failedMappingsFile, failedMappings);
|
|
1041
501
|
totalSkipped += failedMappings.length;
|
|
1042
|
-
await importUsersBatch(
|
|
502
|
+
await importUsersBatch(config, mappedUsers, totalImported);
|
|
1043
503
|
totalProcessed += pageUsers.length;
|
|
1044
504
|
totalImported += mappedUsers.length;
|
|
1045
505
|
cursor = pageUsers[pageUsers.length - 1]?.rowndUserId;
|
|
1046
|
-
await saveCheckpoint(
|
|
506
|
+
await saveCheckpoint(config.checkpoint.file, {
|
|
1047
507
|
cursor,
|
|
1048
508
|
importedCount: totalImported,
|
|
1049
509
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -1067,12 +527,12 @@ async function runCli() {
|
|
|
1067
527
|
printHelp();
|
|
1068
528
|
return;
|
|
1069
529
|
}
|
|
1070
|
-
const
|
|
1071
|
-
const result = await migrateRowndUsersToSuperTokens(
|
|
530
|
+
const config = await loadConfig(parseRequiredConfigArg(args));
|
|
531
|
+
const result = await migrateRowndUsersToSuperTokens(config);
|
|
1072
532
|
console.log(`Migrated ${result.totalImported} users`);
|
|
1073
533
|
if (result.totalSkipped > 0) {
|
|
1074
534
|
console.warn(
|
|
1075
|
-
`Skipped ${result.totalSkipped} users. Details saved to ${getFailedMappingsFilePath(
|
|
535
|
+
`Skipped ${result.totalSkipped} users. Details saved to ${getFailedMappingsFilePath(config.checkpoint.file)}`
|
|
1076
536
|
);
|
|
1077
537
|
}
|
|
1078
538
|
}
|