class

Vapid::Encryption

Inherits Reference < Object

Implements Web Push Message Encryption (RFC 8291) using the aes128gcm content encoding scheme

Constants

MAX_PAYLOAD_SIZE = 3993

Maximum payload size for encrypted push messages

Class methods

encrypt(payload : String, user_public_key : String, user_auth : String) : NamedTuple(encrypted: Bytes, salt: String, server_public_key: String)

Encrypts a payload for web push using aes128gcm encoding

Parameters

  • payload: The plaintext message to encrypt (JSON string)
  • user_public_key: The subscriber's p256dh key (base64url encoded)
  • user_auth: The subscriber's auth secret (base64url encoded)

Returns

A tuple containing:

  • encrypted_payload: The encrypted message bytes
  • salt: The salt used (base64url encoded)
  • server_public_key: The ephemeral server public key (base64url encoded)
Source