@kyro-cms/core 0.2.10 → 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/README.md +2 -3
- package/dist/{chunk-BLMFBDBG.cjs → chunk-44BF6ALS.cjs} +4 -5
- package/dist/chunk-44BF6ALS.cjs.map +1 -0
- package/dist/{chunk-GLCPGZPM.js → chunk-GE5DMB44.js} +3 -3
- package/dist/chunk-GE5DMB44.js.map +1 -0
- package/dist/client.d.cts +2 -3
- package/dist/client.d.ts +2 -3
- package/dist/drizzle/index.d.cts +1 -2
- package/dist/drizzle/index.d.ts +1 -2
- package/dist/index-Bz9JqRGI.d.cts +86 -0
- package/dist/index-Bz9JqRGI.d.ts +86 -0
- package/dist/index.cjs +7 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +171 -6
- package/dist/index.d.ts +171 -6
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/redis-adapter-E7PMN5HW.cjs +13 -0
- package/dist/{redis-adapter-2N6VA7BI.cjs.map → redis-adapter-E7PMN5HW.cjs.map} +1 -1
- package/dist/redis-adapter-HOO67RBQ.js +4 -0
- package/dist/{redis-adapter-RA24FNCX.js.map → redis-adapter-HOO67RBQ.js.map} +1 -1
- package/dist/{types-BSR91JFN.d.cts → types-1u353OHN.d.cts} +1 -34
- package/dist/{types-BSR91JFN.d.ts → types-1u353OHN.d.ts} +1 -34
- package/package.json +6 -1
- package/dist/chunk-BLMFBDBG.cjs.map +0 -1
- package/dist/chunk-GLCPGZPM.js.map +0 -1
- package/dist/rate-limit-BvUAVCzw.d.cts +0 -223
- package/dist/rate-limit-CJnqG1mG.d.ts +0 -223
- package/dist/redis-adapter-2N6VA7BI.cjs +0 -13
- package/dist/redis-adapter-RA24FNCX.js +0 -4
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
export { A as AuditAction, g as AuditLogger, h as createAuditContext } from './types-BSR91JFN.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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
export { A as AuditAction, g as AuditLogger, h as createAuditContext } from './types-BSR91JFN.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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { allSettingsGlobals, blogCollections, blogGlobals, coreSettingsGlobals, createTemplateConfig, ecommerceCollections, ecommerceGlobals, ecommerceSettingsGlobals, kitchenSinkCollections, mediaCollections, minimalCollections } from './chunk-KB6QF4HO.js';
|
|
2
|
-
export { RedisAuthAdapter } from './chunk-
|
|
2
|
+
export { RedisAuthAdapter } from './chunk-GE5DMB44.js';
|
|
3
3
|
import { PasswordPolicy, SQLiteAuthAdapter } from './chunk-RRYXQMZG.js';
|
|
4
4
|
export { PasswordPolicy, SQLiteAuthAdapter, autoBootstrap, bootstrapAdmin, getBootstrapFromEnv } from './chunk-RRYXQMZG.js';
|
|
5
5
|
import { createAuditContext } from './chunk-QKOFKITP.js';
|
|
@@ -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;
|
|
@@ -4797,7 +4801,7 @@ async function createAuthConfig(databaseType) {
|
|
|
4797
4801
|
const distributed = getEnvBool("KYRO_DISTRIBUTED", false);
|
|
4798
4802
|
let authAdapter;
|
|
4799
4803
|
if (distributed) {
|
|
4800
|
-
const { RedisAuthAdapter: RedisAuthAdapter2 } = await import('./redis-adapter-
|
|
4804
|
+
const { RedisAuthAdapter: RedisAuthAdapter2 } = await import('./redis-adapter-HOO67RBQ.js');
|
|
4801
4805
|
const redisUrl = getEnv("REDIS_URL", "redis://localhost:6379");
|
|
4802
4806
|
const redisTls = getEnvBool("REDIS_TLS", false);
|
|
4803
4807
|
const redisAdapter = new RedisAuthAdapter2({ url: redisUrl, tls: redisTls });
|