Skip to content

Commit 1069f61

Browse files
fix: md4 support on Node.js v17 (#193)
1 parent d9f4e23 commit 1069f61

File tree

6 files changed

+329
-68
lines changed

6 files changed

+329
-68
lines changed

.github/workflows/nodejs.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: loader-utils
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- next
8+
pull_request:
9+
branches:
10+
- master
11+
- next
12+
13+
jobs:
14+
lint:
15+
name: Lint - ${{ matrix.os }} - Node v${{ matrix.node-version }}
16+
17+
env:
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
20+
strategy:
21+
matrix:
22+
os: [ubuntu-latest]
23+
node-version: [12.x]
24+
25+
runs-on: ${{ matrix.os }}
26+
27+
steps:
28+
- uses: actions/checkout@v2
29+
with:
30+
fetch-depth: 0
31+
32+
- name: Use Node.js ${{ matrix.node-version }}
33+
uses: actions/setup-node@v2
34+
with:
35+
node-version: ${{ matrix.node-version }}
36+
cache: 'yarn'
37+
38+
- name: Install dependencies
39+
run: yarn
40+
41+
- name: Lint
42+
run: yarn lint
43+
44+
- name: Security audit
45+
run: yarn audit
46+
47+
- name: Check commit message
48+
uses: wagoid/commitlint-github-action@v4
49+
50+
test:
51+
name: Test - ${{ matrix.os }} - Node v${{ matrix.node-version }}
52+
53+
strategy:
54+
matrix:
55+
os: [ubuntu-latest, windows-latest, macos-latest]
56+
node-version: [8.x, 10.x, 12.x, 14.x, 16.x, 17.x]
57+
58+
runs-on: ${{ matrix.os }}
59+
60+
steps:
61+
- name: Setup Git
62+
if: matrix.os == 'windows-latest'
63+
run: git config --global core.autocrlf input
64+
65+
- uses: actions/checkout@v2
66+
67+
- name: Use Node.js ${{ matrix.node-version }}
68+
uses: actions/setup-node@v2
69+
with:
70+
node-version: ${{ matrix.node-version }}
71+
cache: 'yarn'
72+
73+
- name: Install dependencies
74+
run: yarn
75+
76+
- name: Run tests
77+
run: yarn test
78+
79+
- name: Submit coverage data to codecov
80+
uses: codecov/codecov-action@v2
81+
with:
82+
token: ${{ secrets.CODECOV_TOKEN }}

.travis.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

appveyor.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

lib/getHashDigest.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,29 @@ function encodeBufferToBase(buffer, base) {
3939
return output;
4040
}
4141

42+
let createMd4 = undefined;
43+
4244
function getHashDigest(buffer, hashType, digestType, maxLength) {
4345
hashType = hashType || 'md4';
4446
maxLength = maxLength || 9999;
4547

46-
const hash = require('crypto').createHash(hashType);
48+
let hash;
49+
50+
try {
51+
hash = require('crypto').createHash(hashType);
52+
} catch (error) {
53+
if (error.code === 'ERR_OSSL_EVP_UNSUPPORTED' && hashType === 'md4') {
54+
if (createMd4 === undefined) {
55+
createMd4 = require('./hash/md4');
56+
}
57+
58+
hash = createMd4();
59+
}
60+
61+
if (!hash) {
62+
throw error;
63+
}
64+
}
4765

4866
hash.update(buffer);
4967

lib/hash/md4.js

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy