hono 4.12.31 → 4.12.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -42,7 +42,7 @@ class SSEStreamingApi extends import_stream.StreamingApi {
42
42
  const sseData = [
43
43
  message.event && `event: ${message.event}`,
44
44
  dataLines,
45
- message.id && `id: ${message.id}`,
45
+ message.id !== void 0 && `id: ${message.id}`,
46
46
  message.retry !== void 0 && `retry: ${message.retry}`
47
47
  ].filter(Boolean).join("\n") + "\n\n";
48
48
  await this.write(sseData);
@@ -71,14 +71,20 @@ const secureHeaders = (customOptions) => {
71
71
  const headersToSet = getFilteredHeaders(options);
72
72
  const callbacks = [];
73
73
  if (options.contentSecurityPolicy) {
74
- const [callback, value] = getCSPDirectives(options.contentSecurityPolicy);
74
+ const [callback, value] = getCSPDirectives(
75
+ options.contentSecurityPolicy,
76
+ "Content-Security-Policy"
77
+ );
75
78
  if (callback) {
76
79
  callbacks.push(callback);
77
80
  }
78
81
  headersToSet.push(["Content-Security-Policy", value]);
79
82
  }
80
83
  if (options.contentSecurityPolicyReportOnly) {
81
- const [callback, value] = getCSPDirectives(options.contentSecurityPolicyReportOnly);
84
+ const [callback, value] = getCSPDirectives(
85
+ options.contentSecurityPolicyReportOnly,
86
+ "Content-Security-Policy-Report-Only"
87
+ );
82
88
  if (callback) {
83
89
  callbacks.push(callback);
84
90
  }
@@ -111,7 +117,7 @@ function getFilteredHeaders(options) {
111
117
  return typeof overrideValue === "string" ? [defaultValue[0], overrideValue] : defaultValue;
112
118
  });
113
119
  }
114
- function getCSPDirectives(contentSecurityPolicy) {
120
+ function getCSPDirectives(contentSecurityPolicy, headerName) {
115
121
  const callbacks = [];
116
122
  const resultValues = [];
117
123
  for (const [directive, value] of Object.entries(contentSecurityPolicy)) {
@@ -136,7 +142,7 @@ function getCSPDirectives(contentSecurityPolicy) {
136
142
  resultValues.pop();
137
143
  return callbacks.length === 0 ? [void 0, resultValues.join("")] : [
138
144
  (ctx, headersToSet) => headersToSet.map((values) => {
139
- if (values[0] === "Content-Security-Policy" || values[0] === "Content-Security-Policy-Report-Only") {
145
+ if (values[0] === headerName) {
140
146
  const clone = values[1].slice();
141
147
  callbacks.forEach((cb) => {
142
148
  cb(ctx, clone);
@@ -98,7 +98,7 @@ class HonoRequest {
98
98
  if (name) {
99
99
  return this.raw.headers.get(name) ?? void 0;
100
100
  }
101
- const headerData = {};
101
+ const headerData = /* @__PURE__ */ Object.create(null);
102
102
  this.raw.headers.forEach((value, key) => {
103
103
  headerData[key] = value;
104
104
  });
@@ -146,7 +146,7 @@ const getNextParam = (acceptHeader, startIndex) => {
146
146
  const getNextAcceptValue = (acceptHeader, startIndex) => {
147
147
  const accept = {
148
148
  type: "",
149
- params: {},
149
+ params: /* @__PURE__ */ Object.create(null),
150
150
  q: 1
151
151
  };
152
152
  startIndex = consumeWhitespace(acceptHeader, startIndex);
@@ -192,7 +192,7 @@ const _getQueryParam = (url, key, multiple) => {
192
192
  return void 0;
193
193
  }
194
194
  }
195
- const results = {};
195
+ const results = /* @__PURE__ */ Object.create(null);
196
196
  encoded ??= /[%+]/.test(url);
197
197
  let keyIndex = url.indexOf("?", 8);
198
198
  while (keyIndex !== -1) {
@@ -20,7 +20,7 @@ var SSEStreamingApi = class extends StreamingApi {
20
20
  const sseData = [
21
21
  message.event && `event: ${message.event}`,
22
22
  dataLines,
23
- message.id && `id: ${message.id}`,
23
+ message.id !== void 0 && `id: ${message.id}`,
24
24
  message.retry !== void 0 && `retry: ${message.retry}`
25
25
  ].filter(Boolean).join("\n") + "\n\n";
26
26
  await this.write(sseData);
@@ -49,14 +49,20 @@ var secureHeaders = (customOptions) => {
49
49
  const headersToSet = getFilteredHeaders(options);
50
50
  const callbacks = [];
51
51
  if (options.contentSecurityPolicy) {
52
- const [callback, value] = getCSPDirectives(options.contentSecurityPolicy);
52
+ const [callback, value] = getCSPDirectives(
53
+ options.contentSecurityPolicy,
54
+ "Content-Security-Policy"
55
+ );
53
56
  if (callback) {
54
57
  callbacks.push(callback);
55
58
  }
56
59
  headersToSet.push(["Content-Security-Policy", value]);
57
60
  }
58
61
  if (options.contentSecurityPolicyReportOnly) {
59
- const [callback, value] = getCSPDirectives(options.contentSecurityPolicyReportOnly);
62
+ const [callback, value] = getCSPDirectives(
63
+ options.contentSecurityPolicyReportOnly,
64
+ "Content-Security-Policy-Report-Only"
65
+ );
60
66
  if (callback) {
61
67
  callbacks.push(callback);
62
68
  }
@@ -89,7 +95,7 @@ function getFilteredHeaders(options) {
89
95
  return typeof overrideValue === "string" ? [defaultValue[0], overrideValue] : defaultValue;
90
96
  });
91
97
  }
92
- function getCSPDirectives(contentSecurityPolicy) {
98
+ function getCSPDirectives(contentSecurityPolicy, headerName) {
93
99
  const callbacks = [];
94
100
  const resultValues = [];
95
101
  for (const [directive, value] of Object.entries(contentSecurityPolicy)) {
@@ -114,7 +120,7 @@ function getCSPDirectives(contentSecurityPolicy) {
114
120
  resultValues.pop();
115
121
  return callbacks.length === 0 ? [void 0, resultValues.join("")] : [
116
122
  (ctx, headersToSet) => headersToSet.map((values) => {
117
- if (values[0] === "Content-Security-Policy" || values[0] === "Content-Security-Policy-Report-Only") {
123
+ if (values[0] === headerName) {
118
124
  const clone = values[1].slice();
119
125
  callbacks.forEach((cb) => {
120
126
  cb(ctx, clone);
package/dist/request.js CHANGED
@@ -76,7 +76,7 @@ var HonoRequest = class {
76
76
  if (name) {
77
77
  return this.raw.headers.get(name) ?? void 0;
78
78
  }
79
- const headerData = {};
79
+ const headerData = /* @__PURE__ */ Object.create(null);
80
80
  this.raw.headers.forEach((value, key) => {
81
81
  headerData[key] = value;
82
82
  });
@@ -96,6 +96,15 @@ interface Authorizer {
96
96
  userArn: string;
97
97
  userId: string;
98
98
  };
99
+ jwt?: {
100
+ claims: Record<string, string | number | boolean | string[]>;
101
+ scopes: string[] | null;
102
+ };
103
+ /**
104
+ * The `context` object returned by a Lambda (REQUEST) authorizer.
105
+ * It is `null` when the authorizer returns no context.
106
+ */
107
+ lambda?: Record<string, unknown> | null;
99
108
  }
100
109
  export interface ApiGatewayRequestContextV2 {
101
110
  accountId: string;
@@ -125,7 +125,7 @@ var getNextParam = (acceptHeader, startIndex) => {
125
125
  var getNextAcceptValue = (acceptHeader, startIndex) => {
126
126
  const accept = {
127
127
  type: "",
128
- params: {},
128
+ params: /* @__PURE__ */ Object.create(null),
129
129
  q: 1
130
130
  };
131
131
  startIndex = consumeWhitespace(acceptHeader, startIndex);
package/dist/utils/url.js CHANGED
@@ -159,7 +159,7 @@ var _getQueryParam = (url, key, multiple) => {
159
159
  return void 0;
160
160
  }
161
161
  }
162
- const results = {};
162
+ const results = /* @__PURE__ */ Object.create(null);
163
163
  encoded ??= /[%+]/.test(url);
164
164
  let keyIndex = url.indexOf("?", 8);
165
165
  while (keyIndex !== -1) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "4.12.31",
3
+ "version": "4.12.32",
4
4
  "description": "Web framework built on Web Standards",
5
5
  "main": "dist/cjs/index.js",
6
6
  "type": "module",