@chronary/sdk 0.7.0 → 0.8.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 +32 -0
- package/README.md +6 -0
- package/dist/index.cjs +313 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +615 -41
- package/dist/index.d.ts +615 -41
- package/dist/index.js +310 -44
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,38 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@chronary/sdk` will be documented in this file starting with the soft-launch release.
|
|
4
4
|
|
|
5
|
+
## Unreleased
|
|
6
|
+
|
|
7
|
+
- Add the `developer` plan: `PlanId` includes it, `Plan.annual_price`, `BillingSummary.pending_plan` / `pending_plan_interval` / `pending_plan_at`, `BillingUpgradeOption.plan` (`developer` | `pro`) and `via`, `UpgradeRequest.plan`. Errors expose `upgradePlan` (the plan `upgradeUrl` leads to). Additive; `BillingSummary.plan` stays a plain string (#1911).
|
|
8
|
+
|
|
9
|
+
## 0.8.1 — 2026-11-09
|
|
10
|
+
|
|
11
|
+
- Internal hardening of `baseUrl` normalisation and `RateLimit` header parsing. No API change.
|
|
12
|
+
- `waitlist.join()` now resolves to `{ waitlisted: true, message }` (HTTP 202) for every email, whether new, already on the list or with an active account. It no longer returns the entry (`data`) and no longer throws 409 `email_taken`. `WaitlistJoinParams` gains `intent`; `WaitlistedOrg` is deprecated (#1655).
|
|
13
|
+
- `agentAuth.signUp()` types the 202 sent while sign-ups are paused: `AgentSignUpWaitlistedResponse` (`{ waitlisted: true, message }`, no `org_id`) (#1655).
|
|
14
|
+
|
|
15
|
+
## 0.8.0 — 2026-10-19
|
|
16
|
+
|
|
17
|
+
- Add the `billing` resource: `billing.get()` and `billing.upgradeRequests.create/get/cancel` so an agent can read plan status and ask its human to upgrade (#1129).
|
|
18
|
+
- Add `PlanRequiredError` (403 `plan_required`). Errors now expose `upgradeUrl`, `docsUrl`, `requiredPlan`, `feature`, `contactUrl`, `metric`, `limit` and the raw `body`.
|
|
19
|
+
- Fix `QuotaExceededError` reporting status 402 for HTTP 429 responses; it now keeps the real status.
|
|
20
|
+
- Add the `org.plan_changed` webhook event type: fires once when the account's plan changes, so agents don't have to poll billing (#1130).
|
|
21
|
+
- Type `BillingSummary.offer` as `BillingOffer | null` — the founding member offer for early-access accounts (`upcoming` / `available` / `redeemed`) (#1121).
|
|
22
|
+
- Add the `calendar_connection.reauthorization_required` webhook event type: fires once when a connected human calendar stops accepting access, so agents learn their availability now fails closed (#1196).
|
|
23
|
+
- Add `connectionLinks.list({ status, calendar_id, limit })` and the setup details on connection links (`requesting_agent_id`, `requested_capabilities`, `requested_publication_policy`, `created_at`) (#1196).
|
|
24
|
+
- Add `webhooks.getDelivery(webhookId, deliveryId)`: one delivery with its attempt timeline (`attempt_log`: HTTP status, duration, response body prefix, error code). Deliveries in `listDeliveries` gain `last_response_status`, `last_error_code` and `last_duration_ms` (#1200).
|
|
25
|
+
- Add `webhooks.sendTest(webhookId, { event_type })`: sends a signed sample payload once (`is_test`, `X-Chronary-Test: 1`, quota-exempt). Deliveries gain `is_test`, and `Webhook` gains `deactivatedAt` and `deactivatedReason` (`manual`, `circuit_breaker`, `unsafe_destination_url`, `account_deletion`) (#1200).
|
|
26
|
+
- `webhooks.listDeliveries` takes `event_type` (exact, or a prefix ending in a dot such as `event.`), `created_after`, `created_before`, `delivery_id`, `is_test` and `cursor`, and returns `next_cursor` and `has_more`. Delivery `status` gains `dropped` (a Free-plan delivery the monthly limit stopped, `last_error_code: 'quota_exceeded'`), and `stats` gains `dropped` (#1200).
|
|
27
|
+
- Add `events.listAll({ calendar_id, agent_id, start_after, start_before, status, source, q, expand })`: events across all of the organization's calendars (`GET /v1/events`), with title search inside a window of at most 31 days. Add `calendars.rotateIcalToken(id)` to regenerate a calendar's subscribe URL, and a `q` search on `calendars.list()`. Array query values are sent as repeated parameters (#1202).
|
|
28
|
+
- Add `bookingPages.listBookings(id, { limit, cursor })`: the bookings made through a page with the invitee's name, email and notes, newest first, paged by `next_cursor`. Add `bookingPages.rotateSlug(id)` to replace a page's public link, and a `calendar_id` filter on `bookingPages.list()` (#1202).
|
|
29
|
+
- Add `webhooks.replayDelivery(webhookId, deliveryId)` (Pro): sends a `failed` or `dropped` delivery again as a new delivery, with an `X-Chronary-Replay-Of` header naming the original. It counts toward the monthly delivery quota. Add the `WebhookReplaySent` type. Deliveries gain `replay_of_delivery_id`, and the delivery detail's `request_headers` gains `x-chronary-replay-of` on a replay (#588).
|
|
30
|
+
- **Webhook secret rotation (#594).** `verifySignature` and `constructEvent` now accept a delivery when the secret matches either `X-Signature` or `X-Signature-Previous`. During a rotation's grace window Chronary sends both headers, the second signed with the replaced secret, so a receiver can switch secrets without rejecting deliveries. Update before you rotate a secret. Add `webhooks.rotateSecret(webhookId, { expire_old_in })` (Pro): returns the new secret once, and the old one keeps working for `now`, `1h`, `24h` (default) or `7d`. `Webhook` gains `previousSecretExpiresAt`.
|
|
31
|
+
- Type `Event.holdPriority` as `number` (was `number | null`). The API has always sent a number: `0` unless a hold set a priority. Code that compares it to `null` now gets a TypeScript "no overlap" error and can drop the check; nothing changes at runtime (#1446).
|
|
32
|
+
|
|
33
|
+
## 0.7.1 — 2026-07-14
|
|
34
|
+
|
|
35
|
+
- Docs-only: neutral wording for the booking-page type (no competitor references). No API change.
|
|
36
|
+
|
|
5
37
|
## 0.7.0 — 2026-07-14
|
|
6
38
|
|
|
7
39
|
- Add the `bookingPages` resource — CRUD for agent-created public scheduling links plus public `listSlots`/`submit` helpers — and a `booking_pages` usage metric (#1036).
|
package/README.md
CHANGED
|
@@ -82,6 +82,12 @@ const event = await Chronary.webhooks.constructEvent(rawBody, headers, secret);
|
|
|
82
82
|
// event.type comes from X-Chronary-Event-Type; event.data is the parsed payload body.
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
+
## Security and support
|
|
86
|
+
|
|
87
|
+
Report vulnerabilities to [security@chronary.ai](mailto:security@chronary.ai) or through private vulnerability reporting on this package's GitHub repository. Please don't open a public issue. Read the full [security policy](https://github.com/Chronary/.github/blob/main/SECURITY.md).
|
|
88
|
+
|
|
89
|
+
Version 0.x is supported with security fixes until at least **April 2031**. Fixes ship in a new 0.x release, so keep up with the latest one. Supported versions and end dates for every Chronary package are listed in the [security policy](https://github.com/Chronary/.github/blob/main/SECURITY.md#supported-versions).
|
|
90
|
+
|
|
85
91
|
## License
|
|
86
92
|
|
|
87
93
|
Apache-2.0
|
package/dist/index.cjs
CHANGED
|
@@ -22,6 +22,7 @@ var index_exports = {};
|
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
APIPromise: () => APIPromise,
|
|
24
24
|
AuthenticationError: () => AuthenticationError,
|
|
25
|
+
BillingClient: () => BillingClient,
|
|
25
26
|
BookingPagesClient: () => BookingPagesClient,
|
|
26
27
|
Chronary: () => Chronary,
|
|
27
28
|
ChronaryError: () => ChronaryError,
|
|
@@ -30,9 +31,11 @@ __export(index_exports, {
|
|
|
30
31
|
CoreClient: () => CoreClient,
|
|
31
32
|
NotFoundError: () => NotFoundError,
|
|
32
33
|
PageIterator: () => PageIterator,
|
|
34
|
+
PlanRequiredError: () => PlanRequiredError,
|
|
33
35
|
QuotaExceededError: () => QuotaExceededError,
|
|
34
36
|
RateLimitError: () => RateLimitError,
|
|
35
37
|
TimeoutError: () => TimeoutError,
|
|
38
|
+
UpgradeRequestsClient: () => UpgradeRequestsClient,
|
|
36
39
|
VERSION: () => VERSION,
|
|
37
40
|
ValidationError: () => ValidationError,
|
|
38
41
|
constructEvent: () => constructEvent,
|
|
@@ -43,33 +46,63 @@ __export(index_exports, {
|
|
|
43
46
|
module.exports = __toCommonJS(index_exports);
|
|
44
47
|
|
|
45
48
|
// src/version.ts
|
|
46
|
-
var VERSION = "0.
|
|
49
|
+
var VERSION = "0.8.1";
|
|
47
50
|
|
|
48
51
|
// src/error.ts
|
|
52
|
+
function str(body, key) {
|
|
53
|
+
const v = body?.[key];
|
|
54
|
+
return typeof v === "string" ? v : void 0;
|
|
55
|
+
}
|
|
56
|
+
function num(body, key) {
|
|
57
|
+
const v = body?.[key];
|
|
58
|
+
return typeof v === "number" ? v : void 0;
|
|
59
|
+
}
|
|
49
60
|
var ChronaryError = class extends Error {
|
|
50
61
|
status;
|
|
51
62
|
requestId;
|
|
52
63
|
headers;
|
|
53
64
|
errorType;
|
|
54
|
-
|
|
65
|
+
/** Raw `error` object from the response body (all server-provided fields). */
|
|
66
|
+
body;
|
|
67
|
+
/** Where a human can upgrade the plan (plan_required / quota_exceeded errors). */
|
|
68
|
+
upgradeUrl;
|
|
69
|
+
docsUrl;
|
|
70
|
+
requiredPlan;
|
|
71
|
+
/** Self-serve plan `upgradeUrl` leads to: the next plan up (quota_exceeded and count-cap errors). */
|
|
72
|
+
upgradePlan;
|
|
73
|
+
feature;
|
|
74
|
+
contactUrl;
|
|
75
|
+
/** Quota metric that was exhausted (quota_exceeded errors). */
|
|
76
|
+
metric;
|
|
77
|
+
limit;
|
|
78
|
+
constructor(message, status, requestId, headers, errorType, body) {
|
|
55
79
|
super(message);
|
|
56
80
|
this.name = "ChronaryError";
|
|
57
81
|
this.status = status;
|
|
58
82
|
this.requestId = requestId;
|
|
59
83
|
this.headers = headers;
|
|
60
84
|
this.errorType = errorType;
|
|
85
|
+
this.body = body;
|
|
86
|
+
this.upgradeUrl = str(body, "upgrade_url");
|
|
87
|
+
this.docsUrl = str(body, "docs_url");
|
|
88
|
+
this.requiredPlan = str(body, "required_plan");
|
|
89
|
+
this.upgradePlan = str(body, "upgrade_plan");
|
|
90
|
+
this.feature = str(body, "feature");
|
|
91
|
+
this.contactUrl = str(body, "contact_url");
|
|
92
|
+
this.metric = str(body, "metric");
|
|
93
|
+
this.limit = num(body, "limit");
|
|
61
94
|
}
|
|
62
95
|
};
|
|
63
96
|
var AuthenticationError = class extends ChronaryError {
|
|
64
|
-
constructor(message, requestId, headers) {
|
|
65
|
-
super(message, 401, requestId, headers, "authentication_error");
|
|
97
|
+
constructor(message, requestId, headers, body) {
|
|
98
|
+
super(message, 401, requestId, headers, "authentication_error", body);
|
|
66
99
|
this.name = "AuthenticationError";
|
|
67
100
|
}
|
|
68
101
|
};
|
|
69
102
|
var RateLimitError = class extends ChronaryError {
|
|
70
103
|
retryAfter;
|
|
71
|
-
constructor(message, requestId, headers) {
|
|
72
|
-
super(message, 429, requestId, headers, "rate_limit_error");
|
|
104
|
+
constructor(message, requestId, headers, body) {
|
|
105
|
+
super(message, 429, requestId, headers, "rate_limit_error", body);
|
|
73
106
|
this.name = "RateLimitError";
|
|
74
107
|
if (headers) {
|
|
75
108
|
const ra = headers.get("retry-after");
|
|
@@ -78,23 +111,29 @@ var RateLimitError = class extends ChronaryError {
|
|
|
78
111
|
}
|
|
79
112
|
};
|
|
80
113
|
var NotFoundError = class extends ChronaryError {
|
|
81
|
-
constructor(message, requestId, headers) {
|
|
82
|
-
super(message, 404, requestId, headers, "not_found");
|
|
114
|
+
constructor(message, requestId, headers, body) {
|
|
115
|
+
super(message, 404, requestId, headers, "not_found", body);
|
|
83
116
|
this.name = "NotFoundError";
|
|
84
117
|
}
|
|
85
118
|
};
|
|
86
119
|
var ValidationError = class extends ChronaryError {
|
|
87
|
-
constructor(message, status, requestId, headers) {
|
|
88
|
-
super(message, status, requestId, headers, "validation_error");
|
|
120
|
+
constructor(message, status, requestId, headers, body) {
|
|
121
|
+
super(message, status, requestId, headers, "validation_error", body);
|
|
89
122
|
this.name = "ValidationError";
|
|
90
123
|
}
|
|
91
124
|
};
|
|
92
125
|
var QuotaExceededError = class extends ChronaryError {
|
|
93
|
-
constructor(message, requestId, headers) {
|
|
94
|
-
super(message,
|
|
126
|
+
constructor(message, requestId, headers, body, status = 429) {
|
|
127
|
+
super(message, status, requestId, headers, "quota_exceeded", body);
|
|
95
128
|
this.name = "QuotaExceededError";
|
|
96
129
|
}
|
|
97
130
|
};
|
|
131
|
+
var PlanRequiredError = class extends ChronaryError {
|
|
132
|
+
constructor(message, requestId, headers, body) {
|
|
133
|
+
super(message, 403, requestId, headers, "plan_required", body);
|
|
134
|
+
this.name = "PlanRequiredError";
|
|
135
|
+
}
|
|
136
|
+
};
|
|
98
137
|
var TimeoutError = class extends ChronaryError {
|
|
99
138
|
constructor(message) {
|
|
100
139
|
super(message, 0);
|
|
@@ -195,7 +234,7 @@ var CoreClient = class {
|
|
|
195
234
|
extraHeaders;
|
|
196
235
|
constructor(config = {}) {
|
|
197
236
|
this.apiKey = config.apiKey ?? getEnvVar("CHRONARY_API_KEY") ?? "";
|
|
198
|
-
this.baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL)
|
|
237
|
+
this.baseUrl = stripTrailingSlashes(config.baseUrl ?? DEFAULT_BASE_URL);
|
|
199
238
|
this.timeout = config.timeout ?? DEFAULT_TIMEOUT;
|
|
200
239
|
this.maxRetries = config.maxRetries ?? DEFAULT_MAX_RETRIES;
|
|
201
240
|
this.logLevel = resolveLogLevel(config);
|
|
@@ -318,7 +357,12 @@ var CoreClient = class {
|
|
|
318
357
|
if (!query) return base;
|
|
319
358
|
const params = new URLSearchParams();
|
|
320
359
|
for (const [key, value] of Object.entries(query)) {
|
|
321
|
-
if (value
|
|
360
|
+
if (value === void 0) continue;
|
|
361
|
+
if (Array.isArray(value)) {
|
|
362
|
+
for (const v of value) params.append(key, v);
|
|
363
|
+
} else {
|
|
364
|
+
params.set(key, String(value));
|
|
365
|
+
}
|
|
322
366
|
}
|
|
323
367
|
const qs = params.toString();
|
|
324
368
|
return qs ? `${base}?${qs}` : base;
|
|
@@ -332,28 +376,34 @@ var CoreClient = class {
|
|
|
332
376
|
const message = errorBody?.error?.message ?? `HTTP ${response.status}`;
|
|
333
377
|
const rid = requestId ?? errorBody?.error?.request_id;
|
|
334
378
|
const errorType = errorBody?.error?.type;
|
|
379
|
+
const body = errorBody?.error;
|
|
335
380
|
switch (response.status) {
|
|
336
381
|
case 400:
|
|
337
382
|
if (errorType === "validation_error") {
|
|
338
|
-
return new ValidationError(message, response.status, rid, response.headers);
|
|
383
|
+
return new ValidationError(message, response.status, rid, response.headers, body);
|
|
339
384
|
}
|
|
340
|
-
return new ChronaryError(message, response.status, rid, response.headers, errorType);
|
|
385
|
+
return new ChronaryError(message, response.status, rid, response.headers, errorType, body);
|
|
341
386
|
case 401:
|
|
342
|
-
return new AuthenticationError(message, rid, response.headers);
|
|
387
|
+
return new AuthenticationError(message, rid, response.headers, body);
|
|
343
388
|
case 402:
|
|
344
|
-
return new QuotaExceededError(message, rid, response.headers);
|
|
389
|
+
return new QuotaExceededError(message, rid, response.headers, body, 402);
|
|
390
|
+
case 403:
|
|
391
|
+
if (errorType === "plan_required") {
|
|
392
|
+
return new PlanRequiredError(message, rid, response.headers, body);
|
|
393
|
+
}
|
|
394
|
+
return new ChronaryError(message, response.status, rid, response.headers, errorType, body);
|
|
345
395
|
case 404:
|
|
346
|
-
return new NotFoundError(message, rid, response.headers);
|
|
396
|
+
return new NotFoundError(message, rid, response.headers, body);
|
|
347
397
|
case 422:
|
|
348
|
-
return new ValidationError(message, response.status, rid, response.headers);
|
|
398
|
+
return new ValidationError(message, response.status, rid, response.headers, body);
|
|
349
399
|
case 429: {
|
|
350
400
|
if (errorType === "quota_exceeded") {
|
|
351
|
-
return new QuotaExceededError(message, rid, response.headers);
|
|
401
|
+
return new QuotaExceededError(message, rid, response.headers, body, 429);
|
|
352
402
|
}
|
|
353
|
-
return new RateLimitError(message, rid, response.headers);
|
|
403
|
+
return new RateLimitError(message, rid, response.headers, body);
|
|
354
404
|
}
|
|
355
405
|
default:
|
|
356
|
-
return new ChronaryError(message, response.status, rid, response.headers, errorType);
|
|
406
|
+
return new ChronaryError(message, response.status, rid, response.headers, errorType, body);
|
|
357
407
|
}
|
|
358
408
|
}
|
|
359
409
|
retryDelay(attempt, lastError) {
|
|
@@ -386,11 +436,30 @@ function parseQuotaSnapshot(headers) {
|
|
|
386
436
|
};
|
|
387
437
|
}
|
|
388
438
|
function parseStructuredParam(header, key) {
|
|
389
|
-
const
|
|
390
|
-
const
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
439
|
+
const prefix = `${key}=`;
|
|
440
|
+
for (const member of header.split(";")) {
|
|
441
|
+
const trimmed = member.trimStart();
|
|
442
|
+
if (!trimmed.startsWith(prefix)) continue;
|
|
443
|
+
const value = trimmed.slice(prefix.length);
|
|
444
|
+
if (!isSignedInteger(value)) continue;
|
|
445
|
+
const n = Number(value);
|
|
446
|
+
return Number.isFinite(n) ? n : void 0;
|
|
447
|
+
}
|
|
448
|
+
return void 0;
|
|
449
|
+
}
|
|
450
|
+
function isSignedInteger(value) {
|
|
451
|
+
const start = value.startsWith("-") ? 1 : 0;
|
|
452
|
+
if (value.length === start) return false;
|
|
453
|
+
for (let i = start; i < value.length; i++) {
|
|
454
|
+
const c = value.charCodeAt(i);
|
|
455
|
+
if (c < 48 || c > 57) return false;
|
|
456
|
+
}
|
|
457
|
+
return true;
|
|
458
|
+
}
|
|
459
|
+
function stripTrailingSlashes(url) {
|
|
460
|
+
let end = url.length;
|
|
461
|
+
while (end > 0 && url.charCodeAt(end - 1) === 47) end--;
|
|
462
|
+
return url.slice(0, end);
|
|
394
463
|
}
|
|
395
464
|
|
|
396
465
|
// src/pagination.ts
|
|
@@ -494,6 +563,14 @@ var CalendarsClient = class {
|
|
|
494
563
|
async delete(id, options) {
|
|
495
564
|
await this.client.request("DELETE", `/v1/calendars/${id}`, void 0, void 0, options);
|
|
496
565
|
}
|
|
566
|
+
/**
|
|
567
|
+
* Regenerate the calendar's iCal subscribe URL. The old URL stops working
|
|
568
|
+
* (copies cached elsewhere can be served for up to 5 minutes); returns the
|
|
569
|
+
* calendar with its new `ical_url`. Organization keys only.
|
|
570
|
+
*/
|
|
571
|
+
async rotateIcalToken(id, options) {
|
|
572
|
+
return this.client.request("POST", `/v1/calendars/${id}/ical-token/rotate`, void 0, void 0, options);
|
|
573
|
+
}
|
|
497
574
|
async getContext(id, options) {
|
|
498
575
|
return this.client.request(
|
|
499
576
|
"GET",
|
|
@@ -545,9 +622,10 @@ var BookingPagesClient = class {
|
|
|
545
622
|
return this.client.request("GET", `/v1/booking-pages/${id}`, void 0, void 0, options);
|
|
546
623
|
}
|
|
547
624
|
list(params = {}) {
|
|
548
|
-
const { limit = 50, offset = 0 } = params;
|
|
625
|
+
const { limit = 50, offset = 0, ...filters } = params;
|
|
549
626
|
return new PageIterator(
|
|
550
627
|
(offset2, l) => this.client.request("GET", "/v1/booking-pages", void 0, {
|
|
628
|
+
...filters,
|
|
551
629
|
limit: l,
|
|
552
630
|
offset: offset2
|
|
553
631
|
}),
|
|
@@ -561,6 +639,22 @@ var BookingPagesClient = class {
|
|
|
561
639
|
async delete(id, options) {
|
|
562
640
|
await this.client.request("DELETE", `/v1/booking-pages/${id}`, void 0, void 0, options);
|
|
563
641
|
}
|
|
642
|
+
/**
|
|
643
|
+
* One page of the bookings made through a booking page, newest start first,
|
|
644
|
+
* with the invitee's details. Pass the returned `next_cursor` as `cursor`
|
|
645
|
+
* for the next page (null on the last page). Bookings made before this
|
|
646
|
+
* endpoint was released are not linked to their page.
|
|
647
|
+
*/
|
|
648
|
+
async listBookings(id, params = {}, options) {
|
|
649
|
+
return this.client.request("GET", `/v1/booking-pages/${id}/bookings`, void 0, { ...params }, options);
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* Replace the page's public link. The old `/book/<slug>` stops working at
|
|
653
|
+
* once; returns the page with its new `slug` and `booking_url`.
|
|
654
|
+
*/
|
|
655
|
+
async rotateSlug(id, options) {
|
|
656
|
+
return this.client.request("POST", `/v1/booking-pages/${id}/rotate-slug`, void 0, void 0, options);
|
|
657
|
+
}
|
|
564
658
|
/**
|
|
565
659
|
* Public: list available slots for a booking page by its slug. No API key is
|
|
566
660
|
* required for this endpoint (the slug is the credential); any key set on the
|
|
@@ -623,6 +717,23 @@ var EventsClient = class {
|
|
|
623
717
|
offset
|
|
624
718
|
);
|
|
625
719
|
}
|
|
720
|
+
/**
|
|
721
|
+
* List events across all of the organization's calendars (`GET /v1/events`),
|
|
722
|
+
* ordered by start time. An agent-scoped key sees only its agent's
|
|
723
|
+
* calendars. `q` searches titles and needs a window of at most 31 days.
|
|
724
|
+
*/
|
|
725
|
+
listAll(params = {}) {
|
|
726
|
+
const { limit = 50, offset = 0, ...filters } = params;
|
|
727
|
+
return new PageIterator(
|
|
728
|
+
(offset2, l) => this.client.request("GET", "/v1/events", void 0, {
|
|
729
|
+
...filters,
|
|
730
|
+
limit: l,
|
|
731
|
+
offset: offset2
|
|
732
|
+
}),
|
|
733
|
+
limit,
|
|
734
|
+
offset
|
|
735
|
+
);
|
|
736
|
+
}
|
|
626
737
|
async update(calendarId, eventId, params, options) {
|
|
627
738
|
return this.client.request(
|
|
628
739
|
"PATCH",
|
|
@@ -811,12 +922,75 @@ var WebhooksClient = class {
|
|
|
811
922
|
await this.client.request("DELETE", `/v1/webhooks/${id}`, void 0, void 0, options);
|
|
812
923
|
}
|
|
813
924
|
async listDeliveries(webhookId, params = {}, options) {
|
|
814
|
-
const { limit = 20, offset = 0,
|
|
925
|
+
const { limit = 20, offset = 0, ...filters } = params;
|
|
926
|
+
const query = { limit, offset };
|
|
927
|
+
for (const [key, value] of Object.entries(filters)) {
|
|
928
|
+
if (value !== void 0) query[key] = value;
|
|
929
|
+
}
|
|
815
930
|
return this.client.request(
|
|
816
931
|
"GET",
|
|
817
932
|
`/v1/webhooks/${webhookId}/deliveries`,
|
|
818
933
|
void 0,
|
|
819
|
-
|
|
934
|
+
query,
|
|
935
|
+
options
|
|
936
|
+
);
|
|
937
|
+
}
|
|
938
|
+
/** One delivery with its payload and every attempt, oldest first. */
|
|
939
|
+
async getDelivery(webhookId, deliveryId, options) {
|
|
940
|
+
return this.client.request(
|
|
941
|
+
"GET",
|
|
942
|
+
`/v1/webhooks/${webhookId}/deliveries/${deliveryId}`,
|
|
943
|
+
void 0,
|
|
944
|
+
void 0,
|
|
945
|
+
options
|
|
946
|
+
);
|
|
947
|
+
}
|
|
948
|
+
/**
|
|
949
|
+
* Send a signed sample payload of one event type to the endpoint. The
|
|
950
|
+
* delivery is marked `is_test`, carries `X-Chronary-Test: 1`, makes one
|
|
951
|
+
* attempt and does not count toward the monthly quota. Poll `getDelivery`
|
|
952
|
+
* with the returned `delivery_id` for the result. Limited to 10 per minute.
|
|
953
|
+
*/
|
|
954
|
+
async sendTest(webhookId, params, options) {
|
|
955
|
+
return this.client.request(
|
|
956
|
+
"POST",
|
|
957
|
+
`/v1/webhooks/${webhookId}/test`,
|
|
958
|
+
params,
|
|
959
|
+
void 0,
|
|
960
|
+
options
|
|
961
|
+
);
|
|
962
|
+
}
|
|
963
|
+
/**
|
|
964
|
+
* Send a `failed` or `dropped` delivery again as a new delivery with its
|
|
965
|
+
* own `delivery_id` (Developer or Pro). The stored payload goes out unchanged, signed
|
|
966
|
+
* with the endpoint's current secret, with an `X-Chronary-Replay-Of`
|
|
967
|
+
* header. It follows the normal retry schedule and counts toward the
|
|
968
|
+
* monthly delivery quota. The endpoint must be active. Sent with an
|
|
969
|
+
* `Idempotency-Key` (generated, or `options.idempotencyKey`), so a retry
|
|
970
|
+
* returns the same replay. Limited to 30 per minute.
|
|
971
|
+
*/
|
|
972
|
+
async replayDelivery(webhookId, deliveryId, options) {
|
|
973
|
+
return this.client.request(
|
|
974
|
+
"POST",
|
|
975
|
+
`/v1/webhooks/${webhookId}/deliveries/${deliveryId}/replay`,
|
|
976
|
+
void 0,
|
|
977
|
+
void 0,
|
|
978
|
+
options
|
|
979
|
+
);
|
|
980
|
+
}
|
|
981
|
+
/**
|
|
982
|
+
* Rotate the endpoint's signing secret (Developer or Pro). The new secret is returned
|
|
983
|
+
* once and signs `X-Signature` from the next attempt. The replaced secret
|
|
984
|
+
* keeps signing `X-Signature-Previous` until `expire_old_in` has passed
|
|
985
|
+
* (default `24h`; `now` drops it at once), so receivers can switch
|
|
986
|
+
* without rejecting deliveries. `verifySignature` accepts either header.
|
|
987
|
+
*/
|
|
988
|
+
async rotateSecret(webhookId, params = {}, options) {
|
|
989
|
+
return this.client.request(
|
|
990
|
+
"POST",
|
|
991
|
+
`/v1/webhooks/${webhookId}/secret/rotate`,
|
|
992
|
+
params,
|
|
993
|
+
void 0,
|
|
820
994
|
options
|
|
821
995
|
);
|
|
822
996
|
}
|
|
@@ -877,6 +1051,12 @@ var ICalSubscriptionsClient = class {
|
|
|
877
1051
|
options
|
|
878
1052
|
);
|
|
879
1053
|
}
|
|
1054
|
+
/**
|
|
1055
|
+
* Start an immediate fetch of the feed. Resolves with `{ status: 'syncing' }`
|
|
1056
|
+
* as soon as the fetch has started; read the subscription a few seconds later
|
|
1057
|
+
* for `last_synced_at` / `last_error`. A paused feed rejects with 409, and a
|
|
1058
|
+
* second sync of the same feed within a minute rejects with 429.
|
|
1059
|
+
*/
|
|
880
1060
|
async sync(id, options) {
|
|
881
1061
|
return this.client.request(
|
|
882
1062
|
"POST",
|
|
@@ -886,6 +1066,26 @@ var ICalSubscriptionsClient = class {
|
|
|
886
1066
|
options
|
|
887
1067
|
);
|
|
888
1068
|
}
|
|
1069
|
+
/** Stop polling the feed until it is resumed. Pausing a paused feed changes nothing. */
|
|
1070
|
+
async pause(id, options) {
|
|
1071
|
+
return this.client.request(
|
|
1072
|
+
"POST",
|
|
1073
|
+
`/v1/ical-subscriptions/${id}/pause`,
|
|
1074
|
+
void 0,
|
|
1075
|
+
void 0,
|
|
1076
|
+
options
|
|
1077
|
+
);
|
|
1078
|
+
}
|
|
1079
|
+
/** Return a paused or failing feed to polling and clear `last_error`. */
|
|
1080
|
+
async resume(id, options) {
|
|
1081
|
+
return this.client.request(
|
|
1082
|
+
"POST",
|
|
1083
|
+
`/v1/ical-subscriptions/${id}/resume`,
|
|
1084
|
+
void 0,
|
|
1085
|
+
void 0,
|
|
1086
|
+
options
|
|
1087
|
+
);
|
|
1088
|
+
}
|
|
889
1089
|
};
|
|
890
1090
|
|
|
891
1091
|
// src/resources/scheduling.ts
|
|
@@ -963,6 +1163,15 @@ var UsageClient = class {
|
|
|
963
1163
|
async get(options) {
|
|
964
1164
|
return this.client.request("GET", "/v1/usage", void 0, void 0, options);
|
|
965
1165
|
}
|
|
1166
|
+
/**
|
|
1167
|
+
* Monthly totals for the last 1-12 UTC calendar months (default 6), oldest
|
|
1168
|
+
* first, ending with the current partial month. Org-level keys only; not
|
|
1169
|
+
* counted toward API calls.
|
|
1170
|
+
*/
|
|
1171
|
+
async history(params, options) {
|
|
1172
|
+
const query = { months: params?.months };
|
|
1173
|
+
return this.client.request("GET", "/v1/usage/history", void 0, query, options);
|
|
1174
|
+
}
|
|
966
1175
|
};
|
|
967
1176
|
|
|
968
1177
|
// src/resources/audit-log.ts
|
|
@@ -977,6 +1186,12 @@ var AuditLogClient = class {
|
|
|
977
1186
|
to: params?.to,
|
|
978
1187
|
action: params?.action,
|
|
979
1188
|
actor_key_prefix: params?.actor_key_prefix,
|
|
1189
|
+
actor_type: params?.actor_type,
|
|
1190
|
+
actor_id: params?.actor_id,
|
|
1191
|
+
request_id: params?.request_id,
|
|
1192
|
+
resource: params?.resource,
|
|
1193
|
+
status_class: params?.status_class,
|
|
1194
|
+
category: params?.category,
|
|
980
1195
|
cursor: params?.cursor,
|
|
981
1196
|
limit: params?.limit
|
|
982
1197
|
};
|
|
@@ -1075,19 +1290,18 @@ var WaitlistClient = class {
|
|
|
1075
1290
|
}
|
|
1076
1291
|
client;
|
|
1077
1292
|
/**
|
|
1078
|
-
* Join the Chronary waitlist
|
|
1079
|
-
*
|
|
1080
|
-
*
|
|
1293
|
+
* Join the Chronary waitlist. Used while open sign-up is gated. Adds the
|
|
1294
|
+
* email to the waitlist; an account is created only when a founder approves
|
|
1295
|
+
* it and the person accepts the emailed invite.
|
|
1081
1296
|
*
|
|
1082
1297
|
* No authentication required — invoke on a `Chronary` client constructed
|
|
1083
1298
|
* with no `apiKey`.
|
|
1084
1299
|
*
|
|
1085
|
-
*
|
|
1086
|
-
* the
|
|
1087
|
-
*
|
|
1300
|
+
* Always resolves to the same `{ waitlisted: true, message }` (HTTP 202),
|
|
1301
|
+
* whether the email is new, already on the list, or has an active account,
|
|
1302
|
+
* so the response can't be used to look up other people's accounts. Only a
|
|
1303
|
+
* new email is sent the confirmation email.
|
|
1088
1304
|
*
|
|
1089
|
-
* @throws ChronaryError (409 `email_taken`) when an active account already
|
|
1090
|
-
* exists for this email — direct the user to sign-in instead.
|
|
1091
1305
|
* @throws ChronaryError (409 `tos_version_stale`) when the supplied
|
|
1092
1306
|
* `tos_version` doesn't match the currently-published version.
|
|
1093
1307
|
* @throws ChronaryError (429 `rate_limit_error`) on the per-IP / per-email
|
|
@@ -1111,7 +1325,7 @@ var FeedbackClient = class {
|
|
|
1111
1325
|
}
|
|
1112
1326
|
client;
|
|
1113
1327
|
/**
|
|
1114
|
-
* Submit structured feedback (bug, feature, or
|
|
1328
|
+
* Submit structured feedback (bug, feature, friction, or support) to Chronary.
|
|
1115
1329
|
*
|
|
1116
1330
|
* Rate-limited to 25 submissions per day per organization (UTC day).
|
|
1117
1331
|
* Available on all plans, including free. The 26th submission returns
|
|
@@ -1138,7 +1352,7 @@ var PlansClient = class {
|
|
|
1138
1352
|
/**
|
|
1139
1353
|
* Fetch the public plan catalog (`GET /v1/plans`).
|
|
1140
1354
|
*
|
|
1141
|
-
* Returns all sellable tiers (free,
|
|
1355
|
+
* Returns all sellable tiers (free, developer, pro) plus the enterprise
|
|
1142
1356
|
* tier with `custom_pricing: true`. No authentication required.
|
|
1143
1357
|
* Responses are cacheable for 5 minutes at the edge.
|
|
1144
1358
|
*/
|
|
@@ -1218,6 +1432,17 @@ var ConnectionLinksClient = class {
|
|
|
1218
1432
|
async create(calendarId, params, options) {
|
|
1219
1433
|
return this.client.request("POST", `/v1/calendars/${calendarId}/connection-links`, params, void 0, options);
|
|
1220
1434
|
}
|
|
1435
|
+
/** Setup links, newest first. An agent-scoped key sees only its own calendars' links. */
|
|
1436
|
+
async list(params = {}, options) {
|
|
1437
|
+
const { status, calendar_id, limit } = params;
|
|
1438
|
+
return this.client.request(
|
|
1439
|
+
"GET",
|
|
1440
|
+
"/v1/connection-links",
|
|
1441
|
+
void 0,
|
|
1442
|
+
{ ...status !== void 0 && { status }, ...calendar_id !== void 0 && { calendar_id }, ...limit !== void 0 && { limit } },
|
|
1443
|
+
options
|
|
1444
|
+
);
|
|
1445
|
+
}
|
|
1221
1446
|
async get(id, options) {
|
|
1222
1447
|
return this.client.request("GET", `/v1/connection-links/${id}`, void 0, void 0, options);
|
|
1223
1448
|
}
|
|
@@ -1226,6 +1451,42 @@ var ConnectionLinksClient = class {
|
|
|
1226
1451
|
}
|
|
1227
1452
|
};
|
|
1228
1453
|
|
|
1454
|
+
// src/resources/billing.ts
|
|
1455
|
+
var UpgradeRequestsClient = class {
|
|
1456
|
+
constructor(client) {
|
|
1457
|
+
this.client = client;
|
|
1458
|
+
}
|
|
1459
|
+
client;
|
|
1460
|
+
/**
|
|
1461
|
+
* Ask a human to upgrade this account's plan. Org keys (`chr_sk_`) only.
|
|
1462
|
+
* Returns an `approval_url` to hand to your human. Honors `idempotencyKey`;
|
|
1463
|
+
* if `reused` is true a request is already pending — poll it instead.
|
|
1464
|
+
*/
|
|
1465
|
+
async create(params = {}, options) {
|
|
1466
|
+
return this.client.request("POST", "/v1/billing/upgrade-requests", params, void 0, options);
|
|
1467
|
+
}
|
|
1468
|
+
/** Poll an upgrade request (at most once a minute). */
|
|
1469
|
+
async get(id, options) {
|
|
1470
|
+
return this.client.request("GET", `/v1/billing/upgrade-requests/${id}`, void 0, void 0, options);
|
|
1471
|
+
}
|
|
1472
|
+
/** Withdraw a pending upgrade request. */
|
|
1473
|
+
async cancel(id, options) {
|
|
1474
|
+
return this.client.request("POST", `/v1/billing/upgrade-requests/${id}/cancel`, void 0, void 0, options);
|
|
1475
|
+
}
|
|
1476
|
+
};
|
|
1477
|
+
var BillingClient = class {
|
|
1478
|
+
constructor(client) {
|
|
1479
|
+
this.client = client;
|
|
1480
|
+
this.upgradeRequests = new UpgradeRequestsClient(client);
|
|
1481
|
+
}
|
|
1482
|
+
client;
|
|
1483
|
+
upgradeRequests;
|
|
1484
|
+
/** Read-only billing summary for the org (plan, status, upgrade options, pending upgrade request). */
|
|
1485
|
+
async get(options) {
|
|
1486
|
+
return this.client.request("GET", "/v1/billing", void 0, void 0, options);
|
|
1487
|
+
}
|
|
1488
|
+
};
|
|
1489
|
+
|
|
1229
1490
|
// src/webhook-verify.ts
|
|
1230
1491
|
var DEFAULT_TOLERANCE = 5 * 60 * 1e3;
|
|
1231
1492
|
function bufToHex(buf) {
|
|
@@ -1269,10 +1530,11 @@ function extractHeaders(headers) {
|
|
|
1269
1530
|
return getHeader(headers, name);
|
|
1270
1531
|
};
|
|
1271
1532
|
const signature = get("X-Signature") ?? get("x-signature");
|
|
1533
|
+
const previousSignature = get("X-Signature-Previous") ?? get("x-signature-previous");
|
|
1272
1534
|
const timestamp = get("X-Timestamp") ?? get("x-timestamp");
|
|
1273
1535
|
if (!signature) throw new ChronaryError("Missing X-Signature header", 0);
|
|
1274
1536
|
if (!timestamp) throw new ChronaryError("Missing X-Timestamp header", 0);
|
|
1275
|
-
return { signature, timestamp };
|
|
1537
|
+
return { signature, previousSignature: previousSignature || null, timestamp };
|
|
1276
1538
|
}
|
|
1277
1539
|
async function verifySignature(rawBody, headers, secret, options) {
|
|
1278
1540
|
if (typeof rawBody !== "string") {
|
|
@@ -1281,7 +1543,7 @@ async function verifySignature(rawBody, headers, secret, options) {
|
|
|
1281
1543
|
0
|
|
1282
1544
|
);
|
|
1283
1545
|
}
|
|
1284
|
-
const { signature, timestamp } = extractHeaders(headers);
|
|
1546
|
+
const { signature, previousSignature, timestamp } = extractHeaders(headers);
|
|
1285
1547
|
const tolerance = options?.tolerance ?? DEFAULT_TOLERANCE;
|
|
1286
1548
|
const tsMs = parseInt(timestamp, 10) * 1e3;
|
|
1287
1549
|
const now = Date.now();
|
|
@@ -1292,7 +1554,9 @@ async function verifySignature(rawBody, headers, secret, options) {
|
|
|
1292
1554
|
);
|
|
1293
1555
|
}
|
|
1294
1556
|
const expected = await computeSignature(secret, timestamp, rawBody);
|
|
1295
|
-
|
|
1557
|
+
const matchesCurrent = constantTimeEqual(expected, signature);
|
|
1558
|
+
const matchesPrevious = previousSignature !== null && constantTimeEqual(expected, previousSignature);
|
|
1559
|
+
if (!matchesCurrent && !matchesPrevious) {
|
|
1296
1560
|
throw new ChronaryError("Webhook signature verification failed", 0);
|
|
1297
1561
|
}
|
|
1298
1562
|
}
|
|
@@ -1324,6 +1588,7 @@ var Chronary = class {
|
|
|
1324
1588
|
account;
|
|
1325
1589
|
terms;
|
|
1326
1590
|
connectionLinks;
|
|
1591
|
+
billing;
|
|
1327
1592
|
constructor(config) {
|
|
1328
1593
|
const client = new CoreClient(config);
|
|
1329
1594
|
this.agents = new AgentsClient(client);
|
|
@@ -1344,6 +1609,7 @@ var Chronary = class {
|
|
|
1344
1609
|
this.account = new AccountClient(client);
|
|
1345
1610
|
this.terms = new TermsClient(client);
|
|
1346
1611
|
this.connectionLinks = new ConnectionLinksClient(client);
|
|
1612
|
+
this.billing = new BillingClient(client);
|
|
1347
1613
|
}
|
|
1348
1614
|
static webhooks = {
|
|
1349
1615
|
verifySignature,
|
|
@@ -1355,6 +1621,7 @@ var index_default = Chronary;
|
|
|
1355
1621
|
0 && (module.exports = {
|
|
1356
1622
|
APIPromise,
|
|
1357
1623
|
AuthenticationError,
|
|
1624
|
+
BillingClient,
|
|
1358
1625
|
BookingPagesClient,
|
|
1359
1626
|
Chronary,
|
|
1360
1627
|
ChronaryError,
|
|
@@ -1363,9 +1630,11 @@ var index_default = Chronary;
|
|
|
1363
1630
|
CoreClient,
|
|
1364
1631
|
NotFoundError,
|
|
1365
1632
|
PageIterator,
|
|
1633
|
+
PlanRequiredError,
|
|
1366
1634
|
QuotaExceededError,
|
|
1367
1635
|
RateLimitError,
|
|
1368
1636
|
TimeoutError,
|
|
1637
|
+
UpgradeRequestsClient,
|
|
1369
1638
|
VERSION,
|
|
1370
1639
|
ValidationError,
|
|
1371
1640
|
constructEvent,
|