@katlux/toolkit 0.1.1-alpha.139 → 0.1.1-alpha.141

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.
Files changed (47) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/runtime/components/KAccordion/KAccordion.global.d.vue.ts +1 -1
  3. package/dist/runtime/components/KAccordion/KAccordion.global.vue.d.ts +1 -1
  4. package/dist/runtime/components/KButton/KButton.global.d.vue.ts +1 -1
  5. package/dist/runtime/components/KButton/KButton.global.vue.d.ts +1 -1
  6. package/dist/runtime/components/KButton/KButton.logic.d.ts +1 -1
  7. package/dist/runtime/components/KCheckbox/KCheckbox.global.d.vue.ts +2 -2
  8. package/dist/runtime/components/KCheckbox/KCheckbox.global.vue.d.ts +2 -2
  9. package/dist/runtime/components/KCombobox/KCombobox.global.d.vue.ts +2 -2
  10. package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +2 -2
  11. package/dist/runtime/components/KCompositeInput/KCompositeInput.global.d.vue.ts +6 -6
  12. package/dist/runtime/components/KCompositeInput/KCompositeInput.global.vue.d.ts +6 -6
  13. package/dist/runtime/components/KCompositeInput/KCompositeInput.logic.d.ts +3 -3
  14. package/dist/runtime/components/KDatatable/KDataIterator.global.d.vue.ts +1 -1
  15. package/dist/runtime/components/KDatatable/KDataIterator.global.vue.d.ts +1 -1
  16. package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +3 -3
  17. package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +3 -3
  18. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.d.vue.ts +1 -1
  19. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue.d.ts +1 -1
  20. package/dist/runtime/components/KHourPicker/KHourPicker.global.d.vue.ts +2 -2
  21. package/dist/runtime/components/KHourPicker/KHourPicker.global.vue.d.ts +2 -2
  22. package/dist/runtime/components/KMaskTextbox/KMaskTextbox.global.d.vue.ts +1 -1
  23. package/dist/runtime/components/KMaskTextbox/KMaskTextbox.global.vue.d.ts +1 -1
  24. package/dist/runtime/components/KRadiobox/KRadiobox.global.d.vue.ts +1 -1
  25. package/dist/runtime/components/KRadiobox/KRadiobox.global.vue.d.ts +1 -1
  26. package/dist/runtime/components/KRangeSlider/KRangeSlider.global.d.vue.ts +1 -1
  27. package/dist/runtime/components/KRangeSlider/KRangeSlider.global.vue.d.ts +1 -1
  28. package/dist/runtime/components/KSlider/KSlider.global.d.vue.ts +1 -1
  29. package/dist/runtime/components/KSlider/KSlider.global.vue.d.ts +1 -1
  30. package/dist/runtime/components/KTextarea/KTextarea.global.d.vue.ts +1 -1
  31. package/dist/runtime/components/KTextarea/KTextarea.global.vue.d.ts +1 -1
  32. package/dist/runtime/components/KTextbox/KTextbox.global.d.vue.ts +2 -2
  33. package/dist/runtime/components/KTextbox/KTextbox.global.vue.d.ts +2 -2
  34. package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +2 -2
  35. package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +2 -2
  36. package/dist/skills/katlux-config/SKILL.md +7 -7
  37. package/dist/skills/katlux-providers/SKILL.md +1 -1
  38. package/dist/skills/katlux-providers/providers/CAPIFlatServerDataProvider.md +25 -0
  39. package/dist/skills/katlux-providers/providers/encryption-asymmetric.md +102 -0
  40. package/dist/skills/katlux-providers/providers/encryption-field-level.md +260 -0
  41. package/dist/skills/katlux-providers/providers/encryption-key-management.md +196 -0
  42. package/dist/skills/katlux-providers/providers/encryption-key-pinning.md +115 -0
  43. package/dist/skills/katlux-providers/providers/encryption-streaming.md +84 -0
  44. package/dist/skills/katlux-providers/providers/encryption-symmetric.md +139 -0
  45. package/dist/skills/katlux-providers/providers/encryption-threat-model.md +110 -0
  46. package/dist/skills/katlux-providers/providers/encryption.md +44 -188
  47. package/package.json +2 -2
@@ -0,0 +1,84 @@
1
+ # Katlux Encryption Architecture: Web Streams Chunked AEAD Encryption
2
+
3
+ > Part of the Katlux Cryptographic Architecture (`@katlux/providers`).
4
+ > See [encryption.md](encryption.md) for the master index.
5
+
6
+ ---
7
+
8
+ ## 1. Overview
9
+
10
+ Streaming AEAD cipher for large files, document payloads, media, and archives using native Web Streams (`TransformStream`). Built on the **STREAM** construction (Hoang, Reyhanitabar, Rogaway, Vizár — 2015) using AES-256-GCM, per-stream wrapped DEKs, deterministic 96-bit nonces, and authenticated header binding.
11
+
12
+ > [!NOTE]
13
+ > The wire format is Katlux-specific (`KTLXSTRM\x01`) and is **not** interoperable with Tink, `age`, or libsodium.
14
+
15
+ ---
16
+
17
+ ## 2. Wire Format (Version 1)
18
+
19
+ | Field | Size | Description |
20
+ | :--- | :--- | :--- |
21
+ | **Magic** | 8 bytes | ASCII `KTLXSTRM` (`0x4B 0x54 0x4C 0x58 0x53 0x54 0x52 0x4D`) |
22
+ | **Version** | 1 byte | `0x01` |
23
+ | **Algorithm** | 1 byte | `0x01` (AES-256-GCM) |
24
+ | **Chunk Size** | 4 bytes | Plaintext bytes per block (uint32 BE, default `65536`, range `4096..4194304`) |
25
+ | **Nonce Prefix** | 7 bytes | Cryptographically random bytes generated per stream |
26
+ | **KID Length + KID** | 1 + $n$ bytes | UTF-8 key identifier string ($n \le 255$, `0` if absent) |
27
+ | **Wrapped DEK Length + DEK** | 2 + $m$ bytes | uint16 BE length + binary wrapped 256-bit AES-GCM data encryption key |
28
+
29
+ - **Chunk Nonce Layout (96 bits / 12 bytes)**:
30
+ `noncePrefix (7 bytes) ‖ chunkCounter (uint32 BE, 4 bytes) ‖ finalFlag (1 byte: 0x00 non-final, 0x01 final)`
31
+ - **Header Binding**: The entire serialized header bytes serve as Additional Authenticated Data (`AAD`) for every single chunk, preventing header substitution or cipher downgrade attacks.
32
+ - **Constant Memory Guarantee**: Stream transformers enforce a strict internal buffer ceiling ($\le 2 \times (chunkSize + 16)$ bytes).
33
+
34
+ ---
35
+
36
+ ## 3. Usage Examples
37
+
38
+ ```ts
39
+ import {
40
+ createEncryptionStream,
41
+ createDecryptionStream,
42
+ encryptBlob,
43
+ decryptBlob
44
+ } from '@katlux/providers'
45
+
46
+ // 1. Streaming file encryption
47
+ const fileStream = file.stream()
48
+ const encryptedStream = fileStream.pipeThrough(
49
+ createEncryptionStream({ key: wrappingKey, kid: 'v1', chunkSize: 65536 })
50
+ )
51
+
52
+ // 2. Streaming file decryption
53
+ const decryptedStream = encryptedStream.pipeThrough(
54
+ createDecryptionStream({ key: wrappingKey })
55
+ )
56
+
57
+ // 3. Blob helpers
58
+ const encryptedBlob = await encryptBlob(fileBlob, { key: wrappingKey })
59
+ const decryptedBlob = await decryptBlob(encryptedBlob, { key: wrappingKey }, 'application/pdf')
60
+ ```
61
+
62
+ ---
63
+
64
+ ## 4. Node.js Stream Interoperability
65
+
66
+ ```ts
67
+ import { Readable } from 'node:stream'
68
+ import { createEncryptionStream } from '@katlux/providers'
69
+
70
+ // Convert Node.js Readable to Web ReadableStream
71
+ const webStream = Readable.toWeb(nodeReadable)
72
+ const encryptedWebStream = webStream.pipeThrough(createEncryptionStream({ key }))
73
+
74
+ // Convert back to Node.js Readable
75
+ const nodeEncryptedStream = Readable.fromWeb(encryptedWebStream)
76
+ ```
77
+
78
+ ---
79
+
80
+ ## 5. Threat Model & Security Boundaries
81
+
82
+ - **Header Tamper Resistance**: Modifying any byte in the magic, version, algorithm, chunk size, nonce prefix, kid, or wrapped DEK invalidates the AAD tag and aborts with `ERR_STREAM_AUTH_FAILED`.
83
+ - **Truncation Defense**: Dropping chunks or cutting the stream prematurely fails with `ERR_STREAM_TRUNCATED` on `flush()`.
84
+ - **Reordering & Extension Defense**: Swapping blocks or appending unauthorized chunks alters nonces or final flags, immediately throwing `ERR_STREAM_AUTH_FAILED`.
@@ -0,0 +1,139 @@
1
+ # Katlux Encryption Architecture: Symmetric Cipher Providers
2
+
3
+ > Part of the Katlux Cryptographic Architecture (`@katlux/providers`).
4
+ > See [encryption.md](encryption.md) for the master index.
5
+
6
+ ---
7
+
8
+ ## 1. Overview of Symmetric Providers
9
+
10
+ | Provider | Algorithm | Environment | Primary Use Case |
11
+ | :--- | :--- | :--- | :--- |
12
+ | `CWebCryptoEncryptionProvider` | AES-GCM-256 | Browser & Server (Async) | Modern Web Crypto standard, built-in AEAD integrity, PBKDF2/HKDF support |
13
+ | `CWebCryptoAESCBCProvider` | AES-CBC-256 + HMAC-SHA-256 | Browser & Server (Async) | Legacy compliance, Encrypt-then-MAC authentication |
14
+ | `CNodeCryptoEncryptionProvider` | AES-GCM-256 | Server (Sync/Async) | Zero-microtask synchronous server routes via `node:crypto` |
15
+
16
+ ---
17
+
18
+ ## 2. `CWebCryptoEncryptionProvider` (AES-GCM-256)
19
+
20
+ Standard native Web Crypto implementation using AES-GCM with a 128-bit authentication tag and a 96-bit random IV.
21
+
22
+ ### Basic Usage
23
+ ```ts
24
+ import { CWebCryptoEncryptionProvider } from '@katlux/providers'
25
+
26
+ const cipher = new CWebCryptoEncryptionProvider({
27
+ key: 'my-passphrase-or-raw-32-byte-key',
28
+ kid: 'tenant-v1',
29
+ kdf: 'pbkdf2', // 'pbkdf2' for passwords, 'none' for 256-bit keys
30
+ kdfIterations: 310000
31
+ })
32
+
33
+ // Encrypt arbitrary object, array, or string:
34
+ const envelope = await cipher.encrypt({ ssn: '123-45-6789', salary: 150000 })
35
+
36
+ // Decrypt back to original structure:
37
+ const data = await cipher.decrypt(envelope)
38
+ ```
39
+
40
+ ---
41
+
42
+ ## 3. `CWebCryptoAESCBCProvider` (AES-CBC-256 + HMAC-SHA-256)
43
+
44
+ Combines AES-CBC-256 with HMAC-SHA-256 in a secure **Encrypt-then-MAC** construction for legacy environments.
45
+
46
+ ```ts
47
+ import { CWebCryptoAESCBCProvider } from '@katlux/providers'
48
+
49
+ const cbcCipher = new CWebCryptoAESCBCProvider({
50
+ key: process.env.LEGACY_CIPHER_KEY,
51
+ kid: 'legacy-v1',
52
+ kdf: 'pbkdf2'
53
+ })
54
+
55
+ const envelope = await cbcCipher.encrypt('sensitive-data')
56
+ const decrypted = await cbcCipher.decrypt(envelope)
57
+ ```
58
+
59
+ ---
60
+
61
+ ## 4. `CNodeCryptoEncryptionProvider` (Node.js Sync/Async)
62
+
63
+ Synchronous, zero-microtask AES-GCM encryption using native `node:crypto`. 100% binary-interoperable with `CWebCryptoEncryptionProvider`.
64
+
65
+ ### Synchronous Server Route Example
66
+ ```ts
67
+ import { CNodeCryptoEncryptionProvider } from '@katlux/providers'
68
+
69
+ const nodeCipher = new CNodeCryptoEncryptionProvider({
70
+ key: process.env.SERVER_ENCRYPTION_KEY,
71
+ kid: 'server-v1',
72
+ strict: true
73
+ })
74
+
75
+ export default defineEventHandler(async (event) => {
76
+ const body = await readBody(event)
77
+ // Zero microtask delay:
78
+ const encrypted = nodeCipher.encryptSync(body, { recordId: 'REC-123', field: 'taxId' })
79
+ return encrypted
80
+ })
81
+ ```
82
+
83
+ - **Strict Tag Enforcement**: Strictly enforces a 16-byte (128-bit) GCM tag on all decryption operations, rejecting truncated tags (e.g. 12, 8, or 4 bytes).
84
+
85
+ ---
86
+
87
+ ## 5. Built-in Keyring & Multi-Key Rotation
88
+
89
+ Katlux cipher providers natively support multi-key keyrings for zero-downtime rotation.
90
+
91
+ ```ts
92
+ const cipher = new CWebCryptoEncryptionProvider({
93
+ keys: {
94
+ 'k2025': oldKey,
95
+ 'k2026': newKey
96
+ },
97
+ activeKid: 'k2026' // All outbound encryption uses k2026
98
+ })
99
+
100
+ // Outbound encryption automatically tags kid: 'k2026':
101
+ const newEnvelope = await cipher.encrypt(data)
102
+
103
+ // Decryption dynamically routes through keys[envelope.kid]:
104
+ const oldDecrypted = await cipher.decrypt(legacyEnvelope) // Decrypts with k2025
105
+ const newDecrypted = await cipher.decrypt(newEnvelope) // Decrypts with k2026
106
+
107
+ // Dynamic runtime rotation:
108
+ cipher.setKeyring({ 'k2026': newKey, 'k2027': nextKey }, 'k2027')
109
+
110
+ // Concurrent warmup:
111
+ await cipher.warmupKey()
112
+ ```
113
+
114
+ - **Whitelist Enforcement**: Envelopes carrying an unknown `kid` not present in `allowedKids` (defaults to `Object.keys(keys)`) are rejected with `Unauthorized key: kid '${payload.kid}' is not in allowedKids`.
115
+
116
+ ---
117
+
118
+ ## 6. Strict Decryption & Whitelisting
119
+
120
+ When `strict: true` is enabled:
121
+ - **Plaintext Injection Prevention**: If any designated sensitive field is unencrypted plaintext, decryption immediately throws a security violation error.
122
+ - **Algorithm Whitelisting**: Restricts accepted decryption algorithms to `allowedAlgorithms` (defaults to `['AES-GCM']`).
123
+
124
+ ---
125
+
126
+ ## 7. Dynamic Authenticated Additional Data (AAD)
127
+
128
+ ```ts
129
+ const cipher = new CWebCryptoEncryptionProvider({
130
+ key: myKey,
131
+ baseAad: 'tenant:corp',
132
+ aadFields: ['org_id', 'department_id'] // Binds sibling record fields into AAD
133
+ })
134
+
135
+ // Automatically binds: aad:tenant:corp|record:REC-42|field:salary|org_id:101|department_id:finance
136
+ const envelope = await cipher.encrypt(record, { recordId: 'REC-42' })
137
+ ```
138
+
139
+ Transposition (moving the ciphertext to a different record or column) causes GCM tag verification to fail immediately.
@@ -0,0 +1,110 @@
1
+ # Katlux Encryption Architecture: Threat Model, Boundaries & Contracts
2
+
3
+ > Part of the Katlux Cryptographic Architecture (`@katlux/providers`).
4
+ > See [encryption.md](encryption.md) for the master index.
5
+
6
+ ---
7
+
8
+ ## 1. E2EE Architecture & Threat Model Boundary
9
+
10
+ - **Primary Objective**: Provide robust **End-to-End Encryption (E2EE)** to prevent catastrophic server-side data leaks (database dumps, cloud infrastructure compromises, rogue backend admin access). In multi-tenant, multi-user SaaS architectures, all GDPR-protected and sensitive data is stored and relayed exclusively as ciphertext envelopes (`__encrypted: true`).
11
+ - **Multi-User Role-Based Key Sharing**: Users with appropriate roles (defined in database permissions) can encrypt and decrypt shared tenant data. Roles may contain symmetric keys or wrapped/encrypted keys. Keys may exist in memory or be wrapped for secure transport across the network to client sessions.
12
+ - **Asymmetric Sender Authenticity Boundary**: Hybrid asymmetric ciphers (`CRSAEncryptionProvider`, `CECDHEncryptionProvider`) provide **recipient confidentiality** (only the holder of the recipient private key can decrypt), but do **not** provide sender authenticity on their own—anyone possessing the recipient public key can encrypt envelopes. In multi-user multi-tenant architectures where write authenticity must be strictly enforced, pair asymmetric encryption with digital signatures (ECDSA/Ed25519) or symmetric tenant role keys (AES-GCM).
13
+ - **Explicit Non-Goals (Client Endpoint Security)**: The encryption system does **not** protect against client-side compromise (OS-level trojans, hardware keyloggers, screen grabbers, or malicious browser extensions). Once data is legitimately decrypted in client DOM/memory for the authorized user to view, local endpoint security is the user's/device owner's responsibility.
14
+
15
+ ---
16
+
17
+ ## 2. Envelope Contract (`IEncryptedPayload`)
18
+
19
+ All Katlux encrypted payloads conform to a standardized envelope format:
20
+
21
+ ```ts
22
+ export interface IEncryptedPayload {
23
+ __encrypted: true
24
+ ciphertext: string // Base64 ciphertext (always present)
25
+ alg: string // 'AES-GCM' | 'AES-CBC-256+HMAC-SHA-256' | 'RSA-OAEP-4096+AES-GCM-256' | 'ECDH-P-256+AES-GCM-256'
26
+ kid?: string // Key identifier / version for key rotation tracking
27
+ iv?: string // Base64 IV
28
+ salt?: string // Base64 KDF salt
29
+ kdf?: string // 'PBKDF2' | 'HKDF'
30
+ iter?: number // PBKDF2 iteration count (default: 310,000, clamped [1,000, 600,000])
31
+ tag?: string // Explicit HMAC tag (AES-CBC)
32
+ wrappedKey?: string // Base64 RSA-wrapped AES key (RSA hybrid)
33
+ sharedKey?: boolean // Shared DEK marker for field-level encryption
34
+ epk?: JsonWebKey // Ephemeral public key (ECDH)
35
+ }
36
+ ```
37
+
38
+ ### Polymorphic Verification
39
+ ```ts
40
+ import { isEncrypted, AEncryptionProvider } from '@katlux/providers'
41
+
42
+ // Fast runtime envelope check:
43
+ if (isEncrypted(data)) {
44
+ // Safe to route to decrypt()
45
+ }
46
+ ```
47
+
48
+ ---
49
+
50
+ ## 3. Provider Options (`IProviderEncryptionOptions`)
51
+
52
+ ```ts
53
+ export interface IProviderEncryptionOptions {
54
+ enabled?: boolean // Master toggle (default: false)
55
+ key?: TKeyProvider // Single key or key provider (legacy/simple mode)
56
+ keys?: Record<string, TKeyProvider | IKeyPair> // Built-in Keyring dictionary mapping kid to keys
57
+ activeKid?: string // Active key identifier from keys to use for outbound encryption
58
+ kid?: string // Key identifier / version (e.g. 'v1', 'tenant-a-key-2026')
59
+ aad?: string | Uint8Array | ArrayBuffer | ((record: any, field: string) => string | Uint8Array | ArrayBuffer) // AEAD Additional Data or dynamic callback
60
+ aadFields?: string[] // Sibling record fields to deterministically bind into AAD (e.g. ['contact_id', 'version'])
61
+ baseAad?: string // Optional base prefix for AAD context binding
62
+ decryptOnSSR?: boolean // default: false. Prevents SSR decryption unless explicitly enabled with server secrets
63
+ fields?: string[] // Field-level encryption: only encrypt listed fields
64
+ strict?: boolean // Enforces strict decryption: unencrypted plaintext in `fields` triggers injection violation; defaults allowedAlgorithms to ['AES-GCM']
65
+ allowedAlgorithms?: string[] // Whitelist of permitted cipher algorithms (e.g. ['AES-GCM'])
66
+ allowedKids?: string[] // Whitelist of permitted Key Identifiers (kid); defaults to Object.keys(keys)
67
+ onDecryptError?: ((info: IDecryptErrorInfo) => any) | boolean | string // Per-field error hook, safe fallback marker, or true for '[⚠ Decryption Error]'
68
+ searchIndex?: boolean // Enables HMAC-SHA256 blind index and trigram search index on encrypted fields
69
+ preEncrypted?: boolean // Set to true if API endpoints return pre-encrypted ciphertext envelopes; enables in-memory index decryption
70
+ hmacKey?: TKeyProvider // Optional dedicated HMAC key for search indexing (defaults to encryption key)
71
+ algorithm?: 'AES-GCM' | string // default: 'AES-GCM'
72
+ customProvider?: IEncryptionProvider // Custom cipher adapter (e.g. CRSA, CECDH, AES-CBC)
73
+ kdf?: 'none' | 'pbkdf2' | 'hkdf' // Key derivation strategy:
74
+ // - 'pbkdf2': Recommended for human passphrases/passwords (OWASP recommended rounds)
75
+ // - 'hkdf': For high-entropy IKM / subkey derivation (warns if used with string passwords)
76
+ // - 'none': When supplying pre-derived 256-bit raw keys, Buffers, or CryptoKeys
77
+ kdfIterations?: number // PBKDF2 rounds (default: 310,000 per OWASP, clamped [1,000, 600,000])
78
+ kdfHash?: 'SHA-256' | 'SHA-512' // KDF hash algorithm
79
+ kdfSalt?: string | Uint8Array | ArrayBuffer // Optional static salt (random salt in envelope if omitted)
80
+ publicKey?: CryptoKey // Optional public key for asymmetric encryption
81
+ privateKey?: CryptoKey // Optional private key for asymmetric decryption
82
+ recipientPublicKey?: CryptoKey // Recipient public key for hybrid encryption
83
+ recipientPrivateKey?: CryptoKey // Recipient private key for hybrid decryption
84
+ curve?: 'P-256' | 'P-384' | 'P-521' // Curve for ECDH providers
85
+ info?: string // Optional context/info string for HKDF
86
+ }
87
+ ```
88
+
89
+ ---
90
+
91
+ ## 4. Factory & Base Provider Creation
92
+
93
+ ```ts
94
+ import { createEncryptionProvider } from '@katlux/providers'
95
+
96
+ // Automatically selects and configures the appropriate cipher engine:
97
+ const cipher = createEncryptionProvider({
98
+ algorithm: 'AES-GCM',
99
+ key: process.env.DATA_KEY,
100
+ kid: 'v1'
101
+ })
102
+ ```
103
+
104
+ ---
105
+
106
+ ## 5. Security Lifecycle & Memory Hygiene
107
+
108
+ - **Memory Zeroization**: Intermediate plaintext byte buffers (`Uint8Array`, `Buffer`) are immediately zeroed in memory via `.fill(0)` within `finally` blocks.
109
+ - **Session Cleanup (`clearKeys()` / `dispose()`)**: Calling `clearKeys()` or `dispose()` on any provider clears in-memory CryptoKeys, zeroes cached key buffers, and invalidates derived key caches upon user logout.
110
+ - **SSR Confidentiality Guard**: With `decryptOnSSR: false` (default zero-trust setting), sensitive payloads remain as encrypted envelopes in server memory and HTML hydration strings.
@@ -1,188 +1,44 @@
1
- ### `EncryptionProvider` (`CWebCryptoEncryptionProvider`, `CWebCryptoAESCBCProvider`, `CRSAEncryptionProvider`, `CECDHEncryptionProvider`, `CNodeCryptoEncryptionProvider`, `CKeyManager`, `AEncryptionProvider`)
2
- Zero-dependency, native cryptographic toolkit for end-to-end client-side, in-flight, and server-side encryption/decryption using native Web Crypto API (`crypto.subtle`) and `node:crypto`. Zero WASM, zero npm dependencies.
3
-
4
- > [!IMPORTANT]
5
- > **E2EE Architecture & Threat Model Boundary**:
6
- > - **Primary Objective**: Provide robust **End-to-End Encryption (E2EE)** to prevent catastrophic server-side data leaks (database dumps, cloud infrastructure compromises, rogue backend admin access). In multi-tenant, multi-user SaaS architectures, all GDPR-protected and sensitive data is stored and relayed exclusively as ciphertext envelopes (`__encrypted: true`).
7
- > - **Multi-User Role-Based Key Sharing**: Users with appropriate roles (defined in database permissions) can encrypt and decrypt shared tenant data. Roles may contain symmetric keys or wrapped/encrypted keys. Keys may exist in memory or be wrapped for secure transport across the network to client sessions.
8
- > - **Asymmetric Sender Authenticity Boundary**: Hybrid asymmetric ciphers (`CRSAEncryptionProvider`, `CECDHEncryptionProvider`) provide **recipient confidentiality** (only the holder of the recipient private key can decrypt), but do **not** provide sender authenticity on their own—anyone possessing the recipient public key can encrypt envelopes. In multi-user multi-tenant architectures where write authenticity must be strictly enforced, pair asymmetric encryption with digital signatures (ECDSA/Ed25519) or symmetric tenant role keys (AES-GCM).
9
- > - **Explicit Non-Goals (Client Endpoint Security)**: The encryption system does **not** protect against client-side compromise (OS-level trojans, hardware keyloggers, screen grabbers, or malicious browser extensions). Once data is legitimately decrypted in client DOM/memory for the authorized user to view, local endpoint security is the user's/device owner's responsibility.
10
-
11
- > **Showcase Pages**:
12
- > - **Overview & SSR**: `/providers/request/encryption`
13
- > - **Symmetric**: `/providers/classes/CWebCryptoEncryptionProvider` (AES-GCM) · `/providers/classes/CWebCryptoAESCBCProvider` (AES-CBC) · `/providers/classes/CNodeCryptoEncryptionProvider` (Node Sync)
14
- > - **Asymmetric / Hybrid**: `/providers/classes/CRSAEncryptionProvider` (RSA-OAEP) · `/providers/classes/CECDHEncryptionProvider` (ECDH)
15
- > - **Key Management**: `/providers/classes/CKeyManager`
16
- > - **Base & Contracts**: `/providers/classes/AEncryptionProvider` · `/providers/interfaces/IEncryptionProvider` · `/providers/interfaces/IProviderEncryptionOptions` · `/providers/interfaces/IKeyPair` · `/providers/interfaces/IKDFOptions` · `/providers/interfaces/IHKDFFromSecretOptions`
17
-
18
- - **Available Providers**:
19
- - `CWebCryptoEncryptionProvider`: AES-GCM-256 with optional PBKDF2/HKDF key derivation. Built-in AEAD, 100% backward-compatible.
20
- - `CWebCryptoAESCBCProvider`: Authenticated AES-CBC-256 + HMAC-SHA-256 (Encrypt-then-MAC) for legacy system compatibility.
21
- - `CRSAEncryptionProvider`: Asymmetric RSA-OAEP-4096 + AES-GCM-256 hybrid cipher for arbitrary-sized single-recipient payloads.
22
- - `CECDHEncryptionProvider`: Forward-secure Elliptic Curve Diffie-Hellman (P-256/384/521) + HKDF + AES-GCM. Ephemeral key per encryption. Ideal for multi-user role sharing (e.g. Account Symmetric Key wrapping).
23
- - `CNodeCryptoEncryptionProvider`: Server-side synchronous AES-GCM via `node:crypto` (`encryptSync`/`decryptSync`). 100% binary-interoperable with `CWebCryptoEncryptionProvider`.
24
- - **Provider Methods (`IEncryptionProvider` / `AEncryptionProvider`)**:
25
- - `encrypt(data: any, options?: IEncryptionContext): Promise<IEncryptedPayload | any>`: Encrypts data into an envelope or field-encrypted record (strictly idempotent; already-encrypted fields/envelopes are never double-encrypted). Attaches `kid` when specified or uses `activeKid`.
26
- - `decrypt(payload: any, options?: IEncryptionContext): Promise<any>`: Decrypts envelope back into original data, immediately zeroing plaintext byte buffers in memory. Dynamically routes decryption through `keys[envelope.kid]` or fallback keys, validating against `allowedKids`. Automatically leverages record-level DEK caching across multi-field records for up to 90% latency reduction.
27
- - `warmupKey(options?: IEncryptionContext): Promise<void>`: Pre-derives and caches CryptoKey / Buffer in memory. When a keyring (`keys`) is configured, resolves and warms up all keys concurrently via `Promise.all`. Supported on `CWebCrypto`, `CWebCryptoAESCBC`, and `CNodeCrypto` (`warmupKeySync` also available on Node).
28
- - `setKeyring(keys: Record<string, TKeyProvider | IKeyPair>, activeKid?: string): void`: Replaces or updates the active keyring dictionary and optionally sets the active outbound key identifier.
29
- - `getKeyring(): Record<string, TKeyProvider | IKeyPair>`: Returns the currently configured keyring dictionary.
30
- - `setActiveKid(kid: string): void`: Sets the active key identifier used for all outbound encryption.
31
- - `getActiveKid(): string | undefined`: Returns the currently active outbound key identifier.
32
- - `isEncrypted(payload: any): boolean`: Polymorphic check if given object is an encrypted envelope. Also available as static `AEncryptionProvider.isEncrypted(payload)`.
33
- - `clearKeys() / dispose()`: Wipes in-memory key caches, zeroes mutable Buffer bytes and keyring caches, and clears sensitive asymmetric keys upon logout/session end.
34
- - `resolveRawKey(keyProvider?: TKeyProvider)`: (Protected on `AEncryptionProvider`) Resolves key or async keyProvider callback. Supports `string`, `Uint8Array`, `ArrayBuffer`, and `CryptoKey` without byte corruption.
35
- - **PEM Import/Export (`CKeyManager` / `CRSA` / `CECDH`)**:
36
- - `importPublicKeyFromPEM(pem, ...)`: Imports SPKI PEM string to `CryptoKey`.
37
- - `importPrivateKeyFromPEM(pem, ...)`: Imports PKCS#8 PEM string to `CryptoKey`.
38
- - `exportPublicKeyToPEM(key)`: Exports `CryptoKey` to standard SPKI PEM string.
39
- - `exportPrivateKeyToPEM(key)`: Exports `CryptoKey` to standard PKCS#8 PEM string.
40
- - **Account Key Wrapping & Re-Wrapping (`CKeyManager`)**:
41
- - `wrapAccountKeyForUser(adek, userPublicKey): Promise<string>`: Wraps an ADEK for a user using RSA-OAEP.
42
- - `unwrapAccountKeyForUser(wrappedKeyBase64, userPrivateKey, unwrappedKeyAlgorithm?, extractable?): Promise<CryptoKey>`: Restores an unextractable AES-GCM ADEK from envelope using RSA-OAEP.
43
- - `rewrapAccountKeyForUser(wrappedKeyBase64, myPrivateKey, recipientPublicKey): Promise<string>`: Atomically re-wraps an ADEK envelope for a new recipient without exposing raw extractable keys to application memory, guaranteeing memory zeroization via `finally`.
44
- - **Digital Signatures & Access Grants (`CKeyManager` / `canonicalizeJson`)**:
45
- - `canonicalizeJson(value): string`: Serializes a JavaScript value to a deterministic, canonical JSON string conforming to RFC 8785 (JCS).
46
- - `generateSigningKeyPair(curve?, extractable?): Promise<IKeyPair>`: Generates an ECDSA P-256 signing key pair.
47
- - `getKeyFingerprint(publicKey): Promise<string>`: Generates a deterministic SHA-256 fingerprint for a public key formatted as `SHA256:<base64url>`.
48
- - `sign(data, privateKey): Promise<string>`: Signs arbitrary data or JSON objects using an ECDSA P-256 private key (objects automatically canonicalized via RFC 8785).
49
- - `verify(data, signature, publicKey): Promise<boolean>`: Verifies an ECDSA P-256 signature against original data or JSON object.
50
- - `signGrant(grant: IAccessGrant, granterPrivateKey, granterPublicKey?): Promise<ISignedGrant>`: Signs a structured access grant, embedding signature and granter key fingerprint.
51
- - `verifyGrant(signedGrant: ISignedGrant, granterPublicKey, options?): Promise<boolean>`: Verifies authenticity, integrity, and granter key fingerprint of an access grant, defeating key-substitution attacks.
52
- - **Domain-Separated Key Derivation (`CKeyManager.deriveAuthAndEncryptionKeys`)**:
53
- - `deriveAuthAndEncryptionKeys(password, salt?, options?): Promise<IDomainDerivedKeys>`: Hardened two-stage derivation pipeline. PBKDF2 stretches low-entropy user password and salt, then HKDF-Expand produces two cryptographically isolated keys (`authKey` for authentication challenges and `encryptionKey` for AES-GCM data encryption) using domain-separated context tags (`katlux-auth-key-v1` and `katlux-encryption-key-v1`). Full compromise of `authKey` reveals zero mathematical information about `encryptionKey`. Intermediate master secret buffers are immediately zeroized in memory.
54
-
55
-
56
-
57
- - **Envelope Contract (`IEncryptedPayload`)**:
58
- ```ts
59
- interface IEncryptedPayload {
60
- __encrypted: true
61
- ciphertext: string // Base64 ciphertext (always present)
62
- alg: string // 'AES-GCM' | 'AES-CBC-256+HMAC-SHA-256' | 'RSA-OAEP-4096+AES-GCM-256' | 'ECDH-P-256+AES-GCM-256'
63
- kid?: string // Key identifier / version for key rotation tracking
64
- iv?: string // Base64 IV
65
- salt?: string // Base64 KDF salt
66
- kdf?: string // 'PBKDF2' | 'HKDF'
67
- iter?: number // PBKDF2 iteration count (default: 310,000, clamped [1,000, 600,000])
68
- tag?: string // Explicit HMAC tag (AES-CBC)
69
- wrappedKey?: string // Base64 RSA-wrapped AES key (RSA hybrid)
70
- sharedKey?: boolean // Shared DEK marker for field-level encryption
71
- epk?: JsonWebKey // Ephemeral public key (ECDH)
72
- }
73
- ```
74
-
75
- - **`IProviderEncryptionOptions`**:
76
- ```ts
77
- interface IProviderEncryptionOptions {
78
- enabled?: boolean // Master toggle (default: false)
79
- key?: TKeyProvider // Single key or key provider (legacy/simple mode)
80
- keys?: Record<string, TKeyProvider | IKeyPair> // Built-in Keyring dictionary mapping kid to keys
81
- activeKid?: string // Active key identifier from keys to use for outbound encryption
82
- kid?: string // Key identifier / version (e.g. 'v1', 'tenant-a-key-2026')
83
- aad?: string | Uint8Array | ArrayBuffer | ((record: any, field: string) => string | Uint8Array | ArrayBuffer) // AEAD Additional Data or dynamic callback
84
- aadFields?: string[] // Sibling record fields to deterministically bind into AAD (e.g. ['contact_id', 'version'])
85
- baseAad?: string // Optional base prefix for AAD context binding
86
- decryptOnSSR?: boolean // default: false. Prevents SSR decryption unless explicitly enabled with server secrets
87
- fields?: string[] // Field-level encryption: only encrypt listed fields
88
- strict?: boolean // Enforces strict decryption: unencrypted plaintext in `fields` triggers injection violation; defaults allowedAlgorithms to ['AES-GCM']
89
- allowedAlgorithms?: string[] // Whitelist of permitted cipher algorithms (e.g. ['AES-GCM'])
90
- allowedKids?: string[] // Whitelist of permitted Key Identifiers (kid); defaults to Object.keys(keys)
91
- onDecryptError?: ((info: IDecryptErrorInfo) => any) | boolean | string // Per-field error hook, safe fallback marker, or true for '[⚠ Decryption Error]'
92
- searchIndex?: boolean // Enables HMAC-SHA256 blind index and trigram search index on encrypted fields
93
- hmacKey?: TKeyProvider // Optional dedicated HMAC key for search indexing (defaults to encryption key)
94
- algorithm?: 'AES-GCM' | string // default: 'AES-GCM'
95
- customProvider?: IEncryptionProvider // Custom cipher adapter (e.g. CRSA, CECDH, AES-CBC)
96
- kdf?: 'none' | 'pbkdf2' | 'hkdf' // Key derivation strategy:
97
- // - 'pbkdf2': Recommended for human passphrases/passwords (OWASP recommended rounds)
98
- // - 'hkdf': For high-entropy IKM / subkey derivation (warns if used with string passwords)
99
- // - 'none': When supplying pre-derived 256-bit raw keys, Buffers, or CryptoKeys
100
- kdfIterations?: number // PBKDF2 rounds (default: 310,000 per OWASP, clamped [1,000, 600,000])
101
- kdfHash?: 'SHA-256' | 'SHA-512' // KDF hash algorithm
102
- kdfSalt?: string | Uint8Array | ArrayBuffer // Optional static salt (random salt in envelope if omitted)
103
- publicKey?: CryptoKey // Optional public key for asymmetric encryption
104
- privateKey?: CryptoKey // Optional private key for asymmetric decryption
105
- recipientPublicKey?: CryptoKey // Recipient public key for hybrid encryption
106
- recipientPrivateKey?: CryptoKey // Recipient private key for hybrid decryption
107
- curve?: 'P-256' | 'P-384' | 'P-521' // Curve for ECDH providers
108
- info?: string // Optional context/info string for HKDF
109
- }
110
- ```
111
-
112
- - **Factory & Provider Creation**:
113
- - `createEncryptionProvider(options: IProviderEncryptionOptions): IEncryptionProvider`: Unified factory that instantiates and configures the appropriate cipher provider based on `options.algorithm` (`'AES-GCM'`, `'AES-CBC'`, `'RSA-OAEP'`, `'ECDH'`) or returns `options.customProvider`. Supports `IKeyPair` or individual keys, HKDF info, curve configuration, and KDF options.
114
-
115
- - **Usage in DataProvider (Client & Server)**:
116
- Supported uniformly across **all** client and server data providers:
117
- - **Local (Non-API)**: `CFlatClientDataProvider`, `CTreeClientDataProvider` (via `AEncryptedClientProvider`)
118
- - **API Client-Side**: `CAPIFlatClientDataProvider`, `CAPITreeClientDataProvider`
119
- - **Server-Side**: `CAPIFlatServerDataProvider`, `CAPITreeServerDataProvider`
120
-
121
- #### Local DataProvider Encryption Architecture
122
- - **Eager Encryption**: `setData(rows)` encrypts designated `fields` immediately before storing in `allData`. Plaintext never persists in `allData`.
123
- - **Non-blocking Ingestion**: `setDataChunked(rows, { chunkSize: 250, yieldStrategy: 'idle' })` yields between chunks to prevent main-thread freezing on large datasets.
124
- - **Idempotent Ingestion**: Pre-encrypted envelopes (`__encrypted: true`, e.g. from IndexedDB or Web Workers) pass through untouched without double-encryption.
125
- - **Lazy Page-Level Decryption**: `loadPageData()` slices `allData` and decrypts only the active page (`pageSize` rows) into `pageData`. Only visible rows are plaintext in memory.
126
- - **Blind Index Search (`CSearchIndex`)**: When `searchIndex: true`, exact match (`==`, `!=`) and substring search (`in`) operate directly on encrypted fields via deterministic HMAC-SHA256 blind tokens and trigram sets without full dataset decryption.
127
- - **Zero-Cost Path**: When `enabled` is false, `setData` runs 100% synchronously with zero microtask overhead.
128
-
129
- ```ts
130
- import { CFlatClientDataProvider } from '@katlux/providers'
131
-
132
- const customerProvider = new CFlatClientDataProvider({
133
- pageSize: 20,
134
- encryption: {
135
- enabled: true,
136
- key: 'secret-key-32-chars-long-12345!',
137
- kid: 'tenant-key-v1',
138
- fields: ['ssn', 'salary', 'creditCard'],
139
- searchIndex: true // Enables search/filter on encrypted fields via CSearchIndex
140
- }
141
- })
142
-
143
- // Eagerly encrypts sensitive fields; leaves id, role, department in plaintext
144
- await customerProvider.setData(rawEmployees)
145
-
146
- // Large dataset ingestion with progress reporting:
147
- await customerProvider.setDataChunked(largeEmployees, {
148
- chunkSize: 500,
149
- onProgress: (p) => console.log(`Encryption progress: ${(p * 100).toFixed(0)}%`)
150
- })
151
-
152
- // Dynamically rotate key:
153
- customerProvider.setEncryption({ enabled: true, key: newKey, kid: 'tenant-key-v2', fields: ['ssn', 'salary'] })
154
-
155
- // Upon user logout / session termination:
156
- customerProvider.clearEncryption() // Clears keys, zeroes memory, and disables encryption
157
- ```
158
-
159
- - **Usage with RequestProvider**:
160
- ```ts
161
- const rp = new RequestProvider()
162
- rp.setEncryption({ enabled: true, key: 'my-secret-32-char-key!!!', kid: 'tenant-key-2026' })
163
- // Outbound POST/PUT/PATCH bodies encrypted; encrypted responses auto-decrypted
164
-
165
- // Upon user logout:
166
- rp.clearEncryption() // Safely clears cached cipher instance, scoped WeakMap instances, and zeroes keys
167
- ```
168
-
169
- #### Authenticated Additional Data (AAD) & Security Guarantees
170
- In multi-tenant, field-encrypted, and SSR scenarios, Katlux cryptographic providers enforce strict, integration-tested security guarantees:
171
- - **Field & Record Binding**: During value-level and field-level encryption, `AEncryptionProvider` and `CNodeCryptoEncryptionProvider` automatically bind:
172
- `aad:${baseAad}|record:${recordId}|field:${fieldName}`
173
- Where `recordId` is extracted from `record.id`, `record._id`, or `options.recordId`.
174
- - **Transposition Tamper Resistance**: Moving or swapping an encrypted envelope from one database row to another, or from one column (`ssn`) to another (`phone`), causes AES-GCM tag verification to immediately fail with an authentication error.
175
- - **Cache-at-Rest Full Envelope**: When caching responses where field-level encryption is active (`fields: [...]`), `RequestProvider` automatically wraps the entire object in a full envelope at rest. Neither targeted sensitive fields nor unlisted metadata fields appear as plaintext in raw storage across any client or server cache adapter.
176
- - **Node GCM 16-Byte Tag Enforcement**: `CNodeCryptoEncryptionProvider` strictly validates a 16-byte (128-bit) authentication tag across all synchronous and asynchronous decryption paths (rejecting truncated 12, 8, or 4-byte tags).
177
- - **Nonce Misuse Resistance**: Initialization Vectors (IVs) are freshly generated via cryptographically secure RNG per operation (12 bytes for GCM, 16 bytes for CBC) with proven uniqueness across sibling fields, batch arrays, and concurrent executions.
178
- - **Deterministic Search Token Segregation**: `CSearchIndex` HMAC-SHA256 blind index tokens are deterministic for search matching and strictly segregated from non-deterministic ciphertext IVs.
179
- - **Non-Extractable Tenant Keys**: `CKeyManager.generateAccountDataKey()` and `CKeyManager.unwrapAccountKeyForUser()` produce `CryptoKey` instances with `extractable: false` by default, safeguarding unwrapped symmetric tenant keys against exfiltration via developer tools or malicious extensions.
180
- - **Atomic Key Re-Wrapping (`CKeyManager.rewrapAccountKeyForUser`)**: When sharing an Account Data Encryption Key (ADEK) between users, `CKeyManager.rewrapAccountKeyForUser(wrappedKey, myPrivateKey, recipientPublicKey)` atomically decrypts the raw key material and re-encrypts it with the recipient's RSA-OAEP public key without ever exposing the raw extractable symmetric key to caller application memory or leaving extractable CryptoKeys in memory. Immediate memory zeroization (`fill(0)`) is guaranteed across all paths.
181
- - **SSR Confidentiality & Cache Auth Guard**: With `decryptOnSSR: false` (the secure zero-trust default), plaintext is never exposed in server memory or serialized HTML hydration payloads. Requests with `cookie` or `Authorization` headers automatically bypass shared server caches (`CApplicationCache`), preventing cross-user session cache poisoning.
182
-
183
- #### Built-in Keyring & Multi-Key Rotation Architecture
184
- - **Zero-Downtime Key Rotation**: Configuring `keys: { 'k2025': key1, 'k2026': key2 }` alongside `activeKid: 'k2026'` ensures all outbound writes are automatically tagged with `kid: 'k2026'` and encrypted with `key2`, while legacy records tagged with `k2025` decrypt seamlessly under `key1`.
185
- - **Automatic Whitelisting & Untrusted `kid` Protection**: `allowedKids` automatically defaults to `Object.keys(keys)` when `keys` is provided. Incoming envelopes carrying an unknown or unregistered `kid` are immediately rejected with an unauthorized key security error (`Unauthorized key: kid '${payload.kid}' is not in allowedKids.`).
186
- - **Concurrent Multi-Key Warmup**: Calling `warmupKey()` (or `warmupKeySync()` on Node) resolves and primes all cryptographic keys across the entire keyring concurrently using `Promise.all`, preventing runtime latency spikes or race conditions during rotation periods.
187
- - **Dynamic Runtime Keyring Management**: Keyrings can be rotated dynamically at runtime using `provider.setKeyring(newKeys, newActiveKid)` or `provider.setActiveKid(newKid)` without recreating provider instances or dropping existing session caches.
188
-
1
+ # Katlux Cryptographic Architecture & Encryption Suite (`@katlux/providers`) Master Index
2
+
3
+ > **Atomic Architecture**: To minimize prompt context and token consumption, the Katlux encryption architecture is split into 7 focused atomic specifications. Read **only** the atomic document required for your task.
4
+
5
+ ---
6
+
7
+ ## 1. Atomic Encryption Specifications
8
+
9
+ | Document | Topic & Focus | Core Classes & Primitives | Document Link |
10
+ | :--- | :--- | :--- | :--- |
11
+ | **Threat Model & Contracts** | E2EE architecture, boundary rules, non-goals, envelope schema, provider options | `IEncryptedPayload`, `IProviderEncryptionOptions`, `createEncryptionProvider`, `isEncrypted` | [encryption-threat-model.md](encryption-threat-model.md) |
12
+ | **Symmetric Ciphers** | AES-GCM-256, authenticated AES-CBC, Node sync cipher, keyring rotation, strict decryption, dynamic AAD | `CWebCryptoEncryptionProvider`, `CWebCryptoAESCBCProvider`, `CNodeCryptoEncryptionProvider` | [encryption-symmetric.md](encryption-symmetric.md) |
13
+ | **Asymmetric Hybrid Ciphers** | RSA-OAEP-4096 and ECDH ephemeral hybrid encryption, SPKI/PKCS#8 PEM import/export | `CRSAEncryptionProvider`, `CECDHEncryptionProvider`, `importPublicKeyFromPEM` | [encryption-asymmetric.md](encryption-asymmetric.md) |
14
+ | **Key Lifecycle & Derivation** | Tenant key generation, ADEK wrapping/rewrapping, RFC 8785 canonical JSON access grants, domain-separated KDF, master passphrase re-keying | `CKeyManager`, `canonicalizeJson`, `deriveAuthAndEncryptionKeys`, `rekeyUserKeypair` | [encryption-key-management.md](encryption-key-management.md) |
15
+ | **Key Pinning (TOFU) & Attestations** | Trust-On-First-Use key store, signed key-reset attestation protocol, 6 strict verification rules, memory/storage adapters | `IKeyPinningStore`, `CMemoryKeyPinningStore`, `CLocalStorageKeyPinningStore`, `CIndexedDBKeyPinningStore`, `verifyAndPinKey`, `signKeyResetAttestation` | [encryption-key-pinning.md](encryption-key-pinning.md) |
16
+ | **Web Streams Chunked AEAD** | Constant-memory chunked streaming cipher, 16-byte header framing protocol, blob helpers, Node stream interoperability | `CWebCryptoStreamCipher`, `createEncryptionStream`, `createDecryptionStream`, `encryptBlob`, `decryptBlob` | [encryption-streaming.md](encryption-streaming.md) |
17
+ | **Field Encryption & Ingestion** | Row scalar encryption, eager client ingestion, pre-encrypted datasets, blind indexing, trigram substring queries, SQL schema | `encryptField`, `decryptField`, `AEncryptedClientProvider`, `CSearchIndex`, `computeBlindIndex` | [encryption-field-level.md](encryption-field-level.md) |
18
+
19
+ ---
20
+
21
+ ## 2. Decision Matrix: Which Cryptographic Tool to Use?
22
+
23
+ | Requirement / Scenario | Recommended Solution | Documentation |
24
+ | :--- | :--- | :--- |
25
+ | Encrypting database rows or API payloads in browser/server | `CWebCryptoEncryptionProvider` (AES-GCM-256) | [encryption-symmetric.md](encryption-symmetric.md) |
26
+ | Fast synchronous encryption in high-throughput Node.js server routes | `CNodeCryptoEncryptionProvider.encryptSync` | [encryption-symmetric.md](encryption-symmetric.md) |
27
+ | Encrypting large files, media, or archives (> 5 MB) without memory bloat | `createEncryptionStream` / `encryptBlob` | [encryption-streaming.md](encryption-streaming.md) |
28
+ | Sharing tenant symmetric keys with specific users | `CKeyManager.wrapAccountKeyForUser` (RSA-OAEP) | [encryption-key-management.md](encryption-key-management.md) |
29
+ | Re-wrapping keys between users without exposing raw bytes | `CKeyManager.rewrapAccountKeyForUser` | [encryption-key-management.md](encryption-key-management.md) |
30
+ | Forward-secure ephemeral key exchange | `CECDHEncryptionProvider` | [encryption-asymmetric.md](encryption-asymmetric.md) |
31
+ | User password change without re-encrypting database payloads | `CKeyManager.rekeyUserKeypair` | [encryption-key-management.md](encryption-key-management.md) |
32
+ | Preventing rogue-admin public key substitution on peers | `CKeyManager.verifyAndPinKey` (TOFU store) | [encryption-key-pinning.md](encryption-key-pinning.md) |
33
+ | Encrypting sensitive columns while leaving IDs plaintext for sorting | `encryptField` / `AEncryptedClientProvider` | [encryption-field-level.md](encryption-field-level.md) |
34
+ | Exact-match lookups or substring search on encrypted database fields | `CSearchIndex` (HMAC-SHA256 blind indices & trigrams) | [encryption-field-level.md](encryption-field-level.md) |
35
+
36
+ ---
37
+
38
+ ## 3. Showcase Live Reference Pages
39
+
40
+ - **Overview & SSR**: `/providers/request/encryption`
41
+ - **Symmetric**: `/providers/classes/CWebCryptoEncryptionProvider` · `/providers/classes/CWebCryptoAESCBCProvider` · `/providers/classes/CNodeCryptoEncryptionProvider`
42
+ - **Asymmetric / Hybrid**: `/providers/classes/CRSAEncryptionProvider` · `/providers/classes/CECDHEncryptionProvider`
43
+ - **Key Management**: `/providers/classes/CKeyManager`
44
+ - **Base & Contracts**: `/providers/classes/AEncryptionProvider` · `/providers/interfaces/IEncryptionProvider` · `/providers/interfaces/IProviderEncryptionOptions`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@katlux/toolkit",
3
- "version": "0.1.1-alpha.139",
3
+ "version": "0.1.1-alpha.141",
4
4
  "description": "Core UI toolkit and utilities for the Katlux ecosystem",
5
5
  "author": "Katlux",
6
6
  "license": "Apache-2.0",
@@ -54,7 +54,7 @@
54
54
  "**/*.sass"
55
55
  ],
56
56
  "dependencies": {
57
- "@katlux/providers": "^0.1.1-alpha.127",
57
+ "@katlux/providers": "^0.1.1-alpha.129",
58
58
  "@nuxt/kit": "^3.12.0",
59
59
  "@nuxtjs/i18n": "^10.4.0",
60
60
  "pug": "^3.0.0",