Class AutoDiscovery

Utilities for automatically discovery resources, such as homeservers for users to log in to.

Hierarchy

  • AutoDiscovery

Constructors

Properties

ALL_ERRORS: string[] = ...
ERROR_GENERIC_FAILURE: GenericFailure = AutoDiscoveryError.GenericFailure
ERROR_INVALID: Invalid = AutoDiscoveryError.Invalid
ERROR_INVALID_HOMESERVER: InvalidHomeserver = AutoDiscoveryError.InvalidHomeserver
ERROR_INVALID_HS_BASE_URL: InvalidHsBaseUrl = AutoDiscoveryError.InvalidHsBaseUrl
ERROR_INVALID_IDENTITY_SERVER: InvalidIdentityServer = AutoDiscoveryError.InvalidIdentityServer
ERROR_INVALID_IS: InvalidIs = AutoDiscoveryError.InvalidIs
ERROR_INVALID_IS_BASE_URL: InvalidIsBaseUrl = AutoDiscoveryError.InvalidIsBaseUrl
ERROR_INVALID_JSON: InvalidJson = AutoDiscoveryError.InvalidJson
ERROR_MISSING_WELLKNOWN: MissingWellknown = AutoDiscoveryError.MissingWellknown
FAIL_ERROR: FAIL_ERROR = AutoDiscoveryAction.FAIL_ERROR

The auto discovery failed. The client is expected to communicate the error to the user and refuse logging in.

FAIL_PROMPT: FAIL_PROMPT = AutoDiscoveryAction.FAIL_PROMPT

The auto discovery failed, however the client may still recover from the problem. The client is recommended to that the same action it would for PROMPT while also warning the user about what went wrong. The client may also treat this the same as a FAIL_ERROR state.

PROMPT: PROMPT = AutoDiscoveryAction.PROMPT

The auto discovery didn't fail but did not find anything of interest. The client is expected to prompt the user for more information, or fail if it prefers.

SUCCESS: SUCCESS = AutoDiscoveryAction.SUCCESS

The auto discovery was successful.

fetchFn?: ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>)

Type declaration

    • (input: RequestInfo | URL, init?: RequestInit): Promise<Response>
    • Parameters

      • input: RequestInfo | URL
      • Optional init: RequestInit

      Returns Promise<Response>

Methods

  • Parameters

    • resource: string | URL
    • Optional options: RequestInit

    Returns Promise<Response>

  • Internal

    Fetches a JSON object from a given URL, as expected by all .well-known related lookups. If the server gives a 404 then the action will be IGNORE. If the server returns something that isn't JSON, the action will be FAIL_PROMPT. For any other failure the action will be FAIL_PROMPT.

    The returned object will be a result of the call in object form with the following properties: raw: The JSON object returned by the server. action: One of SUCCESS, IGNORE, or FAIL_PROMPT. reason: Relatively human-readable description of what went wrong. error: The actual Error, if one exists.

    Returns

    Promise which resolves to the returned state.

    Parameters

    • url: string

      The URL to fetch a JSON object from.

    Returns Promise<IWellKnownConfig>

  • Attempts to automatically discover client configuration information prior to logging in. Such information includes the homeserver URL and identity server URL the client would want. Additional details may also be discovered, and will be transparently included in the response object unaltered.

    Returns

    Promise which resolves to the discovered configuration, which may include error states. Rejects on unexpected failure, not when discovery fails.

    Parameters

    • domain: string

      The homeserver domain to perform discovery on. For example, "matrix.org".

    Returns Promise<ClientConfig>

  • Validates and verifies client configuration information for purposes of logging in. Such information includes the homeserver URL and identity server URL the client would want. Additional details may also be included, and will be transparently brought into the response object unaltered.

    Returns

    Promise which resolves to the verified configuration, which may include error states. Rejects on unexpected failure, not when verification fails.

    Parameters

    • wellknown: IClientWellKnown

      The configuration object itself, as returned by the .well-known auto-discovery endpoint.

    Returns Promise<ClientConfig>

  • Gets the raw discovery client configuration for the given domain name. Should only be used if there's no validation to be done on the resulting object, otherwise use findClientConfig().

    Returns

    Promise which resolves to the domain's client config. Can be an empty object.

    Parameters

    • Optional domain: string

      The domain to get the client config for.

    Returns Promise<IClientWellKnown>

  • Internal

    Sanitizes a given URL to ensure it is either an HTTP or HTTP URL and is suitable for the requirements laid out by .well-known auto discovery. If valid, the URL will also be stripped of any trailing slashes.

    Returns

    The sanitized URL or a falsey value if the URL is invalid.

    Parameters

    • Optional url: null | string

      The potentially invalid URL to sanitize.

    Returns string | false

  • Parameters

    • fetchFn: ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>)
        • (input: RequestInfo | URL, init?: RequestInit): Promise<Response>
        • Parameters

          • input: RequestInfo | URL
          • Optional init: RequestInit

          Returns Promise<Response>

    Returns void

Generated using TypeDoc