deesse 0.2.13 → 0.3.0
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/LICENSE +21 -0
- package/README.md +17 -34
- package/dist/index.d.ts +23 -32
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -126
- package/dist/index.types.d.ts +15 -0
- package/dist/index.types.d.ts.map +1 -0
- package/dist/index.types.js +1 -0
- package/dist/next.d.ts +3 -0
- package/dist/next.d.ts.map +1 -0
- package/dist/next.js +7 -0
- package/dist/paths.d.ts +3 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +2 -0
- package/dist/plugin-api.d.ts +3 -0
- package/dist/plugin-api.d.ts.map +1 -0
- package/dist/plugin-api.js +5 -0
- package/dist/react-types.d.ts +30 -0
- package/dist/react-types.d.ts.map +1 -0
- package/dist/react-types.js +1 -0
- package/dist/react.d.ts +9 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +15 -0
- package/dist/runtime-types.d.ts +20 -0
- package/dist/runtime-types.d.ts.map +1 -0
- package/dist/runtime-types.js +1 -0
- package/dist/runtime.d.ts +11 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +169 -0
- package/dist/types.d.ts +298 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/package.json +52 -39
- package/.turbo/turbo-build.log +0 -4
- package/.turbo/turbo-lint.log +0 -19
- package/.turbo/turbo-type-check.log +0 -4
- package/dist/cache.d.ts +0 -16
- package/dist/cache.d.ts.map +0 -1
- package/dist/cache.js +0 -59
- package/dist/cache.js.map +0 -1
- package/dist/client.d.ts +0 -816
- package/dist/client.d.ts.map +0 -1
- package/dist/client.js +0 -23
- package/dist/client.js.map +0 -1
- package/dist/config/define.d.ts +0 -61
- package/dist/config/define.d.ts.map +0 -1
- package/dist/config/define.js +0 -66
- package/dist/config/define.js.map +0 -1
- package/dist/config/index.d.ts +0 -7
- package/dist/config/index.d.ts.map +0 -1
- package/dist/config/index.js +0 -4
- package/dist/config/index.js.map +0 -1
- package/dist/config/page.d.ts +0 -30
- package/dist/config/page.d.ts.map +0 -1
- package/dist/config/page.js +0 -22
- package/dist/config/page.js.map +0 -1
- package/dist/config/plugin.d.ts +0 -10
- package/dist/config/plugin.d.ts.map +0 -1
- package/dist/config/plugin.js +0 -10
- package/dist/config/plugin.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/admin.d.ts +0 -33
- package/dist/lib/admin.d.ts.map +0 -1
- package/dist/lib/admin.js +0 -69
- package/dist/lib/admin.js.map +0 -1
- package/dist/lib/validation.d.ts +0 -32
- package/dist/lib/validation.d.ts.map +0 -1
- package/dist/lib/validation.js +0 -80
- package/dist/lib/validation.js.map +0 -1
- package/dist/server.d.ts +0 -9
- package/dist/server.d.ts.map +0 -1
- package/dist/server.js +0 -19
- package/dist/server.js.map +0 -1
- package/src/cache.ts +0 -81
- package/src/client.ts +0 -30
- package/src/config/define.ts +0 -135
- package/src/config/index.ts +0 -6
- package/src/config/page.ts +0 -54
- package/src/config/plugin.ts +0 -21
- package/src/index.ts +0 -166
- package/src/server.ts +0 -28
- package/tsconfig.json +0 -12
package/dist/client.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAElE,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,uBAAuB,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;6BAA0E,CAAC;yBAAwC,CAAC;;;2BAAkF,CAAC;mHAAuL,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EADrwJ"}
|
package/dist/client.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { createAuthClient } from "better-auth/react";
|
|
2
|
-
/**
|
|
3
|
-
* Creates a type-safe authentication client.
|
|
4
|
-
* Wraps better-auth's createAuthClient with a simpler API.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```typescript
|
|
8
|
-
* import { createClient } from "deesse";
|
|
9
|
-
*
|
|
10
|
-
* export const client = createClient({
|
|
11
|
-
* auth: {
|
|
12
|
-
* baseURL: "/api/auth",
|
|
13
|
-
* },
|
|
14
|
-
* });
|
|
15
|
-
*
|
|
16
|
-
* // In a component:
|
|
17
|
-
* const { data, isPending } = client.auth.useSession();
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export function createClient(options) {
|
|
21
|
-
return { auth: createAuthClient(options.auth) };
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAOrD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,YAAY,CAC1B,OAA4B;IAE5B,OAAO,EAAE,IAAI,EAAE,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;AAClD,CAAC"}
|
package/dist/config/define.d.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { PostgresJsDatabase } from 'drizzle-orm/postgres-js';
|
|
2
|
-
import type { BetterAuthPlugin } from 'better-auth';
|
|
3
|
-
import type { Plugin } from './plugin';
|
|
4
|
-
import type { PageTree } from './page';
|
|
5
|
-
import type { AdminHeaderConfig } from '@deessejs/admin';
|
|
6
|
-
/**
|
|
7
|
-
* User schema type - each application defines their own schema.
|
|
8
|
-
* Use generics to preserve Drizzle type safety.
|
|
9
|
-
*/
|
|
10
|
-
export type Config<TSchema extends Record<string, unknown> = Record<string, never>> = {
|
|
11
|
-
name?: string;
|
|
12
|
-
database: PostgresJsDatabase<TSchema>;
|
|
13
|
-
plugins?: Plugin[];
|
|
14
|
-
pages?: PageTree[];
|
|
15
|
-
secret: string;
|
|
16
|
-
auth: AuthConfig;
|
|
17
|
-
admin?: {
|
|
18
|
-
header?: AdminHeaderConfig;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Auth configuration - all fields optional for partial override
|
|
23
|
-
*/
|
|
24
|
-
export type AuthConfig = {
|
|
25
|
-
baseURL: string;
|
|
26
|
-
plugins?: BetterAuthPlugin[];
|
|
27
|
-
emailAndPassword?: {
|
|
28
|
-
enabled?: boolean;
|
|
29
|
-
allowSignUp?: boolean;
|
|
30
|
-
requireEmailVerification?: boolean;
|
|
31
|
-
};
|
|
32
|
-
session?: {
|
|
33
|
-
maxAge?: number;
|
|
34
|
-
updateAge?: number;
|
|
35
|
-
};
|
|
36
|
-
trustedOrigins?: string[];
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* Internal config type used at runtime - includes admin plugin
|
|
40
|
-
* Preserves the schema generic for type safety.
|
|
41
|
-
*/
|
|
42
|
-
export type InternalConfig<TSchema extends Record<string, unknown> = Record<string, never>> = Config<TSchema> & {
|
|
43
|
-
auth: {
|
|
44
|
-
baseURL: string;
|
|
45
|
-
plugins: BetterAuthPlugin[];
|
|
46
|
-
emailAndPassword: {
|
|
47
|
-
enabled: boolean;
|
|
48
|
-
};
|
|
49
|
-
session: {
|
|
50
|
-
maxAge: number;
|
|
51
|
-
};
|
|
52
|
-
trustedOrigins: string[];
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
export declare function defineConfig<TSchema extends Record<string, unknown>>(config: Config<TSchema>): InternalConfig<TSchema>;
|
|
56
|
-
/**
|
|
57
|
-
* Get the global config stored by defineConfig().
|
|
58
|
-
* Throws if defineConfig() has not been called.
|
|
59
|
-
*/
|
|
60
|
-
export declare function getGlobalConfig<TSchema extends Record<string, unknown> = Record<string, never>>(): InternalConfig<TSchema>;
|
|
61
|
-
//# sourceMappingURL=define.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../../src/config/define.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGzD;;;GAGG;AACH,MAAM,MAAM,MAAM,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI;IACpF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,CAAC,EAAE;QACN,MAAM,CAAC,EAAE,iBAAiB,CAAC;KAC5B,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC7B,gBAAgB,CAAC,EAAE;QACjB,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,wBAAwB,CAAC,EAAE,OAAO,CAAC;KACpC,CAAC;IACF,OAAO,CAAC,EAAE;QACR,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,cAAc,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG;IAC9G,IAAI,EAAE;QACJ,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,gBAAgB,EAAE,CAAC;QAC5B,gBAAgB,EAAE;YAAE,OAAO,EAAE,OAAO,CAAA;SAAE,CAAC;QACvC,OAAO,EAAE;YAAE,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC;QAC5B,cAAc,EAAE,MAAM,EAAE,CAAC;KAC1B,CAAC;CACH,CAAC;AAsCF,wBAAgB,YAAY,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClE,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,GACtB,cAAc,CAAC,OAAO,CAAC,CA4BzB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,cAAc,CAAC,OAAO,CAAC,CAO1H"}
|
package/dist/config/define.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { admin } from 'better-auth/plugins';
|
|
2
|
-
/**
|
|
3
|
-
* Deep merge two objects, with source overriding target for nested objects.
|
|
4
|
-
* Arrays are concatenated, primitive overrides replace values.
|
|
5
|
-
*/
|
|
6
|
-
function deepMerge(target, source) {
|
|
7
|
-
const result = { ...target };
|
|
8
|
-
for (const key of Object.keys(source)) {
|
|
9
|
-
const targetValue = target[key];
|
|
10
|
-
const sourceValue = source[key];
|
|
11
|
-
if (typeof targetValue === 'object' &&
|
|
12
|
-
targetValue !== null &&
|
|
13
|
-
!Array.isArray(targetValue) &&
|
|
14
|
-
typeof sourceValue === 'object' &&
|
|
15
|
-
sourceValue !== null &&
|
|
16
|
-
!Array.isArray(sourceValue)) {
|
|
17
|
-
result[key] = deepMerge(targetValue, sourceValue);
|
|
18
|
-
}
|
|
19
|
-
else if (sourceValue !== undefined) {
|
|
20
|
-
result[key] = sourceValue;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return result;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Global config storage for getDeesse() without arguments.
|
|
27
|
-
* Stored at module level to persist across HMR.
|
|
28
|
-
* Uses 'any' for the schema since it's a runtime singleton.
|
|
29
|
-
*/
|
|
30
|
-
let globalConfig;
|
|
31
|
-
export function defineConfig(config) {
|
|
32
|
-
// Default auth configuration - admin() is always first
|
|
33
|
-
const defaultAuth = {
|
|
34
|
-
plugins: [admin()],
|
|
35
|
-
emailAndPassword: { enabled: true },
|
|
36
|
-
session: { maxAge: 60 * 60 * 24 * 7 }, // 7 days
|
|
37
|
-
trustedOrigins: [config.auth.baseURL],
|
|
38
|
-
};
|
|
39
|
-
// Merge user config with defaults
|
|
40
|
-
const mergedAuth = {
|
|
41
|
-
baseURL: config.auth.baseURL,
|
|
42
|
-
secret: config.secret,
|
|
43
|
-
plugins: [...defaultAuth.plugins, ...(config.auth.plugins || [])],
|
|
44
|
-
emailAndPassword: deepMerge(defaultAuth.emailAndPassword, config.auth.emailAndPassword || {}),
|
|
45
|
-
session: deepMerge(defaultAuth.session, config.auth.session || {}),
|
|
46
|
-
trustedOrigins: config.auth.trustedOrigins || defaultAuth.trustedOrigins,
|
|
47
|
-
};
|
|
48
|
-
const internalConfig = {
|
|
49
|
-
...config,
|
|
50
|
-
auth: mergedAuth,
|
|
51
|
-
};
|
|
52
|
-
// Store globally for getDeesse() without arguments
|
|
53
|
-
globalConfig = internalConfig;
|
|
54
|
-
return internalConfig;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Get the global config stored by defineConfig().
|
|
58
|
-
* Throws if defineConfig() has not been called.
|
|
59
|
-
*/
|
|
60
|
-
export function getGlobalConfig() {
|
|
61
|
-
if (!globalConfig) {
|
|
62
|
-
throw new Error("Deesse config not defined. Call defineConfig() before accessing getDeesse() without arguments.");
|
|
63
|
-
}
|
|
64
|
-
return globalConfig;
|
|
65
|
-
}
|
|
66
|
-
//# sourceMappingURL=define.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"define.js","sourceRoot":"","sources":["../../src/config/define.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAkD5C;;;GAGG;AACH,SAAS,SAAS,CAAoC,MAAS,EAAE,MAAkB;IACjF,MAAM,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC;IAC7B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAgB,EAAE,CAAC;QACrD,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAChC,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAEhC,IACE,OAAO,WAAW,KAAK,QAAQ;YAC/B,WAAW,KAAK,IAAI;YACpB,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC;YAC3B,OAAO,WAAW,KAAK,QAAQ;YAC/B,WAAW,KAAK,IAAI;YACpB,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAC3B,CAAC;YACD,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CACrB,WAAsC,EACtC,WAAsC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,cAAc,CAAC;AACxB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe;IAC7B,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CACb,gGAAgG,CACjG,CAAC;IACJ,CAAC;IACD,OAAO,YAAuC,CAAC;AACjD,CAAC"}
|
package/dist/config/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { defineConfig } from "./define.js";
|
|
2
|
-
export type { Config, InternalConfig } from "./define.js";
|
|
3
|
-
export { plugin } from "./plugin.js";
|
|
4
|
-
export type { Plugin } from "./plugin.js";
|
|
5
|
-
export { page, section } from "./page.js";
|
|
6
|
-
export type { Page, Section, PageTree } from "./page.js";
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/config/index.js
DELETED
package/dist/config/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/config/page.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
|
-
import type { LucideIcon } from "lucide-react";
|
|
3
|
-
export type Page = {
|
|
4
|
-
type: "page";
|
|
5
|
-
name: string;
|
|
6
|
-
slug: string;
|
|
7
|
-
icon?: LucideIcon;
|
|
8
|
-
content: ReactNode | null;
|
|
9
|
-
};
|
|
10
|
-
export type Section = {
|
|
11
|
-
type: "section";
|
|
12
|
-
name: string;
|
|
13
|
-
slug: string;
|
|
14
|
-
bottom?: boolean;
|
|
15
|
-
children: PageTree[];
|
|
16
|
-
};
|
|
17
|
-
export type PageTree = Page | Section;
|
|
18
|
-
export declare function page(config: {
|
|
19
|
-
name: string;
|
|
20
|
-
slug?: string;
|
|
21
|
-
icon?: LucideIcon;
|
|
22
|
-
content: ReactNode | null;
|
|
23
|
-
}): Page;
|
|
24
|
-
export declare function section(config: {
|
|
25
|
-
name: string;
|
|
26
|
-
slug?: string;
|
|
27
|
-
bottom?: boolean;
|
|
28
|
-
children: PageTree[];
|
|
29
|
-
}): Section;
|
|
30
|
-
//# sourceMappingURL=page.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../src/config/page.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,MAAM,IAAI,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,OAAO,EAAE,SAAS,GAAG,IAAI,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,QAAQ,EAAE,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,OAAO,CAAC;AAMtC,wBAAgB,IAAI,CAAC,MAAM,EAAE;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,OAAO,EAAE,SAAS,GAAG,IAAI,CAAC;CAC3B,GAAG,IAAI,CAQP;AAED,wBAAgB,OAAO,CAAC,MAAM,EAAE;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,QAAQ,EAAE,CAAC;CACtB,GAAG,OAAO,CAQV"}
|
package/dist/config/page.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
function toSlug(name) {
|
|
2
|
-
return name.toLowerCase().replace(/\s+/g, "-");
|
|
3
|
-
}
|
|
4
|
-
export function page(config) {
|
|
5
|
-
return {
|
|
6
|
-
type: "page",
|
|
7
|
-
name: config.name,
|
|
8
|
-
slug: config.slug ?? toSlug(config.name),
|
|
9
|
-
icon: config.icon,
|
|
10
|
-
content: config.content,
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
export function section(config) {
|
|
14
|
-
return {
|
|
15
|
-
type: "section",
|
|
16
|
-
name: config.name,
|
|
17
|
-
slug: config.slug ?? toSlug(config.name),
|
|
18
|
-
bottom: config.bottom,
|
|
19
|
-
children: config.children,
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=page.js.map
|
package/dist/config/page.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"page.js","sourceRoot":"","sources":["../../src/config/page.ts"],"names":[],"mappings":"AAqBA,SAAS,MAAM,CAAC,IAAY;IAC1B,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,MAKpB;IACC,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;QACxC,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,OAAO,EAAE,MAAM,CAAC,OAAO;KACxB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,MAKvB;IACC,OAAO;QACL,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;QACxC,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;KAC1B,CAAC;AACJ,CAAC"}
|
package/dist/config/plugin.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type ZodSchema } from "zod";
|
|
2
|
-
export type Plugin = {
|
|
3
|
-
name: string;
|
|
4
|
-
};
|
|
5
|
-
export type PluginConfig<TParams = never> = {
|
|
6
|
-
name: string;
|
|
7
|
-
schema?: ZodSchema<TParams>;
|
|
8
|
-
};
|
|
9
|
-
export declare function plugin<TParams = never>(config: PluginConfig<TParams>): (params: TParams) => Plugin;
|
|
10
|
-
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/config/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,KAAK,CAAC;AAErC,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,YAAY,CAAC,OAAO,GAAG,KAAK,IAAI;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;CAC7B,CAAC;AAEF,wBAAgB,MAAM,CAAC,OAAO,GAAG,KAAK,EACpC,MAAM,EAAE,YAAY,CAAC,OAAO,CAAC,GAC5B,CAAC,MAAM,EAAE,OAAO,KAAK,MAAM,CAO7B"}
|
package/dist/config/plugin.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/config/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,MAAM,KAAK,CAAC;AAWrC,MAAM,UAAU,MAAM,CACpB,MAA6B;IAE7B,OAAO,CAAC,MAAM,EAAE,EAAE;QAChB,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC9B,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;IAC/B,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAGhC,OAAO,EAAE,YAAY,EAAe,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,eAAe,EAAuB,MAAM,oBAAoB,CAAC;AAE1E,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAGlD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,GAAG,EAAE,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.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { Auth } from "better-auth";
|
|
2
|
-
/**
|
|
3
|
-
* Check if the database has any users.
|
|
4
|
-
* Returns true if the database is empty (no users).
|
|
5
|
-
*/
|
|
6
|
-
export declare function isDatabaseEmpty(auth: Auth): Promise<boolean>;
|
|
7
|
-
/**
|
|
8
|
-
* Require that the database is NOT empty.
|
|
9
|
-
* Throws if no users exist.
|
|
10
|
-
*/
|
|
11
|
-
export declare function requireDatabaseNotEmpty(auth: Auth): Promise<void>;
|
|
12
|
-
/**
|
|
13
|
-
* Check if any admin users exist in the database.
|
|
14
|
-
* Returns true if at least one user with role "admin" exists.
|
|
15
|
-
*
|
|
16
|
-
* Uses the internal adapter directly to bypass auth checks.
|
|
17
|
-
* This is necessary because the listUsers API endpoint requires admin permissions,
|
|
18
|
-
* which creates a circular dependency when checking if an admin exists.
|
|
19
|
-
*/
|
|
20
|
-
export declare function hasAdminUsers(auth: Auth): Promise<boolean>;
|
|
21
|
-
export interface EmailValidationOptions {
|
|
22
|
-
allowedDomains?: string[];
|
|
23
|
-
blockedDomains?: string[];
|
|
24
|
-
requireOrganization?: boolean;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Validate an admin email against configured rules.
|
|
28
|
-
*/
|
|
29
|
-
export declare function validateAdminEmail(email: string, options?: EmailValidationOptions): {
|
|
30
|
-
valid: boolean;
|
|
31
|
-
error?: string;
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=admin.d.ts.map
|
package/dist/lib/admin.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../src/lib/admin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAExC;;;GAGG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAQlE;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAOvE;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAShE;AAED,MAAM,WAAW,sBAAsB;IACrC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,sBAA2B,GACnC;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CA0BpC"}
|
package/dist/lib/admin.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check if the database has any users.
|
|
3
|
-
* Returns true if the database is empty (no users).
|
|
4
|
-
*/
|
|
5
|
-
export async function isDatabaseEmpty(auth) {
|
|
6
|
-
try {
|
|
7
|
-
const result = await auth.api.listUsers({ limit: 1 });
|
|
8
|
-
return !result?.users || result.users.length === 0;
|
|
9
|
-
}
|
|
10
|
-
catch {
|
|
11
|
-
// If listUsers fails, assume not empty (safer default)
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Require that the database is NOT empty.
|
|
17
|
-
* Throws if no users exist.
|
|
18
|
-
*/
|
|
19
|
-
export async function requireDatabaseNotEmpty(auth) {
|
|
20
|
-
if (await isDatabaseEmpty(auth)) {
|
|
21
|
-
throw new Error("Database is empty. Cannot proceed with this operation. " +
|
|
22
|
-
"Use the First Admin Setup page to create the initial admin account.");
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Check if any admin users exist in the database.
|
|
27
|
-
* Returns true if at least one user with role "admin" exists.
|
|
28
|
-
*
|
|
29
|
-
* Uses the internal adapter directly to bypass auth checks.
|
|
30
|
-
* This is necessary because the listUsers API endpoint requires admin permissions,
|
|
31
|
-
* which creates a circular dependency when checking if an admin exists.
|
|
32
|
-
*/
|
|
33
|
-
export async function hasAdminUsers(auth) {
|
|
34
|
-
try {
|
|
35
|
-
// Access internal adapter directly - bypasses all auth middleware
|
|
36
|
-
const context = await auth.$context;
|
|
37
|
-
const users = await context.internalAdapter.listUsers(100);
|
|
38
|
-
return users.some((u) => u.role === "admin") ?? false;
|
|
39
|
-
}
|
|
40
|
-
catch {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Validate an admin email against configured rules.
|
|
46
|
-
*/
|
|
47
|
-
export function validateAdminEmail(email, options = {}) {
|
|
48
|
-
const domain = email.split('@')[1]?.toLowerCase();
|
|
49
|
-
if (!domain) {
|
|
50
|
-
return { valid: false, error: "Invalid email format" };
|
|
51
|
-
}
|
|
52
|
-
// Check blocked domains
|
|
53
|
-
if (options.blockedDomains?.includes(domain)) {
|
|
54
|
-
return { valid: false, error: `Email domain ${domain} is blocked` };
|
|
55
|
-
}
|
|
56
|
-
// Check allowed domains (if specified)
|
|
57
|
-
if (options.allowedDomains?.length && !options.allowedDomains.includes(domain)) {
|
|
58
|
-
return { valid: false, error: `Email must be from: ${options.allowedDomains.join(', ')}` };
|
|
59
|
-
}
|
|
60
|
-
// Require organization (no public email domains)
|
|
61
|
-
if (options.requireOrganization) {
|
|
62
|
-
const PUBLIC_DOMAINS = ['gmail.com', 'yahoo.com', 'hotmail.com', 'outlook.com', 'icloud.com'];
|
|
63
|
-
if (PUBLIC_DOMAINS.includes(domain)) {
|
|
64
|
-
return { valid: false, error: "Personal email domains are not allowed. Use an organizational email." };
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return { valid: true };
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=admin.js.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CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC;IAElD,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC;IACzD,CAAC;IAED,wBAAwB;IACxB,IAAI,OAAO,CAAC,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC7C,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,gBAAgB,MAAM,aAAa,EAAE,CAAC;IACtE,CAAC;IAED,uCAAuC;IACvC,IAAI,OAAO,CAAC,cAAc,EAAE,MAAM,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/E,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,uBAAuB,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;IAC7F,CAAC;IAED,iDAAiD;IACjD,IAAI,OAAO,CAAC,mBAAmB,EAAE,CAAC;QAChC,MAAM,cAAc,GAAG,CAAC,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC;QAC9F,IAAI,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACpC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,sEAAsE,EAAE,CAAC;QACzG,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACzB,CAAC"}
|
package/dist/lib/validation.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Email validation utilities for admin email enforcement
|
|
3
|
-
*/
|
|
4
|
-
export declare const PUBLIC_EMAIL_DOMAINS: readonly ["gmail.com", "yahoo.com", "hotmail.com", "outlook.com", "icloud.com", "mail.com", "aol.com", "protonmail.com", "zoho.com", "yandex.com", "gmx.com"];
|
|
5
|
-
export type PublicEmailDomain = (typeof PUBLIC_EMAIL_DOMAINS)[number];
|
|
6
|
-
/**
|
|
7
|
-
* Check if an email uses a public email domain
|
|
8
|
-
*/
|
|
9
|
-
export declare function isPublicEmailDomain(email: string): boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Get allowed domains from ADMIN_ALLOWED_DOMAINS environment variable.
|
|
12
|
-
* Returns empty array if not configured (no restrictions).
|
|
13
|
-
*/
|
|
14
|
-
export declare function getAllowedDomains(): string[];
|
|
15
|
-
/**
|
|
16
|
-
* Check if an email is from an allowed domain.
|
|
17
|
-
* If no allowed domains are configured, all domains are allowed.
|
|
18
|
-
*/
|
|
19
|
-
export declare function isAllowedAdminEmail(email: string): boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Validate admin email against organizational requirements.
|
|
22
|
-
* Returns an error message if validation fails.
|
|
23
|
-
*/
|
|
24
|
-
export declare function validateAdminEmailDomain(email: string): {
|
|
25
|
-
valid: true;
|
|
26
|
-
} | {
|
|
27
|
-
valid: false;
|
|
28
|
-
code: string;
|
|
29
|
-
message: string;
|
|
30
|
-
suggestion?: string;
|
|
31
|
-
};
|
|
32
|
-
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/lib/validation.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,oBAAoB,+JAYvB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtE;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAG1D;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,EAAE,CAO5C;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAK1D;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,MAAM,GACZ;IAAE,KAAK,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CA8BxF"}
|
package/dist/lib/validation.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Email validation utilities for admin email enforcement
|
|
3
|
-
*/
|
|
4
|
-
export const PUBLIC_EMAIL_DOMAINS = [
|
|
5
|
-
'gmail.com',
|
|
6
|
-
'yahoo.com',
|
|
7
|
-
'hotmail.com',
|
|
8
|
-
'outlook.com',
|
|
9
|
-
'icloud.com',
|
|
10
|
-
'mail.com',
|
|
11
|
-
'aol.com',
|
|
12
|
-
'protonmail.com',
|
|
13
|
-
'zoho.com',
|
|
14
|
-
'yandex.com',
|
|
15
|
-
'gmx.com',
|
|
16
|
-
];
|
|
17
|
-
/**
|
|
18
|
-
* Check if an email uses a public email domain
|
|
19
|
-
*/
|
|
20
|
-
export function isPublicEmailDomain(email) {
|
|
21
|
-
const domain = email.split('@')[1]?.toLowerCase();
|
|
22
|
-
return PUBLIC_EMAIL_DOMAINS.includes(domain);
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Get allowed domains from ADMIN_ALLOWED_DOMAINS environment variable.
|
|
26
|
-
* Returns empty array if not configured (no restrictions).
|
|
27
|
-
*/
|
|
28
|
-
export function getAllowedDomains() {
|
|
29
|
-
const envValue = process.env['ADMIN_ALLOWED_DOMAINS'];
|
|
30
|
-
if (!envValue)
|
|
31
|
-
return [];
|
|
32
|
-
return envValue
|
|
33
|
-
.split(',')
|
|
34
|
-
.map((d) => d.trim().toLowerCase())
|
|
35
|
-
.filter(Boolean);
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Check if an email is from an allowed domain.
|
|
39
|
-
* If no allowed domains are configured, all domains are allowed.
|
|
40
|
-
*/
|
|
41
|
-
export function isAllowedAdminEmail(email) {
|
|
42
|
-
const allowed = getAllowedDomains();
|
|
43
|
-
if (!allowed.length)
|
|
44
|
-
return true; // No restriction configured
|
|
45
|
-
const domain = email.split('@')[1]?.toLowerCase();
|
|
46
|
-
return allowed.includes(domain);
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Validate admin email against organizational requirements.
|
|
50
|
-
* Returns an error message if validation fails.
|
|
51
|
-
*/
|
|
52
|
-
export function validateAdminEmailDomain(email) {
|
|
53
|
-
// Check if email is from a public domain (warning level, not blocking)
|
|
54
|
-
const isPublic = isPublicEmailDomain(email);
|
|
55
|
-
const allowed = getAllowedDomains();
|
|
56
|
-
// If allowed domains are configured, enforce them strictly
|
|
57
|
-
if (allowed.length > 0) {
|
|
58
|
-
const domain = email.split('@')[1]?.toLowerCase();
|
|
59
|
-
if (!allowed.includes(domain)) {
|
|
60
|
-
return {
|
|
61
|
-
valid: false,
|
|
62
|
-
code: 'INVALID_EMAIL_DOMAIN',
|
|
63
|
-
message: `Admin email must be from an allowed domain. Allowed: ${allowed.join(', ')}`,
|
|
64
|
-
suggestion: 'Set ADMIN_ALLOWED_DOMAINS environment variable to configure allowed email domains',
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
// If email is from a public domain, return warning info (but allow through)
|
|
69
|
-
if (isPublic && allowed.length === 0) {
|
|
70
|
-
const domain = email.split('@')[1]?.toLowerCase();
|
|
71
|
-
return {
|
|
72
|
-
valid: false,
|
|
73
|
-
code: 'PUBLIC_EMAIL_DOMAIN',
|
|
74
|
-
message: `${email} is a public email domain. Admin accounts should use organizational email addresses.`,
|
|
75
|
-
suggestion: `Set ADMIN_ALLOWED_DOMAINS environment variable to restrict to organizational domains only (e.g., ADMIN_ALLOWED_DOMAINS=${domain})`,
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
return { valid: true };
|
|
79
|
-
}
|
|
80
|
-
//# sourceMappingURL=validation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/lib/validation.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,WAAW;IACX,WAAW;IACX,aAAa;IACb,aAAa;IACb,YAAY;IACZ,UAAU;IACV,SAAS;IACT,gBAAgB;IAChB,UAAU;IACV,YAAY;IACZ,SAAS;CACD,CAAC;AAIX;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAa;IAC/C,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC;IAClD,OAAO,oBAAoB,CAAC,QAAQ,CAAC,MAA2B,CAAC,CAAC;AACpE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB;IAC/B,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;IACtD,IAAI,CAAC,QAAQ;QAAE,OAAO,EAAE,CAAC;IACzB,OAAO,QAAQ;SACZ,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;SAClC,MAAM,CAAC,OAAO,CAAC,CAAC;AACrB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAa;IAC/C,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC;IACpC,IAAI,CAAC,OAAO,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC,CAAC,4BAA4B;IAC9D,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC;IAClD,OAAO,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAClC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CACtC,KAAa;IAEb,uEAAuE;IACvE,MAAM,QAAQ,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC;IAEpC,2DAA2D;IAC3D,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC;QAClD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YAC9B,OAAO;gBACL,KAAK,EAAE,KAAK;gBACZ,IAAI,EAAE,sBAAsB;gBAC5B,OAAO,EAAE,wDAAwD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;gBACrF,UAAU,EAAE,mFAAmF;aAChG,CAAC;QACJ,CAAC;IACH,CAAC;IAED,4EAA4E;IAC5E,IAAI,QAAQ,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrC,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC;QAClD,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,IAAI,EAAE,qBAAqB;YAC3B,OAAO,EAAE,GAAG,KAAK,sFAAsF;YACvG,UAAU,EAAE,0HAA0H,MAAM,GAAG;SAChJ,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACzB,CAAC"}
|
package/dist/server.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
2
|
-
import type { Auth } from "better-auth";
|
|
3
|
-
import type { InternalConfig } from "./config/define";
|
|
4
|
-
export type Deesse = {
|
|
5
|
-
auth: Auth;
|
|
6
|
-
database: PostgresJsDatabase;
|
|
7
|
-
};
|
|
8
|
-
export declare function createDeesse(config: InternalConfig): Deesse;
|
|
9
|
-
//# sourceMappingURL=server.d.ts.map
|
package/dist/server.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAItD,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,kBAAkB,CAAC;CAC9B,CAAC;AAEF,wBAAgB,YAAY,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAgB3D"}
|
package/dist/server.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { betterAuth } from "better-auth";
|
|
2
|
-
import { drizzleAdapter } from "@better-auth/drizzle-adapter";
|
|
3
|
-
export function createDeesse(config) {
|
|
4
|
-
const auth = betterAuth({
|
|
5
|
-
database: drizzleAdapter(config.database, {
|
|
6
|
-
provider: "pg",
|
|
7
|
-
}),
|
|
8
|
-
baseURL: config.auth.baseURL,
|
|
9
|
-
secret: config.secret,
|
|
10
|
-
emailAndPassword: config.auth.emailAndPassword,
|
|
11
|
-
trustedOrigins: config.auth.trustedOrigins,
|
|
12
|
-
plugins: config.auth.plugins,
|
|
13
|
-
});
|
|
14
|
-
return {
|
|
15
|
-
auth,
|
|
16
|
-
database: config.database,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=server.js.map
|
package/dist/server.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAO9D,MAAM,UAAU,YAAY,CAAC,MAAsB;IACjD,MAAM,IAAI,GAAG,UAAU,CAAC;QACtB,QAAQ,EAAE,cAAc,CAAC,MAAM,CAAC,QAAQ,EAAE;YACxC,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO;QAC5B,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,gBAAgB,EAAE,MAAM,CAAC,IAAI,CAAC,gBAAgB;QAC9C,cAAc,EAAE,MAAM,CAAC,IAAI,CAAC,cAAc;QAC1C,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO;KAC7B,CAAS,CAAC;IAEX,OAAO;QACL,IAAI;QACJ,QAAQ,EAAE,MAAM,CAAC,QAAQ;KAC1B,CAAC;AACJ,CAAC"}
|