(bytes: Uint8Array)
| 79 | // --- Helpers --- |
| 80 | |
| 81 | function bytesToBase64url(bytes: Uint8Array): string { |
| 82 | // Loop to avoid RangeError on large payloads (same approach as compress.ts) |
| 83 | let binary = ''; |
| 84 | for (let i = 0; i < bytes.length; i++) { |
| 85 | binary += String.fromCharCode(bytes[i]); |
| 86 | } |
| 87 | return btoa(binary) |
| 88 | .replace(/\+/g, '-') |
| 89 | .replace(/\//g, '_') |
| 90 | .replace(/=/g, ''); |
| 91 | } |
| 92 | |
| 93 | function base64urlToBytes(b64: string): Uint8Array { |
| 94 | const base64 = b64.replace(/-/g, '+').replace(/_/g, '/'); |