Skip to content

Commit 1a5ea19

Browse files
committed
feat: v0.1.5 | Add CSCA masterlist's support
1 parent b96270b commit 1a5ea19

File tree

7 files changed

+47
-4
lines changed

7 files changed

+47
-4
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,4 +182,8 @@ dist
182182

183183
/index.ts
184184

185-
docs/
185+
docs/
186+
187+
# ICAO Masterlists
188+
189+
*.ml

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<img src="https://raw.githubusercontent.com/li0ard/tsemrtd/main/.github/logo.svg" alt="tsemrtd logo" title="tsemrtd" width="120" /><br>
44
</a><br>
55
<b>tsemrtd</b><br>
6-
<b>simple library for eMRTD Datagroups</b>
6+
<b>simple library for eMRTD datagroups</b>
77
<br><br>
88
<a href="https://github.com/li0ard/tsemrtd/actions/workflows/test.yml"><img src="https://github.com/li0ard/tsemrtd/actions/workflows/test.yml/badge.svg" /></a>
99
<a href="https://jsr.io/@li0ard/tsemrtd"><img src="https://jsr.io/badges/@li0ard/tsemrtd" /></a>
@@ -24,6 +24,7 @@
2424
- Type-Safe: Most of the APIs are strictly typed to help your workflow
2525
- Compliance: Fully complies with ICAO 9303 and ISO/IEC 19794 standards
2626
- Supports Bun, Node.js, Deno, Browsers, Cloudflare Workers
27+
- Supports CSCA masterlist's (ICAO PKD)
2728

2829
## Installation
2930

jsr.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@li0ard/tsemrtd",
3-
"version": "0.1.4",
3+
"version": "0.1.5",
44
"exports": "./src/index.ts",
55
"publish": {
66
"include": [

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "tsemrtd",
33
"module": "index.ts",
4-
"version": "0.1.4",
4+
"version": "0.1.5",
55
"type": "module",
66
"author": "li0ard",
77
"repository": {

src/asn1/pkd.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { AsnProp, AsnType, AsnPropTypes, AsnTypeTypes, AsnArray } from "@peculiar/asn1-schema";
2+
import { Certificate } from "@peculiar/asn1-x509";
3+
4+
/** Class for ASN1 schema of Certificates set */
5+
@AsnType({ type: AsnTypeTypes.Set, itemType: Certificate })
6+
export class Certificates extends AsnArray<Certificate> {}
7+
8+
/** Class for ASN1 schema of CSCA master list. Described by ICAO 9303 p.12 section 9.2 */
9+
export class CSCAMasterList {
10+
/** Master list version */
11+
@AsnProp({ type: AsnPropTypes.Integer })
12+
version: number = 0;
13+
14+
/** CSCA certificates */
15+
@AsnProp({ type: Certificates })
16+
certificates: Certificates = new Certificates()
17+
}

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ export { DG12 } from "./dg12"
1010
export { DG14 } from "./dg14"
1111
export { DG15 } from "./dg15"
1212
export { SOD } from "./sod"
13+
export { PKD } from "./pkd"
1314
export * as Enums from "./consts/enums"
1415
export * as Interfaces from "./consts/interfaces"

src/pkd.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { AsnConvert, OctetString } from "@peculiar/asn1-schema";
2+
import { ContentInfo, SignedData } from "@peculiar/asn1-cms";
3+
import { CSCAMasterList } from "./asn1/pkd";
4+
5+
/**
6+
* Class for working with CSCA master list
7+
*/
8+
export class PKD {
9+
/**
10+
* Get CSCA certificates from master list
11+
* @param data Data of ICAO master list file (.ml)
12+
*/
13+
static load(data: string | Buffer): CSCAMasterList {
14+
if(typeof data == "string") data = Buffer.from(data, "hex");
15+
16+
let contentInfo = AsnConvert.parse(data, ContentInfo)
17+
let signedData = AsnConvert.parse(contentInfo.content, SignedData)
18+
return AsnConvert.parse(signedData.encapContentInfo.eContent?.single as OctetString, CSCAMasterList)
19+
}
20+
}

0 commit comments

Comments
 (0)