aftermath-ts-sdk - v3.3.3
    Preparing search index...

    The Auth class manages creation and refreshing of access tokens to obtain higher rate limits on the Aftermath API. It includes methods to initialize authorization either by a direct callback-based approach or by importing a local Sui keystore. Optionally, administrative functions are provided for creating specialized auth accounts.

    const auth = new Auth();
    const stopAuth = await auth.init({
    walletAddress: "0x<address>",
    signMessageCallback: async ({ message }) => {
    // sign message
    },
    });
    // ... make authenticated requests ...
    stopAuth(); // stop auto refresh

    Hierarchy (View Summary)

    Index
    config: CallerConfig

    The mutable configuration used for subsequent requests.

    • Admin-only: Creates a new auth account with specific rate limits for a given accountWalletAddress. The walletAddress performing this action must have admin privileges, or the call will fail. Use this to create custom sub-accounts with limited scope or usage rates.

      Parameters

      • inputs: {
            accountName: string;
            accountWalletAddress: string;
            rateLimits: RateLimit[];
            signMessageCallback: SignMessageCallback;
            walletAddress: string;
        }

        Contains:

        • walletAddress: The admin's wallet address
        • signMessageCallback: The admin's signing callback
        • accountName: A short name or identifier for the account
        • accountWalletAddress: The Sui address representing this sub-account
        • rateLimits: An array specifying the rate limits (method-based) for the sub-account

      Returns Promise<boolean>

      A promise resolving to true if successful, otherwise throws or returns false.

    • Initializes the auth system by fetching an access token for the provided wallet address. After obtaining the token, it automatically schedules periodic refresh calls until stopped.

      Parameters

      • inputs: { signMessageCallback: SignMessageCallback; walletAddress: string }

        An object containing the user's walletAddress and a signMessageCallback function for cryptographically signing messages.

      Returns Promise<() => void>

      A function that, when called, cancels further token refresh attempts.

      const auth = new Auth();
      const stopAuth = await auth.init({
      walletAddress: "0x<address>",
      signMessageCallback: async ({ message }) => {
      // sign the message with your private key / keypair
      },
      });

      // ... make authorized calls ...

      stopAuth(); // Cancel further token refreshes
    • Returns the canonical Aftermath API host for a Sui network.

      To target a custom or local host, pass baseUrl in CallerConfig to the constructor instead.

      Parameters

      • network: SuiNetwork

        The Sui network whose host to return.

      Returns string

      The network's HTTPS or local HTTP API host.