Registry / auth-security / askit-auth-sdk

askit-auth-sdk

JSON →
library1.0.0jsnpmunverified

Client SDK for the ASK IT Auth Server — a lightweight, fully-typed TypeScript library that wraps the Auth Server REST API. It provides easy authentication flows (login, register, email verification, password reset) with automatic JWT token management and role helpers. v1.0.0 is the current stable version, released as a single package with no dependencies. Works in Node.js, browsers, and modern JavaScript runtimes. Key differentiators: ESM-only, built-in token storage, explicit error handling via AuthError class, and TypeScript-first design.

npm install askit-auth-sdk
INSTALL
IMPORT
SIG · ASKIT-AUTH-SDK
A
askit-auth-sdk
auth-securityjavascriptv1.0.0
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.

AskITAuth
import { AskITAuth } from '@askit/auth-sdk'
const AskITAuth = require('@askit/auth-sdk')
ESM-only package; CommonJS require will fail.
AuthError
import { AuthError } from '@askit/auth-sdk'
import AuthError from '@askit/auth-sdk'
AuthError is a named export, not default.
AskITAuth (type)
import type { AskITAuth } from '@askit/auth-sdk'
import { AskITAuth } from '@askit/auth-sdk' // if only type needed
For type-only imports, use `import type` to avoid runtime overhead.
AuthUser (type)
import type { AuthUser } from '@askit/auth-sdk'
const AuthUser = require('@askit/auth-sdk').AuthUser
AuthUser is a TypeScript interface, not a runtime value.

Creates an AskITAuth client, logs in with email/password, stores the JWT automatically, and retrieves the current user profile.

import { AskITAuth } from '@askit/auth-sdk'; const auth = new AskITAuth({ baseUrl: 'https://auth.askaihk.com', }); async function main() { const { token, user } = await auth.login({ email: 'murphy.lai@askit.com.hk', password: 'myPassword123', }); console.log(`Welcome, ${user.full_name}!`); console.log(`Role: ${user.role}`); const me = await auth.me(); console.log(me.email); } main().catch(console.error);
Debug
Known issues
gotchaAfter login, the JWT is stored in-memory by default. It is not persisted to localStorage or cookies automatically.
fix
Manually call auth.setToken(token) with a stored token on app load, or implement your own persistence layer.
affects: >=1.0.0
gotchaThe baseUrl must not end with a trailing slash. The SDK does not normalize URLs.
fix
Ensure the baseUrl does not end with '/'. Example: 'https://auth.askaihk.com', not 'https://auth.askaihk.com/'.
affects: >=1.0.0
breakingIn v1.0.0, the AuthError class was introduced. In the beta version, errors were plain Error objects.
fix
Update to v1.0.0 and catch AuthError instead of Error for API errors.
affects: <1.0.0
deprecatedThe `askit-auth-sdk` package (without scope) is deprecated. Use `@askit/auth-sdk` instead.
fix
Uninstall 'askit-auth-sdk' and install '@askit/auth-sdk'.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module '@askit/auth-sdk' or its corresponding type declarations.
Package not installed or TypeScript not configured to resolve scoped packages.
fix
Run `npm install @askit/auth-sdk` and ensure tsconfig.json includes `"moduleResolution": "node"` or `"bundler"`.
TypeError: (0 , _askit_auth_sdk.AskITAuth) is not a constructor
Using CommonJS require() on an ESM-only package.
fix
Change `const AskITAuth = require('@askit/auth-sdk')` to `import { AskITAuth } from '@askit/auth-sdk'`.
Property 'login' does not exist on type 'typeof import("...")'.
Attempting to call AskITAuth.login as a static method instead of creating an instance.
fix
Create an instance first: `const auth = new AskITAuth({ baseUrl: '...' });` then call `auth.login(...)`.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
29 hits · last 30 days
node
24
Amazon
1
OpenAI (training)
1
Resources
askit-auth-sdk — npm install askit-auth-sdk · libregistry