mirror of
https://github.com/danbulant/jose
synced 2026-05-24 12:35:36 +00:00
parent
3d2a2b8eee
commit
e44cd18ea4
1 changed files with 15 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
import fetchJwks from '../runtime/fetch_jwks.js'
|
import fetchJwks from '../runtime/fetch_jwks.js'
|
||||||
|
import { isCloudflareWorkers } from '../runtime/env.js'
|
||||||
|
|
||||||
import type { KeyLike, JWSHeaderParameters, FlattenedJWSInput, GetKeyFunction } from '../types.d'
|
import type { KeyLike, JWSHeaderParameters, FlattenedJWSInput, GetKeyFunction } from '../types.d'
|
||||||
import { JWKSInvalid, JWKSNoMatchingKey } from '../util/errors.js'
|
import { JWKSInvalid, JWKSNoMatchingKey } from '../util/errors.js'
|
||||||
|
|
@ -89,6 +90,20 @@ class RemoteJWKSet extends LocalJWKSet {
|
||||||
}
|
}
|
||||||
|
|
||||||
async reload() {
|
async reload() {
|
||||||
|
// see https://github.com/panva/jose/issues/355
|
||||||
|
if (this._pendingFetch && isCloudflareWorkers()) {
|
||||||
|
return new Promise<void>((resolve) => {
|
||||||
|
const isDone = () => {
|
||||||
|
if (this._pendingFetch === undefined) {
|
||||||
|
resolve()
|
||||||
|
} else {
|
||||||
|
setTimeout(isDone, 5)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
isDone()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
if (!this._pendingFetch) {
|
if (!this._pendingFetch) {
|
||||||
this._pendingFetch = fetchJwks(this._url, this._timeoutDuration, this._options)
|
this._pendingFetch = fetchJwks(this._url, this._timeoutDuration, this._options)
|
||||||
.then((json) => {
|
.then((json) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue