@shad-claiborne/hono-middleware-oidc 1.1.0 → 1.1.1

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.
package/dist/index.d.ts CHANGED
@@ -13,6 +13,12 @@ export declare const handleFlow: MiddlewareHandler;
13
13
  * @returns
14
14
  */
15
15
  export declare const addIdentity: MiddlewareHandler;
16
+ /**
17
+ * checkIdentity
18
+ * @param c
19
+ * @returns
20
+ */
21
+ export declare const checkIdentity: MiddlewareHandler;
16
22
  /**
17
23
  * receiveAuth
18
24
  * @param c
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@ import { deleteCookie, getSignedCookie, setSignedCookie } from "hono/cookie";
2
2
  import { createIdentityProvider, } from "@shad-claiborne/basic-oidc";
3
3
  import randomstring from "randomstring";
4
4
  import { env } from "hono/adapter";
5
+ import { HTTPException } from "hono/http-exception";
5
6
  /**
6
7
  * activateToken
7
8
  * @param c
@@ -89,6 +90,17 @@ export const addIdentity = async (c, next) => {
89
90
  }
90
91
  await next();
91
92
  };
93
+ /**
94
+ * checkIdentity
95
+ * @param c
96
+ * @returns
97
+ */
98
+ export const checkIdentity = async (c, next) => {
99
+ const id = c.get('identity');
100
+ if (!id)
101
+ throw new HTTPException(401, { message: 'Unauthorized' });
102
+ await next();
103
+ };
92
104
  /**
93
105
  * receiveAuth
94
106
  * @param c
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shad-claiborne/hono-middleware-oidc",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "OIDC middleware for Hono",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",