@neabyte/auth-core
v0.3.0
Published
Auth validation, normalization, and generation for modern runtimes
Maintainers
Readme
Auth Core
Auth validation, normalization, and generation for modern runtimes.
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-corenpm
npm install @neabyte/auth-coreCDN (browser / any ESM)
<script type="module">
import { Email, Password, Username } from 'https://esm.sh/@neabyte/auth-core'
// or pin version: .../[email protected]
</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, ornullif invalid.
import { Email, Password, Username } from '@neabyte/auth-core'
Email.isValid('[email protected]')
// 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 checkUnit tests — format/lint tests and run all tests:
deno task testTests live under tests/ (one file per module).
License
This project is licensed under the MIT license. See the LICENSE file for details.
