@kyro-cms/core 0.3.0 → 0.3.1

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/index.d.cts CHANGED
@@ -17,17 +17,16 @@ export { DrizzleAdapter, PostgresAuthAdapter, collectionToDrizzleSchema, createD
17
17
  export { MongoDBAdapter, createMongoDBAdapter } from './mongodb/index.cjs';
18
18
  export { buildGraphQLSchema, createGraphQLSchema } from './graphql/index.cjs';
19
19
  export { createHonoApp, createRESTAPI } from './rest/index.cjs';
20
- import { R as RateLimitConfig, b as RateLimitResult, L as LockoutConfig, a as LockoutStatus } from './rate-limit-BmBKGQKx.cjs';
21
- export { q as AccountLockout, A as AdminStylingConfig, C as CSSGenerator, F as FieldStyling, r as RateLimiter, s as RedisAuthAdapter, S as StylingConfig, d as StylingMode, T as ThemeBorderRadius, e as ThemeColors, f as ThemeConfig, g as ThemeFonts, h as ThemeShadows, i as ThemeSpacing, j as createAdminStyling, k as defaultDarkTheme, l as defaultFieldStyling, m as defaultLightTheme, n as ecommerce2026Theme, o as generateCSSVariables, p as generateTailwindConfig } from './rate-limit-BmBKGQKx.cjs';
22
- import { f as AuthUser, c as AuthAdapter, a as AuditLog, b as AuditLogFilter, U as UserRole, S as Session, e as AuthTokenConfig, R as RegisterData, d as AuthResult, L as LoginCredentials, J as JWTPayload } from './types-CGA0z0XD.cjs';
23
- export { A as AuditAction, g as AuditLogger, h as createAuditContext } from './types-CGA0z0XD.cjs';
20
+ export { A as AdminStylingConfig, C as CSSGenerator, F as FieldStyling, S as StylingConfig, a as StylingMode, T as ThemeBorderRadius, b as ThemeColors, c as ThemeConfig, d as ThemeFonts, e as ThemeShadows, f as ThemeSpacing, g as createAdminStyling, h as defaultDarkTheme, i as defaultFieldStyling, j as defaultLightTheme, k as ecommerce2026Theme, l as generateCSSVariables, m as generateTailwindConfig } from './index-Bz9JqRGI.cjs';
21
+ import { d as AuditLog, e as AuditLogFilter, A as AuthAdapter, U as UserRole, c as AuthUser, S as Session, b as AuthTokenConfig, R as RegisterData, a as AuthResult, L as LoginCredentials, J as JWTPayload } from './types-1u353OHN.cjs';
22
+ export { f as AuditAction } from './types-1u353OHN.cjs';
24
23
  import Database from 'better-sqlite3';
25
24
  import { W as WebhookPayload, a as WebhookDelivery, b as WebhookConfig } from './WebhookService-mZZ75syh.cjs';
26
25
  export { A as ALL_WEBHOOK_EVENTS, C as CreateWebhookData, U as UpdateWebhookData, c as WEBHOOK_COLLECTION, d as WEBHOOK_DELIVERY_COLLECTION, e as WEBHOOK_EVENTS, f as WebhookEvent, g as WebhookService, h as WebhookTriggerResult, i as createWebhookService } from './WebhookService-mZZ75syh.cjs';
27
26
  export { TemplateConfig, allSettingsGlobals, blogCollections, blogGlobals, coreSettingsGlobals, createTemplateConfig, ecommerceCollections, ecommerceGlobals, ecommerceSettingsGlobals, kitchenSinkCollections, mediaCollections, minimalCollections } from './templates/index.cjs';
27
+ import { Redis } from 'ioredis';
28
28
  import 'ws';
29
29
  import 'drizzle-orm/postgres-js';
30
- import 'ioredis';
31
30
 
32
31
  interface DeliveryResult {
33
32
  success: boolean;
@@ -74,6 +73,38 @@ declare function normalizeRichTextDocument(value: unknown): RichTextDocument;
74
73
  declare function normalizeRichTextValue<T>(value: T): T;
75
74
  declare function renderRichText(value: unknown): string;
76
75
 
76
+ declare class AuditLogger {
77
+ private redis;
78
+ private prefix;
79
+ private retentionDays;
80
+ constructor(redis: Redis, retentionDays?: number, prefix?: string);
81
+ log(data: Omit<AuditLog, "id" | "timestamp">): Promise<string>;
82
+ get(id: string): Promise<AuditLog | null>;
83
+ query(filter?: AuditLogFilter): Promise<{
84
+ logs: AuditLog[];
85
+ total: number;
86
+ }>;
87
+ getRecent(limit?: number): Promise<AuditLog[]>;
88
+ getUserActivity(userId: string, limit?: number): Promise<AuditLog[]>;
89
+ getStats(startDate?: Date, endDate?: Date): Promise<{
90
+ totalEvents: number;
91
+ byAction: Record<string, number>;
92
+ successRate: number;
93
+ failedLogins: number;
94
+ uniqueUsers: Set<string>;
95
+ }>;
96
+ cleanup(): Promise<number>;
97
+ private getKeyForDate;
98
+ private getKeysForDateRange;
99
+ private matchesFilter;
100
+ private serializeLog;
101
+ private deserializeLog;
102
+ }
103
+ declare function createAuditContext(req: Request): {
104
+ ipAddress: string;
105
+ userAgent: string;
106
+ };
107
+
77
108
  declare class Kyro {
78
109
  registry: Registry;
79
110
  db: BaseAdapter;
@@ -306,6 +337,72 @@ declare const presetPlugins: {
306
337
  Wishlist: typeof WishlistPlugin;
307
338
  };
308
339
 
340
+ interface RedisAuthAdapterOptions {
341
+ url?: string;
342
+ host?: string;
343
+ port?: number;
344
+ password?: string;
345
+ db?: number;
346
+ keyPrefix?: string;
347
+ tokenExpiration?: number;
348
+ refreshTokenExpiration?: number;
349
+ tls?: boolean;
350
+ }
351
+ declare class RedisAuthAdapter implements AuthAdapter {
352
+ private redis;
353
+ private prefix;
354
+ private tokenExpiration;
355
+ private refreshExpiration;
356
+ constructor(options?: RedisAuthAdapterOptions);
357
+ connect(): Promise<void>;
358
+ disconnect(): Promise<void>;
359
+ private userKey;
360
+ private sessionKey;
361
+ private refreshKey;
362
+ private userByEmailKey;
363
+ private passwordHistoryKey;
364
+ createUser(data: {
365
+ email: string;
366
+ password: string;
367
+ role?: UserRole;
368
+ tenantId?: string;
369
+ }): Promise<AuthUser>;
370
+ findUserByEmail(email: string): Promise<AuthUser | null>;
371
+ findUserById(userId: string): Promise<AuthUser | null>;
372
+ updateUser(userId: string, data: Partial<AuthUser>): Promise<AuthUser | null>;
373
+ deleteUser(userId: string): Promise<boolean>;
374
+ hashPassword(password: string): Promise<string>;
375
+ verifyPassword(email: string, password: string): Promise<AuthUser | null>;
376
+ createSession(userId: string, data?: {
377
+ ipAddress?: string;
378
+ userAgent?: string;
379
+ }): Promise<Session>;
380
+ findSessionByToken(token: string): Promise<Session | null>;
381
+ deleteSession(sessionId: string): Promise<boolean>;
382
+ deleteUserSessions(userId: string): Promise<number>;
383
+ addPasswordToHistory(userId: string, passwordHash: string): Promise<void>;
384
+ getPasswordHistory(userId: string, count?: number): Promise<string[]>;
385
+ isPasswordInHistory(password: string, userId: string, historyCount?: number): Promise<boolean>;
386
+ private userToHash;
387
+ private hashToUser;
388
+ private sessionToHash;
389
+ private hashToSession;
390
+ private auditLogKey;
391
+ private auditLogIndexKey;
392
+ findAuditLogs(filter: {
393
+ userId?: string;
394
+ action?: string | string[];
395
+ resource?: string;
396
+ success?: boolean;
397
+ limit?: number;
398
+ offset?: number;
399
+ }): Promise<{
400
+ logs: any[];
401
+ total: number;
402
+ }>;
403
+ createAuditLog(data: any): Promise<any>;
404
+ }
405
+
309
406
  interface EmailConfig$1 {
310
407
  provider: "smtp" | "resend" | "sendgrid" | "mailgun" | "ses";
311
408
  from: string;
@@ -439,6 +536,74 @@ declare class PasswordPolicy {
439
536
  getConfig(): PasswordPolicyConfig;
440
537
  }
441
538
 
539
+ interface LockoutConfig {
540
+ maxAttempts: number;
541
+ lockDuration: number;
542
+ notifyUser: boolean;
543
+ notifyAdmin: boolean;
544
+ adminNotifyAfter: number;
545
+ }
546
+ interface LockoutStatus {
547
+ locked: boolean;
548
+ attemptsRemaining: number;
549
+ lockedUntil?: Date;
550
+ totalAttempts: number;
551
+ }
552
+ declare class AccountLockout {
553
+ private redis;
554
+ private prefix;
555
+ private config;
556
+ constructor(redis: Redis, config?: Partial<LockoutConfig>, prefix?: string);
557
+ private lockKey;
558
+ private historyKey;
559
+ checkLockout(userId: string): Promise<LockoutStatus>;
560
+ recordFailedAttempt(userId: string): Promise<LockoutStatus>;
561
+ lockAccount(userId: string, duration?: number): Promise<void>;
562
+ unlockAccount(userId: string): Promise<void>;
563
+ resetAttempts(userId: string): Promise<void>;
564
+ getLockoutHistory(userId: string, limit?: number): Promise<Date[]>;
565
+ getLockoutStats(userId: string): Promise<{
566
+ totalFailedAttempts: number;
567
+ lockoutCount: number;
568
+ lastLockout: Date | null;
569
+ averageAttemptsBeforeLockout: number;
570
+ }>;
571
+ shouldNotifyAdmin(currentAttempts: number): boolean;
572
+ getConfig(): LockoutConfig;
573
+ setConfig(config: Partial<LockoutConfig>): void;
574
+ }
575
+
576
+ interface RateLimitConfig {
577
+ window: number;
578
+ max: number;
579
+ }
580
+ interface RateLimitResult {
581
+ allowed: boolean;
582
+ remaining: number;
583
+ resetAt: number;
584
+ retryAfter?: number;
585
+ }
586
+ declare class RateLimiter {
587
+ private redis;
588
+ private prefix;
589
+ private limits;
590
+ private userLimits;
591
+ constructor(redis: Redis, limits?: Record<string, RateLimitConfig>, userLimits?: Record<string, RateLimitConfig>, prefix?: string);
592
+ private getKey;
593
+ check(type: string, identifier: string): Promise<RateLimitResult>;
594
+ checkUser(type: string, userId: string, identifier: string): Promise<RateLimitResult>;
595
+ reset(type: string, identifier: string): Promise<void>;
596
+ resetUser(type: string, userId: string, identifier: string): Promise<void>;
597
+ getStatus(type: string, identifier: string): Promise<{
598
+ count: number;
599
+ limit: number;
600
+ remaining: number;
601
+ resetAt: number;
602
+ }>;
603
+ setLimit(type: string, config: RateLimitConfig): void;
604
+ setUserLimit(type: string, config: RateLimitConfig): void;
605
+ }
606
+
442
607
  declare class InMemoryRateLimiter {
443
608
  private storage;
444
609
  private userStorage;
@@ -1104,4 +1269,4 @@ declare function defineConfig(config: {
1104
1269
  debug?: KyroConfig["debug"];
1105
1270
  }): KyroConfig;
1106
1271
 
1107
- export { AbstractBaseAdapter, type AdapterOptions, AnalyticsPlugin, AuditLog, AuditLogFilter, Auth, AuthAdapter, AuthResult, Session as AuthSession, AuthTokenConfig, AuthUser, BaseAdapter, CollectionConfig, CommentsPlugin, type CompareVersionsOptions, ConfigService, ConfigValidationError, CreateArgs, type CreateVersionOptions, type DatabaseConnectionOptions, type DatabaseType, type DatabaseType$1 as DbAdapterType, DeleteArgs, type DeliveryOptions, type DeliveryResult, Dialect, type DraftPublishConfig, type DrizzleAdapterOptions, type EmailConfig, EmailTransport, Field, FindArgs, FindByIDArgs, FindResult, GlobalConfig, Hook, InMemoryAccountLockout, InMemoryAuditLogger, InMemoryAuthAdapter, InMemoryRateLimiter, JWTPayload, Kyro, type KyroAuthConfig, KyroConfig, KyroPlugin, KyroPubSub, KyroWSServer, LocalAdapter, LoginCredentials, MediaService, type MongoDBAdapterOptions, PasswordPolicy, type PluginAPI, type PluginHooks, PluginManager, type PublishVersionOptions, RegisterData, Registry, Request$1 as Request, ReviewsPlugin, SEOPLugin, SQLiteAuthAdapter, Session, type StorageConfig, UpdateArgs, User, UserRole, type Version, type VersionAdapter, type VersionDiff, type VersionHistoryOptions, VersionManager, type VersionPublishSchedule, type VersionStatus, WebhookConfig, WebhookDelivery, WebhookPayload, WishlistPlugin, authConfig, autoBootstrap, bootstrapAdmin, buildDeliveryRecord, collectionToCreateZod, collectionToUpdateZod, collectionToWhereZod, collectionToZod, createAuth, createAuthConfig, createColumnsNode, createKyro, createLocalAdapter, createLocalStorage, createTestPayload, createVersionManager, defineConfig, deliverWebhook, deliverWithRetry, fieldToZod, generateWebhookSecret, getBootstrapFromEnv, getDefaultDraftPublishConfig, globalToZod, isArchived, isDraft, isPublished, normalizeRichTextDocument, normalizeRichTextValue, presetPlugins, renderRichText, resolveProvider, richTextStyles, signPayload, validateCollection, validateConfig, validateFields, validateGlobal };
1272
+ export { AbstractBaseAdapter, AccountLockout, type AdapterOptions, AnalyticsPlugin, AuditLog, AuditLogFilter, AuditLogger, Auth, AuthAdapter, AuthResult, Session as AuthSession, AuthTokenConfig, AuthUser, BaseAdapter, CollectionConfig, CommentsPlugin, type CompareVersionsOptions, ConfigService, ConfigValidationError, CreateArgs, type CreateVersionOptions, type DatabaseConnectionOptions, type DatabaseType, type DatabaseType$1 as DbAdapterType, DeleteArgs, type DeliveryOptions, type DeliveryResult, Dialect, type DraftPublishConfig, type DrizzleAdapterOptions, type EmailConfig, EmailTransport, Field, FindArgs, FindByIDArgs, FindResult, GlobalConfig, Hook, InMemoryAccountLockout, InMemoryAuditLogger, InMemoryAuthAdapter, InMemoryRateLimiter, JWTPayload, Kyro, type KyroAuthConfig, KyroConfig, KyroPlugin, KyroPubSub, KyroWSServer, LocalAdapter, LoginCredentials, MediaService, type MongoDBAdapterOptions, PasswordPolicy, type PluginAPI, type PluginHooks, PluginManager, type PublishVersionOptions, RateLimiter, RedisAuthAdapter, RegisterData, Registry, Request$1 as Request, ReviewsPlugin, SEOPLugin, SQLiteAuthAdapter, Session, type StorageConfig, UpdateArgs, User, UserRole, type Version, type VersionAdapter, type VersionDiff, type VersionHistoryOptions, VersionManager, type VersionPublishSchedule, type VersionStatus, WebhookConfig, WebhookDelivery, WebhookPayload, WishlistPlugin, authConfig, autoBootstrap, bootstrapAdmin, buildDeliveryRecord, collectionToCreateZod, collectionToUpdateZod, collectionToWhereZod, collectionToZod, createAuditContext, createAuth, createAuthConfig, createColumnsNode, createKyro, createLocalAdapter, createLocalStorage, createTestPayload, createVersionManager, defineConfig, deliverWebhook, deliverWithRetry, fieldToZod, generateWebhookSecret, getBootstrapFromEnv, getDefaultDraftPublishConfig, globalToZod, isArchived, isDraft, isPublished, normalizeRichTextDocument, normalizeRichTextValue, presetPlugins, renderRichText, resolveProvider, richTextStyles, signPayload, validateCollection, validateConfig, validateFields, validateGlobal };
package/dist/index.d.ts CHANGED
@@ -17,17 +17,16 @@ export { DrizzleAdapter, PostgresAuthAdapter, collectionToDrizzleSchema, createD
17
17
  export { MongoDBAdapter, createMongoDBAdapter } from './mongodb/index.js';
18
18
  export { buildGraphQLSchema, createGraphQLSchema } from './graphql/index.js';
19
19
  export { createHonoApp, createRESTAPI } from './rest/index.js';
20
- import { R as RateLimitConfig, b as RateLimitResult, L as LockoutConfig, a as LockoutStatus } from './rate-limit-CmDv55RV.js';
21
- export { q as AccountLockout, A as AdminStylingConfig, C as CSSGenerator, F as FieldStyling, r as RateLimiter, s as RedisAuthAdapter, S as StylingConfig, d as StylingMode, T as ThemeBorderRadius, e as ThemeColors, f as ThemeConfig, g as ThemeFonts, h as ThemeShadows, i as ThemeSpacing, j as createAdminStyling, k as defaultDarkTheme, l as defaultFieldStyling, m as defaultLightTheme, n as ecommerce2026Theme, o as generateCSSVariables, p as generateTailwindConfig } from './rate-limit-CmDv55RV.js';
22
- import { f as AuthUser, c as AuthAdapter, a as AuditLog, b as AuditLogFilter, U as UserRole, S as Session, e as AuthTokenConfig, R as RegisterData, d as AuthResult, L as LoginCredentials, J as JWTPayload } from './types-CGA0z0XD.js';
23
- export { A as AuditAction, g as AuditLogger, h as createAuditContext } from './types-CGA0z0XD.js';
20
+ export { A as AdminStylingConfig, C as CSSGenerator, F as FieldStyling, S as StylingConfig, a as StylingMode, T as ThemeBorderRadius, b as ThemeColors, c as ThemeConfig, d as ThemeFonts, e as ThemeShadows, f as ThemeSpacing, g as createAdminStyling, h as defaultDarkTheme, i as defaultFieldStyling, j as defaultLightTheme, k as ecommerce2026Theme, l as generateCSSVariables, m as generateTailwindConfig } from './index-Bz9JqRGI.js';
21
+ import { d as AuditLog, e as AuditLogFilter, A as AuthAdapter, U as UserRole, c as AuthUser, S as Session, b as AuthTokenConfig, R as RegisterData, a as AuthResult, L as LoginCredentials, J as JWTPayload } from './types-1u353OHN.js';
22
+ export { f as AuditAction } from './types-1u353OHN.js';
24
23
  import Database from 'better-sqlite3';
25
24
  import { W as WebhookPayload, a as WebhookDelivery, b as WebhookConfig } from './WebhookService-BznDc2AT.js';
26
25
  export { A as ALL_WEBHOOK_EVENTS, C as CreateWebhookData, U as UpdateWebhookData, c as WEBHOOK_COLLECTION, d as WEBHOOK_DELIVERY_COLLECTION, e as WEBHOOK_EVENTS, f as WebhookEvent, g as WebhookService, h as WebhookTriggerResult, i as createWebhookService } from './WebhookService-BznDc2AT.js';
27
26
  export { TemplateConfig, allSettingsGlobals, blogCollections, blogGlobals, coreSettingsGlobals, createTemplateConfig, ecommerceCollections, ecommerceGlobals, ecommerceSettingsGlobals, kitchenSinkCollections, mediaCollections, minimalCollections } from './templates/index.js';
27
+ import { Redis } from 'ioredis';
28
28
  import 'ws';
29
29
  import 'drizzle-orm/postgres-js';
30
- import 'ioredis';
31
30
 
32
31
  interface DeliveryResult {
33
32
  success: boolean;
@@ -74,6 +73,38 @@ declare function normalizeRichTextDocument(value: unknown): RichTextDocument;
74
73
  declare function normalizeRichTextValue<T>(value: T): T;
75
74
  declare function renderRichText(value: unknown): string;
76
75
 
76
+ declare class AuditLogger {
77
+ private redis;
78
+ private prefix;
79
+ private retentionDays;
80
+ constructor(redis: Redis, retentionDays?: number, prefix?: string);
81
+ log(data: Omit<AuditLog, "id" | "timestamp">): Promise<string>;
82
+ get(id: string): Promise<AuditLog | null>;
83
+ query(filter?: AuditLogFilter): Promise<{
84
+ logs: AuditLog[];
85
+ total: number;
86
+ }>;
87
+ getRecent(limit?: number): Promise<AuditLog[]>;
88
+ getUserActivity(userId: string, limit?: number): Promise<AuditLog[]>;
89
+ getStats(startDate?: Date, endDate?: Date): Promise<{
90
+ totalEvents: number;
91
+ byAction: Record<string, number>;
92
+ successRate: number;
93
+ failedLogins: number;
94
+ uniqueUsers: Set<string>;
95
+ }>;
96
+ cleanup(): Promise<number>;
97
+ private getKeyForDate;
98
+ private getKeysForDateRange;
99
+ private matchesFilter;
100
+ private serializeLog;
101
+ private deserializeLog;
102
+ }
103
+ declare function createAuditContext(req: Request): {
104
+ ipAddress: string;
105
+ userAgent: string;
106
+ };
107
+
77
108
  declare class Kyro {
78
109
  registry: Registry;
79
110
  db: BaseAdapter;
@@ -306,6 +337,72 @@ declare const presetPlugins: {
306
337
  Wishlist: typeof WishlistPlugin;
307
338
  };
308
339
 
340
+ interface RedisAuthAdapterOptions {
341
+ url?: string;
342
+ host?: string;
343
+ port?: number;
344
+ password?: string;
345
+ db?: number;
346
+ keyPrefix?: string;
347
+ tokenExpiration?: number;
348
+ refreshTokenExpiration?: number;
349
+ tls?: boolean;
350
+ }
351
+ declare class RedisAuthAdapter implements AuthAdapter {
352
+ private redis;
353
+ private prefix;
354
+ private tokenExpiration;
355
+ private refreshExpiration;
356
+ constructor(options?: RedisAuthAdapterOptions);
357
+ connect(): Promise<void>;
358
+ disconnect(): Promise<void>;
359
+ private userKey;
360
+ private sessionKey;
361
+ private refreshKey;
362
+ private userByEmailKey;
363
+ private passwordHistoryKey;
364
+ createUser(data: {
365
+ email: string;
366
+ password: string;
367
+ role?: UserRole;
368
+ tenantId?: string;
369
+ }): Promise<AuthUser>;
370
+ findUserByEmail(email: string): Promise<AuthUser | null>;
371
+ findUserById(userId: string): Promise<AuthUser | null>;
372
+ updateUser(userId: string, data: Partial<AuthUser>): Promise<AuthUser | null>;
373
+ deleteUser(userId: string): Promise<boolean>;
374
+ hashPassword(password: string): Promise<string>;
375
+ verifyPassword(email: string, password: string): Promise<AuthUser | null>;
376
+ createSession(userId: string, data?: {
377
+ ipAddress?: string;
378
+ userAgent?: string;
379
+ }): Promise<Session>;
380
+ findSessionByToken(token: string): Promise<Session | null>;
381
+ deleteSession(sessionId: string): Promise<boolean>;
382
+ deleteUserSessions(userId: string): Promise<number>;
383
+ addPasswordToHistory(userId: string, passwordHash: string): Promise<void>;
384
+ getPasswordHistory(userId: string, count?: number): Promise<string[]>;
385
+ isPasswordInHistory(password: string, userId: string, historyCount?: number): Promise<boolean>;
386
+ private userToHash;
387
+ private hashToUser;
388
+ private sessionToHash;
389
+ private hashToSession;
390
+ private auditLogKey;
391
+ private auditLogIndexKey;
392
+ findAuditLogs(filter: {
393
+ userId?: string;
394
+ action?: string | string[];
395
+ resource?: string;
396
+ success?: boolean;
397
+ limit?: number;
398
+ offset?: number;
399
+ }): Promise<{
400
+ logs: any[];
401
+ total: number;
402
+ }>;
403
+ createAuditLog(data: any): Promise<any>;
404
+ }
405
+
309
406
  interface EmailConfig$1 {
310
407
  provider: "smtp" | "resend" | "sendgrid" | "mailgun" | "ses";
311
408
  from: string;
@@ -439,6 +536,74 @@ declare class PasswordPolicy {
439
536
  getConfig(): PasswordPolicyConfig;
440
537
  }
441
538
 
539
+ interface LockoutConfig {
540
+ maxAttempts: number;
541
+ lockDuration: number;
542
+ notifyUser: boolean;
543
+ notifyAdmin: boolean;
544
+ adminNotifyAfter: number;
545
+ }
546
+ interface LockoutStatus {
547
+ locked: boolean;
548
+ attemptsRemaining: number;
549
+ lockedUntil?: Date;
550
+ totalAttempts: number;
551
+ }
552
+ declare class AccountLockout {
553
+ private redis;
554
+ private prefix;
555
+ private config;
556
+ constructor(redis: Redis, config?: Partial<LockoutConfig>, prefix?: string);
557
+ private lockKey;
558
+ private historyKey;
559
+ checkLockout(userId: string): Promise<LockoutStatus>;
560
+ recordFailedAttempt(userId: string): Promise<LockoutStatus>;
561
+ lockAccount(userId: string, duration?: number): Promise<void>;
562
+ unlockAccount(userId: string): Promise<void>;
563
+ resetAttempts(userId: string): Promise<void>;
564
+ getLockoutHistory(userId: string, limit?: number): Promise<Date[]>;
565
+ getLockoutStats(userId: string): Promise<{
566
+ totalFailedAttempts: number;
567
+ lockoutCount: number;
568
+ lastLockout: Date | null;
569
+ averageAttemptsBeforeLockout: number;
570
+ }>;
571
+ shouldNotifyAdmin(currentAttempts: number): boolean;
572
+ getConfig(): LockoutConfig;
573
+ setConfig(config: Partial<LockoutConfig>): void;
574
+ }
575
+
576
+ interface RateLimitConfig {
577
+ window: number;
578
+ max: number;
579
+ }
580
+ interface RateLimitResult {
581
+ allowed: boolean;
582
+ remaining: number;
583
+ resetAt: number;
584
+ retryAfter?: number;
585
+ }
586
+ declare class RateLimiter {
587
+ private redis;
588
+ private prefix;
589
+ private limits;
590
+ private userLimits;
591
+ constructor(redis: Redis, limits?: Record<string, RateLimitConfig>, userLimits?: Record<string, RateLimitConfig>, prefix?: string);
592
+ private getKey;
593
+ check(type: string, identifier: string): Promise<RateLimitResult>;
594
+ checkUser(type: string, userId: string, identifier: string): Promise<RateLimitResult>;
595
+ reset(type: string, identifier: string): Promise<void>;
596
+ resetUser(type: string, userId: string, identifier: string): Promise<void>;
597
+ getStatus(type: string, identifier: string): Promise<{
598
+ count: number;
599
+ limit: number;
600
+ remaining: number;
601
+ resetAt: number;
602
+ }>;
603
+ setLimit(type: string, config: RateLimitConfig): void;
604
+ setUserLimit(type: string, config: RateLimitConfig): void;
605
+ }
606
+
442
607
  declare class InMemoryRateLimiter {
443
608
  private storage;
444
609
  private userStorage;
@@ -1104,4 +1269,4 @@ declare function defineConfig(config: {
1104
1269
  debug?: KyroConfig["debug"];
1105
1270
  }): KyroConfig;
1106
1271
 
1107
- export { AbstractBaseAdapter, type AdapterOptions, AnalyticsPlugin, AuditLog, AuditLogFilter, Auth, AuthAdapter, AuthResult, Session as AuthSession, AuthTokenConfig, AuthUser, BaseAdapter, CollectionConfig, CommentsPlugin, type CompareVersionsOptions, ConfigService, ConfigValidationError, CreateArgs, type CreateVersionOptions, type DatabaseConnectionOptions, type DatabaseType, type DatabaseType$1 as DbAdapterType, DeleteArgs, type DeliveryOptions, type DeliveryResult, Dialect, type DraftPublishConfig, type DrizzleAdapterOptions, type EmailConfig, EmailTransport, Field, FindArgs, FindByIDArgs, FindResult, GlobalConfig, Hook, InMemoryAccountLockout, InMemoryAuditLogger, InMemoryAuthAdapter, InMemoryRateLimiter, JWTPayload, Kyro, type KyroAuthConfig, KyroConfig, KyroPlugin, KyroPubSub, KyroWSServer, LocalAdapter, LoginCredentials, MediaService, type MongoDBAdapterOptions, PasswordPolicy, type PluginAPI, type PluginHooks, PluginManager, type PublishVersionOptions, RegisterData, Registry, Request$1 as Request, ReviewsPlugin, SEOPLugin, SQLiteAuthAdapter, Session, type StorageConfig, UpdateArgs, User, UserRole, type Version, type VersionAdapter, type VersionDiff, type VersionHistoryOptions, VersionManager, type VersionPublishSchedule, type VersionStatus, WebhookConfig, WebhookDelivery, WebhookPayload, WishlistPlugin, authConfig, autoBootstrap, bootstrapAdmin, buildDeliveryRecord, collectionToCreateZod, collectionToUpdateZod, collectionToWhereZod, collectionToZod, createAuth, createAuthConfig, createColumnsNode, createKyro, createLocalAdapter, createLocalStorage, createTestPayload, createVersionManager, defineConfig, deliverWebhook, deliverWithRetry, fieldToZod, generateWebhookSecret, getBootstrapFromEnv, getDefaultDraftPublishConfig, globalToZod, isArchived, isDraft, isPublished, normalizeRichTextDocument, normalizeRichTextValue, presetPlugins, renderRichText, resolveProvider, richTextStyles, signPayload, validateCollection, validateConfig, validateFields, validateGlobal };
1272
+ export { AbstractBaseAdapter, AccountLockout, type AdapterOptions, AnalyticsPlugin, AuditLog, AuditLogFilter, AuditLogger, Auth, AuthAdapter, AuthResult, Session as AuthSession, AuthTokenConfig, AuthUser, BaseAdapter, CollectionConfig, CommentsPlugin, type CompareVersionsOptions, ConfigService, ConfigValidationError, CreateArgs, type CreateVersionOptions, type DatabaseConnectionOptions, type DatabaseType, type DatabaseType$1 as DbAdapterType, DeleteArgs, type DeliveryOptions, type DeliveryResult, Dialect, type DraftPublishConfig, type DrizzleAdapterOptions, type EmailConfig, EmailTransport, Field, FindArgs, FindByIDArgs, FindResult, GlobalConfig, Hook, InMemoryAccountLockout, InMemoryAuditLogger, InMemoryAuthAdapter, InMemoryRateLimiter, JWTPayload, Kyro, type KyroAuthConfig, KyroConfig, KyroPlugin, KyroPubSub, KyroWSServer, LocalAdapter, LoginCredentials, MediaService, type MongoDBAdapterOptions, PasswordPolicy, type PluginAPI, type PluginHooks, PluginManager, type PublishVersionOptions, RateLimiter, RedisAuthAdapter, RegisterData, Registry, Request$1 as Request, ReviewsPlugin, SEOPLugin, SQLiteAuthAdapter, Session, type StorageConfig, UpdateArgs, User, UserRole, type Version, type VersionAdapter, type VersionDiff, type VersionHistoryOptions, VersionManager, type VersionPublishSchedule, type VersionStatus, WebhookConfig, WebhookDelivery, WebhookPayload, WishlistPlugin, authConfig, autoBootstrap, bootstrapAdmin, buildDeliveryRecord, collectionToCreateZod, collectionToUpdateZod, collectionToWhereZod, collectionToZod, createAuditContext, createAuth, createAuthConfig, createColumnsNode, createKyro, createLocalAdapter, createLocalStorage, createTestPayload, createVersionManager, defineConfig, deliverWebhook, deliverWithRetry, fieldToZod, generateWebhookSecret, getBootstrapFromEnv, getDefaultDraftPublishConfig, globalToZod, isArchived, isDraft, isPublished, normalizeRichTextDocument, normalizeRichTextValue, presetPlugins, renderRichText, resolveProvider, richTextStyles, signPayload, validateCollection, validateConfig, validateFields, validateGlobal };
package/dist/index.js CHANGED
@@ -3614,8 +3614,12 @@ var RateLimiter = class {
3614
3614
  this.userLimits[type] = config;
3615
3615
  }
3616
3616
  };
3617
+
3618
+ // src/auth/security/audit-log-types.ts
3617
3619
  var DEFAULT_RETENTION_CONFIG = {
3618
3620
  retentionDays: 30};
3621
+
3622
+ // src/auth/security/audit-log.ts
3619
3623
  var AuditLogger = class {
3620
3624
  redis;
3621
3625
  prefix;