Skip to content

Commit 2ee862d

Browse files
committed
šŸ› Use randomUUID util
1 parent fb39d95 commit 2ee862d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ā€Žpackages/hub/src/lib/oauth-login-url.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { base64FromBytes } from "../../../shared/src";
22
import { HUB_URL } from "../consts";
33
import { createApiError } from "../error";
4+
import { randomUUID } from "../utils/randomUUID";
45

56
/**
67
* Use "Sign in with Hub" to authenticate a user, and get oauth user info / access token.
@@ -87,9 +88,9 @@ export async function oauthLoginUrl(opts?: {
8788
userinfo_endpoint: string;
8889
} = await openidConfigRes.json();
8990

90-
const newNonce = crypto.randomUUID();
91+
const newNonce = await randomUUID();
9192
// Two random UUIDs concatenated together, because min length is 43 and max length is 128
92-
const newCodeVerifier = crypto.randomUUID() + crypto.randomUUID();
93+
const newCodeVerifier = (await randomUUID()) + (await randomUUID());
9394

9495
localStorage.setItem("huggingface.co:oauth:nonce", newNonce);
9596
localStorage.setItem("huggingface.co:oauth:code_verifier", newCodeVerifier);

0 commit comments

Comments
Ā (0)