UNPKG

@lucidcms/core

Version:

The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.

2 lines 706 B
import e from"../../../constants/constants.mjs";import t from"../../../utils/helpers/is-request-secure.mjs";import{randomBytes as n}from"node:crypto";import{setCookie as r}from"hono/cookie";import{sign as i}from"hono/jwt";const a=async(a,o)=>{try{let s=a.get(`config`),c=Date.now(),l=n(8).toString(`hex`),u=await i({id:o,exp:Math.floor(c/1e3)+e.accessTokenExpiration,iat:Math.floor(c/1e3),nonce:l},s.secrets.accessToken,e.jwt.algorithm);return r(a,e.cookies.accessToken,u,{maxAge:e.accessTokenExpiration,httpOnly:!0,secure:t(a),sameSite:`strict`,path:`/`}),{error:void 0,data:void 0}}catch{return{error:{type:`authorisation`},data:void 0}}};export{a as default}; //# sourceMappingURL=generate-token.mjs.map