Skip to content

Commit ec578b2

Browse files
committed
remove Extension, add byte
1 parent 3bdbcf8 commit ec578b2

14 files changed

+28
-81
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/.vscode
22
/deno.lock
3-
/dist
3+
/dist
4+
/playground

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.3",
3+
"version": "0.7.5",
44
"exports": "./src/mod.ts",
55
"publish": {
66
"exclude": ["dist/"]

src/alert.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export class AlertLevel extends Enum {
2828

2929
/**return 8 */
3030
get bit() { return 8 }
31+
get byte() { return Uint8Array.of(+this)}
3132
}
3233

3334

@@ -196,6 +197,7 @@ export class AlertDescription extends Enum {
196197
/**return 8 */
197198
get bit() { return 8 }
198199
get length() { return 1 }
200+
get byte() { return Uint8Array.of(+this)}
199201

200202
get level() {
201203
const warning = [

src/certificatetype.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export class CertificateType extends Enum {
2323
/**return 8 */
2424
get bit() { return 8 }
2525
get length() { return 1 }
26+
get byte(){ return Uint8Array.of(+this)}
2627

2728
}
2829

src/extensiontype.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// deno-lint-ignore-file no-slow-types
22
// @ts-self-types="../type/extensiontype.d.ts"
33

4-
import { Uint16, Constrained, Struct } from "./dep.ts";
4+
import { Uint16 } from "./dep.ts";
55
import { Enum } from "./enum.js";
66

77
/**
@@ -215,10 +215,9 @@ export class ExtensionType extends Enum {
215215
get bit() { return 16 }
216216
get length() { return 2 }
217217

218-
extension(extension_data){return new Extension(this, extension_data)}
219218
}
220219

221-
export class ExtensionData extends Constrained {
220+
/* export class ExtensionData extends Constrained {
222221
opaque
223222
static fromOpaque(opaque) { return new ExtensionData(opaque) }
224223
static from(array) {
@@ -247,7 +246,7 @@ export class Extension extends Struct {
247246
const extension_data = ExtensionData.from(copy.subarray(2));
248247
return new Extension(extension_type, extension_data.opaque)
249248
}
250-
}
249+
} */
251250

252251

253252

src/keyupdate.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export class KeyUpdateRequest extends Enum {
2727
/**return 8 */
2828
get bit() { return 8 }
2929
get length() { return 1 }
30+
get byte(){ return Uint8Array.of(+this)}
3031

3132
}
3233

type/alert.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export class AlertLevel extends Enum {
1717
static from(octet: Uint8Array): AlertLevel;
1818
/**return 8 */
1919
get bit(): number;
20+
get byte(): Uint8Array;
2021
}
2122
/**
2223
* Enum class representing various TLS alert descriptions based on RFC 8446.
@@ -152,6 +153,7 @@ export class AlertDescription extends Enum {
152153
/**return 8 */
153154
get bit(): number;
154155
get level(): AlertLevel;
156+
get byte(): Uint8;
155157
}
156158
declare class Alert extends Uint8Array {
157159
/**
@@ -186,4 +188,5 @@ declare class Alert extends Uint8Array {
186188
*/
187189
static from(array: Uint8Array): Alert;
188190
}
191+
import { Uint8 } from "../src/dep.ts";
189192
import { Enum } from "../src/enum.js";

type/certificatetype.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Enum } from "../src/enum.js";
2-
import { Constrained, x509 } from "../src/dep.ts";
2+
import { Constrained, Uint8, x509 } from "../src/dep.ts";
33

44
/**
55
* Represents TLS Certificate Types.
@@ -27,6 +27,7 @@ export class CertificateType extends Enum {
2727
* @readonly
2828
*/
2929
get bit(): number;
30+
get byte(): Uint8;
3031
}
3132

3233
/**

type/cipher.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Uint16 } from "../src/dep.ts";
12
import { Enum } from "../src/enum.js";
23

34
/**
@@ -32,8 +33,8 @@ export class Cipher extends Enum {
3233
* Gets the 2-byte identifier of the cipher suite.
3334
* @returns A `Uint8Array` containing the cipher suite identifier.
3435
*/
35-
get Uint16(): Uint8Array;
36-
get byte(): Uint8Array;
36+
get Uint16(): Uint16;
37+
get byte(): Uint16;
3738

3839
/**
3940
* Get hash length for respective cipher

type/extensiontype.d.ts

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -102,70 +102,5 @@ export class ExtensionType extends Enum {
102102
*/
103103
get bit(): number;
104104

105-
/**
106-
* Create an Extension instance with the current extension type and extension data.
107-
* @param extension_data The associated data for the extension.
108-
* @returns A new Extension instance.
109-
*/
110-
extension(extension_data: Uint8Array): Extension;
111-
}
112-
113-
/**
114-
* Represents extension data in a TLS context.
115-
* The data is a constrained opaque value with a length between 0 and 2^16 - 1.
116-
*/
117-
export class ExtensionData extends Constrained {
118-
/** The raw opaque extension data. */
119-
opaque: Uint8Array;
120-
121-
/**
122-
* Creates a new `ExtensionData` instance from an opaque value.
123-
*
124-
* @param opaque - The opaque value to initialize the `ExtensionData` instance.
125-
* @returns An instance of `ExtensionData`.
126-
*/
127-
static fromOpaque(opaque: Uint8Array): ExtensionData;
128-
129-
/**
130-
* Parses an `ExtensionData` instance from a serialized array.
131-
*
132-
* @param array - The serialized array containing the `ExtensionData` data.
133-
* @returns An instance of `ExtensionData`.
134-
*/
135-
static from(array: Uint8Array): ExtensionData;
136-
137-
/**
138-
* Constructs a new `ExtensionData` instance.
139-
*
140-
* @param opaque - The opaque value for the extension data.
141-
*/
142-
constructor(opaque: Uint8Array);
143105
}
144106

145-
/**
146-
* Represents an extension in a TLS context.
147-
* Consists of an extension type and associated extension data.
148-
*/
149-
export class Extension extends Struct {
150-
/** The extension type. */
151-
extension_type: Uint16;
152-
153-
/** The associated extension data. */
154-
extension_data: Uint8Array;
155-
156-
/**
157-
* Constructs a new `Extension` instance.
158-
*
159-
* @param extension_type - The type of the extension (as a `Uint16`).
160-
* @param extension_data - The associated extension data.
161-
*/
162-
constructor(extension_type: Uint16, extension_data: Uint8Array);
163-
164-
/**
165-
* Parses an `Extension` instance from a serialized array.
166-
*
167-
* @param array - The serialized array containing the extension data.
168-
* @returns An instance of `Extension`.
169-
*/
170-
static from(array: Uint8Array): Extension;
171-
}

0 commit comments

Comments
 (0)