Coverage for src / lexigram / contracts / notification / web_push.py: 100%
12 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-08-19 05:41 +0800
« prev ^ index » next coverage.py v7.13.5, created at 2026-08-19 05:41 +0800
1"""Web Push notification value types — RFC 8030 subscription format."""
3from __future__ import annotations
5from dataclasses import dataclass
8@dataclass(frozen=True, slots=True)
9class WebPushKeys:
10 """Crypto keys for Web Push message encryption (RFC 8291).
12 Mirrors the ``keys`` property of the browser
13 ``PushSubscription.toJSON()`` output.
15 Attributes:
16 p256dh: Base64URL-encoded P-256 ECDH public key.
17 auth: Base64URL-encoded authentication secret.
18 """
20 p256dh: str
21 auth: str
24@dataclass(frozen=True, slots=True)
25class WebPushSubscription:
26 """A browser Web Push subscription — RFC 8030 endpoint + keys.
28 Mirrors the top-level shape of ``PushSubscription.toJSON()``.
30 Attributes:
31 endpoint: The push service URL that accepts encrypted messages.
32 keys: The P-256 public key + auth secret for encryption.
33 expiration_time: Unix timestamp (seconds) when the subscription
34 expires, or ``None`` if it never expires.
35 """
37 endpoint: str
38 keys: WebPushKeys
39 expiration_time: int | None = None
42__all__ = ["WebPushKeys", "WebPushSubscription"]