typescript-sdk/vitest.setup.ts
Konstantin Konstantinov 4fb4d4d55e
SEP-1046: Client credentials flow for M2M without user interaction (#1157)
Co-authored-by: Paul Carleton <paulc@anthropic.com>
2025-11-28 17:01:15 +00:00

8 lines
446 B
TypeScript

import { webcrypto } from 'node:crypto';
// Polyfill globalThis.crypto for environments (e.g. Node 18) where it is not defined.
// This is necessary for the tests to run in Node 18, specifically for the jose library, which relies on the globalThis.crypto object.
if (typeof globalThis.crypto === 'undefined') {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(globalThis as any).crypto = webcrypto as unknown as Crypto;
}