Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add revocation to js issuer and disclose functions #33

Merged
merged 12 commits into from
May 10, 2021
17 changes: 15 additions & 2 deletions src/assets/js/irma-functions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// be sure that you are loading irmajs functions

function irmaDiscloseOrSign(attributes, header = 'Disclosing attribute with', label = '', message = '') {
function irmaDiscloseOrSign(attributes, header = 'Disclosing attribute with', label = '', message = '',
revocation = null) {
const labelRequest = !label ? {} : {
'labels': {
'0': {
Expand All @@ -12,11 +13,13 @@ function irmaDiscloseOrSign(attributes, header = 'Disclosing attribute with', la
const request = !message ? {
'@context': 'https://irma.app/ld/request/disclosure/v2',
'disclose': attributes,
'revocation': revocation,
...labelRequest
} : {
'@context': 'https://irma.app/ld/request/signature/v2',
'message': message,
'disclose': attributes,
'revocation': revocation,
...labelRequest
};

Expand All @@ -30,15 +33,25 @@ function irmaIssueCredential(credential, attributes, header = 'Issuing credentia
console.log('issueCredential');
let validity = {};
if (attributes.validity) {
validity = {validity: attributes.validity};
validity = {
validity: attributes.validity
};
delete attributes.validity;
}
let revocationKey = {};
if (attributes.revocationKey) {
revocationKey = {
revocationKey: attributes.revocationKey
};
delete attributes.revocationKey;
}
const request = {
'@context': 'https://irma.app/ld/request/issuance/v2',
'credentials': [{
credential: credential,
attributes: attributes,
...validity,
...revocationKey,
}],
'disclose': disclosePayload,
};
Expand Down
1 change: 1 addition & 0 deletions src/id-card/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@
},
saveIdCard: function () {
console.log('saveIdCard');
this.idCardToIssue['revocationKey'] = this.idCardToIssue.number;
const self = this;
return irmaIssueCredential(CREDENTIAL.ID_CARD_ID_CARD, this.idCardToIssue, HEADER_MESSAGES.ISSUE_ID_CARD_ID_CARD)
.then((_) => {
Expand Down