@localnerve/csp-hashes 2.0.1 → 2.0.3

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/index.js CHANGED
@@ -4,7 +4,7 @@
4
4
  * Return a Vinyl transform object stream to process html files for
5
5
  * generating the required CSP hashes for inline and attribute scripts, styles.
6
6
  *
7
- * Copyright (c) 2022 Alex Grant (@localnerve), LocalNerve LLC
7
+ * Copyright (c) 2022-2023 Alex Grant (@localnerve), LocalNerve LLC
8
8
  * Licensed under the MIT license.
9
9
  */
10
10
  /* eslint-env node */
package/lib/index.js CHANGED
@@ -4,7 +4,7 @@
4
4
  * Return a Vinyl transform object stream to process html files for
5
5
  * generating the required CSP hashes for inline and attribute scripts, styles.
6
6
  *
7
- * Copyright (c) 2022 Alex Grant (@localnerve), LocalNerve LLC
7
+ * Copyright (c) 2022-2023 Alex Grant (@localnerve), LocalNerve LLC
8
8
  * Licensed under the MIT license.
9
9
  */
10
10
  import { Transform } from 'stream';
@@ -4,7 +4,7 @@
4
4
  * A convenience method to remove the content of a Content-Security-Policy in a meta tag.
5
5
  * Useful for development builds that need to ignore CSP meta tags.
6
6
  *
7
- * Copyright (c) 2022 Alex Grant (@localnerve), LocalNerve LLC
7
+ * Copyright (c) 2022-2023 Alex Grant (@localnerve), LocalNerve LLC
8
8
  * Licensed under the MIT license.
9
9
  */
10
10
  import { Transform } from 'stream';
package/license.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2022, Alex Grant, LocalNerve, LLC
1
+ Copyright 2022-2023, Alex Grant, LocalNerve, LLC
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@localnerve/csp-hashes",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "Flexible library to generate CSP hashes",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -16,9 +16,9 @@
16
16
  },
17
17
  "devDependencies": {
18
18
  "@babel/preset-env": "^7.20.2",
19
- "eslint": "^8.30.0",
20
- "jest": "^29.3.1",
21
- "vinyl": "^2.2.1"
19
+ "eslint": "^8.36.0",
20
+ "jest": "^29.5.0",
21
+ "vinyl": "^3.0.0"
22
22
  },
23
23
  "dependencies": {
24
24
  "cheerio": "^1.0.0-rc.12"
package/readme.md CHANGED
@@ -8,6 +8,7 @@
8
8
 
9
9
  ## Contents
10
10
  + [Overview](#overview)
11
+ + [Breaking Changes](#breaking-changes)
11
12
  + [API](#API)
12
13
  + [Options](#options)
13
14
  + [Callback Function](#callback-function)
@@ -15,11 +16,15 @@
15
16
  + [Example Usage](#example-usage)
16
17
  + [CSP Headers](#build-step-to-maintain-csp-headers)
17
18
  + [Meta Tag](#build-step-to-maintain-csp-meta-tags)
19
+ + [Non-Esm Usage](#non-esm-usage)
18
20
  + [MIT License](#license)
19
21
 
20
22
  ## Overview
21
23
  This Nodejs library generates script and style inline element and attribute hashes. It is for use in the generation of HTTP content security policy (CSP) headers or to replace/update Meta tags as a website build step. Ready for use with [Gulp](https://github.com/gulpjs/gulp).
22
24
 
25
+ ## Breaking Changes
26
+ + As of Version 2+, this is an ES Module. See [Non-Esm Usage](#non-esm-usage) for how to use outside of ESM.
27
+
23
28
  ## Prerequisites
24
29
  + NodeJS 14+
25
30
 
@@ -154,6 +159,19 @@ export function stripCspMetaContents (settings) {
154
159
  }
155
160
  ```
156
161
 
162
+ ### Non-ESM usage
163
+ As of Version 2, this package is an ES Module, making it incompatible with `require`. To use outside of ESM, you can use this with a dynamic import as in the following example:
164
+
165
+ ```javascript
166
+ import('@localnerve/csp-hashes').then(({ hashstream }) => {
167
+ hashstream({
168
+ callback: (p, hashes, contents) => {
169
+ // do stuff
170
+ }
171
+ });
172
+ });
173
+ ```
174
+
157
175
  ## LICENSE
158
176
 
159
177
  * [MIT, Alex Grant, LocalNerve, LLC](license.md)