@orello/auth
v1.0.7
Published
Authentication package for Orello.
Downloads
859
Maintainers
Readme
@orello/auth
A lightweight, type-safe authentication provider for Orello applications. Built to simplify OAuth integration with Orello accounts.
Features
- Simple Redirect: Easy-to-use method to initiate the Orello OAuth flow.
- Token Exchange: Standardized handling of authorization codes for access tokens.
- User Info Retrieval: Fetch authenticated user profiles with a single call.
- TypeScript First: Full type safety for authentication configurations and responses.
Installation
pnpm add @orello/auth
# or
npm install @orello/authQuick Start
Basic Configuration
import { OrelloAuthProvider } from "@orello/auth";
const auth = new OrelloAuthProvider({
clientKey: process.env.ORELLO_CLIENT_KEY,
clientSecret: process.env.ORELLO_CLIENT_SECRET, // Required for handleCallback
redirectUri: "https://your-app.com/callback",
scope: "openid profile email" // Optional
});Authentication Flow
1. Redirect to Orello
// This will redirect the user to Orello's login page
await auth.continueWithOrello();2. Handle Callback
// On your redirect page, get the 'code' from URL params
const code = new URLSearchParams(window.location.search).get("code");
if (code) {
const tokens = await auth.handleCallback(code);
console.log("Access Token:", tokens.access_token);
}3. Get User Information
const user = await auth.getUser(tokens.access_token);
console.log("Logged in user:", user.name);Contributing
Please see CONTRIBUTING.md for details on how to get involved.
License
MIT © HB Group
