Skip to content

Commit

Permalink
Merge pull request #63 from lorena-ssi/multiCred
Browse files Browse the repository at this point in the history
Multi credentials in wallet via SDK
  • Loading branch information
celeduc committed Jun 26, 2020
2 parents dbf2415 + 8fbf636 commit 752bbe6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@lorena-ssi/lorena-sdk",
"version": "2.0.3",
"version": "2.0.4",
"description": "Lorena SDK",
"author": "Alex Puig <alex@caelumlabs.com>",
"license": "MIT",
Expand Down
20 changes: 14 additions & 6 deletions src/index.js
Expand Up @@ -257,16 +257,24 @@ export default class Lorena extends EventEmitter {
}

/**
* handle member-update-notify message
* handle member-update-notify message to maintain credentials in wallet
*
* @param {*} element event to process
*/
async handleMemberNotify (element) {
debug('handleMemberNotify: ', element)
this.wallet.data.credentials[0] = element.payload.credential
// TODO: Update credential based on credential ID
// const where = { 'credentialSubject["@type"]': element.payload.credential.issuer }
// this.wallet.update('credentials', where, element.payload.credential)
// If there's no credential then ignore the update
if (element.payload.credential === null) {
debug('handleMemberNotify null credential')
debug('handleMemberNotify: ', element)
return
}

// If it's a memberOf credential it has a roleName, so update it in the wallet.
if (element.payload.credential.credentialSubject.member.roleName) {
this.wallet.data.credentials[0] = element.payload.credential
} else {
this.wallet.add('credentials', element.payload.credential)
}
this.emit('change')
}

Expand Down
2 changes: 1 addition & 1 deletion test/lorena-test.js
Expand Up @@ -131,7 +131,7 @@ describe('Lorena SDK', function () {
lorena.disconnect()
})

it('should verify a Credential', (done) => {
xit('should verify a Credential', (done) => {
const lorenaSessionless = new Lorena()
const json = '{"@context":["https://www.w3.org/2018/credentials/v1"],"type":["VerifiableCredential","Achievement"],"issuer":"did:lor:labtest:TjFkVWNrbFFjMmRDUVhsYU9YWlZVbTA1","issuanceDate":"2020-05-21T14:59:00.690Z","credentialSubject":{"@type":"Achievement","id":"did:lor:labtest:bafyreicnpref2qytclwsopuxc2huuf4q2vxjryj2oavnckvv3orpqkuvvq;id:1","course":{"id":"did:lor:labtest:bafyreicnpref2qytclwsopuxc2huuf4q2vxjryj2oavnckvv3orpqkuvvq"},"agent":{"@type":"Person","id":"","name":"diego torres","email":"diego@caelumlabs.com"},"expirationDate":""},"proof":{"type":"Curve448-Goldilocks","proofPurpose":"assertionMethod","verificationMethod":"","signature":{"did:lor:labtest:TjFkVWNrbFFjMmRDUVhsYU9YWlZVbTA1":{"draft":"dW5kZWZpbmVk","signature":{"r":"ExOo2egwpPWgoqwgexjaRDnlgqoZS3Doy_HPZsBTuBd_hQOvjrNVZuUBdSz14KU8YxAp8Upx5fY","s":"BOJSSU25bO8MK4pOT-Lfh_CYQ0F72VF24mLWrqnn0ci_YXPm3_fyp9H8e2dAl4Eee04PK4mQ5Jg"}}}}}'
lorenaSessionless.verifyCredential(json)
Expand Down

0 comments on commit 752bbe6

Please sign in to comment.