npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@rempays/layer-core

v1.0.1-beta.0

Published

Core utilities layer for RemPays platform with AWS services integration (Cognito, S3, Secrets Manager, Textract, Facebook API)

Readme

@rempays/layer-core

Core utilities layer for RemPays platform with AWS services integration (Cognito, S3, Secrets Manager, Textract, Facebook API).

Installation

npm install @rempays/layer-core

Modules

1. Cognito Service

Authentication and user management with AWS Cognito.

import { CognitoService } from '@rempays/layer-core/cognito';

const cognito = new CognitoService({
  userPoolId: 'us-east-1_xxxxx',
  clientId: 'xxxxx',
  region: 'us-east-1'
});

// Register user
const result = await cognito.signUp({
  phoneNumber: '+1234567890',
  email: '[email protected]',
  password: 'SecurePass123'
});

// Confirm registration with OTP
await cognito.confirmSignUp('+1234567890', '123456');

// Sign in with custom auth
const authResponse = await cognito.signInCustomAuth({
  phoneNumber: '+1234567890'
});

// Verify OTP code
const tokens = await cognito.respondToAuthChallenge({
  phoneNumber: '+1234567890',
  code: '123456',
  session: authResponse.session
});

// Get user info
const user = await cognito.getUser(tokens.accessToken!);

// Refresh token
const newTokens = await cognito.refreshToken({
  refreshToken: tokens.refreshToken!
});

Available Methods

CognitoService

  • signUp(params) - Register new user
  • confirmSignUp(phoneNumber, code) - Confirm registration with OTP
  • signInCustomAuth(params) - Sign in with custom authentication
  • signInSRP(params) - Sign in with SRP
  • respondToAuthChallenge(params) - Verify OTP code
  • refreshToken(params) - Refresh access tokens
  • getUser(accessToken) - Get authenticated user info
  • adminGetUser(phoneNumber) - Get user info (admin)
  • adminInitiateAuth(phoneNumber) - Initiate auth as admin

Environment Variables

COGNITO_USER_POOL_ID=us-east-1_XXXXXXXXX
COGNITO_CLIENT_ID=XXXXXXXXXXXXXXXXXXXXXXXXXX
AWS_REGION=us-east-1

IAM Permissions Required

Your Lambda or application needs these permissions:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "cognito-idp:SignUp",
        "cognito-idp:ConfirmSignUp",
        "cognito-idp:InitiateAuth",
        "cognito-idp:RespondToAuthChallenge",
        "cognito-idp:GetUser",
        "cognito-idp:AdminGetUser",
        "cognito-idp:AdminInitiateAuth"
      ],
      "Resource": "arn:aws:cognito-idp:REGION:ACCOUNT_ID:userpool/USER_POOL_ID"
    }
  ]
}

Development

# Install dependencies
npm install

# Build
npm run build

# Watch mode
npm run dev

License

UNLICENSED

2. Secrets Manager

Manage secrets from AWS Secrets Manager.

import { getSecret, getSecrets, getSecretJSON } from '@rempays/layer-core/secrets';

// Get single secret
const apiKey = await getSecret('api_key');

// Get multiple secrets
const secrets = await getSecrets(['api_key', 'db_password']);

// Get JSON secret
const config = await getSecretJSON<{ host: string; port: number }>('db_config');

3. S3 Service

File operations with AWS S3.

import { S3Service } from '@rempays/layer-core/s3';

// Upload file
const s3Uri = await S3Service.uploadFile({
  key: 'documents/file.pdf',
  body: buffer,
  contentType: 'application/pdf',
  metadata: { userId: '123' }
});

// Download file
const fileBuffer = await S3Service.downloadFile('documents/file.pdf');

// Generate document key
const key = S3Service.generateDocumentKey({
  chatId: 'chat123',
  messageId: 'msg456',
  extension: 'pdf'
});

4. Textract Service

Extract text from documents using AWS Textract.

import { TextractService } from '@rempays/layer-core/textract';

// Analyze document from S3
const text = await TextractService.analyzeDocumentFromS3('my-bucket', 'document.pdf');

// Analyze document from bytes
const imageBytes = new Uint8Array(buffer);
const extractedText = await TextractService.analyzeDocumentFromBytes(imageBytes);

5. Facebook API (WhatsApp)

Send messages via WhatsApp Business API.

import { FacebookApi } from '@rempays/layer-core/facebook-api';

// Send text message
await FacebookApi.sendText({
  to: '+1234567890',
  body: 'Hello from RemPays!',
  previewUrl: true
});

// Send template
await FacebookApi.sendTemplate({
  to: '+1234567890',
  name: 'welcome_template',
  languageCode: 'en',
  components: []
});

// Send interactive buttons
await FacebookApi.sendInteractiveButtons({
  to: '+1234567890',
  body: 'Choose an option:',
  buttons: [
    { type: 'reply', id: 'opt1', title: 'Option 1' },
    { type: 'reply', id: 'opt2', title: 'Option 2' }
  ]
});

// Send interactive list
await FacebookApi.sendInteractiveList({
  to: '+1234567890',
  body: 'Select from menu:',
  buttonText: 'View Menu',
  sections: [
    {
      title: 'Main Options',
      rows: [
        { id: '1', title: 'Option 1', description: 'Description 1' },
        { id: '2', title: 'Option 2', description: 'Description 2' }
      ]
    }
  ]
});

// Send image
await FacebookApi.sendImage({
  to: '+1234567890',
  link: 'https://example.com/image.jpg',
  caption: 'Check this out!'
});

// Send document
await FacebookApi.sendDocument({
  to: '+1234567890',
  link: 'https://example.com/document.pdf',
  filename: 'invoice.pdf',
  caption: 'Your invoice'
});

// Mark as read
await FacebookApi.markAsRead({ messageId: 'msg_id' });

Available Methods Summary

CognitoService

  • signUp(params) - Register new user
  • confirmSignUp(phoneNumber, code) - Confirm registration with OTP
  • signInCustomAuth(params) - Sign in with custom authentication
  • signInSRP(params) - Sign in with SRP
  • respondToAuthChallenge(params) - Verify OTP code
  • refreshToken(params) - Refresh access tokens
  • getUser(accessToken) - Get authenticated user info
  • adminGetUser(phoneNumber) - Get user info (admin)
  • adminInitiateAuth(phoneNumber) - Initiate auth as admin

Secrets

  • getSecret(keyName, environment?) - Get single secret
  • getSecrets(keyNames, environment?) - Get multiple secrets
  • getSecretJSON<T>(keyName, environment?) - Get and parse JSON secret

S3Service

  • uploadFile(params) - Upload file to S3
  • downloadFile(key) - Download file from S3
  • generateDocumentKey(params) - Generate unique document key

TextractService

  • analyzeDocumentFromS3(bucket, key) - Extract text from S3 document
  • analyzeDocumentFromBytes(bytes) - Extract text from byte array

FacebookApi

  • sendText(params) - Send text message
  • sendTemplate(params) - Send template message
  • sendInteractiveButtons(params) - Send interactive buttons
  • sendInteractiveList(params) - Send interactive list
  • sendImage(params) - Send image
  • sendDocument(params) - Send document
  • sendLocation(params) - Send location
  • markAsRead(params) - Mark message as read
  • setTyping(params) - Set typing indicator