Files
orca/src/cli/runtime/runtime-remote-pairing.ts
T
OrcaWinandm4air 34e2e5f469 refactor(remote): clients connect through a paired-connection handle, not a pairing offer (#27533)
Desktop, CLI, web and runtime transports now take a PairedRuntimeConnection
(endpoint, pinned host key, credential) instead of a PairingOffer. Offers stay on
the pairing input path (codes, QR, links, environment add) and are converted with
pairedRuntimeConnectionFromOffer. The credential is token-only today; request
envelopes still carry the same deviceToken, so the wire is unchanged.

This lets device-key and ticket credentials replace the token later without
touching every connect call site again.

Co-authored-by: m4air <m4air@Mac.localdomain>
2026-10-11 14:02:03 -07:00

37 lines
1.1 KiB
TypeScript

import {
pairedRuntimeConnectionFromOffer,
type PairedRuntimeConnection
} from '../../shared/paired-runtime-connection'
import { parsePairingCode } from '../../shared/pairing'
import { resolveEnvironmentPairingOffer } from './environments'
import { RuntimeClientError } from './types'
export function resolveRemoteConnection(
userDataPath: string,
pairingCode: string | null,
environmentSelector: string | null
): PairedRuntimeConnection | null {
if (pairingCode && environmentSelector) {
throw new RuntimeClientError(
'invalid_argument',
'Use either --pairing-code or --environment, not both.'
)
}
if (environmentSelector) {
return pairedRuntimeConnectionFromOffer(
resolveEnvironmentPairingOffer(userDataPath, environmentSelector)
)
}
if (!pairingCode) {
return null
}
const pairing = parsePairingCode(pairingCode)
if (!pairing) {
throw new RuntimeClientError(
'invalid_argument',
'Invalid remote pairing code. Expected an orca://pair?... URL or bare pairing payload.'
)
}
return pairedRuntimeConnectionFromOffer(pairing)
}