- AES-256-GCM via SubtleCrypto (browsers + React Native with polyfill) - Wire-compatible EncryptedField with @bytelyst/field-encrypt (server) and BLFieldEncrypt (Swift/Kotlin native SDKs) - encryptField, decryptField, generateKey, keyFromHex, keyToHex - PBKDF2 key derivation (600k iterations per OWASP 2023) - isEncryptedField type guard, toHex/fromHex helpers - 22 Vitest tests, all passing - Add Web Crypto globals to root ESLint config
37 lines
1.4 KiB
TypeScript
37 lines
1.4 KiB
TypeScript
/**
|
|
* @bytelyst/client-encrypt
|
|
*
|
|
* Client-side AES-256-GCM field encryption using Web Crypto API.
|
|
* Works in browsers and React Native (with SubtleCrypto polyfill).
|
|
* Wire-compatible with @bytelyst/field-encrypt (server) and
|
|
* BLFieldEncrypt (Swift/Kotlin native SDKs).
|
|
*
|
|
* @example
|
|
* ```typescript
|
|
* import { generateKey, encryptField, decryptField } from '@bytelyst/client-encrypt';
|
|
*
|
|
* const key = await generateKey();
|
|
* const encrypted = await encryptField('sensitive data', key, 'dek_user1_notes');
|
|
* const plaintext = await decryptField(encrypted, key);
|
|
* ```
|
|
*/
|
|
|
|
// ── Main API ────────────────────────────────────────
|
|
export {
|
|
encryptField,
|
|
decryptField,
|
|
generateKey,
|
|
keyFromHex,
|
|
keyToHex,
|
|
deriveKey,
|
|
} from './aes-gcm.js';
|
|
|
|
// ── Type guards ─────────────────────────────────────
|
|
export { isEncryptedField } from './guards.js';
|
|
|
|
// ── Hex utilities ───────────────────────────────────
|
|
export { toHex, fromHex } from './hex.js';
|
|
|
|
// ── Types ───────────────────────────────────────────
|
|
export type { EncryptedField, ClientEncryptContext } from './types.js';
|