mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 17:17:38 +00:00
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>
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import type { PairedE2EEAuthCredential } from './paired-e2ee-client-handshake'
|
|
import type { PairingOffer } from './pairing'
|
|
|
|
// What a client needs to connect to a paired host. Why not PairingOffer: an offer is
|
|
// pairing input; a connection carries a credential that will not always be a token.
|
|
export type PairedRuntimeConnection = {
|
|
endpoint: string
|
|
hostPublicKeyB64: string
|
|
credential: PairedE2EEAuthCredential
|
|
pairedDeviceId?: string
|
|
}
|
|
|
|
type OfferConnectionFields = Pick<
|
|
PairingOffer,
|
|
'endpoint' | 'deviceToken' | 'publicKeyB64' | 'pairedDeviceId'
|
|
> &
|
|
Partial<Pick<PairingOffer, 'v' | 'scope'>>
|
|
|
|
export function pairedRuntimeConnectionFromOffer(
|
|
offer: OfferConnectionFields
|
|
): PairedRuntimeConnection {
|
|
return {
|
|
endpoint: offer.endpoint,
|
|
hostPublicKeyB64: offer.publicKeyB64,
|
|
credential: { kind: 'token', deviceToken: offer.deviceToken },
|
|
...(offer.pairedDeviceId ? { pairedDeviceId: offer.pairedDeviceId } : {})
|
|
}
|
|
}
|
|
|
|
// The token request envelopes still carry on the wire.
|
|
export function pairedRuntimeConnectionToken(connection: PairedRuntimeConnection): string {
|
|
return connection.credential.deviceToken
|
|
}
|