fix(typert): address remote gateway review
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
import { Context, Service } from 'cordis'
|
||||
import { z } from 'zod'
|
||||
import { isTypeRTRemoteSegment } from '@deepseek-ai/dsh-type-meta'
|
||||
import type {
|
||||
InvocationDescriptor,
|
||||
TypeRTClientContextBinder,
|
||||
@@ -600,8 +601,9 @@ function validateCodec(codec: InvocationDescriptor['result'], subject: string):
|
||||
}
|
||||
|
||||
function validateWireName(subject: string, value: string): void {
|
||||
validateSegment(subject, value)
|
||||
if (value.includes('/')) throw new Error(`typert: invalid ${subject} "${value}" — must not contain "/"`)
|
||||
if (!isTypeRTRemoteSegment(value)) {
|
||||
throw new Error(`typert: invalid ${subject} "${value}" — must contain only RPC endpoint segment characters`)
|
||||
}
|
||||
}
|
||||
|
||||
function validateSegment(subject: string, value: string): void {
|
||||
|
||||
@@ -247,6 +247,14 @@ describe('TypertRegistry', () => {
|
||||
})).toThrow('endpoint "goals/create" is already registered')
|
||||
})
|
||||
|
||||
it.each(['create#v2', 'create goal'])('rejects untransportable invocation method %s', async (method) => {
|
||||
const ctx = await makeCtx()
|
||||
expect(() => ctx.typert.remotes.register({
|
||||
package: '@fixture/invalid-endpoint',
|
||||
descriptors: [{ ...invocation(), method }],
|
||||
})).toThrow('RPC endpoint segment characters')
|
||||
})
|
||||
|
||||
it('mounts Remote contributions in the calling fiber and withdraws them exactly', async () => {
|
||||
const ctx = await makeCtx()
|
||||
const descriptor = invocation()
|
||||
|
||||
Reference in New Issue
Block a user