Files
spaces-startos/startos/actions/showSubsCredentials.ts
T
spacesopsandCursor 073344d4d1
Build Service / BuildPackage (push) Canceled after 0s
0.3.0:1
Group Actions and Config by category (Space-CLI, Bitcoin, Spaced,
Subspaces, Certrelay, Nacho) and build x86 + arm only.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-24 03:34:34 -04:00

81 lines
2.2 KiB
TypeScript

import { storeJson } from '../fileModels/storeJson'
import { actionGroups } from '../actionGroups'
import { i18n } from '../i18n'
import { sdk } from '../sdk'
import { SUBSPACES_UI_PORT } from '../utils'
export const showSubsCredentials = sdk.Action.withoutInput(
// id
'show-subs-credentials',
// metadata
async ({ effects }) => ({
name: i18n('Show Subspaces Auth Credentials'),
description: i18n(
'Display the HTTP basic auth username and password used in front of the Subspaces Web UI and Subs API. Returns blanks if no credentials have been set yet.',
),
warning: null,
allowedStatuses: 'any',
group: actionGroups.subspacesAuth,
visibility: 'enabled',
}),
// run
async ({ effects }) => {
const [subsAuth, enabled] = await Promise.all([
storeJson.read((s) => s.subsAuth).once(),
storeJson.read((s) => s.subsAuthEnabled).once(),
])
const username = subsAuth?.username ?? ''
const password = subsAuth?.password ?? ''
const status =
enabled === true
? i18n('Auth is ENABLED — these credentials are enforced.')
: i18n(
'Auth is DISABLED — subs is serving unauthenticated. These credentials will take effect when enabled.',
)
const url = subsAuth
? `http://${subsAuth.username}:${subsAuth.password}@127.0.0.1:${SUBSPACES_UI_PORT}`
: ''
return {
version: '1',
title: i18n('Show Subspaces Auth Credentials'),
message: status,
result: {
type: 'group',
value: [
{
type: 'single',
name: i18n('SUBS_BASIC_AUTH_USER'),
description: null,
value: username,
masked: false,
copyable: true,
qr: false,
},
{
type: 'single',
name: i18n('SUBS_BASIC_AUTH_PASSWORD'),
description: null,
value: password,
masked: true,
copyable: true,
qr: false,
},
{
type: 'single',
name: i18n('Connection URL'),
description: null,
value: url,
masked: true,
copyable: true,
qr: false,
},
],
},
}
},
)