Skip to content

Commit

Permalink
fix: JWT claims would overwrite the issuer object in the credential. …
Browse files Browse the repository at this point in the history
…Disable Factom tests
  • Loading branch information
nklomp committed Nov 8, 2022
1 parent 12dae72 commit f41cf64
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('@sphereon/factom-did-provider', () => {
} as IKeyManager,
} as IRequiredContext*/

it('should create identifier', () => {
xit('should create identifier', () => {
// jest.spyOn(fetch, '').mockResolvedValueOnce(Promise.resolve(restResponse));
const identifier = factomDIDProvider.createIdentifier(
{
Expand Down
20 changes: 19 additions & 1 deletion packages/ssi-types/__tests__/uniform-claims.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import * as fs from 'fs'
import { CredentialMapper, ICredential, IVerifiableCredential, ICredentialSubject } from '../src'
import {
CredentialMapper,
ICredential,
IVerifiableCredential,
ICredentialSubject,
W3CVerifiableCredential,
} from '../src'

function getFile(path: string) {
return fs.readFileSync(path, 'utf-8')
Expand Down Expand Up @@ -110,6 +116,18 @@ describe('Uniform VC claims', () => {
})`
)
})

it('should work with jsonLD VC from Diwala', () => {
const ldpVc: IVerifiableCredential = getFileAsJson('packages/ssi-types/__tests__/vc_vp_examples/vc/vc_edu-plugfest-diwala.json')
const vc = CredentialMapper.toUniformCredential(ldpVc)
expect(vc.issuanceDate).toEqual("2022-11-04T12:32:03Z")
})

it('should work with jwt VC from Velocity', () => {
const jwtVc: W3CVerifiableCredential = getFile('packages/ssi-types/__tests__/vc_vp_examples/vc/vc_edu-plugfest-velocity.jwt')
const vc = CredentialMapper.toUniformCredential(jwtVc)
expect(vc.issuanceDate).toEqual("2022-11-07T21:29:29Z")
})
})

describe('Uniform VP claims', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://purl.imsglobal.org/spec/ob/v3p0/context.json"
],
"id": "urn:uuid:4f090e16-2d5f-49c7-bf0a-6db89d5637ff",
"type": [
"VerifiableCredential",
"OpenBadgeCredential"
],
"name": "JFF x vc-edu PlugFest 2 Interoperability",
"issuer": {
"type": [
"Profile"
],
"id": "did:key:z6MkrzXCdarP1kaZcJb3pmNi295wfxerDrmTqPv5c6MkP2r9",
"name": "Jobs for the Future (JFF)",
"url": "https://www.jff.org/",
"image": "https://w3c-ccg.github.io/vc-ed/plugfest-1-2022/images/JFF_LogoLockup.png"
},
"issuanceDate": "2022-11-04T12:32:03Z",
"credentialSubject": {
"type": [
"AchievementSubject"
],
"id": "did:key:z6MkmhiKsUB95WnSaV3YT8UqqmBMRDjXGHprrRXWbS94U26f",
"achievement": {
"id": "urn:uuid:04047d6a-a20e-4d58-847d-dbf13d22c2aa",
"type": [
"Achievement"
],
"name": "JFF x vc-edu PlugFest 2 Interoperability",
"description": "This credential solution supports the use of OBv3 and w3c Verifiable Credentials and is interoperable with at least two other solutions. This was demonstrated successfully during JFF x vc-edu PlugFest 2.",
"criteria": {
"narrative": "Solutions providers earned this badge by demonstrating interoperability between multiple providers based on the OBv3 candidate final standard, with some additional required fields. Credential issuers earning this badge successfully issued a credential into at least two wallets. Wallet implementers earning this badge successfully displayed credentials issued by at least two different credential issuers."
},
"image": {
"id": "https://w3c-ccg.github.io/vc-ed/plugfest-2-2022/images/JFF-VC-EDU-PLUGFEST2-badge-image.png",
"type": "Image"
}
}
},
"proof": {
"type": "Ed25519Signature2018",
"created": "2022-11-04T12:32:04Z",
"verificationMethod": "did:key:z6MkrzXCdarP1kaZcJb3pmNi295wfxerDrmTqPv5c6MkP2r9#z6MkrzXCdarP1kaZcJb3pmNi295wfxerDrmTqPv5c6MkP2r9",
"proofPurpose": "assertionMethod",
"jws": "eyJhbGciOiJFZERTQSIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..fq3x2YvRtwxF4pGJQPvKLr31LPIUEfVLQg1sJ7b8ZuESFptVQDWi_wAzpSO5HIz4AdQx0omgjHp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UF9BIiwic3ViIjoiZGlkOmp3azpleUpqY25ZaU9pSnpaV053TWpVMmF6RWlMQ0pyZEhraU9pSkZReUlzSW5WelpTSTZJbk5wWnlJc0luZ2lPaUpEV1V0R2NubE5Vak5zZG5semJ6ZDRSMEp5U3pCclEyRllhR3BIYVd0V0xXczFPR0ZITUZJMFNYaHpJaXdpZVNJNklqRXROSGhMWjBwUGRGVnJiM1puUmpWcWNVYzFObUp4YW1sblQwSlRNV0ZPT0VkQk4xRXlhRGxSUm1zaWZRIiwiaWF0IjoxNjY3ODU2NTY5fQ.-SiM5d7UrYn1gdj2hU5T5LnLQzhIklOtoexbyebLMeha0K89vkujsbFN4HNFP2TSfRYFt0-jXwDaZ8RNKESwFA
3 changes: 2 additions & 1 deletion packages/ssi-types/src/mapper/credential-mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,9 @@ export class CredentialMapper {
throw new Error(`Inconsistent issuers between JWT claim (${decoded.iss}) and VC value (${issuer.id})`)
}
}
} else {
credential.issuer = decoded.iss
}
credential.issuer = decoded.iss
}

if (decoded.sub) {
Expand Down

0 comments on commit f41cf64

Please sign in to comment.