Skip to content

NeaByteLab/Auth-Core

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Auth Core

Auth validation, normalization, and generation for modern runtimes.

Module type: Deno/ESM npm version JSR CI License

Features

  • Cipher — Encrypt and decrypt with a shared secret; URL-safe output.
  • Email — Validate, normalize, and extract domain or local part.
  • Fullname — Validate and normalize human names with optional formatting.
  • Hostname — Validate and normalize hostnames (e.g. for TLS or DNS).
  • Password — Validate rules, score strength, or generate random passwords.
  • Pin — Validate and normalize numeric PINs (e.g. 4–8 digits).
  • Username — Validate and normalize usernames (letters, numbers, underscore).

Installation

Deno

deno add jsr:@neabyte/auth-core

npm

npm install @neabyte/auth-core

CDN (browser / any ESM)

<script type="module">
  import { Email, Password, Username } from 'https://esm.sh/@neabyte/auth-core'
  // or pin version: .../auth-core@x.x.x
</script>
  • Latest: https://esm.sh/@neabyte/auth-core
  • Pinned: https://esm.sh/@neabyte/auth-core@<version>

Quick Start

Import the classes you need.

  • Use isValid() for a quick boolean check
  • validate() when you need { valid, errors } (e.g. to show errors in a form)
  • normalize() when you want a cleaned string to store or display, or null if invalid.
import { Email, Password, Username } from '@neabyte/auth-core'

Email.isValid('john@doe.com')
// true

Password.validate('short', { minLength: 8 })
// { valid: false, errors: ['Password must be at least 8 characters'] }

Username.normalize('  Jane_Doe  ')
// 'jane_doe'

Note

TypeScript types (e.g. PinResult, PasswordOptions) are exported. More details: USAGE.md

Build & Test

From the repo root (requires Deno).

Check — format, lint, and typecheck source:

deno task check

Unit tests — format/lint tests and run all tests:

deno task test

Tests live under tests/ (one file per module).

License

This project is licensed under the MIT license. See the LICENSE file for details.