@contentgrowth/content-auth 0.5.6 → 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/dist/backend/index.d.ts
CHANGED
|
@@ -829,6 +829,12 @@ interface AuthConfig {
|
|
|
829
829
|
database: D1Database | any;
|
|
830
830
|
secret: string;
|
|
831
831
|
baseUrl?: string;
|
|
832
|
+
/**
|
|
833
|
+
* Enable debug logging to see what config is passed to Better Auth.
|
|
834
|
+
* Useful for troubleshooting configuration issues.
|
|
835
|
+
* Default: false
|
|
836
|
+
*/
|
|
837
|
+
debug?: boolean;
|
|
832
838
|
/**
|
|
833
839
|
* Explicitly specify the database provider.
|
|
834
840
|
* Defaults to 'sqlite' (which works for D1).
|
package/dist/backend/index.js
CHANGED
|
@@ -360,6 +360,7 @@ var createAuth = (config) => {
|
|
|
360
360
|
database,
|
|
361
361
|
secret,
|
|
362
362
|
baseUrl,
|
|
363
|
+
debug = false,
|
|
363
364
|
provider: _,
|
|
364
365
|
useCloudflareNativeHashing = true,
|
|
365
366
|
emailVerification,
|
|
@@ -385,13 +386,20 @@ var createAuth = (config) => {
|
|
|
385
386
|
const orgTableName = schemaMapping?.organization?.tableName || "organizations";
|
|
386
387
|
const memberTableName = schemaMapping?.member?.tableName || "members";
|
|
387
388
|
const invitationTableName = schemaMapping?.invitation?.tableName || "invitations";
|
|
388
|
-
const
|
|
389
|
-
const
|
|
390
|
-
const
|
|
391
|
-
const
|
|
392
|
-
const
|
|
393
|
-
const
|
|
394
|
-
const
|
|
389
|
+
const mergedUserAdditionalFields = { ...schemaMapping?.user?.additionalFields, ...user?.additionalFields };
|
|
390
|
+
const mergedSessionAdditionalFields = { ...schemaMapping?.session?.additionalFields, ...session?.additionalFields };
|
|
391
|
+
const mergedAccountAdditionalFields = { ...schemaMapping?.account?.additionalFields, ...account?.additionalFields };
|
|
392
|
+
const mergedVerificationAdditionalFields = { ...schemaMapping?.verification?.additionalFields, ...verification?.additionalFields };
|
|
393
|
+
const mergedOrgAdditionalFields = { ...schemaMapping?.organization?.additionalFields, ...organization?.additionalFields };
|
|
394
|
+
const mergedMemberAdditionalFields = { ...schemaMapping?.member?.additionalFields, ...member?.additionalFields };
|
|
395
|
+
const mergedInvitationAdditionalFields = { ...schemaMapping?.invitation?.additionalFields, ...invitation?.additionalFields };
|
|
396
|
+
const usersTable = createUsersTable(userTableName, schemaMapping?.user?.fields, mergedUserAdditionalFields);
|
|
397
|
+
const organizationsTable = createOrganizationsTable(orgTableName, schemaMapping?.organization?.fields, mergedOrgAdditionalFields);
|
|
398
|
+
const sessionsTable = createSessionsTable(sessionTableName, usersTable, schemaMapping?.session?.fields, mergedSessionAdditionalFields);
|
|
399
|
+
const accountsTable = createAccountsTable(accountTableName, usersTable, schemaMapping?.account?.fields, mergedAccountAdditionalFields);
|
|
400
|
+
const verificationsTable = createVerificationsTable(verificationTableName, schemaMapping?.verification?.fields, mergedVerificationAdditionalFields);
|
|
401
|
+
const membersTable = createMembersTable(memberTableName, organizationsTable, usersTable, schemaMapping?.member?.fields, mergedMemberAdditionalFields);
|
|
402
|
+
const invitationsTable = createInvitationsTable(invitationTableName, organizationsTable, usersTable, schemaMapping?.invitation?.fields, mergedInvitationAdditionalFields);
|
|
395
403
|
const userKey = schemaMapping?.user?.tableName || "user";
|
|
396
404
|
const sessionKey = schemaMapping?.session?.tableName || "session";
|
|
397
405
|
const accountKey = schemaMapping?.account?.tableName || "account";
|
|
@@ -429,6 +437,43 @@ var createAuth = (config) => {
|
|
|
429
437
|
const sessionConfig = buildModelConfig(schemaMapping?.session);
|
|
430
438
|
const accountConfig = buildModelConfig(schemaMapping?.account);
|
|
431
439
|
const verificationConfig = buildModelConfig(schemaMapping?.verification);
|
|
440
|
+
if (debug) {
|
|
441
|
+
console.log("[ContentAuth-DEBUG] ========================================");
|
|
442
|
+
console.log("[ContentAuth-DEBUG] Configuration passed to content-auth:");
|
|
443
|
+
console.log("[ContentAuth-DEBUG] - baseUrl:", baseUrl);
|
|
444
|
+
console.log("[ContentAuth-DEBUG] - provider:", provider);
|
|
445
|
+
console.log("[ContentAuth-DEBUG] - useCloudflareNativeHashing:", useCloudflareNativeHashing);
|
|
446
|
+
console.log("[ContentAuth-DEBUG] - emailVerification:", JSON.stringify(emailVerification || "not configured"));
|
|
447
|
+
console.log("[ContentAuth-DEBUG] - turnstile:", turnstileConfig ? "configured" : "not configured");
|
|
448
|
+
console.log("[ContentAuth-DEBUG] - emailNormalization:", JSON.stringify(emailNormalization || "not configured"));
|
|
449
|
+
console.log("[ContentAuth-DEBUG] - signInTracking:", JSON.stringify(signInTracking || "not configured"));
|
|
450
|
+
console.log("[ContentAuth-DEBUG] - onSignup:", onSignup ? "provided" : "not provided");
|
|
451
|
+
console.log("[ContentAuth-DEBUG] - onSignin:", onSignin ? "provided" : "not provided");
|
|
452
|
+
console.log("[ContentAuth-DEBUG] ========================================");
|
|
453
|
+
console.log("[ContentAuth-DEBUG] Schema Mapping:");
|
|
454
|
+
console.log("[ContentAuth-DEBUG] - schemaMapping:", JSON.stringify(schemaMapping, null, 2));
|
|
455
|
+
console.log("[ContentAuth-DEBUG] ========================================");
|
|
456
|
+
console.log("[ContentAuth-DEBUG] Direct model configs passed:");
|
|
457
|
+
console.log("[ContentAuth-DEBUG] - user:", JSON.stringify(user, null, 2));
|
|
458
|
+
console.log("[ContentAuth-DEBUG] - session:", JSON.stringify(session || "not provided"));
|
|
459
|
+
console.log("[ContentAuth-DEBUG] - account:", JSON.stringify(account || "not provided"));
|
|
460
|
+
console.log("[ContentAuth-DEBUG] - verification:", JSON.stringify(verification || "not provided"));
|
|
461
|
+
console.log("[ContentAuth-DEBUG] - organization:", JSON.stringify(organization || "not provided"));
|
|
462
|
+
console.log("[ContentAuth-DEBUG] - member:", JSON.stringify(member || "not provided"));
|
|
463
|
+
console.log("[ContentAuth-DEBUG] - invitation:", JSON.stringify(invitation || "not provided"));
|
|
464
|
+
console.log("[ContentAuth-DEBUG] ========================================");
|
|
465
|
+
console.log("[ContentAuth-DEBUG] Built model configs (from schemaMapping):");
|
|
466
|
+
console.log("[ContentAuth-DEBUG] - userConfig:", JSON.stringify(userConfig, null, 2));
|
|
467
|
+
console.log("[ContentAuth-DEBUG] - sessionConfig:", JSON.stringify(sessionConfig || "not built"));
|
|
468
|
+
console.log("[ContentAuth-DEBUG] - accountConfig:", JSON.stringify(accountConfig || "not built"));
|
|
469
|
+
console.log("[ContentAuth-DEBUG] - verificationConfig:", JSON.stringify(verificationConfig || "not built"));
|
|
470
|
+
console.log("[ContentAuth-DEBUG] ========================================");
|
|
471
|
+
console.log("[ContentAuth-DEBUG] Merged additionalFields for Drizzle schema:");
|
|
472
|
+
console.log("[ContentAuth-DEBUG] - user additionalFields:", JSON.stringify(mergedUserAdditionalFields, null, 2));
|
|
473
|
+
console.log("[ContentAuth-DEBUG] - session additionalFields:", JSON.stringify(mergedSessionAdditionalFields || "none"));
|
|
474
|
+
console.log("[ContentAuth-DEBUG] - account additionalFields:", JSON.stringify(mergedAccountAdditionalFields || "none"));
|
|
475
|
+
console.log("[ContentAuth-DEBUG] ========================================");
|
|
476
|
+
}
|
|
432
477
|
const userIdColumn = schemaMapping?.user?.fields?.id || "id";
|
|
433
478
|
const emailConfig = rest.emailAndPassword || { enabled: true };
|
|
434
479
|
const { emailAndPassword, hooks: userHooks, ...otherOptions } = rest;
|
|
@@ -569,6 +614,29 @@ var createAuth = (config) => {
|
|
|
569
614
|
hooks: contentAuthHooks,
|
|
570
615
|
...otherOptions
|
|
571
616
|
});
|
|
617
|
+
if (debug) {
|
|
618
|
+
console.log("[ContentAuth-DEBUG] ========================================");
|
|
619
|
+
console.log("[ContentAuth-DEBUG] Final config passed to betterAuth():");
|
|
620
|
+
console.log("[ContentAuth-DEBUG] - baseURL:", baseUrl);
|
|
621
|
+
console.log("[ContentAuth-DEBUG] - emailAndPassword:", JSON.stringify(emailPasswordOptions));
|
|
622
|
+
console.log("[ContentAuth-DEBUG] - emailVerification:", emailVerification ? "passed" : "not passed");
|
|
623
|
+
console.log("[ContentAuth-DEBUG] ========================================");
|
|
624
|
+
console.log("[ContentAuth-DEBUG] Merged model configs passed to betterAuth():");
|
|
625
|
+
const mergedUserConfig = userConfig || user ? { ...userConfig, ...user } : void 0;
|
|
626
|
+
console.log("[ContentAuth-DEBUG] - user:", JSON.stringify(mergedUserConfig, null, 2));
|
|
627
|
+
const mergedSessionConfig = sessionConfig || session ? { ...sessionConfig, ...session } : void 0;
|
|
628
|
+
console.log("[ContentAuth-DEBUG] - session:", JSON.stringify(mergedSessionConfig || "not passed"));
|
|
629
|
+
const mergedAccountConfig = accountConfig || account ? { ...accountConfig, ...account } : void 0;
|
|
630
|
+
console.log("[ContentAuth-DEBUG] - account:", JSON.stringify(mergedAccountConfig || "not passed"));
|
|
631
|
+
const mergedVerificationConfig = verificationConfig || verification ? { ...verificationConfig, ...verification } : void 0;
|
|
632
|
+
console.log("[ContentAuth-DEBUG] - verification:", JSON.stringify(mergedVerificationConfig || "not passed"));
|
|
633
|
+
console.log("[ContentAuth-DEBUG] - organization:", organization ? "passed" : "not passed");
|
|
634
|
+
console.log("[ContentAuth-DEBUG] - member:", member ? "passed" : "not passed");
|
|
635
|
+
console.log("[ContentAuth-DEBUG] - invitation:", invitation ? "passed" : "not passed");
|
|
636
|
+
console.log("[ContentAuth-DEBUG] ========================================");
|
|
637
|
+
console.log("[ContentAuth-DEBUG] Other options passed to betterAuth():", Object.keys(otherOptions).join(", "));
|
|
638
|
+
console.log("[ContentAuth-DEBUG] ========================================");
|
|
639
|
+
}
|
|
572
640
|
return auth;
|
|
573
641
|
};
|
|
574
642
|
var authMiddleware = (auth) => {
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentgrowth/content-auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Better Auth wrapper with UI components for Cloudflare Workers & Pages. Includes custom schema mapping, Turnstile bot protection, and email normalization.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|