@pushforge/builder
Version:
A robust, cross-platform Web Push notification library that handles VAPID authentication and payload encryption following the Web Push Protocol standard. Works in Node.js 16+, Browsers, Deno, Bun and Cloudflare Workers.
17 lines (16 loc) • 1.05 kB
TypeScript
import type { PushOptions } from './types.js';
/**
* Constructs the VAPID headers for a push notification request.
*
* This function generates the necessary headers for sending a push notification
* using the VAPID protocol, including authentication and encryption information.
*
* @param {PushOptions} options - The options for the push notification, including the JSON Web Key (JWK) and JWT data.
* @param {number} payloadLength - The length of the payload being sent in the push notification.
* @param {Uint8Array} salt - A salt value used in the encryption process.
* @param {CryptoKey} localPublicKey - The local public key used for encryption.
* @returns {Promise<Record<string, string> | Headers>} A promise that resolves to an object containing the VAPID headers.
*
* @throws {Error} Throws an error if the JWT creation fails or if key export fails.
*/
export declare const vapidHeaders: (options: PushOptions, payloadLength: number, salt: Uint8Array, localPublicKey: CryptoKey) => Promise<Record<string, string> | Headers>;