Skip to content

Commit

Permalink
fix: md4 support on Node.js v17 (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait authored Oct 29, 2021
1 parent d9f4e23 commit 1069f61
Show file tree
Hide file tree
Showing 6 changed files with 329 additions and 68 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: loader-utils

on:
push:
branches:
- master
- next
pull_request:
branches:
- master
- next

jobs:
lint:
name: Lint - ${{ matrix.os }} - Node v${{ matrix.node-version }}

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

strategy:
matrix:
os: [ubuntu-latest]
node-version: [12.x]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'

- name: Install dependencies
run: yarn

- name: Lint
run: yarn lint

- name: Security audit
run: yarn audit

- name: Check commit message
uses: wagoid/commitlint-github-action@v4

test:
name: Test - ${{ matrix.os }} - Node v${{ matrix.node-version }}

strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [8.x, 10.x, 12.x, 14.x, 16.x, 17.x]

runs-on: ${{ matrix.os }}

steps:
- name: Setup Git
if: matrix.os == 'windows-latest'
run: git config --global core.autocrlf input

- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'

- name: Install dependencies
run: yarn

- name: Run tests
run: yarn test

- name: Submit coverage data to codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
36 changes: 0 additions & 36 deletions .travis.yml

This file was deleted.

31 changes: 0 additions & 31 deletions appveyor.yml

This file was deleted.

20 changes: 19 additions & 1 deletion lib/getHashDigest.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,29 @@ function encodeBufferToBase(buffer, base) {
return output;
}

let createMd4 = undefined;

function getHashDigest(buffer, hashType, digestType, maxLength) {
hashType = hashType || 'md4';
maxLength = maxLength || 9999;

const hash = require('crypto').createHash(hashType);
let hash;

try {
hash = require('crypto').createHash(hashType);
} catch (error) {
if (error.code === 'ERR_OSSL_EVP_UNSUPPORTED' && hashType === 'md4') {
if (createMd4 === undefined) {
createMd4 = require('./hash/md4');
}

hash = createMd4();
}

if (!hash) {
throw error;
}
}

hash.update(buffer);

Expand Down
20 changes: 20 additions & 0 deletions lib/hash/md4.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1069f61

Please sign in to comment.