Skip to content

Commit

Permalink
rearrange presentation exchange code with some comments, it still doe…
Browse files Browse the repository at this point in the history
…snt work
  • Loading branch information
finn-tbd committed Jul 31, 2023
1 parent f197770 commit 0f76c05
Showing 1 changed file with 28 additions and 16 deletions.
44 changes: 28 additions & 16 deletions packages/web5/tests/web5-vc-ssi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,11 @@ describe('web5.vc.ssi', () => {
expect(ssiResponse.verified).to.be.true;
});
it('a presentation exchange', async () => {
const issuerDID = await ssiRequest('/v1/dids/key', { keyType: 'Ed25519' });
const holderDID = await new DidKeyApi().create();

let credentialResponse = await ssiRequest('/v1/credentials', {
data: {
additionalName : 'Mclovin',
dateOfBirth : '1987-01-02',
familyName : 'Andres',
givenName : 'Uribe'
},
issuer : issuerDID.did.id,
verificationMethodId : issuerDID.did.verificationMethod[0].id,
subject : holderDID.id,
expiry : '2051-10-05T14:48:00.000Z'
});
// 1. create a DID on the SSI service
const issuerDID = await ssiRequest('/v1/dids/key', { keyType: 'Ed25519' });

// 2. create a presentation definition on the SSI service
let presentationDefinition = await ssiRequest('/v1/presentations/definitions', {
name : 'name',
purpose : 'purpose',
Expand All @@ -96,6 +85,29 @@ describe('web5.vc.ssi', () => {
]
});

// 3. create a presentation request using the DID from 1 and the presentation definiton from 2

// 4. locally create a DID
const holderDID = await new DidKeyApi().create();

// 5. locally create the credential(s) needed to fulfil the presentation defintion, signed by DID from 4
// TODO: this should be done locally not remotely
let credentialResponse = await ssiRequest('/v1/credentials', {
data: {
additionalName : 'Mclovin',
dateOfBirth : '1987-01-02',
familyName : 'Andres',
givenName : 'Uribe'
},
issuer : issuerDID.did.id,
verificationMethodId : issuerDID.did.verificationMethod[0].id,
subject : holderDID.id,
expiry : '2051-10-05T14:48:00.000Z'
});


// 6. build presentation submission that complies with presentation request
// TODO: this should probably be generated by the library
const submissionJWTData = {
vp: {
'@context': [
Expand All @@ -118,8 +130,7 @@ describe('web5.vc.ssi', () => {
}
};

console.log(holderDID);

// 7. sign presentation submission as a verifiable presentation JWT
// this doesn't work, I don't know why
// sample privateKeyJwk value:
// {
Expand Down Expand Up @@ -158,6 +169,7 @@ describe('web5.vc.ssi', () => {
.setExpirationTime('2y')
.sign(jwk);

// 8. submit to service
let createSubmissionResponse = await ssiRequest('/v1/presentations/submissions', { submissionJwt: submissionJWT });

expect(createSubmissionResponse.done).to.be.true;
Expand Down

0 comments on commit 0f76c05

Please sign in to comment.