@folderharbor/sdk
    Preparing search index...

    Class FolderHarbor

    Core SDK for FolderHarbor's API!

    Full docs: https://folderharbor.github.io/ts-sdk

    // no auth token
    const client = new FolderHarbor({ server: "https://demo.fh.novatea.dev" });
    // with auth token
    const client = new FolderHarbor({ server: "https://demo.fh.novatea.dev", token: "[your token]" });

    If the details passed in the constructor are invalid

    Constructors

    Properties

    auth: {
        login: (body: FHLogin) => Promise<FHLoginRes>;
        logout: () => Promise<void>;
        register: (body: FHLogin) => Promise<FHLoginRes>;
    } = ...

    Methods to manage user authentication.

    Type Declaration

    • login: (body: FHLogin) => Promise<FHLoginRes>

      Logs in to a FolderHarbor server using user credentials.

      If anything went wrong, either in the process of requesting, or in the response from the server

      const session = await client.auth.login({ username: "test", password: "meow", persist: false });
      
    • logout: () => Promise<void>

      Logs out and invalidates the session token.

      If your session is invalid, expired, or for a locked account

      If anything else went wrong, either in the process of requesting, or in the response from the server

      await client.auth.logout();
      
    • register: (body: FHLogin) => Promise<FHLoginRes>

      Registers for a new account on a FolderHarbor server. Note that this will error if the server doesn't have registration enabled! I recommend calling FolderHarbor#clientconfig() and checking that registration is enabled.

      If anything went wrong, either in the process of requesting, or in the response from the server

      const session = await client.auth.register({ username: "mrrp", password: "example123", persist: true });
      

    Methods

    • Gets information from the server that is important client-side.

      Returns Promise<FHClientConfig>

      The "client configuration" from the server

      If anything went wrong, either in the process of requesting, or in the response from the server

      const info = await client.clientconfig();
      
    • Gets the connection URLs for different file-transferring protocols.

      Returns Promise<FHProtocols>

      The connection URLs for any enabled protocols, and null for disabled ones

      If your session is invalid, expired, or for a locked account

      If anything went wrong, either in the process of requesting, or in the response from the server

      const urls = await client.protocols();
      
    • Request wrapper for the other methods, used internally

      Type Parameters

      • T

      Parameters

      • path: string

        The path to fetch on the server, without a leading slash!

      • Optionalinit: RequestInit

        A request body, this uses the same syntax as the Fetch API

      Returns Promise<T>

      The object returned from the API, matching the type that was used in the call

      If your session is invalid, expired, or for a locked account

      If you don't have permission to take a given admin action

      If anything else went wrong, either in the process of requesting, or in the response from the server

      const body = await client.request<{ token: string }>("auth", { method: "POST", body: JSON.stringify({ username: "test", password: "example" }) });