11import type { DevframeNodeContext , DevframeRpcClientFunctions , DevframeRpcServerFunctions } from '../../types'
22import { mkdtempSync , writeFileSync } from 'node:fs'
33import { createServer } from 'node:http'
4+ import { createSecureServer } from 'node:http2'
45import { tmpdir } from 'node:os'
56import { join } from 'node:path'
67import { defineDevframe } from 'devframe'
@@ -10,6 +11,7 @@ import { getPort } from 'get-port-please'
1011import { describe , expect , it , vi } from 'vitest'
1112import { WebSocket } from 'ws'
1213import { getTempAuthCode } from '../../node/auth/state'
14+ import { getInternalContext } from '../../node/hub-internals/context'
1315import { initDevframe } from '../initiate'
1416
1517const HANDSHAKE = { authToken : '' , ua : 'test' , origin : 'http://localhost' }
@@ -206,6 +208,30 @@ describe('adapters/handler', () => {
206208 }
207209 } )
208210
211+ it ( 'shared-server tier: a TLS host server advertises wss://' , async ( ) => {
212+ const host = '127.0.0.1'
213+ const server = createSecureServer ( { allowHTTP1 : true } )
214+ await new Promise < void > ( resolve => server . listen ( 0 , host , resolve ) )
215+ const { port } = server . address ( ) as { port : number }
216+ const devtools = initDevframe ( defineTestDef ( 'handler-tls' ) , {
217+ base : '/__handler-tls/' ,
218+ auth : false ,
219+ host,
220+ server : server as any ,
221+ } )
222+
223+ try {
224+ await devtools . ready
225+ expect ( getInternalContext ( await devtools . context ) . wsEndpoint ) . toEqual ( {
226+ url : `wss://localhost:${ port } /__handler-tls/__ws` ,
227+ } )
228+ }
229+ finally {
230+ await devtools . close ( )
231+ await new Promise < void > ( resolve => server . close ( ( ) => resolve ( ) ) )
232+ }
233+ } )
234+
209235 it ( 'ws.url tier: advertises the external endpoint verbatim, owns no transport' , async ( ) => {
210236 const devtools = initDevframe ( defineTestDef ( 'handler-remote' ) , { base : '/__handler-remote/' , ws : { url : 'wss://devtools.example.com/relay/__ws' } } )
211237
0 commit comments