@lornatang/dsh-atlassian 0.1.12 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +1 -1
- package/README.zh.md +1 -1
- package/lib/board.js +7 -1
- package/lib/bridge.js +41 -6
- package/lib/oauth.js +5 -4
- package/lib/open-url.js +2 -1
- package/lib/routes.js +1 -20
- package/lib/types/board.d.ts +7 -1
- package/lib/types/bridge.d.ts +7 -0
- package/lib/types/oauth.d.ts +2 -1
- package/lib/types/routes.d.ts +2 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.14 - 2026-11-19
|
|
4
|
+
|
|
5
|
+
- Reuse the site resolved while connecting for the first Jira board render, removing a duplicate accessibleatlassianresources MCP round-trip; the board still falls back to its own lookup when the cached site is stale.
|
|
6
|
+
|
|
7
|
+
## 0.1.13 - 2026-11-19
|
|
8
|
+
|
|
9
|
+
- Remove a duplicated request-target pre-check left over from the route hardening; malformed URLs still receive the same 400 response.
|
|
10
|
+
- Share one loopback-host predicate between the OAuth callback and the browser helper instead of two copies.
|
|
11
|
+
- Drop the unused OAuth provider logger option, the unused board availability helper and a redundant board options type.
|
|
12
|
+
|
|
3
13
|
## 0.1.12 - 2026-11-18
|
|
4
14
|
|
|
5
15
|
- Re-arm the OAuth callback listener when authorization starts, so a callback port that becomes available after a failed bind no longer leaves the published redirect URI pointing at port 0.
|
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ dsh plugin --profile <name> add @lornatang/dsh-atlassian
|
|
|
34
34
|
dsh plugin --profile <name> remove @lornatang/dsh-atlassian
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
The same release is also attached as an archive on GitHub: `dsh plugin --profile <name> add https://github.com/Lornatang/dsh-atlassian/releases/download/v0.1.
|
|
37
|
+
The same release is also attached as an archive on GitHub: `dsh plugin --profile <name> add https://github.com/Lornatang/dsh-atlassian/releases/download/v0.1.14/lornatang-dsh-atlassian-0.1.14.tgz`.
|
|
38
38
|
|
|
39
39
|
`add` composes the layer into the profile: the profile's `cordis.patch.yml` gains an insert entry with row id `atlassian`, package `@lornatang/dsh-atlassian`, and the five values the shipped patch carries — `mode: cloud`, `serverName: atlassian`, `url: https://mcp.atlassian.com/v1/mcp`, `redirectPort: 3334` and `autoOpenBrowser: true`. The manifest declares `dsh.bundle.patch: ./cordis.patch.yml`, which is the declaration the reconcile step reads; `remove` deletes the entry again. Restart DSH after either command, because the profile composes its rows and its client half only at startup, then open Settings → Atlassian. Releases before 0.1.5 published this package as `@lornatang/dsh-atlassian-bridge`; add the scoped name, remove the old package from the same profile and restart once — the row, its settings and the stored credentials survive.
|
|
40
40
|
|
package/README.zh.md
CHANGED
|
@@ -34,7 +34,7 @@ dsh plugin --profile <name> add @lornatang/dsh-atlassian
|
|
|
34
34
|
dsh plugin --profile <name> remove @lornatang/dsh-atlassian
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
也可以从 GitHub release 附带的压缩包安装同一版本:`dsh plugin --profile <name> add https://github.com/Lornatang/dsh-atlassian/releases/download/v0.1.
|
|
37
|
+
也可以从 GitHub release 附带的压缩包安装同一版本:`dsh plugin --profile <name> add https://github.com/Lornatang/dsh-atlassian/releases/download/v0.1.14/lornatang-dsh-atlassian-0.1.14.tgz`。
|
|
38
38
|
|
|
39
39
|
`add` 会把本层组合进 profile:profile 的 `cordis.patch.yml` 会增加一条 insert 记录,行 id 为 `atlassian`,包名为 `@lornatang/dsh-atlassian`,并带上随包提供的补丁中的五个值——`mode: cloud`、`serverName: atlassian`、`url: https://mcp.atlassian.com/v1/mcp`、`redirectPort: 3334` 与 `autoOpenBrowser: true`。包的 manifest 声明了 `dsh.bundle.patch: ./cordis.patch.yml`,reconcile 步骤读取的正是这条声明;`remove` 会再次删除该记录。两条命令执行后都要重启 DSH,因为 profile 只在启动时组合自己的行与客户端部分,随后打开 Settings → Atlassian。0.1.5 之前的版本以 `@lornatang/dsh-atlassian-bridge` 发布;添加带作用域的新名称、从同一 profile 删除旧包、重启一次即可——行、其设置与已保存的凭据都会保留。
|
|
40
40
|
|
package/lib/board.js
CHANGED
|
@@ -31,7 +31,6 @@ export class JiraBoard {
|
|
|
31
31
|
#resource;
|
|
32
32
|
#pending;
|
|
33
33
|
constructor(bridge) { this.#bridge = bridge; }
|
|
34
|
-
available() { return !!this.#bridge.rawNameMatching(/searchJiraIssuesUsingJql/i); }
|
|
35
34
|
get site() { return this.#resource?.epoch === (this.#bridge.epoch?.() ?? 0) ? this.#resource.site : undefined; }
|
|
36
35
|
async #call(pattern, args, timeoutMs) {
|
|
37
36
|
const name = this.#bridge.rawNameMatching(pattern);
|
|
@@ -60,6 +59,13 @@ export class JiraBoard {
|
|
|
60
59
|
const epoch = this.#bridge.epoch?.() ?? 0;
|
|
61
60
|
if (this.#resource?.epoch === epoch)
|
|
62
61
|
return this.#resource.id;
|
|
62
|
+
// The bridge resolves the same resource while connecting; reuse that result
|
|
63
|
+
// instead of paying a second MCP round-trip on the first board render.
|
|
64
|
+
const shared = this.#bridge.resource?.();
|
|
65
|
+
if (shared && shared.epoch === epoch) {
|
|
66
|
+
this.#resource = { epoch, id: shared.id, base: shared.base, site: shared.site };
|
|
67
|
+
return shared.id;
|
|
68
|
+
}
|
|
63
69
|
if (this.#pending?.epoch === epoch)
|
|
64
70
|
return this.#pending.promise;
|
|
65
71
|
const promise = this.#resolveSite(epoch);
|
package/lib/bridge.js
CHANGED
|
@@ -57,6 +57,7 @@ export class AtlassianBridge {
|
|
|
57
57
|
#refreshes = new Set();
|
|
58
58
|
#waiters = new Set();
|
|
59
59
|
#waiting = false;
|
|
60
|
+
#resource;
|
|
60
61
|
#allowLoopbackHttp;
|
|
61
62
|
constructor(host, options) {
|
|
62
63
|
this.#host = host;
|
|
@@ -184,7 +185,7 @@ export class AtlassianBridge {
|
|
|
184
185
|
throw new Error('atlassian: refresh is already in progress');
|
|
185
186
|
};
|
|
186
187
|
this.#provider = new AtlassianOAuthProvider({
|
|
187
|
-
store: options.store, redirectUri: () => this.#callback.redirectUri, allowLoopbackHttp: network.allowLoopbackHttp,
|
|
188
|
+
store: options.store, redirectUri: () => this.#callback.redirectUri, allowLoopbackHttp: network.allowLoopbackHttp,
|
|
188
189
|
onAuthorizationUrl: (url) => {
|
|
189
190
|
if (!active())
|
|
190
191
|
return;
|
|
@@ -214,6 +215,10 @@ export class AtlassianBridge {
|
|
|
214
215
|
}
|
|
215
216
|
#newOperation() { return { generation: this.#generation, signal: this.#controller.signal }; }
|
|
216
217
|
epoch() { return this.#generation; }
|
|
218
|
+
/** Site resolved during connect, shared with the board to avoid a duplicate MCP call. */
|
|
219
|
+
resource() {
|
|
220
|
+
return this.#resource?.epoch === this.#generation ? this.#resource : undefined;
|
|
221
|
+
}
|
|
217
222
|
#setStatus(status) { this.#status = status; this.#wake(); }
|
|
218
223
|
#setUrl(url) { this.#url = url; this.#wake(); }
|
|
219
224
|
#wake() { const waiters = [...this.#waiters]; this.#waiters.clear(); for (const wake of waiters)
|
|
@@ -328,7 +333,7 @@ export class AtlassianBridge {
|
|
|
328
333
|
check();
|
|
329
334
|
this.#setStatus('connecting');
|
|
330
335
|
this.#error = undefined;
|
|
331
|
-
const client = new Client({ name: 'dsh-atlassian', version: '0.1.
|
|
336
|
+
const client = new Client({ name: 'dsh-atlassian', version: '0.1.14' });
|
|
332
337
|
// Releasing the session lease here would race the SDK's saveTokens; an
|
|
333
338
|
// exchange that is still in flight is released by its own finally block.
|
|
334
339
|
client.onerror = () => { const operation = this.#operation.getStore(); if (operation?.exchangePending)
|
|
@@ -449,11 +454,39 @@ export class AtlassianBridge {
|
|
|
449
454
|
try {
|
|
450
455
|
const result = await client.callTool({ name, arguments: {} }, undefined, { timeout: 20000, signal });
|
|
451
456
|
const items = JSON.parse(display(result.content));
|
|
452
|
-
const
|
|
457
|
+
const list = Array.isArray(items) ? items : [items];
|
|
458
|
+
// Publish the first safe site label for the status snapshot. The board's
|
|
459
|
+
// stricter URL policy decides which entry can act as its cloud resource.
|
|
460
|
+
const first = list[0];
|
|
453
461
|
if (first && typeof first === 'object' && typeof first['url'] === 'string') {
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
462
|
+
try {
|
|
463
|
+
const reported = new URL(first['url']);
|
|
464
|
+
secureUrl(reported, this.#allowLoopbackHttp);
|
|
465
|
+
await this.#options.store.patch({ site: reported.host }, () => !this.#disposed && generation === this.#generation && !signal.aborted, undefined, undefined, signal);
|
|
466
|
+
}
|
|
467
|
+
catch { /* The status label is optional; the board still validates URLs itself. */ }
|
|
468
|
+
}
|
|
469
|
+
for (const item of list) {
|
|
470
|
+
if (!item || typeof item !== 'object')
|
|
471
|
+
continue;
|
|
472
|
+
const entry = item;
|
|
473
|
+
const id = entry['id'];
|
|
474
|
+
const url = entry['url'];
|
|
475
|
+
if (typeof id !== 'string' || !id || typeof url !== 'string' || !url)
|
|
476
|
+
continue;
|
|
477
|
+
let parsed;
|
|
478
|
+
try {
|
|
479
|
+
parsed = new URL(url);
|
|
480
|
+
if (!['http:', 'https:'].includes(parsed.protocol) || parsed.username || parsed.password)
|
|
481
|
+
continue;
|
|
482
|
+
}
|
|
483
|
+
catch {
|
|
484
|
+
continue;
|
|
485
|
+
}
|
|
486
|
+
if (!this.#disposed && generation === this.#generation && !signal.aborted) {
|
|
487
|
+
this.#resource = { epoch: generation, id, base: `${parsed.origin}${parsed.pathname.replace(/\/$/, '')}`, site: parsed.host };
|
|
488
|
+
}
|
|
489
|
+
break;
|
|
457
490
|
}
|
|
458
491
|
}
|
|
459
492
|
catch { /* The connection can work without a site label. */ }
|
|
@@ -468,6 +501,7 @@ export class AtlassianBridge {
|
|
|
468
501
|
}
|
|
469
502
|
async disconnect() {
|
|
470
503
|
this.#generation++;
|
|
504
|
+
this.#resource = undefined;
|
|
471
505
|
this.#controller.abort();
|
|
472
506
|
this.#controller = new AbortController();
|
|
473
507
|
this.#setStatus('idle');
|
|
@@ -488,6 +522,7 @@ export class AtlassianBridge {
|
|
|
488
522
|
return;
|
|
489
523
|
this.#disposed = true;
|
|
490
524
|
this.#generation++;
|
|
525
|
+
this.#resource = undefined;
|
|
491
526
|
this.#controller.abort();
|
|
492
527
|
this.#setStatus('idle');
|
|
493
528
|
this.#callback.cancelWait();
|
package/lib/oauth.js
CHANGED
|
@@ -75,17 +75,18 @@ function limitCloudResponse(response, allowEvents) {
|
|
|
75
75
|
});
|
|
76
76
|
return limited;
|
|
77
77
|
}
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
/** Loopback hosts may use plain HTTP for local MCP and OAuth endpoints. */
|
|
79
|
+
export function isLoopbackHost(hostname) {
|
|
80
|
+
return ['localhost', '127.0.0.1', '[::1]'].includes(hostname);
|
|
80
81
|
}
|
|
81
82
|
export function secureUrl(url, allowLoopbackHttp) {
|
|
82
|
-
if (url.username || url.password || (url.protocol !== 'https:' && !(allowLoopbackHttp && url.protocol === 'http:' &&
|
|
83
|
+
if (url.username || url.password || (url.protocol !== 'https:' && !(allowLoopbackHttp && url.protocol === 'http:' && isLoopbackHost(url.hostname)))) {
|
|
83
84
|
throw new Error('Cloud and OAuth endpoints must use HTTPS without embedded credentials');
|
|
84
85
|
}
|
|
85
86
|
}
|
|
86
87
|
/** Restrict every discovered OAuth and MCP endpoint, including redirect targets. */
|
|
87
88
|
export function createCloudFetch(serverUrl) {
|
|
88
|
-
const allowLoopbackHttp = serverUrl.protocol === 'http:' &&
|
|
89
|
+
const allowLoopbackHttp = serverUrl.protocol === 'http:' && isLoopbackHost(serverUrl.hostname);
|
|
89
90
|
secureUrl(serverUrl, allowLoopbackHttp);
|
|
90
91
|
return {
|
|
91
92
|
allowLoopbackHttp,
|
package/lib/open-url.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
|
+
import { isLoopbackHost } from './oauth.js';
|
|
2
3
|
/** Open a browser without invoking a shell. */
|
|
3
4
|
export function openInBrowser(value) {
|
|
4
5
|
let url;
|
|
@@ -8,7 +9,7 @@ export function openInBrowser(value) {
|
|
|
8
9
|
catch {
|
|
9
10
|
return Promise.resolve(false);
|
|
10
11
|
}
|
|
11
|
-
if (url.protocol !== 'https:' && !(url.protocol === 'http:' &&
|
|
12
|
+
if (url.protocol !== 'https:' && !(url.protocol === 'http:' && isLoopbackHost(url.hostname))) {
|
|
12
13
|
return Promise.resolve(false);
|
|
13
14
|
}
|
|
14
15
|
const command = process.platform === 'win32' ? 'rundll32.exe' : process.platform === 'darwin' ? 'open' : 'xdg-open';
|
package/lib/routes.js
CHANGED
|
@@ -50,25 +50,6 @@ function required(input, key) {
|
|
|
50
50
|
}
|
|
51
51
|
export function registerRoutes(web, bridge, board, options, fence, connection) {
|
|
52
52
|
return web.register({ kind: 'prefix', path: ROUTE_PREFIX, handler: async (req, res) => {
|
|
53
|
-
if (!fence) {
|
|
54
|
-
respond(res, 503, { ok: false, error: 'DSH connection service is unavailable' });
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const rejection = fence.requestRejection(req);
|
|
58
|
-
if (rejection !== undefined) {
|
|
59
|
-
res.writeHead(rejection).end();
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
let url;
|
|
63
|
-
try {
|
|
64
|
-
url = new URL(req.url ?? '/', 'http://localhost');
|
|
65
|
-
}
|
|
66
|
-
catch {
|
|
67
|
-
respond(res, 400, { ok: false, code: 'bad-request', error: 'Invalid request URL' });
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
const action = url.pathname.slice(ROUTE_PREFIX.length).replace(/^\//, '');
|
|
71
|
-
const method = req.method ?? 'GET';
|
|
72
53
|
try {
|
|
73
54
|
if (!fence) {
|
|
74
55
|
respond(res, 503, { ok: false, error: 'DSH connection service is unavailable' });
|
|
@@ -84,7 +65,7 @@ export function registerRoutes(web, bridge, board, options, fence, connection) {
|
|
|
84
65
|
url = new URL(req.url ?? '/', 'http://localhost');
|
|
85
66
|
}
|
|
86
67
|
catch {
|
|
87
|
-
respond(res, 400, { ok: false, error: '
|
|
68
|
+
respond(res, 400, { ok: false, error: 'Invalid request URL' });
|
|
88
69
|
return;
|
|
89
70
|
}
|
|
90
71
|
const action = url.pathname.slice(ROUTE_PREFIX.length).replace(/^\//, '');
|
package/lib/types/board.d.ts
CHANGED
|
@@ -7,6 +7,13 @@ export interface ToolBridge {
|
|
|
7
7
|
};
|
|
8
8
|
/** Changes whenever the connection is replaced, so cached site data can be invalidated. */
|
|
9
9
|
epoch?(): number;
|
|
10
|
+
/** Site resolved while connecting, so the first board render need not repeat that MCP call. */
|
|
11
|
+
resource?(): {
|
|
12
|
+
epoch: number;
|
|
13
|
+
id: string;
|
|
14
|
+
base: string;
|
|
15
|
+
site: string;
|
|
16
|
+
} | undefined;
|
|
10
17
|
}
|
|
11
18
|
export interface BoardStatus {
|
|
12
19
|
name: string;
|
|
@@ -63,7 +70,6 @@ export declare class BoardError extends Error {
|
|
|
63
70
|
export declare class JiraBoard {
|
|
64
71
|
#private;
|
|
65
72
|
constructor(bridge: ToolBridge);
|
|
66
|
-
available(): boolean;
|
|
67
73
|
get site(): string | undefined;
|
|
68
74
|
cloudId(): Promise<string>;
|
|
69
75
|
load(query: BoardQuery): Promise<BoardPayload>;
|
package/lib/types/bridge.d.ts
CHANGED
|
@@ -37,6 +37,13 @@ export declare class AtlassianBridge {
|
|
|
37
37
|
#private;
|
|
38
38
|
constructor(host: BridgeHost, options: BridgeOptions);
|
|
39
39
|
epoch(): number;
|
|
40
|
+
/** Site resolved during connect, shared with the board to avoid a duplicate MCP call. */
|
|
41
|
+
resource(): {
|
|
42
|
+
epoch: number;
|
|
43
|
+
id: string;
|
|
44
|
+
base: string;
|
|
45
|
+
site: string;
|
|
46
|
+
} | undefined;
|
|
40
47
|
snapshot(): BridgeSnapshot;
|
|
41
48
|
rawNames(): readonly string[];
|
|
42
49
|
rawNameMatching(pattern: RegExp): string | undefined;
|
package/lib/types/oauth.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export interface AuthorizationCallback {
|
|
|
13
13
|
}
|
|
14
14
|
export declare class RedirectRegistrationChanged extends Error {
|
|
15
15
|
}
|
|
16
|
+
/** Loopback hosts may use plain HTTP for local MCP and OAuth endpoints. */
|
|
17
|
+
export declare function isLoopbackHost(hostname: string): boolean;
|
|
16
18
|
export declare function secureUrl(url: URL, allowLoopbackHttp: boolean): void;
|
|
17
19
|
/** Restrict every discovered OAuth and MCP endpoint, including redirect targets. */
|
|
18
20
|
export declare function createCloudFetch(serverUrl: URL): {
|
|
@@ -35,7 +37,6 @@ export declare class AtlassianOAuthProvider implements OAuthClientProvider {
|
|
|
35
37
|
redirectUri: () => string;
|
|
36
38
|
onAuthorizationUrl: (url: string) => void;
|
|
37
39
|
allowLoopbackHttp: boolean;
|
|
38
|
-
logger: Logger;
|
|
39
40
|
active?: () => boolean;
|
|
40
41
|
tokenRead?: (tokens: OAuthTokens | undefined) => void;
|
|
41
42
|
refreshExpected?: () => OAuthTokens | undefined;
|
package/lib/types/routes.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
2
|
import type { BridgeSnapshot } from './bridge.js';
|
|
3
|
+
import type { BoardConfig } from './config.js';
|
|
3
4
|
import { type JiraBoard, type ToolBridge } from './board.js';
|
|
4
5
|
export declare const ROUTE_PREFIX = "/plugins/atlassian";
|
|
5
6
|
export interface RouteRegistrar {
|
|
@@ -12,12 +13,6 @@ export interface RouteRegistrar {
|
|
|
12
13
|
export interface RequestFence {
|
|
13
14
|
requestRejection(req: IncomingMessage): number | undefined;
|
|
14
15
|
}
|
|
15
|
-
export interface BoardRouteOptions {
|
|
16
|
-
jql: string;
|
|
17
|
-
limit: number;
|
|
18
|
-
timeoutMs: number;
|
|
19
|
-
promptTemplate: string;
|
|
20
|
-
}
|
|
21
16
|
export interface EditableConnection {
|
|
22
17
|
snapshot(): {
|
|
23
18
|
jiraUrl: string;
|
|
@@ -36,4 +31,4 @@ export interface PluginBridge extends ToolBridge {
|
|
|
36
31
|
start(): Promise<void>;
|
|
37
32
|
dispose(): Promise<void>;
|
|
38
33
|
}
|
|
39
|
-
export declare function registerRoutes(web: RouteRegistrar, bridge: PluginBridge, board: JiraBoard, options:
|
|
34
|
+
export declare function registerRoutes(web: RouteRegistrar, bridge: PluginBridge, board: JiraBoard, options: BoardConfig, fence: RequestFence | undefined, connection?: EditableConnection): () => void;
|
package/package.json
CHANGED