@sanity/debug-preview-url-secret-plugin 0.0.1 → 1.0.1

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/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # @sanity/debug-preview-url-secret-plugin
2
+
3
+ ## 1.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#130](https://github.com/sanity-io/plugins/pull/130) [`4399a30`](https://github.com/sanity-io/plugins/commit/4399a3093607d330942791e2f23981906cb8b56d) Thanks [@stipsan](https://github.com/stipsan)! - Improve quality of generated dts
8
+
9
+ ## 1.0.0
10
+
11
+ ### Major Changes
12
+
13
+ - [#37](https://github.com/sanity-io/plugins/pull/37) [`004bf6a`](https://github.com/sanity-io/plugins/commit/004bf6a7edf74cd45fd1dc499ff9f48b64c19712) Thanks [@stipsan](https://github.com/stipsan)! - Initial release of `@sanity/debug-preview-url-secret-plugin`, which replaces `@sanity/preview-url-secret/sanity-plugin-debug-secrets`.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Sanity.io
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,45 +1,42 @@
1
1
  # @sanity/debug-preview-url-secret-plugin
2
2
 
3
- ## ⚠️ IMPORTANT NOTICE ⚠️
4
-
5
- **This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
6
-
7
- This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
8
-
9
- ## Purpose
10
-
11
- This package exists to:
12
- 1. Configure OIDC trusted publishing for the package name `@sanity/debug-preview-url-secret-plugin`
13
- 2. Enable secure, token-less publishing from CI/CD workflows
14
- 3. Establish provenance for packages published under this name
15
-
16
- ## What is OIDC Trusted Publishing?
17
-
18
- OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
19
-
20
- ## Setup Instructions
21
-
22
- To properly configure OIDC trusted publishing for this package:
23
-
24
- 1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
25
- 2. Configure the trusted publisher (e.g., GitHub Actions)
26
- 3. Specify the repository and workflow that should be allowed to publish
27
- 4. Use the configured workflow to publish your actual package
28
-
29
- ## DO NOT USE THIS PACKAGE
30
-
31
- This package is a placeholder for OIDC configuration only. It:
32
- - Contains no executable code
33
- - Provides no functionality
34
- - Should not be installed as a dependency
35
- - Exists only for administrative purposes
36
-
37
- ## More Information
38
-
39
- For more details about npm's trusted publishing feature, see:
40
- - [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
41
- - [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
42
-
43
- ---
44
-
45
- **Maintained for OIDC setup purposes only**
3
+ [![npm stat](https://img.shields.io/npm/dm/@sanity/debug-preview-url-secret-plugin.svg?style=flat-square)](https://npm-stat.com/charts.html?package=@sanity/debug-preview-url-secret-plugin)
4
+ [![npm version](https://img.shields.io/npm/v/@sanity/debug-preview-url-secret-plugin.svg?style=flat-square)](https://www.npmjs.com/package/@sanity/debug-preview-url-secret-plugin)
5
+
6
+ ```sh
7
+ npm install @sanity/debug-preview-url-secret-plugin
8
+ ```
9
+
10
+ This package is used together with [`sanity/presentation`] to debug URL preview secrets and their status.
11
+
12
+ Add the plugin to your `sanity.config.ts`:
13
+
14
+ ```ts
15
+ // ./sanity.config.ts
16
+ import { debugSecrets } from "@sanity/debug-preview-url-secret-plugin";
17
+ import { defineConfig } from "sanity";
18
+ import { structureTool } from "sanity/structure";
19
+ import { presentationTool } from "sanity/presentation";
20
+
21
+ export default defineConfig({
22
+ // ... other options
23
+ plugins: [
24
+ // ... other plugins
25
+ structureTool(),
26
+ presentationTool({
27
+ previewUrl: {
28
+ // @TODO change to the URL of the application, or `location.origin` if it's an embedded Studio
29
+ origin: "http://localhost:3000",
30
+ previewMode: {
31
+ enable: "/api/draft",
32
+ },
33
+ },
34
+ }),
35
+ debugSecrets(),
36
+ ],
37
+ });
38
+ ```
39
+
40
+ You should see a new `@sanity/preview-url-secret` type in Structure Tool, which lists out secrets with metadata about when they were created and in what context.
41
+
42
+ [`sanity/presentation`]: https://www.sanity.io/docs/visual-editing/configuring-the-presentation-tool
@@ -0,0 +1,4 @@
1
+ import * as sanity0 from "sanity";
2
+ declare const debugSecrets: sanity0.Plugin<void>;
3
+ export { debugSecrets };
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":["debugSecrets","sanity0","Plugin"],"sources":["../src/index.d.ts"],"sourcesContent":["export declare const debugSecrets: import(\"sanity\").Plugin<void>;\n//# sourceMappingURL=index.d.ts.map"],"mappings":";cAAqBA,cAA2CC,OAAAA,CAAZC"}
package/dist/index.js ADDED
@@ -0,0 +1,59 @@
1
+ import { LockIcon, CloseCircleIcon, CheckmarkCircleIcon } from "@sanity/icons";
2
+ import { schemaType, SECRET_TTL } from "@sanity/preview-url-secret/constants";
3
+ import { defineType, definePlugin } from "sanity";
4
+ const schema = defineType({
5
+ type: "document",
6
+ icon: LockIcon,
7
+ name: schemaType,
8
+ title: "@sanity/preview-url-secret",
9
+ readOnly: !0,
10
+ fields: [
11
+ {
12
+ type: "string",
13
+ name: "secret",
14
+ title: "Secret"
15
+ },
16
+ {
17
+ type: "string",
18
+ name: "source",
19
+ title: "Source Tool"
20
+ },
21
+ {
22
+ type: "string",
23
+ name: "studioUrl",
24
+ title: "Studio URL"
25
+ },
26
+ {
27
+ type: "string",
28
+ name: "userId",
29
+ title: "Sanity User ID"
30
+ }
31
+ ],
32
+ preview: {
33
+ select: {
34
+ source: "source",
35
+ studioUrl: "studioUrl",
36
+ updatedAt: "_updatedAt"
37
+ },
38
+ prepare(data) {
39
+ const url = data.studioUrl ? new URL(data.studioUrl, location.origin) : void 0, updatedAt = new Date(data.updatedAt).getTime(), expiresAt = new Date(updatedAt + 1e3 * SECRET_TTL), expired = expiresAt < /* @__PURE__ */ new Date(), icon = expired ? CloseCircleIcon : CheckmarkCircleIcon;
40
+ return {
41
+ title: url ? `${url.host}${url.pathname}` : data.source,
42
+ subtitle: expired ? "Expired" : `Expires in ${Math.round((expiresAt.getTime() - Date.now()) / (1e3 * 60))} minutes`,
43
+ media: icon
44
+ };
45
+ }
46
+ }
47
+ }), debugSecrets = definePlugin(() => ({
48
+ name: "sanity-plugin-debug-secrets",
49
+ schema: { types: [schema] },
50
+ document: {
51
+ actions: (prev, context) => context.schemaType !== schemaType ? prev : prev.filter(({ action }) => action === "delete"),
52
+ inspectors: (prev, context) => context.documentType !== schemaType ? prev : [],
53
+ unstable_fieldActions: (prev, context) => context.schemaType.name !== schemaType ? prev : []
54
+ }
55
+ }));
56
+ export {
57
+ debugSecrets
58
+ };
59
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import {CheckmarkCircleIcon, CloseCircleIcon, LockIcon} from '@sanity/icons'\nimport {schemaType, SECRET_TTL} from '@sanity/preview-url-secret/constants'\nimport {definePlugin, defineType} from 'sanity'\n\nconst schema = defineType({\n type: 'document',\n icon: LockIcon,\n name: schemaType,\n title: '@sanity/preview-url-secret',\n readOnly: true,\n fields: [\n {\n type: 'string',\n name: 'secret',\n title: 'Secret',\n },\n {\n type: 'string',\n name: 'source',\n title: 'Source Tool',\n },\n {\n type: 'string',\n name: 'studioUrl',\n title: 'Studio URL',\n },\n {\n type: 'string',\n name: 'userId',\n title: 'Sanity User ID',\n },\n ],\n preview: {\n select: {\n source: 'source',\n studioUrl: 'studioUrl',\n updatedAt: '_updatedAt',\n },\n prepare(data) {\n const url = data.studioUrl ? new URL(data.studioUrl, location.origin) : undefined\n const updatedAt = new Date(data.updatedAt).getTime()\n const expiresAt = new Date(updatedAt + 1000 * SECRET_TTL)\n const expired = expiresAt < new Date()\n const icon = expired ? CloseCircleIcon : CheckmarkCircleIcon\n return {\n title: url ? `${url.host}${url.pathname}` : data.source,\n subtitle: expired\n ? 'Expired'\n : `Expires in ${Math.round((expiresAt.getTime() - Date.now()) / (1000 * 60))} minutes`,\n media: icon,\n }\n },\n },\n})\n\nexport const debugSecrets = definePlugin<void>(() => {\n return {\n name: 'sanity-plugin-debug-secrets',\n schema: {types: [schema]},\n document: {\n actions: (prev, context) => {\n if (context.schemaType !== schemaType) {\n return prev\n }\n return prev.filter(({action}) => action === 'delete')\n },\n inspectors: (prev, context) => {\n if (context.documentType !== schemaType) {\n return prev\n }\n return []\n },\n unstable_fieldActions: (prev, context) => {\n if (context.schemaType.name !== schemaType) {\n return prev\n }\n return []\n },\n },\n }\n})\n"],"names":[],"mappings":";;;AAIA,MAAM,SAAS,WAAW;AAAA,EACxB,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA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BAAuB,CAAC,MAAM,YACxB,QAAQ,WAAW,SAAS,aACvB,OAEF,CAAA;AAAA,EAAC;AAGd,EACD;"}
package/package.json CHANGED
@@ -1,10 +1,55 @@
1
1
  {
2
2
  "name": "@sanity/debug-preview-url-secret-plugin",
3
- "version": "0.0.1",
4
- "description": "OIDC trusted publishing setup package for @sanity/debug-preview-url-secret-plugin",
3
+ "version": "1.0.1",
4
+ "homepage": "https://github.com/sanity-io/plugins/tree/main/plugins/%40sanity/debug-preview-url-secret-plugin#readme",
5
+ "bugs": {
6
+ "url": "https://github.com/sanity-io/plugins/issues"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+ssh://git@github.com/sanity-io/plugins.git",
11
+ "directory": "plugins/@sanity/debug-preview-url-secret-plugin"
12
+ },
5
13
  "keywords": [
6
- "oidc",
7
- "trusted-publishing",
8
- "setup"
9
- ]
10
- }
14
+ "sanity",
15
+ "studio",
16
+ "sanity-plugin"
17
+ ],
18
+ "license": "MIT",
19
+ "author": "Sanity.io <hello@sanity.io>",
20
+ "type": "module",
21
+ "exports": {
22
+ ".": "./dist/index.js",
23
+ "./package.json": "./package.json"
24
+ },
25
+ "types": "./dist/index.d.ts",
26
+ "files": [
27
+ "dist",
28
+ "CHANGELOG.md"
29
+ ],
30
+ "dependencies": {
31
+ "@sanity/icons": "^3.7.4",
32
+ "@sanity/preview-url-secret": "^3.0.0"
33
+ },
34
+ "devDependencies": {
35
+ "@sanity/pkg-utils": "^10.0.0",
36
+ "@types/react": "^19.2.7",
37
+ "@typescript/native-preview": "7.0.0-dev.20251129.1",
38
+ "react": "^19.2.0",
39
+ "sanity": "^4.20.0",
40
+ "typescript": "5.9.3",
41
+ "@repo/package.config": "0.0.0",
42
+ "@repo/tsconfig": "1.0.0"
43
+ },
44
+ "peerDependencies": {
45
+ "react": "^18.3 || ^19",
46
+ "sanity": "^4"
47
+ },
48
+ "engines": {
49
+ "node": ">=20.19 <22 || >=22.12"
50
+ },
51
+ "scripts": {
52
+ "build": "pkg build --strict --check --clean",
53
+ "typecheck": "(cd ../../.. && tsgo --project plugins/@sanity/debug-preview-url-secret-plugin/tsconfig.json)"
54
+ }
55
+ }