sarvam-agents-client 0.5.2 → 0.5.3
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 +52 -29
- package/dist/apis/AgentsApi.d.ts +96 -11
- package/dist/apis/AgentsApi.js +229 -9
- package/dist/apis/ConversationsApi.d.ts +5 -2
- package/dist/apis/ConversationsApi.js +7 -2
- package/dist/client.d.ts +3 -2
- package/dist/client.js +2 -1
- package/dist/compose/deploy.d.ts +14 -3
- package/dist/compose/deploy.js +60 -7
- package/dist/compose/errors.d.ts +4 -0
- package/dist/compose/errors.js +6 -1
- package/dist/compose/settingsTransport.d.ts +18 -13
- package/dist/compose/settingsTransport.js +78 -130
- package/dist/compose/transport.d.ts +12 -2
- package/dist/compose/webhook.d.ts +10 -13
- package/dist/compose/webhook.js +48 -45
- package/dist/compose/webhookSecrets.d.ts +79 -49
- package/dist/compose/webhookSecrets.js +244 -195
- package/dist/esm/apis/AgentsApi.d.ts +96 -11
- package/dist/esm/apis/AgentsApi.js +230 -10
- package/dist/esm/apis/ConversationsApi.d.ts +5 -2
- package/dist/esm/apis/ConversationsApi.js +7 -2
- package/dist/esm/client.d.ts +3 -2
- package/dist/esm/client.js +2 -1
- package/dist/esm/compose/deploy.d.ts +14 -3
- package/dist/esm/compose/deploy.js +60 -7
- package/dist/esm/compose/errors.d.ts +4 -0
- package/dist/esm/compose/errors.js +4 -0
- package/dist/esm/compose/settingsTransport.d.ts +18 -13
- package/dist/esm/compose/settingsTransport.js +80 -132
- package/dist/esm/compose/transport.d.ts +12 -2
- package/dist/esm/compose/webhook.d.ts +10 -13
- package/dist/esm/compose/webhook.js +45 -42
- package/dist/esm/compose/webhookSecrets.d.ts +79 -49
- package/dist/esm/compose/webhookSecrets.js +241 -193
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/models/AgentConversationDetail.d.ts +12 -0
- package/dist/esm/models/AgentConversationDetail.js +4 -0
- package/dist/esm/models/AgentConversationView.d.ts +12 -0
- package/dist/esm/models/AgentConversationView.js +4 -0
- package/dist/esm/models/AgentResource.d.ts +7 -0
- package/dist/esm/models/AgentResource.js +3 -0
- package/dist/esm/models/AgentVersionSavedResource.d.ts +65 -0
- package/dist/esm/models/AgentVersionSavedResource.js +60 -0
- package/dist/esm/models/AgentWebhookList.d.ts +33 -0
- package/dist/esm/models/AgentWebhookList.js +44 -0
- package/dist/esm/models/AgentWebhookView.d.ts +76 -0
- package/dist/esm/models/AgentWebhookView.js +70 -0
- package/dist/esm/models/ConversationDetail.d.ts +6 -0
- package/dist/esm/models/ConversationDetail.js +2 -0
- package/dist/esm/models/ConversationView.d.ts +6 -0
- package/dist/esm/models/ConversationView.js +2 -0
- package/dist/esm/models/ErrorDetailItem.d.ts +3 -0
- package/dist/esm/models/FileNodeView.d.ts +7 -0
- package/dist/esm/models/FileNodeView.js +3 -0
- package/dist/esm/models/QueueMessageInput.d.ts +6 -0
- package/dist/esm/models/QueueMessageInput.js +2 -0
- package/dist/esm/models/RotatedWebhookSecretView.d.ts +58 -0
- package/dist/esm/models/RotatedWebhookSecretView.js +61 -0
- package/dist/esm/models/SaveWarningView.d.ts +44 -0
- package/dist/esm/models/SaveWarningView.js +51 -0
- package/dist/esm/models/ShareSkippedResource.d.ts +41 -0
- package/dist/esm/models/ShareSkippedResource.js +47 -0
- package/dist/esm/models/WebhookSecretPutBody.d.ts +32 -0
- package/dist/esm/models/WebhookSecretPutBody.js +43 -0
- package/dist/esm/models/WebhookSecretStateView.d.ts +52 -0
- package/dist/esm/models/WebhookSecretStateView.js +56 -0
- package/dist/esm/models/WebhookSecretValueView.d.ts +32 -0
- package/dist/esm/models/WebhookSecretValueView.js +44 -0
- package/dist/esm/models/WebhookWarning.d.ts +44 -0
- package/dist/esm/models/WebhookWarning.js +51 -0
- package/dist/esm/models/index.d.ts +10 -0
- package/dist/esm/models/index.js +10 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -1
- package/dist/models/AgentConversationDetail.d.ts +12 -0
- package/dist/models/AgentConversationDetail.js +4 -0
- package/dist/models/AgentConversationView.d.ts +12 -0
- package/dist/models/AgentConversationView.js +4 -0
- package/dist/models/AgentResource.d.ts +7 -0
- package/dist/models/AgentResource.js +3 -0
- package/dist/models/AgentVersionSavedResource.d.ts +65 -0
- package/dist/models/AgentVersionSavedResource.js +67 -0
- package/dist/models/AgentWebhookList.d.ts +33 -0
- package/dist/models/AgentWebhookList.js +51 -0
- package/dist/models/AgentWebhookView.d.ts +76 -0
- package/dist/models/AgentWebhookView.js +78 -0
- package/dist/models/ConversationDetail.d.ts +6 -0
- package/dist/models/ConversationDetail.js +2 -0
- package/dist/models/ConversationView.d.ts +6 -0
- package/dist/models/ConversationView.js +2 -0
- package/dist/models/ErrorDetailItem.d.ts +3 -0
- package/dist/models/FileNodeView.d.ts +7 -0
- package/dist/models/FileNodeView.js +3 -0
- package/dist/models/QueueMessageInput.d.ts +6 -0
- package/dist/models/QueueMessageInput.js +2 -0
- package/dist/models/RotatedWebhookSecretView.d.ts +58 -0
- package/dist/models/RotatedWebhookSecretView.js +69 -0
- package/dist/models/SaveWarningView.d.ts +44 -0
- package/dist/models/SaveWarningView.js +58 -0
- package/dist/models/ShareSkippedResource.d.ts +41 -0
- package/dist/models/ShareSkippedResource.js +54 -0
- package/dist/models/WebhookSecretPutBody.d.ts +32 -0
- package/dist/models/WebhookSecretPutBody.js +50 -0
- package/dist/models/WebhookSecretStateView.d.ts +52 -0
- package/dist/models/WebhookSecretStateView.js +64 -0
- package/dist/models/WebhookSecretValueView.d.ts +32 -0
- package/dist/models/WebhookSecretValueView.js +51 -0
- package/dist/models/WebhookWarning.d.ts +44 -0
- package/dist/models/WebhookWarning.js +58 -0
- package/dist/models/index.d.ts +10 -0
- package/dist/models/index.js +10 -0
- package/package.json +1 -1
- package/src/apis/AgentsApi.ts +366 -11
- package/src/apis/ConversationsApi.ts +9 -2
- package/src/client.ts +3 -2
- package/src/compose/deploy.ts +71 -10
- package/src/compose/errors.ts +4 -0
- package/src/compose/settingsTransport.ts +78 -131
- package/src/compose/transport.ts +10 -2
- package/src/compose/webhook.ts +49 -45
- package/src/compose/webhookSecrets.ts +227 -179
- package/src/index.ts +2 -1
- package/src/models/AgentConversationDetail.ts +16 -0
- package/src/models/AgentConversationView.ts +16 -0
- package/src/models/AgentResource.ts +15 -0
- package/src/models/AgentVersionSavedResource.ts +119 -0
- package/src/models/AgentWebhookList.ts +74 -0
- package/src/models/AgentWebhookView.ts +129 -0
- package/src/models/ConversationDetail.ts +8 -0
- package/src/models/ConversationView.ts +8 -0
- package/src/models/ErrorDetailItem.ts +3 -0
- package/src/models/FileNodeView.ts +16 -0
- package/src/models/QueueMessageInput.ts +8 -0
- package/src/models/RotatedWebhookSecretView.ts +103 -0
- package/src/models/SaveWarningView.ts +84 -0
- package/src/models/ShareSkippedResource.ts +78 -0
- package/src/models/WebhookSecretPutBody.ts +66 -0
- package/src/models/WebhookSecretStateView.ts +94 -0
- package/src/models/WebhookSecretValueView.ts +66 -0
- package/src/models/WebhookWarning.ts +84 -0
- package/src/models/index.ts +10 -0
package/dist/compose/webhook.js
CHANGED
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.WEBHOOKS_MAX = void 0;
|
|
4
4
|
exports.urlProblem = urlProblem;
|
|
5
5
|
exports.checkWebhooks = checkWebhooks;
|
|
6
6
|
exports.copyWebhooks = copyWebhooks;
|
|
7
7
|
exports.webhooksJson = webhooksJson;
|
|
8
8
|
exports.webhookHost = webhookHost;
|
|
9
|
-
exports.
|
|
10
|
-
exports.
|
|
9
|
+
exports.isLegacyCredentialName = isLegacyCredentialName;
|
|
10
|
+
exports.withoutLegacyCredentials = withoutLegacyCredentials;
|
|
11
11
|
/**
|
|
12
12
|
* `webhooks` entries of `agent.json`, checked locally with the server's cheap rules (as the Python SDK does).
|
|
13
13
|
*
|
|
14
|
-
* The server (`claw_common/agent_settings/webhooks.py`) also checks that the host resolves to a public address
|
|
15
|
-
*
|
|
16
|
-
* I/O and stay on the server, which refuses the save with a 422 that `deploy` throws as `UserError`.
|
|
14
|
+
* The server (`claw_common/agent_settings/webhooks.py`) also checks that the host resolves to a public address; that
|
|
15
|
+
* needs I/O and stays on the server, which refuses the save with a 422 that `deploy` throws as `UserError`.
|
|
17
16
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
17
|
+
* A webhook is identified by its URL. Its signing secret lives in the server's webhook secret store (panja #1857):
|
|
18
|
+
* `deploy` creates it for each webhook it adds and returns it once (`Deployment.webhookSecrets`);
|
|
19
|
+
* `client.webhooks` views, rotates, sets and deletes it.
|
|
20
|
+
*
|
|
21
|
+
* `secretCredential` is deprecated and ignored: the server no longer reads the vault for signing. It is still
|
|
22
|
+
* accepted and never sent, so `agent.json` stays clean.
|
|
21
23
|
*/
|
|
22
24
|
const node_crypto_1 = require("node:crypto");
|
|
23
25
|
const errors_js_1 = require("./errors.js");
|
|
24
26
|
const webhooks_js_1 = require("../webhooks.js");
|
|
25
27
|
exports.WEBHOOKS_MAX = 5;
|
|
26
28
|
const WEBHOOK_URL_MAX = 2048;
|
|
27
|
-
const SECRET_CREDENTIAL_MAX = 256;
|
|
28
29
|
const LABEL = /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/;
|
|
29
30
|
// A last label that is a number (decimal, or 0x hex) makes resolvers read the whole host as an IPv4 address.
|
|
30
31
|
const NUMERIC_LABEL = /^(?:[0-9]+|0x[0-9a-f]*)$/;
|
|
@@ -156,7 +157,8 @@ function checkWebhooks(webhooks) {
|
|
|
156
157
|
throw new errors_js_1.UserError(where + "secretCredential: must be a string");
|
|
157
158
|
}
|
|
158
159
|
// Python's Webhook is extra="forbid": a key dropped silently (a misplaced secret) would never verify.
|
|
159
|
-
|
|
160
|
+
// A webhook is identified by its URL: a `name` is refused here, as the server does.
|
|
161
|
+
const extra = Object.keys(hook).find((k) => !["url", "events", "secretCredential"].includes(k));
|
|
160
162
|
if (extra !== undefined)
|
|
161
163
|
throw new errors_js_1.UserError(where + extra + ": Extra inputs are not permitted");
|
|
162
164
|
const problem = urlProblem(url);
|
|
@@ -170,11 +172,6 @@ function checkWebhooks(webhooks) {
|
|
|
170
172
|
}
|
|
171
173
|
if (new Set(events).size !== events.length)
|
|
172
174
|
throw new errors_js_1.UserError(where + "events: events must not repeat an event.");
|
|
173
|
-
const n = typeof secretCredential === "string" ? codePoints(secretCredential) : 1;
|
|
174
|
-
if (n < 1 || n > SECRET_CREDENTIAL_MAX) {
|
|
175
|
-
throw new errors_js_1.UserError(where + "secret_credential: secret_credential must be the name of a vault credential " +
|
|
176
|
-
`(1 to ${SECRET_CREDENTIAL_MAX} characters).`);
|
|
177
|
-
}
|
|
178
175
|
const key = urlKey(url);
|
|
179
176
|
if (seen.has(key)) {
|
|
180
177
|
throw new errors_js_1.UserError(where + "url: webhooks must not list the same url twice; put all its events on one entry.");
|
|
@@ -182,47 +179,30 @@ function checkWebhooks(webhooks) {
|
|
|
182
179
|
seen.add(key);
|
|
183
180
|
});
|
|
184
181
|
}
|
|
185
|
-
/** Only
|
|
186
|
-
* writes anyway (one spelling keeps one fingerprint). */
|
|
182
|
+
/** Only `url` and `events` (a copy): `secretCredential` is ignored, so it is dropped here. */
|
|
187
183
|
function copyWebhooks(webhooks) {
|
|
188
|
-
return webhooks.map((h) => {
|
|
189
|
-
const copy = { url: h.url, events: [...h.events] };
|
|
190
|
-
const name = h.secretCredential;
|
|
191
|
-
if (name !== undefined && !isSdkCredentialName(name, h.url))
|
|
192
|
-
copy.secretCredential = name;
|
|
193
|
-
return copy;
|
|
194
|
-
});
|
|
184
|
+
return webhooks.map((h) => ({ url: h.url, events: [...h.events] }));
|
|
195
185
|
}
|
|
196
186
|
function webhooksJson(webhooks) {
|
|
197
|
-
return webhooks.map((h) => {
|
|
198
|
-
const out = { url: h.url, events: [...h.events] };
|
|
199
|
-
if (h.secretCredential !== undefined)
|
|
200
|
-
out["secret_credential"] = h.secretCredential;
|
|
201
|
-
return out;
|
|
202
|
-
});
|
|
187
|
+
return webhooks.map((h) => ({ url: h.url, events: [...h.events] }));
|
|
203
188
|
}
|
|
204
189
|
/** The host of an allowed webhook URL, lowercased, without a trailing dot or a port. */
|
|
205
190
|
function webhookHost(url) {
|
|
206
191
|
return stripTrailingDots(hostPort(split(url)[1])[0]);
|
|
207
192
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
193
|
+
// -- 0.5.x compatibility ----------------------------------------------------------------------------------------
|
|
194
|
+
// The 0.5.x SDK filled in `secret_credential` as `webhook-secret:<agentId>:<host>` on every webhook it deployed. An
|
|
195
|
+
// agent it deployed still has that name in agent.json; the deploy reads such a webhook without it, so the stored
|
|
196
|
+
// `sdk_hash` (computed without it) still matches and the agent does not read as edited outside the SDK.
|
|
197
|
+
const LEGACY_PREFIX = "webhook-secret:";
|
|
211
198
|
function hashedHost(host) {
|
|
212
199
|
return "sha256-" + (0, node_crypto_1.createHash)("sha256").update(host, "utf8").digest("hex").slice(0, 32);
|
|
213
200
|
}
|
|
214
|
-
/**
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
const host = webhookHost(url);
|
|
218
|
-
const name = `${exports.SECRET_NAME_PREFIX}${agentId}:${host}`;
|
|
219
|
-
return codePoints(name) <= SECRET_NAME_MAX ? name : `${exports.SECRET_NAME_PREFIX}${agentId}:${hashedHost(host)}`;
|
|
220
|
-
}
|
|
221
|
-
/** Whether `name` is the SDK's credential name for `url`'s host, for any agent. */
|
|
222
|
-
function isSdkCredentialName(name, url) {
|
|
223
|
-
if (typeof name !== "string" || !name.startsWith(exports.SECRET_NAME_PREFIX) || urlProblem(url) !== null)
|
|
201
|
+
/** Whether `name` is the `secret_credential` the 0.5.x SDK filled in for `url`'s host, for any agent. */
|
|
202
|
+
function isLegacyCredentialName(name, url) {
|
|
203
|
+
if (typeof name !== "string" || !name.startsWith(LEGACY_PREFIX) || urlProblem(url) !== null)
|
|
224
204
|
return false;
|
|
225
|
-
const rest = name.slice(
|
|
205
|
+
const rest = name.slice(LEGACY_PREFIX.length);
|
|
226
206
|
const at = rest.lastIndexOf(":");
|
|
227
207
|
if (at <= 0)
|
|
228
208
|
return false;
|
|
@@ -231,3 +211,26 @@ function isSdkCredentialName(name, url) {
|
|
|
231
211
|
const host = webhookHost(url);
|
|
232
212
|
return !agentId.includes(":") && (tail === host || tail === hashedHost(host));
|
|
233
213
|
}
|
|
214
|
+
/** `settings` with the `secret_credential` the 0.5.x SDK filled in removed from each webhook. */
|
|
215
|
+
function withoutLegacyCredentials(settings) {
|
|
216
|
+
const hooks = settings["webhooks"];
|
|
217
|
+
if (!Array.isArray(hooks))
|
|
218
|
+
return settings;
|
|
219
|
+
const legacy = (h) => {
|
|
220
|
+
if (typeof h !== "object" || h === null)
|
|
221
|
+
return false;
|
|
222
|
+
const { url, secret_credential: name } = h;
|
|
223
|
+
return typeof url === "string" && isLegacyCredentialName(name, url);
|
|
224
|
+
};
|
|
225
|
+
if (!hooks.some(legacy))
|
|
226
|
+
return settings;
|
|
227
|
+
return {
|
|
228
|
+
...settings,
|
|
229
|
+
webhooks: hooks.map((h) => {
|
|
230
|
+
if (!legacy(h))
|
|
231
|
+
return h;
|
|
232
|
+
const { secret_credential: _dropped, ...rest } = h;
|
|
233
|
+
return rest;
|
|
234
|
+
}),
|
|
235
|
+
};
|
|
236
|
+
}
|
|
@@ -1,64 +1,94 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `client.webhooks`:
|
|
3
|
-
* `sarvam_agents.compose.webhook_secrets`).
|
|
2
|
+
* `client.webhooks`: list an agent's webhooks, and create, view, rotate, set and delete each one's signing secret (as
|
|
3
|
+
* Python's `sarvam_agents.compose.webhook_secrets`).
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* (SARC-2597: PUT/DELETE secret, rotate-secret, secretStatus), a second backend replaces this one in `secretBackend`
|
|
10
|
-
* and nothing else changes.
|
|
5
|
+
* Built on the owner-only routes of the server's webhook secret store (panja #1857, SARC-2597):
|
|
6
|
+
* `GET /v1/agents/{id}/webhooks` and `POST`/`GET`/`PUT`/`DELETE .../webhooks/{webhookKey}/secret` and
|
|
7
|
+
* `POST .../rotate-secret`. The `webhookKey` is always read from the list, by the webhook's exact URL; it is never
|
|
8
|
+
* computed here.
|
|
11
9
|
*
|
|
12
10
|
* No secret is logged, kept on an object or put in an error message.
|
|
13
11
|
*/
|
|
14
|
-
import {
|
|
12
|
+
import { AgentsApi } from "../apis/AgentsApi.js";
|
|
13
|
+
import type { AgentWebhookView } from "../models/AgentWebhookView.js";
|
|
15
14
|
import type { Configuration } from "../runtime.js";
|
|
16
15
|
import type { Webhook } from "./webhook.js";
|
|
16
|
+
/** `"set"`: deliveries are signed with the webhook's secret. `"missing"`: it has none, so nothing is sent to it. */
|
|
17
17
|
export type SecretStatus = "set" | "missing";
|
|
18
|
-
/**
|
|
19
|
-
export declare const
|
|
20
|
-
/** The
|
|
21
|
-
|
|
22
|
-
export declare const PLACEHOLDER_DESCRIPTION = "Webhook signing secret managed by the Sarvam Agents SDK (client.webhooks). Placeholder: call client.webhooks.set_secret";
|
|
23
|
-
/** Where webhook secrets live. Swap the implementation in `secretBackend`, nowhere else. */
|
|
24
|
-
export interface SecretBackend {
|
|
25
|
-
/** Store `secret` for `url` on the agent, replacing any current one. */
|
|
26
|
-
put(agentId: string, url: string, secret: string): Promise<void>;
|
|
27
|
-
/** `"set"` only for a secret stored by `put`; a placeholder from `ensure` is `"missing"`. */
|
|
28
|
-
status(agentId: string, url: string): Promise<SecretStatus>;
|
|
29
|
-
/** Remove the secret; nothing to remove is not an error. */
|
|
30
|
-
delete(agentId: string, url: string): Promise<void>;
|
|
31
|
-
/** For `deploy`: make sure the agent has a secret for `url` (a random placeholder one if none) and return the
|
|
32
|
-
* credential name for agent.json `secret_credential` and `status` (`"missing"` while it is a placeholder). */
|
|
33
|
-
ensure(agentId: string, url: string): Promise<{
|
|
34
|
-
name: string;
|
|
35
|
-
status: SecretStatus;
|
|
36
|
-
}>;
|
|
37
|
-
}
|
|
38
|
-
/** The one place that picks where secrets live. */
|
|
39
|
-
export declare function secretBackend(api: {
|
|
40
|
-
config?: Configuration;
|
|
41
|
-
customApis?: CustomAPIsApi;
|
|
42
|
-
}): SecretBackend;
|
|
18
|
+
/** How long a replaced secret keeps signing after `rotateSecret` or `setSecret` (fixed by the server). */
|
|
19
|
+
export declare const PREVIOUS_SECRET_SECONDS = 86400;
|
|
20
|
+
/** The fine-grained reason of a chat_service error (`details[0].code` or `.reason`), else undefined. */
|
|
21
|
+
export declare function errorCode(err: unknown): Promise<string | undefined>;
|
|
43
22
|
/**
|
|
44
|
-
* `client.webhooks`:
|
|
23
|
+
* `client.webhooks`: an agent's agent.json webhooks and each one's signing secret.
|
|
24
|
+
*
|
|
25
|
+
* `url` is the webhook's URL exactly as in agent.json (or a webhook object). Its `webhookKey` is read from `list` by
|
|
26
|
+
* exact URL match, so the agent must have the webhook (`deploy` it first). Secrets are `whsec_` plus base64 of 24 to
|
|
27
|
+
* 64 bytes. Only the agent's owner can call these.
|
|
45
28
|
*
|
|
46
|
-
* `
|
|
47
|
-
*
|
|
29
|
+
* `deploy` already creates the secret of each webhook it adds and returns it once (`Deployment.webhookSecrets`).
|
|
30
|
+
* Nothing is delivered to a webhook without a secret.
|
|
48
31
|
*/
|
|
49
32
|
export declare class WebhookSecrets {
|
|
50
33
|
#private;
|
|
34
|
+
/** The generated API these helpers call. */
|
|
35
|
+
readonly api: AgentsApi;
|
|
51
36
|
constructor(config: Configuration);
|
|
52
|
-
/**
|
|
53
|
-
*
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
*
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
|
|
63
|
-
|
|
37
|
+
/**
|
|
38
|
+
* The agent's webhooks, each with `webhookKey`, `url`, `events`, `inAgentJson`, `secretStatus` (`"set"` or
|
|
39
|
+
* `"missing"`), `secretUpdatedAt` and, during the 24 hours after a rotation, `previousExpiresAt`.
|
|
40
|
+
*
|
|
41
|
+
* After them come orphans: a secret whose webhook was removed from agent.json is kept (the same URL added back signs
|
|
42
|
+
* with it again) and listed with `inAgentJson: false` and `url: null` (the server keeps only the key). Remove one
|
|
43
|
+
* with `deleteSecret(agentId, { webhookKey })`.
|
|
44
|
+
*/
|
|
45
|
+
list(agentId: string): Promise<AgentWebhookView[]>;
|
|
46
|
+
/** `"set"` or `"missing"` (nothing is sent to a webhook without a secret). */
|
|
47
|
+
secretStatus(agentId: string, url: string | Webhook): Promise<SecretStatus>;
|
|
48
|
+
/** The webhook's current signing secret, to view again at any time (never the previous one during a rotation).
|
|
49
|
+
* Throws `UserError` when it has none. If it leaked, rotate it. */
|
|
50
|
+
getSecret(agentId: string, url: string | Webhook): Promise<string>;
|
|
51
|
+
/** Create the webhook's first signing secret (or a new one after a delete) and return it. Give it to your receiver.
|
|
52
|
+
* Throws `SecretExistsError` when the webhook already has one: rotate it instead. */
|
|
53
|
+
createSecret(agentId: string, url: string | Webhook): Promise<string>;
|
|
54
|
+
/**
|
|
55
|
+
* Replace the webhook's signing secret with a new one the server generates, and return it.
|
|
56
|
+
*
|
|
57
|
+
* The old secret keeps signing for 24 hours (fixed), so every delivery meanwhile carries both signatures: switch
|
|
58
|
+
* your receiver to the new secret within that time. There is one previous slot: rotating again within the 24 hours
|
|
59
|
+
* drops the first old secret at once. After a leak, cut over at once instead: `deleteSecret`, then `createSecret`.
|
|
60
|
+
* Throws `UserError` when the webhook has no secret: create one first.
|
|
61
|
+
*/
|
|
62
|
+
rotateSecret(agentId: string, url: string | Webhook): Promise<string>;
|
|
63
|
+
/**
|
|
64
|
+
* Use `secret`, one you made, as the webhook's signing secret (bring your own). A secret it replaces keeps signing
|
|
65
|
+
* for 24 hours. The server never echoes it. A malformed secret throws `SecretFormatError` before anything is sent.
|
|
66
|
+
*
|
|
67
|
+
* Called without `secret` (the 0.5 form, deprecated) it generates one here, sets it and returns it, with a warning.
|
|
68
|
+
*/
|
|
69
|
+
setSecret(agentId: string, url: string | Webhook, secret: string): Promise<void>;
|
|
70
|
+
/** @deprecated The 0.5 form: generates a secret, sets it and returns it. Call `createSecret` (no secret yet) or
|
|
71
|
+
* `rotateSecret` (replace it) instead. */
|
|
72
|
+
setSecret(agentId: string, url: string | Webhook): Promise<string>;
|
|
73
|
+
/**
|
|
74
|
+
* Remove the webhook's signing secret (the current one and any previous one). Nothing is sent to the webhook until
|
|
75
|
+
* it gets a new one (`createSecret` or `setSecret`), even if it is removed from agent.json and added back. Nothing
|
|
76
|
+
* to remove is not an error.
|
|
77
|
+
*
|
|
78
|
+
* Pass the webhook's `url`, or `{ webhookKey }` (from `list`) for an orphan: a secret whose webhook was removed from
|
|
79
|
+
* agent.json has no URL.
|
|
80
|
+
*/
|
|
81
|
+
deleteSecret(agentId: string, url: string | Webhook | {
|
|
82
|
+
webhookKey: string;
|
|
83
|
+
}): Promise<void>;
|
|
64
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* For `deploy`: create the secret of each of `urls` that is in `added` (the webhooks the deploy added) and whose
|
|
87
|
+
* `secretStatus` is `missing`. Returns the new secrets by URL and the URLs still without a secret: a failed create, a
|
|
88
|
+
* webhook not listed, and a webhook deployed before whose secret is missing (never recreated here). Never rotates or
|
|
89
|
+
* overwrites a secret. A failed create is reported as missing, never thrown; a failed list throws.
|
|
90
|
+
*/
|
|
91
|
+
export declare function createMissingSecrets(api: AgentsApi, agentId: string, urls: readonly string[], added: ReadonlySet<string>): Promise<{
|
|
92
|
+
created: Record<string, string>;
|
|
93
|
+
missing: string[];
|
|
94
|
+
}>;
|