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

1"""Web Push notification value types — RFC 8030 subscription format.""" 

2 

3from __future__ import annotations 

4 

5from dataclasses import dataclass 

6 

7 

8@dataclass(frozen=True, slots=True) 

9class WebPushKeys: 

10 """Crypto keys for Web Push message encryption (RFC 8291). 

11 

12 Mirrors the ``keys`` property of the browser 

13 ``PushSubscription.toJSON()`` output. 

14 

15 Attributes: 

16 p256dh: Base64URL-encoded P-256 ECDH public key. 

17 auth: Base64URL-encoded authentication secret. 

18 """ 

19 

20 p256dh: str 

21 auth: str 

22 

23 

24@dataclass(frozen=True, slots=True) 

25class WebPushSubscription: 

26 """A browser Web Push subscription — RFC 8030 endpoint + keys. 

27 

28 Mirrors the top-level shape of ``PushSubscription.toJSON()``. 

29 

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 """ 

36 

37 endpoint: str 

38 keys: WebPushKeys 

39 expiration_time: int | None = None 

40 

41 

42__all__ = ["WebPushKeys", "WebPushSubscription"]