Modules@robinpath/auth

@robinpath/auth

0.1.1Public

API authentication helpers (Basic, Bearer, API key, HMAC) for RobinPath

@robinpath/auth

API authentication helpers: Basic, Bearer, API key, HMAC signing, and password hashing

Category Functions Auth License

Why use this module?

The auth module lets you:

  • Create a Basic authentication header from username and password
  • Parse a Basic auth header to extract username and password
  • Create a Bearer authentication header from a token
  • Extract the token from a Bearer auth header
  • Create an API key configuration for header or query parameter placement

All functions are callable directly from RobinPath scripts with a simple, consistent API.

Installation

npm install @robinpath/auth

Quick Start

No credentials needed — start using it right away:

auth.parseBasic "Basic dXNlcjpwYXNz"

Available Functions

FunctionDescription
auth.basicCreate a Basic authentication header from username and password
auth.parseBasicParse a Basic auth header to extract username and password
auth.bearerCreate a Bearer authentication header from a token
auth.parseBearerExtract the token from a Bearer auth header
auth.apiKeyCreate an API key configuration for header or query parameter placement
auth.hmacSignCreate an HMAC signature for a payload
auth.hmacVerifyVerify an HMAC signature using timing-safe comparison
auth.generateApiKeyGenerate a cryptographically secure random API key
auth.hashPasswordHash a password using PBKDF2 with a random salt
auth.verifyPasswordVerify a password against a PBKDF2 hash (timing-safe)
auth.buildAuthHeaderBuild an Authorization header from a type and credentials
auth.parseAuthHeaderParse any Authorization header into its scheme and credentials

Examples

Parse a Basic auth header to extract username and password

auth.parseBasic "Basic dXNlcjpwYXNz"

Create a Bearer authentication header from a token

auth.bearer "eyJhbGciOi..."

Extract the token from a Bearer auth header

auth.parseBearer "Bearer eyJhbGciOi..."

Integration with RobinPath

import { RobinPath } from "@wiredwp/robinpath";
import Module from "@robinpath/auth";

const rp = new RobinPath();
rp.registerModule(Module.name, Module.functions);
rp.registerModuleMeta(Module.name, Module.functionMetadata);

const result = await rp.executeScript(`
  auth.parseBasic "Basic dXNlcjpwYXNz"
`);

Full API Reference

See MODULE.md for complete documentation including all parameters, return types, error handling, and advanced examples.

Related Modules

License

MIT

Versions (1)

VersionTagPublished
0.1.1latestyesterday
Install
$ robinpath install @robinpath/auth
Version0.1.1
LicenseMIT
Unpacked Size5.6 KB
Versions1
Weekly Downloads0
Total Downloads0
Stars0
Last Publishyesterday
Createdyesterday

Category

web