mirror of
https://github.com/stablyai/orca.git
synced 2026-10-30 16:47:34 +00:00
* feat(runtime): device-key authentication and per-installation key migration (host) * fix(runtime): corrupt registry is never a revocation verdict; keyed sockets dispatch without a token; forks keep their Relay binding * fix(runtime): keep an unparseable device registry aside; an unlisted key is never 'revoked' while it exists * fix(runtime): a set-aside corrupt registry keeps verdicts doubtful even when the registry file is missing * test(runtime): registerDeviceKey reaches the bound socket through the dispatcher for runtime and mobile rows --------- Co-authored-by: m4air <m4air@Mac.localdomain>
60 lines
1.9 KiB
TypeScript
60 lines
1.9 KiB
TypeScript
import { defineMethod } from '../core'
|
|
import {
|
|
DELEGATED_MOBILE_DEVICE_SYNC_METHOD,
|
|
DelegatedMobileDeviceSyncParamsSchema
|
|
} from '../../../../shared/delegated-mobile-device-contract'
|
|
import { RegisterDeviceKeyParamsSchema } from '../../../../shared/device-key-registration-contract'
|
|
import { REGISTER_DEVICE_KEY_METHOD } from '../../../../shared/device-key-proof'
|
|
import {
|
|
PairingGetEndpointsParamsSchema,
|
|
PairingProvisionRelayParamsSchema
|
|
} from '../../../../shared/mobile-relay-credential-contract'
|
|
|
|
export const PAIRING_METHODS = [
|
|
defineMethod({
|
|
name: 'pairing.getEndpoints',
|
|
permission: 'pairing-admin',
|
|
params: PairingGetEndpointsParamsSchema,
|
|
handler: async (params, ctx) => {
|
|
if (!ctx.pairing) {
|
|
throw new Error('pairing_context_unavailable')
|
|
}
|
|
return await ctx.pairing.getEndpoints(params)
|
|
}
|
|
}),
|
|
defineMethod({
|
|
name: 'pairing.provisionRelay',
|
|
permission: 'pairing-admin',
|
|
params: PairingProvisionRelayParamsSchema,
|
|
handler: async (params, ctx) => {
|
|
if (!ctx.pairing) {
|
|
throw new Error('pairing_context_unavailable')
|
|
}
|
|
return await ctx.pairing.provisionRelay(params)
|
|
}
|
|
}),
|
|
defineMethod({
|
|
name: REGISTER_DEVICE_KEY_METHOD,
|
|
permission: 'device-self',
|
|
params: RegisterDeviceKeyParamsSchema,
|
|
handler: (params, ctx) => {
|
|
if (!ctx.deviceSelf) {
|
|
throw new Error('device_key_registration_unavailable')
|
|
}
|
|
return ctx.deviceSelf.registerDeviceKey(params)
|
|
}
|
|
}),
|
|
defineMethod({
|
|
name: DELEGATED_MOBILE_DEVICE_SYNC_METHOD,
|
|
// Why: paired desktops call this and are never granted pairing-admin; children reach no further (rpc-caller-scope.ts).
|
|
permission: 'workspace',
|
|
params: DelegatedMobileDeviceSyncParamsSchema,
|
|
handler: (params, ctx) => {
|
|
if (!ctx.delegatedMobileDevices) {
|
|
throw new Error('runtime_device_required')
|
|
}
|
|
return ctx.delegatedMobileDevices.sync(params.phones)
|
|
}
|
|
})
|
|
]
|