@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.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.0.463latest

Version History

VersionDownloads (Last 7 Days)Published
0.0.463
0.0.452
0.0.442
0.0.431
0.0.421
0.0.412
0.0.401
0.0.392
0.0.381
0.0.372
0.0.361
0.0.352
0.0.342
0.0.322
0.0.312
0.0.302
0.0.291
0.0.281
0.0.272
0.0.261
0.0.252
0.0.242
0.0.231
0.0.222
0.0.211
0.0.201
0.0.192
0.0.181
0.0.171
0.0.161
0.0.152
0.0.142
0.0.131
0.0.122
0.0.101
0.0.81
0.0.71
0.0.61
0.0.52
0.0.41
0.0.32
0.0.22
0.0.12

Package Sidebar

Install

npm i @ashiknesin/helpers

Weekly Downloads

48

Version

0.0.46

License

MIT

Unpacked Size

182 kB

Total Files

9

Last publish

Collaborators

  • ashiknesin