Skip to content

Commit 655403a

Browse files
committed
🐛 Fix code challenge
1 parent 7bf1885 commit 655403a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

packages/hub/src/lib/oauth-login.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { base64FromBytes } from "../../../shared/src";
12
import { HUB_URL } from "../consts";
23
import { createApiError } from "../error";
3-
import { hexFromBytes } from "../utils/hexFromBytes";
44

55
/**
66
* Use "Sign in with Hub" to authenticate a user, and get oauth user info / access token.
@@ -243,9 +243,12 @@ export async function oauthLogin(opts?: {
243243
throw new Error("Missing clientId");
244244
}
245245

246-
const challenge = hexFromBytes(
246+
const challenge = base64FromBytes(
247247
new Uint8Array(await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(newCodeVerifier)))
248-
);
248+
)
249+
.replace(/[+]/g, "-")
250+
.replace(/[/]/g, "_")
251+
.replace(/=/g, "");
249252

250253
window.location.href = `${opendidConfig.authorization_endpoint}?${new URLSearchParams({
251254
client_id: clientId,

0 commit comments

Comments
 (0)