@@ -29,103 +29,6 @@ export class CertificateType extends Enum {
2929
3030}
3131
32- export class CertificateEntry extends Uint8Array {
33- static from ( array ) {
34- const copy = Uint8Array . from ( array ) ;
35- let offset = 0
36- const cert_data = Cert_data . from ( copy . subarray ( offset ) ) ; offset += cert_data . length ;
37- const extensions = Extensions . from ( copy . subarray ( offset ) ) ;
38- return new CertificateEntry ( cert_data . opaque , ...extensions . extension )
39- }
40- constructor ( opaque , ...extension ) {
41- const cert_data = new Cert_data ( opaque ) ;
42- const extensions = new Extensions ( ...extension ) ;
43- const struct = new Struct ( cert_data , extensions ) ;
44- super ( struct ) ;
45- this . opaque = opaque ;
46- this . extension = extension
47- this . x509 = new x509 . X509Certificate ( btoa ( String . fromCharCode ( ...opaque ) ) )
48- }
49- }
50-
51- export class Certificate extends Uint8Array {
52- static from ( array ) {
53- const copy = Uint8Array . from ( array ) ;
54- let offset = 0 ;
55- const certificate_request_context = Certificate_request_context . from ( copy . subarray ( offset ) ) ; offset += certificate_request_context . length ;
56- const certificate_list = Certificate_list . from ( copy . subarray ( offset ) ) ;
57- return new Certificate ( certificate_request_context . opaque , ...certificate_list . certificateEntry )
58- }
59- constructor ( opaque , ...certificateEntry ) {
60- const certificate_request_context = new Certificate_request_context ( opaque ) ;
61- const certificate_list = new Certificate_list ( ...certificateEntry ) ;
62- const struct = new Struct ( certificate_request_context , certificate_list ) ;
63- super ( struct ) ;
64- this . opaque = opaque ;
65- this . certificateEntry = certificateEntry
66- }
67- }
68-
69- class Cert_data extends Constrained {
70- static from ( array ) {
71- const copy = Uint8Array . from ( array ) ;
72- const lengthOf = Uint24 . from ( copy ) . value ;
73- return new Cert_data ( copy . subarray ( 3 , lengthOf + 3 ) )
74- }
75- constructor ( opaque ) {
76- super ( 1 , 2 ** 24 - 1 , opaque ) ;
77- this . opaque = opaque
78- }
79- }
80-
81- class Extensions extends Constrained {
82- static from ( array ) {
83- const copy = Uint8Array . from ( array ) ;
84- const _lengthOf = Uint16 . from ( copy ) . value ;
85- let offset = 2 ;
86- const extensions = [ ] ;
87- while ( offset < copy . length ) {
88- const extension = Extension . from ( copy . subarray ( offset ) ) ; offset += extension . length ;
89- extensions . push ( extension ) ;
90- }
91- return new Extensions ( ...extensions )
92- }
93- constructor ( ...extension ) {
94- super ( 0 , 2 ** 16 - 1 , ...extension ) ;
95- this . extension = extension
96- }
97- }
98-
99- class Certificate_request_context extends Constrained {
100- static from ( array ) {
101- const copy = Uint8Array . from ( array ) ;
102- const lengthOf = Uint8 . from ( copy ) . value ;
103- return new Certificate_request_context ( copy . subarray ( 1 , lengthOf + 1 ) )
104- }
105- constructor ( opaque ) {
106- super ( 0 , 2 ** 8 - 1 , opaque ) ;
107- this . opaque = opaque
108- }
109- }
110-
111- class Certificate_list extends Constrained {
112- static from ( array ) {
113- const copy = Uint8Array . from ( array ) ;
114- const _lengthOf = Uint24 . from ( copy ) . value ;
115- let offset = 3 ;
116- const certificateEntries = [ ]
117- while ( offset < copy . length ) {
118- const certificateEntry = CertificateEntry . from ( copy . subarray ( offset ) ) ; offset += certificateEntry . length ;
119- certificateEntries . push ( certificateEntry )
120- }
121- return new Certificate_list ( ...certificateEntries )
122- }
123- constructor ( ...certificateEntry ) {
124- super ( 0 , 2 ** 24 - 1 , ...certificateEntry ) ;
125- this . certificateEntry = certificateEntry
126- }
127- }
128-
12932
13033
13134// npx -p typescript tsc ./src/certificatetype.js --declaration --allowJs --emitDeclarationOnly --lib ESNext --outDir ./dist
0 commit comments