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

@gravito/satellite-membership

v0.1.7

Published

這是 Gravito 生態系中的標準會員管理衛星模組(Satellite)。基於 **DDD (領域驅動設計)** 與 **Galaxy Architecture** 構建,專為高效能、高擴展性與 Bun 原生環境優化。

Readme

🛰️ Gravito Membership Satellite

這是 Gravito 生態系中的標準會員管理衛星模組(Satellite)。基於 DDD (領域驅動設計)Galaxy Architecture 構建,專為高效能、高擴展性與 Bun 原生環境優化。

✨ 核心功能

  • 身分驗證 (Auth): 整合 Sentinel 模組,支援 Session 登入與 持久化 (Remember Me)
  • 註冊流程: 包含自動生成驗證權杖與電子郵件發送 Hook。
  • 安全防護:
    • 多設備登入限制 (Single Device Login): 可開關功能,自動註冊並踢除舊裝置。
    • 密碼安全: 使用 Bun 原生加密,支援自動 Rehash。
    • Passkeys (WebAuthn): 內建 Passkeys 登錄 + 登入 API,可配合 @simplewebauthn/browser 與瀏覽器原生驗證器。
  • 美化郵件 (Beautiful Emails):
    • 使用 Prism 模板引擎。
    • 支援現代化 HTML 佈局。
    • 完整多語系支持 (i18n)。
  • 動態 Metadata: 會員實體支援無 Schema 的元數據擴展,適合電商、訂閱制等場景。

🚀 快速開始

... (內容省略) ...

🛠️ 擴充與自定義 (DX Guide)

想要自定義品牌、覆寫郵件樣式或增加業務邏輯?請參考我們的: 👉 Membership 擴充與自定義指南 (EXTENDING.md)

想要使用 Passkeys?請參考: 👉 Passkeys Integration Guide (PASSKEYS.md)

⚙️ 配置選項

core 配置中調整以下開關:

{
  membership: {
    auth: {
      // 是否限制帳號只能在單一裝置登入
      single_device: true, 
      // 是否啟用持久化登入 (Remember Me)
      remember_me: true
    },
    branding: {
      name: 'Your Project Name',
      primary_color: '#3b82f6' // Tailwind Blue 500
    }
  },
  app: {
    url: 'https://yourapp.com'
  }
}

🎨 自定義模板

本模組提供預設的郵件模板。如果您想更換設計,只需在您的專案中建立以下檔案,Prism 會優先使用您的檔案:

  • views/emails/welcome.html
  • views/emails/reset_password.html
  • views/emails/level_changed.html

模板中可以使用 {{ branding.name }}{{ branding.color }} 來保持一致性。

本模組不強制綁定郵件驅動,而是透過 Hook 觸發動作。若您啟用了 OrbitSignal,本模組會自動處理以下 Hook:

  • membership:send-verification: 發送註冊驗證郵件。
  • membership:send-reset-password: 發送密碼重設郵件。
  • membership:level-changed: 當會員等級提升時發送慶祝郵件。

📦 隊列整合 (Queue Integration)

為了獲得最佳效能,建議掛載 OrbitStream 來啟用非同步發信。本模組已預設呼叫 mail.queue()

1. 安裝隊列軌道

import { OrbitStream } from '@gravito/stream'

await core.orbit(new OrbitStream({
  default: 'redis',
  connections: {
    redis: { driver: 'redis', host: 'localhost' }
  }
}))

2. 運作原理

  • 有隊列時: 郵件動作會被推入 default 隊列,API 請求會立即回傳。
  • 無隊列時: 系統會自動降級為同步發送(Sync Send),確保功能不中斷。

🛠️ API 使用範例

會員註冊

const register = container.make('membership.register')
await register.execute({
  name: 'Carl',
  email: '[email protected]',
  passwordPlain: 'secret123'
})

多設備登入檢查 (Middleware)

您可以將此中間件應用於敏感路由:

import { verifySingleDevice } from '@gravito/satellite-membership/middleware'

router.get('/profile', verifySingleDevice, (c) => { ... })

📄 授權

MIT License