@passkeykit/server 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,9 +10,19 @@ Handles challenge generation, attestation/assertion verification, and includes s
10
10
  ## Install
11
11
 
12
12
  ```bash
13
- npm install @passkeykit/server
13
+ npm install @passkeykit/server @simplewebauthn/server
14
14
  ```
15
15
 
16
+ > `@simplewebauthn/server` is a **peer dependency** — you control the version. This keeps the package itself lightweight while giving you full WebAuthn verification.
17
+ >
18
+ > **Password-only?** If you only need `hashPassword` / `verifyPassword`, import from the subpath — no WebAuthn dependency required:
19
+ > ```bash
20
+ > npm install @passkeykit/server
21
+ > ```
22
+ > ```typescript
23
+ > import { hashPassword, verifyPassword } from '@passkeykit/server/password';
24
+ > ```
25
+
16
26
  ## Quick Start
17
27
 
18
28
  ### Stateless (Serverless / Vercel / Cloudflare)
@@ -217,11 +227,12 @@ interface PasskeyServerConfig {
217
227
 
218
228
  ## Exports
219
229
 
220
- | Import Path | Contents |
221
- |-------------|----------|
222
- | `@passkeykit/server` | `PasskeyServer`, stores, password hashing, types |
223
- | `@passkeykit/server/express` | `createExpressRoutes()` — ready-made Express router |
224
- | `@passkeykit/server/argon2` | `hashPassword()`, `verifyPassword()`native argon2id |
230
+ | Import Path | Contents | Requires |
231
+ |-------------|----------|----------|
232
+ | `@passkeykit/server` | `PasskeyServer`, stores, password hashing, types | `@simplewebauthn/server` |
233
+ | `@passkeykit/server/password` | `hashPassword()`, `verifyPassword()`, `needsRehash()` scrypt | None (pure JS) |
234
+ | `@passkeykit/server/express` | `createExpressRoutes()` — ready-made Express router | `express` |
235
+ | `@passkeykit/server/argon2` | `hashPassword()`, `verifyPassword()` — native argon2id | `argon2` |
225
236
 
226
237
  ## Client Pairing
227
238
 
package/dist/esm/index.js CHANGED
@@ -4,10 +4,6 @@
4
4
  * Server-side WebAuthn passkey verification with challenge-response pattern
5
5
  * and scrypt password hashing (pure JS, works everywhere).
6
6
  *
7
- * @ai_context This is the core auth library used across all dnldev apps.
8
- * Challenge generation and verification MUST happen server-side.
9
- * Client never sees raw challenges — only attestation/assertion responses.
10
- *
11
7
  * Two modes:
12
8
  * - **Stateless** (default): No server-side state. Set `encryptionKey` in config.
13
9
  * - **Stateful**: Provide a `challengeStore` (memory, file, Redis, etc).
@@ -12,7 +12,7 @@
12
12
  * $scrypt$ln=17,r=8,p=1$<base64salt>$<base64hash>
13
13
  */
14
14
  import { scrypt as scryptSync } from '@noble/hashes/scrypt';
15
- import { randomBytes } from 'crypto';
15
+ import { randomBytes, timingSafeEqual as tse } from 'crypto';
16
16
  /** Default scrypt parameters (OWASP recommendations for interactive login) */
17
17
  const DEFAULTS = {
18
18
  N: 2 ** 17, // 131072 — CPU/memory cost
@@ -76,6 +76,5 @@ function parsePhc(phc) {
76
76
  function timingSafeEqual(a, b) {
77
77
  if (a.length !== b.length)
78
78
  return false;
79
- const { timingSafeEqual: tse } = require('crypto');
80
79
  return tse(a, b);
81
80
  }
@@ -1,9 +1,8 @@
1
1
  /**
2
2
  * Built-in store implementations for common backends.
3
3
  *
4
- * @ai_context These are convenience implementations. For production with
5
- * multiple server instances, use a shared store (Redis, database, Firestore).
6
- * For single-server apps (like MovieBox, MediaBox), FileStore works great.
4
+ * For production with multiple server instances, implement the ChallengeStore
5
+ * and CredentialStore interfaces with a shared backend (Redis, database, etc).
7
6
  */
8
7
  import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'fs';
9
8
  import { dirname } from 'path';
@@ -54,7 +53,6 @@ export class MemoryCredentialStore {
54
53
  * File-based challenge store. Challenges are stored in a JSON file.
55
54
  * Auto-cleans expired challenges on every operation.
56
55
  *
57
- * @ai_context Used by MovieBox/MediaBox which store auth in auth.json.
58
56
  * Not suitable for multi-process servers (race conditions on file writes).
59
57
  */
60
58
  export class FileChallengeStore {
package/dist/esm/types.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Type definitions for @passkeykit/server
3
3
  *
4
- * @ai_context These types define the storage interface abstraction.
4
+ * These types define the storage interface abstraction.
5
5
  * Apps provide their own ChallengeStore and CredentialStore implementations
6
- * so the library works with any backend (Firestore, file JSON, SQLite, etc).
6
+ * so the library works with any backend (Firestore, file JSON, SQLite, Redis, etc).
7
7
  */
8
8
  export {};
package/dist/index.d.ts CHANGED
@@ -4,10 +4,6 @@
4
4
  * Server-side WebAuthn passkey verification with challenge-response pattern
5
5
  * and scrypt password hashing (pure JS, works everywhere).
6
6
  *
7
- * @ai_context This is the core auth library used across all dnldev apps.
8
- * Challenge generation and verification MUST happen server-side.
9
- * Client never sees raw challenges — only attestation/assertion responses.
10
- *
11
7
  * Two modes:
12
8
  * - **Stateless** (default): No server-side state. Set `encryptionKey` in config.
13
9
  * - **Stateful**: Provide a `challengeStore` (memory, file, Redis, etc).
package/dist/index.js CHANGED
@@ -5,10 +5,6 @@
5
5
  * Server-side WebAuthn passkey verification with challenge-response pattern
6
6
  * and scrypt password hashing (pure JS, works everywhere).
7
7
  *
8
- * @ai_context This is the core auth library used across all dnldev apps.
9
- * Challenge generation and verification MUST happen server-side.
10
- * Client never sees raw challenges — only attestation/assertion responses.
11
- *
12
8
  * Two modes:
13
9
  * - **Stateless** (default): No server-side state. Set `encryptionKey` in config.
14
10
  * - **Stateful**: Provide a `challengeStore` (memory, file, Redis, etc).
package/dist/password.js CHANGED
@@ -81,6 +81,5 @@ function parsePhc(phc) {
81
81
  function timingSafeEqual(a, b) {
82
82
  if (a.length !== b.length)
83
83
  return false;
84
- const { timingSafeEqual: tse } = require('crypto');
85
- return tse(a, b);
84
+ return (0, crypto_1.timingSafeEqual)(a, b);
86
85
  }
package/dist/stores.d.ts CHANGED
@@ -1,9 +1,8 @@
1
1
  /**
2
2
  * Built-in store implementations for common backends.
3
3
  *
4
- * @ai_context These are convenience implementations. For production with
5
- * multiple server instances, use a shared store (Redis, database, Firestore).
6
- * For single-server apps (like MovieBox, MediaBox), FileStore works great.
4
+ * For production with multiple server instances, implement the ChallengeStore
5
+ * and CredentialStore interfaces with a shared backend (Redis, database, etc).
7
6
  */
8
7
  import type { ChallengeStore, CredentialStore, StoredChallenge, StoredCredential } from './types.js';
9
8
  export declare class MemoryChallengeStore implements ChallengeStore {
@@ -23,7 +22,6 @@ export declare class MemoryCredentialStore implements CredentialStore {
23
22
  * File-based challenge store. Challenges are stored in a JSON file.
24
23
  * Auto-cleans expired challenges on every operation.
25
24
  *
26
- * @ai_context Used by MovieBox/MediaBox which store auth in auth.json.
27
25
  * Not suitable for multi-process servers (race conditions on file writes).
28
26
  */
29
27
  export declare class FileChallengeStore implements ChallengeStore {
package/dist/stores.js CHANGED
@@ -2,9 +2,8 @@
2
2
  /**
3
3
  * Built-in store implementations for common backends.
4
4
  *
5
- * @ai_context These are convenience implementations. For production with
6
- * multiple server instances, use a shared store (Redis, database, Firestore).
7
- * For single-server apps (like MovieBox, MediaBox), FileStore works great.
5
+ * For production with multiple server instances, implement the ChallengeStore
6
+ * and CredentialStore interfaces with a shared backend (Redis, database, etc).
8
7
  */
9
8
  Object.defineProperty(exports, "__esModule", { value: true });
10
9
  exports.FileCredentialStore = exports.FileChallengeStore = exports.MemoryCredentialStore = exports.MemoryChallengeStore = void 0;
@@ -59,7 +58,6 @@ exports.MemoryCredentialStore = MemoryCredentialStore;
59
58
  * File-based challenge store. Challenges are stored in a JSON file.
60
59
  * Auto-cleans expired challenges on every operation.
61
60
  *
62
- * @ai_context Used by MovieBox/MediaBox which store auth in auth.json.
63
61
  * Not suitable for multi-process servers (race conditions on file writes).
64
62
  */
65
63
  class FileChallengeStore {
package/dist/types.d.ts CHANGED
@@ -1,18 +1,18 @@
1
1
  /**
2
2
  * Type definitions for @passkeykit/server
3
3
  *
4
- * @ai_context These types define the storage interface abstraction.
4
+ * These types define the storage interface abstraction.
5
5
  * Apps provide their own ChallengeStore and CredentialStore implementations
6
- * so the library works with any backend (Firestore, file JSON, SQLite, etc).
6
+ * so the library works with any backend (Firestore, file JSON, SQLite, Redis, etc).
7
7
  */
8
8
  import type { AuthenticatorTransportFuture } from '@simplewebauthn/server';
9
9
  /** Configuration for PasskeyServer */
10
10
  export interface PasskeyServerConfig {
11
- /** Relying Party name shown to users (e.g. "MovieBox", "SafeHarbor") */
11
+ /** Relying Party name shown to users (e.g. "My App") */
12
12
  rpName: string;
13
- /** Relying Party ID — must be a valid domain (e.g. "movies.danieltech.dev") */
13
+ /** Relying Party ID — must be a valid domain (e.g. "auth.example.com") */
14
14
  rpId: string;
15
- /** Allowed origins for WebAuthn (e.g. ["https://movies.danieltech.dev"]) */
15
+ /** Allowed origins for WebAuthn (e.g. ["https://example.com"]) */
16
16
  allowedOrigins: string[];
17
17
  /**
18
18
  * Challenge store implementation (stateful mode).
package/dist/types.js CHANGED
@@ -2,8 +2,8 @@
2
2
  /**
3
3
  * Type definitions for @passkeykit/server
4
4
  *
5
- * @ai_context These types define the storage interface abstraction.
5
+ * These types define the storage interface abstraction.
6
6
  * Apps provide their own ChallengeStore and CredentialStore implementations
7
- * so the library works with any backend (Firestore, file JSON, SQLite, etc).
7
+ * so the library works with any backend (Firestore, file JSON, SQLite, Redis, etc).
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@passkeykit/server",
3
- "version": "2.0.1",
4
- "description": "Server-side WebAuthn passkey verification \u2014 stateless or stateful, pure JS, works on serverless",
3
+ "version": "2.1.0",
4
+ "description": "Server-side WebAuthn passkey verification stateless or stateful, pure JS, works on serverless",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/esm/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -11,6 +11,11 @@
11
11
  "require": "./dist/index.js",
12
12
  "types": "./dist/index.d.ts"
13
13
  },
14
+ "./password": {
15
+ "import": "./dist/esm/password.js",
16
+ "require": "./dist/password.js",
17
+ "types": "./dist/password.d.ts"
18
+ },
14
19
  "./express": {
15
20
  "import": "./dist/esm/express-routes.js",
16
21
  "require": "./dist/express-routes.js",
@@ -49,14 +54,17 @@
49
54
  ],
50
55
  "license": "MIT",
51
56
  "dependencies": {
52
- "@simplewebauthn/server": "^13.1.1",
53
57
  "@noble/hashes": "^1.7.0"
54
58
  },
55
59
  "peerDependencies": {
60
+ "@simplewebauthn/server": "^13.0.0",
56
61
  "express": "^4.0.0 || ^5.0.0",
57
62
  "argon2": "^0.41.0"
58
63
  },
59
64
  "peerDependenciesMeta": {
65
+ "@simplewebauthn/server": {
66
+ "optional": false
67
+ },
60
68
  "express": {
61
69
  "optional": true
62
70
  },