Skip to content

Commit acb7563

Browse files
committed
remove jsr:@tls/struct replaced wih jsr:@aicone/byte
1 parent cb40453 commit acb7563

File tree

7 files changed

+75
-41
lines changed

7 files changed

+75
-41
lines changed

deno.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tls/param",
3-
"version": "0.2.6",
3+
"version": "0.2.7",
44
"exports": "./src/mod.ts",
55
"publish": {
66
"exclude": ["dist/"]
@@ -13,9 +13,9 @@
1313
}
1414
},
1515
"imports": {
16-
"@std/assert": "jsr:@std/assert@^1.0.2",
17-
"@tls/enum": "jsr:@tls/enum@^0.9.0",
18-
"@tls/extension": "jsr:@tls/extension@^0.4.7",
19-
"@tls/struct": "jsr:@tls/struct@^0.3.8"
16+
"@aicone/byte": "jsr:@aicone/byte@^0.7.9",
17+
"@std/assert": "jsr:@std/assert@^1.0.12",
18+
"@tls/enum": "jsr:@tls/enum@^0.9.3",
19+
"@tls/extension": "jsr:@tls/extension@^0.5.5"
2020
}
2121
}

deno.lock

Lines changed: 34 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/certificatereq.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//@ts-self-types="../type/certificatereq.d.ts"
22

3-
import { Uint16, Extension, parseItems } from "./dep.ts";
4-
import { parseExtension } from "./utils.js";
3+
import { Uint16, Extension } from "./dep.ts";
4+
import { parseExtension, parseItems } from "./utils.js";
55

66
/* class Extensions extends Constrained {
77
static from(array) {

src/dep.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export * from "@tls/struct"
21
export * from "@tls/extension"
3-
export * from "@tls/enum"
2+
export * from "@tls/enum"
3+
export * from "@aicone/byte"

src/encrypted.js

Lines changed: 2 additions & 2 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/encrypted.d.ts"
3-
import { Uint16, parseItems } from "./dep.ts";
3+
import { Uint16 } from "./dep.ts";
44
import { Extension } from "./dep.ts"
5-
import { parseExtension } from "./utils.js";
5+
import { parseExtension, parseItems } from "./utils.js";
66

77
export class EncryptedExtensions extends Uint8Array {
88
#extensions

src/utils.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
ExtensionType,
33
NamedGroupList, RecordSizeLimit,
44
KeyShareClientHello, ServerNameList, PskKeyExchangeModes,
5-
Cookie, Supported_signature_algorithms,
5+
Cookie, SignatureSchemeList,
66
OfferedPsks,
77
EarlyDataIndication,
88
Padding,
@@ -21,7 +21,7 @@ export function parseExtension(extension) {
2121
extension.parser = Versions; break;
2222
}
2323
case ExtensionType.SIGNATURE_ALGORITHMS: {
24-
extension.parser = Supported_signature_algorithms; break;
24+
extension.parser = SignatureSchemeList; break;
2525
}
2626
case ExtensionType.SERVER_NAME: {
2727
extension.parser = extension.data.length ? ServerNameList : extension.data; break;
@@ -47,4 +47,25 @@ export function parseExtension(extension) {
4747
default:
4848
break;
4949
}
50+
}
51+
52+
53+
export function parseItems(copy, start, lengthOf, Fn, option = {}) {
54+
if (start + lengthOf > copy.length) {
55+
throw new RangeError("Specified length exceeds available data.");
56+
}
57+
const { parser= null, store= new Set(), storeset = (store, data)=>{store.set(data.key, data.value)} } = option
58+
if (!(store instanceof Set || store instanceof Map || store instanceof Array)) {
59+
throw new TypeError("store must be an instance of Set, Map, or Array.");
60+
}
61+
62+
let offset = start;
63+
while ((offset < lengthOf + start) && (offset < copy.length)) {
64+
const item = Fn.from(copy.subarray(offset)); offset += item.length;
65+
if (parser) parser(item)
66+
if (store instanceof Set) store.add(item);
67+
else if (store instanceof Map) storeset(store, item);
68+
else store.push(item)
69+
}
70+
return store
5071
}

test/encryptedext_test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
import { HexaDecimal } from "../src/dep.ts";
1+
import { Byte } from "../src/dep.ts";
22
import { EncryptedExtensions } from "../src/encrypted.js";
33
import { assertEquals } from "jsr:@std/assert";
44

55
/* Deno.test("EncryptedExtension", ()=>{
6-
const test = HexaDecimal.fromString(`08 00 00 28 00 26 00 0a 00 14 00
6+
const test = Byte.fromHex(`08 00 00 28 00 26 00 0a 00 14 00
77
12 00 1d 00 17 00 18 00 19 01 00 01 01 01 02 01 03 01 04 00 1c
8-
00 02 40 01 00 00 00 00 00 2a 00 00`).byte
8+
00 02 40 01 00 00 00 00 00 2a 00 00`)
99
1010
const back = EncryptedExtensions.fromHandshake(encryptedExtensionMsg).handshake;
1111
assertEquals(test.toString(), back.toString())
1212
}) */
1313

14-
/* const encryptedExtensionMsg = HexaDecimal.fromString(`08 00 00 28 00 26 00 0a 00 14 00
14+
/* const encryptedExtensionMsg = Byte.fromHex(`08 00 00 28 00 26 00 0a 00 14 00
1515
12 00 1d 00 17 00 18 00 19 01 00 01 01 01 02 01 03 01 04 00 1c
16-
00 02 40 01 00 00 00 00 00 2a 00 00`).byte
16+
00 02 40 01 00 00 00 00 00 2a 00 00`)
1717
1818
const back = EncryptedExtensions.fromHandshake(encryptedExtensionMsg).handshake;
1919
2020
const test = Uint8Array.of(8,0,0,2,0,0);
2121
const back_0 = EncryptedExtensions.fromHandshake(test);
2222
const back_1 = EncryptedExtensions.from(test.subarray(4)) */
2323

24-
const test_1 = HexaDecimal.fromString(`00 26 00 0a 00 14 00
24+
const test_1 = Byte.fromHex(`00 26 00 0a 00 14 00
2525
12 00 1d 00 17 00 18 00 19 01 00 01 01 01 02 01 03 01 04 00 1c
26-
00 02 40 01 00 00 00 00 00 2a 00 00`).byte
26+
00 02 40 01 00 00 00 00 00 2a 00 00`)
2727
const back_1 = EncryptedExtensions.from(test_1)
2828

2929
const _n = null;

0 commit comments

Comments
 (0)