( header: string | null, )
| 44 | const redirect = (location: string) => new Response(null, { status: 302, headers: { location } }); |
| 45 | |
| 46 | const decodeBasic = ( |
| 47 | header: string | null, |
| 48 | ): { readonly username: string; readonly password: string } | null => { |
| 49 | if (!header?.startsWith("Basic ")) return null; |
| 50 | const decoded = atob(header.slice("Basic ".length)); |
| 51 | const separator = decoded.indexOf(":"); |
| 52 | if (separator < 0) return null; |
| 53 | return { username: decoded.slice(0, separator), password: decoded.slice(separator + 1) }; |
| 54 | }; |
| 55 | |
| 56 | const base64url = (buffer: ArrayBuffer): string => { |
| 57 | const bytes = new Uint8Array(buffer); |
no outgoing calls
no test coverage detected