From a798c307e11cd8d414ee23259fe0c5730dfb8841 Mon Sep 17 00:00:00 2001 From: Yusuke Wada Date: Mon, 6 Mar 2023 20:24:49 +0900 Subject: [PATCH] feat(firebase-auth): support Hono v3 (#60) * feat(firebase-auth): support Hono v3 * add changeset --- .changeset/thirty-snails-develop.md | 5 +++++ packages/firebase-auth/package.json | 6 +++--- packages/firebase-auth/src/index.ts | 11 +++-------- yarn.lock | 5 +++++ 4 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 .changeset/thirty-snails-develop.md diff --git a/.changeset/thirty-snails-develop.md b/.changeset/thirty-snails-develop.md new file mode 100644 index 00000000..6513bba7 --- /dev/null +++ b/.changeset/thirty-snails-develop.md @@ -0,0 +1,5 @@ +--- +'@hono/firebase-auth': minor +--- + +feat: support Hono v3 diff --git a/packages/firebase-auth/package.json b/packages/firebase-auth/package.json index be4ac955..d4fbf69c 100644 --- a/packages/firebase-auth/package.json +++ b/packages/firebase-auth/package.json @@ -31,17 +31,17 @@ "firebase-auth-cloudflare-workers": "^1.0.0" }, "peerDependencies": { - "hono": "^2.7.2" + "hono": "3.*" }, "devDependencies": { - "hono": "^2.7.2", "@cloudflare/workers-types": "^3.14.1", "@types/jest": "^28.1.4", "firebase-tools": "^11.4.0", + "hono": "^3.0.3", "jest": "^28.1.2", "jest-environment-miniflare": "^2.6.0", "prettier": "^2.7.1", "ts-jest": "^28.0.5", "typescript": "^4.7.4" } -} \ No newline at end of file +} diff --git a/packages/firebase-auth/src/index.ts b/packages/firebase-auth/src/index.ts index 38df8768..b0dc335e 100644 --- a/packages/firebase-auth/src/index.ts +++ b/packages/firebase-auth/src/index.ts @@ -1,10 +1,11 @@ -import type { EmulatorEnv, KeyStorer, FirebaseIdToken } from 'firebase-auth-cloudflare-workers' +import type { KeyStorer, FirebaseIdToken } from 'firebase-auth-cloudflare-workers' import { Auth, WorkersKVStoreSingle } from 'firebase-auth-cloudflare-workers' import type { Context, MiddlewareHandler } from 'hono' -export interface VerifyFirebaseAuthEnv extends EmulatorEnv { +export type VerifyFirebaseAuthEnv = { PUBLIC_JWK_CACHE_KEY?: string | undefined PUBLIC_JWK_CACHE_KV?: KVNamespace | undefined + FIREBASE_AUTH_EMULATOR_HOST: string | undefined } export interface VerifyFirebaseAuthConfig { @@ -24,12 +25,6 @@ const defaultKeyStoreInitializer = (c: Context): KeyStorer => { ) } -type Env = { - Bindings: { - FIREBASE_AUTH_EMULATOR_HOST: string - } -} - export const verifyFirebaseAuth = (userConfig: VerifyFirebaseAuthConfig): MiddlewareHandler => { const config = { projectId: userConfig.projectId, diff --git a/yarn.lock b/yarn.lock index b55b3d9e..c42571ef 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5232,6 +5232,11 @@ hono@^3.0.2: resolved "https://registry.yarnpkg.com/hono/-/hono-3.0.2.tgz#807a1b0514c6563917d8c278e6da7101bdac1d19" integrity sha512-jhb0eCiUTOzbOXZyXQCOk1gf3MKjV4ZXY3PRT6lzma0XPsnnHuDOHYF7RCMHYe7jhl4Y0IAzrmWXneXhOMHypA== +hono@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/hono/-/hono-3.0.3.tgz#26b62bece753941dd3d290d03ff3338f71535017" + integrity sha512-6Lb/TPH7Me1GAjFR7k/duzTcHS5y+rxFyL6Ky0kYQQlu92l99t53CFMVcdNUpHeStarPOs4Uzl413zIvxaI15A== + hosted-git-info@^2.1.4: version "2.8.9" resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9"