mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2024-12-22 22:49:28 -07:00
fix: fix compliance with Keyoxide v2 spec
This commit is contained in:
parent
58561d6e0d
commit
6eb2435127
3 changed files with 26 additions and 8 deletions
12
src/claim.js
12
src/claim.js
|
@ -321,20 +321,24 @@ export class Claim {
|
||||||
*/
|
*/
|
||||||
toJSON () {
|
toJSON () {
|
||||||
let displayName = this._uri
|
let displayName = this._uri
|
||||||
let displayUrl = ''
|
let displayUrl = null
|
||||||
let displayServiceProviderName = ''
|
let displayServiceProviderName = null
|
||||||
|
|
||||||
if (this._status >= 200 && this._status < 300) {
|
if (this._status >= 200 && this._status < 300) {
|
||||||
displayName = this._matches[0].profile.display
|
displayName = this._matches[0].profile.display
|
||||||
displayUrl = this._matches[0].profile.uri
|
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 {
|
return {
|
||||||
claimVersion: 2,
|
claimVersion: 2,
|
||||||
uri: this._uri,
|
uri: this._uri,
|
||||||
proofs: [this._fingerprint],
|
proofs: [this._fingerprint],
|
||||||
matches: this._matches,
|
matches: this._matches.map(x => x.toJSON()),
|
||||||
status: this._status,
|
status: this._status,
|
||||||
display: {
|
display: {
|
||||||
name: displayName,
|
name: displayName,
|
||||||
|
|
|
@ -84,7 +84,7 @@ export class Profile {
|
||||||
*/
|
*/
|
||||||
encoding: PublicKeyEncoding.NONE,
|
encoding: PublicKeyEncoding.NONE,
|
||||||
/**
|
/**
|
||||||
* The raw cryptographic key
|
* The encoded cryptographic key
|
||||||
* @type {string | null}
|
* @type {string | null}
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
|
@ -164,8 +164,8 @@ export class Profile {
|
||||||
primaryPersonaIndex: this.primaryPersonaIndex,
|
primaryPersonaIndex: this.primaryPersonaIndex,
|
||||||
publicKey: {
|
publicKey: {
|
||||||
keyType: this.publicKey.keyType,
|
keyType: this.publicKey.keyType,
|
||||||
format: this.publicKey.format,
|
encoding: this.publicKey.encoding,
|
||||||
keyData: this.publicKey.keyData,
|
encodedKey: this.publicKey.encodedKey,
|
||||||
fetch: {
|
fetch: {
|
||||||
method: this.publicKey.fetch.method,
|
method: this.publicKey.fetch.method,
|
||||||
query: this.publicKey.fetch.query,
|
query: this.publicKey.fetch.query,
|
||||||
|
|
|
@ -94,7 +94,7 @@ export class ServiceProvider {
|
||||||
request: {
|
request: {
|
||||||
/**
|
/**
|
||||||
* Location of the proof
|
* Location of the proof
|
||||||
* @type {string}
|
* @type {string | null}
|
||||||
*/
|
*/
|
||||||
uri: spObj.proof.request.uri,
|
uri: spObj.proof.request.uri,
|
||||||
/**
|
/**
|
||||||
|
@ -131,4 +131,18 @@ export class ServiceProvider {
|
||||||
target: spObj.proof.target
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue