Registry / auth-security / test-backend-schema-library

test-backend-schema-library

JSON →
library2.0.3jsnpmunverified

A modular authentication library for Node.js backends integrating AWS Cognito JWT validation and MongoDB connectivity. Version 2.0.3 provides a registerable module with synchronous configuration. Features token verification, database connection management, and TypeScript-first design. Differentiates through opinionated module registration pattern and direct Cognito integration.

npm install test-backend-schema-library
INSTALL
IMPORT
SIG · TEST-BACKEND-SCHEM
T
test-backend-schema-library
auth-securityjavascriptv2.0.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ValidateTokenModule
import { ValidateTokenModule } from 'career-edge-backend-auth-library'
import ValidateTokenModule from 'career-edge-backend-auth-library'
Default export does not exist; use named import.
TokenService
import { TokenService } from 'career-edge-backend-auth-library'
const { TokenService } = require('career-edge-backend-auth-library')
Package is ESM-only, requires import syntax.
TokenGuard
import { TokenGuard } from 'career-edge-backend-auth-library'
import { TokenGuard } from 'career-edge-backend-auth-library/guards'
TokenGuard is re-exported from the main entry point, not a subpath.

Shows module registration with all required configuration fields and TokenService injection in a NestJS service class.

import { Module } from '@nestjs/common'; import { ValidateTokenModule } from 'career-edge-backend-auth-library'; @Module({ imports: [ ValidateTokenModule.register({ AWS_COGNITO_JWK_URL: process.env.COGNITO_JWK_URL ?? '', AWS_API_VERSION: process.env.API_VERSION ?? '2016-04-18', AWS_REGION: process.env.AWS_REGION ?? '', AWS_ACCESS_KEY_ID: process.env.AWS_ACCESS_KEY_ID ?? '', AWS_SECRET_ACCESS_KEY: process.env.AWS_SECRET_ACCESS_KEY ?? '', DATABASE_CONNECTION_STRING: process.env.MONGO_URI ?? '', DATABASE_NAME: process.env.DATABASE_NAME ?? '', }), ], providers: [], controllers: [] }) export class AppModule {} // In a service: import { Injectable } from '@nestjs/common'; import { TokenService } from 'career-edge-backend-auth-library'; @Injectable() export class ExampleService { constructor(private readonly tokenService: TokenService) {} async validate(token: string) { return this.tokenService.validateToken(token); } }
Debug
Known issues
breakingConfiguration object changed between versions: removed optional fields and added DATABASE_CONNECTION_STRING and DATABASE_NAME. Existing code using older config will fail.
fix
Update the register() call to include all required fields as shown in the README.
affects: <2.0.0
breakingThe library is ESM-only since v2. CommonJS require() statements will throw an error.
fix
Use import statements instead of require. Ensure your project supports ESM (e.g., type: module in package.json).
affects: >=2.0.0
gotchaAWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are required even if using IAM roles; passing empty strings may cause runtime errors.
fix
Provide valid AWS credentials or use AWS SDK credential chain on EC2/ECS.
affects: >=1.0.0
gotchaDATABASE_CONNECTION_STRING must include the database name in the URI (e.g., mongodb://host/dbname) because DATABASE_NAME option is additional but may be ignored if present in the URI.
fix
Ensure the MongoDB URI includes the database name. The separate DATABASE_NAME is optional and may override.
affects: >=2.0.0
deprecatedAwsSdk v2 is used internally. AWS SDK v3 is recommended; future versions will migrate.
fix
No immediate action needed, but plan for migration when library updates.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'career-edge-backend-auth-library'
Package not installed or import path incorrect.
fix
Run npm install career-edge-backend-auth-library and ensure the import statement is correct.
TypeError: ValidateTokenModule.register is not a function
Likely using a default import instead of named import, or the module has changed its API.
fix
Use named import: import { ValidateTokenModule } from 'career-edge-backend-auth-library'. If problem persists, check version >=2.0.0.
MongooseError: Mongoose connection error: missing database name
DATABASE_CONNECTION_STRING does not contain the database name, and DATABASE_NAME is empty.
fix
Provide a valid MongoDB URI that includes the database name (e.g., mongodb://localhost:27017/mydb).
JsonWebTokenError: invalid signature
JWT token does not match the JWK from Cognito; possibly wrong JWK URL or token expired.
fix
Verify AWS_COGNITO_JWK_URL is correct and the token is still valid.
Upgrade
Version history
2.0.3latest on npm
Audit
Dependencies
@nestjs/commonrequiredRequired for module registration and dependency injection
mongooserequiredUsed for MongoDB database connection
jsonwebtokenrequiredJWT verification against Cognito JWKs
aws-sdkrequiredAWS SDK for Cognito operations
Agent activity
34 hits · last 30 days
node
28
Meta
2
OpenAI (training)
1
Resources
test-backend-schema-library — npm install test-backend-schema-library · libregistry