verify-rsa-jwt-cloudflare-worker
Advanced tools
Comparing version
import type { Context, MiddlewareHandler } from "hono"; | ||
import type { GeneralKeyValueStore, Jwks, VerificationResult } from "."; | ||
export type VerifyRsaJwtConfig = { | ||
getCookieByKey?: GetCookieByKey; | ||
jwksUri?: string; | ||
@@ -12,1 +13,7 @@ jwks?: Jwks; | ||
export declare function getPayloadFromContext(ctx: Context): any; | ||
interface GetCookie { | ||
(c: Context, key: string): string | undefined; | ||
} | ||
export type GetCookieByKey = (ctx: Context) => string | undefined; | ||
export declare function createGetCookieByKey(getCookie: GetCookie, key: string): GetCookieByKey; | ||
export {}; |
@@ -5,3 +5,4 @@ import { getJwks, useKVStore, verify } from "."; | ||
return async (ctx, next) => { | ||
const jwtToken = ctx.req.header("Authorization")?.replace(/Bearer\s+/i, ""); | ||
const jwtToken = ctx.req.header("Authorization")?.replace(/Bearer\s+/i, "") || | ||
config?.getCookieByKey?.(ctx); | ||
if (!jwtToken || jwtToken.length === 0) { | ||
@@ -34,1 +35,6 @@ return new Response("Bad Request", { status: 400 }); | ||
} | ||
export function createGetCookieByKey(getCookie, key) { | ||
return function getCookieByKey(ctx) { | ||
return getCookie(ctx, key); | ||
}; | ||
} |
/// <reference types="@cloudflare/workers-types" /> | ||
export { getJwks } from "./get-jwks"; | ||
export type { Jwks } from "./get-jwks"; | ||
export { getPayloadFromContext, verifyRsaJwt } from "./hono-middleware"; | ||
export type { VerifyRsaJwtConfig } from "./hono-middleware"; | ||
export { createGetCookieByKey, getPayloadFromContext, verifyRsaJwt, type GetCookieByKey, type VerifyRsaJwtConfig, } from "./hono-middleware"; | ||
export { useKVStore } from "./use-kv-store"; | ||
@@ -7,0 +6,0 @@ export type { GeneralKeyValueStore, KVNamespaceOrKeyValueStore, KVStore, } from "./use-kv-store"; |
export { getJwks } from "./get-jwks"; | ||
export { getPayloadFromContext, verifyRsaJwt } from "./hono-middleware"; | ||
export { createGetCookieByKey, getPayloadFromContext, verifyRsaJwt, } from "./hono-middleware"; | ||
export { useKVStore } from "./use-kv-store"; | ||
export { verify } from "./verify"; |
@@ -5,3 +5,3 @@ { | ||
"author": "Wataru Oguchi", | ||
"version": "1.3.6", | ||
"version": "1.4.0", | ||
"license": "MIT", | ||
@@ -8,0 +8,0 @@ "repository": { |
17743
2.93%210
6.06%