@contentgrowth/content-auth 0.6.0 → 0.6.2

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.
@@ -9,7 +9,7 @@ import {
9
9
  normalizeEmail,
10
10
  schema_exports,
11
11
  verifyTurnstile
12
- } from "../chunk-2NKKUZUC.js";
12
+ } from "../chunk-MDSQC2UU.js";
13
13
  import "../chunk-R5U7XKVJ.js";
14
14
  export {
15
15
  Hono,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  authClient
3
- } from "./chunk-NKDKDBM2.js";
3
+ } from "./chunk-W5RBQBED.js";
4
4
 
5
5
  // src/frontend/components/react/AuthForm.tsx
6
6
  import { useState, useRef, useEffect } from "react";
@@ -386,13 +386,20 @@ var createAuth = (config) => {
386
386
  const orgTableName = schemaMapping?.organization?.tableName || "organizations";
387
387
  const memberTableName = schemaMapping?.member?.tableName || "members";
388
388
  const invitationTableName = schemaMapping?.invitation?.tableName || "invitations";
389
- const usersTable = createUsersTable(userTableName, schemaMapping?.user?.fields, schemaMapping?.user?.additionalFields);
390
- const organizationsTable = createOrganizationsTable(orgTableName, schemaMapping?.organization?.fields, schemaMapping?.organization?.additionalFields);
391
- const sessionsTable = createSessionsTable(sessionTableName, usersTable, schemaMapping?.session?.fields, schemaMapping?.session?.additionalFields);
392
- const accountsTable = createAccountsTable(accountTableName, usersTable, schemaMapping?.account?.fields, schemaMapping?.account?.additionalFields);
393
- const verificationsTable = createVerificationsTable(verificationTableName, schemaMapping?.verification?.fields, schemaMapping?.verification?.additionalFields);
394
- const membersTable = createMembersTable(memberTableName, organizationsTable, usersTable, schemaMapping?.member?.fields, schemaMapping?.member?.additionalFields);
395
- const invitationsTable = createInvitationsTable(invitationTableName, organizationsTable, usersTable, schemaMapping?.invitation?.fields, schemaMapping?.invitation?.additionalFields);
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);
396
403
  const userKey = schemaMapping?.user?.tableName || "user";
397
404
  const sessionKey = schemaMapping?.session?.tableName || "session";
398
405
  const accountKey = schemaMapping?.account?.tableName || "account";
@@ -461,6 +468,11 @@ var createAuth = (config) => {
461
468
  console.log("[ContentAuth-DEBUG] - accountConfig:", JSON.stringify(accountConfig || "not built"));
462
469
  console.log("[ContentAuth-DEBUG] - verificationConfig:", JSON.stringify(verificationConfig || "not built"));
463
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] ========================================");
464
476
  }
465
477
  const userIdColumn = schemaMapping?.user?.fields?.id || "id";
466
478
  const emailConfig = rest.emailAndPassword || { enabled: true };
@@ -1,12 +1,16 @@
1
1
  // src/frontend/client.ts
2
2
  import { createAuthClient } from "better-auth/react";
3
3
  import { organizationClient } from "better-auth/client/plugins";
4
- var createClient = (baseUrl) => {
4
+ var createClient = (baseUrl, options = {}) => {
5
+ const { refetchOnWindowFocus = false } = options;
5
6
  return createAuthClient({
6
7
  baseURL: baseUrl,
7
8
  plugins: [
8
9
  organizationClient()
9
- ]
10
+ ],
11
+ sessionOptions: {
12
+ refetchOnWindowFocus
13
+ }
10
14
  });
11
15
  };
12
16
  var authClient = createClient();
@@ -3,7 +3,21 @@ import * as _better_fetch_fetch from '@better-fetch/fetch';
3
3
  import * as better_auth from 'better-auth';
4
4
  import * as better_auth_plugins from 'better-auth/plugins';
5
5
 
6
- declare const createClient: (baseUrl?: string) => {
6
+ interface ContentAuthClientOptions {
7
+ /**
8
+ * Controls whether the session is re-fetched when the browser window
9
+ * regains focus (e.g. lock/unlock screen, switching apps in a PWA).
10
+ *
11
+ * Defaults to `false`. Re-fetching on focus causes a React re-render
12
+ * cascade that can interrupt active client-side sessions (e.g. vocabulary
13
+ * review flows) by triggering component remounts.
14
+ *
15
+ * Set to `true` only for apps that need the session to be always
16
+ * up-to-date immediately after the user returns to the tab.
17
+ */
18
+ refetchOnWindowFocus?: boolean;
19
+ }
20
+ declare const createClient: (baseUrl?: string, options?: ContentAuthClientOptions) => {
7
21
  useActiveOrganization: () => {
8
22
  data: better_auth.Prettify<{
9
23
  id: string;
@@ -3194,4 +3208,4 @@ declare const authClient: {
3194
3208
  };
3195
3209
  };
3196
3210
 
3197
- export { authClient, createClient };
3211
+ export { type ContentAuthClientOptions, authClient, createClient };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  authClient,
3
3
  createClient
4
- } from "../chunk-NKDKDBM2.js";
4
+ } from "../chunk-W5RBQBED.js";
5
5
  import "../chunk-R5U7XKVJ.js";
6
6
  export {
7
7
  authClient,
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { authClient } from './client.js';
3
- export { createClient } from './client.js';
3
+ export { ContentAuthClientOptions, createClient } from './client.js';
4
4
  import 'nanostores';
5
5
  import '@better-fetch/fetch';
6
6
  import 'better-auth';
@@ -7,11 +7,11 @@ import {
7
7
  PasswordChanger,
8
8
  ProfileEditor,
9
9
  ResetPasswordForm
10
- } from "../chunk-AHFGJJZD.js";
10
+ } from "../chunk-EDNWJGKD.js";
11
11
  import {
12
12
  authClient,
13
13
  createClient
14
- } from "../chunk-NKDKDBM2.js";
14
+ } from "../chunk-W5RBQBED.js";
15
15
  import "../chunk-R5U7XKVJ.js";
16
16
  export {
17
17
  AuthForm,
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { AuthConfig, EmailNormalizationConfig, FieldAttribute, SchemaMapping, SignInTrackingConfig, TableMapping, TurnstileConfig, authMiddleware, createAuth, createAuthApp, getInvitationLink, getSessionToken, isGmailAddress, normalizeEmail, schema, verifyTurnstile } from './backend/index.js';
2
2
  export { AuthForm, CreateOrganizationForm, ForgotPasswordForm, InviteMemberForm, OrganizationSwitcher, PasswordChanger, PasswordChangerProps, ProfileEditor, ProfileEditorProps, ResetPasswordForm } from './frontend/index.js';
3
- export { authClient, createClient } from './frontend/client.js';
3
+ export { ContentAuthClientOptions, authClient, createClient } from './frontend/client.js';
4
4
  export * from 'better-auth';
5
5
  export { Hono } from 'hono';
6
6
  import 'hono/types';
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  normalizeEmail,
10
10
  schema_exports,
11
11
  verifyTurnstile
12
- } from "./chunk-2NKKUZUC.js";
12
+ } from "./chunk-MDSQC2UU.js";
13
13
  import {
14
14
  AuthForm,
15
15
  CreateOrganizationForm,
@@ -19,11 +19,11 @@ import {
19
19
  PasswordChanger,
20
20
  ProfileEditor,
21
21
  ResetPasswordForm
22
- } from "./chunk-AHFGJJZD.js";
22
+ } from "./chunk-EDNWJGKD.js";
23
23
  import {
24
24
  authClient,
25
25
  createClient
26
- } from "./chunk-NKDKDBM2.js";
26
+ } from "./chunk-W5RBQBED.js";
27
27
  import "./chunk-R5U7XKVJ.js";
28
28
  export {
29
29
  AuthForm,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentgrowth/content-auth",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
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",