Skip to content

Commit b67bce8

Browse files
committed
remove Handshake and EndOfEarlyData
1 parent d18cf3a commit b67bce8

File tree

4 files changed

+4
-122
lines changed

4 files changed

+4
-122
lines changed

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tls/enum",
3-
"version": "0.7.1",
3+
"version": "0.7.2",
44
"exports": "./src/mod.ts",
55
"publish": {
66
"exclude": ["dist/"]

src/handshaketype.js

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// deno-lint-ignore-file no-slow-types
22
// @ts-self-types="../type/handshaketype.d.ts"
33
import { Enum } from "./enum.js";
4-
import { Struct, Uint24, Uint8 } from "./dep.ts";
5-
import { ContentType } from "./contentype.js"
4+
import { Uint8 } from "./dep.ts";
5+
66

77
/**
88
* Represents TLS 1.3 Handshake message types as defined in RFC 8446 Section 4
@@ -101,51 +101,9 @@ export class HandshakeType extends Enum {
101101
/**return 8 */
102102
get bit() { return 8 }
103103
get length() { return 1 }
104-
105-
handshake(message) {
106-
return Handshake.fromMessage(this, message)
107-
}
108-
109104
get Uint8() { return Uint8.fromValue(+this) }
110105
get byte() { return this.Uint8 }
111106
}
112107

113-
export class Handshake extends Uint8Array {
114-
msg_type
115-
message
116-
static fromMessage(msg_type, message) {
117-
return new Handshake(msg_type, message)
118-
}
119-
static from(array) {
120-
const copy = Uint8Array.from(array)
121-
const msg_type = HandshakeType.fromValue(copy[0]);
122-
const lengthOf = Uint24.from(copy.subarray(1)).value;
123-
const message = copy.subarray(4, 4 + lengthOf)
124-
return new Handshake(msg_type, message)
125-
}
126-
constructor(msg_type, message) {
127-
const struct = new Struct(msg_type.Uint8, Uint24.fromValue(message.length), message)
128-
super(struct)
129-
this.msg_type = msg_type;
130-
this.message = message
131-
this.items = struct.items
132-
}
133-
get byte() { return Uint8Array.from(this) }
134-
tlsInnerPlaintext(numZeros) {
135-
return ContentType.APPLICATION_DATA.tlsInnerPlaintext(this, numZeros)
136-
}
137-
}
138-
139-
export class EndOfEarlyData extends Uint8Array {
140-
static fromHandshake(array) {
141-
const type = HandshakeType.fromValue(array.at(0));
142-
if (type !== HandshakeType.END_OF_EARLY_DATA) return TypeError(`Expected ${HandshakeType.END_OF_EARLY_DATA.name}`)
143-
return new EndOfEarlyData
144-
}
145-
constructor() {
146-
super()
147-
}
148-
get handshake() { return HandshakeType.END_OF_EARLY_DATA.handshake(this) }
149-
}
150108

151109
// npx -p typescript tsc ./src/handshaketype.js --declaration --allowJs --emitDeclarationOnly --lib ESNext --outDir ./dist

test/handshaketype_test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { HandshakeType, EndOfEarlyData } from "../src/handshaketype.js";
1+
import { HandshakeType } from "../src/handshaketype.js";
22

33
console.log(HandshakeType.CLIENT_HELLO);
44
console.log(HandshakeType.CLIENT_HELLO)
@@ -10,8 +10,6 @@ for (const e of codes) {
1010
}
1111

1212

13-
const eoData = new EndOfEarlyData;
14-
const eoDataHandshake = eoData.handshake;
1513

1614

1715

type/handshaketype.d.ts

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -78,84 +78,10 @@ export declare class HandshakeType extends Enum {
7878
*/
7979
get bit(): number;
8080

81-
/**
82-
* Creates a `Handshake` object from this type and a message.
83-
* @param message - The message associated with the handshake.
84-
* @returns {Handshake}
85-
*/
86-
handshake(message: Uint8Array): Handshake;
87-
8881
/**
8982
* Returns the Uint8 representation of the handshake type.
9083
*/
9184
get Uint8(): Uint8Array;
9285
get byte(): Uint8Array;
9386
}
9487

95-
/**
96-
* Represents a TLS Handshake message.
97-
*/
98-
export declare class Handshake extends Uint8Array {
99-
/**
100-
* The handshake message type.
101-
*/
102-
readonly msg_type: HandshakeType;
103-
104-
/**
105-
* The handshake message payload.
106-
*/
107-
readonly message: Uint8Array;
108-
109-
/**
110-
* Creates a `Handshake` object from a message type and payload.
111-
* @param msg_type - The type of handshake message.
112-
* @param message - The handshake message payload.
113-
* @returns {Handshake}
114-
*/
115-
static fromMessage(msg_type: HandshakeType, message: Uint8Array): Handshake;
116-
117-
/**
118-
* Parses a `Handshake` object from a `Uint8Array`.
119-
* @param array - The array containing the handshake message data.
120-
* @returns {Handshake} The parsed Handshake object.
121-
*/
122-
static from(array: Uint8Array): Handshake;
123-
124-
/**
125-
* Creates a new `Handshake` object.
126-
* @param msg_type - The handshake type.
127-
* @param message - The handshake message payload.
128-
*/
129-
constructor(msg_type: HandshakeType, message: Uint8Array);
130-
/** return Uint8Array */
131-
get byte(): Uint8Array
132-
133-
/**
134-
* Generates TLS inner plaintext by processing the current context with specified padding.
135-
*
136-
* @param {number} numZeros - The number of zero bytes to use as padding in the TLS inner plaintext.
137-
* @returns {Uint8Array} The formatted TLS inner plaintext data.
138-
*/
139-
tlsInnerPlaintext(numZeros: number): Uint8Array;
140-
}
141-
142-
declare class EndOfEarlyData extends Uint8Array {
143-
/**
144-
* Creates an `EndOfEarlyData` instance from a handshake array.
145-
* @param array - The array containing handshake data.
146-
* @returns An `EndOfEarlyData` instance if the type matches,
147-
* otherwise throws a `TypeError` with the expected type.
148-
*/
149-
static fromHandshake(array: Uint8Array): EndOfEarlyData | TypeError;
150-
151-
/**
152-
* Constructs an empty `EndOfEarlyData` instance.
153-
*/
154-
constructor();
155-
156-
/**
157-
* Processes and retrieves handshake information for the `EndOfEarlyData` instance.
158-
* @returns The result of the handshake process.
159-
*/
160-
get handshake(): Handshake;
161-
}

0 commit comments

Comments
 (0)