@katlux/providers 0.1.1-alpha.105 → 0.1.1-alpha.109
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.cjs +5050 -4121
- package/dist/index.d.cts +252 -22
- package/dist/index.d.mts +252 -22
- package/dist/index.d.ts +252 -22
- package/dist/index.mjs +5035 -4122
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -10,6 +10,10 @@ interface IEncryptedPayload {
|
|
|
10
10
|
wrappedKey?: string;
|
|
11
11
|
sharedKey?: boolean;
|
|
12
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;
|
|
13
17
|
}
|
|
14
18
|
type TRawKey = string | CryptoKey | Uint8Array | ArrayBuffer;
|
|
15
19
|
type TKeyProvider = TRawKey | (() => TRawKey | Promise<TRawKey>);
|
|
@@ -20,6 +24,13 @@ interface IEncryptionContext {
|
|
|
20
24
|
/** Whitelist of specific field names to encrypt/decrypt (e.g. ['name', 'surname']). Any unlisted field remains plaintext. */
|
|
21
25
|
fields?: string[];
|
|
22
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;
|
|
23
34
|
/** Whether to encrypt/decrypt individual values while preserving JSON keys (default: true) */
|
|
24
35
|
valueEncryption?: boolean;
|
|
25
36
|
publicKey?: CryptoKey;
|
|
@@ -49,6 +60,11 @@ interface IProviderEncryptionOptions {
|
|
|
49
60
|
enabled?: boolean;
|
|
50
61
|
/** Secret key, passphrase, CryptoKey, key pair, or async key provider function */
|
|
51
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;
|
|
52
68
|
/**
|
|
53
69
|
* Whether decryption is permitted during Server-Side Rendering (SSR).
|
|
54
70
|
* In an End-to-End (E2E) zero-trust model, defaults to false to prevent
|
|
@@ -61,13 +77,22 @@ interface IProviderEncryptionOptions {
|
|
|
61
77
|
lazy?: boolean;
|
|
62
78
|
/** Whitelist of specific field names to encrypt/decrypt (e.g. ['name', 'surname']). Any unlisted field remains plaintext. */
|
|
63
79
|
fields?: string[];
|
|
80
|
+
/** Enable HMAC-SHA256 blind indexing and trigram search index on encrypted fields for local DataProviders */
|
|
81
|
+
searchIndex?: boolean;
|
|
82
|
+
/** Optional dedicated HMAC key for search indexing (defaults to encryption key if omitted) */
|
|
83
|
+
hmacKey?: TKeyProvider;
|
|
64
84
|
/** Cryptographic algorithm identifier (defaults to 'AES-GCM') */
|
|
65
85
|
algorithm?: 'AES-GCM' | string;
|
|
86
|
+
/** Custom cipher adapter implementing IEncryptionProvider (e.g. CRSAEncryptionProvider, CECDHEncryptionProvider, CWebCryptoAESCBCProvider) */
|
|
87
|
+
customProvider?: IEncryptionProvider;
|
|
66
88
|
/** Whether to use synchronous Node.js crypto provider (CNodeCryptoEncryptionProvider) */
|
|
67
89
|
sync?: boolean;
|
|
68
|
-
/**
|
|
69
|
-
|
|
70
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Key Derivation Function strategy ('none' | 'pbkdf2' | 'hkdf'). Defaults to 'pbkdf2'.
|
|
92
|
+
* - 'pbkdf2': Recommended for human passphrases/passwords (OWASP recommended with work factor iterations).
|
|
93
|
+
* - 'hkdf': For deriving subkeys from high-entropy cryptographic keys or secrets (not for low-entropy human passwords).
|
|
94
|
+
* - 'none': Direct key import for raw high-entropy 256-bit symmetric keys or CryptoKeys.
|
|
95
|
+
*/
|
|
71
96
|
kdf?: 'none' | 'pbkdf2' | 'hkdf';
|
|
72
97
|
/** Number of PBKDF2 iterations (default: 310,000 per OWASP recommendation) */
|
|
73
98
|
kdfIterations?: number;
|
|
@@ -275,6 +300,7 @@ type TPageDataHandler<TRow = TDataRow> = (currentPage: number, pageSize: number,
|
|
|
275
300
|
signal?: AbortSignal;
|
|
276
301
|
}) => IDataResult<TRow> | Promise<IDataResult<TRow>>;
|
|
277
302
|
interface IDataProviderOptions {
|
|
303
|
+
apiUrl?: string;
|
|
278
304
|
idKey?: string;
|
|
279
305
|
filter?: IDataFilter;
|
|
280
306
|
sortList?: IDataSort[];
|
|
@@ -439,6 +465,9 @@ declare abstract class ADataProvider<TRow = TDataRow> {
|
|
|
439
465
|
set filter(f: IDataFilter | null);
|
|
440
466
|
get sortList(): IDataSort[];
|
|
441
467
|
set sortList(s: IDataSort[]);
|
|
468
|
+
get hasMore(): boolean;
|
|
469
|
+
nextPage(): Promise<void>;
|
|
470
|
+
loadMore(): Promise<void>;
|
|
442
471
|
private _listeners;
|
|
443
472
|
private _stateListeners;
|
|
444
473
|
private _pendingChangedKeys;
|
|
@@ -464,7 +493,7 @@ declare abstract class ADataProvider<TRow = TDataRow> {
|
|
|
464
493
|
setFilter(filter: IDataFilter | null, immediate?: boolean): void;
|
|
465
494
|
setSortList(sortList: IDataSort[], immediate?: boolean): void;
|
|
466
495
|
setCurrentPage(currentPage: number): void;
|
|
467
|
-
setPageSize(pageSize: number): void;
|
|
496
|
+
setPageSize(pageSize: number, resetPage?: boolean): void;
|
|
468
497
|
setSelectedRows(rows: TRow[]): void;
|
|
469
498
|
setSelectAll(val: boolean): void;
|
|
470
499
|
abstract loadPageData(options?: {
|
|
@@ -475,17 +504,116 @@ declare abstract class ADataProvider<TRow = TDataRow> {
|
|
|
475
504
|
cancelPending(): void;
|
|
476
505
|
}
|
|
477
506
|
|
|
478
|
-
|
|
507
|
+
interface ISetDataChunkedOptions {
|
|
508
|
+
chunkSize?: number;
|
|
509
|
+
onProgress?: (progress: {
|
|
510
|
+
processed: number;
|
|
511
|
+
total: number;
|
|
512
|
+
percent: number;
|
|
513
|
+
}) => void;
|
|
514
|
+
yieldStrategy?: 'microtask' | 'timeout';
|
|
515
|
+
}
|
|
516
|
+
declare function getCipherProvider(encryption?: IProviderEncryptionOptions): IEncryptionProvider | undefined;
|
|
517
|
+
declare function clearCachedCipherProvider(encryption?: IProviderEncryptionOptions): void;
|
|
518
|
+
declare function isDataEncrypted(provider?: IEncryptionProvider, data?: any): boolean;
|
|
519
|
+
declare function buildEncryptionContext(encryption?: IProviderEncryptionOptions, url?: string, _defaultIdKey?: string): IEncryptionContext;
|
|
520
|
+
declare function decryptPageRows<T = any>(rows: T[], encryption?: IProviderEncryptionOptions, apiUrl?: string, idKey?: string): Promise<{
|
|
521
|
+
rows: T[];
|
|
522
|
+
decrypted: boolean;
|
|
523
|
+
}>;
|
|
524
|
+
declare function encryptRows<T = any>(rows: T[], encryption?: IProviderEncryptionOptions, apiUrl?: string, idKey?: string): Promise<T[]>;
|
|
525
|
+
declare function encryptRowsChunked<T = any>(rows: T[], encryption: IProviderEncryptionOptions, options?: ISetDataChunkedOptions, apiUrl?: string, idKey?: string, onChunkEncrypted?: (chunkPlain: T[], chunkEncrypted: T[], chunkStartIndex: number) => Promise<void> | void): Promise<T[]>;
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* Normalizes text for consistent deterministic blind indexing (lowercased, trimmed, NFKC normalized).
|
|
529
|
+
*/
|
|
530
|
+
declare function normalizeIndexTerm(value: any): string;
|
|
531
|
+
/**
|
|
532
|
+
* Extracts 3-character trigrams from a string for substring search.
|
|
533
|
+
*/
|
|
534
|
+
declare function extractTrigrams(value: any): string[];
|
|
535
|
+
interface ISearchIndexRowEntry {
|
|
536
|
+
token: string;
|
|
537
|
+
trigrams: Set<string>;
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* CSearchIndex provides deterministic blind indexing (HMAC-SHA256) and trigram token sets
|
|
541
|
+
* for client-side privacy-preserving searching and filtering across encrypted fields without decryption.
|
|
542
|
+
*/
|
|
543
|
+
declare class CSearchIndex {
|
|
544
|
+
private _hmacKey?;
|
|
545
|
+
private _rawKeyMaterial;
|
|
546
|
+
private _index;
|
|
547
|
+
private _indexedFields;
|
|
548
|
+
constructor(keyMaterial: TKeyProvider, fields?: string[]);
|
|
549
|
+
get indexedFields(): readonly string[];
|
|
550
|
+
setFields(fields: string[]): void;
|
|
551
|
+
private _getHmacKey;
|
|
552
|
+
/**
|
|
553
|
+
* Computes a deterministic HMAC-SHA256 token for a term.
|
|
554
|
+
*/
|
|
555
|
+
computeToken(term: any): Promise<string>;
|
|
556
|
+
/**
|
|
557
|
+
* Computes HMAC-SHA256 tokens for all trigrams of a term.
|
|
558
|
+
*/
|
|
559
|
+
computeTrigramTokens(term: any): Promise<Set<string>>;
|
|
560
|
+
/**
|
|
561
|
+
* Indexes a single row before its fields are encrypted.
|
|
562
|
+
*/
|
|
563
|
+
indexRow(row: any, plaintextFields?: Record<string, any>): Promise<void>;
|
|
564
|
+
/**
|
|
565
|
+
* Indexes an array of rows.
|
|
566
|
+
*/
|
|
567
|
+
indexRows(rows: any[], plaintextMap?: Map<any, Record<string, any>>): Promise<void>;
|
|
568
|
+
/**
|
|
569
|
+
* Returns the index entry for a given row and field.
|
|
570
|
+
*/
|
|
571
|
+
getEntry(row: any, field: string): ISearchIndexRowEntry | undefined;
|
|
572
|
+
/**
|
|
573
|
+
* Evaluates whether a row matches an exact or substring query on an indexed encrypted field.
|
|
574
|
+
*/
|
|
575
|
+
evaluateField(operator: string, row: any, field: string, filterValue: any): Promise<boolean | null>;
|
|
576
|
+
/**
|
|
577
|
+
* Pre-computes query tokens for an active filter, returning a high-performance synchronous
|
|
578
|
+
* evaluator function suitable for row-by-row filtering in memory.
|
|
579
|
+
*/
|
|
580
|
+
createFilterEvaluator(filter: IDataFilter): Promise<((row: any) => boolean) | null>;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
declare abstract class AEncryptedClientProvider<TRow = TDataRow> extends ADataProvider<TRow> {
|
|
584
|
+
encryption?: IProviderEncryptionOptions;
|
|
585
|
+
protected _searchIndex?: CSearchIndex;
|
|
586
|
+
constructor(options?: IDataProviderOptions);
|
|
587
|
+
get isEncryptionEnabled(): boolean;
|
|
588
|
+
get searchIndex(): CSearchIndex | undefined;
|
|
589
|
+
private _warmupKeyAsync;
|
|
590
|
+
protected _initSearchIndex(): void;
|
|
591
|
+
setEncryption(encryption?: IProviderEncryptionOptions): void;
|
|
592
|
+
clearEncryption(): void;
|
|
593
|
+
protected encryptRows(rows: TRow[]): Promise<TRow[]>;
|
|
594
|
+
protected encryptRowsChunked(rows: TRow[], options?: ISetDataChunkedOptions): Promise<TRow[]>;
|
|
595
|
+
protected decryptRows(rows: TRow[]): Promise<{
|
|
596
|
+
rows: TRow[];
|
|
597
|
+
decrypted: boolean;
|
|
598
|
+
}>;
|
|
599
|
+
abstract setData(data: TRow[]): Promise<void> | void;
|
|
600
|
+
setDataChunked(data: TRow[], options?: ISetDataChunkedOptions): Promise<void>;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
declare class CFlatClientDataProvider<TRow = TDataRow> extends AEncryptedClientProvider<TRow> {
|
|
479
604
|
private _allData;
|
|
480
605
|
filteredData: TRow[];
|
|
481
606
|
private _rowMap;
|
|
482
|
-
|
|
483
|
-
|
|
607
|
+
protected _filterDirty: boolean;
|
|
608
|
+
protected _sortDirty: boolean;
|
|
609
|
+
protected _activeFilterEvaluator: ((row: any) => boolean) | null;
|
|
484
610
|
constructor(options?: IDataProviderOptions);
|
|
485
611
|
get allData(): TRow[];
|
|
486
612
|
set allData(data: TRow[]);
|
|
487
613
|
get rowMap(): readonly TRow[];
|
|
488
|
-
setData(data: TRow[]): void;
|
|
614
|
+
setData(data: TRow[]): Promise<void> | void;
|
|
615
|
+
protected _setDataEncrypted(data: TRow[]): Promise<void>;
|
|
616
|
+
setDataChunked(data: TRow[], options?: ISetDataChunkedOptions): Promise<void>;
|
|
489
617
|
protected onFilterUpdated(): void;
|
|
490
618
|
protected onSortUpdated(): void;
|
|
491
619
|
setFilter(filter: IDataFilter | null, immediate?: boolean): void;
|
|
@@ -498,6 +626,7 @@ declare class CFlatClientDataProvider<TRow = TDataRow> extends ADataProvider<TRo
|
|
|
498
626
|
disableCache?: boolean;
|
|
499
627
|
}): Promise<void>;
|
|
500
628
|
refresh(hardRefresh?: boolean): Promise<void>;
|
|
629
|
+
private _computeFilteredAndSorted;
|
|
501
630
|
loadPageData(): Promise<void>;
|
|
502
631
|
}
|
|
503
632
|
|
|
@@ -532,9 +661,19 @@ declare class RequestProvider {
|
|
|
532
661
|
setCacheProvider(provider?: ACacheProvider | ECacheStrategy): void;
|
|
533
662
|
setCacheLifetime(lifetime: number): void;
|
|
534
663
|
setDeduplicate(deduplicate: boolean): void;
|
|
664
|
+
setQueue(queue: boolean): void;
|
|
535
665
|
encryption?: IProviderEncryptionOptions;
|
|
536
666
|
private _cachedCipherProvider?;
|
|
537
667
|
private _lastEncryptionConfig?;
|
|
668
|
+
private _scopedCipherProviders;
|
|
669
|
+
/**
|
|
670
|
+
* Configures E2EE payload encryption for outbound mutations and inbound responses.
|
|
671
|
+
*
|
|
672
|
+
* Threat Model: Protects sensitive SaaS tenant data against backend/database breaches.
|
|
673
|
+
* Multi-user sharing is supported by role-based session keys passed dynamically.
|
|
674
|
+
* Local client endpoint compromise (malware, trojans, keyloggers) is out of scope.
|
|
675
|
+
*/
|
|
676
|
+
private disposeCipherInstance;
|
|
538
677
|
setEncryption(encryption?: IProviderEncryptionOptions): void;
|
|
539
678
|
clearEncryption(): void;
|
|
540
679
|
onDataReceived(callback: (data: any, generation?: number) => void): void;
|
|
@@ -543,7 +682,7 @@ declare class RequestProvider {
|
|
|
543
682
|
refresh(hardRefresh?: boolean): Promise<any>;
|
|
544
683
|
private resolveContext;
|
|
545
684
|
private getInFlightMap;
|
|
546
|
-
|
|
685
|
+
getUniqueKey(url: string, options?: IRequestOptions): string;
|
|
547
686
|
registerRequest<T>(url: string, options?: IRequestOptions): Promise<T>;
|
|
548
687
|
static executeAll(): void;
|
|
549
688
|
private isSameOriginUrl;
|
|
@@ -554,14 +693,6 @@ declare class RequestProvider {
|
|
|
554
693
|
request<T>(url: string, options?: IRequestOptions): Promise<T>;
|
|
555
694
|
}
|
|
556
695
|
|
|
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
|
-
}>;
|
|
565
696
|
declare abstract class AAPIDataProvider {
|
|
566
697
|
apiUrl: string;
|
|
567
698
|
cacheStrategy: ECacheStrategy | null;
|
|
@@ -585,8 +716,11 @@ declare class CAPIFlatClientDataProvider<TRow = TDataRow> extends CFlatClientDat
|
|
|
585
716
|
cacheStrategy: ECacheStrategy | null;
|
|
586
717
|
cacheLifetime: number;
|
|
587
718
|
refreshOnMutation: boolean | undefined;
|
|
588
|
-
|
|
719
|
+
private _isAccumulating;
|
|
720
|
+
private _inFlightLoadMore;
|
|
721
|
+
private _lastDataReceivedPromise;
|
|
589
722
|
constructor(options?: IDataProviderOptions);
|
|
723
|
+
loadMore(): Promise<void>;
|
|
590
724
|
setEncryption(encryption?: IProviderEncryptionOptions): void;
|
|
591
725
|
clearEncryption(): void;
|
|
592
726
|
setContextKey(key: string): void;
|
|
@@ -650,6 +784,7 @@ declare class CTreeClientDataProvider<TRow extends TDataRow = TDataRow> extends
|
|
|
650
784
|
private _nodeMapCache;
|
|
651
785
|
private _sortedNodeIdsCache;
|
|
652
786
|
private _filteredNodesCache;
|
|
787
|
+
private _allVisibleRowsCache;
|
|
653
788
|
invalidateStaticCache(): void;
|
|
654
789
|
setFilter(filter: IDataFilter | null, immediate?: boolean): void;
|
|
655
790
|
protected onFilterUpdated(): void;
|
|
@@ -657,7 +792,10 @@ declare class CTreeClientDataProvider<TRow extends TDataRow = TDataRow> extends
|
|
|
657
792
|
private get _nodeMap();
|
|
658
793
|
private get _sortedNodeIds();
|
|
659
794
|
constructor(options?: ITreeDataProviderOptions);
|
|
660
|
-
|
|
795
|
+
protected _applyTreeData(rows: TRow[]): void;
|
|
796
|
+
setData(data: TRow[]): Promise<void> | void;
|
|
797
|
+
protected _setDataEncrypted(data: TRow[]): Promise<void>;
|
|
798
|
+
setDataChunked(data: TRow[], options?: ISetDataChunkedOptions): Promise<void>;
|
|
661
799
|
private buildStaticNodes;
|
|
662
800
|
protected onSortUpdated(): void;
|
|
663
801
|
setSortList(sortList: IDataSort[], immediate?: boolean): void;
|
|
@@ -668,6 +806,9 @@ declare class CTreeClientDataProvider<TRow extends TDataRow = TDataRow> extends
|
|
|
668
806
|
loadPageData(): Promise<void>;
|
|
669
807
|
get treeNodes(): ITreeNode<TRow>[];
|
|
670
808
|
get allVisibleNodes(): ITreeNode<TRow>[];
|
|
809
|
+
get rowMap(): readonly (TRow & ITreeNode<TRow> & {
|
|
810
|
+
__treeNode: ITreeNode<TRow>;
|
|
811
|
+
})[];
|
|
671
812
|
get allVisibleRows(): (TRow & ITreeNode<TRow> & {
|
|
672
813
|
__treeNode: ITreeNode<TRow>;
|
|
673
814
|
})[];
|
|
@@ -693,7 +834,7 @@ declare class CAPITreeClientDataProvider<TRow extends TDataRow = TDataRow> exten
|
|
|
693
834
|
cacheStrategy: ECacheStrategy | null;
|
|
694
835
|
cacheLifetime: number;
|
|
695
836
|
refreshOnMutation: boolean | undefined;
|
|
696
|
-
|
|
837
|
+
private _lastDataReceivedPromise;
|
|
697
838
|
constructor(options?: ITreeDataProviderOptions);
|
|
698
839
|
setEncryption(encryption?: IProviderEncryptionOptions): void;
|
|
699
840
|
clearEncryption(): void;
|
|
@@ -927,6 +1068,7 @@ declare class CCookieCache extends ACacheProvider {
|
|
|
927
1068
|
|
|
928
1069
|
declare class CLocalStorageCache extends ACacheProvider {
|
|
929
1070
|
private static instance;
|
|
1071
|
+
private static _writeCount;
|
|
930
1072
|
static getInstance(): CLocalStorageCache;
|
|
931
1073
|
type: string;
|
|
932
1074
|
private quotaOptions;
|
|
@@ -1248,6 +1390,7 @@ declare const filterData: (data: any[], filter: IDataFilter, options?: {
|
|
|
1248
1390
|
idKey: string;
|
|
1249
1391
|
parentKey: string;
|
|
1250
1392
|
};
|
|
1393
|
+
rowEvaluator?: (row: any) => boolean;
|
|
1251
1394
|
}) => {
|
|
1252
1395
|
results: any[];
|
|
1253
1396
|
expandedNodes?: Set<string | number>;
|
|
@@ -1266,6 +1409,7 @@ declare const useFilterLogic: () => {
|
|
|
1266
1409
|
idKey: string;
|
|
1267
1410
|
parentKey: string;
|
|
1268
1411
|
};
|
|
1412
|
+
rowEvaluator?: (row: any) => boolean;
|
|
1269
1413
|
}) => {
|
|
1270
1414
|
results: any[];
|
|
1271
1415
|
expandedNodes?: Set<string | number>;
|
|
@@ -1440,6 +1584,11 @@ declare class CKeyManager {
|
|
|
1440
1584
|
static resolveSalt(salt?: Uint8Array | ArrayBuffer | string): Uint8Array;
|
|
1441
1585
|
/**
|
|
1442
1586
|
* Generates a random AES CryptoKey suitable for AES-GCM or AES-CBC.
|
|
1587
|
+
*
|
|
1588
|
+
* E2EE Threat Model Note: Focuses on protecting GDPR/tenant data against database and
|
|
1589
|
+
* server-side leaks. Keys remain extractable by default to enable role-based key sharing,
|
|
1590
|
+
* wrapping, and transfer between authorized client sessions in multi-user SaaS apps.
|
|
1591
|
+
* Client-side malware/trojan protection is out of scope.
|
|
1443
1592
|
*/
|
|
1444
1593
|
static generateAESKey(length?: 128 | 256, algorithm?: 'AES-GCM' | 'AES-CBC' | 'AES-KW', extractable?: boolean): Promise<CryptoKey>;
|
|
1445
1594
|
/**
|
|
@@ -1535,7 +1684,20 @@ interface ICWebCryptoOptions {
|
|
|
1535
1684
|
kdfHash?: 'SHA-256' | 'SHA-512';
|
|
1536
1685
|
kdfSalt?: string | Uint8Array | ArrayBuffer;
|
|
1537
1686
|
info?: string | Uint8Array | ArrayBuffer;
|
|
1687
|
+
kid?: string;
|
|
1688
|
+
keyId?: string;
|
|
1538
1689
|
}
|
|
1690
|
+
/**
|
|
1691
|
+
* Zero-dependency AES-256-GCM cipher provider using native Web Crypto API (crypto.subtle).
|
|
1692
|
+
*
|
|
1693
|
+
* E2EE Threat Model Scope:
|
|
1694
|
+
* - Purpose: Provides client-side End-to-End Encryption (E2EE) to safeguard GDPR and tenant
|
|
1695
|
+
* records against database and server-side data breaches in multi-tenant SaaS systems.
|
|
1696
|
+
* - Multi-User Key Sharing: Authorized users in the same tenant encrypt/decrypt shared data
|
|
1697
|
+
* based on database roles that distribute symmetric or wrapped keys.
|
|
1698
|
+
* - Non-Goals: Client-side trojan, keylogger, or DOM-scraping malware defense is out of scope
|
|
1699
|
+
* and remains the responsibility of the client endpoint device owner.
|
|
1700
|
+
*/
|
|
1539
1701
|
declare class CWebCryptoEncryptionProvider extends AEncryptionProvider {
|
|
1540
1702
|
private _defaultKdf;
|
|
1541
1703
|
private _cachedKey?;
|
|
@@ -1544,6 +1706,8 @@ declare class CWebCryptoEncryptionProvider extends AEncryptionProvider {
|
|
|
1544
1706
|
private _cachedKdf?;
|
|
1545
1707
|
private _cachedIter?;
|
|
1546
1708
|
private _cachedHash?;
|
|
1709
|
+
private _cachedKeyId?;
|
|
1710
|
+
private _configuredKid?;
|
|
1547
1711
|
private _decryptSaltCache;
|
|
1548
1712
|
setDefaultKey(key: TKeyProvider): void;
|
|
1549
1713
|
clearKeys(): void;
|
|
@@ -1572,6 +1736,8 @@ interface ICWebCryptoAESCBCOptions {
|
|
|
1572
1736
|
kdfHash?: 'SHA-256' | 'SHA-512';
|
|
1573
1737
|
kdfSalt?: string | Uint8Array | ArrayBuffer;
|
|
1574
1738
|
info?: string | Uint8Array | ArrayBuffer;
|
|
1739
|
+
kid?: string;
|
|
1740
|
+
keyId?: string;
|
|
1575
1741
|
}
|
|
1576
1742
|
/**
|
|
1577
1743
|
* Authenticated AES-CBC-256 provider with Encrypt-then-MAC (HMAC-SHA-256).
|
|
@@ -1590,6 +1756,7 @@ declare class CWebCryptoAESCBCProvider extends AEncryptionProvider {
|
|
|
1590
1756
|
private _cachedKdf?;
|
|
1591
1757
|
private _cachedIter?;
|
|
1592
1758
|
private _cachedHash?;
|
|
1759
|
+
private _configuredKid?;
|
|
1593
1760
|
private _kdfOptions?;
|
|
1594
1761
|
private _decryptSaltCache;
|
|
1595
1762
|
constructor(key?: TKeyProvider | IKeyPair, options?: ICWebCryptoAESCBCOptions);
|
|
@@ -1625,6 +1792,12 @@ declare class CWebCryptoAESCBCProvider extends AEncryptionProvider {
|
|
|
1625
1792
|
* 3. The AES-GCM data key is wrapped with the recipient's RSA-OAEP public key.
|
|
1626
1793
|
* 4. The envelope packages ciphertext, IV, and wrappedKey.
|
|
1627
1794
|
* 5. Only the holder of the matching RSA private key can unwrap the data key and decrypt.
|
|
1795
|
+
*
|
|
1796
|
+
* Security Advisory (Sender Authenticity): Asymmetric hybrid encryption guarantees confidentiality
|
|
1797
|
+
* for the recipient, but does NOT authenticate the identity of the sender. Any party in possession
|
|
1798
|
+
* of the recipient's public key can encrypt data. In multi-user / multi-tenant workflows where sender
|
|
1799
|
+
* authenticity is required, sign payloads with a digital signature (e.g. ECDSA/RSA-PSS) or use
|
|
1800
|
+
* authenticated symmetric role keys (AES-GCM) governed by database role permissions.
|
|
1628
1801
|
*/
|
|
1629
1802
|
declare class CRSAEncryptionProvider extends AEncryptionProvider {
|
|
1630
1803
|
private publicKey?;
|
|
@@ -1676,6 +1849,12 @@ type TECDHCurve = 'P-256' | 'P-384' | 'P-521';
|
|
|
1676
1849
|
* 4. Payload is encrypted with AES-GCM.
|
|
1677
1850
|
* 5. Ephemeral public key (JWK) is attached to the envelope (`epk`).
|
|
1678
1851
|
* 6. Only the recipient with the matching private key can agree with `epk` and decrypt.
|
|
1852
|
+
*
|
|
1853
|
+
* Security Advisory (Sender Authenticity): ECDH ephemeral-static hybrid encryption guarantees confidentiality
|
|
1854
|
+
* for the recipient, but does NOT authenticate the identity of the sender. Any party with the recipient's
|
|
1855
|
+
* public key can generate an ephemeral keypair and send encrypted envelopes. In multi-user / multi-tenant
|
|
1856
|
+
* SaaS environments requiring sender authenticity, sign payloads with a digital signature (ECDSA/Ed25519)
|
|
1857
|
+
* or use authenticated symmetric role keys (AES-GCM) managed via database role permissions.
|
|
1679
1858
|
*/
|
|
1680
1859
|
declare class CECDHEncryptionProvider extends AEncryptionProvider {
|
|
1681
1860
|
private recipientPublicKey?;
|
|
@@ -1736,6 +1915,8 @@ interface ICNodeCryptoOptions {
|
|
|
1736
1915
|
kdfHash?: 'SHA-256' | 'SHA-512';
|
|
1737
1916
|
kdfSalt?: string | Uint8Array | ArrayBuffer;
|
|
1738
1917
|
info?: string | Uint8Array | ArrayBuffer;
|
|
1918
|
+
kid?: string;
|
|
1919
|
+
keyId?: string;
|
|
1739
1920
|
}
|
|
1740
1921
|
/**
|
|
1741
1922
|
* Server-side synchronous AES-GCM-256 encryption provider using Node.js native `node:crypto`.
|
|
@@ -1755,6 +1936,7 @@ declare class CNodeCryptoEncryptionProvider extends AEncryptionProvider {
|
|
|
1755
1936
|
private _cachedKdf?;
|
|
1756
1937
|
private _cachedIter?;
|
|
1757
1938
|
private _cachedHash?;
|
|
1939
|
+
private _configuredKid?;
|
|
1758
1940
|
setDefaultKey(key: TKeyProvider): void;
|
|
1759
1941
|
clearKeys(): void;
|
|
1760
1942
|
warmupKey(options?: IEncryptionContext): Promise<void>;
|
|
@@ -1803,10 +1985,58 @@ declare class CNodeCryptoEncryptionProvider extends AEncryptionProvider {
|
|
|
1803
1985
|
*/
|
|
1804
1986
|
declare function createEncryptionProvider(options?: IProviderEncryptionOptions): IEncryptionProvider;
|
|
1805
1987
|
|
|
1988
|
+
/**
|
|
1989
|
+
* Shared cryptographic utilities for Web Crypto API access and random byte generation.
|
|
1990
|
+
* Internal module for Katlux Encryption Providers.
|
|
1991
|
+
*/
|
|
1992
|
+
/**
|
|
1993
|
+
* Resolves the SubtleCrypto instance from globalThis.
|
|
1994
|
+
* Throws a descriptive error if Web Crypto API is unavailable.
|
|
1995
|
+
*/
|
|
1996
|
+
declare function getSubtleCrypto(): SubtleCrypto;
|
|
1997
|
+
/**
|
|
1998
|
+
* Fills a typed array with cryptographically secure random values using crypto.getRandomValues.
|
|
1999
|
+
*/
|
|
2000
|
+
declare function getRandomValues(array: Uint8Array): Uint8Array;
|
|
2001
|
+
declare const textEncoder: TextEncoder;
|
|
2002
|
+
declare const textDecoder: TextDecoder;
|
|
2003
|
+
/**
|
|
2004
|
+
* Resolves an HKDF info / context parameter into a Uint8Array.
|
|
2005
|
+
* Safely preserves raw binary buffers (Uint8Array, ArrayBuffer) without string coercion.
|
|
2006
|
+
*/
|
|
2007
|
+
declare function resolveInfoBytes(info?: string | Uint8Array | ArrayBuffer, fallback?: string): Uint8Array;
|
|
2008
|
+
/**
|
|
2009
|
+
* Safely assigns a property to a target object, preventing prototype pollution attacks
|
|
2010
|
+
* via __proto__, constructor, or prototype manipulation.
|
|
2011
|
+
*/
|
|
2012
|
+
declare function safeSetProperty(target: Record<string, any>, key: string, value: any): void;
|
|
2013
|
+
/**
|
|
2014
|
+
* Converts an ArrayBuffer or Uint8Array into a Base64-encoded string.
|
|
2015
|
+
*/
|
|
2016
|
+
declare function toBase64(buffer: ArrayBuffer | Uint8Array): string;
|
|
2017
|
+
/**
|
|
2018
|
+
* Fast 64-bit FNV-1a hash formatted as a hex string.
|
|
2019
|
+
* Non-cryptographic, zero-allocation, synchronous hash used for safe heap cache indexing
|
|
2020
|
+
* without retaining plaintext secrets in compound Map keys.
|
|
2021
|
+
*/
|
|
2022
|
+
declare function fastKeyHash(str: string): string;
|
|
2023
|
+
/**
|
|
2024
|
+
* Computes a collision-free, safe string identifier for a resolved key.
|
|
2025
|
+
* Hashes raw string passphrases to ensure secrets never reside in compound Map keys (Minor 8)
|
|
2026
|
+
* and resolves function outputs so multi-tenant SSR requests never collide on function references (Major 3).
|
|
2027
|
+
*/
|
|
2028
|
+
declare function getSafeKeyIdentifier(rawKey: any): string;
|
|
2029
|
+
/**
|
|
2030
|
+
* Returns a collision-free string identifier for a key provider or fallback key.
|
|
2031
|
+
* Uses a hashed identifier for strings and WeakMap for objects to prevent
|
|
2032
|
+
* cross-tenant cache collisions and avoid storing secrets in heap Map keys.
|
|
2033
|
+
*/
|
|
2034
|
+
declare function getKeyIdentifier(keyProvider?: any, defaultKey?: any): string;
|
|
2035
|
+
|
|
1806
2036
|
/**
|
|
1807
2037
|
* Universal helper that verifies whether an arbitrary object is a Katlux encrypted payload envelope.
|
|
1808
2038
|
*/
|
|
1809
2039
|
declare function isEncrypted(payload: any): boolean;
|
|
1810
2040
|
|
|
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 };
|
|
2041
|
+
export { AAPIDataProvider, ADataProvider, AEncryptedClientProvider, AEncryptionProvider, CAPIFlatClientDataProvider, CAPIFlatServerDataProvider, CAPITreeClientDataProvider, CAPITreeServerDataProvider, CApplicationCache, CBrowserSessionCache, CCookieCache, CECDHEncryptionProvider, CFlatClientDataProvider, CFlatServerDataProvider, CIndexedDBCache, CKeyManager, CLocalStorageCache, CMemoryCache, CNodeCryptoEncryptionProvider, CRSAEncryptionProvider, CSearchIndex, 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, encryptRows, encryptRowsChunked, evaluateFilter, extractTrigrams, fastKeyHash, fetchWithSSR, filterData, filterTreeData, getAppRoute, getAppRouter, getCipherProvider, getHydrationAdapter, getKeyIdentifier, getPlatformApp, getRandomValues, getSSRData, getSSRPayload, getSafeKeyIdentifier, getSubtleCrypto, isDataEncrypted, isEncrypted, normalizeIndexTerm, onPlatformReady, resolveInfoBytes, safeSetProperty, setHydrationAdapter, sortData, textDecoder, textEncoder, toBase64, useDebounce, useFilterLogic, useSortLogic };
|
|
2042
|
+
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, ISearchIndexRowEntry, ISetDataChunkedOptions, ITreeDataProvider, ITreeDataProviderOptions, ITreeNode, ITreeNodeStatic, IVirtualScrollState, IWrappedKey, KProductItemData, KProductRowAction, TDataProviderListener, TDataProviderStateChangeListener, TDataRow, TECDHCurve, TKatluxStore, TKeyProvider, TPageDataHandler, TQueueItemStatus, TRawKey, TTreePageDataHandler, TTreeRow, TUnsubscribe, TreePaginationMode };
|