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 🙏

© 2024 – Pkg Stats / Ryan Hefner

custody-wallet-common

v1.0.11

Published

- Common Database(Entity) - network - asset - JWT - OTP - Logging

Downloads

36

Readme

Custody Wallet Common 모듈

  • Common Database(Entity)
    • network
    • asset
  • JWT
  • OTP
  • Logging

설치

npm install custody-wallet-common

모듈 구성

  1. JWT 모듈

    • JWT 토큰 생성, 검증, 추출 기능 제공
    • JwtService를 통한 토큰 관리
  2. OTP 모듈

    • 일회용 비밀번호 생성 및 검증
    • OTP 인증 URL 생성
    • OtpService를 통한 OTP 관리
  3. Loggin 모듈

JWT 모듈

사용법

import { JwtModule } from 'custody-wallet-common';

@Module({
  imports: [
    JwtModule.forRoot({
      secret: 'your-secret-key',
      signOptions: { expiresIn: '1h' },
    }),
    // 또는 비동기 구성을 위해
    JwtModule.forRootAsync({
      imports: [ConfigModule],
      useFactory: async (configService: ConfigService) => ({
        secret: configService.get('JWT_SECRET'),
        signOptions: { expiresIn: configService.get('JWT_EXPIRES_IN') },
      }),
      inject: [ConfigService],
    }),
  ],
})
export class AppModule {}

서비스에서 JwtService를 주입 후 사용:

constructor(private jwtService: JwtService) {}

async someMethod() {
  const token = await this.jwtService.generateToken({ userId: 1 });
  const payload = await this.jwtService.verifyToken(token);
}

OTP 모듈

OTP 모듈은 일회용 비밀번호 생성 및 검증, OTP 인증 URL 생성 기능을 제공합니다.

사용법

import { OtpModule } from 'custody-wallet-common';

@Module({
  imports: [
    OtpModule.forRoot({
      issuer: '귀하의 회사',
      appName: '귀하의 앱',
    }),
    // 또는 비동기 구성을 위해
    OtpModule.forRootAsync({
      imports: [ConfigModule],
      useFactory: async (configService: ConfigService) => ({
        issuer: configService.get('OTP_ISSUER'),
        appName: configService.get('OTP_APP_NAME'),
      }),
      inject: [ConfigService],
    }),
  ],
})
export class AppModule {}

서비스에서 OtpService를 주입 후 사용:

constructor(private otpService: OtpService) {}

async setupOtp(email: string) {
  const { secret, otpAuthUrl } = this.otpService.setupOtp(email);
  // secret을 안전하게 저장하고 otpAuthUrl을 클라이언트에 반환
}

verifyOtp(token: string, secret: string) {
  return this.otpService.verifyToken(token, secret);
}

API 참조

JwtService

  • generateToken(payload: Buffer | object): Promise<string>
    • JWT 토큰을 생성합니다.
  • verifyToken(token: string): Promise<JwtPayload>
    • JWT 토큰을 검증하고 페이로드를 반환합니다.
  • extractToken(request: Request): string | undefined
    • 요청 헤더에서 JWT 토큰을 추출합니다.

OtpService

  • generateSecret(): string
    • OTP 비밀키를 생성합니다.
  • generateToken(secret: string): string
    • OTP 토큰을 생성합니다.
  • verifyToken(token: string, secret: string): boolean
    • OTP 토큰을 검증합니다.
  • generateOtpAuthUrl(email: string, secret: string): string
    • OTP 인증 URL을 생성합니다.
  • setupOtp(email: string): { secret: string; otpAuthUrl: string }
    • OTP 설정에 필요한 비밀키와 인증 URL을 생성합니다.