Skip to content

Commit

Permalink
Fix: Multiple entry point exception.
Browse files Browse the repository at this point in the history
The X509Certificate class is now only used
in the library where the compiler uses
resolves the main entry to the correct js file. There is also another solution to
fix the problem: delete the "browser" field
in the x509 package.json (not really a clean solution...)

Some links:
https://webpack.js.org/configuration/entry-context/

microsoft/TypeScript#21423
  • Loading branch information
fuubi committed Aug 3, 2021
1 parent 53dfce6 commit 76c3e75
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions examples/ts-react/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
DccBase45, Jwt, Verifier,
ZlibDecoder
} from "digital-covid-certificate-lib";
import {X509Certificate} from "@peculiar/x509/";

function App() {
const validVaccinationCert = "HC1:NCFK60DG0/3WUWGSLKH47GO0Y%5S.PK%96L79CK-500XK0JCV496F3PYJ-982F3:OR2B8Y50.FK6ZK7:EDOLOPCO8F6%E3.DA%EOPC1G72A6YM86G7/F6/G80X6H%6946746T%6C46/96SF60R6FN8UPC0JCZ69FVCPD0LVC6JD846Y96C463W5307+EDG8F3I80/D6$CBECSUER:C2$NS346$C2%E9VC- CSUE145GB8JA5B$D% D3IA4W5646646-96:96.JCP9EJY8L/5M/5546.96SF63KC.SC4KCD3DX47B46IL6646H*6Z/ER2DD46JH8946JPCT3E5JDLA7$Q69464W51S6..DX%DZJC2/DYOA$$E5$C JC3/D9Z95LEZED1ECW.C8WE2OA3ZAGY8MPCG/DU2DRB8MTA8+9$PC5$CUZC$$5Y$5FBB*10GBH A81QK UV-$SOGD1APAB4$5UV C-EWB4T*6H%QV/DAP9L7J3Y4O/WVI5IW3672HO-HV16IW3JHV-FI%WJCPBI8QTE008I+FPR01MYFA6EBN2SR3H+4KH1M9RCIM2 VV15REG 516N93SS70RBUCH-RJM2JMULZ6*/HBBW7W7:S2BU7T6PRTMF4ALUNEXH3P7 LE0YF0TGE461PBK9TD68HDIT4AIFD9NH14V%GBCONJOV$KN C+3U-IT$SE-A2V+9UO9WYRJ4HN+M/Z5W$QEDT/8C:88OQ4DXOBBIQ453863NPW0EJXG8$GH1T 38C*UI6T /FCDC%6VLNOA6W6BEYJJUH2Z-SOJO1D7JMALD8 $1%5B.GH$7AQOHZ:K3BNO1"
Expand Down Expand Up @@ -38,7 +37,7 @@ function App() {
{
jwt: new Jwt(CH_KEYS_UPDATE_LIST_JWT),
verifySignature: true,
rootCertificate: new X509Certificate(CH_ROOT_CERTIFICATE)
rootCertificate: CH_ROOT_CERTIFICATE
}
)
console.log(keystore)
Expand Down
4 changes: 2 additions & 2 deletions src/crypto/key-store/ChKeyStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {IKeyStore} from "./IKeyStore";
export type ChKeyStoreIdentifier = string
export type ChKeyStoreLoadingArgs = {
jwt: Jwt, verifySignature: boolean
rootCertificate?: X509Certificate
rootCertificate?: string
}

export class ChKeyStore implements IKeyStore<ChKeyStoreLoadingArgs, ChKeyStoreIdentifier>{
Expand All @@ -18,7 +18,7 @@ export class ChKeyStore implements IKeyStore<ChKeyStoreLoadingArgs, ChKeyStoreId
const {jwt, rootCertificate} = args;
const trustChain: X509Certificate[] = jwt.header.x5c.map(cert => new X509Certificate(cert))
if(rootCertificate){
trustChain.push(rootCertificate)
trustChain.push(new X509Certificate(rootCertificate))
}
for (let i = 0; i < trustChain.length; i++) {
const valid = await trustChain[i].verify({date: new Date(), publicKey: trustChain[i+1]})
Expand Down
2 changes: 1 addition & 1 deletion test/unit/crypto/kes-store/KeyStore.test.ts

Large diffs are not rendered by default.

0 comments on commit 76c3e75

Please sign in to comment.