Registry / auth-security / ankhem-auth

ankhem-auth

JSON →
library0.0.25jsnpmunverified

Ankhem Auth is a minimal authentication component for JavaScript/TypeScript applications, part of the Ankhem ecosystem. Current stable version 0.0.25. Released irregularly as a pre-1.0 package. It provides basic auth utilities (login, logout, token management) with a small API surface. Differentiators: zero-dependency design (except Ankhem core), simple token storage abstraction, and TypeScript definitions included. Not recommended for production without careful review due to early stage.

npm install ankhem-auth
INSTALL
IMPORT
SIG · ANKHEM-AUTH
A
ankhem-auth
auth-securityjavascriptv0.0.25
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.

Auth
import { Auth } from 'ankhem-auth'
const Auth = require('ankhem-auth').Auth
ESM-only; CommonJS require() may not work depending on bundler configuration.
default
import Auth from 'ankhem-auth'
Default export is the same as named Auth export. Both work identically.
TokenStorage
import { TokenStorage } from 'ankhem-auth'
Additional interface exported for custom token storage implementations.

Creates an Auth instance, logs in with credentials, logs out, and retrieves the current token.

import { Auth } from 'ankhem-auth'; const auth = new Auth({ storage: localStorage, tokenKey: 'myapp_token' }); auth.login({ username: 'user', password: 'pass' }).then(user => { console.log('Logged in', user); }).catch(err => console.error(err)); auth.logout(); const token = auth.getToken();
Debug
Known issues
gotchaAuth constructor expects an object with storage and tokenKey; if not provided, defaults to in-memory storage, which loses tokens on page refresh in browser.
fix
Always pass a persistent storage like localStorage as shown in quickstart.
affects: >=0.0.0
breakingVersion 0.0.20 changed login() return type from Promise<string> to Promise<{ user: any; token: string }>.
fix
Update code to expect an object instead of a string: response.token vs response.
affects: >=0.0.20
deprecatedMethod setToken() deprecated since 0.0.22; use updateToken() instead.
fix
Replace setToken() calls with updateToken() with same arguments.
affects: >=0.0.22
Errors
Common errors & fixes
TypeError: Cannot destructure property 'storage' of 'undefined' as it is undefined.
Auth constructor called without an argument (e.g., new Auth()).
fix
Call new Auth({ storage: localStorage, tokenKey: 'token' }) with options object.
Uncaught TypeError: auth.login is not a function
Using default import in a way that resolves to the Auth class itself, but attempting to call without instantiating.
fix
Instantiate Auth first: const auth = new Auth(config); then auth.login(...).
Property 'user' does not exist on type 'string'
Assuming login returns a string after version 0.0.20, which returns an object.
fix
Update TypeScript types: use response.user or response.token.
Upgrade
Version history
0.0.25latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
52 hits · last 30 days
node
46
OpenAI (training)
1
Resources
ankhem-auth — npm install ankhem-auth · libregistry