UNPKG

@withstudiocms/auth-kit

Version:

Utilities for managing authentication

58 lines (57 loc) 2.29 kB
interface SrvRecord { priority: number; weight: number; port: number; name: string; } interface AvatarOptions { email?: string; openid?: string; https?: boolean; [key: string]: any; } interface UserIdentity { hash: string | null; domain: string | null; } export type TargetComponents = [string | null, number | null]; /** * Return the right (target, port) pair from a list of SRV records. */ export declare const srvHostname: (records: SrvRecord[]) => TargetComponents; /** * Ensure we are getting a (mostly) valid hostname and port number * from the DNS resolver and return the final hostname:port string. */ export declare const sanitizedTarget: (targetComponents: TargetComponents, https: boolean) => string | null; /** * Generate user hash based on the email address or OpenID and return * it along with the relevant domain. */ export declare const parseUserIdentity: (email?: string, openid?: string) => UserIdentity; /** * Return the DNS service to query for a given domain and scheme. */ export declare const serviceName: (domain: string | null, https: boolean) => string | null; /** * Assemble the final avatar URL based on the provided components. */ export declare const composeAvatarUrl: (delegationServer: string | null, avatarHash: string, queryString: string, https: boolean) => string; /** * Get the delegation server for a given domain. */ export declare const getDelegationServer: (domain: string | null, https: boolean) => Promise<string | null>; /** * Generate an avatar URL for the given options. */ export declare const getAvatarUrl: (options: AvatarOptions) => Promise<string>; declare const _default: { getAvatarUrl: (options: AvatarOptions) => Promise<string>; sanitizedTarget: (targetComponents: TargetComponents, https: boolean) => string | null; srvHostname: (records: SrvRecord[]) => TargetComponents; parseUserIdentity: (email?: string, openid?: string) => UserIdentity; serviceName: (domain: string | null, https: boolean) => string | null; composeAvatarUrl: (delegationServer: string | null, avatarHash: string, queryString: string, https: boolean) => string; getDelegationServer: (domain: string | null, https: boolean) => Promise<string | null>; }; export default _default;