Content to encrypt as a UTF-8 string
MIME content type for the cty header. Used by decryption to identify file format. Typically 'application/smart-health-card' or 'application/fhir+json'.
Optional
enableCompression?: booleanWhether to compress content with raw DEFLATE before encryption. Recommended for verbose content like FHIR JSON. Not recommended for already-compressed content like SMART Health Cards.
256-bit encryption key encoded as base64url (43 characters). Should be generated using cryptographically secure random bytes.
JWE Compact serialization string (5 base64url parts separated by dots)
SHLEncryptionError When encryption fails due to invalid key, content, or crypto operations
// Encrypt FHIR resource with compression
const fhirJson = JSON.stringify(myFhirBundle);
const jwe = await encryptSHLFile({
content: fhirJson,
key: 'abc123...', // 43-char base64url key
contentType: 'application/fhir+json',
enableCompression: true
});
// Encrypt SMART Health Card without compression
const shcJson = JSON.stringify({ verifiableCredential: [jwsString] });
const jwe = await encryptSHLFile({
content: shcJson,
key: 'abc123...', // same key as above
contentType: 'application/smart-health-card',
enableCompression: false
});
Encrypts content as JWE Compact using A256GCM direct encryption.
Follows the SMART Health Links specification for file encryption using: