Self-hosted, federated location sharing app and server that prioritizes user privacy and security
end-to-end-encryption location-sharing privacy self-hosted federated
at auth 1.8 kB view raw
1// THIS FILE IS TEMPORARY UNTIL WE CAN HAVE A TYPESCRIPT VERSION THAT INCLUDE THE BASE64 <-> UINT8ARRAY CONVERSION STUFF 2 3declare global { 4 interface Uint8Array { 5 /** 6 * Converts this `Uint8Array` to a Base64 or Base64URL encoded string. 7 * 8 * @param options Optional configuration: 9 * - `alphabet`: Selects between `"base64"` (default) and `"base64url"` alphabets. 10 * - `omitPadding`: If true, omits the trailing `=` padding characters. 11 * 12 * @returns The Base64-encoded representation of the byte array. 13 * 14 * @example 15 * ```ts 16 * const bytes = new Uint8Array([72, 101, 108, 108, 111]); 17 * console.log(bytes.toBase64()); // "SGVsbG8=" 18 * ``` 19 */ 20 toBase64(options?: { alphabet?: "base64" | "base64url"; omitPadding?: boolean }): string; 21 } 22 23 interface Uint8ArrayConstructor { 24 /** 25 * Creates a `Uint8Array` from a Base64 or Base64URL encoded string. 26 * 27 * @param base64 The input string to decode. 28 * @param options Optional configuration: 29 * - `alphabet`: Selects between `"base64"` (default) and `"base64url"` alphabets. 30 * - `lastChunkHandling`: Controls how to handle incomplete input: 31 * - `"strict"` (default): Throws an error if input is not valid Base64. 32 * - `"loose"`: Tolerates missing padding or invalid trailing characters. 33 * - `"stop-before-partial"`: Ignores an incomplete trailing chunk. 34 * 35 * @returns A new `Uint8Array` containing the decoded bytes. 36 * 37 * @example 38 * ```ts 39 * const bytes = Uint8Array.fromBase64("SGVsbG8="); 40 * console.log(new TextDecoder().decode(bytes)); // "Hello" 41 * ``` 42 */ 43 fromBase64( 44 base64: string, 45 options?: { 46 alphabet?: "base64" | "base64url"; 47 lastChunkHandling?: "loose" | "strict" | "stop-before-partial"; 48 }, 49 ): Uint8Array; 50 } 51} 52 53export {};