@rolder/kit 3.0.0-alpha.11 → 3.0.0-alpha.112
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/ai/index.d.ts +2 -0
- package/dist/ai/index.js +2 -0
- package/dist/ai/ui/chat/Root.d.ts +55 -0
- package/dist/ai/ui/chat/Root.js +18 -0
- package/dist/ai/ui/chat/chatInput/File.js +71 -0
- package/dist/ai/ui/chat/chatInput/FileIcon.js +43 -0
- package/dist/ai/ui/chat/chatInput/Root.d.ts +9 -0
- package/dist/ai/ui/chat/chatInput/Root.js +24 -0
- package/dist/ai/ui/chat/chatInput/Submit.js +23 -0
- package/dist/ai/ui/{promptInput → chat/chatInput}/Textarea.js +8 -7
- package/dist/ai/ui/{promptInput → chat/chatInput}/index.d.ts +2 -3
- package/dist/ai/ui/{promptInput → chat/chatInput}/index.js +2 -2
- package/dist/ai/ui/chat/chatInput/store/file.d.ts +8 -0
- package/dist/ai/ui/chat/chatInput/store/file.js +32 -0
- package/dist/ai/ui/chat/chatInput/store/fileErrorNotificaton.d.ts +2 -0
- package/dist/ai/ui/chat/chatInput/store/fileErrorNotificaton.js +21 -0
- package/dist/ai/ui/chat/chatInput/store/index.d.ts +2 -0
- package/dist/ai/ui/chat/chatInput/store/index.js +2 -0
- package/dist/ai/ui/chat/chatInput/store/input.d.ts +13 -0
- package/dist/ai/ui/chat/chatInput/store/input.js +81 -0
- package/dist/ai/ui/chat/chatInput/store/parseFile.d.ts +2 -0
- package/dist/ai/ui/chat/chatInput/store/parseFile.js +23 -0
- package/dist/ai/ui/chat/index.d.ts +12 -0
- package/dist/ai/ui/chat/index.js +15 -0
- package/dist/ai/ui/chat/messages/Empty.d.ts +4 -0
- package/dist/ai/ui/chat/messages/Empty.js +11 -0
- package/dist/ai/ui/chat/messages/Loader.d.ts +5 -0
- package/dist/ai/ui/chat/messages/Loader.js +12 -0
- package/dist/ai/ui/chat/messages/Message.d.ts +8 -0
- package/dist/ai/ui/chat/messages/Message.js +22 -0
- package/dist/ai/ui/chat/messages/Messages.d.ts +3 -0
- package/dist/ai/ui/chat/messages/Messages.js +40 -0
- package/dist/ai/ui/chat/messages/index.d.ts +2 -0
- package/dist/ai/ui/chat/messages/index.js +2 -0
- package/dist/ai/ui/chat/parts/File.d.ts +6 -0
- package/dist/ai/ui/{conversation → chat/parts}/File.js +10 -10
- package/dist/ai/ui/chat/parts/FileIcon.js +43 -0
- package/dist/ai/ui/chat/parts/PartPaper.d.ts +8 -0
- package/dist/ai/ui/chat/parts/PartPaper.js +14 -0
- package/dist/ai/ui/chat/parts/TextPart.d.ts +6 -0
- package/dist/ai/ui/chat/parts/TextPart.js +15 -0
- package/dist/ai/ui/chat/parts/ToolExecution.d.ts +7 -0
- package/dist/ai/ui/chat/parts/ToolExecution.js +56 -0
- package/dist/ai/ui/chat/parts/ToolPart.d.ts +10 -0
- package/dist/ai/ui/chat/parts/ToolPart.js +24 -0
- package/dist/ai/ui/chat/parts/index.d.ts +3 -0
- package/dist/ai/ui/chat/parts/index.js +3 -0
- package/dist/ai/ui/chat/store/index.d.ts +4 -0
- package/dist/ai/ui/chat/store/index.js +4 -0
- package/dist/ai/ui/chat/store/messages.d.ts +12 -0
- package/dist/ai/ui/chat/store/messages.js +40 -0
- package/dist/ai/ui/chat/store/send.d.ts +14 -0
- package/dist/ai/ui/chat/store/send.js +16 -0
- package/dist/ai/ui/chat/store/states.d.ts +11 -0
- package/dist/ai/ui/chat/store/states.js +20 -0
- package/dist/ai/ui/chat/store/useInitChat.d.ts +3 -0
- package/dist/ai/ui/chat/store/useInitChat.js +40 -0
- package/dist/ai/ui/index.d.ts +1 -0
- package/dist/ai/ui/index.js +1 -0
- package/dist/ai/utils/index.d.ts +2 -0
- package/dist/ai/utils/index.js +2 -0
- package/dist/app/AppDefaults.js +1 -1
- package/dist/app/DefaultApp.js +1 -1
- package/dist/app/cookieColorSchemeManager.js +1 -1
- package/dist/app/defaultTheme.d.ts +7 -7
- package/dist/app/index.d.ts +3 -0
- package/dist/app/index.js +3 -0
- package/dist/betterAuth/client/getAuthClient.d.ts +3050 -0
- package/dist/betterAuth/client/getAuthClient.js +18 -0
- package/dist/betterAuth/client/index.d.ts +1 -0
- package/dist/betterAuth/client/index.js +1 -0
- package/dist/betterAuth/index.d.ts +3 -0
- package/dist/betterAuth/index.js +3 -0
- package/dist/betterAuth/server/defaultAuthServerConfig.d.ts +452 -0
- package/dist/betterAuth/server/defaultAuthServerConfig.js +49 -0
- package/dist/betterAuth/server/env.d.ts +1 -0
- package/dist/betterAuth/server/env.js +8 -0
- package/dist/betterAuth/server/getDBSession.d.ts +2 -0
- package/dist/betterAuth/server/getDBSession.js +85 -0
- package/dist/betterAuth/server/getSessionToken.d.ts +1 -0
- package/dist/betterAuth/server/getSessionToken.js +14 -0
- package/dist/betterAuth/server/getSessionUser.d.ts +1 -0
- package/dist/betterAuth/server/getSessionUser.js +22 -0
- package/dist/betterAuth/server/index.d.ts +10 -0
- package/dist/betterAuth/server/index.js +11 -0
- package/dist/betterAuth/server/surrealDbAdapter/adapter.d.ts +8 -0
- package/dist/betterAuth/server/surrealDbAdapter/adapter.js +64 -0
- package/dist/betterAuth/server/surrealDbAdapter/adapter.test.d.ts +1 -0
- package/dist/betterAuth/server/surrealDbAdapter/adapter.test.js +84 -0
- package/dist/betterAuth/server/surrealDbAdapter/db/getDB.d.ts +2 -0
- package/dist/betterAuth/server/surrealDbAdapter/db/getDB.js +26 -0
- package/dist/betterAuth/server/surrealDbAdapter/db/index.d.ts +1 -0
- package/dist/betterAuth/server/surrealDbAdapter/db/index.js +1 -0
- package/dist/betterAuth/server/surrealDbAdapter/db/schema.d.ts +1 -0
- package/dist/betterAuth/server/surrealDbAdapter/db/schema.js +97 -0
- package/dist/betterAuth/server/surrealDbAdapter/index.d.ts +1 -0
- package/dist/betterAuth/server/surrealDbAdapter/index.js +1 -0
- package/dist/betterAuth/server/surrealDbAdapter/methods/count.d.ts +2 -0
- package/dist/betterAuth/server/surrealDbAdapter/methods/count.js +17 -0
- package/dist/betterAuth/server/surrealDbAdapter/methods/create.d.ts +2 -0
- package/dist/betterAuth/server/surrealDbAdapter/methods/create.js +21 -0
- package/dist/betterAuth/server/surrealDbAdapter/methods/delete.d.ts +2 -0
- package/dist/betterAuth/server/surrealDbAdapter/methods/delete.js +18 -0
- package/dist/betterAuth/server/surrealDbAdapter/methods/deleteMany.d.ts +2 -0
- package/dist/betterAuth/server/surrealDbAdapter/methods/deleteMany.js +19 -0
- package/dist/betterAuth/server/surrealDbAdapter/methods/findMany.d.ts +2 -0
- package/dist/betterAuth/server/surrealDbAdapter/methods/findMany.js +51 -0
- package/dist/betterAuth/server/surrealDbAdapter/methods/findOne.d.ts +2 -0
- package/dist/betterAuth/server/surrealDbAdapter/methods/findOne.js +42 -0
- package/dist/betterAuth/server/surrealDbAdapter/methods/index.d.ts +8 -0
- package/dist/betterAuth/server/surrealDbAdapter/methods/index.js +8 -0
- package/dist/betterAuth/server/surrealDbAdapter/methods/types.d.ts +56 -0
- package/dist/betterAuth/server/surrealDbAdapter/methods/update.d.ts +2 -0
- package/dist/betterAuth/server/surrealDbAdapter/methods/update.js +25 -0
- package/dist/betterAuth/server/surrealDbAdapter/methods/updateMany.d.ts +2 -0
- package/dist/betterAuth/server/surrealDbAdapter/methods/updateMany.js +21 -0
- package/dist/betterAuth/server/surrealDbAdapter/types.d.ts +2 -0
- package/dist/betterAuth/server/surrealDbAdapter/utils/applyJoinMappings.d.ts +2 -0
- package/dist/betterAuth/server/surrealDbAdapter/utils/applyJoinMappings.js +31 -0
- package/dist/betterAuth/server/surrealDbAdapter/utils/buildExpression.d.ts +3 -0
- package/dist/betterAuth/server/surrealDbAdapter/utils/buildExpression.js +58 -0
- package/dist/betterAuth/server/surrealDbAdapter/utils/buildJoinPlan.d.ts +9 -0
- package/dist/betterAuth/server/surrealDbAdapter/utils/buildJoinPlan.js +46 -0
- package/dist/betterAuth/server/surrealDbAdapter/utils/buildSelectFields.d.ts +1 -0
- package/dist/betterAuth/server/surrealDbAdapter/utils/buildSelectFields.js +5 -0
- package/dist/betterAuth/server/surrealDbAdapter/utils/index.d.ts +6 -0
- package/dist/betterAuth/server/surrealDbAdapter/utils/index.js +6 -0
- package/dist/betterAuth/server/surrealDbAdapter/utils/normalizeOutputRecordIds.d.ts +2 -0
- package/dist/betterAuth/server/surrealDbAdapter/utils/normalizeOutputRecordIds.js +43 -0
- package/dist/betterAuth/server/surrealDbAdapter/utils/normalizeRecordIds.d.ts +2 -0
- package/dist/betterAuth/server/surrealDbAdapter/utils/normalizeRecordIds.js +38 -0
- package/dist/betterAuth/server/surrealDbAdapter/utils/normalizeWhereValue.d.ts +2 -0
- package/dist/betterAuth/server/surrealDbAdapter/utils/normalizeWhereValue.js +33 -0
- package/dist/betterAuth/server/surrealDbAdapter/utils/types.d.ts +34 -0
- package/dist/betterAuth/server/types.d.ts +8 -0
- package/dist/betterAuth/useSessionUser.d.ts +1 -0
- package/dist/betterAuth/useSessionUser.js +8 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +2 -0
- package/dist/styles.css +3 -8
- package/dist/surrealDB/deafaultCrud.d.ts +2 -0
- package/dist/{surreal → surrealDB}/deafaultCrud.js +6 -5
- package/dist/surrealDB/getDBInstance.d.ts +3 -0
- package/dist/surrealDB/getDBInstance.js +34 -0
- package/dist/surrealDB/getDBInstanceTanstack.d.ts +3 -0
- package/dist/{surreal/connection.js → surrealDB/getDBInstanceTanstack.js} +2 -2
- package/dist/surrealDB/index.d.ts +6 -0
- package/dist/surrealDB/index.js +6 -0
- package/dist/{surreal/connection.d.ts → surrealDB/types.d.ts} +3 -3
- package/dist/surrealDB/types.js +0 -0
- package/dist/tanstack/cookie/index.d.ts +3 -0
- package/dist/tanstack/cookie/index.js +4 -0
- package/dist/{functions → tanstack/cookie}/setCookie.d.ts +1 -1
- package/dist/tanstack/index.d.ts +3 -0
- package/dist/tanstack/index.js +3 -0
- package/dist/tanstack/middlewares/index.d.ts +6 -0
- package/dist/tanstack/middlewares/index.js +5 -0
- package/dist/tanstack/middlewares/locale.d.ts +4 -0
- package/dist/{app/defaultRequestMiddlewares.js → tanstack/middlewares/locale.js} +2 -5
- package/dist/tanstack/s3/getS3Client.d.ts +2 -0
- package/dist/tanstack/s3/getS3Client.js +18 -0
- package/dist/tanstack/s3/getSignedFileUrlFn.d.ts +4 -0
- package/dist/tanstack/s3/getSignedFileUrlFn.js +21 -0
- package/dist/tanstack/s3/index.d.ts +2 -0
- package/dist/tanstack/s3/index.js +2 -0
- package/dist/tanstack/s3/uploadRequest.d.ts +3 -0
- package/dist/tanstack/s3/uploadRequest.js +21 -0
- package/dist/ui/AnimatedChevron.d.ts +3 -4
- package/dist/ui/AnimatedChevron.js +6 -25
- package/dist/ui/JsonInput.d.ts +1 -1
- package/dist/ui/JsonInput.js +1 -1
- package/dist/ui/editor/Content.d.ts +2 -2
- package/dist/ui/editor/Content.js +2 -2
- package/dist/ui/editor/Root.d.ts +7 -1
- package/dist/ui/editor/Root.js +42 -5
- package/dist/ui/editor/Toolbar.d.ts +3 -2
- package/dist/ui/editor/Toolbar.js +7 -25
- package/dist/ui/editor/index.d.ts +5 -9
- package/dist/ui/editor/index.js +3 -4
- package/dist/ui/editor/store.d.ts +6 -0
- package/dist/ui/editor/store.js +10 -0
- package/dist/ui/error/DefaultError.d.ts +1 -1
- package/dist/ui/error/DefaultNotFound.d.ts +1 -1
- package/dist/ui/error/Forbidden.d.ts +1 -1
- package/dist/ui/form/buttons/CancelButton.d.ts +2 -2
- package/dist/ui/form/buttons/CancelButton.js +4 -26
- package/dist/ui/form/buttons/SubmitButton.d.ts +2 -2
- package/dist/ui/form/buttons/SubmitButton.js +4 -29
- package/dist/ui/form/buttons/SubscribeActionIcon.d.ts +2 -2
- package/dist/ui/form/buttons/SubscribeButton.d.ts +2 -2
- package/dist/ui/form/context.d.ts +55 -55
- package/dist/ui/form/context.js +3 -3
- package/dist/ui/form/fields/JsonField.d.ts +1 -1
- package/dist/ui/form/fields/MultiSelectField.d.ts +1 -1
- package/dist/ui/form/fields/NumberField.d.ts +1 -1
- package/dist/ui/form/fields/PasswordField.d.ts +2 -0
- package/dist/ui/form/fields/{PassowrdField.js → PasswordField.js} +2 -2
- package/dist/ui/form/fields/SelectField.d.ts +1 -1
- package/dist/ui/form/fields/SwitchField.d.ts +1 -1
- package/dist/ui/form/fields/TextField.d.ts +1 -1
- package/dist/ui/form/fields/TextPasswordField.d.ts +2 -0
- package/dist/ui/form/fields/TextPasswordField.js +29 -0
- package/dist/ui/form/fields/TextareaField.d.ts +1 -1
- package/dist/ui/form/fields/index.d.ts +2 -2
- package/dist/ui/form/fields/index.js +2 -2
- package/dist/ui/form/index.d.ts +0 -1
- package/dist/ui/form/index.js +1 -2
- package/dist/ui/index.d.ts +9 -0
- package/dist/ui/index.js +9 -0
- package/dist/ui/saveInput/JsonInput.d.ts +2 -2
- package/dist/ui/saveInput/NumberInput.d.ts +2 -2
- package/dist/ui/saveInput/SaveInput.d.ts +14 -14
- package/dist/ui/saveInput/Select.d.ts +2 -2
- package/dist/ui/saveInput/Switch.d.ts +2 -2
- package/dist/ui/saveInput/TextInput.d.ts +2 -2
- package/dist/ui/saveInput/Textarea.d.ts +2 -2
- package/dist/ui/scrollArea/Root.d.ts +7 -0
- package/dist/ui/scrollArea/Root.js +42 -0
- package/dist/ui/scrollArea/ScrollButton.d.ts +7 -0
- package/dist/ui/scrollArea/ScrollButton.js +30 -0
- package/dist/ui/scrollArea/index.d.ts +6 -3
- package/dist/ui/scrollArea/index.js +7 -3
- package/dist/ui/scrollArea/methods.d.ts +4 -0
- package/dist/ui/scrollArea/methods.js +32 -0
- package/dist/ui/scrollArea/store.d.ts +12 -0
- package/dist/ui/scrollArea/store.js +25 -0
- package/dist/{ui/form/fieldsSchema.d.ts → zodSchemas.d.ts} +1 -1
- package/dist/{ui/form/fieldsSchema.js → zodSchemas.js} +2 -2
- package/package.json +103 -71
- package/dist/ai/ui/conversation/ConversationContext.d.ts +0 -7
- package/dist/ai/ui/conversation/ConversationContext.js +0 -8
- package/dist/ai/ui/conversation/ConversationProvider.d.ts +0 -2
- package/dist/ai/ui/conversation/ConversationProvider.js +0 -14
- package/dist/ai/ui/conversation/Empty.d.ts +0 -1
- package/dist/ai/ui/conversation/Empty.js +0 -21
- package/dist/ai/ui/conversation/File.d.ts +0 -4
- package/dist/ai/ui/conversation/FileIcon.js +0 -225
- package/dist/ai/ui/conversation/Loader.d.ts +0 -2
- package/dist/ai/ui/conversation/Loader.js +0 -12
- package/dist/ai/ui/conversation/Message.d.ts +0 -4
- package/dist/ai/ui/conversation/Message.js +0 -25
- package/dist/ai/ui/conversation/Root.d.ts +0 -2
- package/dist/ai/ui/conversation/Root.js +0 -26
- package/dist/ai/ui/conversation/index.d.ts +0 -13
- package/dist/ai/ui/conversation/index.js +0 -14
- package/dist/ai/ui/conversation/types.d.ts +0 -7
- package/dist/ai/ui/conversation/useChatMessage.d.ts +0 -2
- package/dist/ai/ui/conversation/useChatMessage.js +0 -12
- package/dist/ai/ui/promptInput/File.js +0 -117
- package/dist/ai/ui/promptInput/FileIcon.js +0 -225
- package/dist/ai/ui/promptInput/PromptInputContext.d.ts +0 -12
- package/dist/ai/ui/promptInput/PromptInputContext.js +0 -8
- package/dist/ai/ui/promptInput/PromptInputProvider.d.ts +0 -2
- package/dist/ai/ui/promptInput/PromptInputProvider.js +0 -50
- package/dist/ai/ui/promptInput/Root.d.ts +0 -3
- package/dist/ai/ui/promptInput/Root.js +0 -17
- package/dist/ai/ui/promptInput/Submit.js +0 -40
- package/dist/ai/ui/promptInput/types.d.ts +0 -11
- package/dist/app/defaultRequestMiddlewares.d.ts +0 -4
- package/dist/index.d.ts +0 -26
- package/dist/index.js +0 -26
- package/dist/surreal/deafaultCrud.d.ts +0 -2
- package/dist/ui/editor/Provider.d.ts +0 -17
- package/dist/ui/editor/Provider.js +0 -80
- package/dist/ui/editor/types.d.ts +0 -7
- package/dist/ui/form/fields/PassowrdField.d.ts +0 -2
- package/dist/ui/form/fields/TextPassowrdField.d.ts +0 -2
- package/dist/ui/form/fields/TextPassowrdField.js +0 -51
- package/dist/ui/scrollArea/ScrollArea.d.ts +0 -62
- package/dist/ui/scrollArea/ScrollArea.js +0 -30
- package/dist/ui/scrollArea/ScrollAreaButton.d.ts +0 -5
- package/dist/ui/scrollArea/ScrollAreaButton.js +0 -51
- package/dist/ui/scrollArea/ScrollAreaContent.d.ts +0 -6
- package/dist/ui/scrollArea/ScrollAreaContent.js +0 -29
- package/dist/ui/scrollArea/context.d.ts +0 -28
- package/dist/ui/scrollArea/context.js +0 -10
- package/dist/ui/scrollArea/types.d.ts +0 -65
- package/dist/ui/scrollArea/useScrollArea.d.ts +0 -9
- package/dist/ui/scrollArea/useScrollArea.js +0 -146
- /package/dist/ai/ui/{promptInput → chat/chatInput}/File.d.ts +0 -0
- /package/dist/ai/ui/{conversation → chat/chatInput}/FileIcon.d.ts +0 -0
- /package/dist/ai/ui/{promptInput → chat/chatInput}/Footer.d.ts +0 -0
- /package/dist/ai/ui/{promptInput → chat/chatInput}/Footer.js +0 -0
- /package/dist/ai/ui/{promptInput → chat/chatInput}/Submit.d.ts +0 -0
- /package/dist/ai/ui/{promptInput → chat/chatInput}/Textarea.d.ts +0 -0
- /package/dist/ai/ui/{promptInput → chat/parts}/FileIcon.d.ts +0 -0
- /package/dist/{ai/ui/conversation → betterAuth/server/surrealDbAdapter/methods}/types.js +0 -0
- /package/dist/{ai/ui/promptInput → betterAuth/server/surrealDbAdapter}/types.js +0 -0
- /package/dist/{ui/editor → betterAuth/server/surrealDbAdapter/utils}/types.js +0 -0
- /package/dist/{ui/scrollArea → betterAuth/server}/types.js +0 -0
- /package/dist/{surreal → surrealDB}/deserialize.d.ts +0 -0
- /package/dist/{surreal → surrealDB}/deserialize.js +0 -0
- /package/dist/{surreal → surrealDB}/encryption.d.ts +0 -0
- /package/dist/{surreal → surrealDB}/encryption.js +0 -0
- /package/dist/{functions → tanstack/cookie}/getCookie.d.ts +0 -0
- /package/dist/{functions → tanstack/cookie}/getCookie.js +0 -0
- /package/dist/{functions → tanstack/cookie}/setCookie.js +0 -0
- /package/dist/{functions → tanstack/cookie}/setCookies.d.ts +0 -0
- /package/dist/{functions → tanstack/cookie}/setCookies.js +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { adminClient, usernameClient } from "better-auth/client/plugins";
|
|
2
|
+
import { defaultRoles } from "better-auth/plugins/organization/access";
|
|
3
|
+
import { createAuthClient } from "better-auth/react";
|
|
4
|
+
const getAuthClient = (config)=>{
|
|
5
|
+
const roles = config?.roles || defaultRoles;
|
|
6
|
+
const betterAuthClientOptions = config?.betterAuthClientOptions;
|
|
7
|
+
return createAuthClient({
|
|
8
|
+
...betterAuthClientOptions,
|
|
9
|
+
plugins: [
|
|
10
|
+
adminClient({
|
|
11
|
+
roles
|
|
12
|
+
}),
|
|
13
|
+
usernameClient(),
|
|
14
|
+
...betterAuthClientOptions?.plugins || []
|
|
15
|
+
]
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
export { getAuthClient };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './getAuthClient';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./getAuthClient.js";
|
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
import { type JwtOptions } from 'better-auth/plugins';
|
|
2
|
+
export declare const defaultAuthServerPluginOptions: {
|
|
3
|
+
admin: {
|
|
4
|
+
bannedUserMessage: string;
|
|
5
|
+
};
|
|
6
|
+
jwt: {
|
|
7
|
+
jwks: {
|
|
8
|
+
keyPairConfig: {
|
|
9
|
+
alg: "EdDSA";
|
|
10
|
+
crv: "Ed25519";
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
jwt: {
|
|
14
|
+
issuer: string;
|
|
15
|
+
audience: string;
|
|
16
|
+
expirationTime: string;
|
|
17
|
+
definePayload: ({ user, session }: {
|
|
18
|
+
user: import("better-auth").User & Record<string, any>;
|
|
19
|
+
session: import("better-auth").Session & Record<string, any>;
|
|
20
|
+
}) => {
|
|
21
|
+
id: string;
|
|
22
|
+
ns: string;
|
|
23
|
+
db: string;
|
|
24
|
+
ac: string;
|
|
25
|
+
email: string;
|
|
26
|
+
name: string;
|
|
27
|
+
role: string;
|
|
28
|
+
sessionId: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export declare const defaultAuthServerConfig: {
|
|
34
|
+
baseURL: string;
|
|
35
|
+
secret: string | undefined;
|
|
36
|
+
database: (options: Parameters<import("better-auth/adapters").AdapterFactory>[0]) => import("better-auth").DBAdapter<import("better-auth").BetterAuthOptions>;
|
|
37
|
+
experimental: {
|
|
38
|
+
joins: boolean;
|
|
39
|
+
};
|
|
40
|
+
emailAndPassword: {
|
|
41
|
+
enabled: boolean;
|
|
42
|
+
};
|
|
43
|
+
plugins: ({
|
|
44
|
+
id: "username";
|
|
45
|
+
init(ctx: import("better-auth").AuthContext): {
|
|
46
|
+
options: {
|
|
47
|
+
databaseHooks: {
|
|
48
|
+
user: {
|
|
49
|
+
create: {
|
|
50
|
+
before(user: {
|
|
51
|
+
id: string;
|
|
52
|
+
createdAt: Date;
|
|
53
|
+
updatedAt: Date;
|
|
54
|
+
email: string;
|
|
55
|
+
emailVerified: boolean;
|
|
56
|
+
name: string;
|
|
57
|
+
image?: string | null | undefined;
|
|
58
|
+
} & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null): Promise<{
|
|
59
|
+
data: {
|
|
60
|
+
displayUsername?: string | undefined;
|
|
61
|
+
username?: string | undefined;
|
|
62
|
+
id: string;
|
|
63
|
+
createdAt: Date;
|
|
64
|
+
updatedAt: Date;
|
|
65
|
+
email: string;
|
|
66
|
+
emailVerified: boolean;
|
|
67
|
+
name: string;
|
|
68
|
+
image?: string | null | undefined;
|
|
69
|
+
};
|
|
70
|
+
}>;
|
|
71
|
+
};
|
|
72
|
+
update: {
|
|
73
|
+
before(user: Partial<{
|
|
74
|
+
id: string;
|
|
75
|
+
createdAt: Date;
|
|
76
|
+
updatedAt: Date;
|
|
77
|
+
email: string;
|
|
78
|
+
emailVerified: boolean;
|
|
79
|
+
name: string;
|
|
80
|
+
image?: string | null | undefined;
|
|
81
|
+
}> & Record<string, unknown>, context: import("better-auth").GenericEndpointContext | null): Promise<{
|
|
82
|
+
data: {
|
|
83
|
+
displayUsername?: string | undefined;
|
|
84
|
+
username?: string | undefined;
|
|
85
|
+
id?: string | undefined;
|
|
86
|
+
createdAt?: Date | undefined;
|
|
87
|
+
updatedAt?: Date | undefined;
|
|
88
|
+
email?: string | undefined;
|
|
89
|
+
emailVerified?: boolean | undefined;
|
|
90
|
+
name?: string | undefined;
|
|
91
|
+
image?: string | null | undefined;
|
|
92
|
+
};
|
|
93
|
+
}>;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
endpoints: {
|
|
100
|
+
signInUsername: import("better-auth").StrictEndpoint<"/sign-in/username", {
|
|
101
|
+
method: "POST";
|
|
102
|
+
body: import("zod").ZodObject<{
|
|
103
|
+
username: import("zod").ZodString;
|
|
104
|
+
password: import("zod").ZodString;
|
|
105
|
+
rememberMe: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
106
|
+
callbackURL: import("zod").ZodOptional<import("zod").ZodString>;
|
|
107
|
+
}, import("better-auth").$strip>;
|
|
108
|
+
metadata: {
|
|
109
|
+
openapi: {
|
|
110
|
+
summary: string;
|
|
111
|
+
description: string;
|
|
112
|
+
responses: {
|
|
113
|
+
200: {
|
|
114
|
+
description: string;
|
|
115
|
+
content: {
|
|
116
|
+
"application/json": {
|
|
117
|
+
schema: {
|
|
118
|
+
type: "object";
|
|
119
|
+
properties: {
|
|
120
|
+
token: {
|
|
121
|
+
type: string;
|
|
122
|
+
description: string;
|
|
123
|
+
};
|
|
124
|
+
user: {
|
|
125
|
+
$ref: string;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
required: string[];
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
422: {
|
|
134
|
+
description: string;
|
|
135
|
+
content: {
|
|
136
|
+
"application/json": {
|
|
137
|
+
schema: {
|
|
138
|
+
type: "object";
|
|
139
|
+
properties: {
|
|
140
|
+
message: {
|
|
141
|
+
type: string;
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
}, {
|
|
152
|
+
token: string;
|
|
153
|
+
user: {
|
|
154
|
+
id: string;
|
|
155
|
+
createdAt: Date;
|
|
156
|
+
updatedAt: Date;
|
|
157
|
+
email: string;
|
|
158
|
+
emailVerified: boolean;
|
|
159
|
+
name: string;
|
|
160
|
+
image?: string | null | undefined;
|
|
161
|
+
} & {
|
|
162
|
+
username: string;
|
|
163
|
+
displayUsername: string;
|
|
164
|
+
};
|
|
165
|
+
} | null>;
|
|
166
|
+
isUsernameAvailable: import("better-auth").StrictEndpoint<"/is-username-available", {
|
|
167
|
+
method: "POST";
|
|
168
|
+
body: import("zod").ZodObject<{
|
|
169
|
+
username: import("zod").ZodString;
|
|
170
|
+
}, import("better-auth").$strip>;
|
|
171
|
+
}, {
|
|
172
|
+
available: boolean;
|
|
173
|
+
}>;
|
|
174
|
+
};
|
|
175
|
+
schema: {
|
|
176
|
+
user: {
|
|
177
|
+
fields: {
|
|
178
|
+
username: {
|
|
179
|
+
type: "string";
|
|
180
|
+
required: false;
|
|
181
|
+
sortable: true;
|
|
182
|
+
unique: true;
|
|
183
|
+
returned: true;
|
|
184
|
+
transform: {
|
|
185
|
+
input(value: import("better-auth").DBPrimitive): string | number | boolean | Date | unknown[] | Record<string, unknown> | null | undefined;
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
displayUsername: {
|
|
189
|
+
type: "string";
|
|
190
|
+
required: false;
|
|
191
|
+
transform: {
|
|
192
|
+
input(value: import("better-auth").DBPrimitive): string | number | boolean | Date | unknown[] | Record<string, unknown> | null | undefined;
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
hooks: {
|
|
199
|
+
before: {
|
|
200
|
+
matcher(context: import("better-auth").HookEndpointContext): boolean;
|
|
201
|
+
handler: (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>;
|
|
202
|
+
}[];
|
|
203
|
+
};
|
|
204
|
+
options: import("better-auth/plugins").UsernameOptions | undefined;
|
|
205
|
+
$ERROR_CODES: {
|
|
206
|
+
readonly INVALID_USERNAME_OR_PASSWORD: "Invalid username or password";
|
|
207
|
+
readonly EMAIL_NOT_VERIFIED: "Email not verified";
|
|
208
|
+
readonly UNEXPECTED_ERROR: "Unexpected error";
|
|
209
|
+
readonly USERNAME_IS_ALREADY_TAKEN: "Username is already taken. Please try another.";
|
|
210
|
+
readonly USERNAME_TOO_SHORT: "Username is too short";
|
|
211
|
+
readonly USERNAME_TOO_LONG: "Username is too long";
|
|
212
|
+
readonly INVALID_USERNAME: "Username is invalid";
|
|
213
|
+
readonly INVALID_DISPLAY_USERNAME: "Display username is invalid";
|
|
214
|
+
};
|
|
215
|
+
} | {
|
|
216
|
+
id: "jwt";
|
|
217
|
+
options: NoInfer<{
|
|
218
|
+
jwks: {
|
|
219
|
+
keyPairConfig: {
|
|
220
|
+
alg: "EdDSA";
|
|
221
|
+
crv: "Ed25519";
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
jwt: {
|
|
225
|
+
issuer: string;
|
|
226
|
+
audience: string;
|
|
227
|
+
expirationTime: string;
|
|
228
|
+
definePayload: ({ user, session }: {
|
|
229
|
+
user: import("better-auth").User & Record<string, any>;
|
|
230
|
+
session: import("better-auth").Session & Record<string, any>;
|
|
231
|
+
}) => {
|
|
232
|
+
id: string;
|
|
233
|
+
ns: string;
|
|
234
|
+
db: string;
|
|
235
|
+
ac: string;
|
|
236
|
+
email: string;
|
|
237
|
+
name: string;
|
|
238
|
+
role: string;
|
|
239
|
+
sessionId: string;
|
|
240
|
+
};
|
|
241
|
+
};
|
|
242
|
+
}>;
|
|
243
|
+
endpoints: {
|
|
244
|
+
getJwks: import("better-auth").StrictEndpoint<string, {
|
|
245
|
+
method: "GET";
|
|
246
|
+
metadata: {
|
|
247
|
+
openapi: {
|
|
248
|
+
operationId: string;
|
|
249
|
+
description: string;
|
|
250
|
+
responses: {
|
|
251
|
+
"200": {
|
|
252
|
+
description: string;
|
|
253
|
+
content: {
|
|
254
|
+
"application/json": {
|
|
255
|
+
schema: {
|
|
256
|
+
type: "object";
|
|
257
|
+
properties: {
|
|
258
|
+
keys: {
|
|
259
|
+
type: string;
|
|
260
|
+
description: string;
|
|
261
|
+
items: {
|
|
262
|
+
type: string;
|
|
263
|
+
properties: {
|
|
264
|
+
kid: {
|
|
265
|
+
type: string;
|
|
266
|
+
description: string;
|
|
267
|
+
};
|
|
268
|
+
kty: {
|
|
269
|
+
type: string;
|
|
270
|
+
description: string;
|
|
271
|
+
};
|
|
272
|
+
alg: {
|
|
273
|
+
type: string;
|
|
274
|
+
description: string;
|
|
275
|
+
};
|
|
276
|
+
use: {
|
|
277
|
+
type: string;
|
|
278
|
+
description: string;
|
|
279
|
+
enum: string[];
|
|
280
|
+
nullable: boolean;
|
|
281
|
+
};
|
|
282
|
+
n: {
|
|
283
|
+
type: string;
|
|
284
|
+
description: string;
|
|
285
|
+
nullable: boolean;
|
|
286
|
+
};
|
|
287
|
+
e: {
|
|
288
|
+
type: string;
|
|
289
|
+
description: string;
|
|
290
|
+
nullable: boolean;
|
|
291
|
+
};
|
|
292
|
+
crv: {
|
|
293
|
+
type: string;
|
|
294
|
+
description: string;
|
|
295
|
+
nullable: boolean;
|
|
296
|
+
};
|
|
297
|
+
x: {
|
|
298
|
+
type: string;
|
|
299
|
+
description: string;
|
|
300
|
+
nullable: boolean;
|
|
301
|
+
};
|
|
302
|
+
y: {
|
|
303
|
+
type: string;
|
|
304
|
+
description: string;
|
|
305
|
+
nullable: boolean;
|
|
306
|
+
};
|
|
307
|
+
};
|
|
308
|
+
required: string[];
|
|
309
|
+
};
|
|
310
|
+
};
|
|
311
|
+
};
|
|
312
|
+
required: string[];
|
|
313
|
+
};
|
|
314
|
+
};
|
|
315
|
+
};
|
|
316
|
+
};
|
|
317
|
+
};
|
|
318
|
+
};
|
|
319
|
+
};
|
|
320
|
+
}, import("better-auth").JSONWebKeySet>;
|
|
321
|
+
getToken: import("better-auth").StrictEndpoint<"/token", {
|
|
322
|
+
method: "GET";
|
|
323
|
+
requireHeaders: true;
|
|
324
|
+
use: ((inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
325
|
+
session: {
|
|
326
|
+
session: Record<string, any> & {
|
|
327
|
+
id: string;
|
|
328
|
+
createdAt: Date;
|
|
329
|
+
updatedAt: Date;
|
|
330
|
+
userId: string;
|
|
331
|
+
expiresAt: Date;
|
|
332
|
+
token: string;
|
|
333
|
+
ipAddress?: string | null | undefined;
|
|
334
|
+
userAgent?: string | null | undefined;
|
|
335
|
+
};
|
|
336
|
+
user: Record<string, any> & {
|
|
337
|
+
id: string;
|
|
338
|
+
createdAt: Date;
|
|
339
|
+
updatedAt: Date;
|
|
340
|
+
email: string;
|
|
341
|
+
emailVerified: boolean;
|
|
342
|
+
name: string;
|
|
343
|
+
image?: string | null | undefined;
|
|
344
|
+
};
|
|
345
|
+
};
|
|
346
|
+
}>)[];
|
|
347
|
+
metadata: {
|
|
348
|
+
openapi: {
|
|
349
|
+
operationId: string;
|
|
350
|
+
description: string;
|
|
351
|
+
responses: {
|
|
352
|
+
200: {
|
|
353
|
+
description: string;
|
|
354
|
+
content: {
|
|
355
|
+
"application/json": {
|
|
356
|
+
schema: {
|
|
357
|
+
type: "object";
|
|
358
|
+
properties: {
|
|
359
|
+
token: {
|
|
360
|
+
type: string;
|
|
361
|
+
};
|
|
362
|
+
};
|
|
363
|
+
};
|
|
364
|
+
};
|
|
365
|
+
};
|
|
366
|
+
};
|
|
367
|
+
};
|
|
368
|
+
};
|
|
369
|
+
};
|
|
370
|
+
}, {
|
|
371
|
+
token: string;
|
|
372
|
+
}>;
|
|
373
|
+
signJWT: import("better-auth").StrictEndpoint<string, {
|
|
374
|
+
method: "POST";
|
|
375
|
+
metadata: {
|
|
376
|
+
$Infer: {
|
|
377
|
+
body: {
|
|
378
|
+
payload: import("better-auth").JWTPayload;
|
|
379
|
+
overrideOptions?: JwtOptions | undefined;
|
|
380
|
+
};
|
|
381
|
+
};
|
|
382
|
+
};
|
|
383
|
+
body: import("zod").ZodObject<{
|
|
384
|
+
payload: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>;
|
|
385
|
+
overrideOptions: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>;
|
|
386
|
+
}, import("better-auth").$strip>;
|
|
387
|
+
}, {
|
|
388
|
+
token: string;
|
|
389
|
+
}>;
|
|
390
|
+
verifyJWT: import("better-auth").StrictEndpoint<string, {
|
|
391
|
+
method: "POST";
|
|
392
|
+
metadata: {
|
|
393
|
+
$Infer: {
|
|
394
|
+
body: {
|
|
395
|
+
token: string;
|
|
396
|
+
issuer?: string;
|
|
397
|
+
};
|
|
398
|
+
response: {
|
|
399
|
+
payload: {
|
|
400
|
+
sub: string;
|
|
401
|
+
aud: string;
|
|
402
|
+
[key: string]: any;
|
|
403
|
+
} | null;
|
|
404
|
+
};
|
|
405
|
+
};
|
|
406
|
+
};
|
|
407
|
+
body: import("zod").ZodObject<{
|
|
408
|
+
token: import("zod").ZodString;
|
|
409
|
+
issuer: import("zod").ZodOptional<import("zod").ZodString>;
|
|
410
|
+
}, import("better-auth").$strip>;
|
|
411
|
+
}, {
|
|
412
|
+
payload: (import("better-auth").JWTPayload & Required<Pick<import("better-auth").JWTPayload, "sub" | "aud">>) | null;
|
|
413
|
+
}>;
|
|
414
|
+
};
|
|
415
|
+
hooks: {
|
|
416
|
+
after: {
|
|
417
|
+
matcher(context: import("better-auth").HookEndpointContext): boolean;
|
|
418
|
+
handler: (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>;
|
|
419
|
+
}[];
|
|
420
|
+
};
|
|
421
|
+
schema: {
|
|
422
|
+
jwks: {
|
|
423
|
+
fields: {
|
|
424
|
+
publicKey: {
|
|
425
|
+
type: "string";
|
|
426
|
+
required: true;
|
|
427
|
+
};
|
|
428
|
+
privateKey: {
|
|
429
|
+
type: "string";
|
|
430
|
+
required: true;
|
|
431
|
+
};
|
|
432
|
+
createdAt: {
|
|
433
|
+
type: "date";
|
|
434
|
+
required: true;
|
|
435
|
+
};
|
|
436
|
+
expiresAt: {
|
|
437
|
+
type: "date";
|
|
438
|
+
required: false;
|
|
439
|
+
};
|
|
440
|
+
};
|
|
441
|
+
};
|
|
442
|
+
};
|
|
443
|
+
} | {
|
|
444
|
+
id: "tanstack-start-cookies";
|
|
445
|
+
hooks: {
|
|
446
|
+
after: {
|
|
447
|
+
matcher(ctx: import("better-auth").HookEndpointContext): true;
|
|
448
|
+
handler: (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>;
|
|
449
|
+
}[];
|
|
450
|
+
};
|
|
451
|
+
})[];
|
|
452
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jwt, username } from "better-auth/plugins";
|
|
2
|
+
import { tanstackStartCookies } from "better-auth/tanstack-start";
|
|
3
|
+
import { baseUrl } from "./env.js";
|
|
4
|
+
import { surrealDbAdapter } from "./surrealDbAdapter/index.js";
|
|
5
|
+
const defaultAuthServerPluginOptions = {
|
|
6
|
+
admin: {
|
|
7
|
+
bannedUserMessage: 'Доступ к приложению заблокирован. Обратитесь к администратору.'
|
|
8
|
+
},
|
|
9
|
+
jwt: {
|
|
10
|
+
jwks: {
|
|
11
|
+
keyPairConfig: {
|
|
12
|
+
alg: 'EdDSA',
|
|
13
|
+
crv: 'Ed25519'
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
jwt: {
|
|
17
|
+
issuer: baseUrl,
|
|
18
|
+
audience: baseUrl,
|
|
19
|
+
expirationTime: '15m',
|
|
20
|
+
definePayload: ({ user, session })=>({
|
|
21
|
+
id: user.id,
|
|
22
|
+
ns: process.env.SURREALDB_NAMESPACE || 'dev',
|
|
23
|
+
db: process.env.SURREALDB_DATABASE || 'data',
|
|
24
|
+
ac: 'better_auth_jwt',
|
|
25
|
+
email: user.email,
|
|
26
|
+
name: user.name,
|
|
27
|
+
role: user.role,
|
|
28
|
+
sessionId: session.id
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const defaultAuthServerConfig = {
|
|
34
|
+
baseURL: baseUrl,
|
|
35
|
+
secret: process.env.BETTER_AUTH_SECRET,
|
|
36
|
+
database: surrealDbAdapter(),
|
|
37
|
+
experimental: {
|
|
38
|
+
joins: true
|
|
39
|
+
},
|
|
40
|
+
emailAndPassword: {
|
|
41
|
+
enabled: true
|
|
42
|
+
},
|
|
43
|
+
plugins: [
|
|
44
|
+
username(),
|
|
45
|
+
jwt(defaultAuthServerPluginOptions.jwt),
|
|
46
|
+
tanstackStartCookies()
|
|
47
|
+
]
|
|
48
|
+
};
|
|
49
|
+
export { defaultAuthServerConfig, defaultAuthServerPluginOptions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const baseUrl: string;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { createServerOnlyFn } from "@tanstack/react-start";
|
|
2
|
+
import { getDBInstance } from "../../surrealDB/index.js";
|
|
3
|
+
import { getSessionToken } from "./getSessionToken.js";
|
|
4
|
+
function _ts_add_disposable_resource(env, value, async) {
|
|
5
|
+
if (null != value) {
|
|
6
|
+
if ("object" != typeof value && "function" != typeof value) throw new TypeError("Object expected.");
|
|
7
|
+
var dispose, inner;
|
|
8
|
+
if (async) {
|
|
9
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
10
|
+
dispose = value[Symbol.asyncDispose];
|
|
11
|
+
}
|
|
12
|
+
if (void 0 === dispose) {
|
|
13
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
14
|
+
dispose = value[Symbol.dispose];
|
|
15
|
+
if (async) inner = dispose;
|
|
16
|
+
}
|
|
17
|
+
if ("function" != typeof dispose) throw new TypeError("Object not disposable.");
|
|
18
|
+
if (inner) dispose = function() {
|
|
19
|
+
try {
|
|
20
|
+
inner.call(this);
|
|
21
|
+
} catch (e) {
|
|
22
|
+
return Promise.reject(e);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
env.stack.push({
|
|
26
|
+
value: value,
|
|
27
|
+
dispose: dispose,
|
|
28
|
+
async: async
|
|
29
|
+
});
|
|
30
|
+
} else if (async) env.stack.push({
|
|
31
|
+
async: true
|
|
32
|
+
});
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
function getDBSession_ts_dispose_resources(env) {
|
|
36
|
+
var _SuppressedError = "function" == typeof SuppressedError ? SuppressedError : function(error, suppressed, message) {
|
|
37
|
+
var e = new Error(message);
|
|
38
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
39
|
+
};
|
|
40
|
+
return (getDBSession_ts_dispose_resources = function(env) {
|
|
41
|
+
function fail(e) {
|
|
42
|
+
env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
43
|
+
env.hasError = true;
|
|
44
|
+
}
|
|
45
|
+
var r, s = 0;
|
|
46
|
+
function next() {
|
|
47
|
+
while(r = env.stack.pop())try {
|
|
48
|
+
if (!r.async && 1 === s) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
49
|
+
if (r.dispose) {
|
|
50
|
+
var result = r.dispose.call(r.value);
|
|
51
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) {
|
|
52
|
+
fail(e);
|
|
53
|
+
return next();
|
|
54
|
+
});
|
|
55
|
+
} else s |= 1;
|
|
56
|
+
} catch (e) {
|
|
57
|
+
fail(e);
|
|
58
|
+
}
|
|
59
|
+
if (1 === s) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
60
|
+
if (env.hasError) throw env.error;
|
|
61
|
+
}
|
|
62
|
+
return next();
|
|
63
|
+
})(env);
|
|
64
|
+
}
|
|
65
|
+
const getDBSession = createServerOnlyFn(async (surrealDBProps = {})=>{
|
|
66
|
+
const env = {
|
|
67
|
+
stack: [],
|
|
68
|
+
error: void 0,
|
|
69
|
+
hasError: false
|
|
70
|
+
};
|
|
71
|
+
try {
|
|
72
|
+
const token = await getSessionToken();
|
|
73
|
+
const db = await getDBInstance(surrealDBProps);
|
|
74
|
+
const dbSession = _ts_add_disposable_resource(env, await db.newSession(), true);
|
|
75
|
+
if (token) await dbSession.authenticate(token);
|
|
76
|
+
return dbSession;
|
|
77
|
+
} catch (e) {
|
|
78
|
+
env.error = e;
|
|
79
|
+
env.hasError = true;
|
|
80
|
+
} finally{
|
|
81
|
+
const result = getDBSession_ts_dispose_resources(env);
|
|
82
|
+
if (result) await result;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
export { getDBSession };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getSessionToken: () => Promise<any>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getRequestHeaders } from "@tanstack/react-start/server";
|
|
2
|
+
import { baseUrl } from "./env.js";
|
|
3
|
+
const getSessionToken = async ()=>{
|
|
4
|
+
const headers = getRequestHeaders();
|
|
5
|
+
const tokenResponse = await fetch(`${baseUrl}/api/auth/token`, {
|
|
6
|
+
headers: {
|
|
7
|
+
cookie: headers.get('cookie') || ''
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
if (!tokenResponse.ok) throw new Error('Failed to get JWT token');
|
|
11
|
+
const { token } = await tokenResponse.json();
|
|
12
|
+
return token;
|
|
13
|
+
};
|
|
14
|
+
export { getSessionToken };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getSessionUser<TUser = unknown>(): Promise<TUser | undefined>;
|