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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@hm-soft/account-lock

v0.1.0

Published

로그인 브루트포스 방지/계정 잠금 정책 — 저장소 비의존 순수 상태 계산 (고정/지수 백오프, 시도 윈도우)

Downloads

66

Readme

@hm-soft/account-lock

로그인 브루트포스 공격을 막는 계정 잠금 정책. 저장소에 의존하지 않는 순수 상태 계산이라, 잠금 상태를 어디에(DB·Redis 등) 저장하든 끼워 넣을 수 있습니다.

설치

npm install @hm-soft/account-lock

사용

import { initialState, isLocked, recordFailure, recordSuccess } from "@hm-soft/account-lock";

const policy = { maxAttempts: 5, lockDurationMs: 15 * 60 * 1000 };

// 로그인 시도
let state = user.lockState ?? initialState();

if (isLocked(state)) {
  throw new Error("계정이 잠겼습니다. 잠시 후 다시 시도하세요.");
}

if (await checkPassword(input)) {
  await db.save(userId, { lockState: recordSuccess() }); // 성공 → 리셋
} else {
  const r = recordFailure(state, policy);
  await db.save(userId, { lockState: r.state });          // 새 상태 저장
  if (r.locked) {
    throw new Error(`${Math.ceil(r.retryAfterMs / 1000)}초 후 다시 시도하세요.`);
  }
  throw new Error(`비밀번호가 틀렸습니다. ${r.remainingAttempts}회 남음.`);
}

API

| 함수 | 설명 | |------|------| | initialState() | 빈 잠금 상태 | | isLocked(state, now?) | 현재 잠김 여부 | | msUntilUnlock(state, now?) | 잠금 해제까지 남은 ms | | recordFailure(state, policy?, now?) | 실패 1건 기록 → { state, locked, retryAfterMs, remainingAttempts, lockedUntil } | | recordSuccess() | 성공 시 상태 초기화 |

LockPolicy

| 옵션 | 기본값 | 설명 | |------|--------|------| | maxAttempts | 5 | 잠기기까지 허용 실패 횟수 | | lockDurationMs | 15분 | 잠금 지속 시간 | | attemptWindowMs | — | 이 시간 내 새 실패 없으면 횟수 리셋 | | backoff | "fixed" | "exponential"이면 반복 잠금마다 시간 2배 | | maxLockDurationMs | — | 지수 백오프 시간 상한 |

특징

  • 저장소 비의존LockState는 숫자뿐이라 그대로 직렬화/저장 가능
  • 테스트 용이now를 주입할 수 있어 시간 의존 로직도 결정적으로 테스트
  • 고정/지수 백오프 — 단순 잠금부터 반복 공격 점증 차단까지

License

Apache-2.0