From 503f0798e6a6ba44b11d0826b2886565c7944c19 Mon Sep 17 00:00:00 2001 From: Innei Date: Fri, 21 Jun 2024 20:03:27 +0800 Subject: [PATCH] fix: crypto compatible Signed-off-by: Innei --- apps/core/src/modules/authn/authn.service.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/core/src/modules/authn/authn.service.ts b/apps/core/src/modules/authn/authn.service.ts index 465e4550..3178b593 100644 --- a/apps/core/src/modules/authn/authn.service.ts +++ b/apps/core/src/modules/authn/authn.service.ts @@ -27,9 +27,11 @@ import type { VerifiedRegistrationResponse, } from '@simplewebauthn/server' -// TODO support below the node v20 - -globalThis.crypto = require('node:crypto') +// TODO Compatible with versions below node v20 +if (!globalThis.crypto) { + // eslint-disable-next-line @typescript-eslint/no-var-requires + globalThis.crypto = require('node:crypto').webcrypto +} @Injectable() export class AuthnService { constructor(