Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Cloudflare with dynamic import for 'node:crypto' #10

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/internal/api/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion src/notifications/helpers/webhooks-validator.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down