@sanity/preview-url-secret
Advanced tools
Comparing version 1.6.19 to 1.6.20
@@ -9,2 +9,9 @@ <!-- markdownlint-disable --><!-- textlint-disable --> | ||
## [1.6.20](https://github.com/sanity-io/visual-editing/compare/preview-url-secret-v1.6.19...preview-url-secret-v1.6.20) (2024-08-12) | ||
### Bug Fixes | ||
* **deps:** update dependency @sanity/client to v6.21.2 ([#1749](https://github.com/sanity-io/visual-editing/issues/1749)) ([b9efdd2](https://github.com/sanity-io/visual-editing/commit/b9efdd2a672fdef518bc22a29a25992c938ba1ef)) | ||
## [1.6.19](https://github.com/sanity-io/visual-editing/compare/preview-url-secret-v1.6.18...preview-url-secret-v1.6.19) (2024-08-02) | ||
@@ -11,0 +18,0 @@ |
@@ -1,1 +0,1 @@ | ||
import{u as e,b as t}from"./_chunks-es/constants.js";function r(r){const{draftMode:n,previewMode:a,origin:o=(typeof location>"u"?"https://localhost":location.origin)}=r,i=(null==a?void 0:a.enable)||(null==n?void 0:n.enable);let{preview:s="/"}=r;const c=new URL(s,o),h=i?new URL(i,o):void 0;return async n=>{try{if(n.previewSearchParam){const e=new URL(n.previewSearchParam,c);e.origin===c.origin&&(s=`${e.pathname}${e.search}`)}else if(n.referrer){const e=new URL(n.referrer);e.origin===c.origin&&(s=`${e.pathname}${e.search}`)}}catch{}typeof location<"u"&&location.origin===c.origin&&n.studioBasePath&&(s.startsWith(`${n.studioBasePath}/`)||s===n.studioBasePath)&&(s=r.preview||"/");const a=new URL(s,c);if(h){const r=new URL(h),{searchParams:o}=r;return o.set(e,n.previewUrlSecret),a.pathname!==r.pathname&&o.set(t,`${a.pathname}${a.search}`),r.toString()}return a.toString()}}export{r as definePreviewUrl};//# sourceMappingURL=define-preview-url.js.map | ||
import{u as e,b as t}from"./_chunks-es/constants.js";function r(r){const{draftMode:a,previewMode:n,origin:o=(typeof location>"u"?"https://localhost":location.origin)}=r,i=n?.enable||a?.enable;let{preview:s="/"}=r;const c=new URL(s,o),h=i?new URL(i,o):void 0;return async a=>{try{if(a.previewSearchParam){const e=new URL(a.previewSearchParam,c);e.origin===c.origin&&(s=`${e.pathname}${e.search}`)}else if(a.referrer){const e=new URL(a.referrer);e.origin===c.origin&&(s=`${e.pathname}${e.search}`)}}catch{}typeof location<"u"&&location.origin===c.origin&&a.studioBasePath&&(s.startsWith(`${a.studioBasePath}/`)||s===a.studioBasePath)&&(s=r.preview||"/");const n=new URL(s,c);if(h){const r=new URL(h),{searchParams:o}=r;return o.set(e,a.previewUrlSecret),n.pathname!==r.pathname&&o.set(t,`${n.pathname}${n.search}`),r.toString()}return n.toString()}}export{r as definePreviewUrl};//# sourceMappingURL=define-preview-url.js.map |
@@ -1,1 +0,1 @@ | ||
import{a as e,u as t,b as r,f as i,t as s,i as o}from"./_chunks-es/constants.js";async function n(n,a,l="Cloudflare-Workers"===(e=>null==(e=globalThis.navigator)?void 0:e.userAgent)()){const c=function(t){if(!t)throw new TypeError("`client` is required");if(!t.config().token)throw new TypeError("`client` must have a `token` specified");return t.withConfig({apiVersion:e,useCdn:!1,perspective:"published",resultSourceMap:!1,stega:!1})}(n);let u;try{u=function(e){const i=new URL(e,"http://localhost"),s=i.searchParams.get(t);if(!s)throw new Error("Missing secret");let o;const n=i.searchParams.get(r);if(n){const{pathname:e,search:t,hash:r}=new URL(n,"http://localhost");o=`${e}${t}${r}`}return{secret:s,redirectTo:o}}(a)}catch(e){return o&&console.error("Failed to parse preview URL",e,{previewUrl:a,client:c}),{isValid:!1}}const{isValid:d,studioUrl:h}=await async function(e,t,r){if(typeof EdgeRuntime<"u"&&await new Promise((e=>setTimeout(e,300))),!t||!t.trim())return{isValid:!1,studioUrl:null};const o=await e.fetch(i,{secret:t},{tag:s,...r?void 0:{cache:"no-store"}});return null!=o&&o._id&&null!=o&&o._updatedAt&&null!=o&&o.secret?{isValid:t===o.secret,studioUrl:o.studioUrl}:{isValid:!1,studioUrl:null}}(c,u.secret,l),p=d?u.redirectTo:void 0;let f;if(d)try{f=new URL(h).origin}catch(e){o&&console.error("Failed to parse studioUrl",e,{previewUrl:a,studioUrl:h})}return{isValid:d,redirectTo:p,studioOrigin:f}}export{r as urlSearchParamPreviewPathname,t as urlSearchParamPreviewSecret,n as validatePreviewUrl};//# sourceMappingURL=index.js.map | ||
import{a as e,u as t,b as r,f as i,t as s,i as o}from"./_chunks-es/constants.js";async function n(n,a,c="Cloudflare-Workers"===globalThis.navigator?.userAgent){const l=function(t){if(!t)throw new TypeError("`client` is required");if(!t.config().token)throw new TypeError("`client` must have a `token` specified");return t.withConfig({apiVersion:e,useCdn:!1,perspective:"published",resultSourceMap:!1,stega:!1})}(n);let u;try{u=function(e){const i=new URL(e,"http://localhost"),s=i.searchParams.get(t);if(!s)throw new Error("Missing secret");let o;const n=i.searchParams.get(r);if(n){const{pathname:e,search:t,hash:r}=new URL(n,"http://localhost");o=`${e}${t}${r}`}return{secret:s,redirectTo:o}}(a)}catch(e){return o&&console.error("Failed to parse preview URL",e,{previewUrl:a,client:l}),{isValid:!1}}const{isValid:d,studioUrl:h}=await async function(e,t,r){if(typeof EdgeRuntime<"u"&&await new Promise((e=>setTimeout(e,300))),!t||!t.trim())return{isValid:!1,studioUrl:null};const o=await e.fetch(i,{secret:t},{tag:s,...r?void 0:{cache:"no-store"}});return o?._id&&o?._updatedAt&&o?.secret?{isValid:t===o.secret,studioUrl:o.studioUrl}:{isValid:!1,studioUrl:null}}(l,u.secret,c),p=d?u.redirectTo:void 0;let f;if(d)try{f=new URL(h).origin}catch(e){o&&console.error("Failed to parse studioUrl",e,{previewUrl:a,studioUrl:h})}return{isValid:d,redirectTo:p,studioOrigin:f}}export{r as urlSearchParamPreviewPathname,t as urlSearchParamPreviewSecret,n as validatePreviewUrl};//# sourceMappingURL=index.js.map |
{ | ||
"name": "@sanity/preview-url-secret", | ||
"version": "1.6.19", | ||
"version": "1.6.20", | ||
"homepage": "https://github.com/sanity-io/visual-editing/tree/main/packages/preview-url-secret#readme", | ||
@@ -134,19 +134,19 @@ "bugs": { | ||
"devDependencies": { | ||
"@repo/channels": "0.4.0", | ||
"@sanity/client": "^6.21.1", | ||
"@sanity/icons": "^3.2.0", | ||
"@sanity/client": "^6.21.2", | ||
"@sanity/icons": "^3.3.1", | ||
"@sanity/pkg-utils": "6.9.3", | ||
"@typescript-eslint/eslint-plugin": "^7.13.1", | ||
"@typescript-eslint/parser": "^7.13.1", | ||
"@typescript-eslint/eslint-plugin": "^7.18.0", | ||
"@typescript-eslint/parser": "^7.18.0", | ||
"eslint": "^8.57.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-prettier": "^5.1.3", | ||
"eslint-plugin-simple-import-sort": "^12.1.0", | ||
"sanity": "^3.47.1", | ||
"eslint-plugin-prettier": "^5.2.1", | ||
"eslint-plugin-simple-import-sort": "^12.1.1", | ||
"sanity": "^3.53.0", | ||
"typescript": "5.4.5", | ||
"vitest": "^1.6.0", | ||
"vitest": "^2.0.5", | ||
"@repo/channels": "0.4.0", | ||
"@repo/package.config": "0.0.0" | ||
}, | ||
"peerDependencies": { | ||
"@sanity/client": "^6.21.1" | ||
"@sanity/client": "^6.21.2" | ||
}, | ||
@@ -161,6 +161,6 @@ "engines": { | ||
"build": "pkg build --strict --check --clean", | ||
"dev": "pkg build --strict", | ||
"lint": "eslint .", | ||
"test": "vitest --pass-with-no-tests --typecheck", | ||
"watch": "pkg watch --strict" | ||
"test": "vitest --pass-with-no-tests --typecheck" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
120996
803