fix: review

This commit is contained in:
Yarmo Mackenbach 2024-01-29 14:05:17 +01:00
parent fe6588dcbb
commit f8d0422443
No known key found for this signature in database
GPG key ID: C248C28D432560ED
45 changed files with 48 additions and 114 deletions

View file

@ -82,7 +82,7 @@ export async function fetchASPE (uri) {
* @param {string} uri - The ASPE URI associated with the profile
* @returns {Promise<Profile>} The extracted profile
* @example
* const key = await doip.aspe.parseProfileJws('...');
* const key = await doip.aspe.parseProfileJws('...', 'aspe:domain.example:123');
*/
export async function parseProfileJws (profileJws, uri) {
const matches = uri.match(/aspe:(.*):(.*)/)
@ -132,7 +132,7 @@ export async function parseProfileJws (profileJws, uri) {
const profileDescription = payloadJson['http://ariadne.id/description']
/** @type {string} */
const profileThemeColor = payloadJson['http://ariadne.id/color']
/** @type {string[]} */
/** @type {Array<string>} */
const profileClaims = payloadJson['http://ariadne.id/claims']
const profileClaimsParsed = profileClaims.map(x => new Claim(x, uri))

View file

@ -70,15 +70,16 @@ export class Claim {
*/
this._status = ClaimStatus.INIT
/**
* @type {ServiceProvider[]}
* @type {Array<ServiceProvider>}
*/
this._matches = []
}
/**
* @function
* @param {object} claimObject - JSON representation of a claim
* @returns {Claim | Error} Parsed claim
* @param {*} claimObject - JSON representation of a claim
* @returns {Claim} Parsed claim
* @throws Will throw an error if the JSON object can't be coerced into a Claim
* @example
* doip.Claim.fromJSON(JSON.stringify(claim));
*/
@ -214,7 +215,6 @@ export class Claim {
* checked for the fingerprint. The verification stops when either a positive
* result was obtained, or an unambiguous claim definition was processed
* regardless of the result.
* @async
* @function
* @param {import('./types').VerificationConfig} [opts] - Options for proxy, fetchers
*/
@ -244,7 +244,7 @@ export class Claim {
let claimData = this._matches[index]
/** @type {import('./types').VerificationResult} */
/** @type {import('./types').VerificationResult | null} */
let verificationResult = null
let proofData = null
let proofFetchError

View file

@ -22,7 +22,6 @@ import { ProxyPolicy } from './enums.js'
/**
* The default claim verification config used throughout the library
* @constant
* @type {import('./types').VerificationConfig}
*/
export const opts = {

View file

@ -38,7 +38,6 @@ export const timeout = 5000
/**
* Execute a fetch request
* @function
* @async
* @param {object} data - Data used in the request
* @param {string} data.url - The URL of the account to verify
* @param {number} [data.fetcherTimeout] - Optional timeout for the fetcher

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* Fetch proofs from {@link module:profile~Profile} obtained through ASPE
* Fetch proofs from Profile obtained through ASPE
* @module fetcher/aspe
* @example
* import { fetcher } from 'doipjs';
@ -38,7 +38,6 @@ const reURI = /^aspe:([a-zA-Z0-9.\-_]*):([a-zA-Z0-9]*)/
/**
* Execute a fetch request
* @function
* @async
* @param {object} data - Data used in the request
* @param {string} data.aspeUri - ASPE URI of the targeted profile
* @param {number} [data.fetcherTimeout] - Optional timeout for the fetcher

View file

@ -35,7 +35,6 @@ export const timeout = 5000
/**
* Execute a fetch request
* @function
* @async
* @param {object} data - Data used in the request
* @param {string} data.domain - The targeted domain
* @param {number} [data.fetcherTimeout] - Optional timeout for the fetcher

View file

@ -35,7 +35,6 @@ export const timeout = 5000
/**
* Execute a GraphQL query via HTTP request
* @function
* @async
* @param {object} data - Data used in the request
* @param {string} data.url - The URL pointing at the GraphQL HTTP endpoint
* @param {string} data.query - The GraphQL query to fetch the data containing the proof

View file

@ -36,7 +36,6 @@ export const timeout = 5000
/**
* Execute a fetch request
* @function
* @async
* @param {object} data - Data used in the request
* @param {string} data.url - The URL pointing at targeted content
* @param {string} data.format - The format of the targeted content

View file

@ -35,13 +35,12 @@ export const timeout = 20000
/**
* Execute a fetch request
* @function
* @async
* @param {object} data - Data used in the request
* @param {string} data.nick - The nick of the targeted account
* @param {string} data.domain - The domain on which the targeted account is registered
* @param {number} [data.fetcherTimeout] - Optional timeout for the fetcher
* @param {import('../types').VerificationConfig} [opts] - Options used to enable the request
* @returns {Promise<string[]>} The fetched proofs from an IRC account
* @returns {Promise<Array<string>>} The fetched proofs from an IRC account
*/
export async function fn (data, opts) {
let timeoutHandle

View file

@ -37,7 +37,6 @@ export const timeout = 5000
/**
* Execute a fetch request
* @function
* @async
* @param {object} data - Data used in the request
* @param {string} data.eventId - The identifier of the targeted post
* @param {string} data.roomId - The identifier of the room containing the targeted post

View file

@ -45,7 +45,6 @@ export const timeout = 5000
/**
* Execute a fetch request
* @function
* @async
* @param {object} data - Data used in the request
* @param {string} data.url - The URL pointing at targeted content
* @param {OpenPgpQueryProtocol} data.protocol - The protocol used to access the targeted content

View file

@ -36,7 +36,6 @@ export const timeout = 5000
/**
* Execute a fetch request
* @function
* @async
* @param {object} data - Data used in the request
* @param {string} data.chat - Telegram public group name (slug)
* @param {string} data.user - Telegram username

View file

@ -41,17 +41,12 @@ let iqCaller = null
* Start the XMPP client
* @ignore
* @function
* @async
* @param {import('../types').XmppClaimVerificationConfig} params - XMPP claim verification config
* @returns {Promise<object>} The fetched proofs from an XMPP account
*/
const xmppStart = async (params) => {
return new Promise((resolve, reject) => {
const xmpp = client({
service: params.service,
username: params.username,
password: params.password
})
const xmpp = client({ ...params })
if (process.env.NODE_ENV !== 'production') {
debug(xmpp, true)
}
@ -69,7 +64,6 @@ const xmppStart = async (params) => {
/**
* Execute a fetch request
* @function
* @async
* @param {object} data - Data used in the request
* @param {string} data.id - The identifier of the targeted account
* @param {number} [data.fetcherTimeout] - Optional timeout for the fetcher

View file

@ -13,6 +13,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* @module doipjs
* @license Apache-2.0
*/
export { Profile } from './profile.js'
export { Persona } from './persona.js'
export { Claim } from './claim.js'

View file

@ -18,7 +18,6 @@ import { Claim } from './claim.js'
/**
* @class
* @classdesc A persona with identity claims
* @public
* @example
* const claim = Claim('https://alice.tld', '123');
* const pers = Persona('Alice', 'About Alice', [claim]);
@ -26,7 +25,7 @@ import { Claim } from './claim.js'
export class Persona {
/**
* @param {string} name - Name of the persona
* @param {Claim[]} claims - Claims of the persona
* @param {Array<Claim>} claims - Claims of the persona
*/
constructor (name, claims) {
/**
@ -67,7 +66,7 @@ export class Persona {
this.themeColor = null
/**
* List of identity claims
* @type {Claim[]}
* @type {Array<Claim>}
* @public
*/
this.claims = claims

View file

@ -20,7 +20,6 @@ import { Persona } from './persona.js'
* @class
* @classdesc A profile of personas with identity claims
* @param {Array<Persona>} personas - Personas of the profile
* @public
* @example
* const claim = Claim('https://alice.tld', '123');
* const pers = Persona('Alice', 'About Alice', [claim]);
@ -80,7 +79,7 @@ export class Profile {
}
/**
* List of verifier URLs
* @type {import('./types').ProfileVerifier[]}
* @type {Array<import('./types').ProfileVerifier>}
* @public
*/
this.verifiers = []

View file

@ -29,7 +29,6 @@ import { ServiceProvider } from './serviceProvider.js'
* the `data` parameter and the proxy policy set in the `opts` parameter to
* choose the right approach to fetch the proof. An error will be thrown if no
* approach is possible.
* @async
* @param {ServiceProvider} data - Data from a claim definition
* @param {import('./types').VerificationConfig} opts - Options to enable the request
* @returns {Promise<object|string>} Fetched proof data

View file

@ -14,9 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* ActivityPub service provider
*
* Link: [Keyoxide documentation](https://docs.keyoxide.org/service-providers/activitypub/)
* ActivityPub service provider ({@link https://docs.keyoxide.org/service-providers/activitypub/|Keyoxide docs})
* @module serviceProviders/activitypub
* @example
* import { ServiceProviderDefinitions } from 'doipjs';

View file

@ -14,9 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* ASPE service provider
*
* Link: [Keyoxide documentation](https://docs.keyoxide.org/service-providers/aspe/)
* ASPE service provider ({@link https://docs.keyoxide.org/service-providers/aspe/|Keyoxide docs})
* @module serviceProviders/aspe
* @example
* import { ServiceProviderDefinitions } from 'doipjs';

View file

@ -14,9 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* Discourse service provider
*
* Link: [Keyoxide documentation](https://docs.keyoxide.org/service-providers/discourse/)
* Discourse service provider ({@link https://docs.keyoxide.org/service-providers/discourse/|Keyoxide docs})
* @module serviceProviders/discourse
* @example
* import { ServiceProviderDefinitions } from 'doipjs';

View file

@ -14,9 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* DNS service provider
*
* Link: [Keyoxide documentation](https://docs.keyoxide.org/service-providers/dns/)
* DNS service provider ({@link https://docs.keyoxide.org/service-providers/dns/|Keyoxide docs})
* @module serviceProviders/dns
* @example
* import { ServiceProviderDefinitions } from 'doipjs';

View file

@ -14,9 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* Forem service provider
*
* Link: [Keyoxide documentation](https://docs.keyoxide.org/service-providers/forem/)
* Forem service provider ({@link https://docs.keyoxide.org/service-providers/forem/|Keyoxide docs})
* @module serviceProviders/forem
* @example
* import { ServiceProviderDefinitions } from 'doipjs';

View file

@ -14,9 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* Forgejo service provider
*
* Link: [Keyoxide documentation](https://docs.keyoxide.org/service-providers/forgejo/)
* Forgejo service provider ({@link https://docs.keyoxide.org/service-providers/forgejo/|Keyoxide docs})
* @module serviceProviders/forgejo
* @example
* import { ServiceProviderDefinitions } from 'doipjs';

View file

@ -14,9 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* Gitea service provider
*
* Link: [Keyoxide documentation](https://docs.keyoxide.org/service-providers/gitea/)
* Gitea service provider ({@link https://docs.keyoxide.org/service-providers/gitea/|Keyoxide docs})
* @module serviceProviders/gitea
* @example
* import { ServiceProviderDefinitions } from 'doipjs';

View file

@ -14,9 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* Github service provider
*
* Link: [Keyoxide documentation](https://docs.keyoxide.org/service-providers/github/)
* Github service provider ({@link https://docs.keyoxide.org/service-providers/github/|Keyoxide docs})
* @module serviceProviders/github
* @example
* import { ServiceProviderDefinitions } from 'doipjs';

View file

@ -14,9 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* Gitlab service provider
*
* Link: [Keyoxide documentation](https://docs.keyoxide.org/service-providers/gitlab/)
* Gitlab service provider ({@link https://docs.keyoxide.org/service-providers/gitlab/|Keyoxide docs})
* @module serviceProviders/gitlab
* @example
* import { ServiceProviderDefinitions } from 'doipjs';

View file

@ -14,9 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* Hackernews service provider
*
* Link: [Keyoxide documentation](https://docs.keyoxide.org/service-providers/hackernews/)
* Hackernews service provider ({@link https://docs.keyoxide.org/service-providers/hackernews/|Keyoxide docs})
* @module serviceProviders/hackernews
* @example
* import { ServiceProviderDefinitions } from 'doipjs';

View file

@ -14,9 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* IRC service provider
*
* Link: [Keyoxide documentation](https://docs.keyoxide.org/service-providers/irc/)
* IRC service provider ({@link https://docs.keyoxide.org/service-providers/irc/|Keyoxide docs})
* @module serviceProviders/irc
* @example
* import { ServiceProviderDefinitions } from 'doipjs';

View file

@ -14,9 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* Keybase service provider
*
* Link: [Keyoxide documentation](https://docs.keyoxide.org/service-providers/keybase/)
* Keybase service provider ({@link https://docs.keyoxide.org/service-providers/keybase/|Keyoxide docs})
* @module serviceProviders/keybase
* @example
* import { ServiceProviderDefinitions } from 'doipjs';

View file

@ -14,9 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* Liberapay service provider
*
* Link: [Keyoxide documentation](https://docs.keyoxide.org/service-providers/liberapay/)
* Liberapay service provider ({@link https://docs.keyoxide.org/service-providers/liberapay/|Keyoxide docs})
* @module serviceProviders/liberapay
* @example
* import { ServiceProviderDefinitions } from 'doipjs';

View file

@ -14,9 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* Lichess service provider
*
* Link: [Keyoxide documentation](https://docs.keyoxide.org/service-providers/lichess/)
* Lichess service provider ({@link https://docs.keyoxide.org/service-providers/lichess/|Keyoxide docs})
* @module serviceProviders/lichess
* @example
* import { ServiceProviderDefinitions } from 'doipjs';

View file

@ -14,9 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* Lobste.rs service provider
*
* Link: [Keyoxide documentation](https://docs.keyoxide.org/service-providers/lobsters/)
* Lobste.rs service provider ({@link https://docs.keyoxide.org/service-providers/lobsters/|Keyoxide docs})
* @module serviceProviders/lobsters
* @example
* import { ServiceProviderDefinitions } from 'doipjs';

View file

@ -14,9 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* Matrix service provider
*
* Link: [Keyoxide documentation](https://docs.keyoxide.org/service-providers/matrix/)
* Matrix service provider ({@link https://docs.keyoxide.org/service-providers/matrix/|Keyoxide docs})
* @module serviceProviders/matrix
* @example
* import { ServiceProviderDefinitions } from 'doipjs';

View file

@ -14,9 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* OpenCollective service provider
*
* Link: [Keyoxide documentation](https://docs.keyoxide.org/service-providers/opencollective/)
* OpenCollective service provider ({@link https://docs.keyoxide.org/service-providers/opencollective/|Keyoxide docs})
* @module serviceProviders/opencollective
* @example
* import { ServiceProviderDefinitions } from 'doipjs';

View file

@ -14,9 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* OpenPGP service provider
*
* Link: [Keyoxide documentation](https://docs.keyoxide.org/service-providers/openpgp/)
* OpenPGP service provider ({@link https://docs.keyoxide.org/service-providers/openpgp/|Keyoxide docs})
* @module serviceProviders/openpgp
* @example
* import { ServiceProviderDefinitions } from 'doipjs';

View file

@ -14,9 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* ORCiD service provider
*
* Link: [Keyoxide documentation](https://docs.keyoxide.org/service-providers/orcid/)
* ORCiD service provider ({@link https://docs.keyoxide.org/service-providers/orcid/|Keyoxide docs})
* @module serviceProviders/orcid
* @example
* import { ServiceProviderDefinitions } from 'doipjs';

View file

@ -14,9 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* Owncast service provider
*
* Link: [Keyoxide documentation](https://docs.keyoxide.org/service-providers/owncast/)
* Owncast service provider ({@link https://docs.keyoxide.org/service-providers/owncast/|Keyoxide docs})
* @module serviceProviders/owncast
* @example
* import { ServiceProviderDefinitions } from 'doipjs';

View file

@ -14,9 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* Reddit service provider
*
* Link: [Keyoxide documentation](https://docs.keyoxide.org/service-providers/reddit/)
* Reddit service provider ({@link https://docs.keyoxide.org/service-providers/reddit/|Keyoxide docs})
* @module serviceProviders/reddit
* @example
* import { ServiceProviderDefinitions } from 'doipjs';

View file

@ -14,9 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* StackExchange service provider
*
* Link: [Keyoxide documentation](https://docs.keyoxide.org/service-providers/stackexchange/)
* StackExchange service provider ({@link https://docs.keyoxide.org/service-providers/stackexchange/|Keyoxide docs})
* @module serviceProviders/stackexchange
* @example
* import { ServiceProviderDefinitions } from 'doipjs';

View file

@ -14,9 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* Telegram service provider
*
* Link: [Keyoxide documentation](https://docs.keyoxide.org/service-providers/telegram/)
* Telegram service provider ({@link https://docs.keyoxide.org/service-providers/telegram/|Keyoxide docs})
* @module serviceProviders/telegram
* @example
* import { ServiceProviderDefinitions } from 'doipjs';

View file

@ -14,9 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* Twitter service provider
*
* Link: [Keyoxide documentation](https://docs.keyoxide.org/service-providers/twitter/)
* Twitter service provider ({@link https://docs.keyoxide.org/service-providers/twitter/|Keyoxide docs})
* @module serviceProviders/twitter
* @example
* import { ServiceProviderDefinitions } from 'doipjs';

View file

@ -14,9 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* XMPP service provider
*
* Link: [Keyoxide documentation](https://docs.keyoxide.org/service-providers/xmpp/)
* XMPP service provider ({@link https://docs.keyoxide.org/service-providers/xmpp/|Keyoxide docs})
* @module serviceProviders/xmpp
* @example
* import { ServiceProviderDefinitions } from 'doipjs';

View file

@ -26,7 +26,6 @@ import { Persona } from './persona.js'
/**
* Extract the profile from a signature and fetch the associated key
* @async
* @param {string} signature - The plaintext signature to parse
* @returns {Promise<Profile>} The profile obtained from the signature
*/

View file

@ -57,7 +57,7 @@ import { PublicKeyType, PublicKeyEncoding, PublicKeyFetchMethod, ProxyPolicy, Cl
* @typedef {object} ServiceProviderProof
* @property {ServiceProviderProofRequest} request - Details to request the potential proof
* @property {ServiceProviderProofResponse} response - Details about the expected response
* @property {ProofTarget[]} target - Details about the target located in the response
* @property {Array<ProofTarget>} target - Details about the target located in the response
*/
/**
@ -175,7 +175,7 @@ import { PublicKeyType, PublicKeyEncoding, PublicKeyFetchMethod, ProxyPolicy, Cl
* @property {boolean} result - Whether the proof was found and the claim verified
* @property {boolean} completed - Whether the verification process completed without errors
* @property {VerificationResultProof} [proof] - Details about the proof and how it was fetched
* @property {any[]} errors - Errors that ocurred during the verification process
* @property {Array<any>} errors - Errors that ocurred during the verification process
*/
/**
@ -191,7 +191,7 @@ import { PublicKeyType, PublicKeyEncoding, PublicKeyFetchMethod, ProxyPolicy, Cl
* @property {ClaimFormat} format - How the response data is formatted
* @property {EntityEncodingFormat} encoding - How the response data is encoded
* @property {ClaimRelation} relation - How the proof is related to the response data
* @property {string[]} path - Path to the proof inside the response data object
* @property {Array<string>} path - Path to the proof inside the response data object
*/
export const Types = {}

View file

@ -215,8 +215,8 @@ const containsProof = async (data, params) => {
/**
* Run a JSON object through the verification process
* @function
* @param {any} proofData - Data potentially containing the proof
* @param {string[]} checkPath - Paths to check for proof
* @param {*} proofData - Data potentially containing the proof
* @param {Array<string>} checkPath - Paths to check for proof
* @param {import('./types').VerificationParams} params - Verification parameters
* @returns {Promise<boolean>} Whether the proof was found in the object
*/
@ -266,7 +266,6 @@ const runJSON = async (proofData, checkPath, params) => {
/**
* Run the verification by searching for the proof in the fetched data
* @async
* @param {object} proofData - The proof data
* @param {ServiceProvider} claimData - The claim data
* @param {string} fingerprint - The fingerprint