Skip to content

Commit 255a95c

Browse files
committed
remove signatureSchemeList
1 parent c816f48 commit 255a95c

File tree

5 files changed

+7
-107
lines changed

5 files changed

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

src/signaturescheme.js

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -67,60 +67,7 @@ export class SignatureScheme extends Enum {
6767
*
6868
* @returns {Uint16} The Uint16 representation of the SignatureScheme.
6969
*/
70-
toUint16() { return Uint16.fromValue(+this); }
70+
get Uint16() { return Uint16.fromValue(+this); }
7171
}
7272

73-
/**
74-
* Represents a list of supported signature schemes.
75-
*/
76-
export class SignatureSchemeList extends Constrained {
77-
supported_signature_algorithms;
78-
79-
/**
80-
* Creates a SignatureSchemeList instance from the provided signature schemes.
81-
*
82-
* @param {...SignatureScheme} signatureScheme - The signature schemes to include in the list.
83-
*/
84-
constructor(...signatureScheme) {
85-
super(2, 65534, ...signatureScheme.map(e => e.toUint16()));
86-
this.supported_signature_algorithms = signatureScheme;
87-
}
88-
89-
/**
90-
* Creates a SignatureSchemeList from the provided signature schemes.
91-
*
92-
* @static
93-
* @param {...SignatureScheme} signatureScheme - The signature schemes to include in the list.
94-
* @returns {SignatureSchemeList} A new instance of SignatureSchemeList.
95-
*/
96-
static fromSchemes(...signatureScheme) {
97-
return new SignatureSchemeList(...signatureScheme);
98-
}
99-
100-
/**
101-
* Creates a SignatureSchemeList from a Uint8Array.
102-
*
103-
* @static
104-
* @param {Uint8Array} array - The array to parse into a SignatureSchemeList.
105-
* @returns {SignatureSchemeList} A new instance of SignatureSchemeList.
106-
* @throws {Error} If the length of the array is invalid.
107-
*/
108-
static from(array) {
109-
const arrayCopy = new Uint8Array(array);
110-
const length = Uint16.from(arrayCopy.subarray(0, 2)).value;
111-
// Validate length against array size
112-
if (length + 2 > arrayCopy.length) {
113-
throw new Error('Invalid SignatureSchemeList length');
114-
}
115-
116-
const signatureSchemes = [];
117-
for (let i = 2; i < length + 2; i += 2) {
118-
signatureSchemes.push(SignatureScheme.from(arrayCopy.subarray(i, i + 2)));
119-
}
120-
return SignatureSchemeList.fromSchemes(...signatureSchemes);
121-
}
122-
}
123-
124-
125-
12673
// npx -p typescript tsc ./src/signaturescheme.js --declaration --allowJs --emitDeclarationOnly --lib ESNext --outDir ./dist

test/signaturescheme_test.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { SignatureScheme, SignatureSchemeList } from "../src/signaturescheme.js";
1+
import { SignatureScheme } from "../src/signaturescheme.js";
22
import { assertEquals } from "jsr:@std/assert";
33

44
console.log(SignatureScheme.ED448);
@@ -11,17 +11,8 @@ for (const e of codes) {
1111

1212
Deno.test("SignatureAlgorithmSchema", () => {
1313
// Example usage
14-
const test = SignatureSchemeList.fromSchemes(
15-
SignatureScheme.ECDSA_SECP256R1_SHA256,
16-
SignatureScheme.ECDSA_SECP384R1_SHA384,
17-
SignatureScheme.ECDSA_SECP521R1_SHA512,
18-
SignatureScheme.RSA_PSS_PSS_SHA256,
19-
SignatureScheme.RSA_PSS_PSS_SHA384,
20-
SignatureScheme.RSA_PSS_PSS_SHA512,
21-
SignatureScheme.ED25519,
22-
SignatureScheme.ED448
23-
);
24-
const back = SignatureSchemeList.from(test);
14+
const test = SignatureScheme.ED448.Uint16
15+
const back = SignatureScheme.from(test).Uint16;
2516
assertEquals(test, back)
2617
})
2718

test/version_test.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Import your classes
2-
import { Version, ProtocolVersion, Versions } from "../src/version.js";
2+
import { Version, ProtocolVersion } from "../src/version.js";
33
import { assertEquals } from "jsr:@std/assert";
44

55
// Helper function to create Uint8Array from two bytes
@@ -61,8 +61,3 @@ Deno.test("ProtocolVersion Class - Constructor", () => {
6161
assertEquals(protocolVersion.version, Version.TLS13, "Expected ProtocolVersion to match Version.TLS13");
6262
});
6363

64-
Deno.test("Versions", () => {
65-
const test = Versions.fromVersions(Version.TLS12, Version.TLS13);
66-
const back = Versions.from(test)
67-
assertEquals(test, back)
68-
})

type/signaturescheme.d.ts

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -47,38 +47,5 @@ export class SignatureScheme extends Enum {
4747
*
4848
* @returns {Uint16} The Uint16 representation of the SignatureScheme.
4949
*/
50-
toUint16(): Uint16;
51-
}
52-
53-
/**
54-
* Represents a list of supported signature schemes.
55-
*/
56-
export class SignatureSchemeList extends Constrained {
57-
supported_signature_algorithms: SignatureScheme[];
58-
59-
/**
60-
* Creates a SignatureSchemeList instance from the provided signature schemes.
61-
*
62-
* @param {...SignatureScheme} signatureScheme - The signature schemes to include in the list.
63-
*/
64-
constructor(...signatureScheme: SignatureScheme[]);
65-
66-
/**
67-
* Creates a SignatureSchemeList from the provided signature schemes.
68-
*
69-
* @static
70-
* @param {...SignatureScheme} signatureScheme - The signature schemes to include in the list.
71-
* @returns {SignatureSchemeList} A new instance of SignatureSchemeList.
72-
*/
73-
static fromSchemes(...signatureScheme: SignatureScheme[]): SignatureSchemeList;
74-
75-
/**
76-
* Creates a SignatureSchemeList from a Uint8Array.
77-
*
78-
* @static
79-
* @param {Uint8Array} array - The array to parse into a SignatureSchemeList.
80-
* @returns {SignatureSchemeList} A new instance of SignatureSchemeList.
81-
* @throws {Error} If the length of the array is invalid.
82-
*/
83-
static from(array: Uint8Array): SignatureSchemeList;
50+
get Uint16(): Uint16;
8451
}

0 commit comments

Comments
 (0)