Skip to content

Commit

Permalink
Merge pull request #296 from Sphereon-Opensource/feature/MWALL-717_jw…
Browse files Browse the repository at this point in the history
…t-decode-crash

feature/MWALL-717_jwt-decode-crash
  • Loading branch information
sanderPostma authored Dec 12, 2024
2 parents 886ea5b + d1c812c commit 35f7353
Show file tree
Hide file tree
Showing 16 changed files with 3,892 additions and 3,890 deletions.
8 changes: 4 additions & 4 deletions packages/ebsi-support/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
},
"dependencies": {
"@ethersproject/random": "^5.7.0",
"@sphereon/did-auth-siop": "0.16.1-next.224",
"@sphereon/did-auth-siop-adapter": "0.16.1-next.224",
"@sphereon/did-auth-siop": "0.16.1-next.231",
"@sphereon/did-auth-siop-adapter": "0.16.1-next.231",
"@sphereon/pex": "5.0.0-unstable.28",
"@sphereon/pex-models": "^2.3.2",
"@sphereon/ssi-sdk-ext.did-resolver-ebsi": "0.27.0",
Expand Down Expand Up @@ -44,8 +44,8 @@
"xstate": "^4.38.3"
},
"devDependencies": {
"@sphereon/oid4vci-client": "0.16.1-next.224",
"@sphereon/oid4vci-common": "0.16.1-next.224",
"@sphereon/oid4vci-client": "0.16.1-next.231",
"@sphereon/oid4vci-common": "0.16.1-next.231",
"@sphereon/ssi-express-support": "workspace:*",
"@sphereon/ssi-sdk-ext.key-manager": "0.27.0",
"@sphereon/ssi-sdk-ext.kms-local": "0.27.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/mdl-mdoc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"build:clean": "tsc --build --clean && tsc --build"
},
"dependencies": {
"@sphereon/did-auth-siop": "0.16.1-next.224",
"@sphereon/did-auth-siop": "0.16.1-next.231",
"@sphereon/kmp-mdoc-core": "0.2.0-SNAPSHOT.26",
"@sphereon/pex": "5.0.0-unstable.28",
"@sphereon/pex-models": "^2.3.2",
Expand All @@ -35,8 +35,8 @@
"uuid": "^9.0.1"
},
"devDependencies": {
"@sphereon/oid4vci-client": "0.16.1-next.224",
"@sphereon/oid4vci-common": "0.16.1-next.224",
"@sphereon/oid4vci-client": "0.16.1-next.231",
"@sphereon/oid4vci-common": "0.16.1-next.231",
"@sphereon/ssi-express-support": "workspace:*",
"@sphereon/ssi-sdk-ext.key-manager": "0.27.0",
"@sphereon/ssi-sdk-ext.kms-local": "0.27.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/oid4vci-holder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
},
"dependencies": {
"@sphereon/kmp-mdoc-core": "0.2.0-SNAPSHOT.26",
"@sphereon/oid4vci-client": "0.16.1-next.224",
"@sphereon/oid4vci-common": "0.16.1-next.224",
"@sphereon/oid4vci-client": "0.16.1-next.231",
"@sphereon/oid4vci-common": "0.16.1-next.231",
"@sphereon/ssi-sdk-ext.did-utils": "0.27.0",
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.27.0",
"@sphereon/ssi-sdk-ext.jwt-service": "0.27.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/oid4vci-issuer-rest-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"start:dev": "ts-node __tests__/RestAPI.ts"
},
"dependencies": {
"@sphereon/oid4vci-common": "0.16.1-next.224",
"@sphereon/oid4vci-issuer": "0.16.1-next.224",
"@sphereon/oid4vci-issuer-server": "0.16.1-next.224",
"@sphereon/oid4vci-common": "0.16.1-next.231",
"@sphereon/oid4vci-issuer": "0.16.1-next.231",
"@sphereon/oid4vci-issuer-server": "0.16.1-next.231",
"@sphereon/ssi-express-support": "workspace:*",
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.27.0",
"@sphereon/ssi-sdk.kv-store-temp": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/oid4vci-issuer-rest-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"generate-plugin-schema": "ts-node ../../packages/dev/bin/sphereon.js dev generate-plugin-schema"
},
"dependencies": {
"@sphereon/oid4vci-common": "0.16.1-next.224",
"@sphereon/oid4vci-common": "0.16.1-next.231",
"@sphereon/ssi-types": "workspace:*",
"@veramo/core": "4.2.0",
"cross-fetch": "^3.1.8"
Expand Down
2 changes: 1 addition & 1 deletion packages/oid4vci-issuer-store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"build:clean": "tsc --build --clean && tsc --build"
},
"dependencies": {
"@sphereon/oid4vci-common": "0.16.1-next.224",
"@sphereon/oid4vci-common": "0.16.1-next.231",
"@sphereon/ssi-sdk-ext.did-utils": "0.27.0",
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.27.0",
"@sphereon/ssi-sdk.kv-store-temp": "workspace:*",
Expand Down
6 changes: 3 additions & 3 deletions packages/oid4vci-issuer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"build:clean": "tsc --build --clean && tsc --build"
},
"dependencies": {
"@sphereon/oid4vci-common": "0.16.1-next.224",
"@sphereon/oid4vci-issuer": "0.16.1-next.224",
"@sphereon/oid4vci-common": "0.16.1-next.231",
"@sphereon/oid4vci-issuer": "0.16.1-next.231",
"@sphereon/ssi-sdk-ext.did-utils": "0.27.0",
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.27.0",
"@sphereon/ssi-sdk.agent-config": "workspace:*",
Expand All @@ -31,7 +31,7 @@
"@veramo/core": "4.2.0",
"@veramo/credential-w3c": "4.2.0",
"cross-fetch": "^3.1.8",
"jwt-decode": "^3.1.2",
"jwt-decode": "^4.0.0",
"uuid": "^9.0.1"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/oid4vci-issuer/src/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { CredentialPayload, DIDDocument, ProofFormat } from '@veramo/core'
import { bytesToBase64 } from '@veramo/utils'
import { createJWT, decodeJWT, JWTVerifyOptions, verifyJWT } from 'did-jwt'
import { Resolvable } from 'did-resolver'
import jwtDecode from 'jwt-decode'
import { jwtDecode } from 'jwt-decode'
import { IIssuerOptions, IRequiredContext } from './types/IOID4VCIIssuer'

export function getJwtVerifyCallback({ verifyOpts }: { verifyOpts?: JWTVerifyOptions }, _context: IRequiredContext) {
Expand Down
2 changes: 1 addition & 1 deletion packages/siopv2-oid4vp-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"access": "public"
},
"dependencies": {
"@sphereon/did-auth-siop": "0.16.1-next.224",
"@sphereon/did-auth-siop": "0.16.1-next.231",
"@sphereon/ssi-sdk.core": "workspace:*",
"@sphereon/ssi-types": "workspace:*",
"uint8arrays": "3.1.1"
Expand Down
6 changes: 3 additions & 3 deletions packages/siopv2-oid4vp-op-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"build:clean": "tsc --build --clean && tsc --build"
},
"dependencies": {
"@sphereon/did-auth-siop": "0.16.1-next.224",
"@sphereon/did-auth-siop-adapter": "0.16.1-next.224",
"@sphereon/oid4vc-common": "0.16.1-next.224",
"@sphereon/did-auth-siop": "0.16.1-next.231",
"@sphereon/did-auth-siop-adapter": "0.16.1-next.231",
"@sphereon/oid4vc-common": "0.16.1-next.231",
"@sphereon/pex": "5.0.0-unstable.28",
"@sphereon/pex-models": "^2.3.2",
"@sphereon/ssi-sdk-ext.did-utils": "0.27.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/siopv2-oid4vp-rp-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"build:clean": "tsc --build --clean && tsc --build"
},
"dependencies": {
"@sphereon/did-auth-siop": "0.16.1-next.224",
"@sphereon/did-auth-siop-adapter": "0.16.1-next.224",
"@sphereon/oid4vc-common": "0.16.1-next.224",
"@sphereon/did-auth-siop": "0.16.1-next.231",
"@sphereon/did-auth-siop-adapter": "0.16.1-next.231",
"@sphereon/oid4vc-common": "0.16.1-next.231",
"@sphereon/pex": "5.0.0-unstable.28",
"@sphereon/ssi-sdk-ext.did-utils": "0.27.0",
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.27.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/siopv2-oid4vp-rp-rest-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"start:dev": "ts-node __tests__/RestAPI.ts"
},
"dependencies": {
"@sphereon/did-auth-siop": "0.16.1-next.224",
"@sphereon/did-auth-siop": "0.16.1-next.231",
"@sphereon/ssi-express-support": "workspace:*",
"@sphereon/ssi-sdk.core": "workspace:*",
"@sphereon/ssi-sdk.credential-validation": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/ssi-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@sphereon/kmp-mdoc-core": "0.2.0-SNAPSHOT.26",
"debug": "^4.3.5",
"events": "^3.3.0",
"jwt-decode": "^3.1.2",
"jwt-decode": "^4.0.0",
"uint8arrays": "3.1.1"
},
"devDependencies": {
Expand Down
14 changes: 7 additions & 7 deletions packages/ssi-types/src/mapper/credential-mapper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { IssuerType } from '@veramo/core'
import jwt_decode from 'jwt-decode'
import {
AsyncHasher,
decodeMdocDeviceResponse,
Expand Down Expand Up @@ -45,6 +44,7 @@ import { getMdocDecodedPayload, MdocDocument } from '../types/mso_mdoc'
import { ObjectUtils } from '../utils'
import { com } from '@sphereon/kmp-mdoc-core'
import DeviceResponseCbor = com.sphereon.mdoc.data.device.DeviceResponseCbor
import { jwtDecode } from 'jwt-decode'

export class CredentialMapper {
/**
Expand All @@ -69,8 +69,8 @@ export class CredentialMapper {
hasher?: Hasher
): JwtDecodedVerifiablePresentation | IVerifiablePresentation | SdJwtDecodedVerifiableCredential | MdocOid4vpMdocVpToken | MdocDeviceResponse {
if (CredentialMapper.isJwtEncoded(presentation)) {
const payload = jwt_decode(presentation as string) as JwtDecodedVerifiablePresentation
const header = jwt_decode(presentation as string, { header: true }) as Record<string, any>
const payload = jwtDecode(presentation as string) as JwtDecodedVerifiablePresentation
const header = jwtDecode(presentation as string, { header: true }) as Record<string, any>

payload.vp.proof = {
type: IProofType.JwtProof2020,
Expand Down Expand Up @@ -114,8 +114,8 @@ export class CredentialMapper {
hasher?: Hasher
): JwtDecodedVerifiableCredential | IVerifiableCredential | SdJwtDecodedVerifiableCredential {
if (CredentialMapper.isJwtEncoded(credential)) {
const payload = jwt_decode(credential as string) as JwtDecodedVerifiableCredential
const header = jwt_decode(credential as string, { header: true }) as Record<string, any>
const payload = jwtDecode(credential as string) as JwtDecodedVerifiableCredential
const header = jwtDecode(credential as string, { header: true }) as Record<string, any>
payload.vc.proof = {
type: IProofType.JwtProof2020,
created: payload.nbf,
Expand Down Expand Up @@ -530,7 +530,7 @@ export class CredentialMapper {
makeCredentialsUniform: boolean = true,
opts?: { maxTimeSkewInMS?: number }
): IPresentation {
return CredentialMapper.jwtDecodedPresentationToUniformPresentation(jwt_decode(jwt), makeCredentialsUniform, opts)
return CredentialMapper.jwtDecodedPresentationToUniformPresentation(jwtDecode(jwt), makeCredentialsUniform, opts)
}

static jwtDecodedPresentationToUniformPresentation(
Expand Down Expand Up @@ -660,7 +660,7 @@ export class CredentialMapper {
maxTimeSkewInMS?: number
}
): IVerifiableCredential {
return CredentialMapper.jwtDecodedCredentialToUniformCredential(jwt_decode(jwt), opts)
return CredentialMapper.jwtDecodedCredentialToUniformCredential(jwtDecode(jwt), opts)
}

static jwtDecodedCredentialToUniformCredential(
Expand Down
2 changes: 1 addition & 1 deletion packages/w3c-vc-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"start:dev": "ts-node __tests__/agent.ts"
},
"dependencies": {
"@sphereon/did-auth-siop": "0.16.1-next.224",
"@sphereon/did-auth-siop": "0.16.1-next.231",
"@sphereon/ssi-express-support": "workspace:*",
"@sphereon/ssi-sdk.agent-config": "workspace:*",
"@sphereon/ssi-sdk.core": "workspace:*",
Expand Down
Loading

0 comments on commit 35f7353

Please sign in to comment.