@atlasauth/backend 0.17.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.
- package/CHANGELOG.md +40 -0
- package/dist/backchannel-handlers.d.ts +87 -0
- package/dist/backchannel-handlers.js +137 -0
- package/dist/backchannel-handlers.js.map +1 -0
- package/dist/client/activity.d.ts +13 -2
- package/dist/client/activity.js.map +1 -1
- package/dist/client/audit-logs.d.ts +7 -0
- package/dist/client/audit-logs.js.map +1 -1
- package/dist/client/compliance.d.ts +216 -0
- package/dist/client/compliance.js +77 -0
- package/dist/client/compliance.js.map +1 -0
- package/dist/client/credentials.d.ts +409 -0
- package/dist/client/credentials.js +158 -0
- package/dist/client/credentials.js.map +1 -0
- package/dist/client/data-subject-requests.d.ts +36 -1
- package/dist/client/data-subject-requests.js.map +1 -1
- package/dist/client/design.d.ts +48 -0
- package/dist/client/design.js +9 -0
- package/dist/client/design.js.map +1 -1
- package/dist/client/entitlement-overrides.d.ts +30 -0
- package/dist/client/entitlement-overrides.js +9 -0
- package/dist/client/entitlement-overrides.js.map +1 -1
- package/dist/client/env.d.ts +16 -0
- package/dist/client/env.js +38 -0
- package/dist/client/env.js.map +1 -0
- package/dist/client/error.d.ts +10 -0
- package/dist/client/error.js +4 -0
- package/dist/client/error.js.map +1 -1
- package/dist/client/index.d.ts +382 -7
- package/dist/client/index.js +44 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/instance.d.ts +401 -3
- package/dist/client/instance.js +77 -3
- package/dist/client/instance.js.map +1 -1
- package/dist/client/integrations.d.ts +107 -0
- package/dist/client/integrations.js +25 -0
- package/dist/client/integrations.js.map +1 -0
- package/dist/client/messaging.d.ts +18 -4
- package/dist/client/messaging.js +6 -2
- package/dist/client/messaging.js.map +1 -1
- package/dist/client/oauth-clients.d.ts +11 -3
- package/dist/client/oauth-clients.js +4 -2
- package/dist/client/oauth-clients.js.map +1 -1
- package/dist/client/operator.d.ts +100 -0
- package/dist/client/operator.js +132 -0
- package/dist/client/operator.js.map +1 -0
- package/dist/client/platform.d.ts +233 -9
- package/dist/client/platform.js +74 -6
- package/dist/client/platform.js.map +1 -1
- package/dist/client/policies.d.ts +316 -0
- package/dist/client/policies.js +103 -0
- package/dist/client/policies.js.map +1 -0
- package/dist/client/privacy.d.ts +127 -0
- package/dist/client/privacy.js +44 -0
- package/dist/client/privacy.js.map +1 -0
- package/dist/client/referrals.d.ts +53 -6
- package/dist/client/referrals.js +9 -0
- package/dist/client/referrals.js.map +1 -1
- package/dist/client/request.d.ts +38 -1
- package/dist/client/request.js +6 -2
- package/dist/client/request.js.map +1 -1
- package/dist/client/sealed-box.d.ts +7 -0
- package/dist/client/sealed-box.js +62 -0
- package/dist/client/sealed-box.js.map +1 -0
- package/dist/client/sessions.d.ts +16 -5
- package/dist/client/sessions.js +7 -10
- package/dist/client/sessions.js.map +1 -1
- package/dist/client/status.d.ts +200 -0
- package/dist/client/status.js +54 -0
- package/dist/client/status.js.map +1 -0
- package/dist/client/users.d.ts +15 -0
- package/dist/client/webhooks.d.ts +244 -11
- package/dist/client/webhooks.js +52 -3
- package/dist/client/webhooks.js.map +1 -1
- package/dist/index.d.ts +9 -6
- package/dist/index.js +20 -4
- package/dist/index.js.map +1 -1
- package/dist/oidc.d.ts +65 -1
- package/dist/oidc.js +46 -0
- package/dist/oidc.js.map +1 -1
- package/dist/policy-source.d.ts +104 -0
- package/dist/policy-source.js +99 -0
- package/dist/policy-source.js.map +1 -0
- package/dist/referral-test-calls.d.ts +26 -13
- package/dist/referral-test-calls.js +40 -14
- package/dist/referral-test-calls.js.map +1 -1
- package/dist/testing.d.ts +41 -6
- package/dist/testing.js +34 -2
- package/dist/testing.js.map +1 -1
- package/dist/webhooks.d.ts +8 -0
- package/dist/webhooks.js +13 -4
- package/dist/webhooks.js.map +1 -1
- package/package.json +6 -3
|
@@ -11,7 +11,7 @@ import type { UserReferralResult } from './users';
|
|
|
11
11
|
* call is retried, and `user.referral_attributed` is sent when it resolves.
|
|
12
12
|
*
|
|
13
13
|
* `provider` is `webhook` (the Atlas referral protocol, which any platform can
|
|
14
|
-
* implement; see {@link verifyReferralRequest}), `
|
|
14
|
+
* implement; see {@link verifyReferralRequest}), `referalli` (the built-in
|
|
15
15
|
* Referalli adapter: `endpoint_url` is your Referalli base URL, plus
|
|
16
16
|
* `connection_id`, `signing_secret` and optionally `tracking_token`) or
|
|
17
17
|
* another built-in vendor adapter.
|
|
@@ -49,6 +49,10 @@ export interface ReferralProviderInfo {
|
|
|
49
49
|
needs: Array<'endpoint_url' | 'signing_secret' | 'api_key' | 'connection_id' | 'tracking_token'>;
|
|
50
50
|
/** The vendor's own first-party tracking cookie, suggested when this provider is picked. */
|
|
51
51
|
default_context_cookie: string | null;
|
|
52
|
+
/** Every cookie the vendor has written, in the order Atlas tries them. */
|
|
53
|
+
default_context_cookies?: string[];
|
|
54
|
+
/** Retired spellings of `id`, accepted on write (for example `referally` for `referalli`). */
|
|
55
|
+
aliases?: string[];
|
|
52
56
|
docs_url: string | null;
|
|
53
57
|
}
|
|
54
58
|
/** Fraud and bot protection for referred sign-ups (`security` on the settings). */
|
|
@@ -117,9 +121,9 @@ export interface ReferralInboundStatus {
|
|
|
117
121
|
} | null;
|
|
118
122
|
}
|
|
119
123
|
/** A referral program whose script or cookie the browser reads. */
|
|
120
|
-
export type ReferralBrowserSource = '
|
|
124
|
+
export type ReferralBrowserSource = 'referalli' | 'rewardful' | 'tolt' | 'promotekit' | 'firstpromoter' | 'partnerstack' | 'dub';
|
|
121
125
|
/** Which consent manager decides on the tracking cookie's ids: `auto` (any common one), one manager, or `app` (only the app's own decision). */
|
|
122
|
-
export type ReferralConsentProvider = 'auto' | 'cookiemunch' | 'onetrust' | 'cookiebot' | 'didomi' | 'usercentrics' | 'osano' | 'cookieyes' | 'complianz' | 'klaro' | 'tcf' | 'consent_mode' | 'app';
|
|
126
|
+
export type ReferralConsentProvider = 'auto' | 'atlasconsent' | 'cookiemunch' | 'onetrust' | 'cookiebot' | 'didomi' | 'usercentrics' | 'osano' | 'cookieyes' | 'complianz' | 'klaro' | 'tcf' | 'consent_mode' | 'gpc' | 'app';
|
|
123
127
|
/** What a platform answers to a ping. */
|
|
124
128
|
export interface ReferralPing {
|
|
125
129
|
ok: boolean;
|
|
@@ -141,6 +145,27 @@ export interface ReferralPing {
|
|
|
141
145
|
error_code?: string | null;
|
|
142
146
|
error?: string | null;
|
|
143
147
|
}
|
|
148
|
+
/** A one-click (OAuth) install a deployment offers for a referral platform. */
|
|
149
|
+
export interface ReferralOneClick {
|
|
150
|
+
id: string;
|
|
151
|
+
name: string;
|
|
152
|
+
available: boolean;
|
|
153
|
+
/** What the connection is saved as: `referalli` or `webhook` (the generic protocol). */
|
|
154
|
+
provider: string;
|
|
155
|
+
scope: string;
|
|
156
|
+
redirect_uri: string;
|
|
157
|
+
}
|
|
158
|
+
/** `POST /v1/instance/referrals/{preset}/install`. */
|
|
159
|
+
export interface ReferralInstall {
|
|
160
|
+
object: 'referral_install';
|
|
161
|
+
preset: string;
|
|
162
|
+
provider: string;
|
|
163
|
+
/** Send the merchant here to pick an organization and program. */
|
|
164
|
+
authorize_url: string;
|
|
165
|
+
redirect_uri: string;
|
|
166
|
+
/** Epoch ms; the link lasts 15 minutes. */
|
|
167
|
+
expires_at: number;
|
|
168
|
+
}
|
|
144
169
|
/** `GET /v1/instance/referrals`. */
|
|
145
170
|
export interface ReferralSettings {
|
|
146
171
|
object: 'referral_settings';
|
|
@@ -159,8 +184,18 @@ export interface ReferralSettings {
|
|
|
159
184
|
api_key_set: boolean;
|
|
160
185
|
/** Query parameters that carry a referral code, in priority order (default `ref`, `via`, `aff`). */
|
|
161
186
|
url_params: string[];
|
|
162
|
-
/**
|
|
187
|
+
/** The first tracking cookie read under consent; null = never read a cookie. `context_cookies` lists them all. */
|
|
163
188
|
context_cookie: string | null;
|
|
189
|
+
/** Every tracking cookie, in the order they are tried. */
|
|
190
|
+
context_cookies?: string[];
|
|
191
|
+
/** Retired spellings of `provider` that are still accepted on write. */
|
|
192
|
+
provider_aliases?: string[];
|
|
193
|
+
/** What the chosen provider can do now: its built-in capabilities plus what its last ping advertised. */
|
|
194
|
+
capabilities?: ReferralProviderCapabilities | null;
|
|
195
|
+
/** One-click connect to Referalli (the `referalli` preset). */
|
|
196
|
+
one_click?: ReferralOneClick | null;
|
|
197
|
+
/** Every platform this deployment offers a one-click install for. */
|
|
198
|
+
one_click_presets?: ReferralOneClick[];
|
|
164
199
|
consent_category: string;
|
|
165
200
|
consent_fallback_category: string | null;
|
|
166
201
|
/** Every new user becomes a referrer (gets a code and link from the platform). */
|
|
@@ -170,7 +205,7 @@ export interface ReferralSettings {
|
|
|
170
205
|
/** How long a sign-up waits for the platform (100-5000 ms, default 3000). */
|
|
171
206
|
timeout_ms: number;
|
|
172
207
|
security: ReferralSecuritySettings;
|
|
173
|
-
/** Public tracking token (the `
|
|
208
|
+
/** Public tracking token (the `referalli` adapter derives the code lookup from it). */
|
|
174
209
|
tracking_token?: string | null;
|
|
175
210
|
/** Public, CORS-enabled lookup with `{code}` for "X invited you" on hosted sign-up. */
|
|
176
211
|
code_lookup_url?: string | null;
|
|
@@ -221,7 +256,10 @@ export interface UpdateReferralSettingsBody {
|
|
|
221
256
|
inbound_endpoint_id?: string | null;
|
|
222
257
|
/** 1-10 names of `[A-Za-z0-9_.-]{1,40}`. */
|
|
223
258
|
url_params?: string[];
|
|
224
|
-
|
|
259
|
+
/** A cookie name, or a list of up to 5 tried in order; null clears. */
|
|
260
|
+
context_cookie?: string | string[] | null;
|
|
261
|
+
/** The same with a list; wins over `context_cookie`. */
|
|
262
|
+
context_cookies?: string[] | null;
|
|
225
263
|
consent_category?: string;
|
|
226
264
|
consent_fallback_category?: string | null;
|
|
227
265
|
auto_enroll_users?: boolean;
|
|
@@ -433,6 +471,15 @@ export declare function referralsResource(request: RequestFn): {
|
|
|
433
471
|
kind?: ReferralCallKind;
|
|
434
472
|
error_code?: string;
|
|
435
473
|
}, idempotencyKey?: string): Promise<ReferralRetryFailedResult>;
|
|
474
|
+
/**
|
|
475
|
+
* `POST /v1/instance/referrals/{preset}/install` — start a one-click
|
|
476
|
+
* connection to a referral platform (`referalli`, or any id in
|
|
477
|
+
* `one_click_presets`). 422 `REFERRALS_NOT_CONFIGURED` when the deployment
|
|
478
|
+
* does not offer it; connect with a key or signing secret then.
|
|
479
|
+
*/
|
|
480
|
+
install(preset: string, body?: {
|
|
481
|
+
return_to?: string | null;
|
|
482
|
+
}): Promise<ReferralInstall>;
|
|
436
483
|
/**
|
|
437
484
|
* `POST /v1/instance/referrals/simulate` — send a sign-up call for a fake
|
|
438
485
|
* user (`atlas_test_<random>`, never stored) with an optional code, and
|
package/dist/client/referrals.js
CHANGED
|
@@ -38,6 +38,15 @@ function referralsResource(request) {
|
|
|
38
38
|
retryFailed(filter = {}, idempotencyKey) {
|
|
39
39
|
return request({ method: 'POST', path: '/v1/instance/referrals/calls/retry_failed', body: filter, idempotencyKey });
|
|
40
40
|
},
|
|
41
|
+
/**
|
|
42
|
+
* `POST /v1/instance/referrals/{preset}/install` — start a one-click
|
|
43
|
+
* connection to a referral platform (`referalli`, or any id in
|
|
44
|
+
* `one_click_presets`). 422 `REFERRALS_NOT_CONFIGURED` when the deployment
|
|
45
|
+
* does not offer it; connect with a key or signing secret then.
|
|
46
|
+
*/
|
|
47
|
+
install(preset, body = {}) {
|
|
48
|
+
return request({ method: 'POST', path: `/v1/instance/referrals/${(0, request_1.enc)(preset)}/install`, body });
|
|
49
|
+
},
|
|
41
50
|
/**
|
|
42
51
|
* `POST /v1/instance/referrals/simulate` — send a sign-up call for a fake
|
|
43
52
|
* user (`atlas_test_<random>`, never stored) with an optional code, and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"referrals.js","sourceRoot":"","sources":["../../src/client/referrals.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"referrals.js","sourceRoot":"","sources":["../../src/client/referrals.ts"],"names":[],"mappings":";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E,IAAI,EAAE,0BAA0B,IAAA,aAAG,EAAC,MAAM,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;QAClG,CAAC;QACD;;;;WAIG;QACH,QAAQ,CAAC,OAA0B,EAAE;YACnC,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,iCAAiC,EAAE,IAAI,EAAE,CAAC,CAAC;QACpF,CAAC;QACD;;;;WAIG;QACH,QAAQ,CAAC,IAA0B,EAAE,cAAuB;YAC1D,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,iCAAiC,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC;QACpG,CAAC;QACD,iDAAiD;QACjD,WAAW,CAAC,EAAU;YACpB,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,mCAAmC,IAAA,aAAG,EAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QACxF,CAAC;QACD;;;WAGG;QACH,UAAU,CAAC,MAAc;YACvB,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,IAAA,aAAG,EAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;QAC/E,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/client/request.d.ts
CHANGED
|
@@ -38,6 +38,40 @@ export interface AtlasClientConfig {
|
|
|
38
38
|
* newer API version. Not called in strict mode, where the write fails instead.
|
|
39
39
|
*/
|
|
40
40
|
onUnknownFields?: (event: UnknownFieldsEvent) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Dry run: every write (POST/PUT/PATCH/DELETE) is sent with `?dry_run=true`,
|
|
43
|
+
* so Atlas validates it and answers with the changes it WOULD make
|
|
44
|
+
* ({@link DryRunResult}) without changing anything. Use it for a single plan
|
|
45
|
+
* with `client.withOptions({ dryRun: true })`; the method's declared return
|
|
46
|
+
* type is then a `DryRunResult` at runtime.
|
|
47
|
+
*/
|
|
48
|
+
dryRun?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Sealed secret delivery: an `x25519:<public key>` (see `generateSealKeyPair`
|
|
51
|
+
* in `@atlasauth/backend`). Sent as `X-Secret-Recipient` on every request, so
|
|
52
|
+
* every shown-once secret in a response arrives sealed (`sealed_secret`, …)
|
|
53
|
+
* instead of in plaintext. Open it with `openSealedSecret`.
|
|
54
|
+
*/
|
|
55
|
+
secretRecipient?: string;
|
|
56
|
+
}
|
|
57
|
+
/** One change a write would make (or made), in the config-changelog shape. */
|
|
58
|
+
export interface DryRunChange {
|
|
59
|
+
section: string;
|
|
60
|
+
before: unknown;
|
|
61
|
+
after: unknown;
|
|
62
|
+
}
|
|
63
|
+
/** What a write answers with `?dry_run=true` (see {@link AtlasClientConfig.dryRun}). */
|
|
64
|
+
export interface DryRunResult {
|
|
65
|
+
object: 'dry_run';
|
|
66
|
+
dry_run: true;
|
|
67
|
+
/** `native`: the endpoint validated in full. `plan`: the body diffed over the current object, unvalidated. */
|
|
68
|
+
mode: 'native' | 'plan';
|
|
69
|
+
validated: boolean;
|
|
70
|
+
method: string;
|
|
71
|
+
path: string;
|
|
72
|
+
changes: DryRunChange[];
|
|
73
|
+
would_return?: unknown;
|
|
74
|
+
note: string;
|
|
41
75
|
}
|
|
42
76
|
/** What {@link AtlasClientConfig.onUnknownFields} receives. */
|
|
43
77
|
export interface UnknownFieldsEvent {
|
|
@@ -48,7 +82,7 @@ export interface UnknownFieldsEvent {
|
|
|
48
82
|
fields: string[];
|
|
49
83
|
}
|
|
50
84
|
/** Per-client settings `withOptions` can override. */
|
|
51
|
-
export type AtlasRequestSettings = Pick<AtlasClientConfig, 'strict' | 'onUnknownFields'>;
|
|
85
|
+
export type AtlasRequestSettings = Pick<AtlasClientConfig, 'strict' | 'onUnknownFields' | 'dryRun'>;
|
|
52
86
|
/** A raw (non-JSON) request body, e.g. image bytes for a design-asset upload. */
|
|
53
87
|
export interface RawBody {
|
|
54
88
|
data: Blob | ArrayBuffer | ArrayBufferView;
|
|
@@ -74,6 +108,8 @@ export interface RequestOptions {
|
|
|
74
108
|
raw?: boolean;
|
|
75
109
|
/** Per-request override of {@link AtlasClientConfig.strict}. */
|
|
76
110
|
strict?: boolean;
|
|
111
|
+
/** Extra request headers. */
|
|
112
|
+
headers?: Record<string, string>;
|
|
77
113
|
}
|
|
78
114
|
/** Serialize a query object to a string, dropping null/undefined, spreading arrays. */
|
|
79
115
|
export declare function serializeQuery(query: QueryParams | undefined): string;
|
|
@@ -89,6 +125,7 @@ export declare function createRequest(config: AtlasClientConfig): RequestFn;
|
|
|
89
125
|
export interface KeyedRequestConfig extends AtlasRequestSettings {
|
|
90
126
|
apiUrl?: string;
|
|
91
127
|
fetch?: typeof fetch;
|
|
128
|
+
secretRecipient?: string;
|
|
92
129
|
}
|
|
93
130
|
/**
|
|
94
131
|
* The request core for any bearer key: the secret key (`sk_...`) of the
|
package/dist/client/request.js
CHANGED
|
@@ -49,11 +49,15 @@ function createKeyedRequest(key, config) {
|
|
|
49
49
|
throw new Error('No fetch implementation found. Pass { fetch } to createAtlasClient on a runtime without a global fetch.');
|
|
50
50
|
}
|
|
51
51
|
return async function request(options) {
|
|
52
|
-
const
|
|
52
|
+
const dryRun = config.dryRun === true && options.method !== 'GET';
|
|
53
|
+
const url = joinUrl(base, options.path) + serializeQuery(dryRun ? { ...options.query, dry_run: 'true' } : options.query);
|
|
53
54
|
const headers = {
|
|
55
|
+
...(options.headers ?? {}),
|
|
54
56
|
authorization: `Bearer ${key}`,
|
|
55
57
|
accept: 'application/json',
|
|
56
58
|
};
|
|
59
|
+
if (config.secretRecipient)
|
|
60
|
+
headers['x-secret-recipient'] = config.secretRecipient;
|
|
57
61
|
let body;
|
|
58
62
|
if (options.rawBody !== undefined) {
|
|
59
63
|
const { data, contentType } = options.rawBody;
|
|
@@ -68,7 +72,7 @@ function createKeyedRequest(key, config) {
|
|
|
68
72
|
headers['content-type'] = 'application/json';
|
|
69
73
|
body = JSON.stringify(options.body);
|
|
70
74
|
}
|
|
71
|
-
if (options.idempotencyKey) {
|
|
75
|
+
if (options.idempotencyKey && !dryRun) {
|
|
72
76
|
headers['idempotency-key'] = options.idempotencyKey;
|
|
73
77
|
}
|
|
74
78
|
const strict = options.strict ?? config.strict;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/client/request.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/client/request.ts"],"names":[],"mappings":";;;AA6HA,wCAYC;AAGD,kBAEC;AAYD,sCAKC;AAaD,gDAuEC;AAnPD,mCAA6D;AAmG7D,sEAAsE;AACzD,QAAA,eAAe,GAAG,2BAA2B,CAAC;AAwB3D,uFAAuF;AACvF,SAAgB,cAAc,CAAC,KAA8B;IAC3D,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC;IACtB,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YAAE,SAAS;QACpD,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACtD,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;YACvB,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI;gBAAE,SAAS;YAC5C,KAAK,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC,GAAG,CAAC,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAC5E,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC,MAAM,CAAC,CA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uint8Array;
|
|
2
|
+
export declare function generateSealKeyPair(): {
|
|
3
|
+
publicKey: Uint8Array;
|
|
4
|
+
secretKey: Uint8Array;
|
|
5
|
+
};
|
|
6
|
+
export declare function sealBox(message: Uint8Array | string, recipientPublicKey: Uint8Array): Uint8Array;
|
|
7
|
+
export declare function openSealedBox(sealed: Uint8Array, publicKey: Uint8Array, secretKey: Uint8Array): Uint8Array;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.beforeNm = beforeNm;
|
|
4
|
+
exports.generateSealKeyPair = generateSealKeyPair;
|
|
5
|
+
exports.sealBox = sealBox;
|
|
6
|
+
exports.openSealedBox = openSealedBox;
|
|
7
|
+
const ed25519_1 = require("@noble/curves/ed25519");
|
|
8
|
+
const salsa_1 = require("@noble/ciphers/salsa");
|
|
9
|
+
const blake2b_1 = require("@noble/hashes/blake2b");
|
|
10
|
+
/**
|
|
11
|
+
* libsodium `crypto_box_seal` / `crypto_box_seal_open`, in pure JS so the
|
|
12
|
+
* client keeps running on every runtime (Node, Deno, Bun, edge, browsers).
|
|
13
|
+
*
|
|
14
|
+
* nonce = BLAKE2b-192(epk ‖ pk); k = HSalsa20(X25519(sk, pk), 0¹⁶)
|
|
15
|
+
* box = epk ‖ XSalsa20-Poly1305(k, nonce, message)
|
|
16
|
+
*/
|
|
17
|
+
const SIGMA = new Uint32Array([0x61707865, 0x3320646e, 0x79622d32, 0x6b206574]);
|
|
18
|
+
function u32(b) {
|
|
19
|
+
const out = new Uint32Array(b.length / 4);
|
|
20
|
+
for (let i = 0; i < out.length; i += 1)
|
|
21
|
+
out[i] = (b[i * 4] | (b[i * 4 + 1] << 8) | (b[i * 4 + 2] << 16) | (b[i * 4 + 3] << 24)) >>> 0;
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
24
|
+
function beforeNm(publicKey, secretKey) {
|
|
25
|
+
const shared = ed25519_1.x25519.getSharedSecret(secretKey, publicKey);
|
|
26
|
+
const out = new Uint32Array(8);
|
|
27
|
+
(0, salsa_1.hsalsa)(SIGMA, u32(shared), new Uint32Array(4), out);
|
|
28
|
+
const bytes = new Uint8Array(32);
|
|
29
|
+
out.forEach((w, i) => {
|
|
30
|
+
bytes[i * 4] = w & 0xff;
|
|
31
|
+
bytes[i * 4 + 1] = (w >>> 8) & 0xff;
|
|
32
|
+
bytes[i * 4 + 2] = (w >>> 16) & 0xff;
|
|
33
|
+
bytes[i * 4 + 3] = (w >>> 24) & 0xff;
|
|
34
|
+
});
|
|
35
|
+
return bytes;
|
|
36
|
+
}
|
|
37
|
+
function nonceFor(epk, pk) {
|
|
38
|
+
const input = new Uint8Array(64);
|
|
39
|
+
input.set(epk, 0);
|
|
40
|
+
input.set(pk, 32);
|
|
41
|
+
return (0, blake2b_1.blake2b)(input, { dkLen: 24 });
|
|
42
|
+
}
|
|
43
|
+
function generateSealKeyPair() {
|
|
44
|
+
const secretKey = ed25519_1.x25519.utils.randomPrivateKey();
|
|
45
|
+
return { publicKey: ed25519_1.x25519.getPublicKey(secretKey), secretKey };
|
|
46
|
+
}
|
|
47
|
+
function sealBox(message, recipientPublicKey) {
|
|
48
|
+
const plain = typeof message === 'string' ? new TextEncoder().encode(message) : message;
|
|
49
|
+
const eph = generateSealKeyPair();
|
|
50
|
+
const boxed = (0, salsa_1.xsalsa20poly1305)(beforeNm(recipientPublicKey, eph.secretKey), nonceFor(eph.publicKey, recipientPublicKey)).encrypt(plain);
|
|
51
|
+
const out = new Uint8Array(32 + boxed.length);
|
|
52
|
+
out.set(eph.publicKey, 0);
|
|
53
|
+
out.set(boxed, 32);
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
function openSealedBox(sealed, publicKey, secretKey) {
|
|
57
|
+
if (sealed.length < 48)
|
|
58
|
+
throw new Error('openSealedBox: too short');
|
|
59
|
+
const epk = sealed.subarray(0, 32);
|
|
60
|
+
return (0, salsa_1.xsalsa20poly1305)(beforeNm(epk, secretKey), nonceFor(epk, publicKey)).decrypt(sealed.subarray(32));
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=sealed-box.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sealed-box.js","sourceRoot":"","sources":["../../src/client/sealed-box.ts"],"names":[],"mappings":";;AAoBA,4BAYC;AASD,kDAGC;AAED,0BAQC;AAED,sCAIC;AA5DD,mDAA+C;AAC/C,gDAAgE;AAChE,mDAAgD;AAEhD;;;;;;GAMG;AAEH,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;AAEhF,SAAS,GAAG,CAAC,CAAa;IACxB,MAAM,GAAG,GAAG,IAAI,WAAW,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC1C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC;QAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAE,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;IAC1I,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAgB,QAAQ,CAAC,SAAqB,EAAE,SAAqB;IACnE,MAAM,MAAM,GAAG,gBAAM,CAAC,eAAe,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAC5D,MAAM,GAAG,GAAG,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;IAC/B,IAAA,cAAM,E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E,kBAA8B;IAClF,MAAM,KAAK,GAAG,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IACxF,MAAM,GAAG,GAAG,mBAAmB,EAAE,CAAC;IAClC,MAAM,KAAK,GAAG,IAAA,wBAAgB,EAAC,QAAQ,CAAC,kBAAkB,EAAE,GAAG,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACxI,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAC9C,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;IAC1B,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACnB,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAgB,aAAa,CAAC,MAAkB,EAAE,SAAqB,EAAE,SAAqB;IAC5F,IAAI,MAAM,CAAC,MAAM,GAAG,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IACpE,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACnC,OAAO,IAAA,wBAAgB,EAAC,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC,EAAE,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;AAC3G,CAAC"}
|
|
@@ -59,6 +59,16 @@ export interface MintedSession {
|
|
|
59
59
|
custom_data?: Record<string, unknown> | null;
|
|
60
60
|
}
|
|
61
61
|
/** A JWT minted from a named JWT template. */
|
|
62
|
+
/** An identity-integration token (claims: /schemas/integration-token-v1.json). */
|
|
63
|
+
export interface SessionIntegrationToken {
|
|
64
|
+
object: 'integration_token';
|
|
65
|
+
integration: string;
|
|
66
|
+
product: string;
|
|
67
|
+
jwt: string;
|
|
68
|
+
/** Seconds until the token expires (at most 120). */
|
|
69
|
+
expires_in: number;
|
|
70
|
+
audience: string;
|
|
71
|
+
}
|
|
62
72
|
export interface SessionTemplateToken {
|
|
63
73
|
object: string;
|
|
64
74
|
jwt: string;
|
|
@@ -98,9 +108,10 @@ export declare function sessionsResource(request: RequestFn): {
|
|
|
98
108
|
* effective write per minute, so calling it on every request is safe.
|
|
99
109
|
*/
|
|
100
110
|
touch(id: string): Promise<TouchedSession>;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
111
|
+
getToken: {
|
|
112
|
+
(id: string, template: string): Promise<SessionTemplateToken>;
|
|
113
|
+
(id: string, options: {
|
|
114
|
+
for: string;
|
|
115
|
+
}): Promise<SessionIntegrationToken>;
|
|
116
|
+
};
|
|
106
117
|
};
|
package/dist/client/sessions.js
CHANGED
|
@@ -3,6 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.sessionsResource = sessionsResource;
|
|
4
4
|
const request_1 = require("./request");
|
|
5
5
|
function sessionsResource(request) {
|
|
6
|
+
function getToken(id, what) {
|
|
7
|
+
if (typeof what === 'object') {
|
|
8
|
+
return request({ method: 'POST', path: `/v1/sessions/${(0, request_1.enc)(id)}/integration_tokens/${(0, request_1.enc)(what.for)}` });
|
|
9
|
+
}
|
|
10
|
+
return request({ method: 'POST', path: `/v1/sessions/${(0, request_1.enc)(id)}/tokens/${(0, request_1.enc)(what)}` });
|
|
11
|
+
}
|
|
6
12
|
return {
|
|
7
13
|
/**
|
|
8
14
|
* `POST /v1/sessions` — mint a session for a user without the sign-in flow.
|
|
@@ -46,16 +52,7 @@ function sessionsResource(request) {
|
|
|
46
52
|
touch(id) {
|
|
47
53
|
return request({ method: 'POST', path: `/v1/sessions/${(0, request_1.enc)(id)}/touch` });
|
|
48
54
|
},
|
|
49
|
-
|
|
50
|
-
* `POST /v1/sessions/:id/tokens/:template` — mint a token from a named JWT
|
|
51
|
-
* template for this session. The reserved name `session` is refused.
|
|
52
|
-
*/
|
|
53
|
-
getToken(id, template) {
|
|
54
|
-
return request({
|
|
55
|
-
method: 'POST',
|
|
56
|
-
path: `/v1/sessions/${(0, request_1.enc)(id)}/tokens/${(0, request_1.enc)(template)}`,
|
|
57
|
-
});
|
|
58
|
-
},
|
|
55
|
+
getToken,
|
|
59
56
|
};
|
|
60
57
|
}
|
|
61
58
|
//# sourceMappingURL=sessions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessions.js","sourceRoot":"","sources":["../../src/client/sessions.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"sessions.js","sourceRoot":"","sources":["../../src/client/sessions.ts"],"names":[],"mappings":";;AAiFA,4CA+DC;AAhJD,uCAAgD;AAiFhD,SAAgB,gBAAgB,CAAC,OAAkB;IAYjD,SAAS,QAAQ,CAAC,EAAU,EAAE,IAA8B;QAC1D,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7B,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,IAAA,aAAG,EAAC,EAAE,CAAC,uBAAuB,IAAA,aAAG,EAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;QAC1G,CAAC;QACD,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,IAAA,aAAG,EAAC,EAAE,CAAC,WAAW,IAAA,aAAG,EAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;IAC1F,CAAC;IACD,OAAO;QACL;;;WAGG;QACH,MAAM,CAAC,MAA2B;YAChC,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,MA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C,QAAQ,EAAE,CAAC,CAAC;QAC5E,CAAC;QACD,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
|
@@ -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
|
+
};
|