Skip to content

Commit 1121c4a

Browse files
committed
feat: add new connector settings for web auth
1 parent 7e5e224 commit 1121c4a

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

app/composables/useConnector.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ const STORAGE_KEY = 'npmx-connector'
5757
const DEFAULT_PORT = 31415
5858

5959
export const useConnector = createSharedComposable(function useConnector() {
60+
const { settings } = useSettings()
61+
6062
// Persisted connection config
6163
const config = useState<{ token: string; port: number } | null>('connector-config', () => null)
6264

@@ -303,7 +305,11 @@ export const useConnector = createSharedComposable(function useConnector() {
303305
ApiResponse<{ results: unknown[]; otpRequired?: boolean }>
304306
>('/execute', {
305307
method: 'POST',
306-
body: otp ? { otp } : undefined,
308+
body: {
309+
otp,
310+
interactive: settings.value.connector.webAuth,
311+
openUrls: settings.value.connector.autoOpenURL,
312+
},
307313
})
308314
if (response?.success) {
309315
await refreshState()

app/composables/useSettings.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ export interface AppSettings {
2929
selectedLocale: LocaleObject['code'] | null
3030
/** Search provider for package search */
3131
searchProvider: SearchProvider
32+
/** Connector preferences */
33+
connector: {
34+
/** Use web-based authentication instead of CLI token */
35+
webAuth: boolean
36+
/** Automatically open the web auth page in the browser */
37+
autoOpenURL: boolean
38+
}
3239
sidebar: {
3340
collapsed: string[]
3441
}
@@ -42,6 +49,10 @@ const DEFAULT_SETTINGS: AppSettings = {
4249
selectedLocale: null,
4350
preferredBackgroundTheme: null,
4451
searchProvider: import.meta.test ? 'npm' : 'algolia',
52+
connector: {
53+
webAuth: false,
54+
autoOpenURL: false,
55+
},
4556
sidebar: {
4657
collapsed: [],
4758
},

0 commit comments

Comments
 (0)