Skip to content

Commit 44d1da3

Browse files
committed
chore: wip
1 parent 5440920 commit 44d1da3

4 files changed

Lines changed: 450 additions & 351 deletions

File tree

src/asn1-validator.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const privateKeyValidator: Asn1Validator = {
3636
type: Type.INTEGER,
3737
constructed: false,
3838
capture: 'privateKeyVersion',
39-
value: []
39+
value: [],
4040
}, {
4141
// privateKeyAlgorithm
4242
name: 'PrivateKeyInfo.privateKeyAlgorithm',
@@ -49,7 +49,7 @@ export const privateKeyValidator: Asn1Validator = {
4949
type: Type.OID,
5050
constructed: false,
5151
capture: 'privateKeyOid',
52-
value: []
52+
value: [],
5353
}],
5454
}, {
5555
// PrivateKey
@@ -58,7 +58,7 @@ export const privateKeyValidator: Asn1Validator = {
5858
type: Type.OCTETSTRING,
5959
constructed: false,
6060
capture: 'privateKey',
61-
value: []
61+
value: [],
6262
}],
6363
}
6464

@@ -79,7 +79,7 @@ export const publicKeyValidator: Asn1Validator = {
7979
type: Type.OID,
8080
constructed: false,
8181
capture: 'publicKeyOid',
82-
value: []
82+
value: [],
8383
}],
8484
},
8585
// capture group for ed25519PublicKey
@@ -90,8 +90,8 @@ export const publicKeyValidator: Asn1Validator = {
9090
constructed: false,
9191
composed: true,
9292
captureBitStringValue: 'ed25519PublicKey',
93-
value: []
94-
}]
93+
value: [],
94+
}],
9595
}
9696

9797
export const asn1Validator: ValidatorMap = {

src/asn1.ts

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -133,35 +133,36 @@
133133
* The full OID (including ASN.1 tag and length of 6 bytes) is:
134134
* 0x06062A864886F70D
135135
*/
136-
import { createBuffer, bytesToHex, decodeUtf8, ByteStringBuffer } from './utils'
136+
import type { ByteStringBuffer } from './utils'
137137
import { oids } from './oids'
138+
import { bytesToHex, createBuffer, decodeUtf8 } from './utils'
138139

139140
interface ExtendedError extends Error {
140-
available?: number;
141-
remaining?: number;
142-
requested?: number;
143-
byteCount?: number;
144-
integer?: number;
141+
available?: number
142+
remaining?: number
143+
requested?: number
144+
byteCount?: number
145+
integer?: number
145146
}
146147

147148
interface Asn1Object {
148-
tagClass: number;
149-
type: number;
150-
constructed: boolean;
151-
composed: boolean;
152-
value: any;
153-
bitStringContents?: string;
154-
original?: Asn1Object;
149+
tagClass: number
150+
type: number
151+
constructed: boolean
152+
composed: boolean
153+
value: any
154+
bitStringContents?: string
155+
original?: Asn1Object
155156
}
156157

157158
interface CreateOptions {
158-
bitStringContents?: string;
159+
bitStringContents?: string
159160
}
160161

161162
interface DerOptions {
162-
strict?: boolean;
163-
parseAllBytes?: boolean;
164-
decodeBitStrings?: boolean;
163+
strict?: boolean
164+
parseAllBytes?: boolean
165+
decodeBitStrings?: boolean
165166
}
166167

167168
/**
@@ -309,9 +310,10 @@ export function equals(obj1: Asn1Object | any[] | string, obj2: Asn1Object | any
309310
if (obj1.length !== obj2.length)
310311
return false
311312

312-
for (let i = 0; i < obj1.length; ++i)
313+
for (let i = 0; i < obj1.length; ++i) {
313314
if (!asn1.equals(obj1[i], obj2[i], options))
314315
return false
316+
}
315317

316318
return true
317319
}
@@ -1514,7 +1516,7 @@ export const asn1: Asn1 = {
15141516
derToInteger,
15151517
validate,
15161518
prettyPrint,
1517-
toDer
1519+
toDer,
15181520
} as const
15191521

15201522
export default asn1

0 commit comments

Comments
 (0)