@@ -4974,35 +4974,35 @@ function processTlsOptions(tls, forServer) {
49744974 validateBoolean ( tlsTrace , 'options.tlsTrace' ) ;
49754975
49764976 // Encode the ALPN option to wire format (length-prefixed protocol names).
4977- // Server: array of protocol names. Client: single protocol name.
4978- // If not specified, the C++ default (h3) is used.
4979- let encodedAlpn ;
4980- if ( alpn !== undefined ) {
4981- const protocols = forServer ?
4982- ( ArrayIsArray ( alpn ) ? alpn : [ alpn ] ) :
4983- [ alpn ] ;
4984- if ( ! forServer ) {
4985- validateString ( alpn , 'options.alpn' ) ;
4986- }
4987- let totalLen = 0 ;
4988- for ( let i = 0 ; i < protocols . length ; i ++ ) {
4989- validateString ( protocols [ i ] , `options.alpn[ ${ i } ]` ) ;
4990- if ( protocols [ i ] . length === 0 || protocols [ i ] . length > 255 ) {
4991- throw new ERR_INVALID_ARG_VALUE ( `options.alpn[ ${ i } ]` , protocols [ i ] ,
4992- 'must be between 1 and 255 characters' ) ;
4993- }
4994- totalLen += 1 + protocols [ i ] . length ;
4995- }
4996- // Build wire format: [len1][name1][len2][name2]...
4997- const buf = Buffer . allocUnsafe ( totalLen ) ;
4998- let offset = 0 ;
4999- for ( let i = 0 ; i < protocols . length ; i ++ ) {
5000- buf [ offset ++ ] = protocols [ i ] . length ;
5001- buf . write ( protocols [ i ] , offset , 'ascii' ) ;
5002- offset += protocols [ i ] . length ;
5003- }
5004- encodedAlpn = buf . toString ( 'latin1' ) ;
5005- }
4977+ if ( alpn === undefined ) {
4978+ throw new ERR_INVALID_ARG_VALUE (
4979+ 'options.alpn' , alpn ,
4980+ 'is required' ) ;
4981+ }
4982+ const protocols = forServer ?
4983+ ( ArrayIsArray ( alpn ) ? alpn : [ alpn ] ) :
4984+ [ alpn ] ;
4985+ if ( ! forServer ) {
4986+ validateString ( alpn , 'options.alpn' ) ;
4987+ }
4988+ let totalLen = 0 ;
4989+ for ( let i = 0 ; i < protocols . length ; i ++ ) {
4990+ validateString ( protocols [ i ] , `options.alpn[ ${ i } ]` ) ;
4991+ if ( protocols [ i ] . length === 0 || protocols [ i ] . length > 255 ) {
4992+ throw new ERR_INVALID_ARG_VALUE ( `options.alpn[ ${ i } ]` , protocols [ i ] ,
4993+ 'must be between 1 and 255 characters' ) ;
4994+ }
4995+ totalLen += 1 + protocols [ i ] . length ;
4996+ }
4997+ // Build wire format: [len1][name1][len2][name2]...
4998+ const buf = Buffer . allocUnsafe ( totalLen ) ;
4999+ let offset = 0 ;
5000+ for ( let i = 0 ; i < protocols . length ; i ++ ) {
5001+ buf [ offset ++ ] = protocols [ i ] . length ;
5002+ buf . write ( protocols [ i ] , offset , 'ascii' ) ;
5003+ offset += protocols [ i ] . length ;
5004+ }
5005+ const encodedAlpn = buf . toString ( 'latin1' ) ;
50065006
50075007 if ( ca !== undefined ) {
50085008 const caInputs = ArrayIsArray ( ca ) ? ca : [ ca ] ;
@@ -5195,6 +5195,7 @@ function processSessionOptions(options, config = kEmptyObject) {
51955195 // HTTP/3 application-specific options. Nested under `application`
51965196 // to separate protocol-specific settings from transport-level ones.
51975197 application = kEmptyObject ,
5198+
51985199 // Session callbacks that can be set at construction time to avoid
51995200 // race conditions with events that fire during or immediately
52005201 // after the handshake.
@@ -5226,6 +5227,10 @@ function processSessionOptions(options, config = kEmptyObject) {
52265227 targetAddress,
52275228 } = config ;
52285229
5230+ const applicationName = options [ kApplication ] ;
5231+ assert ( applicationName === undefined || typeof applicationName === 'string' ,
5232+ 'options[kApplication] must be a registered application name' ) ;
5233+
52295234 if ( token !== undefined ) {
52305235 if ( ! isArrayBufferView ( token ) ) {
52315236 throw new ERR_INVALID_ARG_TYPE ( 'options.token' ,
@@ -5329,6 +5334,7 @@ function processSessionOptions(options, config = kEmptyObject) {
53295334 maxDatagramSendAttempts,
53305335 streamIdleTimeout,
53315336 application,
5337+ applicationName,
53325338 onerror,
53335339 onstream,
53345340 ondatagram,
@@ -5465,6 +5471,8 @@ module.exports = {
54655471 CC_ALGO_BBR ,
54665472 DEFAULT_CIPHERS ,
54675473 DEFAULT_GROUPS ,
5474+ // Internal only for http3+quic integration
5475+ kApplication,
54685476 // These are exported only for internal testing purposes.
54695477 getQuicStreamState,
54705478 getQuicSessionState,
0 commit comments