@sphereon/ssi-types
Advanced tools
Comparing version 0.9.1-unstable.17 to 0.9.1-unstable.18
@@ -1,2 +0,2 @@ | ||
import { DocumentFormat, ICredential, IPresentation, IVerifiableCredential, IVerifiablePresentation, JwtDecodedVerifiableCredential, JwtDecodedVerifiablePresentation, OriginalVerifiableCredential, OriginalVerifiablePresentation, W3CVerifiableCredential, W3CVerifiablePresentation, WrappedVerifiableCredential, WrappedVerifiablePresentation } from '../types'; | ||
import { DocumentFormat, IPresentation, IVerifiableCredential, IVerifiablePresentation, JwtDecodedVerifiableCredential, JwtDecodedVerifiablePresentation, OriginalVerifiableCredential, OriginalVerifiablePresentation, W3CVerifiableCredential, W3CVerifiablePresentation, WrappedVerifiableCredential, WrappedVerifiablePresentation } from '../types'; | ||
export declare class CredentialMapper { | ||
@@ -32,3 +32,3 @@ static decodeVerifiablePresentation(presentation: OriginalVerifiablePresentation): JwtDecodedVerifiablePresentation | IVerifiablePresentation; | ||
maxTimeSkewInMS?: number; | ||
}): ICredential; | ||
}): IVerifiableCredential; | ||
static jwtDecodedCredentialToUniformCredential(decoded: JwtDecodedVerifiableCredential, opts?: { | ||
@@ -35,0 +35,0 @@ maxTimeSkewInMS?: number; |
@@ -140,11 +140,2 @@ "use strict"; | ||
} | ||
if (decoded.aud) { | ||
const verifier = presentation.verifier; | ||
if (verifier) { | ||
if (verifier !== decoded.aud) { | ||
throw new Error(`Inconsistent holders between JWT claim (${decoded.iss}) and VC value (${verifier})`); | ||
} | ||
} | ||
presentation.verifier = decoded.aud; | ||
} | ||
if (decoded.jti) { | ||
@@ -180,6 +171,2 @@ const id = presentation.id; | ||
: decoded; | ||
// At time of writing Velocity Networks does not conform to specification. Adding bare minimum @context section to stop parsers from crashing and whatnot | ||
if (!uniformPresentation['@context']) { | ||
uniformPresentation['@context'] = ['https://www.w3.org/2018/credentials/v1']; | ||
} | ||
uniformPresentation.verifiableCredential = (_a = uniformPresentation.verifiableCredential) === null || _a === void 0 ? void 0 : _a.map((vc) => CredentialMapper.toUniformCredential(vc, opts)); // We cast it because we IPresentation needs a VC. The internal Credential doesn't have the required Proof anymore (that is intended) | ||
@@ -186,0 +173,0 @@ return uniformPresentation; |
@@ -75,3 +75,2 @@ import { PresentationSubmission } from './pex'; | ||
holder?: string; | ||
verifier?: string; | ||
[x: string]: any; | ||
@@ -162,4 +161,2 @@ } | ||
jti: string; | ||
aud: string; | ||
iat: string; | ||
[x: string]: any; | ||
@@ -166,0 +163,0 @@ } |
{ | ||
"name": "@sphereon/ssi-types", | ||
"description": "SSI Common Types", | ||
"version": "0.9.1-unstable.17+9f929cb", | ||
"version": "0.9.1-unstable.18+a4e1114", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"scripts": { | ||
"build": "tsc --build" | ||
"build": "tsc --build", | ||
"build:clean": "tsc --build --clean && tsc --build" | ||
}, | ||
@@ -18,4 +19,3 @@ "dependencies": { | ||
"prettier": "^2.4.1", | ||
"ts-jest": "^27.0.7", | ||
"typescript": "4.6.4" | ||
"ts-jest": "^27.0.7" | ||
}, | ||
@@ -42,3 +42,3 @@ "files": [ | ||
], | ||
"gitHead": "9f929cb88baf569a1b51d699d1cd2456c5d03255" | ||
"gitHead": "a4e11143915eb1638d999fffdcd92b8578227b2b" | ||
} |
import { | ||
DocumentFormat, | ||
ICredential, | ||
IPresentation, | ||
@@ -188,11 +187,2 @@ IProof, | ||
} | ||
if (decoded.aud) { | ||
const verifier = presentation.verifier | ||
if (verifier) { | ||
if (verifier !== decoded.aud) { | ||
throw new Error(`Inconsistent holders between JWT claim (${decoded.iss}) and VC value (${verifier})`) | ||
} | ||
} | ||
presentation.verifier = decoded.aud | ||
} | ||
if (decoded.jti) { | ||
@@ -231,8 +221,2 @@ const id = presentation.id | ||
: (decoded as IVerifiablePresentation) | ||
// At time of writing Velocity Networks does not conform to specification. Adding bare minimum @context section to stop parsers from crashing and whatnot | ||
if (!uniformPresentation['@context']) { | ||
uniformPresentation['@context'] = ['https://www.w3.org/2018/credentials/v1'] | ||
} | ||
uniformPresentation.verifiableCredential = uniformPresentation.verifiableCredential?.map((vc) => | ||
@@ -244,3 +228,3 @@ CredentialMapper.toUniformCredential(vc, opts) | ||
static jwtEncodedCredentialToUniformCredential(jwt: string, opts?: { maxTimeSkewInMS?: number }): ICredential { | ||
static jwtEncodedCredentialToUniformCredential(jwt: string, opts?: { maxTimeSkewInMS?: number }): IVerifiableCredential { | ||
return CredentialMapper.jwtDecodedCredentialToUniformCredential(jwt_decode(jwt), opts) | ||
@@ -247,0 +231,0 @@ } |
@@ -99,3 +99,2 @@ import { PresentationSubmission } from './pex' | ||
holder?: string | ||
verifier?: string | ||
@@ -196,4 +195,2 @@ [x: string]: any | ||
jti: string | ||
aud: string | ||
iat: string | ||
@@ -200,0 +197,0 @@ [x: string]: any |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
5
102203
1495