@shgysk8zer0/importmap 1.4.30 → 1.4.32
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 +15 -0
- package/cli.cjs +14 -9
- package/cli.js +14 -9
- package/hash.js +11 -11
- package/importmap.cjs +13 -9
- package/importmap.js +13 -9
- package/importmap.json +13 -9
- package/index.cjs +23 -20
- package/index.js +23 -20
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [v1.4.32] - 2024-12-19
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- Add `@shgysk8zer0/geoutils`
|
|
14
|
+
- Add basic tests for hashing
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
- Update `hash()` to now use new `Uint8Array` methods
|
|
18
|
+
- Use `@shgysk8zer0/polyfills` as an external dependency
|
|
19
|
+
|
|
20
|
+
## [v1.4.31] - 2024-12-13
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
- Add `@shgysk8zer0/suid`
|
|
24
|
+
|
|
10
25
|
### [v1.4.30] - 2024-12-13
|
|
11
26
|
|
|
12
27
|
### Added
|
package/cli.cjs
CHANGED
|
@@ -5,6 +5,7 @@ var yaml_js = require('@shgysk8zer0/npm-utils/yaml.js');
|
|
|
5
5
|
var commander = require('commander');
|
|
6
6
|
var node_path = require('node:path');
|
|
7
7
|
require('node:fs/promises');
|
|
8
|
+
require('@shgysk8zer0/polyfills');
|
|
8
9
|
require('@shgysk8zer0/npm-utils/path.js');
|
|
9
10
|
|
|
10
11
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
@@ -13,16 +14,20 @@ const imports = {
|
|
|
13
14
|
"@shgysk8zer0/konami": "https://unpkg.com/@shgysk8zer0/konami@1.1.1/konami.js",
|
|
14
15
|
"@shgysk8zer0/polyfills": "https://unpkg.com/@shgysk8zer0/polyfills@0.4.7/browser.min.js",
|
|
15
16
|
"@shgysk8zer0/polyfills/": "https://unpkg.com/@shgysk8zer0/polyfills@0.4.7/",
|
|
16
|
-
"@shgysk8zer0/jwk-utils": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.0.
|
|
17
|
-
"@shgysk8zer0/jwk-utils/": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.0.
|
|
17
|
+
"@shgysk8zer0/jwk-utils": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.0.18/jwk-utils.min.js",
|
|
18
|
+
"@shgysk8zer0/jwk-utils/": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.0.18/",
|
|
18
19
|
"@shgysk8zer0/jswaggersheets": "https://unpkg.com/@shgysk8zer0/jswaggersheets@1.1.0/swagger.js",
|
|
19
20
|
"@shgysk8zer0/jswaggersheets/": "https://unpkg.com/@shgysk8zer0/jswaggersheets@1.1.0/",
|
|
20
21
|
"@shgysk8zer0/jss/": "https://unpkg.com/@shgysk8zer0/jss@1.0.1/",
|
|
21
22
|
"@shgysk8zer0/consts/": "https://unpkg.com/@shgysk8zer0/consts@1.0.8/",
|
|
22
23
|
"@shgysk8zer0/http/": "https://unpkg.com/@shgysk8zer0/http@1.0.5/",
|
|
23
24
|
"@shgysk8zer0/http-status": "https://unpkg.com/@shgysk8zer0/http-status@1.1.2/http-status.js",
|
|
24
|
-
"@shgysk8zer0/aes-gcm": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.
|
|
25
|
-
"@shgysk8zer0/aes-gcm/": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.
|
|
25
|
+
"@shgysk8zer0/aes-gcm": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.5/aes-gcm.min.js",
|
|
26
|
+
"@shgysk8zer0/aes-gcm/": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.5/",
|
|
27
|
+
"@shgysk8zer0/suid": "https://unpkg.com/@shgysk8zer0/suid@1.0.0/suid.min.js",
|
|
28
|
+
"@shgysk8zer0/suid/": "https://unpkg.com/@shgysk8zer0/suid@1.0.0/",
|
|
29
|
+
"@shgysk8zer0/geoutils": "https://unpkg.com/@shgysk8zer0/geoutils@1.0.0/geoutils.min.js",
|
|
30
|
+
"@shgysk8zer0/geoutils/": "https://unpkg.com/@shgysk8zer0/geoutils@1.0.0/",
|
|
26
31
|
"@aegisjsproject/trusted-types": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/bundle.min.js",
|
|
27
32
|
"@aegisjsproject/trusted-types/": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/",
|
|
28
33
|
"@aegisjsproject/parsers": "https://unpkg.com/@aegisjsproject/parsers@0.0.16/bundle.min.js",
|
|
@@ -52,11 +57,11 @@ const imports = {
|
|
|
52
57
|
"@webcomponents/custom-elements": "https://unpkg.com/@webcomponents/custom-elements@1.6.0/custom-elements.min.js",
|
|
53
58
|
leaflet: "https://unpkg.com/leaflet@1.9.4/dist/leaflet-src.esm.js",
|
|
54
59
|
"urlpattern-polyfill": "https://unpkg.com/urlpattern-polyfill@10.0.0/index.js",
|
|
55
|
-
"highlight.js": "https://unpkg.com/@highlightjs/cdn-assets@11.
|
|
56
|
-
"highlight.js/": "https://unpkg.com/@highlightjs/cdn-assets@11.
|
|
57
|
-
"@highlightjs/cdn-assets": "https://unpkg.com/@highlightjs/cdn-assets@11.
|
|
58
|
-
"@highlightjs/cdn-assets/": "https://unpkg.com/@highlightjs/cdn-assets@11.
|
|
59
|
-
marked: "https://unpkg.com/marked@15.0.
|
|
60
|
+
"highlight.js": "https://unpkg.com/@highlightjs/cdn-assets@11.11.0/es/core.min.js",
|
|
61
|
+
"highlight.js/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.0/es/",
|
|
62
|
+
"@highlightjs/cdn-assets": "https://unpkg.com/@highlightjs/cdn-assets@11.11.0/es/core.min.js",
|
|
63
|
+
"@highlightjs/cdn-assets/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.0/es/",
|
|
64
|
+
marked: "https://unpkg.com/marked@15.0.4/lib/marked.esm.js",
|
|
60
65
|
"marked-highlight": "https://unpkg.com/marked-highlight@2.2.1/src/index.js",
|
|
61
66
|
yaml: "https://unpkg.com/yaml@2.6.1/browser/dist/index.js",
|
|
62
67
|
"yaml/": "https://unpkg.com/yaml@2.6.1/browser/dist/",
|
package/cli.js
CHANGED
|
@@ -3,6 +3,7 @@ import { writeYAMLFile, readYAMLFile } from '@shgysk8zer0/npm-utils/yaml.js';
|
|
|
3
3
|
import { program } from 'commander';
|
|
4
4
|
import { extname } from 'node:path';
|
|
5
5
|
import 'node:fs/promises';
|
|
6
|
+
import '@shgysk8zer0/polyfills';
|
|
6
7
|
import '@shgysk8zer0/npm-utils/path.js';
|
|
7
8
|
|
|
8
9
|
const imports = {
|
|
@@ -10,16 +11,20 @@ const imports = {
|
|
|
10
11
|
"@shgysk8zer0/konami": "https://unpkg.com/@shgysk8zer0/konami@1.1.1/konami.js",
|
|
11
12
|
"@shgysk8zer0/polyfills": "https://unpkg.com/@shgysk8zer0/polyfills@0.4.7/browser.min.js",
|
|
12
13
|
"@shgysk8zer0/polyfills/": "https://unpkg.com/@shgysk8zer0/polyfills@0.4.7/",
|
|
13
|
-
"@shgysk8zer0/jwk-utils": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.0.
|
|
14
|
-
"@shgysk8zer0/jwk-utils/": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.0.
|
|
14
|
+
"@shgysk8zer0/jwk-utils": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.0.18/jwk-utils.min.js",
|
|
15
|
+
"@shgysk8zer0/jwk-utils/": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.0.18/",
|
|
15
16
|
"@shgysk8zer0/jswaggersheets": "https://unpkg.com/@shgysk8zer0/jswaggersheets@1.1.0/swagger.js",
|
|
16
17
|
"@shgysk8zer0/jswaggersheets/": "https://unpkg.com/@shgysk8zer0/jswaggersheets@1.1.0/",
|
|
17
18
|
"@shgysk8zer0/jss/": "https://unpkg.com/@shgysk8zer0/jss@1.0.1/",
|
|
18
19
|
"@shgysk8zer0/consts/": "https://unpkg.com/@shgysk8zer0/consts@1.0.8/",
|
|
19
20
|
"@shgysk8zer0/http/": "https://unpkg.com/@shgysk8zer0/http@1.0.5/",
|
|
20
21
|
"@shgysk8zer0/http-status": "https://unpkg.com/@shgysk8zer0/http-status@1.1.2/http-status.js",
|
|
21
|
-
"@shgysk8zer0/aes-gcm": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.
|
|
22
|
-
"@shgysk8zer0/aes-gcm/": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.
|
|
22
|
+
"@shgysk8zer0/aes-gcm": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.5/aes-gcm.min.js",
|
|
23
|
+
"@shgysk8zer0/aes-gcm/": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.5/",
|
|
24
|
+
"@shgysk8zer0/suid": "https://unpkg.com/@shgysk8zer0/suid@1.0.0/suid.min.js",
|
|
25
|
+
"@shgysk8zer0/suid/": "https://unpkg.com/@shgysk8zer0/suid@1.0.0/",
|
|
26
|
+
"@shgysk8zer0/geoutils": "https://unpkg.com/@shgysk8zer0/geoutils@1.0.0/geoutils.min.js",
|
|
27
|
+
"@shgysk8zer0/geoutils/": "https://unpkg.com/@shgysk8zer0/geoutils@1.0.0/",
|
|
23
28
|
"@aegisjsproject/trusted-types": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/bundle.min.js",
|
|
24
29
|
"@aegisjsproject/trusted-types/": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/",
|
|
25
30
|
"@aegisjsproject/parsers": "https://unpkg.com/@aegisjsproject/parsers@0.0.16/bundle.min.js",
|
|
@@ -49,11 +54,11 @@ const imports = {
|
|
|
49
54
|
"@webcomponents/custom-elements": "https://unpkg.com/@webcomponents/custom-elements@1.6.0/custom-elements.min.js",
|
|
50
55
|
leaflet: "https://unpkg.com/leaflet@1.9.4/dist/leaflet-src.esm.js",
|
|
51
56
|
"urlpattern-polyfill": "https://unpkg.com/urlpattern-polyfill@10.0.0/index.js",
|
|
52
|
-
"highlight.js": "https://unpkg.com/@highlightjs/cdn-assets@11.
|
|
53
|
-
"highlight.js/": "https://unpkg.com/@highlightjs/cdn-assets@11.
|
|
54
|
-
"@highlightjs/cdn-assets": "https://unpkg.com/@highlightjs/cdn-assets@11.
|
|
55
|
-
"@highlightjs/cdn-assets/": "https://unpkg.com/@highlightjs/cdn-assets@11.
|
|
56
|
-
marked: "https://unpkg.com/marked@15.0.
|
|
57
|
+
"highlight.js": "https://unpkg.com/@highlightjs/cdn-assets@11.11.0/es/core.min.js",
|
|
58
|
+
"highlight.js/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.0/es/",
|
|
59
|
+
"@highlightjs/cdn-assets": "https://unpkg.com/@highlightjs/cdn-assets@11.11.0/es/core.min.js",
|
|
60
|
+
"@highlightjs/cdn-assets/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.0/es/",
|
|
61
|
+
marked: "https://unpkg.com/marked@15.0.4/lib/marked.esm.js",
|
|
57
62
|
"marked-highlight": "https://unpkg.com/marked-highlight@2.2.1/src/index.js",
|
|
58
63
|
yaml: "https://unpkg.com/yaml@2.6.1/browser/dist/index.js",
|
|
59
64
|
"yaml/": "https://unpkg.com/yaml@2.6.1/browser/dist/",
|
package/hash.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import '@shgysk8zer0/polyfills';
|
|
2
|
+
|
|
1
3
|
export const SHA1 = 'SHA-1';
|
|
2
4
|
export const SHA256 = 'SHA-256';
|
|
3
5
|
export const SHA384 = 'SHA-384';
|
|
@@ -6,32 +8,30 @@ export const DEFAULT_ALGO = SHA384;
|
|
|
6
8
|
export const SHA = SHA1;
|
|
7
9
|
|
|
8
10
|
export const BASE64 = 'base64';
|
|
11
|
+
export const BASE64_URL = 'base64url';
|
|
9
12
|
export const SRI = 'sri';
|
|
10
13
|
export const HEX = 'hex';
|
|
11
14
|
export const BUFFER = 'buffer';
|
|
12
15
|
|
|
13
16
|
export async function hash(data, { algo = DEFAULT_ALGO, output = BUFFER } = {}) {
|
|
14
|
-
const
|
|
15
|
-
const hash = await crypto.subtle.digest(algo,
|
|
17
|
+
const bytes = new TextEncoder().encode(data);
|
|
18
|
+
const hash = await crypto.subtle.digest(algo, bytes);
|
|
16
19
|
|
|
17
20
|
switch (output) {
|
|
18
21
|
case BUFFER:
|
|
19
22
|
return hash;
|
|
20
23
|
|
|
21
24
|
case HEX:
|
|
22
|
-
return
|
|
23
|
-
new Uint8Array(hash),
|
|
24
|
-
byte => byte.toString(16).padStart(2, '0')
|
|
25
|
-
).join('');
|
|
25
|
+
return new Uint8Array(hash).toHex();
|
|
26
26
|
|
|
27
27
|
case BASE64:
|
|
28
|
-
return
|
|
28
|
+
return new Uint8Array(hash).toBase64({ alphabet: BASE64 });
|
|
29
|
+
|
|
30
|
+
case BASE64_URL:
|
|
31
|
+
return new Uint8Array(hash).toBase64({ alphabet: BASE64_URL });
|
|
29
32
|
|
|
30
33
|
case SRI: {
|
|
31
|
-
|
|
32
|
-
const charCodes = new Uint8Array(codeUnits.buffer);
|
|
33
|
-
const result = btoa(String.fromCharCode(...charCodes));
|
|
34
|
-
return `${algo.replace('-', '').toLowerCase()}-${result}`;
|
|
34
|
+
return `${algo.replace('-', '').toLowerCase()}-${new Uint8Array(hash).toBase64({ alphabet: BASE64 })}`;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
default:
|
package/importmap.cjs
CHANGED
|
@@ -5,16 +5,20 @@ const imports = {
|
|
|
5
5
|
"@shgysk8zer0/konami": "https://unpkg.com/@shgysk8zer0/konami@1.1.1/konami.js",
|
|
6
6
|
"@shgysk8zer0/polyfills": "https://unpkg.com/@shgysk8zer0/polyfills@0.4.7/browser.min.js",
|
|
7
7
|
"@shgysk8zer0/polyfills/": "https://unpkg.com/@shgysk8zer0/polyfills@0.4.7/",
|
|
8
|
-
"@shgysk8zer0/jwk-utils": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.0.
|
|
9
|
-
"@shgysk8zer0/jwk-utils/": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.0.
|
|
8
|
+
"@shgysk8zer0/jwk-utils": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.0.18/jwk-utils.min.js",
|
|
9
|
+
"@shgysk8zer0/jwk-utils/": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.0.18/",
|
|
10
10
|
"@shgysk8zer0/jswaggersheets": "https://unpkg.com/@shgysk8zer0/jswaggersheets@1.1.0/swagger.js",
|
|
11
11
|
"@shgysk8zer0/jswaggersheets/": "https://unpkg.com/@shgysk8zer0/jswaggersheets@1.1.0/",
|
|
12
12
|
"@shgysk8zer0/jss/": "https://unpkg.com/@shgysk8zer0/jss@1.0.1/",
|
|
13
13
|
"@shgysk8zer0/consts/": "https://unpkg.com/@shgysk8zer0/consts@1.0.8/",
|
|
14
14
|
"@shgysk8zer0/http/": "https://unpkg.com/@shgysk8zer0/http@1.0.5/",
|
|
15
15
|
"@shgysk8zer0/http-status": "https://unpkg.com/@shgysk8zer0/http-status@1.1.2/http-status.js",
|
|
16
|
-
"@shgysk8zer0/aes-gcm": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.
|
|
17
|
-
"@shgysk8zer0/aes-gcm/": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.
|
|
16
|
+
"@shgysk8zer0/aes-gcm": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.5/aes-gcm.min.js",
|
|
17
|
+
"@shgysk8zer0/aes-gcm/": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.5/",
|
|
18
|
+
"@shgysk8zer0/suid": "https://unpkg.com/@shgysk8zer0/suid@1.0.0/suid.min.js",
|
|
19
|
+
"@shgysk8zer0/suid/": "https://unpkg.com/@shgysk8zer0/suid@1.0.0/",
|
|
20
|
+
"@shgysk8zer0/geoutils": "https://unpkg.com/@shgysk8zer0/geoutils@1.0.0/geoutils.min.js",
|
|
21
|
+
"@shgysk8zer0/geoutils/": "https://unpkg.com/@shgysk8zer0/geoutils@1.0.0/",
|
|
18
22
|
"@aegisjsproject/trusted-types": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/bundle.min.js",
|
|
19
23
|
"@aegisjsproject/trusted-types/": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/",
|
|
20
24
|
"@aegisjsproject/parsers": "https://unpkg.com/@aegisjsproject/parsers@0.0.16/bundle.min.js",
|
|
@@ -44,11 +48,11 @@ const imports = {
|
|
|
44
48
|
"@webcomponents/custom-elements": "https://unpkg.com/@webcomponents/custom-elements@1.6.0/custom-elements.min.js",
|
|
45
49
|
leaflet: "https://unpkg.com/leaflet@1.9.4/dist/leaflet-src.esm.js",
|
|
46
50
|
"urlpattern-polyfill": "https://unpkg.com/urlpattern-polyfill@10.0.0/index.js",
|
|
47
|
-
"highlight.js": "https://unpkg.com/@highlightjs/cdn-assets@11.
|
|
48
|
-
"highlight.js/": "https://unpkg.com/@highlightjs/cdn-assets@11.
|
|
49
|
-
"@highlightjs/cdn-assets": "https://unpkg.com/@highlightjs/cdn-assets@11.
|
|
50
|
-
"@highlightjs/cdn-assets/": "https://unpkg.com/@highlightjs/cdn-assets@11.
|
|
51
|
-
marked: "https://unpkg.com/marked@15.0.
|
|
51
|
+
"highlight.js": "https://unpkg.com/@highlightjs/cdn-assets@11.11.0/es/core.min.js",
|
|
52
|
+
"highlight.js/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.0/es/",
|
|
53
|
+
"@highlightjs/cdn-assets": "https://unpkg.com/@highlightjs/cdn-assets@11.11.0/es/core.min.js",
|
|
54
|
+
"@highlightjs/cdn-assets/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.0/es/",
|
|
55
|
+
marked: "https://unpkg.com/marked@15.0.4/lib/marked.esm.js",
|
|
52
56
|
"marked-highlight": "https://unpkg.com/marked-highlight@2.2.1/src/index.js",
|
|
53
57
|
yaml: "https://unpkg.com/yaml@2.6.1/browser/dist/index.js",
|
|
54
58
|
"yaml/": "https://unpkg.com/yaml@2.6.1/browser/dist/",
|
package/importmap.js
CHANGED
|
@@ -3,16 +3,20 @@ const imports = {
|
|
|
3
3
|
"@shgysk8zer0/konami": "https://unpkg.com/@shgysk8zer0/konami@1.1.1/konami.js",
|
|
4
4
|
"@shgysk8zer0/polyfills": "https://unpkg.com/@shgysk8zer0/polyfills@0.4.7/browser.min.js",
|
|
5
5
|
"@shgysk8zer0/polyfills/": "https://unpkg.com/@shgysk8zer0/polyfills@0.4.7/",
|
|
6
|
-
"@shgysk8zer0/jwk-utils": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.0.
|
|
7
|
-
"@shgysk8zer0/jwk-utils/": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.0.
|
|
6
|
+
"@shgysk8zer0/jwk-utils": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.0.18/jwk-utils.min.js",
|
|
7
|
+
"@shgysk8zer0/jwk-utils/": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.0.18/",
|
|
8
8
|
"@shgysk8zer0/jswaggersheets": "https://unpkg.com/@shgysk8zer0/jswaggersheets@1.1.0/swagger.js",
|
|
9
9
|
"@shgysk8zer0/jswaggersheets/": "https://unpkg.com/@shgysk8zer0/jswaggersheets@1.1.0/",
|
|
10
10
|
"@shgysk8zer0/jss/": "https://unpkg.com/@shgysk8zer0/jss@1.0.1/",
|
|
11
11
|
"@shgysk8zer0/consts/": "https://unpkg.com/@shgysk8zer0/consts@1.0.8/",
|
|
12
12
|
"@shgysk8zer0/http/": "https://unpkg.com/@shgysk8zer0/http@1.0.5/",
|
|
13
13
|
"@shgysk8zer0/http-status": "https://unpkg.com/@shgysk8zer0/http-status@1.1.2/http-status.js",
|
|
14
|
-
"@shgysk8zer0/aes-gcm": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.
|
|
15
|
-
"@shgysk8zer0/aes-gcm/": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.
|
|
14
|
+
"@shgysk8zer0/aes-gcm": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.5/aes-gcm.min.js",
|
|
15
|
+
"@shgysk8zer0/aes-gcm/": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.5/",
|
|
16
|
+
"@shgysk8zer0/suid": "https://unpkg.com/@shgysk8zer0/suid@1.0.0/suid.min.js",
|
|
17
|
+
"@shgysk8zer0/suid/": "https://unpkg.com/@shgysk8zer0/suid@1.0.0/",
|
|
18
|
+
"@shgysk8zer0/geoutils": "https://unpkg.com/@shgysk8zer0/geoutils@1.0.0/geoutils.min.js",
|
|
19
|
+
"@shgysk8zer0/geoutils/": "https://unpkg.com/@shgysk8zer0/geoutils@1.0.0/",
|
|
16
20
|
"@aegisjsproject/trusted-types": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/bundle.min.js",
|
|
17
21
|
"@aegisjsproject/trusted-types/": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/",
|
|
18
22
|
"@aegisjsproject/parsers": "https://unpkg.com/@aegisjsproject/parsers@0.0.16/bundle.min.js",
|
|
@@ -42,11 +46,11 @@ const imports = {
|
|
|
42
46
|
"@webcomponents/custom-elements": "https://unpkg.com/@webcomponents/custom-elements@1.6.0/custom-elements.min.js",
|
|
43
47
|
leaflet: "https://unpkg.com/leaflet@1.9.4/dist/leaflet-src.esm.js",
|
|
44
48
|
"urlpattern-polyfill": "https://unpkg.com/urlpattern-polyfill@10.0.0/index.js",
|
|
45
|
-
"highlight.js": "https://unpkg.com/@highlightjs/cdn-assets@11.
|
|
46
|
-
"highlight.js/": "https://unpkg.com/@highlightjs/cdn-assets@11.
|
|
47
|
-
"@highlightjs/cdn-assets": "https://unpkg.com/@highlightjs/cdn-assets@11.
|
|
48
|
-
"@highlightjs/cdn-assets/": "https://unpkg.com/@highlightjs/cdn-assets@11.
|
|
49
|
-
marked: "https://unpkg.com/marked@15.0.
|
|
49
|
+
"highlight.js": "https://unpkg.com/@highlightjs/cdn-assets@11.11.0/es/core.min.js",
|
|
50
|
+
"highlight.js/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.0/es/",
|
|
51
|
+
"@highlightjs/cdn-assets": "https://unpkg.com/@highlightjs/cdn-assets@11.11.0/es/core.min.js",
|
|
52
|
+
"@highlightjs/cdn-assets/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.0/es/",
|
|
53
|
+
marked: "https://unpkg.com/marked@15.0.4/lib/marked.esm.js",
|
|
50
54
|
"marked-highlight": "https://unpkg.com/marked-highlight@2.2.1/src/index.js",
|
|
51
55
|
yaml: "https://unpkg.com/yaml@2.6.1/browser/dist/index.js",
|
|
52
56
|
"yaml/": "https://unpkg.com/yaml@2.6.1/browser/dist/",
|
package/importmap.json
CHANGED
|
@@ -4,16 +4,20 @@
|
|
|
4
4
|
"@shgysk8zer0/konami": "https://unpkg.com/@shgysk8zer0/konami@1.1.1/konami.js",
|
|
5
5
|
"@shgysk8zer0/polyfills": "https://unpkg.com/@shgysk8zer0/polyfills@0.4.7/browser.min.js",
|
|
6
6
|
"@shgysk8zer0/polyfills/": "https://unpkg.com/@shgysk8zer0/polyfills@0.4.7/",
|
|
7
|
-
"@shgysk8zer0/jwk-utils": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.0.
|
|
8
|
-
"@shgysk8zer0/jwk-utils/": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.0.
|
|
7
|
+
"@shgysk8zer0/jwk-utils": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.0.18/jwk-utils.min.js",
|
|
8
|
+
"@shgysk8zer0/jwk-utils/": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.0.18/",
|
|
9
9
|
"@shgysk8zer0/jswaggersheets": "https://unpkg.com/@shgysk8zer0/jswaggersheets@1.1.0/swagger.js",
|
|
10
10
|
"@shgysk8zer0/jswaggersheets/": "https://unpkg.com/@shgysk8zer0/jswaggersheets@1.1.0/",
|
|
11
11
|
"@shgysk8zer0/jss/": "https://unpkg.com/@shgysk8zer0/jss@1.0.1/",
|
|
12
12
|
"@shgysk8zer0/consts/": "https://unpkg.com/@shgysk8zer0/consts@1.0.8/",
|
|
13
13
|
"@shgysk8zer0/http/": "https://unpkg.com/@shgysk8zer0/http@1.0.5/",
|
|
14
14
|
"@shgysk8zer0/http-status": "https://unpkg.com/@shgysk8zer0/http-status@1.1.2/http-status.js",
|
|
15
|
-
"@shgysk8zer0/aes-gcm": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.
|
|
16
|
-
"@shgysk8zer0/aes-gcm/": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.
|
|
15
|
+
"@shgysk8zer0/aes-gcm": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.5/aes-gcm.min.js",
|
|
16
|
+
"@shgysk8zer0/aes-gcm/": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.5/",
|
|
17
|
+
"@shgysk8zer0/suid": "https://unpkg.com/@shgysk8zer0/suid@1.0.0/suid.min.js",
|
|
18
|
+
"@shgysk8zer0/suid/": "https://unpkg.com/@shgysk8zer0/suid@1.0.0/",
|
|
19
|
+
"@shgysk8zer0/geoutils": "https://unpkg.com/@shgysk8zer0/geoutils@1.0.0/geoutils.min.js",
|
|
20
|
+
"@shgysk8zer0/geoutils/": "https://unpkg.com/@shgysk8zer0/geoutils@1.0.0/",
|
|
17
21
|
"@aegisjsproject/trusted-types": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/bundle.min.js",
|
|
18
22
|
"@aegisjsproject/trusted-types/": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/",
|
|
19
23
|
"@aegisjsproject/parsers": "https://unpkg.com/@aegisjsproject/parsers@0.0.16/bundle.min.js",
|
|
@@ -43,11 +47,11 @@
|
|
|
43
47
|
"@webcomponents/custom-elements": "https://unpkg.com/@webcomponents/custom-elements@1.6.0/custom-elements.min.js",
|
|
44
48
|
"leaflet": "https://unpkg.com/leaflet@1.9.4/dist/leaflet-src.esm.js",
|
|
45
49
|
"urlpattern-polyfill": "https://unpkg.com/urlpattern-polyfill@10.0.0/index.js",
|
|
46
|
-
"highlight.js": "https://unpkg.com/@highlightjs/cdn-assets@11.
|
|
47
|
-
"highlight.js/": "https://unpkg.com/@highlightjs/cdn-assets@11.
|
|
48
|
-
"@highlightjs/cdn-assets": "https://unpkg.com/@highlightjs/cdn-assets@11.
|
|
49
|
-
"@highlightjs/cdn-assets/": "https://unpkg.com/@highlightjs/cdn-assets@11.
|
|
50
|
-
"marked": "https://unpkg.com/marked@15.0.
|
|
50
|
+
"highlight.js": "https://unpkg.com/@highlightjs/cdn-assets@11.11.0/es/core.min.js",
|
|
51
|
+
"highlight.js/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.0/es/",
|
|
52
|
+
"@highlightjs/cdn-assets": "https://unpkg.com/@highlightjs/cdn-assets@11.11.0/es/core.min.js",
|
|
53
|
+
"@highlightjs/cdn-assets/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.0/es/",
|
|
54
|
+
"marked": "https://unpkg.com/marked@15.0.4/lib/marked.esm.js",
|
|
51
55
|
"marked-highlight": "https://unpkg.com/marked-highlight@2.2.1/src/index.js",
|
|
52
56
|
"yaml": "https://unpkg.com/yaml@2.6.1/browser/dist/index.js",
|
|
53
57
|
"yaml/": "https://unpkg.com/yaml@2.6.1/browser/dist/",
|
package/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var promises = require('node:fs/promises');
|
|
4
|
+
require('@shgysk8zer0/polyfills');
|
|
4
5
|
var yaml_js = require('@shgysk8zer0/npm-utils/yaml.js');
|
|
5
6
|
var json_js = require('@shgysk8zer0/npm-utils/json.js');
|
|
6
7
|
var path_js = require('@shgysk8zer0/npm-utils/path.js');
|
|
@@ -10,16 +11,20 @@ const imports$1 = {
|
|
|
10
11
|
"@shgysk8zer0/konami": "https://unpkg.com/@shgysk8zer0/konami@1.1.1/konami.js",
|
|
11
12
|
"@shgysk8zer0/polyfills": "https://unpkg.com/@shgysk8zer0/polyfills@0.4.7/browser.min.js",
|
|
12
13
|
"@shgysk8zer0/polyfills/": "https://unpkg.com/@shgysk8zer0/polyfills@0.4.7/",
|
|
13
|
-
"@shgysk8zer0/jwk-utils": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.0.
|
|
14
|
-
"@shgysk8zer0/jwk-utils/": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.0.
|
|
14
|
+
"@shgysk8zer0/jwk-utils": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.0.18/jwk-utils.min.js",
|
|
15
|
+
"@shgysk8zer0/jwk-utils/": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.0.18/",
|
|
15
16
|
"@shgysk8zer0/jswaggersheets": "https://unpkg.com/@shgysk8zer0/jswaggersheets@1.1.0/swagger.js",
|
|
16
17
|
"@shgysk8zer0/jswaggersheets/": "https://unpkg.com/@shgysk8zer0/jswaggersheets@1.1.0/",
|
|
17
18
|
"@shgysk8zer0/jss/": "https://unpkg.com/@shgysk8zer0/jss@1.0.1/",
|
|
18
19
|
"@shgysk8zer0/consts/": "https://unpkg.com/@shgysk8zer0/consts@1.0.8/",
|
|
19
20
|
"@shgysk8zer0/http/": "https://unpkg.com/@shgysk8zer0/http@1.0.5/",
|
|
20
21
|
"@shgysk8zer0/http-status": "https://unpkg.com/@shgysk8zer0/http-status@1.1.2/http-status.js",
|
|
21
|
-
"@shgysk8zer0/aes-gcm": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.
|
|
22
|
-
"@shgysk8zer0/aes-gcm/": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.
|
|
22
|
+
"@shgysk8zer0/aes-gcm": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.5/aes-gcm.min.js",
|
|
23
|
+
"@shgysk8zer0/aes-gcm/": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.5/",
|
|
24
|
+
"@shgysk8zer0/suid": "https://unpkg.com/@shgysk8zer0/suid@1.0.0/suid.min.js",
|
|
25
|
+
"@shgysk8zer0/suid/": "https://unpkg.com/@shgysk8zer0/suid@1.0.0/",
|
|
26
|
+
"@shgysk8zer0/geoutils": "https://unpkg.com/@shgysk8zer0/geoutils@1.0.0/geoutils.min.js",
|
|
27
|
+
"@shgysk8zer0/geoutils/": "https://unpkg.com/@shgysk8zer0/geoutils@1.0.0/",
|
|
23
28
|
"@aegisjsproject/trusted-types": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/bundle.min.js",
|
|
24
29
|
"@aegisjsproject/trusted-types/": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/",
|
|
25
30
|
"@aegisjsproject/parsers": "https://unpkg.com/@aegisjsproject/parsers@0.0.16/bundle.min.js",
|
|
@@ -49,11 +54,11 @@ const imports$1 = {
|
|
|
49
54
|
"@webcomponents/custom-elements": "https://unpkg.com/@webcomponents/custom-elements@1.6.0/custom-elements.min.js",
|
|
50
55
|
leaflet: "https://unpkg.com/leaflet@1.9.4/dist/leaflet-src.esm.js",
|
|
51
56
|
"urlpattern-polyfill": "https://unpkg.com/urlpattern-polyfill@10.0.0/index.js",
|
|
52
|
-
"highlight.js": "https://unpkg.com/@highlightjs/cdn-assets@11.
|
|
53
|
-
"highlight.js/": "https://unpkg.com/@highlightjs/cdn-assets@11.
|
|
54
|
-
"@highlightjs/cdn-assets": "https://unpkg.com/@highlightjs/cdn-assets@11.
|
|
55
|
-
"@highlightjs/cdn-assets/": "https://unpkg.com/@highlightjs/cdn-assets@11.
|
|
56
|
-
marked: "https://unpkg.com/marked@15.0.
|
|
57
|
+
"highlight.js": "https://unpkg.com/@highlightjs/cdn-assets@11.11.0/es/core.min.js",
|
|
58
|
+
"highlight.js/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.0/es/",
|
|
59
|
+
"@highlightjs/cdn-assets": "https://unpkg.com/@highlightjs/cdn-assets@11.11.0/es/core.min.js",
|
|
60
|
+
"@highlightjs/cdn-assets/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.0/es/",
|
|
61
|
+
marked: "https://unpkg.com/marked@15.0.4/lib/marked.esm.js",
|
|
57
62
|
"marked-highlight": "https://unpkg.com/marked-highlight@2.2.1/src/index.js",
|
|
58
63
|
yaml: "https://unpkg.com/yaml@2.6.1/browser/dist/index.js",
|
|
59
64
|
"yaml/": "https://unpkg.com/yaml@2.6.1/browser/dist/",
|
|
@@ -83,32 +88,30 @@ const SHA384 = 'SHA-384';
|
|
|
83
88
|
const DEFAULT_ALGO = SHA384;
|
|
84
89
|
|
|
85
90
|
const BASE64 = 'base64';
|
|
91
|
+
const BASE64_URL = 'base64url';
|
|
86
92
|
const SRI = 'sri';
|
|
87
93
|
const HEX = 'hex';
|
|
88
94
|
const BUFFER = 'buffer';
|
|
89
95
|
|
|
90
96
|
async function hash(data, { algo = DEFAULT_ALGO, output = BUFFER } = {}) {
|
|
91
|
-
const
|
|
92
|
-
const hash = await crypto.subtle.digest(algo,
|
|
97
|
+
const bytes = new TextEncoder().encode(data);
|
|
98
|
+
const hash = await crypto.subtle.digest(algo, bytes);
|
|
93
99
|
|
|
94
100
|
switch (output) {
|
|
95
101
|
case BUFFER:
|
|
96
102
|
return hash;
|
|
97
103
|
|
|
98
104
|
case HEX:
|
|
99
|
-
return
|
|
100
|
-
new Uint8Array(hash),
|
|
101
|
-
byte => byte.toString(16).padStart(2, '0')
|
|
102
|
-
).join('');
|
|
105
|
+
return new Uint8Array(hash).toHex();
|
|
103
106
|
|
|
104
107
|
case BASE64:
|
|
105
|
-
return
|
|
108
|
+
return new Uint8Array(hash).toBase64({ alphabet: BASE64 });
|
|
109
|
+
|
|
110
|
+
case BASE64_URL:
|
|
111
|
+
return new Uint8Array(hash).toBase64({ alphabet: BASE64_URL });
|
|
106
112
|
|
|
107
113
|
case SRI: {
|
|
108
|
-
|
|
109
|
-
const charCodes = new Uint8Array(codeUnits.buffer);
|
|
110
|
-
const result = btoa(String.fromCharCode(...charCodes));
|
|
111
|
-
return `${algo.replace('-', '').toLowerCase()}-${result}`;
|
|
114
|
+
return `${algo.replace('-', '').toLowerCase()}-${new Uint8Array(hash).toBase64({ alphabet: BASE64 })}`;
|
|
112
115
|
}
|
|
113
116
|
|
|
114
117
|
default:
|
package/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { writeFile } from 'node:fs/promises';
|
|
2
|
+
import '@shgysk8zer0/polyfills';
|
|
2
3
|
import { readYAMLFile, writeYAMLFile } from '@shgysk8zer0/npm-utils/yaml.js';
|
|
3
4
|
import { readJSONFile, writeJSONFile } from '@shgysk8zer0/npm-utils/json.js';
|
|
4
5
|
import { getFileURL } from '@shgysk8zer0/npm-utils/path.js';
|
|
@@ -8,16 +9,20 @@ const imports$1 = {
|
|
|
8
9
|
"@shgysk8zer0/konami": "https://unpkg.com/@shgysk8zer0/konami@1.1.1/konami.js",
|
|
9
10
|
"@shgysk8zer0/polyfills": "https://unpkg.com/@shgysk8zer0/polyfills@0.4.7/browser.min.js",
|
|
10
11
|
"@shgysk8zer0/polyfills/": "https://unpkg.com/@shgysk8zer0/polyfills@0.4.7/",
|
|
11
|
-
"@shgysk8zer0/jwk-utils": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.0.
|
|
12
|
-
"@shgysk8zer0/jwk-utils/": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.0.
|
|
12
|
+
"@shgysk8zer0/jwk-utils": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.0.18/jwk-utils.min.js",
|
|
13
|
+
"@shgysk8zer0/jwk-utils/": "https://unpkg.com/@shgysk8zer0/jwk-utils@1.0.18/",
|
|
13
14
|
"@shgysk8zer0/jswaggersheets": "https://unpkg.com/@shgysk8zer0/jswaggersheets@1.1.0/swagger.js",
|
|
14
15
|
"@shgysk8zer0/jswaggersheets/": "https://unpkg.com/@shgysk8zer0/jswaggersheets@1.1.0/",
|
|
15
16
|
"@shgysk8zer0/jss/": "https://unpkg.com/@shgysk8zer0/jss@1.0.1/",
|
|
16
17
|
"@shgysk8zer0/consts/": "https://unpkg.com/@shgysk8zer0/consts@1.0.8/",
|
|
17
18
|
"@shgysk8zer0/http/": "https://unpkg.com/@shgysk8zer0/http@1.0.5/",
|
|
18
19
|
"@shgysk8zer0/http-status": "https://unpkg.com/@shgysk8zer0/http-status@1.1.2/http-status.js",
|
|
19
|
-
"@shgysk8zer0/aes-gcm": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.
|
|
20
|
-
"@shgysk8zer0/aes-gcm/": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.
|
|
20
|
+
"@shgysk8zer0/aes-gcm": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.5/aes-gcm.min.js",
|
|
21
|
+
"@shgysk8zer0/aes-gcm/": "https://unpkg.com/@shgysk8zer0/aes-gcm@1.0.5/",
|
|
22
|
+
"@shgysk8zer0/suid": "https://unpkg.com/@shgysk8zer0/suid@1.0.0/suid.min.js",
|
|
23
|
+
"@shgysk8zer0/suid/": "https://unpkg.com/@shgysk8zer0/suid@1.0.0/",
|
|
24
|
+
"@shgysk8zer0/geoutils": "https://unpkg.com/@shgysk8zer0/geoutils@1.0.0/geoutils.min.js",
|
|
25
|
+
"@shgysk8zer0/geoutils/": "https://unpkg.com/@shgysk8zer0/geoutils@1.0.0/",
|
|
21
26
|
"@aegisjsproject/trusted-types": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/bundle.min.js",
|
|
22
27
|
"@aegisjsproject/trusted-types/": "https://unpkg.com/@aegisjsproject/trusted-types@1.0.2/",
|
|
23
28
|
"@aegisjsproject/parsers": "https://unpkg.com/@aegisjsproject/parsers@0.0.16/bundle.min.js",
|
|
@@ -47,11 +52,11 @@ const imports$1 = {
|
|
|
47
52
|
"@webcomponents/custom-elements": "https://unpkg.com/@webcomponents/custom-elements@1.6.0/custom-elements.min.js",
|
|
48
53
|
leaflet: "https://unpkg.com/leaflet@1.9.4/dist/leaflet-src.esm.js",
|
|
49
54
|
"urlpattern-polyfill": "https://unpkg.com/urlpattern-polyfill@10.0.0/index.js",
|
|
50
|
-
"highlight.js": "https://unpkg.com/@highlightjs/cdn-assets@11.
|
|
51
|
-
"highlight.js/": "https://unpkg.com/@highlightjs/cdn-assets@11.
|
|
52
|
-
"@highlightjs/cdn-assets": "https://unpkg.com/@highlightjs/cdn-assets@11.
|
|
53
|
-
"@highlightjs/cdn-assets/": "https://unpkg.com/@highlightjs/cdn-assets@11.
|
|
54
|
-
marked: "https://unpkg.com/marked@15.0.
|
|
55
|
+
"highlight.js": "https://unpkg.com/@highlightjs/cdn-assets@11.11.0/es/core.min.js",
|
|
56
|
+
"highlight.js/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.0/es/",
|
|
57
|
+
"@highlightjs/cdn-assets": "https://unpkg.com/@highlightjs/cdn-assets@11.11.0/es/core.min.js",
|
|
58
|
+
"@highlightjs/cdn-assets/": "https://unpkg.com/@highlightjs/cdn-assets@11.11.0/es/",
|
|
59
|
+
marked: "https://unpkg.com/marked@15.0.4/lib/marked.esm.js",
|
|
55
60
|
"marked-highlight": "https://unpkg.com/marked-highlight@2.2.1/src/index.js",
|
|
56
61
|
yaml: "https://unpkg.com/yaml@2.6.1/browser/dist/index.js",
|
|
57
62
|
"yaml/": "https://unpkg.com/yaml@2.6.1/browser/dist/",
|
|
@@ -81,32 +86,30 @@ const SHA384 = 'SHA-384';
|
|
|
81
86
|
const DEFAULT_ALGO = SHA384;
|
|
82
87
|
|
|
83
88
|
const BASE64 = 'base64';
|
|
89
|
+
const BASE64_URL = 'base64url';
|
|
84
90
|
const SRI = 'sri';
|
|
85
91
|
const HEX = 'hex';
|
|
86
92
|
const BUFFER = 'buffer';
|
|
87
93
|
|
|
88
94
|
async function hash(data, { algo = DEFAULT_ALGO, output = BUFFER } = {}) {
|
|
89
|
-
const
|
|
90
|
-
const hash = await crypto.subtle.digest(algo,
|
|
95
|
+
const bytes = new TextEncoder().encode(data);
|
|
96
|
+
const hash = await crypto.subtle.digest(algo, bytes);
|
|
91
97
|
|
|
92
98
|
switch (output) {
|
|
93
99
|
case BUFFER:
|
|
94
100
|
return hash;
|
|
95
101
|
|
|
96
102
|
case HEX:
|
|
97
|
-
return
|
|
98
|
-
new Uint8Array(hash),
|
|
99
|
-
byte => byte.toString(16).padStart(2, '0')
|
|
100
|
-
).join('');
|
|
103
|
+
return new Uint8Array(hash).toHex();
|
|
101
104
|
|
|
102
105
|
case BASE64:
|
|
103
|
-
return
|
|
106
|
+
return new Uint8Array(hash).toBase64({ alphabet: BASE64 });
|
|
107
|
+
|
|
108
|
+
case BASE64_URL:
|
|
109
|
+
return new Uint8Array(hash).toBase64({ alphabet: BASE64_URL });
|
|
104
110
|
|
|
105
111
|
case SRI: {
|
|
106
|
-
|
|
107
|
-
const charCodes = new Uint8Array(codeUnits.buffer);
|
|
108
|
-
const result = btoa(String.fromCharCode(...charCodes));
|
|
109
|
-
return `${algo.replace('-', '').toLowerCase()}-${result}`;
|
|
112
|
+
return `${algo.replace('-', '').toLowerCase()}-${new Uint8Array(hash).toBase64({ alphabet: BASE64 })}`;
|
|
110
113
|
}
|
|
111
114
|
|
|
112
115
|
default:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shgysk8zer0/importmap",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.32",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=18.0.0"
|
|
6
6
|
},
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"importmap-utils": "./cli.mjs"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
|
-
"test": "npm run lint:js && npm run test:imports",
|
|
36
|
+
"test": "npm run lint:js && npm run run:tests && npm run test:imports",
|
|
37
37
|
"preversion": "npm test && npm run build",
|
|
38
38
|
"prepare": "npm test && npm run build",
|
|
39
39
|
"update": "node ./update.js",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"build": "npm run build:js",
|
|
43
43
|
"build:js": "rollup -c",
|
|
44
44
|
"test:imports": "rollup -c rollup.test.config.js",
|
|
45
|
+
"run:tests": "node --test *.test.js",
|
|
45
46
|
"create:lock": "npm i --package-lock-only --ignore-scripts --no-audit --no-fund",
|
|
46
47
|
"version:bump": "npm run version:bump:patch",
|
|
47
48
|
"version:bump:patch": "npm version --no-git-tag-version patch && npm run create:lock",
|
|
@@ -66,6 +67,7 @@
|
|
|
66
67
|
},
|
|
67
68
|
"dependencies": {
|
|
68
69
|
"@shgysk8zer0/npm-utils": "^1.1.3",
|
|
70
|
+
"@shgysk8zer0/polyfills": "^0.4.7",
|
|
69
71
|
"commander": "^12.1.0"
|
|
70
72
|
}
|
|
71
73
|
}
|