diff --git a/changelog.md b/changelog.md index 458d30d77..f3f982555 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,8 @@ ## [Unreleased] +- Fix subtle crypto import for node versions that ship it natively (> v15) + ## [0.1.0] - The backend implementation now uses the web fetch api instead of relying on diff --git a/packages/backend/src/util/JWT.ts b/packages/backend/src/util/JWT.ts index 68f8e879e..2a7c3a2c8 100644 --- a/packages/backend/src/util/JWT.ts +++ b/packages/backend/src/util/JWT.ts @@ -24,8 +24,11 @@ let subtle = if (!subtle) subtle = import('node:crypto') .then((c: any) => c.webcrypto.subtle) - .catch(() => import('@peculiar/webcrypto')) - .then(c => new c.Crypto().subtle as any) + .catch(() => { + return import('@peculiar/webcrypto').then( + c => new c.Crypto().subtle as any + ) + }) .catch(() => undefined) const algorithms = {