{"id":18565,"library":"mogh_auth_client","title":"Mogh Auth Client","description":"Mogh Auth Client is a TypeScript library for authenticating with the Mogh authentication service, version 1.3.0. It supports token-based authentication and session management. The package ships with TypeScript types and is intended for use in Node.js or browser environments. It is maintained by the MoghTech team with a focus on security and ease of integration.","status":"active","version":"1.3.0","language":"javascript","source_language":"en","source_url":"https://github.com/moghtech/lib","tags":["javascript","typescript"],"install":[{"cmd":"npm install mogh_auth_client","lang":"bash","label":"npm"},{"cmd":"yarn add mogh_auth_client","lang":"bash","label":"yarn"},{"cmd":"pnpm add mogh_auth_client","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Performing HTTP requests to the Mogh auth server","package":"axios","optional":false}],"imports":[{"note":"Default export not available; must use named import. This is a class that requires instantiation with config.","wrong":"import MoghAuthClient from 'mogh_auth_client'","symbol":"MoghAuthClient","correct":"import { MoghAuthClient } from 'mogh_auth_client'"},{"note":"CommonJS requires destructured require for named export. Only works if package supports CJS.","wrong":"const MoghAuthClient = require('mogh_auth_client')","symbol":"MoghAuthClient","correct":"const { MoghAuthClient } = require('mogh_auth_client')"},{"note":"Type-only import for options interface, available since v1.2.0.","wrong":"","symbol":"MoghAuthClientOptions","correct":"import type { MoghAuthClientOptions } from 'mogh_auth_client'"},{"note":"Constructor requires configuration object with 'apiKey' and 'endpoint'.","wrong":"const client = new MoghAuthClient()","symbol":"MoghAuthClient","correct":"import { MoghAuthClient } from 'mogh_auth_client'"}],"quickstart":{"code":"import { MoghAuthClient } from 'mogh_auth_client';\n\nconst client = new MoghAuthClient({\n  apiKey: process.env.MOGH_API_KEY ?? '',\n  endpoint: 'https://auth.mogh.io/v1'\n});\n\nasync function authenticate() {\n  try {\n    const result = await client.authenticate({\n      username: 'user@example.com',\n      password: 'securepassword'\n    });\n    console.log('Access Token:', result.accessToken);\n  } catch (error) {\n    console.error('Auth failed:', error);\n  }\n}\n\nauthenticate();","lang":"typescript","description":"Creates a MoghAuthClient instance and authenticates a user with email and password, then logs the access token."},"warnings":[{"fix":"Update constructor call: new MoghAuthClient({ apiKey: '...' }) instead of { clientId: '...' }.","message":"In v1.3.0, the constructor options changed: 'apiKey' replaced 'clientId'. Old code using 'clientId' will fail.","severity":"breaking","affected_versions":"<1.3.0"},{"fix":"Replace callbacks with async/await: const result = await client.authenticate(...).","message":"The 'authenticate' method's callback style is deprecated. Use async/await or Promises as of v1.2.0.","severity":"deprecated","affected_versions":">=1.2.0"},{"fix":"Install axios: npm install axios","message":"The package requires axios as a peer dependency but does not list it in 'dependencies' in package.json. If axios is not installed, runtime error occurs.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure endpoint is like 'https://auth.mogh.io/v1' without trailing slash.","message":"The 'endpoint' option must not have a trailing slash. Including it may cause unexpected 404 errors.","severity":"gotcha","affected_versions":">=1.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 axios' in your project.","cause":"Axios is a peer dependency that is not automatically installed.","error":"Error: Cannot find module 'axios'"},{"fix":"Use import { MoghAuthClient } from 'mogh_auth_client'.","cause":"Using default import instead of named import, resulting in undefined class method.","error":"TypeError: client.authenticate is not a function"},{"fix":"Check that the apiKey in constructor is correct and set via environment variable.","cause":"API key is invalid or not provided.","error":"HttpError: 401 Unauthorized"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}