@@ -86,7 +86,7 @@ export class HandshakeType extends Enum {
8686 */
8787 static MESSAGE_HASH = new HandshakeType ( 'MESSAGE_HASH' , 0xFE ) ;
8888
89-
89+
9090 /**
9191 * Check and return HandshakeType if valid
9292 *
@@ -99,51 +99,52 @@ export class HandshakeType extends Enum {
9999 }
100100
101101 /**return 8 */
102- get bit ( ) { return 8 }
102+ get bit ( ) { return 8 }
103+ get length ( ) { return 1 }
103104
104- handshake ( message ) {
105+ handshake ( message ) {
105106 return Handshake . fromMessage ( this , message )
106107 }
107108
108- get Uint8 ( ) { return Uint8 . fromValue ( + this ) }
109+ get Uint8 ( ) { return Uint8 . fromValue ( + this ) }
109110}
110111
111112export class Handshake extends Uint8Array {
112113 msg_type
113114 message
114- static fromMessage ( msg_type , message ) {
115+ static fromMessage ( msg_type , message ) {
115116 return new Handshake ( msg_type , message )
116117 }
117- static from ( array ) {
118+ static from ( array ) {
118119 const copy = Uint8Array . from ( array )
119120 const msg_type = HandshakeType . fromValue ( copy [ 0 ] ) ;
120121 const lengthOf = Uint24 . from ( copy . subarray ( 1 ) ) . value ;
121122 const message = copy . subarray ( 4 , 4 + lengthOf )
122123 return new Handshake ( msg_type , message )
123124 }
124- constructor ( msg_type , message ) {
125- const struct = new Struct ( msg_type . Uint8 , Uint24 . fromValue ( message . length ) , message )
125+ constructor ( msg_type , message ) {
126+ const struct = new Struct ( msg_type . Uint8 , Uint24 . fromValue ( message . length ) , message )
126127 super ( struct )
127128 this . msg_type = msg_type ;
128129 this . message = message
129130 this . items = struct . items
130131 }
131- get byte ( ) { return Uint8Array . from ( this ) }
132- tlsInnerPlaintext ( numZeros ) {
132+ get byte ( ) { return Uint8Array . from ( this ) }
133+ tlsInnerPlaintext ( numZeros ) {
133134 return ContentType . APPLICATION_DATA . tlsInnerPlaintext ( this , numZeros )
134135 }
135136}
136137
137138export class EndOfEarlyData extends Uint8Array {
138- static fromHandshake ( array ) {
139+ static fromHandshake ( array ) {
139140 const type = HandshakeType . fromValue ( array . at ( 0 ) ) ;
140- if ( type !== HandshakeType . END_OF_EARLY_DATA ) return TypeError ( `Expected ${ HandshakeType . END_OF_EARLY_DATA . name } ` )
141+ if ( type !== HandshakeType . END_OF_EARLY_DATA ) return TypeError ( `Expected ${ HandshakeType . END_OF_EARLY_DATA . name } ` )
141142 return new EndOfEarlyData
142143 }
143- constructor ( ) {
144+ constructor ( ) {
144145 super ( )
145146 }
146- get handshake ( ) { return HandshakeType . END_OF_EARLY_DATA . handshake ( this ) }
147+ get handshake ( ) { return HandshakeType . END_OF_EARLY_DATA . handshake ( this ) }
147148}
148149
149150// npx -p typescript tsc ./src/handshaketype.js --declaration --allowJs --emitDeclarationOnly --lib ESNext --outDir ./dist
0 commit comments