Skip to content

Commit d89b32a

Browse files
fix: use accounts.clerk.com with __publishable_key param (no hostname derivation)
Agent-Logs-Url: https://github.com/highperformancecoder/minsky/sessions/7a238887-8850-4b05-95ab-e2adf8d60497 Co-authored-by: highperformancecoder <3075825+highperformancecoder@users.noreply.github.com>
1 parent 4596f7f commit d89b32a

1 file changed

Lines changed: 11 additions & 23 deletions

File tree

gui-js/apps/minsky-electron/src/app/managers/WindowManager.ts

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -386,31 +386,19 @@ export class WindowManager {
386386
}
387387

388388
static async openLoginWindow(): Promise<string | null> {
389-
// Derive the Clerk frontendApi hostname from the publishable key.
390-
// Key format: pk_<type>_<base64(frontendApi + '$')>
391-
const encoded = CLERK_PUBLISHABLE_KEY.split('_')[2] ?? '';
392-
const padded = encoded + '='.repeat((4 - (encoded.length % 4)) % 4);
393-
let frontendApi: string;
394-
try {
395-
frontendApi = Buffer.from(padded, 'base64').toString('utf8').replace(/\$$/, '');
396-
} catch {
397-
log.error('WindowManager.openLoginWindow: invalid Clerk publishable key');
398-
return Promise.resolve(null);
399-
}
400-
401-
// Open Clerk's hosted sign-in page in a dedicated BrowserWindow.
402-
// Because this window loads from HTTPS (not file://), Clerk's CDN
403-
// resources and React UI components load normally — the full standard
404-
// Clerk sign-in UI is displayed, including every configured OAuth provider.
405-
// This mirrors the approach used by @clerk/electron without requiring that
406-
// package.
389+
// Open Clerk's Accounts Portal sign-in page in a dedicated BrowserWindow.
390+
// Passing __publishable_key tells Clerk which app to authenticate against —
391+
// no hostname derivation required. Because this window loads from HTTPS
392+
// (not file://), Clerk's CDN resources and React UI components load
393+
// normally — the full standard Clerk sign-in UI is displayed, including
394+
// every configured OAuth provider.
407395
//
408-
// After successful sign-in, Clerk redirects to redirect_url ('minsky://signed-in').
409-
// We intercept that navigation with will-navigate, execute JS in the still-live
410-
// sign-in page to obtain a JWT from window.Clerk.session.getToken(), stash it,
411-
// and close the window.
396+
// After successful sign-in, Clerk redirects to redirect_url
397+
// ('minsky://signed-in'). We intercept that navigation with will-navigate,
398+
// execute JS in the still-live sign-in page to obtain a JWT from
399+
// window.Clerk.session.getToken(), stash it, and close the window.
412400
const redirectUrl = 'minsky://signed-in';
413-
const signInUrl = `https://${frontendApi}/sign-in?redirect_url=${encodeURIComponent(redirectUrl)}`;
401+
const signInUrl = `https://accounts.clerk.com/sign-in?__publishable_key=${encodeURIComponent(CLERK_PUBLISHABLE_KEY)}&redirect_url=${encodeURIComponent(redirectUrl)}`;
414402

415403
return new Promise<string>((resolve) => {
416404
const loginWindow = new BrowserWindow({

0 commit comments

Comments
 (0)