Auth

Authentication providers for API keys and OAuth.

Interactive Demo

Authenticate with API key

Try "demo-key-123" for a valid token.

Code Example

auth-demo.ts
import { ApiKeyAuthProvider, OAuthProvider } from "@shivamsharma11/agent-sdk";

// API Key Auth
const apiKeyStore = {
  findByToken: async (token: string) => {
    if (token === "valid-key") {
      return { id: "user-1", scopes: ["read", "write"] };
    }
    return null;
  },
};

const authProvider = new ApiKeyAuthProvider(apiKeyStore);
const principal = await authProvider.authenticate({
  token: "valid-key",
});

// OAuth Provider (placeholder - requires OAuth verifier adapter)
const oauthProvider = new OAuthProvider();