(bytes: Uint8Array)
| 5 | * Convert Uint8Array to Base64URL string (URL-safe, no padding). |
| 6 | */ |
| 7 | export function toBase64Url(bytes: Uint8Array): string { |
| 8 | const chunkSize = 0x8000; |
| 9 | const chunks: string[] = []; |
| 10 | for (let offset = 0; offset < bytes.length; offset += chunkSize) { |
| 11 | chunks.push(String.fromCharCode(...bytes.subarray(offset, offset + chunkSize))); |
| 12 | } |
| 13 | const base64 = btoa(chunks.join('')); |
| 14 | return base64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, ''); |
| 15 | } |
| 16 | |
| 17 | /** |
| 18 | * Convert Base64URL string to Uint8Array. |
no outgoing calls