Changeset d43230f in Klonkt


Ignore:
Timestamp:
07/21/2026 01:17:03 AM (7 weeks ago)
Author:
Robin <roboburr@…>
Branches:
main
Children:
6cbd014
Parents:
9e9e6f9
git-author:
Robin Genis <roboburr@…> (07/21/2026 01:17:02 AM)
git-committer:
Robin <roboburr@…> (07/21/2026 01:17:03 AM)
Message:

Harden: lazy-load @simplewebauthn/server so a missing dep never crashes boot

A canary that autofollows main before npm ci has run (or if it fails) would otherwise crash on the static import. The paid flow now imports the lib on first use, so only that flow degrades until the dependency is installed.

Co-Authored-By: Claude Opus 4.8 <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/services/PasskeyService.js

    r9e9e6f9 rd43230f  
    77import crypto from 'crypto';
    88import db from '../config/database.js';
    9 import { generateRegistrationOptions, verifyRegistrationResponse } from '@simplewebauthn/server';
     9
     10// Lazy so a not-yet-installed dependency can never crash app boot; only the
     11// paid passkey flow fails until `npm ci` has run.
     12let _lib = null;
     13async function lib() { if (!_lib) _lib = await import('@simplewebauthn/server'); return _lib; }
    1014
    1115const DEFAULT_TTL_DAYS = 32;   // aligns with Patreon's monthly cycle; re-link after
     
    2125export async function registrationOptions(base, siteSlug) {
    2226  const { rpID } = rpFor(base);
     27  const { generateRegistrationOptions } = await lib();
    2328  return generateRegistrationOptions({
    2429    rpName: `Supporter of ${siteSlug}`,
     
    3944  let v;
    4045  try {
     46    const { verifyRegistrationResponse } = await lib();
    4147    v = await verifyRegistrationResponse({
    4248      response,
Note: See TracChangeset for help on using the changeset viewer.