diff --git a/src/internal/api/client.ts b/src/internal/api/client.ts index e4acfb2..b4c4c4d 100644 --- a/src/internal/api/client.ts +++ b/src/internal/api/client.ts @@ -4,10 +4,15 @@ import fetch from 'node-fetch'; import { SDK_VERSION } from '../../version'; import { type PaddleOptions } from '../types/config'; import { Environment } from './environment'; -import { randomUUID } from 'crypto'; import { Logger } from '../base/logger'; import { convertToSnakeCase } from './case-helpers'; import { type ErrorResponse } from '../types/response'; +import type { randomUUID as randomUUIDFn } from 'node:crypto'; +let randomUUID: typeof randomUUIDFn; +(async () => { + const crypto = await import('node:crypto'); + randomUUID = crypto.randomUUID; +})(); export class Client { private readonly baseUrl: string; diff --git a/src/notifications/helpers/webhooks-validator.ts b/src/notifications/helpers/webhooks-validator.ts index 3877a39..60e3f85 100644 --- a/src/notifications/helpers/webhooks-validator.ts +++ b/src/notifications/helpers/webhooks-validator.ts @@ -1,4 +1,9 @@ -import { createHmac } from 'crypto'; +import type { createHmac as createHmacFn } from 'node:crypto'; +let createHmac: typeof createHmacFn; +(async () => { + const crypto = await import('node:crypto'); + createHmac = crypto.createHmac; +})(); interface ParsedHeaders { ts: number;