Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
kaven-utils
Advanced tools
npm i kaven-utils --save
or
yarn add kaven-utils
import KavenUtility from "kaven-utils";
KavenUtility.MethodName();
// ...
// Your own utility.js
import { KavenUtility } from "kaven-utils";
export default new class Utility extends KavenUtility {
// ...
}();
export declare class KavenUtility extends KavenBasic {
readonly Platform: NodeJS.Platform;
readonly IsWin32: boolean;
ExternalIPRules: IExternalIPRule[];
protected isInitialized: boolean;
protected readonly ansiUp: Au;
protected readonly chalkInstance: Chalk;
constructor();
Initialize(): void;
BuildLogString(level?: LogLevel, ...args: any[]): string;
BuildError(...param: any[]): string;
OverrideConsole(): this;
GetColoredStatus(code: string | number): string | number;
CopyFileSync(dest: string, src: string): any;
FindLogFile(): Promise<string>;
ResetLogFile(fileName: string, backupFolder?: string): boolean;
GetLogContent(file?: string, html?: boolean): Promise<any>;
GetFileContent(fileName: string, html?: boolean): Promise<string>;
IsDirectory(strPath: string): boolean;
GetFileExtension(fileName: string, trimDot?: boolean, toLowerCase?: boolean): string;
GetFileName(fileName: string): string;
ZipFolder(folderPath: string, fileName: string, topFolderName?: string): Promise<string>;
SevenZipFolder(folderPath: string, fileName: string, password?: string): Promise<string>;
Run7zCommand(command: string, switches?: any): Promise<string>;
SevenZipFiles(files: string[], fileName: string, password?: string): Promise<string>;
BackupMongoDB(outputDir: string, databaseName?: string, host?: string, databaseUser?: string, databasePassword?: string): Promise<string>;
DeleteFolder(folderPath: string): Promise<string[]>;
DeleteFileOrDirectory(...paths: string[]): Promise<string[]>;
UploadFileToFTPServer(fileName: string, serverHost?: string, serverPort?: number, serverUserName?: string, serverUserPassword?: string): Promise<string>;
SendEmail(config: MailConfig, option: MailOption): Promise<{}>;
GenerateQRCode(data: string, version?: number, errorCorrectionLevel?: "low" | "medium" | "quartile" | "high" | "L" | "M" | "Q" | "H", toSJISFunc?: (codePoint: string) => number): Promise<any>;
StartSchedule(func: () => void, year?: number | number[], month?: number | number[], date?: number | number[], dayOfWeek?: number | number[], hour?: number | number[], minute?: number | number[], second?: number | number[]): schedule.Job;
StartScheduleLikeCron(func: () => void, rule: string): schedule.Job;
Base64Encode(data: string, encoding?: string): string;
Base64Decode(base64Data: string, encoding?: string): string;
CreateCertificate(options?: pem.CertificateCreationOptions): Promise<pem.CertificateCreationResult>;
SaveStringToFile(str: string, savePath: string): Promise<string>;
WriteStringToClipboard(text: string): void;
WriteStringToClipboardAsync(text: string): Promise<void>;
ReadStringFromClipboard(): string;
ReadStringFromClipboardAsync(): Promise<string>;
DownloadFile(url: string, savePath: string): Promise<string>;
GetFileSizeInBytes(filePath: string): Promise<number>;
ResetLogFileIf(overBytes?: number): Promise<boolean>;
MakeDirectory(dir: string): Promise<string>;
MakeDirectorySync(dir: string): string;
LoadJsonFile(filePath: string): Promise<IndexObject>;
HMAC_SHA1(stringToSign: string, secret: string): Buffer;
GetAllFilesRecursively(dir: string, extensions?: string[], ignorePaths?: string[]): string[];
GetAllFiles(dir: string): string[];
FindAndReplaceInFiles(dirOrFiles: string | string[], conditions?: string[][], newStrMethod?: (str: string) => string, extensions?: string[], showLog?: boolean): Promise<void>;
GetFileType(buf: Buffer | Uint8Array): FileType.FileTypeResult;
GetFileTypeFromFile(file: string): Promise<FileType.FileTypeResult>;
GetFileList(filesOrFolders: string[], excludeFilesOrFolders?: string[], fileTypes?: string[]): string[];
RunCommand(command: string, options?: {
encoding: BufferEncoding;
} & ExecOptions): Promise<{
stdout: string;
stderr: string;
}>;
RunCommandAndDecode(command: string, decodeEncoding?: string): Promise<{
stdout: string;
stderr: string;
}>;
Exec(command: string, options?: IExecOptions, autoDecode?: boolean): import("child_process").ChildProcess;
Spawn(command: string, args?: ReadonlyArray<string>, options?: SpawnOptions, autoDecode?: boolean): import("child_process").ChildProcess;
CopyFileOrDirectory(src: string, dest: string, options?: ncpOptions): Promise<string>;
CreateJWT(payload: string | object | Buffer, secret: string, options: JWT.SignOptions): Promise<string>;
VerifyJWT(token: string, secret: string, options?: JWT.SignOptions): Promise<{
[key: string]: any;
}>;
DecodeJWT(token: string, options?: JWT.DecodeOptions): string | {
[key: string]: any;
};
ReadFileBytes(file: string, length: number, offset?: number): Promise<Buffer>;
IsFileOrDirectoryExist(...paths: string[]): boolean[];
GetProtocolFromURL(url: string): string;
HTTPGet<T>(url: string): Promise<IHTTPResponse<T>>;
HTTPPost<T>(url: string, data: any): Promise<IHTTPResponse<T>>;
GetExternalIP(): Promise<string>;
InitializeTextLogger(stdoutFile: string, stderrFile: string): void;
}
Add clipboard support base on clipboardy
Add following functions:
export declare function WriteStringToClipboard(text: string): void;
export declare function WriteStringToClipboardAsync(text: string): Promise<void>;
export declare function ReadStringFromClipboard(): string;
export declare function ReadStringFromClipboardAsync(): Promise<string>;
export declare function SplitStringByNewline(str: string): string[];
Add following functions:
export declare function RemoveInvalidCharactersForPath(path: string): string;
export declare function DownloadFile(url: string, path: string): Promise<string>;
export declare function GetFileSizeInBytes(path: string): Promise<number>;
export declare function ResetLogFileIf(overBytes?: number): Promise<boolean>;
export declare function MakeDirectory(dir: string): Promise<string>;
export declare function MakeDirectorySync(dir: string): string;
Add following functions:
interface String {
GetIndent(): string;
}
Add:
export declare let IsDebugMode: boolean;
Improve:
export declare function CopyFileSync(dest: string, src: string): any;
Add:
interface String {
OnlyContains(...characters: string[]): boolean;
ToArray(): string[];
Distinct(): string;
}
interface Array < T > {
Distinct(): Array < T > ;
First(): T;
Last(): T;
}
export declare let IsDebugMode: boolean;
export declare function LoadJsonFile(path: string): Promise<{[index: string]: any;}>;
export declare function GetNextVersion(version: string): string | number;
Add:
export declare namespace KavenCommon
export declare namespace KavenUtility
export default KavenUtility;
Code Improve
Add:
static RunCommand(command: string, options?: {
encoding: BufferEncoding;
} & ExecOptions): Promise<{
stdout: string;
stderr: string;
}>;
static RunCommandAndDecode(command: string, decodeEncoding?: string): Promise<{
stdout: string;
stderr: string;
}>;
static CopyFileOrDirectory(src: string, dest: string, options?: ncpOptions): Promise<boolean>;
Add:
static ReadFileBytes(file: string, length: number, offset?: number): Promise<Buffer>;
static GetFileTypeFromFile(file: string): Promise<FileType.FileTypeResult>;
Improve:
static GetFileExtension(fileName: string, trimDot = false, toLowerCase = false)
Fix #5, #6
Add CLI support
Code Refactoring
FAQs
Utils for Node.js.
The npm package kaven-utils receives a total of 5 weekly downloads. As such, kaven-utils popularity was classified as not popular.
We found that kaven-utils demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.