New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@typinghare/trick

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@typinghare/trick - npm Package Compare versions

Comparing version
2.1.1
to
2.1.2
+7
-11
dist/app.js

@@ -11,3 +11,3 @@ import { Command } from 'commander';

const program = new Command();
program.version('2.1.0');
program.version('2.1.2');
program.description('Save credential files to remote safely and easily.');

@@ -117,3 +117,2 @@ program

const rootDirectory = getRootDirectory();
const trickRootDirectory = path.resolve(rootDirectory, config.trickRootDirectory);
for (const targetName of targetNames) {

@@ -123,4 +122,3 @@ const target = getTargetFromConfig(config, targetName);

const srcFilePaths = target.files;
fsExtra.ensureDir(trickRootDirectory);
encryptFiles(srcFilePaths, trickRootDirectory, passphrase, config.encryption.iterationCount);
encryptFiles(config, rootDirectory, srcFilePaths, passphrase);
}

@@ -143,3 +141,2 @@ });

const rootDirectory = getRootDirectory();
const trickRootDirectory = path.resolve(rootDirectory, config.trickRootDirectory);
for (const targetName of targetNames) {

@@ -149,4 +146,3 @@ const target = getTargetFromConfig(config, targetName);

const srcFilePaths = target.files;
fsExtra.ensureDir(trickRootDirectory);
decryptFiles(srcFilePaths, trickRootDirectory, passphrase, config.encryption.iterationCount);
decryptFiles(config, rootDirectory, srcFilePaths, passphrase);
}

@@ -180,3 +176,3 @@ });

.command('list-defaults')
.description('Display the default target name.')
.description('Display the default target name.')
.action(function () {

@@ -211,3 +207,3 @@ updateConfig((config) => {

fsExtra.ensureDirSync(passphraseDirectory);
console.log(success(`Created passphrase directory: ${passphraseDirectory}`));
console.log(success(`Created passphrase directory: ${colorFilePath(passphraseDirectory)}`));
}

@@ -218,7 +214,7 @@ const passphraseFile = path.join(passphraseDirectory, targetName);

fsExtra.chmodSync(passphraseFile, 0o600);
console.log(success(`Created passphrase file: ${passphraseFile}`));
console.log(success(`Created passphrase file: ${colorFilePath(passphraseFile)}`));
console.log(success(`You have to edit the file to set the passphrase.`));
}
else {
console.log(warning(`Passphrase file already exists: ${passphraseFile}`));
console.log(warning(`Passphrase file already exists: ${colorFilePath(passphraseFile)}`));
}

@@ -225,0 +221,0 @@ });

export declare function colorTargetName(targetName: string): string;
export declare function colorFilePath(filePath: string): string;
export declare function colorSourceFilePath(filePath: string): string;
export declare function colorTargetFilePath(message: string): string;

@@ -8,1 +8,7 @@ import chalk from 'chalk';

}
export function colorSourceFilePath(filePath) {
return chalk.italic.green(filePath);
}
export function colorTargetFilePath(message) {
return chalk.italic.magenta(message);
}

@@ -0,1 +1,2 @@

import { Config } from './config.js';
/**

@@ -39,11 +40,10 @@ * Encrypts a file using OpenSSL with AES-256-CBC and PBKDF2 key derivation.

*
* @param config The configuration object.
* @param rootDir The root directory where the trick configuration is located.
* @param srcFilePaths An array of file paths to be encrypted.
* @param destDir The directory where the encrypted files will be saved.
* @param passphrase The passphrase used for encryption.
* @param iterationCount The number of iterations to use for PBKDF2.
* @returns Resolves when all files are successfully encrypted.
* @throws {FailToEncryptFileError} If any file fails to encrypt.
*/
export declare function encryptFiles(srcFilePaths: string[], destDir: string, passphrase: string, iterationCount: number): Promise<void>;
/**
export declare function encryptFiles(config: Config, rootDir: string, srcFilePaths: string[], passphrase: string): Promise<void>; /**
* Decrypts multiple files using OpenSSL with AES-256-CBC and PBKDF2 key derivation.

@@ -54,9 +54,9 @@ *

*
* @param config The configuration object.
* @param rootDir The root directory where the trick configuration is located.
* @param srcFilePaths An array of original file paths that were encrypted.
* @param destDir The directory containing the encrypted files.
* @param passphrase The passphrase used for decryption.
* @param iterationCount The number of iterations used for PBKDF2.
* @returns Resolves when all files are successfully decrypted.
* @throws {FailToDecryptFileError} If any file fails to decrypt.
*/
export declare function decryptFiles(srcFilePaths: string[], destDir: string, passphrase: string, iterationCount: number): Promise<void>;
export declare function decryptFiles(config: Config, rootDir: string, srcFilePaths: string[], passphrase: string): Promise<void>;

@@ -6,2 +6,3 @@ import { execa } from 'execa';

import { success } from './console.js';
import { colorSourceFilePath, colorTargetFilePath } from './color.js';
/**

@@ -110,17 +111,21 @@ * Encrypts a file using OpenSSL with AES-256-CBC and PBKDF2 key derivation.

*
* @param config The configuration object.
* @param rootDir The root directory where the trick configuration is located.
* @param srcFilePaths An array of file paths to be encrypted.
* @param destDir The directory where the encrypted files will be saved.
* @param passphrase The passphrase used for encryption.
* @param iterationCount The number of iterations to use for PBKDF2.
* @returns Resolves when all files are successfully encrypted.
* @throws {FailToEncryptFileError} If any file fails to encrypt.
*/
export async function encryptFiles(srcFilePaths, destDir, passphrase, iterationCount) {
export async function encryptFiles(config, rootDir, srcFilePaths, passphrase) {
const iterationCount = config.encryption.iterationCount;
const trickRootDirectory = config.trickRootDirectory;
fsExtra.ensureDir(path.join(rootDir, trickRootDirectory));
for (const srcFilePath of srcFilePaths) {
const destFilePath = path.join(destDir, srcFilePath + '.enc');
await encryptFile(srcFilePath, destFilePath, passphrase, iterationCount);
console.log(success(`Encrypted: ${srcFilePath} -> ${destFilePath}`));
const destFilePath = path.join(trickRootDirectory, srcFilePath + '.enc');
const absoluteDestFilePath = path.join(rootDir, destFilePath);
const absoluteSrcFilePath = path.resolve(rootDir, srcFilePath);
await encryptFile(absoluteSrcFilePath, absoluteDestFilePath, passphrase, iterationCount);
console.log(success(`Encrypted: ${colorSourceFilePath(srcFilePath)} -> ${colorTargetFilePath(destFilePath)}`));
}
}
/**
} /**
* Decrypts multiple files using OpenSSL with AES-256-CBC and PBKDF2 key derivation.

@@ -131,15 +136,19 @@ *

*
* @param config The configuration object.
* @param rootDir The root directory where the trick configuration is located.
* @param srcFilePaths An array of original file paths that were encrypted.
* @param destDir The directory containing the encrypted files.
* @param passphrase The passphrase used for decryption.
* @param iterationCount The number of iterations used for PBKDF2.
* @returns Resolves when all files are successfully decrypted.
* @throws {FailToDecryptFileError} If any file fails to decrypt.
*/
export async function decryptFiles(srcFilePaths, destDir, passphrase, iterationCount) {
export async function decryptFiles(config, rootDir, srcFilePaths, passphrase) {
const iterationCount = config.encryption.iterationCount;
const trickRootDirectory = config.trickRootDirectory;
for (const srcFilePath of srcFilePaths) {
const destFilePath = path.join(destDir, srcFilePath + '.enc');
await decryptFile(srcFilePath, destFilePath, passphrase, iterationCount);
console.log(success(`Decrypted: ${destFilePath} -> ${srcFilePath}`));
const destFilePath = path.join(trickRootDirectory, srcFilePath + '.enc');
const absoluteDestFilePath = path.join(rootDir, destFilePath);
const absoluteSrcFilePath = path.resolve(rootDir, srcFilePath);
await decryptFile(absoluteSrcFilePath, absoluteDestFilePath, passphrase, iterationCount);
console.log(success(`Decrypted: ${colorTargetFilePath(destFilePath)} -> ${colorSourceFilePath(srcFilePath)}`));
}
}
{
"name": "@typinghare/trick",
"description": "Save credential files to remote safely and easily.",
"version": "2.1.1",
"version": "2.1.2",
"main": "dist/index.js",

@@ -11,2 +11,5 @@ "types": "dist/index.d.ts",

},
"scripts": {
"build": "node_modules/typescript/bin/tsc"
},
"author": {

@@ -55,5 +58,3 @@ "name": "James Chen",

},
"scripts": {
"build": "node_modules/typescript/bin/tsc"
}
}
"packageManager": "pnpm@10.27.0"
}

@@ -18,3 +18,3 @@ import { Command } from 'commander'

const program = new Command()
program.version('2.1.0')
program.version('2.1.2')
program.description('Save credential files to remote safely and easily.')

@@ -140,3 +140,2 @@

const rootDirectory = getRootDirectory()
const trickRootDirectory = path.resolve(rootDirectory, config.trickRootDirectory)
for (const targetName of targetNames) {

@@ -147,4 +146,3 @@ const target: Target = getTargetFromConfig(config, targetName)

fsExtra.ensureDir(trickRootDirectory)
encryptFiles(srcFilePaths, trickRootDirectory, passphrase, config.encryption.iterationCount)
encryptFiles(config, rootDirectory, srcFilePaths, passphrase)
}

@@ -170,3 +168,2 @@ })

const rootDirectory = getRootDirectory()
const trickRootDirectory = path.resolve(rootDirectory, config.trickRootDirectory)
for (const targetName of targetNames) {

@@ -177,4 +174,3 @@ const target: Target = getTargetFromConfig(config, targetName)

fsExtra.ensureDir(trickRootDirectory)
decryptFiles(srcFilePaths, trickRootDirectory, passphrase, config.encryption.iterationCount)
decryptFiles(config, rootDirectory, srcFilePaths, passphrase)
}

@@ -213,3 +209,3 @@ })

.command('list-defaults')
.description('Display the default target name.')
.description('Display the default target name.')
.action(function (): void {

@@ -246,3 +242,3 @@ updateConfig((config) => {

fsExtra.ensureDirSync(passphraseDirectory)
console.log(success(`Created passphrase directory: ${passphraseDirectory}`))
console.log(success(`Created passphrase directory: ${colorFilePath(passphraseDirectory)}`))
}

@@ -254,6 +250,6 @@

fsExtra.chmodSync(passphraseFile, 0o600)
console.log(success(`Created passphrase file: ${passphraseFile}`))
console.log(success(`Created passphrase file: ${colorFilePath(passphraseFile)}`))
console.log(success(`You have to edit the file to set the passphrase.`))
} else {
console.log(warning(`Passphrase file already exists: ${passphraseFile}`))
console.log(warning(`Passphrase file already exists: ${colorFilePath(passphraseFile)}`))
}

@@ -260,0 +256,0 @@ })

@@ -10,1 +10,9 @@ import chalk from 'chalk'

}
export function colorSourceFilePath(filePath: string): string {
return chalk.italic.green(filePath)
}
export function colorTargetFilePath(message: string): string {
return chalk.italic.magenta(message)
}

@@ -6,2 +6,4 @@ import { execa } from 'execa'

import { success } from './console.js'
import { colorSourceFilePath, colorTargetFilePath } from './color.js'
import { Config } from './config.js'

@@ -125,6 +127,6 @@ /**

*
* @param config The configuration object.
* @param rootDir The root directory where the trick configuration is located.
* @param srcFilePaths An array of file paths to be encrypted.
* @param destDir The directory where the encrypted files will be saved.
* @param passphrase The passphrase used for encryption.
* @param iterationCount The number of iterations to use for PBKDF2.
* @returns Resolves when all files are successfully encrypted.

@@ -134,15 +136,23 @@ * @throws {FailToEncryptFileError} If any file fails to encrypt.

export async function encryptFiles(
config: Config,
rootDir: string,
srcFilePaths: string[],
destDir: string,
passphrase: string,
iterationCount: number
passphrase: string
): Promise<void> {
const iterationCount: number = config.encryption.iterationCount
const trickRootDirectory: string = config.trickRootDirectory
fsExtra.ensureDir(path.join(rootDir, trickRootDirectory))
for (const srcFilePath of srcFilePaths) {
const destFilePath: string = path.join(destDir, srcFilePath + '.enc')
await encryptFile(srcFilePath, destFilePath, passphrase, iterationCount)
console.log(success(`Encrypted: ${srcFilePath} -> ${destFilePath}`))
const destFilePath: string = path.join(trickRootDirectory, srcFilePath + '.enc')
const absoluteDestFilePath: string = path.join(rootDir, destFilePath)
const absoluteSrcFilePath: string = path.resolve(rootDir, srcFilePath)
await encryptFile(absoluteSrcFilePath, absoluteDestFilePath, passphrase, iterationCount)
console.log(
success(
`Encrypted: ${colorSourceFilePath(srcFilePath)} -> ${colorTargetFilePath(destFilePath)}`
)
)
}
}
/**
} /**
* Decrypts multiple files using OpenSSL with AES-256-CBC and PBKDF2 key derivation.

@@ -153,6 +163,6 @@ *

*
* @param config The configuration object.
* @param rootDir The root directory where the trick configuration is located.
* @param srcFilePaths An array of original file paths that were encrypted.
* @param destDir The directory containing the encrypted files.
* @param passphrase The passphrase used for decryption.
* @param iterationCount The number of iterations used for PBKDF2.
* @returns Resolves when all files are successfully decrypted.

@@ -162,12 +172,21 @@ * @throws {FailToDecryptFileError} If any file fails to decrypt.

export async function decryptFiles(
config: Config,
rootDir: string,
srcFilePaths: string[],
destDir: string,
passphrase: string,
iterationCount: number
passphrase: string
): Promise<void> {
const iterationCount: number = config.encryption.iterationCount
const trickRootDirectory: string = config.trickRootDirectory
for (const srcFilePath of srcFilePaths) {
const destFilePath: string = path.join(destDir, srcFilePath + '.enc')
await decryptFile(srcFilePath, destFilePath, passphrase, iterationCount)
console.log(success(`Decrypted: ${destFilePath} -> ${srcFilePath}`))
const destFilePath: string = path.join(trickRootDirectory, srcFilePath + '.enc')
const absoluteDestFilePath: string = path.join(rootDir, destFilePath)
const absoluteSrcFilePath: string = path.resolve(rootDir, srcFilePath)
await decryptFile(absoluteSrcFilePath, absoluteDestFilePath, passphrase, iterationCount)
console.log(
success(
`Decrypted: ${colorTargetFilePath(destFilePath)} -> ${colorSourceFilePath(srcFilePath)}`
)
)
}
}