@ashiknesin/helpers
TypeScript icon, indicating that this package has built-in type declarations

0.0.46 • Public • Published

AshikNesin's Helpers

This library provides a set of functions to simplify common tasks related to solving captchas, working with AWS services, managing files, and interacting with the Supabase storage. It leverages popular libraries like Axios, Pino, P-Retry, and others to ensure efficient and reliable functionality.

Functions

Captcha Solving

solveCaptcha

async solveCaptcha({
  type: string,             // Optional. Default is "image-to-text"
  base64Image: string,      // Base64-encoded image data
  imageUrl: string,         // URL of the image
  apiKey: string,           // 2Captcha API Key
  waitUntilResponse: bool    // Optional. Default is true
})

Solves a captcha using the 2Captcha service.

AWS

AWS Parameter Store

class paramStore {
  async getParameter(name: string, options?: any): Promise<{ data: string, error: Error }>
  async getParameters(names: string[], options?: any): Promise<{ data: { [name: string]: string }, error: Error }>
  async getManyByPath(path: string, options?: any): Promise<{ data: { [name: string]: string }, error: Error }>
  async get(param: string | string[], options?: any): Promise<{ data: any, error: Error }>
  async set(name: string, value: string): Promise<{ data: any, error: Error }>
}

Provides a convenient interface to interact with AWS Systems Manager Parameter Store.

dynamoDB

class dynamoDB {
  // AWS DynamoDB Document Client instance
}

s3

class s3 {
  async upload(key: string, body: any, options?: any): Promise<{ data: { filePath: string }, error: Error }>
  async download(key: string, destination: string): Promise<{ data: { filePath: string }, error: Error }>
  async remove(keys: string[]): Promise<{ data: { filePaths: string[] }, error: Error }>
  async createSignedUrl(key: string, expiresIn: number): Promise<{ data: { signedUrl: string }, error: Error }>
}

Provides utility functions for interacting with AWS S3.

File Management

zipDirectory

async zipDirectory(inputDirectory: string, outputZipPath: string): Promise<void>

Zips a directory into a specified zip file.

unzipDirectory

async unzipDirectory(inputZipPath: string, outputDirectory: string): Promise<void>

Unzips a zip file into a specified directory.

Supabase

supabaseAdmin

const supabaseAdmin = createClient({
  url: string,
  key: string
})

Creates an instance of the Supabase client for administrative purposes.

supabaseUploadFile

async supabaseUploadFile(bucket: string, filePath: string, fileData: any): Promise<void>

Uploads a file to the Supabase storage.

supabaseDownloadFile

async supabaseDownloadFile(bucket: string, filePath: string, destination: string): Promise<void>

Downloads a file from the Supabase storage.

Usage

import {
  solveCaptcha,
  paramStore,
  dynamoDB,
  s3,
  zipDirectory,
  unzipDirectory,
  supabaseAdmin,
  supabaseUploadFile,
  supabaseDownloadFile
} from 'captcha-solver';

// Example usage
const captchaResult = await solveCaptcha({
  base64Image: 'base64EncodedImageData',
  apiKey: 'your2CaptchaApiKey'
});

const paramValue = await paramStore.getParameter('parameterName');
const s3SignedUrl = await s3.createSignedUrl('objectKey', 3600);

// ... (other examples)

Deps

License

This library is released under the MIT License.

Readme

Keywords

Package Sidebar

Install

npm i @ashiknesin/helpers

Weekly Downloads

1

Version

0.0.46

License

MIT

Unpacked Size

182 kB

Total Files

9

Last publish

Collaborators

  • ashiknesin