forked from Mirrors/doipjs
Run prettier
This commit is contained in:
parent
b9c76b7c0e
commit
34dc50d031
3 changed files with 66 additions and 58 deletions
58
docs/api.md
58
docs/api.md
|
@ -50,11 +50,11 @@ Verifies the identity behind the provided **array of uris** using the **fingerpr
|
|||
|
||||
**Parameters**
|
||||
|
||||
| Name | Type | Mandatory | Description |
|
||||
| ----------- | ------ | --------- | -------------------------------- |
|
||||
| uriArray | array | true | array of uris |
|
||||
| fingerprint | string | false | the fingerprint of the claim |
|
||||
| opts | object | false | options (see below) |
|
||||
| Name | Type | Mandatory | Description |
|
||||
| ----------- | ------ | --------- | ---------------------------- |
|
||||
| uriArray | array | true | array of uris |
|
||||
| fingerprint | string | false | the fingerprint of the claim |
|
||||
| opts | object | false | options (see below) |
|
||||
|
||||
**Options**
|
||||
|
||||
|
@ -71,15 +71,15 @@ _(async)_ doip.claims.verify(key, [fingerprint], [opts])
|
|||
|
||||
Verifies the identity behind the claims contained within the provided
|
||||
**key** using the **fingerprint**. This key is outputted by the
|
||||
[keys.fetch.*()](#keysfetchuriuri) commands.
|
||||
[keys.fetch.\*()](#keysfetchuriuri) commands.
|
||||
|
||||
**Parameters**
|
||||
|
||||
| Name | Type | Mandatory | Description |
|
||||
| ----------- | ------ | --------- | -------------------------------- |
|
||||
| key | object | true | a public key |
|
||||
| fingerprint | string | false | the fingerprint of the claim |
|
||||
| opts | object | false | options (see below) |
|
||||
| Name | Type | Mandatory | Description |
|
||||
| ----------- | ------ | --------- | ---------------------------- |
|
||||
| key | object | true | a public key |
|
||||
| fingerprint | string | false | the fingerprint of the claim |
|
||||
| opts | object | false | options (see below) |
|
||||
|
||||
**Options**
|
||||
|
||||
|
@ -99,9 +99,9 @@ other `keys.fetch.*` commands.
|
|||
|
||||
**Parameters**
|
||||
|
||||
| Name | Type | Mandatory | Description |
|
||||
| ----------- | ------ | --------- | -------------------------------- |
|
||||
| uri | string | true | public key identifier |
|
||||
| Name | Type | Mandatory | Description |
|
||||
| ---- | ------ | --------- | --------------------- |
|
||||
| uri | string | true | public key identifier |
|
||||
|
||||
Possible formats for `uri`:
|
||||
|
||||
|
@ -110,7 +110,7 @@ Possible formats for `uri`:
|
|||
`hkp:EMAIL` ⇒ `keys.fetch.hkp(EMAIL)`
|
||||
`hkp:EMAIL:KEYSERVER` ⇒ `keys.fetch.hkp(EMAIL, KEYSERVER)`
|
||||
`wkd:EMAIL` ⇒ `keys.fetch.wkd(EMAIL)`
|
||||
`kb:USERNAME:FINGERPRINT` ⇒ `keys.fetch.keybase(USERNAME, FINGERPRINT)`
|
||||
`kb:USERNAME:FINGERPRINT` ⇒ `keys.fetch.keybase(USERNAME, FINGERPRINT)`
|
||||
|
||||
**Returns**
|
||||
|
||||
|
@ -124,10 +124,10 @@ Fetches a key using HKP-compatible key servers.
|
|||
|
||||
**Parameters**
|
||||
|
||||
| Name | Type | Mandatory | Description |
|
||||
| ---------------- | ------ | --------- | -------------------------------- |
|
||||
| fingerprint | string | true | public key identifier |
|
||||
| keyserverBaseUrl | string | false | base URL of keyserver |
|
||||
| Name | Type | Mandatory | Description |
|
||||
| ---------------- | ------ | --------- | --------------------- |
|
||||
| fingerprint | string | true | public key identifier |
|
||||
| keyserverBaseUrl | string | false | base URL of keyserver |
|
||||
|
||||
`keyserverBaseUrl` defaults to `https://keys.openpgp.org/`.
|
||||
|
||||
|
@ -143,10 +143,10 @@ Fetches a key using HKP-compatible key servers.
|
|||
|
||||
**Parameters**
|
||||
|
||||
| Name | Type | Mandatory | Description |
|
||||
| ---------------- | ------ | --------- | -------------------------------- |
|
||||
| email | string | true | public key identifier |
|
||||
| keyserverBaseUrl | string | false | base URL of keyserver |
|
||||
| Name | Type | Mandatory | Description |
|
||||
| ---------------- | ------ | --------- | --------------------- |
|
||||
| email | string | true | public key identifier |
|
||||
| keyserverBaseUrl | string | false | base URL of keyserver |
|
||||
|
||||
`keyserverBaseUrl` defaults to `https://keys.openpgp.org/`.
|
||||
|
||||
|
@ -162,9 +162,9 @@ Fetches a key using the WKD protocol.
|
|||
|
||||
**Parameters**
|
||||
|
||||
| Name | Type | Mandatory | Description |
|
||||
| ----------- | ------ | --------- | -------------------------------- |
|
||||
| wkdId | string | true | WKD identifier |
|
||||
| Name | Type | Mandatory | Description |
|
||||
| ----- | ------ | --------- | -------------- |
|
||||
| wkdId | string | true | WKD identifier |
|
||||
|
||||
`wkdId` looks like an email address and is formatted as `username@domain.org`.
|
||||
|
||||
|
@ -180,9 +180,9 @@ Parses the `keyPlaintext`.
|
|||
|
||||
**Parameters**
|
||||
|
||||
| Name | Type | Mandatory | Description |
|
||||
| ------------ | ------ | --------- | -------------------------------- |
|
||||
| keyPlaintext | string | true | ASCII key content |
|
||||
| Name | Type | Mandatory | Description |
|
||||
| ------------ | ------ | --------- | ----------------- |
|
||||
| keyPlaintext | string | true | ASCII key content |
|
||||
|
||||
**Returns**
|
||||
|
||||
|
|
|
@ -16,7 +16,11 @@ limitations under the License.
|
|||
const path = require('path')
|
||||
const mergeOptions = require('merge-options')
|
||||
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 keys = require('./keys')
|
||||
const utils = require('./utils')
|
||||
|
|
|
@ -65,37 +65,41 @@ const match = (uri, opts) => {
|
|||
return matches
|
||||
}
|
||||
|
||||
const directRequestHandler = async (spData, opts) => {
|
||||
const url = spData.proof.fetch ? spData.proof.fetch : spData.proof.uri
|
||||
let res
|
||||
const directRequestHandler = (spData, opts) => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const url = spData.proof.fetch ? spData.proof.fetch : spData.proof.uri
|
||||
let res
|
||||
|
||||
switch (spData.proof.format) {
|
||||
case 'json':
|
||||
res = await req(url, null, {
|
||||
Accept: 'application/json',
|
||||
'User-Agent': `doipjs/${require('../package.json').version}`,
|
||||
})
|
||||
return await res.json()
|
||||
break
|
||||
case 'text':
|
||||
res = await req(url)
|
||||
return await res.text()
|
||||
break
|
||||
default:
|
||||
throw new Error('No specified proof data format')
|
||||
break
|
||||
}
|
||||
switch (spData.proof.format) {
|
||||
case 'json':
|
||||
res = await req(url, null, {
|
||||
Accept: 'application/json',
|
||||
'User-Agent': `doipjs/${require('../package.json').version}`,
|
||||
})
|
||||
resolve(await res.json())
|
||||
break
|
||||
case 'text':
|
||||
res = await req(url)
|
||||
resolve(await res.text())
|
||||
break
|
||||
default:
|
||||
reject('No specified proof data format')
|
||||
break
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const proxyRequestHandler = async (spData, opts) => {
|
||||
const url = spData.proof.fetch ? spData.proof.fetch : spData.proof.uri
|
||||
const res = await req(
|
||||
utils.generateProxyURL(spData.proof.format, url, opts),
|
||||
null,
|
||||
{ Accept: 'application/json' }
|
||||
)
|
||||
const json = await res.json()
|
||||
return json.content
|
||||
const proxyRequestHandler = (spData, opts) => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const url = spData.proof.fetch ? spData.proof.fetch : spData.proof.uri
|
||||
const res = await req(
|
||||
utils.generateProxyURL(spData.proof.format, url, opts),
|
||||
null,
|
||||
{ Accept: 'application/json' }
|
||||
)
|
||||
const json = await res.json()
|
||||
resolve(json.content)
|
||||
})
|
||||
}
|
||||
|
||||
exports.list = list
|
||||
|
|
Loading…
Reference in a new issue