mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2024-12-23 06:59:29 -07:00
Add return after resolve and reject
This commit is contained in:
parent
a1ff96a1b9
commit
de5d358b31
1 changed files with 11 additions and 4 deletions
|
@ -157,10 +157,11 @@ const verify = async (input, fingerprint, opts) => {
|
||||||
|
|
||||||
const promiseClaim = new Promise(async (resolve, reject) => {
|
const promiseClaim = new Promise(async (resolve, reject) => {
|
||||||
let objResult = {
|
let objResult = {
|
||||||
isVerified: null,
|
isVerified: false,
|
||||||
errors: [],
|
errors: [],
|
||||||
serviceproviderData: null,
|
serviceproviderData: undefined,
|
||||||
}
|
}
|
||||||
|
|
||||||
const uri = input.replace(/^\s+|\s+$/g, '')
|
const uri = input.replace(/^\s+|\s+$/g, '')
|
||||||
|
|
||||||
if (!fingerprint) {
|
if (!fingerprint) {
|
||||||
|
@ -177,12 +178,14 @@ const verify = async (input, fingerprint, opts) => {
|
||||||
if (!validUrl.isUri(uri)) {
|
if (!validUrl.isUri(uri)) {
|
||||||
objResult.errors.push('invalid_uri')
|
objResult.errors.push('invalid_uri')
|
||||||
reject(objResult)
|
reject(objResult)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const spMatches = serviceproviders.match(uri, opts)
|
const spMatches = serviceproviders.match(uri, opts)
|
||||||
|
|
||||||
if ('returnMatchesOnly' in opts && opts.returnMatchesOnly) {
|
if ('returnMatchesOnly' in opts && opts.returnMatchesOnly) {
|
||||||
resolve(spMatches)
|
resolve(spMatches)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let claimVerificationDone = false,
|
let claimVerificationDone = false,
|
||||||
|
@ -270,15 +273,19 @@ const verify = async (input, fingerprint, opts) => {
|
||||||
objResult.isVerified = claimVerificationResult.isVerified
|
objResult.isVerified = claimVerificationResult.isVerified
|
||||||
objResult.serviceproviderData = spData
|
objResult.serviceproviderData = spData
|
||||||
resolve(objResult)
|
resolve(objResult)
|
||||||
|
return
|
||||||
})
|
})
|
||||||
|
|
||||||
const promiseTimeout = new Promise((res) => {
|
const promiseTimeout = new Promise((resolve) => {
|
||||||
const objResult = {
|
const objResult = {
|
||||||
isVerified: false,
|
isVerified: false,
|
||||||
errors: ['verification_timed_out'],
|
errors: ['verification_timed_out'],
|
||||||
serviceproviderData: undefined,
|
serviceproviderData: undefined,
|
||||||
}
|
}
|
||||||
setTimeout(() => res(objResult), 5000)
|
setTimeout(() => {
|
||||||
|
resolve(objResult)
|
||||||
|
return
|
||||||
|
}, 3000)
|
||||||
})
|
})
|
||||||
|
|
||||||
return await Promise.race([promiseClaim, promiseTimeout])
|
return await Promise.race([promiseClaim, promiseTimeout])
|
||||||
|
|
Loading…
Reference in a new issue