@orion-belt/sdk 0.0.0-stage → 1.0.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/LICENSE ADDED
@@ -0,0 +1,225 @@
1
+ Commons Clause License Condition v1.0
2
+
3
+ The Software is provided to you by the Licensor under the License, as defined
4
+ below, subject to the following condition.
5
+
6
+ Without limiting other conditions in the License, the grant of rights under
7
+ the License will not include, and the License does not grant to you, the
8
+ right to Sell the Software.
9
+
10
+ For purposes of the foregoing, "Sell" means practicing any or all of the
11
+ rights granted to you under the License to provide to third parties, for a
12
+ fee or other consideration (including without limitation fees for hosting or
13
+ consulting/support services related to the Software), a product or service
14
+ whose value derives, entirely or substantially, from the functionality of the
15
+ Software. Any license notice or attribution required by the License must also
16
+ include this Commons Clause License Condition notice.
17
+
18
+ Software: Orion Belt
19
+ License: Apache License 2.0 (below)
20
+ Licensor: Mohamed Zrouga
21
+
22
+ ------------------------------------------------------------------------------
23
+
24
+ Apache License
25
+ Version 2.0, January 2004
26
+ http://www.apache.org/licenses/
27
+
28
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
29
+
30
+ 1. Definitions.
31
+
32
+ "License" shall mean the terms and conditions for use, reproduction,
33
+ and distribution as defined by Sections 1 through 9 of this document.
34
+
35
+ "Licensor" shall mean the copyright owner or entity authorized by
36
+ the copyright owner that is granting the License.
37
+
38
+ "Legal Entity" shall mean the union of the acting entity and all
39
+ other entities that control, are controlled by, or are under common
40
+ control with that entity. For the purposes of this definition,
41
+ "control" means (i) the power, direct or indirect, to cause the
42
+ direction or management of such entity, whether by contract or
43
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
44
+ outstanding shares, or (iii) beneficial ownership of such entity.
45
+
46
+ "You" (or "Your") shall mean an individual or Legal Entity
47
+ exercising permissions granted by this License.
48
+
49
+ "Source" form shall mean the preferred form for making modifications,
50
+ including but not limited to software source code, documentation
51
+ source, and configuration files.
52
+
53
+ "Object" form shall mean any form resulting from mechanical
54
+ transformation or translation of a Source form, including but
55
+ not limited to compiled object code, generated documentation,
56
+ and conversions to other media types.
57
+
58
+ "Work" shall mean the work of authorship, whether in Source or
59
+ Object form, made available under the License, as indicated by a
60
+ copyright notice that is included in or attached to the work
61
+ (an example is provided in the Appendix below).
62
+
63
+ "Derivative Works" shall mean any work, whether in Source or Object
64
+ form, that is based on (or derived from) the Work and for which the
65
+ editorial revisions, annotations, elaborations, or other modifications
66
+ represent, as a whole, an original work of authorship. For the purposes
67
+ of this License, Derivative Works shall not include works that remain
68
+ separable from, or merely link (or bind by name) to the interfaces of,
69
+ the Work and Derivative Works thereof.
70
+
71
+ "Contribution" shall mean any work of authorship, including
72
+ the original version of the Work and any modifications or additions
73
+ to that Work or Derivative Works thereof, that is intentionally
74
+ submitted to Licensor for inclusion in the Work by the copyright owner
75
+ or by an individual or Legal Entity authorized to submit on behalf of
76
+ the copyright owner. For the purposes of this definition, "submitted"
77
+ means any form of electronic, verbal, or written communication sent
78
+ to the Licensor or its representatives, including but not limited to
79
+ communication on electronic mailing lists, source code control systems,
80
+ and issue tracking systems that are managed by, or on behalf of, the
81
+ Licensor for the purpose of discussing and improving the Work, but
82
+ excluding communication that is conspicuously marked or otherwise
83
+ designated in writing by the copyright owner as "Not a Contribution."
84
+
85
+ "Contributor" shall mean Licensor and any individual or Legal Entity
86
+ on behalf of whom a Contribution has been received by Licensor and
87
+ subsequently incorporated within the Work.
88
+
89
+ 2. Grant of Copyright License.
90
+
91
+ Subject to the terms and conditions of this License, each Contributor
92
+ hereby grants to You a perpetual, worldwide, non-exclusive, no-charge,
93
+ royalty-free, irrevocable copyright license to reproduce, prepare
94
+ Derivative Works of, publicly display, publicly perform, sublicense,
95
+ and distribute the Work and such Derivative Works in Source or Object
96
+ form.
97
+
98
+ 3. Grant of Patent License.
99
+
100
+ Subject to the terms and conditions of this License, each Contributor
101
+ hereby grants to You a perpetual, worldwide, non-exclusive, no-charge,
102
+ royalty-free, irrevocable (except as stated in this section) patent
103
+ license to make, have made, use, offer to sell, sell, import, and
104
+ otherwise transfer the Work, where such license applies only to those
105
+ patent claims licensable by such Contributor that are necessarily
106
+ infringed by their Contribution(s) alone or by combination of their
107
+ Contribution(s) with the Work to which such Contribution(s) was
108
+ submitted. If You institute patent litigation against any entity
109
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
110
+ the Work or a Contribution incorporated within the Work constitutes
111
+ direct or contributory patent infringement, then any patent licenses
112
+ granted to You under this License for that Work shall terminate as of
113
+ the date such litigation is filed.
114
+
115
+ 4. Redistribution.
116
+
117
+ You may reproduce and distribute copies of the Work or Derivative
118
+ Works thereof in any medium, with or without modifications, and in
119
+ Source or Object form, provided that You meet the following conditions:
120
+
121
+ (a) You must give any other recipients of the Work or
122
+ Derivative Works a copy of this License; and
123
+
124
+ (b) You must cause any modified files to carry prominent notices
125
+ stating that You changed the files; and
126
+
127
+ (c) You must retain, in the Source form of any Derivative Works
128
+ that You distribute, all copyright, patent, trademark, and
129
+ attribution notices from the Source form of the Work,
130
+ excluding those notices that do not pertain to any part of
131
+ the Derivative Works; and
132
+
133
+ (d) If the Work includes a "NOTICE" text file as part of its
134
+ distribution, then any Derivative Works that You distribute must
135
+ include a readable copy of the attribution notices contained
136
+ within such NOTICE file, excluding those notices that do not
137
+ pertain to any part of the Derivative Works, in at least one
138
+ of the following places: within a NOTICE text file distributed
139
+ as part of the Derivative Works; within the Source form or
140
+ documentation, if provided along with the Derivative Works; or,
141
+ within a display generated by the Derivative Works, if and
142
+ wherever such third-party notices normally appear. The contents
143
+ of the NOTICE file are for informational purposes only and
144
+ do not modify the License. You may add Your own attribution
145
+ notices within Derivative Works that You distribute, alongside
146
+ or as an addendum to the NOTICE text from the Work, provided
147
+ that such additional attribution notices cannot be construed
148
+ as modifying the License.
149
+
150
+ You may add Your own copyright statement to Your modifications and
151
+ may provide additional or different license terms and conditions
152
+ for use, reproduction, or distribution of Your modifications, or
153
+ for any such Derivative Works as a whole, provided Your use,
154
+ reproduction, and distribution of the Work otherwise complies with
155
+ the conditions stated in this License.
156
+
157
+ 5. Submission of Contributions.
158
+
159
+ Unless You explicitly state otherwise, any Contribution intentionally
160
+ submitted for inclusion in the Work by You to the Licensor shall be
161
+ under the terms and conditions of this License, without any additional
162
+ terms or conditions.
163
+ Notwithstanding the above, nothing herein shall supersede or modify
164
+ the terms of any separate license agreement you may have executed
165
+ with Licensor regarding such Contributions.
166
+
167
+ 6. Trademarks.
168
+
169
+ This License does not grant permission to use the trade names,
170
+ trademarks, service marks, or product names of the Licensor,
171
+ except as required for reasonable and customary use in describing the
172
+ origin of the Work and reproducing the content of the NOTICE file.
173
+
174
+ 7. Disclaimer of Warranty.
175
+
176
+ Unless required by applicable law or agreed to in writing, Licensor
177
+ provides the Work (and each Contributor provides its Contributions)
178
+ on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
179
+ either express or implied, including, without limitation, any
180
+ warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY,
181
+ or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for
182
+ determining the appropriateness of using or redistributing the Work
183
+ and assume any risks associated with Your exercise of permissions
184
+ under this License.
185
+
186
+ 8. Limitation of Liability.
187
+
188
+ In no event and under no legal theory, whether in tort (including
189
+ negligence), contract, or otherwise, unless required by applicable
190
+ law (such as deliberate and grossly negligent acts) or agreed to in
191
+ writing, shall any Contributor be liable to You for damages, including
192
+ any direct, indirect, special, incidental, or consequential damages
193
+ of any character arising as a result of this License or out of the
194
+ use or inability to use the Work (including but not limited to damages
195
+ for loss of goodwill, work stoppage, computer failure or malfunction,
196
+ or any and all other commercial damages or losses), even if such
197
+ Contributor has been advised of the possibility of such damages.
198
+
199
+ 9. Accepting Warranty or Additional Liability.
200
+
201
+ While redistributing the Work or Derivative Works thereof, You may
202
+ choose to offer, and charge a fee for, acceptance of support, warranty,
203
+ indemnity, or other liability obligations and/or rights consistent
204
+ with this License. However, in accepting such obligations, You may act
205
+ only on Your own behalf and on Your sole responsibility, not on behalf
206
+ of any other Contributor, and only if You agree to indemnify, defend,
207
+ and hold each Contributor harmless for any liability incurred by, or
208
+ claims asserted against, such Contributor by reason of your accepting
209
+ any such warranty or additional liability.
210
+
211
+ END OF TERMS AND CONDITIONS
212
+
213
+ Copyright 2026 Mohamed Zrouga <med@zrouga.email>
214
+
215
+ Licensed under the Apache License, Version 2.0 (the "License");
216
+ you may not use this file except in compliance with the License.
217
+ You may obtain a copy of the License at
218
+
219
+ http://www.apache.org/licenses/LICENSE-2.0
220
+
221
+ Unless required by applicable law or agreed to in writing, software
222
+ distributed under the License is distributed on an "AS IS" BASIS,
223
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
224
+ See the License for the specific language governing permissions and
225
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,112 @@
1
- # Temporary Holding Version
1
+ # @orion-belt/sdk
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ TypeScript client for the [Orion Belt](https://github.com/orion-belt-dev/orion-belt)
4
+ API, for console extensions and web integrations.
5
+
6
+ - Covers every `/api/v1` endpoint the server exposes. A test checks the client
7
+ against the server's route table, so new endpoints can't be missed.
8
+ - No runtime dependencies: built on the platform `fetch`, so it runs in Node 20+,
9
+ Deno, Bun and browsers.
10
+ - ES module with type declarations.
11
+
12
+ ## Install
13
+
14
+ ```sh
15
+ npm install @orion-belt/sdk
16
+ ```
17
+
18
+ ## Use
19
+
20
+ ```ts
21
+ import { ApiError, OrionBeltClient } from '@orion-belt/sdk';
22
+
23
+ const client = new OrionBeltClient({ baseUrl: 'https://pam.example.com', apiKey: '...' });
24
+
25
+ for (const machine of await client.listMachines()) {
26
+ console.log(machine.name, machine.is_active);
27
+ }
28
+
29
+ try {
30
+ await client.getMachine('does-not-exist');
31
+ } catch (err) {
32
+ if (err instanceof ApiError) console.log(err.statusCode, err.serverMessage);
33
+ }
34
+ ```
35
+
36
+ Method names follow the [Go SDK](https://github.com/orion-belt-dev/orion-belt/tree/master/pkg/sdk)
37
+ in camelCase. Request and response fields keep the API's snake_case names. For
38
+ an endpoint the client has no method for yet, use
39
+ `client.request(method, path, body)`.
40
+
41
+ Options: `apiKey`, `sessionToken`, `bearerToken`, `timeoutMs` (default 30 s, 0
42
+ disables it), `userAgent` (ignored by browsers), `headers`, and `fetch` to
43
+ supply your own implementation.
44
+
45
+ ### Authentication
46
+
47
+ Pass a credential in the options, or log in. The login helpers store the
48
+ credential they get back on the client (read it back from `client.credentials`).
49
+
50
+ | Helper | Credential |
51
+ |--------|------------|
52
+ | `loginWithSshKey(username, signer)` | API key |
53
+ | `loginWithSshSession(username, signer)` | session token (+ JWT) |
54
+ | `loginWithSshJwt(username, signer)` | JWT bearer token |
55
+ | `loginWithPassword(username, password, totpCode)` | session token (+ JWT) |
56
+
57
+ A `Signer` proves you hold an SSH key registered to the user. It needs a
58
+ `publicKey` (the authorized_keys line) and a `sign(data)` that returns the
59
+ signature format and the raw signature, sync or async. In Node, for an ed25519 key:
60
+
61
+ ```ts
62
+ import { createPrivateKey, createPublicKey, sign } from 'node:crypto';
63
+ import { readFileSync } from 'node:fs';
64
+
65
+ const privateKey = createPrivateKey(readFileSync('id_ed25519.pem')); // PKCS#8 PEM
66
+ const signer = {
67
+ publicKey: readFileSync('id_ed25519.pub', 'utf8').trim(),
68
+ sign: (data: Uint8Array) => ({ format: 'ssh-ed25519', signature: sign(null, data, privateKey) }),
69
+ };
70
+ await client.loginWithSshKey('alice', signer);
71
+ ```
72
+
73
+ Node can't read OpenSSH-format private keys. Convert one with
74
+ `ssh-keygen -p -m PKCS8 -f id_ed25519` (on a copy). For RSA keys, return
75
+ `rsa-sha2-256` and an RSA-SHA256 PKCS#1 v1.5 signature.
76
+
77
+ `logout()` ends the HTTP session and clears the session and bearer tokens from
78
+ the client. The server does not revoke a JWT at logout; it stays valid until
79
+ it expires.
80
+
81
+ ### WebSockets
82
+
83
+ `terminalWsUrl()` and `sessionWatchWsUrl()` return the `ws://`/`wss://` URL.
84
+ The server authenticates the upgrade request by header, so use a client that
85
+ can send `client.authHeaders()` (for example `ws` in Node). The browser
86
+ `WebSocket` API cannot set headers; in a browser the session cookie is used
87
+ instead.
88
+
89
+ ## Develop
90
+
91
+ From `sdk/js`, with Node 22+:
92
+
93
+ ```sh
94
+ npm ci --ignore-scripts
95
+ npm run lint
96
+ npm run check
97
+ npm test # node:test with coverage, fails under 90% lines/branches
98
+ npm run build
99
+ ```
100
+
101
+ If the server adds an endpoint, regenerate the route list
102
+ (`go test ./pkg/api -run TestRoutesManifest -update-routes` from the repo root).
103
+ Then add the method and its entry in `test/contract.test.ts`.
104
+
105
+ ## Release
106
+
107
+ Bump `version` in `package.json` and push a tag `sdk-js-v<version>`. The
108
+ `SDK release` workflow tests, builds and publishes to npm with provenance.
109
+
110
+ ## License
111
+
112
+ Apache License 2.0 with the Commons Clause condition. See [LICENSE](https://github.com/orion-belt-dev/orion-belt/blob/master/LICENSE).
@@ -0,0 +1,232 @@
1
+ import type { AccessAnomaly, AccessExplanation, AccessRequest, AgentInstallScriptRequest, AgentInstallScriptResponse, APIKey, APIKeyLoginResult, AuditLog, AuthUser, BootstrapCode, BulkGrantRequest, BulkResult, CapabilityCatalog, CreateAccessRequestRequest, CreateAPIKeyRequest, CreateAPIKeyResponse, CreateMachineRequest, CreateUserRequest, EffectiveAccess, FileListResponse, FileUploadResponse, GatewayInfo, GrantPermissionRequest, IssuedCert, JWTLoginResult, KubeReconcileResult, Machine, MFAEnrollResponse, MFAStatus, Notification, NotificationPolicy, NotificationPolicyResult, NotificationPrefs, NotificationPrefsResult, NotificationTemplate, NotificationTemplateEntry, PasswordLoginResult, Permission, PluginConfigResult, PluginInfo, RegisterAgentRequest, RegisterAgentResponse, RegisterClientRequest, RegisterClientResponse, RiskPolicy, Session, SetupStatus, SSHCertificate, SSHKey, TrustedCA, UpdateMachineRequest, UpdatePermissionRequest, UpdateUserRequest, UsageDashboard, User, VersionInfo, WebAuthnCredential } from './types.js';
2
+ export type ClientOptions = {
3
+ /** Server base URL, e.g. https://pam.example.com. */
4
+ baseUrl: string;
5
+ apiKey?: string;
6
+ sessionToken?: string;
7
+ bearerToken?: string;
8
+ /** Per-request timeout; 0 disables it. Defaults to 30 s. */
9
+ timeoutMs?: number;
10
+ /**
11
+ * Sent as User-Agent where the runtime allows it (not in browsers). The
12
+ * gateway records it as the device signal on access requests.
13
+ */
14
+ userAgent?: string;
15
+ headers?: Record<string, string>;
16
+ /** fetch implementation; defaults to the global one. */
17
+ fetch?: typeof fetch;
18
+ };
19
+ /**
20
+ * Proves possession of an SSH key for the challenge logins. `publicKey` is
21
+ * the authorized_keys line; `sign` returns the SSH signature format
22
+ * (ssh-ed25519, rsa-sha2-256, ...) and the raw signature blob over `data`.
23
+ */
24
+ export interface Signer {
25
+ readonly publicKey: string;
26
+ sign(data: Uint8Array): Promise<{
27
+ format: string;
28
+ signature: Uint8Array;
29
+ }> | {
30
+ format: string;
31
+ signature: Uint8Array;
32
+ };
33
+ }
34
+ /** A non-2xx response. `message` is the server's `error` field when it sent one. */
35
+ export declare class ApiError extends Error {
36
+ readonly statusCode: number;
37
+ readonly body: string;
38
+ readonly serverMessage: string;
39
+ constructor(statusCode: number, serverMessage: string, body: string);
40
+ }
41
+ /**
42
+ * Client for one Orion Belt server. Auth precedence matches the server:
43
+ * X-API-Key wins over X-Session-Token; a bearer token is sent alongside
44
+ * either. The login helpers store the credential they obtain on the client.
45
+ */
46
+ export declare class OrionBeltClient {
47
+ readonly baseUrl: string;
48
+ private readonly timeoutMs;
49
+ private readonly headers;
50
+ private readonly fetchImpl;
51
+ private apiKey;
52
+ private sessionToken;
53
+ private bearerToken;
54
+ constructor(options: ClientOptions);
55
+ setApiKey(apiKey?: string): void;
56
+ setSessionToken(sessionToken?: string): void;
57
+ setBearerToken(bearerToken?: string): void;
58
+ /** Current credentials, e.g. to persist a session obtained by a login helper. */
59
+ get credentials(): {
60
+ apiKey?: string;
61
+ sessionToken?: string;
62
+ bearerToken?: string;
63
+ };
64
+ /** Absolute URL for an API path; paths without /api/ are taken as /api/v1-relative. */
65
+ url(path: string): string;
66
+ /** The credential headers this client sends, e.g. for opening the WebSocket endpoints. */
67
+ authHeaders(): Record<string, string>;
68
+ private send;
69
+ /**
70
+ * Sends a JSON request and returns the decoded response (undefined for an
71
+ * empty body). Use it for endpoints this client has no method for yet.
72
+ */
73
+ request<T = unknown>(method: string, path: string, body?: unknown, options?: {
74
+ auth?: boolean;
75
+ }): Promise<T>;
76
+ /** Sends a request without a body and returns the raw response bytes. */
77
+ requestBytes(method: string, path: string, options?: {
78
+ auth?: boolean;
79
+ }): Promise<Uint8Array>;
80
+ private list;
81
+ private storeSession;
82
+ /** Addresses the gateway advertises to clients and agents. Needs no credentials. */
83
+ getGatewayInfo(): Promise<GatewayInfo>;
84
+ /** The server's build version. Needs no credentials. */
85
+ getVersion(): Promise<VersionInfo>;
86
+ /** The server's OpenAPI 3 document, as YAML text. */
87
+ getOpenApiSpec(): Promise<string>;
88
+ /** Where to find the OpenAPI document (/openapi.json answers with pointers, not the spec). */
89
+ getOpenApiIndex(): Promise<Record<string, unknown>>;
90
+ /** Registers an agent. The server requires an admin or operator, so credentials are sent. */
91
+ registerAgent(req: RegisterAgentRequest): Promise<RegisterAgentResponse>;
92
+ /** Registers a user. `is_admin` is honoured only for an admin caller or the first account. */
93
+ registerClient(req: RegisterClientRequest): Promise<RegisterClientResponse>;
94
+ /** A one-time challenge for the SSH-key logins. */
95
+ issueChallenge(username: string): Promise<string>;
96
+ private signedLogin;
97
+ /** SSH challenge login that returns a session token (POST /public/login). */
98
+ loginWithSshSession(username: string, signer: Signer, totpCode?: string): Promise<PasswordLoginResult>;
99
+ /** SSH challenge login that returns an API key (POST /public/login/key). */
100
+ loginWithSshKey(username: string, signer: Signer, totpCode?: string): Promise<APIKeyLoginResult>;
101
+ /** SSH challenge login that returns a JWT bearer token (POST /public/login/token). */
102
+ loginWithSshJwt(username: string, signer: Signer, totpCode?: string): Promise<JWTLoginResult>;
103
+ loginWithPassword(username: string, password: string, totpCode?: string): Promise<PasswordLoginResult>;
104
+ redeemBrowserBootstrap(code: string): Promise<PasswordLoginResult>;
105
+ webauthnLoginBegin(username: string): Promise<Record<string, unknown>>;
106
+ webauthnLoginFinish(username: string, response: Record<string, unknown>): Promise<PasswordLoginResult>;
107
+ /** Calls a plugin's inbound webhook. The plugin authenticates the caller itself. */
108
+ pluginWebhook<T = unknown>(plugin: string, path: string, method?: string, body?: unknown): Promise<T>;
109
+ /**
110
+ * Ends the HTTP session and drops the session and bearer tokens from this
111
+ * client. The server does not revoke a JWT at logout: one issued alongside
112
+ * the session stays valid until it expires.
113
+ */
114
+ logout(): Promise<void>;
115
+ getCurrentUser(): Promise<AuthUser>;
116
+ /** A one-time code that opens a browser session as this user. */
117
+ requestBrowserBootstrap(): Promise<BootstrapCode>;
118
+ setPassword(password: string, totpCode: string): Promise<void>;
119
+ clearPassword(totpCode: string): Promise<void>;
120
+ mfaEnroll(): Promise<MFAEnrollResponse>;
121
+ mfaConfirm(code: string): Promise<void>;
122
+ mfaDisable(code: string): Promise<void>;
123
+ mfaStatus(): Promise<MFAStatus>;
124
+ webauthnRegisterBegin(): Promise<Record<string, unknown>>;
125
+ /** Completes registration and returns the new credential's ID. */
126
+ webauthnRegisterFinish(response: Record<string, unknown>): Promise<string>;
127
+ webauthnCredentials(): Promise<WebAuthnCredential[]>;
128
+ webauthnDeleteCredential(credentialId: string): Promise<void>;
129
+ listSshKeys(): Promise<SSHKey[]>;
130
+ addSshKey(name: string, publicKey: string): Promise<SSHKey>;
131
+ deleteSshKey(keyId: string): Promise<void>;
132
+ /** Creates a key; the raw key is in `api_key` and is returned only this once. */
133
+ createApiKey(req: CreateAPIKeyRequest): Promise<CreateAPIKeyResponse>;
134
+ listApiKeys(): Promise<APIKey[]>;
135
+ revokeApiKey(keyId: string): Promise<void>;
136
+ deleteApiKey(keyId: string): Promise<void>;
137
+ listNotifications(limit?: number): Promise<Notification[]>;
138
+ unreadNotificationCount(): Promise<number>;
139
+ markNotificationRead(notificationId: string): Promise<void>;
140
+ markAllNotificationsRead(): Promise<void>;
141
+ /** The caller's preferences and the admin bounds they were resolved within. */
142
+ getNotificationPrefs(): Promise<NotificationPrefsResult>;
143
+ /** Stores preferences. Values outside the admin policy are clamped; `adjusted` says so. */
144
+ putNotificationPrefs(prefs: NotificationPrefs): Promise<NotificationPrefsResult>;
145
+ listUsers(): Promise<User[]>;
146
+ getUser(userId: string): Promise<User>;
147
+ createUser(req: CreateUserRequest): Promise<User>;
148
+ updateUser(userId: string, req: UpdateUserRequest): Promise<User>;
149
+ deleteUser(userId: string): Promise<void>;
150
+ listMachines(): Promise<Machine[]>;
151
+ getMachine(machineId: string): Promise<Machine>;
152
+ /** Resolves a machine by name from listMachines; throws when absent. */
153
+ getMachineByName(name: string): Promise<Machine>;
154
+ createMachine(req: CreateMachineRequest): Promise<Machine>;
155
+ updateMachine(machineId: string, req: UpdateMachineRequest): Promise<Machine>;
156
+ /** Deletes a machine, or with `archive` deactivates it and keeps its history. */
157
+ deleteMachine(machineId: string, archive?: boolean): Promise<void>;
158
+ /** Reconciles a cluster's RoleBindings with its grants; `dryRun` only reports drift. */
159
+ kubeReconcile(machineId: string, dryRun?: boolean): Promise<KubeReconcileResult>;
160
+ getUserPermissions(userId: string): Promise<Permission[]>;
161
+ getMachinePermissions(machineId: string): Promise<Permission[]>;
162
+ listAllPermissions(limit?: number): Promise<Permission[]>;
163
+ grantPermission(req: GrantPermissionRequest): Promise<Permission>;
164
+ updatePermission(permissionId: string, req: UpdatePermissionRequest): Promise<Permission>;
165
+ revokePermission(permissionId: string): Promise<void>;
166
+ /** Grants one access type on every user x machine pair. */
167
+ bulkGrantPermissions(req: BulkGrantRequest): Promise<BulkResult>;
168
+ bulkRevokePermissions(ids: string[]): Promise<BulkResult>;
169
+ /** Resolved access for one user or one machine; set exactly one. */
170
+ effectivePermissions(filter: {
171
+ userId?: string;
172
+ machineId?: string;
173
+ }): Promise<EffectiveAccess[]>;
174
+ /** What the caller holds or could request. `scope` is "related" (default) or "all". */
175
+ listCapabilities(scope?: string, userId?: string): Promise<CapabilityCatalog>;
176
+ /** Whether a user (default: the caller) may reach a machine as `remoteUser`, and why. */
177
+ explainAccess(machine: string, remoteUser: string, accessType?: string, user?: string): Promise<AccessExplanation>;
178
+ listAccessRequests(status?: string): Promise<AccessRequest[]>;
179
+ createAccessRequest(req: CreateAccessRequestRequest): Promise<AccessRequest>;
180
+ getAccessRequest(requestId: string): Promise<AccessRequest>;
181
+ listPendingAccessRequests(): Promise<AccessRequest[]>;
182
+ approveAccessRequest(requestId: string, reviewerId?: string): Promise<void>;
183
+ rejectAccessRequest(requestId: string, reviewerId?: string): Promise<void>;
184
+ getRiskPolicy(): Promise<RiskPolicy>;
185
+ /** Replaces the risk policy outright; send the whole document. */
186
+ putRiskPolicy(policy: RiskPolicy): Promise<RiskPolicy>;
187
+ listSessions(status?: string): Promise<Session[]>;
188
+ listActiveSessions(): Promise<Session[]>;
189
+ getSession(sessionId: string): Promise<Session>;
190
+ /** The raw session recording. */
191
+ getSessionContent(sessionId: string): Promise<Uint8Array>;
192
+ listAuditLogs(limit?: number): Promise<AuditLog[]>;
193
+ /** Report bytes. `params` carries report options such as from/to or as_of. */
194
+ exportReport(reportName: string, format?: string, params?: Record<string, string>): Promise<Uint8Array>;
195
+ getUsageDashboard(windowHours?: number, top?: number): Promise<UsageDashboard>;
196
+ listAnomalies(limit?: number, userId?: string): Promise<AccessAnomaly[]>;
197
+ getSetupStatus(): Promise<SetupStatus>;
198
+ getNotificationPolicy(): Promise<NotificationPolicyResult>;
199
+ /** Replaces the policy outright; send the whole document. */
200
+ putNotificationPolicy(policy: NotificationPolicy): Promise<NotificationPolicy>;
201
+ listNotificationTemplates(): Promise<NotificationTemplateEntry[]>;
202
+ putNotificationTemplate(event: string, template: NotificationTemplate): Promise<NotificationTemplate>;
203
+ /** Drops the override, returning the event to its built-in copy. */
204
+ deleteNotificationTemplate(event: string): Promise<void>;
205
+ listPlugins(): Promise<PluginInfo[]>;
206
+ /** Stores config. `configure_error` reports a config the plugin rejected after saving. */
207
+ updatePluginConfig(name: string, enabled: boolean, config: Record<string, unknown>): Promise<PluginConfigResult>;
208
+ enablePlugin(name: string): Promise<PluginInfo>;
209
+ disablePlugin(name: string): Promise<PluginInfo>;
210
+ /** Machine IDs with a live agent connection. */
211
+ listConnectedAgents(): Promise<string[]>;
212
+ /** Sends a control command (reload, drain, undrain, update) and returns its output. */
213
+ sendAgentCommand(machineId: string, command: string): Promise<string>;
214
+ disconnectAgent(machineId: string): Promise<void>;
215
+ generateAgentInstallScript(req: AgentInstallScriptRequest): Promise<AgentInstallScriptResponse>;
216
+ getTrustedCa(): Promise<TrustedCA>;
217
+ issueUserCert(publicKey: string, ttlHours?: number): Promise<IssuedCert>;
218
+ exportCa(): Promise<TrustedCA>;
219
+ listSshCertificates(certType?: string): Promise<SSHCertificate[]>;
220
+ revokeSshCertificate(serial: string, reason?: string): Promise<void>;
221
+ /** Lists a directory; the server defaults to "/" as root. */
222
+ listFiles(machine: string, path?: string, remoteUser?: string): Promise<FileListResponse>;
223
+ downloadFile(machine: string, path: string, remoteUser?: string): Promise<Uint8Array>;
224
+ uploadFile(machine: string, path: string, fileName: string, content: Blob | Uint8Array | ArrayBuffer, remoteUser?: string): Promise<FileUploadResponse>;
225
+ makeDir(machine: string, path: string, remoteUser?: string): Promise<void>;
226
+ deleteFile(machine: string, path: string, remoteUser?: string): Promise<void>;
227
+ private wsUrl;
228
+ /** URL of an interactive web terminal on `machine`. */
229
+ terminalWsUrl(machine: string, remoteUser?: string): string;
230
+ /** URL that streams a live session's output to a watcher. */
231
+ sessionWatchWsUrl(sessionId: string): string;
232
+ }