diff --git a/src/lib/auth/operations.ts b/src/lib/auth/operations.ts index 9670c32c..795dd6ba 100644 --- a/src/lib/auth/operations.ts +++ b/src/lib/auth/operations.ts @@ -1,5 +1,3 @@ -import { randomBytes } from 'node:crypto' - import { type ConfigStore, getConfigStore } from 'lib/config/index.js' import { type AuthContext, resolveAuth } from 'lib/context.js' import { @@ -134,29 +132,6 @@ export const selectWorkspace = ( config.set('current_workspace_id', workspaceId) } -/** - * Point the CLI at a fake Seam Connect endpoint and store the well-known - * token it accepts. Returns the generated endpoint URL for reporting. - */ -export const selectFakeEndpoint = ({ - urlSeed = randomBytes(5).toString('hex'), - config = getConfigStore(), -}: { - urlSeed?: string - config?: ConfigStore -} = {}): { endpoint: string; token: string } => { - const auth = resolveAuth(config) - assertMutable(auth, 'endpoint', 'select an endpoint') - assertMutable(auth, 'token', 'log in') - - const endpoint = `https://${urlSeed}.fakeseamconnect.seam.vc` - const token = 'seam_apikey1_token' - storeEndpoint(endpoint, config) - config.set(`${endpoint}.pat`, token) - - return { endpoint, token } -} - /** Store whether API definitions come from the endpoint instead of npm. */ export const setUseRemoteApiDefs = ( useRemoteApiDefs: boolean, diff --git a/src/lib/interactions/endpoint-selection.ts b/src/lib/interactions/endpoint-selection.ts index c17595c3..3c77ba31 100644 --- a/src/lib/interactions/endpoint-selection.ts +++ b/src/lib/interactions/endpoint-selection.ts @@ -1,24 +1,14 @@ -import { randomBytes } from 'node:crypto' - -import { - assertMutable, - selectEndpoint, - selectFakeEndpoint, -} from 'lib/auth/operations.js' +import { assertMutable, selectEndpoint } from 'lib/auth/operations.js' import { getConfigStore } from 'lib/config/index.js' import { resolveAuth } from 'lib/context.js' import { getOutput } from 'lib/output/get-output.js' -import { promptAutocomplete, promptText } from 'lib/prompt.js' +import { promptAutocomplete } from 'lib/prompt.js' export async function interactForEndpointSelection() { const config = getConfigStore() assertMutable(resolveAuth(config), 'endpoint', 'select an endpoint') - const endpoints = [ - 'http://localhost:3020', - 'https://connect.getseam.com', - 'https://fakeseamconnect.seam.vc', - ] + const endpoints = ['http://localhost:3020', 'https://connect.getseam.com'] // Searchable, as selecting a device or a command is. const endpoint = await promptAutocomplete({ @@ -29,20 +19,6 @@ export async function interactForEndpointSelection() { })), }) - const output = getOutput() - if (endpoint === endpoints[2]) { - let userUrlSeed = await promptText({ - message: - 'You can input a custom endpoint URL or leave this field empty to use a new fakeserver.', - }) - - if (userUrlSeed.trim().length === 0) { - userUrlSeed = randomBytes(5).toString('hex') - } - selectFakeEndpoint({ urlSeed: userUrlSeed, config }) - output.info(`PAT set to use fakeseamconnect with "seam_apikey1_token"`) - } else { - selectEndpoint(endpoint, config) - } - output.info(`Endpoint set to ${endpoint}`) + selectEndpoint(endpoint, config) + getOutput().info(`Endpoint set to ${endpoint}`) } diff --git a/src/lib/prompt.test.ts b/src/lib/prompt.test.ts index 1349c6d0..4fb49813 100644 --- a/src/lib/prompt.test.ts +++ b/src/lib/prompt.test.ts @@ -31,10 +31,9 @@ test('searchChoices: matches any part of a name, not only its start', () => { const endpoints = [ { label: 'http://localhost:3020' }, { label: 'https://connect.getseam.com' }, - { label: 'https://fakeseamconnect.seam.vc' }, ] - expect(search('fake', endpoints)).toEqual([endpoints[2]]) + expect(search('seam', endpoints)).toEqual([endpoints[1]]) }) test('searchChoices: offers every choice until something is typed', () => { diff --git a/test/auth/operations.test.ts b/test/auth/operations.test.ts index 80f88bb0..adebde84 100644 --- a/test/auth/operations.test.ts +++ b/test/auth/operations.test.ts @@ -4,7 +4,6 @@ import { login, logout, selectEndpoint, - selectFakeEndpoint, selectWorkspace, storeToken, } from 'lib/auth/operations.js' @@ -212,26 +211,3 @@ test(`selectWorkspace: refuses while ${workspaceIdEnvVar} is set`, () => { selectWorkspace('workspace1', store) }).toThrow(`Cannot select a workspace while ${workspaceIdEnvVar} is set`) }) - -test('selectFakeEndpoint: stores the endpoint and its well-known token', () => { - const store = createMemoryConfigStore({ current_workspace_id: 'workspace1' }) - - const { endpoint: fakeEndpoint } = selectFakeEndpoint({ - urlSeed: 'abc123', - config: store, - }) - - expect(fakeEndpoint).toBe('https://abc123.fakeseamconnect.seam.vc') - expect(store.get('endpoint')).toBe(fakeEndpoint) - expect(store.get(`${fakeEndpoint}.pat`)).toBe('seam_apikey1_token') - expect(store.has('current_workspace_id')).toBe(false) -}) - -test(`selectFakeEndpoint: refuses while ${endpointEnvVar} is set`, () => { - process.env[endpointEnvVar] = endpoint - const store = createMemoryConfigStore() - - expect(() => - selectFakeEndpoint({ urlSeed: 'abc123', config: store }), - ).toThrow(`Cannot select an endpoint while ${endpointEnvVar} is set`) -})