@kyro-cms/core 0.3.0 → 0.3.2

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.
@@ -1,5 +1,3 @@
1
- import { Redis } from 'ioredis';
2
-
3
1
  type AuditAction = "login" | "logout" | "login_failed" | "register" | "verify_email" | "password_change" | "password_reset" | "password_reset_request" | "role_change" | "permission_change" | "document_create" | "document_update" | "document_delete" | "settings_change" | "user_lockout" | "user_unlock" | "user_create" | "user_update" | "user_delete" | "api_request" | "api_key_create" | "api_key_delete" | "tenant_create" | "tenant_delete";
4
2
  interface AuditLog {
5
3
  id: string;
@@ -32,37 +30,6 @@ interface AuditLogFilter {
32
30
  limit?: number;
33
31
  offset?: number;
34
32
  }
35
- declare class AuditLogger {
36
- private redis;
37
- private prefix;
38
- private retentionDays;
39
- constructor(redis: Redis, retentionDays?: number, prefix?: string);
40
- log(data: Omit<AuditLog, "id" | "timestamp">): Promise<string>;
41
- get(id: string): Promise<AuditLog | null>;
42
- query(filter?: AuditLogFilter): Promise<{
43
- logs: AuditLog[];
44
- total: number;
45
- }>;
46
- getRecent(limit?: number): Promise<AuditLog[]>;
47
- getUserActivity(userId: string, limit?: number): Promise<AuditLog[]>;
48
- getStats(startDate?: Date, endDate?: Date): Promise<{
49
- totalEvents: number;
50
- byAction: Record<string, number>;
51
- successRate: number;
52
- failedLogins: number;
53
- uniqueUsers: Set<string>;
54
- }>;
55
- cleanup(): Promise<number>;
56
- private getKeyForDate;
57
- private getKeysForDateRange;
58
- private matchesFilter;
59
- private serializeLog;
60
- private deserializeLog;
61
- }
62
- declare function createAuditContext(req: Request): {
63
- ipAddress: string;
64
- userAgent: string;
65
- };
66
33
 
67
34
  interface AuthUser {
68
35
  id: string;
@@ -156,4 +123,4 @@ interface AuthAdapter {
156
123
  createAuditLog(data: Omit<AuditLog, "id" | "timestamp">): Promise<AuditLog>;
157
124
  }
158
125
 
159
- export { type AuditAction as A, type JWTPayload as J, type LoginCredentials as L, type RegisterData as R, type Session as S, type UserRole as U, type AuditLog as a, type AuditLogFilter as b, type AuthAdapter as c, type AuthResult as d, type AuthTokenConfig as e, type AuthUser as f, AuditLogger as g, createAuditContext as h };
126
+ export type { AuthAdapter as A, JWTPayload as J, LoginCredentials as L, RegisterData as R, Session as S, UserRole as U, AuthResult as a, AuthTokenConfig as b, AuthUser as c, AuditLog as d, AuditLogFilter as e, AuditAction as f };
@@ -1,5 +1,3 @@
1
- import { Redis } from 'ioredis';
2
-
3
1
  type AuditAction = "login" | "logout" | "login_failed" | "register" | "verify_email" | "password_change" | "password_reset" | "password_reset_request" | "role_change" | "permission_change" | "document_create" | "document_update" | "document_delete" | "settings_change" | "user_lockout" | "user_unlock" | "user_create" | "user_update" | "user_delete" | "api_request" | "api_key_create" | "api_key_delete" | "tenant_create" | "tenant_delete";
4
2
  interface AuditLog {
5
3
  id: string;
@@ -32,37 +30,6 @@ interface AuditLogFilter {
32
30
  limit?: number;
33
31
  offset?: number;
34
32
  }
35
- declare class AuditLogger {
36
- private redis;
37
- private prefix;
38
- private retentionDays;
39
- constructor(redis: Redis, retentionDays?: number, prefix?: string);
40
- log(data: Omit<AuditLog, "id" | "timestamp">): Promise<string>;
41
- get(id: string): Promise<AuditLog | null>;
42
- query(filter?: AuditLogFilter): Promise<{
43
- logs: AuditLog[];
44
- total: number;
45
- }>;
46
- getRecent(limit?: number): Promise<AuditLog[]>;
47
- getUserActivity(userId: string, limit?: number): Promise<AuditLog[]>;
48
- getStats(startDate?: Date, endDate?: Date): Promise<{
49
- totalEvents: number;
50
- byAction: Record<string, number>;
51
- successRate: number;
52
- failedLogins: number;
53
- uniqueUsers: Set<string>;
54
- }>;
55
- cleanup(): Promise<number>;
56
- private getKeyForDate;
57
- private getKeysForDateRange;
58
- private matchesFilter;
59
- private serializeLog;
60
- private deserializeLog;
61
- }
62
- declare function createAuditContext(req: Request): {
63
- ipAddress: string;
64
- userAgent: string;
65
- };
66
33
 
67
34
  interface AuthUser {
68
35
  id: string;
@@ -156,4 +123,4 @@ interface AuthAdapter {
156
123
  createAuditLog(data: Omit<AuditLog, "id" | "timestamp">): Promise<AuditLog>;
157
124
  }
158
125
 
159
- export { type AuditAction as A, type JWTPayload as J, type LoginCredentials as L, type RegisterData as R, type Session as S, type UserRole as U, type AuditLog as a, type AuditLogFilter as b, type AuthAdapter as c, type AuthResult as d, type AuthTokenConfig as e, type AuthUser as f, AuditLogger as g, createAuditContext as h };
126
+ export type { AuthAdapter as A, JWTPayload as J, LoginCredentials as L, RegisterData as R, Session as S, UserRole as U, AuthResult as a, AuthTokenConfig as b, AuthUser as c, AuditLog as d, AuditLogFilter as e, AuditAction as f };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kyro-cms/core",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Astro-native headless CMS with multi-database adapters, multi-protocol APIs, and multi-vendor support",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -1,223 +0,0 @@
1
- import { c as AuthAdapter, U as UserRole, f as AuthUser, S as Session } from './types-CGA0z0XD.cjs';
2
- import { Redis } from 'ioredis';
3
-
4
- type StylingMode = 'css' | 'tailwind' | 'css-in-js' | 'styled-components' | 'vanilla-extract';
5
- interface StylingConfig {
6
- mode: StylingMode;
7
- theme?: ThemeConfig;
8
- customProperties?: Record<string, string>;
9
- }
10
- interface ThemeConfig {
11
- colors?: ThemeColors;
12
- fonts?: ThemeFonts;
13
- spacing?: ThemeSpacing;
14
- borderRadius?: ThemeBorderRadius;
15
- shadows?: ThemeShadows;
16
- breakpoints?: Record<string, string>;
17
- }
18
- interface ThemeColors {
19
- primary?: string;
20
- secondary?: string;
21
- accent?: string;
22
- background?: string;
23
- surface?: string;
24
- text?: string;
25
- textMuted?: string;
26
- border?: string;
27
- error?: string;
28
- warning?: string;
29
- success?: string;
30
- info?: string;
31
- }
32
- interface ThemeFonts {
33
- sans?: string;
34
- serif?: string;
35
- mono?: string;
36
- }
37
- interface ThemeSpacing {
38
- xs?: string;
39
- sm?: string;
40
- md?: string;
41
- lg?: string;
42
- xl?: string;
43
- '2xl'?: string;
44
- '3xl'?: string;
45
- '4xl'?: string;
46
- }
47
- interface ThemeBorderRadius {
48
- sm?: string;
49
- md?: string;
50
- lg?: string;
51
- xl?: string;
52
- full?: string;
53
- }
54
- interface ThemeShadows {
55
- sm?: string;
56
- md?: string;
57
- lg?: string;
58
- xl?: string;
59
- }
60
- declare class CSSGenerator {
61
- private config;
62
- private css;
63
- constructor(config: StylingConfig);
64
- addRule(selector: string, properties: Record<string, string>): this;
65
- addMediaQuery(breakpoint: string, rules: string[]): this;
66
- generate(): string;
67
- }
68
- declare function generateTailwindConfig(theme: ThemeConfig): Record<string, any>;
69
- declare const defaultLightTheme: ThemeConfig;
70
- declare const defaultDarkTheme: ThemeConfig;
71
- declare const ecommerce2026Theme: ThemeConfig;
72
- declare function generateCSSVariables(theme: ThemeConfig): string;
73
- interface AdminStylingConfig {
74
- mode: StylingMode;
75
- theme?: ThemeConfig;
76
- customStyles?: string;
77
- componentOverrides?: Record<string, Record<string, string>>;
78
- }
79
- declare function createAdminStyling(config: AdminStylingConfig): string;
80
- interface FieldStyling {
81
- wrapper?: Record<string, string>;
82
- label?: Record<string, string>;
83
- input?: Record<string, string>;
84
- error?: Record<string, string>;
85
- description?: Record<string, string>;
86
- }
87
- declare const defaultFieldStyling: Record<string, FieldStyling>;
88
-
89
- interface RedisAuthAdapterOptions {
90
- url?: string;
91
- host?: string;
92
- port?: number;
93
- password?: string;
94
- db?: number;
95
- keyPrefix?: string;
96
- tokenExpiration?: number;
97
- refreshTokenExpiration?: number;
98
- tls?: boolean;
99
- }
100
- declare class RedisAuthAdapter implements AuthAdapter {
101
- private redis;
102
- private prefix;
103
- private tokenExpiration;
104
- private refreshExpiration;
105
- constructor(options?: RedisAuthAdapterOptions);
106
- connect(): Promise<void>;
107
- disconnect(): Promise<void>;
108
- private userKey;
109
- private sessionKey;
110
- private refreshKey;
111
- private userByEmailKey;
112
- private passwordHistoryKey;
113
- createUser(data: {
114
- email: string;
115
- password: string;
116
- role?: UserRole;
117
- tenantId?: string;
118
- }): Promise<AuthUser>;
119
- findUserByEmail(email: string): Promise<AuthUser | null>;
120
- findUserById(userId: string): Promise<AuthUser | null>;
121
- updateUser(userId: string, data: Partial<AuthUser>): Promise<AuthUser | null>;
122
- deleteUser(userId: string): Promise<boolean>;
123
- hashPassword(password: string): Promise<string>;
124
- verifyPassword(email: string, password: string): Promise<AuthUser | null>;
125
- createSession(userId: string, data?: {
126
- ipAddress?: string;
127
- userAgent?: string;
128
- }): Promise<Session>;
129
- findSessionByToken(token: string): Promise<Session | null>;
130
- deleteSession(sessionId: string): Promise<boolean>;
131
- deleteUserSessions(userId: string): Promise<number>;
132
- addPasswordToHistory(userId: string, passwordHash: string): Promise<void>;
133
- getPasswordHistory(userId: string, count?: number): Promise<string[]>;
134
- isPasswordInHistory(password: string, userId: string, historyCount?: number): Promise<boolean>;
135
- private userToHash;
136
- private hashToUser;
137
- private sessionToHash;
138
- private hashToSession;
139
- private auditLogKey;
140
- private auditLogIndexKey;
141
- findAuditLogs(filter: {
142
- userId?: string;
143
- action?: string | string[];
144
- resource?: string;
145
- success?: boolean;
146
- limit?: number;
147
- offset?: number;
148
- }): Promise<{
149
- logs: any[];
150
- total: number;
151
- }>;
152
- createAuditLog(data: any): Promise<any>;
153
- }
154
-
155
- interface LockoutConfig {
156
- maxAttempts: number;
157
- lockDuration: number;
158
- notifyUser: boolean;
159
- notifyAdmin: boolean;
160
- adminNotifyAfter: number;
161
- }
162
- interface LockoutStatus {
163
- locked: boolean;
164
- attemptsRemaining: number;
165
- lockedUntil?: Date;
166
- totalAttempts: number;
167
- }
168
- declare class AccountLockout {
169
- private redis;
170
- private prefix;
171
- private config;
172
- constructor(redis: Redis, config?: Partial<LockoutConfig>, prefix?: string);
173
- private lockKey;
174
- private historyKey;
175
- checkLockout(userId: string): Promise<LockoutStatus>;
176
- recordFailedAttempt(userId: string): Promise<LockoutStatus>;
177
- lockAccount(userId: string, duration?: number): Promise<void>;
178
- unlockAccount(userId: string): Promise<void>;
179
- resetAttempts(userId: string): Promise<void>;
180
- getLockoutHistory(userId: string, limit?: number): Promise<Date[]>;
181
- getLockoutStats(userId: string): Promise<{
182
- totalFailedAttempts: number;
183
- lockoutCount: number;
184
- lastLockout: Date | null;
185
- averageAttemptsBeforeLockout: number;
186
- }>;
187
- shouldNotifyAdmin(currentAttempts: number): boolean;
188
- getConfig(): LockoutConfig;
189
- setConfig(config: Partial<LockoutConfig>): void;
190
- }
191
-
192
- interface RateLimitConfig {
193
- window: number;
194
- max: number;
195
- }
196
- interface RateLimitResult {
197
- allowed: boolean;
198
- remaining: number;
199
- resetAt: number;
200
- retryAfter?: number;
201
- }
202
- declare class RateLimiter {
203
- private redis;
204
- private prefix;
205
- private limits;
206
- private userLimits;
207
- constructor(redis: Redis, limits?: Record<string, RateLimitConfig>, userLimits?: Record<string, RateLimitConfig>, prefix?: string);
208
- private getKey;
209
- check(type: string, identifier: string): Promise<RateLimitResult>;
210
- checkUser(type: string, userId: string, identifier: string): Promise<RateLimitResult>;
211
- reset(type: string, identifier: string): Promise<void>;
212
- resetUser(type: string, userId: string, identifier: string): Promise<void>;
213
- getStatus(type: string, identifier: string): Promise<{
214
- count: number;
215
- limit: number;
216
- remaining: number;
217
- resetAt: number;
218
- }>;
219
- setLimit(type: string, config: RateLimitConfig): void;
220
- setUserLimit(type: string, config: RateLimitConfig): void;
221
- }
222
-
223
- export { type AdminStylingConfig as A, CSSGenerator as C, type FieldStyling as F, type LockoutConfig as L, type RateLimitConfig as R, type StylingConfig as S, type ThemeBorderRadius as T, type LockoutStatus as a, type RateLimitResult as b, type RedisAuthAdapterOptions as c, type StylingMode as d, type ThemeColors as e, type ThemeConfig as f, type ThemeFonts as g, type ThemeShadows as h, type ThemeSpacing as i, createAdminStyling as j, defaultDarkTheme as k, defaultFieldStyling as l, defaultLightTheme as m, ecommerce2026Theme as n, generateCSSVariables as o, generateTailwindConfig as p, AccountLockout as q, RateLimiter as r, RedisAuthAdapter as s };
@@ -1,223 +0,0 @@
1
- import { c as AuthAdapter, U as UserRole, f as AuthUser, S as Session } from './types-CGA0z0XD.js';
2
- import { Redis } from 'ioredis';
3
-
4
- type StylingMode = 'css' | 'tailwind' | 'css-in-js' | 'styled-components' | 'vanilla-extract';
5
- interface StylingConfig {
6
- mode: StylingMode;
7
- theme?: ThemeConfig;
8
- customProperties?: Record<string, string>;
9
- }
10
- interface ThemeConfig {
11
- colors?: ThemeColors;
12
- fonts?: ThemeFonts;
13
- spacing?: ThemeSpacing;
14
- borderRadius?: ThemeBorderRadius;
15
- shadows?: ThemeShadows;
16
- breakpoints?: Record<string, string>;
17
- }
18
- interface ThemeColors {
19
- primary?: string;
20
- secondary?: string;
21
- accent?: string;
22
- background?: string;
23
- surface?: string;
24
- text?: string;
25
- textMuted?: string;
26
- border?: string;
27
- error?: string;
28
- warning?: string;
29
- success?: string;
30
- info?: string;
31
- }
32
- interface ThemeFonts {
33
- sans?: string;
34
- serif?: string;
35
- mono?: string;
36
- }
37
- interface ThemeSpacing {
38
- xs?: string;
39
- sm?: string;
40
- md?: string;
41
- lg?: string;
42
- xl?: string;
43
- '2xl'?: string;
44
- '3xl'?: string;
45
- '4xl'?: string;
46
- }
47
- interface ThemeBorderRadius {
48
- sm?: string;
49
- md?: string;
50
- lg?: string;
51
- xl?: string;
52
- full?: string;
53
- }
54
- interface ThemeShadows {
55
- sm?: string;
56
- md?: string;
57
- lg?: string;
58
- xl?: string;
59
- }
60
- declare class CSSGenerator {
61
- private config;
62
- private css;
63
- constructor(config: StylingConfig);
64
- addRule(selector: string, properties: Record<string, string>): this;
65
- addMediaQuery(breakpoint: string, rules: string[]): this;
66
- generate(): string;
67
- }
68
- declare function generateTailwindConfig(theme: ThemeConfig): Record<string, any>;
69
- declare const defaultLightTheme: ThemeConfig;
70
- declare const defaultDarkTheme: ThemeConfig;
71
- declare const ecommerce2026Theme: ThemeConfig;
72
- declare function generateCSSVariables(theme: ThemeConfig): string;
73
- interface AdminStylingConfig {
74
- mode: StylingMode;
75
- theme?: ThemeConfig;
76
- customStyles?: string;
77
- componentOverrides?: Record<string, Record<string, string>>;
78
- }
79
- declare function createAdminStyling(config: AdminStylingConfig): string;
80
- interface FieldStyling {
81
- wrapper?: Record<string, string>;
82
- label?: Record<string, string>;
83
- input?: Record<string, string>;
84
- error?: Record<string, string>;
85
- description?: Record<string, string>;
86
- }
87
- declare const defaultFieldStyling: Record<string, FieldStyling>;
88
-
89
- interface RedisAuthAdapterOptions {
90
- url?: string;
91
- host?: string;
92
- port?: number;
93
- password?: string;
94
- db?: number;
95
- keyPrefix?: string;
96
- tokenExpiration?: number;
97
- refreshTokenExpiration?: number;
98
- tls?: boolean;
99
- }
100
- declare class RedisAuthAdapter implements AuthAdapter {
101
- private redis;
102
- private prefix;
103
- private tokenExpiration;
104
- private refreshExpiration;
105
- constructor(options?: RedisAuthAdapterOptions);
106
- connect(): Promise<void>;
107
- disconnect(): Promise<void>;
108
- private userKey;
109
- private sessionKey;
110
- private refreshKey;
111
- private userByEmailKey;
112
- private passwordHistoryKey;
113
- createUser(data: {
114
- email: string;
115
- password: string;
116
- role?: UserRole;
117
- tenantId?: string;
118
- }): Promise<AuthUser>;
119
- findUserByEmail(email: string): Promise<AuthUser | null>;
120
- findUserById(userId: string): Promise<AuthUser | null>;
121
- updateUser(userId: string, data: Partial<AuthUser>): Promise<AuthUser | null>;
122
- deleteUser(userId: string): Promise<boolean>;
123
- hashPassword(password: string): Promise<string>;
124
- verifyPassword(email: string, password: string): Promise<AuthUser | null>;
125
- createSession(userId: string, data?: {
126
- ipAddress?: string;
127
- userAgent?: string;
128
- }): Promise<Session>;
129
- findSessionByToken(token: string): Promise<Session | null>;
130
- deleteSession(sessionId: string): Promise<boolean>;
131
- deleteUserSessions(userId: string): Promise<number>;
132
- addPasswordToHistory(userId: string, passwordHash: string): Promise<void>;
133
- getPasswordHistory(userId: string, count?: number): Promise<string[]>;
134
- isPasswordInHistory(password: string, userId: string, historyCount?: number): Promise<boolean>;
135
- private userToHash;
136
- private hashToUser;
137
- private sessionToHash;
138
- private hashToSession;
139
- private auditLogKey;
140
- private auditLogIndexKey;
141
- findAuditLogs(filter: {
142
- userId?: string;
143
- action?: string | string[];
144
- resource?: string;
145
- success?: boolean;
146
- limit?: number;
147
- offset?: number;
148
- }): Promise<{
149
- logs: any[];
150
- total: number;
151
- }>;
152
- createAuditLog(data: any): Promise<any>;
153
- }
154
-
155
- interface LockoutConfig {
156
- maxAttempts: number;
157
- lockDuration: number;
158
- notifyUser: boolean;
159
- notifyAdmin: boolean;
160
- adminNotifyAfter: number;
161
- }
162
- interface LockoutStatus {
163
- locked: boolean;
164
- attemptsRemaining: number;
165
- lockedUntil?: Date;
166
- totalAttempts: number;
167
- }
168
- declare class AccountLockout {
169
- private redis;
170
- private prefix;
171
- private config;
172
- constructor(redis: Redis, config?: Partial<LockoutConfig>, prefix?: string);
173
- private lockKey;
174
- private historyKey;
175
- checkLockout(userId: string): Promise<LockoutStatus>;
176
- recordFailedAttempt(userId: string): Promise<LockoutStatus>;
177
- lockAccount(userId: string, duration?: number): Promise<void>;
178
- unlockAccount(userId: string): Promise<void>;
179
- resetAttempts(userId: string): Promise<void>;
180
- getLockoutHistory(userId: string, limit?: number): Promise<Date[]>;
181
- getLockoutStats(userId: string): Promise<{
182
- totalFailedAttempts: number;
183
- lockoutCount: number;
184
- lastLockout: Date | null;
185
- averageAttemptsBeforeLockout: number;
186
- }>;
187
- shouldNotifyAdmin(currentAttempts: number): boolean;
188
- getConfig(): LockoutConfig;
189
- setConfig(config: Partial<LockoutConfig>): void;
190
- }
191
-
192
- interface RateLimitConfig {
193
- window: number;
194
- max: number;
195
- }
196
- interface RateLimitResult {
197
- allowed: boolean;
198
- remaining: number;
199
- resetAt: number;
200
- retryAfter?: number;
201
- }
202
- declare class RateLimiter {
203
- private redis;
204
- private prefix;
205
- private limits;
206
- private userLimits;
207
- constructor(redis: Redis, limits?: Record<string, RateLimitConfig>, userLimits?: Record<string, RateLimitConfig>, prefix?: string);
208
- private getKey;
209
- check(type: string, identifier: string): Promise<RateLimitResult>;
210
- checkUser(type: string, userId: string, identifier: string): Promise<RateLimitResult>;
211
- reset(type: string, identifier: string): Promise<void>;
212
- resetUser(type: string, userId: string, identifier: string): Promise<void>;
213
- getStatus(type: string, identifier: string): Promise<{
214
- count: number;
215
- limit: number;
216
- remaining: number;
217
- resetAt: number;
218
- }>;
219
- setLimit(type: string, config: RateLimitConfig): void;
220
- setUserLimit(type: string, config: RateLimitConfig): void;
221
- }
222
-
223
- export { type AdminStylingConfig as A, CSSGenerator as C, type FieldStyling as F, type LockoutConfig as L, type RateLimitConfig as R, type StylingConfig as S, type ThemeBorderRadius as T, type LockoutStatus as a, type RateLimitResult as b, type RedisAuthAdapterOptions as c, type StylingMode as d, type ThemeColors as e, type ThemeConfig as f, type ThemeFonts as g, type ThemeShadows as h, type ThemeSpacing as i, createAdminStyling as j, defaultDarkTheme as k, defaultFieldStyling as l, defaultLightTheme as m, ecommerce2026Theme as n, generateCSSVariables as o, generateTailwindConfig as p, AccountLockout as q, RateLimiter as r, RedisAuthAdapter as s };