MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / verifyJwtWithRefreshRetry

Function verifyJwtWithRefreshRetry

apps/cloud/src/auth/workos.ts:186–208  ·  view source on GitHub ↗
(
  accessToken: string,
  jwks: CachedRemoteJWKSet,
)

Source from the content-addressed store, hash-verified

184 });
185
186const verifyJwtWithRefreshRetry = (
187 accessToken: string,
188 jwks: CachedRemoteJWKSet,
189): Effect.Effect<boolean, ServiceAdapterError> =>
190 verifyJwtOnce(accessToken, jwks).pipe(
191 Effect.as(true),
192 Effect.catchTag("ServiceAdapterError", (error) => {
193 if (isErrorWithCode(error.cause) && error.cause.code === JWKSNoMatchingKey.code) {
194 return Effect.sync(() => jwks.forceRefresh()).pipe(
195 Effect.flatMap(() => verifyJwtOnce(accessToken, jwks)),
196 Effect.as(true),
197 Effect.catchTag("ServiceAdapterError", (retryError) =>
198 isJwtVerificationFailure(retryError.cause)
199 ? Effect.succeed(false)
200 : Effect.fail(retryError),
201 ),
202 );
203 }
204 if (isJwtVerificationFailure(error.cause)) return Effect.succeed(false);
205 if (isJwksSystemFailure(error.cause)) return Effect.fail(error);
206 return Effect.fail(error);
207 }),
208 );
209
210const verifySealedSessionLocally = (
211 sessionData: string,

Callers 1

Calls 4

verifyJwtOnceFunction · 0.85
isJwtVerificationFailureFunction · 0.85
isJwksSystemFailureFunction · 0.85
syncMethod · 0.65

Tested by

no test coverage detected