vite-plugin-sri4 4.1.0 → 5.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/package.json CHANGED
@@ -1,31 +1,31 @@
1
1
  {
2
2
  "name": "vite-plugin-sri4",
3
- "version": "4.1.0",
3
+ "version": "5.0.0",
4
4
  "description": "A Vite plugin to generate Subresource Integrity (SRI) hashes for output files.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.js",
8
8
  "exports": {
9
9
  ".": {
10
+ "types": "./types/index.d.ts",
10
11
  "import": "./dist/index.js",
11
12
  "require": "./dist/index.cjs"
12
13
  }
13
14
  },
14
15
  "files": [
15
- "dist"
16
+ "dist",
17
+ "types",
18
+ "LICENSE"
16
19
  ],
17
20
  "scripts": {
18
21
  "build": "rollup -c",
19
22
  "dev": "rollup -c -w",
20
- "lint": "oxlint src test example rollup.config.mjs vitest.config.js",
23
+ "lint": "oxlint src test types example rollup.config.mjs vitest.config.js",
21
24
  "test": "vitest run",
22
25
  "test:watch": "vitest",
23
26
  "test:coverage": "vitest run --coverage",
24
27
  "prepublishOnly": "npm run build"
25
28
  },
26
- "dependencies": {
27
- "cross-fetch": "^4.1.0"
28
- },
29
29
  "peerDependencies": {
30
30
  "vite": "^6.4.0 || ^7.0.0 || ^8.0.0"
31
31
  },
@@ -45,7 +45,7 @@
45
45
  "subresource integrity"
46
46
  ],
47
47
  "author": "Zac",
48
- "license": "ISC",
48
+ "license": "MIT",
49
49
  "publishConfig": {
50
50
  "access": "public"
51
51
  },
@@ -56,5 +56,9 @@
56
56
  "bugs": {
57
57
  "url": "https://github.com/7a6163/vite-plugin-sri4/issues"
58
58
  },
59
- "homepage": "https://github.com/7a6163/vite-plugin-sri4#readme"
59
+ "homepage": "https://github.com/7a6163/vite-plugin-sri4#readme",
60
+ "types": "./types/index.d.ts",
61
+ "engines": {
62
+ "node": ">=18"
63
+ }
60
64
  }
@@ -0,0 +1,72 @@
1
+ import type { Plugin } from 'vite'
2
+
3
+ /** The only algorithms the SRI spec defines; browsers reject anything else. */
4
+ export type SriHashAlgorithm = 'sha256' | 'sha384' | 'sha512'
5
+
6
+ export interface SriOptions {
7
+ /**
8
+ * Hash algorithm used to compute the integrity value.
9
+ * @default 'sha384'
10
+ */
11
+ hashAlgorithm?: SriHashAlgorithm
12
+
13
+ /**
14
+ * Value for the injected `crossorigin` attribute. Tags that already declare
15
+ * one are left alone.
16
+ * @default 'anonymous'
17
+ */
18
+ crossorigin?: 'anonymous' | 'use-credentials'
19
+
20
+ /**
21
+ * Hostnames to leave untouched. Matches the host itself and its subdomains.
22
+ * Only applies to external URLs, protocol-relative `//host/path` included;
23
+ * use the `skip-sri` attribute on a tag to opt a single element out.
24
+ * @default []
25
+ */
26
+ bypassDomains?: string[]
27
+
28
+ /**
29
+ * Hostnames whose bytes you vouch for. An external resource is normally only
30
+ * hashed when its origin declares the URL immutable (`Cache-Control:
31
+ * immutable`, or a max-age of a year or more); a host listed here is hashed
32
+ * regardless. Matches the host itself and its subdomains.
33
+ *
34
+ * Use it for a stable host that does not set the header - not to force SRI
35
+ * onto a vendor's rolling URL, which will break on their next deploy.
36
+ * @default []
37
+ */
38
+ trustDomains?: string[]
39
+
40
+ /**
41
+ * Warn instead of failing the build when an asset resolves to neither a
42
+ * bundle entry nor a file in `publicDir`.
43
+ * @default false
44
+ */
45
+ ignoreMissingAsset?: boolean
46
+
47
+ /**
48
+ * Log verbosity.
49
+ * @default 'warn'
50
+ */
51
+ logLevel?: 'silent' | 'error' | 'warn' | 'info' | 'debug'
52
+
53
+ /**
54
+ * Inject `<script type="importmap">` carrying an `integrity` map for every
55
+ * JS chunk, covering modules loaded at runtime by `import()` that have no
56
+ * build-time tag to rewrite.
57
+ * @default false
58
+ */
59
+ importmap?: boolean
60
+
61
+ /**
62
+ * Emit `sri-manifest.json` mapping every non-HTML output file to its hash,
63
+ * for servers that render HTML per request.
64
+ * @default false
65
+ */
66
+ manifest?: boolean
67
+ }
68
+
69
+ declare function sri(options?: SriOptions): Plugin
70
+
71
+ export default sri
72
+ export { sri }