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

Fix TypeScript 5.3 build error #63

Merged
merged 8 commits into from
Jan 22, 2024
Merged
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
17 changes: 17 additions & 0 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
root: true
parser: "@typescript-eslint/parser"
plugins:
- "@typescript-eslint"
extends:
- eslint:recommended
- plugin:@typescript-eslint/recommended
ignorePatterns:
- "build/**/*.ts"
- "test/**/*.ts"
- "src/**/*.spec.ts"
rules:
"@typescript-eslint/no-explicit-any": 0
"@typescript-eslint/explicit-function-return-type": 1
"@typescript-eslint/no-unused-vars":
- warn
- argsIgnorePattern: "^_"
10 changes: 5 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
echo 'The pull request has not been merged'
exit 1

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

Expand All @@ -33,9 +33,9 @@ jobs:
git config user.email github-actions@github.com

- name: Use Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: 16.x
node-version: 20.x
registry-url: "https://registry.npmjs.org"

- name: Setup .npmrc
Expand Down Expand Up @@ -82,15 +82,15 @@ jobs:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}

- name: Push changes
uses: ad-m/github-push-action@v0.6.0
uses: ad-m/github-push-action@v0.8.0
if: env.PREV_VERSION != env.CURRENT_VERSION
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
tags: true

- name: Create comment
uses: actions/github-script@0.8.0
uses: actions/github-script@v7
if: env.PREV_VERSION != env.CURRENT_VERSION
with:
github-token: ${{secrets.GITHUB_TOKEN}}
Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,27 @@ jobs:

strategy:
matrix:
node-version: [16.x, 18.x]
node-version: [18.x, 20.x]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- uses: actions/cache@v4
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
${{ runner.os }}-yarn-

- name: Install global dependencies
run: npm i yarn -g
Expand All @@ -51,6 +51,6 @@ jobs:
run: npm run coverage

- name: Coveralls
uses: coverallsapp/github-action@master
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
32 changes: 17 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"build": "rollup -c",
"clear": "rimraf build/*",
"rebuild": "npm run clear && npm run build",
"lint": "tslint -p .",
"lint:fix": "tslint --fix -p .",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint --fix . --ext .ts",
"coverage": "nyc npm test",
"precoveragehtml": "npm run coverage",
"coveragehtml": "nyc report -r html",
Expand All @@ -38,25 +38,27 @@
"shake"
],
"dependencies": {
"@peculiar/asn1-schema": "^2.3.6",
"@peculiar/asn1-schema": "^2.3.8",
"@peculiar/json-schema": "^1.1.12",
"asn1js": "^3.0.1",
"pvtsutils": "^1.3.2",
"tslib": "^2.4.0"
"pvtsutils": "^1.3.5",
"tslib": "^2.6.2"
},
"devDependencies": {
"@types/mocha": "^10.0.1",
"@types/node": "^18.15.5",
"@types/mocha": "^10.0.6",
"@types/node": "^20.11.5",
"coveralls": "^3.1.1",
"@typescript-eslint/eslint-plugin": "^6.17.0",
"@typescript-eslint/parser": "^6.17.0",
"eslint": "^8.56.0",
"mocha": "^10.2.0",
"nyc": "^15.1.0",
"rimraf": "^4.4.0",
"rollup": "^3.20.0",
"rollup-plugin-dts": "^5.3.0",
"rollup-plugin-typescript2": "^0.34.1",
"ts-node": "^10.9.1",
"tslint": "^6.1.3",
"typescript": "^5.0.2"
"rimraf": "^5.0.5",
"rollup": "^4.9.6",
"rollup-plugin-dts": "^6.1.0",
"rollup-plugin-typescript2": "^0.36.0",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
},
"author": "PeculiarVentures",
"license": "MIT",
Expand Down Expand Up @@ -89,4 +91,4 @@
"test/**/*.ts"
]
}
}
}
4 changes: 2 additions & 2 deletions src/aes/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CryptoKey } from "../crypto_key";

export abstract class AesProvider extends ProviderCrypto {

public checkGenerateKeyParams(algorithm: AesKeyGenParams) {
public checkGenerateKeyParams(algorithm: AesKeyGenParams): void {
// length
this.checkRequiredProperty(algorithm, "length");
if (typeof algorithm.length !== "number") {
Expand All @@ -19,7 +19,7 @@ export abstract class AesProvider extends ProviderCrypto {
}
}

public checkDerivedKeyParams(algorithm: AesKeyGenParams) {
public checkDerivedKeyParams(algorithm: AesKeyGenParams): void {
this.checkGenerateKeyParams(algorithm);
}

Expand Down
2 changes: 1 addition & 1 deletion src/aes/cbc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export abstract class AesCbcProvider extends AesProvider {

public usages: KeyUsages = ["encrypt", "decrypt", "wrapKey", "unwrapKey"];

public checkAlgorithmParams(algorithm: AesCbcParams) {
public checkAlgorithmParams(algorithm: AesCbcParams): void {
this.checkRequiredProperty(algorithm, "iv");
if (!(algorithm.iv instanceof ArrayBuffer || ArrayBuffer.isView(algorithm.iv))) {
throw new TypeError("iv: Is not of type '(ArrayBuffer or ArrayBufferView)'");
Expand Down
2 changes: 1 addition & 1 deletion src/aes/cmac.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export abstract class AesCmacProvider extends AesProvider {

public usages: KeyUsages = ["sign", "verify"];

public checkAlgorithmParams(algorithm: AesCmacParams) {
public checkAlgorithmParams(algorithm: AesCmacParams): void {
this.checkRequiredProperty(algorithm, "length");
if (typeof algorithm.length !== "number") {
throw new TypeError("length: Is not a Number");
Expand Down
2 changes: 1 addition & 1 deletion src/aes/ctr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export abstract class AesCtrProvider extends AesProvider {

public usages: KeyUsages = ["encrypt", "decrypt", "wrapKey", "unwrapKey"];

public checkAlgorithmParams(algorithm: AesCtrParams) {
public checkAlgorithmParams(algorithm: AesCtrParams): void {
// counter
this.checkRequiredProperty(algorithm, "counter");
if (!(algorithm.counter instanceof ArrayBuffer || ArrayBuffer.isView(algorithm.counter))) {
Expand Down
4 changes: 2 additions & 2 deletions src/aes/gsm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export abstract class AesGcmProvider extends AesProvider {

public usages: KeyUsages = ["encrypt", "decrypt", "wrapKey", "unwrapKey"];

public checkAlgorithmParams(algorithm: AesGcmParams) {
public checkAlgorithmParams(algorithm: AesGcmParams): void {
// iv
this.checkRequiredProperty(algorithm, "iv");
if (!(algorithm.iv instanceof ArrayBuffer || ArrayBuffer.isView(algorithm.iv))) {
Expand All @@ -29,7 +29,7 @@ export abstract class AesGcmProvider extends AesProvider {
case 112:
case 120:
case 128:
break;
break;
default:
throw new OperationError("tagLength: Must be one of 32, 64, 96, 104, 112, 120 or 128");
}
Expand Down
3 changes: 1 addition & 2 deletions src/asn1/ec_private_key.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as asn1js from "asn1js";
import { AsnIntegerConverter, AsnProp, AsnPropTypes, AsnSerializer } from "@peculiar/asn1-schema";
import { IJsonConvertible } from "@peculiar/json-schema";
import { Convert } from "pvtsutils";
Expand Down Expand Up @@ -46,7 +45,7 @@ export class EcPrivateKey implements IJsonConvertible {

return this;
}
public toJSON() {
public toJSON(): JsonWebKey {
const jwk: JsonWebKey = {};
jwk.d = Convert.ToBase64Url(this.privateKey);
if (this.publicKey) {
Expand Down
2 changes: 1 addition & 1 deletion src/asn1/ec_public_key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class EcPublicKey implements IJsonConvertible {
}
}

public toJSON() {
public toJSON(): JsonWebKey {
let bytes = new Uint8Array(this.value);

if (bytes[0] !== 0x04) {
Expand Down
4 changes: 2 additions & 2 deletions src/asn1/ed_private_key.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AsnIntegerConverter, AsnProp, AsnPropTypes, AsnSerializer, AsnType, AsnTypeTypes } from "@peculiar/asn1-schema";
import { AsnProp, AsnPropTypes, AsnType, AsnTypeTypes } from "@peculiar/asn1-schema";
import { IJsonConvertible } from "@peculiar/json-schema";
import { Convert } from "pvtsutils";

Expand All @@ -16,7 +16,7 @@ export class EdPrivateKey implements IJsonConvertible {

return this;
}
public toJSON() {
public toJSON(): JsonWebKey {
const jwk: JsonWebKey = {
d: Convert.ToBase64Url(this.value),
};
Expand Down
5 changes: 2 additions & 3 deletions src/asn1/ed_public_key.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { AsnProp, AsnPropTypes, AsnType, AsnTypeTypes } from "@peculiar/asn1-schema";
import { IJsonConvertible } from "@peculiar/json-schema";
import { Convert } from "pvtsutils";
import { CryptoError } from "../errors";

// RFC 8410
// https://datatracker.ietf.org/doc/html/rfc8410
Expand All @@ -20,8 +19,8 @@ export class EdPublicKey implements IJsonConvertible {
}
}

public toJSON() {
const json = {
public toJSON(): JsonWebKey {
const json: JsonWebKey = {
x: Convert.ToBase64Url(this.value),
};

Expand Down
2 changes: 1 addition & 1 deletion src/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export abstract class Crypto implements globalThis.Crypto {
public abstract readonly subtle: SubtleCrypto;

// @internal
public get [Symbol.toStringTag]() {
public get [Symbol.toStringTag](): string {
return "Crypto";
}

Expand Down
6 changes: 3 additions & 3 deletions src/crypto_key.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { KeyUsages, NativeCryptoKey } from "./types";
import { KeyUsages } from "./types";

// tslint:disable-next-line:no-empty-interface
export interface KeyAlgorithm extends Algorithm {
Expand All @@ -8,7 +8,7 @@ const KEY_TYPES = ["secret", "private", "public"];

export class CryptoKey implements globalThis.CryptoKey {

public static create<T extends CryptoKey>(this: new() => T, algorithm: KeyAlgorithm, type: KeyType, extractable: boolean, usages: KeyUsages): T {
public static create<T extends CryptoKey>(this: new () => T, algorithm: KeyAlgorithm, type: KeyType, extractable: boolean, usages: KeyUsages): T {
const key = new this();
key.algorithm = algorithm;
key.type = type;
Expand All @@ -28,7 +28,7 @@ export class CryptoKey implements globalThis.CryptoKey {
public extractable!: boolean;

// @internal
public get[Symbol.toStringTag]() {
public get [Symbol.toStringTag](): string {
return "CryptoKey";
}
}
6 changes: 3 additions & 3 deletions src/des/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export abstract class DesProvider extends ProviderCrypto {
public abstract keySizeBits: number;
public abstract ivSize: number;

public checkAlgorithmParams(algorithm: AesCbcParams) {
public checkAlgorithmParams(algorithm: AesCbcParams): void {
if (this.ivSize) {
this.checkRequiredProperty(algorithm, "iv");
if (!(algorithm.iv instanceof ArrayBuffer || ArrayBuffer.isView(algorithm.iv))) {
Expand All @@ -40,7 +40,7 @@ export abstract class DesProvider extends ProviderCrypto {
}
}

public checkGenerateKeyParams(algorithm: DesKeyGenParams) {
public checkGenerateKeyParams(algorithm: DesKeyGenParams): void {
// length
this.checkRequiredProperty(algorithm, "length");
if (typeof algorithm.length !== "number") {
Expand All @@ -51,7 +51,7 @@ export abstract class DesProvider extends ProviderCrypto {
}
}

public checkDerivedKeyParams(algorithm: DesDerivedKeyParams) {
public checkDerivedKeyParams(algorithm: DesDerivedKeyParams): void {
this.checkGenerateKeyParams(algorithm);
}

Expand Down
4 changes: 2 additions & 2 deletions src/ec/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export abstract class EllipticProvider extends ProviderCrypto {

public abstract namedCurves: string[];

public checkGenerateKeyParams(algorithm: EcKeyGenParams) {
public checkGenerateKeyParams(algorithm: EcKeyGenParams): void {
// named curve
this.checkRequiredProperty(algorithm, "namedCurve");
this.checkNamedCurve(algorithm.namedCurve);
}

public checkNamedCurve(namedCurve: string) {
public checkNamedCurve(namedCurve: string): void {
for (const item of this.namedCurves) {
if (item.toLowerCase() === namedCurve.toLowerCase()) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/ec/curves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class EcCurves {

private constructor() { }

public static register(item: EcCurveParams) {
public static register(item: EcCurveParams): void {
const oid = new asn1.ObjectIdentifier();
oid.value = item.id;
const raw = AsnConvert.serialize(oid);
Expand Down
2 changes: 1 addition & 1 deletion src/ec/ecdh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export abstract class EcdhProvider extends EllipticProvider {

public namedCurves = ["P-256", "P-384", "P-521", "K-256"];

public checkAlgorithmParams(algorithm: EcdhKeyDeriveParams) {
public checkAlgorithmParams(algorithm: EcdhKeyDeriveParams): void {
// public
this.checkRequiredProperty(algorithm, "public");
if (!(algorithm.public instanceof CryptoKey)) {
Expand Down
2 changes: 1 addition & 1 deletion src/ec/ecdsa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export abstract class EcdsaProvider extends EllipticProvider {

public namedCurves = ["P-256", "P-384", "P-521", "K-256"];

public checkAlgorithmParams(algorithm: EcdsaParams) {
public checkAlgorithmParams(algorithm: EcdsaParams): void {
this.checkRequiredProperty(algorithm, "hash");
this.checkHashAlgorithm(algorithm.hash as Algorithm, this.hashAlgorithms);
}
Expand Down
Loading
Loading