npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

nanuid-websdk

v2.1.7

Published

NANU.ID WEB AUTH SDK (SW Development Kit) for WEBJS/TS

Readme

NanuID OAuth SDK

NanuID OAuth SDK는 간편하고 빠르게 OAuth 인증을 구현할 수 있도록 지원하는 라이브러리입니다.
NanuID OAuth SDK is a library designed to facilitate quick and easy OAuth authentication implementation.

⚡️ 특징 (Features)

  • JWT 토큰 검증 및 자동 갱신
    JWT token validation and automatic refresh
  • 쿠키 및 수동 토큰 관리 지원
    Cookie-based and manual token management
  • TypeScript 완벽 지원
    Full TypeScript support
  • Axios를 활용한 인증된 HTTP 클라이언트 제공
    Provides an authorized HTTP client using Axios

🛠️ 설치 (Installation)

npm install nanuid-websdk

⚖️ 사용 방법 (Usage)

🔒 토큰 검증 (Token Validation)

// 쿠키에 저장된 토큰 검증
// Validate token from cookie
const result = OAuthSDK.validateToken();

// 특정 토큰 검증
// Validate specific token
const result = OAuthSDK.validateToken('your-token');

🛠️ 토큰 관리 (Token Management)

// 저장된 액세스 토큰 가져오기
// Get stored access token
const token = OAuthSDK.getToken();
const token = OAuthSDK.getToken('manual-token');

// 토큰 갱신 (Refresh)
// Reissue access token
const newToken = await OAuthSDK.reissueToken();
const newToken = await OAuthSDK.reissueToken('refresh-token');

// 토큰 설정
// Set access and refresh tokens
OAuthSDK.setTokens(accessToken, refreshToken);

// 로그아웃 (토큰 삭제 및 리디렉션 가능)
// Logout and optionally redirect
OAuthSDK.logout();
OAuthSDK.logout('/login');

🛡️ HTTP 클라이언트 (Authorized HTTP Client)

// 인증된 Axios 클라이언트 생성
// Create authorized Axios client
const client = await OAuthSDK.createAuthorizedClient();
const client = await OAuthSDK.createAuthorizedClient('manual-token');

📘 API 레퍼런스 (API Reference)

validateToken(token?: string): TokenValidationResult

  • JWT 토큰의 유효성을 검사합니다. (형식 및 만료 여부 확인)
    Validates JWT token format and expiration.
  • 토큰이 제공되지 않으면 쿠키에서 자동으로 가져옵니다.
    Uses cookie token if none is provided.

getToken(token?: string): string | undefined

  • 특정 토큰을 반환합니다. 토큰이 제공되지 않으면 쿠키에서 가져옵니다.
    Returns the provided token or retrieves it from cookies if none is given.

reissueToken(refreshToken?: string): Promise<string | null>

  • 저장된 리프레시 토큰을 사용하여 새 액세스 토큰을 발급합니다.
    Issues a new access token using the stored refresh token.
  • 리프레시 토큰이 명시적으로 제공되지 않으면 저장된 값을 사용합니다.
    Uses stored refresh token if none is provided.

setTokens(accessToken: string, refreshToken: string, days: number = 1): void

  • 액세스 토큰을 쿠키에, 리프레시 토큰을 localStorage에 저장합니다.
    Stores the access token in cookies and the refresh token in localStorage.
  • 기본적으로 1일 동안 유지됩니다.
    Defaults to 1-day storage.

logout(redirectUrl?: string): void

  • 저장된 모든 인증 토큰을 제거합니다.
    Clears stored authentication tokens.
  • redirectUrl이 제공되면 해당 URL로 리디렉션됩니다.
    Redirects to the specified URL if provided.

createAuthorizedClient(token?: string): Promise<AxiosInstance>

  • Authorization 헤더가 자동으로 추가된 Axios 인스턴스를 생성합니다.
    Creates an Axios instance with an Authorization header.
  • 토큰이 제공되지 않으면 쿠키에서 가져온 값을 사용합니다.
    Uses the cookie token if none is provided.

🔖 타입 정의 (Types)

interface TokenValidationResult {
  isValid: boolean;
  expiresIn?: number;
  error?: string;
}

interface TokenResponse {
  access_token: string;
  refresh_token: string;
}