Files
cobble/src/utils/url-base64-to-uint8-array.ts
T
tben dbfe48796b Make the app an installable PWA with phone layout and Web Push
Add a generated manifest, icon set, offline page and service worker that never caches authenticated HTML, plus install and update UI. Turn the rail into a drawer below md with container-query internals, dvh and safe-area handling, and reconnect the socket after visibility/network changes. Add Web Push subscriptions, presence-aware delivery, notification settings and tests.
2026-10-19 17:12:16 +01:00

19 lines
540 B
TypeScript

/**
* A base64url VAPID public key as the bytes `PushManager.subscribe`
* expects.
*/
export default function urlBase64ToUint8Array(base64_string: string) {
const padding = "=".repeat((4 - (base64_string.length % 4)) % 4);
const base64 = (base64_string + padding)
.replace(/-/g, "+")
.replace(/_/g, "/");
const raw = atob(base64);
const bytes = new Uint8Array(raw.length);
for (let index = 0; index < raw.length; index += 1) {
bytes[index] = raw.charCodeAt(index);
}
return bytes;
}