{"id":18125,"library":"askit-auth-sdk","title":"@askit/auth-sdk","description":"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.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","askit","auth","authentication","jwt","sdk","typescript"],"install":[{"cmd":"npm install askit-auth-sdk","lang":"bash","label":"npm"},{"cmd":"yarn add askit-auth-sdk","lang":"bash","label":"yarn"},{"cmd":"pnpm add askit-auth-sdk","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only package; CommonJS require will fail.","wrong":"const AskITAuth = require('@askit/auth-sdk')","symbol":"AskITAuth","correct":"import { AskITAuth } from '@askit/auth-sdk'"},{"note":"AuthError is a named export, not default.","wrong":"import AuthError from '@askit/auth-sdk'","symbol":"AuthError","correct":"import { AuthError } from '@askit/auth-sdk'"},{"note":"For type-only imports, use `import type` to avoid runtime overhead.","wrong":"import { AskITAuth } from '@askit/auth-sdk' // if only type needed","symbol":"AskITAuth (type)","correct":"import type { AskITAuth } from '@askit/auth-sdk'"},{"note":"AuthUser is a TypeScript interface, not a runtime value.","wrong":"const AuthUser = require('@askit/auth-sdk').AuthUser","symbol":"AuthUser (type)","correct":"import type { AuthUser } from '@askit/auth-sdk'"}],"quickstart":{"code":"import { AskITAuth } from '@askit/auth-sdk';\n\nconst auth = new AskITAuth({\n  baseUrl: 'https://auth.askaihk.com',\n});\n\nasync function main() {\n  const { token, user } = await auth.login({\n    email: 'murphy.lai@askit.com.hk',\n    password: 'myPassword123',\n  });\n\n  console.log(`Welcome, ${user.full_name}!`);\n  console.log(`Role: ${user.role}`);\n\n  const me = await auth.me();\n  console.log(me.email);\n}\n\nmain().catch(console.error);","lang":"typescript","description":"Creates an AskITAuth client, logs in with email/password, stores the JWT automatically, and retrieves the current user profile."},"warnings":[{"fix":"Manually call auth.setToken(token) with a stored token on app load, or implement your own persistence layer.","message":"After login, the JWT is stored in-memory by default. It is not persisted to localStorage or cookies automatically.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure the baseUrl does not end with '/'. Example: 'https://auth.askaihk.com', not 'https://auth.askaihk.com/'.","message":"The baseUrl must not end with a trailing slash. The SDK does not normalize URLs.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Update to v1.0.0 and catch AuthError instead of Error for API errors.","message":"In v1.0.0, the AuthError class was introduced. In the beta version, errors were plain Error objects.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Uninstall 'askit-auth-sdk' and install '@askit/auth-sdk'.","message":"The `askit-auth-sdk` package (without scope) is deprecated. Use `@askit/auth-sdk` instead.","severity":"deprecated","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run `npm install @askit/auth-sdk` and ensure tsconfig.json includes `\"moduleResolution\": \"node\"` or `\"bundler\"`.","cause":"Package not installed or TypeScript not configured to resolve scoped packages.","error":"Cannot find module '@askit/auth-sdk' or its corresponding type declarations."},{"fix":"Change `const AskITAuth = require('@askit/auth-sdk')` to `import { AskITAuth } from '@askit/auth-sdk'`.","cause":"Using CommonJS require() on an ESM-only package.","error":"TypeError: (0 , _askit_auth_sdk.AskITAuth) is not a constructor"},{"fix":"Create an instance first: `const auth = new AskITAuth({ baseUrl: '...' });` then call `auth.login(...)`.","cause":"Attempting to call AskITAuth.login as a static method instead of creating an instance.","error":"Property 'login' does not exist on type 'typeof import(\"...\")'."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}