Skip to content

Commit

Permalink
fix: Don't use global crypto. (#298)
Browse files Browse the repository at this point in the history
## Proposed changes

Node v18 does not have a global `crypto`, so make sure we import the
things we need.
  • Loading branch information
jmoseley authored Feb 20, 2025
1 parent cc7484e commit 8ce57d8
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/gensx-cli/src/commands/login.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { createHash } from "crypto";
import { mkdir, writeFile } from "fs/promises";
import { homedir, platform } from "os";
import { hostname } from "os";
import path from "path";

import { createHash, getRandomValues } from "node:crypto";

import { consola } from "consola";
import { stringify as stringifyIni } from "ini";
import open from "open";
Expand Down Expand Up @@ -66,9 +67,7 @@ type DeviceAuthStatus =
};

function generateVerificationCode(): string {
return Buffer.from(crypto.getRandomValues(new Uint8Array(32))).toString(
"base64url",
);
return Buffer.from(getRandomValues(new Uint8Array(32))).toString("base64url");
}

function createCodeHash(code: string): string {
Expand Down

0 comments on commit 8ce57d8

Please sign in to comment.