@contentgrowth/content-auth 0.4.3 → 0.4.4
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.js
CHANGED
|
@@ -332,6 +332,13 @@ var createAuth = (config) => {
|
|
|
332
332
|
turnstile: turnstileConfig,
|
|
333
333
|
emailNormalization,
|
|
334
334
|
schemaMapping,
|
|
335
|
+
user,
|
|
336
|
+
session,
|
|
337
|
+
account,
|
|
338
|
+
verification,
|
|
339
|
+
organization,
|
|
340
|
+
member,
|
|
341
|
+
invitation,
|
|
335
342
|
...rest
|
|
336
343
|
} = config;
|
|
337
344
|
const userTableName = schemaMapping?.user?.tableName || "users";
|
|
@@ -442,14 +449,14 @@ var createAuth = (config) => {
|
|
|
442
449
|
before: contentAuthBeforeHook,
|
|
443
450
|
after: async (context) => {
|
|
444
451
|
const path = context.path || "";
|
|
445
|
-
const
|
|
452
|
+
const user2 = context.user || context.response?.user || context.data?.user || context.context?.returned?.user || context.context?.newSession?.user;
|
|
446
453
|
if (emailNormalization?.enabled && rawDb?.prepare) {
|
|
447
|
-
if ((path.includes("/sign-up") || path.includes("/callback")) &&
|
|
454
|
+
if ((path.includes("/sign-up") || path.includes("/callback")) && user2?.id && user2?.email) {
|
|
448
455
|
try {
|
|
449
|
-
const normalized = normalizeEmail(
|
|
456
|
+
const normalized = normalizeEmail(user2.email);
|
|
450
457
|
await rawDb.prepare(
|
|
451
458
|
`UPDATE ${userTableName} SET ${normalizedEmailColumn} = ? WHERE ${userIdColumn} = ? AND (${normalizedEmailColumn} IS NULL OR ${normalizedEmailColumn} != ?)`
|
|
452
|
-
).bind(normalized,
|
|
459
|
+
).bind(normalized, user2.id, normalized).run();
|
|
453
460
|
} catch (e) {
|
|
454
461
|
console.error(`[ContentAuth] Failed to set normalized_email: ${e.message}`);
|
|
455
462
|
}
|
|
@@ -468,11 +475,14 @@ var createAuth = (config) => {
|
|
|
468
475
|
emailAndPassword: emailPasswordOptions,
|
|
469
476
|
// Pass emailVerification config if provided
|
|
470
477
|
...emailVerification ? { emailVerification } : {},
|
|
471
|
-
// Model configs
|
|
472
|
-
...userConfig ? { user: userConfig } : {},
|
|
473
|
-
...sessionConfig ? { session: sessionConfig } : {},
|
|
474
|
-
...accountConfig ? { account: accountConfig } : {},
|
|
475
|
-
...verificationConfig ? { verification: verificationConfig } : {},
|
|
478
|
+
// Model configs: Merge schema mapping config with user provided config
|
|
479
|
+
...userConfig || user ? { user: { ...userConfig, ...user } } : {},
|
|
480
|
+
...sessionConfig || session ? { session: { ...sessionConfig, ...session } } : {},
|
|
481
|
+
...accountConfig || account ? { account: { ...accountConfig, ...account } } : {},
|
|
482
|
+
...verificationConfig || verification ? { verification: { ...verificationConfig, ...verification } } : {},
|
|
483
|
+
...orgKey || organization ? { organization: { ...schemaMapping?.organization?.tableName ? { modelName: schemaMapping.organization.tableName } : {}, ...organization } } : {},
|
|
484
|
+
...memberKey || member ? { member: { ...schemaMapping?.member?.tableName ? { modelName: schemaMapping.member.tableName } : {}, ...member } } : {},
|
|
485
|
+
...invitationKey || invitation ? { invitation: { ...schemaMapping?.invitation?.tableName ? { modelName: schemaMapping.invitation.tableName } : {}, ...invitation } } : {},
|
|
476
486
|
// Merge content-auth hooks with user hooks
|
|
477
487
|
hooks: contentAuthHooks,
|
|
478
488
|
...otherOptions
|
|
@@ -525,11 +525,11 @@ declare const createClient: (baseUrl?: string) => {
|
|
|
525
525
|
} & {
|
|
526
526
|
organization: {
|
|
527
527
|
updateMemberRole: <FetchOptions extends better_auth.ClientFetchOption<Partial<{
|
|
528
|
-
role:
|
|
528
|
+
role: better_auth.LiteralString | "member" | "admin" | "owner" | better_auth.LiteralString[] | ("member" | "admin" | "owner")[];
|
|
529
529
|
memberId: string;
|
|
530
530
|
organizationId?: string | undefined;
|
|
531
531
|
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: better_auth.Prettify<{
|
|
532
|
-
role:
|
|
532
|
+
role: better_auth.LiteralString | "member" | "admin" | "owner" | better_auth.LiteralString[] | ("member" | "admin" | "owner")[];
|
|
533
533
|
memberId: string;
|
|
534
534
|
organizationId?: string | undefined;
|
|
535
535
|
} & {
|
|
@@ -628,7 +628,7 @@ declare const createClient: (baseUrl?: string) => {
|
|
|
628
628
|
sortDirection?: "asc" | "desc" | undefined;
|
|
629
629
|
filterField?: string | undefined;
|
|
630
630
|
filterValue?: string | number | boolean | undefined;
|
|
631
|
-
filterOperator?: "eq" | "ne" | "
|
|
631
|
+
filterOperator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "contains" | undefined;
|
|
632
632
|
organizationId?: string | undefined;
|
|
633
633
|
organizationSlug?: string | undefined;
|
|
634
634
|
}> & Record<string, any>, Record<string, any> | undefined>>(data_0?: better_auth.Prettify<{
|
|
@@ -639,7 +639,7 @@ declare const createClient: (baseUrl?: string) => {
|
|
|
639
639
|
sortDirection?: "asc" | "desc" | undefined;
|
|
640
640
|
filterField?: string | undefined;
|
|
641
641
|
filterValue?: string | number | boolean | undefined;
|
|
642
|
-
filterOperator?: "eq" | "ne" | "
|
|
642
|
+
filterOperator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "contains" | undefined;
|
|
643
643
|
organizationId?: string | undefined;
|
|
644
644
|
organizationSlug?: string | undefined;
|
|
645
645
|
} | undefined;
|
|
@@ -746,7 +746,7 @@ declare const createClient: (baseUrl?: string) => {
|
|
|
746
746
|
} & {
|
|
747
747
|
signIn: {
|
|
748
748
|
social: <FetchOptions extends better_auth.ClientFetchOption<Partial<{
|
|
749
|
-
provider: (string & {}) | "
|
|
749
|
+
provider: (string & {}) | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "huggingface" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linear" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "vercel";
|
|
750
750
|
callbackURL?: string | undefined;
|
|
751
751
|
newUserCallbackURL?: string | undefined;
|
|
752
752
|
errorCallbackURL?: string | undefined;
|
|
@@ -763,7 +763,7 @@ declare const createClient: (baseUrl?: string) => {
|
|
|
763
763
|
loginHint?: string | undefined;
|
|
764
764
|
additionalData?: Record<string, any> | undefined;
|
|
765
765
|
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: better_auth.Prettify<{
|
|
766
|
-
provider: (string & {}) | "
|
|
766
|
+
provider: (string & {}) | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "huggingface" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linear" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "vercel";
|
|
767
767
|
callbackURL?: string | undefined;
|
|
768
768
|
newUserCallbackURL?: string | undefined;
|
|
769
769
|
errorCallbackURL?: string | undefined;
|
|
@@ -2102,11 +2102,11 @@ declare const authClient: {
|
|
|
2102
2102
|
} & {
|
|
2103
2103
|
organization: {
|
|
2104
2104
|
updateMemberRole: <FetchOptions extends better_auth.ClientFetchOption<Partial<{
|
|
2105
|
-
role:
|
|
2105
|
+
role: better_auth.LiteralString | "member" | "admin" | "owner" | better_auth.LiteralString[] | ("member" | "admin" | "owner")[];
|
|
2106
2106
|
memberId: string;
|
|
2107
2107
|
organizationId?: string | undefined;
|
|
2108
2108
|
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: better_auth.Prettify<{
|
|
2109
|
-
role:
|
|
2109
|
+
role: better_auth.LiteralString | "member" | "admin" | "owner" | better_auth.LiteralString[] | ("member" | "admin" | "owner")[];
|
|
2110
2110
|
memberId: string;
|
|
2111
2111
|
organizationId?: string | undefined;
|
|
2112
2112
|
} & {
|
|
@@ -2205,7 +2205,7 @@ declare const authClient: {
|
|
|
2205
2205
|
sortDirection?: "asc" | "desc" | undefined;
|
|
2206
2206
|
filterField?: string | undefined;
|
|
2207
2207
|
filterValue?: string | number | boolean | undefined;
|
|
2208
|
-
filterOperator?: "eq" | "ne" | "
|
|
2208
|
+
filterOperator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "contains" | undefined;
|
|
2209
2209
|
organizationId?: string | undefined;
|
|
2210
2210
|
organizationSlug?: string | undefined;
|
|
2211
2211
|
}> & Record<string, any>, Record<string, any> | undefined>>(data_0?: better_auth.Prettify<{
|
|
@@ -2216,7 +2216,7 @@ declare const authClient: {
|
|
|
2216
2216
|
sortDirection?: "asc" | "desc" | undefined;
|
|
2217
2217
|
filterField?: string | undefined;
|
|
2218
2218
|
filterValue?: string | number | boolean | undefined;
|
|
2219
|
-
filterOperator?: "eq" | "ne" | "
|
|
2219
|
+
filterOperator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "contains" | undefined;
|
|
2220
2220
|
organizationId?: string | undefined;
|
|
2221
2221
|
organizationSlug?: string | undefined;
|
|
2222
2222
|
} | undefined;
|
|
@@ -2323,7 +2323,7 @@ declare const authClient: {
|
|
|
2323
2323
|
} & {
|
|
2324
2324
|
signIn: {
|
|
2325
2325
|
social: <FetchOptions extends better_auth.ClientFetchOption<Partial<{
|
|
2326
|
-
provider: (string & {}) | "
|
|
2326
|
+
provider: (string & {}) | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "huggingface" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linear" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "vercel";
|
|
2327
2327
|
callbackURL?: string | undefined;
|
|
2328
2328
|
newUserCallbackURL?: string | undefined;
|
|
2329
2329
|
errorCallbackURL?: string | undefined;
|
|
@@ -2340,7 +2340,7 @@ declare const authClient: {
|
|
|
2340
2340
|
loginHint?: string | undefined;
|
|
2341
2341
|
additionalData?: Record<string, any> | undefined;
|
|
2342
2342
|
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0: better_auth.Prettify<{
|
|
2343
|
-
provider: (string & {}) | "
|
|
2343
|
+
provider: (string & {}) | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "huggingface" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linear" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "vercel";
|
|
2344
2344
|
callbackURL?: string | undefined;
|
|
2345
2345
|
newUserCallbackURL?: string | undefined;
|
|
2346
2346
|
errorCallbackURL?: string | undefined;
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentgrowth/content-auth",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
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",
|