@katlux/providers 0.1.1-alpha.127 → 0.1.1-alpha.128
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1509 -1224
- package/dist/index.d.cts +106 -3
- package/dist/index.d.mts +106 -3
- package/dist/index.d.ts +106 -3
- package/dist/index.mjs +1509 -1224
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -81,9 +81,28 @@ interface IEncryptionContext {
|
|
|
81
81
|
kdfHash?: 'SHA-256' | 'SHA-512';
|
|
82
82
|
info?: string | Uint8Array | ArrayBuffer;
|
|
83
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Context options for single scalar field encryption/decryption with bound AAD.
|
|
86
|
+
*/
|
|
87
|
+
interface IFieldEncryptionContext extends Omit<IEncryptionContext, 'aadFields'> {
|
|
88
|
+
/** Record identifier to bind into AAD */
|
|
89
|
+
recordId?: string | number;
|
|
90
|
+
/** Target field name being encrypted/decrypted */
|
|
91
|
+
fieldName?: string;
|
|
92
|
+
/** Sibling record fields (map or array of keys) to deterministically bind into AEAD */
|
|
93
|
+
aadFields?: Record<string, any> | string[];
|
|
94
|
+
/** Optional base AAD prefix */
|
|
95
|
+
baseAad?: string;
|
|
96
|
+
}
|
|
84
97
|
interface IEncryptionProvider {
|
|
85
98
|
encrypt(data: any, options?: IEncryptionContext): Promise<IEncryptedPayload | any>;
|
|
86
99
|
decrypt(payload: IEncryptedPayload | any, options?: IEncryptionContext): Promise<any>;
|
|
100
|
+
/** Encrypts a single scalar value with contextual AAD binding */
|
|
101
|
+
encryptField?(value: any, context?: IFieldEncryptionContext): Promise<IEncryptedPayload>;
|
|
102
|
+
/** Decrypts a single scalar field envelope with contextual AAD */
|
|
103
|
+
decryptField?(envelope: IEncryptedPayload, context?: IFieldEncryptionContext): Promise<any>;
|
|
104
|
+
/** Computes deterministic HMAC-SHA256 blind index hash */
|
|
105
|
+
computeBlindIndex?(value: any, hmacKey?: CryptoKey | TKeyProvider): Promise<string>;
|
|
87
106
|
warmupKey?(options?: IEncryptionContext): Promise<void>;
|
|
88
107
|
isEncrypted?(payload: any): boolean;
|
|
89
108
|
setDefaultKey?(key: TKeyProvider | IKeyPair): void;
|
|
@@ -153,6 +172,11 @@ interface IProviderEncryptionOptions {
|
|
|
153
172
|
onDecryptError?: ((info: IDecryptErrorInfo) => any) | boolean | string;
|
|
154
173
|
/** Enable HMAC-SHA256 blind indexing and trigram search index on encrypted fields for local DataProviders */
|
|
155
174
|
searchIndex?: boolean;
|
|
175
|
+
/**
|
|
176
|
+
* Set to true if API endpoints or data sources return pre-encrypted ciphertext envelopes.
|
|
177
|
+
* When true, DataProviders decrypt search fields during ingest to populate CSearchIndex.
|
|
178
|
+
*/
|
|
179
|
+
preEncrypted?: boolean;
|
|
156
180
|
/** Optional dedicated HMAC key for search indexing (defaults to encryption key if omitted) */
|
|
157
181
|
hmacKey?: TKeyProvider;
|
|
158
182
|
/** Cryptographic algorithm identifier (defaults to 'AES-GCM') */
|
|
@@ -684,6 +708,11 @@ declare class CSearchIndex {
|
|
|
684
708
|
* Computes a deterministic HMAC-SHA256 token for a term.
|
|
685
709
|
*/
|
|
686
710
|
computeToken(term: any): Promise<string>;
|
|
711
|
+
/**
|
|
712
|
+
* Computes a deterministic HMAC-SHA256 blind index hash for a term using the configured HMAC key.
|
|
713
|
+
* Performs Unicode NFKC normalization, trimming, and lowercasing.
|
|
714
|
+
*/
|
|
715
|
+
computeBlindIndex(term: any): Promise<string>;
|
|
687
716
|
/**
|
|
688
717
|
* Computes HMAC-SHA256 tokens for all trigrams of a term.
|
|
689
718
|
*/
|
|
@@ -692,6 +721,11 @@ declare class CSearchIndex {
|
|
|
692
721
|
* Indexes a single row before its fields are encrypted.
|
|
693
722
|
*/
|
|
694
723
|
indexRow(row: any, plaintextFields?: Record<string, any>): Promise<void>;
|
|
724
|
+
/**
|
|
725
|
+
* Indexes a row using pre-decrypted plaintext field values.
|
|
726
|
+
* Allows indexing rows that contain pre-encrypted ciphertext envelopes in allData.
|
|
727
|
+
*/
|
|
728
|
+
indexRowDecrypted(row: any, decryptedPlaintext: Record<string, any>): Promise<void>;
|
|
695
729
|
/**
|
|
696
730
|
* Indexes an array of rows.
|
|
697
731
|
*/
|
|
@@ -723,6 +757,11 @@ declare abstract class AEncryptedClientProvider<TRow = TDataRow> extends ADataPr
|
|
|
723
757
|
clearEncryption(): void;
|
|
724
758
|
protected encryptRows(rows: TRow[]): Promise<TRow[]>;
|
|
725
759
|
protected encryptRowsChunked(rows: TRow[], options?: ISetDataChunkedOptions): Promise<TRow[]>;
|
|
760
|
+
/**
|
|
761
|
+
* Indexes pre-encrypted rows by performing a transient in-memory decryption pass
|
|
762
|
+
* on search fields to populate CSearchIndex without mutating underlying encrypted records in allData.
|
|
763
|
+
*/
|
|
764
|
+
indexPreEncryptedRows(rows: TRow[]): Promise<void>;
|
|
726
765
|
decryptRows(rows: TRow[]): Promise<{
|
|
727
766
|
rows: TRow[];
|
|
728
767
|
decrypted: boolean;
|
|
@@ -1660,6 +1699,7 @@ declare function onPlatformReady(cb: () => void): void;
|
|
|
1660
1699
|
*/
|
|
1661
1700
|
declare abstract class AEncryptionProvider implements IEncryptionProvider {
|
|
1662
1701
|
protected defaultKey?: TKeyProvider | IKeyPair;
|
|
1702
|
+
protected _hmacKey?: TKeyProvider;
|
|
1663
1703
|
protected keys?: Record<string, TKeyProvider | IKeyPair>;
|
|
1664
1704
|
protected activeKid?: string;
|
|
1665
1705
|
protected allowedKids?: string[];
|
|
@@ -1667,6 +1707,7 @@ declare abstract class AEncryptionProvider implements IEncryptionProvider {
|
|
|
1667
1707
|
keys?: Record<string, TKeyProvider | IKeyPair>;
|
|
1668
1708
|
activeKid?: string;
|
|
1669
1709
|
allowedKids?: string[];
|
|
1710
|
+
hmacKey?: TKeyProvider;
|
|
1670
1711
|
[key: string]: any;
|
|
1671
1712
|
});
|
|
1672
1713
|
/**
|
|
@@ -1693,6 +1734,19 @@ declare abstract class AEncryptionProvider implements IEncryptionProvider {
|
|
|
1693
1734
|
* Retrieves the active Key Identifier (kid).
|
|
1694
1735
|
*/
|
|
1695
1736
|
getActiveKid(): string | undefined;
|
|
1737
|
+
/**
|
|
1738
|
+
* Sets or updates the dedicated HMAC key or key provider callback for blind indexing.
|
|
1739
|
+
*/
|
|
1740
|
+
setHmacKey(key: TKeyProvider): void;
|
|
1741
|
+
/**
|
|
1742
|
+
* Retrieves the currently configured HMAC key or key provider callback.
|
|
1743
|
+
*/
|
|
1744
|
+
getHmacKey(): TKeyProvider | undefined;
|
|
1745
|
+
/**
|
|
1746
|
+
* Computes a deterministic HMAC-SHA256 blind index hash for an arbitrary term.
|
|
1747
|
+
* If no hmacKey is explicitly provided, uses the provider's configured hmacKey or default key.
|
|
1748
|
+
*/
|
|
1749
|
+
computeBlindIndex(value: any, hmacKey?: CryptoKey | TKeyProvider): Promise<string>;
|
|
1696
1750
|
/**
|
|
1697
1751
|
* Pre-derives and caches the native CryptoKey for subsequent cryptographic operations.
|
|
1698
1752
|
* Subclasses should override this with a dedicated, non-side-effecting implementation.
|
|
@@ -1770,6 +1824,22 @@ declare abstract class AEncryptionProvider implements IEncryptionProvider {
|
|
|
1770
1824
|
* Implemented by concrete cryptographic providers.
|
|
1771
1825
|
*/
|
|
1772
1826
|
abstract decryptValue(payload: IEncryptedPayload, options?: IEncryptionContext): Promise<any>;
|
|
1827
|
+
/**
|
|
1828
|
+
* Encrypts a single scalar value with contextual AAD binding into an IEncryptedPayload envelope.
|
|
1829
|
+
* Binds recordId, fieldName, and sibling aadFields deterministically to protect against ciphertext swapping.
|
|
1830
|
+
*
|
|
1831
|
+
* @param value - Scalar value (string, number, boolean, object) to encrypt.
|
|
1832
|
+
* @param context - Field encryption context with recordId, fieldName, and optional sibling aadFields.
|
|
1833
|
+
*/
|
|
1834
|
+
encryptField(value: any, context?: IFieldEncryptionContext): Promise<IEncryptedPayload>;
|
|
1835
|
+
/**
|
|
1836
|
+
* Decrypts a single IEncryptedPayload envelope back into its scalar plaintext value using contextual AAD.
|
|
1837
|
+
* Validates recordId, fieldName, and sibling aadFields integrity.
|
|
1838
|
+
*
|
|
1839
|
+
* @param envelope - The IEncryptedPayload envelope to decrypt.
|
|
1840
|
+
* @param context - Field encryption context matching the encryption parameters.
|
|
1841
|
+
*/
|
|
1842
|
+
decryptField(envelope: IEncryptedPayload, context?: IFieldEncryptionContext): Promise<any>;
|
|
1773
1843
|
/**
|
|
1774
1844
|
* Top-level polymorphic encryption method.
|
|
1775
1845
|
* Automatically performs value-level encryption:
|
|
@@ -1861,11 +1931,19 @@ declare class CKeyManager {
|
|
|
1861
1931
|
/**
|
|
1862
1932
|
* Imports a public key from a PEM (SPKI) or base64 SPKI string.
|
|
1863
1933
|
*/
|
|
1864
|
-
static importPublicKeyFromPEM(pem: string, algorithm?: 'RSA-OAEP' | 'ECDH', curve?: 'P-256' | 'P-384' | 'P-521', hash?: 'SHA-256' | 'SHA-512'): Promise<CryptoKey>;
|
|
1934
|
+
static importPublicKeyFromPEM(pem: string, algorithm?: 'RSA-OAEP' | 'ECDH' | 'ECDSA', curve?: 'P-256' | 'P-384' | 'P-521', hash?: 'SHA-256' | 'SHA-512'): Promise<CryptoKey>;
|
|
1935
|
+
/**
|
|
1936
|
+
* Imports an ECDSA public key from PEM (SPKI) or base64 SPKI string for signature verification.
|
|
1937
|
+
*/
|
|
1938
|
+
static importECDSAPublicKeyFromPEM(pem: string, curve?: 'P-256' | 'P-384' | 'P-521'): Promise<CryptoKey>;
|
|
1865
1939
|
/**
|
|
1866
1940
|
* Imports a private key from a PEM (PKCS#8) or base64 PKCS#8 string.
|
|
1867
1941
|
*/
|
|
1868
|
-
static importPrivateKeyFromPEM(pem: string, algorithm?: 'RSA-OAEP' | 'ECDH', curve?: 'P-256' | 'P-384' | 'P-521', hash?: 'SHA-256' | 'SHA-512'): Promise<CryptoKey>;
|
|
1942
|
+
static importPrivateKeyFromPEM(pem: string, algorithm?: 'RSA-OAEP' | 'ECDH' | 'ECDSA', curve?: 'P-256' | 'P-384' | 'P-521', hash?: 'SHA-256' | 'SHA-512'): Promise<CryptoKey>;
|
|
1943
|
+
/**
|
|
1944
|
+
* Imports an ECDSA private key from PEM (PKCS#8) or base64 PKCS#8 string for signing.
|
|
1945
|
+
*/
|
|
1946
|
+
static importECDSAPrivateKeyFromPEM(pem: string, curve?: 'P-256' | 'P-384' | 'P-521'): Promise<CryptoKey>;
|
|
1869
1947
|
/**
|
|
1870
1948
|
* Exports a public CryptoKey to a standard PEM (SPKI) string.
|
|
1871
1949
|
*/
|
|
@@ -1898,6 +1976,16 @@ declare class CKeyManager {
|
|
|
1898
1976
|
* Returns the restored AES-GCM CryptoKey ready for use in CWebCryptoEncryptionProvider.
|
|
1899
1977
|
*/
|
|
1900
1978
|
static unwrapAccountKeyForUser(wrappedKeyBase64: string, userPrivateKey: CryptoKey, unwrappedKeyAlgorithm?: any, extractable?: boolean): Promise<CryptoKey>;
|
|
1979
|
+
/**
|
|
1980
|
+
* Wraps an HMAC blind indexing key for a specific recipient user using their RSA-OAEP public key.
|
|
1981
|
+
* Returns a Base64-encoded wrapped key string suitable for storage in role-map / access tables.
|
|
1982
|
+
*/
|
|
1983
|
+
static wrapHMACKeyForUser(hmacKey: CryptoKey, userPublicKey: CryptoKey): Promise<string>;
|
|
1984
|
+
/**
|
|
1985
|
+
* Unwraps a Base64-encoded HMAC key using a recipient's RSA-OAEP private key.
|
|
1986
|
+
* Restores the CryptoKey configured for HMAC signing and verification in search indexing.
|
|
1987
|
+
*/
|
|
1988
|
+
static unwrapHMACKeyForUser(wrappedKeyBase64: string, userPrivateKey: CryptoKey, hash?: 'SHA-256' | 'SHA-384' | 'SHA-512', extractable?: boolean): Promise<CryptoKey>;
|
|
1901
1989
|
/**
|
|
1902
1990
|
* Atomically re-wraps an Account Data Encryption Key (ADEK) for a new recipient
|
|
1903
1991
|
* without exposing the raw extractable symmetric key to caller application code.
|
|
@@ -1939,6 +2027,10 @@ declare class CKeyManager {
|
|
|
1939
2027
|
* Generates an ECDSA P-256 signing key pair.
|
|
1940
2028
|
*/
|
|
1941
2029
|
static generateSigningKeyPair(curve?: 'P-256' | 'P-384' | 'P-521', extractable?: boolean): Promise<IKeyPair>;
|
|
2030
|
+
/**
|
|
2031
|
+
* Generates an ECDSA signing key pair. Alias for generateSigningKeyPair.
|
|
2032
|
+
*/
|
|
2033
|
+
static generateECDSAKeyPair(curve?: 'P-256' | 'P-384' | 'P-521', extractable?: boolean): Promise<IKeyPair>;
|
|
1942
2034
|
/**
|
|
1943
2035
|
* Generates a deterministic SHA-256 fingerprint for a public key (SPKI or raw).
|
|
1944
2036
|
* Formatted as `SHA256:<base64url>`.
|
|
@@ -1953,6 +2045,15 @@ declare class CKeyManager {
|
|
|
1953
2045
|
* Verifies an ECDSA P-256 signature against original data or JSON object.
|
|
1954
2046
|
*/
|
|
1955
2047
|
static verify(data: any | string | Uint8Array, signature: string, publicKey: CryptoKey): Promise<boolean>;
|
|
2048
|
+
/**
|
|
2049
|
+
* Computes a deterministic HMAC-SHA256 blind index hash for an arbitrary term using the supplied CryptoKey.
|
|
2050
|
+
* Performs Unicode NFKC normalization, trimming, and lowercasing before computing the signature.
|
|
2051
|
+
*
|
|
2052
|
+
* @param value - The input string, number, or object to compute the blind index for.
|
|
2053
|
+
* @param hmacKey - CryptoKey configured for HMAC signing.
|
|
2054
|
+
* @returns Lowercase hexadecimal HMAC-SHA256 blind index hash.
|
|
2055
|
+
*/
|
|
2056
|
+
static computeBlindIndex(value: any, hmacKey: CryptoKey): Promise<string>;
|
|
1956
2057
|
/**
|
|
1957
2058
|
* Signs a structured access grant, embedding signature and granter key fingerprint.
|
|
1958
2059
|
*/
|
|
@@ -1974,6 +2075,7 @@ interface ICWebCryptoOptions {
|
|
|
1974
2075
|
keys?: Record<string, TKeyProvider | IKeyPair>;
|
|
1975
2076
|
activeKid?: string;
|
|
1976
2077
|
allowedKids?: string[];
|
|
2078
|
+
hmacKey?: TKeyProvider;
|
|
1977
2079
|
}
|
|
1978
2080
|
/**
|
|
1979
2081
|
* Zero-dependency AES-256-GCM cipher provider using native Web Crypto API (crypto.subtle).
|
|
@@ -2210,6 +2312,7 @@ interface ICNodeCryptoOptions {
|
|
|
2210
2312
|
keys?: Record<string, TKeyProvider | IKeyPair>;
|
|
2211
2313
|
activeKid?: string;
|
|
2212
2314
|
allowedKids?: string[];
|
|
2315
|
+
hmacKey?: TKeyProvider;
|
|
2213
2316
|
}
|
|
2214
2317
|
/**
|
|
2215
2318
|
* Server-side synchronous AES-GCM-256 encryption provider using Node.js native `node:crypto`.
|
|
@@ -2347,4 +2450,4 @@ declare function canonicalizeJson(value: any, seen?: Set<any>): string;
|
|
|
2347
2450
|
declare function isEncrypted(payload: any): boolean;
|
|
2348
2451
|
|
|
2349
2452
|
export { AAPIDataProvider, ADataProvider, AEncryptedClientProvider, AEncryptionProvider, CAPIFlatClientDataProvider, CAPIFlatServerDataProvider, CAPITreeClientDataProvider, CAPITreeServerDataProvider, CApplicationCache, CBrowserSessionCache, CCookieCache, CECDHEncryptionProvider, CFlatClientDataProvider, CFlatServerDataProvider, CIndexedDBCache, CKeyManager, CLocalStorageCache, CMemoryCache, CNodeCryptoEncryptionProvider, CRSAEncryptionProvider, CSearchIndex, CServerSessionCache, CTreeClientDataProvider, CTreeServerDataProvider, CWebCryptoAESCBCProvider, CWebCryptoEncryptionProvider, CacheProviderFactory, 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, createEncryptionProvider, debounce, decryptPageRows, encryptRows, encryptRowsChunked, evaluateFilter, extractTrigrams, fastKeyHash, fetchWithSSR, filterData, filterTreeData, getAppRoute, getAppRouter, getCipherProvider, getHydrationAdapter, getKeyIdentifier, getPlatformApp, getRandomValues, getSSRData, getSSRPayload, getSafeKeyIdentifier, getSubtleCrypto, isAuthOrDecryptionError, isDataEncrypted, isEncrypted, normalizeIndexTerm, onPlatformReady, resolveInfoBytes, safeSetProperty, setHydrationAdapter, sortData, textDecoder, textEncoder, toBase64, useDebounce, useFilterLogic, useSortLogic };
|
|
2350
|
-
export type { CacheDriverLoader, IAccessGrant, ICNodeCryptoOptions, ICWebCryptoAESCBCOptions, ICWebCryptoOptions, ICacheEntry, ICacheQuotaOptions, ICookieCacheOptions, IDataFilter, IDataProviderOptions, IDataProviderSetStateOptions, IDataProviderState, IDataResult, IDataSort, IDeadLetterItem, IDebouncedFunction, IDecryptErrorInfo, IDeriveAuthAndEncryptionOptions, IDomainDerivedKeys, IEncryptedPayload, IEncryptionContext, IEncryptionProvider, IFlushOptions, IHKDFFromSecretOptions, IKDFOptions, IKDatatableAction, IKeyPair, IPlatformRouter, IProviderEncryptionOptions, IQueueStorageAdapter, IQueuedOperation, IRequestOptions, ISSRHydrationAdapter, ISearchIndexRowEntry, ISetDataChunkedOptions, ISignedGrant, ITreeDataProvider, ITreeDataProviderOptions, ITreeNode, ITreeNodeStatic, IVerifyGrantOptions, IVirtualScrollState, IWrappedKey, KProductItemData, KProductRowAction, TDataProviderListener, TDataProviderStateChangeListener, TDataRow, TECDHCurve, TKatluxStore, TKeyProvider, TPageDataHandler, TQueueItemStatus, TRawKey, TTreePageDataHandler, TTreeRow, TUnsubscribe, TreePaginationMode };
|
|
2453
|
+
export type { CacheDriverLoader, IAccessGrant, ICNodeCryptoOptions, ICWebCryptoAESCBCOptions, ICWebCryptoOptions, ICacheEntry, ICacheQuotaOptions, ICookieCacheOptions, IDataFilter, IDataProviderOptions, IDataProviderSetStateOptions, IDataProviderState, IDataResult, IDataSort, IDeadLetterItem, IDebouncedFunction, IDecryptErrorInfo, IDeriveAuthAndEncryptionOptions, IDomainDerivedKeys, IEncryptedPayload, IEncryptionContext, IEncryptionProvider, IFieldEncryptionContext, IFlushOptions, IHKDFFromSecretOptions, IKDFOptions, IKDatatableAction, IKeyPair, IPlatformRouter, IProviderEncryptionOptions, IQueueStorageAdapter, IQueuedOperation, IRequestOptions, ISSRHydrationAdapter, ISearchIndexRowEntry, ISetDataChunkedOptions, ISignedGrant, ITreeDataProvider, ITreeDataProviderOptions, ITreeNode, ITreeNodeStatic, IVerifyGrantOptions, IVirtualScrollState, IWrappedKey, KProductItemData, KProductRowAction, TDataProviderListener, TDataProviderStateChangeListener, TDataRow, TECDHCurve, TKatluxStore, TKeyProvider, TPageDataHandler, TQueueItemStatus, TRawKey, TTreePageDataHandler, TTreeRow, TUnsubscribe, TreePaginationMode };
|