Skip to content

Commit

Permalink
Run codacy action separate for each language
Browse files Browse the repository at this point in the history
  • Loading branch information
ranisalt committed Dec 16, 2023
1 parent 88fd680 commit 3bfd04e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 297 deletions.
17 changes: 0 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,8 @@ jobs:

- name: Run tests with coverage
if: matrix.node-version >= 20
env:
NODE_V8_COVERAGE: coverage/tmp
run: yarn test-coverage

- name: Generate coverage
if: matrix.node-version >= 20 && matrix.os == 'ubuntu-20.04'
run: |
sudo apt install lcov
npx c8 report --reporter=text-lcov > lcov-js.info
lcov -c -d . --no-external -o lcov-cpp.info
lcov -r lcov-cpp.info "*/node_modules/*" -o lcov-cpp.info
- name: Send coverage to Codacy
if: matrix.node-version >= 20 && matrix.os == 'ubuntu-20.04'
uses: codacy/codacy-coverage-reporter-action@v1
with:
coverage-reports: lcov-cpp.info, lcov-js.info
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}

test-alpine:
name: Test on Alpine Linux
runs-on: ubuntu-latest
Expand Down
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
[![Financial contributors on Open Collective][opencollective-image]][opencollective-url]
[![Build status][actions-image]][actions-url]
[![NPM package][npm-image]][npm-url]
[![Coverage status][coverage-image]][coverage-url]
[![Code Quality][codequality-image]][codequality-url]

Bindings to the reference [Argon2](https://github.com/P-H-C/phc-winner-argon2)
implementation.
Expand Down Expand Up @@ -212,7 +210,3 @@ license over Argon2 and the reference implementation.
[npm-url]: https://www.npmjs.com/package/argon2
[actions-image]: https://img.shields.io/github/actions/workflow/status/ranisalt/node-argon2/ci.yml?branch=master&style=flat-square
[actions-url]: https://github.com/ranisalt/node-argon2/actions
[coverage-image]: https://img.shields.io/codacy/coverage/3aa6daee00154e1492660ecb2f788f73/master.svg?style=flat-square
[coverage-url]: https://app.codacy.com/gh/ranisalt/node-argon2
[codequality-image]: https://img.shields.io/codacy/grade/3aa6daee00154e1492660ecb2f788f73/master.svg?style=flat-square
[codequality-url]: https://app.codacy.com/gh/ranisalt/node-argon2
28 changes: 15 additions & 13 deletions argon2.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"use strict";
const assert = require("node:assert");
const { randomBytes, timingSafeEqual } = require("node:crypto");
const { promisify } = require("node:util");
const { deserialize, serialize } = require("@phc/format");
const gypBuild = require("node-gyp-build");
import assert from "node:assert";
import { randomBytes, timingSafeEqual } from "node:crypto";
import { fileURLToPath } from "node:url";
import { promisify } from "node:util";
import { deserialize, serialize } from "@phc/format";
import gypBuild from "node-gyp-build";

const { hash: _hash } = gypBuild(fileURLToPath(new URL(".", import.meta.url)));

Expand All @@ -12,8 +12,12 @@ const bindingsHash = promisify(_hash);
/** @type {(size: number) => Promise<Buffer>} */
const generateSalt = promisify(randomBytes);

/** @enum {0 | 1 | 2} */
const types = Object.freeze({ argon2d: 0, argon2i: 1, argon2id: 2 });
export const argon2d = 0;
export const argon2i = 1;
export const argon2id = 2;

/** @enum {argon2i | argon2d | argon2id} */
const types = Object.freeze({ argon2d, argon2i, argon2id });

/** @enum {'argon2d' | 'argon2i' | 'argon2id'} */
const names = Object.freeze({
Expand Down Expand Up @@ -74,7 +78,7 @@ export const limits = Object.freeze({
* @param {Options & { raw?: boolean }} options
* @returns {Promise<Buffer | string>}
*/
async function hash(plain, options) {
export async function hash(plain, options) {
const { raw, salt, saltLength, ...rest } = { ...defaults, ...options };

for (const [key, { min, max }] of Object.entries(limits)) {
Expand Down Expand Up @@ -115,7 +119,7 @@ async function hash(plain, options) {
* @param {Options} [options] The current parameters for Argon2
* @return {boolean} `true` if the digest parameters do not match the parameters in `options`, otherwise `false`
*/
function needsRehash(digest, options) {
export function needsRehash(digest, options) {
const { memoryCost, timeCost, version } = { ...defaults, ...options };

const {
Expand All @@ -132,7 +136,7 @@ function needsRehash(digest, options) {
* @param {Options} [options] The current parameters for Argon2
* @return {Promise<boolean>} `true` if the digest parameters matches the hash generated from `plain`, otherwise `false`
*/
async function verify(digest, plain, options) {
export async function verify(digest, plain, options) {
const {
id,
version = 0x10,
Expand Down Expand Up @@ -160,5 +164,3 @@ async function verify(digest, plain, options) {
)
);
}

module.exports = { defaults, hash, needsRehash, verify, ...types };
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
},
"scripts": {
"build": "prebuildify --napi --strip --tag-armv --tag-libc",
"format": "prettier --write \"*.{js,json}\"",
"format": "prettier --write \"*.{json,mjs}\"",
"install": "node-gyp-build",
"prepack": "yarn prepare",
"prepare": "tsc",
Expand Down
260 changes: 0 additions & 260 deletions test.js

This file was deleted.

0 comments on commit 3bfd04e

Please sign in to comment.