@sanity/debug-preview-url-secret-plugin 0.0.1 → 1.0.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/CHANGELOG.md +7 -0
- package/LICENSE +21 -0
- package/README.md +40 -43
- package/dist/index.d.ts +3 -0
- package/dist/index.js +63 -0
- package/dist/index.js.map +1 -0
- package/package.json +57 -7
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# @sanity/debug-preview-url-secret-plugin
|
|
2
|
+
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#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
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
---
|
|
44
|
-
|
|
45
|
-
**Maintained for OIDC setup purposes only**
|
|
3
|
+
[](https://npm-stat.com/charts.html?package=@sanity/debug-preview-url-secret-plugin)
|
|
4
|
+
[](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
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { definePlugin, defineType } from "sanity";
|
|
2
|
+
import { LockIcon, CloseCircleIcon, CheckmarkCircleIcon } from "@sanity/icons";
|
|
3
|
+
import { schemaType, SECRET_TTL } from "@sanity/preview-url-secret/constants";
|
|
4
|
+
const debugSecrets = definePlugin(() => ({
|
|
5
|
+
name: "sanity-plugin-debug-secrets",
|
|
6
|
+
schema: {
|
|
7
|
+
types: [
|
|
8
|
+
defineType({
|
|
9
|
+
type: "document",
|
|
10
|
+
icon: LockIcon,
|
|
11
|
+
name: schemaType,
|
|
12
|
+
title: "@sanity/preview-url-secret",
|
|
13
|
+
readOnly: !0,
|
|
14
|
+
fields: [
|
|
15
|
+
{
|
|
16
|
+
type: "string",
|
|
17
|
+
name: "secret",
|
|
18
|
+
title: "Secret"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
type: "string",
|
|
22
|
+
name: "source",
|
|
23
|
+
title: "Source Tool"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
type: "string",
|
|
27
|
+
name: "studioUrl",
|
|
28
|
+
title: "Studio URL"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
type: "string",
|
|
32
|
+
name: "userId",
|
|
33
|
+
title: "Sanity User ID"
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
preview: {
|
|
37
|
+
select: {
|
|
38
|
+
source: "source",
|
|
39
|
+
studioUrl: "studioUrl",
|
|
40
|
+
updatedAt: "_updatedAt"
|
|
41
|
+
},
|
|
42
|
+
prepare(data) {
|
|
43
|
+
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;
|
|
44
|
+
return {
|
|
45
|
+
title: url ? `${url.host}${url.pathname}` : data.source,
|
|
46
|
+
subtitle: expired ? "Expired" : `Expires in ${Math.round((expiresAt.getTime() - Date.now()) / (1e3 * 60))} minutes`,
|
|
47
|
+
media: icon
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
document: {
|
|
55
|
+
actions: (prev, context) => context.schemaType !== schemaType ? prev : prev.filter(({ action }) => action === "delete"),
|
|
56
|
+
inspectors: (prev, context) => context.documentType !== schemaType ? prev : [],
|
|
57
|
+
unstable_fieldActions: (prev, context) => context.schemaType.name !== schemaType ? prev : []
|
|
58
|
+
}
|
|
59
|
+
}));
|
|
60
|
+
export {
|
|
61
|
+
debugSecrets
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import {definePlugin, defineType} from 'sanity'\n\nimport {CheckmarkCircleIcon, CloseCircleIcon, LockIcon} from '@sanity/icons'\nimport {schemaType, SECRET_TTL} from '@sanity/preview-url-secret/constants'\n\nexport const debugSecrets = definePlugin<void>(() => {\n return {\n name: 'sanity-plugin-debug-secrets',\n schema: {\n types: [\n 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']\n ? new URL(data['studioUrl'], location.origin)\n : 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 ],\n },\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":";;;AAKO,MA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AAY,WAAW,QAAQ;AAAA,IAEtD,YAAY,CAAC,MAAM,YACb,QAAQ,iBAAiB,aACpB,OAEF,CAAA;AAAA,IAET,uBAAuB,CAAC,MAAM,YACxB,QAAQ,WAAW,SAAS,aACvB,OAEF,CAAA;AAAA,EAAC;AAGd,EACD;"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/debug-preview-url-secret-plugin",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"
|
|
3
|
+
"version": "1.0.0",
|
|
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
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
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
|
+
".": {
|
|
23
|
+
"source": "./src/index.ts",
|
|
24
|
+
"default": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"CHANGELOG.md"
|
|
32
|
+
],
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@sanity/icons": "^3.7.4",
|
|
35
|
+
"@sanity/preview-url-secret": "^3.0.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@sanity/pkg-utils": "^9.1.1",
|
|
39
|
+
"@types/react": "^19.2.6",
|
|
40
|
+
"@typescript/native-preview": "7.0.0-dev.20251121.1",
|
|
41
|
+
"react": "^19.2.0",
|
|
42
|
+
"sanity": "^4.17.0",
|
|
43
|
+
"typescript": "5.9.3",
|
|
44
|
+
"@repo/package.config": "0.0.0"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"react": "^18.3 || ^19",
|
|
48
|
+
"sanity": "^4"
|
|
49
|
+
},
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": ">=20.19 <22 || >=22.12"
|
|
52
|
+
},
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"access": "public"
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"typecheck": "(cd ../../.. && tsgo --project plugins/@sanity/debug-preview-url-secret-plugin/tsconfig.json)",
|
|
58
|
+
"build": "pkg build --strict --check --clean"
|
|
59
|
+
}
|
|
60
|
+
}
|