Skip to content

Commit

Permalink
add add method to clientHello
Browse files Browse the repository at this point in the history
  • Loading branch information
Srabutdotcom committed Jan 2, 2025
1 parent bb83851 commit 52fc562
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tls/keyexchange",
"version": "0.0.7",
"version": "0.0.8",
"exports": "./src/mod.ts",
"publish": {
"exclude": ["dist/"]
Expand Down
5 changes: 5 additions & 0 deletions src/clienthello.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
EarlyDataIndication,
Padding,
ContentType,
safeuint8array,
} from "./dep.ts"

export class ClientHello extends Struct {
Expand Down Expand Up @@ -85,6 +86,10 @@ export class ClientHello extends Struct {
)
}
toRecord() { return ContentType.HANDSHAKE.tlsPlainText(this) }
add(data){
const array = safeuint8array(this, data);
return ClientHello.from(array)
}
}

export class Cipher_suites extends Constrained {
Expand Down
12 changes: 9 additions & 3 deletions type/clienthello.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {
Constrained,
Extension,
Struct,
TLSPlaintext,
Version,
TLSPlaintext
} from "../src/dep.ts";

/**
Expand Down Expand Up @@ -73,12 +73,18 @@ export class ClientHello extends Struct {
static fromServerName(serverName: string): ClientHello;
/**
* Converts the current instance into a TLSPlaintext record.
*
*
* @returns {TLSPlaintext} A `TLSPlaintext` object representing the current instance.
* The `ContentType` is set to `HANDSHAKE`, and the data is encoded as a plaintext record.
*/
toRecord(): TLSPlaintext;

/**
* Appends the given data to the current instance and creates a new `ClientHello` object.
*
* @param {Uint8Array} data - The data to be appended. Must be a valid `Uint8Array`.
* @returns {ClientHello} A new `ClientHello` instance with the combined data.
*/
add(data: Uint8Array): ClientHello;
}

/**
Expand Down

0 comments on commit 52fc562

Please sign in to comment.