From eaf4f1316da7011518e97639c4f03e8dd8c211ff Mon Sep 17 00:00:00 2001 From: asher Date: Wed, 14 Apr 2021 16:04:46 +1200 Subject: [PATCH 01/10] add revocation to js issuer and disclose functions --- src/assets/js/irma-functions.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/assets/js/irma-functions.js b/src/assets/js/irma-functions.js index f1271b8..05e3fbb 100644 --- a/src/assets/js/irma-functions.js +++ b/src/assets/js/irma-functions.js @@ -1,6 +1,6 @@ // 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 = []) { const labelRequest = !label ? {} : { 'labels': { '0': { @@ -12,11 +12,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 }; @@ -26,7 +28,7 @@ function irmaDiscloseOrSign(attributes, header = 'Disclosing attribute with', la }); } -function irmaIssueCredential(credential, attributes, header = 'Issuing credential with', disclosePayload = null) { +function irmaIssueCredential(credential, attributes, header = 'Issuing credential with', disclosePayload = null, revocationKey = None) { console.log('issueCredential'); let validity = {}; if (attributes.validity) { @@ -38,6 +40,7 @@ function irmaIssueCredential(credential, attributes, header = 'Issuing credentia 'credentials': [{ credential: credential, attributes: attributes, + revocationKey: revocationKey, ...validity, }], 'disclose': disclosePayload, From 99bdc77eee1a9152c1c836fb28b3163ce15c716b Mon Sep 17 00:00:00 2001 From: asher Date: Fri, 16 Apr 2021 11:09:14 +1200 Subject: [PATCH 02/10] seperated revocable credential issuer --- src/assets/js/irma-functions.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/assets/js/irma-functions.js b/src/assets/js/irma-functions.js index 05e3fbb..4684588 100644 --- a/src/assets/js/irma-functions.js +++ b/src/assets/js/irma-functions.js @@ -28,7 +28,29 @@ function irmaDiscloseOrSign(attributes, header = 'Disclosing attribute with', la }); } -function irmaIssueCredential(credential, attributes, header = 'Issuing credential with', disclosePayload = null, revocationKey = None) { +function irmaIssueCredential(credential, attributes, header = 'Issuing credential with', disclosePayload = null) { + console.log('issueCredential'); + let validity = {}; + if (attributes.validity) { + validity = {validity: attributes.validity}; + delete attributes.validity; + } + const request = { + '@context': 'https://irma.app/ld/request/issuance/v2', + 'credentials': [{ + credential: credential, + attributes: attributes, + ...validity, + }], + 'disclose': disclosePayload, + }; + return irmaDoSession(request, header).then(function (result) { + console.log("Successful issuing credential! 🎉", result) + return result; + }); +} + +function irmaIssueRevocableCredential(credential, attributes, revocationKey, header = 'Issuing credential with', disclosePayload = null) { console.log('issueCredential'); let validity = {}; if (attributes.validity) { From 4b300d701f5a0bd8e4506525b12ff275eda14075 Mon Sep 17 00:00:00 2001 From: asher Date: Mon, 19 Apr 2021 12:29:10 +1200 Subject: [PATCH 03/10] receive revocationKey in attributes --- src/assets/js/irma-functions.js | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/src/assets/js/irma-functions.js b/src/assets/js/irma-functions.js index 4684588..2ee45f1 100644 --- a/src/assets/js/irma-functions.js +++ b/src/assets/js/irma-functions.js @@ -35,35 +35,18 @@ function irmaIssueCredential(credential, attributes, header = 'Issuing credentia validity = {validity: attributes.validity}; delete attributes.validity; } - const request = { - '@context': 'https://irma.app/ld/request/issuance/v2', - 'credentials': [{ - credential: credential, - attributes: attributes, - ...validity, - }], - 'disclose': disclosePayload, - }; - return irmaDoSession(request, header).then(function (result) { - console.log("Successful issuing credential! 🎉", result) - return result; - }); -} - -function irmaIssueRevocableCredential(credential, attributes, revocationKey, header = 'Issuing credential with', disclosePayload = null) { - console.log('issueCredential'); - let validity = {}; - if (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, - revocationKey: revocationKey, ...validity, + ...revocationKey, }], 'disclose': disclosePayload, }; From 790f235365be19dbbb6bce0c4d1d380a5e4f160e Mon Sep 17 00:00:00 2001 From: Ehsan Faraji-Jalal Date: Thu, 6 May 2021 09:10:24 +1200 Subject: [PATCH 04/10] set revocation key and request for proof --- src/id-card/index.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/id-card/index.html b/src/id-card/index.html index 3d73965..8f97476 100644 --- a/src/id-card/index.html +++ b/src/id-card/index.html @@ -223,6 +223,7 @@ }, saveIdCard: function () { console.log('saveIdCard'); + this.idCardToIssue['revocationKey'] = luxon.DateTime.now().ts; const self = this; return irmaIssueCredential(CREDENTIAL.ID_CARD_ID_CARD, this.idCardToIssue, HEADER_MESSAGES.ISSUE_ID_CARD_ID_CARD) .then((_) => { @@ -281,7 +282,7 @@ ] ]]; - irmaDiscloseOrSign(toDisclose, 'Please, provide your IDNZ card details.') + irmaDiscloseOrSign(toDisclose, 'Please, provide your IDNZ card details.', '', '', [CREDENTIAL.ID_CARD_ID_CARD]) .then((result) => { this.messageClear(); this.logged = true; From 9fc7a6fdc574c338f84bcf6a7b619e1c4e5ea94f Mon Sep 17 00:00:00 2001 From: Ehsan Faraji-Jalal Date: Thu, 6 May 2021 09:10:56 +1200 Subject: [PATCH 05/10] request for nonrevoked proof when disclosing --- src/wine-shop.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wine-shop.html b/src/wine-shop.html index b6e5e1b..22f3d9d 100644 --- a/src/wine-shop.html +++ b/src/wine-shop.html @@ -74,7 +74,7 @@ clearOutput(); - return irmaDiscloseOrSign(toDisclose.toApi(), HEADER_MESSAGES.DISCLOSE_AGE) + return irmaDiscloseOrSign(toDisclose.toApi(), HEADER_MESSAGES.DISCLOSE_AGE, '', '', [CREDENTIAL.ID_CARD_ID_CARD]) .then(result => { showSuccess('Success'); return irmaDisclosedResultSingleRawValue(result); From af45592a0413f7a2cba080e1eb409dd0c0fb2d78 Mon Sep 17 00:00:00 2001 From: Ehsan Faraji-Jalal Date: Thu, 6 May 2021 09:12:04 +1200 Subject: [PATCH 06/10] styling --- src/assets/js/irma-functions.js | 59 ++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/src/assets/js/irma-functions.js b/src/assets/js/irma-functions.js index d02550f..c3227f7 100644 --- a/src/assets/js/irma-functions.js +++ b/src/assets/js/irma-functions.js @@ -1,43 +1,48 @@ // be sure that you are loading irmajs functions -function irmaDiscloseOrSign(attributes, header = 'Disclosing attribute with', label = '', message = '', revocation = []) { - const labelRequest = !label ? {} : { - 'labels': { - '0': { - 'en': label, - 'nl': label - } - } - }; - 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 - }; +function irmaDiscloseOrSign(attributes, header = 'Disclosing attribute with', label = '', message = '', +revocation = null) { + const labelRequest = !label ? {} : { + 'labels': { + '0': { + 'en': label, + 'nl': label + } + } + }; + 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 + }; - return irmaDoSession(request, header).then(result => { - console.log("Successful disclosure! 🎉", result) - return result; - }); + return irmaDoSession(request, header).then(result => { + console.log("Successful disclosure! 🎉", result) + return result; + }); } function irmaIssueCredential(credential, attributes, header = 'Issuing credential with', disclosePayload = null) { 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}; + revocationKey = { + revocationKey: attributes.revocationKey + }; delete attributes.revocationKey; } const request = { From 4e56135e57d0645e496a3018f5360774187afbf1 Mon Sep 17 00:00:00 2001 From: Ehsan Faraji-Jalal Date: Mon, 10 May 2021 12:55:14 +1200 Subject: [PATCH 07/10] convert revocation key to string --- src/id-card/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/id-card/index.html b/src/id-card/index.html index 8f97476..3cc59b3 100644 --- a/src/id-card/index.html +++ b/src/id-card/index.html @@ -223,7 +223,7 @@ }, saveIdCard: function () { console.log('saveIdCard'); - this.idCardToIssue['revocationKey'] = luxon.DateTime.now().ts; + this.idCardToIssue['revocationKey'] = `${luxon.DateTime.now().ts}`; const self = this; return irmaIssueCredential(CREDENTIAL.ID_CARD_ID_CARD, this.idCardToIssue, HEADER_MESSAGES.ISSUE_ID_CARD_ID_CARD) .then((_) => { From 7945cacce462ae35b8711ee51c1b3769a98e0b23 Mon Sep 17 00:00:00 2001 From: Ehsan Faraji-Jalal Date: Mon, 10 May 2021 12:56:15 +1200 Subject: [PATCH 08/10] not asking nonrevok proof for now --- src/wine-shop.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wine-shop.html b/src/wine-shop.html index 22f3d9d..b6e5e1b 100644 --- a/src/wine-shop.html +++ b/src/wine-shop.html @@ -74,7 +74,7 @@ clearOutput(); - return irmaDiscloseOrSign(toDisclose.toApi(), HEADER_MESSAGES.DISCLOSE_AGE, '', '', [CREDENTIAL.ID_CARD_ID_CARD]) + return irmaDiscloseOrSign(toDisclose.toApi(), HEADER_MESSAGES.DISCLOSE_AGE) .then(result => { showSuccess('Success'); return irmaDisclosedResultSingleRawValue(result); From e5108e02f2749cfba29b3158978a35e2ac96f6a3 Mon Sep 17 00:00:00 2001 From: Ehsan Faraji-Jalal Date: Mon, 10 May 2021 12:56:15 +1200 Subject: [PATCH 09/10] not asking nonrevok proof for now --- src/id-card/index.html | 2 +- src/wine-shop.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/id-card/index.html b/src/id-card/index.html index 3cc59b3..a96c2a6 100644 --- a/src/id-card/index.html +++ b/src/id-card/index.html @@ -282,7 +282,7 @@ ] ]]; - irmaDiscloseOrSign(toDisclose, 'Please, provide your IDNZ card details.', '', '', [CREDENTIAL.ID_CARD_ID_CARD]) + irmaDiscloseOrSign(toDisclose, 'Please, provide your IDNZ card details.') .then((result) => { this.messageClear(); this.logged = true; diff --git a/src/wine-shop.html b/src/wine-shop.html index 22f3d9d..b6e5e1b 100644 --- a/src/wine-shop.html +++ b/src/wine-shop.html @@ -74,7 +74,7 @@ clearOutput(); - return irmaDiscloseOrSign(toDisclose.toApi(), HEADER_MESSAGES.DISCLOSE_AGE, '', '', [CREDENTIAL.ID_CARD_ID_CARD]) + return irmaDiscloseOrSign(toDisclose.toApi(), HEADER_MESSAGES.DISCLOSE_AGE) .then(result => { showSuccess('Success'); return irmaDisclosedResultSingleRawValue(result); From b24aa328b658de07d838fc1d4a9543cc5080c32d Mon Sep 17 00:00:00 2001 From: Ehsan Faraji-Jalal Date: Mon, 10 May 2021 15:32:50 +1200 Subject: [PATCH 10/10] use id card number as revocationKey --- src/id-card/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/id-card/index.html b/src/id-card/index.html index a96c2a6..3c01516 100644 --- a/src/id-card/index.html +++ b/src/id-card/index.html @@ -223,7 +223,7 @@ }, saveIdCard: function () { console.log('saveIdCard'); - this.idCardToIssue['revocationKey'] = `${luxon.DateTime.now().ts}`; + 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((_) => {