Socket
Socket
Sign inDemoInstall

@sanity/preview-url-secret

Package Overview
Dependencies
Maintainers
48
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sanity/preview-url-secret - npm Package Compare versions

Comparing version 1.6.10 to 1.6.11

8

CHANGELOG.md

@@ -9,2 +9,10 @@ <!-- markdownlint-disable --><!-- textlint-disable -->

## [1.6.11](https://github.com/sanity-io/visual-editing/compare/preview-url-secret-v1.6.10...preview-url-secret-v1.6.11) (2024-04-22)
### Bug Fixes
* **deps:** update dependency @sanity/client to v6.15.20 ([#1385](https://github.com/sanity-io/visual-editing/issues/1385)) ([8ead6bf](https://github.com/sanity-io/visual-editing/commit/8ead6bf64505b194ebe1b084d6f5b6d4f1d7196e))
* preserve URL hash ([d37e317](https://github.com/sanity-io/visual-editing/commit/d37e317fdcbb97841966e18ec371bd46a6769bd2))
## [1.6.10](https://github.com/sanity-io/visual-editing/compare/preview-url-secret-v1.6.9...preview-url-secret-v1.6.10) (2024-04-19)

@@ -11,0 +19,0 @@

2

dist/index.d.ts

@@ -11,3 +11,3 @@ /**

/**
* If the URL is valid, and the studior URL is known and valid, then its origin will be here
* If the URL is valid, and the studio URL is known and valid, then its origin will be here
*/

@@ -14,0 +14,0 @@ studioOrigin?: string

@@ -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}=new URL(n,"http://localhost");o=`${e}${t}`}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,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
{
"name": "@sanity/preview-url-secret",
"version": "1.6.10",
"version": "1.6.11",
"homepage": "https://github.com/sanity-io/visual-editing/tree/main/packages/preview-url-secret#readme",

@@ -81,2 +81,4 @@ "bugs": {

"src",
"!src/**/*.test.ts",
"!src/**/*.test-d.ts",
"CHANGELOG.md"

@@ -134,7 +136,7 @@ ],

"@repo/channels": "0.4.0",
"@sanity/client": "^6.15.19",
"@sanity/client": "^6.15.20",
"@sanity/icons": "^2.11.8",
"@sanity/pkg-utils": "6.8.1",
"@typescript-eslint/eslint-plugin": "^7.7.0",
"@typescript-eslint/parser": "^7.7.0",
"@typescript-eslint/eslint-plugin": "^7.7.1",
"@typescript-eslint/parser": "^7.7.1",
"eslint": "^8.57.0",

@@ -150,3 +152,3 @@ "eslint-config-prettier": "^9.1.0",

"peerDependencies": {
"@sanity/client": "^6.15.19"
"@sanity/client": "^6.15.20"
},

@@ -153,0 +155,0 @@ "engines": {

@@ -16,6 +16,6 @@ import {urlSearchParamPreviewPathname, urlSearchParamPreviewSecret} from './constants'

if (unsafeRedirectTo) {
const {pathname, search} = new URL(unsafeRedirectTo, 'http://localhost')
redirectTo = `${pathname}${search}`
const {pathname, search, hash} = new URL(unsafeRedirectTo, 'http://localhost')
redirectTo = `${pathname}${search}${hash}`
}
return {secret, redirectTo}
}

@@ -51,3 +51,3 @@ /** @internal */

/**
* If the URL is valid, and the studior URL is known and valid, then its origin will be here
* If the URL is valid, and the studio URL is known and valid, then its origin will be here
*/

@@ -54,0 +54,0 @@ studioOrigin?: string

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc