Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Small test cleanup & versions upgrade. #92

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions .eslintrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Build esm
run: yarn build:esm
- name: Install puppeteer and static
run: yarn add puppeteer@9.1.1 [email protected]
run: yarn add puppeteer@23.9.0 [email protected]
- name: Launch static
run: yarn static &
- name: Browser Test
Expand Down
45 changes: 45 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

export default [...compat.extends(
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
), {
plugins: {
"@typescript-eslint": typescriptEslint,
},

languageOptions: {
parser: tsParser,
},

rules: {
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-require-imports": "off",

"sort-imports": ["error", {
ignoreDeclarationSort: true,
ignoreMemberSort: true,
memberSyntaxSortOrder: ["none", "all", "single", "multiple"],
}],

"comma-dangle": ["error", "always-multiline"],
},
}];
27 changes: 13 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,24 @@
"types": "dist/index.d.ts",
"private": false,
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.1",
"@magic-works/ttypescript-browser-like-import-transformer": "^3.0.0",
"@types/crypto-js": "3.1.43",
"@types/jsbn": "1.2.29",
"@types/node": "^15.0.3",
"@typescript-eslint/eslint-plugin": "^4.23.0",
"@typescript-eslint/parser": "^4.23.0",
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@magic-works/ttypescript-browser-like-import-transformer": "^4.0.0",
"@types/crypto-js": "4.2.2",
"@types/jsbn": "1.2.33",
"@types/node": "^20.8.4",
"@typescript-eslint/eslint-plugin": "^8.16.0",
"@typescript-eslint/parser": "^8.16.0",
"@zoltu/typescript-transformer-append-js-extension": "^1.0.1",
"eslint": "^7.26.0",
"nyc": "^15.1.0",
"eslint": "^9.15.0",
"nyc": "^17.1.0",
"prettier": "^2.3.0",
"source-map-support": "^0.5.19",
"tap-diff": "^0.1.1",
"tap-junit": "^4.2.0",
"tape": "^5.2.2",
"tape": "^5.9.0",
"tape-promise": "^4.0.0",
"ts-node": "^9.1.1",
"ttypescript": "^1.5.12",
"typescript": "^4.2.4"
"ts-node": "^10.9.2",
"ttypescript": "^1.5.15",
"typescript": "^4.9.5"
},
"scripts": {
"build": "yarn tsc --build tsconfig.json",
Expand Down
3 changes: 1 addition & 2 deletions src/cross-env-crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export let crossEnvCrypto: CompatibleCrypto;
try {
const webcrypto =
(typeof window !== "undefined" && window.crypto) ||
// eslint-disable-next-line @typescript-eslint/no-var-requires
require("crypto").webcrypto; // Node v15+ has webcrypto built in, lets use that if we can

if (webcrypto) {
Expand All @@ -33,7 +32,7 @@ try {
};
} else {
// otherwise lets use node's crypto
// eslint-disable-next-line @typescript-eslint/no-var-requires

const nodeCrypto = require("crypto");
const nodeCreateHashToHashFunction =
(algorithm: AlgorithmIdentifier) => (data: ArrayBuffer) =>
Expand Down
12 changes: 5 additions & 7 deletions test/parameters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ test("Size of N is correct", (t) => {
// Yes, the 256 bits number is actually 257 bits number
// https://groups.google.com/forum/#!topic/clipperz/DJFqZYHv2qk
const expectedSizeInBytes: number[] = [33, 64, 96, 128, 192, 256];
const actualSizeInBytes: number[] = new Array(6).fill(0);
Object.keys(SRPParameters.PrimeGroup).map((key, idx) => {
actualSizeInBytes[idx] = bigIntToArrayBuffer(
SRPParameters.PrimeGroup[key].N,
).byteLength;
});
actualSizeInBytes.sort((x, y) => x - y);
const actualSizeInBytes: number[] = Object.keys(SRPParameters.PrimeGroup)
.map(
(key) => bigIntToArrayBuffer(SRPParameters.PrimeGroup[key].N).byteLength,
)
.sort((x, y) => x - y);
t.deepEqual(expectedSizeInBytes, actualSizeInBytes, "N sizes are correct");
});
2 changes: 1 addition & 1 deletion tsconfig.esm.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"noImplicitThis": true,
"strict": true,
"noImplicitAny": false,
"typeRoots": ["node_modules/@types", "types"],
"typeRoots": ["node_modules/@types"],
"plugins": [{
"transform": "@magic-works/ttypescript-browser-like-import-transformer",
"after": true
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"noImplicitThis": true,
"strict": true,
"noImplicitAny": false,
"typeRoots": ["node_modules/@types", "types"]
"typeRoots": ["node_modules/@types"]
},
"include": ["src/**/*"]
}
Expand Down
Loading
Loading