Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 72 additions & 16 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
"format": "biome check --write --formatter-enabled=true --assist-enabled=true ",
"version": "changeset version",
"release": "bun run build:packages && changeset publish",
"build:packages": "bun run build:sdk && bun run build:gateway && bun run build:pm2 && bun run build:cron && bun run build:linear && bun run build:telegram && bun run build:cli",
"build:packages": "bun run build:sdk && bun run build:gateway && bun run build:pm2 && bun run build:cron && bun run build:linear && bun run build:jira && bun run build:telegram && bun run build:cli",
"build:linear": "cd packages/linear && bun run build",
"build:jira": "cd packages/jira && bun run build",
"build:cron": "cd packages/cron && bun run build",
"build:sdk": "cd packages/sdk && bun run build",
"build:gateway": "cd packages/gateway && bun run build",
Expand Down
47 changes: 47 additions & 0 deletions packages/jira/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "@locusai/locus-jira",
"version": "0.1.0",
"description": "Fetch and execute Jira issues with Locus",
"type": "module",
"bin": {
"locus-jira": "./bin/locus-jira.js"
},
"files": [
"bin",
"package.json",
"README.md"
],
"locus": {
"displayName": "Jira",
"description": "Fetch and execute Jira issues with Locus",
"commands": [
"jira"
],
"version": "0.1.0"
},
"scripts": {
"build": "bun build src/cli.ts --outfile bin/locus-jira.js --target node",
"typecheck": "tsc --noEmit",
"lint": "biome lint .",
"format": "biome format --write .",
"clean": "rm -rf dist bin node_modules"
},
"dependencies": {
"@locusai/sdk": "^0.26.1",
"axios": "^1.7.0",
"open": "^10.0.0"
},
"devDependencies": {
"@types/node": "^22.0.0",
"typescript": "^5.7.0"
},
"keywords": [
"locusai-package",
"locus",
"jira"
],
"engines": {
"node": ">=18"
},
"license": "MIT"
}
67 changes: 67 additions & 0 deletions packages/jira/src/auth/api-token.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* API Token authentication for Jira Cloud.
*
* Prompts the user for instance URL, email, and API token,
* then validates by calling GET /rest/api/3/myself with Basic auth.
*/

import axios from "axios";
import { handleJiraError } from "../errors.js";
import type { JiraApiTokenCredentials } from "../types.js";
import { normalizeUrl, prompt } from "./prompt.js";

/**
* Interactively prompt the user for Jira Cloud API token credentials
* and validate them by calling the /rest/api/3/myself endpoint.
*/
export async function promptForApiToken(): Promise<JiraApiTokenCredentials> {
process.stderr.write("\n Jira Cloud — API Token Authentication\n\n");

const rawUrl = await prompt(
" Jira instance URL (e.g. https://myteam.atlassian.net): "
);
if (!rawUrl) {
throw new Error("Instance URL is required.");
}
const baseUrl = normalizeUrl(rawUrl);

const email = await prompt(" Email: ");
if (!email) {
throw new Error("Email is required.");
}

const apiToken = await prompt(" API token: ", true);
if (!apiToken) {
throw new Error("API token is required.");
}

process.stderr.write(" Validating credentials...\n");

const encoded = Buffer.from(`${email}:${apiToken}`).toString("base64");

try {
const response = await axios.get(`${baseUrl}/rest/api/3/myself`, {
headers: {
Authorization: `Basic ${encoded}`,
Accept: "application/json",
},
timeout: 15_000,
});

const displayName =
(response.data as Record<string, unknown>)?.displayName ?? email;
process.stderr.write(` Authenticated as: ${displayName}\n\n`);
} catch (error) {
if (axios.isAxiosError(error)) {
handleJiraError(error);
}
throw error;
}

return {
method: "api-token",
email,
apiToken,
baseUrl,
};
}
Loading