Socket
Socket
Sign inDemoInstall

@sanity/preview-url-secret

Package Overview
Dependencies
Maintainers
56
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.22-canary.9 to 1.6.22-canary.10

dist/validate-secret.cjs

2

dist/create-secret.d.ts

@@ -19,3 +19,3 @@ import type {SanityClient} from '@sanity/client'

* as well as those that use `import type { SanityClient } from '@sanity/client'`
* @internal
* @public
*/

@@ -22,0 +22,0 @@ export declare type SanityClientLike = {

@@ -20,3 +20,3 @@ /**

* as well as those that use `import type { SanityClient } from '@sanity/client'`
* @internal
* @public
*/

@@ -23,0 +23,0 @@ export declare type SanityClientLike = {

@@ -1,2 +0,3 @@

import { apiVersion, urlSearchParamPreviewSecret, urlSearchParamPreviewPathname, fetchSecretQuery, tag, isDev } from './constants.js';
import { apiVersion, urlSearchParamPreviewSecret, urlSearchParamPreviewPathname, isDev } from './constants.js';
import { validateSecret } from './validate-secret.js';

@@ -39,24 +40,2 @@ function createClientWithConfig(client) {

async function validateSecret(client, secret, disableCacheNoStore) {
if (typeof EdgeRuntime !== "undefined") {
await new Promise((resolve) => setTimeout(resolve, 300));
}
if (!secret || !secret.trim()) {
return { isValid: false, studioUrl: null };
}
const result = await client.fetch(
fetchSecretQuery,
{ secret },
{
tag,
// In CloudFlare Workers we can't pass the cache header
...!disableCacheNoStore ? { cache: "no-store" } : void 0
}
);
if (!result?._id || !result?._updatedAt || !result?.secret) {
return { isValid: false, studioUrl: null };
}
return { isValid: secret === result.secret, studioUrl: result.studioUrl };
}
async function validatePreviewUrl(_client, previewUrl, disableCacheNoStore = globalThis.navigator?.userAgent === "Cloudflare-Workers") {

@@ -63,0 +42,0 @@ const client = createClientWithConfig(_client);

{
"name": "@sanity/preview-url-secret",
"version": "1.6.22-canary.9",
"version": "1.6.22-canary.10",
"homepage": "https://github.com/sanity-io/visual-editing/tree/main/packages/preview-url-secret#readme",

@@ -54,2 +54,8 @@ "bugs": {

},
"./validate-secret": {
"source": "./src/_exports/validate-secret.ts",
"import": "./dist/validate-secret.js",
"require": "./dist/validate-secret.cjs",
"default": "./dist/validate-secret.js"
},
"./without-secret-search-params": {

@@ -83,2 +89,5 @@ "source": "./src/_exports/without-secret-search-params.ts",

],
"validate-secret": [
"./dist/validate-secret.d.ts"
],
"without-secret-search-params": [

@@ -115,6 +124,6 @@ "./dist/without-secret-search-params.d.ts"

"vitest": "^2.1.1",
"@repo/channels": "0.4.0",
"@repo/package.config": "0.0.0",
"@repo/eslint-config": "0.0.0",
"@repo/package.config": "0.0.0",
"@repo/prettier-config": "0.0.0"
"@repo/prettier-config": "0.0.0",
"@repo/channels": "0.4.0"
},

@@ -121,0 +130,0 @@ "peerDependencies": {

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

* as well as those that use `import type { SanityClient } from '@sanity/client'`
* @internal
* @public
*/

@@ -21,0 +21,0 @@ export type SanityClientLike = {

import {fetchSecretQuery, tag} from './constants'
import type {FetchSecretQueryParams, FetchSecretQueryResponse, SanityClientLike} from './types'
/** @internal */
export type {SanityClientLike}
/** @public */
export async function validateSecret(

@@ -6,0 +8,0 @@ client: SanityClientLike,

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

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