@shad-claiborne/hono-middleware-oidc 1.0.1 → 1.0.2
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.js +6 -10
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -25,14 +25,13 @@ export const withIdentity = createMiddleware(async (c, next) => {
|
|
|
25
25
|
id = await provider.getIdentity(tokenResponse);
|
|
26
26
|
if (tokenResponse.access_token)
|
|
27
27
|
await setSignedCookie(c, HONO_OIDC_ACCESS_TOKEN_COOKIE, tokenResponse.access_token, HONO_OIDC_COOKIE_SECRET, { httpOnly: true, secure: true, sameSite: 'Lax' });
|
|
28
|
-
if (tokenResponse.refresh_token)
|
|
29
|
-
|
|
28
|
+
if (tokenResponse.refresh_token) {
|
|
29
|
+
const maxAge = tokenResponse.refresh_token_expires_in ?? (24 * 60 * 60);
|
|
30
|
+
await setSignedCookie(c, HONO_OIDC_REFRESH_TOKEN_COOKIE, tokenResponse.refresh_token, HONO_OIDC_COOKIE_SECRET, { httpOnly: true, secure: true, sameSite: 'Lax', maxAge });
|
|
31
|
+
}
|
|
30
32
|
if (tokenResponse.id_token) {
|
|
31
|
-
let maxAge = 3600;
|
|
32
33
|
const idToken = await provider.decodeIdentityToken(tokenResponse.id_token);
|
|
33
|
-
|
|
34
|
-
maxAge = idToken.exp - Math.floor(Date.now() / 1000);
|
|
35
|
-
}
|
|
34
|
+
const maxAge = idToken.exp - Math.floor(Date.now() / 1000);
|
|
36
35
|
await setSignedCookie(c, HONO_OIDC_ID_TOKEN_COOKIE, tokenResponse.id_token, HONO_OIDC_COOKIE_SECRET, { httpOnly: true, secure: true, sameSite: 'Lax', maxAge });
|
|
37
36
|
}
|
|
38
37
|
}
|
|
@@ -82,11 +81,8 @@ export const forAuthorization = createMiddleware(async (c) => {
|
|
|
82
81
|
if (tokenResponse.refresh_token)
|
|
83
82
|
await setSignedCookie(c, HONO_OIDC_REFRESH_TOKEN_COOKIE, tokenResponse.refresh_token, HONO_OIDC_COOKIE_SECRET, { httpOnly: true, secure: true, sameSite: 'Lax' });
|
|
84
83
|
if (tokenResponse.id_token) {
|
|
85
|
-
let maxAge = 3600;
|
|
86
84
|
const idToken = await provider.decodeIdentityToken(tokenResponse.id_token);
|
|
87
|
-
|
|
88
|
-
maxAge = idToken.exp - Math.floor(Date.now() / 1000);
|
|
89
|
-
}
|
|
85
|
+
const maxAge = idToken.exp - Math.floor(Date.now() / 1000);
|
|
90
86
|
await setSignedCookie(c, HONO_OIDC_ID_TOKEN_COOKIE, tokenResponse.id_token, HONO_OIDC_COOKIE_SECRET, { httpOnly: true, secure: true, sameSite: 'Lax', maxAge });
|
|
91
87
|
}
|
|
92
88
|
return c.redirect(state.originUrl);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shad-claiborne/hono-middleware-oidc",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "OIDC middleware for Hono",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"vitest": "^4.0.17"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@shad-claiborne/basic-oidc": "^1.1.
|
|
49
|
+
"@shad-claiborne/basic-oidc": "^1.1.13",
|
|
50
50
|
"axios": "^1.13.2",
|
|
51
51
|
"crypto-js": "^4.2.0",
|
|
52
52
|
"hono": "^4.11.3",
|