From 6eb24351278da8322954d5c4d1963cf56e9f3f9c Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Mon, 10 Jul 2023 10:25:17 +0200 Subject: [PATCH] fix: fix compliance with Keyoxide v2 spec --- src/claim.js | 12 ++++++++---- src/profile.js | 6 +++--- src/serviceProvider.js | 16 +++++++++++++++- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/claim.js b/src/claim.js index b9867c1..8ae31c7 100644 --- a/src/claim.js +++ b/src/claim.js @@ -321,20 +321,24 @@ export class Claim { */ toJSON () { let displayName = this._uri - let displayUrl = '' - let displayServiceProviderName = '' + let displayUrl = null + let displayServiceProviderName = null if (this._status >= 200 && this._status < 300) { displayName = this._matches[0].profile.display displayUrl = this._matches[0].profile.uri - displayServiceProviderName = this._matches[0].about.id + displayServiceProviderName = this._matches[0].about.name + } else if (this._status == ClaimStatus.MATCHED && !this.isAmbiguous()) { + displayName = this._matches[0].profile.display + displayUrl = this._matches[0].profile.uri + displayServiceProviderName = this._matches[0].about.name } return { claimVersion: 2, uri: this._uri, proofs: [this._fingerprint], - matches: this._matches, + matches: this._matches.map(x => x.toJSON()), status: this._status, display: { name: displayName, diff --git a/src/profile.js b/src/profile.js index e816037..cc74a69 100644 --- a/src/profile.js +++ b/src/profile.js @@ -84,7 +84,7 @@ export class Profile { */ encoding: PublicKeyEncoding.NONE, /** - * The raw cryptographic key + * The encoded cryptographic key * @type {string | null} * @public */ @@ -164,8 +164,8 @@ export class Profile { primaryPersonaIndex: this.primaryPersonaIndex, publicKey: { keyType: this.publicKey.keyType, - format: this.publicKey.format, - keyData: this.publicKey.keyData, + encoding: this.publicKey.encoding, + encodedKey: this.publicKey.encodedKey, fetch: { method: this.publicKey.fetch.method, query: this.publicKey.fetch.query, diff --git a/src/serviceProvider.js b/src/serviceProvider.js index 0d8ba49..3ef5d99 100644 --- a/src/serviceProvider.js +++ b/src/serviceProvider.js @@ -94,7 +94,7 @@ export class ServiceProvider { request: { /** * Location of the proof - * @type {string} + * @type {string | null} */ uri: spObj.proof.request.uri, /** @@ -131,4 +131,18 @@ export class ServiceProvider { target: spObj.proof.target } } + + /** + * Get a JSON representation of the ServiceProvider object + * @function + * @returns {object} + */ + toJSON () { + return { + about: this.about, + profile: this.profile, + claim: this.claim, + proof: this.proof + } + } }