{"id":18635,"library":"opencode-copilot-auth","title":"OpenCode Copilot Auth","description":"Provides authentication utilities for OpenCode Copilot, an AI-powered code assistant. Version 0.0.12 is the latest. The package handles JWT token management and GitHub App authentication flows. It is designed for Node.js environments and supports both CommonJS and ESM. It simplifies the process of obtaining and validating access tokens for Copilot services.","status":"active","version":"0.0.12","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install opencode-copilot-auth","lang":"bash","label":"npm"},{"cmd":"yarn add opencode-copilot-auth","lang":"bash","label":"yarn"},{"cmd":"pnpm add opencode-copilot-auth","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default export also available.","symbol":"AuthClient","correct":"import { AuthClient } from 'opencode-copilot-auth'"},{"note":"Package supports CJS require, but named imports are preferred.","wrong":"const getToken = require('opencode-copilot-auth').getToken","symbol":"getToken","correct":"import { getToken } from 'opencode-copilot-auth'"},{"note":"Used to validate JWT tokens.","symbol":"verifyToken","correct":"import { verifyToken } from 'opencode-copilot-auth'"}],"quickstart":{"code":"import { AuthClient, getToken } from 'opencode-copilot-auth';\n\nconst client = new AuthClient({\n  appId: process.env.APP_ID ?? '',\n  privateKey: process.env.PRIVATE_KEY ?? '',\n});\n\nconst token = await getToken({\n  installationId: process.env.INSTALLATION_ID ?? '',\n  client,\n});\n\nconsole.log(token);","lang":"typescript","description":"Initializes an AuthClient with environment variables and retrieves a token for a GitHub App installation."},"warnings":[{"fix":"Ensure Node version is >=14.","message":"Requires Node.js 14 or higher due to use of ES2020 features.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Use `process.env.PRIVATE_KEY.replace(/\\\\n/g, '\\n')` or store as base64.","message":"Private key must be in PEM format with escaped newlines if passed as environment variable.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Use `getToken({ installationId, client })` instead.","message":"The `getInstallationToken` method is deprecated in favor of `getToken`.","severity":"deprecated","affected_versions":">=0.0.10"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure private key is a valid RSA private key in PEM format with proper \\n characters.","cause":"Private key is not in correct PEM format or has incorrect line endings.","error":"Error: Unable to parse private key: openssl error"},{"fix":"Use `new AuthClient(opts)` and pass it as `client` parameter to `getToken`.","cause":"AuthClient instance not properly initialized or wrong import.","error":"TypeError: client.getToken is not a function"},{"fix":"Check that `getToken` returned a valid token and that it is passed correctly.","cause":"Token string is not a valid JWT or is undefined.","error":"Error: Invalid JWT: jwt malformed"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}