@lwrjs/security 0.10.0-alpha.16 → 0.10.0-alpha.17

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.
@@ -35,7 +35,10 @@ function isViewDefinitionResponse(response) {
35
35
  }
36
36
  function secure(routeHandler, options) {
37
37
  return async (request, context) => {
38
- const routeHandlerResponse = await routeHandler(request, context);
38
+ let routeHandlerResponse = routeHandler(request, context);
39
+ if (routeHandlerResponse instanceof Promise) {
40
+ routeHandlerResponse = await routeHandlerResponse;
41
+ }
39
42
  if (isViewResponse(routeHandlerResponse)) {
40
43
  if (!routeHandlerResponse.headers || !routeHandlerResponse.headers["content-type"].startsWith("text/html")) {
41
44
  return routeHandlerResponse;
@@ -1,4 +1,4 @@
1
- export declare type Directives = {
1
+ export type Directives = {
2
2
  [key: string]: string[];
3
3
  };
4
4
  export interface ContentSecurityPolicy {
@@ -1,3 +1,3 @@
1
- export declare type ReferrerPolicy = string | string[];
1
+ export type ReferrerPolicy = string | string[];
2
2
  export default function referrerPolicy(header?: string, option?: ReferrerPolicy): string;
3
3
  //# sourceMappingURL=referrer-policy.d.ts.map
@@ -18,8 +18,10 @@ function isViewDefinitionResponse(response) {
18
18
  */
19
19
  export function secure(routeHandler, options) {
20
20
  return async (request, context) => {
21
- // TODO: handle sync response
22
- const routeHandlerResponse = await routeHandler(request, context);
21
+ let routeHandlerResponse = routeHandler(request, context);
22
+ if (routeHandlerResponse instanceof Promise) {
23
+ routeHandlerResponse = await routeHandlerResponse;
24
+ }
23
25
  if (isViewResponse(routeHandlerResponse)) {
24
26
  // only apply headers when the view response is html
25
27
  if (!routeHandlerResponse.headers ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lwrjs/security",
3
- "version": "0.10.0-alpha.16",
3
+ "version": "0.10.0-alpha.17",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "types": "build/es/index.d.ts",
@@ -29,13 +29,13 @@
29
29
  "build/**/*.d.ts"
30
30
  ],
31
31
  "dependencies": {
32
- "@lwrjs/shared-utils": "0.10.0-alpha.16"
32
+ "@lwrjs/shared-utils": "0.10.0-alpha.17"
33
33
  },
34
34
  "devDependencies": {
35
- "@lwrjs/types": "0.10.0-alpha.16"
35
+ "@lwrjs/types": "0.10.0-alpha.17"
36
36
  },
37
37
  "engines": {
38
38
  "node": ">=16.0.0 <20"
39
39
  },
40
- "gitHead": "c5a13d471330c0f738d0c783fd1b69f456c544bd"
40
+ "gitHead": "36cfce3a18bf3dc71a7d5203bbaa9aa752ccce06"
41
41
  }