UNPKG

@corti/dictation-web

Version:
59 lines (58 loc) 2.54 kB
/** * Returns the localized name of a language given its BCP-47 code. * * @param languageCode - The BCP-47 language code (e.g. "en") * @returns The localized language name (e.g. "English") or the original code if unavailable. */ export declare function getLanguageName(languageCode: string): string; /** * Requests access to the microphone. * * This function checks if the microphone permission is in "prompt" state, then requests * access and stops any active tracks immediately. It also logs if permission is already granted. * * @returns A promise that resolves when the permission request is complete. */ export declare function requestMicAccess(): Promise<void>; /** * Retrieves available audio input devices. * * This function uses the mediaDevices API to enumerate devices and filters out those * which are audio inputs. In some browsers, you may need to request user media before * device labels are populated. * * @returns A promise that resolves with an object containing: * - `devices`: an array of MediaDeviceInfo objects for audio inputs. * - `defaultDeviceId`: the deviceId of the first audio input, if available. */ export declare function getAudioDevices(): Promise<{ devices: MediaDeviceInfo[]; defaultDevice?: MediaDeviceInfo; }>; /** * Decodes a JWT token and extracts environment and tenant details from its issuer URL. * * This function assumes the JWT token follows the standard header.payload.signature format. * It decodes the payload from base64 URL format, parses it as JSON, and then uses a regex * to extract the `environment` and `tenant` from the issuer URL (iss field) if it matches the pattern: * https://keycloak.{environment}.corti.app/realms/{tenant}. * * @param token - A JSON Web Token (JWT) string. * @returns An object containing: * - `environment`: The extracted environment from the issuer URL. * - `tenant`: The extracted tenant from the issuer URL. * - `accessToken`: The original token string. * If the issuer URL doesn't match the expected format, the function returns the full decoded token details. * * @throws Will throw an error if: * - The token format is invalid. * - The base64 decoding or URI decoding fails. * - The JSON payload is invalid. * - The token payload does not contain an issuer (iss) field. */ export declare function decodeToken(token: string): { environment: string; tenant: string; accessToken: string; } | undefined; export declare function getMediaStream(deviceId?: string): Promise<MediaStream>;