@momentumcms/auth 0.1.9 → 0.1.10
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/CHANGELOG.md +11 -0
- package/index.cjs +17 -6
- package/index.js +16 -6
- package/package.json +1 -1
- package/src/core.d.ts +8 -0
- package/src/index.d.ts +1 -0
- package/src/lib/auth-collections.d.ts +3 -6
- package/src/lib/auth-core.d.ts +55 -0
- package/src/lib/auth.d.ts +2 -40
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
## 0.1.10 (2026-02-17)
|
|
2
|
+
|
|
3
|
+
### 🩹 Fixes
|
|
4
|
+
|
|
5
|
+
- **create-momentum-app:** add shell option to execFileSync for Windows ([#28](https://github.com/DonaldMurillo/momentum-cms/pull/28))
|
|
6
|
+
|
|
7
|
+
### ❤️ Thank You
|
|
8
|
+
|
|
9
|
+
- Claude Opus 4.6
|
|
10
|
+
- Donald Murillo @DonaldMurillo
|
|
11
|
+
|
|
1
12
|
## 0.1.9 (2026-02-16)
|
|
2
13
|
|
|
3
14
|
This was a version bump only for auth to align it with other projects, there were no code changes.
|
package/index.cjs
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// libs/auth/src/index.ts
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
|
+
AUTH_ROLES: () => AUTH_ROLES,
|
|
33
34
|
AuthAccountCollection: () => AuthAccountCollection,
|
|
34
35
|
AuthApiKeysCollection: () => AuthApiKeysCollection,
|
|
35
36
|
AuthSessionCollection: () => AuthSessionCollection,
|
|
@@ -48,6 +49,14 @@ __export(src_exports, {
|
|
|
48
49
|
});
|
|
49
50
|
module.exports = __toCommonJS(src_exports);
|
|
50
51
|
|
|
52
|
+
// libs/auth/src/lib/auth-core.ts
|
|
53
|
+
var AUTH_ROLES = [
|
|
54
|
+
{ label: "Admin", value: "admin" },
|
|
55
|
+
{ label: "Editor", value: "editor" },
|
|
56
|
+
{ label: "User", value: "user" },
|
|
57
|
+
{ label: "Viewer", value: "viewer" }
|
|
58
|
+
];
|
|
59
|
+
|
|
51
60
|
// libs/auth/src/lib/auth.ts
|
|
52
61
|
var import_better_auth = require("better-auth");
|
|
53
62
|
var import_plugins = require("better-auth/plugins");
|
|
@@ -805,12 +814,6 @@ var MediaCollection = defineCollection({
|
|
|
805
814
|
});
|
|
806
815
|
|
|
807
816
|
// libs/auth/src/lib/auth-collections.ts
|
|
808
|
-
var AUTH_ROLES = [
|
|
809
|
-
{ label: "Admin", value: "admin" },
|
|
810
|
-
{ label: "Editor", value: "editor" },
|
|
811
|
-
{ label: "User", value: "user" },
|
|
812
|
-
{ label: "Viewer", value: "viewer" }
|
|
813
|
-
];
|
|
814
817
|
var AuthUserCollection = defineCollection({
|
|
815
818
|
slug: "auth-user",
|
|
816
819
|
dbName: "user",
|
|
@@ -1021,6 +1024,13 @@ function momentumAuth(config) {
|
|
|
1021
1024
|
name: "momentum-auth",
|
|
1022
1025
|
// Static collections for admin UI route data (read at config time)
|
|
1023
1026
|
collections: finalAuthCollections,
|
|
1027
|
+
// Browser-safe import paths for the admin config generator
|
|
1028
|
+
browserImports: {
|
|
1029
|
+
collections: {
|
|
1030
|
+
path: "@momentumcms/auth/collections",
|
|
1031
|
+
exportName: "BASE_AUTH_COLLECTIONS"
|
|
1032
|
+
}
|
|
1033
|
+
},
|
|
1024
1034
|
getAuth() {
|
|
1025
1035
|
if (!authInstance) {
|
|
1026
1036
|
throw new Error("Auth not initialized. Call onInit first (via initializeMomentum).");
|
|
@@ -1209,6 +1219,7 @@ function authOrganization() {
|
|
|
1209
1219
|
}
|
|
1210
1220
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1211
1221
|
0 && (module.exports = {
|
|
1222
|
+
AUTH_ROLES,
|
|
1212
1223
|
AuthAccountCollection,
|
|
1213
1224
|
AuthApiKeysCollection,
|
|
1214
1225
|
AuthSessionCollection,
|
package/index.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
// libs/auth/src/lib/auth-core.ts
|
|
2
|
+
var AUTH_ROLES = [
|
|
3
|
+
{ label: "Admin", value: "admin" },
|
|
4
|
+
{ label: "Editor", value: "editor" },
|
|
5
|
+
{ label: "User", value: "user" },
|
|
6
|
+
{ label: "Viewer", value: "viewer" }
|
|
7
|
+
];
|
|
8
|
+
|
|
1
9
|
// libs/auth/src/lib/auth.ts
|
|
2
10
|
import { betterAuth } from "better-auth";
|
|
3
11
|
import { twoFactor } from "better-auth/plugins";
|
|
@@ -755,12 +763,6 @@ var MediaCollection = defineCollection({
|
|
|
755
763
|
});
|
|
756
764
|
|
|
757
765
|
// libs/auth/src/lib/auth-collections.ts
|
|
758
|
-
var AUTH_ROLES = [
|
|
759
|
-
{ label: "Admin", value: "admin" },
|
|
760
|
-
{ label: "Editor", value: "editor" },
|
|
761
|
-
{ label: "User", value: "user" },
|
|
762
|
-
{ label: "Viewer", value: "viewer" }
|
|
763
|
-
];
|
|
764
766
|
var AuthUserCollection = defineCollection({
|
|
765
767
|
slug: "auth-user",
|
|
766
768
|
dbName: "user",
|
|
@@ -971,6 +973,13 @@ function momentumAuth(config) {
|
|
|
971
973
|
name: "momentum-auth",
|
|
972
974
|
// Static collections for admin UI route data (read at config time)
|
|
973
975
|
collections: finalAuthCollections,
|
|
976
|
+
// Browser-safe import paths for the admin config generator
|
|
977
|
+
browserImports: {
|
|
978
|
+
collections: {
|
|
979
|
+
path: "@momentumcms/auth/collections",
|
|
980
|
+
exportName: "BASE_AUTH_COLLECTIONS"
|
|
981
|
+
}
|
|
982
|
+
},
|
|
974
983
|
getAuth() {
|
|
975
984
|
if (!authInstance) {
|
|
976
985
|
throw new Error("Auth not initialized. Call onInit first (via initializeMomentum).");
|
|
@@ -1158,6 +1167,7 @@ function authOrganization() {
|
|
|
1158
1167
|
};
|
|
1159
1168
|
}
|
|
1160
1169
|
export {
|
|
1170
|
+
AUTH_ROLES,
|
|
1161
1171
|
AuthAccountCollection,
|
|
1162
1172
|
AuthApiKeysCollection,
|
|
1163
1173
|
AuthSessionCollection,
|
package/package.json
CHANGED
package/src/core.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @momentumcms/auth/core
|
|
3
|
+
*
|
|
4
|
+
* Browser-safe entry point for auth types and constants.
|
|
5
|
+
* Import from here in browser contexts (admin UI, SSR client bundles)
|
|
6
|
+
* instead of `@momentumcms/auth` which pulls in Node.js dependencies.
|
|
7
|
+
*/
|
|
8
|
+
export { AUTH_ROLES, type MomentumUser, type MomentumSession, type OAuthProviderConfig, type OAuthProvidersConfig, } from './lib/auth-core';
|
package/src/index.d.ts
CHANGED
|
@@ -9,12 +9,9 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Column types are chosen to match Better Auth's expected schema exactly.
|
|
11
11
|
*/
|
|
12
|
-
import type { CollectionConfig
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* Used by both server middleware and admin UI for role validation and display.
|
|
16
|
-
*/
|
|
17
|
-
export declare const AUTH_ROLES: SelectOption[];
|
|
12
|
+
import type { CollectionConfig } from '@momentumcms/core';
|
|
13
|
+
import { AUTH_ROLES } from './auth-core';
|
|
14
|
+
export { AUTH_ROLES };
|
|
18
15
|
export declare const AuthUserCollection: CollectionConfig;
|
|
19
16
|
export declare const AuthSessionCollection: CollectionConfig;
|
|
20
17
|
export declare const AuthAccountCollection: CollectionConfig;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-safe Auth Core Types & Constants
|
|
3
|
+
*
|
|
4
|
+
* This module contains ONLY types and constants that have zero Node.js dependencies.
|
|
5
|
+
* It can be safely imported in browser contexts (admin UI, SSR client bundles)
|
|
6
|
+
* without pulling in `better-auth`, `pg`, `nodemailer`, or other server-only packages.
|
|
7
|
+
*
|
|
8
|
+
* Server-only code (createMomentumAuth, email service, etc.) lives in `auth.ts`.
|
|
9
|
+
*/
|
|
10
|
+
import type { SelectOption } from '@momentumcms/core';
|
|
11
|
+
/**
|
|
12
|
+
* Canonical list of auth roles, ordered by privilege (highest first).
|
|
13
|
+
* Used by both server middleware and admin UI for role validation and display.
|
|
14
|
+
*/
|
|
15
|
+
export declare const AUTH_ROLES: SelectOption[];
|
|
16
|
+
/**
|
|
17
|
+
* User type from Better Auth with additional role field.
|
|
18
|
+
*/
|
|
19
|
+
export interface MomentumUser {
|
|
20
|
+
id: string;
|
|
21
|
+
email: string;
|
|
22
|
+
name: string;
|
|
23
|
+
role: string;
|
|
24
|
+
emailVerified: boolean;
|
|
25
|
+
twoFactorEnabled?: boolean;
|
|
26
|
+
image?: string | null;
|
|
27
|
+
createdAt: Date;
|
|
28
|
+
updatedAt: Date;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Session type from Better Auth.
|
|
32
|
+
*/
|
|
33
|
+
export interface MomentumSession {
|
|
34
|
+
id: string;
|
|
35
|
+
userId: string;
|
|
36
|
+
token: string;
|
|
37
|
+
expiresAt: Date;
|
|
38
|
+
ipAddress?: string | null;
|
|
39
|
+
userAgent?: string | null;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* OAuth provider configuration.
|
|
43
|
+
*/
|
|
44
|
+
export interface OAuthProviderConfig {
|
|
45
|
+
clientId: string;
|
|
46
|
+
clientSecret: string;
|
|
47
|
+
redirectURI?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Supported OAuth providers.
|
|
51
|
+
*/
|
|
52
|
+
export interface OAuthProvidersConfig {
|
|
53
|
+
google?: OAuthProviderConfig;
|
|
54
|
+
github?: OAuthProviderConfig;
|
|
55
|
+
}
|
package/src/lib/auth.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import type { Pool } from 'pg';
|
|
|
3
3
|
import type { Database } from 'better-sqlite3';
|
|
4
4
|
import { type EmailConfig } from './email';
|
|
5
5
|
import type { Field } from '@momentumcms/core';
|
|
6
|
+
import type { OAuthProvidersConfig } from './auth-core';
|
|
7
|
+
export type { MomentumUser, MomentumSession, OAuthProviderConfig, OAuthProvidersConfig } from './auth-core';
|
|
6
8
|
/**
|
|
7
9
|
* Database configuration for Better Auth.
|
|
8
10
|
* Supports both SQLite (better-sqlite3) and PostgreSQL (pg).
|
|
@@ -25,21 +27,6 @@ export interface MomentumEmailOptions extends EmailConfig {
|
|
|
25
27
|
/** Require email verification on signup. Default: false */
|
|
26
28
|
requireEmailVerification?: boolean;
|
|
27
29
|
}
|
|
28
|
-
/**
|
|
29
|
-
* OAuth provider configuration.
|
|
30
|
-
*/
|
|
31
|
-
export interface OAuthProviderConfig {
|
|
32
|
-
clientId: string;
|
|
33
|
-
clientSecret: string;
|
|
34
|
-
redirectURI?: string;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Supported OAuth providers.
|
|
38
|
-
*/
|
|
39
|
-
export interface OAuthProvidersConfig {
|
|
40
|
-
google?: OAuthProviderConfig;
|
|
41
|
-
github?: OAuthProviderConfig;
|
|
42
|
-
}
|
|
43
30
|
/**
|
|
44
31
|
* Configuration options for Momentum Auth.
|
|
45
32
|
*/
|
|
@@ -82,31 +69,6 @@ export interface MomentumAuthConfigLegacy {
|
|
|
82
69
|
/** Enable two-factor authentication (TOTP). Default: false */
|
|
83
70
|
twoFactorAuth?: boolean;
|
|
84
71
|
}
|
|
85
|
-
/**
|
|
86
|
-
* User type from Better Auth with additional role field.
|
|
87
|
-
*/
|
|
88
|
-
export interface MomentumUser {
|
|
89
|
-
id: string;
|
|
90
|
-
email: string;
|
|
91
|
-
name: string;
|
|
92
|
-
role: string;
|
|
93
|
-
emailVerified: boolean;
|
|
94
|
-
twoFactorEnabled?: boolean;
|
|
95
|
-
image?: string | null;
|
|
96
|
-
createdAt: Date;
|
|
97
|
-
updatedAt: Date;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Session type from Better Auth.
|
|
101
|
-
*/
|
|
102
|
-
export interface MomentumSession {
|
|
103
|
-
id: string;
|
|
104
|
-
userId: string;
|
|
105
|
-
token: string;
|
|
106
|
-
expiresAt: Date;
|
|
107
|
-
ipAddress?: string | null;
|
|
108
|
-
userAgent?: string | null;
|
|
109
|
-
}
|
|
110
72
|
/**
|
|
111
73
|
* Get the list of enabled OAuth provider names from config/env vars.
|
|
112
74
|
* Useful for exposing available providers to the client.
|