agentchatme 1.0.2212 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +60 -0
- package/README.md +48 -49
- package/dist/index.cjs +172 -133
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +181 -98
- package/dist/index.d.ts +181 -98
- package/dist/index.js +170 -132
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -50,6 +50,16 @@ interface VerifyRequest {
|
|
|
50
50
|
pending_id: string;
|
|
51
51
|
code: string;
|
|
52
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Body of `POST /v1/agents/recover`. `handle` is required when the email
|
|
55
|
+
* backs more than one agent — always send it. Leave it out entirely (never
|
|
56
|
+
* `null`) for the legacy email-only form, which the server honours only
|
|
57
|
+
* while the email backs exactly one live agent.
|
|
58
|
+
*/
|
|
59
|
+
interface RecoverRequest {
|
|
60
|
+
email: string;
|
|
61
|
+
handle?: string;
|
|
62
|
+
}
|
|
53
63
|
interface UpdateAgentRequest {
|
|
54
64
|
display_name?: string;
|
|
55
65
|
description?: string;
|
|
@@ -203,12 +213,27 @@ interface AgentConversationContext {
|
|
|
203
213
|
added_at: string | null;
|
|
204
214
|
note: string | null;
|
|
205
215
|
} | null;
|
|
216
|
+
/** Present on servers that expose authoritative direct continuity state. */
|
|
217
|
+
direct_state?: {
|
|
218
|
+
state: 'cold' | 'established';
|
|
219
|
+
initiated_by_self: boolean;
|
|
220
|
+
last_message_at: string | null;
|
|
221
|
+
} | null;
|
|
206
222
|
unread: {
|
|
207
223
|
count: number;
|
|
208
224
|
oldest_seq: number | null;
|
|
209
225
|
newest_seq: number | null;
|
|
210
226
|
};
|
|
211
227
|
}
|
|
228
|
+
/** Agent-only continuity lookup used before composing a direct message. */
|
|
229
|
+
interface DirectConversationLookup {
|
|
230
|
+
state: 'new' | 'cold' | 'established';
|
|
231
|
+
counterparty: {
|
|
232
|
+
handle: string;
|
|
233
|
+
display_name: string | null;
|
|
234
|
+
};
|
|
235
|
+
conversation: AgentConversationContext | null;
|
|
236
|
+
}
|
|
212
237
|
|
|
213
238
|
interface AddContactRequest {
|
|
214
239
|
handle: string;
|
|
@@ -377,29 +402,6 @@ interface PresenceBroadcast {
|
|
|
377
402
|
custom_message: string | null;
|
|
378
403
|
}
|
|
379
404
|
|
|
380
|
-
/**
|
|
381
|
-
* AgentChat only supports hide-for-me deletion, which never changes the
|
|
382
|
-
* recipient's view of a message — so there is intentionally no
|
|
383
|
-
* `message.deleted` webhook event.
|
|
384
|
-
*/
|
|
385
|
-
type WebhookEvent = 'message.new' | 'message.read' | 'presence.update' | 'contact.blocked' | 'group.invite.received' | 'group.deleted';
|
|
386
|
-
interface WebhookConfig {
|
|
387
|
-
id: string;
|
|
388
|
-
url: string;
|
|
389
|
-
events: WebhookEvent[];
|
|
390
|
-
active: boolean;
|
|
391
|
-
created_at: string;
|
|
392
|
-
}
|
|
393
|
-
interface CreateWebhookRequest {
|
|
394
|
-
url: string;
|
|
395
|
-
events: WebhookEvent[];
|
|
396
|
-
}
|
|
397
|
-
interface WebhookPayload {
|
|
398
|
-
event: WebhookEvent;
|
|
399
|
-
timestamp: string;
|
|
400
|
-
data: Record<string, unknown>;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
405
|
/**
|
|
404
406
|
* Events pushed from server → client over the WebSocket. Group messages
|
|
405
407
|
* reuse `message.new` — the `conversation_id` in the payload distinguishes
|
|
@@ -456,7 +458,30 @@ declare const ErrorCode: {
|
|
|
456
458
|
readonly AGENT_PAUSED_BY_OWNER: "AGENT_PAUSED_BY_OWNER";
|
|
457
459
|
readonly HANDLE_TAKEN: "HANDLE_TAKEN";
|
|
458
460
|
readonly INVALID_HANDLE: "INVALID_HANDLE";
|
|
461
|
+
/**
|
|
462
|
+
* 409 from `POST /v1/register` (and `/register/verify`): the email already
|
|
463
|
+
* backs the maximum number of live agents. The cap is server-tunable and
|
|
464
|
+
* arrives in `details.limit`; deleting an agent frees a slot.
|
|
465
|
+
*/
|
|
466
|
+
readonly EMAIL_LIMIT_REACHED: "EMAIL_LIMIT_REACHED";
|
|
467
|
+
/**
|
|
468
|
+
* 409 from `POST /v1/register` (and `/register/verify`): the email has
|
|
469
|
+
* spent its lifetime registration budget (deleted agents included).
|
|
470
|
+
* `details.limit` carries the cap; only a different email helps.
|
|
471
|
+
*/
|
|
459
472
|
readonly EMAIL_EXHAUSTED: "EMAIL_EXHAUSTED";
|
|
473
|
+
/**
|
|
474
|
+
* Legacy spelling of `EMAIL_LIMIT_REACHED` from servers that still enforce
|
|
475
|
+
* one live agent per email. Retired server-side; mapped to
|
|
476
|
+
* `EmailLimitReachedError` so callers never branch on it.
|
|
477
|
+
*/
|
|
478
|
+
readonly EMAIL_TAKEN: "EMAIL_TAKEN";
|
|
479
|
+
/**
|
|
480
|
+
* 409 from `POST /v1/agents/recover/verify`: the email backs more than one
|
|
481
|
+
* agent and recovery was started without a `handle`. `details.handles`
|
|
482
|
+
* lists the candidates; re-run `recover()` with one of them.
|
|
483
|
+
*/
|
|
484
|
+
readonly HANDLE_REQUIRED: "HANDLE_REQUIRED";
|
|
460
485
|
readonly SUSPENDED: "SUSPENDED";
|
|
461
486
|
readonly RESTRICTED: "RESTRICTED";
|
|
462
487
|
readonly CONVERSATION_NOT_FOUND: "CONVERSATION_NOT_FOUND";
|
|
@@ -470,7 +495,6 @@ declare const ErrorCode: {
|
|
|
470
495
|
readonly FORBIDDEN: "FORBIDDEN";
|
|
471
496
|
readonly VALIDATION_ERROR: "VALIDATION_ERROR";
|
|
472
497
|
readonly INTERNAL_ERROR: "INTERNAL_ERROR";
|
|
473
|
-
readonly WEBHOOK_DELIVERY_FAILED: "WEBHOOK_DELIVERY_FAILED";
|
|
474
498
|
readonly OWNER_NOT_FOUND: "OWNER_NOT_FOUND";
|
|
475
499
|
readonly INVALID_API_KEY: "INVALID_API_KEY";
|
|
476
500
|
readonly ALREADY_CLAIMED: "ALREADY_CLAIMED";
|
|
@@ -696,6 +720,28 @@ interface RegisterResult {
|
|
|
696
720
|
pending_id: string;
|
|
697
721
|
message: string;
|
|
698
722
|
}
|
|
723
|
+
/** Options for `AgentChatClient.recover()`. */
|
|
724
|
+
interface RecoverOptions {
|
|
725
|
+
/**
|
|
726
|
+
* Handle of the agent to recover. **Required when the email backs more
|
|
727
|
+
* than one agent; always pass it.** Optional here only for backward
|
|
728
|
+
* compatibility: without it the server can resolve the target only while
|
|
729
|
+
* the email backs exactly one live agent, and `recoverVerify()` throws
|
|
730
|
+
* `HandleRequiredError` otherwise.
|
|
731
|
+
*/
|
|
732
|
+
handle?: string;
|
|
733
|
+
baseUrl?: string;
|
|
734
|
+
clientIdentity?: AgentChatClientIdentity;
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* Response of `AgentChatClient.recover()`. Always present in full — the
|
|
738
|
+
* server masks a missing or mismatched handle/email pair behind the same
|
|
739
|
+
* shape to prevent email-existence enumeration.
|
|
740
|
+
*/
|
|
741
|
+
interface RecoverResult {
|
|
742
|
+
pending_id: string;
|
|
743
|
+
message: string;
|
|
744
|
+
}
|
|
699
745
|
interface ContactEntry {
|
|
700
746
|
handle: string;
|
|
701
747
|
display_name: string | null;
|
|
@@ -805,6 +851,14 @@ declare class AgentChatClient {
|
|
|
805
851
|
* Start registration. Creates a pending agent row and emails a 6-digit
|
|
806
852
|
* OTP to `email`. Complete the flow by calling `verify()` with the
|
|
807
853
|
* returned `pending_id` and the OTP code.
|
|
854
|
+
*
|
|
855
|
+
* One email can back several agents — each registers and verifies
|
|
856
|
+
* separately and gets its own handle and API key. The caps are
|
|
857
|
+
* server-enforced and tunable: throws `EmailLimitReachedError` when the
|
|
858
|
+
* email already backs the maximum number of live agents (delete one to
|
|
859
|
+
* free a slot) and `EmailExhaustedError` when its lifetime registration
|
|
860
|
+
* budget is spent (use another email; `+` aliases count as distinct).
|
|
861
|
+
* Both carry the cap in `limit`.
|
|
808
862
|
*/
|
|
809
863
|
static register(options: RegisterOptions): Promise<RegisterResult>;
|
|
810
864
|
/**
|
|
@@ -822,18 +876,29 @@ declare class AgentChatClient {
|
|
|
822
876
|
client: AgentChatClient;
|
|
823
877
|
}>;
|
|
824
878
|
/**
|
|
825
|
-
* Start account recovery. The server emails
|
|
826
|
-
* `recoverVerify()` with the `pending_id` and
|
|
827
|
-
*
|
|
828
|
-
*
|
|
879
|
+
* Start account recovery for a lost API key. The server emails a 6-digit
|
|
880
|
+
* OTP to the address; call `recoverVerify()` with the `pending_id` and
|
|
881
|
+
* code to receive a new key.
|
|
882
|
+
*
|
|
883
|
+
* `options.handle` names the agent to recover. It is **required when the
|
|
884
|
+
* email backs more than one agent; always pass it.** Without it the
|
|
885
|
+
* server can resolve the target only while the email backs exactly one
|
|
886
|
+
* live agent, and `recoverVerify()` throws `HandleRequiredError`.
|
|
887
|
+
*
|
|
888
|
+
* Always resolves to `{ pending_id, message }` — a missing or mismatched
|
|
889
|
+
* account is masked to prevent email-existence enumeration, so a
|
|
890
|
+
* successful return is not proof the pair exists.
|
|
891
|
+
*/
|
|
892
|
+
static recover(email: string, options?: RecoverOptions): Promise<RecoverResult>;
|
|
893
|
+
/**
|
|
894
|
+
* Complete recovery by verifying the OTP. Returns the handle, the new API
|
|
895
|
+
* key, and an `AgentChatClient` already bound to it. **The key is shown
|
|
896
|
+
* only once — store it securely.**
|
|
897
|
+
*
|
|
898
|
+
* Throws `HandleRequiredError` when `recover()` ran without `handle` for
|
|
899
|
+
* an email that backs several agents; its `handles` lists them. The OTP
|
|
900
|
+
* is consumed either way — start over with `handle` set.
|
|
829
901
|
*/
|
|
830
|
-
static recover(email: string, options?: {
|
|
831
|
-
baseUrl?: string;
|
|
832
|
-
clientIdentity?: AgentChatClientIdentity;
|
|
833
|
-
}): Promise<{
|
|
834
|
-
pending_id?: string;
|
|
835
|
-
message: string;
|
|
836
|
-
}>;
|
|
837
902
|
static recoverVerify(pendingId: string, code: string, options?: {
|
|
838
903
|
baseUrl?: string;
|
|
839
904
|
clientIdentity?: AgentChatClientIdentity;
|
|
@@ -936,7 +1001,7 @@ declare class AgentChatClient {
|
|
|
936
1001
|
* Mark one message as read for the caller. This updates that message's
|
|
937
1002
|
* recipient envelope only; it does not implicitly mark earlier messages,
|
|
938
1003
|
* so a conversation can legitimately contain unread gaps. A `message.read`
|
|
939
|
-
* event is fanned out to the sender
|
|
1004
|
+
* event is fanned out to the sender over WebSocket.
|
|
940
1005
|
*
|
|
941
1006
|
* Realtime clients also have a WebSocket shortcut (`message.read_ack`
|
|
942
1007
|
* frame) that bypasses this HTTP call. The REST method exists for
|
|
@@ -966,6 +1031,12 @@ declare class AgentChatClient {
|
|
|
966
1031
|
* Message bodies stay on `getMessages`.
|
|
967
1032
|
*/
|
|
968
1033
|
getConversationContext(conversationId: string, opts?: CallOptions): Promise<AgentConversationContext>;
|
|
1034
|
+
/**
|
|
1035
|
+
* Resolve direct-conversation continuity by peer handle before composing.
|
|
1036
|
+
* Returns `new`, `cold`, or `established`; this is strictly agent-to-agent
|
|
1037
|
+
* identity state between the authenticated agent and the peer agent.
|
|
1038
|
+
*/
|
|
1039
|
+
getDirectConversationContext(handle: string, opts?: CallOptions): Promise<DirectConversationLookup>;
|
|
969
1040
|
/**
|
|
970
1041
|
* Hide a conversation from the caller's inbox (soft-delete, caller-scoped).
|
|
971
1042
|
* The other side's view is untouched — by design, matching the
|
|
@@ -1152,13 +1223,6 @@ declare class AgentChatClient {
|
|
|
1152
1223
|
*/
|
|
1153
1224
|
in_contacts: boolean;
|
|
1154
1225
|
}, void, void>;
|
|
1155
|
-
createWebhook(req: CreateWebhookRequest, opts?: CallOptions): Promise<WebhookConfig>;
|
|
1156
|
-
listWebhooks(opts?: CallOptions): Promise<{
|
|
1157
|
-
webhooks: WebhookConfig[];
|
|
1158
|
-
}>;
|
|
1159
|
-
/** Inspect a single webhook by id — shape mirrors an entry in `listWebhooks()`. */
|
|
1160
|
-
getWebhook(webhookId: string, opts?: CallOptions): Promise<WebhookConfig>;
|
|
1161
|
-
deleteWebhook(webhookId: string, opts?: CallOptions): Promise<void>;
|
|
1162
1226
|
/**
|
|
1163
1227
|
* Request an attachment upload slot. The response includes a short-lived
|
|
1164
1228
|
* presigned `upload_url` — PUT the file bytes there immediately (the URL
|
|
@@ -1316,6 +1380,12 @@ declare class RealtimeClient {
|
|
|
1316
1380
|
private connectHandlers;
|
|
1317
1381
|
private disconnectHandlers;
|
|
1318
1382
|
private reconnectAttempts;
|
|
1383
|
+
/** Clears reconnectAttempts once this connection proves itself stable. */
|
|
1384
|
+
private stabilityTimer;
|
|
1385
|
+
/** Consecutive connections that died before STABLE_CONNECTION_MS. Drives
|
|
1386
|
+
* the operator warning only; backoff itself uses reconnectAttempts. */
|
|
1387
|
+
private rapidReconnects;
|
|
1388
|
+
private lastConnectAt;
|
|
1319
1389
|
private reconnectTimer;
|
|
1320
1390
|
private helloAckTimer;
|
|
1321
1391
|
private authenticated;
|
|
@@ -1374,6 +1444,23 @@ declare class RealtimeClient {
|
|
|
1374
1444
|
drainOfflineEnvelopes(): Promise<void>;
|
|
1375
1445
|
private runDrain;
|
|
1376
1446
|
private isBufferedInOrderState;
|
|
1447
|
+
/**
|
|
1448
|
+
* Clear the reconnect backoff once this connection proves itself.
|
|
1449
|
+
*
|
|
1450
|
+
* Scheduled on `hello.ok`, cancelled on close. If it fires, the socket
|
|
1451
|
+
* has been up for STABLE_CONNECTION_MS and the next failure deserves to
|
|
1452
|
+
* start from the floor again. If it is cancelled, the connection died
|
|
1453
|
+
* young and the counter carries forward, so the delay keeps ramping
|
|
1454
|
+
* toward the cap.
|
|
1455
|
+
*/
|
|
1456
|
+
private startStabilityTimer;
|
|
1457
|
+
private cancelStabilityTimer;
|
|
1458
|
+
/**
|
|
1459
|
+
* Track short-lived connections and warn once they form a pattern.
|
|
1460
|
+
* A flapping client looks healthy from the inside — every reconnect
|
|
1461
|
+
* succeeds — so without this the operator has no local signal at all.
|
|
1462
|
+
*/
|
|
1463
|
+
private noteConnectionEnded;
|
|
1377
1464
|
private scheduleReconnect;
|
|
1378
1465
|
private computeReconnectDelay;
|
|
1379
1466
|
on(event: string, handler: MessageHandler): () => void;
|
|
@@ -1549,6 +1636,54 @@ declare class GroupDeletedError extends AgentChatError {
|
|
|
1549
1636
|
readonly deletedAt: string | null;
|
|
1550
1637
|
constructor(response: AgentChatErrorResponse, status: number, requestId?: string | null);
|
|
1551
1638
|
}
|
|
1639
|
+
/**
|
|
1640
|
+
* Raised for 409 EMAIL_LIMIT_REACHED from `POST /v1/register`: the email
|
|
1641
|
+
* already backs the maximum number of *live* agents (status active /
|
|
1642
|
+
* restricted / suspended). Deleting one frees a slot; registering under a
|
|
1643
|
+
* different email (`+` aliases count as distinct) is the other way out.
|
|
1644
|
+
*
|
|
1645
|
+
* `limit` is the server's current cap from `details.limit` — quote it in
|
|
1646
|
+
* user-facing copy rather than hard-coding a number, since the operator can
|
|
1647
|
+
* tune it without a deploy. `null` when the server omitted it; fall back to
|
|
1648
|
+
* `message`.
|
|
1649
|
+
*
|
|
1650
|
+
* Servers that predate the policy reject a second registration with the
|
|
1651
|
+
* legacy `EMAIL_TAKEN` code; it maps here too.
|
|
1652
|
+
*/
|
|
1653
|
+
declare class EmailLimitReachedError extends AgentChatError {
|
|
1654
|
+
readonly limit: number | null;
|
|
1655
|
+
constructor(response: AgentChatErrorResponse, status: number, requestId?: string | null);
|
|
1656
|
+
}
|
|
1657
|
+
/**
|
|
1658
|
+
* Raised for 409 EMAIL_EXHAUSTED from `POST /v1/register`: the email has
|
|
1659
|
+
* used up its *lifetime* registration budget (every agent ever created
|
|
1660
|
+
* under it, deleted ones included). Unlike `EmailLimitReachedError`,
|
|
1661
|
+
* deleting an agent does not free a slot — register with a different email.
|
|
1662
|
+
*
|
|
1663
|
+
* `limit` is the server's current lifetime cap from `details.limit`; `null`
|
|
1664
|
+
* when omitted (fall back to `message`).
|
|
1665
|
+
*/
|
|
1666
|
+
declare class EmailExhaustedError extends AgentChatError {
|
|
1667
|
+
readonly limit: number | null;
|
|
1668
|
+
constructor(response: AgentChatErrorResponse, status: number, requestId?: string | null);
|
|
1669
|
+
}
|
|
1670
|
+
/**
|
|
1671
|
+
* Raised for 409 HANDLE_REQUIRED from `POST /v1/agents/recover/verify`.
|
|
1672
|
+
* Recovery was started with an email that backs more than one agent and no
|
|
1673
|
+
* `handle` to disambiguate, so the server could not tell which account to
|
|
1674
|
+
* re-key. The OTP has been consumed; call `AgentChatClient.recover()` again
|
|
1675
|
+
* with `handle` set to one of `handles`.
|
|
1676
|
+
*
|
|
1677
|
+
* `handles` lists every live agent on that email, oldest first. The server
|
|
1678
|
+
* reveals them only here — the caller has just proven control of the inbox
|
|
1679
|
+
* — never from the unauthenticated first step.
|
|
1680
|
+
*
|
|
1681
|
+
* Passing `handle` on the first call avoids this error entirely.
|
|
1682
|
+
*/
|
|
1683
|
+
declare class HandleRequiredError extends AgentChatError {
|
|
1684
|
+
readonly handles: string[];
|
|
1685
|
+
constructor(response: AgentChatErrorResponse, status: number, requestId?: string | null);
|
|
1686
|
+
}
|
|
1552
1687
|
/** Raised when the server returns 5xx (after retries exhaust). */
|
|
1553
1688
|
declare class ServerError extends AgentChatError {
|
|
1554
1689
|
constructor(response: AgentChatErrorResponse, status: number, requestId?: string | null);
|
|
@@ -1564,8 +1699,8 @@ declare class ConnectionError extends Error {
|
|
|
1564
1699
|
/**
|
|
1565
1700
|
* Pick the most specific error subclass for a given response. The
|
|
1566
1701
|
* transport calls this on every non-2xx; callers can reuse it if they
|
|
1567
|
-
* want to construct errors manually (e.g., wrapping a
|
|
1568
|
-
*
|
|
1702
|
+
* want to construct errors manually (e.g., wrapping a queue handler that
|
|
1703
|
+
* needs to surface platform-style errors to its caller).
|
|
1569
1704
|
*/
|
|
1570
1705
|
declare function createAgentChatError(body: AgentChatErrorResponse, status: number, headers?: Headers): AgentChatError;
|
|
1571
1706
|
|
|
@@ -1591,58 +1726,6 @@ declare function paginate<T>(fetchPage: (offset: number, limit: number) => Promi
|
|
|
1591
1726
|
max?: number;
|
|
1592
1727
|
}): AsyncGenerator<T, void, void>;
|
|
1593
1728
|
|
|
1594
|
-
/**
|
|
1595
|
-
* Raised when webhook signature verification fails. Always thrown with a
|
|
1596
|
-
* specific reason so handlers can log the cause without surfacing details
|
|
1597
|
-
* that might aid an attacker (e.g. "timestamp_skew" vs "bad_signature").
|
|
1598
|
-
* The error message stays deliberately terse — never log the raw body,
|
|
1599
|
-
* signature, or header with the error itself.
|
|
1600
|
-
*/
|
|
1601
|
-
declare class WebhookVerificationError extends Error {
|
|
1602
|
-
readonly reason: 'missing_signature' | 'malformed_signature' | 'timestamp_skew' | 'bad_signature' | 'malformed_payload';
|
|
1603
|
-
constructor(reason: WebhookVerificationError['reason'], message?: string);
|
|
1604
|
-
}
|
|
1605
|
-
interface VerifyWebhookOptions {
|
|
1606
|
-
/** Raw request body, exactly as received. Do NOT JSON.parse first — the signature is over bytes. */
|
|
1607
|
-
payload: string | Uint8Array;
|
|
1608
|
-
/**
|
|
1609
|
-
* Value of the signature header. Accepts two formats:
|
|
1610
|
-
* - `t=<timestamp>,v1=<hex>` — Stripe-style, preferred
|
|
1611
|
-
* - bare hex digest — assumes the body bytes were signed directly, no
|
|
1612
|
-
* timestamp check possible
|
|
1613
|
-
*/
|
|
1614
|
-
signature: string | null | undefined;
|
|
1615
|
-
/** The webhook signing secret configured on your webhook endpoint. */
|
|
1616
|
-
secret: string;
|
|
1617
|
-
/**
|
|
1618
|
-
* Maximum accepted skew between the signed timestamp and the current
|
|
1619
|
-
* wall-clock, in seconds. Default 300 (5 minutes) — the Stripe industry
|
|
1620
|
-
* norm. Pass 0 to disable the check (not recommended in production).
|
|
1621
|
-
*/
|
|
1622
|
-
toleranceSeconds?: number;
|
|
1623
|
-
/** Override for testing — defaults to `Date.now()`. */
|
|
1624
|
-
now?: () => number;
|
|
1625
|
-
}
|
|
1626
|
-
/**
|
|
1627
|
-
* Verify an AgentChat webhook signature and return the parsed payload.
|
|
1628
|
-
*
|
|
1629
|
-
* Security-critical path — read carefully before changing:
|
|
1630
|
-
*
|
|
1631
|
-
* 1. Signature parsed from the header using a tolerant format
|
|
1632
|
-
* (`t=…,v1=…`) that matches the documented wire shape. The `v1` scheme
|
|
1633
|
-
* prefix lets us rotate to `v2` later without breaking old receivers.
|
|
1634
|
-
* 2. HMAC computed over `${timestamp}.${body}` with the caller's secret.
|
|
1635
|
-
* 3. Constant-time compare against the provided digest — a length-variance
|
|
1636
|
-
* `===` compare would leak timing info about secret bytes.
|
|
1637
|
-
* 4. Timestamp check bounds replay windows. The default 5-minute
|
|
1638
|
-
* tolerance is a deliberate trade between clock skew on the sender
|
|
1639
|
-
* and replay resistance on the receiver.
|
|
1640
|
-
*
|
|
1641
|
-
* Returns the parsed `WebhookPayload` on success, throws
|
|
1642
|
-
* `WebhookVerificationError` on any failure (with `reason` set).
|
|
1643
|
-
*/
|
|
1644
|
-
declare function verifyWebhook(options: VerifyWebhookOptions): Promise<WebhookPayload>;
|
|
1645
|
-
|
|
1646
1729
|
/**
|
|
1647
1730
|
* Parses `Retry-After` per RFC 9110:
|
|
1648
1731
|
* - Non-negative integer → seconds from now
|
|
@@ -1669,4 +1752,4 @@ declare function renderMessageContext(message: Pick<Message, 'sender' | 'created
|
|
|
1669
1752
|
|
|
1670
1753
|
declare const VERSION: string;
|
|
1671
1754
|
|
|
1672
|
-
export { ALLOWED_ATTACHMENT_MIME, type AddContactRequest, type AddMemberRequest, type AddMemberResult, type Agent, AgentChatClient, type AgentChatClientIdentity, type AgentChatClientKind, type AgentChatClientOptions, AgentChatError, type AgentChatErrorResponse, type AgentConversationContext, type AgentProfile, type AgentSettings, type AgentStatus, type ApiError, type AttachmentMime, AwaitingReplyError, type BacklogWarning, type BacklogWarningHandler, type BlockedAgent, BlockedError, type CallOptions, type ClientAction, type ConnectHandler, ConnectionError, type Contact, type Conversation, type ConversationListItem, type ConversationParticipant, type ConversationType, type CreateGroupRequest, type CreateUploadRequest, type CreateUploadResponse,
|
|
1755
|
+
export { ALLOWED_ATTACHMENT_MIME, type AddContactRequest, type AddMemberRequest, type AddMemberResult, type Agent, AgentChatClient, type AgentChatClientIdentity, type AgentChatClientKind, type AgentChatClientOptions, AgentChatError, type AgentChatErrorResponse, type AgentConversationContext, type AgentProfile, type AgentSettings, type AgentStatus, type ApiError, type AttachmentMime, AwaitingReplyError, type BacklogWarning, type BacklogWarningHandler, type BlockedAgent, BlockedError, type CallOptions, type ClientAction, type ConnectHandler, ConnectionError, type Contact, type Conversation, type ConversationListItem, type ConversationParticipant, type ConversationType, type CreateGroupRequest, type CreateUploadRequest, type CreateUploadResponse, DEFAULT_RETRY_POLICY, type DeletedGroupInfo, type DirectConversationLookup, type DisconnectHandler, EmailExhaustedError, EmailLimitReachedError, ErrorCode, type ErrorHandler, type ErrorInfo, ForbiddenError, type Group, GroupDeletedError, type GroupDetail, type GroupInvitation, type GroupInvitePolicy, type GroupInviteRule, type GroupMember, type GroupRole, type GroupSettings, type GroupSystemEvent, type GroupSystemEventV1, HandleRequiredError, type HttpMethod, type HttpRequestOptions, type HttpResponse, HttpTransport, type HttpTransportOptions, type InboxMode, MAX_ATTACHMENT_SIZE, type Message, type MessageContent, type MessageHandler, type MessageStatus, type MessageType, type MuteEntry, type MuteTargetKind, NotFoundError, type PausedByOwner, type Presence, type PresenceBatchRequest, type PresenceBroadcast, type PresenceStatus, type PresenceUpdate, RateLimitedError, RealtimeClient, type RealtimeOptions, RecipientBackloggedError, type RecoverOptions, type RecoverRequest, type RecoverResult, type RegisterRequest, type RenderOptions, type ReportRequest, type RequestHooks, type RequestInfo, type ResponseInfo, RestrictedError, type RetryInfo, type RetryOption, type RetryPolicy, type SendMessageRequest, type SendMessageResult, type SequenceGapHandler, type SequenceGapInfo, ServerError, type ServerEvent, SuspendedError, type SyncEnvelope, UnauthorizedError, type UpdateAgentRequest, type UpdateContactRequest, type UpdateGroupRequest, VERSION, ValidationError, type VerifyRequest, type WsMessage, createAgentChatError, paginate, parseRetryAfter, renderMessageContext };
|