From c9bd83025cadf7a93dbba9ede959a383f1af4c61 Mon Sep 17 00:00:00 2001 From: Yusuke Wada Date: Fri, 21 Feb 2025 10:58:38 +0900 Subject: [PATCH] refactor: support TypeScript 5.7 for Deno 2.2 (#3939) * refactor: support TypeScript 5.7 for Deno 2.2 * remove `Buffer` test --- runtime-tests/deno/hono.test.ts | 10 ---------- src/helper/websocket/index.ts | 2 +- src/utils/jwt/jwt.ts | 3 ++- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/runtime-tests/deno/hono.test.ts b/runtime-tests/deno/hono.test.ts index fd5b544ff..72db91000 100644 --- a/runtime-tests/deno/hono.test.ts +++ b/runtime-tests/deno/hono.test.ts @@ -34,13 +34,3 @@ Deno.test('environment variables', () => { const { NAME } = env<{ NAME: string }>(c) assertEquals(NAME, 'Deno') }) - -Deno.test('Buffers', async () => { - const app = new Hono().get('/', async (c) => { - return c.body(Buffer.from('hello')) - }) - - const res = await app.request('/') - assertEquals(res.status, 200) - assertEquals(await res.text(), 'hello') -}) diff --git a/src/helper/websocket/index.ts b/src/helper/websocket/index.ts index 0c896bed0..2ec7e090e 100644 --- a/src/helper/websocket/index.ts +++ b/src/helper/websocket/index.ts @@ -40,7 +40,7 @@ export type WSReadyState = 0 | 1 | 2 | 3 * An argument for WSContext class */ export interface WSContextInit { - send(data: string | ArrayBuffer, options: SendOptions): void + send(data: string | ArrayBuffer | Uint8Array, options: SendOptions): void close(code?: number, reason?: string): void raw?: T diff --git a/src/utils/jwt/jwt.ts b/src/utils/jwt/jwt.ts index 8083375fa..c1f51e99e 100644 --- a/src/utils/jwt/jwt.ts +++ b/src/utils/jwt/jwt.ts @@ -22,7 +22,8 @@ import type { JWTPayload } from './types' import { utf8Decoder, utf8Encoder } from './utf8' const encodeJwtPart = (part: unknown): string => - encodeBase64Url(utf8Encoder.encode(JSON.stringify(part))).replace(/=/g, '') + encodeBase64Url(utf8Encoder.encode(JSON.stringify(part)).buffer).replace(/=/g, '') + const encodeSignaturePart = (buf: ArrayBufferLike): string => encodeBase64Url(buf).replace(/=/g, '') const decodeJwtPart = (part: string): TokenHeader | JWTPayload | undefined =>