@antasphere/cli-core 0.1.0 → 0.3.0
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/README.md +41 -7
- package/dist/config.d.ts +41 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +54 -0
- package/dist/config.js.map +1 -1
- package/dist/connect-on-demand.d.ts +114 -0
- package/dist/connect-on-demand.d.ts.map +1 -0
- package/dist/connect-on-demand.js +130 -0
- package/dist/connect-on-demand.js.map +1 -0
- package/dist/connect.d.ts +109 -0
- package/dist/connect.d.ts.map +1 -0
- package/dist/connect.js +79 -0
- package/dist/connect.js.map +1 -0
- package/dist/index.d.ts +14 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/dist/org.d.ts +42 -0
- package/dist/org.d.ts.map +1 -0
- package/dist/org.js +39 -0
- package/dist/org.js.map +1 -0
- package/package.json +2 -2
- package/src/config.ts +84 -0
- package/src/connect-on-demand.ts +250 -0
- package/src/connect.ts +166 -0
- package/src/index.ts +33 -5
- package/src/org.ts +73 -0
package/README.md
CHANGED
|
@@ -65,6 +65,40 @@ expiresInDays?, workspaceId? })` (the full key appears exactly once),
|
|
|
65
65
|
with `status`/`code`/`message`.
|
|
66
66
|
- `CliIo` + `ask` + `printJson` — the injectable I/O seam (env, streams,
|
|
67
67
|
fetch, interactive prompt) so tool CLIs run in-process under test.
|
|
68
|
+
- `CliConnectClient({ hubBaseUrl, toolBaseUrl })` — the cross-tool connect
|
|
69
|
+
exchange (binding patterns §7, gcloud model — one hub login serves every
|
|
70
|
+
federated tool): `toolToken(hubApiKey, { resource, workspaceId? })` asks
|
|
71
|
+
the hub for a 120 s single-org JWT, `cliConnect(token)` trades it at the
|
|
72
|
+
tool for a tool-local key (no auth header — the JWT is the credential),
|
|
73
|
+
`exchange(hubApiKey, body)` composes both; the hub key never reaches the
|
|
74
|
+
tool. Errors are `CliConnectError` (a `CliAuthError`) tagged with the
|
|
75
|
+
failing `stage` plus the two remedies: `needsHubLogin` (hub 401, or 403
|
|
76
|
+
`insufficient_scope` from a pre-`sso:exchange` key) and `needsReExchange`
|
|
77
|
+
(tool 401 on an expired/replayed JWT).
|
|
78
|
+
- `lookupWorkspaceKey / storeWorkspaceKey / removeWorkspaceKey` — the
|
|
79
|
+
per-(tool, HUB org) cache of exchange-minted keys, held in the tool
|
|
80
|
+
profile's additive `workspaceKeys` map. The legacy single `apiKey` keeps
|
|
81
|
+
working unchanged and answers an org lookup only when the profile says it
|
|
82
|
+
is bound to exactly that workspace.
|
|
83
|
+
- `connectOnDemand({ tool, toolBaseUrl, resource?, org?, profileName?, env,
|
|
84
|
+
fetch?, notify?, messages? })` + `probeToolInstance(toolBaseUrl, fetch?)`
|
|
85
|
+
— the connect-on-demand seam a tool CLI runs when NO direct credential
|
|
86
|
+
resolved (extracted from the Slideless CLI): the anonymous `GET
|
|
87
|
+
/instance` probe gates the flow (only an Antasphere-cloud instance takes
|
|
88
|
+
it — self-hosted/unreachable ones answer `{ outcome: 'not_cloud' }` and
|
|
89
|
+
the tool raises its classic no-key error unchanged), the hub credential
|
|
90
|
+
is read from the `HUB_TOOL` profile, `exchange` runs with one
|
|
91
|
+
re-exchange retry on a dead 120 s JWT (missing/rejected hub login →
|
|
92
|
+
guided `antasphere login` `CliUsageError`), and the minted key is cached
|
|
93
|
+
per (tool, hub org) with first-contact baseUrl pinning — never onto a
|
|
94
|
+
profile that names another instance. `notify` receives the human
|
|
95
|
+
"Connected to …" notice (wire your stderr); `messages` overrides the
|
|
96
|
+
branded copy (defaults reproduce the Slideless strings modulo tool
|
|
97
|
+
name). Success: `{ outcome: 'connected', key, result, cached }`.
|
|
98
|
+
- `getActiveWorkspace / setActiveWorkspace / resolveTargetWorkspace (env)` —
|
|
99
|
+
hub-profile org context: what `antasphere org use` reads/writes
|
|
100
|
+
(`activeWorkspaceId` on the hub profile), and the exchange-target order
|
|
101
|
+
`--org` override → active org → the hub key's bound workspace.
|
|
68
102
|
- `migrateLegacyConfig(env, { tool, legacyDir })` — one-shot, non-destructive
|
|
69
103
|
import of a tool's pre-cli-core `$XDG_CONFIG_HOME/<legacyDir>/config.json`
|
|
70
104
|
into the shared home. Imports only when the tool has no profiles in the
|
|
@@ -117,7 +151,7 @@ with no npm token — npm authenticates the workflow's OIDC identity directly.
|
|
|
117
151
|
|
|
118
152
|
```bash
|
|
119
153
|
# bump package.json#version, commit, then:
|
|
120
|
-
git tag v0.
|
|
154
|
+
git tag v0.3.0 && git push origin v0.3.0
|
|
121
155
|
```
|
|
122
156
|
|
|
123
157
|
**First publish is manual.** Trusted publishing can only be configured on a
|
|
@@ -133,12 +167,12 @@ npm publish # publishConfig.access = public
|
|
|
133
167
|
After that, configure the trusted publisher on npmjs.com
|
|
134
168
|
(package → Settings → Trusted Publisher → GitHub Actions) with exactly:
|
|
135
169
|
|
|
136
|
-
| Field | Value
|
|
137
|
-
| -------------------- |
|
|
138
|
-
| Organization or user | `antasphere`
|
|
139
|
-
| Repository | `cli-core`
|
|
140
|
-
| Workflow filename | `publish.yml`
|
|
141
|
-
| Environment |
|
|
170
|
+
| Field | Value |
|
|
171
|
+
| -------------------- | --------------- |
|
|
172
|
+
| Organization or user | `antasphere` |
|
|
173
|
+
| Repository | `cli-core` |
|
|
174
|
+
| Workflow filename | `publish.yml` |
|
|
175
|
+
| Environment | _(leave empty)_ |
|
|
142
176
|
|
|
143
177
|
and every further release is just the tag.
|
|
144
178
|
|
package/dist/config.d.ts
CHANGED
|
@@ -23,6 +23,21 @@
|
|
|
23
23
|
* XDG_CONFIG_HOME.
|
|
24
24
|
*/
|
|
25
25
|
export type CliEnv = Record<string, string | undefined>;
|
|
26
|
+
/**
|
|
27
|
+
* A tool-local key minted by the cross-tool connect exchange (binding
|
|
28
|
+
* patterns §7), cached in the tool's profile under the HUB org it was
|
|
29
|
+
* exchanged for. Every field beyond the key itself is informational.
|
|
30
|
+
*/
|
|
31
|
+
export interface CliWorkspaceKey {
|
|
32
|
+
/** Full tool-local API key (`slk_`-style) — shown once at mint, cached here. */
|
|
33
|
+
apiKey: string;
|
|
34
|
+
/** The tool-local workspace the key is bound to (the hub org's projection). */
|
|
35
|
+
toolWorkspaceId?: string;
|
|
36
|
+
/** The signed-in account's email at mint. */
|
|
37
|
+
email?: string;
|
|
38
|
+
/** ISO timestamp of the exchange that minted the key. */
|
|
39
|
+
mintedAt?: string;
|
|
40
|
+
}
|
|
26
41
|
export interface CliProfile {
|
|
27
42
|
/** `<prefix>_...` API key for this profile. */
|
|
28
43
|
apiKey?: string;
|
|
@@ -32,6 +47,12 @@ export interface CliProfile {
|
|
|
32
47
|
email?: string;
|
|
33
48
|
/** The org/workspace the key is bound to (one workspace per credential). */
|
|
34
49
|
workspaceId?: string;
|
|
50
|
+
/** Hub profiles only: the org selected via `antasphere org use` (overrides
|
|
51
|
+
* the key's bound `workspaceId` as the default exchange target). */
|
|
52
|
+
activeWorkspaceId?: string;
|
|
53
|
+
/** Tool profiles only: exchange-minted keys, one per HUB org — the
|
|
54
|
+
* per-(tool, org) cache of the cross-tool connect flow. */
|
|
55
|
+
workspaceKeys?: Record<string, CliWorkspaceKey>;
|
|
35
56
|
}
|
|
36
57
|
export interface CliConfig {
|
|
37
58
|
activeProfile?: string;
|
|
@@ -53,4 +74,24 @@ export declare function saveConfig(env: CliEnv, tool: string, config: CliConfig)
|
|
|
53
74
|
export declare function clearConfig(env: CliEnv, tool: string): void;
|
|
54
75
|
/** `ant_abcd1234_…` → `ant_abcd1234_…c3f9` — safe for terminals and logs. */
|
|
55
76
|
export declare function redactKey(key: string): string;
|
|
77
|
+
/**
|
|
78
|
+
* The cached tool-local key for a HUB org, if any. Strictly org-matched:
|
|
79
|
+
* the per-org cache first, then the legacy single `apiKey` — but ONLY when
|
|
80
|
+
* the profile's `workspaceId` says it is bound to exactly this workspace.
|
|
81
|
+
* A key whose binding is unknown is never returned for an org lookup.
|
|
82
|
+
*/
|
|
83
|
+
export declare function lookupWorkspaceKey(profile: CliProfile | undefined, workspaceId: string): string | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Cache an exchange-minted tool key under (profile, hub org), creating the
|
|
86
|
+
* profile on first contact (and making it active when no profile is active
|
|
87
|
+
* yet — first cloud connect on a fresh machine). Every other profile field
|
|
88
|
+
* is preserved untouched. Returns the file written.
|
|
89
|
+
*/
|
|
90
|
+
export declare function storeWorkspaceKey(env: CliEnv, tool: string, profileName: string, workspaceId: string, entry: CliWorkspaceKey): string;
|
|
91
|
+
/**
|
|
92
|
+
* Drop one org's cached key from a profile (tool logout for that org).
|
|
93
|
+
* Returns whether anything was removed; the legacy single `apiKey` is never
|
|
94
|
+
* touched — it belongs to the tool's own login flow.
|
|
95
|
+
*/
|
|
96
|
+
export declare function removeWorkspaceKey(env: CliEnv, tool: string, profileName: string, workspaceId: string): boolean;
|
|
56
97
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAExD,MAAM,WAAW,UAAU;IACzB,+CAA+C;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8EAA8E;IAC9E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,WAAW,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;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,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,MAAM,CAiB/E;AAED,qEAAqE;AACrE,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAG3D;AAED,6EAA6E;AAC7E,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG7C;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAM3G;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,eAAe,GACrB,MAAM,CASR;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,GAClB,OAAO,CAaT"}
|
package/dist/config.js
CHANGED
|
@@ -75,4 +75,58 @@ export function redactKey(key) {
|
|
|
75
75
|
return '****';
|
|
76
76
|
return `${key.slice(0, 13)}…${key.slice(-4)}`;
|
|
77
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* The cached tool-local key for a HUB org, if any. Strictly org-matched:
|
|
80
|
+
* the per-org cache first, then the legacy single `apiKey` — but ONLY when
|
|
81
|
+
* the profile's `workspaceId` says it is bound to exactly this workspace.
|
|
82
|
+
* A key whose binding is unknown is never returned for an org lookup.
|
|
83
|
+
*/
|
|
84
|
+
export function lookupWorkspaceKey(profile, workspaceId) {
|
|
85
|
+
if (!profile)
|
|
86
|
+
return undefined;
|
|
87
|
+
const entry = profile.workspaceKeys?.[workspaceId];
|
|
88
|
+
if (entry?.apiKey)
|
|
89
|
+
return entry.apiKey;
|
|
90
|
+
if (profile.apiKey && profile.workspaceId === workspaceId)
|
|
91
|
+
return profile.apiKey;
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Cache an exchange-minted tool key under (profile, hub org), creating the
|
|
96
|
+
* profile on first contact (and making it active when no profile is active
|
|
97
|
+
* yet — first cloud connect on a fresh machine). Every other profile field
|
|
98
|
+
* is preserved untouched. Returns the file written.
|
|
99
|
+
*/
|
|
100
|
+
export function storeWorkspaceKey(env, tool, profileName, workspaceId, entry) {
|
|
101
|
+
const config = loadConfig(env, tool);
|
|
102
|
+
const profile = config.profiles[profileName] ?? {};
|
|
103
|
+
config.profiles[profileName] = {
|
|
104
|
+
...profile,
|
|
105
|
+
workspaceKeys: { ...profile.workspaceKeys, [workspaceId]: entry }
|
|
106
|
+
};
|
|
107
|
+
if (!config.activeProfile)
|
|
108
|
+
config.activeProfile = profileName;
|
|
109
|
+
return saveConfig(env, tool, config);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Drop one org's cached key from a profile (tool logout for that org).
|
|
113
|
+
* Returns whether anything was removed; the legacy single `apiKey` is never
|
|
114
|
+
* touched — it belongs to the tool's own login flow.
|
|
115
|
+
*/
|
|
116
|
+
export function removeWorkspaceKey(env, tool, profileName, workspaceId) {
|
|
117
|
+
const config = loadConfig(env, tool);
|
|
118
|
+
const profile = config.profiles[profileName];
|
|
119
|
+
if (!profile?.workspaceKeys || !(workspaceId in profile.workspaceKeys))
|
|
120
|
+
return false;
|
|
121
|
+
const { [workspaceId]: _dropped, ...rest } = profile.workspaceKeys;
|
|
122
|
+
if (Object.keys(rest).length === 0) {
|
|
123
|
+
const { workspaceKeys: _empty, ...bare } = profile;
|
|
124
|
+
config.profiles[profileName] = bare;
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
config.profiles[profileName] = { ...profile, workspaceKeys: rest };
|
|
128
|
+
}
|
|
129
|
+
saveConfig(env, tool, config);
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
78
132
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChG,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChG,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAmE1C,+EAA+E;AAC/E,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,CAAC;AAE9B,MAAM,OAAO,GAAG,mBAAmB,CAAC;AAEpC,oEAAoE;AACpE,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,2BAA2B,IAAI,6CAA6C,CAAC,CAAC;IAChG,CAAC;AACH,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,UAAU,CAAC,GAAW,EAAE,IAAY;IAClD,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC1B,MAAM,IAAI,GAAG,GAAG,CAAC,eAAe,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAClF,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,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,IAAY,EACZ,WAAmB,EACnB,WAAmB;IAEnB,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACrC,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAC7C,IAAI,CAAC,OAAO,EAAE,aAAa,IAAI,CAAC,CAAC,WAAW,IAAI,OAAO,CAAC,aAAa,CAAC;QAAE,OAAO,KAAK,CAAC;IACrF,MAAM,EAAE,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC;IACnE,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;QACnD,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;IACtC,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;IACrE,CAAC;IACD,UAAU,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IAC9B,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { CliEnv } from './config.js';
|
|
2
|
+
import type { CliConnectResult } from './connect.js';
|
|
3
|
+
/**
|
|
4
|
+
* Connect-on-demand (binding patterns §7, gcloud model), extracted from the
|
|
5
|
+
* Slideless CLI so every Antasphere tool CLI inherits "one `antasphere login`
|
|
6
|
+
* serves every federated tool". When a tool CLI resolves NO credential of its
|
|
7
|
+
* own, it calls `connectOnDemand`:
|
|
8
|
+
*
|
|
9
|
+
* 1. Discovery gates the flow: only an Antasphere-CLOUD instance can mint
|
|
10
|
+
* keys through the hub (unauthenticated GET /instance — never guess).
|
|
11
|
+
* Unreachable, foreign, or self-hosted instances answer `not_cloud`
|
|
12
|
+
* and the tool raises its classic no-key error unchanged.
|
|
13
|
+
* 2. The hub credential is what `antasphere login` stored on the hub
|
|
14
|
+
* profile (the config home's HUB_TOOL namespace) — hub URL included,
|
|
15
|
+
* never a hardcoded constant here.
|
|
16
|
+
* 3. `CliConnectClient.exchange` trades it for a tool-local key (one
|
|
17
|
+
* re-exchange retry when the 120 s JWT dies in transit; a rejected hub
|
|
18
|
+
* credential maps to guided `antasphere login` advice).
|
|
19
|
+
* 4. The minted key is cached per (tool, HUB org) — but only onto a
|
|
20
|
+
* profile that names THIS instance (a fresh profile gets pinned to it);
|
|
21
|
+
* a profile pointing elsewhere never receives it.
|
|
22
|
+
*
|
|
23
|
+
* A new tool needs only its namespace, base URL, and copy — the flow itself
|
|
24
|
+
* is tool-agnostic.
|
|
25
|
+
*/
|
|
26
|
+
/** What the unauthenticated discovery probe learned about a tool instance. */
|
|
27
|
+
export interface ToolInstanceProbe {
|
|
28
|
+
/** Whether the instance signs in through the Antasphere hub (advertises
|
|
29
|
+
* the `antasphere` auth method, or calls itself the cloud edition). */
|
|
30
|
+
cloud: boolean;
|
|
31
|
+
/** The instance's self-reported edition (`cloud`, `oss`, …). */
|
|
32
|
+
edition: string | undefined;
|
|
33
|
+
/** The advertised auth methods (open enum — unknown entries kept). */
|
|
34
|
+
authMethods: string[];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Probe a tool instance's unauthenticated discovery endpoint
|
|
38
|
+
* (`GET {toolBaseUrl}/api/v1/instance`). Returns what it advertises, or
|
|
39
|
+
* `null` when the instance is unreachable or answers a foreign shape —
|
|
40
|
+
* callers treat both exactly like "not cloud".
|
|
41
|
+
*/
|
|
42
|
+
export declare function probeToolInstance(toolBaseUrl: string, fetchImpl?: typeof globalThis.fetch): Promise<ToolInstanceProbe | null>;
|
|
43
|
+
/** The facts the connected notice is rendered from. */
|
|
44
|
+
export interface ConnectNoticeFacts {
|
|
45
|
+
/** The tool instance the exchange connected to (origin-normalized). */
|
|
46
|
+
toolBaseUrl: string;
|
|
47
|
+
/** The signed-in account's email at mint. */
|
|
48
|
+
email: string;
|
|
49
|
+
/** The HUB org the exchange resolved to. */
|
|
50
|
+
hubWorkspaceId: string;
|
|
51
|
+
/** Whether the minted key was cached (per (tool, hub org)). */
|
|
52
|
+
cached: boolean;
|
|
53
|
+
/** The tool profile the cache targeted. */
|
|
54
|
+
profileName: string;
|
|
55
|
+
/** When NOT cached: the other instance the profile points at. */
|
|
56
|
+
profileBaseUrl?: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Branded copy seams. Defaults reproduce the Slideless CLI's strings modulo
|
|
60
|
+
* the tool name (the tool namespace stands in for the display name, and the
|
|
61
|
+
* key-env-var name is derived from it: `slideless` → `SLIDELESS_API_KEY`).
|
|
62
|
+
*/
|
|
63
|
+
export interface ConnectOnDemandMessages {
|
|
64
|
+
/** `CliUsageError` text when the instance is cloud but no `antasphere
|
|
65
|
+
* login` credential is stored on the hub profile. */
|
|
66
|
+
missingHubLogin?: string;
|
|
67
|
+
/** `CliUsageError` text when the hub rejected the stored credential. */
|
|
68
|
+
hubLoginRejected?: string;
|
|
69
|
+
/** Renders the success notice handed to `notify` (newline included). */
|
|
70
|
+
connected?: (facts: ConnectNoticeFacts) => string;
|
|
71
|
+
}
|
|
72
|
+
export interface ConnectOnDemandOptions {
|
|
73
|
+
/** The tool's config namespace (lowercase slug — it names the cache file). */
|
|
74
|
+
tool: string;
|
|
75
|
+
/** The resolved tool instance origin the CLI is talking to. */
|
|
76
|
+
toolBaseUrl: string;
|
|
77
|
+
/** The exchange resource URL; default = this instance's MCP endpoint,
|
|
78
|
+
* `${toolBaseUrl}/mcp` (the tool's registered resource URL). */
|
|
79
|
+
resource?: string;
|
|
80
|
+
/** Target hub org for the exchange (`--org` → `antasphere org use` → the
|
|
81
|
+
* hub key's bound org — resolve via `resolveTargetWorkspace`); omit =
|
|
82
|
+
* the hub defaults to the key's bound org server-side. */
|
|
83
|
+
org?: string;
|
|
84
|
+
/** The tool profile the minted key is cached on; default `DEFAULT_PROFILE`. */
|
|
85
|
+
profileName?: string;
|
|
86
|
+
env: CliEnv;
|
|
87
|
+
fetch?: typeof globalThis.fetch;
|
|
88
|
+
/** Receives the human "Connected to …" notice (tools wire their stderr);
|
|
89
|
+
* omitted = silent. Machine output stays untouched either way. */
|
|
90
|
+
notify?: (line: string) => void;
|
|
91
|
+
messages?: ConnectOnDemandMessages;
|
|
92
|
+
}
|
|
93
|
+
export type ConnectOnDemandOutcome = {
|
|
94
|
+
outcome: 'connected';
|
|
95
|
+
/** The minted tool-local key — this invocation's credential. */
|
|
96
|
+
key: string;
|
|
97
|
+
/** The full exchange result (user, hub org, tool workspace, key meta). */
|
|
98
|
+
result: CliConnectResult;
|
|
99
|
+
/** Whether the key was cached per (tool, hub org) for the next run. */
|
|
100
|
+
cached: boolean;
|
|
101
|
+
} | {
|
|
102
|
+
/** Not an Antasphere-cloud instance (or unreachable): the caller
|
|
103
|
+
* raises its classic no-key error unchanged. */
|
|
104
|
+
outcome: 'not_cloud';
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* The hub → tool exchange fallback a tool CLI runs when no direct credential
|
|
108
|
+
* resolved. Returns `not_cloud` when the instance is not an Antasphere-cloud
|
|
109
|
+
* one (or unreachable). Throws a guided `CliUsageError` when the instance IS
|
|
110
|
+
* cloud but the hub login is missing or rejected; every other exchange
|
|
111
|
+
* failure propagates as its `CliConnectError`.
|
|
112
|
+
*/
|
|
113
|
+
export declare function connectOnDemand(opts: ConnectOnDemandOptions): Promise<ConnectOnDemandOutcome>;
|
|
114
|
+
//# sourceMappingURL=connect-on-demand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connect-on-demand.d.ts","sourceRoot":"","sources":["../src/connect-on-demand.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM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AG,CAAC,EAAE,MAAM,CAAC;IACb,+EAA+E;IAC/E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC;uEACmE;IACnE,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,QAAQ,CAAC,EAAE,uBAAuB,CAAC;CACpC;AAED,MAAM,MAAM,sBAAsB,GAC9B;IACE,OAAO,EAAE,WAAW,CAAC;IACrB,gEAAgE;IAChE,GAAG,EAAE,MAAM,CAAC;IACZ,0EAA0E;IAC1E,MAAM,EAAE,gBAAgB,CAAC;IACzB,uEAAuE;IACvE,MAAM,EAAE,OAAO,CAAC;CACjB,GACD;IACE;qDACiD;IACjD,OAAO,EAAE,WAAW,CAAC;CACtB,CAAC;AAEN;;;;;;GAMG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CA8EnG"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { assertToolNamespace, HUB_TOOL, loadConfig, saveConfig, storeWorkspaceKey } from './config.js';
|
|
2
|
+
import { CliConnectClient, CliConnectError } from './connect.js';
|
|
3
|
+
import { CliUsageError, DEFAULT_PROFILE, resolveProfile } from './resolve.js';
|
|
4
|
+
/**
|
|
5
|
+
* Probe a tool instance's unauthenticated discovery endpoint
|
|
6
|
+
* (`GET {toolBaseUrl}/api/v1/instance`). Returns what it advertises, or
|
|
7
|
+
* `null` when the instance is unreachable or answers a foreign shape —
|
|
8
|
+
* callers treat both exactly like "not cloud".
|
|
9
|
+
*/
|
|
10
|
+
export async function probeToolInstance(toolBaseUrl, fetchImpl) {
|
|
11
|
+
const f = fetchImpl ?? globalThis.fetch.bind(globalThis);
|
|
12
|
+
try {
|
|
13
|
+
const res = await f(`${toolBaseUrl.replace(/\/+$/, '')}/api/v1/instance`, {
|
|
14
|
+
method: 'GET',
|
|
15
|
+
// Discovery is served cacheable for CLI/MCP clients, but the probe
|
|
16
|
+
// must see live state (mirrors the tool SDKs' discovery call).
|
|
17
|
+
cache: 'no-store'
|
|
18
|
+
});
|
|
19
|
+
if (!res.ok)
|
|
20
|
+
return null;
|
|
21
|
+
const info = (await res.json().catch(() => null));
|
|
22
|
+
const methods = info?.auth?.methods;
|
|
23
|
+
if (!Array.isArray(methods))
|
|
24
|
+
return null;
|
|
25
|
+
const authMethods = methods.filter((m) => typeof m === 'string');
|
|
26
|
+
const edition = typeof info?.edition === 'string' ? info.edition : undefined;
|
|
27
|
+
return { cloud: authMethods.includes('antasphere') || edition === 'cloud', edition, authMethods };
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function defaultMissingHubLogin(tool) {
|
|
34
|
+
const envVar = `${tool.replace(/-/g, '_').toUpperCase()}_API_KEY`;
|
|
35
|
+
return (`This ${tool} instance signs in through the Antasphere hub. Run \`antasphere login\` once, ` +
|
|
36
|
+
`then retry — or pass --api-key / set ${envVar}.`);
|
|
37
|
+
}
|
|
38
|
+
const DEFAULT_HUB_LOGIN_REJECTED = 'The stored Antasphere hub credential was rejected — run `antasphere login` again, then retry.';
|
|
39
|
+
function defaultConnected(facts) {
|
|
40
|
+
return (`Connected to ${facts.toolBaseUrl} as ${facts.email} via Antasphere (org ${facts.hubWorkspaceId})` +
|
|
41
|
+
(facts.cached
|
|
42
|
+
? ''
|
|
43
|
+
: ` — key NOT cached: profile '${facts.profileName}' points at ${facts.profileBaseUrl}`) +
|
|
44
|
+
'.\n');
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The hub → tool exchange fallback a tool CLI runs when no direct credential
|
|
48
|
+
* resolved. Returns `not_cloud` when the instance is not an Antasphere-cloud
|
|
49
|
+
* one (or unreachable). Throws a guided `CliUsageError` when the instance IS
|
|
50
|
+
* cloud but the hub login is missing or rejected; every other exchange
|
|
51
|
+
* failure propagates as its `CliConnectError`.
|
|
52
|
+
*/
|
|
53
|
+
export async function connectOnDemand(opts) {
|
|
54
|
+
assertToolNamespace(opts.tool);
|
|
55
|
+
const toolBaseUrl = opts.toolBaseUrl.replace(/\/+$/, '');
|
|
56
|
+
const messages = opts.messages ?? {};
|
|
57
|
+
// 1. Only a CLOUD instance can mint keys through the hub — ask discovery,
|
|
58
|
+
// never guess. An unreachable or foreign instance is `not_cloud`.
|
|
59
|
+
const probe = await probeToolInstance(toolBaseUrl, opts.fetch);
|
|
60
|
+
if (!probe?.cloud)
|
|
61
|
+
return { outcome: 'not_cloud' };
|
|
62
|
+
// 2. The hub credential is what `antasphere login` stored on the hub
|
|
63
|
+
// profile (HUB_TOOL namespace) — one login for the whole tool family.
|
|
64
|
+
// The hub URL comes from that same profile, never from a constant here.
|
|
65
|
+
const { profile: hubProfile } = resolveProfile(loadConfig(opts.env, HUB_TOOL), undefined);
|
|
66
|
+
const hubKey = hubProfile?.apiKey;
|
|
67
|
+
const hubBaseUrl = hubProfile?.baseUrl;
|
|
68
|
+
if (!hubKey || !hubBaseUrl) {
|
|
69
|
+
throw new CliUsageError(messages.missingHubLogin ?? defaultMissingHubLogin(opts.tool));
|
|
70
|
+
}
|
|
71
|
+
// 3. The exchange resource defaults to THIS instance's registered resource
|
|
72
|
+
// URL — its MCP endpoint, derived from the resolved instance origin.
|
|
73
|
+
const resource = opts.resource ?? `${toolBaseUrl}/mcp`;
|
|
74
|
+
const connect = new CliConnectClient({
|
|
75
|
+
hubBaseUrl,
|
|
76
|
+
toolBaseUrl,
|
|
77
|
+
...(opts.fetch ? { fetch: opts.fetch } : {})
|
|
78
|
+
});
|
|
79
|
+
const body = { resource, ...(opts.org ? { workspaceId: opts.org } : {}) };
|
|
80
|
+
let result;
|
|
81
|
+
try {
|
|
82
|
+
result = await connect.exchange(hubKey, body);
|
|
83
|
+
}
|
|
84
|
+
catch (e) {
|
|
85
|
+
if (e instanceof CliConnectError && e.needsReExchange) {
|
|
86
|
+
// The 120 s JWT died in transit (expired/replayed) — one fresh
|
|
87
|
+
// exchange; a second rejection propagates.
|
|
88
|
+
result = await connect.exchange(hubKey, body);
|
|
89
|
+
}
|
|
90
|
+
else if (e instanceof CliConnectError && e.needsHubLogin) {
|
|
91
|
+
throw new CliUsageError(messages.hubLoginRejected ?? DEFAULT_HUB_LOGIN_REJECTED);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
throw e;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// 4. Cache the minted key per (tool, hub org) — but only onto a profile
|
|
98
|
+
// that names THIS instance (or a fresh one, which gets pinned to it),
|
|
99
|
+
// never onto a profile pointing somewhere else.
|
|
100
|
+
const profileName = opts.profileName ?? DEFAULT_PROFILE;
|
|
101
|
+
const existing = loadConfig(opts.env, opts.tool).profiles[profileName];
|
|
102
|
+
const cached = !existing?.baseUrl || existing.baseUrl.replace(/\/+$/, '') === toolBaseUrl;
|
|
103
|
+
if (cached) {
|
|
104
|
+
storeWorkspaceKey(opts.env, opts.tool, profileName, result.hubWorkspaceId, {
|
|
105
|
+
apiKey: result.key,
|
|
106
|
+
toolWorkspaceId: result.toolWorkspaceId,
|
|
107
|
+
email: result.user.email,
|
|
108
|
+
mintedAt: new Date().toISOString()
|
|
109
|
+
});
|
|
110
|
+
if (!existing?.baseUrl) {
|
|
111
|
+
// First contact: pin the profile to this instance so the next
|
|
112
|
+
// invocation resolves the URL and the cached key with no flags.
|
|
113
|
+
const cfg = loadConfig(opts.env, opts.tool);
|
|
114
|
+
cfg.profiles[profileName] = { ...cfg.profiles[profileName], baseUrl: toolBaseUrl };
|
|
115
|
+
saveConfig(opts.env, opts.tool, cfg);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
const facts = {
|
|
119
|
+
toolBaseUrl,
|
|
120
|
+
email: result.user.email,
|
|
121
|
+
hubWorkspaceId: result.hubWorkspaceId,
|
|
122
|
+
cached,
|
|
123
|
+
profileName,
|
|
124
|
+
// `cached` is false only when the profile names another instance.
|
|
125
|
+
...(cached ? {} : { profileBaseUrl: existing?.baseUrl })
|
|
126
|
+
};
|
|
127
|
+
opts.notify?.((messages.connected ?? defaultConnected)(facts));
|
|
128
|
+
return { outcome: 'connected', key: result.key, result, cached };
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=connect-on-demand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connect-on-demand.js","sourceRoot":"","sources":["../src/connect-on-demand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEvG,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAqC9E;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,WAAmB,EACnB,SAAmC;IAEnC,MAAM,CAAC,GAAG,SAAS,IAAI,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACzD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,GAAG,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,kBAAkB,EAAE;YACxE,MAAM,EAAE,KAAK;YACb,mEAAmE;YACnE,+DAA+D;YAC/D,KAAK,EAAE,UAAU;SAClB,CAAC,CAAC;QACH,IAAI,CAAC,GAAG,CAAC,EAAE;YAAE,OAAO,IAAI,CAAC;QACzB,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAGxC,CAAC;QACT,MAAM,OAAO,GAAG,IAAI,EAAE,IAAI,EAAE,OAAO,CA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,KAAK;YACxB,QAAQ,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACnC,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC;YACvB,8DAA8D;YAC9D,gEAAgE;YAChE,MAAM,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YAC5C,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;YACnF,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAED,MAAM,KAAK,GAAuB;QAChC,WAAW;QACX,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK;QACxB,cAAc,EAAE,MAAM,CAAC,cAAc;QACrC,MAAM;QACN,WAAW;QACX,kEAAkE;QAClE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;KACzD,CAAC;IACF,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,SAAS,IAAI,gBAAgB,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAE/D,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { CliAuthError, type CliAuthMintedKey } from './auth.js';
|
|
2
|
+
/**
|
|
3
|
+
* The CLI cross-tool connect exchange (binding patterns §7, gcloud model):
|
|
4
|
+
* one `antasphere login` serves every federated tool. On demand, the hub
|
|
5
|
+
* API key is traded for a tool-local key in two calls:
|
|
6
|
+
*
|
|
7
|
+
* 1. POST {hub}/api/v1/sso/tool-token — auth = hub API key (Bearer),
|
|
8
|
+
* body `{ resource, workspaceId? }` → a single-org, 120-second JWT
|
|
9
|
+
* for the tool's resource URL. The token is OPAQUE to this client:
|
|
10
|
+
* it is relayed hub → tool, never inspected or stored.
|
|
11
|
+
* 2. POST {tool}/api/v1/sso/cli-connect — NO auth header (the JWT is
|
|
12
|
+
* the credential), body `{ token }` → the tool verifies, JIT-provisions,
|
|
13
|
+
* and mints an ordinary tool-local API key, returned exactly once.
|
|
14
|
+
*
|
|
15
|
+
* The hub key is sent to the HUB only — it never reaches the tool. The
|
|
16
|
+
* minted key is cached per (tool, hub org) in the tool's config namespace
|
|
17
|
+
* (config.ts `workspaceKeys`); day-to-day tool CLI calls then take the
|
|
18
|
+
* ordinary local API-key path with the hub out of the loop.
|
|
19
|
+
*/
|
|
20
|
+
export type CliConnectStage = 'hub' | 'tool';
|
|
21
|
+
/**
|
|
22
|
+
* A failed exchange call, tagged with WHICH side rejected it so a CLI can
|
|
23
|
+
* pick the remedy without string-matching:
|
|
24
|
+
*
|
|
25
|
+
* - hub 400 `unknown_resource` — the resource URL is not in the registry.
|
|
26
|
+
* - hub 403 `no_membership` / `workspace_suspended` — the target org is
|
|
27
|
+
* not exchangeable for this user; pick another org.
|
|
28
|
+
* - `needsHubLogin` — the hub rejected the KEY itself; re-run
|
|
29
|
+
* `antasphere login`.
|
|
30
|
+
* - `needsReExchange` — the tool rejected the 120 s JWT (expired/replayed
|
|
31
|
+
* in transit); run the exchange again.
|
|
32
|
+
* - tool 429 `rate_limited` — back off and retry.
|
|
33
|
+
*/
|
|
34
|
+
export declare class CliConnectError extends CliAuthError {
|
|
35
|
+
readonly stage: CliConnectStage;
|
|
36
|
+
constructor(stage: CliConnectStage, status: number, code: string, message: string, details?: unknown);
|
|
37
|
+
/**
|
|
38
|
+
* The hub rejected the key itself: invalid/revoked (401), or a key
|
|
39
|
+
* minted before the `sso:exchange` scope existed (403 insufficient_scope
|
|
40
|
+
* — old keys simply lack it). The fix is a fresh `antasphere login`.
|
|
41
|
+
*/
|
|
42
|
+
get needsHubLogin(): boolean;
|
|
43
|
+
/** The tool rejected the JWT (expired/replayed) — run the exchange again. */
|
|
44
|
+
get needsReExchange(): boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface CliToolTokenBody {
|
|
47
|
+
/** The tool's registry resource URL (e.g. `https://app.slideless.ai/mcp`). */
|
|
48
|
+
resource: string;
|
|
49
|
+
/** Target hub org — any live ACTIVE membership of the user (gcloud
|
|
50
|
+
* model); omit = the hub key's bound workspace. */
|
|
51
|
+
workspaceId?: string;
|
|
52
|
+
}
|
|
53
|
+
export interface CliToolTokenMinted {
|
|
54
|
+
/** The single-org exchange JWT — opaque, ~120 s; relay it, never keep it. */
|
|
55
|
+
token: string;
|
|
56
|
+
/** ISO expiry of the JWT (informational; the minted key outlives it). */
|
|
57
|
+
expiresAt: string;
|
|
58
|
+
/** The hub org the token was minted for (explicit target or the key's bound org). */
|
|
59
|
+
workspaceId: string;
|
|
60
|
+
}
|
|
61
|
+
export interface CliConnected {
|
|
62
|
+
/** Full tool-local key (`slk_`-style) — shown once, never retrievable. */
|
|
63
|
+
key: string;
|
|
64
|
+
apiKey: CliAuthMintedKey;
|
|
65
|
+
user: {
|
|
66
|
+
id: string;
|
|
67
|
+
email: string;
|
|
68
|
+
name: string;
|
|
69
|
+
};
|
|
70
|
+
/** The tool-local workspace the key is bound to (the hub org's projection). */
|
|
71
|
+
workspaceId: string;
|
|
72
|
+
}
|
|
73
|
+
/** The flattened outcome of a full exchange — everything a CLI caches. */
|
|
74
|
+
export interface CliConnectResult {
|
|
75
|
+
/** Full tool-local key — cache it per (tool, `hubWorkspaceId`). */
|
|
76
|
+
key: string;
|
|
77
|
+
apiKey: CliAuthMintedKey;
|
|
78
|
+
user: {
|
|
79
|
+
id: string;
|
|
80
|
+
email: string;
|
|
81
|
+
name: string;
|
|
82
|
+
};
|
|
83
|
+
/** The HUB org the exchange resolved to — the cache key (config.ts). */
|
|
84
|
+
hubWorkspaceId: string;
|
|
85
|
+
/** The tool-local workspace the minted key is bound to (informational). */
|
|
86
|
+
toolWorkspaceId: string;
|
|
87
|
+
}
|
|
88
|
+
export interface CliConnectClientOptions {
|
|
89
|
+
/** Hub origin, e.g. https://account.antasphere.com */
|
|
90
|
+
hubBaseUrl: string;
|
|
91
|
+
/** Tool instance origin, e.g. https://app.slideless.ai */
|
|
92
|
+
toolBaseUrl: string;
|
|
93
|
+
fetch?: typeof globalThis.fetch;
|
|
94
|
+
}
|
|
95
|
+
export declare class CliConnectClient {
|
|
96
|
+
private readonly hubBaseUrl;
|
|
97
|
+
private readonly toolBaseUrl;
|
|
98
|
+
private readonly fetchImpl;
|
|
99
|
+
constructor(options: CliConnectClientOptions);
|
|
100
|
+
/** Step 1 — the hub mints the 120 s single-org JWT for the tool's resource. */
|
|
101
|
+
toolToken(hubApiKey: string, body: CliToolTokenBody): Promise<CliToolTokenMinted>;
|
|
102
|
+
/** Step 2 — the tool verifies the JWT (its only credential) and mints its key. */
|
|
103
|
+
cliConnect(token: string): Promise<CliConnected>;
|
|
104
|
+
/** The full two-call exchange. The hub key goes to the hub ONLY. */
|
|
105
|
+
exchange(hubApiKey: string, body: CliToolTokenBody): Promise<CliConnectResult>;
|
|
106
|
+
/** Mirrors CliAuthClient's parse: `{ error: { code, message, details } }` envelopes. */
|
|
107
|
+
private call;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=connect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAEhE;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,MAAM,CAAC;AAE7C;;;;;;;;;;;;GAYG;AACH,qBAAa,e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