Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hono

Package Overview
Dependencies
Maintainers
0
Versions
337
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hono - npm Package Compare versions

Comparing version 4.5.0 to 4.5.1

11

dist/cjs/client/client.js

@@ -160,4 +160,11 @@ "use strict";

const targetUrl = new URL(webSocketUrl);
for (const key in opts.args[0]?.query) {
targetUrl.searchParams.set(key, opts.args[0].query[key]);
const queryParams = opts.args[0]?.query;
if (queryParams) {
Object.entries(queryParams).forEach(([key, value]) => {
if (Array.isArray(value)) {
value.forEach((item) => targetUrl.searchParams.append(key, item));
} else {
targetUrl.searchParams.set(key, value);
}
});
}

@@ -164,0 +171,0 @@ return new WebSocket(targetUrl.toString());

12

dist/cjs/middleware/bearer-auth/index.js

@@ -36,6 +36,9 @@ "use strict";

}
if (!options.prefix) {
if (options.prefix === void 0) {
options.prefix = PREFIX;
}
const realm = options.realm?.replace(/"/g, '\\"');
const prefixRegexStr = options.prefix === "" ? "" : `${options.prefix} +`;
const regexp = new RegExp(`^${prefixRegexStr}(${TOKEN_STRINGS}) *$`);
const wwwAuthenticatePrefix = options.prefix === "" ? "" : `${options.prefix} `;
return async function bearerAuth2(c, next) {

@@ -47,3 +50,3 @@ const headerToken = c.req.header(options.headerName || HEADER);

headers: {
"WWW-Authenticate": `${options.prefix} realm="` + realm + '"'
"WWW-Authenticate": `${wwwAuthenticatePrefix}realm="` + realm + '"'
}

@@ -53,3 +56,2 @@ });

} else {
const regexp = new RegExp("^" + options.prefix + " +(" + TOKEN_STRINGS + ") *$");
const match = regexp.exec(headerToken);

@@ -60,3 +62,3 @@ if (!match) {

headers: {
"WWW-Authenticate": `${options.prefix} error="invalid_request"`
"WWW-Authenticate": `${wwwAuthenticatePrefix}error="invalid_request"`
}

@@ -83,3 +85,3 @@ });

headers: {
"WWW-Authenticate": `${options.prefix} error="invalid_token"`
"WWW-Authenticate": `${wwwAuthenticatePrefix}error="invalid_token"`
}

@@ -86,0 +88,0 @@ });

@@ -27,2 +27,5 @@ "use strict";

var import_buffer = require("../utils/buffer");
const jsonRegex = /^application\/([a-z-\.]+\+)?json$/;
const multipartRegex = /^multipart\/form-data(; boundary=[A-Za-z0-9'()+_,\-./:=?]+)?$/;
const urlencodedRegex = /^application\/x-www-form-urlencoded$/;
const validator = (target, validationFunc) => {

@@ -34,5 +37,4 @@ return async (c, next) => {

case "json":
if (!contentType || !/^application\/([a-z-\.]+\+)?json/.test(contentType)) {
const message = `Invalid HTTP header: Content-Type=${contentType}`;
throw new import_http_exception.HTTPException(400, { message });
if (!contentType || !jsonRegex.test(contentType)) {
break;
}

@@ -47,3 +49,3 @@ try {

case "form": {
if (!contentType) {
if (!contentType || !(multipartRegex.test(contentType) || urlencodedRegex.test(contentType))) {
break;

@@ -50,0 +52,0 @@ }

@@ -144,4 +144,11 @@ // src/client/client.ts

const targetUrl = new URL(webSocketUrl);
for (const key in opts.args[0]?.query) {
targetUrl.searchParams.set(key, opts.args[0].query[key]);
const queryParams = opts.args[0]?.query;
if (queryParams) {
Object.entries(queryParams).forEach(([key, value]) => {
if (Array.isArray(value)) {
value.forEach((item) => targetUrl.searchParams.append(key, item));
} else {
targetUrl.searchParams.set(key, value);
}
});
}

@@ -148,0 +155,0 @@ return new WebSocket(targetUrl.toString());

@@ -14,6 +14,9 @@ // src/middleware/bearer-auth/index.ts

}
if (!options.prefix) {
if (options.prefix === void 0) {
options.prefix = PREFIX;
}
const realm = options.realm?.replace(/"/g, '\\"');
const prefixRegexStr = options.prefix === "" ? "" : `${options.prefix} +`;
const regexp = new RegExp(`^${prefixRegexStr}(${TOKEN_STRINGS}) *$`);
const wwwAuthenticatePrefix = options.prefix === "" ? "" : `${options.prefix} `;
return async function bearerAuth2(c, next) {

@@ -25,3 +28,3 @@ const headerToken = c.req.header(options.headerName || HEADER);

headers: {
"WWW-Authenticate": `${options.prefix} realm="` + realm + '"'
"WWW-Authenticate": `${wwwAuthenticatePrefix}realm="` + realm + '"'
}

@@ -31,3 +34,2 @@ });

} else {
const regexp = new RegExp("^" + options.prefix + " +(" + TOKEN_STRINGS + ") *$");
const match = regexp.exec(headerToken);

@@ -38,3 +40,3 @@ if (!match) {

headers: {
"WWW-Authenticate": `${options.prefix} error="invalid_request"`
"WWW-Authenticate": `${wwwAuthenticatePrefix}error="invalid_request"`
}

@@ -61,3 +63,3 @@ });

headers: {
"WWW-Authenticate": `${options.prefix} error="invalid_token"`
"WWW-Authenticate": `${wwwAuthenticatePrefix}error="invalid_token"`
}

@@ -64,0 +66,0 @@ });

@@ -65,6 +65,2 @@ /**

});
/**
* @experimental
* `createApp` is an experimental feature.
*/
createApp: () => Hono<E>;

@@ -71,0 +67,0 @@ createMiddleware: <I extends Input = {}>(middleware: MiddlewareHandler<E, P, I>) => MiddlewareHandler<E, P, I>;

@@ -29,3 +29,3 @@ /**

* @param {string} [options.realm=""] - The domain name of the realm, as part of the returned WWW-Authenticate challenge header.
* @param {string} [options.prefix="Bearer"] - The prefix (or known as `schema`) for the Authorization header value.
* @param {string} [options.prefix="Bearer"] - The prefix (or known as `schema`) for the Authorization header value. If set to the empty string, no prefix is expected.
* @param {string} [options.headerName=Authorization] - The header name.

@@ -32,0 +32,0 @@ * @param {Function} [options.hashFunction] - A function to handle hashing for safe comparison of authentication tokens.

@@ -9,2 +9,3 @@ /**

import type { SignatureAlgorithm } from '../../utils/jwt/jwa';
import type { SignatureKey } from '../../utils/jwt/jws';
export type JwtVariables = {

@@ -19,3 +20,3 @@ jwtPayload: any;

* @param {object} options - The options for the JWT middleware.
* @param {string} [options.secret] - A value of your secret key.
* @param {SignatureKey} [options.secret] - A value of your secret key.
* @param {string} [options.cookie] - If this value is set, then the value is retrieved from the cookie header using that value as a key, which is then validated as a token.

@@ -42,3 +43,3 @@ * @param {SignatureAlgorithm} [options.alg=HS256] - An algorithm type that is used for verifying. Available types are `HS256` | `HS384` | `HS512` | `RS256` | `RS384` | `RS512` | `PS256` | `PS384` | `PS512` | `ES256` | `ES384` | `ES512` | `EdDSA`.

export declare const jwt: (options: {
secret: string;
secret: SignatureKey;
cookie?: string | {

@@ -51,3 +52,3 @@ key: string;

}) => MiddlewareHandler;
export declare const verify: (token: string, publicKey: import("../../utils/jwt/jws").SignatureKey, alg?: "HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "PS256" | "PS384" | "PS512" | "ES256" | "ES384" | "ES512" | "EdDSA") => Promise<import("../../utils/jwt/types").JWTPayload>;
export declare const verify: (token: string, publicKey: SignatureKey, alg?: "HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "PS256" | "PS384" | "PS512" | "ES256" | "ES384" | "ES512" | "EdDSA") => Promise<import("../../utils/jwt/types").JWTPayload>;
export declare const decode: (token: string) => {

@@ -57,2 +58,2 @@ header: import("../../utils/jwt/jwt").TokenHeader;

};
export declare const sign: (payload: import("../../utils/jwt/types").JWTPayload, privateKey: import("../../utils/jwt/jws").SignatureKey, alg?: "HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "PS256" | "PS384" | "PS512" | "ES256" | "ES384" | "ES512" | "EdDSA") => Promise<string>;
export declare const sign: (payload: import("../../utils/jwt/types").JWTPayload, privateKey: SignatureKey, alg?: "HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "PS256" | "PS384" | "PS512" | "ES256" | "ES384" | "ES512" | "EdDSA") => Promise<string>;

@@ -5,2 +5,5 @@ // src/validator/validator.ts

import { bufferToFormData } from "../utils/buffer.js";
var jsonRegex = /^application\/([a-z-\.]+\+)?json$/;
var multipartRegex = /^multipart\/form-data(; boundary=[A-Za-z0-9'()+_,\-./:=?]+)?$/;
var urlencodedRegex = /^application\/x-www-form-urlencoded$/;
var validator = (target, validationFunc) => {

@@ -12,5 +15,4 @@ return async (c, next) => {

case "json":
if (!contentType || !/^application\/([a-z-\.]+\+)?json/.test(contentType)) {
const message = `Invalid HTTP header: Content-Type=${contentType}`;
throw new HTTPException(400, { message });
if (!contentType || !jsonRegex.test(contentType)) {
break;
}

@@ -25,3 +27,3 @@ try {

case "form": {
if (!contentType) {
if (!contentType || !(multipartRegex.test(contentType) || urlencodedRegex.test(contentType))) {
break;

@@ -28,0 +30,0 @@ }

{
"name": "hono",
"version": "4.5.0",
"version": "4.5.1",
"description": "Web framework built on Web Standards",

@@ -28,8 +28,9 @@ "main": "dist/cjs/index.js",

"copy:package.cjs.json": "cp ./package.cjs.json ./dist/cjs/package.json && cp ./package.cjs.json ./dist/types/package.json ",
"build": "rimraf dist && bun ./build.ts && bun run copy:package.cjs.json",
"build": "bun run --shell bun remove-dist && bun ./build.ts && bun run copy:package.cjs.json",
"postbuild": "publint",
"watch": "rimraf dist && bun ./build.ts --watch && bun run copy:package.cjs.json",
"watch": "bun run --shell bun remove-dist && bun ./build.ts --watch && bun run copy:package.cjs.json",
"coverage": "vitest --run --coverage",
"prerelease": "bun test:deno && bun run build",
"release": "np"
"release": "np",
"remove-dist": "rm -rf dist"
},

@@ -631,3 +632,2 @@ "exports": {

"publint": "^0.1.8",
"rimraf": "^3.0.2",
"supertest": "^6.3.3",

@@ -634,0 +634,0 @@ "typescript": "^5.3.3",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc