47 lines
1.7 KiB
TypeScript
47 lines
1.7 KiB
TypeScript
/**
|
|
* Avoid modifying this file. It's part of
|
|
* https://github.com/supabase-community/base64url-js. Submit all fixes on
|
|
* that repo!
|
|
*/
|
|
/**
|
|
* Converts a JavaScript string (which may include any valid character) into a
|
|
* Base64-URL encoded string. The string is first encoded in UTF-8 which is
|
|
* then encoded as Base64-URL.
|
|
*
|
|
* @param str The string to convert.
|
|
*/
|
|
export declare function stringToBase64URL(str: string): string;
|
|
/**
|
|
* Converts a Base64-URL encoded string into a JavaScript string. It is assumed
|
|
* that the underlying string has been encoded as UTF-8.
|
|
*
|
|
* @param str The Base64-URL encoded string.
|
|
*/
|
|
export declare function stringFromBase64URL(str: string): string;
|
|
/**
|
|
* Converts a Unicode codepoint to a multi-byte UTF-8 sequence.
|
|
*
|
|
* @param codepoint The Unicode codepoint.
|
|
* @param emit Function which will be called for each UTF-8 byte that represents the codepoint.
|
|
*/
|
|
export declare function codepointToUTF8(codepoint: number, emit: (byte: number) => void): void;
|
|
/**
|
|
* Converts a JavaScript string to a sequence of UTF-8 bytes.
|
|
*
|
|
* @param str The string to convert to UTF-8.
|
|
* @param emit Function which will be called for each UTF-8 byte of the string.
|
|
*/
|
|
export declare function stringToUTF8(str: string, emit: (byte: number) => void): void;
|
|
/**
|
|
* Converts a UTF-8 byte to a Unicode codepoint.
|
|
*
|
|
* @param byte The UTF-8 byte next in the sequence.
|
|
* @param state The shared state between consecutive UTF-8 bytes in the
|
|
* sequence, an object with the shape `{ utf8seq: 0, codepoint: 0 }`.
|
|
* @param emit Function which will be called for each codepoint.
|
|
*/
|
|
export declare function stringFromUTF8(byte: number, state: {
|
|
utf8seq: number;
|
|
codepoint: number;
|
|
}, emit: (codepoint: number) => void): void;
|