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
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
MoghAuthClient
✓ import { MoghAuthClient } from 'mogh_auth_client'
✗ import MoghAuthClient from 'mogh_auth_client'
Default export not available; must use named import. This is a class that requires instantiation with config.
MoghAuthClient
✓ const { MoghAuthClient } = require('mogh_auth_client')
✗ const MoghAuthClient = require('mogh_auth_client')
CommonJS requires destructured require for named export. Only works if package supports CJS.
MoghAuthClientOptions
✓ import type { MoghAuthClientOptions } from 'mogh_auth_client'
Type-only import for options interface, available since v1.2.0.
MoghAuthClient
✓ import { MoghAuthClient } from 'mogh_auth_client'
✗ const client = new MoghAuthClient()
Constructor requires configuration object with 'apiKey' and 'endpoint'.
Creates a MoghAuthClient instance and authenticates a user with email and password, then logs the access token.
import { MoghAuthClient } from 'mogh_auth_client';
const client = new MoghAuthClient({
apiKey: process.env.MOGH_API_KEY ?? '',
endpoint: 'https://auth.mogh.io/v1'
});
async function authenticate() {
try {
const result = await client.authenticate({
username: 'user@example.com',
password: 'securepassword'
});
console.log('Access Token:', result.accessToken);
} catch (error) {
console.error('Auth failed:', error);
}
}
authenticate();
Errors
Common errors & fixes
Error: Cannot find module 'axios'
Axios is a peer dependency that is not automatically installed.
fixRun 'npm install axios' in your project.
TypeError: client.authenticate is not a function
Using default import instead of named import, resulting in undefined class method.
fixUse import { MoghAuthClient } from 'mogh_auth_client'. HttpError: 401 Unauthorized
API key is invalid or not provided.
fixCheck that the apiKey in constructor is correct and set via environment variable.
Audit
Dependencies
axiosrequiredPerforming HTTP requests to the Mogh auth server