(value: string, encoding: "base64" | "base64url")
| 357 | }; |
| 358 | |
| 359 | const normalizeBase64 = (value: string, encoding: "base64" | "base64url"): string => { |
| 360 | const compact = value.replace(/\s/g, ""); |
| 361 | const alphabet = |
| 362 | encoding === "base64url" ? compact.replace(/-/g, "+").replace(/_/g, "/") : compact; |
| 363 | const remainder = alphabet.length % 4; |
| 364 | return remainder === 0 ? alphabet : `${alphabet}${"=".repeat(4 - remainder)}`; |
| 365 | }; |
| 366 | |
| 367 | const byteLengthFromBase64 = (base64: string): number => { |
| 368 | const compact = base64.replace(/\s/g, ""); |
no test coverage detected