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

Update dependencies may 2024 #240

Merged
merged 1 commit into from
May 14, 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
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@
},
"devDependencies": {
"@types/async": "^3.2.24",
"@types/better-sqlite3": "^7.6.9",
"@types/chai": "^4.3.14",
"@types/inquirer": "^8.2.10",
"@types/better-sqlite3": "^7.6.10",
"@types/chai": "^4.3.16",
"@types/inquirer": "^9.0.7",
"@types/mocha": "^10.0.6",
"@types/node": "^18.19.31",
"@typescript-eslint/eslint-plugin": "^7.7.0",
"@typescript-eslint/parser": "^7.7.0",
"@types/node": "^18.19.33",
"@typescript-eslint/eslint-plugin": "^7.8.0",
"@typescript-eslint/parser": "^7.8.0",
"@yao-pkg/pkg": "^5.11.5",
"chai": "^4.4.1",
"esbuild": "^0.21.2",
Expand All @@ -75,16 +75,16 @@
"@json2csv/transforms": "^7.0.6",
"@napi-rs/clipboard": "^1.1.2",
"@napi-rs/keyring": "^1.1.6",
"@node-rs/argon2": "^1.8.0",
"better-sqlite3": "^9.5.0",
"commander": "^11.1.0",
"@node-rs/argon2": "^1.8.3",
"better-sqlite3": "^10.0.0",
"commander": "^12.0.0",
"got": "^11.8.6",
"inquirer": "^8.2.6",
"inquirer": "^9.2.20",
"inquirer-search-list": "^1.2.6",
"jsonpath-plus": "^8.1.0",
"jsonpath-plus": "^9.0.0",
"node-mac-auth": "^1.0.0",
"otplib": "^12.0.1",
"playwright-core": "^1.43.1",
"playwright-core": "^1.44.0",
"winston": "^3.13.0",
"xml-js": "^1.6.11",
"zlib": "^1.0.5"
Expand Down
2 changes: 1 addition & 1 deletion src/modules/api-connect/postRequestAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const postRequestAPI = <T>(params: PostRequestAPIParams<T>) => {
...(customHeaders || {}),
};

let authorizationHeader = null;
let authorizationHeader: string | null = null;

if (authentication.type !== 'none') {
authorizationHeader = signRequest({
Expand Down
18 changes: 9 additions & 9 deletions src/modules/crypto/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from 'chai';
import { assert } from 'chai';
import * as crypto from 'crypto';
import { decrypt } from './decrypt';
import { encryptAesCbcHmac256 } from './encrypt';
Expand All @@ -14,20 +14,20 @@ describe('Encrypt and decrypt using random symmetric key', () => {
const decodedBase64 = buffer.toString('ascii');
const { encryptedData } = deserializeEncryptedData(decodedBase64, buffer);

expect(encryptedData.keyDerivation.algo).to.equal('noderivation', 'Invalid key derivation algorithm');
expect(encryptedData.cipherConfig.encryption).to.equal('aes256', 'Invalid encryption algorithm');
expect(encryptedData.cipherConfig.cipherMode).to.equal('cbchmac', 'Invalid encryption mode');
expect(encryptedData.cipherConfig.ivLength).to.equal(16, 'Invalid IV length');
expect(encryptedData.cipherData.salt).length(0, 'Invalid salt length');
expect(encryptedData.cipherData.iv).length(16, 'Invalid IV');
expect(encryptedData.cipherData.hash).length(32, 'Invalid hash length');
assert(encryptedData.keyDerivation.algo === 'noderivation', 'Invalid key derivation algorithm');
assert(encryptedData.cipherConfig.encryption === 'aes256', 'Invalid encryption algorithm');
assert(encryptedData.cipherConfig.cipherMode === 'cbchmac', 'Invalid encryption mode');
assert(encryptedData.cipherConfig.ivLength === 16, 'Invalid IV length');
assert(encryptedData.cipherData.salt.length === 0, 'Invalid salt length');
assert(encryptedData.cipherData.iv.length === 16, 'Invalid IV');
assert(encryptedData.cipherData.hash.length === 32, 'Invalid hash length');
});

it('decryption of encryption should successfully return the input', async () => {
const input = 'The input string I want to encrypt';
const key = crypto.randomBytes(32);
const encryptedInput = encryptAesCbcHmac256(key, Buffer.from(input));
const decryptedInput = await decrypt(encryptedInput, { type: 'alreadyComputed', symmetricKey: key });
expect(input).to.equal(decryptedInput.toString());
assert(input === decryptedInput.toString(), 'Decrypted input is different from the original input');
});
});
16 changes: 8 additions & 8 deletions src/requestApi.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as got from 'got';
import { Response, HTTPError } from 'got';
import * as apiConnect from './modules/api-connect';
import { CLI_VERSION, cliVersionToString } from './cliVersion';
import { gotImplementation } from './utils/';

interface RequestApi {
payload: Dictionary<unknown>;
payload: Record<string, unknown>;
path: string;
authentication: apiConnect.Authentication;
}
Expand Down Expand Up @@ -43,9 +43,9 @@ const makeStagingCloudflareHeaders = () =>
const requestApi = async <T>(params: RequestApi): Promise<T> => {
const { payload, path, authentication } = params;

let response;
let response: Response<string>;
try {
response = await apiConnect.postRequestAPI<got.Response<string>>({
response = await apiConnect.postRequestAPI<Response<string>>({
requestFunction: gotImplementation,
authentication,
path: 'v1/' + path,
Expand All @@ -56,7 +56,7 @@ const requestApi = async <T>(params: RequestApi): Promise<T> => {
});
} catch (error: unknown) {
// Generate a DashlaneApiError if appropriate
if (error instanceof got.HTTPError && typeof error.response?.body === 'string') {
if (error instanceof HTTPError && typeof error.response?.body === 'string') {
let details;
try {
details = (JSON.parse(error.response.body) as DashlaneApiErrorResponse).errors[0];
Expand All @@ -77,7 +77,7 @@ const requestApi = async <T>(params: RequestApi): Promise<T> => {
};

export interface RequestAppApi {
payload: Dictionary<unknown>;
payload: Record<string, unknown>;
path: string;
}

Expand All @@ -93,7 +93,7 @@ export const requestAppApi = async <T>(params: RequestAppApi): Promise<T> => {

export interface RequestUserApi {
login: string;
payload: Dictionary<unknown>;
payload: Record<string, unknown>;
path: string;
deviceKeys: {
accessKey: string;
Expand All @@ -116,7 +116,7 @@ export const requestUserApi = async <T>(params: RequestUserApi): Promise<T> => {

export interface RequestTeamApi {
teamUuid: string;
payload: Dictionary<unknown>;
payload: Record<string, unknown>;
path: string;
teamDeviceKeys: {
accessKey: string;
Expand Down
6 changes: 3 additions & 3 deletions src/utils/gotImplementation.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as got from 'got';
import got, { Response } from 'got';
import * as apiConnect from '../modules/api-connect';

export const gotImplementation: apiConnect.RequestFunction<got.Response<string>> = (
export const gotImplementation: apiConnect.RequestFunction<Response<string>> = (
options: apiConnect.RequestFunctionOptions
) => {
const { headers, json, url } = options;

return got.default.post(url, {
return got.post(url, {
headers,
json,
retry: { limit: 3 },
Expand Down
5 changes: 2 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"compilerOptions": {
"jsx": "react",
/* Visit https://aka.ms/tsconfig.json to read more about this file */

/* Projects */
Expand All @@ -12,7 +11,7 @@
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */

/* Language and Environment */
"target": "es2020" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
"target": "ES2022" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
Expand Down Expand Up @@ -99,5 +98,5 @@
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
},
"exclude": ["documentation/components/**/*"]
"exclude": ["documentation/**/*", "scripts/**/*"]
}
Loading