prismic 1.6.1 → 1.7.0
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/auth-IehtWQjS.mjs +1 -0
- package/dist/builders-hKD4IrLX-BwgX8hql.mjs +97 -0
- package/dist/env-DbZx_TgQ.mjs +1 -0
- package/dist/index.mjs +192 -55
- package/dist/{nextjs-AYG0nc8K.mjs → nextjs-BNMpl2Nc.mjs} +3 -3
- package/dist/nuxt-DJG48HGU.mjs +90 -0
- package/dist/package-D7f_4PH5.mjs +1 -0
- package/dist/packageJson-BNFJTFZF.mjs +2 -0
- package/dist/request-DClMWmnH.mjs +1 -0
- package/dist/schemas-CyhgtjZl.mjs +1 -0
- package/dist/{segment-4X9XW3DX.mjs → segment-B4aDWMdC.mjs} +1 -1
- package/dist/string-Bf7FlVOu.mjs +173 -0
- package/dist/subprocesses/refreshToken.mjs +1 -1
- package/dist/subprocesses/sendSegmentEvents.mjs +1 -1
- package/dist/subprocesses/updateVersionState.mjs +1 -1
- package/dist/{sveltekit-C0aTxdd3.mjs → sveltekit-DgUUeJoO.mjs} +7 -7
- package/dist/update-notifier-zw3PKsIt.mjs +1 -0
- package/package.json +1 -1
- package/dist/auth-CFvQoAjM.mjs +0 -1
- package/dist/builders-hKD4IrLX-CxJn8TFj.mjs +0 -97
- package/dist/env-LvTyEV-S.mjs +0 -1
- package/dist/json-CCpSnNgM.mjs +0 -1
- package/dist/nuxt-Bsg0kvON.mjs +0 -90
- package/dist/package-DZQ0fS1u.mjs +0 -1
- package/dist/packageJson-CfpsZ9YS.mjs +0 -2
- package/dist/schemas-BDdFIiZQ.mjs +0 -1
- package/dist/string-Cm7AZ7LW.mjs +0 -173
- package/dist/update-notifier-C2AFlvX2.mjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_ as e,d as t,g as n,p as r,s as i}from"./schemas-CyhgtjZl.mjs";import{a,d as o,f as s,o as c,s as l}from"./request-DClMWmnH.mjs";import{n as u,t as d}from"./env-DbZx_TgQ.mjs";import{readFile as f,rm as p}from"node:fs/promises";import{fileURLToPath as m,pathToFileURL as h}from"node:url";import{spawn as g}from"node:child_process";import{createServer as _}from"node:http";import{homedir as v}from"node:os";async function y(e,t){let{host:n}=t,i=b(n),o=new URL(`refreshtoken`,i);return o.searchParams.set(`token`,e),await a(o,{schema:r()})}function b(e){return new URL(`https://auth.${e}/`)}function x(e,t){if(t)return s(h(t));if(process.platform===`win32`){let t=process.env.APPDATA;if(t)return new URL(`${e}/`,s(h(t)))}if(process.platform!==`darwin`){let t=process.env.XDG_CONFIG_HOME;if(t)return new URL(`${e}/`,s(h(t)))}let n=s(h(v()));return new URL(`.config/${e}/`,n)}const S=x(`prismic`,u.PRISMIC_CONFIG_DIR),C=new URL(`credentials.json`,S),w=new URL(`update-notifier.json`,S),T=i({token:t(r().check(n(1))),host:t(r().check(n(1)))});async function E(){return(await A())?.token}async function D(){return u.PRISMIC_HOST?u.PRISMIC_HOST:(await A())?.host||d}async function O(){let e=await E();if(!e)return;let t=await D(),n=await y(e,{host:t});return await j({token:n,host:t}),n}async function k(){if(!await l(C))return!0;try{return await p(C,{force:!0}),!0}catch{return!1}}async function A(){try{let t=await f(C,`utf-8`);return e(T,JSON.parse(t))}catch{return}}async function j(e){await o(C,c(e))}async function M(e){let t=await D(),n=`https://${t}`;return new Promise((r,i)=>{let a=_((e,i)=>{if(e.method===`OPTIONS`){i.writeHead(204,{"Access-Control-Allow-Origin":n,"Access-Control-Allow-Methods":`POST, OPTIONS`,"Access-Control-Allow-Headers":`Content-Type`}),i.end();return}if(e.method===`POST`){let s=``;e.on(`data`,e=>{s+=e.toString()}),e.on(`end`,async()=>{try{let{cookies:e,email:c}=JSON.parse(s),l=e.find(e=>e.startsWith(`prismic-auth=`))?.split(`;`)[0]?.replace(/^prismic-auth=/,``);if(!l){i.writeHead(400,{"Access-Control-Allow-Origin":n,"Content-Type":`application/json`}),i.end(JSON.stringify({error:`Invalid request`}));return}await j({token:l,host:t}),i.writeHead(200,{"Access-Control-Allow-Origin":n,"Content-Type":`application/json`}),i.end(JSON.stringify({success:!0})),clearTimeout(o),a.close(),r({email:c})}catch{i.writeHead(400,{"Access-Control-Allow-Origin":n,"Content-Type":`application/json`}),i.end(JSON.stringify({error:`Invalid request`}))}});return}i.writeHead(404),i.end()}),o=setTimeout(()=>{a.close(),i(Error(`Login timed out. Please try again.`))},18e4),s=async()=>{let n=a.address();if(!n||typeof n==`string`){clearTimeout(o),a.close(),i(Error(`Failed to start login server`));return}let r=await F(t,n.port);e?.onReady?.(r)};a.on(`error`,e=>{e.code===`EADDRINUSE`&&a.listening===!1?a.listen(0,`0.0.0.0`,s):(clearTimeout(o),i(e))}),a.listen(5555,`0.0.0.0`,s)})}const N=new URL(`.prismic`,s(h(v())));async function P(){let e;try{e=await f(N,`utf-8`)}catch{return}try{let t=JSON.parse(e);if(!t||t.latestKnownVersion===void 0&&t.lastUpdateCheckAt===void 0)return}catch{return}try{await p(N,{force:!0})}catch{}}async function F(e,t){let n=new URL(`dashboard/cli/login`,`https://${e}/`);return n.searchParams.set(`source`,`prismic-cli`),n.searchParams.set(`port`,t.toString()),n}function I(){try{let e=m(new URL(`./subprocesses/refreshToken.mjs`,import.meta.url));g(process.execPath,[e],{detached:!0,stdio:`ignore`}).unref()}catch{}}export{k as a,w as c,E as i,M as n,O as o,D as r,I as s,P as t};
|