@kyro-cms/core 0.1.1 → 0.1.3
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 +202 -113
- package/dist/bootstrap-2WJK6PG7.cjs +29 -0
- package/dist/bootstrap-2WJK6PG7.cjs.map +1 -0
- package/dist/bootstrap-Q2TWUQF3.js +4 -0
- package/dist/bootstrap-Q2TWUQF3.js.map +1 -0
- package/dist/chunk-3QX6KG2S.js +2125 -0
- package/dist/chunk-3QX6KG2S.js.map +1 -0
- package/dist/chunk-5AOILNGY.cjs +212 -0
- package/dist/chunk-5AOILNGY.cjs.map +1 -0
- package/dist/{chunk-DKSMFC3L.js → chunk-EINVJPFM.js} +2 -2
- package/dist/{chunk-DKSMFC3L.js.map → chunk-EINVJPFM.js.map} +1 -1
- package/dist/chunk-F5B64H5S.cjs +2149 -0
- package/dist/chunk-F5B64H5S.cjs.map +1 -0
- package/dist/chunk-I4BORBXT.cjs +914 -0
- package/dist/chunk-I4BORBXT.cjs.map +1 -0
- package/dist/chunk-KA3UOIFC.js +206 -0
- package/dist/chunk-KA3UOIFC.js.map +1 -0
- package/dist/chunk-KWTKEBHM.cjs +176 -0
- package/dist/chunk-KWTKEBHM.cjs.map +1 -0
- package/dist/chunk-M4JFHQ5J.js +170 -0
- package/dist/chunk-M4JFHQ5J.js.map +1 -0
- package/dist/chunk-PZ5AY32C.js +9 -0
- package/dist/chunk-PZ5AY32C.js.map +1 -0
- package/dist/chunk-Q7SFCCGT.cjs +11 -0
- package/dist/chunk-Q7SFCCGT.cjs.map +1 -0
- package/dist/chunk-U4CHJTWX.cjs +94 -0
- package/dist/chunk-U4CHJTWX.cjs.map +1 -0
- package/dist/{chunk-3Q3FS5J4.cjs → chunk-V3B25QOK.cjs} +2 -2
- package/dist/{chunk-3Q3FS5J4.cjs.map → chunk-V3B25QOK.cjs.map} +1 -1
- package/dist/chunk-V67YXRBT.js +899 -0
- package/dist/chunk-V67YXRBT.js.map +1 -0
- package/dist/chunk-XLMVCGXA.js +86 -0
- package/dist/chunk-XLMVCGXA.js.map +1 -0
- package/dist/cli/index.cjs +106 -14
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +106 -14
- package/dist/cli/index.js.map +1 -1
- package/dist/database-37KXWUER.js +5 -0
- package/dist/database-37KXWUER.js.map +1 -0
- package/dist/database-LJKD3HE4.cjs +22 -0
- package/dist/database-LJKD3HE4.cjs.map +1 -0
- package/dist/drizzle/index.cjs +25 -5
- package/dist/drizzle/index.d.cts +5 -49
- package/dist/drizzle/index.d.ts +5 -49
- package/dist/drizzle/index.js +5 -1
- package/dist/graphql/index.cjs +1 -0
- package/dist/graphql/index.js +1 -0
- package/dist/index-BVFlb7uU.d.ts +192 -0
- package/dist/index-CzkEHKqu.d.cts +192 -0
- package/dist/index.cjs +1479 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +421 -65
- package/dist/index.d.ts +421 -65
- package/dist/index.js +1384 -22
- package/dist/index.js.map +1 -1
- package/dist/mongodb/index.cjs +1 -0
- package/dist/mongodb/index.js +1 -0
- package/dist/postgres-auth-adapter-CYZAVPPP.cjs +14 -0
- package/dist/postgres-auth-adapter-CYZAVPPP.cjs.map +1 -0
- package/dist/postgres-auth-adapter-LTDUGBMB.js +5 -0
- package/dist/postgres-auth-adapter-LTDUGBMB.js.map +1 -0
- package/dist/rest/index.cjs +1 -0
- package/dist/rest/index.js +1 -0
- package/dist/templates/index.cjs +94 -536
- package/dist/templates/index.cjs.map +1 -1
- package/dist/templates/index.d.cts +45 -1
- package/dist/templates/index.d.ts +45 -1
- package/dist/templates/index.js +2 -535
- package/dist/templates/index.js.map +1 -1
- package/dist/trpc/index.cjs +1 -0
- package/dist/trpc/index.js +1 -0
- package/dist/ws/index.cjs +1 -0
- package/dist/ws/index.js +1 -0
- package/package.json +23 -8
package/dist/index.d.cts
CHANGED
|
@@ -5,18 +5,25 @@ import * as hono from 'hono';
|
|
|
5
5
|
import * as hono_types from 'hono/types';
|
|
6
6
|
import { R as Registry } from './index-DI0DRPNv.cjs';
|
|
7
7
|
export { c as createRegistry, g as getRegistry, r as resetRegistry } from './index-DI0DRPNv.cjs';
|
|
8
|
-
import { B as BaseAdapter, K as KyroConfig, f as User, g as Request, C as CollectionConfig, G as GlobalConfig, F as Field, a as FindArgs, b as FindResult, c as FindByIDArgs, d as CreateArgs, U as UpdateArgs, D as DeleteArgs, H as Hook } from './types-BGM5MV_K.cjs';
|
|
8
|
+
import { B as BaseAdapter, K as KyroConfig, f as User, g as Request$1, C as CollectionConfig, G as GlobalConfig, F as Field, a as FindArgs, b as FindResult, c as FindByIDArgs, d as CreateArgs, U as UpdateArgs, D as DeleteArgs, H as Hook } from './types-BGM5MV_K.cjs';
|
|
9
9
|
export { A as ALL_FIELD_TYPES, h as AccessArgs, i as AccessControl, j as AdapterConfig, k as AdminConfig, l as ArrayField, m as AuthConfig, n as BaseField, o as Block, p as BlocksField, q as COMPLEX_FIELD_TYPES, r as CheckboxField, s as CodeField, t as CollapsibleField, u as CollectionAccess, v as CollectionHooks, w as ColorField, x as CreateResult, y as DateField, E as EmailField, z as FieldAccess, I as FieldAdmin, J as FieldHooks, L as FieldType, M as GlobalAccess, N as GlobalHooks, O as GroupField, Q as HookArgs, S as ImageSize, T as JSONField, V as LAYOUT_FIELD_TYPES, W as MarkdownField, X as NumberField, Y as PRIMITIVE_FIELD_TYPES, Z as PasswordField, P as PluginConfig, _ as RELATIONAL_FIELD_TYPES, $ as RadioField, R as RelationshipField, a0 as RichTextBlock, a1 as RichTextField, a2 as RowField, a3 as SelectField, a4 as TabsField, a5 as TextField, a6 as TextareaField, a7 as UploadConfig, e as UploadField, a8 as ValidateOptions, a9 as VersionConfig, aa as WhereClause, ab as evaluateAccess, ac as getWhereClause, ad as isArrayField, ae as isBlocksField, af as isGroupField, ag as isLayoutField, ah as isNumberField, ai as isRelationshipField, aj as isRichTextField, ak as isSelectField, al as isTextField, am as isUploadField, an as mergeWhereClauses, ao as runFieldHooks, ap as runHooks } from './types-BGM5MV_K.cjs';
|
|
10
10
|
import { KyroPubSub, KyroWSServer } from './ws/index.cjs';
|
|
11
11
|
export { PubSub, createWSServer } from './ws/index.cjs';
|
|
12
12
|
import { ZodTypeAny } from 'zod';
|
|
13
13
|
export { z } from 'zod';
|
|
14
14
|
import { A as AbstractBaseAdapter } from './base-DlhVlwnN.cjs';
|
|
15
|
-
|
|
15
|
+
import { A as AuthAdapter, U as UserRole, a as AuthUser, S as Session, b as AuthTokenConfig, R as RegisterData, c as AuthResult, L as LoginCredentials, J as JWTPayload } from './index-CzkEHKqu.cjs';
|
|
16
|
+
export { D as DrizzleAdapter, P as PostgresAuthAdapter, d as collectionToDrizzleSchema, e as createDatabase, f as createDrizzleAdapter, g as fieldToDrizzleType, r as runMigrations, s as seedDefaultRoles } from './index-CzkEHKqu.cjs';
|
|
16
17
|
export { MongoDBAdapter, createMongoDBAdapter } from './mongodb/index.cjs';
|
|
17
18
|
export { buildGraphQLSchema, createGraphQLSchema } from './graphql/index.cjs';
|
|
18
19
|
export { createHonoApp, createRESTAPI } from './rest/index.cjs';
|
|
20
|
+
export { TemplateConfig, allSettingsGlobals, blogCollections, blogGlobals, coreSettingsGlobals, createTemplateConfig, ecommerceCollections, ecommerceGlobals, ecommerceSettingsGlobals, kitchenSinkCollections, mediaCollections, minimalCollections } from './templates/index.cjs';
|
|
21
|
+
import Redis from 'ioredis';
|
|
22
|
+
import { SentMessageInfo } from 'nodemailer';
|
|
23
|
+
import Database from 'better-sqlite3';
|
|
19
24
|
import 'ws';
|
|
25
|
+
import 'drizzle-orm/postgres-js';
|
|
26
|
+
import 'postgres';
|
|
20
27
|
|
|
21
28
|
declare class Kyro {
|
|
22
29
|
registry: Registry;
|
|
@@ -28,17 +35,17 @@ declare class Kyro {
|
|
|
28
35
|
init(): Promise<void>;
|
|
29
36
|
getREST(options?: {
|
|
30
37
|
user?: User;
|
|
31
|
-
req?: Request;
|
|
38
|
+
req?: Request$1;
|
|
32
39
|
tenantID?: string;
|
|
33
40
|
}): hono.Hono<hono_types.BlankEnv, hono_types.BlankSchema, "/">;
|
|
34
41
|
getGraphQL(options?: {
|
|
35
42
|
user?: User;
|
|
36
|
-
req?: Request;
|
|
43
|
+
req?: Request$1;
|
|
37
44
|
tenantID?: string;
|
|
38
45
|
}): graphql.GraphQLSchema;
|
|
39
46
|
getTRPC(options?: {
|
|
40
47
|
user?: User;
|
|
41
|
-
req?: Request;
|
|
48
|
+
req?: Request$1;
|
|
42
49
|
tenantID?: string;
|
|
43
50
|
}): KyroRouter;
|
|
44
51
|
startWebSocket(options?: {
|
|
@@ -95,6 +102,7 @@ type AdapterOptions = DrizzleAdapterOptions | MongoDBAdapterOptions;
|
|
|
95
102
|
|
|
96
103
|
declare class LocalAdapter extends AbstractBaseAdapter {
|
|
97
104
|
private db;
|
|
105
|
+
private path?;
|
|
98
106
|
private migrations;
|
|
99
107
|
constructor(options: {
|
|
100
108
|
db?: any;
|
|
@@ -332,77 +340,409 @@ interface FieldStyling {
|
|
|
332
340
|
}
|
|
333
341
|
declare const defaultFieldStyling: Record<string, FieldStyling>;
|
|
334
342
|
|
|
335
|
-
interface
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
343
|
+
interface RedisAuthAdapterOptions {
|
|
344
|
+
url?: string;
|
|
345
|
+
host?: string;
|
|
346
|
+
port?: number;
|
|
347
|
+
password?: string;
|
|
348
|
+
db?: number;
|
|
349
|
+
keyPrefix?: string;
|
|
350
|
+
tokenExpiration?: number;
|
|
351
|
+
refreshTokenExpiration?: number;
|
|
352
|
+
tls?: boolean;
|
|
353
|
+
}
|
|
354
|
+
declare class RedisAuthAdapter implements AuthAdapter {
|
|
355
|
+
private redis;
|
|
356
|
+
private prefix;
|
|
357
|
+
private tokenExpiration;
|
|
358
|
+
private refreshExpiration;
|
|
359
|
+
constructor(options?: RedisAuthAdapterOptions);
|
|
360
|
+
connect(): Promise<void>;
|
|
361
|
+
disconnect(): Promise<void>;
|
|
362
|
+
private userKey;
|
|
363
|
+
private sessionKey;
|
|
364
|
+
private refreshKey;
|
|
365
|
+
private userByEmailKey;
|
|
366
|
+
private passwordHistoryKey;
|
|
367
|
+
createUser(data: {
|
|
368
|
+
email: string;
|
|
369
|
+
passwordHash: string;
|
|
370
|
+
role?: UserRole;
|
|
371
|
+
tenantId?: string;
|
|
372
|
+
}): Promise<AuthUser>;
|
|
373
|
+
findUserByEmail(email: string): Promise<AuthUser | null>;
|
|
374
|
+
findUserById(userId: string): Promise<AuthUser | null>;
|
|
375
|
+
updateUser(userId: string, data: Partial<AuthUser>): Promise<AuthUser | null>;
|
|
376
|
+
deleteUser(userId: string): Promise<boolean>;
|
|
377
|
+
hashPassword(password: string): Promise<string>;
|
|
378
|
+
verifyPassword(password: string, hash: string): Promise<boolean>;
|
|
379
|
+
createSession(userId: string, data?: {
|
|
380
|
+
ipAddress?: string;
|
|
381
|
+
userAgent?: string;
|
|
382
|
+
}): Promise<Session>;
|
|
383
|
+
findSessionByToken(token: string): Promise<Session | null>;
|
|
384
|
+
deleteSession(sessionId: string): Promise<boolean>;
|
|
385
|
+
deleteUserSessions(userId: string): Promise<number>;
|
|
386
|
+
addPasswordToHistory(userId: string, passwordHash: string): Promise<void>;
|
|
387
|
+
getPasswordHistory(userId: string, count?: number): Promise<string[]>;
|
|
388
|
+
isPasswordInHistory(password: string, userId: string, historyCount?: number): Promise<boolean>;
|
|
389
|
+
private userToHash;
|
|
390
|
+
private hashToUser;
|
|
391
|
+
private sessionToHash;
|
|
392
|
+
private hashToSession;
|
|
353
393
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
tenant?: string;
|
|
359
|
-
iat: number;
|
|
360
|
-
exp: number;
|
|
361
|
-
}
|
|
362
|
-
interface AuthTokenConfig {
|
|
363
|
-
secret: string;
|
|
364
|
-
expiresIn?: string | number;
|
|
365
|
-
refreshExpiresIn?: string | number;
|
|
366
|
-
issuer?: string;
|
|
367
|
-
audience?: string[];
|
|
394
|
+
|
|
395
|
+
interface SQLiteAuthAdapterOptions {
|
|
396
|
+
path?: string;
|
|
397
|
+
db?: Database.Database;
|
|
368
398
|
saltRounds?: number;
|
|
369
399
|
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
}
|
|
380
|
-
interface AuthResult {
|
|
381
|
-
success: boolean;
|
|
382
|
-
user?: AuthUser;
|
|
383
|
-
session?: Session;
|
|
384
|
-
token?: string;
|
|
385
|
-
error?: string;
|
|
386
|
-
}
|
|
387
|
-
interface AuthAdapter {
|
|
400
|
+
declare class SQLiteAuthAdapter implements AuthAdapter {
|
|
401
|
+
private db;
|
|
402
|
+
private path;
|
|
403
|
+
private saltRounds;
|
|
404
|
+
private externalDb;
|
|
405
|
+
constructor(options?: SQLiteAuthAdapterOptions);
|
|
406
|
+
connect(): Promise<void>;
|
|
407
|
+
disconnect(): Promise<void>;
|
|
408
|
+
private ensureTables;
|
|
388
409
|
createUser(data: {
|
|
389
410
|
email: string;
|
|
390
411
|
passwordHash: string;
|
|
391
|
-
role
|
|
392
|
-
|
|
412
|
+
role?: UserRole;
|
|
413
|
+
tenantId?: string;
|
|
393
414
|
}): Promise<AuthUser>;
|
|
394
415
|
findUserByEmail(email: string): Promise<AuthUser | null>;
|
|
395
|
-
findUserById(
|
|
396
|
-
updateUser(
|
|
397
|
-
deleteUser(
|
|
398
|
-
verifyPassword(password: string, hash: string): Promise<boolean>;
|
|
416
|
+
findUserById(userId: string): Promise<AuthUser | null>;
|
|
417
|
+
updateUser(userId: string, data: Partial<AuthUser>): Promise<AuthUser | null>;
|
|
418
|
+
deleteUser(userId: string): Promise<boolean>;
|
|
399
419
|
hashPassword(password: string): Promise<string>;
|
|
400
|
-
|
|
420
|
+
verifyPassword(password: string, hash: string): Promise<boolean>;
|
|
421
|
+
createSession(userId: string, data?: {
|
|
422
|
+
ipAddress?: string;
|
|
423
|
+
userAgent?: string;
|
|
424
|
+
}): Promise<Session>;
|
|
401
425
|
findSessionByToken(token: string): Promise<Session | null>;
|
|
402
|
-
|
|
403
|
-
|
|
426
|
+
findSessionByRefreshToken(refreshToken: string): Promise<Session | null>;
|
|
427
|
+
deleteSession(sessionId: string): Promise<boolean>;
|
|
428
|
+
deleteUserSessions(userId: string): Promise<number>;
|
|
429
|
+
hasAnyUsers(): Promise<boolean>;
|
|
430
|
+
addPasswordToHistory(userId: string, passwordHash: string): Promise<void>;
|
|
431
|
+
getPasswordHistory(userId: string, count?: number): Promise<string[]>;
|
|
432
|
+
private rowToUser;
|
|
433
|
+
private rowToSession;
|
|
404
434
|
}
|
|
405
435
|
|
|
436
|
+
interface EmailConfig {
|
|
437
|
+
host: string;
|
|
438
|
+
port: number;
|
|
439
|
+
secure: boolean;
|
|
440
|
+
auth: {
|
|
441
|
+
user: string;
|
|
442
|
+
pass: string;
|
|
443
|
+
};
|
|
444
|
+
from: string;
|
|
445
|
+
fromName?: string;
|
|
446
|
+
}
|
|
447
|
+
interface EmailOptions {
|
|
448
|
+
to: string | string[];
|
|
449
|
+
subject: string;
|
|
450
|
+
html: string;
|
|
451
|
+
text?: string;
|
|
452
|
+
}
|
|
453
|
+
interface EmailTemplates {
|
|
454
|
+
verifyEmail: (link: string, userName?: string) => {
|
|
455
|
+
subject: string;
|
|
456
|
+
html: string;
|
|
457
|
+
text: string;
|
|
458
|
+
};
|
|
459
|
+
resetPassword: (link: string, userName?: string) => {
|
|
460
|
+
subject: string;
|
|
461
|
+
html: string;
|
|
462
|
+
text: string;
|
|
463
|
+
};
|
|
464
|
+
welcome: (userName?: string) => {
|
|
465
|
+
subject: string;
|
|
466
|
+
html: string;
|
|
467
|
+
text: string;
|
|
468
|
+
};
|
|
469
|
+
accountLocked: (attempts: number, duration: number, userName?: string) => {
|
|
470
|
+
subject: string;
|
|
471
|
+
html: string;
|
|
472
|
+
text: string;
|
|
473
|
+
};
|
|
474
|
+
passwordChanged: (userName?: string) => {
|
|
475
|
+
subject: string;
|
|
476
|
+
html: string;
|
|
477
|
+
text: string;
|
|
478
|
+
};
|
|
479
|
+
newLogin: (location: string, time: string, userName?: string) => {
|
|
480
|
+
subject: string;
|
|
481
|
+
html: string;
|
|
482
|
+
text: string;
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
declare class EmailTransport {
|
|
486
|
+
private transporter;
|
|
487
|
+
private from;
|
|
488
|
+
private fromName;
|
|
489
|
+
private templates;
|
|
490
|
+
constructor(config: EmailConfig, templates?: Partial<EmailTemplates>);
|
|
491
|
+
send(options: EmailOptions): Promise<SentMessageInfo>;
|
|
492
|
+
getTemplates(): EmailTemplates;
|
|
493
|
+
verifyConnection(): Promise<boolean>;
|
|
494
|
+
static fromEnv(): EmailTransport | null;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
interface BootstrapConfig {
|
|
498
|
+
redisUrl?: string;
|
|
499
|
+
redisHost?: string;
|
|
500
|
+
redisPort?: number;
|
|
501
|
+
redisPassword?: string;
|
|
502
|
+
authAdapter?: AuthAdapter;
|
|
503
|
+
adminEmail: string;
|
|
504
|
+
adminPassword: string;
|
|
505
|
+
adminRole?: string;
|
|
506
|
+
tenantId?: string;
|
|
507
|
+
emailConfig?: {
|
|
508
|
+
host: string;
|
|
509
|
+
port: number;
|
|
510
|
+
secure: boolean;
|
|
511
|
+
auth: {
|
|
512
|
+
user: string;
|
|
513
|
+
pass: string;
|
|
514
|
+
};
|
|
515
|
+
from: string;
|
|
516
|
+
fromName?: string;
|
|
517
|
+
};
|
|
518
|
+
sendWelcomeEmail?: boolean;
|
|
519
|
+
}
|
|
520
|
+
interface BootstrapResult {
|
|
521
|
+
success: boolean;
|
|
522
|
+
user?: AuthUser;
|
|
523
|
+
error?: string;
|
|
524
|
+
}
|
|
525
|
+
declare function bootstrapAdmin(config: BootstrapConfig): Promise<BootstrapResult>;
|
|
526
|
+
declare function getBootstrapFromEnv(): BootstrapConfig | null;
|
|
527
|
+
declare function autoBootstrap(): Promise<BootstrapResult | null>;
|
|
528
|
+
|
|
529
|
+
interface PasswordPolicyConfig {
|
|
530
|
+
minLength: number;
|
|
531
|
+
requireUppercase: boolean;
|
|
532
|
+
requireLowercase: boolean;
|
|
533
|
+
requireNumbers: boolean;
|
|
534
|
+
requireSpecialChars: boolean;
|
|
535
|
+
preventReuse: number;
|
|
536
|
+
maxLength?: number;
|
|
537
|
+
}
|
|
538
|
+
interface ValidationResult {
|
|
539
|
+
valid: boolean;
|
|
540
|
+
errors: string[];
|
|
541
|
+
}
|
|
542
|
+
declare class PasswordPolicy {
|
|
543
|
+
private config;
|
|
544
|
+
constructor(config?: Partial<PasswordPolicyConfig>);
|
|
545
|
+
validate(password: string): ValidationResult;
|
|
546
|
+
checkReuse(passwordHash: string, history: string[], verifyFn: (password: string, hash: string) => Promise<boolean>): Promise<ValidationResult>;
|
|
547
|
+
isInHistory(password: string, history: string[], verifyFn: (password: string, hash: string) => Promise<boolean>): Promise<boolean>;
|
|
548
|
+
generatePassword(length?: number): string;
|
|
549
|
+
getStrength(password: string): {
|
|
550
|
+
score: number;
|
|
551
|
+
label: string;
|
|
552
|
+
feedback: string[];
|
|
553
|
+
};
|
|
554
|
+
setConfig(config: Partial<PasswordPolicyConfig>): void;
|
|
555
|
+
getConfig(): PasswordPolicyConfig;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
interface LockoutConfig {
|
|
559
|
+
maxAttempts: number;
|
|
560
|
+
lockDuration: number;
|
|
561
|
+
notifyUser: boolean;
|
|
562
|
+
notifyAdmin: boolean;
|
|
563
|
+
adminNotifyAfter: number;
|
|
564
|
+
}
|
|
565
|
+
interface LockoutStatus {
|
|
566
|
+
locked: boolean;
|
|
567
|
+
attemptsRemaining: number;
|
|
568
|
+
lockedUntil?: Date;
|
|
569
|
+
totalAttempts: number;
|
|
570
|
+
}
|
|
571
|
+
declare class AccountLockout {
|
|
572
|
+
private redis;
|
|
573
|
+
private prefix;
|
|
574
|
+
private config;
|
|
575
|
+
constructor(redis: Redis, config?: Partial<LockoutConfig>, prefix?: string);
|
|
576
|
+
private lockKey;
|
|
577
|
+
private historyKey;
|
|
578
|
+
checkLockout(userId: string): Promise<LockoutStatus>;
|
|
579
|
+
recordFailedAttempt(userId: string): Promise<LockoutStatus>;
|
|
580
|
+
lockAccount(userId: string, duration?: number): Promise<void>;
|
|
581
|
+
unlockAccount(userId: string): Promise<void>;
|
|
582
|
+
resetAttempts(userId: string): Promise<void>;
|
|
583
|
+
getLockoutHistory(userId: string, limit?: number): Promise<Date[]>;
|
|
584
|
+
getLockoutStats(userId: string): Promise<{
|
|
585
|
+
totalFailedAttempts: number;
|
|
586
|
+
lockoutCount: number;
|
|
587
|
+
lastLockout: Date | null;
|
|
588
|
+
averageAttemptsBeforeLockout: number;
|
|
589
|
+
}>;
|
|
590
|
+
shouldNotifyAdmin(currentAttempts: number): boolean;
|
|
591
|
+
getConfig(): LockoutConfig;
|
|
592
|
+
setConfig(config: Partial<LockoutConfig>): void;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
interface RateLimitConfig {
|
|
596
|
+
window: number;
|
|
597
|
+
max: number;
|
|
598
|
+
}
|
|
599
|
+
interface RateLimitResult {
|
|
600
|
+
allowed: boolean;
|
|
601
|
+
remaining: number;
|
|
602
|
+
resetAt: number;
|
|
603
|
+
retryAfter?: number;
|
|
604
|
+
}
|
|
605
|
+
declare class RateLimiter {
|
|
606
|
+
private redis;
|
|
607
|
+
private prefix;
|
|
608
|
+
private limits;
|
|
609
|
+
private userLimits;
|
|
610
|
+
constructor(redis: Redis, limits?: Record<string, RateLimitConfig>, userLimits?: Record<string, RateLimitConfig>, prefix?: string);
|
|
611
|
+
private getKey;
|
|
612
|
+
check(type: string, identifier: string): Promise<RateLimitResult>;
|
|
613
|
+
checkUser(type: string, userId: string, identifier: string): Promise<RateLimitResult>;
|
|
614
|
+
reset(type: string, identifier: string): Promise<void>;
|
|
615
|
+
resetUser(type: string, userId: string, identifier: string): Promise<void>;
|
|
616
|
+
getStatus(type: string, identifier: string): Promise<{
|
|
617
|
+
count: number;
|
|
618
|
+
limit: number;
|
|
619
|
+
remaining: number;
|
|
620
|
+
resetAt: number;
|
|
621
|
+
}>;
|
|
622
|
+
setLimit(type: string, config: RateLimitConfig): void;
|
|
623
|
+
setUserLimit(type: string, config: RateLimitConfig): void;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
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";
|
|
627
|
+
interface AuditLog {
|
|
628
|
+
id: string;
|
|
629
|
+
timestamp: Date;
|
|
630
|
+
action: AuditAction;
|
|
631
|
+
userId?: string;
|
|
632
|
+
userEmail?: string;
|
|
633
|
+
role?: string;
|
|
634
|
+
resource: string;
|
|
635
|
+
resourceId?: string;
|
|
636
|
+
changes?: {
|
|
637
|
+
field: string;
|
|
638
|
+
old: any;
|
|
639
|
+
new: any;
|
|
640
|
+
}[];
|
|
641
|
+
ipAddress?: string;
|
|
642
|
+
userAgent?: string;
|
|
643
|
+
success: boolean;
|
|
644
|
+
error?: string;
|
|
645
|
+
metadata?: Record<string, any>;
|
|
646
|
+
}
|
|
647
|
+
interface AuditLogFilter {
|
|
648
|
+
userId?: string;
|
|
649
|
+
action?: AuditAction | AuditAction[];
|
|
650
|
+
resource?: string;
|
|
651
|
+
resourceId?: string;
|
|
652
|
+
success?: boolean;
|
|
653
|
+
startDate?: Date;
|
|
654
|
+
endDate?: Date;
|
|
655
|
+
limit?: number;
|
|
656
|
+
offset?: number;
|
|
657
|
+
}
|
|
658
|
+
declare class AuditLogger {
|
|
659
|
+
private redis;
|
|
660
|
+
private prefix;
|
|
661
|
+
private retentionDays;
|
|
662
|
+
constructor(redis: Redis, retentionDays?: number, prefix?: string);
|
|
663
|
+
log(data: Omit<AuditLog, "id" | "timestamp">): Promise<string>;
|
|
664
|
+
get(id: string): Promise<AuditLog | null>;
|
|
665
|
+
query(filter?: AuditLogFilter): Promise<{
|
|
666
|
+
logs: AuditLog[];
|
|
667
|
+
total: number;
|
|
668
|
+
}>;
|
|
669
|
+
getRecent(limit?: number): Promise<AuditLog[]>;
|
|
670
|
+
getUserActivity(userId: string, limit?: number): Promise<AuditLog[]>;
|
|
671
|
+
getStats(startDate?: Date, endDate?: Date): Promise<{
|
|
672
|
+
totalEvents: number;
|
|
673
|
+
byAction: Record<string, number>;
|
|
674
|
+
successRate: number;
|
|
675
|
+
failedLogins: number;
|
|
676
|
+
uniqueUsers: Set<string>;
|
|
677
|
+
}>;
|
|
678
|
+
cleanup(): Promise<number>;
|
|
679
|
+
private getKeyForDate;
|
|
680
|
+
private getKeysForDateRange;
|
|
681
|
+
private matchesFilter;
|
|
682
|
+
private serializeLog;
|
|
683
|
+
private deserializeLog;
|
|
684
|
+
}
|
|
685
|
+
declare function createAuditContext(req: Request): {
|
|
686
|
+
ipAddress: string;
|
|
687
|
+
userAgent: string;
|
|
688
|
+
};
|
|
689
|
+
|
|
690
|
+
interface AuthRoutesConfig {
|
|
691
|
+
redis: RedisAuthAdapter;
|
|
692
|
+
email?: EmailTransport;
|
|
693
|
+
jwtSecret: string;
|
|
694
|
+
jwtExpiresIn?: string;
|
|
695
|
+
jwtIssuer?: string;
|
|
696
|
+
jwtAudience?: string;
|
|
697
|
+
passwordPolicy?: PasswordPolicy;
|
|
698
|
+
lockout?: AccountLockout;
|
|
699
|
+
rateLimiter?: RateLimiter;
|
|
700
|
+
auditLogger?: AuditLogger;
|
|
701
|
+
baseUrl?: string;
|
|
702
|
+
emailVerificationRequired?: boolean;
|
|
703
|
+
}
|
|
704
|
+
declare class AuthRoutes {
|
|
705
|
+
private redis;
|
|
706
|
+
private email?;
|
|
707
|
+
private jwtSecret;
|
|
708
|
+
private jwtExpiresIn;
|
|
709
|
+
private jwtIssuer?;
|
|
710
|
+
private jwtAudience?;
|
|
711
|
+
private passwordPolicy;
|
|
712
|
+
private lockout?;
|
|
713
|
+
private rateLimiter?;
|
|
714
|
+
private auditLogger?;
|
|
715
|
+
private baseUrl;
|
|
716
|
+
private emailVerificationRequired;
|
|
717
|
+
constructor(config: AuthRoutesConfig);
|
|
718
|
+
register(req: Request): Promise<Response>;
|
|
719
|
+
login(req: Request): Promise<Response>;
|
|
720
|
+
logout(req: Request): Promise<Response>;
|
|
721
|
+
refresh(req: Request): Promise<Response>;
|
|
722
|
+
me(req: Request): Promise<Response>;
|
|
723
|
+
changePassword(req: Request): Promise<Response>;
|
|
724
|
+
forgotPassword(req: Request): Promise<Response>;
|
|
725
|
+
verifyEmail(req: Request): Promise<Response>;
|
|
726
|
+
private recordFailedLogin;
|
|
727
|
+
private sanitizeUser;
|
|
728
|
+
private jsonResponse;
|
|
729
|
+
private errorResponse;
|
|
730
|
+
private rateLimitResponse;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
interface KyroAuthConfig {
|
|
734
|
+
redis: RedisAuthAdapter;
|
|
735
|
+
redisClient: Redis;
|
|
736
|
+
email?: EmailTransport;
|
|
737
|
+
passwordPolicy: PasswordPolicy;
|
|
738
|
+
lockout?: AccountLockout;
|
|
739
|
+
rateLimiter?: RateLimiter;
|
|
740
|
+
auditLogger?: AuditLogger;
|
|
741
|
+
routes: AuthRoutes;
|
|
742
|
+
}
|
|
743
|
+
declare function createAuthConfig(): Promise<KyroAuthConfig>;
|
|
744
|
+
declare const authConfig: Promise<KyroAuthConfig>;
|
|
745
|
+
|
|
406
746
|
declare class Auth {
|
|
407
747
|
private adapter;
|
|
408
748
|
private config;
|
|
@@ -522,4 +862,20 @@ declare function isPublished(status: VersionStatus): boolean;
|
|
|
522
862
|
declare function isDraft(status: VersionStatus): boolean;
|
|
523
863
|
declare function isArchived(status: VersionStatus): boolean;
|
|
524
864
|
|
|
525
|
-
|
|
865
|
+
declare function defineConfig(config: {
|
|
866
|
+
collections?: CollectionConfig[] | Record<string, CollectionConfig>;
|
|
867
|
+
globals?: GlobalConfig[] | Record<string, GlobalConfig>;
|
|
868
|
+
adapter: KyroConfig["adapter"];
|
|
869
|
+
plugins?: KyroConfig["plugins"];
|
|
870
|
+
auth?: KyroConfig["auth"];
|
|
871
|
+
cors?: KyroConfig["cors"];
|
|
872
|
+
admin?: KyroConfig["admin"];
|
|
873
|
+
upload?: KyroConfig["upload"];
|
|
874
|
+
graphQL?: KyroConfig["graphQL"];
|
|
875
|
+
typescript?: KyroConfig["typescript"];
|
|
876
|
+
localization?: KyroConfig["localization"];
|
|
877
|
+
rateLimit?: KyroConfig["rateLimit"];
|
|
878
|
+
debug?: KyroConfig["debug"];
|
|
879
|
+
}): KyroConfig;
|
|
880
|
+
|
|
881
|
+
export { AbstractBaseAdapter, AccountLockout, type AdapterOptions, type AdminStylingConfig, AnalyticsPlugin, type AuditAction, type AuditLog, type AuditLogFilter, AuditLogger, Auth, AuthAdapter, AuthResult, Session as AuthSession, AuthTokenConfig, AuthUser, BaseAdapter, CSSGenerator, CollectionConfig, CommentsPlugin, type CompareVersionsOptions, ConfigValidationError, CreateArgs, type CreateVersionOptions, type DatabaseConnectionOptions, type DatabaseType, DeleteArgs, type DraftPublishConfig, type DrizzleAdapterOptions, EmailTransport, Field, type FieldStyling, FindArgs, FindByIDArgs, FindResult, GlobalConfig, Hook, JWTPayload, Kyro, type KyroAuthConfig, KyroConfig, KyroPlugin, KyroPubSub, KyroWSServer, LocalAdapter, LoginCredentials, type MongoDBAdapterOptions, PasswordPolicy, type PluginAPI, type PluginHooks, PluginManager, type PublishVersionOptions, RateLimiter, RedisAuthAdapter, RegisterData, Registry, Request$1 as Request, ReviewsPlugin, SEOPLugin, SQLiteAuthAdapter, type StylingConfig, type StylingMode, type ThemeBorderRadius, type ThemeColors, type ThemeConfig, type ThemeFonts, type ThemeShadows, type ThemeSpacing, UpdateArgs, User, UserRole, type Version, type VersionAdapter, type VersionDiff, type VersionHistoryOptions, VersionManager, type VersionPublishSchedule, type VersionStatus, WishlistPlugin, authConfig, autoBootstrap, bootstrapAdmin, collectionToCreateZod, collectionToUpdateZod, collectionToWhereZod, collectionToZod, createAdminStyling, createAuditContext, createAuth, createAuthConfig, createKyro, createLocalAdapter, createVersionManager, defaultDarkTheme, defaultFieldStyling, defaultLightTheme, defineConfig, ecommerce2026Theme, fieldToZod, generateCSSVariables, generateTailwindConfig, getBootstrapFromEnv, getDefaultDraftPublishConfig, globalToZod, isArchived, isDraft, isPublished, presetPlugins, validateCollection, validateConfig, validateFields, validateGlobal };
|