Skip to content

v1.0.0

Choose a tag to compare

@github-actions github-actions released this 23 Mar 03:48

Major Changes

  • 39ae0f4: Bump Clerk dependencies @clerk/backend and @clerk/shared to Clerk Core 3 versions.

    This release also raises the minimum supported elysia version to 1.4.0.

Minor Changes

  • 9684bc8: Introduces machine authentication, supporting four token types: api_key, oauth_token, machine_token, and session_token. For backwards compatibility, session_token remains the default when no token type is specified. This enables machine-to-machine authentication and use cases such as API keys and OAuth integrations. Existing applications continue to work without modification.

    You can specify which token types are allowed by using the acceptsToken option in the auth() function. This option can be set to a specific type, an array of types, or 'any' to accept all supported tokens.

    Example usage:

    import { clerkPlugin } from "elysia-clerk";
    
    export const app = new Elysia()
      .onError(({ code, error }) => {
        console.error(code, error);
      })
      .use(clerkPlugin())
      .get("/api/protected", ({ auth }) => {
        const authObject = auth({ acceptsToken: "any" });
    
        if (!authObject.isAuthenticated) {
          // do something for unauthenticated requests
        }
    
        if (authObject.tokenType === "session_token") {
          console.log("this is session token from a user");
        } else {
          console.log("this is some other type of machine token");
          console.log("more specifically, a " + authObject.tokenType);
        }
      })
      .listen(8080);