Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

update port

Suraja66c2450a8d2
diff --git a/packages/cli/src/api/callback.ts b/packages/cli/src/api/callback.ts
index f2cbb79107..f8ecc3162d 100644
--- a/packages/cli/src/api/callback.ts
+++ b/packages/cli/src/api/callback.ts
@@ -11,11 +11,13 @@ interface OAuthCallbackServerProps {
oauth2Client: OAuth2Client;
redirectUri: string;
spinner: Ora;
+ codeVerifier: string;
}
export function oauthCallbackServer({
oauth2Client,
redirectUri,
+ codeVerifier,
spinner,
}: OAuthCallbackServerProps) {
const server = http.createServer(async (req, res) => {
@@ -41,9 +43,6 @@ export function oauthCallbackServer({
try {
spinner.text = "Verifying";
- const config = new Configstore("dub-cli");
- const codeVerifier = config.get("code_verifier");
-
const { accessToken } = await oauth2Client.authorizationCode.getToken({
code,
redirectUri,
@@ -57,6 +56,7 @@ export function oauthCallbackServer({
domain: "dub.sh",
};
+ const config = new Configstore("dub-cli");
config.set(configInfo);
if (!config.path) {
@@ -75,8 +75,9 @@ export function oauthCallbackServer({
res.writeHead(500, { "Content-Type": "text/html" });
res.end("An error occurred during authentication. Please try again.");
} finally {
- server.close();
- process.exit(0);
+ server.close(() => {
+ process.exit(0);
+ });
}
});
@@ -85,5 +86,5 @@ export function oauthCallbackServer({
process.exit(0);
}, 300000);
- server.listen(4040);
+ server.listen(4587);
}
diff --git a/packages/cli/src/commands/login.ts b/packages/cli/src/commands/login.ts
index 306ab59349..3630a02e2e 100644
--- a/packages/cli/src/commands/login.ts
+++ b/packages/cli/src/commands/login.ts
@@ -3,7 +3,6 @@ import { getNanoid } from "@/utils/get-nanoid";
import { handleError } from "@/utils/handle-error";
import { OAuth2Client } from "@badgateway/oauth2-client";
import { Command } from "commander";
-import Configstore from "configstore";
import open from "open";
import ora from "ora";
@@ -20,10 +19,7 @@ export const login = new Command()
.action(async () => {
try {
const codeVerifier = getNanoid(64);
- const redirectUri = "http://localhost:4040/callback";
-
- const config = new Configstore("dub-cli");
- config.set("code_verifier", codeVerifier);
+ const redirectUri = "http://localhost:4587/callback";
const authUrl = await oauth2Client.authorizationCode.getAuthorizeUri({
redirectUri,
@@ -40,6 +36,7 @@ export const login = new Command()
oauthCallbackServer({
oauth2Client,
redirectUri,
+ codeVerifier,
spinner,
});
} catch (error) {