@wopr-network/platform-core 1.14.3 → 1.14.5
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/dist/auth/better-auth.js +12 -1
- package/package.json +1 -1
- package/src/auth/better-auth.ts +10 -1
package/dist/auth/better-auth.js
CHANGED
|
@@ -189,7 +189,18 @@ export function initBetterAuth(config) {
|
|
|
189
189
|
export async function runAuthMigrations() {
|
|
190
190
|
if (!_config)
|
|
191
191
|
throw new Error("BetterAuth not initialized — call initBetterAuth() first");
|
|
192
|
-
|
|
192
|
+
// better-auth 1.5.x moved getMigrations from "better-auth/db" to "better-auth/db/migration"
|
|
193
|
+
let getMigrations;
|
|
194
|
+
try {
|
|
195
|
+
({ getMigrations } = (await import("better-auth/db/migration")));
|
|
196
|
+
}
|
|
197
|
+
catch (err) {
|
|
198
|
+
// Only fall back if the module path doesn't exist (ERR_MODULE_NOT_FOUND / ERR_PACKAGE_PATH_NOT_EXPORTED)
|
|
199
|
+
const code = err.code;
|
|
200
|
+
if (code !== "ERR_MODULE_NOT_FOUND" && code !== "ERR_PACKAGE_PATH_NOT_EXPORTED")
|
|
201
|
+
throw err;
|
|
202
|
+
({ getMigrations } = (await import("better-auth/db")));
|
|
203
|
+
}
|
|
193
204
|
const { runMigrations } = await getMigrations(authOptions(_config));
|
|
194
205
|
await runMigrations();
|
|
195
206
|
if (_config.twoFactor !== false) {
|
package/package.json
CHANGED
package/src/auth/better-auth.ts
CHANGED
|
@@ -264,7 +264,16 @@ export function initBetterAuth(config: BetterAuthConfig): void {
|
|
|
264
264
|
export async function runAuthMigrations(): Promise<void> {
|
|
265
265
|
if (!_config) throw new Error("BetterAuth not initialized — call initBetterAuth() first");
|
|
266
266
|
type DbModule = { getMigrations: (opts: BetterAuthOptions) => Promise<{ runMigrations: () => Promise<void> }> };
|
|
267
|
-
|
|
267
|
+
// better-auth 1.5.x moved getMigrations from "better-auth/db" to "better-auth/db/migration"
|
|
268
|
+
let getMigrations: DbModule["getMigrations"];
|
|
269
|
+
try {
|
|
270
|
+
({ getMigrations } = (await import("better-auth/db/migration")) as unknown as DbModule);
|
|
271
|
+
} catch (err: unknown) {
|
|
272
|
+
// Only fall back if the module path doesn't exist (ERR_MODULE_NOT_FOUND / ERR_PACKAGE_PATH_NOT_EXPORTED)
|
|
273
|
+
const code = (err as { code?: string }).code;
|
|
274
|
+
if (code !== "ERR_MODULE_NOT_FOUND" && code !== "ERR_PACKAGE_PATH_NOT_EXPORTED") throw err;
|
|
275
|
+
({ getMigrations } = (await import("better-auth/db")) as unknown as DbModule);
|
|
276
|
+
}
|
|
268
277
|
const { runMigrations } = await getMigrations(authOptions(_config));
|
|
269
278
|
await runMigrations();
|
|
270
279
|
if (_config.twoFactor !== false) {
|