@katlux/providers 0.1.1-alpha.104 → 0.1.1-alpha.106

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
@@ -1,3 +1,151 @@
1
+ interface IEncryptedPayload {
2
+ __encrypted: true;
3
+ ciphertext: string;
4
+ alg: string;
5
+ iv?: string;
6
+ salt?: string;
7
+ kdf?: string;
8
+ iter?: number;
9
+ tag?: string;
10
+ wrappedKey?: string;
11
+ sharedKey?: boolean;
12
+ epk?: JsonWebKey;
13
+ /** Optional Key Identifier for role-based key routing and key rotation */
14
+ kid?: string;
15
+ /** True if AEAD additionalData was bound during encryption */
16
+ aad?: boolean;
17
+ }
18
+ type TRawKey = string | CryptoKey | Uint8Array | ArrayBuffer;
19
+ type TKeyProvider = TRawKey | (() => TRawKey | Promise<TRawKey>);
20
+ interface IEncryptionContext {
21
+ url?: string;
22
+ method?: string;
23
+ isServer?: boolean;
24
+ /** Whitelist of specific field names to encrypt/decrypt (e.g. ['name', 'surname']). Any unlisted field remains plaintext. */
25
+ fields?: string[];
26
+ key?: TKeyProvider | IKeyPair;
27
+ /** Optional Key Identifier for multi-role key routing and rotation */
28
+ kid?: string;
29
+ keyId?: string;
30
+ /** Authenticated Additional Data (AAD) bound to the ciphertext to prevent field/record swapping */
31
+ aad?: string | Uint8Array | ArrayBuffer;
32
+ /** Internal flag indicating that key derivation has already been warmed for this batch */
33
+ _warmedKey?: any;
34
+ /** Whether to encrypt/decrypt individual values while preserving JSON keys (default: true) */
35
+ valueEncryption?: boolean;
36
+ publicKey?: CryptoKey;
37
+ privateKey?: CryptoKey;
38
+ recipientPublicKey?: CryptoKey;
39
+ recipientPrivateKey?: CryptoKey;
40
+ curve?: 'P-256' | 'P-384' | 'P-521';
41
+ kdf?: 'none' | 'pbkdf2' | 'hkdf';
42
+ kdfSalt?: string | Uint8Array | ArrayBuffer;
43
+ kdfIterations?: number;
44
+ kdfHash?: 'SHA-256' | 'SHA-512';
45
+ info?: string | Uint8Array | ArrayBuffer;
46
+ }
47
+ interface IEncryptionProvider {
48
+ encrypt(data: any, options?: IEncryptionContext): Promise<IEncryptedPayload | any>;
49
+ decrypt(payload: IEncryptedPayload | any, options?: IEncryptionContext): Promise<any>;
50
+ warmupKey?(options?: IEncryptionContext): Promise<void>;
51
+ isEncrypted?(payload: any): boolean;
52
+ setDefaultKey?(key: TKeyProvider | IKeyPair): void;
53
+ clearKeys?(): void;
54
+ dispose?(): void;
55
+ [Symbol.dispose]?(): void;
56
+ [Symbol.asyncDispose]?(): Promise<void>;
57
+ }
58
+ interface IProviderEncryptionOptions {
59
+ /** Enable or disable encryption */
60
+ enabled?: boolean;
61
+ /** Secret key, passphrase, CryptoKey, key pair, or async key provider function */
62
+ key?: TKeyProvider | IKeyPair;
63
+ /** Optional Key Identifier for multi-role key routing and key rotation */
64
+ kid?: string;
65
+ keyId?: string;
66
+ /** Authenticated Additional Data (AAD) bound to the ciphertext to prevent field/record swapping */
67
+ aad?: string | Uint8Array | ArrayBuffer;
68
+ /**
69
+ * Whether decryption is permitted during Server-Side Rendering (SSR).
70
+ * In an End-to-End (E2E) zero-trust model, defaults to false to prevent
71
+ * plaintext data in server memory or SSR payloads.
72
+ */
73
+ decryptOnSSR?: boolean;
74
+ /** Whether to encrypt/decrypt individual values while preserving JSON object keys (default: true) */
75
+ valueEncryption?: boolean;
76
+ /** Whether to defer row/item decryption to active page rendering in DataProviders */
77
+ lazy?: boolean;
78
+ /** Whitelist of specific field names to encrypt/decrypt (e.g. ['name', 'surname']). Any unlisted field remains plaintext. */
79
+ fields?: string[];
80
+ /** Cryptographic algorithm identifier (defaults to 'AES-GCM') */
81
+ algorithm?: 'AES-GCM' | string;
82
+ /** Custom cipher adapter implementing IEncryptionProvider (e.g. CRSAEncryptionProvider, CECDHEncryptionProvider, CWebCryptoAESCBCProvider) */
83
+ customProvider?: IEncryptionProvider;
84
+ /** Whether to use synchronous Node.js crypto provider (CNodeCryptoEncryptionProvider) */
85
+ sync?: boolean;
86
+ /**
87
+ * Key Derivation Function strategy ('none' | 'pbkdf2' | 'hkdf'). Defaults to 'pbkdf2'.
88
+ * - 'pbkdf2': Recommended for human passphrases/passwords (OWASP recommended with work factor iterations).
89
+ * - 'hkdf': For deriving subkeys from high-entropy cryptographic keys or secrets (not for low-entropy human passwords).
90
+ * - 'none': Direct key import for raw high-entropy 256-bit symmetric keys or CryptoKeys.
91
+ */
92
+ kdf?: 'none' | 'pbkdf2' | 'hkdf';
93
+ /** Number of PBKDF2 iterations (default: 310,000 per OWASP recommendation) */
94
+ kdfIterations?: number;
95
+ /** Hash algorithm for PBKDF2 or HKDF ('SHA-256' | 'SHA-512', default: 'SHA-256') */
96
+ kdfHash?: 'SHA-256' | 'SHA-512';
97
+ /** Optional static salt for KDF. If omitted, a cryptographically secure random salt is generated and included in the envelope. */
98
+ kdfSalt?: string | Uint8Array | ArrayBuffer;
99
+ /** Optional public key for asymmetric providers */
100
+ publicKey?: CryptoKey;
101
+ /** Optional private key for asymmetric providers */
102
+ privateKey?: CryptoKey;
103
+ /** Optional recipient public key for asymmetric/hybrid encryption */
104
+ recipientPublicKey?: CryptoKey;
105
+ /** Optional recipient private key for asymmetric/hybrid decryption */
106
+ recipientPrivateKey?: CryptoKey;
107
+ /** Elliptic curve name for ECDH ('P-256' | 'P-384' | 'P-521') */
108
+ curve?: 'P-256' | 'P-384' | 'P-521';
109
+ /** Optional context/info string or buffer for HKDF key derivation */
110
+ info?: string | Uint8Array | ArrayBuffer;
111
+ }
112
+ /**
113
+ * Public and private key pair container for asymmetric / hybrid encryption providers (RSA, ECDH).
114
+ */
115
+ interface IKeyPair {
116
+ publicKey: CryptoKey;
117
+ privateKey: CryptoKey;
118
+ }
119
+ /**
120
+ * Represents a key wrapped by a key-encrypting key (KEK) using AES-KW or asymmetric wrapping.
121
+ */
122
+ interface IWrappedKey {
123
+ wrappedKey: string;
124
+ alg: string;
125
+ }
126
+ /**
127
+ * Options for Key Derivation Functions (PBKDF2 / HKDF) in CKeyManager and encryption providers.
128
+ */
129
+ interface IKDFOptions {
130
+ kdf: 'pbkdf2' | 'hkdf';
131
+ salt?: Uint8Array | ArrayBuffer | string;
132
+ iterations?: number;
133
+ hash?: 'SHA-256' | 'SHA-512';
134
+ info?: string | Uint8Array | ArrayBuffer;
135
+ keyLength?: 128 | 256;
136
+ extractable?: boolean;
137
+ }
138
+ /**
139
+ * Options for deriving a key from an existing CryptoKey secret via HKDF.
140
+ */
141
+ interface IHKDFFromSecretOptions {
142
+ salt?: Uint8Array | ArrayBuffer | string;
143
+ hash?: 'SHA-256' | 'SHA-512';
144
+ info?: string | Uint8Array | ArrayBuffer;
145
+ keyLength?: 128 | 256;
146
+ extractable?: boolean;
147
+ }
148
+
1
149
  /**
2
150
  * types.ts — Framework-agnostic hydration and platform abstraction contracts.
3
151
  */
@@ -58,6 +206,14 @@ interface ICacheEntry<T> {
58
206
  data: T;
59
207
  timestamp: number;
60
208
  lifetime: number;
209
+ lastAccessed?: number;
210
+ accessCount?: number;
211
+ }
212
+ interface ICacheQuotaOptions {
213
+ maxEntries?: number;
214
+ maxSizeBytes?: number;
215
+ quotaThresholdRatio?: number;
216
+ fallbackToMemory?: boolean;
61
217
  }
62
218
  interface IRequestOptions {
63
219
  method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
@@ -77,6 +233,9 @@ interface IRequestOptions {
77
233
  tags?: string[];
78
234
  signal?: AbortSignal;
79
235
  _generation?: number;
236
+ encryption?: IProviderEncryptionOptions;
237
+ /** If true, returns raw response without decrypting, useful for DataProvider lazy page-level decryption */
238
+ skipDecryption?: boolean;
80
239
  }
81
240
  /** Queue persistence backend with automatic fallback: IndexedDB → LocalStorage → Memory */
82
241
  declare enum EQueueStorage {
@@ -137,6 +296,7 @@ type TPageDataHandler<TRow = TDataRow> = (currentPage: number, pageSize: number,
137
296
  signal?: AbortSignal;
138
297
  }) => IDataResult<TRow> | Promise<IDataResult<TRow>>;
139
298
  interface IDataProviderOptions {
299
+ apiUrl?: string;
140
300
  idKey?: string;
141
301
  filter?: IDataFilter;
142
302
  sortList?: IDataSort[];
@@ -153,6 +313,7 @@ interface IDataProviderOptions {
153
313
  refreshOnMutation?: boolean;
154
314
  filterDebounce?: number;
155
315
  sortDebounce?: number;
316
+ encryption?: IProviderEncryptionOptions;
156
317
  }
157
318
  interface IDataProviderState<TRow = TDataRow> {
158
319
  currentPage: number;
@@ -222,6 +383,8 @@ interface ITreeDataProvider<TRow = TDataRow> {
222
383
  collapseAll?(): void;
223
384
  expandAll?(): void;
224
385
  isExpanded?(id: string | number): boolean;
386
+ allVisibleNodes?: ITreeNode<TRow>[];
387
+ allVisibleRows?: (TRow & ITreeNode<TRow>)[];
225
388
  }
226
389
  interface ITreeDataProviderOptions extends IDataProviderOptions {
227
390
  parentKey?: string;
@@ -241,6 +404,7 @@ type TTreePageDataHandler<TRow = TDataRow> = (currentPage: number, pageSize: num
241
404
  expandedByDefault: boolean;
242
405
  }, options?: {
243
406
  disableCache?: boolean;
407
+ signal?: AbortSignal;
244
408
  }) => IDataResult<TRow> | Promise<IDataResult<TRow>>;
245
409
  interface KProductItemData {
246
410
  id: string | number;
@@ -260,7 +424,9 @@ interface KProductRowAction {
260
424
 
261
425
  declare abstract class ADataProvider<TRow = TDataRow> {
262
426
  idKey: string;
263
- pageData: TRow[];
427
+ protected _pageData: TRow[];
428
+ get pageData(): TRow[];
429
+ set pageData(val: TRow[]);
264
430
  protected _rowCount: number;
265
431
  get rowCount(): number;
266
432
  set rowCount(val: number);
@@ -295,6 +461,9 @@ declare abstract class ADataProvider<TRow = TDataRow> {
295
461
  set filter(f: IDataFilter | null);
296
462
  get sortList(): IDataSort[];
297
463
  set sortList(s: IDataSort[]);
464
+ get hasMore(): boolean;
465
+ nextPage(): Promise<void>;
466
+ loadMore(): Promise<void>;
298
467
  private _listeners;
299
468
  private _stateListeners;
300
469
  private _pendingChangedKeys;
@@ -320,7 +489,7 @@ declare abstract class ADataProvider<TRow = TDataRow> {
320
489
  setFilter(filter: IDataFilter | null, immediate?: boolean): void;
321
490
  setSortList(sortList: IDataSort[], immediate?: boolean): void;
322
491
  setCurrentPage(currentPage: number): void;
323
- setPageSize(pageSize: number): void;
492
+ setPageSize(pageSize: number, resetPage?: boolean): void;
324
493
  setSelectedRows(rows: TRow[]): void;
325
494
  setSelectAll(val: boolean): void;
326
495
  abstract loadPageData(options?: {
@@ -388,26 +557,56 @@ declare class RequestProvider {
388
557
  setCacheProvider(provider?: ACacheProvider | ECacheStrategy): void;
389
558
  setCacheLifetime(lifetime: number): void;
390
559
  setDeduplicate(deduplicate: boolean): void;
560
+ setQueue(queue: boolean): void;
561
+ encryption?: IProviderEncryptionOptions;
562
+ private _cachedCipherProvider?;
563
+ private _lastEncryptionConfig?;
564
+ private _scopedCipherProviders;
565
+ /**
566
+ * Configures E2EE payload encryption for outbound mutations and inbound responses.
567
+ *
568
+ * Threat Model: Protects sensitive SaaS tenant data against backend/database breaches.
569
+ * Multi-user sharing is supported by role-based session keys passed dynamically.
570
+ * Local client endpoint compromise (malware, trojans, keyloggers) is out of scope.
571
+ */
572
+ private disposeCipherInstance;
573
+ setEncryption(encryption?: IProviderEncryptionOptions): void;
574
+ clearEncryption(): void;
391
575
  onDataReceived(callback: (data: any, generation?: number) => void): void;
392
576
  private invokeDataReceivedCallback;
393
577
  hasLastUrl(): boolean;
394
578
  refresh(hardRefresh?: boolean): Promise<any>;
395
579
  private resolveContext;
396
580
  private getInFlightMap;
397
- private getUniqueKey;
581
+ getUniqueKey(url: string, options?: IRequestOptions): string;
398
582
  registerRequest<T>(url: string, options?: IRequestOptions): Promise<T>;
399
583
  static executeAll(): void;
400
584
  private isSameOriginUrl;
585
+ private getCipherProvider;
586
+ private isDataEncrypted;
587
+ private buildEncryptionContext;
588
+ private decryptPayloadIfNeeded;
401
589
  request<T>(url: string, options?: IRequestOptions): Promise<T>;
402
590
  }
403
591
 
592
+ declare function getCipherProvider(encryption?: IProviderEncryptionOptions): IEncryptionProvider | undefined;
593
+ declare function clearCachedCipherProvider(encryption?: IProviderEncryptionOptions): void;
594
+ declare function isDataEncrypted(provider?: IEncryptionProvider, data?: any): boolean;
595
+ declare function buildEncryptionContext(encryption?: IProviderEncryptionOptions, url?: string, _defaultIdKey?: string): IEncryptionContext;
596
+ declare function decryptPageRows<T = any>(rows: T[], encryption?: IProviderEncryptionOptions, apiUrl?: string, idKey?: string): Promise<{
597
+ rows: T[];
598
+ decrypted: boolean;
599
+ }>;
404
600
  declare abstract class AAPIDataProvider {
405
601
  apiUrl: string;
406
602
  cacheStrategy: ECacheStrategy | null;
407
603
  cacheLifetime: number;
408
604
  requestProvider: RequestProvider;
409
605
  refreshOnMutation: boolean | undefined;
606
+ encryption?: IProviderEncryptionOptions;
410
607
  constructor(options?: IDataProviderOptions);
608
+ setEncryption(encryption?: IProviderEncryptionOptions): void;
609
+ clearEncryption(): void;
411
610
  abstract setAPIUrl(url: string): void;
412
611
  abstract create(item: any): Promise<void>;
413
612
  abstract update(item: any): Promise<void>;
@@ -421,7 +620,13 @@ declare class CAPIFlatClientDataProvider<TRow = TDataRow> extends CFlatClientDat
421
620
  cacheStrategy: ECacheStrategy | null;
422
621
  cacheLifetime: number;
423
622
  refreshOnMutation: boolean | undefined;
623
+ encryption?: IProviderEncryptionOptions;
624
+ private _isAccumulating;
625
+ private _inFlightLoadMore;
424
626
  constructor(options?: IDataProviderOptions);
627
+ loadMore(): Promise<void>;
628
+ setEncryption(encryption?: IProviderEncryptionOptions): void;
629
+ clearEncryption(): void;
425
630
  setContextKey(key: string): void;
426
631
  setCacheStrategy(strategy: ECacheStrategy): void;
427
632
  setCacheLifetime(lifetime: number): void;
@@ -432,6 +637,7 @@ declare class CAPIFlatClientDataProvider<TRow = TDataRow> extends CFlatClientDat
432
637
  create(item: any): Promise<void>;
433
638
  update(item: any): Promise<void>;
434
639
  delete(items: any[]): Promise<void>;
640
+ loadPageData(): Promise<void>;
435
641
  }
436
642
 
437
643
  declare class CFlatServerDataProvider<TRow = TDataRow> extends ADataProvider<TRow> {
@@ -447,6 +653,7 @@ declare class CFlatServerDataProvider<TRow = TDataRow> extends ADataProvider<TRo
447
653
  signal?: AbortSignal;
448
654
  }): Promise<void>;
449
655
  refresh(hardRefresh?: boolean): Promise<void>;
656
+ cancelPending(): void;
450
657
  }
451
658
 
452
659
  declare class CAPIFlatServerDataProvider<TRow = TDataRow> extends CFlatServerDataProvider<TRow> implements AAPIDataProvider {
@@ -455,9 +662,12 @@ declare class CAPIFlatServerDataProvider<TRow = TDataRow> extends CFlatServerDat
455
662
  cacheStrategy: ECacheStrategy | null;
456
663
  cacheLifetime: number;
457
664
  refreshOnMutation: boolean | undefined;
665
+ encryption?: IProviderEncryptionOptions;
458
666
  /** Incremented on every new request; stale onDataReceived callbacks are discarded. */
459
667
  private _requestGeneration;
460
668
  constructor(options?: IDataProviderOptions);
669
+ setEncryption(encryption?: IProviderEncryptionOptions): void;
670
+ clearEncryption(): void;
461
671
  refresh(hardRefresh?: boolean): Promise<void>;
462
672
  refreshData(options?: {
463
673
  disableCache?: boolean;
@@ -478,20 +688,31 @@ declare class CTreeClientDataProvider<TRow extends TDataRow = TDataRow> extends
478
688
  private _nodeMapCache;
479
689
  private _sortedNodeIdsCache;
480
690
  private _filteredNodesCache;
691
+ private _allVisibleRowsCache;
481
692
  invalidateStaticCache(): void;
482
693
  setFilter(filter: IDataFilter | null, immediate?: boolean): void;
694
+ protected onFilterUpdated(): void;
483
695
  private get _staticNodes();
484
696
  private get _nodeMap();
485
697
  private get _sortedNodeIds();
486
698
  constructor(options?: ITreeDataProviderOptions);
487
699
  setData(data: TRow[]): void;
488
700
  private buildStaticNodes;
701
+ protected onSortUpdated(): void;
702
+ setSortList(sortList: IDataSort[], immediate?: boolean): void;
489
703
  private computeSortedIds;
490
704
  private isNodeVisible;
491
705
  private paginateNodes;
492
706
  private updatePageData;
493
707
  loadPageData(): Promise<void>;
494
708
  get treeNodes(): ITreeNode<TRow>[];
709
+ get allVisibleNodes(): ITreeNode<TRow>[];
710
+ get rowMap(): readonly (TRow & ITreeNode<TRow> & {
711
+ __treeNode: ITreeNode<TRow>;
712
+ })[];
713
+ get allVisibleRows(): (TRow & ITreeNode<TRow> & {
714
+ __treeNode: ITreeNode<TRow>;
715
+ })[];
495
716
  get visibleRows(): ITreeNode<TRow>[];
496
717
  getAllNodes(): ITreeNode<TRow>[];
497
718
  getFlatNodes(): ITreeNode<TRow>[];
@@ -514,7 +735,10 @@ declare class CAPITreeClientDataProvider<TRow extends TDataRow = TDataRow> exten
514
735
  cacheStrategy: ECacheStrategy | null;
515
736
  cacheLifetime: number;
516
737
  refreshOnMutation: boolean | undefined;
738
+ encryption?: IProviderEncryptionOptions;
517
739
  constructor(options?: ITreeDataProviderOptions);
740
+ setEncryption(encryption?: IProviderEncryptionOptions): void;
741
+ clearEncryption(): void;
518
742
  setContextKey(key: string): void;
519
743
  refresh(hardRefresh?: boolean): Promise<void>;
520
744
  refreshData(options?: {
@@ -525,6 +749,7 @@ declare class CAPITreeClientDataProvider<TRow extends TDataRow = TDataRow> exten
525
749
  create(item: any): Promise<void>;
526
750
  update(item: any): Promise<void>;
527
751
  delete(items: any[]): Promise<void>;
752
+ loadPageData(): Promise<void>;
528
753
  }
529
754
 
530
755
  /**
@@ -558,6 +783,7 @@ declare class CTreeServerDataProvider<TRow = TDataRow> extends ADataProvider<TRo
558
783
  signal?: AbortSignal;
559
784
  }): Promise<void>;
560
785
  refresh(hardRefresh?: boolean): Promise<void>;
786
+ cancelPending(): void;
561
787
  toggleNode(nodeId: string | number): void;
562
788
  expand(nodeId: string | number): void;
563
789
  collapse(nodeId: string | number): void;
@@ -579,9 +805,12 @@ declare class CAPITreeServerDataProvider<TRow = TDataRow> extends CTreeServerDat
579
805
  cacheStrategy: ECacheStrategy | null;
580
806
  cacheLifetime: number;
581
807
  refreshOnMutation: boolean | undefined;
808
+ encryption?: IProviderEncryptionOptions;
582
809
  /** Incremented on every new request; stale onDataReceived callbacks are discarded. */
583
810
  private _requestGeneration;
584
811
  constructor(options?: ITreeDataProviderOptions);
812
+ setEncryption(encryption?: IProviderEncryptionOptions): void;
813
+ clearEncryption(): void;
585
814
  refresh(hardRefresh?: boolean): Promise<void>;
586
815
  refreshData(options?: {
587
816
  disableCache?: boolean;
@@ -668,11 +897,14 @@ declare class CServerSessionCache extends ACacheProvider {
668
897
  static get storage(): Map<string, Map<string, ICacheEntry<any>>>;
669
898
  static getSnapshot(): Map<string, Map<string, ICacheEntry<any>>>;
670
899
  static MAX_SERVER_SESSIONS: number;
900
+ static MAX_ENTRIES_PER_SESSION: number;
901
+ static CLEANUP_INTERVAL_OPS: number;
902
+ private static _opCounter;
671
903
  /**
672
- * Purges expired entries across all server sessions synchronously when the storage
673
- * exceeds MAX_SERVER_SESSIONS. Avoids persistent background setInterval timers on Node.js/SSR.
904
+ * Purges expired entries across server sessions.
905
+ * Can be run in bounded batches (maxSessionsToCheck) to prevent blocking the event loop.
674
906
  */
675
- static purgeExpiredServerSessions(): void;
907
+ static purgeExpiredServerSessions(maxSessionsToCheck?: number): void;
676
908
  private sessionIdCache;
677
909
  private readonly SESSION_ID_KEY;
678
910
  constructor();
@@ -737,10 +969,32 @@ declare class CCookieCache extends ACacheProvider {
737
969
 
738
970
  declare class CLocalStorageCache extends ACacheProvider {
739
971
  private static instance;
972
+ private static _writeCount;
740
973
  static getInstance(): CLocalStorageCache;
741
974
  type: string;
975
+ private quotaOptions;
976
+ configureQuota(options: Partial<ICacheQuotaOptions>): void;
977
+ getQuotaOptions(): Required<ICacheQuotaOptions>;
742
978
  private constructor();
743
979
  private _hydrateFromPayload;
980
+ /**
981
+ * Estimates current cache storage consumption in bytes and item counts without full JSON.parse overhead.
982
+ */
983
+ estimateStorageUsage(): {
984
+ totalBytes: number;
985
+ entryCount: number;
986
+ thresholdBytes: number;
987
+ isNearQuota: boolean;
988
+ };
989
+ /**
990
+ * Inspects all cache:* items in LocalStorage and returns metadata sorted for LRU analysis.
991
+ */
992
+ private _getCacheEntriesMetadata;
993
+ /**
994
+ * Evicts least recently used or oldest entries until storage usage drops by targetRatio.
995
+ * Returns number of evicted items.
996
+ */
997
+ evictLRU(targetRatio?: number): number;
744
998
  getKeyList(context?: any): Promise<Array<string>>;
745
999
  get<T>(key: string, context?: any): Promise<T | null>;
746
1000
  set<T>(key: string, data: T, lifetime: number, context?: any): Promise<void>;
@@ -754,10 +1008,26 @@ declare class CIndexedDBCache extends ACacheProvider {
754
1008
  private static instance;
755
1009
  private static instances;
756
1010
  readonly storeName: string;
1011
+ private quotaOptions;
1012
+ configureQuota(options: Partial<ICacheQuotaOptions>): void;
1013
+ getQuotaOptions(): Required<ICacheQuotaOptions>;
757
1014
  static getInstance(storeName?: string): CIndexedDBCache;
758
1015
  constructor(storeName?: string);
759
1016
  private _hydrateFromPayload;
760
1017
  private getStore;
1018
+ /**
1019
+ * Checks browser navigator.storage estimate to see if storage usage is near quota.
1020
+ */
1021
+ estimateStorageUsage(): Promise<{
1022
+ quota: number;
1023
+ usage: number;
1024
+ ratio: number;
1025
+ isNearQuota: boolean;
1026
+ }>;
1027
+ /**
1028
+ * Evicts least recently used entries from IndexedDB.
1029
+ */
1030
+ evictLRU(targetRatio?: number): Promise<number>;
761
1031
  getKeyList(context?: any): Promise<Array<string>>;
762
1032
  get<T>(key: string, context?: any): Promise<T | null>;
763
1033
  set<T>(key: string, data: T, lifetime: number, context?: any): Promise<void>;
@@ -926,6 +1196,8 @@ declare class RequestQueue {
926
1196
  private static _onDeadLetter;
927
1197
  private static _onFlushComplete;
928
1198
  private static _onNetworkError;
1199
+ private static _headerProvider;
1200
+ static setHeaderProvider(provider: (() => Record<string, string> | Promise<Record<string, string>>) | null): void;
929
1201
  /**
930
1202
  * Load persisted queue from storage into state.
931
1203
  * Call once at app startup, before any flush or enqueue operations.
@@ -1110,5 +1382,560 @@ declare function getAppRouter(): any;
1110
1382
  */
1111
1383
  declare function onPlatformReady(cb: () => void): void;
1112
1384
 
1113
- export { AAPIDataProvider, ADataProvider, CAPIFlatClientDataProvider, CAPIFlatServerDataProvider, CAPITreeClientDataProvider, CAPITreeServerDataProvider, CApplicationCache, CBrowserSessionCache, CCookieCache, CFlatClientDataProvider, CFlatServerDataProvider, CIndexedDBCache, CLocalStorageCache, CMemoryCache, CServerSessionCache, CTreeClientDataProvider, CTreeServerDataProvider, CacheProviderFactory, DefaultHydrationAdapter, ECacheStrategy, EDataFilterOperator, EQueueStorage, KatluxIndexedDB, QueueStorageFactory, RequestProvider, RequestProviderRegistry, RequestQueue, SENSITIVE_HEADER_KEYS, applyOperator, clearSSRData, compareAnd, compareEqual, compareIn, compareOr, compareValues, debounce, evaluateFilter, fetchWithSSR, filterData, filterTreeData, getAppRoute, getAppRouter, getHydrationAdapter, getPlatformApp, getSSRData, getSSRPayload, onPlatformReady, setHydrationAdapter, sortData, useDebounce, useFilterLogic, useSortLogic };
1114
- export type { CacheDriverLoader, ICacheEntry, IDataFilter, IDataProviderOptions, IDataProviderSetStateOptions, IDataProviderState, IDataResult, IDataSort, IDeadLetterItem, IDebouncedFunction, IFlushOptions, IKDatatableAction, IPlatformRouter, IQueueStorageAdapter, IQueuedOperation, IRequestOptions, ISSRHydrationAdapter, ITreeDataProvider, ITreeDataProviderOptions, ITreeNode, ITreeNodeStatic, IVirtualScrollState, KProductItemData, KProductRowAction, TDataProviderListener, TDataProviderStateChangeListener, TDataRow, TKatluxStore, TPageDataHandler, TQueueItemStatus, TTreePageDataHandler, TTreeRow, TUnsubscribe, TreePaginationMode };
1385
+ /**
1386
+ * Foundational abstract base class for all Katlux encryption provider implementations.
1387
+ * Provides key storage, lifecycle management, reusable value-level traversal,
1388
+ * and enforces the isomorphic IEncryptionProvider contract.
1389
+ */
1390
+ declare abstract class AEncryptionProvider implements IEncryptionProvider {
1391
+ protected defaultKey?: TKeyProvider | IKeyPair;
1392
+ constructor(key?: TKeyProvider | IKeyPair);
1393
+ /**
1394
+ * Sets or updates the default secret key, CryptoKey, or async key provider function.
1395
+ */
1396
+ setDefaultKey(key: TKeyProvider | IKeyPair): void;
1397
+ /**
1398
+ * Retrieves the currently configured default key or key provider callback.
1399
+ */
1400
+ getDefaultKey(): TKeyProvider | IKeyPair | undefined;
1401
+ /**
1402
+ * Pre-derives and caches the native CryptoKey for subsequent cryptographic operations.
1403
+ * Subclasses should override this with a dedicated, non-side-effecting implementation.
1404
+ */
1405
+ warmupKey(_options?: IEncryptionContext): Promise<void>;
1406
+ /**
1407
+ * Resolves raw key from keyProvider callback or defaultKey.
1408
+ */
1409
+ protected resolveRawKey(keyProvider?: TKeyProvider | IKeyPair | any): Promise<TRawKey>;
1410
+ /**
1411
+ * Checks whether the given payload is an encrypted envelope.
1412
+ */
1413
+ static isEncrypted(payload: any): boolean;
1414
+ /**
1415
+ * Checks whether the given payload is an encrypted envelope.
1416
+ */
1417
+ isEncrypted(payload: any): boolean;
1418
+ /**
1419
+ * Clears configured keys and cached cryptographic material from memory.
1420
+ */
1421
+ clearKeys(): void;
1422
+ /**
1423
+ * Alias for clearKeys() to conform with standard disposal patterns.
1424
+ */
1425
+ dispose(): void;
1426
+ /**
1427
+ * ECMAScript Explicit Resource Management protocol (using / await using declarations).
1428
+ */
1429
+ [Symbol.dispose](): void;
1430
+ [Symbol.asyncDispose](): Promise<void>;
1431
+ /**
1432
+ * Encrypts a single value (string, object, primitive) into an IEncryptedPayload envelope.
1433
+ * Implemented by concrete cryptographic providers.
1434
+ */
1435
+ abstract encryptValue(value: any, options?: IEncryptionContext): Promise<IEncryptedPayload>;
1436
+ /**
1437
+ * Decrypts a single IEncryptedPayload envelope back into its original plaintext.
1438
+ * Implemented by concrete cryptographic providers.
1439
+ */
1440
+ abstract decryptValue(payload: IEncryptedPayload, options?: IEncryptionContext): Promise<any>;
1441
+ /**
1442
+ * Top-level polymorphic encryption method.
1443
+ * Automatically performs value-level encryption:
1444
+ * - If data is an array of objects: recursively encrypts each row.
1445
+ * - If data is an object: encrypts specified fields (or all values if valueEncryption is true),
1446
+ * preserving JSON object keys so backend APIs and ORMs can parse keys and perform upserts.
1447
+ * - If data is a primitive or whole-payload envelope: encrypts as a single value.
1448
+ */
1449
+ encrypt(data: any, options?: IEncryptionContext): Promise<any>;
1450
+ /**
1451
+ * Top-level polymorphic decryption method.
1452
+ * Automatically performs value-level decryption:
1453
+ * - If payload is an encrypted envelope: decrypts directly via decryptValue.
1454
+ * - If payload is an array of objects: decrypts each row.
1455
+ * - If payload is an object: decrypts any encrypted value cells across fields.
1456
+ */
1457
+ decrypt(payload: any, options?: IEncryptionContext): Promise<any>;
1458
+ }
1459
+
1460
+ /**
1461
+ * Static cryptographic key lifecycle management utility.
1462
+ * Provides key generation, JWK import/export, key wrapping (AES-KW / RSA-OAEP),
1463
+ * and standard Key Derivation Functions (PBKDF2 / HKDF).
1464
+ */
1465
+ declare class CKeyManager {
1466
+ /**
1467
+ * Generates a cryptographically secure random byte buffer of the specified length.
1468
+ */
1469
+ static randomBytes(length: number): Uint8Array;
1470
+ /**
1471
+ * Converts an ArrayBuffer or Uint8Array into a Base64-encoded string.
1472
+ */
1473
+ static toBase64(buffer: ArrayBuffer | Uint8Array): string;
1474
+ /**
1475
+ * Converts a Base64 or Base64URL-encoded string back into a Uint8Array.
1476
+ * Normalizes URL-safe characters and padding, strictly validating against the Base64 alphabet.
1477
+ */
1478
+ static fromBase64(base64: string): Uint8Array;
1479
+ /**
1480
+ * Deterministically resolves a salt from Uint8Array, ArrayBuffer, Base64/Base64URL string, or raw text string.
1481
+ * Guarantees 100% identical salt byte resolution between Node.js and Browser environments.
1482
+ */
1483
+ static resolveSalt(salt?: Uint8Array | ArrayBuffer | string): Uint8Array;
1484
+ /**
1485
+ * Generates a random AES CryptoKey suitable for AES-GCM or AES-CBC.
1486
+ *
1487
+ * E2EE Threat Model Note: Focuses on protecting GDPR/tenant data against database and
1488
+ * server-side leaks. Keys remain extractable by default to enable role-based key sharing,
1489
+ * wrapping, and transfer between authorized client sessions in multi-user SaaS apps.
1490
+ * Client-side malware/trojan protection is out of scope.
1491
+ */
1492
+ static generateAESKey(length?: 128 | 256, algorithm?: 'AES-GCM' | 'AES-CBC' | 'AES-KW', extractable?: boolean): Promise<CryptoKey>;
1493
+ /**
1494
+ * Exports an AES CryptoKey as a raw base64 string.
1495
+ */
1496
+ static exportAESKey(key: CryptoKey): Promise<string>;
1497
+ /**
1498
+ * Imports an AES CryptoKey from a raw base64 string.
1499
+ */
1500
+ static importAESKey(base64: string, algorithm?: 'AES-GCM' | 'AES-CBC' | 'AES-KW', extractable?: boolean): Promise<CryptoKey>;
1501
+ /**
1502
+ * Generates an RSA-OAEP public/private key pair (2048 or 4096 bits).
1503
+ */
1504
+ static generateRSAKeyPair(bits?: 2048 | 4096, hash?: 'SHA-256' | 'SHA-512', extractable?: boolean): Promise<IKeyPair>;
1505
+ /**
1506
+ * Generates an ECDH public/private key pair for elliptic curve Diffie-Hellman.
1507
+ */
1508
+ static generateECDHKeyPair(curve?: 'P-256' | 'P-384' | 'P-521', extractable?: boolean): Promise<IKeyPair>;
1509
+ /**
1510
+ * Exports a public CryptoKey to a portable JsonWebKey (JWK).
1511
+ */
1512
+ static exportPublicKey(key: CryptoKey): Promise<JsonWebKey>;
1513
+ /**
1514
+ * Exports a private CryptoKey to a portable JsonWebKey (JWK).
1515
+ */
1516
+ static exportPrivateKey(key: CryptoKey): Promise<JsonWebKey>;
1517
+ /**
1518
+ * Imports a public key from a JsonWebKey (JWK).
1519
+ */
1520
+ static importPublicKey(jwk: JsonWebKey, algorithm?: string | RsaHashedImportParams | EcKeyImportParams): Promise<CryptoKey>;
1521
+ /**
1522
+ * Imports a private key from a JsonWebKey (JWK).
1523
+ */
1524
+ static importPrivateKey(jwk: JsonWebKey, algorithm?: string | RsaHashedImportParams | EcKeyImportParams): Promise<CryptoKey>;
1525
+ /**
1526
+ * Imports a public key from a PEM (SPKI) or base64 SPKI string.
1527
+ */
1528
+ static importPublicKeyFromPEM(pem: string, algorithm?: 'RSA-OAEP' | 'ECDH', curve?: 'P-256' | 'P-384' | 'P-521', hash?: 'SHA-256' | 'SHA-512'): Promise<CryptoKey>;
1529
+ /**
1530
+ * Imports a private key from a PEM (PKCS#8) or base64 PKCS#8 string.
1531
+ */
1532
+ static importPrivateKeyFromPEM(pem: string, algorithm?: 'RSA-OAEP' | 'ECDH', curve?: 'P-256' | 'P-384' | 'P-521', hash?: 'SHA-256' | 'SHA-512'): Promise<CryptoKey>;
1533
+ /**
1534
+ * Exports a public CryptoKey to a standard PEM (SPKI) string.
1535
+ */
1536
+ static exportPublicKeyToPEM(key: CryptoKey): Promise<string>;
1537
+ /**
1538
+ * Exports a private CryptoKey to a standard PEM (PKCS#8) string.
1539
+ */
1540
+ static exportPrivateKeyToPEM(key: CryptoKey): Promise<string>;
1541
+ /**
1542
+ * Wraps a target CryptoKey (e.g. an Account Symmetric Key) using a wrapping key
1543
+ * (AES-KW or RSA-OAEP).
1544
+ */
1545
+ static wrapKey(keyToWrap: CryptoKey, wrappingKey: CryptoKey, format?: KeyFormat): Promise<string>;
1546
+ /**
1547
+ * Unwraps a base64-encoded wrapped key using an unwrapping key (AES-KW or RSA-OAEP).
1548
+ */
1549
+ static unwrapKey(wrappedBase64: string, unwrappingKey: CryptoKey, unwrappedKeyAlgorithm?: any, extractable?: boolean, keyUsages?: KeyUsage[], format?: KeyFormat): Promise<CryptoKey>;
1550
+ /**
1551
+ * Generates a high-entropy symmetric AES-GCM Account Data Encryption Key (ADEK).
1552
+ * Designed for multi-user table and field-level encryption.
1553
+ */
1554
+ static generateAccountDataKey(length?: 128 | 192 | 256): Promise<CryptoKey>;
1555
+ /**
1556
+ * Wraps an Account Data Encryption Key (ADEK) for a specific user using the user's public key (RSA-OAEP).
1557
+ * Returns a Base64-encoded wrapped key string suitable for storage in role-map / access tables.
1558
+ */
1559
+ static wrapAccountKeyForUser(adek: CryptoKey, userPublicKey: CryptoKey): Promise<string>;
1560
+ /**
1561
+ * Unwraps a Base64-encoded Account Data Encryption Key (ADEK) using the user's private key (RSA-OAEP).
1562
+ * Returns the restored AES-GCM CryptoKey ready for use in CWebCryptoEncryptionProvider.
1563
+ */
1564
+ static unwrapAccountKeyForUser(wrappedKeyBase64: string, userPrivateKey: CryptoKey, unwrappedKeyAlgorithm?: any): Promise<CryptoKey>;
1565
+ /**
1566
+ * Derives a symmetric AES-GCM CryptoKey from a passphrase using PBKDF2 or HKDF.
1567
+ * Returns the derived CryptoKey and the base64-encoded salt.
1568
+ */
1569
+ static deriveKey(passphrase: string | Uint8Array | ArrayBuffer, options: IKDFOptions): Promise<{
1570
+ key: CryptoKey;
1571
+ salt: string;
1572
+ }>;
1573
+ /**
1574
+ * Derives an AES-GCM CryptoKey from a high-entropy secret (e.g. an ECDH shared secret key)
1575
+ * using HKDF.
1576
+ */
1577
+ static deriveKeyFromSecret(secretKey: CryptoKey, options?: IHKDFFromSecretOptions): Promise<CryptoKey>;
1578
+ }
1579
+
1580
+ interface ICWebCryptoOptions {
1581
+ kdf?: 'none' | 'pbkdf2' | 'hkdf';
1582
+ kdfIterations?: number;
1583
+ kdfHash?: 'SHA-256' | 'SHA-512';
1584
+ kdfSalt?: string | Uint8Array | ArrayBuffer;
1585
+ info?: string | Uint8Array | ArrayBuffer;
1586
+ kid?: string;
1587
+ keyId?: string;
1588
+ }
1589
+ /**
1590
+ * Zero-dependency AES-256-GCM cipher provider using native Web Crypto API (crypto.subtle).
1591
+ *
1592
+ * E2EE Threat Model Scope:
1593
+ * - Purpose: Provides client-side End-to-End Encryption (E2EE) to safeguard GDPR and tenant
1594
+ * records against database and server-side data breaches in multi-tenant SaaS systems.
1595
+ * - Multi-User Key Sharing: Authorized users in the same tenant encrypt/decrypt shared data
1596
+ * based on database roles that distribute symmetric or wrapped keys.
1597
+ * - Non-Goals: Client-side trojan, keylogger, or DOM-scraping malware defense is out of scope
1598
+ * and remains the responsibility of the client endpoint device owner.
1599
+ */
1600
+ declare class CWebCryptoEncryptionProvider extends AEncryptionProvider {
1601
+ private _defaultKdf;
1602
+ private _cachedKey?;
1603
+ private _kdfOptions?;
1604
+ private _cachedSalt?;
1605
+ private _cachedKdf?;
1606
+ private _cachedIter?;
1607
+ private _cachedHash?;
1608
+ private _cachedKeyId?;
1609
+ private _configuredKid?;
1610
+ private _decryptSaltCache;
1611
+ setDefaultKey(key: TKeyProvider): void;
1612
+ clearKeys(): void;
1613
+ constructor(key?: TKeyProvider | IKeyPair, options?: ICWebCryptoOptions);
1614
+ /**
1615
+ * Derives or returns a CryptoKey for encryption/decryption based on KDF settings.
1616
+ */
1617
+ private resolveCryptoKey;
1618
+ private _resolveCryptoKeyInternal;
1619
+ static isEncrypted(payload: any): boolean;
1620
+ isEncrypted(payload: any): boolean;
1621
+ warmupKey(options?: IEncryptionContext): Promise<void>;
1622
+ /**
1623
+ * Encrypts a single value into an AES-GCM envelope.
1624
+ */
1625
+ encryptValue(data: any, options?: IEncryptionContext): Promise<IEncryptedPayload>;
1626
+ /**
1627
+ * Decrypts a single AES-GCM envelope back into its plaintext.
1628
+ */
1629
+ decryptValue(payload: IEncryptedPayload, options?: IEncryptionContext): Promise<any>;
1630
+ }
1631
+
1632
+ interface ICWebCryptoAESCBCOptions {
1633
+ kdf?: 'none' | 'pbkdf2' | 'hkdf';
1634
+ kdfIterations?: number;
1635
+ kdfHash?: 'SHA-256' | 'SHA-512';
1636
+ kdfSalt?: string | Uint8Array | ArrayBuffer;
1637
+ info?: string | Uint8Array | ArrayBuffer;
1638
+ kid?: string;
1639
+ keyId?: string;
1640
+ }
1641
+ /**
1642
+ * Authenticated AES-CBC-256 provider with Encrypt-then-MAC (HMAC-SHA-256).
1643
+ *
1644
+ * AES-CBC provides confidentiality but no integrity protection by itself.
1645
+ * This provider implements Encrypt-then-MAC: an HMAC-SHA-256 tag is computed
1646
+ * over the (IV || ciphertext) and stored in the envelope's `tag` field.
1647
+ * Upon decryption, the HMAC is strictly verified before CBC decryption to mitigate
1648
+ * padding oracle and bit-flipping attacks.
1649
+ */
1650
+ declare class CWebCryptoAESCBCProvider extends AEncryptionProvider {
1651
+ private _defaultKdf;
1652
+ private _cachedEncKey?;
1653
+ private _cachedMacKey?;
1654
+ private _cachedSalt?;
1655
+ private _cachedKdf?;
1656
+ private _cachedIter?;
1657
+ private _cachedHash?;
1658
+ private _configuredKid?;
1659
+ private _kdfOptions?;
1660
+ private _decryptSaltCache;
1661
+ constructor(key?: TKeyProvider | IKeyPair, options?: ICWebCryptoAESCBCOptions);
1662
+ setDefaultKey(key: TKeyProvider | IKeyPair): void;
1663
+ clearKeys(): void;
1664
+ warmupKey(options?: IEncryptionContext): Promise<void>;
1665
+ /**
1666
+ * Derives 64 bytes (512 bits) of key material:
1667
+ * - Bytes 0..31 (256 bits) for AES-CBC encryption key
1668
+ * - Bytes 32..63 (256 bits) for HMAC-SHA-256 authentication key
1669
+ */
1670
+ private resolveCBCKeys;
1671
+ private _deriveCBCKeysInternal;
1672
+ static isEncrypted(payload: any): boolean;
1673
+ isEncrypted(payload: any): boolean;
1674
+ /**
1675
+ * Encrypts a single value into an authenticated AES-CBC-256+HMAC-SHA-256 envelope.
1676
+ */
1677
+ encryptValue(data: any, options?: IEncryptionContext): Promise<IEncryptedPayload>;
1678
+ /**
1679
+ * Decrypts a single AES-CBC-256+HMAC-SHA-256 envelope back into its plaintext.
1680
+ */
1681
+ decryptValue(payload: IEncryptedPayload, options?: IEncryptionContext): Promise<any>;
1682
+ }
1683
+
1684
+ /**
1685
+ * Asymmetric / Hybrid encryption provider combining RSA-OAEP (2048/4096-bit) with AES-GCM-256.
1686
+ *
1687
+ * Direct RSA encryption is bounded by key size (RSA-4096 max ~446 bytes).
1688
+ * This provider implements the industry-standard Hybrid Encryption scheme:
1689
+ * 1. A random 256-bit AES-GCM data key is generated per encryption.
1690
+ * 2. Payload is encrypted with the AES-GCM data key (unlimited payload size, authenticated).
1691
+ * 3. The AES-GCM data key is wrapped with the recipient's RSA-OAEP public key.
1692
+ * 4. The envelope packages ciphertext, IV, and wrappedKey.
1693
+ * 5. Only the holder of the matching RSA private key can unwrap the data key and decrypt.
1694
+ *
1695
+ * Security Advisory (Sender Authenticity): Asymmetric hybrid encryption guarantees confidentiality
1696
+ * for the recipient, but does NOT authenticate the identity of the sender. Any party in possession
1697
+ * of the recipient's public key can encrypt data. In multi-user / multi-tenant workflows where sender
1698
+ * authenticity is required, sign payloads with a digital signature (e.g. ECDSA/RSA-PSS) or use
1699
+ * authenticated symmetric role keys (AES-GCM) governed by database role permissions.
1700
+ */
1701
+ declare class CRSAEncryptionProvider extends AEncryptionProvider {
1702
+ private publicKey?;
1703
+ private privateKey?;
1704
+ setDefaultKey(key: TKeyProvider | IKeyPair | Record<string, any>): void;
1705
+ constructor(publicKeyOrPair?: CryptoKey | IKeyPair | {
1706
+ publicKey?: CryptoKey;
1707
+ privateKey?: CryptoKey;
1708
+ recipientPublicKey?: CryptoKey;
1709
+ recipientPrivateKey?: CryptoKey;
1710
+ }, privateKey?: CryptoKey);
1711
+ setPublicKey(key: CryptoKey): void;
1712
+ getPublicKey(): CryptoKey | undefined;
1713
+ setPrivateKey(key: CryptoKey): void;
1714
+ getPrivateKey(): CryptoKey | undefined;
1715
+ clearKeys(): void;
1716
+ static generateKeyPair(bits?: 2048 | 4096): Promise<IKeyPair>;
1717
+ static exportPublicKey(key: CryptoKey): Promise<JsonWebKey>;
1718
+ static exportPrivateKey(key: CryptoKey): Promise<JsonWebKey>;
1719
+ static importPublicKey(jwk: JsonWebKey): Promise<CryptoKey>;
1720
+ static importPrivateKey(jwk: JsonWebKey): Promise<CryptoKey>;
1721
+ static importPublicKeyFromPEM(pem: string, hash?: 'SHA-256' | 'SHA-512'): Promise<CryptoKey>;
1722
+ static importPrivateKeyFromPEM(pem: string, hash?: 'SHA-256' | 'SHA-512'): Promise<CryptoKey>;
1723
+ static exportPublicKeyToPEM(key: CryptoKey): Promise<string>;
1724
+ static exportPrivateKeyToPEM(key: CryptoKey): Promise<string>;
1725
+ static isEncrypted(payload: any): boolean;
1726
+ isEncrypted(payload: any): boolean;
1727
+ /**
1728
+ * Encrypts a single value into a hybrid RSA-OAEP + AES-GCM envelope.
1729
+ */
1730
+ encryptValue(data: any, options?: IEncryptionContext): Promise<IEncryptedPayload>;
1731
+ /**
1732
+ * Decrypts a single hybrid RSA-OAEP + AES-GCM envelope back into its plaintext.
1733
+ */
1734
+ decryptValue(payload: IEncryptedPayload, options?: IEncryptionContext): Promise<any>;
1735
+ encrypt(data: any, options?: IEncryptionContext): Promise<any>;
1736
+ decrypt(payload: any, options?: IEncryptionContext): Promise<any>;
1737
+ }
1738
+
1739
+ type TECDHCurve = 'P-256' | 'P-384' | 'P-521';
1740
+ /**
1741
+ * Modern Asymmetric / Hybrid encryption provider using ECDH (Elliptic Curve Diffie-Hellman)
1742
+ * with HKDF key derivation and AES-GCM-256 authenticated encryption.
1743
+ *
1744
+ * Implements forward-secure hybrid encryption:
1745
+ * 1. An ephemeral ECDH keypair is generated per encryption operation.
1746
+ * 2. Key agreement with recipient's ECDH public key produces a high-entropy shared secret.
1747
+ * 3. HKDF derives a 256-bit AES-GCM data key from the shared secret.
1748
+ * 4. Payload is encrypted with AES-GCM.
1749
+ * 5. Ephemeral public key (JWK) is attached to the envelope (`epk`).
1750
+ * 6. Only the recipient with the matching private key can agree with `epk` and decrypt.
1751
+ *
1752
+ * Security Advisory (Sender Authenticity): ECDH ephemeral-static hybrid encryption guarantees confidentiality
1753
+ * for the recipient, but does NOT authenticate the identity of the sender. Any party with the recipient's
1754
+ * public key can generate an ephemeral keypair and send encrypted envelopes. In multi-user / multi-tenant
1755
+ * SaaS environments requiring sender authenticity, sign payloads with a digital signature (ECDSA/Ed25519)
1756
+ * or use authenticated symmetric role keys (AES-GCM) managed via database role permissions.
1757
+ */
1758
+ declare class CECDHEncryptionProvider extends AEncryptionProvider {
1759
+ private recipientPublicKey?;
1760
+ private recipientPrivateKey?;
1761
+ private curve;
1762
+ setDefaultKey(key: TKeyProvider | IKeyPair | Record<string, any>): void;
1763
+ constructor(recipientPublicKeyOrPair?: CryptoKey | IKeyPair | {
1764
+ recipientPublicKey?: CryptoKey;
1765
+ publicKey?: CryptoKey;
1766
+ recipientPrivateKey?: CryptoKey;
1767
+ privateKey?: CryptoKey;
1768
+ curve?: TECDHCurve;
1769
+ }, recipientPrivateKey?: CryptoKey, curve?: TECDHCurve);
1770
+ setRecipientPublicKey(key: CryptoKey): void;
1771
+ getRecipientPublicKey(): CryptoKey | undefined;
1772
+ setRecipientPrivateKey(key: CryptoKey): void;
1773
+ getRecipientPrivateKey(): CryptoKey | undefined;
1774
+ getCurve(): TECDHCurve;
1775
+ clearKeys(): void;
1776
+ static generateKeyPair(curve?: TECDHCurve): Promise<IKeyPair>;
1777
+ static exportPublicKey(key: CryptoKey): Promise<JsonWebKey>;
1778
+ static exportPrivateKey(key: CryptoKey): Promise<JsonWebKey>;
1779
+ static importPublicKey(jwk: JsonWebKey, curve?: TECDHCurve): Promise<CryptoKey>;
1780
+ static importPrivateKey(jwk: JsonWebKey, curve?: TECDHCurve): Promise<CryptoKey>;
1781
+ static importPublicKeyFromPEM(pem: string, curve?: TECDHCurve): Promise<CryptoKey>;
1782
+ static importPrivateKeyFromPEM(pem: string, curve?: TECDHCurve): Promise<CryptoKey>;
1783
+ static exportPublicKeyToPEM(key: CryptoKey): Promise<string>;
1784
+ static exportPrivateKeyToPEM(key: CryptoKey): Promise<string>;
1785
+ static isEncrypted(payload: any): boolean;
1786
+ isEncrypted(payload: any): boolean;
1787
+ /**
1788
+ * Encrypts a single value into an ECDH+HKDF+AES-GCM envelope.
1789
+ */
1790
+ encryptValue(data: any, options?: IEncryptionContext): Promise<IEncryptedPayload>;
1791
+ /**
1792
+ * Encrypts multiple designated fields of a record using a single ephemeral ECDH keypair and shared DEK.
1793
+ */
1794
+ private encryptFieldsWithSharedDEK;
1795
+ /**
1796
+ * Derives the AES-GCM data key for a given ECDH envelope.
1797
+ */
1798
+ private deriveDecryptionKey;
1799
+ /**
1800
+ * Decrypts ciphertext buffer using a derived data key.
1801
+ */
1802
+ private decryptCiphertextWithKey;
1803
+ /**
1804
+ * Decrypts a single ECDH+HKDF+AES-GCM envelope back into its plaintext.
1805
+ */
1806
+ decryptValue(payload: IEncryptedPayload, options?: IEncryptionContext): Promise<any>;
1807
+ encrypt(data: any, options?: IEncryptionContext): Promise<any>;
1808
+ decrypt(payload: any, options?: IEncryptionContext): Promise<any>;
1809
+ }
1810
+
1811
+ interface ICNodeCryptoOptions {
1812
+ kdf?: 'none' | 'pbkdf2' | 'hkdf';
1813
+ kdfIterations?: number;
1814
+ kdfHash?: 'SHA-256' | 'SHA-512';
1815
+ kdfSalt?: string | Uint8Array | ArrayBuffer;
1816
+ info?: string | Uint8Array | ArrayBuffer;
1817
+ kid?: string;
1818
+ keyId?: string;
1819
+ }
1820
+ /**
1821
+ * Server-side synchronous AES-GCM-256 encryption provider using Node.js native `node:crypto`.
1822
+ *
1823
+ * Fully interoperable with `CWebCryptoEncryptionProvider`:
1824
+ * - Data encrypted by `CNodeCryptoEncryptionProvider` can be decrypted by `CWebCryptoEncryptionProvider`.
1825
+ * - Data encrypted by `CWebCryptoEncryptionProvider` can be decrypted by `CNodeCryptoEncryptionProvider`.
1826
+ *
1827
+ * Provides both synchronous (`encryptSync`, `decryptSync`) and standard Promise-based
1828
+ * (`encrypt`, `decrypt`) methods for Nitro routes, worker threads, and CLI tools.
1829
+ */
1830
+ declare class CNodeCryptoEncryptionProvider extends AEncryptionProvider {
1831
+ private _defaultKdf;
1832
+ private _kdfOptions?;
1833
+ private _cachedKey?;
1834
+ private _cachedSalt?;
1835
+ private _cachedKdf?;
1836
+ private _cachedIter?;
1837
+ private _cachedHash?;
1838
+ private _configuredKid?;
1839
+ setDefaultKey(key: TKeyProvider): void;
1840
+ clearKeys(): void;
1841
+ warmupKey(options?: IEncryptionContext): Promise<void>;
1842
+ /**
1843
+ * Synchronously pre-derives and caches the encryption key for subsequent synchronous operations.
1844
+ */
1845
+ warmupKeySync(options?: IEncryptionContext): void;
1846
+ private resolveInfoBuffer;
1847
+ constructor(key?: TKeyProvider | IKeyPair, options?: ICNodeCryptoOptions);
1848
+ private resolveRawKeySync;
1849
+ private resolveRawKeyAsync;
1850
+ private deriveKeySync;
1851
+ private deriveKeyAsync;
1852
+ static isEncrypted(payload: any): boolean;
1853
+ isEncrypted(payload: any): boolean;
1854
+ /**
1855
+ * Synchronously encrypts a single value into an AES-GCM envelope using Node.js crypto.
1856
+ */
1857
+ encryptValueSync(data: any, options?: IEncryptionContext): IEncryptedPayload;
1858
+ private decryptCiphertextWithKey;
1859
+ /**
1860
+ * Synchronously decrypts a single AES-GCM envelope back into its plaintext.
1861
+ */
1862
+ decryptValueSync(payload: IEncryptedPayload, options?: IEncryptionContext): any;
1863
+ encryptSync(data: any, options?: IEncryptionContext): any;
1864
+ decryptSync(payload: any, options?: IEncryptionContext): any;
1865
+ encryptFieldsSync(data: any, fields: string[]): any;
1866
+ decryptFieldsSync(data: any, fields: string[]): any;
1867
+ encryptFields(data: any, fields: string[]): Promise<any>;
1868
+ decryptFields(data: any, fields: string[]): Promise<any>;
1869
+ encryptValue(data: any, options?: IEncryptionContext): Promise<IEncryptedPayload>;
1870
+ decryptValue(payload: IEncryptedPayload, options?: IEncryptionContext): Promise<any>;
1871
+ decrypt(payload: any, options?: IEncryptionContext): Promise<any>;
1872
+ }
1873
+
1874
+ /**
1875
+ * Universal factory function that creates and returns the appropriate IEncryptionProvider
1876
+ * instance according to the configured algorithm and cryptographic options.
1877
+ *
1878
+ * Algorithm dispatch:
1879
+ * - 'AES-GCM' (default): CWebCryptoEncryptionProvider
1880
+ * - 'AES-CBC' | 'AES-CBC-256+HMAC-SHA-256': CWebCryptoAESCBCProvider
1881
+ * - 'RSA-OAEP' | 'RSA-*': CRSAEncryptionProvider
1882
+ * - 'ECDH' | 'ECDH-*': CECDHEncryptionProvider
1883
+ * - 'NODE-CRYPTO' | sync: true: CNodeCryptoEncryptionProvider
1884
+ */
1885
+ declare function createEncryptionProvider(options?: IProviderEncryptionOptions): IEncryptionProvider;
1886
+
1887
+ /**
1888
+ * Shared cryptographic utilities for Web Crypto API access and random byte generation.
1889
+ * Internal module for Katlux Encryption Providers.
1890
+ */
1891
+ /**
1892
+ * Resolves the SubtleCrypto instance from globalThis.
1893
+ * Throws a descriptive error if Web Crypto API is unavailable.
1894
+ */
1895
+ declare function getSubtleCrypto(): SubtleCrypto;
1896
+ /**
1897
+ * Fills a typed array with cryptographically secure random values using crypto.getRandomValues.
1898
+ */
1899
+ declare function getRandomValues(array: Uint8Array): Uint8Array;
1900
+ declare const textEncoder: TextEncoder;
1901
+ declare const textDecoder: TextDecoder;
1902
+ /**
1903
+ * Resolves an HKDF info / context parameter into a Uint8Array.
1904
+ * Safely preserves raw binary buffers (Uint8Array, ArrayBuffer) without string coercion.
1905
+ */
1906
+ declare function resolveInfoBytes(info?: string | Uint8Array | ArrayBuffer, fallback?: string): Uint8Array;
1907
+ /**
1908
+ * Safely assigns a property to a target object, preventing prototype pollution attacks
1909
+ * via __proto__, constructor, or prototype manipulation.
1910
+ */
1911
+ declare function safeSetProperty(target: Record<string, any>, key: string, value: any): void;
1912
+ /**
1913
+ * Converts an ArrayBuffer or Uint8Array into a Base64-encoded string.
1914
+ */
1915
+ declare function toBase64(buffer: ArrayBuffer | Uint8Array): string;
1916
+ /**
1917
+ * Fast 64-bit FNV-1a hash formatted as a hex string.
1918
+ * Non-cryptographic, zero-allocation, synchronous hash used for safe heap cache indexing
1919
+ * without retaining plaintext secrets in compound Map keys.
1920
+ */
1921
+ declare function fastKeyHash(str: string): string;
1922
+ /**
1923
+ * Computes a collision-free, safe string identifier for a resolved key.
1924
+ * Hashes raw string passphrases to ensure secrets never reside in compound Map keys (Minor 8)
1925
+ * and resolves function outputs so multi-tenant SSR requests never collide on function references (Major 3).
1926
+ */
1927
+ declare function getSafeKeyIdentifier(rawKey: any): string;
1928
+ /**
1929
+ * Returns a collision-free string identifier for a key provider or fallback key.
1930
+ * Uses a hashed identifier for strings and WeakMap for objects to prevent
1931
+ * cross-tenant cache collisions and avoid storing secrets in heap Map keys.
1932
+ */
1933
+ declare function getKeyIdentifier(keyProvider?: any, defaultKey?: any): string;
1934
+
1935
+ /**
1936
+ * Universal helper that verifies whether an arbitrary object is a Katlux encrypted payload envelope.
1937
+ */
1938
+ declare function isEncrypted(payload: any): boolean;
1939
+
1940
+ export { AAPIDataProvider, ADataProvider, AEncryptionProvider, CAPIFlatClientDataProvider, CAPIFlatServerDataProvider, CAPITreeClientDataProvider, CAPITreeServerDataProvider, CApplicationCache, CBrowserSessionCache, CCookieCache, CECDHEncryptionProvider, CFlatClientDataProvider, CFlatServerDataProvider, CIndexedDBCache, CKeyManager, CLocalStorageCache, CMemoryCache, CNodeCryptoEncryptionProvider, CRSAEncryptionProvider, CServerSessionCache, CTreeClientDataProvider, CTreeServerDataProvider, CWebCryptoAESCBCProvider, CWebCryptoEncryptionProvider, CacheProviderFactory, DefaultHydrationAdapter, ECacheStrategy, EDataFilterOperator, EQueueStorage, KatluxIndexedDB, QueueStorageFactory, RequestProvider, RequestProviderRegistry, RequestQueue, SENSITIVE_HEADER_KEYS, applyOperator, buildEncryptionContext, clearCachedCipherProvider, clearSSRData, compareAnd, compareEqual, compareIn, compareOr, compareValues, createEncryptionProvider, debounce, decryptPageRows, evaluateFilter, fastKeyHash, fetchWithSSR, filterData, filterTreeData, getAppRoute, getAppRouter, getCipherProvider, getHydrationAdapter, getKeyIdentifier, getPlatformApp, getRandomValues, getSSRData, getSSRPayload, getSafeKeyIdentifier, getSubtleCrypto, isDataEncrypted, isEncrypted, onPlatformReady, resolveInfoBytes, safeSetProperty, setHydrationAdapter, sortData, textDecoder, textEncoder, toBase64, useDebounce, useFilterLogic, useSortLogic };
1941
+ export type { CacheDriverLoader, ICNodeCryptoOptions, ICWebCryptoAESCBCOptions, ICWebCryptoOptions, ICacheEntry, ICacheQuotaOptions, IDataFilter, IDataProviderOptions, IDataProviderSetStateOptions, IDataProviderState, IDataResult, IDataSort, IDeadLetterItem, IDebouncedFunction, IEncryptedPayload, IEncryptionContext, IEncryptionProvider, IFlushOptions, IHKDFFromSecretOptions, IKDFOptions, IKDatatableAction, IKeyPair, IPlatformRouter, IProviderEncryptionOptions, IQueueStorageAdapter, IQueuedOperation, IRequestOptions, ISSRHydrationAdapter, ITreeDataProvider, ITreeDataProviderOptions, ITreeNode, ITreeNodeStatic, IVirtualScrollState, IWrappedKey, KProductItemData, KProductRowAction, TDataProviderListener, TDataProviderStateChangeListener, TDataRow, TECDHCurve, TKatluxStore, TKeyProvider, TPageDataHandler, TQueueItemStatus, TRawKey, TTreePageDataHandler, TTreeRow, TUnsubscribe, TreePaginationMode };