@contentgrowth/content-auth 0.5.2 → 0.5.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/dist/backend/index.d.ts +13 -1
- package/dist/backend/index.js +1 -1
- package/dist/{chunk-52ZT54FA.js → chunk-XN2NSYRD.js} +14 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/schema/auth.sql +2 -0
package/dist/backend/index.d.ts
CHANGED
|
@@ -759,6 +759,12 @@ interface EmailNormalizationConfig {
|
|
|
759
759
|
/** Column name in users table. Default: 'normalized_email' */
|
|
760
760
|
columnName?: string;
|
|
761
761
|
}
|
|
762
|
+
interface SignInTrackingConfig {
|
|
763
|
+
/** Enable sign-in tracking (lastSignedInAt column). Default: false */
|
|
764
|
+
enabled: boolean;
|
|
765
|
+
/** Column name for last sign-in timestamp. Default: 'lastSignedInAt' */
|
|
766
|
+
columnName?: string;
|
|
767
|
+
}
|
|
762
768
|
/**
|
|
763
769
|
* Field attribute for additional fields in custom schema
|
|
764
770
|
*/
|
|
@@ -861,6 +867,12 @@ interface AuthConfig {
|
|
|
861
867
|
* Requires a 'normalized_email' column in the users table.
|
|
862
868
|
*/
|
|
863
869
|
emailNormalization?: EmailNormalizationConfig;
|
|
870
|
+
/**
|
|
871
|
+
* Sign-in tracking to record when users last signed in.
|
|
872
|
+
* Useful for engagement analytics and identifying inactive users.
|
|
873
|
+
* Requires a 'lastSignedInAt' column (or custom name) in the users table.
|
|
874
|
+
*/
|
|
875
|
+
signInTracking?: SignInTrackingConfig;
|
|
864
876
|
/**
|
|
865
877
|
* Custom schema mapping to use existing tables with Better Auth.
|
|
866
878
|
* Maps Better Auth's default table/column names to your existing database schema.
|
|
@@ -876,4 +888,4 @@ declare const createAuthApp: (config: AuthConfig) => {
|
|
|
876
888
|
auth: better_auth.Auth<any>;
|
|
877
889
|
};
|
|
878
890
|
|
|
879
|
-
export { type AuthConfig, type EmailNormalizationConfig, type FieldAttribute, type SchemaMapping, type TableMapping, type TurnstileConfig, authMiddleware, createAuth, createAuthApp, getInvitationLink, getSessionToken, isGmailAddress, normalizeEmail, schema, verifyTurnstile };
|
|
891
|
+
export { type AuthConfig, type EmailNormalizationConfig, type FieldAttribute, type SchemaMapping, type SignInTrackingConfig, type TableMapping, type TurnstileConfig, authMiddleware, createAuth, createAuthApp, getInvitationLink, getSessionToken, isGmailAddress, normalizeEmail, schema, verifyTurnstile };
|
package/dist/backend/index.js
CHANGED
|
@@ -365,6 +365,7 @@ var createAuth = (config) => {
|
|
|
365
365
|
emailVerification,
|
|
366
366
|
turnstile: turnstileConfig,
|
|
367
367
|
emailNormalization,
|
|
368
|
+
signInTracking,
|
|
368
369
|
schemaMapping,
|
|
369
370
|
user,
|
|
370
371
|
session,
|
|
@@ -496,6 +497,19 @@ var createAuth = (config) => {
|
|
|
496
497
|
}
|
|
497
498
|
}
|
|
498
499
|
}
|
|
500
|
+
if (signInTracking?.enabled && rawDb?.prepare && user2?.id) {
|
|
501
|
+
if (path.includes("/sign-in") || path.includes("/sign-up") || path.includes("/callback")) {
|
|
502
|
+
try {
|
|
503
|
+
const lastSignedInColumn = signInTracking.columnName || "lastSignedInAt";
|
|
504
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
505
|
+
await rawDb.prepare(
|
|
506
|
+
`UPDATE ${userTableName} SET ${lastSignedInColumn} = ? WHERE ${userIdColumn} = ?`
|
|
507
|
+
).bind(now, user2.id).run();
|
|
508
|
+
} catch (e) {
|
|
509
|
+
console.error(`[ContentAuth] Failed to update lastSignedInAt: ${e.message}`);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
}
|
|
499
513
|
if (userHooks?.after) {
|
|
500
514
|
return userHooks.after(context);
|
|
501
515
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { AuthConfig, EmailNormalizationConfig, FieldAttribute, SchemaMapping, TableMapping, TurnstileConfig, authMiddleware, createAuth, createAuthApp, getInvitationLink, getSessionToken, isGmailAddress, normalizeEmail, schema, verifyTurnstile } from './backend/index.js';
|
|
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
3
|
export { authClient, createClient } from './frontend/client.js';
|
|
4
4
|
export * from 'better-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.5.
|
|
3
|
+
"version": "0.5.3",
|
|
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",
|
package/schema/auth.sql
CHANGED
|
@@ -29,6 +29,8 @@ CREATE TABLE IF NOT EXISTS users (
|
|
|
29
29
|
updatedAt TIMESTAMP NOT NULL
|
|
30
30
|
-- Optional: For Gmail duplicate prevention (see docs)
|
|
31
31
|
-- normalized_email TEXT
|
|
32
|
+
-- Optional: Sign-in tracking for engagement analytics
|
|
33
|
+
-- lastSignedInAt TIMESTAMP -- Updated on each sign-in
|
|
32
34
|
);
|
|
33
35
|
|
|
34
36
|
-- Sessions
|