@atlasauth/backend 0.18.0 → 0.19.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.
Files changed (86) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/backchannel-handlers.d.ts +87 -0
  3. package/dist/backchannel-handlers.js +137 -0
  4. package/dist/backchannel-handlers.js.map +1 -0
  5. package/dist/client/activity.d.ts +13 -2
  6. package/dist/client/activity.js.map +1 -1
  7. package/dist/client/audit-logs.d.ts +7 -0
  8. package/dist/client/audit-logs.js.map +1 -1
  9. package/dist/client/compliance.d.ts +216 -0
  10. package/dist/client/compliance.js +77 -0
  11. package/dist/client/compliance.js.map +1 -0
  12. package/dist/client/credentials.d.ts +409 -0
  13. package/dist/client/credentials.js +158 -0
  14. package/dist/client/credentials.js.map +1 -0
  15. package/dist/client/data-subject-requests.d.ts +36 -1
  16. package/dist/client/data-subject-requests.js.map +1 -1
  17. package/dist/client/design.d.ts +48 -0
  18. package/dist/client/design.js +9 -0
  19. package/dist/client/design.js.map +1 -1
  20. package/dist/client/entitlement-overrides.d.ts +30 -0
  21. package/dist/client/entitlement-overrides.js +9 -0
  22. package/dist/client/entitlement-overrides.js.map +1 -1
  23. package/dist/client/env.d.ts +16 -0
  24. package/dist/client/env.js +38 -0
  25. package/dist/client/env.js.map +1 -0
  26. package/dist/client/error.d.ts +10 -0
  27. package/dist/client/error.js +4 -0
  28. package/dist/client/error.js.map +1 -1
  29. package/dist/client/index.d.ts +312 -7
  30. package/dist/client/index.js +39 -1
  31. package/dist/client/index.js.map +1 -1
  32. package/dist/client/instance.d.ts +401 -3
  33. package/dist/client/instance.js +77 -3
  34. package/dist/client/instance.js.map +1 -1
  35. package/dist/client/integrations.d.ts +107 -0
  36. package/dist/client/integrations.js +25 -0
  37. package/dist/client/integrations.js.map +1 -0
  38. package/dist/client/messaging.d.ts +18 -4
  39. package/dist/client/messaging.js +6 -2
  40. package/dist/client/messaging.js.map +1 -1
  41. package/dist/client/oauth-clients.d.ts +11 -3
  42. package/dist/client/oauth-clients.js +4 -2
  43. package/dist/client/oauth-clients.js.map +1 -1
  44. package/dist/client/operator.d.ts +100 -0
  45. package/dist/client/operator.js +132 -0
  46. package/dist/client/operator.js.map +1 -0
  47. package/dist/client/platform.d.ts +233 -9
  48. package/dist/client/platform.js +74 -6
  49. package/dist/client/platform.js.map +1 -1
  50. package/dist/client/privacy.d.ts +127 -0
  51. package/dist/client/privacy.js +44 -0
  52. package/dist/client/privacy.js.map +1 -0
  53. package/dist/client/referrals.d.ts +53 -6
  54. package/dist/client/referrals.js +9 -0
  55. package/dist/client/referrals.js.map +1 -1
  56. package/dist/client/request.d.ts +38 -1
  57. package/dist/client/request.js +6 -2
  58. package/dist/client/request.js.map +1 -1
  59. package/dist/client/sealed-box.d.ts +7 -0
  60. package/dist/client/sealed-box.js +62 -0
  61. package/dist/client/sealed-box.js.map +1 -0
  62. package/dist/client/sessions.d.ts +16 -5
  63. package/dist/client/sessions.js +7 -10
  64. package/dist/client/sessions.js.map +1 -1
  65. package/dist/client/status.d.ts +200 -0
  66. package/dist/client/status.js +54 -0
  67. package/dist/client/status.js.map +1 -0
  68. package/dist/client/webhooks.d.ts +244 -11
  69. package/dist/client/webhooks.js +52 -3
  70. package/dist/client/webhooks.js.map +1 -1
  71. package/dist/index.d.ts +8 -6
  72. package/dist/index.js +19 -4
  73. package/dist/index.js.map +1 -1
  74. package/dist/oidc.d.ts +65 -1
  75. package/dist/oidc.js +46 -0
  76. package/dist/oidc.js.map +1 -1
  77. package/dist/referral-test-calls.d.ts +26 -13
  78. package/dist/referral-test-calls.js +40 -14
  79. package/dist/referral-test-calls.js.map +1 -1
  80. package/dist/testing.d.ts +41 -6
  81. package/dist/testing.js +34 -2
  82. package/dist/testing.js.map +1 -1
  83. package/dist/webhooks.d.ts +8 -0
  84. package/dist/webhooks.js +13 -4
  85. package/dist/webhooks.js.map +1 -1
  86. package/package.json +6 -3
@@ -0,0 +1,200 @@
1
+ import { type RequestFn } from './request';
2
+ /**
3
+ * Atlas service status for your instance: the incident subscription (owner
4
+ * email, `status_incident.*` webhooks, a private RSS / Atom feed) filtered by
5
+ * region, component and impact; the incidents that concern you; and the
6
+ * upstream status pages (any Statuspage-compatible URL) your app depends on.
7
+ *
8
+ * The public Statuspage-compatible feed itself needs no key:
9
+ * `https://<frontend api>/v1/status/api/v2/summary.json` (and the other
10
+ * Statuspage files, RSS and Atom) — point any status page at it.
11
+ */
12
+ export type StatusComponentId = 'frontend_api' | 'backend_api' | 'database' | 'cache' | 'background_jobs';
13
+ export type StatusImpact = 'none' | 'minor' | 'major' | 'critical';
14
+ export type StatusIncidentStatus = 'investigating' | 'identified' | 'monitoring' | 'resolved' | 'scheduled' | 'in_progress' | 'completed';
15
+ export type StatusDependencyState = 'operational' | 'degraded' | 'partial_outage' | 'major_outage' | 'maintenance' | 'unknown';
16
+ /** `GET /v1/status` (public). */
17
+ export interface ServiceStatus {
18
+ object: 'status';
19
+ status: 'operational' | 'degraded' | 'major_outage';
20
+ updated_at: number;
21
+ regions: string[];
22
+ groups: Array<{
23
+ id: string;
24
+ name: string;
25
+ component_ids: string[];
26
+ }>;
27
+ components: Array<{
28
+ id: StatusComponentId;
29
+ name: string;
30
+ status: 'operational' | 'degraded' | 'major_outage' | 'unknown';
31
+ description: string;
32
+ group: string;
33
+ regions: string[];
34
+ }>;
35
+ incidents: Array<{
36
+ id: string;
37
+ kind: 'incident' | 'maintenance';
38
+ title: string;
39
+ status: StatusIncidentStatus;
40
+ impact: StatusImpact;
41
+ regions: string[];
42
+ component_ids: string[];
43
+ started_at: number;
44
+ resolved_at: number | null;
45
+ updated_at: number;
46
+ }>;
47
+ }
48
+ export interface StatusSubscription {
49
+ object: 'status_subscription';
50
+ /** A subscription exists (it may be disabled). */
51
+ subscribed: boolean;
52
+ enabled: boolean;
53
+ /** [] = every region. */
54
+ regions: string[];
55
+ /** [] = every component. */
56
+ component_ids: StatusComponentId[];
57
+ min_impact: 'minor' | 'major' | 'critical';
58
+ include_maintenance: boolean;
59
+ email_owners: boolean;
60
+ webhook: boolean;
61
+ /** The private feed; treat it as a secret (`rotateFeed` replaces it). */
62
+ rss_url: string | null;
63
+ atom_url: string | null;
64
+ available_regions: string[];
65
+ available_components: Array<{
66
+ id: StatusComponentId;
67
+ name: string;
68
+ }>;
69
+ updated_at: number | null;
70
+ }
71
+ export interface UpdateStatusSubscriptionBody {
72
+ enabled?: boolean;
73
+ regions?: string[];
74
+ component_ids?: StatusComponentId[];
75
+ min_impact?: 'minor' | 'major' | 'critical';
76
+ include_maintenance?: boolean;
77
+ email_owners?: boolean;
78
+ webhook?: boolean;
79
+ }
80
+ export interface StatusIncidentUpdate {
81
+ id: string;
82
+ status: StatusIncidentStatus;
83
+ body: string;
84
+ created_at: number;
85
+ }
86
+ export interface StatusIncident {
87
+ object: 'status_incident';
88
+ id: string;
89
+ kind: 'incident' | 'maintenance';
90
+ title: string;
91
+ status: StatusIncidentStatus;
92
+ impact: StatusImpact;
93
+ regions: string[];
94
+ component_ids: string[];
95
+ started_at: number;
96
+ resolved_at: number | null;
97
+ updated_at: number;
98
+ source: 'atlas' | 'import' | (string & {});
99
+ scheduled_for: number | null;
100
+ scheduled_until: number | null;
101
+ /** Oldest first. */
102
+ updates: StatusIncidentUpdate[];
103
+ }
104
+ /** `data` of the `status_incident.created` / `updated` / `resolved` webhook events. */
105
+ export interface StatusIncidentEventData {
106
+ object: 'status_incident';
107
+ id: string;
108
+ kind: 'incident' | 'maintenance';
109
+ title: string;
110
+ status: StatusIncidentStatus;
111
+ impact: StatusImpact;
112
+ regions: string[];
113
+ component_ids: string[];
114
+ /** The part of the incident that matches your subscription. */
115
+ affected_regions: string[];
116
+ affected_component_ids: string[];
117
+ started_at: number;
118
+ resolved_at: number | null;
119
+ update: StatusIncidentUpdate;
120
+ /** The incident on the status page. */
121
+ url: string;
122
+ }
123
+ export interface StatusDependency {
124
+ object: 'status_dependency';
125
+ id: string;
126
+ name: string;
127
+ /** Base URL of the Statuspage-compatible page (Atlas reads `{url}/api/v2/summary.json`). */
128
+ url: string;
129
+ component_filter: string[];
130
+ enabled: boolean;
131
+ state: StatusDependencyState;
132
+ indicator: string | null;
133
+ description: string | null;
134
+ components: Array<{
135
+ id: string;
136
+ name: string;
137
+ status: string;
138
+ }>;
139
+ incidents: Array<{
140
+ id: string;
141
+ name: string;
142
+ status: string;
143
+ impact: string;
144
+ updatedAt: string | null;
145
+ }>;
146
+ last_checked_at: number | null;
147
+ last_success_at: number | null;
148
+ last_error: string | null;
149
+ /** The last check failed or none has succeeded yet: `state` may be out of date. */
150
+ stale: boolean;
151
+ created_at: number;
152
+ }
153
+ export interface CreateStatusDependencyBody {
154
+ name: string;
155
+ url: string;
156
+ component_filter?: string[];
157
+ enabled?: boolean;
158
+ }
159
+ export interface UpdateStatusDependencyBody {
160
+ name?: string;
161
+ component_filter?: string[];
162
+ enabled?: boolean;
163
+ }
164
+ export declare function statusResource(request: RequestFn): {
165
+ /** `GET /v1/status` — the public service status (components with group and regions, open incidents). */
166
+ service(): Promise<ServiceStatus>;
167
+ /** `GET /v1/instance/status_subscription`. */
168
+ getSubscription(): Promise<StatusSubscription>;
169
+ /** `PUT /v1/instance/status_subscription` — create or change it; only the fields sent change. */
170
+ updateSubscription(body: UpdateStatusSubscriptionBody): Promise<StatusSubscription>;
171
+ /** `DELETE /v1/instance/status_subscription` — turn it off (settings are kept). */
172
+ disableSubscription(): Promise<StatusSubscription>;
173
+ /** `POST /v1/instance/status_subscription/rotate_feed` — a new private feed URL; the old one 404s. */
174
+ rotateFeed(): Promise<StatusSubscription>;
175
+ /** `GET /v1/instance/status_incidents` — incidents that concern this instance, newest first. */
176
+ listIncidents(params?: {
177
+ open?: boolean;
178
+ limit?: number;
179
+ }): Promise<{
180
+ object: "list";
181
+ data: StatusIncident[];
182
+ }>;
183
+ /** `GET /v1/instance/status_dependencies` — with `state`, the worst among the enabled ones. */
184
+ listDependencies(): Promise<{
185
+ object: "list";
186
+ data: StatusDependency[];
187
+ state: StatusDependencyState;
188
+ }>;
189
+ /** `POST /v1/instance/status_dependencies` — read at once; the answer carries the state or `last_error`. */
190
+ createDependency(body: CreateStatusDependencyBody): Promise<StatusDependency>;
191
+ getDependency(id: string): Promise<StatusDependency>;
192
+ updateDependency(id: string, body: UpdateStatusDependencyBody): Promise<StatusDependency>;
193
+ deleteDependency(id: string): Promise<{
194
+ object: "status_dependency";
195
+ id: string;
196
+ deleted: true;
197
+ }>;
198
+ /** `POST /v1/instance/status_dependencies/:id/refresh` — read the page now. */
199
+ refreshDependency(id: string): Promise<StatusDependency>;
200
+ };
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.statusResource = statusResource;
4
+ const request_1 = require("./request");
5
+ function statusResource(request) {
6
+ return {
7
+ /** `GET /v1/status` — the public service status (components with group and regions, open incidents). */
8
+ service() {
9
+ return request({ method: 'GET', path: '/v1/status' });
10
+ },
11
+ /** `GET /v1/instance/status_subscription`. */
12
+ getSubscription() {
13
+ return request({ method: 'GET', path: '/v1/instance/status_subscription' });
14
+ },
15
+ /** `PUT /v1/instance/status_subscription` — create or change it; only the fields sent change. */
16
+ updateSubscription(body) {
17
+ return request({ method: 'PUT', path: '/v1/instance/status_subscription', body });
18
+ },
19
+ /** `DELETE /v1/instance/status_subscription` — turn it off (settings are kept). */
20
+ disableSubscription() {
21
+ return request({ method: 'DELETE', path: '/v1/instance/status_subscription' });
22
+ },
23
+ /** `POST /v1/instance/status_subscription/rotate_feed` — a new private feed URL; the old one 404s. */
24
+ rotateFeed() {
25
+ return request({ method: 'POST', path: '/v1/instance/status_subscription/rotate_feed' });
26
+ },
27
+ /** `GET /v1/instance/status_incidents` — incidents that concern this instance, newest first. */
28
+ listIncidents(params = {}) {
29
+ return request({ method: 'GET', path: '/v1/instance/status_incidents', query: { ...params } });
30
+ },
31
+ /** `GET /v1/instance/status_dependencies` — with `state`, the worst among the enabled ones. */
32
+ listDependencies() {
33
+ return request({ method: 'GET', path: '/v1/instance/status_dependencies' });
34
+ },
35
+ /** `POST /v1/instance/status_dependencies` — read at once; the answer carries the state or `last_error`. */
36
+ createDependency(body) {
37
+ return request({ method: 'POST', path: '/v1/instance/status_dependencies', body });
38
+ },
39
+ getDependency(id) {
40
+ return request({ method: 'GET', path: `/v1/instance/status_dependencies/${(0, request_1.enc)(id)}` });
41
+ },
42
+ updateDependency(id, body) {
43
+ return request({ method: 'PATCH', path: `/v1/instance/status_dependencies/${(0, request_1.enc)(id)}`, body });
44
+ },
45
+ deleteDependency(id) {
46
+ return request({ method: 'DELETE', path: `/v1/instance/status_dependencies/${(0, request_1.enc)(id)}` });
47
+ },
48
+ /** `POST /v1/instance/status_dependencies/:id/refresh` — read the page now. */
49
+ refreshDependency(id) {
50
+ return request({ method: 'POST', path: `/v1/instance/status_dependencies/${(0, request_1.enc)(id)}/refresh` });
51
+ },
52
+ };
53
+ }
54
+ //# sourceMappingURL=status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/client/status.ts"],"names":[],"mappings":";;AA8JA,wCAgDC;AA9MD,uCAAgD;AA8JhD,SAAgB,cAAc,CAAC,OAAkB;IAC/C,OAAO;QACL,wGAAwG;QACxG,OAAO;YACL,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;QACxD,CAAC;QACD,8CAA8C;QAC9C,eAAe;YACb,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,kCAAkC,EAAE,CAAC,CAAC;QAC9E,CAAC;QACD,iGAAiG;QACjG,kBAAkB,CAAC,IAAkC;YACnD,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,kCAAkC,EAAE,IAAI,EAAE,CAAC,CAAC;QACpF,CAAC;QACD,mFAAmF;QACnF,mBAAmB;YACjB,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,kCAAkC,EAAE,CAAC,CAAC;QACjF,CAAC;QACD,sGAAsG;QACtG,UAAU;YACR,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,8CAA8C,EAAE,CAAC,CAAC;QAC3F,CAAC;QACD,gGAAgG;QAChG,aAAa,CAAC,SAA6C,EAAE;YAC3D,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,+BAA+B,EAAE,KAAK,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,CAAC,CAAC;QACjG,CAAC;QACD,+FAA+F;QAC/F,gBAAgB;YACd,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,kCAAkC,EAAE,CAAC,CAAC;QAC9E,CAAC;QACD,4GAA4G;QAC5G,gBAAgB,CAAC,IAAgC;YAC/C,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,kCAAkC,EAAE,IAAI,EAAE,CAAC,CAAC;QACrF,CAAC;QACD,aAAa,CAAC,EAAU;YACtB,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,oCAAoC,IAAA,aAAG,EAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QACzF,CAAC;QACD,gBAAgB,CAAC,EAAU,EAAE,IAAgC;YAC3D,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,oCAAoC,IAAA,aAAG,EAAC,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;QACjG,CAAC;QACD,gBAAgB,CAAC,EAAU;YACzB,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,oCAAoC,IAAA,aAAG,EAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAC5F,CAAC;QACD,+EAA+E;QAC/E,iBAAiB,CAAC,EAAU;YAC1B,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,oCAAoC,IAAA,aAAG,EAAC,EAAE,CAAC,UAAU,EAAE,CAAC,CAAC;QAClG,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -1,13 +1,98 @@
1
+ import { type ProvisioningFields, type ProvisioningInput, type ProvisioningMetadata } from './compliance';
1
2
  import { type RequestFn } from './request';
2
- export interface WebhookEndpoint {
3
+ export type WebhookDestinationType = 'https' | 'aws_eventbridge' | 'gcp_pubsub' | 'cloudflare_queue';
4
+ /** Where deliveries go. Credentials are never returned. */
5
+ export type WebhookDestination = {
6
+ type: 'https';
7
+ } | {
8
+ type: 'aws_eventbridge';
9
+ region: string;
10
+ event_bus_name: string;
11
+ source?: string;
12
+ } | {
13
+ type: 'gcp_pubsub';
14
+ project_id: string;
15
+ topic_id: string;
16
+ } | {
17
+ type: 'cloudflare_queue';
18
+ account_id: string;
19
+ queue_id: string;
20
+ };
21
+ /** Your own credentials for an event destination (stored encrypted, write-only). */
22
+ export type WebhookDestinationCredentials = {
23
+ access_key_id: string;
24
+ secret_access_key: string;
25
+ session_token?: string;
26
+ } | {
27
+ service_account_json: string | Record<string, unknown>;
28
+ } | {
29
+ api_token: string;
30
+ };
31
+ export interface WebhookLastFailure {
32
+ at: number;
33
+ status: number | null;
34
+ error: string | null;
35
+ }
36
+ export interface WebhookAutoDisableRule {
37
+ after_failing_ms: number;
38
+ after_consecutive_failures: number;
39
+ consecutive_failures_min_failing_ms: number;
40
+ description: string;
41
+ }
42
+ export interface WebhookRetention {
43
+ events_days: number;
44
+ delivery_log_days: number;
45
+ replay_window_days: number;
46
+ }
47
+ export interface WebhookEndpoint extends ProvisioningFields {
3
48
  object: 'webhook_endpoint';
4
49
  id: string;
50
+ /** The HTTPS receiver, or a descriptor such as `aws-eventbridge://us-east-1/default`. */
5
51
  url: string;
52
+ description?: string | null;
6
53
  enabled_events: string[];
54
+ /** Which names `*` delivers under. */
55
+ event_naming?: 'canonical' | 'legacy';
7
56
  active: boolean;
57
+ /** A third-party receiver: preflight does not flag its host. */
58
+ external?: boolean;
59
+ signature_versions?: Array<'v1' | 'v2'>;
60
+ destination?: WebhookDestination & {
61
+ credentials_set?: boolean;
62
+ };
63
+ health?: 'healthy' | 'failing' | 'disabled';
8
64
  /** Start of the current failure streak (epoch ms), or null when the last delivery succeeded. */
9
65
  failing_since?: number | null;
66
+ /** Start of the streak that preceded the last re-enable (epoch ms); what `since: 'failing_since'` resolves to once the live streak is cleared. */
67
+ last_failing_since?: number | null;
10
68
  disabled_at: number | null;
69
+ last_success_at?: number | null;
70
+ last_failure?: WebhookLastFailure | null;
71
+ consecutive_failures?: number;
72
+ /** Share of attempts in the last 24 hours that succeeded (0–1), null with none. */
73
+ success_rate_24h?: number | null;
74
+ attempts_24h?: {
75
+ succeeded: number;
76
+ failed: number;
77
+ };
78
+ /** Who is emailed when it fails; null = the account's owners. */
79
+ alert_contacts?: string[] | null;
80
+ alerts_sent?: {
81
+ first_sent_at: number | null;
82
+ second_sent_at: number | null;
83
+ disabled_sent_at: number | null;
84
+ };
85
+ auto_disable?: WebhookAutoDisableRule;
86
+ /** On an update that re-enabled the endpoint: the replay that re-sends what it missed. */
87
+ replay?: {
88
+ since: number;
89
+ method: 'POST';
90
+ path: string;
91
+ note: string;
92
+ } | null;
93
+ /** On create / upsert: whether this call created it. */
94
+ created?: boolean;
95
+ updated_at?: number;
11
96
  /**
12
97
  * While a secret rotation overlap is open: when the previous secret stops
13
98
  * signing deliveries (epoch ms). Until then every delivery carries two
@@ -24,8 +109,9 @@ export interface WebhookDelivery {
24
109
  object: 'webhook_delivery';
25
110
  id: string;
26
111
  event_id: string;
27
- /** The event type, or null once the event has passed its retention. */
112
+ /** The name the event was delivered as, or null once the event has passed its retention. */
28
113
  event_type?: string | null;
114
+ latency_ms?: number | null;
29
115
  attempt_number: number;
30
116
  max_attempts?: number;
31
117
  /** The payload that was sent (null once the event has passed its retention). */
@@ -45,16 +131,95 @@ export interface WebhookDelivery {
45
131
  delivered_at: number | null;
46
132
  created_at: number;
47
133
  }
48
- export interface CreateWebhookEndpointBody {
49
- url: string;
50
- /** Each entry is `"*"` or a known event name. */
134
+ export interface WebhookEndpointSettings {
135
+ /** Each entry is `"*"` or an event name (canonical or a deprecated spelling). */
51
136
  enabled_events?: string[];
137
+ event_naming?: 'canonical' | 'legacy';
138
+ external?: boolean;
139
+ signature_versions?: Array<'v1' | 'v2'>;
140
+ /** Up to 20 addresses; null = the account's owners. */
141
+ alert_contacts?: string[] | null;
142
+ description?: string | null;
143
+ /** An event destination instead of an HTTPS url. */
144
+ destination?: WebhookDestination;
145
+ destination_credentials?: WebhookDestinationCredentials;
146
+ }
147
+ export interface CreateWebhookEndpointBody extends WebhookEndpointSettings, ProvisioningInput {
148
+ /** Required unless `destination` is an event destination. */
149
+ url?: string;
52
150
  }
53
151
  /** Change an endpoint in place. The signing secret is kept. */
54
- export interface UpdateWebhookEndpointBody {
152
+ export interface UpdateWebhookEndpointBody extends WebhookEndpointSettings {
55
153
  url?: string;
56
- enabled_events?: string[];
57
154
  active?: boolean;
155
+ /** Replaces the provisioning metadata. */
156
+ metadata?: ProvisioningMetadata;
157
+ }
158
+ /** Find-or-create by url. */
159
+ export interface UpsertWebhookEndpointBody extends WebhookEndpointSettings {
160
+ url: string;
161
+ }
162
+ /** The inline result of `test(id, { wait })`. */
163
+ export interface WebhookTestResult {
164
+ object: 'webhook_test_result';
165
+ delivery_id: string;
166
+ event_id: string;
167
+ status: 'success' | 'failed';
168
+ http_status: number | null;
169
+ latency_ms: number | null;
170
+ response_snippet: string | null;
171
+ error: string | null;
172
+ signature_header_sent: string | null;
173
+ will_retry: boolean;
174
+ }
175
+ export interface WebhookWindow {
176
+ /** Epoch ms or ISO 8601 (at most 90 days ago), or the keyword `'failing_since'` for the endpoint's own failure streak. */
177
+ since?: number | string;
178
+ until?: number | string;
179
+ }
180
+ export interface WebhookBulkResult {
181
+ object: 'webhook_redelivery' | 'webhook_replay';
182
+ endpoint_id: string;
183
+ queued: number;
184
+ events_considered?: number;
185
+ has_more: boolean;
186
+ /** Pass as `since` to continue. */
187
+ next_since: number | null;
188
+ retention: WebhookRetention;
189
+ }
190
+ export interface EgressIps {
191
+ object: 'egress_ips';
192
+ /** false: this deployment does not send from fixed addresses. */
193
+ static: boolean;
194
+ ipv4: string[];
195
+ ipv6: string[];
196
+ applies_to: string[];
197
+ note: string;
198
+ }
199
+ export type DeliveryTargetKind = 'webhook_endpoint' | 'referral_connection' | 'backchannel_receiver' | 'integration';
200
+ export interface DeliveryHealth {
201
+ object: 'delivery_health';
202
+ kind: DeliveryTargetKind;
203
+ target_id: string;
204
+ url: string | null;
205
+ label: string | null;
206
+ state: 'healthy' | 'failing' | 'disabled';
207
+ failing_since: number | null;
208
+ disabled_at: number | null;
209
+ last_success_at: number | null;
210
+ last_failure: WebhookLastFailure | null;
211
+ consecutive_failures: number;
212
+ success_rate_24h: number | null;
213
+ attempts_24h: {
214
+ succeeded: number;
215
+ failed: number;
216
+ };
217
+ alert_contacts: string[] | null;
218
+ alerts: {
219
+ first_sent_at: number | null;
220
+ second_sent_at: number | null;
221
+ disabled_sent_at: number | null;
222
+ };
58
223
  }
59
224
  /** One subscribable event, described. */
60
225
  export interface WebhookEventCatalogEntry {
@@ -62,8 +227,18 @@ export interface WebhookEventCatalogEntry {
62
227
  description: string;
63
228
  /** Who should act on it, e.g. `rp_sessions`, `rp_accounts`, `dsar`. Empty: no relying party needs it. */
64
229
  relevant_for: string[];
65
- /** Set on a superseded spelling: subscribe to this event instead. */
230
+ /** Set on a deprecated spelling: subscribe to this canonical event instead. */
66
231
  deprecated_alias_of?: string;
232
+ /** `rename`: sent whenever the canonical event is; `companion`: only for some occurrences. */
233
+ alias_kind?: 'rename' | 'companion';
234
+ deprecated_at?: string;
235
+ /** After this the deprecated spelling is no longer sent (ISO 8601). */
236
+ sunset_at?: string;
237
+ /** JSON pointer to this event's payload schema in the OpenAPI document (`components.schemas.WebhookEvent.<name>`). */
238
+ payload_schema?: string;
239
+ version?: number;
240
+ /** When the event became available (YYYY-MM-DD). */
241
+ since?: string;
67
242
  }
68
243
  /** The endpoint list plus the delivery settings that apply to every endpoint. */
69
244
  export interface WebhookEndpointList {
@@ -81,6 +256,15 @@ export interface WebhookEndpointList {
81
256
  retry_schedule_ms?: number[];
82
257
  /** Delivery attempts per event before it is marked failed. */
83
258
  max_attempts?: number;
259
+ auto_disable?: WebhookAutoDisableRule;
260
+ retention?: WebhookRetention;
261
+ signature_versions?: string[];
262
+ destination_types?: Array<{
263
+ type: WebhookDestinationType;
264
+ name: string;
265
+ config: string[];
266
+ credentials: string[];
267
+ }>;
84
268
  }
85
269
  export interface WebhookSigningSecret {
86
270
  object: 'webhook_secret';
@@ -110,12 +294,33 @@ export interface WebhookDeliveryQueued {
110
294
  note: string;
111
295
  }
112
296
  export interface ListWebhookDeliveriesParams {
113
- /** How many deliveries to return (1–100, default 50). */
297
+ /** How many deliveries to return (1–1000, default 50). */
114
298
  limit?: number;
299
+ starting_after?: string;
300
+ status?: 'pending' | 'success' | 'failed';
301
+ /** Comma-separated event names. */
302
+ event_type?: string;
303
+ /** Epoch ms or ISO 8601. */
304
+ since?: number | string;
305
+ until?: number | string;
115
306
  }
116
307
  export declare function webhooksResource(request: RequestFn): {
117
308
  endpoints: {
118
- list(): Promise<WebhookEndpointList>;
309
+ /** `includeDeprecated` adds the deprecated event spellings to the catalogue. */
310
+ /** `metadata` filters on provisioning tags (`?metadata[key]=value`). */
311
+ list(opts?: {
312
+ includeDeprecated?: boolean;
313
+ metadata?: ProvisioningMetadata;
314
+ }): Promise<WebhookEndpointList>;
315
+ get(id: string): Promise<WebhookEndpoint>;
316
+ /**
317
+ * Find-or-create by url: updates the endpoint with this url to `body`, or
318
+ * creates it (then `secret` is in the result, once). Safe to run on every deploy.
319
+ */
320
+ upsertByUrl(body: UpsertWebhookEndpointBody, idempotencyKey?: string): Promise<WebhookEndpoint & {
321
+ secret?: string;
322
+ created: boolean;
323
+ }>;
119
324
  /** Update url, enabled_events or active. The signing secret is kept. */
120
325
  update(id: string, body: UpdateWebhookEndpointBody): Promise<WebhookEndpoint>;
121
326
  /** Show the current signing secret again. Audited. */
@@ -126,8 +331,23 @@ export declare function webhooksResource(request: RequestFn): {
126
331
  * every delivery is signed with both, so a verifier holding either passes.
127
332
  */
128
333
  rotateSecret(id: string, body?: RotateWebhookSecretBody): Promise<WebhookSigningSecret>;
129
- /** Send a synthetic `webhook.test` event to this endpoint only. */
334
+ /** Send a synthetic `webhook.test` event to this endpoint only (queued for the worker). */
130
335
  test(id: string): Promise<WebhookDeliveryQueued>;
336
+ /**
337
+ * Send `webhook.test` now and return the result: status, HTTP status,
338
+ * latency, response snippet, error and the signature header sent.
339
+ * `wait` is at most 10 s (`'10s'`, `'5000ms'`).
340
+ */
341
+ testNow(id: string, wait?: string): Promise<WebhookTestResult>;
342
+ /** Bulk redeliver every event whose latest attempt in the window has `status` (default failed). */
343
+ redeliverWindow(id: string, body?: WebhookWindow & {
344
+ status?: "failed" | "success";
345
+ }, idempotencyKey?: string): Promise<WebhookBulkResult>;
346
+ /** Re-send everything since `since` the endpoint subscribes to and has not received. */
347
+ replay(id: string, body: WebhookWindow & {
348
+ since: number | string;
349
+ event_type?: string;
350
+ }, idempotencyKey?: string): Promise<WebhookBulkResult>;
131
351
  /** Redeliver a past event as a fresh attempt (409 once past its retention). */
132
352
  redeliver(id: string, deliveryId: string): Promise<WebhookDeliveryQueued>;
133
353
  create(body: CreateWebhookEndpointBody, idempotencyKey?: string): Promise<WebhookEndpointWithSecret>;
@@ -143,6 +363,19 @@ export declare function webhooksResource(request: RequestFn): {
143
363
  has_more: boolean;
144
364
  next_cursor?: string | null;
145
365
  }>;
366
+ /** The addresses deliveries leave from (public). */
367
+ egressIps(): Promise<EgressIps>;
368
+ /** Delivery health of every outbound target (webhooks, referral connection, back-channel receivers, integrations). */
369
+ health(params?: {
370
+ kind?: DeliveryTargetKind;
371
+ state?: "unhealthy" | "all";
372
+ }): Promise<{
373
+ data: DeliveryHealth[];
374
+ has_more: boolean;
375
+ unhealthy_count: number;
376
+ }>;
377
+ /** Set who is emailed when a target fails (null = the account's owners). */
378
+ setAlertContacts(kind: DeliveryTargetKind, targetId: string, alertContacts: string[] | null): Promise<DeliveryHealth>;
146
379
  /** Redeliver a past event (same as `endpoints.redeliver`). */
147
380
  redeliver(endpointId: string, deliveryId: string): Promise<WebhookDeliveryQueued>;
148
381
  };
@@ -1,12 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.webhooksResource = webhooksResource;
4
+ const compliance_1 = require("./compliance");
4
5
  const request_1 = require("./request");
5
6
  function webhooksResource(request) {
6
7
  return {
7
8
  endpoints: {
8
- list() {
9
- return request({ method: 'GET', path: '/v1/webhook_endpoints' });
9
+ /** `includeDeprecated` adds the deprecated event spellings to the catalogue. */
10
+ /** `metadata` filters on provisioning tags (`?metadata[key]=value`). */
11
+ list(opts = {}) {
12
+ return request({
13
+ method: 'GET',
14
+ path: '/v1/webhook_endpoints',
15
+ query: { ...(opts.includeDeprecated ? { include_deprecated: 'true' } : {}), ...(0, compliance_1.metadataQuery)(opts.metadata) },
16
+ });
17
+ },
18
+ get(id) {
19
+ return request({ method: 'GET', path: `/v1/webhook_endpoints/${(0, request_1.enc)(id)}` });
20
+ },
21
+ /**
22
+ * Find-or-create by url: updates the endpoint with this url to `body`, or
23
+ * creates it (then `secret` is in the result, once). Safe to run on every deploy.
24
+ */
25
+ upsertByUrl(body, idempotencyKey) {
26
+ return request({ method: 'PUT', path: '/v1/webhook_endpoints/by_url', body, idempotencyKey });
10
27
  },
11
28
  /** Update url, enabled_events or active. The signing secret is kept. */
12
29
  update(id, body) {
@@ -24,10 +41,26 @@ function webhooksResource(request) {
24
41
  rotateSecret(id, body) {
25
42
  return request({ method: 'POST', path: `/v1/webhook_endpoints/${(0, request_1.enc)(id)}/rotate_secret`, body });
26
43
  },
27
- /** Send a synthetic `webhook.test` event to this endpoint only. */
44
+ /** Send a synthetic `webhook.test` event to this endpoint only (queued for the worker). */
28
45
  test(id) {
29
46
  return request({ method: 'POST', path: `/v1/webhook_endpoints/${(0, request_1.enc)(id)}/test` });
30
47
  },
48
+ /**
49
+ * Send `webhook.test` now and return the result: status, HTTP status,
50
+ * latency, response snippet, error and the signature header sent.
51
+ * `wait` is at most 10 s (`'10s'`, `'5000ms'`).
52
+ */
53
+ testNow(id, wait = '10s') {
54
+ return request({ method: 'POST', path: `/v1/webhook_endpoints/${(0, request_1.enc)(id)}/test`, query: { wait } });
55
+ },
56
+ /** Bulk redeliver every event whose latest attempt in the window has `status` (default failed). */
57
+ redeliverWindow(id, body = {}, idempotencyKey) {
58
+ return request({ method: 'POST', path: `/v1/webhook_endpoints/${(0, request_1.enc)(id)}/redeliver`, body, idempotencyKey });
59
+ },
60
+ /** Re-send everything since `since` the endpoint subscribes to and has not received. */
61
+ replay(id, body, idempotencyKey) {
62
+ return request({ method: 'POST', path: `/v1/webhook_endpoints/${(0, request_1.enc)(id)}/replay`, body, idempotencyKey });
63
+ },
31
64
  /** Redeliver a past event as a fresh attempt (409 once past its retention). */
32
65
  redeliver(id, deliveryId) {
33
66
  return request({
@@ -50,6 +83,22 @@ function webhooksResource(request) {
50
83
  query: { ...params },
51
84
  });
52
85
  },
86
+ /** The addresses deliveries leave from (public). */
87
+ egressIps() {
88
+ return request({ method: 'GET', path: '/v1/meta/egress_ips' });
89
+ },
90
+ /** Delivery health of every outbound target (webhooks, referral connection, back-channel receivers, integrations). */
91
+ health(params = {}) {
92
+ return request({ method: 'GET', path: '/v1/delivery_health', query: { ...params } });
93
+ },
94
+ /** Set who is emailed when a target fails (null = the account's owners). */
95
+ setAlertContacts(kind, targetId, alertContacts) {
96
+ return request({
97
+ method: 'PUT',
98
+ path: `/v1/delivery_health/${(0, request_1.enc)(kind)}/${(0, request_1.enc)(targetId)}/alert_contacts`,
99
+ body: { alert_contacts: alertContacts },
100
+ });
101
+ },
53
102
  /** Redeliver a past event (same as `endpoints.redeliver`). */
54
103
  redeliver(endpointId, deliveryId) {
55
104
  return request({