MCPcopy Create free account
hub / github.com/boringstack-xyz/boringstack / serializeSubscription

Function serializeSubscription

apps/ui/src/hooks/useWebPush.hooks.ts:51–67  ·  view source on GitHub ↗
(
  subscription: PushSubscription
)

Source from the content-addressed store, hash-verified

49}
50
51const serializeSubscription = (
52 subscription: PushSubscription
53): ISerializedSubscription => {
54 const json = subscription.toJSON();
55
56 return {
57 endpoint: json.endpoint ?? subscription.endpoint,
58 keys: {
59 p256dh: json.keys?.p256dh ?? "",
60 auth: json.keys?.auth ?? ""
61 },
62 expirationTime:
63 typeof subscription.expirationTime === "number"
64 ? subscription.expirationTime
65 : null
66 };
67};
68
69/**
70 * Single source of truth for Web Push subscription state on the client.

Callers 1

useWebPushFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected