import { storeJson } from '../fileModels/storeJson' import { actionGroups } from '../actionGroups' import { i18n } from '../i18n' import { sdk } from '../sdk' import { SUBSPACES_PROVER_PORT } from '../utils' export const showSubsProverCredentials = sdk.Action.withoutInput( // id 'show-subs-prover-credentials', // metadata async ({ effects }) => ({ name: i18n('Show Subspaces Prover Auth Credentials'), description: i18n( 'Display the HTTP basic auth username and password used in front of the Subspaces Prover. Returns blanks if no credentials have been set yet.', ), warning: null, allowedStatuses: 'any', group: actionGroups.subspacesProverAuth, visibility: 'enabled', }), // run async ({ effects }) => { const [subsProverAuth, enabled] = await Promise.all([ storeJson.read((s) => s.subsProverAuth).once(), storeJson.read((s) => s.subsProverAuthEnabled).once(), ]) const username = subsProverAuth?.username ?? '' const password = subsProverAuth?.password ?? '' const status = enabled === true ? i18n('Auth is ENABLED — these credentials are enforced.') : i18n( 'Auth is DISABLED — subs-prover is serving unauthenticated. These credentials will take effect when enabled.', ) const url = subsProverAuth ? `http://${subsProverAuth.username}:${subsProverAuth.password}@127.0.0.1:${SUBSPACES_PROVER_PORT}` : '' return { version: '1', title: i18n('Show Subspaces Prover Auth Credentials'), message: status, result: { type: 'group', value: [ { type: 'single', name: i18n('SUBS_PROVER_BASIC_AUTH_USER'), description: null, value: username, masked: false, copyable: true, qr: false, }, { type: 'single', name: i18n('SUBS_PROVER_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, }, ], }, } }, )