UNPKG

@redocly/graphql-docs

Version:

Redocly GraphQL docs

2 lines (1 loc) 444 B
import{isHostAllowed as r,isLocalhost as i}from"./helpers/index.js";import{validate as n}from"./validate.js";function a(t){return Date.now()/1e3>t}async function u(t){if(process.env.NODE_ENV==="development")return{valid:!0,allowed:!0};const o=window.location.hostname;if(!t)return{local:i(o)};let e;try{e=await n(t)}catch{return{valid:!1,cryptoMissing:!0}}return e.valid=!0,e.expired=e.e?a(e.e):!0,e.allowed=r(o,e.h),e}export{u as parseToken};