
배터리 포함, 완전히 플러그형 인증 라이브러리. 4가지 플로우, 토큰 저장, 갱신, 프로세스 간 락, 키체인 통합. 모든 요소를 처리하며, 모든 요소를 교체할 수 있습니다.
npm install cli-auth전략을 선택하세요. 기반 로직은 다 포함됩니다.
서버, Docker 셸, 또는 브라우저를 열 수 없는 모든 환경에 적합합니다.
1import { createCliAuth, keyringStorage } from 'cli-auth';2import { Entry } from '@napi-rs/keyring';3 4const auth = createCliAuth({5 strategy: 'device-code',6 provider: {7 metadata: {8 deviceAuthorizationEndpoint: 'https://your-tenant.logto.app/oidc/device/auth',9 tokenEndpoint: 'https://your-tenant.logto.app/oidc/token',10 },11 },12 clientId: 'your-cli-client',13 storage: keyringStorage({ entry: new Entry('your-cli', 'tokens') }),14 scope: 'openid offline_access',15});16 17await auth.login({18 onAuthorization: ({ userCode, verificationUri }) => {19 console.log(`Visit ${verificationUri} and enter ${userCode}`);20 },21});22 23const accessToken = await auth.getToken();아래의 모든 항목은 실제 버그, 경쟁 조건, 혹은 우리가 이미 해결한 명세 조항입니다.

저장, 락, fetch, 콜백 페이지 모두 후크로 제공됩니다. 하드코딩된 값은 없습니다. 슬롯을 클릭하면 설정이 바로 바뀌는 모습을 볼 수 있습니다.
저장소1import { createCliAuth } from 'cli-auth';2 3const auth = createCliAuth({4 strategy: 'authorization-code',5 provider: { /* ... */ },6 clientId: 'your-cli-client',7 storage: keyringStorage({ entry: new Entry('your-cli', 'tokens') }),8});모든 OAuth 2.0 / OIDC 호환 서버와 동작합니다. 엔드포인트만 지정하면 바로 사용할 수 있습니다. 꼭 Logto 용이 아닙니다.