Run prettier

This commit is contained in:
Yarmo Mackenbach 2020-12-05 23:14:09 +01:00
parent b9c76b7c0e
commit 34dc50d031
3 changed files with 66 additions and 58 deletions

View file

@ -50,11 +50,11 @@ Verifies the identity behind the provided **array of uris** using the **fingerpr
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ----------- | ------ | --------- | -------------------------------- | | ----------- | ------ | --------- | ---------------------------- |
| uriArray | array | true | array of uris | | uriArray | array | true | array of uris |
| fingerprint | string | false | the fingerprint of the claim | | fingerprint | string | false | the fingerprint of the claim |
| opts | object | false | options (see below) | | opts | object | false | options (see below) |
**Options** **Options**
@ -71,15 +71,15 @@ _(async)_ doip.claims.verify(key, [fingerprint], [opts])
Verifies the identity behind the claims contained within the provided Verifies the identity behind the claims contained within the provided
**key** using the **fingerprint**. This key is outputted by the **key** using the **fingerprint**. This key is outputted by the
[keys.fetch.*()](#keysfetchuriuri) commands. [keys.fetch.\*()](#keysfetchuriuri) commands.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ----------- | ------ | --------- | -------------------------------- | | ----------- | ------ | --------- | ---------------------------- |
| key | object | true | a public key | | key | object | true | a public key |
| fingerprint | string | false | the fingerprint of the claim | | fingerprint | string | false | the fingerprint of the claim |
| opts | object | false | options (see below) | | opts | object | false | options (see below) |
**Options** **Options**
@ -99,9 +99,9 @@ other `keys.fetch.*` commands.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ----------- | ------ | --------- | -------------------------------- | | ---- | ------ | --------- | --------------------- |
| uri | string | true | public key identifier | | uri | string | true | public key identifier |
Possible formats for `uri`: Possible formats for `uri`:
@ -124,10 +124,10 @@ Fetches a key using HKP-compatible key servers.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---------------- | ------ | --------- | -------------------------------- | | ---------------- | ------ | --------- | --------------------- |
| fingerprint | string | true | public key identifier | | fingerprint | string | true | public key identifier |
| keyserverBaseUrl | string | false | base URL of keyserver | | keyserverBaseUrl | string | false | base URL of keyserver |
`keyserverBaseUrl` defaults to `https://keys.openpgp.org/`. `keyserverBaseUrl` defaults to `https://keys.openpgp.org/`.
@ -143,10 +143,10 @@ Fetches a key using HKP-compatible key servers.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---------------- | ------ | --------- | -------------------------------- | | ---------------- | ------ | --------- | --------------------- |
| email | string | true | public key identifier | | email | string | true | public key identifier |
| keyserverBaseUrl | string | false | base URL of keyserver | | keyserverBaseUrl | string | false | base URL of keyserver |
`keyserverBaseUrl` defaults to `https://keys.openpgp.org/`. `keyserverBaseUrl` defaults to `https://keys.openpgp.org/`.
@ -162,9 +162,9 @@ Fetches a key using the WKD protocol.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ----------- | ------ | --------- | -------------------------------- | | ----- | ------ | --------- | -------------- |
| wkdId | string | true | WKD identifier | | wkdId | string | true | WKD identifier |
`wkdId` looks like an email address and is formatted as `username@domain.org`. `wkdId` looks like an email address and is formatted as `username@domain.org`.
@ -180,9 +180,9 @@ Parses the `keyPlaintext`.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------------ | ------ | --------- | -------------------------------- | | ------------ | ------ | --------- | ----------------- |
| keyPlaintext | string | true | ASCII key content | | keyPlaintext | string | true | ASCII key content |
**Returns** **Returns**

View file

@ -16,7 +16,11 @@ limitations under the License.
const path = require('path') const path = require('path')
const mergeOptions = require('merge-options') const mergeOptions = require('merge-options')
const validUrl = require('valid-url') const validUrl = require('valid-url')
const openpgp = require(path.join(require.resolve('openpgp'), '..', 'openpgp.min.js')) const openpgp = require(path.join(
require.resolve('openpgp'),
'..',
'openpgp.min.js'
))
const serviceproviders = require('./serviceproviders') const serviceproviders = require('./serviceproviders')
const keys = require('./keys') const keys = require('./keys')
const utils = require('./utils') const utils = require('./utils')

View file

@ -65,37 +65,41 @@ const match = (uri, opts) => {
return matches return matches
} }
const directRequestHandler = async (spData, opts) => { const directRequestHandler = (spData, opts) => {
const url = spData.proof.fetch ? spData.proof.fetch : spData.proof.uri return new Promise(async (resolve, reject) => {
let res const url = spData.proof.fetch ? spData.proof.fetch : spData.proof.uri
let res
switch (spData.proof.format) { switch (spData.proof.format) {
case 'json': case 'json':
res = await req(url, null, { res = await req(url, null, {
Accept: 'application/json', Accept: 'application/json',
'User-Agent': `doipjs/${require('../package.json').version}`, 'User-Agent': `doipjs/${require('../package.json').version}`,
}) })
return await res.json() resolve(await res.json())
break break
case 'text': case 'text':
res = await req(url) res = await req(url)
return await res.text() resolve(await res.text())
break break
default: default:
throw new Error('No specified proof data format') reject('No specified proof data format')
break break
} }
})
} }
const proxyRequestHandler = async (spData, opts) => { const proxyRequestHandler = (spData, opts) => {
const url = spData.proof.fetch ? spData.proof.fetch : spData.proof.uri return new Promise(async (resolve, reject) => {
const res = await req( const url = spData.proof.fetch ? spData.proof.fetch : spData.proof.uri
utils.generateProxyURL(spData.proof.format, url, opts), const res = await req(
null, utils.generateProxyURL(spData.proof.format, url, opts),
{ Accept: 'application/json' } null,
) { Accept: 'application/json' }
const json = await res.json() )
return json.content const json = await res.json()
resolve(json.content)
})
} }
exports.list = list exports.list = list