@last1id/sdk
v0.1.0
Published
Zero-to-login OIDC SDK for Last1 ID
Downloads
28
Readme
@last1id/sdk
Zero-to-login SDK for Last1 ID OIDC Authorization Code + PKCE.
Install
npm install @last1id/sdkUsage
import { createPkcePair, buildAuthorizeUrl, exchangeCode } from "@last1id/sdk";
const pkce = await createPkcePair();
const authorizeUrl = buildAuthorizeUrl(
{
issuerUrl: "https://id.last1.com",
clientId: process.env.LAST1_CLIENT_ID!,
redirectUri: "https://app.example.com/auth/callback",
scopes: ["openid", "profile", "offline_access"]
},
pkce
);
// Redirect user to authorizeUrl, then exchange code in callback route.
const tokenSet = await exchangeCode({
issuerUrl: "https://id.last1.com",
clientId: process.env.LAST1_CLIENT_ID!,
clientSecret: process.env.LAST1_CLIENT_SECRET!,
redirectUri: "https://app.example.com/auth/callback",
code: "AUTH_CODE",
codeVerifier: pkce.codeVerifier
});
createPkcePair()uses Web Crypto and returns a Promise. It works in modern browsers and Node 20+.
