(value: string, encoding: "base64" | "base64url")
| 398 | }; |
| 399 | |
| 400 | const normalizeBase64 = (value: string, encoding: "base64" | "base64url"): string => { |
| 401 | const compact = value.replace(/\s/g, ""); |
| 402 | const alphabet = |
| 403 | encoding === "base64url" ? compact.replace(/-/g, "+").replace(/_/g, "/") : compact; |
| 404 | const remainder = alphabet.length % 4; |
| 405 | return remainder === 0 ? alphabet : `${alphabet}${"=".repeat(4 - remainder)}`; |
| 406 | }; |
| 407 | |
| 408 | const byteLengthFromBase64 = (base64: string): number => { |
| 409 | const compact = base64.replace(/\s/g, ""); |
no test coverage detected