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

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,130 @@
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
+ }
14
+ type TRawKey = string | CryptoKey | Uint8Array | ArrayBuffer;
15
+ type TKeyProvider = TRawKey | (() => TRawKey | Promise<TRawKey>);
16
+ interface IEncryptionContext {
17
+ url?: string;
18
+ method?: string;
19
+ isServer?: boolean;
20
+ /** Whitelist of specific field names to encrypt/decrypt (e.g. ['name', 'surname']). Any unlisted field remains plaintext. */
21
+ fields?: string[];
22
+ key?: TKeyProvider | IKeyPair;
23
+ /** Whether to encrypt/decrypt individual values while preserving JSON keys (default: true) */
24
+ valueEncryption?: boolean;
25
+ publicKey?: CryptoKey;
26
+ privateKey?: CryptoKey;
27
+ recipientPublicKey?: CryptoKey;
28
+ recipientPrivateKey?: CryptoKey;
29
+ curve?: 'P-256' | 'P-384' | 'P-521';
30
+ kdf?: 'none' | 'pbkdf2' | 'hkdf';
31
+ kdfSalt?: string | Uint8Array | ArrayBuffer;
32
+ kdfIterations?: number;
33
+ kdfHash?: 'SHA-256' | 'SHA-512';
34
+ info?: string | Uint8Array | ArrayBuffer;
35
+ }
36
+ interface IEncryptionProvider {
37
+ encrypt(data: any, options?: IEncryptionContext): Promise<IEncryptedPayload | any>;
38
+ decrypt(payload: IEncryptedPayload | any, options?: IEncryptionContext): Promise<any>;
39
+ warmupKey?(options?: IEncryptionContext): Promise<void>;
40
+ isEncrypted?(payload: any): boolean;
41
+ setDefaultKey?(key: TKeyProvider | IKeyPair): void;
42
+ clearKeys?(): void;
43
+ dispose?(): void;
44
+ [Symbol.dispose]?(): void;
45
+ [Symbol.asyncDispose]?(): Promise<void>;
46
+ }
47
+ interface IProviderEncryptionOptions {
48
+ /** Enable or disable encryption */
49
+ enabled?: boolean;
50
+ /** Secret key, passphrase, CryptoKey, key pair, or async key provider function */
51
+ key?: TKeyProvider | IKeyPair;
52
+ /**
53
+ * Whether decryption is permitted during Server-Side Rendering (SSR).
54
+ * In an End-to-End (E2E) zero-trust model, defaults to false to prevent
55
+ * plaintext data in server memory or SSR payloads.
56
+ */
57
+ decryptOnSSR?: boolean;
58
+ /** Whether to encrypt/decrypt individual values while preserving JSON object keys (default: true) */
59
+ valueEncryption?: boolean;
60
+ /** Whether to defer row/item decryption to active page rendering in DataProviders */
61
+ lazy?: boolean;
62
+ /** Whitelist of specific field names to encrypt/decrypt (e.g. ['name', 'surname']). Any unlisted field remains plaintext. */
63
+ fields?: string[];
64
+ /** Cryptographic algorithm identifier (defaults to 'AES-GCM') */
65
+ algorithm?: 'AES-GCM' | string;
66
+ /** Whether to use synchronous Node.js crypto provider (CNodeCryptoEncryptionProvider) */
67
+ sync?: boolean;
68
+ /** Custom encryption provider instance implementing IEncryptionProvider */
69
+ customProvider?: IEncryptionProvider;
70
+ /** Key Derivation Function strategy ('none' | 'pbkdf2' | 'hkdf'). Defaults to 'pbkdf2'. */
71
+ kdf?: 'none' | 'pbkdf2' | 'hkdf';
72
+ /** Number of PBKDF2 iterations (default: 310,000 per OWASP recommendation) */
73
+ kdfIterations?: number;
74
+ /** Hash algorithm for PBKDF2 or HKDF ('SHA-256' | 'SHA-512', default: 'SHA-256') */
75
+ kdfHash?: 'SHA-256' | 'SHA-512';
76
+ /** Optional static salt for KDF. If omitted, a cryptographically secure random salt is generated and included in the envelope. */
77
+ kdfSalt?: string | Uint8Array | ArrayBuffer;
78
+ /** Optional public key for asymmetric providers */
79
+ publicKey?: CryptoKey;
80
+ /** Optional private key for asymmetric providers */
81
+ privateKey?: CryptoKey;
82
+ /** Optional recipient public key for asymmetric/hybrid encryption */
83
+ recipientPublicKey?: CryptoKey;
84
+ /** Optional recipient private key for asymmetric/hybrid decryption */
85
+ recipientPrivateKey?: CryptoKey;
86
+ /** Elliptic curve name for ECDH ('P-256' | 'P-384' | 'P-521') */
87
+ curve?: 'P-256' | 'P-384' | 'P-521';
88
+ /** Optional context/info string or buffer for HKDF key derivation */
89
+ info?: string | Uint8Array | ArrayBuffer;
90
+ }
91
+ /**
92
+ * Public and private key pair container for asymmetric / hybrid encryption providers (RSA, ECDH).
93
+ */
94
+ interface IKeyPair {
95
+ publicKey: CryptoKey;
96
+ privateKey: CryptoKey;
97
+ }
98
+ /**
99
+ * Represents a key wrapped by a key-encrypting key (KEK) using AES-KW or asymmetric wrapping.
100
+ */
101
+ interface IWrappedKey {
102
+ wrappedKey: string;
103
+ alg: string;
104
+ }
105
+ /**
106
+ * Options for Key Derivation Functions (PBKDF2 / HKDF) in CKeyManager and encryption providers.
107
+ */
108
+ interface IKDFOptions {
109
+ kdf: 'pbkdf2' | 'hkdf';
110
+ salt?: Uint8Array | ArrayBuffer | string;
111
+ iterations?: number;
112
+ hash?: 'SHA-256' | 'SHA-512';
113
+ info?: string | Uint8Array | ArrayBuffer;
114
+ keyLength?: 128 | 256;
115
+ extractable?: boolean;
116
+ }
117
+ /**
118
+ * Options for deriving a key from an existing CryptoKey secret via HKDF.
119
+ */
120
+ interface IHKDFFromSecretOptions {
121
+ salt?: Uint8Array | ArrayBuffer | string;
122
+ hash?: 'SHA-256' | 'SHA-512';
123
+ info?: string | Uint8Array | ArrayBuffer;
124
+ keyLength?: 128 | 256;
125
+ extractable?: boolean;
126
+ }
127
+
1
128
  /**
2
129
  * types.ts — Framework-agnostic hydration and platform abstraction contracts.
3
130
  */
@@ -58,6 +185,14 @@ interface ICacheEntry<T> {
58
185
  data: T;
59
186
  timestamp: number;
60
187
  lifetime: number;
188
+ lastAccessed?: number;
189
+ accessCount?: number;
190
+ }
191
+ interface ICacheQuotaOptions {
192
+ maxEntries?: number;
193
+ maxSizeBytes?: number;
194
+ quotaThresholdRatio?: number;
195
+ fallbackToMemory?: boolean;
61
196
  }
62
197
  interface IRequestOptions {
63
198
  method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
@@ -77,6 +212,9 @@ interface IRequestOptions {
77
212
  tags?: string[];
78
213
  signal?: AbortSignal;
79
214
  _generation?: number;
215
+ encryption?: IProviderEncryptionOptions;
216
+ /** If true, returns raw response without decrypting, useful for DataProvider lazy page-level decryption */
217
+ skipDecryption?: boolean;
80
218
  }
81
219
  /** Queue persistence backend with automatic fallback: IndexedDB → LocalStorage → Memory */
82
220
  declare enum EQueueStorage {
@@ -153,6 +291,7 @@ interface IDataProviderOptions {
153
291
  refreshOnMutation?: boolean;
154
292
  filterDebounce?: number;
155
293
  sortDebounce?: number;
294
+ encryption?: IProviderEncryptionOptions;
156
295
  }
157
296
  interface IDataProviderState<TRow = TDataRow> {
158
297
  currentPage: number;
@@ -222,6 +361,8 @@ interface ITreeDataProvider<TRow = TDataRow> {
222
361
  collapseAll?(): void;
223
362
  expandAll?(): void;
224
363
  isExpanded?(id: string | number): boolean;
364
+ allVisibleNodes?: ITreeNode<TRow>[];
365
+ allVisibleRows?: (TRow & ITreeNode<TRow>)[];
225
366
  }
226
367
  interface ITreeDataProviderOptions extends IDataProviderOptions {
227
368
  parentKey?: string;
@@ -241,6 +382,7 @@ type TTreePageDataHandler<TRow = TDataRow> = (currentPage: number, pageSize: num
241
382
  expandedByDefault: boolean;
242
383
  }, options?: {
243
384
  disableCache?: boolean;
385
+ signal?: AbortSignal;
244
386
  }) => IDataResult<TRow> | Promise<IDataResult<TRow>>;
245
387
  interface KProductItemData {
246
388
  id: string | number;
@@ -260,7 +402,9 @@ interface KProductRowAction {
260
402
 
261
403
  declare abstract class ADataProvider<TRow = TDataRow> {
262
404
  idKey: string;
263
- pageData: TRow[];
405
+ protected _pageData: TRow[];
406
+ get pageData(): TRow[];
407
+ set pageData(val: TRow[]);
264
408
  protected _rowCount: number;
265
409
  get rowCount(): number;
266
410
  set rowCount(val: number);
@@ -388,6 +532,11 @@ declare class RequestProvider {
388
532
  setCacheProvider(provider?: ACacheProvider | ECacheStrategy): void;
389
533
  setCacheLifetime(lifetime: number): void;
390
534
  setDeduplicate(deduplicate: boolean): void;
535
+ encryption?: IProviderEncryptionOptions;
536
+ private _cachedCipherProvider?;
537
+ private _lastEncryptionConfig?;
538
+ setEncryption(encryption?: IProviderEncryptionOptions): void;
539
+ clearEncryption(): void;
391
540
  onDataReceived(callback: (data: any, generation?: number) => void): void;
392
541
  private invokeDataReceivedCallback;
393
542
  hasLastUrl(): boolean;
@@ -398,16 +547,31 @@ declare class RequestProvider {
398
547
  registerRequest<T>(url: string, options?: IRequestOptions): Promise<T>;
399
548
  static executeAll(): void;
400
549
  private isSameOriginUrl;
550
+ private getCipherProvider;
551
+ private isDataEncrypted;
552
+ private buildEncryptionContext;
553
+ private decryptPayloadIfNeeded;
401
554
  request<T>(url: string, options?: IRequestOptions): Promise<T>;
402
555
  }
403
556
 
557
+ declare function getCipherProvider(encryption?: IProviderEncryptionOptions): IEncryptionProvider | undefined;
558
+ declare function clearCachedCipherProvider(encryption?: IProviderEncryptionOptions): void;
559
+ declare function isDataEncrypted(provider?: IEncryptionProvider, data?: any, visited?: WeakSet<object>): boolean;
560
+ declare function buildEncryptionContext(encryption?: IProviderEncryptionOptions, url?: string, _defaultIdKey?: string): IEncryptionContext;
561
+ declare function decryptPageRows<T = any>(rows: T[], encryption?: IProviderEncryptionOptions, apiUrl?: string, idKey?: string): Promise<{
562
+ rows: T[];
563
+ decrypted: boolean;
564
+ }>;
404
565
  declare abstract class AAPIDataProvider {
405
566
  apiUrl: string;
406
567
  cacheStrategy: ECacheStrategy | null;
407
568
  cacheLifetime: number;
408
569
  requestProvider: RequestProvider;
409
570
  refreshOnMutation: boolean | undefined;
571
+ encryption?: IProviderEncryptionOptions;
410
572
  constructor(options?: IDataProviderOptions);
573
+ setEncryption(encryption?: IProviderEncryptionOptions): void;
574
+ clearEncryption(): void;
411
575
  abstract setAPIUrl(url: string): void;
412
576
  abstract create(item: any): Promise<void>;
413
577
  abstract update(item: any): Promise<void>;
@@ -421,7 +585,10 @@ declare class CAPIFlatClientDataProvider<TRow = TDataRow> extends CFlatClientDat
421
585
  cacheStrategy: ECacheStrategy | null;
422
586
  cacheLifetime: number;
423
587
  refreshOnMutation: boolean | undefined;
588
+ encryption?: IProviderEncryptionOptions;
424
589
  constructor(options?: IDataProviderOptions);
590
+ setEncryption(encryption?: IProviderEncryptionOptions): void;
591
+ clearEncryption(): void;
425
592
  setContextKey(key: string): void;
426
593
  setCacheStrategy(strategy: ECacheStrategy): void;
427
594
  setCacheLifetime(lifetime: number): void;
@@ -432,6 +599,7 @@ declare class CAPIFlatClientDataProvider<TRow = TDataRow> extends CFlatClientDat
432
599
  create(item: any): Promise<void>;
433
600
  update(item: any): Promise<void>;
434
601
  delete(items: any[]): Promise<void>;
602
+ loadPageData(): Promise<void>;
435
603
  }
436
604
 
437
605
  declare class CFlatServerDataProvider<TRow = TDataRow> extends ADataProvider<TRow> {
@@ -447,6 +615,7 @@ declare class CFlatServerDataProvider<TRow = TDataRow> extends ADataProvider<TRo
447
615
  signal?: AbortSignal;
448
616
  }): Promise<void>;
449
617
  refresh(hardRefresh?: boolean): Promise<void>;
618
+ cancelPending(): void;
450
619
  }
451
620
 
452
621
  declare class CAPIFlatServerDataProvider<TRow = TDataRow> extends CFlatServerDataProvider<TRow> implements AAPIDataProvider {
@@ -455,9 +624,12 @@ declare class CAPIFlatServerDataProvider<TRow = TDataRow> extends CFlatServerDat
455
624
  cacheStrategy: ECacheStrategy | null;
456
625
  cacheLifetime: number;
457
626
  refreshOnMutation: boolean | undefined;
627
+ encryption?: IProviderEncryptionOptions;
458
628
  /** Incremented on every new request; stale onDataReceived callbacks are discarded. */
459
629
  private _requestGeneration;
460
630
  constructor(options?: IDataProviderOptions);
631
+ setEncryption(encryption?: IProviderEncryptionOptions): void;
632
+ clearEncryption(): void;
461
633
  refresh(hardRefresh?: boolean): Promise<void>;
462
634
  refreshData(options?: {
463
635
  disableCache?: boolean;
@@ -480,18 +652,25 @@ declare class CTreeClientDataProvider<TRow extends TDataRow = TDataRow> extends
480
652
  private _filteredNodesCache;
481
653
  invalidateStaticCache(): void;
482
654
  setFilter(filter: IDataFilter | null, immediate?: boolean): void;
655
+ protected onFilterUpdated(): void;
483
656
  private get _staticNodes();
484
657
  private get _nodeMap();
485
658
  private get _sortedNodeIds();
486
659
  constructor(options?: ITreeDataProviderOptions);
487
660
  setData(data: TRow[]): void;
488
661
  private buildStaticNodes;
662
+ protected onSortUpdated(): void;
663
+ setSortList(sortList: IDataSort[], immediate?: boolean): void;
489
664
  private computeSortedIds;
490
665
  private isNodeVisible;
491
666
  private paginateNodes;
492
667
  private updatePageData;
493
668
  loadPageData(): Promise<void>;
494
669
  get treeNodes(): ITreeNode<TRow>[];
670
+ get allVisibleNodes(): ITreeNode<TRow>[];
671
+ get allVisibleRows(): (TRow & ITreeNode<TRow> & {
672
+ __treeNode: ITreeNode<TRow>;
673
+ })[];
495
674
  get visibleRows(): ITreeNode<TRow>[];
496
675
  getAllNodes(): ITreeNode<TRow>[];
497
676
  getFlatNodes(): ITreeNode<TRow>[];
@@ -514,7 +693,10 @@ declare class CAPITreeClientDataProvider<TRow extends TDataRow = TDataRow> exten
514
693
  cacheStrategy: ECacheStrategy | null;
515
694
  cacheLifetime: number;
516
695
  refreshOnMutation: boolean | undefined;
696
+ encryption?: IProviderEncryptionOptions;
517
697
  constructor(options?: ITreeDataProviderOptions);
698
+ setEncryption(encryption?: IProviderEncryptionOptions): void;
699
+ clearEncryption(): void;
518
700
  setContextKey(key: string): void;
519
701
  refresh(hardRefresh?: boolean): Promise<void>;
520
702
  refreshData(options?: {
@@ -525,6 +707,7 @@ declare class CAPITreeClientDataProvider<TRow extends TDataRow = TDataRow> exten
525
707
  create(item: any): Promise<void>;
526
708
  update(item: any): Promise<void>;
527
709
  delete(items: any[]): Promise<void>;
710
+ loadPageData(): Promise<void>;
528
711
  }
529
712
 
530
713
  /**
@@ -558,6 +741,7 @@ declare class CTreeServerDataProvider<TRow = TDataRow> extends ADataProvider<TRo
558
741
  signal?: AbortSignal;
559
742
  }): Promise<void>;
560
743
  refresh(hardRefresh?: boolean): Promise<void>;
744
+ cancelPending(): void;
561
745
  toggleNode(nodeId: string | number): void;
562
746
  expand(nodeId: string | number): void;
563
747
  collapse(nodeId: string | number): void;
@@ -579,9 +763,12 @@ declare class CAPITreeServerDataProvider<TRow = TDataRow> extends CTreeServerDat
579
763
  cacheStrategy: ECacheStrategy | null;
580
764
  cacheLifetime: number;
581
765
  refreshOnMutation: boolean | undefined;
766
+ encryption?: IProviderEncryptionOptions;
582
767
  /** Incremented on every new request; stale onDataReceived callbacks are discarded. */
583
768
  private _requestGeneration;
584
769
  constructor(options?: ITreeDataProviderOptions);
770
+ setEncryption(encryption?: IProviderEncryptionOptions): void;
771
+ clearEncryption(): void;
585
772
  refresh(hardRefresh?: boolean): Promise<void>;
586
773
  refreshData(options?: {
587
774
  disableCache?: boolean;
@@ -668,11 +855,14 @@ declare class CServerSessionCache extends ACacheProvider {
668
855
  static get storage(): Map<string, Map<string, ICacheEntry<any>>>;
669
856
  static getSnapshot(): Map<string, Map<string, ICacheEntry<any>>>;
670
857
  static MAX_SERVER_SESSIONS: number;
858
+ static MAX_ENTRIES_PER_SESSION: number;
859
+ static CLEANUP_INTERVAL_OPS: number;
860
+ private static _opCounter;
671
861
  /**
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.
862
+ * Purges expired entries across server sessions.
863
+ * Can be run in bounded batches (maxSessionsToCheck) to prevent blocking the event loop.
674
864
  */
675
- static purgeExpiredServerSessions(): void;
865
+ static purgeExpiredServerSessions(maxSessionsToCheck?: number): void;
676
866
  private sessionIdCache;
677
867
  private readonly SESSION_ID_KEY;
678
868
  constructor();
@@ -739,8 +929,29 @@ declare class CLocalStorageCache extends ACacheProvider {
739
929
  private static instance;
740
930
  static getInstance(): CLocalStorageCache;
741
931
  type: string;
932
+ private quotaOptions;
933
+ configureQuota(options: Partial<ICacheQuotaOptions>): void;
934
+ getQuotaOptions(): Required<ICacheQuotaOptions>;
742
935
  private constructor();
743
936
  private _hydrateFromPayload;
937
+ /**
938
+ * Estimates current cache storage consumption in bytes and item counts without full JSON.parse overhead.
939
+ */
940
+ estimateStorageUsage(): {
941
+ totalBytes: number;
942
+ entryCount: number;
943
+ thresholdBytes: number;
944
+ isNearQuota: boolean;
945
+ };
946
+ /**
947
+ * Inspects all cache:* items in LocalStorage and returns metadata sorted for LRU analysis.
948
+ */
949
+ private _getCacheEntriesMetadata;
950
+ /**
951
+ * Evicts least recently used or oldest entries until storage usage drops by targetRatio.
952
+ * Returns number of evicted items.
953
+ */
954
+ evictLRU(targetRatio?: number): number;
744
955
  getKeyList(context?: any): Promise<Array<string>>;
745
956
  get<T>(key: string, context?: any): Promise<T | null>;
746
957
  set<T>(key: string, data: T, lifetime: number, context?: any): Promise<void>;
@@ -754,10 +965,26 @@ declare class CIndexedDBCache extends ACacheProvider {
754
965
  private static instance;
755
966
  private static instances;
756
967
  readonly storeName: string;
968
+ private quotaOptions;
969
+ configureQuota(options: Partial<ICacheQuotaOptions>): void;
970
+ getQuotaOptions(): Required<ICacheQuotaOptions>;
757
971
  static getInstance(storeName?: string): CIndexedDBCache;
758
972
  constructor(storeName?: string);
759
973
  private _hydrateFromPayload;
760
974
  private getStore;
975
+ /**
976
+ * Checks browser navigator.storage estimate to see if storage usage is near quota.
977
+ */
978
+ estimateStorageUsage(): Promise<{
979
+ quota: number;
980
+ usage: number;
981
+ ratio: number;
982
+ isNearQuota: boolean;
983
+ }>;
984
+ /**
985
+ * Evicts least recently used entries from IndexedDB.
986
+ */
987
+ evictLRU(targetRatio?: number): Promise<number>;
761
988
  getKeyList(context?: any): Promise<Array<string>>;
762
989
  get<T>(key: string, context?: any): Promise<T | null>;
763
990
  set<T>(key: string, data: T, lifetime: number, context?: any): Promise<void>;
@@ -926,6 +1153,8 @@ declare class RequestQueue {
926
1153
  private static _onDeadLetter;
927
1154
  private static _onFlushComplete;
928
1155
  private static _onNetworkError;
1156
+ private static _headerProvider;
1157
+ static setHeaderProvider(provider: (() => Record<string, string> | Promise<Record<string, string>>) | null): void;
929
1158
  /**
930
1159
  * Load persisted queue from storage into state.
931
1160
  * Call once at app startup, before any flush or enqueue operations.
@@ -1110,5 +1339,474 @@ declare function getAppRouter(): any;
1110
1339
  */
1111
1340
  declare function onPlatformReady(cb: () => void): void;
1112
1341
 
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 };
1342
+ /**
1343
+ * Foundational abstract base class for all Katlux encryption provider implementations.
1344
+ * Provides key storage, lifecycle management, reusable value-level traversal,
1345
+ * and enforces the isomorphic IEncryptionProvider contract.
1346
+ */
1347
+ declare abstract class AEncryptionProvider implements IEncryptionProvider {
1348
+ protected defaultKey?: TKeyProvider | IKeyPair;
1349
+ constructor(key?: TKeyProvider | IKeyPair);
1350
+ /**
1351
+ * Sets or updates the default secret key, CryptoKey, or async key provider function.
1352
+ */
1353
+ setDefaultKey(key: TKeyProvider | IKeyPair): void;
1354
+ /**
1355
+ * Retrieves the currently configured default key or key provider callback.
1356
+ */
1357
+ getDefaultKey(): TKeyProvider | IKeyPair | undefined;
1358
+ /**
1359
+ * Pre-derives and caches the native CryptoKey for subsequent cryptographic operations.
1360
+ * Subclasses should override this with a dedicated, non-side-effecting implementation.
1361
+ */
1362
+ warmupKey(_options?: IEncryptionContext): Promise<void>;
1363
+ /**
1364
+ * Resolves raw key from keyProvider callback or defaultKey.
1365
+ */
1366
+ protected resolveRawKey(keyProvider?: TKeyProvider | IKeyPair | any): Promise<TRawKey>;
1367
+ /**
1368
+ * Checks whether the given payload is an encrypted envelope.
1369
+ */
1370
+ static isEncrypted(payload: any): boolean;
1371
+ /**
1372
+ * Checks whether the given payload is an encrypted envelope.
1373
+ */
1374
+ isEncrypted(payload: any): boolean;
1375
+ /**
1376
+ * Clears configured keys and cached cryptographic material from memory.
1377
+ */
1378
+ clearKeys(): void;
1379
+ /**
1380
+ * Alias for clearKeys() to conform with standard disposal patterns.
1381
+ */
1382
+ dispose(): void;
1383
+ /**
1384
+ * ECMAScript Explicit Resource Management protocol (using / await using declarations).
1385
+ */
1386
+ [Symbol.dispose](): void;
1387
+ [Symbol.asyncDispose](): Promise<void>;
1388
+ /**
1389
+ * Encrypts a single value (string, object, primitive) into an IEncryptedPayload envelope.
1390
+ * Implemented by concrete cryptographic providers.
1391
+ */
1392
+ abstract encryptValue(value: any, options?: IEncryptionContext): Promise<IEncryptedPayload>;
1393
+ /**
1394
+ * Decrypts a single IEncryptedPayload envelope back into its original plaintext.
1395
+ * Implemented by concrete cryptographic providers.
1396
+ */
1397
+ abstract decryptValue(payload: IEncryptedPayload, options?: IEncryptionContext): Promise<any>;
1398
+ /**
1399
+ * Top-level polymorphic encryption method.
1400
+ * Automatically performs value-level encryption:
1401
+ * - If data is an array of objects: recursively encrypts each row.
1402
+ * - If data is an object: encrypts specified fields (or all values if valueEncryption is true),
1403
+ * preserving JSON object keys so backend APIs and ORMs can parse keys and perform upserts.
1404
+ * - If data is a primitive or whole-payload envelope: encrypts as a single value.
1405
+ */
1406
+ encrypt(data: any, options?: IEncryptionContext): Promise<any>;
1407
+ /**
1408
+ * Top-level polymorphic decryption method.
1409
+ * Automatically performs value-level decryption:
1410
+ * - If payload is an encrypted envelope: decrypts directly via decryptValue.
1411
+ * - If payload is an array of objects: decrypts each row.
1412
+ * - If payload is an object: decrypts any encrypted value cells across fields.
1413
+ */
1414
+ decrypt(payload: any, options?: IEncryptionContext): Promise<any>;
1415
+ }
1416
+
1417
+ /**
1418
+ * Static cryptographic key lifecycle management utility.
1419
+ * Provides key generation, JWK import/export, key wrapping (AES-KW / RSA-OAEP),
1420
+ * and standard Key Derivation Functions (PBKDF2 / HKDF).
1421
+ */
1422
+ declare class CKeyManager {
1423
+ /**
1424
+ * Generates a cryptographically secure random byte buffer of the specified length.
1425
+ */
1426
+ static randomBytes(length: number): Uint8Array;
1427
+ /**
1428
+ * Converts an ArrayBuffer or Uint8Array into a Base64-encoded string.
1429
+ */
1430
+ static toBase64(buffer: ArrayBuffer | Uint8Array): string;
1431
+ /**
1432
+ * Converts a Base64 or Base64URL-encoded string back into a Uint8Array.
1433
+ * Normalizes URL-safe characters and padding, strictly validating against the Base64 alphabet.
1434
+ */
1435
+ static fromBase64(base64: string): Uint8Array;
1436
+ /**
1437
+ * Deterministically resolves a salt from Uint8Array, ArrayBuffer, Base64/Base64URL string, or raw text string.
1438
+ * Guarantees 100% identical salt byte resolution between Node.js and Browser environments.
1439
+ */
1440
+ static resolveSalt(salt?: Uint8Array | ArrayBuffer | string): Uint8Array;
1441
+ /**
1442
+ * Generates a random AES CryptoKey suitable for AES-GCM or AES-CBC.
1443
+ */
1444
+ static generateAESKey(length?: 128 | 256, algorithm?: 'AES-GCM' | 'AES-CBC' | 'AES-KW', extractable?: boolean): Promise<CryptoKey>;
1445
+ /**
1446
+ * Exports an AES CryptoKey as a raw base64 string.
1447
+ */
1448
+ static exportAESKey(key: CryptoKey): Promise<string>;
1449
+ /**
1450
+ * Imports an AES CryptoKey from a raw base64 string.
1451
+ */
1452
+ static importAESKey(base64: string, algorithm?: 'AES-GCM' | 'AES-CBC' | 'AES-KW', extractable?: boolean): Promise<CryptoKey>;
1453
+ /**
1454
+ * Generates an RSA-OAEP public/private key pair (2048 or 4096 bits).
1455
+ */
1456
+ static generateRSAKeyPair(bits?: 2048 | 4096, hash?: 'SHA-256' | 'SHA-512', extractable?: boolean): Promise<IKeyPair>;
1457
+ /**
1458
+ * Generates an ECDH public/private key pair for elliptic curve Diffie-Hellman.
1459
+ */
1460
+ static generateECDHKeyPair(curve?: 'P-256' | 'P-384' | 'P-521', extractable?: boolean): Promise<IKeyPair>;
1461
+ /**
1462
+ * Exports a public CryptoKey to a portable JsonWebKey (JWK).
1463
+ */
1464
+ static exportPublicKey(key: CryptoKey): Promise<JsonWebKey>;
1465
+ /**
1466
+ * Exports a private CryptoKey to a portable JsonWebKey (JWK).
1467
+ */
1468
+ static exportPrivateKey(key: CryptoKey): Promise<JsonWebKey>;
1469
+ /**
1470
+ * Imports a public key from a JsonWebKey (JWK).
1471
+ */
1472
+ static importPublicKey(jwk: JsonWebKey, algorithm?: string | RsaHashedImportParams | EcKeyImportParams): Promise<CryptoKey>;
1473
+ /**
1474
+ * Imports a private key from a JsonWebKey (JWK).
1475
+ */
1476
+ static importPrivateKey(jwk: JsonWebKey, algorithm?: string | RsaHashedImportParams | EcKeyImportParams): Promise<CryptoKey>;
1477
+ /**
1478
+ * Imports a public key from a PEM (SPKI) or base64 SPKI string.
1479
+ */
1480
+ static importPublicKeyFromPEM(pem: string, algorithm?: 'RSA-OAEP' | 'ECDH', curve?: 'P-256' | 'P-384' | 'P-521', hash?: 'SHA-256' | 'SHA-512'): Promise<CryptoKey>;
1481
+ /**
1482
+ * Imports a private key from a PEM (PKCS#8) or base64 PKCS#8 string.
1483
+ */
1484
+ static importPrivateKeyFromPEM(pem: string, algorithm?: 'RSA-OAEP' | 'ECDH', curve?: 'P-256' | 'P-384' | 'P-521', hash?: 'SHA-256' | 'SHA-512'): Promise<CryptoKey>;
1485
+ /**
1486
+ * Exports a public CryptoKey to a standard PEM (SPKI) string.
1487
+ */
1488
+ static exportPublicKeyToPEM(key: CryptoKey): Promise<string>;
1489
+ /**
1490
+ * Exports a private CryptoKey to a standard PEM (PKCS#8) string.
1491
+ */
1492
+ static exportPrivateKeyToPEM(key: CryptoKey): Promise<string>;
1493
+ /**
1494
+ * Wraps a target CryptoKey (e.g. an Account Symmetric Key) using a wrapping key
1495
+ * (AES-KW or RSA-OAEP).
1496
+ */
1497
+ static wrapKey(keyToWrap: CryptoKey, wrappingKey: CryptoKey, format?: KeyFormat): Promise<string>;
1498
+ /**
1499
+ * Unwraps a base64-encoded wrapped key using an unwrapping key (AES-KW or RSA-OAEP).
1500
+ */
1501
+ static unwrapKey(wrappedBase64: string, unwrappingKey: CryptoKey, unwrappedKeyAlgorithm?: any, extractable?: boolean, keyUsages?: KeyUsage[], format?: KeyFormat): Promise<CryptoKey>;
1502
+ /**
1503
+ * Generates a high-entropy symmetric AES-GCM Account Data Encryption Key (ADEK).
1504
+ * Designed for multi-user table and field-level encryption.
1505
+ */
1506
+ static generateAccountDataKey(length?: 128 | 192 | 256): Promise<CryptoKey>;
1507
+ /**
1508
+ * Wraps an Account Data Encryption Key (ADEK) for a specific user using the user's public key (RSA-OAEP).
1509
+ * Returns a Base64-encoded wrapped key string suitable for storage in role-map / access tables.
1510
+ */
1511
+ static wrapAccountKeyForUser(adek: CryptoKey, userPublicKey: CryptoKey): Promise<string>;
1512
+ /**
1513
+ * Unwraps a Base64-encoded Account Data Encryption Key (ADEK) using the user's private key (RSA-OAEP).
1514
+ * Returns the restored AES-GCM CryptoKey ready for use in CWebCryptoEncryptionProvider.
1515
+ */
1516
+ static unwrapAccountKeyForUser(wrappedKeyBase64: string, userPrivateKey: CryptoKey, unwrappedKeyAlgorithm?: any): Promise<CryptoKey>;
1517
+ /**
1518
+ * Derives a symmetric AES-GCM CryptoKey from a passphrase using PBKDF2 or HKDF.
1519
+ * Returns the derived CryptoKey and the base64-encoded salt.
1520
+ */
1521
+ static deriveKey(passphrase: string | Uint8Array | ArrayBuffer, options: IKDFOptions): Promise<{
1522
+ key: CryptoKey;
1523
+ salt: string;
1524
+ }>;
1525
+ /**
1526
+ * Derives an AES-GCM CryptoKey from a high-entropy secret (e.g. an ECDH shared secret key)
1527
+ * using HKDF.
1528
+ */
1529
+ static deriveKeyFromSecret(secretKey: CryptoKey, options?: IHKDFFromSecretOptions): Promise<CryptoKey>;
1530
+ }
1531
+
1532
+ interface ICWebCryptoOptions {
1533
+ kdf?: 'none' | 'pbkdf2' | 'hkdf';
1534
+ kdfIterations?: number;
1535
+ kdfHash?: 'SHA-256' | 'SHA-512';
1536
+ kdfSalt?: string | Uint8Array | ArrayBuffer;
1537
+ info?: string | Uint8Array | ArrayBuffer;
1538
+ }
1539
+ declare class CWebCryptoEncryptionProvider extends AEncryptionProvider {
1540
+ private _defaultKdf;
1541
+ private _cachedKey?;
1542
+ private _kdfOptions?;
1543
+ private _cachedSalt?;
1544
+ private _cachedKdf?;
1545
+ private _cachedIter?;
1546
+ private _cachedHash?;
1547
+ private _decryptSaltCache;
1548
+ setDefaultKey(key: TKeyProvider): void;
1549
+ clearKeys(): void;
1550
+ constructor(key?: TKeyProvider | IKeyPair, options?: ICWebCryptoOptions);
1551
+ /**
1552
+ * Derives or returns a CryptoKey for encryption/decryption based on KDF settings.
1553
+ */
1554
+ private resolveCryptoKey;
1555
+ private _resolveCryptoKeyInternal;
1556
+ static isEncrypted(payload: any): boolean;
1557
+ isEncrypted(payload: any): boolean;
1558
+ warmupKey(options?: IEncryptionContext): Promise<void>;
1559
+ /**
1560
+ * Encrypts a single value into an AES-GCM envelope.
1561
+ */
1562
+ encryptValue(data: any, options?: IEncryptionContext): Promise<IEncryptedPayload>;
1563
+ /**
1564
+ * Decrypts a single AES-GCM envelope back into its plaintext.
1565
+ */
1566
+ decryptValue(payload: IEncryptedPayload, options?: IEncryptionContext): Promise<any>;
1567
+ }
1568
+
1569
+ interface ICWebCryptoAESCBCOptions {
1570
+ kdf?: 'none' | 'pbkdf2' | 'hkdf';
1571
+ kdfIterations?: number;
1572
+ kdfHash?: 'SHA-256' | 'SHA-512';
1573
+ kdfSalt?: string | Uint8Array | ArrayBuffer;
1574
+ info?: string | Uint8Array | ArrayBuffer;
1575
+ }
1576
+ /**
1577
+ * Authenticated AES-CBC-256 provider with Encrypt-then-MAC (HMAC-SHA-256).
1578
+ *
1579
+ * AES-CBC provides confidentiality but no integrity protection by itself.
1580
+ * This provider implements Encrypt-then-MAC: an HMAC-SHA-256 tag is computed
1581
+ * over the (IV || ciphertext) and stored in the envelope's `tag` field.
1582
+ * Upon decryption, the HMAC is strictly verified before CBC decryption to mitigate
1583
+ * padding oracle and bit-flipping attacks.
1584
+ */
1585
+ declare class CWebCryptoAESCBCProvider extends AEncryptionProvider {
1586
+ private _defaultKdf;
1587
+ private _cachedEncKey?;
1588
+ private _cachedMacKey?;
1589
+ private _cachedSalt?;
1590
+ private _cachedKdf?;
1591
+ private _cachedIter?;
1592
+ private _cachedHash?;
1593
+ private _kdfOptions?;
1594
+ private _decryptSaltCache;
1595
+ constructor(key?: TKeyProvider | IKeyPair, options?: ICWebCryptoAESCBCOptions);
1596
+ setDefaultKey(key: TKeyProvider | IKeyPair): void;
1597
+ clearKeys(): void;
1598
+ warmupKey(options?: IEncryptionContext): Promise<void>;
1599
+ /**
1600
+ * Derives 64 bytes (512 bits) of key material:
1601
+ * - Bytes 0..31 (256 bits) for AES-CBC encryption key
1602
+ * - Bytes 32..63 (256 bits) for HMAC-SHA-256 authentication key
1603
+ */
1604
+ private resolveCBCKeys;
1605
+ private _deriveCBCKeysInternal;
1606
+ static isEncrypted(payload: any): boolean;
1607
+ isEncrypted(payload: any): boolean;
1608
+ /**
1609
+ * Encrypts a single value into an authenticated AES-CBC-256+HMAC-SHA-256 envelope.
1610
+ */
1611
+ encryptValue(data: any, options?: IEncryptionContext): Promise<IEncryptedPayload>;
1612
+ /**
1613
+ * Decrypts a single AES-CBC-256+HMAC-SHA-256 envelope back into its plaintext.
1614
+ */
1615
+ decryptValue(payload: IEncryptedPayload, options?: IEncryptionContext): Promise<any>;
1616
+ }
1617
+
1618
+ /**
1619
+ * Asymmetric / Hybrid encryption provider combining RSA-OAEP (2048/4096-bit) with AES-GCM-256.
1620
+ *
1621
+ * Direct RSA encryption is bounded by key size (RSA-4096 max ~446 bytes).
1622
+ * This provider implements the industry-standard Hybrid Encryption scheme:
1623
+ * 1. A random 256-bit AES-GCM data key is generated per encryption.
1624
+ * 2. Payload is encrypted with the AES-GCM data key (unlimited payload size, authenticated).
1625
+ * 3. The AES-GCM data key is wrapped with the recipient's RSA-OAEP public key.
1626
+ * 4. The envelope packages ciphertext, IV, and wrappedKey.
1627
+ * 5. Only the holder of the matching RSA private key can unwrap the data key and decrypt.
1628
+ */
1629
+ declare class CRSAEncryptionProvider extends AEncryptionProvider {
1630
+ private publicKey?;
1631
+ private privateKey?;
1632
+ setDefaultKey(key: TKeyProvider | IKeyPair | Record<string, any>): void;
1633
+ constructor(publicKeyOrPair?: CryptoKey | IKeyPair | {
1634
+ publicKey?: CryptoKey;
1635
+ privateKey?: CryptoKey;
1636
+ recipientPublicKey?: CryptoKey;
1637
+ recipientPrivateKey?: CryptoKey;
1638
+ }, privateKey?: CryptoKey);
1639
+ setPublicKey(key: CryptoKey): void;
1640
+ getPublicKey(): CryptoKey | undefined;
1641
+ setPrivateKey(key: CryptoKey): void;
1642
+ getPrivateKey(): CryptoKey | undefined;
1643
+ clearKeys(): void;
1644
+ static generateKeyPair(bits?: 2048 | 4096): Promise<IKeyPair>;
1645
+ static exportPublicKey(key: CryptoKey): Promise<JsonWebKey>;
1646
+ static exportPrivateKey(key: CryptoKey): Promise<JsonWebKey>;
1647
+ static importPublicKey(jwk: JsonWebKey): Promise<CryptoKey>;
1648
+ static importPrivateKey(jwk: JsonWebKey): Promise<CryptoKey>;
1649
+ static importPublicKeyFromPEM(pem: string, hash?: 'SHA-256' | 'SHA-512'): Promise<CryptoKey>;
1650
+ static importPrivateKeyFromPEM(pem: string, hash?: 'SHA-256' | 'SHA-512'): Promise<CryptoKey>;
1651
+ static exportPublicKeyToPEM(key: CryptoKey): Promise<string>;
1652
+ static exportPrivateKeyToPEM(key: CryptoKey): Promise<string>;
1653
+ static isEncrypted(payload: any): boolean;
1654
+ isEncrypted(payload: any): boolean;
1655
+ /**
1656
+ * Encrypts a single value into a hybrid RSA-OAEP + AES-GCM envelope.
1657
+ */
1658
+ encryptValue(data: any, options?: IEncryptionContext): Promise<IEncryptedPayload>;
1659
+ /**
1660
+ * Decrypts a single hybrid RSA-OAEP + AES-GCM envelope back into its plaintext.
1661
+ */
1662
+ decryptValue(payload: IEncryptedPayload, options?: IEncryptionContext): Promise<any>;
1663
+ encrypt(data: any, options?: IEncryptionContext): Promise<any>;
1664
+ decrypt(payload: any, options?: IEncryptionContext): Promise<any>;
1665
+ }
1666
+
1667
+ type TECDHCurve = 'P-256' | 'P-384' | 'P-521';
1668
+ /**
1669
+ * Modern Asymmetric / Hybrid encryption provider using ECDH (Elliptic Curve Diffie-Hellman)
1670
+ * with HKDF key derivation and AES-GCM-256 authenticated encryption.
1671
+ *
1672
+ * Implements forward-secure hybrid encryption:
1673
+ * 1. An ephemeral ECDH keypair is generated per encryption operation.
1674
+ * 2. Key agreement with recipient's ECDH public key produces a high-entropy shared secret.
1675
+ * 3. HKDF derives a 256-bit AES-GCM data key from the shared secret.
1676
+ * 4. Payload is encrypted with AES-GCM.
1677
+ * 5. Ephemeral public key (JWK) is attached to the envelope (`epk`).
1678
+ * 6. Only the recipient with the matching private key can agree with `epk` and decrypt.
1679
+ */
1680
+ declare class CECDHEncryptionProvider extends AEncryptionProvider {
1681
+ private recipientPublicKey?;
1682
+ private recipientPrivateKey?;
1683
+ private curve;
1684
+ setDefaultKey(key: TKeyProvider | IKeyPair | Record<string, any>): void;
1685
+ constructor(recipientPublicKeyOrPair?: CryptoKey | IKeyPair | {
1686
+ recipientPublicKey?: CryptoKey;
1687
+ publicKey?: CryptoKey;
1688
+ recipientPrivateKey?: CryptoKey;
1689
+ privateKey?: CryptoKey;
1690
+ curve?: TECDHCurve;
1691
+ }, recipientPrivateKey?: CryptoKey, curve?: TECDHCurve);
1692
+ setRecipientPublicKey(key: CryptoKey): void;
1693
+ getRecipientPublicKey(): CryptoKey | undefined;
1694
+ setRecipientPrivateKey(key: CryptoKey): void;
1695
+ getRecipientPrivateKey(): CryptoKey | undefined;
1696
+ getCurve(): TECDHCurve;
1697
+ clearKeys(): void;
1698
+ static generateKeyPair(curve?: TECDHCurve): Promise<IKeyPair>;
1699
+ static exportPublicKey(key: CryptoKey): Promise<JsonWebKey>;
1700
+ static exportPrivateKey(key: CryptoKey): Promise<JsonWebKey>;
1701
+ static importPublicKey(jwk: JsonWebKey, curve?: TECDHCurve): Promise<CryptoKey>;
1702
+ static importPrivateKey(jwk: JsonWebKey, curve?: TECDHCurve): Promise<CryptoKey>;
1703
+ static importPublicKeyFromPEM(pem: string, curve?: TECDHCurve): Promise<CryptoKey>;
1704
+ static importPrivateKeyFromPEM(pem: string, curve?: TECDHCurve): Promise<CryptoKey>;
1705
+ static exportPublicKeyToPEM(key: CryptoKey): Promise<string>;
1706
+ static exportPrivateKeyToPEM(key: CryptoKey): Promise<string>;
1707
+ static isEncrypted(payload: any): boolean;
1708
+ isEncrypted(payload: any): boolean;
1709
+ /**
1710
+ * Encrypts a single value into an ECDH+HKDF+AES-GCM envelope.
1711
+ */
1712
+ encryptValue(data: any, options?: IEncryptionContext): Promise<IEncryptedPayload>;
1713
+ /**
1714
+ * Encrypts multiple designated fields of a record using a single ephemeral ECDH keypair and shared DEK.
1715
+ */
1716
+ private encryptFieldsWithSharedDEK;
1717
+ /**
1718
+ * Derives the AES-GCM data key for a given ECDH envelope.
1719
+ */
1720
+ private deriveDecryptionKey;
1721
+ /**
1722
+ * Decrypts ciphertext buffer using a derived data key.
1723
+ */
1724
+ private decryptCiphertextWithKey;
1725
+ /**
1726
+ * Decrypts a single ECDH+HKDF+AES-GCM envelope back into its plaintext.
1727
+ */
1728
+ decryptValue(payload: IEncryptedPayload, options?: IEncryptionContext): Promise<any>;
1729
+ encrypt(data: any, options?: IEncryptionContext): Promise<any>;
1730
+ decrypt(payload: any, options?: IEncryptionContext): Promise<any>;
1731
+ }
1732
+
1733
+ interface ICNodeCryptoOptions {
1734
+ kdf?: 'none' | 'pbkdf2' | 'hkdf';
1735
+ kdfIterations?: number;
1736
+ kdfHash?: 'SHA-256' | 'SHA-512';
1737
+ kdfSalt?: string | Uint8Array | ArrayBuffer;
1738
+ info?: string | Uint8Array | ArrayBuffer;
1739
+ }
1740
+ /**
1741
+ * Server-side synchronous AES-GCM-256 encryption provider using Node.js native `node:crypto`.
1742
+ *
1743
+ * Fully interoperable with `CWebCryptoEncryptionProvider`:
1744
+ * - Data encrypted by `CNodeCryptoEncryptionProvider` can be decrypted by `CWebCryptoEncryptionProvider`.
1745
+ * - Data encrypted by `CWebCryptoEncryptionProvider` can be decrypted by `CNodeCryptoEncryptionProvider`.
1746
+ *
1747
+ * Provides both synchronous (`encryptSync`, `decryptSync`) and standard Promise-based
1748
+ * (`encrypt`, `decrypt`) methods for Nitro routes, worker threads, and CLI tools.
1749
+ */
1750
+ declare class CNodeCryptoEncryptionProvider extends AEncryptionProvider {
1751
+ private _defaultKdf;
1752
+ private _kdfOptions?;
1753
+ private _cachedKey?;
1754
+ private _cachedSalt?;
1755
+ private _cachedKdf?;
1756
+ private _cachedIter?;
1757
+ private _cachedHash?;
1758
+ setDefaultKey(key: TKeyProvider): void;
1759
+ clearKeys(): void;
1760
+ warmupKey(options?: IEncryptionContext): Promise<void>;
1761
+ /**
1762
+ * Synchronously pre-derives and caches the encryption key for subsequent synchronous operations.
1763
+ */
1764
+ warmupKeySync(options?: IEncryptionContext): void;
1765
+ private resolveInfoBuffer;
1766
+ constructor(key?: TKeyProvider | IKeyPair, options?: ICNodeCryptoOptions);
1767
+ private resolveRawKeySync;
1768
+ private resolveRawKeyAsync;
1769
+ private deriveKeySync;
1770
+ private deriveKeyAsync;
1771
+ static isEncrypted(payload: any): boolean;
1772
+ isEncrypted(payload: any): boolean;
1773
+ /**
1774
+ * Synchronously encrypts a single value into an AES-GCM envelope using Node.js crypto.
1775
+ */
1776
+ encryptValueSync(data: any, options?: IEncryptionContext): IEncryptedPayload;
1777
+ private decryptCiphertextWithKey;
1778
+ /**
1779
+ * Synchronously decrypts a single AES-GCM envelope back into its plaintext.
1780
+ */
1781
+ decryptValueSync(payload: IEncryptedPayload, options?: IEncryptionContext): any;
1782
+ encryptSync(data: any, options?: IEncryptionContext): any;
1783
+ decryptSync(payload: any, options?: IEncryptionContext): any;
1784
+ encryptFieldsSync(data: any, fields: string[]): any;
1785
+ decryptFieldsSync(data: any, fields: string[]): any;
1786
+ encryptFields(data: any, fields: string[]): Promise<any>;
1787
+ decryptFields(data: any, fields: string[]): Promise<any>;
1788
+ encryptValue(data: any, options?: IEncryptionContext): Promise<IEncryptedPayload>;
1789
+ decryptValue(payload: IEncryptedPayload, options?: IEncryptionContext): Promise<any>;
1790
+ decrypt(payload: any, options?: IEncryptionContext): Promise<any>;
1791
+ }
1792
+
1793
+ /**
1794
+ * Universal factory function that creates and returns the appropriate IEncryptionProvider
1795
+ * instance according to the configured algorithm and cryptographic options.
1796
+ *
1797
+ * Algorithm dispatch:
1798
+ * - 'AES-GCM' (default): CWebCryptoEncryptionProvider
1799
+ * - 'AES-CBC' | 'AES-CBC-256+HMAC-SHA-256': CWebCryptoAESCBCProvider
1800
+ * - 'RSA-OAEP' | 'RSA-*': CRSAEncryptionProvider
1801
+ * - 'ECDH' | 'ECDH-*': CECDHEncryptionProvider
1802
+ * - 'NODE-CRYPTO' | sync: true: CNodeCryptoEncryptionProvider
1803
+ */
1804
+ declare function createEncryptionProvider(options?: IProviderEncryptionOptions): IEncryptionProvider;
1805
+
1806
+ /**
1807
+ * Universal helper that verifies whether an arbitrary object is a Katlux encrypted payload envelope.
1808
+ */
1809
+ declare function isEncrypted(payload: any): boolean;
1810
+
1811
+ 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, fetchWithSSR, filterData, filterTreeData, getAppRoute, getAppRouter, getCipherProvider, getHydrationAdapter, getPlatformApp, getSSRData, getSSRPayload, isDataEncrypted, isEncrypted, onPlatformReady, setHydrationAdapter, sortData, useDebounce, useFilterLogic, useSortLogic };
1812
+ 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 };