@contentgrowth/content-auth 0.2.2 → 0.2.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.d.ts
CHANGED
|
@@ -1074,6 +1074,27 @@ declare namespace schema {
|
|
|
1074
1074
|
declare function getInvitationLink(data: any, baseUrl: string): {
|
|
1075
1075
|
link: any;
|
|
1076
1076
|
};
|
|
1077
|
+
/**
|
|
1078
|
+
* Extracts the session token from the request.
|
|
1079
|
+
* Checks "Authorization: Bearer <token>" header first.
|
|
1080
|
+
* Then checks cookies for "better-auth.session_token", "session_token", and "__Secure-better-auth.session_token".
|
|
1081
|
+
*
|
|
1082
|
+
* @param req The Request object
|
|
1083
|
+
* @returns The session token or null if not found
|
|
1084
|
+
*/
|
|
1085
|
+
declare function getSessionToken(req: Request): string | null;
|
|
1086
|
+
/**
|
|
1087
|
+
* Programmatically triggers a password reset email for a user.
|
|
1088
|
+
* This bypasses the need for an HTTP call by using better-auth's internal API.
|
|
1089
|
+
*
|
|
1090
|
+
* @param auth The auth instance created by createAuth()
|
|
1091
|
+
* @param email The user's email address
|
|
1092
|
+
* @returns Promise that resolves when the reset email is triggered
|
|
1093
|
+
*/
|
|
1094
|
+
declare function triggerPasswordReset(auth: any, email: string): Promise<{
|
|
1095
|
+
success: boolean;
|
|
1096
|
+
error?: string;
|
|
1097
|
+
}>;
|
|
1077
1098
|
|
|
1078
1099
|
interface AuthConfig {
|
|
1079
1100
|
/**
|
|
@@ -1104,4 +1125,4 @@ declare const createAuthApp: (config: AuthConfig) => {
|
|
|
1104
1125
|
auth: better_auth.Auth<any>;
|
|
1105
1126
|
};
|
|
1106
1127
|
|
|
1107
|
-
export { type AuthConfig, authMiddleware, createAuth, createAuthApp, getInvitationLink, schema };
|
|
1128
|
+
export { type AuthConfig, authMiddleware, createAuth, createAuthApp, getInvitationLink, getSessionToken, schema, triggerPasswordReset };
|
package/dist/backend/index.js
CHANGED
|
@@ -4,8 +4,10 @@ import {
|
|
|
4
4
|
createAuth,
|
|
5
5
|
createAuthApp,
|
|
6
6
|
getInvitationLink,
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
getSessionToken,
|
|
8
|
+
schema_exports,
|
|
9
|
+
triggerPasswordReset
|
|
10
|
+
} from "../chunk-43OBL3NC.js";
|
|
9
11
|
import "../chunk-R5U7XKVJ.js";
|
|
10
12
|
export {
|
|
11
13
|
Hono,
|
|
@@ -13,5 +15,7 @@ export {
|
|
|
13
15
|
createAuth,
|
|
14
16
|
createAuthApp,
|
|
15
17
|
getInvitationLink,
|
|
16
|
-
|
|
18
|
+
getSessionToken,
|
|
19
|
+
schema_exports as schema,
|
|
20
|
+
triggerPasswordReset
|
|
17
21
|
};
|
|
@@ -175,6 +175,33 @@ function getInvitationLink(data, baseUrl) {
|
|
|
175
175
|
link: rawLink
|
|
176
176
|
};
|
|
177
177
|
}
|
|
178
|
+
function getSessionToken(req) {
|
|
179
|
+
const authHeader = req.headers.get("Authorization");
|
|
180
|
+
if (authHeader?.startsWith("Bearer ")) {
|
|
181
|
+
return authHeader.split(" ")[1];
|
|
182
|
+
}
|
|
183
|
+
const cookieHeader = req.headers.get("Cookie");
|
|
184
|
+
if (!cookieHeader) return null;
|
|
185
|
+
const cookies = {};
|
|
186
|
+
cookieHeader.split(";").forEach((c) => {
|
|
187
|
+
const [key, value] = c.trim().split("=");
|
|
188
|
+
if (key && value) {
|
|
189
|
+
cookies[key] = value;
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
return cookies["better-auth.session_token"] || cookies["session_token"] || cookies["__Secure-better-auth.session_token"] || null;
|
|
193
|
+
}
|
|
194
|
+
async function triggerPasswordReset(auth, email) {
|
|
195
|
+
try {
|
|
196
|
+
await auth.api.forgetPassword({
|
|
197
|
+
body: { email }
|
|
198
|
+
});
|
|
199
|
+
return { success: true };
|
|
200
|
+
} catch (e) {
|
|
201
|
+
console.error("[triggerPasswordReset] Failed:", e);
|
|
202
|
+
return { success: false, error: e.message || "Failed to trigger password reset" };
|
|
203
|
+
}
|
|
204
|
+
}
|
|
178
205
|
|
|
179
206
|
// src/backend/index.ts
|
|
180
207
|
var createAuth = (config) => {
|
|
@@ -235,6 +262,8 @@ var createAuthApp = (config) => {
|
|
|
235
262
|
export {
|
|
236
263
|
schema_exports,
|
|
237
264
|
getInvitationLink,
|
|
265
|
+
getSessionToken,
|
|
266
|
+
triggerPasswordReset,
|
|
238
267
|
Hono,
|
|
239
268
|
createAuth,
|
|
240
269
|
authMiddleware,
|
|
@@ -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;
|
|
@@ -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.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { AuthConfig, authMiddleware, createAuth, createAuthApp, getInvitationLink, schema } from './backend/index.js';
|
|
1
|
+
export { AuthConfig, authMiddleware, createAuth, createAuthApp, getInvitationLink, getSessionToken, schema, triggerPasswordReset } from './backend/index.js';
|
|
2
2
|
export { AuthForm, CreateOrganizationForm, InviteMemberForm, OrganizationSwitcher } from './frontend/index.js';
|
|
3
3
|
export { authClient, createClient } from './frontend/client.js';
|
|
4
4
|
export * from 'better-auth';
|
package/dist/index.js
CHANGED
|
@@ -4,8 +4,10 @@ import {
|
|
|
4
4
|
createAuth,
|
|
5
5
|
createAuthApp,
|
|
6
6
|
getInvitationLink,
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
getSessionToken,
|
|
8
|
+
schema_exports,
|
|
9
|
+
triggerPasswordReset
|
|
10
|
+
} from "./chunk-43OBL3NC.js";
|
|
9
11
|
import {
|
|
10
12
|
AuthForm,
|
|
11
13
|
CreateOrganizationForm,
|
|
@@ -29,5 +31,7 @@ export {
|
|
|
29
31
|
createAuthApp,
|
|
30
32
|
createClient,
|
|
31
33
|
getInvitationLink,
|
|
32
|
-
|
|
34
|
+
getSessionToken,
|
|
35
|
+
schema_exports as schema,
|
|
36
|
+
triggerPasswordReset
|
|
33
37
|
};
|