
Security News
/Research
Popular node-ipc npm Package Infected with Credential Stealer
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.
jira-client-oauth2
Advanced tools
A modern, promise-based, and fully-typed TypeScript client for the Jira Cloud REST API, using OAuth 2.0 (3LO) for authentication.
This library simplifies interactions with the Jira API by providing a clean, intuitive interface for common operations like creating issues, searching with JQL, managing projects, and more. It handles the underlying Axios requests, error handling, and API endpoints, so you can focus on your application logic.
JiraApiError with detailed information.npm install jira-client-oauth2
To use the client, you first need to obtain an accessToken and cloudId from your Jira OAuth 2.0 flow.
cloudId by making a GET request to https://api.atlassian.com/oauth/token/accessible-resources with a valid access token.import { JiraOAuth2Client } from 'jira-client-oauth2';
// Configuration with your credentials
const config = {
accessToken: 'YOUR_ACCESS_TOKEN',
cloudId: 'YOUR_CLOUD_ID',
};
const jiraClient = new JiraOAuth2Client(config);
async function main() {
try {
// Get the current user's profile
const currentUser = await jiraClient.getCurrentUser();
console.log(`Successfully authenticated as: ${currentUser.displayName}`);
// Create a new issue
const newIssue = await jiraClient.createIssue({
fields: {
project: {
key: 'PROJ',
},
summary: 'This is a test issue from my app!',
issuetype: {
name: 'Task',
},
description: {
type: 'doc',
version: 1,
content: [
{
type: 'paragraph',
content: [
{
type: 'text',
text: 'This is the issue description.',
},
],
},
],
},
},
});
console.log(`Created issue: ${newIssue.self}`);
// Search for all 'Bugs' in a project
const searchResults = await jiraClient.searchIssues('project = "PROJ" AND issuetype = Bug');
console.log(`Found ${searchResults.total} bugs.`);
} catch (error) {
console.error('An error occurred:', error.message);
// The error object has more details if it's a JiraApiError
if (error.isJiraApiError) {
console.error('Jira API Error Details:', error.details);
}
}
}
main();
OAuth 2.0 access tokens expire. When you refresh your token, you can easily update the client instance to use the new one for all subsequent requests.
// Assume you have a function to refresh your OAuth token
const newAccessToken = await refreshMyOAuthToken();
// Update the client instance
jiraClient.setAccessToken(newAccessToken);
// All future calls will use the new token
const issue = await jiraClient.getIssue('PROJ-123');
The client is organized into logical sections based on the Jira API structure.
createIssue(issueData): Creates a new issue.getIssue(issueKey, expand?): Retrieves an issue by its key.updateIssue(issueKey, updateData): Updates an issue's fields.updateAssignee(issueKey, accountId): Changes the assignee of an issue.deleteIssue(issueKey): Permanently deletes an issue.searchIssues(jql, options?): Searches for issues using a JQL query.getEpics(projectKey): A helper to find all Epics in a project.addAttachment(issueKey, filePath): Attaches a file to an issue.linkIssues(linkRequest): Creates a link between two issues.getTransitions(issueKey): Lists the available workflow transitions for an issue.transitionIssue(issueKey, transitionId, fields?, comment?): Moves an issue to a new status.getProjects(): Retrieves all projects visible to the user.createProject(projectData): Creates a new project (requires admin permissions).getIssueTypeScheme(projectKey): Gets the issue type scheme for a project.getWorkflowScheme(projectKey): Gets the workflow scheme for a project.getAllBoards(startAt?, maxResults?): Retrieves all Agile boards.getIssuesForBoard(boardId, options?): Retrieves issues for a specific board.getCurrentUser(): Retrieves the profile of the authenticated user.The client throws a custom JiraApiError when an API request fails. This error object contains detailed information to help with debugging:
.message: A user-friendly error summary..status: The HTTP status code of the response (e.g., 404)..statusText: The HTTP status text (e.g., "Not Found")..details: The original error payload from the Jira API..isJiraApiError: A boolean flag (true) to easily identify this error type.Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
This project is MIT licensed.
FAQs
Jira client class with OAuth2.0 support.
We found that jira-client-oauth2 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
/Research
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.

Security News
TeamPCP and BreachForums are promoting a Shai-Hulud supply chain attack contest with a $1,000 prize for the biggest package compromise.

Security News
Packagist urges PHP projects to update Composer after a GitHub token format change exposed some GitHub Actions tokens in CI logs.