@katlux/providers 0.1.1-alpha.132 → 0.1.1-alpha.134
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -6
- package/dist/index.cjs +15948 -8557
- package/dist/index.d.cts +2402 -1004
- package/dist/index.d.mts +2402 -1004
- package/dist/index.d.ts +2402 -1004
- package/dist/index.mjs +15826 -8544
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { H3Event } from 'h3';
|
|
2
|
+
import * as NodeCrypto from 'node:crypto';
|
|
3
|
+
|
|
1
4
|
declare enum EDataFilterOperator {
|
|
2
5
|
Equal = "==",
|
|
3
6
|
NotEqual = "!=",
|
|
@@ -10,13 +13,28 @@ declare enum EDataFilterOperator {
|
|
|
10
13
|
And = "and",
|
|
11
14
|
Or = "or",
|
|
12
15
|
Nand = "nand",
|
|
13
|
-
Nor = "nor"
|
|
16
|
+
Nor = "nor",
|
|
17
|
+
Between = "between",
|
|
18
|
+
Contains = "contains",
|
|
19
|
+
Like = "like"
|
|
14
20
|
}
|
|
15
21
|
interface IDataFilter {
|
|
16
22
|
operator: EDataFilterOperator;
|
|
17
23
|
field: TDataRow | IDataFilter | IDataFilter[];
|
|
18
24
|
active: boolean;
|
|
19
25
|
}
|
|
26
|
+
declare const SEARCH_FILTER_NOT_OPERATOR: "not";
|
|
27
|
+
interface ISearchFilterNotNode {
|
|
28
|
+
operator: typeof SEARCH_FILTER_NOT_OPERATOR;
|
|
29
|
+
field: TSearchFilterNode;
|
|
30
|
+
active: boolean;
|
|
31
|
+
}
|
|
32
|
+
interface ISearchFilterCompoundNode {
|
|
33
|
+
operator: EDataFilterOperator.And | EDataFilterOperator.Or | EDataFilterOperator.Nand | EDataFilterOperator.Nor;
|
|
34
|
+
field: TSearchFilterNode[];
|
|
35
|
+
active: boolean;
|
|
36
|
+
}
|
|
37
|
+
type TSearchFilterNode = IDataFilter | ISearchFilterNotNode | ISearchFilterCompoundNode;
|
|
20
38
|
interface IDataSort {
|
|
21
39
|
field: string;
|
|
22
40
|
direction: 'asc' | 'desc';
|
|
@@ -43,6 +61,7 @@ interface ICacheQuotaOptions {
|
|
|
43
61
|
maxSizeBytes?: number;
|
|
44
62
|
quotaThresholdRatio?: number;
|
|
45
63
|
fallbackToMemory?: boolean;
|
|
64
|
+
accessThrottleMs?: number;
|
|
46
65
|
}
|
|
47
66
|
interface ICookieCacheOptions {
|
|
48
67
|
/** Default: 'lax'. */
|
|
@@ -61,13 +80,54 @@ interface ICookieCacheOptions {
|
|
|
61
80
|
path?: string;
|
|
62
81
|
}
|
|
63
82
|
|
|
83
|
+
/**
|
|
84
|
+
* Cryptographic algorithm and key derivation function (KDF) typing for @katlux/providers.
|
|
85
|
+
* Provides compile-time safety, strict autocompletion, and open extensibility.
|
|
86
|
+
*/
|
|
87
|
+
/**
|
|
88
|
+
* Key Derivation Function (KDF) strategies supported by Katlux providers:
|
|
89
|
+
* - 'none': Direct key import (for high-entropy raw keys or CryptoKeys).
|
|
90
|
+
* - 'pbkdf2': Password-Based Key Derivation Function 2 (OWASP standard for human passphrases).
|
|
91
|
+
* - 'hkdf': HMAC-based Extract-and-Expand Key Derivation Function (for high-entropy cryptographic secrets).
|
|
92
|
+
*/
|
|
93
|
+
type TKdfStrategy = 'none' | 'pbkdf2' | 'hkdf';
|
|
94
|
+
/**
|
|
95
|
+
* Supported cryptographic hash functions for KDF key derivation (PBKDF2 / HKDF) and HMAC blind indexing.
|
|
96
|
+
*/
|
|
97
|
+
type TKdfHash = 'SHA-256' | 'SHA-384' | 'SHA-512';
|
|
98
|
+
/**
|
|
99
|
+
* Symmetric authenticated and block cipher algorithms.
|
|
100
|
+
*/
|
|
101
|
+
type TSymmetricAlgorithm = 'AES-GCM' | 'AES-GCM-128' | 'AES-GCM-256' | 'AES-CBC' | 'AES-CBC-128' | 'AES-CBC-256' | 'AES-CBC-128+HMAC-SHA256' | 'AES-CBC-256+HMAC-SHA256' | 'AES-CBC-128+HMAC-SHA-256' | 'AES-CBC-256+HMAC-SHA-256';
|
|
102
|
+
/**
|
|
103
|
+
* Asymmetric RSA-OAEP direct and hybrid algorithms.
|
|
104
|
+
*/
|
|
105
|
+
type TRSAAlgorithm = 'RSA-OAEP' | 'RSA-OAEP-2048' | 'RSA-OAEP-4096' | 'RSA-OAEP-2048+AES-GCM-256' | 'RSA-OAEP-4096+AES-GCM-256';
|
|
106
|
+
/**
|
|
107
|
+
* Asymmetric Elliptic-Curve Diffie-Hellman (ECDH) direct and hybrid algorithms.
|
|
108
|
+
*/
|
|
109
|
+
type TECDHAlgorithm = 'ECDH' | 'ECDH-P-256' | 'ECDH-P-384' | 'ECDH-P-521' | 'ECDH-P-256+AES-GCM-256' | 'ECDH-P-384+AES-GCM-256' | 'ECDH-P-521+AES-GCM-256';
|
|
110
|
+
/**
|
|
111
|
+
* Streaming chunk cipher algorithms.
|
|
112
|
+
*/
|
|
113
|
+
type TStreamAlgorithm = 'AES-CTR' | 'AES-256-CTR';
|
|
114
|
+
/**
|
|
115
|
+
* Union of all built-in supported cryptographic algorithms across Katlux providers.
|
|
116
|
+
*/
|
|
117
|
+
type TSupportedAlgorithm = TSymmetricAlgorithm | TRSAAlgorithm | TECDHAlgorithm | TStreamAlgorithm;
|
|
118
|
+
/**
|
|
119
|
+
* Open union: provides full IDE autocompletion for all built-in Katlux algorithms
|
|
120
|
+
* while allowing custom user-defined ciphers/algorithms.
|
|
121
|
+
*/
|
|
122
|
+
type TEncryptionAlgorithm = TSupportedAlgorithm | (string & {});
|
|
123
|
+
|
|
64
124
|
interface IEncryptedPayload {
|
|
65
125
|
__encrypted: true;
|
|
66
126
|
ciphertext: string;
|
|
67
|
-
alg:
|
|
127
|
+
alg: TEncryptionAlgorithm;
|
|
68
128
|
iv?: string;
|
|
69
129
|
salt?: string;
|
|
70
|
-
kdf?: string;
|
|
130
|
+
kdf?: TKdfStrategy | (string & {});
|
|
71
131
|
iter?: number;
|
|
72
132
|
tag?: string;
|
|
73
133
|
wrappedKey?: string;
|
|
@@ -77,6 +137,8 @@ interface IEncryptedPayload {
|
|
|
77
137
|
kid?: string;
|
|
78
138
|
/** True if AEAD additionalData was bound during encryption */
|
|
79
139
|
aad?: boolean;
|
|
140
|
+
/** Optional Base64-encoded ECDSA sender signature over the canonical envelope */
|
|
141
|
+
signature?: string;
|
|
80
142
|
}
|
|
81
143
|
type TRawKey = string | CryptoKey | Uint8Array | ArrayBuffer;
|
|
82
144
|
type TKeyProvider = TRawKey | (() => TRawKey | Promise<TRawKey>);
|
|
@@ -101,7 +163,7 @@ interface IKeyPair {
|
|
|
101
163
|
*/
|
|
102
164
|
interface IWrappedKey {
|
|
103
165
|
wrappedKey: string;
|
|
104
|
-
alg:
|
|
166
|
+
alg: TEncryptionAlgorithm;
|
|
105
167
|
}
|
|
106
168
|
/**
|
|
107
169
|
* Options for Key Derivation Functions (PBKDF2 / HKDF) in CKeyManager and encryption providers.
|
|
@@ -110,7 +172,8 @@ interface IKDFOptions {
|
|
|
110
172
|
kdf: 'pbkdf2' | 'hkdf';
|
|
111
173
|
salt?: Uint8Array | ArrayBuffer | string;
|
|
112
174
|
iterations?: number;
|
|
113
|
-
|
|
175
|
+
maxAllowedIterations?: number;
|
|
176
|
+
hash?: TKdfHash;
|
|
114
177
|
info?: string | Uint8Array | ArrayBuffer;
|
|
115
178
|
keyLength?: 128 | 256;
|
|
116
179
|
extractable?: boolean;
|
|
@@ -120,7 +183,7 @@ interface IKDFOptions {
|
|
|
120
183
|
*/
|
|
121
184
|
interface IHKDFFromSecretOptions {
|
|
122
185
|
salt?: Uint8Array | ArrayBuffer | string;
|
|
123
|
-
hash?:
|
|
186
|
+
hash?: TKdfHash;
|
|
124
187
|
info?: string | Uint8Array | ArrayBuffer;
|
|
125
188
|
keyLength?: 128 | 256;
|
|
126
189
|
extractable?: boolean;
|
|
@@ -167,7 +230,8 @@ interface IDomainDerivedKeys {
|
|
|
167
230
|
*/
|
|
168
231
|
interface IDeriveAuthAndEncryptionOptions {
|
|
169
232
|
iterations?: number;
|
|
170
|
-
|
|
233
|
+
maxAllowedIterations?: number;
|
|
234
|
+
hash?: TKdfHash;
|
|
171
235
|
authKeyLength?: 128 | 256;
|
|
172
236
|
encryptionKeyLength?: 128 | 256;
|
|
173
237
|
authAlgorithm?: 'HMAC' | 'AES-GCM';
|
|
@@ -357,197 +421,156 @@ interface IVerifyAndPinResult {
|
|
|
357
421
|
fingerprint: string;
|
|
358
422
|
}
|
|
359
423
|
|
|
360
|
-
interface IEncryptionContext {
|
|
361
|
-
url?: string;
|
|
362
|
-
method?: string;
|
|
363
|
-
isServer?: boolean;
|
|
364
|
-
/** Whether to bind the request context (URL and method as `req:${method}:${url}`) into AEAD Authenticated Additional Data (AAD) */
|
|
365
|
-
bindRequestContextAad?: boolean;
|
|
366
|
-
/** Whitelist of specific field names to encrypt/decrypt (e.g. ['name', 'surname']). Any unlisted field remains plaintext. */
|
|
367
|
-
fields?: string[];
|
|
368
|
-
/**
|
|
369
|
-
* Enforces strict encryption validation. When true:
|
|
370
|
-
* 1. Any field in `fields` that is NOT an encrypted envelope triggers a decryption error.
|
|
371
|
-
* 2. Envelope algorithm MUST match `allowedAlgorithms` (defaults to ['AES-GCM']).
|
|
372
|
-
* 3. Envelope `kid` (if present) MUST match `allowedKids`.
|
|
373
|
-
*/
|
|
374
|
-
strict?: boolean;
|
|
375
|
-
/** Whitelist of permitted cryptographic algorithms (e.g. ['AES-GCM']). Defaults to ['AES-GCM'] in strict mode. */
|
|
376
|
-
allowedAlgorithms?: string[];
|
|
377
|
-
/** Whitelist of allowed Key Identifiers (kid). */
|
|
378
|
-
allowedKids?: string[];
|
|
379
|
-
/** Built-in Keyring dictionary mapping Key Identifiers (kid) to keys or key provider functions */
|
|
380
|
-
keys?: Record<string, TKeyProvider | IKeyPair>;
|
|
381
|
-
/** Active key identifier from `keys` to use for all outbound encryption operations */
|
|
382
|
-
activeKid?: string;
|
|
383
|
-
/**
|
|
384
|
-
* Hook invoked whenever decryption fails for an individual field or row.
|
|
385
|
-
* Can return a fallback cell value (e.g. sentinel or marker), or string/boolean.
|
|
386
|
-
*/
|
|
387
|
-
onDecryptError?: ((info: IDecryptErrorInfo) => any) | boolean | string;
|
|
388
|
-
key?: TKeyProvider | IKeyPair;
|
|
389
|
-
/** Optional Key Identifier for multi-role key routing and rotation */
|
|
390
|
-
kid?: string;
|
|
391
|
-
keyId?: string;
|
|
392
|
-
/**
|
|
393
|
-
* Authenticated Additional Data (AAD) bound to the ciphertext to prevent field/record swapping.
|
|
394
|
-
* Can be static string/buffer or dynamic callback evaluated per record and field.
|
|
395
|
-
*/
|
|
396
|
-
aad?: string | Uint8Array | ArrayBuffer | ((record: any, field: string) => string | Uint8Array | ArrayBuffer);
|
|
397
|
-
/** Sibling record fields to deterministically bind into AEAD additional data (e.g. ['contact_id', 'version']) */
|
|
398
|
-
aadFields?: string[];
|
|
399
|
-
/** Optional base AAD prefix when aadFields or dynamic aad is enabled */
|
|
400
|
-
baseAad?: string;
|
|
401
|
-
/** Internal flag indicating that key derivation has already been warmed for this batch */
|
|
402
|
-
_warmedKey?: any;
|
|
403
|
-
/** Whether to encrypt/decrypt individual values while preserving JSON keys (default: true) */
|
|
404
|
-
valueEncryption?: boolean;
|
|
405
|
-
publicKey?: CryptoKey;
|
|
406
|
-
privateKey?: CryptoKey;
|
|
407
|
-
recipientPublicKey?: CryptoKey;
|
|
408
|
-
recipientPrivateKey?: CryptoKey;
|
|
409
|
-
curve?: 'P-256' | 'P-384' | 'P-521';
|
|
410
|
-
kdf?: 'none' | 'pbkdf2' | 'hkdf';
|
|
411
|
-
kdfSalt?: string | Uint8Array | ArrayBuffer;
|
|
412
|
-
kdfIterations?: number;
|
|
413
|
-
kdfHash?: 'SHA-256' | 'SHA-512';
|
|
414
|
-
info?: string | Uint8Array | ArrayBuffer;
|
|
415
|
-
}
|
|
416
424
|
/**
|
|
417
|
-
*
|
|
425
|
+
* Normalization options for string comparisons, filtering, and cryptographic indexing.
|
|
418
426
|
*/
|
|
419
|
-
interface
|
|
420
|
-
/** Record identifier to bind into AAD */
|
|
421
|
-
recordId?: string | number;
|
|
422
|
-
/** Target field name being encrypted/decrypted */
|
|
423
|
-
fieldName?: string;
|
|
424
|
-
/** Sibling record fields (map or array of keys) to deterministically bind into AEAD */
|
|
425
|
-
aadFields?: Record<string, any> | string[];
|
|
426
|
-
/** Optional base AAD prefix */
|
|
427
|
-
baseAad?: string;
|
|
428
|
-
}
|
|
429
|
-
interface IEncryptionProvider {
|
|
430
|
-
encrypt(data: any, options?: IEncryptionContext): Promise<IEncryptedPayload | any>;
|
|
431
|
-
decrypt(payload: IEncryptedPayload | any, options?: IEncryptionContext): Promise<any>;
|
|
432
|
-
/** Encrypts a single scalar value with contextual AAD binding */
|
|
433
|
-
encryptField?(value: any, context?: IFieldEncryptionContext): Promise<IEncryptedPayload>;
|
|
434
|
-
/** Decrypts a single scalar field envelope with contextual AAD */
|
|
435
|
-
decryptField?(envelope: IEncryptedPayload, context?: IFieldEncryptionContext): Promise<any>;
|
|
436
|
-
/** Computes deterministic HMAC-SHA256 blind index hash */
|
|
437
|
-
computeBlindIndex?(value: any, hmacKey?: CryptoKey | TKeyProvider): Promise<string>;
|
|
438
|
-
warmupKey?(options?: IEncryptionContext): Promise<void>;
|
|
439
|
-
isEncrypted?(payload: any): boolean;
|
|
440
|
-
setDefaultKey?(key: TKeyProvider | IKeyPair): void;
|
|
441
|
-
setKeyring?(keys: Record<string, TKeyProvider | IKeyPair>, activeKid?: string): void;
|
|
442
|
-
getKeyring?(): Record<string, TKeyProvider | IKeyPair> | undefined;
|
|
443
|
-
setActiveKid?(kid: string): void;
|
|
444
|
-
getActiveKid?(): string | undefined;
|
|
445
|
-
clearKeys?(): void;
|
|
446
|
-
dispose?(): void;
|
|
447
|
-
[Symbol.dispose]?(): void;
|
|
448
|
-
[Symbol.asyncDispose]?(): Promise<void>;
|
|
449
|
-
}
|
|
450
|
-
interface IProviderEncryptionOptions {
|
|
451
|
-
/** Enable or disable encryption */
|
|
452
|
-
enabled?: boolean;
|
|
453
|
-
/** Secret key, passphrase, CryptoKey, key pair, or async key provider function */
|
|
454
|
-
key?: TKeyProvider | IKeyPair;
|
|
455
|
-
/** Built-in Keyring dictionary mapping Key Identifiers (kid) to keys or key provider functions */
|
|
456
|
-
keys?: Record<string, TKeyProvider | IKeyPair>;
|
|
457
|
-
/** Active key identifier from `keys` to use for all outbound encryption operations */
|
|
458
|
-
activeKid?: string;
|
|
459
|
-
/** Optional Key Identifier for multi-role key routing and key rotation */
|
|
460
|
-
kid?: string;
|
|
461
|
-
keyId?: string;
|
|
462
|
-
/**
|
|
463
|
-
* Authenticated Additional Data (AAD) bound to the ciphertext to prevent field/record swapping.
|
|
464
|
-
* Can be static string/buffer or dynamic callback evaluated per record and field.
|
|
465
|
-
*/
|
|
466
|
-
aad?: string | Uint8Array | ArrayBuffer | ((record: any, field: string) => string | Uint8Array | ArrayBuffer);
|
|
467
|
-
/** Sibling record fields to deterministically bind into AEAD additional data (e.g. ['contact_id', 'version']) */
|
|
468
|
-
aadFields?: string[];
|
|
469
|
-
/** Optional base AAD prefix when aadFields or dynamic aad is enabled */
|
|
470
|
-
baseAad?: string;
|
|
471
|
-
/**
|
|
472
|
-
* Whether to bind the request context (HTTP method and URL as `req:${method}:${url}`) into AEAD Authenticated Additional Data (AAD).
|
|
473
|
-
* Defaults to true when URL or method is provided in context, mitigating replay and cross-endpoint confusion attacks (BUG-015).
|
|
474
|
-
* Set to false to disable request context AAD binding.
|
|
475
|
-
*/
|
|
476
|
-
bindRequestContextAad?: boolean;
|
|
477
|
-
/**
|
|
478
|
-
* Whether decryption is permitted during Server-Side Rendering (SSR).
|
|
479
|
-
* In an End-to-End (E2E) zero-trust model, defaults to false to prevent
|
|
480
|
-
* plaintext data in server memory or SSR payloads.
|
|
481
|
-
*/
|
|
482
|
-
decryptOnSSR?: boolean;
|
|
483
|
-
/** Whether to encrypt/decrypt individual values while preserving JSON object keys (default: true) */
|
|
484
|
-
valueEncryption?: boolean;
|
|
485
|
-
/** Whether to defer row/item decryption to active page rendering in DataProviders */
|
|
486
|
-
lazy?: boolean;
|
|
487
|
-
/** Whitelist of specific field names to encrypt/decrypt (e.g. ['name', 'surname']). Any unlisted field remains plaintext. */
|
|
488
|
-
fields?: string[];
|
|
427
|
+
interface INormalizeOptions {
|
|
489
428
|
/**
|
|
490
|
-
*
|
|
491
|
-
*
|
|
492
|
-
* 2. Envelope algorithm MUST match `allowedAlgorithms` (defaults to ['AES-GCM']).
|
|
493
|
-
* 3. Envelope `kid` (if present) MUST match `allowedKids`.
|
|
429
|
+
* Target locale for case conversion (e.g., 'tr', 'tr-TR', 'az', 'en', etc.).
|
|
430
|
+
* When specified, utilizes `String.prototype.toLocaleLowerCase(locale)`.
|
|
494
431
|
*/
|
|
495
|
-
|
|
496
|
-
/** Whitelist of permitted cryptographic algorithms (e.g. ['AES-GCM']). Defaults to ['AES-GCM'] in strict mode. */
|
|
497
|
-
allowedAlgorithms?: string[];
|
|
498
|
-
/** Whitelist of allowed Key Identifiers (kid). */
|
|
499
|
-
allowedKids?: string[];
|
|
432
|
+
locale?: string;
|
|
500
433
|
/**
|
|
501
|
-
*
|
|
502
|
-
*
|
|
434
|
+
* When true, folds non-ASCII, extended Latin, and accented characters to their closest standard ASCII equivalents.
|
|
435
|
+
* Mappings cover Turkish (İ/ı -> i, Ş/ş -> s, Ç/ç -> c, Ğ/ğ -> g, Ö/ö -> o, Ü/ü -> u), Polish (Ł/ł -> l),
|
|
436
|
+
* German (ß/ẞ -> ss), Nordic (Ø/ø -> o, Æ/æ -> ae, Ð/ð -> d, Þ/þ -> th), Croatian/Vietnamese (Đ/đ -> d),
|
|
437
|
+
* Maltese (Ħ/ħ -> h), French (Œ/œ -> oe), and Azerbaijani (Ə/ə -> e).
|
|
438
|
+
* Preserves distinct non-Latin base letters (such as Cyrillic Short I 'Й'/'й') from decomposition.
|
|
503
439
|
*/
|
|
504
|
-
|
|
505
|
-
/** Enable HMAC-SHA256 blind indexing and trigram search index on encrypted fields for local DataProviders */
|
|
506
|
-
searchIndex?: boolean;
|
|
440
|
+
asciiFold?: boolean;
|
|
507
441
|
/**
|
|
508
|
-
*
|
|
509
|
-
*
|
|
442
|
+
* Optional custom normalizer callback for domain- or script-specific character transforms
|
|
443
|
+
* (e.g. Arabic/Persian Alef/Yeh unification, Hebrew Niqqud stripping, CJK fullwidth folding).
|
|
510
444
|
*/
|
|
511
|
-
|
|
512
|
-
/** Optional dedicated HMAC key for search indexing (defaults to encryption key if omitted) */
|
|
513
|
-
hmacKey?: TKeyProvider;
|
|
514
|
-
/** Cryptographic algorithm identifier (defaults to 'AES-GCM') */
|
|
515
|
-
algorithm?: 'AES-GCM' | string;
|
|
516
|
-
/** Custom cipher adapter implementing IEncryptionProvider (e.g. CRSAEncryptionProvider, CECDHEncryptionProvider, CWebCryptoAESCBCProvider) */
|
|
517
|
-
customProvider?: IEncryptionProvider;
|
|
518
|
-
/** Whether to use synchronous Node.js crypto provider (CNodeCryptoEncryptionProvider) */
|
|
519
|
-
sync?: boolean;
|
|
445
|
+
normalizer?: (value: string) => string;
|
|
520
446
|
/**
|
|
521
|
-
*
|
|
522
|
-
*
|
|
523
|
-
* - 'hkdf': For deriving subkeys from high-entropy cryptographic keys or secrets (not for low-entropy human passwords).
|
|
524
|
-
* - 'none': Direct key import for raw high-entropy 256-bit symmetric keys or CryptoKeys.
|
|
447
|
+
* Optional stable identifier for a custom `normalizer` callback (e.g. 'arabic-alef-v1').
|
|
448
|
+
* Captured by `computeBlindIndexSchemeId` so changes to custom normalizers are detectable.
|
|
525
449
|
*/
|
|
526
|
-
|
|
527
|
-
/** Number of PBKDF2 iterations (default: 310,000 per OWASP recommendation) */
|
|
528
|
-
kdfIterations?: number;
|
|
529
|
-
/** Hash algorithm for PBKDF2 or HKDF ('SHA-256' | 'SHA-512', default: 'SHA-256') */
|
|
530
|
-
kdfHash?: 'SHA-256' | 'SHA-512';
|
|
531
|
-
/** Optional static salt for KDF. If omitted, a cryptographically secure random salt is generated and included in the envelope. */
|
|
532
|
-
kdfSalt?: string | Uint8Array | ArrayBuffer;
|
|
533
|
-
/** Optional public key for asymmetric providers */
|
|
534
|
-
publicKey?: CryptoKey;
|
|
535
|
-
/** Optional private key for asymmetric providers */
|
|
536
|
-
privateKey?: CryptoKey;
|
|
537
|
-
/** Optional recipient public key for asymmetric/hybrid encryption */
|
|
538
|
-
recipientPublicKey?: CryptoKey;
|
|
539
|
-
/** Optional recipient private key for asymmetric/hybrid decryption */
|
|
540
|
-
recipientPrivateKey?: CryptoKey;
|
|
541
|
-
/** Elliptic curve name for ECDH ('P-256' | 'P-384' | 'P-521') */
|
|
542
|
-
curve?: 'P-256' | 'P-384' | 'P-521';
|
|
543
|
-
/** Optional context/info string or buffer for HKDF key derivation */
|
|
544
|
-
info?: string | Uint8Array | ArrayBuffer;
|
|
450
|
+
normalizerId?: string;
|
|
545
451
|
}
|
|
452
|
+
/**
|
|
453
|
+
* Folds special characters, extended Latin alphabets, and diacritics into deterministic lowercase ASCII equivalents.
|
|
454
|
+
*
|
|
455
|
+
* Rules:
|
|
456
|
+
* - Turkish / Azerbaijani: İ/ı -> i, Ş/ş -> s, Ç/ç -> c, Ğ/ğ -> g, Ö/ö -> o, Ü/ü -> u, Ə/ə -> e
|
|
457
|
+
* - Polish: Ł/ł -> l
|
|
458
|
+
* - German: ß/ẞ -> ss
|
|
459
|
+
* - Nordic (DA, NO, IS, FO): Ø/ø -> o, Æ/æ -> ae, Ð/ð -> d, Þ/þ -> th
|
|
460
|
+
* - Croatian / Vietnamese / Maltese: Đ/đ -> d, Ħ/ħ -> h
|
|
461
|
+
* - French / Latin Ligatures: Œ/œ -> oe
|
|
462
|
+
* - Cyrillic: Preserves distinct base letter Short I (Й / й) from being corrupted into И / и during NFD stripping.
|
|
463
|
+
* - Standard Unicode NFD decomposition to strip all combining diacritical marks.
|
|
464
|
+
* - Final lowercasing and NFKC normalization.
|
|
465
|
+
*/
|
|
466
|
+
declare function foldAscii(value: string): string;
|
|
467
|
+
/**
|
|
468
|
+
* Canonical normalization primitive shared across:
|
|
469
|
+
* - In-memory filter evaluations (`filterLogic.ts`)
|
|
470
|
+
* - Trigram search indexing (`CSearchIndex.ts`)
|
|
471
|
+
* - Blind-index token generation (`CKeyManager.ts`)
|
|
472
|
+
* - Encrypted filter rewrites (`rewriteEncryptedFilters.ts`)
|
|
473
|
+
*
|
|
474
|
+
* Default behavior:
|
|
475
|
+
* - Coerces value to string
|
|
476
|
+
* - Normalizes via Unicode NFKC (Compatibility Decomposition followed by Canonical Composition)
|
|
477
|
+
* - Trims leading and trailing whitespace
|
|
478
|
+
* - Converts to lowercase via standard Unicode case folding
|
|
479
|
+
* - Strips combining dot above (U+0307) so capital dotted 'İ' matches lowercase 'i' by default
|
|
480
|
+
* - Folds Greek final sigma (ς / U+03C2) to medial sigma (σ / U+03C3) so queries match across word boundaries
|
|
481
|
+
*
|
|
482
|
+
* Configurable options:
|
|
483
|
+
* - `locale`: When provided (such as 'tr' or 'tr-TR'), uses `toLocaleLowerCase(locale)`
|
|
484
|
+
* ensuring Turkish dotted/dotless I conversions (İ -> i, I -> ı).
|
|
485
|
+
* - `asciiFold`: When true, maps diacritics and extended Latin characters to pure ASCII equivalents
|
|
486
|
+
* ensuring cross-locale equivalence (e.g. 'Çelik' == 'Celik', 'Łódź' == 'lodz', 'Straße' == 'strasse').
|
|
487
|
+
* - `normalizer`: Optional custom transformer invoked after baseline normalization.
|
|
488
|
+
*/
|
|
489
|
+
declare function normalizeFilterValue(value: any, options?: INormalizeOptions): string;
|
|
546
490
|
|
|
547
491
|
/**
|
|
548
492
|
* Lifecycle status for blind-index HMAC keys in a multi-KID keyring.
|
|
549
493
|
*/
|
|
550
494
|
type TBlindIndexKeyStatus = 'active' | 'search-only' | 'retired';
|
|
495
|
+
/**
|
|
496
|
+
* Date bucketing granularity options for shadow range buckets.
|
|
497
|
+
*/
|
|
498
|
+
type TDateBucketGranularity = 'year' | 'quarter' | 'month' | 'week' | 'day';
|
|
499
|
+
/**
|
|
500
|
+
* Configuration for date/timestamp shadow range bucketing.
|
|
501
|
+
*
|
|
502
|
+
* @security Deterministic Shadow-Bucket Range Index:
|
|
503
|
+
* Plaintext/hashed bucket tokens reveal record group frequency, bucket ordering, and
|
|
504
|
+
* temporal distribution profiling (equivalent to coarse Order-Preserving Encryption).
|
|
505
|
+
* Not IND-CPA / not zero-leakage.
|
|
506
|
+
*
|
|
507
|
+
* DO NOT USE fine granularities (`'week'`, `'day'`) on high-sensitivity personal data
|
|
508
|
+
* fields such as `birthDate`, `dateOfBirth`, or `dob`; prefer `'year'` or `'quarter'`,
|
|
509
|
+
* or leave the field as unindexed AES-256-GCM.
|
|
510
|
+
*/
|
|
511
|
+
interface IDateRangeBucketConfig {
|
|
512
|
+
type: 'date';
|
|
513
|
+
granularity?: TDateBucketGranularity;
|
|
514
|
+
minDate?: Date | string | number;
|
|
515
|
+
maxDate?: Date | string | number;
|
|
516
|
+
/** Explicitly suppress narrow-granularity warnings on sensitive date fields */
|
|
517
|
+
allowNarrowGranularity?: boolean;
|
|
518
|
+
/** Explicit opt-in to allow range bucketing on high-sensitivity fields */
|
|
519
|
+
allowSensitiveBucket?: boolean;
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* Configuration for stepped numeric shadow range bucketing.
|
|
523
|
+
*
|
|
524
|
+
* @security Deterministic Shadow-Bucket Range Index:
|
|
525
|
+
* Stepped buckets leak value frequency distributions and ordering relations across buckets
|
|
526
|
+
* (coarse OPE-equivalent leakage; NOT IND-CPA and NOT zero-leakage).
|
|
527
|
+
*
|
|
528
|
+
* DO NOT USE narrow steps (`step < 100` throws `ERR_BUCKET_STEP_TOO_NARROW` by default)
|
|
529
|
+
* or fine increments on high-sensitivity personal data (`salary`, `age`, `birthDate`,
|
|
530
|
+
* `creditScore`, `income`, `ssn`, etc.). For sensitive financial data, prefer coarse
|
|
531
|
+
* tier bucketing (e.g. `$25,000+` salary bands) or unindexed AES-256-GCM.
|
|
532
|
+
*/
|
|
533
|
+
interface ISteppedRangeBucketConfig {
|
|
534
|
+
type: 'stepped';
|
|
535
|
+
step: number;
|
|
536
|
+
min?: number;
|
|
537
|
+
max?: number;
|
|
538
|
+
ceiling?: number;
|
|
539
|
+
floor?: number;
|
|
540
|
+
/** Minimum allowed bucket step width (defaults to `DEFAULT_MIN_BUCKET_STEP` = 100) */
|
|
541
|
+
minStep?: number;
|
|
542
|
+
/** Alias for `minStep`: minimum allowed bucket interval width */
|
|
543
|
+
minBucketWidth?: number;
|
|
544
|
+
/** Explicit opt-in to allow steps below `minStep` (emits a configuration warning; `step <= 0` still rejected) */
|
|
545
|
+
allowNarrowStep?: boolean;
|
|
546
|
+
/** Explicit opt-in to allow range bucketing on high-sensitivity fields */
|
|
547
|
+
allowSensitiveBucket?: boolean;
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Configuration for tier / threshold numeric shadow range bucketing.
|
|
551
|
+
*
|
|
552
|
+
* @security Deterministic Shadow-Bucket Range Index:
|
|
553
|
+
* Threshold buckets leak bucket membership frequency and ordering across tiers (NOT zero-leakage).
|
|
554
|
+
*
|
|
555
|
+
* For high-sensitivity fields (`salary`, `age`, `creditScore`, etc.), use broad intervals
|
|
556
|
+
* (e.g. `[0, 25000, 50000, 100000, 250000]`) rather than narrow bands, or use unindexed AES-256-GCM.
|
|
557
|
+
*/
|
|
558
|
+
interface ITierRangeBucketConfig {
|
|
559
|
+
type: 'tier' | 'threshold';
|
|
560
|
+
thresholds: number[];
|
|
561
|
+
/** Minimum allowed interval gap between consecutive thresholds (defaults to `DEFAULT_MIN_BUCKET_STEP` = 100) */
|
|
562
|
+
minStep?: number;
|
|
563
|
+
/** Alias for `minStep`: minimum allowed threshold gap width */
|
|
564
|
+
minBucketWidth?: number;
|
|
565
|
+
/** Explicit opt-in to allow threshold gaps below `minStep` (emits a configuration warning) */
|
|
566
|
+
allowNarrowStep?: boolean;
|
|
567
|
+
/** Explicit opt-in to allow range bucketing on high-sensitivity fields */
|
|
568
|
+
allowSensitiveBucket?: boolean;
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Union type of all shadow range bucket configurations.
|
|
572
|
+
*/
|
|
573
|
+
type TRangeBucketConfig = IDateRangeBucketConfig | ISteppedRangeBucketConfig | ITierRangeBucketConfig;
|
|
551
574
|
/**
|
|
552
575
|
* Keyring mapping key IDs to HMAC CryptoKeys and their lifecycle status.
|
|
553
576
|
* Exactly one key must be 'active', matching activeKid.
|
|
@@ -562,83 +585,211 @@ interface IBlindIndexKeyring {
|
|
|
562
585
|
algorithm?: string;
|
|
563
586
|
}>;
|
|
564
587
|
}
|
|
588
|
+
|
|
565
589
|
/**
|
|
566
|
-
*
|
|
590
|
+
* Historical or alternate version configuration for multi-version blind-index query expansion.
|
|
567
591
|
*/
|
|
568
|
-
interface
|
|
569
|
-
/**
|
|
570
|
-
|
|
571
|
-
/**
|
|
572
|
-
|
|
573
|
-
/**
|
|
574
|
-
|
|
592
|
+
interface IBlindIndexVersionConfig extends INormalizeOptions {
|
|
593
|
+
/** Schema or token version identifier */
|
|
594
|
+
version?: string | number;
|
|
595
|
+
/** Optional version tag prefix (false = unprefixed hex, true = `${version}:`, string = `${versionTag}:`) */
|
|
596
|
+
versionTag?: string | boolean;
|
|
597
|
+
/** Also emit legacy unscoped tokens for this version entry */
|
|
598
|
+
allowLegacyUnscopedTokens?: boolean;
|
|
599
|
+
/** Alias for allowLegacyUnscopedTokens */
|
|
600
|
+
legacyUnscopedTokens?: boolean;
|
|
575
601
|
}
|
|
576
|
-
/**
|
|
577
|
-
* Supported SQL / persistence dialects for query rendering.
|
|
578
|
-
*/
|
|
579
|
-
type TPersistenceDialect = 'postgres' | 'postgresql' | 'sqlite' | 'mysql';
|
|
580
602
|
/**
|
|
581
603
|
* Blind-index field configuration options.
|
|
582
604
|
*/
|
|
583
|
-
interface IBlindIndexFieldConfig {
|
|
605
|
+
interface IBlindIndexFieldConfig extends INormalizeOptions {
|
|
584
606
|
/** Custom target persistence column name (defaults to `${fieldName}_bidx`) */
|
|
585
607
|
column?: string;
|
|
608
|
+
/** Optional custom trigram column name (defaults to `${fieldName}_trigrams`) */
|
|
609
|
+
trigramColumn?: string;
|
|
610
|
+
/** Blind index keyring */
|
|
611
|
+
keyring: IBlindIndexKeyring;
|
|
612
|
+
/** Optional schema or token version identifier */
|
|
613
|
+
version?: string | number;
|
|
614
|
+
/** Optional version tag prefix for matching versioned tokens */
|
|
615
|
+
versionTag?: string | boolean;
|
|
616
|
+
/** Historical token versions/configs to query alongside the current version */
|
|
617
|
+
previousVersions?: Array<string | number | IBlindIndexVersionConfig>;
|
|
618
|
+
/** Allow matching legacy unscoped tokens alongside domain-separated tokens during migration */
|
|
619
|
+
allowLegacyUnscopedTokens?: boolean;
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* Trigram substring search field configuration options.
|
|
623
|
+
*/
|
|
624
|
+
interface ITrigramFieldConfig extends INormalizeOptions {
|
|
625
|
+
/** Custom target persistence column name (defaults to `${fieldName}_trigrams`) */
|
|
626
|
+
column?: string;
|
|
586
627
|
/** Blind index keyring */
|
|
587
628
|
keyring: IBlindIndexKeyring;
|
|
629
|
+
/** Optional schema or token version identifier */
|
|
630
|
+
version?: string | number;
|
|
631
|
+
/** Optional version tag prefix for matching versioned tokens */
|
|
632
|
+
versionTag?: string | boolean;
|
|
633
|
+
/** Historical token versions/configs to query alongside the current version */
|
|
634
|
+
previousVersions?: Array<string | number | IBlindIndexVersionConfig>;
|
|
635
|
+
/** Allow matching legacy unscoped tokens alongside domain-separated tokens during migration */
|
|
636
|
+
allowLegacyUnscopedTokens?: boolean;
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* Range bucket persistence field configuration options.
|
|
640
|
+
*
|
|
641
|
+
* @security Deterministic Shadow-Bucket Range Index: reveals bucket frequency distributions
|
|
642
|
+
* and relative ordering; not IND-CPA / not zero-leakage. Avoid narrow widths on
|
|
643
|
+
* high-sensitivity fields (`salary`, `age`, `birthDate`, `creditScore`).
|
|
644
|
+
*/
|
|
645
|
+
interface IRangeBucketFieldConfig {
|
|
646
|
+
/** Custom target persistence column name (defaults to `${fieldName}_bucket`) */
|
|
647
|
+
column?: string;
|
|
648
|
+
/** Range bucketing configuration ('date', 'stepped', or 'tier') */
|
|
649
|
+
config: TRangeBucketConfig;
|
|
650
|
+
/** Explicit opt-in to allow range bucketing on high-sensitivity fields */
|
|
651
|
+
allowSensitiveBucket?: boolean;
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* Options for computing blind index HMAC-SHA256 tokens, supporting normalization and domain separation.
|
|
655
|
+
*/
|
|
656
|
+
interface IBlindIndexOptions extends INormalizeOptions {
|
|
657
|
+
/** Field name domain context (prevents cross-field token equality) */
|
|
658
|
+
field?: string;
|
|
659
|
+
/** Token type domain context ('eq' for exact equality, 'tri' for substring trigrams) */
|
|
660
|
+
type?: 'eq' | 'tri';
|
|
661
|
+
/** Optional Key Identifier */
|
|
662
|
+
kid?: string;
|
|
663
|
+
/** Optional schema or token version identifier */
|
|
664
|
+
version?: string | number;
|
|
665
|
+
/** Optional version tag prefix for the generated token (e.g. 'v1' produces 'v1:<token>') */
|
|
666
|
+
versionTag?: string | boolean;
|
|
667
|
+
/**
|
|
668
|
+
* PBKDF2 iteration count for blind index HMAC key derivation from passphrase strings (default: 310,000).
|
|
669
|
+
* Edge runtimes such as Cloudflare Workers cap PBKDF2 at 100,000 iterations.
|
|
670
|
+
*/
|
|
671
|
+
kdfIterations?: number;
|
|
588
672
|
}
|
|
589
673
|
/**
|
|
590
674
|
* Options for rewriteEncryptedFilters.
|
|
591
675
|
*/
|
|
592
|
-
interface IEncryptedFilterRewriteOptions {
|
|
676
|
+
interface IEncryptedFilterRewriteOptions extends INormalizeOptions {
|
|
593
677
|
/** Map of field names to their blind-index column configuration or keyring */
|
|
594
678
|
blindIndexFields?: Record<string, IBlindIndexFieldConfig | IBlindIndexKeyring>;
|
|
679
|
+
/** Map of field names to their trigram substring search configuration or keyring */
|
|
680
|
+
trigramFields?: Record<string, ITrigramFieldConfig | IBlindIndexKeyring>;
|
|
681
|
+
/** Map of field names to their range bucket configuration or TRangeBucketConfig */
|
|
682
|
+
rangeBucketFields?: Record<string, IRangeBucketFieldConfig | TRangeBucketConfig>;
|
|
683
|
+
/** Direct map of field names to TRangeBucketConfig (alias for rangeBucketFields) */
|
|
684
|
+
rangeBuckets?: Record<string, TRangeBucketConfig>;
|
|
685
|
+
/** Optional known bucket keys present in persistence store */
|
|
686
|
+
knownBuckets?: Record<string, Iterable<string>>;
|
|
595
687
|
/** Maximum allowable candidate tokens across all expanded values (defaults to 500) */
|
|
596
688
|
maxCandidateTokens?: number;
|
|
597
|
-
/**
|
|
598
|
-
|
|
599
|
-
/**
|
|
600
|
-
|
|
601
|
-
/**
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
689
|
+
/** Optional normalization options override */
|
|
690
|
+
normalizeOptions?: INormalizeOptions;
|
|
691
|
+
/** Explicit opt-in to allow range bucketing on high-sensitivity fields */
|
|
692
|
+
allowSensitiveBucket?: boolean;
|
|
693
|
+
/** Generic fields map that may contain blindIndex, trigrams, and rangeBuckets */
|
|
694
|
+
fields?: Record<string, any>;
|
|
695
|
+
/** Optional schema or token version identifier for generated query tokens */
|
|
696
|
+
version?: string | number;
|
|
697
|
+
/** Optional version tag prefix for generated query tokens (e.g. true -> `${version}:`, or explicit 'v2') */
|
|
698
|
+
versionTag?: string | boolean;
|
|
699
|
+
/** Historical token versions/configs to expand into query candidates during rolling re-indexing */
|
|
700
|
+
previousVersions?: Array<string | number | IBlindIndexVersionConfig>;
|
|
701
|
+
/** When true, also emits legacy unscoped equality tokens alongside field+type scoped tokens (default: false) */
|
|
702
|
+
allowLegacyUnscopedTokens?: boolean;
|
|
703
|
+
/** Expected persisted token scheme identifier (from computeBlindIndexSchemeId); throws ERR_BIDX_SCHEME_MISMATCH if options diverge */
|
|
704
|
+
expectedTokenScheme?: string;
|
|
610
705
|
}
|
|
611
706
|
/**
|
|
612
707
|
* Result returned by rewriteEncryptedFilters.
|
|
613
708
|
*/
|
|
614
|
-
interface
|
|
615
|
-
/**
|
|
616
|
-
|
|
709
|
+
interface IRewrittenEncryptedFilters {
|
|
710
|
+
/** Transformed filter or array of filters with expanded blind-index candidate tokens */
|
|
711
|
+
filters: IDataFilter | IDataFilter[];
|
|
617
712
|
/** Total candidate tokens generated across all filters */
|
|
618
713
|
totalCandidateTokens: number;
|
|
619
|
-
/**
|
|
620
|
-
|
|
621
|
-
paramOffset?: number;
|
|
622
|
-
maxParametersPerClause?: number;
|
|
623
|
-
}): IRenderedSqlClause;
|
|
714
|
+
/** Deterministic token scheme identifier covering normalization options, scope, and framing */
|
|
715
|
+
tokenSchemeId?: string;
|
|
624
716
|
}
|
|
717
|
+
/**
|
|
718
|
+
* Alias for IRewrittenEncryptedFilters for backward compatibility.
|
|
719
|
+
*/
|
|
720
|
+
type IRewrittenPersistenceQuery = IRewrittenEncryptedFilters;
|
|
625
721
|
/**
|
|
626
722
|
* Options for reencryptBatch.
|
|
627
723
|
*/
|
|
628
|
-
interface IReencryptBatchOptions<TRow = any> {
|
|
724
|
+
interface IReencryptBatchOptions<TRow = any> extends INormalizeOptions {
|
|
629
725
|
/** Target Key Identifier to migrate payloads to */
|
|
630
726
|
targetKid: string;
|
|
631
727
|
/** Keyring containing source keys and target key */
|
|
632
728
|
keyring: Record<string, CryptoKey | string | Uint8Array | (() => Promise<CryptoKey>)>;
|
|
633
729
|
/** Model fields containing IEncryptedPayload envelopes */
|
|
634
730
|
encryptedFields: string[];
|
|
731
|
+
/** Model fields to compute and migrate trigram substring search tokens for */
|
|
732
|
+
trigramFields?: string[];
|
|
733
|
+
/** Direct blind index keyring for blind index and trigram computation */
|
|
734
|
+
blindIndexKeyring?: IBlindIndexKeyring;
|
|
635
735
|
/** Optional blind index configuration for sensitive fields */
|
|
636
736
|
blindIndex?: {
|
|
637
|
-
fields
|
|
737
|
+
fields?: string[];
|
|
738
|
+
/** Optional fields to compute and migrate trigram substring search tokens for */
|
|
739
|
+
trigramFields?: string[];
|
|
638
740
|
keyring: IBlindIndexKeyring;
|
|
639
741
|
/** Optional mapping from field name to persistence column name (defaults to `${fieldName}_bidx`) */
|
|
640
742
|
columnMap?: Record<string, string>;
|
|
743
|
+
/**
|
|
744
|
+
* @deprecated Field+type domain separation (`{ field, type: 'eq' }`) is now enabled by default.
|
|
745
|
+
* Use `legacyUnscopedTokens: true` to explicitly opt out for legacy unscoped datasets.
|
|
746
|
+
*/
|
|
747
|
+
domainSeparation?: boolean;
|
|
748
|
+
/** Opt out of field+type domain separation for legacy unscoped blind-index columns (default: false) */
|
|
749
|
+
legacyUnscopedTokens?: boolean;
|
|
750
|
+
/** Optional normalization locale */
|
|
751
|
+
locale?: string;
|
|
752
|
+
/** Optional normalization ASCII folding */
|
|
753
|
+
asciiFold?: boolean;
|
|
754
|
+
/** Optional custom normalizer */
|
|
755
|
+
normalizer?: (value: string) => string;
|
|
756
|
+
/** Optional stable identifier for custom normalizer */
|
|
757
|
+
normalizerId?: string;
|
|
758
|
+
/** Optional schema or token version identifier */
|
|
759
|
+
version?: string | number;
|
|
760
|
+
/** Optional version tag prefix for regenerated tokens */
|
|
761
|
+
versionTag?: string | boolean;
|
|
762
|
+
/** Optional column name for version metadata (defaults to `${bidxCol}_version`) */
|
|
763
|
+
versionColumn?: string;
|
|
764
|
+
/** Optional mapping from field name to version column name */
|
|
765
|
+
versionColumnMap?: Record<string, string>;
|
|
766
|
+
/** Persist token scheme identifier (`computeBlindIndexSchemeId`) into `${col}_scheme` (or `schemeColumn`) */
|
|
767
|
+
persistScheme?: boolean;
|
|
768
|
+
/** Optional column name for persisted token scheme identifier (defaults to `${bidxCol}_scheme`) */
|
|
769
|
+
schemeColumn?: string;
|
|
770
|
+
/** Optional mapping from field name to scheme column name */
|
|
771
|
+
schemeColumnMap?: Record<string, string>;
|
|
641
772
|
};
|
|
773
|
+
/** Optional normalization options override */
|
|
774
|
+
normalizeOptions?: INormalizeOptions;
|
|
775
|
+
/** Opt out of field+type domain separation for legacy unscoped blind-index columns (default: false) */
|
|
776
|
+
legacyUnscopedTokens?: boolean;
|
|
777
|
+
/** Optional schema or token version identifier for regenerated blind index tokens */
|
|
778
|
+
tokenVersion?: string | number;
|
|
779
|
+
/** Optional version tag prefix for regenerated blind index tokens */
|
|
780
|
+
versionTag?: string | boolean;
|
|
781
|
+
/** Persist token scheme identifier (`computeBlindIndexSchemeId`) alongside regenerated tokens */
|
|
782
|
+
persistTokenScheme?: boolean;
|
|
783
|
+
/** Select/re-index rows whose persisted token version matches any value in this list (even if envelope kid === targetKid) */
|
|
784
|
+
staleTokenVersions?: Array<string | number | null | undefined>;
|
|
785
|
+
/** Re-index stale/missing blind-index tokens even if envelope kid === targetKid (default: true when version/versionTag/persistScheme/staleTokenVersions is set) */
|
|
786
|
+
reindexStaleTokens?: boolean;
|
|
787
|
+
/** Maximum PBKDF2 iterations allowed during key derivation (default: 1,000,000) */
|
|
788
|
+
maxAllowedIterations?: number;
|
|
789
|
+
/** Maximum distinct uncached PBKDF2 salt derivations permitted per batch (default: 5 in strict mode; queued up to safety cap in non-strict mode) */
|
|
790
|
+
maxSaltDerivations?: number;
|
|
791
|
+
/** Whether to allow insecure KDF (kdf: 'none') under strict mode */
|
|
792
|
+
allowInsecureKdf?: boolean;
|
|
642
793
|
/** Concurrency version field name on row (default: 'updatedAt') */
|
|
643
794
|
versionField?: string;
|
|
644
795
|
/** Primary key extractor callback (defaults to (row) => row.id) */
|
|
@@ -649,6 +800,28 @@ interface IReencryptBatchOptions<TRow = any> {
|
|
|
649
800
|
baseAad?: string;
|
|
650
801
|
aadFields?: string[];
|
|
651
802
|
buildAad?: (row: TRow, fieldName: string) => string | Uint8Array | undefined;
|
|
803
|
+
/** Error handling strategy when decryption or processing of a row/field fails (default: 'abort' in reencryptBatch, 'record' in reencryptDataset) */
|
|
804
|
+
onRowError?: 'abort' | 'skip' | 'record';
|
|
805
|
+
/** Fail-fast on first row/field decryption or processing error (overrides onRowError when true; default: false in reencryptDataset) */
|
|
806
|
+
abortOnError?: boolean;
|
|
807
|
+
/** Key derivation algorithm for string passphrases (default: 'pbkdf2') */
|
|
808
|
+
kdf?: 'pbkdf2' | 'hkdf' | 'none';
|
|
809
|
+
/** PBKDF2 iterations for string passphrases (default: 310,000) */
|
|
810
|
+
kdfIterations?: number;
|
|
811
|
+
/** Optional salt for string passphrases (default: random 16 bytes per target key) */
|
|
812
|
+
kdfSalt?: string | Uint8Array;
|
|
813
|
+
/** Force fresh PBKDF2 salt generation per row instead of sharing across batch/dataset */
|
|
814
|
+
perRowSalt?: boolean;
|
|
815
|
+
/** Cancellation signal for cooperative abort */
|
|
816
|
+
signal?: AbortSignal;
|
|
817
|
+
/** Strict mode: requires version field for CAS concurrency protection; fails if missing */
|
|
818
|
+
strict?: boolean;
|
|
819
|
+
/** Verify authenticity of envelopes already claiming `targetKid` against `targetKey` (default: true) */
|
|
820
|
+
verifyTargetKid?: boolean;
|
|
821
|
+
/** Attempt recovery using other keys in `keyring` when an envelope claiming `targetKid` fails `targetKey` authentication (default: false) */
|
|
822
|
+
recoverForgedTargetKid?: boolean;
|
|
823
|
+
/** Explicitly allows legacy fallback decryption without AAD when an envelope omits AAD or sets `aad: false` in non-strict mode. Defaults to false. */
|
|
824
|
+
allowUnboundAadFallback?: boolean;
|
|
652
825
|
}
|
|
653
826
|
/**
|
|
654
827
|
* Result returned by reencryptBatch.
|
|
@@ -666,6 +839,13 @@ interface IReencryptBatchResult<TRow = any> {
|
|
|
666
839
|
scannedCount: number;
|
|
667
840
|
migratedCount: number;
|
|
668
841
|
skippedCount: number;
|
|
842
|
+
failedRows: Array<{
|
|
843
|
+
id: any;
|
|
844
|
+
field: string;
|
|
845
|
+
error: Error | string;
|
|
846
|
+
}>;
|
|
847
|
+
/** Whether batch execution was aborted early via AbortSignal */
|
|
848
|
+
aborted?: boolean;
|
|
669
849
|
}
|
|
670
850
|
/**
|
|
671
851
|
* Universal orchestrator options for dataset re-encryption.
|
|
@@ -689,8 +869,8 @@ interface IReencryptDatasetOptions<TRow = any> extends IReencryptBatchOptions<TR
|
|
|
689
869
|
updateRow: (rowId: string | number, patch: Partial<TRow>, expectedVersion: any) => Promise<boolean>;
|
|
690
870
|
/** Callback to refetch a single conflicting record during optimistic concurrency retries */
|
|
691
871
|
refetchRow?: (rowId: string | number) => Promise<TRow | null>;
|
|
692
|
-
/** Progress telemetry callback */
|
|
693
|
-
onProgress?: (progress: IMigrationProgress) => void
|
|
872
|
+
/** Progress telemetry callback (can be async to persist checkpoints) */
|
|
873
|
+
onProgress?: (progress: IMigrationProgress) => void | Promise<void>;
|
|
694
874
|
/** Cancellation signal for cooperative abort */
|
|
695
875
|
signal?: AbortSignal;
|
|
696
876
|
}
|
|
@@ -702,8 +882,18 @@ interface IMigrationProgress {
|
|
|
702
882
|
migratedRows: number;
|
|
703
883
|
skippedRows: number;
|
|
704
884
|
conflictRows: number;
|
|
885
|
+
failedRows?: number;
|
|
886
|
+
/** Unique identifiers of rows that encountered errors so far */
|
|
887
|
+
failedRowIds?: any[];
|
|
705
888
|
currentCursor?: string | number;
|
|
706
889
|
percentComplete?: number;
|
|
890
|
+
/** Persistent checkpoint payload */
|
|
891
|
+
checkpoint?: {
|
|
892
|
+
lastProcessedId: any;
|
|
893
|
+
count: number;
|
|
894
|
+
};
|
|
895
|
+
lastProcessedId?: any;
|
|
896
|
+
count?: number;
|
|
707
897
|
}
|
|
708
898
|
/**
|
|
709
899
|
* Final execution report returned by reencryptDataset.
|
|
@@ -717,32 +907,330 @@ interface IMigrationSummary {
|
|
|
717
907
|
lastProcessedCursor?: string | number;
|
|
718
908
|
completed: boolean;
|
|
719
909
|
durationMs: number;
|
|
910
|
+
failedRows?: Array<{
|
|
911
|
+
id: any;
|
|
912
|
+
field: string;
|
|
913
|
+
error: Error | string;
|
|
914
|
+
}>;
|
|
915
|
+
/** Unique identifiers of rows that failed during migration */
|
|
916
|
+
failedRowIds?: any[];
|
|
917
|
+
/** Whether the migration was cancelled/aborted via AbortSignal */
|
|
918
|
+
aborted?: boolean;
|
|
720
919
|
}
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
interface
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
920
|
+
/**
|
|
921
|
+
* Configuration options for CSearchIndex.
|
|
922
|
+
*/
|
|
923
|
+
interface ISearchIndexOptions extends INormalizeOptions {
|
|
924
|
+
minSearchLength?: number;
|
|
925
|
+
rangeBuckets?: Record<string, TRangeBucketConfig>;
|
|
926
|
+
shadowBuckets?: Record<string, TRangeBucketConfig>;
|
|
927
|
+
/** Explicit opt-in to allow range bucketing on high-sensitivity fields */
|
|
928
|
+
allowSensitiveBucket?: boolean;
|
|
929
|
+
idKey?: string;
|
|
930
|
+
/**
|
|
931
|
+
* Whether to allow matching against unscoped legacy blind index tokens (without field domain separation).
|
|
932
|
+
* Defaults to false for security (prevents cross-field and equality-vs-trigram token collisions).
|
|
933
|
+
*/
|
|
934
|
+
allowLegacyUnscopedTokens?: boolean;
|
|
935
|
+
/**
|
|
936
|
+
* PBKDF2 iteration count for deriving the blind index HMAC key from string key material (default: 310,000 per OWASP).
|
|
937
|
+
* Edge/serverless runtimes such as Cloudflare Workers cap WebCrypto PBKDF2 at 100,000 iterations and require lowering this (e.g., 100_000).
|
|
938
|
+
*/
|
|
939
|
+
kdfIterations?: number;
|
|
940
|
+
/** Optional schema or token version identifier */
|
|
941
|
+
version?: string | number;
|
|
942
|
+
/** Optional version tag prefix for generated blind-index tokens */
|
|
943
|
+
versionTag?: string | boolean;
|
|
944
|
+
}
|
|
945
|
+
/**
|
|
946
|
+
* Per-field search index entry stored for an indexed row.
|
|
947
|
+
*/
|
|
948
|
+
interface ISearchIndexRowEntry {
|
|
949
|
+
token: string;
|
|
950
|
+
trigrams: Set<string>;
|
|
951
|
+
bucket?: string;
|
|
952
|
+
}
|
|
953
|
+
/**
|
|
954
|
+
* Evaluation context passed by CSearchIndex to searchIndexEvaluator helpers.
|
|
955
|
+
*/
|
|
956
|
+
interface ISearchIndexEvalContext {
|
|
957
|
+
options: ISearchIndexOptions;
|
|
958
|
+
minSearchLength: number;
|
|
959
|
+
indexedFields: Set<string>;
|
|
960
|
+
getEntry: (row: any, field: string) => ISearchIndexRowEntry | undefined;
|
|
961
|
+
getRowFieldValue: (row: any, key: string) => any;
|
|
962
|
+
computeToken: (term: any, fieldOrOptions?: string | IBlindIndexOptions) => Promise<string>;
|
|
963
|
+
computeTrigramTokens: (term: any, fieldOrOptions?: string | IBlindIndexOptions) => Promise<Set<string>>;
|
|
964
|
+
resolveBucketsForRange: (operator: string, targetValue: any, fieldOrConfig: string | TRangeBucketConfig, knownBuckets?: Iterable<string>, fieldName?: string) => Set<string>;
|
|
965
|
+
getBucketsForField: (field: string) => Set<string>;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
/**
|
|
969
|
+
* Shared constructor, keyring, KDF, policy, and asymmetric-security options
|
|
970
|
+
* supported by all `AEncryptionProvider` subclasses and `createEncryptionProvider`.
|
|
971
|
+
*/
|
|
972
|
+
interface IBaseEncryptionProviderOptions {
|
|
973
|
+
/** Built-in Keyring dictionary mapping Key Identifiers (kid) to keys or key provider functions */
|
|
974
|
+
keys?: Record<string, TKeyProvider | IKeyPair>;
|
|
975
|
+
/** Active key identifier from `keys` to use for all outbound encryption operations */
|
|
976
|
+
activeKid?: string;
|
|
977
|
+
/** Optional Key Identifier for multi-role key routing and key rotation */
|
|
978
|
+
kid?: string;
|
|
979
|
+
keyId?: string;
|
|
980
|
+
/** Whitelist of allowed Key Identifiers (kid). */
|
|
981
|
+
allowedKids?: string[];
|
|
982
|
+
/** Whitelist of permitted cryptographic algorithms (e.g. ['AES-GCM']). Defaults to ['AES-GCM'] in strict mode. */
|
|
983
|
+
allowedAlgorithms?: TEncryptionAlgorithm[];
|
|
984
|
+
/**
|
|
985
|
+
* Dedicated HMAC key for search indexing and blind index computation.
|
|
986
|
+
* Required when searchIndex is enabled. Must never default to or share the AES data encryption key.
|
|
987
|
+
*/
|
|
988
|
+
hmacKey?: TKeyProvider;
|
|
989
|
+
/**
|
|
990
|
+
* Key Derivation Function strategy ('none' | 'pbkdf2' | 'hkdf'). Defaults to 'pbkdf2'.
|
|
991
|
+
* - 'pbkdf2': Recommended for human passphrases/passwords (OWASP recommended with work factor iterations).
|
|
992
|
+
* - 'hkdf': For deriving subkeys from high-entropy cryptographic keys or secrets (not for low-entropy human passwords).
|
|
993
|
+
* - 'none': Direct key import for raw high-entropy 256-bit symmetric keys or CryptoKeys.
|
|
994
|
+
*/
|
|
995
|
+
kdf?: TKdfStrategy;
|
|
996
|
+
/**
|
|
997
|
+
* Number of PBKDF2 iterations for cipher key derivation and CSearchIndex blind-index HMAC derivation
|
|
998
|
+
* (default: 310,000 per OWASP recommendation).
|
|
999
|
+
* Edge/serverless runtimes such as Cloudflare Workers cap WebCrypto PBKDF2 at 100,000 iterations and will throw
|
|
1000
|
+
* NotSupportedError on the server unless lowered (e.g., `100_000`) or `kdf: 'hkdf'` is used for high-entropy secrets.
|
|
1001
|
+
*/
|
|
1002
|
+
kdfIterations?: number;
|
|
1003
|
+
/** Hash algorithm for PBKDF2 or HKDF ('SHA-256' | 'SHA-512', default: 'SHA-256') */
|
|
1004
|
+
kdfHash?: TKdfHash;
|
|
1005
|
+
/** Optional static salt for KDF. If omitted, a cryptographically secure random salt is generated and included in the envelope. */
|
|
1006
|
+
kdfSalt?: string | Uint8Array | ArrayBuffer;
|
|
1007
|
+
/** Optional context/info string or buffer for HKDF key derivation */
|
|
1008
|
+
info?: string | Uint8Array | ArrayBuffer;
|
|
1009
|
+
/** Whether to allow legacy insecure KDF ('none' / raw SHA-256) when strict mode is active. Defaults to false. */
|
|
1010
|
+
allowInsecureKdf?: boolean;
|
|
1011
|
+
/** Explicitly allows legacy fallback decryption without AAD when an envelope omits AAD or sets `aad: false` in non-strict mode. Defaults to false. */
|
|
1012
|
+
allowUnboundAadFallback?: boolean;
|
|
1013
|
+
/** Maximum allowable PBKDF2 iterations during decryption (default: 1,000,000). Envelopes exceeding this ceiling are rejected with ERR_EXCESSIVE_KDF_ITERATIONS. */
|
|
1014
|
+
maxAllowedIterations?: number;
|
|
1015
|
+
/** Maximum distinct uncached PBKDF2 salt derivations permitted per batch/call (default: 5 in strict mode; queued up to safety cap in non-strict mode). */
|
|
1016
|
+
maxSaltDerivations?: number;
|
|
1017
|
+
/** Optional key-pinning store for Trust On First Use (TOFU) public key verification in asymmetric providers */
|
|
1018
|
+
pinningStore?: IKeyPinningStore;
|
|
1019
|
+
/** Entity / peer identifier used when pinning or verifying recipient public keys (defaults to resolved kid/keyId if omitted) */
|
|
1020
|
+
pinEntityId?: string;
|
|
1021
|
+
/** Additional options forwarded to CKeyManager.verifyAndPinKey (trustedAuthorities, fetchAttestation, onPinChange, clockSkewMs, etc.) */
|
|
1022
|
+
pinningOptions?: Partial<Omit<IVerifyAndPinOptions, 'store'>> & {
|
|
1023
|
+
store?: IKeyPinningStore;
|
|
1024
|
+
};
|
|
1025
|
+
/** Optional ECDSA private key used to sign outbound RSA/ECDH envelopes */
|
|
1026
|
+
senderSigningPrivateKey?: CryptoKey;
|
|
1027
|
+
/** Optional ECDSA public key used to verify inbound RSA/ECDH envelope signatures */
|
|
1028
|
+
senderVerifyPublicKey?: CryptoKey;
|
|
1029
|
+
/** When true, RSA/ECDH decryption rejects envelopes without a valid sender signature */
|
|
1030
|
+
requireSenderSignature?: boolean;
|
|
1031
|
+
}
|
|
1032
|
+
/**
|
|
1033
|
+
* Shared runtime envelope, AAD, strict-validation, and error-handling options
|
|
1034
|
+
* common to both per-call `IEncryptionContext` and provider-level `IProviderEncryptionOptions`.
|
|
1035
|
+
*/
|
|
1036
|
+
interface IEncryptionOperationOptions extends IBaseEncryptionProviderOptions {
|
|
1037
|
+
/** Secret key, passphrase, CryptoKey, key pair, or async key provider function */
|
|
1038
|
+
key?: TKeyProvider | IKeyPair;
|
|
1039
|
+
/**
|
|
1040
|
+
* Whether to bind the request context (HTTP method and canonical normalized URL as `req:${method}:${normalizedUrl}`) into AEAD Authenticated Additional Data (AAD) on outer transport payloads.
|
|
1041
|
+
* Defaults to false (opt-in). When enabled (true), mitigates replay and cross-endpoint confusion attacks on outer transport envelopes.
|
|
1042
|
+
* Decoupled from persistent record/field envelopes to ensure safe GET vs POST/PUT interoperability.
|
|
1043
|
+
*/
|
|
1044
|
+
bindRequestContextAad?: boolean;
|
|
1045
|
+
/** Whitelist of specific field names to encrypt/decrypt (e.g. ['name', 'surname']). Any unlisted field remains plaintext. */
|
|
1046
|
+
fields?: string[];
|
|
1047
|
+
/** Whitelist of field names permitted to remain unencrypted in strict mode without triggering security violations (e.g. ['id', '_id']). */
|
|
1048
|
+
unencryptedFields?: string[];
|
|
1049
|
+
/**
|
|
1050
|
+
* Enforces strict encryption validation. When true:
|
|
1051
|
+
* 1. Any field in `fields` that is NOT an encrypted envelope triggers a decryption error.
|
|
1052
|
+
* 2. Envelope algorithm MUST match `allowedAlgorithms` (defaults to ['AES-GCM']).
|
|
1053
|
+
* 3. Envelope `kid` (if present) MUST match `allowedKids`.
|
|
1054
|
+
*/
|
|
1055
|
+
strict?: boolean;
|
|
1056
|
+
/**
|
|
1057
|
+
* Hook invoked whenever decryption fails for an individual field or row.
|
|
1058
|
+
* Can return a fallback cell value (e.g. sentinel or marker), or string/boolean.
|
|
1059
|
+
*/
|
|
1060
|
+
onDecryptError?: ((info: IDecryptErrorInfo) => any) | boolean | string;
|
|
1061
|
+
/**
|
|
1062
|
+
* Authenticated Additional Data (AAD) bound to the ciphertext to prevent field/record swapping.
|
|
1063
|
+
* Can be static string/buffer or dynamic callback evaluated per record and field.
|
|
1064
|
+
*/
|
|
1065
|
+
aad?: string | Uint8Array | ArrayBuffer | ((record: any, field: string) => string | Uint8Array | ArrayBuffer);
|
|
1066
|
+
/** Sibling record fields to deterministically bind into AEAD additional data (e.g. ['contact_id', 'version']) */
|
|
1067
|
+
aadFields?: string[];
|
|
1068
|
+
/** Optional base AAD prefix when aadFields or dynamic aad is enabled */
|
|
1069
|
+
baseAad?: string;
|
|
1070
|
+
/** Whether to encrypt/decrypt individual values while preserving JSON keys (default: true) */
|
|
1071
|
+
valueEncryption?: boolean;
|
|
1072
|
+
/** Optional public key for asymmetric providers */
|
|
1073
|
+
publicKey?: CryptoKey;
|
|
1074
|
+
/** Optional private key for asymmetric providers */
|
|
1075
|
+
privateKey?: CryptoKey;
|
|
1076
|
+
/** Optional recipient public key for asymmetric/hybrid encryption */
|
|
1077
|
+
recipientPublicKey?: CryptoKey;
|
|
1078
|
+
/** Optional recipient private key for asymmetric/hybrid decryption */
|
|
1079
|
+
recipientPrivateKey?: CryptoKey;
|
|
1080
|
+
/** Elliptic curve name for ECDH ('P-256' | 'P-384' | 'P-521') */
|
|
1081
|
+
curve?: 'P-256' | 'P-384' | 'P-521';
|
|
1082
|
+
}
|
|
1083
|
+
interface IEncryptionContext extends IEncryptionOperationOptions {
|
|
1084
|
+
url?: string;
|
|
1085
|
+
method?: string;
|
|
1086
|
+
isServer?: boolean;
|
|
1087
|
+
}
|
|
1088
|
+
/**
|
|
1089
|
+
* Context options for single scalar field encryption/decryption with bound AAD.
|
|
1090
|
+
*/
|
|
1091
|
+
interface IFieldEncryptionContext extends Omit<IEncryptionContext, 'aadFields'> {
|
|
1092
|
+
/** Record identifier to bind into AAD */
|
|
1093
|
+
recordId?: string | number;
|
|
1094
|
+
/** Target field name being encrypted/decrypted */
|
|
1095
|
+
fieldName?: string;
|
|
1096
|
+
/** Sibling record fields (map or array of keys) to deterministically bind into AEAD */
|
|
1097
|
+
aadFields?: Record<string, any> | string[];
|
|
1098
|
+
/** Optional base AAD prefix */
|
|
1099
|
+
baseAad?: string;
|
|
1100
|
+
}
|
|
1101
|
+
interface IEncryptionProvider {
|
|
1102
|
+
encrypt(data: any, options?: IEncryptionContext): Promise<IEncryptedPayload | any>;
|
|
1103
|
+
decrypt(payload: IEncryptedPayload | any, options?: IEncryptionContext): Promise<any>;
|
|
1104
|
+
/** Encrypts a single scalar value with contextual AAD binding */
|
|
1105
|
+
encryptField?(value: any, context?: IFieldEncryptionContext): Promise<IEncryptedPayload>;
|
|
1106
|
+
/** Decrypts a single scalar field envelope with contextual AAD */
|
|
1107
|
+
decryptField?(envelope: IEncryptedPayload, context?: IFieldEncryptionContext): Promise<any>;
|
|
1108
|
+
/** Computes deterministic HMAC-SHA256 blind index hash */
|
|
1109
|
+
computeBlindIndex?(value: any, hmacKey?: CryptoKey | TKeyProvider): Promise<string>;
|
|
1110
|
+
warmupKey?(options?: IEncryptionContext): Promise<void>;
|
|
1111
|
+
isEncrypted?(payload: any): boolean;
|
|
1112
|
+
setDefaultKey?(key: TKeyProvider | IKeyPair): void;
|
|
1113
|
+
setKeyring?(keys: Record<string, TKeyProvider | IKeyPair>, activeKid?: string): void;
|
|
1114
|
+
getKeyring?(): Record<string, TKeyProvider | IKeyPair> | undefined;
|
|
1115
|
+
setActiveKid?(kid: string): void;
|
|
1116
|
+
getActiveKid?(): string | undefined;
|
|
1117
|
+
clearKeys?(): void;
|
|
1118
|
+
dispose?(): void;
|
|
1119
|
+
[Symbol.dispose]?(): void;
|
|
1120
|
+
[Symbol.asyncDispose]?(): Promise<void>;
|
|
1121
|
+
}
|
|
1122
|
+
interface IProviderEncryptionOptions extends IEncryptionOperationOptions {
|
|
1123
|
+
/** Enable or disable encryption */
|
|
1124
|
+
enabled?: boolean;
|
|
1125
|
+
/**
|
|
1126
|
+
* Whether decryption is permitted during Server-Side Rendering (SSR).
|
|
1127
|
+
* In an End-to-End (E2E) zero-trust model, defaults to false to prevent
|
|
1128
|
+
* plaintext data in server memory or SSR payloads.
|
|
1129
|
+
*/
|
|
1130
|
+
decryptOnSSR?: boolean;
|
|
1131
|
+
/** Whether to defer row/item decryption to active page rendering in DataProviders */
|
|
1132
|
+
lazy?: boolean;
|
|
1133
|
+
/**
|
|
1134
|
+
* When enabled (true) with offline queueing, encrypts binary/FormData payloads
|
|
1135
|
+
* at rest before persisting into IndexedDB/storage, and decrypts them upon flush.
|
|
1136
|
+
*/
|
|
1137
|
+
encryptBinary?: boolean;
|
|
1138
|
+
/** Enable HMAC-SHA256 blind indexing and trigram search index on encrypted fields for local DataProviders */
|
|
1139
|
+
searchIndex?: boolean;
|
|
1140
|
+
/**
|
|
1141
|
+
* Explicitly permits sending plaintext filters for encrypted fields in outbound server queries
|
|
1142
|
+
* when no searchable encryption rewrite configuration is available (in non-strict mode).
|
|
1143
|
+
* Defaults to false (fail-closed: throws ERR_ENCRYPTED_FILTER_PLAINTEXT_LEAK).
|
|
1144
|
+
*/
|
|
1145
|
+
allowPlaintextServerFilter?: boolean;
|
|
1146
|
+
/**
|
|
1147
|
+
* Whether to allow matching against unscoped legacy blind index tokens (without field domain separation).
|
|
1148
|
+
* Defaults to false for security (prevents cross-field and equality-vs-trigram token collisions).
|
|
1149
|
+
*/
|
|
1150
|
+
allowLegacyUnscopedTokens?: boolean;
|
|
1151
|
+
/**
|
|
1152
|
+
* When enabled, maintains an in-memory decrypted row cache to evaluate local client-side filters
|
|
1153
|
+
* on encrypted fields directly without requiring blind indexing.
|
|
1154
|
+
*/
|
|
1155
|
+
decryptedCache?: boolean;
|
|
1156
|
+
/** Target locale for case conversion (e.g. 'tr', 'az', 'en', etc.) */
|
|
1157
|
+
locale?: string;
|
|
1158
|
+
/** When true, folds non-ASCII and accented characters to their standard ASCII equivalents */
|
|
1159
|
+
asciiFold?: boolean;
|
|
1160
|
+
/** Custom normalizer callback for domain- or script-specific character transforms */
|
|
1161
|
+
normalizer?: (value: string) => string;
|
|
1162
|
+
/** Stable identifier for a custom normalizer callback (used in scheme versioning) */
|
|
1163
|
+
normalizerId?: string;
|
|
1164
|
+
/** Optional schema or token version identifier for blind-index query rewriting */
|
|
1165
|
+
tokenVersion?: string | number;
|
|
1166
|
+
/** Optional version tag prefix for blind-index query rewriting */
|
|
1167
|
+
versionTag?: string | boolean;
|
|
1168
|
+
/** Historical token versions/configs to also emit when rewriting encrypted filters */
|
|
1169
|
+
previousVersions?: Array<string | number | IBlindIndexVersionConfig>;
|
|
1170
|
+
/** Expected persisted token scheme identifier; throws ERR_BIDX_SCHEME_MISMATCH on divergence */
|
|
1171
|
+
expectedTokenScheme?: string;
|
|
1172
|
+
/**
|
|
1173
|
+
* Deterministic Shadow-Bucket Range Index configuration across encrypted numeric or date columns.
|
|
1174
|
+
* Security note: reveals bucket frequency distributions and order relations (not IND-CPA / not zero-leakage).
|
|
1175
|
+
* Avoid narrow steps or high-sensitivity fields (`salary`, `age`, `birthDate`, `creditScore`) unless using broad bands (`$25,000+` / `'year'`).
|
|
1176
|
+
*/
|
|
1177
|
+
rangeBuckets?: Record<string, TRangeBucketConfig>;
|
|
1178
|
+
/** Alias for rangeBuckets */
|
|
1179
|
+
shadowBuckets?: Record<string, TRangeBucketConfig>;
|
|
1180
|
+
/** Explicit opt-in to allow range bucketing on high-sensitivity fields */
|
|
1181
|
+
allowSensitiveBucket?: boolean;
|
|
1182
|
+
/**
|
|
1183
|
+
* Set to true if API endpoints or data sources return pre-encrypted ciphertext envelopes.
|
|
1184
|
+
* When true, DataProviders decrypt search fields during ingest to populate CSearchIndex.
|
|
1185
|
+
*/
|
|
1186
|
+
preEncrypted?: boolean;
|
|
1187
|
+
/** Minimum query length for trigram substring searches (default: 3). Queries shorter than this use fallback verification. */
|
|
1188
|
+
minSearchLength?: number;
|
|
1189
|
+
/** Cryptographic algorithm identifier (defaults to 'AES-GCM') */
|
|
1190
|
+
algorithm?: TEncryptionAlgorithm;
|
|
1191
|
+
/** Custom cipher adapter implementing IEncryptionProvider (e.g. CRSAEncryptionProvider, CECDHEncryptionProvider, CWebCryptoAESCBCProvider) */
|
|
1192
|
+
customProvider?: IEncryptionProvider;
|
|
1193
|
+
/** Whether to use synchronous Node.js crypto provider (CNodeCryptoEncryptionProvider) */
|
|
1194
|
+
sync?: boolean;
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
type TDataProviderListener<T = unknown> = (provider: T) => void;
|
|
1198
|
+
type TUnsubscribe = () => void;
|
|
1199
|
+
interface IKDatatableAction {
|
|
1200
|
+
action: Function;
|
|
1201
|
+
label: string;
|
|
1202
|
+
icon?: string;
|
|
1203
|
+
iconOnly?: boolean;
|
|
1204
|
+
type?: 'default' | 'primary' | 'danger' | 'success' | 'warning' | 'info' | 'light' | 'dark';
|
|
1205
|
+
visible?: Function;
|
|
1206
|
+
}
|
|
1207
|
+
type TDataRow = {
|
|
1208
|
+
[key: string]: any;
|
|
1209
|
+
};
|
|
735
1210
|
interface IDataResult<TRow = TDataRow> {
|
|
736
1211
|
rowCount: number;
|
|
737
1212
|
rows: TRow[];
|
|
738
1213
|
}
|
|
739
|
-
type TPageDataHandler<TRow = TDataRow> = (currentPage: number, pageSize: number, filter: IDataFilter, sortList: IDataSort[], options?: {
|
|
1214
|
+
type TPageDataHandler<TRow = TDataRow> = (currentPage: number, pageSize: number, filter: IDataFilter | null, sortList: IDataSort[], options?: {
|
|
740
1215
|
disableCache?: boolean;
|
|
741
1216
|
signal?: AbortSignal;
|
|
1217
|
+
sideChannel?: boolean;
|
|
742
1218
|
}) => IDataResult<TRow> | Promise<IDataResult<TRow>>;
|
|
1219
|
+
interface IBatchProgress {
|
|
1220
|
+
loaded: number;
|
|
1221
|
+
total: number;
|
|
1222
|
+
percent: number;
|
|
1223
|
+
}
|
|
1224
|
+
interface IBatchLoadedEvent<TRow = any> {
|
|
1225
|
+
pageNumber: number;
|
|
1226
|
+
rows: TRow[];
|
|
1227
|
+
totalLoaded: number;
|
|
1228
|
+
rowCount: number;
|
|
1229
|
+
}
|
|
743
1230
|
interface IDataProviderOptions {
|
|
744
1231
|
apiUrl?: string;
|
|
745
1232
|
idKey?: string;
|
|
1233
|
+
fields?: string[];
|
|
746
1234
|
filter?: IDataFilter;
|
|
747
1235
|
sortList?: IDataSort[];
|
|
748
1236
|
pageSize?: number;
|
|
@@ -754,11 +1242,16 @@ interface IDataProviderOptions {
|
|
|
754
1242
|
deduplicate?: boolean;
|
|
755
1243
|
context?: Record<string, unknown>;
|
|
756
1244
|
contextKey?: string;
|
|
757
|
-
urlPageParam?: string;
|
|
758
1245
|
refreshOnMutation?: boolean;
|
|
759
1246
|
filterDebounce?: number;
|
|
760
1247
|
sortDebounce?: number;
|
|
761
1248
|
encryption?: IProviderEncryptionOptions;
|
|
1249
|
+
batchSize?: number | false;
|
|
1250
|
+
batchLoad?: 'initially' | 'onDemand';
|
|
1251
|
+
onDemandFilterPolicy?: 'ingestAll' | 'warnOnly';
|
|
1252
|
+
onBatchLoaded?: (batch: IBatchLoadedEvent<any>) => void;
|
|
1253
|
+
/** Locale identifier (e.g. 'tr', 'tr-TR', 'de-DE') for locale-aware sorting and string normalization. */
|
|
1254
|
+
locale?: string;
|
|
762
1255
|
}
|
|
763
1256
|
interface IDataProviderState<TRow = TDataRow> {
|
|
764
1257
|
currentPage: number;
|
|
@@ -770,6 +1263,15 @@ interface IDataProviderState<TRow = TDataRow> {
|
|
|
770
1263
|
initialLoad?: boolean;
|
|
771
1264
|
error?: Error | unknown;
|
|
772
1265
|
pageData?: TRow[];
|
|
1266
|
+
fields?: string[];
|
|
1267
|
+
isBatchLoading?: boolean;
|
|
1268
|
+
batchProgress?: IBatchProgress;
|
|
1269
|
+
loadedBatches?: number[];
|
|
1270
|
+
stateVersion?: number;
|
|
1271
|
+
selectedRows?: TRow[];
|
|
1272
|
+
selectAll?: boolean;
|
|
1273
|
+
unselectedRows?: TRow[];
|
|
1274
|
+
selectAllScope?: 'page' | 'all';
|
|
773
1275
|
}
|
|
774
1276
|
interface IDataProviderSetStateOptions {
|
|
775
1277
|
immediate?: boolean;
|
|
@@ -784,6 +1286,88 @@ interface IVirtualScrollState {
|
|
|
784
1286
|
itemHeight: number;
|
|
785
1287
|
}
|
|
786
1288
|
|
|
1289
|
+
declare abstract class ACacheProvider {
|
|
1290
|
+
constructor();
|
|
1291
|
+
abstract getKeyList(context?: unknown): Array<string> | Promise<Array<string>>;
|
|
1292
|
+
abstract get<T>(key: string, context?: unknown): Promise<T | null>;
|
|
1293
|
+
abstract set<T>(key: string, data: T, lifetime: number, context?: unknown): Promise<void>;
|
|
1294
|
+
abstract remove(key: string, context?: unknown): Promise<void>;
|
|
1295
|
+
abstract removeByPrefix(prefix: string, context?: unknown): Promise<void>;
|
|
1296
|
+
abstract getRemainingTime(key: string, context?: unknown): Promise<number | null>;
|
|
1297
|
+
abstract cleanupExpired(): Promise<void>;
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
declare class RequestProvider {
|
|
1301
|
+
private static _activeProvidersWithEncryption;
|
|
1302
|
+
static resolveCipherProvider(kid?: string): IEncryptionProvider | undefined;
|
|
1303
|
+
/**
|
|
1304
|
+
* Clears ephemeral session key discriminators. Used for testing fresh runtime sessions.
|
|
1305
|
+
*/
|
|
1306
|
+
static resetEphemeralKeyDiscriminators(): void;
|
|
1307
|
+
cacheProvider: ACacheProvider | null;
|
|
1308
|
+
cacheStrategy?: ECacheStrategy;
|
|
1309
|
+
cacheLifetime: number | null;
|
|
1310
|
+
deduplicate: boolean;
|
|
1311
|
+
cacheKey: string;
|
|
1312
|
+
tags: string[];
|
|
1313
|
+
queue: boolean;
|
|
1314
|
+
private static requestQueue;
|
|
1315
|
+
private static executing;
|
|
1316
|
+
private static requestsInFlight;
|
|
1317
|
+
private static inFlightBridges;
|
|
1318
|
+
private static contextResolver?;
|
|
1319
|
+
static setContextResolver(resolver: ((options?: IRequestOptions) => any) | undefined): void;
|
|
1320
|
+
static getContextResolver(): ((options?: IRequestOptions) => any) | undefined;
|
|
1321
|
+
private _ambientContext?;
|
|
1322
|
+
private lastUrl?;
|
|
1323
|
+
private lastOptions?;
|
|
1324
|
+
private dataReceivedCallback?;
|
|
1325
|
+
encryption?: IProviderEncryptionOptions;
|
|
1326
|
+
private _cachedCipherProvider?;
|
|
1327
|
+
private _lastEncryptionConfig?;
|
|
1328
|
+
private _scopedCipherProviders;
|
|
1329
|
+
constructor(provider?: ACacheProvider | ECacheStrategy, lifetime?: number, deduplicate?: boolean);
|
|
1330
|
+
setCacheProvider(provider?: ACacheProvider | ECacheStrategy): void;
|
|
1331
|
+
setCacheLifetime(lifetime: number): void;
|
|
1332
|
+
setDeduplicate(deduplicate: boolean): void;
|
|
1333
|
+
setQueue(queue: boolean): void;
|
|
1334
|
+
private disposeCipherInstance;
|
|
1335
|
+
setEncryption(encryption?: IProviderEncryptionOptions): void;
|
|
1336
|
+
clearEncryption(): void;
|
|
1337
|
+
onDataReceived(callback: (data: any, generation?: number, url?: string) => void): void;
|
|
1338
|
+
private invokeDataReceivedCallback;
|
|
1339
|
+
private finalizeResponse;
|
|
1340
|
+
hasLastUrl(): boolean;
|
|
1341
|
+
refresh(hardRefresh?: boolean): Promise<any>;
|
|
1342
|
+
private resolveContext;
|
|
1343
|
+
private getInFlightMap;
|
|
1344
|
+
private getInFlightBridgeMap;
|
|
1345
|
+
private isDataEncrypted;
|
|
1346
|
+
private buildEncryptionContext;
|
|
1347
|
+
private decryptPayloadIfNeeded;
|
|
1348
|
+
private getInFlightContainer;
|
|
1349
|
+
getUniqueKey(url: string, options?: IRequestOptions): string;
|
|
1350
|
+
private getCipherProvider;
|
|
1351
|
+
registerRequest<T>(url: string, options?: IRequestOptions): Promise<T>;
|
|
1352
|
+
static executeAll(): void;
|
|
1353
|
+
request<T>(url: string, options?: IRequestOptions): Promise<T>;
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
/**
|
|
1357
|
+
* Server request event contract. Compatible with H3Event (Nuxt 3 / Nitro),
|
|
1358
|
+
* Node.js HTTP incoming messages, and mock/custom server context stubs.
|
|
1359
|
+
*/
|
|
1360
|
+
type TServerRequestEvent = H3Event | {
|
|
1361
|
+
headers?: Headers | Record<string, string | string[] | undefined> | {
|
|
1362
|
+
get?(name: string): string | null | undefined;
|
|
1363
|
+
};
|
|
1364
|
+
node?: {
|
|
1365
|
+
req?: any;
|
|
1366
|
+
res?: any;
|
|
1367
|
+
};
|
|
1368
|
+
context?: Record<string, any>;
|
|
1369
|
+
[key: string]: any;
|
|
1370
|
+
};
|
|
787
1371
|
interface IRequestOptions {
|
|
788
1372
|
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
789
1373
|
body?: any;
|
|
@@ -795,6 +1379,8 @@ interface IRequestOptions {
|
|
|
795
1379
|
query?: Record<string, unknown>;
|
|
796
1380
|
deduplicate?: boolean;
|
|
797
1381
|
context?: Record<string, unknown>;
|
|
1382
|
+
/** Active SSR request event (e.g. H3Event from useRequestEvent() or Nitro event handler) */
|
|
1383
|
+
event?: TServerRequestEvent;
|
|
798
1384
|
disableCache?: boolean;
|
|
799
1385
|
queue?: boolean;
|
|
800
1386
|
queueLabel?: string;
|
|
@@ -802,6 +1388,8 @@ interface IRequestOptions {
|
|
|
802
1388
|
tags?: string[];
|
|
803
1389
|
signal?: AbortSignal;
|
|
804
1390
|
_generation?: number;
|
|
1391
|
+
/** When true, marks a background/side-channel fetch: does not update lastUrl/lastOptions or fire onDataReceived. */
|
|
1392
|
+
sideChannel?: boolean;
|
|
805
1393
|
encryption?: IProviderEncryptionOptions;
|
|
806
1394
|
/** If true, returns raw response without decrypting, useful for DataProvider lazy page-level decryption */
|
|
807
1395
|
skipDecryption?: boolean;
|
|
@@ -837,6 +1425,26 @@ interface IDeadLetterItem extends IQueuedOperation {
|
|
|
837
1425
|
interface IFlushOptions {
|
|
838
1426
|
tag?: string;
|
|
839
1427
|
}
|
|
1428
|
+
interface IQueuedRequest {
|
|
1429
|
+
url: string;
|
|
1430
|
+
options?: IRequestOptions;
|
|
1431
|
+
instance: RequestProvider;
|
|
1432
|
+
context?: any;
|
|
1433
|
+
resolve?: (value: unknown) => void;
|
|
1434
|
+
reject?: (error: Error) => void;
|
|
1435
|
+
}
|
|
1436
|
+
interface InFlightSubscriber {
|
|
1437
|
+
id: number;
|
|
1438
|
+
signal?: AbortSignal;
|
|
1439
|
+
cleanup?: () => void;
|
|
1440
|
+
resolve: (val: any) => void;
|
|
1441
|
+
reject: (err: any) => void;
|
|
1442
|
+
}
|
|
1443
|
+
interface InFlightBridge {
|
|
1444
|
+
controller: AbortController;
|
|
1445
|
+
subscribers: Map<number, InFlightSubscriber>;
|
|
1446
|
+
nextId: number;
|
|
1447
|
+
}
|
|
840
1448
|
|
|
841
1449
|
interface ITreeNode<TRow = TDataRow> {
|
|
842
1450
|
data: TRow;
|
|
@@ -893,7 +1501,7 @@ interface ITreeDataProviderOptions extends IDataProviderOptions {
|
|
|
893
1501
|
* Tree-specific page data handler that includes tree parameters
|
|
894
1502
|
* Server handles tree building, visibility, and pagination
|
|
895
1503
|
*/
|
|
896
|
-
type TTreePageDataHandler<TRow = TDataRow> = (currentPage: number, pageSize: number, filter: IDataFilter, sortList: IDataSort[], treeParams: {
|
|
1504
|
+
type TTreePageDataHandler<TRow = TDataRow> = (currentPage: number, pageSize: number, filter: IDataFilter | null, sortList: IDataSort[], treeParams: {
|
|
897
1505
|
expandedNodes: (string | number)[] | Set<string | number>;
|
|
898
1506
|
parentKey: string;
|
|
899
1507
|
idKey: string;
|
|
@@ -902,24 +1510,9 @@ type TTreePageDataHandler<TRow = TDataRow> = (currentPage: number, pageSize: num
|
|
|
902
1510
|
}, options?: {
|
|
903
1511
|
disableCache?: boolean;
|
|
904
1512
|
signal?: AbortSignal;
|
|
1513
|
+
sideChannel?: boolean;
|
|
905
1514
|
}) => IDataResult<TRow> | Promise<IDataResult<TRow>>;
|
|
906
1515
|
|
|
907
|
-
interface KProductItemData {
|
|
908
|
-
id: string | number;
|
|
909
|
-
title: string;
|
|
910
|
-
image?: string;
|
|
911
|
-
price?: number;
|
|
912
|
-
currency?: string;
|
|
913
|
-
description?: string;
|
|
914
|
-
[key: string]: unknown;
|
|
915
|
-
}
|
|
916
|
-
interface KProductRowAction {
|
|
917
|
-
label: string;
|
|
918
|
-
icon?: string;
|
|
919
|
-
action: (item: KProductItemData) => void;
|
|
920
|
-
color?: 'primary' | 'danger' | 'success' | 'warning' | 'info' | 'light' | 'dark' | 'default';
|
|
921
|
-
}
|
|
922
|
-
|
|
923
1516
|
/**
|
|
924
1517
|
* types.ts — Framework-agnostic hydration and platform abstraction contracts.
|
|
925
1518
|
*/
|
|
@@ -951,11 +1544,49 @@ interface IPlatformRouter {
|
|
|
951
1544
|
onReady?(cb: () => void): void;
|
|
952
1545
|
}
|
|
953
1546
|
|
|
1547
|
+
interface IDataProviderGlobalConfig {
|
|
1548
|
+
locale?: string;
|
|
1549
|
+
}
|
|
1550
|
+
/**
|
|
1551
|
+
* Configure project-level defaults for all ADataProvider instances.
|
|
1552
|
+
*/
|
|
1553
|
+
declare function setGlobalDataProviderConfig(config: IDataProviderGlobalConfig): void;
|
|
1554
|
+
/**
|
|
1555
|
+
* Get the current project-level DataProvider configuration.
|
|
1556
|
+
*/
|
|
1557
|
+
declare function getGlobalDataProviderConfig(): IDataProviderGlobalConfig;
|
|
954
1558
|
declare abstract class ADataProvider<TRow = TDataRow> {
|
|
955
1559
|
idKey: string;
|
|
1560
|
+
protected _locale?: string;
|
|
1561
|
+
get locale(): string | undefined;
|
|
1562
|
+
set locale(val: string | undefined);
|
|
1563
|
+
setLocale(locale?: string): void | Promise<void>;
|
|
956
1564
|
protected _pageData: TRow[];
|
|
957
1565
|
get pageData(): TRow[];
|
|
958
1566
|
set pageData(val: TRow[]);
|
|
1567
|
+
/**
|
|
1568
|
+
* Highest page appended through loadMore() during the current accumulation session.
|
|
1569
|
+
* null when not accumulating (the displayed rows correspond to `currentPage`).
|
|
1570
|
+
* loadMore() never mutates `currentPage`; it tracks progress here instead.
|
|
1571
|
+
*/
|
|
1572
|
+
protected _loadedThroughPage: number | null;
|
|
1573
|
+
/** Query signature of the currently loaded pageData. */
|
|
1574
|
+
protected _loadedQuerySignature: string | null;
|
|
1575
|
+
/** Active non-accumulating page load promise. */
|
|
1576
|
+
protected _activePageLoad: Promise<void> | null;
|
|
1577
|
+
/** Merges incoming rows onto existing rows, deduplicating by `idKey` when present. */
|
|
1578
|
+
protected mergeUniqueRows(existing: TRow[], incoming: TRow[]): TRow[];
|
|
1579
|
+
/** Updates `pageData` and `_loadedThroughPage` during an accumulation session. */
|
|
1580
|
+
protected applyAccumulatedPageData(merged: TRow[], targetPage: number): void;
|
|
1581
|
+
/** Stable signature of the query parameters that determine page contents. */
|
|
1582
|
+
protected _querySignature(): string;
|
|
1583
|
+
protected _fields: string[];
|
|
1584
|
+
protected _selectedRows: TRow[];
|
|
1585
|
+
protected _selectAll: boolean;
|
|
1586
|
+
protected _unselectedRows: TRow[];
|
|
1587
|
+
protected _selectAllScope: 'page' | 'all';
|
|
1588
|
+
get fields(): string[];
|
|
1589
|
+
set fields(val: string[]);
|
|
959
1590
|
protected _rowCount: number;
|
|
960
1591
|
get rowCount(): number;
|
|
961
1592
|
set rowCount(val: number);
|
|
@@ -971,7 +1602,6 @@ declare abstract class ADataProvider<TRow = TDataRow> {
|
|
|
971
1602
|
SSR: boolean;
|
|
972
1603
|
deduplicate: boolean;
|
|
973
1604
|
context: any;
|
|
974
|
-
urlPageParam: string;
|
|
975
1605
|
protected _currentPage: number;
|
|
976
1606
|
protected _pageSize: number;
|
|
977
1607
|
protected _filter: IDataFilter | null;
|
|
@@ -986,10 +1616,20 @@ declare abstract class ADataProvider<TRow = TDataRow> {
|
|
|
986
1616
|
set sortList(s: IDataSort[]);
|
|
987
1617
|
get hasMore(): boolean;
|
|
988
1618
|
nextPage(): Promise<void>;
|
|
1619
|
+
/**
|
|
1620
|
+
* Alias for `nextPage()`.
|
|
1621
|
+
*/
|
|
989
1622
|
loadMore(): Promise<void>;
|
|
1623
|
+
prevPage(): Promise<void>;
|
|
1624
|
+
protected _stateVersion: number;
|
|
1625
|
+
get stateVersion(): number;
|
|
990
1626
|
private _listeners;
|
|
991
1627
|
private _stateListeners;
|
|
992
|
-
private
|
|
1628
|
+
private _sortListeners;
|
|
1629
|
+
private _filterListeners;
|
|
1630
|
+
private _dataListeners;
|
|
1631
|
+
protected _pendingChangedKeys: Set<keyof IDataProviderState<TRow>>;
|
|
1632
|
+
protected _options?: IDataProviderOptions;
|
|
993
1633
|
private _debouncedFilterLoad;
|
|
994
1634
|
private _debouncedSortLoad;
|
|
995
1635
|
constructor(options?: IDataProviderOptions);
|
|
@@ -1003,22 +1643,38 @@ declare abstract class ADataProvider<TRow = TDataRow> {
|
|
|
1003
1643
|
subscribe(listener: TDataProviderListener<this>): TUnsubscribe;
|
|
1004
1644
|
notify(): void;
|
|
1005
1645
|
onStateChange(listener: TDataProviderStateChangeListener<TRow>): TUnsubscribe;
|
|
1646
|
+
onSortChanged(listener: (sortList: IDataSort[]) => void): TUnsubscribe;
|
|
1647
|
+
onFilterChanged(listener: (filter: IDataFilter | null) => void): TUnsubscribe;
|
|
1648
|
+
onDataChanged(listener: (pageData: TRow[]) => void): TUnsubscribe;
|
|
1006
1649
|
getState(): IDataProviderState<TRow>;
|
|
1007
1650
|
protected onFilterUpdated(): void;
|
|
1008
1651
|
protected onSortUpdated(): void;
|
|
1009
1652
|
setState(partial: Partial<IDataProviderState<TRow>>, options?: IDataProviderSetStateOptions): void;
|
|
1010
1653
|
serializeState(): string;
|
|
1011
1654
|
deserializeState(serialized: string | Partial<IDataProviderState<TRow>>, options?: IDataProviderSetStateOptions): void;
|
|
1012
|
-
setFilter(filter: IDataFilter | null, immediate?: boolean): void
|
|
1013
|
-
setSortList(sortList: IDataSort[], immediate?: boolean): void
|
|
1014
|
-
|
|
1015
|
-
|
|
1655
|
+
setFilter(filter: IDataFilter | null, immediate?: boolean): void | Promise<void>;
|
|
1656
|
+
setSortList(sortList: IDataSort[], immediate?: boolean): void | Promise<void>;
|
|
1657
|
+
protected _guardEncryptedSorting(sortList: IDataSort[]): void;
|
|
1658
|
+
setCurrentPage(currentPage: number): void | Promise<void>;
|
|
1659
|
+
setPageSize(pageSize: number, resetPage?: boolean): void | Promise<void>;
|
|
1016
1660
|
abstract loadPageData(options?: {
|
|
1017
1661
|
disableCache?: boolean;
|
|
1018
1662
|
signal?: AbortSignal;
|
|
1019
1663
|
}): void | Promise<void>;
|
|
1020
|
-
|
|
1664
|
+
/**
|
|
1665
|
+
* Fetches or returns the full unpaginated dataset (e.g. for charts, analytics, or bulk exports).
|
|
1666
|
+
*/
|
|
1667
|
+
fetchAll?(options?: {
|
|
1668
|
+
disableCache?: boolean;
|
|
1669
|
+
signal?: AbortSignal;
|
|
1670
|
+
}): Promise<TRow[]>;
|
|
1671
|
+
refresh(hardRefresh?: boolean): Promise<void>;
|
|
1021
1672
|
cancelPending(): void;
|
|
1673
|
+
/**
|
|
1674
|
+
* Side-channel visible window slice resolution without reading or mutating currentPage or pageData.
|
|
1675
|
+
*/
|
|
1676
|
+
resolveRangeRows(startIndex: number, endIndex: number): Promise<TRow[]>;
|
|
1677
|
+
getWindowRows(startIndex: number, endIndex: number): Promise<TRow[]>;
|
|
1022
1678
|
}
|
|
1023
1679
|
|
|
1024
1680
|
interface ISetDataChunkedOptions {
|
|
@@ -1043,16 +1699,24 @@ declare function encryptRowsChunked<T = any>(rows: T[], encryption: IProviderEnc
|
|
|
1043
1699
|
|
|
1044
1700
|
/**
|
|
1045
1701
|
* Normalizes text for consistent deterministic blind indexing (lowercased, trimmed, NFKC normalized).
|
|
1702
|
+
* Delegates to the shared normalizeFilterValue primitive.
|
|
1046
1703
|
*/
|
|
1047
|
-
declare function normalizeIndexTerm(value: any): string;
|
|
1704
|
+
declare function normalizeIndexTerm(value: any, options?: INormalizeOptions): string;
|
|
1048
1705
|
/**
|
|
1049
1706
|
* Extracts 3-character trigrams from a string for substring search.
|
|
1050
1707
|
*/
|
|
1051
|
-
declare function extractTrigrams(value: any): string[];
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1708
|
+
declare function extractTrigrams(value: any, options?: INormalizeOptions): string[];
|
|
1709
|
+
/**
|
|
1710
|
+
* Returns the exact logical complement of an operator if one exists in EDataFilterOperator,
|
|
1711
|
+
* or null for operators without an exact inverse (e.g. contains, like, between, unknown).
|
|
1712
|
+
*/
|
|
1713
|
+
declare function invertFilterOperator(operator: any): EDataFilterOperator | null;
|
|
1714
|
+
/**
|
|
1715
|
+
* Negates a filter AST node using De Morgan's Laws for compound nodes,
|
|
1716
|
+
* exact operator inversion when available, and explicit NOT wrapping otherwise.
|
|
1717
|
+
*/
|
|
1718
|
+
declare function negateFilterNode(filter: TSearchFilterNode | any): TSearchFilterNode;
|
|
1719
|
+
|
|
1056
1720
|
/**
|
|
1057
1721
|
* CSearchIndex provides deterministic blind indexing (HMAC-SHA256) and trigram token sets
|
|
1058
1722
|
* for client-side privacy-preserving searching and filtering across encrypted fields without decryption.
|
|
@@ -1062,23 +1726,45 @@ declare class CSearchIndex {
|
|
|
1062
1726
|
private _rawKeyMaterial;
|
|
1063
1727
|
private _index;
|
|
1064
1728
|
private _indexedFields;
|
|
1065
|
-
|
|
1729
|
+
private _fieldBuckets;
|
|
1730
|
+
private _bucketToRows;
|
|
1731
|
+
private _decryptedRowResolver?;
|
|
1732
|
+
minSearchLength: number;
|
|
1733
|
+
options: ISearchIndexOptions;
|
|
1734
|
+
constructor(keyMaterial: TKeyProvider, fields?: string[], options?: ISearchIndexOptions);
|
|
1066
1735
|
get indexedFields(): readonly string[];
|
|
1067
1736
|
setFields(fields: string[]): void;
|
|
1737
|
+
isFieldIndexed(field: string): boolean;
|
|
1738
|
+
setDecryptedRowResolver(resolver?: (row: any) => any): void;
|
|
1739
|
+
hasDecryptedRowResolver(): boolean;
|
|
1740
|
+
private _addBucketRow;
|
|
1741
|
+
getBucketsForField(field: string): Set<string>;
|
|
1742
|
+
setRangeBuckets(rangeBuckets?: Record<string, TRangeBucketConfig>): void;
|
|
1743
|
+
computeRangeBucket(val: any, fieldOrConfig: string | TRangeBucketConfig, fieldName?: string, options?: {
|
|
1744
|
+
allowSensitiveBucket?: boolean;
|
|
1745
|
+
}): string | undefined;
|
|
1746
|
+
resolveBucketsForRange(operator: string, targetValue: any, fieldOrConfig: string | TRangeBucketConfig, knownBuckets?: Iterable<string>, fieldName?: string, options?: {
|
|
1747
|
+
allowSensitiveBucket?: boolean;
|
|
1748
|
+
}): Set<string>;
|
|
1749
|
+
getCandidateRowsForBuckets(field: string, bucketKeys: Iterable<string>): Set<any>;
|
|
1750
|
+
getCandidateRecordIdsForBuckets(field: string, bucketKeys: Iterable<string>, idKey?: string): Set<any>;
|
|
1751
|
+
getCandidateRecordIdsForRange(operator: string, targetValue: any, field: string, idKey?: string): Set<any>;
|
|
1068
1752
|
private _getHmacKey;
|
|
1069
1753
|
/**
|
|
1070
1754
|
* Computes a deterministic HMAC-SHA256 token for a term.
|
|
1755
|
+
* Supports domain separation via field name or full IBlindIndexOptions.
|
|
1071
1756
|
*/
|
|
1072
|
-
computeToken(term: any): Promise<string>;
|
|
1757
|
+
computeToken(term: any, fieldOrOptions?: string | IBlindIndexOptions): Promise<string>;
|
|
1073
1758
|
/**
|
|
1074
1759
|
* Computes a deterministic HMAC-SHA256 blind index hash for a term using the configured HMAC key.
|
|
1075
1760
|
* Performs Unicode NFKC normalization, trimming, and lowercasing.
|
|
1076
1761
|
*/
|
|
1077
|
-
computeBlindIndex(term: any): Promise<string>;
|
|
1762
|
+
computeBlindIndex(term: any, fieldOrOptions?: string | IBlindIndexOptions): Promise<string>;
|
|
1078
1763
|
/**
|
|
1079
1764
|
* Computes HMAC-SHA256 tokens for all trigrams of a term.
|
|
1765
|
+
* Supports domain separation via field name or full IBlindIndexOptions.
|
|
1080
1766
|
*/
|
|
1081
|
-
computeTrigramTokens(term: any): Promise<Set<string>>;
|
|
1767
|
+
computeTrigramTokens(term: any, fieldOrOptions?: string | IBlindIndexOptions): Promise<Set<string>>;
|
|
1082
1768
|
/**
|
|
1083
1769
|
* Indexes a single row before its fields are encrypted.
|
|
1084
1770
|
*/
|
|
@@ -1100,19 +1786,61 @@ declare class CSearchIndex {
|
|
|
1100
1786
|
* Evaluates whether a row matches an exact or substring query on an indexed encrypted field.
|
|
1101
1787
|
*/
|
|
1102
1788
|
evaluateField(operator: string, row: any, field: string, filterValue: any): Promise<boolean | null>;
|
|
1789
|
+
private _isEncryptedEnvelope;
|
|
1790
|
+
private _getRowFieldValue;
|
|
1791
|
+
private _createEvalContext;
|
|
1103
1792
|
/**
|
|
1104
1793
|
* Pre-computes query tokens for an active filter, returning a high-performance synchronous
|
|
1105
1794
|
* evaluator function suitable for row-by-row filtering in memory.
|
|
1795
|
+
*
|
|
1796
|
+
* Supports hybrid evaluation across encrypted blind-indexed fields and unindexed / plaintext fields:
|
|
1797
|
+
* - Evaluates candidate rows matching the encrypted blind index first.
|
|
1798
|
+
* - Evaluates all unindexed filter conditions against decrypted/plaintext row fields in memory.
|
|
1799
|
+
* - Never treats an unhandled filter branch or null evaluator as a match-all inside an AND conjunction.
|
|
1800
|
+
*/
|
|
1801
|
+
createFilterEvaluator(filter: IDataFilter | any): Promise<((row: any) => boolean) | null>;
|
|
1802
|
+
/**
|
|
1803
|
+
* Secondary in-memory verification filter executed post-decryption to filter out
|
|
1804
|
+
* false positives from non-contiguous trigram matches and verify exact substring containment.
|
|
1805
|
+
*/
|
|
1806
|
+
verifyDecryptedRows<T = any>(rows: T[], filter: IDataFilter | any): T[];
|
|
1807
|
+
/**
|
|
1808
|
+
* Verifies a single decrypted row against an active filter post-decryption.
|
|
1809
|
+
*/
|
|
1810
|
+
verifyDecryptedRow(row: any, filter: IDataFilter | any): boolean;
|
|
1811
|
+
/**
|
|
1812
|
+
* Determines whether an active filter requires post-decryption verification
|
|
1813
|
+
* (e.g. for substring / trigram queries, short queries < minSearchLength, range buckets,
|
|
1814
|
+
* or any queries that may yield candidate false positives in stage-1 blind index filtering).
|
|
1106
1815
|
*/
|
|
1107
|
-
|
|
1816
|
+
requiresPostVerification(filter: IDataFilter | any): boolean;
|
|
1108
1817
|
}
|
|
1109
1818
|
|
|
1110
1819
|
declare abstract class AEncryptedClientProvider<TRow = TDataRow> extends ADataProvider<TRow> {
|
|
1111
1820
|
encryption?: IProviderEncryptionOptions;
|
|
1112
1821
|
protected _searchIndex?: CSearchIndex;
|
|
1822
|
+
protected _decryptedCache: Map<string | number, TRow>;
|
|
1823
|
+
protected _decryptedRefCache: WeakMap<object, TRow>;
|
|
1113
1824
|
constructor(options?: IDataProviderOptions);
|
|
1114
1825
|
get isEncryptionEnabled(): boolean;
|
|
1115
1826
|
get searchIndex(): CSearchIndex | undefined;
|
|
1827
|
+
protected _deleteCacheIdVariants(map: Map<string | number, TRow>, id: unknown): void;
|
|
1828
|
+
protected _containsEncryptedPayload(row: any): boolean;
|
|
1829
|
+
getDecryptedRow(rowOrId: any): TRow | undefined;
|
|
1830
|
+
cacheDecryptedRow(rowOrId: any, decryptedRow: TRow): void;
|
|
1831
|
+
clearDecryptedCache(): void;
|
|
1832
|
+
/**
|
|
1833
|
+
* Invalidate cached decrypted representations for a single row or row ID.
|
|
1834
|
+
*/
|
|
1835
|
+
invalidateDecryptedRow(rowOrId: any): void;
|
|
1836
|
+
/**
|
|
1837
|
+
* Evicts a single row or row ID from both `_decryptedCache` and `_decryptedRefCache`.
|
|
1838
|
+
*/
|
|
1839
|
+
evictDecryptedRow(rowOrId: any): void;
|
|
1840
|
+
populateDecryptedCache(rows: TRow[]): Promise<void>;
|
|
1841
|
+
isFieldEncrypted(field: string, sampleRows?: TRow[]): boolean;
|
|
1842
|
+
warnIfEncryptedFilterWithoutSupport(filter: IDataFilter | any, sampleRows?: TRow[]): void;
|
|
1843
|
+
protected _guardEncryptedSorting(sortList: IDataSort[]): void;
|
|
1116
1844
|
private _warmupKeyAsync;
|
|
1117
1845
|
protected _initSearchIndex(): void;
|
|
1118
1846
|
setEncryption(encryption?: IProviderEncryptionOptions): void;
|
|
@@ -1132,6 +1860,27 @@ declare abstract class AEncryptedClientProvider<TRow = TDataRow> extends ADataPr
|
|
|
1132
1860
|
setDataChunked(data: TRow[], options?: ISetDataChunkedOptions): Promise<void>;
|
|
1133
1861
|
}
|
|
1134
1862
|
|
|
1863
|
+
/**
|
|
1864
|
+
* Minimal encryption/cache adapter surface shared across client providers.
|
|
1865
|
+
*/
|
|
1866
|
+
interface IProviderEncryptionHost<TRow> {
|
|
1867
|
+
isEncryptionEnabled: boolean;
|
|
1868
|
+
encryption?: IProviderEncryptionOptions;
|
|
1869
|
+
searchIndex?: any;
|
|
1870
|
+
idKey: string;
|
|
1871
|
+
encryptRows(rows: TRow[]): Promise<TRow[]>;
|
|
1872
|
+
encryptRowsChunked(rows: TRow[], options?: ISetDataChunkedOptions): Promise<TRow[]>;
|
|
1873
|
+
indexPreEncryptedRows(rows: TRow[]): Promise<void>;
|
|
1874
|
+
populateDecryptedCache(rows: TRow[]): Promise<void>;
|
|
1875
|
+
cacheDecryptedRow(encryptedRow: any, decryptedRow: TRow): void;
|
|
1876
|
+
getDecryptedRow(rowOrId: any): TRow | undefined;
|
|
1877
|
+
decryptRows(rows: TRow[]): Promise<{
|
|
1878
|
+
rows: TRow[];
|
|
1879
|
+
decrypted: boolean;
|
|
1880
|
+
}>;
|
|
1881
|
+
invalidateDecryptedRow(rowOrId: any): void;
|
|
1882
|
+
}
|
|
1883
|
+
|
|
1135
1884
|
declare class CFlatClientDataProvider<TRow = TDataRow> extends AEncryptedClientProvider<TRow> {
|
|
1136
1885
|
private _allData;
|
|
1137
1886
|
filteredData: TRow[];
|
|
@@ -1139,17 +1888,38 @@ declare class CFlatClientDataProvider<TRow = TDataRow> extends AEncryptedClientP
|
|
|
1139
1888
|
protected _filterDirty: boolean;
|
|
1140
1889
|
protected _sortDirty: boolean;
|
|
1141
1890
|
protected _activeFilterEvaluator: ((row: any) => boolean) | null;
|
|
1891
|
+
protected _expectedRowCount?: number;
|
|
1892
|
+
protected _isSparse: boolean;
|
|
1893
|
+
batchSize: number | false;
|
|
1894
|
+
batchLoad: 'initially' | 'onDemand';
|
|
1895
|
+
onDemandFilterPolicy: 'ingestAll' | 'warnOnly';
|
|
1896
|
+
onBatchLoaded?: (batch: IBatchLoadedEvent<TRow>) => void;
|
|
1897
|
+
loadedBatches: Set<number>;
|
|
1898
|
+
protected _rawSourceData?: TRow[];
|
|
1899
|
+
protected _isBatchLoading: boolean;
|
|
1900
|
+
get isBatchLoading(): boolean;
|
|
1901
|
+
set isBatchLoading(val: boolean);
|
|
1902
|
+
protected _batchProgress?: IBatchProgress;
|
|
1903
|
+
get batchProgress(): IBatchProgress | undefined;
|
|
1904
|
+
set batchProgress(val: IBatchProgress | undefined);
|
|
1905
|
+
protected _batchGeneration: number;
|
|
1906
|
+
protected _inFlightLoad?: Promise<void>;
|
|
1142
1907
|
constructor(options?: IDataProviderOptions);
|
|
1908
|
+
protected _assignAllData(data: TRow[], preserveDecryptedCache?: boolean): void;
|
|
1143
1909
|
get allData(): TRow[];
|
|
1144
1910
|
set allData(data: TRow[]);
|
|
1145
1911
|
get rowMap(): readonly TRow[];
|
|
1146
1912
|
setData(data: TRow[]): Promise<void> | void;
|
|
1913
|
+
protected _setDataBatched(data: TRow[]): Promise<void>;
|
|
1914
|
+
/** Adapts protected encryption/cache hooks for stateless batch helpers without exposing protected methods publicly. */
|
|
1915
|
+
protected _getEncryptionHost(): IProviderEncryptionHost<TRow>;
|
|
1147
1916
|
protected _setDataEncrypted(data: TRow[]): Promise<void>;
|
|
1148
1917
|
setDataChunked(data: TRow[], options?: ISetDataChunkedOptions): Promise<void>;
|
|
1149
1918
|
protected onFilterUpdated(): void;
|
|
1150
1919
|
protected onSortUpdated(): void;
|
|
1151
|
-
setFilter(filter: IDataFilter | null, immediate?: boolean): void
|
|
1152
|
-
setSortList(sortList: IDataSort[], immediate?: boolean): void
|
|
1920
|
+
setFilter(filter: IDataFilter | null, immediate?: boolean): void | Promise<void>;
|
|
1921
|
+
setSortList(sortList: IDataSort[], immediate?: boolean): void | Promise<void>;
|
|
1922
|
+
setEncryption(encryption?: IProviderEncryptionOptions): void;
|
|
1153
1923
|
clearEncryption(): void;
|
|
1154
1924
|
/**
|
|
1155
1925
|
* Explicitly rebuilds the reference map array if row properties inside allData were mutated in-place.
|
|
@@ -1159,71 +1929,32 @@ declare class CFlatClientDataProvider<TRow = TDataRow> extends AEncryptedClientP
|
|
|
1159
1929
|
disableCache?: boolean;
|
|
1160
1930
|
}): Promise<void>;
|
|
1161
1931
|
refresh(hardRefresh?: boolean): Promise<void>;
|
|
1932
|
+
fetchAll(): Promise<TRow[]>;
|
|
1933
|
+
protected _getNormalizeOptions(): INormalizeOptions | undefined;
|
|
1934
|
+
protected _countDefinedRows(): number;
|
|
1935
|
+
protected _resolveSortValue(row: any, field: string, rangeBuckets: any): any;
|
|
1936
|
+
protected _buildSortedRowMap(): TRow[];
|
|
1937
|
+
protected _hasEncryptedRowFilterField(row: any, filter: IDataFilter | null, filterFields?: string[]): boolean;
|
|
1938
|
+
protected _hasUnindexedEncryptedFilter(filter: IDataFilter, sampleRows: TRow[]): boolean;
|
|
1939
|
+
/**
|
|
1940
|
+
* Builds a synchronous filter evaluator for decryptedCache mode that never falls back
|
|
1941
|
+
* to running evaluateFilter against encrypted ciphertext payloads.
|
|
1942
|
+
*/
|
|
1943
|
+
protected _createDecryptedCacheFilterEvaluator(filter: IDataFilter, normOpts?: INormalizeOptions): (row: any) => boolean;
|
|
1162
1944
|
private _computeFilteredAndSorted;
|
|
1163
|
-
loadPageData(): Promise<void>;
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
declare class RequestProvider {
|
|
1178
|
-
cacheProvider: ACacheProvider | null;
|
|
1179
|
-
cacheStrategy?: ECacheStrategy;
|
|
1180
|
-
cacheLifetime: number | null;
|
|
1181
|
-
deduplicate: boolean;
|
|
1182
|
-
cacheKey: string;
|
|
1183
|
-
/** Registry tags — set via useRequestProvider() or manually */
|
|
1184
|
-
tags: string[];
|
|
1185
|
-
/** If true, non-GET requests are enqueued instead of sent immediately */
|
|
1186
|
-
queue: boolean;
|
|
1187
|
-
private static requestQueue;
|
|
1188
|
-
private static executing;
|
|
1189
|
-
private static requestsInFlight;
|
|
1190
|
-
private lastUrl?;
|
|
1191
|
-
private lastOptions?;
|
|
1192
|
-
private dataReceivedCallback?;
|
|
1193
|
-
constructor(provider?: ACacheProvider | ECacheStrategy, lifetime?: number, deduplicate?: boolean);
|
|
1194
|
-
setCacheProvider(provider?: ACacheProvider | ECacheStrategy): void;
|
|
1195
|
-
setCacheLifetime(lifetime: number): void;
|
|
1196
|
-
setDeduplicate(deduplicate: boolean): void;
|
|
1197
|
-
setQueue(queue: boolean): void;
|
|
1198
|
-
encryption?: IProviderEncryptionOptions;
|
|
1199
|
-
private _cachedCipherProvider?;
|
|
1200
|
-
private _lastEncryptionConfig?;
|
|
1201
|
-
private _scopedCipherProviders;
|
|
1202
|
-
/**
|
|
1203
|
-
* Configures E2EE payload encryption for outbound mutations and inbound responses.
|
|
1204
|
-
*
|
|
1205
|
-
* Threat Model: Protects sensitive SaaS tenant data against backend/database breaches.
|
|
1206
|
-
* Multi-user sharing is supported by role-based session keys passed dynamically.
|
|
1207
|
-
* Local client endpoint compromise (malware, trojans, keyloggers) is out of scope.
|
|
1208
|
-
*/
|
|
1209
|
-
private disposeCipherInstance;
|
|
1210
|
-
setEncryption(encryption?: IProviderEncryptionOptions): void;
|
|
1211
|
-
clearEncryption(): void;
|
|
1212
|
-
onDataReceived(callback: (data: any, generation?: number) => void): void;
|
|
1213
|
-
private invokeDataReceivedCallback;
|
|
1214
|
-
hasLastUrl(): boolean;
|
|
1215
|
-
refresh(hardRefresh?: boolean): Promise<any>;
|
|
1216
|
-
private resolveContext;
|
|
1217
|
-
private getInFlightMap;
|
|
1218
|
-
getUniqueKey(url: string, options?: IRequestOptions): string;
|
|
1219
|
-
registerRequest<T>(url: string, options?: IRequestOptions): Promise<T>;
|
|
1220
|
-
static executeAll(): void;
|
|
1221
|
-
private isSameOriginUrl;
|
|
1222
|
-
private getCipherProvider;
|
|
1223
|
-
private isDataEncrypted;
|
|
1224
|
-
private buildEncryptionContext;
|
|
1225
|
-
private decryptPayloadIfNeeded;
|
|
1226
|
-
request<T>(url: string, options?: IRequestOptions): Promise<T>;
|
|
1945
|
+
loadPageData(): void | Promise<void>;
|
|
1946
|
+
protected _executeLoadPageDataSync(): void;
|
|
1947
|
+
protected _executeLoadPageData(): Promise<void>;
|
|
1948
|
+
loadBatch(batchNumber: number): Promise<void>;
|
|
1949
|
+
ensureRangeLoaded(startIndex: number, endIndex: number): Promise<void>;
|
|
1950
|
+
loadRange(startIndex: number, endIndex: number): Promise<void>;
|
|
1951
|
+
resolveRangeRows(startIndex: number, endIndex: number): Promise<TRow[]>;
|
|
1952
|
+
getWindowRows(startIndex: number, endIndex: number): Promise<TRow[]>;
|
|
1953
|
+
hasMissingBatches(): boolean;
|
|
1954
|
+
isBatchLoaded(batchNumber: number): boolean;
|
|
1955
|
+
isFullyLoaded(): boolean;
|
|
1956
|
+
getState(): IDataProviderState<TRow>;
|
|
1957
|
+
setState(partial: Partial<IDataProviderState<TRow>>, options?: IDataProviderSetStateOptions): void;
|
|
1227
1958
|
}
|
|
1228
1959
|
|
|
1229
1960
|
declare abstract class AAPIDataProvider {
|
|
@@ -1249,42 +1980,136 @@ declare class CAPIFlatClientDataProvider<TRow = TDataRow> extends CFlatClientDat
|
|
|
1249
1980
|
cacheStrategy: ECacheStrategy | null;
|
|
1250
1981
|
cacheLifetime: number;
|
|
1251
1982
|
refreshOnMutation: boolean | undefined;
|
|
1252
|
-
|
|
1253
|
-
|
|
1983
|
+
protected _isAccumulating: boolean;
|
|
1984
|
+
protected _isStreamingBatches: boolean;
|
|
1985
|
+
protected _inFlightBatches: Map<number, Promise<void>>;
|
|
1986
|
+
protected _requestGeneration: number;
|
|
1987
|
+
protected _activeUrl: string;
|
|
1988
|
+
protected _abortController?: AbortController;
|
|
1989
|
+
protected _knownIds: Set<string | number>;
|
|
1990
|
+
protected _loadedRowCount: number;
|
|
1991
|
+
protected _optimisticRowCountDelta: number;
|
|
1992
|
+
protected _optimisticallyCreatedIds: Set<string | number>;
|
|
1993
|
+
protected _optimisticallyDeletedIds: Set<string | number>;
|
|
1994
|
+
private _streamRefreshTimer?;
|
|
1254
1995
|
private _lastDataReceivedPromise;
|
|
1996
|
+
private _lastBatch1CallbackGen;
|
|
1997
|
+
private _suppressOnDemandWarn;
|
|
1998
|
+
setData(data: TRow[]): Promise<void> | void;
|
|
1999
|
+
protected _assignAllData(data: TRow[], preserveDecryptedCache?: boolean): void;
|
|
2000
|
+
set allData(data: TRow[]);
|
|
2001
|
+
get allData(): TRow[];
|
|
2002
|
+
protected _extractRowId(row: any): string | number | undefined;
|
|
2003
|
+
protected _resetIndexTrackers(rows?: TRow[]): void;
|
|
2004
|
+
protected _countDefinedRows(): number;
|
|
2005
|
+
protected _clearStreamRefreshTimer(): void;
|
|
2006
|
+
protected _scheduleStreamRefresh(reqGen: number): void;
|
|
2007
|
+
protected _bumpRequestGeneration(nextUrl?: string): number;
|
|
2008
|
+
private _shouldSkipDecryption;
|
|
2009
|
+
private _clearMutationCaches;
|
|
1255
2010
|
constructor(options?: IDataProviderOptions);
|
|
1256
|
-
|
|
2011
|
+
/** Encrypts or indexes incoming rows according to provider encryption settings. Returns null if request became stale. */
|
|
2012
|
+
protected _processIncomingRows(incomingRows: TRow[], isStale: () => boolean): Promise<TRow[] | null>;
|
|
2013
|
+
/** Places batch rows into `allData` at `targetIndex`, preserving sparse holes and updating row trackers. */
|
|
2014
|
+
protected _placeBatchRowsAt(processed: TRow[], targetIndex: number): void;
|
|
2015
|
+
private get _effectiveLoadedCount();
|
|
2016
|
+
get hasMore(): boolean;
|
|
1257
2017
|
setEncryption(encryption?: IProviderEncryptionOptions): void;
|
|
1258
2018
|
clearEncryption(): void;
|
|
1259
2019
|
setContextKey(key: string): void;
|
|
1260
2020
|
setCacheStrategy(strategy: ECacheStrategy): void;
|
|
1261
2021
|
setCacheLifetime(lifetime: number): void;
|
|
2022
|
+
private _tryHydrateFromSsr;
|
|
1262
2023
|
refreshData(options?: {
|
|
1263
2024
|
disableCache?: boolean;
|
|
1264
2025
|
}): Promise<void>;
|
|
2026
|
+
protected _fetchBatched(reqGen: number, batchGen: number, disableCache: boolean, shouldSkipDecryption: boolean): Promise<void>;
|
|
2027
|
+
protected _streamRemainingBatches(reqGen: number, batchGen: number, batchSize: number, disableCache: boolean, shouldSkipDecryption: boolean, startPage?: number): Promise<void>;
|
|
2028
|
+
loadBatch(batchNumber: number, options?: {
|
|
2029
|
+
skipPageLoad?: boolean;
|
|
2030
|
+
}): Promise<void>;
|
|
2031
|
+
ensureRangeLoaded(startIndex: number, endIndex: number): Promise<void>;
|
|
2032
|
+
loadRange(startIndex: number, endIndex: number): Promise<void>;
|
|
2033
|
+
setCurrentPage(currentPage: number): Promise<void>;
|
|
2034
|
+
ingestAllBatches(options?: {
|
|
2035
|
+
skipPageLoad?: boolean;
|
|
2036
|
+
}): Promise<void>;
|
|
2037
|
+
setFilter(filter: IDataFilter | null, immediate?: boolean): Promise<void>;
|
|
2038
|
+
setSortList(sortList: IDataSort[], immediate?: boolean): Promise<void>;
|
|
2039
|
+
loadPageData(options?: {
|
|
2040
|
+
disableCache?: boolean;
|
|
2041
|
+
signal?: AbortSignal;
|
|
2042
|
+
}): Promise<void>;
|
|
1265
2043
|
setAPIUrl(url: string): Promise<void>;
|
|
1266
2044
|
create(item: TRow): Promise<void>;
|
|
1267
2045
|
update(item: TRow): Promise<void>;
|
|
1268
2046
|
delete(items: TRow[]): Promise<void>;
|
|
1269
|
-
loadPageData(): Promise<void>;
|
|
1270
2047
|
}
|
|
1271
2048
|
|
|
1272
2049
|
declare class CFlatServerDataProvider<TRow = TDataRow> extends ADataProvider<TRow> {
|
|
1273
2050
|
pageDataHandler: TPageDataHandler<TRow>;
|
|
1274
2051
|
contextKey: string;
|
|
1275
2052
|
encryption?: IProviderEncryptionOptions;
|
|
2053
|
+
protected _allData: TRow[];
|
|
2054
|
+
private _unpaginatedData;
|
|
2055
|
+
private _unpaginatedDataSignature;
|
|
2056
|
+
protected _isAccumulating: boolean;
|
|
2057
|
+
protected _inFlightLoadMore: boolean;
|
|
2058
|
+
get allData(): TRow[];
|
|
2059
|
+
set allData(val: TRow[]);
|
|
2060
|
+
protected _invalidateUnpaginatedData(): void;
|
|
1276
2061
|
private latestRequestId;
|
|
1277
2062
|
private abortController;
|
|
2063
|
+
private _rangeCache;
|
|
2064
|
+
private _rangeCacheSignature;
|
|
2065
|
+
private _inFlightRangePages;
|
|
2066
|
+
private _verifiedStream;
|
|
2067
|
+
private _preserveVerifiedStreamOnNextLoad;
|
|
2068
|
+
protected _invalidateRangeCache(): void;
|
|
2069
|
+
protected _invalidateVerifiedStream(): void;
|
|
2070
|
+
private _getVerifiedStreamRowCount;
|
|
2071
|
+
private _ensureVerifiedRowsCount;
|
|
1278
2072
|
constructor(options?: IDataProviderOptions);
|
|
1279
2073
|
setEncryption(encryption?: IProviderEncryptionOptions): void;
|
|
1280
2074
|
clearEncryption(): void;
|
|
1281
2075
|
setContextKey(key: string): void;
|
|
1282
2076
|
setPageDataHandler(handler: TPageDataHandler<TRow>): Promise<void>;
|
|
2077
|
+
setCurrentPage(currentPage: number): void | Promise<void>;
|
|
1283
2078
|
loadPageData(options?: {
|
|
1284
2079
|
disableCache?: boolean;
|
|
1285
2080
|
signal?: AbortSignal;
|
|
2081
|
+
page?: number;
|
|
2082
|
+
accumulate?: boolean;
|
|
1286
2083
|
}): Promise<void>;
|
|
2084
|
+
private _applySSRNormalizedResult;
|
|
2085
|
+
private _runLoadPageData;
|
|
2086
|
+
/**
|
|
2087
|
+
* Paginated mode: `currentPage * pageSize < rowCount`.
|
|
2088
|
+
* Accumulating mode (after loadMore): `lastAppendedPage * pageSize < rowCount`.
|
|
2089
|
+
* `_allData.length` is intentionally NOT used: in paginated mode it only holds the current
|
|
2090
|
+
* page (always < rowCount), and after fetchAll() it holds the full dataset.
|
|
2091
|
+
*/
|
|
2092
|
+
get hasMore(): boolean;
|
|
2093
|
+
/**
|
|
2094
|
+
* Appends the next server page to the displayed rows without mutating `currentPage`.
|
|
2095
|
+
*/
|
|
2096
|
+
loadMore(): Promise<void>;
|
|
2097
|
+
/**
|
|
2098
|
+
* Fetches the complete unpaginated dataset from the server (e.g. for charts or exports).
|
|
2099
|
+
* Passes pageSize: 0 to the page data handler without modifying this provider's active paginated `pageSize`.
|
|
2100
|
+
* Stores the result in `_allData` and returns it.
|
|
2101
|
+
*/
|
|
2102
|
+
fetchAll(options?: {
|
|
2103
|
+
disableCache?: boolean;
|
|
2104
|
+
signal?: AbortSignal;
|
|
2105
|
+
}): Promise<TRow[]>;
|
|
1287
2106
|
refresh(hardRefresh?: boolean): Promise<void>;
|
|
2107
|
+
/**
|
|
2108
|
+
* Side-channel random-access window slice resolution for server virtual scrolling.
|
|
2109
|
+
* Fetches only the target server pages covering [startIndex, endIndex) without mutating
|
|
2110
|
+
* `currentPage`, `pageData`, `loading`, or downloading preceding pages sequentially.
|
|
2111
|
+
*/
|
|
2112
|
+
resolveRangeRows(startIndex: number, endIndex: number): Promise<TRow[]>;
|
|
1288
2113
|
cancelPending(): void;
|
|
1289
2114
|
}
|
|
1290
2115
|
|
|
@@ -1320,26 +2145,37 @@ declare class CTreeClientDataProvider<TRow extends TDataRow = TDataRow> extends
|
|
|
1320
2145
|
private _sortedNodeIdsCache;
|
|
1321
2146
|
private _filteredNodesCache;
|
|
1322
2147
|
private _allVisibleRowsCache;
|
|
1323
|
-
|
|
2148
|
+
protected _decryptedNodeMap: Map<string | number, TRow>;
|
|
2149
|
+
clearDecryptedCache(): void;
|
|
2150
|
+
invalidateDecryptedRow(rowOrId: any): void;
|
|
2151
|
+
protected _assignAllData(data: TRow[], preserveDecryptedCache?: boolean): void;
|
|
2152
|
+
get allData(): TRow[];
|
|
2153
|
+
set allData(data: TRow[]);
|
|
1324
2154
|
invalidateStaticCache(): void;
|
|
1325
|
-
|
|
2155
|
+
clearVisibleCache(): void;
|
|
2156
|
+
setFilter(filter: IDataFilter | null, immediate?: boolean): void | Promise<void>;
|
|
1326
2157
|
protected onFilterUpdated(): void;
|
|
1327
2158
|
private get _staticNodes();
|
|
1328
2159
|
private get _nodeMap();
|
|
1329
2160
|
private get _sortedNodeIds();
|
|
1330
2161
|
constructor(options?: ITreeDataProviderOptions);
|
|
1331
|
-
protected _applyTreeData(rows: TRow[]): void;
|
|
2162
|
+
protected _applyTreeData(rows: TRow[], preserveDecryptedCache?: boolean): void;
|
|
1332
2163
|
setData(data: TRow[]): Promise<void> | void;
|
|
2164
|
+
private _decryptAndCacheTreeNodes;
|
|
2165
|
+
protected _setDataBatchedTree(data: TRow[]): Promise<void>;
|
|
1333
2166
|
protected _setDataEncrypted(data: TRow[]): Promise<void>;
|
|
1334
2167
|
setDataChunked(data: TRow[], options?: ISetDataChunkedOptions): Promise<void>;
|
|
1335
|
-
private buildStaticNodes;
|
|
1336
2168
|
protected onSortUpdated(): void;
|
|
1337
|
-
setSortList(sortList: IDataSort[], immediate?: boolean): void
|
|
1338
|
-
private computeSortedIds;
|
|
1339
|
-
private isNodeVisible;
|
|
2169
|
+
setSortList(sortList: IDataSort[], immediate?: boolean): void | Promise<void>;
|
|
1340
2170
|
private paginateNodes;
|
|
2171
|
+
private _createTreeNodeFilterEvaluator;
|
|
1341
2172
|
private updatePageData;
|
|
1342
|
-
|
|
2173
|
+
protected _executeLoadPageDataSync(): void;
|
|
2174
|
+
protected _executeLoadPageData(): Promise<void>;
|
|
2175
|
+
refreshData(options?: {
|
|
2176
|
+
disableCache?: boolean;
|
|
2177
|
+
}): Promise<void>;
|
|
2178
|
+
setEncryption(encryption?: IProviderEncryptionOptions): void;
|
|
1343
2179
|
clearEncryption(): void;
|
|
1344
2180
|
get treeNodes(): ITreeNode<TRow>[];
|
|
1345
2181
|
get allVisibleNodes(): ITreeNode<TRow>[];
|
|
@@ -1349,9 +2185,12 @@ declare class CTreeClientDataProvider<TRow extends TDataRow = TDataRow> extends
|
|
|
1349
2185
|
get allVisibleRows(): (TRow & ITreeNode<TRow> & {
|
|
1350
2186
|
__treeNode: ITreeNode<TRow>;
|
|
1351
2187
|
})[];
|
|
2188
|
+
resolveRangeRows(startIndex: number, endIndex: number): Promise<TRow[]>;
|
|
2189
|
+
getWindowRows(startIndex: number, endIndex: number): Promise<TRow[]>;
|
|
1352
2190
|
get visibleRows(): ITreeNode<TRow>[];
|
|
1353
2191
|
getAllNodes(): ITreeNode<TRow>[];
|
|
1354
2192
|
getFlatNodes(): ITreeNode<TRow>[];
|
|
2193
|
+
private _commitExpansionChange;
|
|
1355
2194
|
toggleNode(nodeId: string | number): void;
|
|
1356
2195
|
expand(nodeId: string | number): void;
|
|
1357
2196
|
collapse(nodeId: string | number): void;
|
|
@@ -1359,6 +2198,7 @@ declare class CTreeClientDataProvider<TRow extends TDataRow = TDataRow> extends
|
|
|
1359
2198
|
collapseNode(nodeId: string | number): void;
|
|
1360
2199
|
expandAll(): void;
|
|
1361
2200
|
collapseAll(): void;
|
|
2201
|
+
setExpandedNodes(nodes: Set<string | number> | (string | number)[]): void;
|
|
1362
2202
|
getNode(nodeId: string | number): ITreeNode<TRow> | undefined;
|
|
1363
2203
|
getChildren(nodeId: string | number): ITreeNode<TRow>[];
|
|
1364
2204
|
getParent(nodeId: string | number): ITreeNode<TRow> | undefined;
|
|
@@ -1371,8 +2211,22 @@ declare class CAPITreeClientDataProvider<TRow extends TDataRow = TDataRow> exten
|
|
|
1371
2211
|
cacheStrategy: ECacheStrategy | null;
|
|
1372
2212
|
cacheLifetime: number;
|
|
1373
2213
|
refreshOnMutation: boolean | undefined;
|
|
2214
|
+
protected _isAccumulating: boolean;
|
|
2215
|
+
protected _inFlightBatches: Map<number, Promise<void>>;
|
|
2216
|
+
protected _requestGeneration: number;
|
|
2217
|
+
protected _activeUrl: string;
|
|
2218
|
+
protected _abortController?: AbortController;
|
|
1374
2219
|
private _lastDataReceivedPromise;
|
|
2220
|
+
private _lastBatch1CallbackGen;
|
|
2221
|
+
setData(data: TRow[]): Promise<void> | void;
|
|
2222
|
+
protected _bumpRequestGeneration(nextUrl?: string): number;
|
|
2223
|
+
private _shouldSkipDecryption;
|
|
2224
|
+
private _clearMutationCaches;
|
|
1375
2225
|
constructor(options?: ITreeDataProviderOptions);
|
|
2226
|
+
/** Encrypts or indexes incoming tree rows when field encryption is enabled. Returns null if stale. */
|
|
2227
|
+
protected _processIncomingTreeRows(incomingRows: TRow[], isStale: () => boolean): Promise<TRow[] | null>;
|
|
2228
|
+
/** Deduplicates incoming tree rows by idKey and appends them to the existing tree buffer. */
|
|
2229
|
+
protected _mergeTreeRows(rows: TRow[]): void;
|
|
1376
2230
|
setEncryption(encryption?: IProviderEncryptionOptions): void;
|
|
1377
2231
|
clearEncryption(): void;
|
|
1378
2232
|
setContextKey(key: string): void;
|
|
@@ -1380,12 +2234,25 @@ declare class CAPITreeClientDataProvider<TRow extends TDataRow = TDataRow> exten
|
|
|
1380
2234
|
refreshData(options?: {
|
|
1381
2235
|
disableCache?: boolean;
|
|
1382
2236
|
}): Promise<void>;
|
|
2237
|
+
private _tryHydrateTreeFromSsr;
|
|
1383
2238
|
private _initialFetch;
|
|
2239
|
+
protected _fetchBatchedTree(reqGen: number, batchGen: number, disableCache: boolean, shouldSkipDecryption: boolean): Promise<void>;
|
|
2240
|
+
protected _streamRemainingTreeBatches(reqGen: number, batchGen: number, batchSize: number, disableCache: boolean, shouldSkipDecryption: boolean, startPage?: number): Promise<void>;
|
|
2241
|
+
loadBatch(batchNumber: number): Promise<void>;
|
|
2242
|
+
ensureRangeLoaded(startIndex: number, endIndex: number): Promise<void>;
|
|
2243
|
+
loadRange(startIndex: number, endIndex: number): Promise<void>;
|
|
2244
|
+
setCurrentPage(currentPage: number): Promise<void>;
|
|
2245
|
+
ingestAllBatches(): Promise<void>;
|
|
2246
|
+
setFilter(filter: IDataFilter | null, immediate?: boolean): Promise<void>;
|
|
2247
|
+
setSortList(sortList: IDataSort[], immediate?: boolean): Promise<void>;
|
|
2248
|
+
loadPageData(options?: {
|
|
2249
|
+
disableCache?: boolean;
|
|
2250
|
+
signal?: AbortSignal;
|
|
2251
|
+
}): Promise<void>;
|
|
1384
2252
|
setAPIUrl(url: string): Promise<void>;
|
|
1385
2253
|
create(item: TRow): Promise<void>;
|
|
1386
2254
|
update(item: TRow): Promise<void>;
|
|
1387
2255
|
delete(items: TRow[]): Promise<void>;
|
|
1388
|
-
loadPageData(): Promise<void>;
|
|
1389
2256
|
}
|
|
1390
2257
|
|
|
1391
2258
|
/**
|
|
@@ -1404,6 +2271,7 @@ declare class CTreeServerDataProvider<TRow = TDataRow> extends ADataProvider<TRo
|
|
|
1404
2271
|
paginateBy: TreePaginationMode;
|
|
1405
2272
|
expandedNodes: Set<string | number>;
|
|
1406
2273
|
pageDataHandler: TTreePageDataHandler<TRow> | null;
|
|
2274
|
+
protected _isAccumulating: boolean;
|
|
1407
2275
|
contextKey: string;
|
|
1408
2276
|
encryption?: IProviderEncryptionOptions;
|
|
1409
2277
|
constructor(options?: ITreeDataProviderOptions);
|
|
@@ -1411,8 +2279,29 @@ declare class CTreeServerDataProvider<TRow = TDataRow> extends ADataProvider<TRo
|
|
|
1411
2279
|
clearEncryption(): void;
|
|
1412
2280
|
setContextKey(key: string): void;
|
|
1413
2281
|
setPageDataHandler(handler: TTreePageDataHandler<TRow>): Promise<void>;
|
|
2282
|
+
setCurrentPage(currentPage: number): void | Promise<void>;
|
|
1414
2283
|
private latestRequestId;
|
|
1415
2284
|
private abortController;
|
|
2285
|
+
private _rangeCache;
|
|
2286
|
+
private _rangeCacheSignature;
|
|
2287
|
+
private _inFlightRangePages;
|
|
2288
|
+
private _verifiedTreeStream;
|
|
2289
|
+
private _preserveVerifiedStreamOnNextLoad;
|
|
2290
|
+
private _unpaginatedData;
|
|
2291
|
+
get unpaginatedData(): TRow[] | null;
|
|
2292
|
+
protected _invalidateUnpaginatedData(): void;
|
|
2293
|
+
protected onFilterUpdated(): void;
|
|
2294
|
+
protected onSortUpdated(): void;
|
|
2295
|
+
protected _invalidateRangeCache(): void;
|
|
2296
|
+
protected _invalidateVerifiedStream(): void;
|
|
2297
|
+
private _createTreeParams;
|
|
2298
|
+
private _getTreeFilledItemCount;
|
|
2299
|
+
private _getTreeVerifiedRowCount;
|
|
2300
|
+
private _getTreePageRows;
|
|
2301
|
+
private _appendAndVerifyTreeBatch;
|
|
2302
|
+
private _flushTreeTelemetry;
|
|
2303
|
+
private _ensureVerifiedTreeCount;
|
|
2304
|
+
protected _querySignature(): string;
|
|
1416
2305
|
/**
|
|
1417
2306
|
* Load page data from server
|
|
1418
2307
|
* Server handles tree building, visibility, and pagination
|
|
@@ -1420,8 +2309,24 @@ declare class CTreeServerDataProvider<TRow = TDataRow> extends ADataProvider<TRo
|
|
|
1420
2309
|
loadPageData(options?: {
|
|
1421
2310
|
disableCache?: boolean;
|
|
1422
2311
|
signal?: AbortSignal;
|
|
2312
|
+
page?: number;
|
|
2313
|
+
accumulate?: boolean;
|
|
1423
2314
|
}): Promise<void>;
|
|
2315
|
+
private _applySSRNormalizedResult;
|
|
2316
|
+
private _runLoadPageData;
|
|
1424
2317
|
refresh(hardRefresh?: boolean): Promise<void>;
|
|
2318
|
+
resolveRangeRows(startIndex: number, endIndex: number): Promise<TRow[]>;
|
|
2319
|
+
loadMore(): Promise<void>;
|
|
2320
|
+
protected _loadMoreInFlight: boolean;
|
|
2321
|
+
protected fetchPageForLoadMore(page: number): Promise<TRow[]>;
|
|
2322
|
+
protected _unpaginatedCache: {
|
|
2323
|
+
sig: string;
|
|
2324
|
+
rows: TRow[];
|
|
2325
|
+
} | null;
|
|
2326
|
+
fetchAll(options?: {
|
|
2327
|
+
disableCache?: boolean;
|
|
2328
|
+
signal?: AbortSignal;
|
|
2329
|
+
}): Promise<TRow[]>;
|
|
1425
2330
|
cancelPending(): void;
|
|
1426
2331
|
toggleNode(nodeId: string | number): void;
|
|
1427
2332
|
expand(nodeId: string | number): void;
|
|
@@ -1621,6 +2526,7 @@ declare class CLocalStorageCache extends ACacheProvider {
|
|
|
1621
2526
|
static getInstance(): CLocalStorageCache;
|
|
1622
2527
|
type: string;
|
|
1623
2528
|
private quotaOptions;
|
|
2529
|
+
private inMemoryAccessMeta;
|
|
1624
2530
|
configureQuota(options: Partial<ICacheQuotaOptions>): void;
|
|
1625
2531
|
getQuotaOptions(): Required<ICacheQuotaOptions>;
|
|
1626
2532
|
private constructor();
|
|
@@ -1794,6 +2700,7 @@ declare class RequestProviderRegistry {
|
|
|
1794
2700
|
}
|
|
1795
2701
|
|
|
1796
2702
|
declare const SENSITIVE_HEADER_KEYS: string[];
|
|
2703
|
+
|
|
1797
2704
|
/**
|
|
1798
2705
|
* RequestQueue
|
|
1799
2706
|
*
|
|
@@ -1805,19 +2712,6 @@ declare const SENSITIVE_HEADER_KEYS: string[];
|
|
|
1805
2712
|
* - No internal retry: the queue is the retry mechanism (items persist until flushed)
|
|
1806
2713
|
* - Partial refresh: registry refresh fires for succeeded tags only
|
|
1807
2714
|
* - Dead-letter is final: Katlux never auto-retries — app decides via retryOne() or discard()
|
|
1808
|
-
*
|
|
1809
|
-
* Usage:
|
|
1810
|
-
* RequestQueue.setStorageBackend(EQueueStorage.IndexedDB)
|
|
1811
|
-
* await RequestQueue.init() // call once at app startup
|
|
1812
|
-
*
|
|
1813
|
-
* // Hooks (set in app setup, not in components)
|
|
1814
|
-
* RequestQueue.onDeadLetter((item, err) => toast.error(`Failed: ${item.label}`))
|
|
1815
|
-
* RequestQueue.onFlushComplete((tags) => console.log('Synced tags:', tags))
|
|
1816
|
-
* RequestQueue.onNetworkError((item) => toast.warn('Offline — will retry when back online'))
|
|
1817
|
-
* RequestQueue.onError((err) => toast.error(`Queue error: ${err.message}`))
|
|
1818
|
-
*
|
|
1819
|
-
* // Flush when back online
|
|
1820
|
-
* window.addEventListener('online', () => RequestQueue.flushAll())
|
|
1821
2715
|
*/
|
|
1822
2716
|
declare class RequestQueue {
|
|
1823
2717
|
static queue: IQueuedOperation[];
|
|
@@ -1830,30 +2724,17 @@ declare class RequestQueue {
|
|
|
1830
2724
|
static setMaxQueueSize(limit: number): void;
|
|
1831
2725
|
static setMaxDeadLetterSize(limit: number): void;
|
|
1832
2726
|
/**
|
|
1833
|
-
*
|
|
1834
|
-
* request options to persistent storage (IndexedDB / LocalStorage).
|
|
1835
|
-
* Sensitive credentials must never be stored in plaintext in browser storage, and are
|
|
1836
|
-
* instead regenerated dynamically at execution time.
|
|
2727
|
+
* Canonical URL resolver appending query parameters consistently with RequestProvider.
|
|
1837
2728
|
*/
|
|
2729
|
+
static resolveFullRequestUrl(url: string, query?: any): string;
|
|
1838
2730
|
/**
|
|
1839
|
-
* Adapts binary, multipart, and specialized payload types
|
|
1840
|
-
* ArrayBuffer, TypedArrays, URLSearchParams) into JSON-serializable structures
|
|
1841
|
-
* to prevent silent payload loss (BUG-014) when persisting to offline storage.
|
|
2731
|
+
* Adapts binary, multipart, and specialized payload types into JSON-serializable structures.
|
|
1842
2732
|
*/
|
|
1843
2733
|
static serializeBody(body: any): Promise<any>;
|
|
1844
|
-
private static serializeFieldValue;
|
|
1845
2734
|
/**
|
|
1846
|
-
* Reconstitutes serialized offline request bodies back into
|
|
1847
|
-
* (FormData, Blob, File, ArrayBuffer, Uint8Array, URLSearchParams) before network transmission.
|
|
2735
|
+
* Reconstitutes serialized offline request bodies back into live runtime instances.
|
|
1848
2736
|
*/
|
|
1849
2737
|
static reconstituteBody(body: any): any;
|
|
1850
|
-
/**
|
|
1851
|
-
* Strips sensitive headers (e.g., authorization, cookie, x-csrf-token) before persisting
|
|
1852
|
-
* request options to persistent storage (IndexedDB / LocalStorage).
|
|
1853
|
-
* Sensitive credentials must never be stored in plaintext in browser storage, and are
|
|
1854
|
-
* instead regenerated dynamically at execution time.
|
|
1855
|
-
*/
|
|
1856
|
-
private static sanitizeOptions;
|
|
1857
2738
|
private static _subscribers;
|
|
1858
2739
|
static subscribe(listener: () => void): () => void;
|
|
1859
2740
|
static notify(): void;
|
|
@@ -1865,15 +2746,21 @@ declare class RequestQueue {
|
|
|
1865
2746
|
private static _onNetworkError;
|
|
1866
2747
|
private static _onError;
|
|
1867
2748
|
private static _headerProvider;
|
|
2749
|
+
private static _cipherResolver;
|
|
2750
|
+
private static _defaultCipherResolver;
|
|
2751
|
+
private static _resetHooks;
|
|
2752
|
+
static onReset(hook: () => void): void;
|
|
1868
2753
|
static setHeaderProvider(provider: (() => Record<string, string> | Promise<Record<string, string>>) | null): void;
|
|
2754
|
+
static setCipherResolver(resolver: ((kid?: string) => IEncryptionProvider | Promise<IEncryptionProvider> | null | undefined) | null): void;
|
|
2755
|
+
static setCipherProvider(provider: IEncryptionProvider | ((kid?: string) => IEncryptionProvider | Promise<IEncryptionProvider> | null | undefined) | null): void;
|
|
2756
|
+
static setDefaultCipherResolver(resolver: ((kid?: string) => IEncryptionProvider | Promise<IEncryptionProvider> | null | undefined) | null): void;
|
|
2757
|
+
private static resolveCipher;
|
|
1869
2758
|
/**
|
|
1870
2759
|
* Load persisted queue from storage into state.
|
|
1871
|
-
* Call once at app startup, before any flush or enqueue operations.
|
|
1872
2760
|
*/
|
|
1873
2761
|
static init(): Promise<void>;
|
|
1874
2762
|
/**
|
|
1875
2763
|
* Set the storage backend. Call before init().
|
|
1876
|
-
* Defaults to IndexedDB with fallback to LocalStorage → Memory.
|
|
1877
2764
|
*/
|
|
1878
2765
|
static setStorageBackend(backend: EQueueStorage): void;
|
|
1879
2766
|
static onDeadLetter(cb: (item: IDeadLetterItem, error: Error) => void): void;
|
|
@@ -1883,26 +2770,21 @@ declare class RequestQueue {
|
|
|
1883
2770
|
static onQueueFatalError(cb: (error: Error) => void): void;
|
|
1884
2771
|
/**
|
|
1885
2772
|
* Add an operation to the pending queue and persist it.
|
|
1886
|
-
* Called internally by RequestProvider when queue: true.
|
|
1887
|
-
* Returns the stable ID of the queued item.
|
|
1888
2773
|
*/
|
|
1889
2774
|
static enqueue(operation: Omit<IQueuedOperation, 'id' | 'createdAt' | 'flushAttempts' | 'status'>): Promise<string>;
|
|
1890
2775
|
static getQueue(tag?: string): IQueuedOperation[];
|
|
1891
2776
|
static getDeadLetterQueue(tag?: string): IDeadLetterItem[];
|
|
2777
|
+
private static handleFlushFailure;
|
|
1892
2778
|
/**
|
|
1893
|
-
* Flush queued items in FIFO order.
|
|
1894
|
-
* Stops on first failure. Refreshes registry for succeeded tags only.
|
|
2779
|
+
* Flush queued items in FIFO order. Stops on first failure.
|
|
1895
2780
|
*/
|
|
1896
2781
|
static flushAll(options?: IFlushOptions): Promise<void>;
|
|
1897
2782
|
/**
|
|
1898
2783
|
* Flush a specific pending item by ID, independent of queue position.
|
|
1899
|
-
* On success: triggers registry refresh for its own tags.
|
|
1900
|
-
* On failure: moves to dead-letter independently.
|
|
1901
2784
|
*/
|
|
1902
2785
|
static flushOne(id: string): Promise<void>;
|
|
1903
2786
|
/**
|
|
1904
2787
|
* Move a dead-letter item back to the FRONT of the pending queue for retry.
|
|
1905
|
-
* App should call flushAll() afterwards.
|
|
1906
2788
|
*/
|
|
1907
2789
|
static retryOne(id: string): Promise<void>;
|
|
1908
2790
|
/**
|
|
@@ -1911,7 +2793,6 @@ declare class RequestQueue {
|
|
|
1911
2793
|
static discard(id: string): Promise<void>;
|
|
1912
2794
|
/**
|
|
1913
2795
|
* Reorder the pending queue by providing an ordered array of IDs.
|
|
1914
|
-
* Fully permissive — causal ordering is the app's responsibility.
|
|
1915
2796
|
*/
|
|
1916
2797
|
static reorder(ids: string[]): void;
|
|
1917
2798
|
private static regenerateHeaders;
|
|
@@ -1942,16 +2823,36 @@ declare class QueueStorageFactory {
|
|
|
1942
2823
|
static _reset(): void;
|
|
1943
2824
|
}
|
|
1944
2825
|
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
declare const
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
2826
|
+
/**
|
|
2827
|
+
* Detects whether an arbitrary value is an encrypted payload envelope.
|
|
2828
|
+
*/
|
|
2829
|
+
declare const isEncryptedPayload: (payload: any) => boolean;
|
|
2830
|
+
/**
|
|
2831
|
+
* Recursively extracts all target field names referenced by an active filter.
|
|
2832
|
+
*/
|
|
2833
|
+
declare const extractFilterFieldNames: (filter: any) => string[];
|
|
2834
|
+
/**
|
|
2835
|
+
* Checks substring containment (`needle` in `haystack`) using shared normalization.
|
|
2836
|
+
*/
|
|
2837
|
+
declare const compareContains: (rowValue: any, filterValue: any, options?: INormalizeOptions) => boolean;
|
|
2838
|
+
/**
|
|
2839
|
+
* Standard set membership check (`val IN [a, b, c]`).
|
|
2840
|
+
*/
|
|
2841
|
+
declare const compareIn: (rowValue: any, filterValue: any, options?: INormalizeOptions) => boolean;
|
|
2842
|
+
declare const compareEqual: (rowValue: any, filterValue: any, options?: INormalizeOptions) => boolean;
|
|
2843
|
+
declare const compareValues: (rowValue: any, filterValue: any, options?: INormalizeOptions) => number;
|
|
2844
|
+
declare const compareAnd: (row: TDataRow, nested: any, options?: INormalizeOptions) => boolean;
|
|
2845
|
+
declare const compareOr: (row: TDataRow, nested: any, options?: INormalizeOptions) => boolean;
|
|
2846
|
+
declare const applyOperator: (operator: string, rowValue: any, filterValue: any, options?: INormalizeOptions) => boolean;
|
|
2847
|
+
/**
|
|
2848
|
+
* Normalizes standard and shorthand filter structures into a canonical IDataFilter tree.
|
|
2849
|
+
*/
|
|
2850
|
+
declare const normalizeFilter: (filter: any) => IDataFilter | null;
|
|
2851
|
+
declare const evaluateFilter: (filter: IDataFilter | any, row: TDataRow, options?: INormalizeOptions) => boolean;
|
|
1952
2852
|
declare const filterTreeData: (nodes: any[], filter: IDataFilter, options: {
|
|
1953
2853
|
idKey: string;
|
|
1954
2854
|
parentKey: string;
|
|
2855
|
+
normalizeOptions?: INormalizeOptions;
|
|
1955
2856
|
}) => {
|
|
1956
2857
|
visibleNodes: any[];
|
|
1957
2858
|
expandedNodes: Set<string | number>;
|
|
@@ -1962,15 +2863,27 @@ declare const filterData: (data: any[], filter: IDataFilter, options?: {
|
|
|
1962
2863
|
parentKey: string;
|
|
1963
2864
|
};
|
|
1964
2865
|
rowEvaluator?: (row: any) => boolean;
|
|
2866
|
+
normalizeOptions?: INormalizeOptions;
|
|
1965
2867
|
}) => {
|
|
1966
2868
|
results: any[];
|
|
1967
2869
|
expandedNodes?: Set<string | number>;
|
|
1968
2870
|
};
|
|
1969
|
-
declare const useFilterLogic: () => {
|
|
1970
|
-
|
|
2871
|
+
declare const useFilterLogic: (defaultOptions?: INormalizeOptions) => {
|
|
2872
|
+
isEncryptedPayload: (payload: any) => boolean;
|
|
2873
|
+
extractFilterFieldNames: (filter: any) => string[];
|
|
2874
|
+
normalizeFilter: (filter: any) => IDataFilter | null;
|
|
2875
|
+
normalizeFilterValue: typeof normalizeFilterValue;
|
|
2876
|
+
foldAscii: typeof foldAscii;
|
|
2877
|
+
compareEqual: (rowValue: any, filterValue: any, options?: INormalizeOptions) => boolean;
|
|
2878
|
+
compareIn: (rowValue: any, filterValue: any, options?: INormalizeOptions) => boolean;
|
|
2879
|
+
compareContains: (rowValue: any, filterValue: any, options?: INormalizeOptions) => boolean;
|
|
2880
|
+
compareValues: (rowValue: any, filterValue: any, options?: INormalizeOptions) => number;
|
|
2881
|
+
applyOperator: (operator: string, rowValue: any, filterValue: any, options?: INormalizeOptions) => boolean;
|
|
2882
|
+
evaluateFilter: (filter: IDataFilter | any, row: TDataRow, options?: INormalizeOptions) => boolean;
|
|
1971
2883
|
filterTreeData: (nodes: any[], filter: IDataFilter, options: {
|
|
1972
2884
|
idKey: string;
|
|
1973
2885
|
parentKey: string;
|
|
2886
|
+
normalizeOptions?: INormalizeOptions;
|
|
1974
2887
|
}) => {
|
|
1975
2888
|
visibleNodes: any[];
|
|
1976
2889
|
expandedNodes: Set<string | number>;
|
|
@@ -1981,15 +2894,21 @@ declare const useFilterLogic: () => {
|
|
|
1981
2894
|
parentKey: string;
|
|
1982
2895
|
};
|
|
1983
2896
|
rowEvaluator?: (row: any) => boolean;
|
|
2897
|
+
normalizeOptions?: INormalizeOptions;
|
|
1984
2898
|
}) => {
|
|
1985
2899
|
results: any[];
|
|
1986
2900
|
expandedNodes?: Set<string | number>;
|
|
1987
2901
|
};
|
|
1988
2902
|
};
|
|
1989
2903
|
|
|
1990
|
-
|
|
2904
|
+
interface ISortDataOptions {
|
|
2905
|
+
resolveValue?: (row: TDataRow, field: string) => any;
|
|
2906
|
+
rangeBuckets?: Record<string, TRangeBucketConfig>;
|
|
2907
|
+
locale?: string;
|
|
2908
|
+
}
|
|
2909
|
+
declare const sortData: (sortList: IDataSort[], rows: TDataRow[], options?: ISortDataOptions) => TDataRow[];
|
|
1991
2910
|
declare const useSortLogic: () => {
|
|
1992
|
-
sortData: (sortList: IDataSort[], rows: TDataRow[]) => TDataRow[];
|
|
2911
|
+
sortData: (sortList: IDataSort[], rows: TDataRow[], options?: ISortDataOptions) => TDataRow[];
|
|
1993
2912
|
};
|
|
1994
2913
|
|
|
1995
2914
|
interface IDebouncedFunction<T extends (...args: any[]) => any> {
|
|
@@ -2054,6 +2973,41 @@ declare function getAppRouter(): any;
|
|
|
2054
2973
|
*/
|
|
2055
2974
|
declare function onPlatformReady(cb: () => void): void;
|
|
2056
2975
|
|
|
2976
|
+
/** Converts an optional AAD string or binary view into a non-empty `Uint8Array`. */
|
|
2977
|
+
declare function aadToBytes(aad?: string | Uint8Array | ArrayBuffer): Uint8Array | undefined;
|
|
2978
|
+
/** Decodes and concatenates Base64/binary ciphertext with an optional detached auth tag. */
|
|
2979
|
+
declare function combineCiphertextAndTag(ciphertext: Uint8Array | string, tag?: Uint8Array | string, expectedTagLength?: number, providerLabel?: string): Uint8Array;
|
|
2980
|
+
/** Serializes a JSON-compatible value into UTF-8 plaintext bytes for sealing. */
|
|
2981
|
+
declare function serializePlaintextToBytes(data: any): Uint8Array;
|
|
2982
|
+
/**
|
|
2983
|
+
* Decodes decrypted plaintext bytes into UTF-8, zeroes the plaintext buffer in `finally`,
|
|
2984
|
+
* and parses JSON while throwing a sanitized `SyntaxError` with zero plaintext leakage.
|
|
2985
|
+
*/
|
|
2986
|
+
declare function parseDecryptedJsonSafely(decryptedBytes: ArrayBuffer | Uint8Array, providerLabel?: string): any;
|
|
2987
|
+
/** Normalizes low-level cipher/unwrap errors while preserving sanitized `SyntaxError` and tagged provider errors. */
|
|
2988
|
+
declare function normalizeDecryptError(err: any, providerLabel: string, fallbackMessage?: string): Error;
|
|
2989
|
+
type IAsymmetricSecurityDefaults = Pick<IBaseEncryptionProviderOptions, 'pinningStore' | 'pinEntityId' | 'pinningOptions' | 'senderSigningPrivateKey' | 'senderVerifyPublicKey' | 'requireSenderSignature'>;
|
|
2990
|
+
/**
|
|
2991
|
+
* Exhaustive tuple of constructor/keyring/KDF/policy/asymmetric-security keys
|
|
2992
|
+
* forwarded from `IProviderEncryptionOptions` to provider constructors.
|
|
2993
|
+
*/
|
|
2994
|
+
declare const PROVIDER_CONSTRUCTOR_OPTION_KEYS: readonly ["keys", "activeKid", "kid", "keyId", "allowedKids", "allowedAlgorithms", "hmacKey", "kdf", "kdfIterations", "kdfHash", "kdfSalt", "info", "allowInsecureKdf", "allowUnboundAadFallback", "maxAllowedIterations", "maxSaltDerivations", "pinningStore", "pinEntityId", "pinningOptions", "senderSigningPrivateKey", "senderVerifyPublicKey", "requireSenderSignature"];
|
|
2995
|
+
/**
|
|
2996
|
+
* Exhaustive tuple of runtime operation keys forwarded from
|
|
2997
|
+
* `IProviderEncryptionOptions` into `IEncryptionContext`.
|
|
2998
|
+
*/
|
|
2999
|
+
declare const ENCRYPTION_CONTEXT_KEYS: readonly ["keys", "activeKid", "kid", "keyId", "allowedKids", "allowedAlgorithms", "hmacKey", "kdf", "kdfIterations", "kdfHash", "kdfSalt", "info", "allowInsecureKdf", "allowUnboundAadFallback", "maxAllowedIterations", "maxSaltDerivations", "pinningStore", "pinEntityId", "pinningOptions", "senderSigningPrivateKey", "senderVerifyPublicKey", "requireSenderSignature", "key", "bindRequestContextAad", "fields", "unencryptedFields", "strict", "onDecryptError", "aad", "aadFields", "baseAad", "valueEncryption", "publicKey", "privateKey", "recipientPublicKey", "recipientPrivateKey", "curve"];
|
|
3000
|
+
/** Extracts defined constructor options for `AEncryptionProvider` subclasses, preserving `kid || keyId` fallback. */
|
|
3001
|
+
declare function pickProviderOptions(options?: IProviderEncryptionOptions): IBaseEncryptionProviderOptions;
|
|
3002
|
+
/** Extracts defined `IEncryptionContext` fields from `IProviderEncryptionOptions` plus optional request/url metadata. */
|
|
3003
|
+
declare function pickEncryptionContext(options?: IProviderEncryptionOptions, overrides?: Pick<IEncryptionContext, 'url' | 'method' | 'isServer'>): IEncryptionContext;
|
|
3004
|
+
|
|
3005
|
+
interface IEncryptRecordSession {
|
|
3006
|
+
dispose?(): void;
|
|
3007
|
+
}
|
|
3008
|
+
interface IDecryptBatchSession {
|
|
3009
|
+
dispose?(): void;
|
|
3010
|
+
}
|
|
2057
3011
|
/**
|
|
2058
3012
|
* Foundational abstract base class for all Katlux encryption provider implementations.
|
|
2059
3013
|
* Provides key storage, lifecycle management, reusable value-level traversal,
|
|
@@ -2065,503 +3019,728 @@ declare abstract class AEncryptionProvider implements IEncryptionProvider {
|
|
|
2065
3019
|
protected keys?: Record<string, TKeyProvider | IKeyPair>;
|
|
2066
3020
|
protected activeKid?: string;
|
|
2067
3021
|
protected allowedKids?: string[];
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
3022
|
+
protected allowedAlgorithms?: TEncryptionAlgorithm[];
|
|
3023
|
+
protected defaultAllowedAlgorithms: TEncryptionAlgorithm[];
|
|
3024
|
+
protected allowInsecureKdf?: boolean;
|
|
3025
|
+
protected allowUnboundAadFallback?: boolean;
|
|
3026
|
+
protected maxAllowedIterations?: number;
|
|
3027
|
+
protected maxSaltDerivations?: number;
|
|
3028
|
+
protected pinningStore?: IKeyPinningStore;
|
|
3029
|
+
protected pinEntityId?: string;
|
|
3030
|
+
protected pinningOptions?: Partial<Omit<IVerifyAndPinOptions, 'store'>> & {
|
|
3031
|
+
store?: IKeyPinningStore;
|
|
3032
|
+
};
|
|
3033
|
+
protected senderSigningPrivateKey?: CryptoKey;
|
|
3034
|
+
protected senderVerifyPublicKey?: CryptoKey;
|
|
3035
|
+
protected requireSenderSignature?: boolean;
|
|
3036
|
+
protected _configuredKid?: string;
|
|
3037
|
+
protected _usesAsymmetricEnvelopeSignature: boolean;
|
|
3038
|
+
constructor(key?: TKeyProvider | IKeyPair | any, options?: IBaseEncryptionProviderOptions);
|
|
3039
|
+
protected _getAsymmetricSecurityDefaults(): IAsymmetricSecurityDefaults;
|
|
3040
|
+
/**
|
|
3041
|
+
* Enforces the symmetric KDF strategy allow-list (`pbkdf2`, `hkdf`, `none`)
|
|
3042
|
+
* and disallows `kdf: 'none'` for encryption or without `allowInsecureKdf: true` on decrypt.
|
|
3043
|
+
*/
|
|
3044
|
+
protected _assertKdfAllowed(kdf: string, isEncrypt: boolean, options?: IEncryptionContext): void;
|
|
2078
3045
|
setDefaultKey(key: TKeyProvider | IKeyPair): void;
|
|
2079
|
-
/**
|
|
2080
|
-
* Retrieves the currently configured default key or key provider callback.
|
|
2081
|
-
*/
|
|
2082
3046
|
getDefaultKey(): TKeyProvider | IKeyPair | undefined;
|
|
2083
|
-
/**
|
|
2084
|
-
* Configures a keyring dictionary of keys with an optional active key identifier.
|
|
2085
|
-
*/
|
|
2086
3047
|
setKeyring(keys: Record<string, TKeyProvider | IKeyPair>, activeKid?: string): void;
|
|
2087
|
-
/**
|
|
2088
|
-
* Retrieves the currently configured keyring dictionary.
|
|
2089
|
-
*/
|
|
2090
3048
|
getKeyring(): Record<string, TKeyProvider | IKeyPair> | undefined;
|
|
2091
|
-
/**
|
|
2092
|
-
* Sets the active Key Identifier (kid) to use for outbound encryption.
|
|
2093
|
-
*/
|
|
2094
3049
|
setActiveKid(kid: string): void;
|
|
2095
|
-
/**
|
|
2096
|
-
* Retrieves the active Key Identifier (kid).
|
|
2097
|
-
*/
|
|
2098
3050
|
getActiveKid(): string | undefined;
|
|
2099
|
-
/**
|
|
2100
|
-
* Sets or updates the dedicated HMAC key or key provider callback for blind indexing.
|
|
2101
|
-
*/
|
|
2102
3051
|
setHmacKey(key: TKeyProvider): void;
|
|
2103
|
-
/**
|
|
2104
|
-
* Retrieves the currently configured HMAC key or key provider callback.
|
|
2105
|
-
*/
|
|
2106
3052
|
getHmacKey(): TKeyProvider | undefined;
|
|
2107
|
-
|
|
2108
|
-
* Computes a deterministic HMAC-SHA256 blind index hash for an arbitrary term.
|
|
2109
|
-
* If no hmacKey is explicitly provided, uses the provider's configured hmacKey or default key.
|
|
2110
|
-
*/
|
|
2111
|
-
computeBlindIndex(value: any, hmacKey?: CryptoKey | TKeyProvider): Promise<string>;
|
|
2112
|
-
/**
|
|
2113
|
-
* Pre-derives and caches the native CryptoKey for subsequent cryptographic operations.
|
|
2114
|
-
* Subclasses should override this with a dedicated, non-side-effecting implementation.
|
|
2115
|
-
*/
|
|
3053
|
+
computeBlindIndex(value: any, hmacKeyOrOptions?: CryptoKey | TKeyProvider | IBlindIndexOptions, options?: IBlindIndexOptions): Promise<string>;
|
|
2116
3054
|
warmupKey(_options?: IEncryptionContext): Promise<void>;
|
|
2117
|
-
/**
|
|
2118
|
-
* Resolves raw key from keyProvider callback or defaultKey.
|
|
2119
|
-
*/
|
|
2120
3055
|
protected resolveRawKey(keyProvider?: TKeyProvider | IKeyPair | any): Promise<TRawKey>;
|
|
2121
|
-
/**
|
|
2122
|
-
* Checks whether the given payload is an encrypted envelope.
|
|
2123
|
-
*/
|
|
2124
3056
|
static isEncrypted(payload: any): boolean;
|
|
2125
|
-
/**
|
|
2126
|
-
* Checks whether the given payload is an encrypted envelope.
|
|
2127
|
-
*/
|
|
2128
3057
|
isEncrypted(payload: any): boolean;
|
|
2129
|
-
/**
|
|
2130
|
-
* Clears configured keys and cached cryptographic material from memory.
|
|
2131
|
-
*/
|
|
2132
3058
|
clearKeys(): void;
|
|
2133
|
-
/**
|
|
2134
|
-
* Alias for clearKeys() to conform with standard disposal patterns.
|
|
2135
|
-
*/
|
|
2136
3059
|
dispose(): void;
|
|
2137
|
-
/**
|
|
2138
|
-
* ECMAScript Explicit Resource Management protocol (using / await using declarations).
|
|
2139
|
-
*/
|
|
2140
3060
|
[Symbol.dispose](): void;
|
|
2141
3061
|
[Symbol.asyncDispose](): Promise<void>;
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
* 2. When encrypting (isDecrypt=false): binds request context `req:${method}:${url}` only if options.bindRequestContextAad === true.
|
|
2146
|
-
* 3. When decrypting (isDecrypt=true): derives request context `req:${method}:${url}` if url or method is provided.
|
|
2147
|
-
* 4. If explicit options.aad is provided: combines with request context if bound, or returns options.aad directly.
|
|
2148
|
-
* 5. Otherwise returns undefined.
|
|
2149
|
-
*/
|
|
2150
|
-
protected _resolveEffectiveAad(options?: IEncryptionContext, isDecrypt?: boolean): string | Uint8Array | ArrayBuffer | undefined;
|
|
2151
|
-
/**
|
|
2152
|
-
* Helper to deterministically bind record ID, contextual sibling fields (aadFields),
|
|
2153
|
-
* dynamic AAD callbacks, and field name into the AAD to prevent ciphertext swapping
|
|
2154
|
-
* between fields, records, or parent entities.
|
|
2155
|
-
*/
|
|
3062
|
+
static normalizeUrl(rawUrl?: string): string;
|
|
3063
|
+
protected _normalizeUrl(rawUrl?: string): string;
|
|
3064
|
+
protected _resolveEffectiveAad(options?: IEncryptionContext, _isDecrypt?: boolean): string | Uint8Array | ArrayBuffer | undefined;
|
|
2156
3065
|
protected _bindFieldAad(data: any, field: string, options?: IEncryptionContext): IEncryptionContext;
|
|
2157
|
-
/**
|
|
2158
|
-
* Validates envelope metadata against algorithm whitelists and key identifiers (kid).
|
|
2159
|
-
* In strict mode, allowedAlgorithms defaults to ['AES-GCM'].
|
|
2160
|
-
*/
|
|
2161
3066
|
protected _validateEnvelopeMetadata(payload: any, options?: IEncryptionContext): Error | undefined;
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
* If `keys` and `activeKid` are configured, selects `key = keys[activeKid]` and sets `kid = activeKid`.
|
|
2165
|
-
*/
|
|
3067
|
+
protected _isRawKeyOrCryptoKey(key: any): boolean;
|
|
3068
|
+
protected _resolveStrictViolationKeys(record: Record<string, any>, targetKeys: string[], options?: IEncryptionContext): string[];
|
|
2166
3069
|
protected _resolveOutboundKeyringOptions(options?: IEncryptionContext): IEncryptionContext;
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
* and the configured keyring (`keys`, `activeKid`, or fallback `key`).
|
|
2170
|
-
*/
|
|
3070
|
+
protected _getActiveDecryptionKey(): TKeyProvider | IKeyPair | undefined;
|
|
3071
|
+
protected _getDefaultFallbackKey(): TKeyProvider | IKeyPair | undefined;
|
|
2171
3072
|
protected _resolveDecryptionKeyForEnvelope(payload: any, options?: IEncryptionContext): TKeyProvider | IKeyPair | undefined;
|
|
2172
|
-
/**
|
|
2173
|
-
* Handles a per-field or per-payload decryption error according to configured options:
|
|
2174
|
-
* - Invokes onDecryptError callback if provided
|
|
2175
|
-
* - Attaches error metadata (__decryptErrors) to the record object
|
|
2176
|
-
* - Returns fallback cell placeholder ('[⚠ Decryption Error]') or rethrows
|
|
2177
|
-
*/
|
|
2178
3073
|
protected _handleDecryptError(err: Error, record: any, field: string, value: any, index: number | undefined, options?: IEncryptionContext): any;
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
abstract
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
3074
|
+
protected abstract _assertSupportedEnvelopeAlgorithm(alg?: string): void;
|
|
3075
|
+
protected abstract _resolveEncryptKeyMaterial(options?: IEncryptionContext, session?: IEncryptRecordSession): Promise<any>;
|
|
3076
|
+
protected abstract _sealPayload(plaintextBytes: Uint8Array, keyMaterial: any, aadBytes: Uint8Array | undefined, options?: IEncryptionContext): Promise<IEncryptedPayload>;
|
|
3077
|
+
protected abstract _resolveDecryptKeyMaterial(payload: IEncryptedPayload, options?: IEncryptionContext, session?: IDecryptBatchSession): Promise<any>;
|
|
3078
|
+
protected abstract _unsealPayload(payload: IEncryptedPayload, keyMaterial: any, aadBytes: Uint8Array | undefined, options?: IEncryptionContext): Promise<ArrayBuffer | Uint8Array>;
|
|
3079
|
+
protected _releaseEncryptKeyMaterial(_keyMaterial: any, _session?: IEncryptRecordSession): void;
|
|
3080
|
+
protected _releaseDecryptKeyMaterial(_keyMaterial: any, _session?: IDecryptBatchSession): void;
|
|
3081
|
+
protected _beginEncryptRecordSession(_options?: IEncryptionContext): Promise<IEncryptRecordSession | undefined>;
|
|
3082
|
+
protected _beginDecryptBatchSession(_options?: IEncryptionContext): IDecryptBatchSession | undefined;
|
|
3083
|
+
protected _prepareFieldDecryptContext(_item: Record<string, any>, _field: string, payload: IEncryptedPayload, options?: IEncryptionContext): {
|
|
3084
|
+
payload: IEncryptedPayload;
|
|
3085
|
+
options?: IEncryptionContext;
|
|
3086
|
+
};
|
|
3087
|
+
protected _finalizeDecryptedRecord(_item: Record<string, any>, _result: Record<string, any>, _options?: IEncryptionContext): void;
|
|
3088
|
+
private _encryptValueWithSession;
|
|
3089
|
+
private _decryptEnvelopeWithAadFallback;
|
|
3090
|
+
private _decryptValueWithSession;
|
|
3091
|
+
encryptValue(value: any, options?: IEncryptionContext): Promise<IEncryptedPayload>;
|
|
3092
|
+
decryptValue(payload: IEncryptedPayload, options?: IEncryptionContext): Promise<any>;
|
|
2196
3093
|
encryptField(value: any, context?: IFieldEncryptionContext): Promise<IEncryptedPayload>;
|
|
2197
|
-
/**
|
|
2198
|
-
* Decrypts a single IEncryptedPayload envelope back into its scalar plaintext value using contextual AAD.
|
|
2199
|
-
* Validates recordId, fieldName, and sibling aadFields integrity.
|
|
2200
|
-
*
|
|
2201
|
-
* @param envelope - The IEncryptedPayload envelope to decrypt.
|
|
2202
|
-
* @param context - Field encryption context matching the encryption parameters.
|
|
2203
|
-
*/
|
|
2204
3094
|
decryptField(envelope: IEncryptedPayload, context?: IFieldEncryptionContext): Promise<any>;
|
|
2205
|
-
/**
|
|
2206
|
-
* Top-level polymorphic encryption method.
|
|
2207
|
-
* Automatically performs value-level encryption:
|
|
2208
|
-
* - If data is an array of objects: recursively encrypts each row.
|
|
2209
|
-
* - If data is an object: encrypts specified fields (or all values if valueEncryption is true),
|
|
2210
|
-
* preserving JSON object keys so backend APIs and ORMs can parse keys and perform upserts.
|
|
2211
|
-
* - If data is a primitive or whole-payload envelope: encrypts as a single value.
|
|
2212
|
-
*/
|
|
2213
3095
|
encrypt(data: any, options?: IEncryptionContext): Promise<any>;
|
|
2214
|
-
|
|
2215
|
-
* Top-level polymorphic decryption method.
|
|
2216
|
-
* Automatically performs value-level decryption:
|
|
2217
|
-
* - If payload is an encrypted envelope: validates metadata and decrypts directly via decryptValue.
|
|
2218
|
-
* - If payload is an array of objects: decrypts each row (batched with local memoization).
|
|
2219
|
-
* - If payload is an object: decrypts any encrypted value cells across fields.
|
|
2220
|
-
* In strict mode:
|
|
2221
|
-
* - Unencrypted plaintext in configured `fields` triggers a decryption error.
|
|
2222
|
-
* - Envelopes are validated against `allowedAlgorithms` and `allowedKids`.
|
|
2223
|
-
* - Errors are routed through `onDecryptError` or populated into `__decryptErrors`.
|
|
2224
|
-
*/
|
|
3096
|
+
private _decryptRecordFields;
|
|
2225
3097
|
decrypt(payload: any, options?: IEncryptionContext): Promise<any>;
|
|
2226
3098
|
}
|
|
3099
|
+
declare function normalizeUrl(rawUrl?: string): string;
|
|
2227
3100
|
|
|
2228
3101
|
/**
|
|
2229
|
-
*
|
|
2230
|
-
* Provides key generation, JWK import/export, key wrapping (AES-KW / RSA-OAEP),
|
|
2231
|
-
* and standard Key Derivation Functions (PBKDF2 / HKDF).
|
|
3102
|
+
* Generates a cryptographically secure random byte buffer of the specified length.
|
|
2232
3103
|
*/
|
|
2233
|
-
declare
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
3104
|
+
declare function randomBytes(length: number): Uint8Array;
|
|
3105
|
+
/**
|
|
3106
|
+
* Converts a Base64 or Base64URL-encoded string back into a Uint8Array.
|
|
3107
|
+
* Normalizes URL-safe characters and padding, strictly validating against the Base64 alphabet.
|
|
3108
|
+
*/
|
|
3109
|
+
declare function fromBase64(base64: string): Uint8Array;
|
|
3110
|
+
/**
|
|
3111
|
+
* Deterministically resolves a salt from Uint8Array, ArrayBuffer, Base64/Base64URL string, or raw text string.
|
|
3112
|
+
* Guarantees 100% identical salt byte resolution between Node.js and Browser environments.
|
|
3113
|
+
*/
|
|
3114
|
+
declare function resolveSalt(salt?: Uint8Array | ArrayBuffer | string): Uint8Array;
|
|
3115
|
+
|
|
3116
|
+
/**
|
|
3117
|
+
* Generates a random AES CryptoKey suitable for AES-GCM or AES-CBC.
|
|
3118
|
+
*
|
|
3119
|
+
* Defaults to `extractable = false` so key material cannot be exported via
|
|
3120
|
+
* `exportKey`/`wrapKey` unless the caller explicitly opts in with `extractable: true`.
|
|
3121
|
+
*/
|
|
3122
|
+
declare function generateAESKey(length?: 128 | 256, algorithm?: 'AES-GCM' | 'AES-CBC' | 'AES-KW', extractable?: boolean): Promise<CryptoKey>;
|
|
3123
|
+
/**
|
|
3124
|
+
* Exports an AES CryptoKey as a raw base64 string.
|
|
3125
|
+
*/
|
|
3126
|
+
declare function exportAESKey(key: CryptoKey): Promise<string>;
|
|
3127
|
+
/**
|
|
3128
|
+
* Imports an AES CryptoKey from a raw base64 string.
|
|
3129
|
+
*/
|
|
3130
|
+
declare function importAESKey(base64: string, algorithm?: 'AES-GCM' | 'AES-CBC' | 'AES-KW', extractable?: boolean): Promise<CryptoKey>;
|
|
3131
|
+
|
|
3132
|
+
/**
|
|
3133
|
+
* Generates an RSA-OAEP public/private key pair (2048 or 4096 bits).
|
|
3134
|
+
*/
|
|
3135
|
+
declare function generateRSAKeyPair(bits?: 2048 | 4096, hash?: 'SHA-256' | 'SHA-512', extractable?: boolean): Promise<IKeyPair>;
|
|
3136
|
+
/**
|
|
3137
|
+
* Generates an ECDH public/private key pair for elliptic curve Diffie-Hellman.
|
|
3138
|
+
*/
|
|
3139
|
+
declare function generateECDHKeyPair(curve?: 'P-256' | 'P-384' | 'P-521', extractable?: boolean): Promise<IKeyPair>;
|
|
3140
|
+
/**
|
|
3141
|
+
* Exports a public CryptoKey to a portable JsonWebKey (JWK).
|
|
3142
|
+
*/
|
|
3143
|
+
declare function exportPublicKey(key: CryptoKey): Promise<JsonWebKey>;
|
|
3144
|
+
/**
|
|
3145
|
+
* Exports a private CryptoKey to a portable JsonWebKey (JWK).
|
|
3146
|
+
*/
|
|
3147
|
+
declare function exportPrivateKey(key: CryptoKey): Promise<JsonWebKey>;
|
|
3148
|
+
/**
|
|
3149
|
+
* Imports a public key from a JsonWebKey (JWK).
|
|
3150
|
+
*/
|
|
3151
|
+
declare function importPublicKey(jwk: JsonWebKey, algorithm?: string | RsaHashedImportParams | EcKeyImportParams): Promise<CryptoKey>;
|
|
3152
|
+
/**
|
|
3153
|
+
* Imports a private key from a JsonWebKey (JWK).
|
|
3154
|
+
*/
|
|
3155
|
+
declare function importPrivateKey(jwk: JsonWebKey, algorithm?: string | RsaHashedImportParams | EcKeyImportParams, extractable?: boolean): Promise<CryptoKey>;
|
|
3156
|
+
/**
|
|
3157
|
+
* Imports a public key from a PEM (SPKI) or base64 SPKI string.
|
|
3158
|
+
*/
|
|
3159
|
+
declare function importPublicKeyFromPEM(pem: string, algorithm?: 'RSA-OAEP' | 'ECDH' | 'ECDSA', curve?: 'P-256' | 'P-384' | 'P-521', hash?: 'SHA-256' | 'SHA-512'): Promise<CryptoKey>;
|
|
3160
|
+
/**
|
|
3161
|
+
* Imports an ECDSA public key from PEM (SPKI) or base64 SPKI string for signature verification.
|
|
3162
|
+
*/
|
|
3163
|
+
declare function importECDSAPublicKeyFromPEM(pem: string, curve?: 'P-256' | 'P-384' | 'P-521'): Promise<CryptoKey>;
|
|
3164
|
+
/**
|
|
3165
|
+
* Imports a private key from a PEM (PKCS#8) or base64 PKCS#8 string.
|
|
3166
|
+
*/
|
|
3167
|
+
declare function importPrivateKeyFromPEM(pem: string, algorithm?: 'RSA-OAEP' | 'ECDH' | 'ECDSA', curve?: 'P-256' | 'P-384' | 'P-521', hash?: 'SHA-256' | 'SHA-512', extractable?: boolean): Promise<CryptoKey>;
|
|
3168
|
+
/**
|
|
3169
|
+
* Imports an ECDSA private key from PEM (PKCS#8) or base64 PKCS#8 string for signing.
|
|
3170
|
+
*/
|
|
3171
|
+
declare function importECDSAPrivateKeyFromPEM(pem: string, curve?: 'P-256' | 'P-384' | 'P-521', extractable?: boolean): Promise<CryptoKey>;
|
|
3172
|
+
/**
|
|
3173
|
+
* Exports a public CryptoKey to a standard PEM (SPKI) string.
|
|
3174
|
+
*/
|
|
3175
|
+
declare function exportPublicKeyToPEM(key: CryptoKey): Promise<string>;
|
|
3176
|
+
/**
|
|
3177
|
+
* Exports a private CryptoKey to a standard PEM (PKCS#8) string.
|
|
3178
|
+
*/
|
|
3179
|
+
declare function exportPrivateKeyToPEM(key: CryptoKey): Promise<string>;
|
|
3180
|
+
|
|
3181
|
+
/**
|
|
3182
|
+
* Wraps a target CryptoKey (e.g. an Account Symmetric Key) using a wrapping key
|
|
3183
|
+
* (AES-KW or RSA-OAEP).
|
|
3184
|
+
*/
|
|
3185
|
+
declare function wrapKey(keyToWrap: CryptoKey, wrappingKey: CryptoKey, format?: KeyFormat): Promise<string>;
|
|
3186
|
+
/**
|
|
3187
|
+
* Unwraps a base64-encoded wrapped key using an unwrapping key (AES-KW, AES-GCM, or RSA-OAEP).
|
|
3188
|
+
*/
|
|
3189
|
+
declare function unwrapKey(wrappedBase64: string, unwrappingKey: CryptoKey, unwrappedKeyAlgorithm?: any, extractable?: boolean, keyUsages?: KeyUsage[], format?: KeyFormat): Promise<CryptoKey>;
|
|
3190
|
+
/**
|
|
3191
|
+
* Generates a high-entropy symmetric AES-GCM Account Data Encryption Key (ADEK).
|
|
3192
|
+
* Designed for multi-user table and field-level encryption.
|
|
3193
|
+
*/
|
|
3194
|
+
declare function generateAccountDataKey(length?: 128 | 192 | 256, extractable?: boolean): Promise<CryptoKey>;
|
|
3195
|
+
/**
|
|
3196
|
+
* Wraps an Account Data Encryption Key (ADEK) for a specific user using the user's public key (RSA-OAEP).
|
|
3197
|
+
* Returns a Base64-encoded wrapped key string suitable for storage in role-map / access tables.
|
|
3198
|
+
*/
|
|
3199
|
+
declare function wrapAccountKeyForUser(adek: CryptoKey, userPublicKey: CryptoKey): Promise<string>;
|
|
3200
|
+
/**
|
|
3201
|
+
* Unwraps a Base64-encoded Account Data Encryption Key (ADEK) using the user's private key (RSA-OAEP).
|
|
3202
|
+
* Returns the restored AES-GCM CryptoKey ready for use in CWebCryptoEncryptionProvider.
|
|
3203
|
+
*/
|
|
3204
|
+
declare function unwrapAccountKeyForUser(wrappedKeyBase64: string, userPrivateKey: CryptoKey, unwrappedKeyAlgorithm?: any, extractable?: boolean): Promise<CryptoKey>;
|
|
3205
|
+
/**
|
|
3206
|
+
* Wraps an HMAC blind indexing key for a specific recipient user using their RSA-OAEP public key.
|
|
3207
|
+
* Returns a Base64-encoded wrapped key string suitable for storage in role-map / access tables.
|
|
3208
|
+
*/
|
|
3209
|
+
declare function wrapHMACKeyForUser(hmacKey: CryptoKey, userPublicKey: CryptoKey): Promise<string>;
|
|
3210
|
+
/**
|
|
3211
|
+
* Unwraps a Base64-encoded HMAC key using a recipient's RSA-OAEP private key.
|
|
3212
|
+
* Restores the CryptoKey configured for HMAC signing and verification in search indexing.
|
|
3213
|
+
*/
|
|
3214
|
+
declare function unwrapHMACKeyForUser(wrappedKeyBase64: string, userPrivateKey: CryptoKey, hash?: 'SHA-256' | 'SHA-384' | 'SHA-512', extractable?: boolean): Promise<CryptoKey>;
|
|
3215
|
+
/**
|
|
3216
|
+
* Atomically re-wraps an Account Data Encryption Key (ADEK) for a new recipient
|
|
3217
|
+
* without exposing the raw extractable symmetric key to caller application code.
|
|
3218
|
+
*
|
|
3219
|
+
* @param wrappedKeyBase64 - The existing ADEK envelope wrapped with current user's public key
|
|
3220
|
+
* @param myPrivateKey - Current user's RSA-OAEP private key
|
|
3221
|
+
* @param recipientPublicKey - New recipient's RSA-OAEP public key
|
|
3222
|
+
* @returns Base64-encoded wrapped key envelope for the recipient
|
|
3223
|
+
*/
|
|
3224
|
+
declare function rewrapAccountKeyForUser(wrappedKeyBase64: string, myPrivateKey: CryptoKey, recipientPublicKey: CryptoKey): Promise<string>;
|
|
3225
|
+
|
|
3226
|
+
/**
|
|
3227
|
+
* Derives a symmetric AES-GCM CryptoKey from a passphrase using PBKDF2 or HKDF.
|
|
3228
|
+
* Returns the derived CryptoKey and the base64-encoded salt.
|
|
3229
|
+
*/
|
|
3230
|
+
declare function deriveKey(passphrase: string | Uint8Array | ArrayBuffer, options: IKDFOptions): Promise<{
|
|
3231
|
+
key: CryptoKey;
|
|
3232
|
+
salt: string;
|
|
3233
|
+
}>;
|
|
3234
|
+
/**
|
|
3235
|
+
* Derives an AES-GCM CryptoKey from a high-entropy secret (e.g. an ECDH shared secret key)
|
|
3236
|
+
* using HKDF.
|
|
3237
|
+
*/
|
|
3238
|
+
declare function deriveKeyFromSecret(secretKey: CryptoKey, options?: IHKDFFromSecretOptions): Promise<CryptoKey>;
|
|
3239
|
+
/**
|
|
3240
|
+
* Derives two domain-separated, cryptographically isolated keys from a user password and salt:
|
|
3241
|
+
* 1. `authKey`: For client authentication, SRP, or server challenge proofs.
|
|
3242
|
+
* 2. `encryptionKey`: For AES-GCM local and field-level data encryption.
|
|
3243
|
+
*
|
|
3244
|
+
* Stage 1 (Password Stretching): PBKDF2-HMAC-SHA256 stretches low-entropy password into master secret.
|
|
3245
|
+
* Stage 2 (Domain Expansion): HKDF-Expand derives subkeys using domain-separated context info tags.
|
|
3246
|
+
* Immediate memory zeroization of intermediate master secret buffer is guaranteed.
|
|
3247
|
+
*
|
|
3248
|
+
* @param password - Master user password or passphrase
|
|
3249
|
+
* @param salt - Salt (or omitted to generate a secure random 16-byte salt)
|
|
3250
|
+
* @param options - PBKDF2 and HKDF configuration options
|
|
3251
|
+
*/
|
|
3252
|
+
declare function deriveAuthAndEncryptionKeys(password: string | Uint8Array | ArrayBuffer, salt?: Uint8Array | ArrayBuffer | string, options?: IDeriveAuthAndEncryptionOptions): Promise<IDomainDerivedKeys>;
|
|
3253
|
+
|
|
3254
|
+
/** Current blind-index HMAC framing protocol identifier (length-prefixed framing). */
|
|
3255
|
+
declare const BLIND_INDEX_FRAMING_VERSION = "lp1";
|
|
3256
|
+
/**
|
|
3257
|
+
* Parameters that determine blind-index token compatibility across writers and queries.
|
|
3258
|
+
*/
|
|
3259
|
+
interface IBlindIndexSchemeOptions extends INormalizeOptions {
|
|
3260
|
+
/** Whether tokens omit field+type domain separation (default: false -> 'field-type') */
|
|
3261
|
+
legacyUnscopedTokens?: boolean;
|
|
3262
|
+
/** Framing protocol version (default: 'lp1') */
|
|
3263
|
+
framing?: 'lp1' | 'legacy-unframed';
|
|
3264
|
+
/** Whether `kid` is explicitly framed into HMAC input (default: false) */
|
|
3265
|
+
includeKidInHmac?: boolean;
|
|
3266
|
+
/** Optional explicit `kid` if passed to `computeBlindIndex` */
|
|
3267
|
+
kid?: string;
|
|
3268
|
+
}
|
|
3269
|
+
/**
|
|
3270
|
+
* Computes a canonical, deterministic scheme identifier covering HMAC framing, domain scope,
|
|
3271
|
+
* and normalization configuration (`locale`, `asciiFold`, `normalizerId`).
|
|
3272
|
+
* Persisting this identifier alongside blind-index columns makes normalization or scope drift detectable.
|
|
3273
|
+
*/
|
|
3274
|
+
declare function computeBlindIndexSchemeId(options?: IBlindIndexSchemeOptions): string;
|
|
3275
|
+
declare const _bidxHmacKeyCache: Map<string, CryptoKey>;
|
|
3276
|
+
/**
|
|
3277
|
+
* Clears the in-memory memoization cache for derived blind-index HMAC CryptoKeys.
|
|
3278
|
+
*/
|
|
3279
|
+
declare function clearBlindIndexKeyCache(): void;
|
|
3280
|
+
/**
|
|
3281
|
+
* Generates an ECDSA P-256 signing key pair.
|
|
3282
|
+
*/
|
|
3283
|
+
declare function generateSigningKeyPair(curve?: 'P-256' | 'P-384' | 'P-521', extractable?: boolean): Promise<IKeyPair>;
|
|
3284
|
+
/**
|
|
3285
|
+
* Generates an ECDSA signing key pair. Alias for generateSigningKeyPair.
|
|
3286
|
+
*/
|
|
3287
|
+
declare function generateECDSAKeyPair(curve?: 'P-256' | 'P-384' | 'P-521', extractable?: boolean): Promise<IKeyPair>;
|
|
3288
|
+
/**
|
|
3289
|
+
* Generates a deterministic SHA-256 fingerprint for a public key (SPKI or raw).
|
|
3290
|
+
* Formatted as `SHA256:<base64url>`.
|
|
3291
|
+
*/
|
|
3292
|
+
declare function getKeyFingerprint(publicKey: CryptoKey | Uint8Array | ArrayBuffer | string): Promise<string>;
|
|
3293
|
+
/**
|
|
3294
|
+
* Signs arbitrary data or JSON objects using an ECDSA P-256 private key.
|
|
3295
|
+
* Objects are automatically serialized via canonicalizeJson() before hashing.
|
|
3296
|
+
*/
|
|
3297
|
+
declare function sign(data: any | string | Uint8Array, privateKey: CryptoKey): Promise<string>;
|
|
3298
|
+
/**
|
|
3299
|
+
* Verifies an ECDSA P-256 signature against original data or JSON object.
|
|
3300
|
+
*/
|
|
3301
|
+
declare function verify(data: any | string | Uint8Array, signature: string, publicKey: CryptoKey): Promise<boolean>;
|
|
3302
|
+
/**
|
|
3303
|
+
* Derives or validates an HMAC-SHA256 CryptoKey for deterministic blind indexing.
|
|
3304
|
+
*
|
|
3305
|
+
* Security Guarantees:
|
|
3306
|
+
* 1. Dedicated Key Requirement: Throws ERR_BIDX_MISSING_HMAC_KEY if keyMaterial is missing/undefined.
|
|
3307
|
+
* 2. Domain Separation: If a string passphrase is provided, it is NEVER imported directly as raw HMAC key material.
|
|
3308
|
+
* Instead, it is stretched via PBKDF2 (default 600,000 iterations; lower to e.g. 100,000 on edge runtimes like
|
|
3309
|
+
* Cloudflare Workers) and expanded with HKDF using an independent salt ('katlux-blind-index-salt-v1') and explicit
|
|
3310
|
+
* domain separation info ('katlux-blind-index'). This prevents GPU dictionary attacks against the AES data key.
|
|
3311
|
+
* 3. Type Enforcement: If a CryptoKey is passed, enforces algorithm.name === 'HMAC'.
|
|
3312
|
+
*/
|
|
3313
|
+
declare function deriveBlindIndexHmacKey(keyMaterial: TKeyProvider | CryptoKey | undefined, options?: {
|
|
3314
|
+
kdfIterations?: number;
|
|
3315
|
+
maxAllowedIterations?: number;
|
|
3316
|
+
}): Promise<CryptoKey>;
|
|
3317
|
+
/**
|
|
3318
|
+
* Computes a deterministic, length-prefixed, domain-separated HMAC-SHA256 blind index token.
|
|
3319
|
+
* Performs Unicode NFKC normalization, trimming, and lowercasing before computing the signature.
|
|
3320
|
+
*
|
|
3321
|
+
* Enforces cryptographic domain separation and unambiguous length-prefixed framing:
|
|
3322
|
+
* `token = HMAC("${bytes(kid)}:${kid}|${bytes(field)}:${field}|${bytes(type)}:${type}|${bytes(val)}:${normalizedValue}", key)`
|
|
3323
|
+
*
|
|
3324
|
+
* Convention on `kid`: `IBlindIndexKeyring` writers (`computeWriteBlindIndex`, `reencryptField`, `CSearchIndex`)
|
|
3325
|
+
* and `rewriteEncryptedFilters` intentionally omit `kid` from HMAC input because each `kid` in a keyring already
|
|
3326
|
+
* maps to a distinct HMAC key. Pass `options.kid` explicitly only if multiple logical key IDs share one raw HMAC key.
|
|
3327
|
+
*
|
|
3328
|
+
* @param value - The input string, number, or object to compute the blind index for.
|
|
3329
|
+
* @param hmacKey - CryptoKey configured for HMAC signing.
|
|
3330
|
+
* @param options - Normalization options and optional domain separation context ({ field?: string; type?: 'eq' | 'tri'; kid?: string; version?: string | number; versionTag?: string | boolean }).
|
|
3331
|
+
* @returns Lowercase hexadecimal HMAC-SHA256 blind index hash (or `${tag}:${hex}` when `versionTag` is enabled).
|
|
3332
|
+
*/
|
|
3333
|
+
declare function computeBlindIndex(value: any, hmacKey: CryptoKey, options?: IBlindIndexOptions): Promise<string>;
|
|
3334
|
+
/**
|
|
3335
|
+
* Signs a structured access grant, embedding signature and granter key fingerprint.
|
|
3336
|
+
*/
|
|
3337
|
+
declare function signGrant(grant: IAccessGrant, granterPrivateKey: CryptoKey, granterPublicKey?: CryptoKey): Promise<ISignedGrant>;
|
|
3338
|
+
/**
|
|
3339
|
+
* Verifies the authenticity and integrity of a signed access grant against granter public key.
|
|
3340
|
+
*/
|
|
3341
|
+
declare function verifyGrant(signedGrant: ISignedGrant, granterPublicKey: CryptoKey, options?: IVerifyGrantOptions): Promise<boolean>;
|
|
3342
|
+
|
|
3343
|
+
/**
|
|
3344
|
+
* Encrypts raw bytes (e.g. PKCS#8 private key) into a standardized Katlux AES-GCM envelope.
|
|
3345
|
+
*
|
|
3346
|
+
* @param data - Raw byte buffer or Uint8Array to encrypt
|
|
3347
|
+
* @param key - AES-GCM CryptoKey (KEK)
|
|
3348
|
+
* @param options - Optional AAD, IV, or Key Identifier (kid)
|
|
3349
|
+
*/
|
|
3350
|
+
declare function encryptPayload(data: ArrayBuffer | Uint8Array, key: CryptoKey, options?: {
|
|
3351
|
+
iv?: Uint8Array;
|
|
3352
|
+
aad?: string | Uint8Array | ArrayBuffer;
|
|
3353
|
+
kid?: string;
|
|
3354
|
+
}): Promise<IEncryptedPayload>;
|
|
3355
|
+
/**
|
|
3356
|
+
* Decrypts an AES-GCM encrypted envelope back into raw bytes.
|
|
3357
|
+
*
|
|
3358
|
+
* @param payload - Standardized Katlux AES-GCM envelope
|
|
3359
|
+
* @param key - AES-GCM CryptoKey (KEK)
|
|
3360
|
+
* @param options - Optional AAD
|
|
3361
|
+
* @returns Raw decrypted ArrayBuffer
|
|
3362
|
+
*/
|
|
3363
|
+
declare function decryptPayload(payload: IEncryptedPayload, key: CryptoKey, options?: {
|
|
3364
|
+
aad?: string | Uint8Array | ArrayBuffer;
|
|
3365
|
+
}): Promise<ArrayBuffer>;
|
|
3366
|
+
/**
|
|
3367
|
+
* Atomically re-keys an existing AES-GCM encrypted envelope from oldKey to newKey.
|
|
3368
|
+
* Decrypts with oldKey, derives a fresh random 96-bit IV, and re-encrypts with newKey.
|
|
3369
|
+
* Memory zeroization of internal plaintext and ciphertext buffers is guaranteed via try...finally.
|
|
3370
|
+
*
|
|
3371
|
+
* @param payload - Existing AES-GCM encrypted payload envelope
|
|
3372
|
+
* @param oldKey - Current AES-GCM CryptoKey (KEK)
|
|
3373
|
+
* @param newKey - New AES-GCM CryptoKey (KEK)
|
|
3374
|
+
* @param options - Optional AAD, newAad, and newKid overrides
|
|
3375
|
+
*/
|
|
3376
|
+
declare function rekeyEncryptedPayload(payload: IEncryptedPayload, oldKey: CryptoKey, newKey: CryptoKey, options?: IRekeyPayloadOptions): Promise<IEncryptedPayload>;
|
|
3377
|
+
/**
|
|
3378
|
+
* Zero-knowledge master passphrase re-keying pipeline for user keypairs.
|
|
3379
|
+
*
|
|
3380
|
+
* Persistence Contract:
|
|
3381
|
+
* The caller must persist `encryptedPrivateKey`, `encryptedSigningKey`, `newSalt`, and the server
|
|
3382
|
+
* auth verifier ATOMICALLY (within a single database transaction or API request).
|
|
3383
|
+
* Partial persistence will lock the user out permanently.
|
|
3384
|
+
*
|
|
3385
|
+
* Zeroization Notice:
|
|
3386
|
+
* JavaScript memory zeroization (`fill(0)`) is best-effort due to garbage collector copies,
|
|
3387
|
+
* string immutability, and V8/SpiderMonkey engine internals. It strictly zeroes typed array buffers
|
|
3388
|
+
* allocated within Katlux control.
|
|
3389
|
+
*
|
|
3390
|
+
* Key Extractability:
|
|
3391
|
+
* All derived Key-Encrypting Keys (KEKs) are strictly non-extractable (`extractable: false`).
|
|
3392
|
+
* `authKey` extractability follows `newKdfOptions.extractable` (defaults to false).
|
|
3393
|
+
*
|
|
3394
|
+
* @param params - Re-keying configuration parameters
|
|
3395
|
+
* @returns Rekeyed private key envelopes, new salt, and fresh derived subkeys
|
|
3396
|
+
*/
|
|
3397
|
+
declare function rekeyUserKeypair(params: IRekeyKeypairParams): Promise<IRekeyedKeypairResult>;
|
|
3398
|
+
|
|
3399
|
+
/**
|
|
3400
|
+
* Helper to resolve a CryptoKey from a TTrustedAuthorities structure matching a given authorityFingerprint.
|
|
3401
|
+
*/
|
|
3402
|
+
declare function resolveAuthorityCryptoKey(trustedAuthorities: TTrustedAuthorities, authorityFingerprint: string): Promise<CryptoKey | null>;
|
|
3403
|
+
/**
|
|
3404
|
+
* Signs a key-reset attestation using an authority ECDSA P-256 private key.
|
|
3405
|
+
*
|
|
3406
|
+
* Used by trusted recovery authorities or administrators to certify that
|
|
3407
|
+
* an entity's pinned public key was legitimately superseded.
|
|
3408
|
+
*/
|
|
3409
|
+
declare function signKeyResetAttestation(attestation: {
|
|
3410
|
+
version?: 1;
|
|
3411
|
+
entityId: string;
|
|
3412
|
+
oldFingerprint: string;
|
|
3413
|
+
newFingerprint: string;
|
|
3414
|
+
sequence: number;
|
|
3415
|
+
issuedAt?: number;
|
|
3416
|
+
expiresAt: number;
|
|
3417
|
+
authorityFingerprint?: string;
|
|
3418
|
+
reason?: string;
|
|
3419
|
+
}, authorityPrivateKey: CryptoKey, authorityPublicKey?: CryptoKey): Promise<ISignedKeyResetAttestation>;
|
|
3420
|
+
/**
|
|
3421
|
+
* Cryptographically verifies a signed key reset attestation against trusted authorities.
|
|
3422
|
+
* Validates schema version (strictly 1), authority signature, and time validity window.
|
|
3423
|
+
*/
|
|
3424
|
+
declare function verifyAttestation(signedAttestation: ISignedKeyResetAttestation, trustedAuthorities: TTrustedAuthorities, options?: {
|
|
3425
|
+
clockSkewMs?: number;
|
|
3426
|
+
maxExpirationWindowMs?: number;
|
|
3427
|
+
now?: number;
|
|
3428
|
+
}): Promise<IKeyResetAttestation>;
|
|
3429
|
+
/**
|
|
3430
|
+
* Verifies an incoming public key against the Key Pinning Store (TOFU),
|
|
3431
|
+
* safely accepting legitimate key replacements accompanied by a valid signed reset attestation.
|
|
3432
|
+
*
|
|
3433
|
+
* Threat Model & Security Considerations:
|
|
3434
|
+
* - Protects against: Substituted public keys from a compromised or rogue key directory after first contact.
|
|
3435
|
+
* - Does not protect against: Initial contact substitution (TOFU attack), malicious JavaScript served by
|
|
3436
|
+
* the same origin, or client-side storage tampering via XSS. Pinning is defense-in-depth.
|
|
3437
|
+
* - Authorities MUST be provisioned out-of-band (e.g. bundled app config), NEVER fetched dynamically from the key server.
|
|
3438
|
+
*
|
|
3439
|
+
* @param entityId - Peer or entity unique identifier
|
|
3440
|
+
* @param publicKey - Presented public key (CryptoKey, SPKI Uint8Array/ArrayBuffer, or PEM/Base64 string)
|
|
3441
|
+
* @param options - Pinning store, trusted authorities, and optional attestation resolver
|
|
3442
|
+
*/
|
|
3443
|
+
declare function verifyAndPinKey(entityId: string, publicKey: CryptoKey | Uint8Array | ArrayBuffer | string, options: IVerifyAndPinOptions): Promise<IVerifyAndPinResult>;
|
|
3444
|
+
|
|
3445
|
+
/**
|
|
3446
|
+
* Validates the structural integrity and lifecycle rules of a blind-index keyring.
|
|
3447
|
+
*
|
|
3448
|
+
* Enforcement rules:
|
|
3449
|
+
* - Keyring must be an object with string `activeKid` and `keys` dictionary.
|
|
3450
|
+
* - Exactly one key in `keys` must have `status: 'active'`.
|
|
3451
|
+
* - The active key's key ID must strictly match `activeKid`.
|
|
3452
|
+
* - Every key must possess a valid HMAC `CryptoKey` instance.
|
|
3453
|
+
*
|
|
3454
|
+
* Throws `ERR_BIDX_KEYRING_INVALID` on any violation.
|
|
3455
|
+
*/
|
|
3456
|
+
declare function validateBlindIndexKeyring(keyring: IBlindIndexKeyring): void;
|
|
3457
|
+
/**
|
|
3458
|
+
* Computes multi-token blind index candidates for search queries across key rotation lifecycles.
|
|
3459
|
+
*
|
|
3460
|
+
* Generates candidate tokens using the currently `active` key and all `search-only` keys.
|
|
3461
|
+
* Normalization (Unicode NFKC -> trim -> lowercase) is 100% identical to write-time tokens.
|
|
3462
|
+
* Returns a de-duplicated array of tokens with the active key's token first.
|
|
3463
|
+
* Returns an empty array `[]` for null/empty inputs.
|
|
3464
|
+
*
|
|
3465
|
+
* @param value - Search term string or primitive
|
|
3466
|
+
* @param keyring - Validated multi-KID blind index keyring
|
|
3467
|
+
*/
|
|
3468
|
+
declare function computeMultiBlindIndex(value: any, keyring: IBlindIndexKeyring, options?: IBlindIndexOptions): Promise<string[]>;
|
|
3469
|
+
/**
|
|
3470
|
+
* Computes the write-time blind index token using exclusively the currently active key.
|
|
3471
|
+
*
|
|
3472
|
+
* Used by data ingestion and re-indexing jobs.
|
|
3473
|
+
*
|
|
3474
|
+
* @param value - Ingest value string or primitive
|
|
3475
|
+
* @param keyring - Validated multi-KID blind index keyring
|
|
3476
|
+
*/
|
|
3477
|
+
declare function computeWriteBlindIndex(value: any, keyring: IBlindIndexKeyring, options?: IBlindIndexOptions): Promise<string>;
|
|
3478
|
+
|
|
3479
|
+
/**
|
|
3480
|
+
* Static cryptographic key lifecycle management facade.
|
|
3481
|
+
* Delegates calls to domain-specific submodules in `./keyManager/`.
|
|
3482
|
+
* Preserves 100% backward compatibility for all public static methods and signatures.
|
|
3483
|
+
*/
|
|
3484
|
+
declare class CKeyManager {
|
|
3485
|
+
private static get _bidxHmacKeyCache();
|
|
3486
|
+
/** Clears the in-memory memoization cache for derived blind-index HMAC CryptoKeys. */
|
|
3487
|
+
static clearBlindIndexKeyCache(): void;
|
|
3488
|
+
static randomBytes(length: number): Uint8Array;
|
|
3489
|
+
static toBase64(buffer: ArrayBuffer | Uint8Array): string;
|
|
3490
|
+
static fromBase64(base64: string): Uint8Array;
|
|
3491
|
+
static resolveSalt(salt?: Uint8Array | ArrayBuffer | string): Uint8Array;
|
|
3492
|
+
static generateAESKey(length?: 128 | 256, algorithm?: 'AES-GCM' | 'AES-CBC' | 'AES-KW', extractable?: boolean): Promise<CryptoKey>;
|
|
3493
|
+
static exportAESKey(key: CryptoKey): Promise<string>;
|
|
3494
|
+
static importAESKey(base64: string, algorithm?: 'AES-GCM' | 'AES-CBC' | 'AES-KW', extractable?: boolean): Promise<CryptoKey>;
|
|
3495
|
+
static generateRSAKeyPair(bits?: 2048 | 4096, hash?: 'SHA-256' | 'SHA-512', extractable?: boolean): Promise<IKeyPair>;
|
|
2276
3496
|
static generateECDHKeyPair(curve?: 'P-256' | 'P-384' | 'P-521', extractable?: boolean): Promise<IKeyPair>;
|
|
2277
|
-
/**
|
|
2278
|
-
* Exports a public CryptoKey to a portable JsonWebKey (JWK).
|
|
2279
|
-
*/
|
|
2280
3497
|
static exportPublicKey(key: CryptoKey): Promise<JsonWebKey>;
|
|
2281
|
-
/**
|
|
2282
|
-
* Exports a private CryptoKey to a portable JsonWebKey (JWK).
|
|
2283
|
-
*/
|
|
2284
3498
|
static exportPrivateKey(key: CryptoKey): Promise<JsonWebKey>;
|
|
2285
|
-
/**
|
|
2286
|
-
* Imports a public key from a JsonWebKey (JWK).
|
|
2287
|
-
*/
|
|
2288
3499
|
static importPublicKey(jwk: JsonWebKey, algorithm?: string | RsaHashedImportParams | EcKeyImportParams): Promise<CryptoKey>;
|
|
2289
|
-
|
|
2290
|
-
* Imports a private key from a JsonWebKey (JWK).
|
|
2291
|
-
*/
|
|
2292
|
-
static importPrivateKey(jwk: JsonWebKey, algorithm?: string | RsaHashedImportParams | EcKeyImportParams): Promise<CryptoKey>;
|
|
2293
|
-
/**
|
|
2294
|
-
* Imports a public key from a PEM (SPKI) or base64 SPKI string.
|
|
2295
|
-
*/
|
|
3500
|
+
static importPrivateKey(jwk: JsonWebKey, algorithm?: string | RsaHashedImportParams | EcKeyImportParams, extractable?: boolean): Promise<CryptoKey>;
|
|
2296
3501
|
static importPublicKeyFromPEM(pem: string, algorithm?: 'RSA-OAEP' | 'ECDH' | 'ECDSA', curve?: 'P-256' | 'P-384' | 'P-521', hash?: 'SHA-256' | 'SHA-512'): Promise<CryptoKey>;
|
|
2297
|
-
/**
|
|
2298
|
-
* Imports an ECDSA public key from PEM (SPKI) or base64 SPKI string for signature verification.
|
|
2299
|
-
*/
|
|
2300
3502
|
static importECDSAPublicKeyFromPEM(pem: string, curve?: 'P-256' | 'P-384' | 'P-521'): Promise<CryptoKey>;
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
*/
|
|
2304
|
-
static importPrivateKeyFromPEM(pem: string, algorithm?: 'RSA-OAEP' | 'ECDH' | 'ECDSA', curve?: 'P-256' | 'P-384' | 'P-521', hash?: 'SHA-256' | 'SHA-512'): Promise<CryptoKey>;
|
|
2305
|
-
/**
|
|
2306
|
-
* Imports an ECDSA private key from PEM (PKCS#8) or base64 PKCS#8 string for signing.
|
|
2307
|
-
*/
|
|
2308
|
-
static importECDSAPrivateKeyFromPEM(pem: string, curve?: 'P-256' | 'P-384' | 'P-521'): Promise<CryptoKey>;
|
|
2309
|
-
/**
|
|
2310
|
-
* Exports a public CryptoKey to a standard PEM (SPKI) string.
|
|
2311
|
-
*/
|
|
3503
|
+
static importPrivateKeyFromPEM(pem: string, algorithm?: 'RSA-OAEP' | 'ECDH' | 'ECDSA', curve?: 'P-256' | 'P-384' | 'P-521', hash?: 'SHA-256' | 'SHA-512', extractable?: boolean): Promise<CryptoKey>;
|
|
3504
|
+
static importECDSAPrivateKeyFromPEM(pem: string, curve?: 'P-256' | 'P-384' | 'P-521', extractable?: boolean): Promise<CryptoKey>;
|
|
2312
3505
|
static exportPublicKeyToPEM(key: CryptoKey): Promise<string>;
|
|
2313
|
-
/**
|
|
2314
|
-
* Exports a private CryptoKey to a standard PEM (PKCS#8) string.
|
|
2315
|
-
*/
|
|
2316
3506
|
static exportPrivateKeyToPEM(key: CryptoKey): Promise<string>;
|
|
2317
|
-
/**
|
|
2318
|
-
* Wraps a target CryptoKey (e.g. an Account Symmetric Key) using a wrapping key
|
|
2319
|
-
* (AES-KW or RSA-OAEP).
|
|
2320
|
-
*/
|
|
2321
3507
|
static wrapKey(keyToWrap: CryptoKey, wrappingKey: CryptoKey, format?: KeyFormat): Promise<string>;
|
|
2322
|
-
/**
|
|
2323
|
-
* Unwraps a base64-encoded wrapped key using an unwrapping key (AES-KW, AES-GCM, or RSA-OAEP).
|
|
2324
|
-
*/
|
|
2325
3508
|
static unwrapKey(wrappedBase64: string, unwrappingKey: CryptoKey, unwrappedKeyAlgorithm?: any, extractable?: boolean, keyUsages?: KeyUsage[], format?: KeyFormat): Promise<CryptoKey>;
|
|
2326
|
-
/**
|
|
2327
|
-
* Generates a high-entropy symmetric AES-GCM Account Data Encryption Key (ADEK).
|
|
2328
|
-
* Designed for multi-user table and field-level encryption.
|
|
2329
|
-
*/
|
|
2330
3509
|
static generateAccountDataKey(length?: 128 | 192 | 256, extractable?: boolean): Promise<CryptoKey>;
|
|
2331
|
-
/**
|
|
2332
|
-
* Wraps an Account Data Encryption Key (ADEK) for a specific user using the user's public key (RSA-OAEP).
|
|
2333
|
-
* Returns a Base64-encoded wrapped key string suitable for storage in role-map / access tables.
|
|
2334
|
-
*/
|
|
2335
3510
|
static wrapAccountKeyForUser(adek: CryptoKey, userPublicKey: CryptoKey): Promise<string>;
|
|
2336
|
-
/**
|
|
2337
|
-
* Unwraps a Base64-encoded Account Data Encryption Key (ADEK) using the user's private key (RSA-OAEP).
|
|
2338
|
-
* Returns the restored AES-GCM CryptoKey ready for use in CWebCryptoEncryptionProvider.
|
|
2339
|
-
*/
|
|
2340
3511
|
static unwrapAccountKeyForUser(wrappedKeyBase64: string, userPrivateKey: CryptoKey, unwrappedKeyAlgorithm?: any, extractable?: boolean): Promise<CryptoKey>;
|
|
2341
|
-
/**
|
|
2342
|
-
* Wraps an HMAC blind indexing key for a specific recipient user using their RSA-OAEP public key.
|
|
2343
|
-
* Returns a Base64-encoded wrapped key string suitable for storage in role-map / access tables.
|
|
2344
|
-
*/
|
|
2345
3512
|
static wrapHMACKeyForUser(hmacKey: CryptoKey, userPublicKey: CryptoKey): Promise<string>;
|
|
2346
|
-
/**
|
|
2347
|
-
* Unwraps a Base64-encoded HMAC key using a recipient's RSA-OAEP private key.
|
|
2348
|
-
* Restores the CryptoKey configured for HMAC signing and verification in search indexing.
|
|
2349
|
-
*/
|
|
2350
3513
|
static unwrapHMACKeyForUser(wrappedKeyBase64: string, userPrivateKey: CryptoKey, hash?: 'SHA-256' | 'SHA-384' | 'SHA-512', extractable?: boolean): Promise<CryptoKey>;
|
|
2351
|
-
/**
|
|
2352
|
-
* Atomically re-wraps an Account Data Encryption Key (ADEK) for a new recipient
|
|
2353
|
-
* without exposing the raw extractable symmetric key to caller application code.
|
|
2354
|
-
*
|
|
2355
|
-
* @param wrappedKeyBase64 - The existing ADEK envelope wrapped with current user's public key
|
|
2356
|
-
* @param myPrivateKey - Current user's RSA-OAEP private key
|
|
2357
|
-
* @param recipientPublicKey - New recipient's RSA-OAEP public key
|
|
2358
|
-
* @returns Base64-encoded wrapped key envelope for the recipient
|
|
2359
|
-
*/
|
|
2360
3514
|
static rewrapAccountKeyForUser(wrappedKeyBase64: string, myPrivateKey: CryptoKey, recipientPublicKey: CryptoKey): Promise<string>;
|
|
2361
|
-
/**
|
|
2362
|
-
* Derives a symmetric AES-GCM CryptoKey from a passphrase using PBKDF2 or HKDF.
|
|
2363
|
-
* Returns the derived CryptoKey and the base64-encoded salt.
|
|
2364
|
-
*/
|
|
2365
3515
|
static deriveKey(passphrase: string | Uint8Array | ArrayBuffer, options: IKDFOptions): Promise<{
|
|
2366
3516
|
key: CryptoKey;
|
|
2367
3517
|
salt: string;
|
|
2368
3518
|
}>;
|
|
2369
|
-
/**
|
|
2370
|
-
* Derives an AES-GCM CryptoKey from a high-entropy secret (e.g. an ECDH shared secret key)
|
|
2371
|
-
* using HKDF.
|
|
2372
|
-
*/
|
|
2373
3519
|
static deriveKeyFromSecret(secretKey: CryptoKey, options?: IHKDFFromSecretOptions): Promise<CryptoKey>;
|
|
2374
|
-
/**
|
|
2375
|
-
* Derives two domain-separated, cryptographically isolated keys from a user password and salt:
|
|
2376
|
-
* 1. `authKey`: For client authentication, SRP, or server challenge proofs.
|
|
2377
|
-
* 2. `encryptionKey`: For AES-GCM local and field-level data encryption.
|
|
2378
|
-
*
|
|
2379
|
-
* Stage 1 (Password Stretching): PBKDF2-HMAC-SHA256 stretches low-entropy password into master secret.
|
|
2380
|
-
* Stage 2 (Domain Expansion): HKDF-Expand derives subkeys using domain-separated context info tags.
|
|
2381
|
-
* Immediate memory zeroization of intermediate master secret buffer is guaranteed.
|
|
2382
|
-
*
|
|
2383
|
-
* @param password - Master user password or passphrase
|
|
2384
|
-
* @param salt - Salt (or omitted to generate a secure random 16-byte salt)
|
|
2385
|
-
* @param options - PBKDF2 and HKDF configuration options
|
|
2386
|
-
*/
|
|
2387
3520
|
static deriveAuthAndEncryptionKeys(password: string | Uint8Array | ArrayBuffer, salt?: Uint8Array | ArrayBuffer | string, options?: IDeriveAuthAndEncryptionOptions): Promise<IDomainDerivedKeys>;
|
|
2388
|
-
/**
|
|
2389
|
-
* Generates an ECDSA P-256 signing key pair.
|
|
2390
|
-
*/
|
|
2391
3521
|
static generateSigningKeyPair(curve?: 'P-256' | 'P-384' | 'P-521', extractable?: boolean): Promise<IKeyPair>;
|
|
2392
|
-
/**
|
|
2393
|
-
* Generates an ECDSA signing key pair. Alias for generateSigningKeyPair.
|
|
2394
|
-
*/
|
|
2395
3522
|
static generateECDSAKeyPair(curve?: 'P-256' | 'P-384' | 'P-521', extractable?: boolean): Promise<IKeyPair>;
|
|
2396
|
-
/**
|
|
2397
|
-
* Generates a deterministic SHA-256 fingerprint for a public key (SPKI or raw).
|
|
2398
|
-
* Formatted as `SHA256:<base64url>`.
|
|
2399
|
-
*/
|
|
2400
3523
|
static getKeyFingerprint(publicKey: CryptoKey | Uint8Array | ArrayBuffer | string): Promise<string>;
|
|
2401
|
-
/**
|
|
2402
|
-
* Signs arbitrary data or JSON objects using an ECDSA P-256 private key.
|
|
2403
|
-
* Objects are automatically serialized via canonicalizeJson() before hashing.
|
|
2404
|
-
*/
|
|
2405
3524
|
static sign(data: any | string | Uint8Array, privateKey: CryptoKey): Promise<string>;
|
|
2406
|
-
/**
|
|
2407
|
-
* Verifies an ECDSA P-256 signature against original data or JSON object.
|
|
2408
|
-
*/
|
|
2409
3525
|
static verify(data: any | string | Uint8Array, signature: string, publicKey: CryptoKey): Promise<boolean>;
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
* @param hmacKey - CryptoKey configured for HMAC signing.
|
|
2416
|
-
* @returns Lowercase hexadecimal HMAC-SHA256 blind index hash.
|
|
2417
|
-
*/
|
|
2418
|
-
static computeBlindIndex(value: any, hmacKey: CryptoKey): Promise<string>;
|
|
2419
|
-
/**
|
|
2420
|
-
* Signs a structured access grant, embedding signature and granter key fingerprint.
|
|
2421
|
-
*/
|
|
3526
|
+
static deriveBlindIndexHmacKey(keyMaterial: TKeyProvider | CryptoKey | undefined, options?: {
|
|
3527
|
+
kdfIterations?: number;
|
|
3528
|
+
maxAllowedIterations?: number;
|
|
3529
|
+
}): Promise<CryptoKey>;
|
|
3530
|
+
static computeBlindIndex(value: any, hmacKey: CryptoKey, options?: IBlindIndexOptions): Promise<string>;
|
|
2422
3531
|
static signGrant(grant: IAccessGrant, granterPrivateKey: CryptoKey, granterPublicKey?: CryptoKey): Promise<ISignedGrant>;
|
|
2423
|
-
/**
|
|
2424
|
-
* Verifies the authenticity and integrity of a signed access grant against granter public key.
|
|
2425
|
-
*/
|
|
2426
3532
|
static verifyGrant(signedGrant: ISignedGrant, granterPublicKey: CryptoKey, options?: IVerifyGrantOptions): Promise<boolean>;
|
|
2427
|
-
/**
|
|
2428
|
-
* Encrypts raw bytes (e.g. PKCS#8 private key) into a standardized Katlux AES-GCM envelope.
|
|
2429
|
-
*
|
|
2430
|
-
* @param data - Raw byte buffer or Uint8Array to encrypt
|
|
2431
|
-
* @param key - AES-GCM CryptoKey (KEK)
|
|
2432
|
-
* @param options - Optional AAD, IV, or Key Identifier (kid)
|
|
2433
|
-
*/
|
|
2434
3533
|
static encryptPayload(data: ArrayBuffer | Uint8Array, key: CryptoKey, options?: {
|
|
2435
3534
|
iv?: Uint8Array;
|
|
2436
3535
|
aad?: string | Uint8Array | ArrayBuffer;
|
|
2437
3536
|
kid?: string;
|
|
2438
3537
|
}): Promise<IEncryptedPayload>;
|
|
2439
|
-
/**
|
|
2440
|
-
* Decrypts an AES-GCM encrypted envelope back into raw bytes.
|
|
2441
|
-
*
|
|
2442
|
-
* @param payload - Standardized Katlux AES-GCM envelope
|
|
2443
|
-
* @param key - AES-GCM CryptoKey (KEK)
|
|
2444
|
-
* @param options - Optional AAD
|
|
2445
|
-
* @returns Raw decrypted ArrayBuffer
|
|
2446
|
-
*/
|
|
2447
3538
|
static decryptPayload(payload: IEncryptedPayload, key: CryptoKey, options?: {
|
|
2448
3539
|
aad?: string | Uint8Array | ArrayBuffer;
|
|
2449
3540
|
}): Promise<ArrayBuffer>;
|
|
2450
|
-
/**
|
|
2451
|
-
* Atomically re-keys an existing AES-GCM encrypted envelope from oldKey to newKey.
|
|
2452
|
-
* Decrypts with oldKey, derives a fresh random 96-bit IV, and re-encrypts with newKey.
|
|
2453
|
-
* Memory zeroization of internal plaintext and ciphertext buffers is guaranteed via try...finally.
|
|
2454
|
-
*
|
|
2455
|
-
* @param payload - Existing AES-GCM encrypted payload envelope
|
|
2456
|
-
* @param oldKey - Current AES-GCM CryptoKey (KEK)
|
|
2457
|
-
* @param newKey - New AES-GCM CryptoKey (KEK)
|
|
2458
|
-
* @param options - Optional AAD, newAad, and newKid overrides
|
|
2459
|
-
*/
|
|
2460
3541
|
static rekeyEncryptedPayload(payload: IEncryptedPayload, oldKey: CryptoKey, newKey: CryptoKey, options?: IRekeyPayloadOptions): Promise<IEncryptedPayload>;
|
|
2461
|
-
/**
|
|
2462
|
-
* Zero-knowledge master passphrase re-keying pipeline for user keypairs.
|
|
2463
|
-
*
|
|
2464
|
-
* Persistence Contract:
|
|
2465
|
-
* The caller must persist `encryptedPrivateKey`, `encryptedSigningKey`, `newSalt`, and the server
|
|
2466
|
-
* auth verifier ATOMICALLY (within a single database transaction or API request).
|
|
2467
|
-
* Partial persistence will lock the user out permanently.
|
|
2468
|
-
*
|
|
2469
|
-
* Zeroization Notice:
|
|
2470
|
-
* JavaScript memory zeroization (`fill(0)`) is best-effort due to garbage collector copies,
|
|
2471
|
-
* string immutability, and V8/SpiderMonkey engine internals. It strictly zeroes typed array buffers
|
|
2472
|
-
* allocated within Katlux control.
|
|
2473
|
-
*
|
|
2474
|
-
* Key Extractability:
|
|
2475
|
-
* All derived Key-Encrypting Keys (KEKs) are strictly non-extractable (`extractable: false`).
|
|
2476
|
-
* `authKey` extractability follows `newKdfOptions.extractable` (defaults to false).
|
|
2477
|
-
*
|
|
2478
|
-
* @param params - Re-keying configuration parameters
|
|
2479
|
-
* @returns Rekeyed private key envelopes, new salt, and fresh derived subkeys
|
|
2480
|
-
*/
|
|
2481
3542
|
static rekeyUserKeypair(params: IRekeyKeypairParams): Promise<IRekeyedKeypairResult>;
|
|
2482
|
-
/**
|
|
2483
|
-
* Helper to resolve a CryptoKey from a TTrustedAuthorities structure matching a given authorityFingerprint.
|
|
2484
|
-
*/
|
|
2485
3543
|
private static resolveAuthorityCryptoKey;
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
static signKeyResetAttestation(attestation: {
|
|
2493
|
-
version?: 1;
|
|
2494
|
-
entityId: string;
|
|
2495
|
-
oldFingerprint: string;
|
|
2496
|
-
newFingerprint: string;
|
|
2497
|
-
sequence: number;
|
|
2498
|
-
issuedAt?: number;
|
|
2499
|
-
expiresAt: number;
|
|
2500
|
-
authorityFingerprint?: string;
|
|
2501
|
-
reason?: string;
|
|
2502
|
-
}, authorityPrivateKey: CryptoKey, authorityPublicKey?: CryptoKey): Promise<ISignedKeyResetAttestation>;
|
|
2503
|
-
/**
|
|
2504
|
-
* Verifies an incoming public key against the Key Pinning Store (TOFU),
|
|
2505
|
-
* safely accepting legitimate key replacements accompanied by a valid signed reset attestation.
|
|
2506
|
-
*
|
|
2507
|
-
* Threat Model & Security Considerations:
|
|
2508
|
-
* - Protects against: Substituted public keys from a compromised or rogue key directory after first contact.
|
|
2509
|
-
* - Does not protect against: Initial contact substitution (TOFU attack), malicious JavaScript served by
|
|
2510
|
-
* the same origin, or client-side storage tampering via XSS. Pinning is defense-in-depth.
|
|
2511
|
-
* - Authorities MUST be provisioned out-of-band (e.g. bundled app config), NEVER fetched dynamically from the key server.
|
|
2512
|
-
*
|
|
2513
|
-
* @param entityId - Peer or entity unique identifier
|
|
2514
|
-
* @param publicKey - Presented public key (CryptoKey, SPKI Uint8Array/ArrayBuffer, or PEM/Base64 string)
|
|
2515
|
-
* @param options - Pinning store, trusted authorities, and optional attestation resolver
|
|
2516
|
-
*/
|
|
3544
|
+
static signKeyResetAttestation(attestation: Parameters<typeof signKeyResetAttestation>[0], authorityPrivateKey: CryptoKey, authorityPublicKey?: CryptoKey): Promise<ISignedKeyResetAttestation>;
|
|
3545
|
+
static verifyAttestation(signedAttestation: ISignedKeyResetAttestation, trustedAuthorities: TTrustedAuthorities, options?: {
|
|
3546
|
+
clockSkewMs?: number;
|
|
3547
|
+
maxExpirationWindowMs?: number;
|
|
3548
|
+
now?: number;
|
|
3549
|
+
}): Promise<IKeyResetAttestation>;
|
|
2517
3550
|
static verifyAndPinKey(entityId: string, publicKey: CryptoKey | Uint8Array | ArrayBuffer | string, options: IVerifyAndPinOptions): Promise<IVerifyAndPinResult>;
|
|
2518
|
-
/**
|
|
2519
|
-
* Validates the structural integrity and lifecycle rules of a blind-index keyring.
|
|
2520
|
-
*
|
|
2521
|
-
* Enforcement rules:
|
|
2522
|
-
* - Keyring must be an object with string `activeKid` and `keys` dictionary.
|
|
2523
|
-
* - Exactly one key in `keys` must have `status: 'active'`.
|
|
2524
|
-
* - The active key's key ID must strictly match `activeKid`.
|
|
2525
|
-
* - Every key must possess a valid HMAC `CryptoKey` instance.
|
|
2526
|
-
*
|
|
2527
|
-
* Throws `ERR_BIDX_KEYRING_INVALID` on any violation.
|
|
2528
|
-
*/
|
|
2529
3551
|
static validateBlindIndexKeyring(keyring: IBlindIndexKeyring): void;
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
3552
|
+
static computeMultiBlindIndex(value: any, keyring: IBlindIndexKeyring, options?: IBlindIndexOptions): Promise<string[]>;
|
|
3553
|
+
static computeWriteBlindIndex(value: any, keyring: IBlindIndexKeyring, options?: IBlindIndexOptions): Promise<string>;
|
|
3554
|
+
static computeBlindIndexSchemeId(options?: IBlindIndexSchemeOptions): string;
|
|
3555
|
+
}
|
|
3556
|
+
|
|
3557
|
+
/**
|
|
3558
|
+
* Shared cryptographic utilities for Web Crypto API access and random byte generation.
|
|
3559
|
+
* Internal module for Katlux Encryption Providers.
|
|
3560
|
+
*/
|
|
3561
|
+
/**
|
|
3562
|
+
* Resolves the SubtleCrypto instance from globalThis.
|
|
3563
|
+
* Throws a descriptive error if Web Crypto API is unavailable.
|
|
3564
|
+
*/
|
|
3565
|
+
declare function getSubtleCrypto(): SubtleCrypto;
|
|
3566
|
+
/**
|
|
3567
|
+
* Fills a typed array with cryptographically secure random values using crypto.getRandomValues.
|
|
3568
|
+
*/
|
|
3569
|
+
declare function getRandomValues(array: Uint8Array): Uint8Array;
|
|
3570
|
+
declare const textEncoder: TextEncoder;
|
|
3571
|
+
declare const textDecoder: TextDecoder;
|
|
3572
|
+
/**
|
|
3573
|
+
* Resolves an HKDF info / context parameter into a Uint8Array.
|
|
3574
|
+
* Safely preserves raw binary buffers (Uint8Array, ArrayBuffer) without string coercion.
|
|
3575
|
+
*/
|
|
3576
|
+
declare function resolveInfoBytes(info?: string | Uint8Array | ArrayBuffer, fallback?: string): Uint8Array;
|
|
3577
|
+
/**
|
|
3578
|
+
* Safely assigns a property to a target object, preventing prototype pollution attacks
|
|
3579
|
+
* via __proto__, constructor, or prototype manipulation.
|
|
3580
|
+
*/
|
|
3581
|
+
declare function safeSetProperty(target: Record<string, any>, key: string, value: any): void;
|
|
3582
|
+
/**
|
|
3583
|
+
* Checks whether two cryptographic keys, passphrases, or buffers represent the identical key material.
|
|
3584
|
+
* Used to enforce strict key isolation between data encryption keys and HMAC blind index keys.
|
|
3585
|
+
*/
|
|
3586
|
+
declare function areKeysIdentical(key1: any, key2: any): boolean;
|
|
3587
|
+
/**
|
|
3588
|
+
* Converts an ArrayBuffer or Uint8Array into a Base64-encoded string.
|
|
3589
|
+
*/
|
|
3590
|
+
declare function toBase64(buffer: ArrayBuffer | Uint8Array): string;
|
|
3591
|
+
/**
|
|
3592
|
+
* Fast 64-bit FNV-1a hash formatted as a hex string.
|
|
3593
|
+
* Non-cryptographic, zero-allocation, synchronous hash used for safe heap cache indexing
|
|
3594
|
+
* without retaining plaintext secrets in compound Map keys.
|
|
3595
|
+
*/
|
|
3596
|
+
declare function fastKeyHash(str: string): string;
|
|
3597
|
+
/**
|
|
3598
|
+
* Computes a collision-free, safe string identifier for a resolved key.
|
|
3599
|
+
* Hashes raw string passphrases to ensure secrets never reside in compound Map keys (Minor 8)
|
|
3600
|
+
* and resolves function outputs so multi-tenant SSR requests never collide on function references (Major 3).
|
|
3601
|
+
*/
|
|
3602
|
+
declare function getSafeKeyIdentifier(rawKey: any): string;
|
|
3603
|
+
/**
|
|
3604
|
+
* Returns a collision-free string identifier for a key provider or fallback key.
|
|
3605
|
+
* Uses a hashed identifier for strings and WeakMap for objects to prevent
|
|
3606
|
+
* cross-tenant cache collisions and avoid storing secrets in heap Map keys.
|
|
3607
|
+
*/
|
|
3608
|
+
declare function getKeyIdentifier(keyProvider?: any, defaultKey?: any): string;
|
|
3609
|
+
declare const DEFAULT_KEY_CACHE_MAX_SIZE = 100;
|
|
3610
|
+
/**
|
|
3611
|
+
* Retrieves an entry from an LRU Map cache and refreshes its recency position.
|
|
3612
|
+
*/
|
|
3613
|
+
declare function getLruCacheEntry<K, V>(cache: Map<K, V>, key: K): V | undefined;
|
|
3614
|
+
/**
|
|
3615
|
+
* Inserts or updates an entry in a bounded LRU Map cache, evicting the least-recently-used
|
|
3616
|
+
* entry if the cache has reached `maxSize`.
|
|
3617
|
+
*/
|
|
3618
|
+
declare function setLruCacheEntry<K, V>(cache: Map<K, V>, key: K, value: V, maxSize?: number, onEvict?: (evictedKey: K, evictedValue: V) => void): void;
|
|
3619
|
+
/**
|
|
3620
|
+
* Detects whether an error thrown during ciphertext decryption is an authentication failure
|
|
3621
|
+
* (e.g. tag mismatch, invalid AAD, corrupted ciphertext) across Web Crypto and Node.js runtimes.
|
|
3622
|
+
* Conforms to W3C Web Cryptography API specification (OperationError) and Node.js crypto error codes.
|
|
3623
|
+
*/
|
|
3624
|
+
declare const ERR_CRYPTO_DECRYPT_FAILED = "ERR_CRYPTO_DECRYPT_FAILED";
|
|
3625
|
+
declare const ERR_AUTH_UNAUTHORIZED = "ERR_AUTH_UNAUTHORIZED";
|
|
3626
|
+
declare const ERR_CRYPTO_TAG_MISMATCH = "ERR_CRYPTO_TAG_MISMATCH";
|
|
3627
|
+
declare const ERR_CRYPTO_AUTH_FAILED = "ERR_CRYPTO_AUTH_FAILED";
|
|
3628
|
+
/**
|
|
3629
|
+
* Detects whether an error thrown during ciphertext decryption is an authentication failure
|
|
3630
|
+
* (e.g. tag mismatch, invalid AAD, corrupted ciphertext) across Web Crypto and Node.js runtimes.
|
|
3631
|
+
* Conforms to W3C Web Cryptography API specification (OperationError) and Node.js crypto error codes.
|
|
3632
|
+
*/
|
|
3633
|
+
declare function isAuthOrDecryptionError(err: any): boolean;
|
|
3634
|
+
/**
|
|
3635
|
+
* Serializes a JavaScript value to a deterministic, canonical JSON string conforming to RFC 8785 (JCS).
|
|
3636
|
+
* Guarantees consistent property sorting by UTF-16 code units, omission of undefined/symbol/function values,
|
|
3637
|
+
* standard ECMAScript number formatting (-0 serialized as 0), and detection of circular references.
|
|
3638
|
+
*/
|
|
3639
|
+
declare function canonicalizeJson(value: any, seen?: Set<any>): string;
|
|
3640
|
+
declare const DEFAULT_PBKDF2_ITERATIONS = 600000;
|
|
3641
|
+
declare const DEFAULT_MAX_ALLOWED_ITERATIONS = 1000000;
|
|
3642
|
+
declare const DEFAULT_MAX_SALT_DERIVATIONS = 5;
|
|
3643
|
+
/**
|
|
3644
|
+
* Validates that a requested PBKDF2 iteration count does not exceed the configured ceiling.
|
|
3645
|
+
* Throws an Error with `code = 'ERR_EXCESSIVE_KDF_ITERATIONS'` when `iterations > maxAllowed`.
|
|
3646
|
+
*/
|
|
3647
|
+
declare function assertMaxAllowedIterations(iterations: number, maxAllowed?: number, context?: string): void;
|
|
3648
|
+
/**
|
|
3649
|
+
* Resolves the effective PBKDF2 iteration count from override, per-call options,
|
|
3650
|
+
* provider defaults, and `DEFAULT_PBKDF2_ITERATIONS`, validates it against the
|
|
3651
|
+
* configured `maxAllowedIterations` ceiling, and clamps it to `[1000, maxAllowed]`.
|
|
3652
|
+
*/
|
|
3653
|
+
declare function resolveAndClampPbkdf2Iterations(params: {
|
|
3654
|
+
iterationsOverride?: number;
|
|
3655
|
+
optionsIterations?: number;
|
|
3656
|
+
defaultIterations?: number;
|
|
3657
|
+
optionsMaxAllowed?: number;
|
|
3658
|
+
providerMaxAllowed?: number;
|
|
3659
|
+
context?: string;
|
|
3660
|
+
}): number;
|
|
3661
|
+
declare const SALT_BUDGET_SYM: unique symbol;
|
|
3662
|
+
interface ISaltDerivationBudget {
|
|
3663
|
+
maxDistinctSalts: number;
|
|
3664
|
+
hardCapSalts: number;
|
|
3665
|
+
strict: boolean;
|
|
3666
|
+
explicitLimit: boolean;
|
|
3667
|
+
seenSalts: Set<string>;
|
|
3668
|
+
queue: Promise<void>;
|
|
2551
3669
|
}
|
|
3670
|
+
/**
|
|
3671
|
+
* Escapes AAD delimiter characters (`%`, `|`, `:`, `=`, `,`) so user-supplied
|
|
3672
|
+
* record IDs, field names, and context values cannot collide with canonical AAD structure.
|
|
3673
|
+
*/
|
|
3674
|
+
declare function escapeAadComponent(value: string): string;
|
|
3675
|
+
/**
|
|
3676
|
+
* Extracts a record's primary key using standard Katlux primary key fallbacks
|
|
3677
|
+
* (`id`, `_id`, `uuid`, `key`), ignoring `null` and `undefined`.
|
|
3678
|
+
*/
|
|
3679
|
+
declare function extractDefaultRowId(row: any): any;
|
|
3680
|
+
/**
|
|
3681
|
+
* Type-tags and delimiter-escapes an `aadFields` value so distinct JS types
|
|
3682
|
+
* (`null` vs `'null'`, `undefined` vs `''`, `7` vs `'7'`, objects) never collide.
|
|
3683
|
+
*/
|
|
3684
|
+
declare function serializeAadFieldValue(val: any): string;
|
|
3685
|
+
/**
|
|
3686
|
+
* Builds the canonical framed AAD string shared by field encryption and batch re-encryption.
|
|
3687
|
+
*/
|
|
3688
|
+
declare function buildCanonicalFieldAad(params: {
|
|
3689
|
+
data: any;
|
|
3690
|
+
field: string;
|
|
3691
|
+
baseAad?: string;
|
|
3692
|
+
explicitAad?: string;
|
|
3693
|
+
aadFields?: string[];
|
|
3694
|
+
recordId?: string | number;
|
|
3695
|
+
getRowId?: (row: any) => string | number | undefined;
|
|
3696
|
+
reqPart?: string;
|
|
3697
|
+
}): string;
|
|
3698
|
+
/**
|
|
3699
|
+
* Attaches a request/batch-scoped PBKDF2 distinct salt derivation budget to options
|
|
3700
|
+
* without adding enumerable string keys. Preserved across object-spread copies.
|
|
3701
|
+
*/
|
|
3702
|
+
declare function attachSaltDerivationBudget<T extends Record<string, any> | undefined>(options: T, providerMaxSaltDerivations?: number): T & {
|
|
3703
|
+
[SALT_BUDGET_SYM]?: ISaltDerivationBudget;
|
|
3704
|
+
};
|
|
3705
|
+
declare function getSaltDerivationBudget(options?: Record<string, any>): ISaltDerivationBudget | undefined;
|
|
3706
|
+
/**
|
|
3707
|
+
* Synchronously claims a PBKDF2 salt derivation slot for `saltKey` within a request/batch budget.
|
|
3708
|
+
* Rejects with `ERR_KDF_SALT_LIMIT_EXCEEDED` when distinct uncached salts exceed the budget cap.
|
|
3709
|
+
*/
|
|
3710
|
+
declare function claimSaltDerivationSlotSync(options: Record<string, any> | undefined, saltKey: string): void;
|
|
3711
|
+
/**
|
|
3712
|
+
* Acquires a PBKDF2 salt derivation slot for `saltKey` within a request/batch budget.
|
|
3713
|
+
* Rejects immediately under strict mode or explicit caps, and safely serializes non-strict
|
|
3714
|
+
* overflow bursts up to `hardCapSalts` before rejecting with `ERR_KDF_SALT_LIMIT_EXCEEDED`.
|
|
3715
|
+
*/
|
|
3716
|
+
declare function acquireSaltDerivationSlot<R>(options: Record<string, any> | undefined, saltKey: string, task: () => Promise<R>): Promise<R>;
|
|
3717
|
+
/**
|
|
3718
|
+
* Runs an async key derivation task inside `acquireSaltDerivationSlot` when `useSlotBudget` is true,
|
|
3719
|
+
* or directly when no PBKDF2 salt-budget slot is needed.
|
|
3720
|
+
*/
|
|
3721
|
+
declare function runWithSaltDerivationSlot<R>(useSlotBudget: boolean, options: Record<string, any> | undefined, saltKey: string, task: () => Promise<R>): Promise<R>;
|
|
3722
|
+
/**
|
|
3723
|
+
* Resolves a salt-scoped key derivation from an LRU Promise cache (bounded to `maxSize`, default 100),
|
|
3724
|
+
* wrapping new PBKDF2 derivations in `acquireSaltDerivationSlot` and evicting failed promises.
|
|
3725
|
+
*/
|
|
3726
|
+
declare function resolveCachedSaltDerivation<T>(params: {
|
|
3727
|
+
cache: Map<string, Promise<T>>;
|
|
3728
|
+
compoundKey: string;
|
|
3729
|
+
deriveTask: () => Promise<T>;
|
|
3730
|
+
useSlotBudget: boolean;
|
|
3731
|
+
options?: Record<string, any>;
|
|
3732
|
+
onCacheHit?: () => void;
|
|
3733
|
+
maxSize?: number;
|
|
3734
|
+
}): Promise<T>;
|
|
2552
3735
|
|
|
2553
|
-
interface
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
info?: string | Uint8Array | ArrayBuffer;
|
|
2559
|
-
kid?: string;
|
|
3736
|
+
interface IResolvedWebCryptoKey {
|
|
3737
|
+
cryptoKey: CryptoKey;
|
|
3738
|
+
salt?: string;
|
|
3739
|
+
kdf?: string;
|
|
3740
|
+
iter?: number;
|
|
2560
3741
|
keyId?: string;
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
allowedKids?: string[];
|
|
2564
|
-
hmacKey?: TKeyProvider;
|
|
3742
|
+
}
|
|
3743
|
+
interface ICWebCryptoOptions extends IBaseEncryptionProviderOptions {
|
|
2565
3744
|
}
|
|
2566
3745
|
/**
|
|
2567
3746
|
* Zero-dependency AES-256-GCM cipher provider using native Web Crypto API (crypto.subtle).
|
|
@@ -2576,16 +3755,18 @@ interface ICWebCryptoOptions {
|
|
|
2576
3755
|
*/
|
|
2577
3756
|
declare class CWebCryptoEncryptionProvider extends AEncryptionProvider {
|
|
2578
3757
|
private _defaultKdf;
|
|
3758
|
+
private _maxAllowedIterations?;
|
|
2579
3759
|
private _cachedKey?;
|
|
3760
|
+
protected _getActiveDecryptionKey(): TKeyProvider | IKeyPair | undefined;
|
|
2580
3761
|
private _kdfOptions?;
|
|
2581
3762
|
private _cachedSalt?;
|
|
2582
3763
|
private _cachedKdf?;
|
|
2583
3764
|
private _cachedIter?;
|
|
2584
3765
|
private _cachedHash?;
|
|
2585
3766
|
private _cachedKeyId?;
|
|
2586
|
-
private _configuredKid?;
|
|
2587
3767
|
private _decryptSaltCache;
|
|
2588
3768
|
private _keyringCache;
|
|
3769
|
+
private _inflightKeyCache;
|
|
2589
3770
|
setDefaultKey(key: TKeyProvider): void;
|
|
2590
3771
|
clearKeys(): void;
|
|
2591
3772
|
constructor(key?: TKeyProvider | IKeyPair, options?: ICWebCryptoOptions);
|
|
@@ -2597,23 +3778,21 @@ declare class CWebCryptoEncryptionProvider extends AEncryptionProvider {
|
|
|
2597
3778
|
static isEncrypted(payload: any): boolean;
|
|
2598
3779
|
isEncrypted(payload: any): boolean;
|
|
2599
3780
|
warmupKey(options?: IEncryptionContext): Promise<void>;
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
* Decrypts a single AES-GCM envelope back into its plaintext.
|
|
2606
|
-
*/
|
|
2607
|
-
decryptValue(payload: IEncryptedPayload, options?: IEncryptionContext): Promise<any>;
|
|
3781
|
+
protected _assertSupportedEnvelopeAlgorithm(alg?: string): void;
|
|
3782
|
+
protected _resolveEncryptKeyMaterial(options?: IEncryptionContext): Promise<IResolvedWebCryptoKey>;
|
|
3783
|
+
protected _sealPayload(plaintextBytes: Uint8Array, keyMaterial: IResolvedWebCryptoKey, aadBytes: Uint8Array | undefined, options?: IEncryptionContext): Promise<IEncryptedPayload>;
|
|
3784
|
+
protected _resolveDecryptKeyMaterial(payload: IEncryptedPayload, options?: IEncryptionContext): Promise<CryptoKey>;
|
|
3785
|
+
protected _unsealPayload(payload: IEncryptedPayload, cryptoKey: CryptoKey, aadBytes: Uint8Array | undefined): Promise<ArrayBuffer>;
|
|
2608
3786
|
}
|
|
2609
3787
|
|
|
2610
|
-
interface ICWebCryptoAESCBCOptions {
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
3788
|
+
interface ICWebCryptoAESCBCOptions extends IBaseEncryptionProviderOptions {
|
|
3789
|
+
}
|
|
3790
|
+
interface IDerivedCBCKeys {
|
|
3791
|
+
encKey: CryptoKey;
|
|
3792
|
+
macKey: CryptoKey;
|
|
3793
|
+
salt?: string;
|
|
3794
|
+
kdf?: string;
|
|
3795
|
+
iter?: number;
|
|
2617
3796
|
keyId?: string;
|
|
2618
3797
|
}
|
|
2619
3798
|
/**
|
|
@@ -2627,17 +3806,18 @@ interface ICWebCryptoAESCBCOptions {
|
|
|
2627
3806
|
*/
|
|
2628
3807
|
declare class CWebCryptoAESCBCProvider extends AEncryptionProvider {
|
|
2629
3808
|
private _defaultKdf;
|
|
3809
|
+
private _maxAllowedIterations?;
|
|
2630
3810
|
private _cachedEncKey?;
|
|
3811
|
+
protected _getActiveDecryptionKey(): TKeyProvider | IKeyPair | undefined;
|
|
2631
3812
|
private _cachedMacKey?;
|
|
2632
3813
|
private _cachedSalt?;
|
|
2633
3814
|
private _cachedKdf?;
|
|
2634
3815
|
private _cachedIter?;
|
|
2635
3816
|
private _cachedHash?;
|
|
2636
3817
|
private _cachedKeyId?;
|
|
2637
|
-
private _configuredKid?;
|
|
2638
3818
|
private _kdfOptions?;
|
|
2639
3819
|
private _decryptSaltCache;
|
|
2640
|
-
constructor(key?: TKeyProvider | IKeyPair, options?: ICWebCryptoAESCBCOptions);
|
|
3820
|
+
constructor(key?: TKeyProvider | IKeyPair | any, options?: ICWebCryptoAESCBCOptions);
|
|
2641
3821
|
setDefaultKey(key: TKeyProvider | IKeyPair): void;
|
|
2642
3822
|
clearKeys(): void;
|
|
2643
3823
|
warmupKey(options?: IEncryptionContext): Promise<void>;
|
|
@@ -2650,16 +3830,23 @@ declare class CWebCryptoAESCBCProvider extends AEncryptionProvider {
|
|
|
2650
3830
|
private _deriveCBCKeysInternal;
|
|
2651
3831
|
static isEncrypted(payload: any): boolean;
|
|
2652
3832
|
isEncrypted(payload: any): boolean;
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
* Decrypts a single AES-CBC-256+HMAC-SHA-256 envelope back into its plaintext.
|
|
2659
|
-
*/
|
|
2660
|
-
decryptValue(payload: IEncryptedPayload, options?: IEncryptionContext): Promise<any>;
|
|
3833
|
+
protected _assertSupportedEnvelopeAlgorithm(alg?: string): void;
|
|
3834
|
+
protected _resolveEncryptKeyMaterial(options?: IEncryptionContext): Promise<IDerivedCBCKeys>;
|
|
3835
|
+
protected _sealPayload(plaintextBytes: Uint8Array, keyMaterial: IDerivedCBCKeys, aadBytes: Uint8Array | undefined, options?: IEncryptionContext): Promise<IEncryptedPayload>;
|
|
3836
|
+
protected _resolveDecryptKeyMaterial(payload: IEncryptedPayload, options?: IEncryptionContext): Promise<IDerivedCBCKeys>;
|
|
3837
|
+
protected _unsealPayload(payload: IEncryptedPayload, keyMaterial: IDerivedCBCKeys, aadBytes: Uint8Array | undefined): Promise<ArrayBuffer>;
|
|
2661
3838
|
}
|
|
2662
3839
|
|
|
3840
|
+
interface IRsaKeyMaterial extends IEncryptRecordSession {
|
|
3841
|
+
dataKey: CryptoKey;
|
|
3842
|
+
wrappedKeyBase64: string;
|
|
3843
|
+
alg: string;
|
|
3844
|
+
kid?: string;
|
|
3845
|
+
sharedKey: boolean;
|
|
3846
|
+
}
|
|
3847
|
+
interface IRsaDecryptBatchSession extends IDecryptBatchSession {
|
|
3848
|
+
keyCache: Map<string, Promise<CryptoKey>>;
|
|
3849
|
+
}
|
|
2663
3850
|
/**
|
|
2664
3851
|
* Asymmetric / Hybrid encryption provider combining RSA-OAEP (2048/4096-bit) with AES-GCM-256.
|
|
2665
3852
|
*
|
|
@@ -2678,43 +3865,55 @@ declare class CWebCryptoAESCBCProvider extends AEncryptionProvider {
|
|
|
2678
3865
|
* authenticated symmetric role keys (AES-GCM) governed by database role permissions.
|
|
2679
3866
|
*/
|
|
2680
3867
|
declare class CRSAEncryptionProvider extends AEncryptionProvider {
|
|
3868
|
+
protected _usesAsymmetricEnvelopeSignature: boolean;
|
|
2681
3869
|
private publicKey?;
|
|
2682
3870
|
private privateKey?;
|
|
3871
|
+
protected _getDefaultFallbackKey(): TKeyProvider | IKeyPair | undefined;
|
|
2683
3872
|
setDefaultKey(key: TKeyProvider | IKeyPair | Record<string, any>): void;
|
|
2684
|
-
constructor(publicKeyOrPair?: CryptoKey | IKeyPair |
|
|
2685
|
-
publicKey?: CryptoKey;
|
|
2686
|
-
privateKey?: CryptoKey;
|
|
2687
|
-
recipientPublicKey?: CryptoKey;
|
|
2688
|
-
recipientPrivateKey?: CryptoKey;
|
|
2689
|
-
}, privateKey?: CryptoKey);
|
|
3873
|
+
constructor(publicKeyOrPair?: CryptoKey | IKeyPair | (IBaseEncryptionProviderOptions & Pick<IEncryptionOperationOptions, 'publicKey' | 'privateKey' | 'recipientPublicKey' | 'recipientPrivateKey'>), privateKey?: CryptoKey);
|
|
2690
3874
|
setPublicKey(key: CryptoKey): void;
|
|
2691
3875
|
getPublicKey(): CryptoKey | undefined;
|
|
2692
3876
|
setPrivateKey(key: CryptoKey): void;
|
|
2693
3877
|
getPrivateKey(): CryptoKey | undefined;
|
|
2694
3878
|
clearKeys(): void;
|
|
2695
|
-
static generateKeyPair(bits?: 2048 | 4096): Promise<IKeyPair>;
|
|
3879
|
+
static generateKeyPair(bits?: 2048 | 4096, extractable?: boolean): Promise<IKeyPair>;
|
|
2696
3880
|
static exportPublicKey(key: CryptoKey): Promise<JsonWebKey>;
|
|
2697
3881
|
static exportPrivateKey(key: CryptoKey): Promise<JsonWebKey>;
|
|
2698
3882
|
static importPublicKey(jwk: JsonWebKey): Promise<CryptoKey>;
|
|
2699
|
-
static importPrivateKey(jwk: JsonWebKey): Promise<CryptoKey>;
|
|
3883
|
+
static importPrivateKey(jwk: JsonWebKey, extractable?: boolean): Promise<CryptoKey>;
|
|
2700
3884
|
static importPublicKeyFromPEM(pem: string, hash?: 'SHA-256' | 'SHA-512'): Promise<CryptoKey>;
|
|
2701
|
-
static importPrivateKeyFromPEM(pem: string, hash?: 'SHA-256' | 'SHA-512'): Promise<CryptoKey>;
|
|
3885
|
+
static importPrivateKeyFromPEM(pem: string, hash?: 'SHA-256' | 'SHA-512', extractable?: boolean): Promise<CryptoKey>;
|
|
2702
3886
|
static exportPublicKeyToPEM(key: CryptoKey): Promise<string>;
|
|
2703
3887
|
static exportPrivateKeyToPEM(key: CryptoKey): Promise<string>;
|
|
2704
3888
|
static isEncrypted(payload: any): boolean;
|
|
2705
3889
|
isEncrypted(payload: any): boolean;
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
3890
|
+
private _resolvePublicKeyAndKid;
|
|
3891
|
+
private _resolvePrivateKeyForDecrypt;
|
|
3892
|
+
protected _assertSupportedEnvelopeAlgorithm(alg?: string): void;
|
|
3893
|
+
private _createEphemeralRsaKeyMaterial;
|
|
3894
|
+
protected _beginEncryptRecordSession(options?: IEncryptionContext): Promise<IRsaKeyMaterial>;
|
|
3895
|
+
protected _resolveEncryptKeyMaterial(options?: IEncryptionContext, session?: IEncryptRecordSession): Promise<IRsaKeyMaterial>;
|
|
3896
|
+
protected _sealPayload(plaintextBytes: Uint8Array, keyMaterial: IRsaKeyMaterial, aadBytes: Uint8Array | undefined): Promise<IEncryptedPayload>;
|
|
3897
|
+
protected _beginDecryptBatchSession(): IRsaDecryptBatchSession;
|
|
3898
|
+
protected _prepareFieldDecryptContext(item: Record<string, any>, _field: string, payload: IEncryptedPayload, options?: IEncryptionContext): {
|
|
3899
|
+
payload: IEncryptedPayload;
|
|
3900
|
+
options?: IEncryptionContext;
|
|
3901
|
+
};
|
|
3902
|
+
protected _finalizeDecryptedRecord(item: Record<string, any>, result: Record<string, any>): void;
|
|
3903
|
+
protected _resolveDecryptKeyMaterial(payload: IEncryptedPayload, options?: IEncryptionContext, session?: IDecryptBatchSession): Promise<CryptoKey>;
|
|
3904
|
+
protected _unsealPayload(payload: IEncryptedPayload, dataKey: CryptoKey, aadBytes: Uint8Array | undefined): Promise<ArrayBuffer>;
|
|
2716
3905
|
}
|
|
2717
3906
|
|
|
3907
|
+
interface IEcdhKeyMaterial extends IEncryptRecordSession {
|
|
3908
|
+
dataKey: CryptoKey;
|
|
3909
|
+
epkJwk: JsonWebKey;
|
|
3910
|
+
saltBase64: string;
|
|
3911
|
+
alg: string;
|
|
3912
|
+
kid?: string;
|
|
3913
|
+
}
|
|
3914
|
+
interface IEcdhDecryptBatchSession extends IDecryptBatchSession {
|
|
3915
|
+
keyCache: Map<string, Promise<CryptoKey>>;
|
|
3916
|
+
}
|
|
2718
3917
|
type TECDHCurve = 'P-256' | 'P-384' | 'P-521';
|
|
2719
3918
|
/**
|
|
2720
3919
|
* Modern Asymmetric / Hybrid encryption provider using ECDH (Elliptic Curve Diffie-Hellman)
|
|
@@ -2735,70 +3934,55 @@ type TECDHCurve = 'P-256' | 'P-384' | 'P-521';
|
|
|
2735
3934
|
* or use authenticated symmetric role keys (AES-GCM) managed via database role permissions.
|
|
2736
3935
|
*/
|
|
2737
3936
|
declare class CECDHEncryptionProvider extends AEncryptionProvider {
|
|
3937
|
+
protected _usesAsymmetricEnvelopeSignature: boolean;
|
|
2738
3938
|
private recipientPublicKey?;
|
|
2739
3939
|
private recipientPrivateKey?;
|
|
3940
|
+
protected _getDefaultFallbackKey(): TKeyProvider | IKeyPair | undefined;
|
|
2740
3941
|
private curve;
|
|
2741
3942
|
setDefaultKey(key: TKeyProvider | IKeyPair | Record<string, any>): void;
|
|
2742
|
-
constructor(recipientPublicKeyOrPair?: CryptoKey | IKeyPair |
|
|
2743
|
-
recipientPublicKey?: CryptoKey;
|
|
2744
|
-
publicKey?: CryptoKey;
|
|
2745
|
-
recipientPrivateKey?: CryptoKey;
|
|
2746
|
-
privateKey?: CryptoKey;
|
|
2747
|
-
curve?: TECDHCurve;
|
|
2748
|
-
}, recipientPrivateKey?: CryptoKey, curve?: TECDHCurve);
|
|
3943
|
+
constructor(recipientPublicKeyOrPair?: CryptoKey | IKeyPair | (IBaseEncryptionProviderOptions & Pick<IEncryptionOperationOptions, 'publicKey' | 'privateKey' | 'recipientPublicKey' | 'recipientPrivateKey' | 'curve'>), recipientPrivateKey?: CryptoKey, curve?: TECDHCurve);
|
|
2749
3944
|
setRecipientPublicKey(key: CryptoKey): void;
|
|
2750
3945
|
getRecipientPublicKey(): CryptoKey | undefined;
|
|
2751
3946
|
setRecipientPrivateKey(key: CryptoKey): void;
|
|
2752
3947
|
getRecipientPrivateKey(): CryptoKey | undefined;
|
|
2753
3948
|
getCurve(): TECDHCurve;
|
|
2754
3949
|
clearKeys(): void;
|
|
2755
|
-
static generateKeyPair(curve?: TECDHCurve): Promise<IKeyPair>;
|
|
3950
|
+
static generateKeyPair(curve?: TECDHCurve, extractable?: boolean): Promise<IKeyPair>;
|
|
2756
3951
|
static exportPublicKey(key: CryptoKey): Promise<JsonWebKey>;
|
|
2757
3952
|
static exportPrivateKey(key: CryptoKey): Promise<JsonWebKey>;
|
|
2758
3953
|
static importPublicKey(jwk: JsonWebKey, curve?: TECDHCurve): Promise<CryptoKey>;
|
|
2759
|
-
static importPrivateKey(jwk: JsonWebKey, curve?: TECDHCurve): Promise<CryptoKey>;
|
|
3954
|
+
static importPrivateKey(jwk: JsonWebKey, curve?: TECDHCurve, extractable?: boolean): Promise<CryptoKey>;
|
|
2760
3955
|
static importPublicKeyFromPEM(pem: string, curve?: TECDHCurve): Promise<CryptoKey>;
|
|
2761
|
-
static importPrivateKeyFromPEM(pem: string, curve?: TECDHCurve): Promise<CryptoKey>;
|
|
3956
|
+
static importPrivateKeyFromPEM(pem: string, curve?: TECDHCurve, extractable?: boolean): Promise<CryptoKey>;
|
|
2762
3957
|
static exportPublicKeyToPEM(key: CryptoKey): Promise<string>;
|
|
2763
3958
|
static exportPrivateKeyToPEM(key: CryptoKey): Promise<string>;
|
|
2764
3959
|
static isEncrypted(payload: any): boolean;
|
|
2765
3960
|
isEncrypted(payload: any): boolean;
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
private deriveDecryptionKey;
|
|
2778
|
-
/**
|
|
2779
|
-
* Decrypts ciphertext buffer using a derived data key.
|
|
2780
|
-
*/
|
|
2781
|
-
private decryptCiphertextWithKey;
|
|
2782
|
-
/**
|
|
2783
|
-
* Decrypts a single ECDH+HKDF+AES-GCM envelope back into its plaintext.
|
|
2784
|
-
*/
|
|
2785
|
-
decryptValue(payload: IEncryptedPayload, options?: IEncryptionContext): Promise<any>;
|
|
2786
|
-
encrypt(data: any, options?: IEncryptionContext): Promise<any>;
|
|
2787
|
-
decrypt(payload: any, options?: IEncryptionContext): Promise<any>;
|
|
3961
|
+
private _resolvePublicKeyAndKid;
|
|
3962
|
+
private _resolvePrivateKeyForDecrypt;
|
|
3963
|
+
protected _assertSupportedEnvelopeAlgorithm(alg?: string): void;
|
|
3964
|
+
private _createEphemeralEcdhKeyMaterial;
|
|
3965
|
+
protected _beginEncryptRecordSession(options?: IEncryptionContext): Promise<IEcdhKeyMaterial>;
|
|
3966
|
+
protected _resolveEncryptKeyMaterial(options?: IEncryptionContext, session?: IEncryptRecordSession): Promise<IEcdhKeyMaterial>;
|
|
3967
|
+
protected _sealPayload(plaintextBytes: Uint8Array, keyMaterial: IEcdhKeyMaterial, aadBytes: Uint8Array | undefined): Promise<IEncryptedPayload>;
|
|
3968
|
+
protected _beginDecryptBatchSession(): IEcdhDecryptBatchSession;
|
|
3969
|
+
private _deriveDecryptionKeyWithPrivKey;
|
|
3970
|
+
protected _resolveDecryptKeyMaterial(payload: IEncryptedPayload, options?: IEncryptionContext, session?: IDecryptBatchSession): Promise<CryptoKey>;
|
|
3971
|
+
protected _unsealPayload(payload: IEncryptedPayload, dataKey: CryptoKey, aadBytes: Uint8Array | undefined): Promise<ArrayBuffer>;
|
|
2788
3972
|
}
|
|
2789
3973
|
|
|
2790
|
-
interface
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
3974
|
+
interface ICachedNodeKeyEntry {
|
|
3975
|
+
key: Buffer;
|
|
3976
|
+
salt?: string;
|
|
3977
|
+
kdf?: string;
|
|
3978
|
+
iter?: number;
|
|
3979
|
+
}
|
|
3980
|
+
|
|
3981
|
+
interface INodeDecryptBatchSession extends IDecryptBatchSession {
|
|
3982
|
+
keyCache: Map<string, Promise<Buffer>>;
|
|
3983
|
+
tempBuffers: Set<Buffer>;
|
|
3984
|
+
}
|
|
3985
|
+
interface ICNodeCryptoOptions extends IBaseEncryptionProviderOptions {
|
|
2802
3986
|
}
|
|
2803
3987
|
/**
|
|
2804
3988
|
* Server-side synchronous AES-GCM-256 encryption provider using Node.js native `node:crypto`.
|
|
@@ -2811,50 +3995,60 @@ interface ICNodeCryptoOptions {
|
|
|
2811
3995
|
* (`encrypt`, `decrypt`) methods for Nitro routes, worker threads, and CLI tools.
|
|
2812
3996
|
*/
|
|
2813
3997
|
declare class CNodeCryptoEncryptionProvider extends AEncryptionProvider {
|
|
3998
|
+
static randomBytes(length: number): Buffer;
|
|
3999
|
+
static createDecipheriv(algorithm: string, key: NodeCrypto.CipherKey, iv: NodeCrypto.BinaryLike | null, options?: NodeCrypto.CipherCCMOptions): NodeCrypto.DecipherGCM;
|
|
2814
4000
|
private _defaultKdf;
|
|
4001
|
+
private _maxAllowedIterations?;
|
|
2815
4002
|
private _kdfOptions?;
|
|
2816
4003
|
private _cachedKey?;
|
|
4004
|
+
protected _getActiveDecryptionKey(): TKeyProvider | IKeyPair | undefined;
|
|
2817
4005
|
private _cachedSalt?;
|
|
2818
4006
|
private _cachedKdf?;
|
|
2819
4007
|
private _cachedIter?;
|
|
2820
4008
|
private _cachedHash?;
|
|
2821
4009
|
private _cachedKeyId?;
|
|
2822
|
-
private _configuredKid?;
|
|
2823
4010
|
private _keyringCache;
|
|
4011
|
+
private _decryptSaltCache;
|
|
4012
|
+
private _inFlightSaltDerivations;
|
|
4013
|
+
constructor(key?: TKeyProvider | IKeyPair, options?: ICNodeCryptoOptions);
|
|
2824
4014
|
private isKeyRetained;
|
|
4015
|
+
private _wipeCachedBuffers;
|
|
2825
4016
|
setDefaultKey(key: TKeyProvider): void;
|
|
2826
4017
|
clearKeys(): void;
|
|
4018
|
+
setKeyring(keys: Record<string, TKeyProvider | IKeyPair>, activeKid?: string): void;
|
|
4019
|
+
private _setPrimaryCached;
|
|
4020
|
+
private _setKeyringCached;
|
|
4021
|
+
private _setDecryptSaltCached;
|
|
2827
4022
|
warmupKey(options?: IEncryptionContext): Promise<void>;
|
|
2828
|
-
/**
|
|
2829
|
-
* Synchronously pre-derives and caches the encryption key for subsequent synchronous operations.
|
|
2830
|
-
*/
|
|
2831
4023
|
warmupKeySync(options?: IEncryptionContext): void;
|
|
2832
|
-
private resolveInfoBuffer;
|
|
2833
|
-
constructor(key?: TKeyProvider | IKeyPair, options?: ICNodeCryptoOptions);
|
|
2834
4024
|
private resolveRawKeySync;
|
|
2835
4025
|
private resolveRawKeyAsync;
|
|
4026
|
+
private _resolveCachedOrRawBuffer;
|
|
4027
|
+
private _recordDerivedKey;
|
|
2836
4028
|
private deriveKeySync;
|
|
2837
4029
|
private deriveKeyAsync;
|
|
2838
4030
|
static isEncrypted(payload: any): boolean;
|
|
2839
4031
|
isEncrypted(payload: any): boolean;
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
4032
|
+
protected _assertSupportedEnvelopeAlgorithm(alg?: string): void;
|
|
4033
|
+
private _validateDecryptPreconditions;
|
|
4034
|
+
private _decryptEnvelopeSyncWithAadFallback;
|
|
4035
|
+
private _decryptFieldPayloadSyncWithKey;
|
|
2843
4036
|
encryptValueSync(data: any, options?: IEncryptionContext): IEncryptedPayload;
|
|
2844
|
-
private decryptCiphertextWithKey;
|
|
2845
|
-
/**
|
|
2846
|
-
* Synchronously decrypts a single AES-GCM envelope back into its plaintext.
|
|
2847
|
-
*/
|
|
2848
4037
|
decryptValueSync(payload: IEncryptedPayload, options?: IEncryptionContext): any;
|
|
2849
4038
|
encryptSync(data: any, options?: IEncryptionContext): any;
|
|
4039
|
+
private _decryptRowSync;
|
|
2850
4040
|
decryptSync(payload: any, options?: IEncryptionContext): any;
|
|
2851
4041
|
encryptFieldsSync(data: any, fields: string[]): any;
|
|
2852
|
-
decryptFieldsSync(data: any, fields: string[]): any;
|
|
4042
|
+
decryptFieldsSync(data: any, fields: string[], options?: IEncryptionContext): any;
|
|
2853
4043
|
encryptFields(data: any, fields: string[]): Promise<any>;
|
|
2854
|
-
decryptFields(data: any, fields: string[]): Promise<any>;
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
4044
|
+
decryptFields(data: any, fields: string[], options?: IEncryptionContext): Promise<any>;
|
|
4045
|
+
protected _resolveEncryptKeyMaterial(options?: IEncryptionContext): Promise<ICachedNodeKeyEntry>;
|
|
4046
|
+
protected _releaseEncryptKeyMaterial(derived: ICachedNodeKeyEntry): void;
|
|
4047
|
+
protected _sealPayload(plaintextBytes: Uint8Array, derived: ICachedNodeKeyEntry, aadBytes: Uint8Array | undefined, options?: IEncryptionContext): Promise<IEncryptedPayload>;
|
|
4048
|
+
protected _beginDecryptBatchSession(): INodeDecryptBatchSession;
|
|
4049
|
+
protected _resolveDecryptKeyMaterial(payload: IEncryptedPayload, options?: IEncryptionContext, session?: IDecryptBatchSession): Promise<Buffer>;
|
|
4050
|
+
protected _releaseDecryptKeyMaterial(key: Buffer, session?: IDecryptBatchSession): void;
|
|
4051
|
+
protected _unsealPayload(payload: IEncryptedPayload, key: Buffer, aadBytes: Uint8Array | undefined): Promise<Buffer>;
|
|
2858
4052
|
}
|
|
2859
4053
|
|
|
2860
4054
|
/**
|
|
@@ -2870,66 +4064,6 @@ declare class CNodeCryptoEncryptionProvider extends AEncryptionProvider {
|
|
|
2870
4064
|
*/
|
|
2871
4065
|
declare function createEncryptionProvider(options?: IProviderEncryptionOptions): IEncryptionProvider;
|
|
2872
4066
|
|
|
2873
|
-
/**
|
|
2874
|
-
* Shared cryptographic utilities for Web Crypto API access and random byte generation.
|
|
2875
|
-
* Internal module for Katlux Encryption Providers.
|
|
2876
|
-
*/
|
|
2877
|
-
/**
|
|
2878
|
-
* Resolves the SubtleCrypto instance from globalThis.
|
|
2879
|
-
* Throws a descriptive error if Web Crypto API is unavailable.
|
|
2880
|
-
*/
|
|
2881
|
-
declare function getSubtleCrypto(): SubtleCrypto;
|
|
2882
|
-
/**
|
|
2883
|
-
* Fills a typed array with cryptographically secure random values using crypto.getRandomValues.
|
|
2884
|
-
*/
|
|
2885
|
-
declare function getRandomValues(array: Uint8Array): Uint8Array;
|
|
2886
|
-
declare const textEncoder: TextEncoder;
|
|
2887
|
-
declare const textDecoder: TextDecoder;
|
|
2888
|
-
/**
|
|
2889
|
-
* Resolves an HKDF info / context parameter into a Uint8Array.
|
|
2890
|
-
* Safely preserves raw binary buffers (Uint8Array, ArrayBuffer) without string coercion.
|
|
2891
|
-
*/
|
|
2892
|
-
declare function resolveInfoBytes(info?: string | Uint8Array | ArrayBuffer, fallback?: string): Uint8Array;
|
|
2893
|
-
/**
|
|
2894
|
-
* Safely assigns a property to a target object, preventing prototype pollution attacks
|
|
2895
|
-
* via __proto__, constructor, or prototype manipulation.
|
|
2896
|
-
*/
|
|
2897
|
-
declare function safeSetProperty(target: Record<string, any>, key: string, value: any): void;
|
|
2898
|
-
/**
|
|
2899
|
-
* Converts an ArrayBuffer or Uint8Array into a Base64-encoded string.
|
|
2900
|
-
*/
|
|
2901
|
-
declare function toBase64(buffer: ArrayBuffer | Uint8Array): string;
|
|
2902
|
-
/**
|
|
2903
|
-
* Fast 64-bit FNV-1a hash formatted as a hex string.
|
|
2904
|
-
* Non-cryptographic, zero-allocation, synchronous hash used for safe heap cache indexing
|
|
2905
|
-
* without retaining plaintext secrets in compound Map keys.
|
|
2906
|
-
*/
|
|
2907
|
-
declare function fastKeyHash(str: string): string;
|
|
2908
|
-
/**
|
|
2909
|
-
* Computes a collision-free, safe string identifier for a resolved key.
|
|
2910
|
-
* Hashes raw string passphrases to ensure secrets never reside in compound Map keys (Minor 8)
|
|
2911
|
-
* and resolves function outputs so multi-tenant SSR requests never collide on function references (Major 3).
|
|
2912
|
-
*/
|
|
2913
|
-
declare function getSafeKeyIdentifier(rawKey: any): string;
|
|
2914
|
-
/**
|
|
2915
|
-
* Returns a collision-free string identifier for a key provider or fallback key.
|
|
2916
|
-
* Uses a hashed identifier for strings and WeakMap for objects to prevent
|
|
2917
|
-
* cross-tenant cache collisions and avoid storing secrets in heap Map keys.
|
|
2918
|
-
*/
|
|
2919
|
-
declare function getKeyIdentifier(keyProvider?: any, defaultKey?: any): string;
|
|
2920
|
-
/**
|
|
2921
|
-
* Detects whether an error thrown during ciphertext decryption is an authentication failure
|
|
2922
|
-
* (e.g. tag mismatch, invalid AAD, corrupted ciphertext) across Web Crypto and Node.js runtimes.
|
|
2923
|
-
* Conforms to W3C Web Cryptography API specification (OperationError) and Node.js crypto error codes.
|
|
2924
|
-
*/
|
|
2925
|
-
declare function isAuthOrDecryptionError(err: any): boolean;
|
|
2926
|
-
/**
|
|
2927
|
-
* Serializes a JavaScript value to a deterministic, canonical JSON string conforming to RFC 8785 (JCS).
|
|
2928
|
-
* Guarantees consistent property sorting by UTF-16 code units, omission of undefined/symbol/function values,
|
|
2929
|
-
* standard ECMAScript number formatting (-0 serialized as 0), and detection of circular references.
|
|
2930
|
-
*/
|
|
2931
|
-
declare function canonicalizeJson(value: any, seen?: Set<any>): string;
|
|
2932
|
-
|
|
2933
4067
|
/**
|
|
2934
4068
|
* Web Streams Chunked AEAD Encryption & Decryption for Large Payloads.
|
|
2935
4069
|
* Implements the STREAM construction (AES-GCM with 96-bit nonces, wrapped per-stream DEK,
|
|
@@ -2951,6 +4085,14 @@ interface IStreamEncryptionOptions {
|
|
|
2951
4085
|
* Allowed range: 4096 (4 KiB) to 4194304 (4 MiB).
|
|
2952
4086
|
*/
|
|
2953
4087
|
chunkSize?: number;
|
|
4088
|
+
/**
|
|
4089
|
+
* PBKDF2 iteration count when `key` is a human passphrase. Default: DEFAULT_PBKDF2_ITERATIONS (600,000).
|
|
4090
|
+
*/
|
|
4091
|
+
kdfIterations?: number;
|
|
4092
|
+
/**
|
|
4093
|
+
* Maximum allowed PBKDF2 iteration count ceiling. Default: DEFAULT_MAX_ALLOWED_ITERATIONS (1,000,000).
|
|
4094
|
+
*/
|
|
4095
|
+
maxAllowedIterations?: number;
|
|
2954
4096
|
}
|
|
2955
4097
|
interface IStreamDecryptionOptions {
|
|
2956
4098
|
/**
|
|
@@ -2965,6 +4107,14 @@ interface IStreamDecryptionOptions {
|
|
|
2965
4107
|
* Alias for keyring to maintain consistency with IProviderEncryptionOptions.
|
|
2966
4108
|
*/
|
|
2967
4109
|
keys?: Record<string, TKeyProvider | IKeyPair>;
|
|
4110
|
+
/**
|
|
4111
|
+
* PBKDF2 iteration count when `key` or keyring entry is a human passphrase. Default: DEFAULT_PBKDF2_ITERATIONS (600,000).
|
|
4112
|
+
*/
|
|
4113
|
+
kdfIterations?: number;
|
|
4114
|
+
/**
|
|
4115
|
+
* Maximum allowed PBKDF2 iteration count ceiling. Default: DEFAULT_MAX_ALLOWED_ITERATIONS (1,000,000).
|
|
4116
|
+
*/
|
|
4117
|
+
maxAllowedIterations?: number;
|
|
2968
4118
|
}
|
|
2969
4119
|
interface IStreamWithBufferMetric<I, O> extends TransformStream<I, O> {
|
|
2970
4120
|
/**
|
|
@@ -2988,6 +4138,12 @@ declare function encryptBlob(blob: Blob, options: IStreamEncryptionOptions): Pro
|
|
|
2988
4138
|
* Decrypts a Blob payload using Web Streams chunked AEAD decryption.
|
|
2989
4139
|
*/
|
|
2990
4140
|
declare function decryptBlob(blob: Blob, options: IStreamDecryptionOptions, mimeType?: string): Promise<Blob>;
|
|
4141
|
+
declare const CWebCryptoStreamCipher: {
|
|
4142
|
+
createEncryptionStream: typeof createEncryptionStream;
|
|
4143
|
+
createDecryptionStream: typeof createDecryptionStream;
|
|
4144
|
+
encryptBlob: typeof encryptBlob;
|
|
4145
|
+
decryptBlob: typeof decryptBlob;
|
|
4146
|
+
};
|
|
2991
4147
|
|
|
2992
4148
|
/**
|
|
2993
4149
|
* In-memory storage adapter for public key pinning records.
|
|
@@ -3003,11 +4159,19 @@ declare class CMemoryKeyPinningStore implements IKeyPinningStore {
|
|
|
3003
4159
|
/**
|
|
3004
4160
|
* LocalStorage adapter for public key pinning records in browser environments.
|
|
3005
4161
|
* Uses namespaced keys in the form `katlux:pin:<namespace>:<entityId>`.
|
|
4162
|
+
*
|
|
4163
|
+
* SECURITY WARNING & THREAT MODEL NOTICE:
|
|
4164
|
+
* Storing pinned public keys in raw browser `localStorage` lacks hardware-backed integrity protection.
|
|
4165
|
+
* An XSS payload executing `localStorage.clear()` or deleting individual pinning keys will wipe stored pins
|
|
4166
|
+
* and force a silent fresh Trust-On-First-Use (TOFU) key registration. For high-security environments,
|
|
4167
|
+
* consider using signed server-side attestation, an authenticated IndexedDB store with subkey HMAC,
|
|
4168
|
+
* or an immutable storage back-end.
|
|
3006
4169
|
*/
|
|
3007
4170
|
declare class CLocalStorageKeyPinningStore implements IKeyPinningStore {
|
|
3008
4171
|
private readonly namespace;
|
|
3009
4172
|
private readonly prefix;
|
|
3010
4173
|
constructor(namespace?: string);
|
|
4174
|
+
private getStorage;
|
|
3011
4175
|
private getKey;
|
|
3012
4176
|
get(entityId: string): Promise<IKeyPin | null>;
|
|
3013
4177
|
compareAndSet(entityId: string, expectedFingerprint: string | null, next: IKeyPin): Promise<boolean>;
|
|
@@ -3027,25 +4191,34 @@ declare class CIndexedDBKeyPinningStore implements IKeyPinningStore {
|
|
|
3027
4191
|
delete(entityId: string): Promise<void>;
|
|
3028
4192
|
clear(): Promise<void>;
|
|
3029
4193
|
}
|
|
4194
|
+
declare const CKeyPinningStore: {
|
|
4195
|
+
Memory: typeof CMemoryKeyPinningStore;
|
|
4196
|
+
LocalStorage: typeof CLocalStorageKeyPinningStore;
|
|
4197
|
+
IndexedDB: typeof CIndexedDBKeyPinningStore;
|
|
4198
|
+
};
|
|
3030
4199
|
|
|
3031
4200
|
/**
|
|
3032
|
-
* Server query rewriter utility for encrypted
|
|
4201
|
+
* Server query rewriter utility for encrypted, blind-indexed, trigram-indexed, and shadow-bucketed columns.
|
|
3033
4202
|
*
|
|
3034
|
-
*
|
|
3035
|
-
*
|
|
3036
|
-
*
|
|
4203
|
+
* Operates strictly as an IDataFilter AST transformation function (No ORM / No SQL generation).
|
|
4204
|
+
* Automatically translates high-level filters on encrypted fields into persistence queries against
|
|
4205
|
+
* indexed persistence columns:
|
|
4206
|
+
* 1. Exact Match (`==`, `!=`, `in`, `nin`) -> Blind index tokens across multi-KID keyring (`_bidx`)
|
|
4207
|
+
* 2. Substring Search (`contains`, `like`) -> Trigram token containment (`_trigrams`)
|
|
4208
|
+
* 3. Range Queries (`<`, `<=`, `>`, `>=`, `between`) -> Shadow discrete bucket tokens (`_bucket`)
|
|
4209
|
+
*
|
|
4210
|
+
* Preserves compound boolean trees (and, or, nand, nor) seamlessly.
|
|
3037
4211
|
*
|
|
3038
4212
|
* @param filters - Single IDataFilter or array of filters
|
|
3039
|
-
* @param options - Configuration mapping fields to blind index keyrings and
|
|
4213
|
+
* @param options - Configuration mapping fields to blind index keyrings, trigrams, and range buckets
|
|
3040
4214
|
*/
|
|
3041
|
-
declare function rewriteEncryptedFilters(filters: IDataFilter | IDataFilter[], options: IEncryptedFilterRewriteOptions): Promise<
|
|
4215
|
+
declare function rewriteEncryptedFilters(filters: IDataFilter | IDataFilter[], options: IEncryptedFilterRewriteOptions): Promise<IRewrittenEncryptedFilters>;
|
|
3042
4216
|
|
|
3043
4217
|
/**
|
|
3044
|
-
*
|
|
3045
|
-
*
|
|
3046
|
-
* Implements storage-agnostic, memory-bounded batch re-encryption and
|
|
3047
|
-
* key migration pipelines for persistent datasets across key rotation lifecycles.
|
|
4218
|
+
* Builds standard contextual AAD string matching Katlux AEAD convention.
|
|
4219
|
+
* Prioritizes explicit `recordId`, then `getRowId(row)`, then standard PK fallbacks (`id`, `_id`, `uuid`, `key`).
|
|
3048
4220
|
*/
|
|
4221
|
+
declare function buildAadString(row: any, field: string, baseAad?: string, aadFields?: string[], recordId?: string | number, getRowId?: (row: any) => string | number | undefined): string;
|
|
3049
4222
|
|
|
3050
4223
|
/**
|
|
3051
4224
|
* Re-encrypts an array of row objects in memory, selectively updating fields that
|
|
@@ -3056,6 +4229,20 @@ declare function rewriteEncryptedFilters(filters: IDataFilter | IDataFilter[], o
|
|
|
3056
4229
|
* @returns Batch processing result detailing modified rows, patches, and metrics
|
|
3057
4230
|
*/
|
|
3058
4231
|
declare function reencryptBatch<TRow = any>(rows: TRow[], options: IReencryptBatchOptions<TRow>): Promise<IReencryptBatchResult<TRow>>;
|
|
4232
|
+
|
|
4233
|
+
/**
|
|
4234
|
+
* Determines whether a row's persisted blind-index or trigram tokens for `field` are stale
|
|
4235
|
+
* relative to `tokenVersion`, `versionTag`, `schemeId`, or `staleTokenVersions`.
|
|
4236
|
+
*/
|
|
4237
|
+
declare function isFieldBlindIndexStale<TRow>(row: TRow, field: string, options: IReencryptBatchOptions<TRow>): boolean;
|
|
4238
|
+
|
|
4239
|
+
/**
|
|
4240
|
+
* Katlux Batch Re-Encryption & Key Migration Orchestrator
|
|
4241
|
+
*
|
|
4242
|
+
* Implements storage-agnostic, memory-bounded batch re-encryption and
|
|
4243
|
+
* key migration pipelines for persistent datasets across key rotation lifecycles.
|
|
4244
|
+
*/
|
|
4245
|
+
|
|
3059
4246
|
/**
|
|
3060
4247
|
* Universal storage-agnostic orchestrator for executing memory-bounded batch
|
|
3061
4248
|
* re-encryption across database tables or remote datasets with optimistic concurrency.
|
|
@@ -3065,10 +4252,221 @@ declare function reencryptBatch<TRow = any>(rows: TRow[], options: IReencryptBat
|
|
|
3065
4252
|
*/
|
|
3066
4253
|
declare function reencryptDataset<TRow = any>(options: IReencryptDatasetOptions<TRow>): Promise<IMigrationSummary>;
|
|
3067
4254
|
|
|
4255
|
+
/**
|
|
4256
|
+
* Default minimum numeric bucket width enforced for non-sensitive fields to prevent
|
|
4257
|
+
* micro-bucketing (which approaches 1:1 deterministic equality leakage / exact value recovery).
|
|
4258
|
+
*/
|
|
4259
|
+
declare const DEFAULT_MIN_BUCKET_STEP = 100;
|
|
4260
|
+
/**
|
|
4261
|
+
* High-sensitivity personal and demographic fields where deterministic shadow-bucket
|
|
4262
|
+
* range indexes are prohibited by default (`ERR_RANGE_BUCKET_SENSITIVE_FIELD`) unless
|
|
4263
|
+
* `allowSensitiveBucket: true` is explicitly configured and per-class floors are respected.
|
|
4264
|
+
*/
|
|
4265
|
+
declare const SENSITIVE_RANGE_BUCKET_FIELDS: readonly string[];
|
|
4266
|
+
interface ISensitiveFieldPolicyRule {
|
|
4267
|
+
readonly classification: 'financial' | 'identifier' | 'creditScore' | 'age' | 'sensitiveDate';
|
|
4268
|
+
readonly minStep?: number;
|
|
4269
|
+
readonly allowedGranularities?: readonly TDateBucketGranularity[];
|
|
4270
|
+
}
|
|
4271
|
+
/**
|
|
4272
|
+
* Per-class range bucket security policy (`rangeBucketPolicy`).
|
|
4273
|
+
*
|
|
4274
|
+
* Sensitive fields throw `ERR_RANGE_BUCKET_SENSITIVE_FIELD` by default unless `allowSensitiveBucket: true`
|
|
4275
|
+
* is explicitly set. Even with `allowSensitiveBucket: true`, each class enforces a minimum floor
|
|
4276
|
+
* (cannot be weakened by `minStep`) unless `allowNarrowStep: true` / `allowNarrowGranularity: true` is passed.
|
|
4277
|
+
*/
|
|
4278
|
+
declare const RANGE_BUCKET_POLICY: {
|
|
4279
|
+
readonly defaultMinStep: 100;
|
|
4280
|
+
readonly classes: {
|
|
4281
|
+
readonly financial: {
|
|
4282
|
+
readonly fields: Set<string>;
|
|
4283
|
+
readonly minStep: 10000;
|
|
4284
|
+
};
|
|
4285
|
+
readonly identifier: {
|
|
4286
|
+
readonly fields: Set<string>;
|
|
4287
|
+
readonly minStep: 1000000;
|
|
4288
|
+
};
|
|
4289
|
+
readonly creditScore: {
|
|
4290
|
+
readonly fields: Set<string>;
|
|
4291
|
+
readonly minStep: 100;
|
|
4292
|
+
};
|
|
4293
|
+
readonly age: {
|
|
4294
|
+
readonly fields: Set<string>;
|
|
4295
|
+
readonly minStep: 10;
|
|
4296
|
+
};
|
|
4297
|
+
readonly sensitiveDate: {
|
|
4298
|
+
readonly fields: Set<string>;
|
|
4299
|
+
readonly allowedGranularities: readonly TDateBucketGranularity[];
|
|
4300
|
+
};
|
|
4301
|
+
};
|
|
4302
|
+
};
|
|
4303
|
+
/** Alias for `RANGE_BUCKET_POLICY`. */
|
|
4304
|
+
declare const rangeBucketPolicy: {
|
|
4305
|
+
readonly defaultMinStep: 100;
|
|
4306
|
+
readonly classes: {
|
|
4307
|
+
readonly financial: {
|
|
4308
|
+
readonly fields: Set<string>;
|
|
4309
|
+
readonly minStep: 10000;
|
|
4310
|
+
};
|
|
4311
|
+
readonly identifier: {
|
|
4312
|
+
readonly fields: Set<string>;
|
|
4313
|
+
readonly minStep: 1000000;
|
|
4314
|
+
};
|
|
4315
|
+
readonly creditScore: {
|
|
4316
|
+
readonly fields: Set<string>;
|
|
4317
|
+
readonly minStep: 100;
|
|
4318
|
+
};
|
|
4319
|
+
readonly age: {
|
|
4320
|
+
readonly fields: Set<string>;
|
|
4321
|
+
readonly minStep: 10;
|
|
4322
|
+
};
|
|
4323
|
+
readonly sensitiveDate: {
|
|
4324
|
+
readonly fields: Set<string>;
|
|
4325
|
+
readonly allowedGranularities: readonly TDateBucketGranularity[];
|
|
4326
|
+
};
|
|
4327
|
+
};
|
|
4328
|
+
};
|
|
4329
|
+
/**
|
|
4330
|
+
* Options controlling bucket width validation, sensitive-field opt-in, and narrow-bucket opt-in behavior.
|
|
4331
|
+
*/
|
|
4332
|
+
interface IRangeBucketValidationOptions {
|
|
4333
|
+
minStep?: number;
|
|
4334
|
+
minBucketWidth?: number;
|
|
4335
|
+
allowNarrowStep?: boolean;
|
|
4336
|
+
allowNarrowGranularity?: boolean;
|
|
4337
|
+
/** Explicit opt-in required to use range bucketing on fields in `SENSITIVE_RANGE_BUCKET_FIELDS`. */
|
|
4338
|
+
allowSensitiveBucket?: boolean;
|
|
4339
|
+
}
|
|
4340
|
+
/**
|
|
4341
|
+
* Validates a range bucket configuration against `rangeBucketPolicy` sensitivity and per-class floor rules.
|
|
4342
|
+
*
|
|
4343
|
+
* - Throws `ERR_RANGE_BUCKET_SENSITIVE_FIELD` for fields in `SENSITIVE_RANGE_BUCKET_FIELDS` unless
|
|
4344
|
+
* `allowSensitiveBucket: true` is set on `config` or `options`.
|
|
4345
|
+
* - Throws `ERR_BUCKET_STEP_TOO_NARROW` when a numeric bucket width/gap is below the effective floor
|
|
4346
|
+
* (per-class floor for sensitive fields, or `minStep` / `DEFAULT_MIN_BUCKET_STEP` = 100 otherwise)
|
|
4347
|
+
* unless `allowNarrowStep: true` is explicitly set (and `step > 0`).
|
|
4348
|
+
* - Throws `ERR_BUCKET_STEP_TOO_NARROW` when a sensitive date field uses fine granularity (`'month'`, `'week'`, `'day'`)
|
|
4349
|
+
* unless `allowNarrowGranularity: true` is explicitly set.
|
|
4350
|
+
*/
|
|
4351
|
+
declare function validateRangeBucketConfig(config: TRangeBucketConfig, fieldName?: string, options?: IRangeBucketValidationOptions): void;
|
|
4352
|
+
/**
|
|
4353
|
+
* Safely parses any date string, Unix timestamp (in seconds or ms), or Date instance.
|
|
4354
|
+
*/
|
|
4355
|
+
declare function parseDateValue(val: any): Date | null;
|
|
4356
|
+
/**
|
|
4357
|
+
* Safely parses numbers from numbers or numeric strings (including currency/commas).
|
|
4358
|
+
*/
|
|
4359
|
+
declare function parseNumericValue(val: any): number | null;
|
|
4360
|
+
type TDirectBucketValidationArg = string | (IRangeBucketValidationOptions & {
|
|
4361
|
+
fieldName?: string;
|
|
4362
|
+
});
|
|
4363
|
+
/**
|
|
4364
|
+
* Computes a deterministic string shadow bucket key for a date or timestamp.
|
|
4365
|
+
* Supported granularities: 'year', 'quarter', 'month', 'week', 'day'.
|
|
4366
|
+
* Validates sensitive-field and granularity rules when `fieldName` or `options` are provided.
|
|
4367
|
+
*/
|
|
4368
|
+
declare function computeDateBucket(val: any, granularity?: TDateBucketGranularity, optionsOrFieldName?: TDirectBucketValidationArg, maybeOptions?: IRangeBucketValidationOptions): string | undefined;
|
|
4369
|
+
/**
|
|
4370
|
+
* Resolves the bounding interval [min, max] (in UTC milliseconds) for a given date bucket key.
|
|
4371
|
+
*/
|
|
4372
|
+
declare function getDateBucketRange(bucketKey: string, granularity?: TDateBucketGranularity): {
|
|
4373
|
+
min: number;
|
|
4374
|
+
max: number;
|
|
4375
|
+
} | null;
|
|
4376
|
+
/**
|
|
4377
|
+
* Computes a stepped numeric shadow bucket key (e.g. 10000 step -> '0-9999', '10000-19999').
|
|
4378
|
+
* Enforces `rangeBucketPolicy` sensitive-field checks and per-class minimum floors
|
|
4379
|
+
* (`DEFAULT_MIN_BUCKET_STEP` = 100 for non-sensitive fields) unless overridden via options.
|
|
4380
|
+
*/
|
|
4381
|
+
declare function computeSteppedBucket(val: any, step: number, min?: number, optionsOrFieldName?: TDirectBucketValidationArg, maybeOptions?: IRangeBucketValidationOptions): string | undefined;
|
|
4382
|
+
/**
|
|
4383
|
+
* Resolves the numeric interval [min, max] for a stepped bucket key.
|
|
4384
|
+
*/
|
|
4385
|
+
declare function getSteppedBucketRange(bucketKey: string, step?: number): {
|
|
4386
|
+
min: number;
|
|
4387
|
+
max: number;
|
|
4388
|
+
} | null;
|
|
4389
|
+
/**
|
|
4390
|
+
* Computes a threshold / tier shadow bucket key (e.g. [0, 25000, 50000] -> '<0', '0-24999', '25000-49999', '>=50000').
|
|
4391
|
+
* Enforces `rangeBucketPolicy` sensitive-field checks and per-class minimum threshold gap floors.
|
|
4392
|
+
*/
|
|
4393
|
+
declare function computeTierBucket(val: any, rawThresholds: number[], optionsOrFieldName?: TDirectBucketValidationArg, maybeOptions?: IRangeBucketValidationOptions): string | undefined;
|
|
4394
|
+
/**
|
|
4395
|
+
* Resolves the numeric interval [min, max] for a tier bucket key.
|
|
4396
|
+
*/
|
|
4397
|
+
declare function getTierBucketRange(bucketKey: string, rawThresholds: number[]): {
|
|
4398
|
+
min: number;
|
|
4399
|
+
max: number;
|
|
4400
|
+
} | null;
|
|
4401
|
+
/**
|
|
4402
|
+
* Computes a shadow range bucket key without re-running config validation (for internal loops
|
|
4403
|
+
* where config has already been validated at setup time).
|
|
4404
|
+
*/
|
|
4405
|
+
declare function computeRangeBucketUnchecked(val: any, config: TRangeBucketConfig): string | undefined;
|
|
4406
|
+
/**
|
|
4407
|
+
* Computes a shadow range bucket key for any value according to its configuration.
|
|
4408
|
+
* Validates the configuration via `validateRangeBucketConfig`.
|
|
4409
|
+
*/
|
|
4410
|
+
declare function computeRangeBucket(val: any, config: TRangeBucketConfig, fieldName?: string, options?: IRangeBucketValidationOptions): string | undefined;
|
|
4411
|
+
/**
|
|
4412
|
+
* Resolves the bounding interval [min, max] for any bucket key and configuration.
|
|
4413
|
+
*/
|
|
4414
|
+
declare function getRangeBucketRange(bucketKey: string, config: TRangeBucketConfig): {
|
|
4415
|
+
min: number;
|
|
4416
|
+
max: number;
|
|
4417
|
+
} | null;
|
|
4418
|
+
/**
|
|
4419
|
+
* Comparator for stepped numeric shadow bucket keys (e.g. `'25000-49999'` vs `'100000-124999'`).
|
|
4420
|
+
* Orders buckets mathematically by their lower bound (and upper bound as tie-breaker) rather than ASCII order.
|
|
4421
|
+
*/
|
|
4422
|
+
declare function compareSteppedBuckets(a: string, b: string): number;
|
|
4423
|
+
/**
|
|
4424
|
+
* Compares two shadow bucket values (or resolved sort values) numerically/chronologically
|
|
4425
|
+
* using the configured TRangeBucketConfig (supports stepped, tier, and date buckets).
|
|
4426
|
+
*/
|
|
4427
|
+
declare function compareRangeBuckets(a: any, b: any, config?: TRangeBucketConfig): number;
|
|
4428
|
+
/**
|
|
4429
|
+
* Checks whether an interval [min, max] satisfies the given query comparison operator and target value.
|
|
4430
|
+
*/
|
|
4431
|
+
declare function isIntervalMatchingOperator(interval: {
|
|
4432
|
+
min: number;
|
|
4433
|
+
max: number;
|
|
4434
|
+
}, operator: string, targetVal: any, isDate: boolean): boolean;
|
|
4435
|
+
/**
|
|
4436
|
+
* Checks whether an interval [min, max] fully satisfies the given query comparison operator and target value
|
|
4437
|
+
* across all points in the interval (i.e. every point in [min, max] satisfies the condition).
|
|
4438
|
+
*/
|
|
4439
|
+
declare function isIntervalFullyMatchingOperator(interval: {
|
|
4440
|
+
min: number;
|
|
4441
|
+
max: number;
|
|
4442
|
+
}, operator: string, targetVal: any, isDate: boolean): boolean;
|
|
4443
|
+
/**
|
|
4444
|
+
* Resolves the complete set of eligible shadow bucket keys that satisfy a given range comparison query.
|
|
4445
|
+
*
|
|
4446
|
+
* Sound-or-throw contract:
|
|
4447
|
+
* - Never silently truncates open-ended stepped or date queries.
|
|
4448
|
+
* - When `knownBuckets` is omitted for open-ended queries (`>`, `>=`, `<`, `<=`, `!=`, `nin`),
|
|
4449
|
+
* requires explicit domain bounds (`min`/`floor` and/or `max`/`ceiling` for stepped; `minDate`/`maxDate` for date)
|
|
4450
|
+
* and throws `ERR_BUCKET_RANGE_UNBOUNDED` if the required bound is absent.
|
|
4451
|
+
*
|
|
4452
|
+
* @param operator - Range operator: '>', '>=', '<', '<=', 'between', '==', '!=', 'in', 'nin'
|
|
4453
|
+
* @param targetValue - Plaintext target comparison value (number, date string, timestamp, or tuple for between)
|
|
4454
|
+
* @param config - Range bucketing configuration ('date', 'stepped', or 'tier')
|
|
4455
|
+
* @param knownBuckets - Optional iterable of all unique bucket keys present in the indexed dataset
|
|
4456
|
+
*/
|
|
4457
|
+
declare function resolveBucketsForRangeUnchecked(operator: string, targetValue: any, config: TRangeBucketConfig, knownBuckets?: Iterable<string>): Set<string>;
|
|
4458
|
+
/**
|
|
4459
|
+
* Resolves all candidate shadow bucket keys for a filter operator and target value.
|
|
4460
|
+
* Validates the range bucket configuration via `validateRangeBucketConfig` (enforcing
|
|
4461
|
+
* `ERR_RANGE_BUCKET_SENSITIVE_FIELD` and `ERR_BUCKET_STEP_TOO_NARROW`) and enforces the
|
|
4462
|
+
* sound-or-throw range contract (`ERR_BUCKET_RANGE_UNBOUNDED`).
|
|
4463
|
+
*/
|
|
4464
|
+
declare function resolveBucketsForRange(operator: string, targetValue: any, config: TRangeBucketConfig, knownBuckets?: Iterable<string>, fieldName?: string, options?: IRangeBucketValidationOptions): Set<string>;
|
|
4465
|
+
|
|
3068
4466
|
/**
|
|
3069
4467
|
* Universal helper that verifies whether an arbitrary object is a Katlux encrypted payload envelope.
|
|
3070
4468
|
*/
|
|
3071
4469
|
declare function isEncrypted(payload: any): boolean;
|
|
3072
4470
|
|
|
3073
|
-
export { AAPIDataProvider, ADataProvider, AEncryptedClientProvider, AEncryptionProvider, CAPIFlatClientDataProvider, CAPIFlatServerDataProvider, CAPITreeClientDataProvider, CAPITreeServerDataProvider, CApplicationCache, CBrowserSessionCache, CCookieCache, CECDHEncryptionProvider, CFlatClientDataProvider, CFlatServerDataProvider, CIndexedDBCache, CIndexedDBKeyPinningStore, CKeyManager, CLocalStorageCache, CLocalStorageKeyPinningStore, CMemoryCache, CMemoryKeyPinningStore, CNodeCryptoEncryptionProvider, CRSAEncryptionProvider, CSearchIndex, CServerSessionCache, CTreeClientDataProvider, CTreeServerDataProvider, CWebCryptoAESCBCProvider, CWebCryptoEncryptionProvider, CacheProviderFactory, DECRYPT_ERROR_SENTINEL, DefaultHydrationAdapter, ECacheStrategy, EDataFilterOperator, EQueueStorage, KatluxIndexedDB, QueueStorageFactory, RequestProvider, RequestProviderRegistry, RequestQueue, SENSITIVE_HEADER_KEYS, applyOperator, buildEncryptionContext, canonicalizeJson, clearCachedCipherProvider, clearSSRData, compareAnd, compareEqual, compareIn, compareOr, compareValues, createDecryptionStream, createEncryptionProvider, createEncryptionStream, debounce, decryptBlob, decryptPageRows, encryptBlob, encryptRows, encryptRowsChunked, evaluateFilter, extractTrigrams, fastKeyHash, fetchWithSSR, filterData, filterTreeData, getAppRoute, getAppRouter, getCipherProvider, getHydrationAdapter, getKeyIdentifier, getPlatformApp, getRandomValues, getSSRData, getSSRPayload, getSafeKeyIdentifier, getSubtleCrypto, isAuthOrDecryptionError, isDataEncrypted, isEncrypted, normalizeIndexTerm, onPlatformReady, reencryptBatch, reencryptDataset, resolveInfoBytes, rewriteEncryptedFilters, safeSetProperty, setHydrationAdapter, sortData, textDecoder, textEncoder, toBase64, useDebounce, useFilterLogic, useSortLogic };
|
|
3074
|
-
export type { CacheDriverLoader,
|
|
4471
|
+
export { AAPIDataProvider, ADataProvider, AEncryptedClientProvider, AEncryptionProvider, BLIND_INDEX_FRAMING_VERSION, CAPIFlatClientDataProvider, CAPIFlatServerDataProvider, CAPITreeClientDataProvider, CAPITreeServerDataProvider, CApplicationCache, CBrowserSessionCache, CCookieCache, CECDHEncryptionProvider, CFlatClientDataProvider, CFlatServerDataProvider, CIndexedDBCache, CIndexedDBKeyPinningStore, CKeyManager, CKeyPinningStore, CLocalStorageCache, CLocalStorageKeyPinningStore, CMemoryCache, CMemoryKeyPinningStore, CNodeCryptoEncryptionProvider, CRSAEncryptionProvider, CSearchIndex, CServerSessionCache, CTreeClientDataProvider, CTreeServerDataProvider, CWebCryptoAESCBCProvider, CWebCryptoEncryptionProvider, CWebCryptoStreamCipher, CacheProviderFactory, DECRYPT_ERROR_SENTINEL, DEFAULT_KEY_CACHE_MAX_SIZE, DEFAULT_MAX_ALLOWED_ITERATIONS, DEFAULT_MAX_SALT_DERIVATIONS, DEFAULT_MIN_BUCKET_STEP, DEFAULT_PBKDF2_ITERATIONS, DefaultHydrationAdapter, ECacheStrategy, EDataFilterOperator, ENCRYPTION_CONTEXT_KEYS, EQueueStorage, ERR_AUTH_UNAUTHORIZED, ERR_CRYPTO_AUTH_FAILED, ERR_CRYPTO_DECRYPT_FAILED, ERR_CRYPTO_TAG_MISMATCH, KatluxIndexedDB, PROVIDER_CONSTRUCTOR_OPTION_KEYS, QueueStorageFactory, RANGE_BUCKET_POLICY, RequestProvider, RequestProviderRegistry, RequestQueue, SEARCH_FILTER_NOT_OPERATOR, SENSITIVE_HEADER_KEYS, SENSITIVE_RANGE_BUCKET_FIELDS, _bidxHmacKeyCache, aadToBytes, acquireSaltDerivationSlot, applyOperator, areKeysIdentical, assertMaxAllowedIterations, attachSaltDerivationBudget, buildAadString, buildCanonicalFieldAad, buildEncryptionContext, canonicalizeJson, claimSaltDerivationSlotSync, clearBlindIndexKeyCache, clearCachedCipherProvider, clearSSRData, combineCiphertextAndTag, compareAnd, compareContains, compareEqual, compareIn, compareOr, compareRangeBuckets, compareSteppedBuckets, compareValues, computeBlindIndex, computeBlindIndexSchemeId, computeDateBucket, computeMultiBlindIndex, computeRangeBucket, computeRangeBucketUnchecked, computeSteppedBucket, computeTierBucket, computeWriteBlindIndex, createDecryptionStream, createEncryptionProvider, createEncryptionStream, debounce, decryptBlob, decryptPageRows, decryptPayload, deriveAuthAndEncryptionKeys, deriveBlindIndexHmacKey, deriveKey, deriveKeyFromSecret, encryptBlob, encryptPayload, encryptRows, encryptRowsChunked, escapeAadComponent, evaluateFilter, exportAESKey, exportPrivateKey, exportPrivateKeyToPEM, exportPublicKey, exportPublicKeyToPEM, extractDefaultRowId, extractFilterFieldNames, extractTrigrams, fastKeyHash, fetchWithSSR, filterData, filterTreeData, foldAscii, fromBase64, generateAESKey, generateAccountDataKey, generateECDHKeyPair, generateECDSAKeyPair, generateRSAKeyPair, generateSigningKeyPair, getAppRoute, getAppRouter, getCipherProvider, getDateBucketRange, getGlobalDataProviderConfig, getHydrationAdapter, getKeyFingerprint, getKeyIdentifier, getLruCacheEntry, getPlatformApp, getRandomValues, getRangeBucketRange, getSSRData, getSSRPayload, getSafeKeyIdentifier, getSaltDerivationBudget, getSteppedBucketRange, getSubtleCrypto, getTierBucketRange, importAESKey, importECDSAPrivateKeyFromPEM, importECDSAPublicKeyFromPEM, importPrivateKey, importPrivateKeyFromPEM, importPublicKey, importPublicKeyFromPEM, invertFilterOperator, isAuthOrDecryptionError, isDataEncrypted, isEncrypted, isEncryptedPayload, isFieldBlindIndexStale, isIntervalFullyMatchingOperator, isIntervalMatchingOperator, negateFilterNode, normalizeDecryptError, normalizeFilter, normalizeFilterValue, normalizeIndexTerm, normalizeUrl, onPlatformReady, parseDateValue, parseDecryptedJsonSafely, parseNumericValue, pickEncryptionContext, pickProviderOptions, randomBytes, rangeBucketPolicy, reencryptBatch, reencryptDataset, rekeyEncryptedPayload, rekeyUserKeypair, resolveAndClampPbkdf2Iterations, resolveAuthorityCryptoKey, resolveBucketsForRange, resolveBucketsForRangeUnchecked, resolveCachedSaltDerivation, resolveInfoBytes, resolveSalt, rewrapAccountKeyForUser, rewriteEncryptedFilters, runWithSaltDerivationSlot, safeSetProperty, serializeAadFieldValue, serializePlaintextToBytes, setGlobalDataProviderConfig, setHydrationAdapter, setLruCacheEntry, sign, signGrant, signKeyResetAttestation, sortData, textDecoder, textEncoder, toBase64, unwrapAccountKeyForUser, unwrapHMACKeyForUser, unwrapKey, useDebounce, useFilterLogic, useSortLogic, validateBlindIndexKeyring, validateRangeBucketConfig, verify, verifyAndPinKey, verifyAttestation, verifyGrant, wrapAccountKeyForUser, wrapHMACKeyForUser, wrapKey };
|
|
4472
|
+
export type { CacheDriverLoader, IAccessGrant, IAsymmetricSecurityDefaults, IBaseEncryptionProviderOptions, IBatchLoadedEvent, IBatchProgress, IBlindIndexFieldConfig, IBlindIndexKeyring, IBlindIndexOptions, IBlindIndexSchemeOptions, IBlindIndexVersionConfig, ICNodeCryptoOptions, ICWebCryptoAESCBCOptions, ICWebCryptoOptions, ICacheEntry, ICacheQuotaOptions, ICookieCacheOptions, IDataFilter, IDataProviderGlobalConfig, IDataProviderOptions, IDataProviderSetStateOptions, IDataProviderState, IDataResult, IDataSort, IDateRangeBucketConfig, IDeadLetterItem, IDebouncedFunction, IDecryptBatchSession, IDecryptErrorInfo, IDeriveAuthAndEncryptionOptions, IDomainDerivedKeys, IEncryptRecordSession, IEncryptedFilterRewriteOptions, IEncryptedPayload, IEncryptionContext, IEncryptionOperationOptions, IEncryptionProvider, IFieldEncryptionContext, IFlushOptions, IHKDFFromSecretOptions, IKDFOptions, IKDatatableAction, IKeyPair, IKeyPin, IKeyPinChangeEvent, IKeyPinningStore, IKeyResetAttestation, IMigrationProgress, IMigrationSummary, INormalizeOptions, IPlatformRouter, IProviderEncryptionOptions, IQueueStorageAdapter, IQueuedOperation, IQueuedRequest, IRangeBucketFieldConfig, IRangeBucketValidationOptions, IReencryptBatchOptions, IReencryptBatchResult, IReencryptDatasetOptions, IRekeyKeypairParams, IRekeyPayloadOptions, IRekeyedKeypairResult, IRequestOptions, IRewrittenEncryptedFilters, IRewrittenPersistenceQuery, ISSRHydrationAdapter, ISaltDerivationBudget, ISearchFilterCompoundNode, ISearchFilterNotNode, ISearchIndexEvalContext, ISearchIndexOptions, ISearchIndexRowEntry, ISensitiveFieldPolicyRule, ISetDataChunkedOptions, ISignedGrant, ISignedKeyResetAttestation, ISortDataOptions, ISteppedRangeBucketConfig, IStreamDecryptionOptions, IStreamEncryptionOptions, IStreamWithBufferMetric, ITierRangeBucketConfig, ITreeDataProvider, ITreeDataProviderOptions, ITreeNode, ITreeNodeStatic, ITrigramFieldConfig, IVerifyAndPinOptions, IVerifyAndPinResult, IVerifyGrantOptions, IVirtualScrollState, IWrappedKey, InFlightBridge, InFlightSubscriber, TBlindIndexKeyStatus, TDataProviderListener, TDataProviderStateChangeListener, TDataRow, TDateBucketGranularity, TECDHAlgorithm, TECDHCurve, TEncryptionAlgorithm, TKatluxStore, TKdfHash, TKdfStrategy, TKeyProvider, TPageDataHandler, TQueueItemStatus, TRSAAlgorithm, TRangeBucketConfig, TRawKey, TSearchFilterNode, TServerRequestEvent, TStreamAlgorithm, TSupportedAlgorithm, TSymmetricAlgorithm, TTreePageDataHandler, TTreeRow, TTrustedAuthorities, TUnsubscribe, TreePaginationMode };
|