@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.
Files changed (93) hide show
  1. package/CHANGELOG.md +40 -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 +382 -7
  30. package/dist/client/index.js +44 -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/policies.d.ts +316 -0
  51. package/dist/client/policies.js +103 -0
  52. package/dist/client/policies.js.map +1 -0
  53. package/dist/client/privacy.d.ts +127 -0
  54. package/dist/client/privacy.js +44 -0
  55. package/dist/client/privacy.js.map +1 -0
  56. package/dist/client/referrals.d.ts +53 -6
  57. package/dist/client/referrals.js +9 -0
  58. package/dist/client/referrals.js.map +1 -1
  59. package/dist/client/request.d.ts +38 -1
  60. package/dist/client/request.js +6 -2
  61. package/dist/client/request.js.map +1 -1
  62. package/dist/client/sealed-box.d.ts +7 -0
  63. package/dist/client/sealed-box.js +62 -0
  64. package/dist/client/sealed-box.js.map +1 -0
  65. package/dist/client/sessions.d.ts +16 -5
  66. package/dist/client/sessions.js +7 -10
  67. package/dist/client/sessions.js.map +1 -1
  68. package/dist/client/status.d.ts +200 -0
  69. package/dist/client/status.js +54 -0
  70. package/dist/client/status.js.map +1 -0
  71. package/dist/client/users.d.ts +15 -0
  72. package/dist/client/webhooks.d.ts +244 -11
  73. package/dist/client/webhooks.js +52 -3
  74. package/dist/client/webhooks.js.map +1 -1
  75. package/dist/index.d.ts +9 -6
  76. package/dist/index.js +20 -4
  77. package/dist/index.js.map +1 -1
  78. package/dist/oidc.d.ts +65 -1
  79. package/dist/oidc.js +46 -0
  80. package/dist/oidc.js.map +1 -1
  81. package/dist/policy-source.d.ts +104 -0
  82. package/dist/policy-source.js +99 -0
  83. package/dist/policy-source.js.map +1 -0
  84. package/dist/referral-test-calls.d.ts +26 -13
  85. package/dist/referral-test-calls.js +40 -14
  86. package/dist/referral-test-calls.js.map +1 -1
  87. package/dist/testing.d.ts +41 -6
  88. package/dist/testing.js +34 -2
  89. package/dist/testing.js.map +1 -1
  90. package/dist/webhooks.d.ts +8 -0
  91. package/dist/webhooks.js +13 -4
  92. package/dist/webhooks.js.map +1 -1
  93. package/package.json +6 -3
@@ -0,0 +1,316 @@
1
+ import { type RequestFn } from './request';
2
+ /**
3
+ * Policy acceptance: the policies (Terms of Service, privacy policy, any key)
4
+ * your users accept at sign-up — and, per policy, again at sign-in when a new
5
+ * version takes effect. A policy's versions go draft → published (with an
6
+ * `effective_at`) → retired; a published version is immutable, and its
7
+ * `content_sha256` is the SHA-256 of the sanitised HTML users are shown.
8
+ * Acceptances are consent records carrying that hash and the reading evidence.
9
+ *
10
+ * Content can also come from any external system through the Atlas policy
11
+ * source protocol (`policySource`): Atlas fetches `GET {endpoint_url}/policies`
12
+ * signed like an Atlas webhook, and your system tells Atlas about a new
13
+ * version with a signed `policy.published` event.
14
+ */
15
+ export type PolicyDisplay = 'checkbox' | 'scroll' | 'link';
16
+ export type PolicyAppliesTo = 'sign_up' | 'sign_in_and_sign_up';
17
+ export type PolicyReaccept = 'none' | 'next_sign_in' | 'grace';
18
+ export interface PolicyVersionRef {
19
+ id: string;
20
+ version: string;
21
+ status: 'draft' | 'published' | 'retired' | (string & {});
22
+ content_sha256: string;
23
+ published_at: number | null;
24
+ effective_at: number | null;
25
+ }
26
+ export interface Policy {
27
+ object: 'policy';
28
+ id: string;
29
+ key: string;
30
+ title: string;
31
+ display: PolicyDisplay;
32
+ required: boolean;
33
+ applies_to: PolicyAppliesTo;
34
+ reaccept: PolicyReaccept;
35
+ grace_days: number | null;
36
+ source: 'atlas' | 'external';
37
+ position: number;
38
+ status: 'active' | 'retired';
39
+ /** External policies: fields changed in Atlas that a sync keeps. */
40
+ overrides: string[];
41
+ /** The version in effect now. */
42
+ current_version: PolicyVersionRef | null;
43
+ /** A newer published version that is not in effect yet. */
44
+ upcoming_version: PolicyVersionRef | null;
45
+ /** The newest version of any status (drafts included). */
46
+ latest_version: PolicyVersionRef | null;
47
+ retired_at: number | null;
48
+ created_at: number;
49
+ updated_at: number;
50
+ }
51
+ export interface PolicyVersion {
52
+ object: 'policy_version';
53
+ id: string;
54
+ policy_id: string;
55
+ policy: string;
56
+ version: string;
57
+ status: 'draft' | 'published' | 'retired';
58
+ content_markdown: string | null;
59
+ /** The sanitised HTML clients render. */
60
+ content_html: string;
61
+ content_url: string | null;
62
+ /** Hex SHA-256 of `content_html`. */
63
+ content_sha256: string;
64
+ summary_of_changes: string | null;
65
+ locale: string | null;
66
+ published_at: number | null;
67
+ effective_at: number | null;
68
+ retired_at: number | null;
69
+ created_at: number;
70
+ updated_at: number;
71
+ /** On list: how many users accepted this version. */
72
+ acceptance_count?: number;
73
+ }
74
+ export interface PolicyAcceptance {
75
+ object: 'policy_acceptance';
76
+ id: string;
77
+ user_id: string;
78
+ policy: string;
79
+ version: string;
80
+ policy_version_id: string | null;
81
+ status: 'accepted' | 'withdrawn';
82
+ source: 'signup' | 'signin' | 'reaccept' | 'api' | 'import' | (string & {}) | null;
83
+ content_sha256: string | null;
84
+ display: PolicyDisplay | null;
85
+ scrolled_to_end: boolean | null;
86
+ view_ms: number | null;
87
+ locale: string | null;
88
+ ip: string | null;
89
+ user_agent: string | null;
90
+ accepted_at: number;
91
+ }
92
+ export interface PolicyStanding {
93
+ object: 'policy_standing';
94
+ policy: string;
95
+ policy_id: string;
96
+ title: string;
97
+ display: PolicyDisplay;
98
+ required: boolean;
99
+ applies_to: PolicyAppliesTo;
100
+ reaccept: PolicyReaccept;
101
+ current_version_id: string | null;
102
+ current_version: string | null;
103
+ content_sha256: string | null;
104
+ summary_of_changes: string | null;
105
+ accepted_version_id: string | null;
106
+ accepted_version: string | null;
107
+ accepted_at: number | null;
108
+ needs_reaccept: boolean;
109
+ /** Accepting is required before the user's next sign-in completes. */
110
+ blocking: boolean;
111
+ grace_ends_at: number | null;
112
+ }
113
+ export interface CreatePolicyBody {
114
+ /** Slug, unique per instance (e.g. `tos`, `privacy`). Becomes the consent record's `policy`. */
115
+ key: string;
116
+ title: string;
117
+ display?: PolicyDisplay;
118
+ required?: boolean;
119
+ applies_to?: PolicyAppliesTo;
120
+ reaccept?: PolicyReaccept;
121
+ /** Required with `reaccept: 'grace'` (1–365). */
122
+ grace_days?: number | null;
123
+ position?: number;
124
+ }
125
+ export type UpdatePolicyBody = Partial<Omit<CreatePolicyBody, 'key'>> & {
126
+ status?: 'active' | 'retired';
127
+ };
128
+ export interface CreatePolicyVersionBody {
129
+ /** A label such as `2026-10-24` or `1.2.0`, unique per policy. */
130
+ version: string;
131
+ /** Markdown (rendered and sanitised by Atlas) — or `content_html`. */
132
+ content_markdown?: string;
133
+ content_html?: string;
134
+ content_url?: string | null;
135
+ summary_of_changes?: string | null;
136
+ locale?: string | null;
137
+ /** Publish immediately instead of saving a draft. */
138
+ publish?: boolean;
139
+ /** With `publish`: when the gate starts asking for it (epoch ms or ISO; default now). */
140
+ effective_at?: number | string;
141
+ }
142
+ export type UpdatePolicyVersionBody = Partial<Omit<CreatePolicyVersionBody, 'publish' | 'effective_at'>>;
143
+ export interface ListPolicyAcceptancesParams {
144
+ /** A version id or label. */
145
+ version?: string;
146
+ /** `accepted` (default), `withdrawn` or `all`. */
147
+ status?: 'accepted' | 'withdrawn' | 'all';
148
+ limit?: number;
149
+ starting_after?: string;
150
+ }
151
+ export interface PolicyAcceptancePage {
152
+ object: 'list';
153
+ data: PolicyAcceptance[];
154
+ has_more: boolean;
155
+ next_cursor: string | null;
156
+ }
157
+ export interface PolicySettings {
158
+ object: 'policy_settings';
159
+ /** Put `pol` (accepted versions of required policies) on session tokens. */
160
+ session_claim: boolean;
161
+ }
162
+ export interface PolicySource {
163
+ object: 'policy_source';
164
+ enabled: boolean;
165
+ endpoint_url: string | null;
166
+ signing_secret_set: boolean;
167
+ sync: 'webhook' | 'poll';
168
+ poll_interval_minutes: number;
169
+ /** Where your source sends `policy.published` / `policy.retired` events. */
170
+ webhook_url: string | null;
171
+ protocol_version: string;
172
+ last_synced_at: number | null;
173
+ last_sync_ok: boolean | null;
174
+ last_sync_error: string | null;
175
+ next_poll_at: number | null;
176
+ }
177
+ export interface UpdatePolicySourceBody {
178
+ enabled?: boolean;
179
+ /** Base URL; Atlas calls `GET {endpoint_url}/policies`. */
180
+ endpoint_url?: string | null;
181
+ /** Write-only (a `whsec_` secret works). */
182
+ signing_secret?: string | null;
183
+ sync?: 'webhook' | 'poll';
184
+ /** Poll mode: 5–1440. */
185
+ poll_interval_minutes?: number;
186
+ }
187
+ export interface PolicySourceDelivery {
188
+ object: 'policy_source_delivery';
189
+ id: string;
190
+ direction: 'outbound' | 'inbound';
191
+ kind: 'fetch' | 'test' | 'poll' | 'webhook';
192
+ status: 'ok' | 'failed' | 'rejected';
193
+ http_status: number | null;
194
+ error: string | null;
195
+ event_type: string | null;
196
+ policy: string | null;
197
+ version: string | null;
198
+ url: string | null;
199
+ changes: Record<string, unknown> | null;
200
+ latency_ms: number | null;
201
+ created_at: number;
202
+ }
203
+ export interface PolicySourceTest {
204
+ object: 'policy_source_test';
205
+ ok: boolean;
206
+ http_status: number | null;
207
+ latency_ms: number | null;
208
+ error: string | null;
209
+ warnings: string[];
210
+ policies: Array<{
211
+ key: string;
212
+ title: string;
213
+ versions: string[];
214
+ }>;
215
+ delivery: PolicySourceDelivery;
216
+ }
217
+ export interface PolicySourceSync {
218
+ object: 'policy_source_sync';
219
+ ok: boolean;
220
+ error: string | null;
221
+ warnings: string[];
222
+ changes: {
223
+ created: string[];
224
+ updated: string[];
225
+ published: string[];
226
+ unchanged: string[];
227
+ rejected: string[];
228
+ retired: string[];
229
+ } | null;
230
+ delivery: PolicySourceDelivery;
231
+ }
232
+ export declare function policiesResource(request: RequestFn): {
233
+ /** `GET /v1/policies` — active policies (`include_retired` for all). */
234
+ list(params?: {
235
+ include_retired?: boolean;
236
+ }): Promise<{
237
+ object: "list";
238
+ data: Policy[];
239
+ }>;
240
+ /** `POST /v1/policies`. */
241
+ create(body: CreatePolicyBody): Promise<Policy>;
242
+ /** `GET /v1/policies/:id` — by id or key. */
243
+ get(idOrKey: string): Promise<Policy>;
244
+ /** `PATCH /v1/policies/:id`. */
245
+ update(idOrKey: string, body: UpdatePolicyBody): Promise<Policy>;
246
+ /** `DELETE /v1/policies/:id` — deletes a never-published policy, retires one with history. */
247
+ delete(idOrKey: string): Promise<{
248
+ object: "policy";
249
+ id: string;
250
+ key: string;
251
+ deleted: boolean;
252
+ retired: boolean;
253
+ policy?: Policy;
254
+ }>;
255
+ versions: {
256
+ list(idOrKey: string): Promise<{
257
+ object: "list";
258
+ data: PolicyVersion[];
259
+ }>;
260
+ /** `POST /v1/policies/:id/versions` — a draft (or published at once with `publish: true`). */
261
+ create(idOrKey: string, body: CreatePolicyVersionBody): Promise<PolicyVersion>;
262
+ get(idOrKey: string, versionIdOrLabel: string): Promise<PolicyVersion>;
263
+ /** Drafts only. */
264
+ update(idOrKey: string, versionIdOrLabel: string, body: UpdatePolicyVersionBody): Promise<PolicyVersion>;
265
+ /** Drafts only. */
266
+ delete(idOrKey: string, versionIdOrLabel: string): Promise<{
267
+ object: "policy_version";
268
+ id: string;
269
+ deleted: true;
270
+ }>;
271
+ /** `POST …/publish` — `effective_at` (epoch ms or ISO; default now) is when the gate starts asking for it. */
272
+ publish(idOrKey: string, versionIdOrLabel: string, body?: {
273
+ effective_at?: number | string;
274
+ }): Promise<PolicyVersion>;
275
+ retire(idOrKey: string, versionIdOrLabel: string): Promise<PolicyVersion>;
276
+ };
277
+ /** `GET /v1/policies/:id/acceptances` — who accepted, newest first. */
278
+ listAcceptances(idOrKey: string, params?: ListPolicyAcceptancesParams): Promise<PolicyAcceptancePage>;
279
+ /** The same as CSV (`format=csv`, up to 100,000 rows). */
280
+ exportAcceptancesCsv(idOrKey: string, params?: Omit<ListPolicyAcceptancesParams, "limit" | "starting_after">): Promise<string>;
281
+ /** `GET /v1/users/:id/policies` — a user's standing on every policy. */
282
+ forUser(userId: string): Promise<{
283
+ object: "list";
284
+ user_id: string;
285
+ data: PolicyStanding[];
286
+ needs_acceptance: boolean;
287
+ }>;
288
+ settings: {
289
+ get(): Promise<PolicySettings>;
290
+ update(body: {
291
+ session_claim?: boolean;
292
+ }): Promise<PolicySettings>;
293
+ };
294
+ };
295
+ export declare function policySourceResource(request: RequestFn): {
296
+ get(): Promise<PolicySource>;
297
+ /** `PUT /v1/instance/policy_source` — partial; `signing_secret` is write-only. */
298
+ update(body: UpdatePolicySourceBody): Promise<PolicySource>;
299
+ /** Disconnect the source (its policies and history stay). */
300
+ delete(): Promise<PolicySource>;
301
+ /** A signed fetch of the feed, validated but not stored. */
302
+ test(): Promise<PolicySourceTest>;
303
+ /** Fetch and store now. */
304
+ sync(): Promise<PolicySourceSync>;
305
+ listDeliveries(params?: {
306
+ limit?: number;
307
+ starting_after?: string;
308
+ kind?: string;
309
+ status?: string;
310
+ }): Promise<{
311
+ object: "list";
312
+ data: PolicySourceDelivery[];
313
+ has_more: boolean;
314
+ next_cursor: string | null;
315
+ }>;
316
+ };
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.policiesResource = policiesResource;
4
+ exports.policySourceResource = policySourceResource;
5
+ const request_1 = require("./request");
6
+ function policiesResource(request) {
7
+ return {
8
+ /** `GET /v1/policies` — active policies (`include_retired` for all). */
9
+ list(params = {}) {
10
+ return request({ method: 'GET', path: '/v1/policies', query: { ...params } });
11
+ },
12
+ /** `POST /v1/policies`. */
13
+ create(body) {
14
+ return request({ method: 'POST', path: '/v1/policies', body });
15
+ },
16
+ /** `GET /v1/policies/:id` — by id or key. */
17
+ get(idOrKey) {
18
+ return request({ method: 'GET', path: `/v1/policies/${(0, request_1.enc)(idOrKey)}` });
19
+ },
20
+ /** `PATCH /v1/policies/:id`. */
21
+ update(idOrKey, body) {
22
+ return request({ method: 'PATCH', path: `/v1/policies/${(0, request_1.enc)(idOrKey)}`, body });
23
+ },
24
+ /** `DELETE /v1/policies/:id` — deletes a never-published policy, retires one with history. */
25
+ delete(idOrKey) {
26
+ return request({ method: 'DELETE', path: `/v1/policies/${(0, request_1.enc)(idOrKey)}` });
27
+ },
28
+ versions: {
29
+ list(idOrKey) {
30
+ return request({ method: 'GET', path: `/v1/policies/${(0, request_1.enc)(idOrKey)}/versions` });
31
+ },
32
+ /** `POST /v1/policies/:id/versions` — a draft (or published at once with `publish: true`). */
33
+ create(idOrKey, body) {
34
+ return request({ method: 'POST', path: `/v1/policies/${(0, request_1.enc)(idOrKey)}/versions`, body });
35
+ },
36
+ get(idOrKey, versionIdOrLabel) {
37
+ return request({ method: 'GET', path: `/v1/policies/${(0, request_1.enc)(idOrKey)}/versions/${(0, request_1.enc)(versionIdOrLabel)}` });
38
+ },
39
+ /** Drafts only. */
40
+ update(idOrKey, versionIdOrLabel, body) {
41
+ return request({ method: 'PATCH', path: `/v1/policies/${(0, request_1.enc)(idOrKey)}/versions/${(0, request_1.enc)(versionIdOrLabel)}`, body });
42
+ },
43
+ /** Drafts only. */
44
+ delete(idOrKey, versionIdOrLabel) {
45
+ return request({ method: 'DELETE', path: `/v1/policies/${(0, request_1.enc)(idOrKey)}/versions/${(0, request_1.enc)(versionIdOrLabel)}` });
46
+ },
47
+ /** `POST …/publish` — `effective_at` (epoch ms or ISO; default now) is when the gate starts asking for it. */
48
+ publish(idOrKey, versionIdOrLabel, body = {}) {
49
+ return request({ method: 'POST', path: `/v1/policies/${(0, request_1.enc)(idOrKey)}/versions/${(0, request_1.enc)(versionIdOrLabel)}/publish`, body });
50
+ },
51
+ retire(idOrKey, versionIdOrLabel) {
52
+ return request({ method: 'POST', path: `/v1/policies/${(0, request_1.enc)(idOrKey)}/versions/${(0, request_1.enc)(versionIdOrLabel)}/retire` });
53
+ },
54
+ },
55
+ /** `GET /v1/policies/:id/acceptances` — who accepted, newest first. */
56
+ listAcceptances(idOrKey, params = {}) {
57
+ return request({ method: 'GET', path: `/v1/policies/${(0, request_1.enc)(idOrKey)}/acceptances`, query: { ...params } });
58
+ },
59
+ /** The same as CSV (`format=csv`, up to 100,000 rows). */
60
+ exportAcceptancesCsv(idOrKey, params = {}) {
61
+ return request({ method: 'GET', path: `/v1/policies/${(0, request_1.enc)(idOrKey)}/acceptances`, query: { ...params, format: 'csv' }, raw: true });
62
+ },
63
+ /** `GET /v1/users/:id/policies` — a user's standing on every policy. */
64
+ forUser(userId) {
65
+ return request({ method: 'GET', path: `/v1/users/${(0, request_1.enc)(userId)}/policies` });
66
+ },
67
+ settings: {
68
+ get() {
69
+ return request({ method: 'GET', path: '/v1/instance/policy_settings' });
70
+ },
71
+ update(body) {
72
+ return request({ method: 'PATCH', path: '/v1/instance/policy_settings', body });
73
+ },
74
+ },
75
+ };
76
+ }
77
+ function policySourceResource(request) {
78
+ return {
79
+ get() {
80
+ return request({ method: 'GET', path: '/v1/instance/policy_source' });
81
+ },
82
+ /** `PUT /v1/instance/policy_source` — partial; `signing_secret` is write-only. */
83
+ update(body) {
84
+ return request({ method: 'PUT', path: '/v1/instance/policy_source', body });
85
+ },
86
+ /** Disconnect the source (its policies and history stay). */
87
+ delete() {
88
+ return request({ method: 'DELETE', path: '/v1/instance/policy_source' });
89
+ },
90
+ /** A signed fetch of the feed, validated but not stored. */
91
+ test() {
92
+ return request({ method: 'POST', path: '/v1/instance/policy_source/test' });
93
+ },
94
+ /** Fetch and store now. */
95
+ sync() {
96
+ return request({ method: 'POST', path: '/v1/instance/policy_source/sync' });
97
+ },
98
+ listDeliveries(params = {}) {
99
+ return request({ method: 'GET', path: '/v1/instance/policy_source/deliveries', query: { ...params } });
100
+ },
101
+ };
102
+ }
103
+ //# sourceMappingURL=policies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policies.js","sourceRoot":"","sources":["../../src/client/policies.ts"],"names":[],"mappings":";;AA8OA,4CAsEC;AAED,oDA8BC;AApVD,uCAAgD;AA8OhD,SAAgB,gBAAgB,CAAC,OAAkB;IACjD,OAAO;QACL,wEAAwE;QACxE,IAAI,CAAC,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AAO,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,4BAA4B,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9E,CAAC;QACD,6DAA6D;QAC7D,MAAM;YACJ,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,4BAA4B,EAAE,CAAC,CAAC;QAC3E,CAAC;QACD,4DAA4D;QAC5D,IAAI;YACF,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,iCAAiC,EAAE,CAAC,CAAC;QAC9E,CAAC;QACD,2BAA2B;QAC3B,IAAI;YACF,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,iCAAiC,EAAE,CAAC,CAAC;QAC9E,CAAC;QACD,cAAc,CAAC,SAAsF,EAAE;YAMrG,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,uCAAuC,EAAE,KAAK,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,CAAC,CAAC;QACzG,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,127 @@
1
+ import { type RequestFn } from './request';
2
+ /**
3
+ * The data-rights executor protocol (v2) — the routes any DSAR orchestrator
4
+ * calls to find a person and carry out a request against their identity data
5
+ * (needs a key with `privacy:execute`) — and the instance's own data-rights
6
+ * orchestrator, where Atlas opens a case when an account deletion is scheduled
7
+ * (needs `instance:read` / `instance:write`).
8
+ */
9
+ export type PrivacyCanonicalType = 'access' | 'deletion' | 'closure' | 'restriction' | 'rectification';
10
+ export type PrivacyRequestStatus = 'pending' | 'scheduled' | 'processing' | 'completed' | 'completed_with_retention' | 'rejected' | 'no_match' | 'cancelled';
11
+ export interface PrivacySubject {
12
+ iss?: string;
13
+ sub?: string;
14
+ ext?: string;
15
+ principal?: string;
16
+ }
17
+ export interface PrivacyLookupResult {
18
+ object: 'privacy_lookup';
19
+ status: 'found' | 'no_match';
20
+ subjectId: string | null;
21
+ matchedBy: 'atlas.sub' | 'atlas.ext' | 'email' | 'email_unverified' | null;
22
+ detail: string | null;
23
+ principal?: string;
24
+ }
25
+ export interface PrivacyRequest {
26
+ object: 'privacy_request';
27
+ id: string;
28
+ type: PrivacyCanonicalType;
29
+ canonicalType: PrivacyCanonicalType;
30
+ requestedType: string;
31
+ status: PrivacyRequestStatus;
32
+ subjectId: string;
33
+ caseId: string | null;
34
+ executeAfter: string | null;
35
+ eta: string | null;
36
+ detail: string | null;
37
+ retention: Array<{
38
+ category: string;
39
+ basis: string;
40
+ until: string;
41
+ }>;
42
+ steps: Array<{
43
+ name: string;
44
+ status: string;
45
+ reason?: string;
46
+ at?: number;
47
+ }>;
48
+ trace: string | null;
49
+ createdAt: string;
50
+ updatedAt: string;
51
+ completedAt: string | null;
52
+ /** On `getRequest` once done. */
53
+ result?: unknown;
54
+ }
55
+ export interface CreatePrivacyRequestBody {
56
+ subjectId: string;
57
+ type: PrivacyCanonicalType | 'export' | 'erasure' | 'erase';
58
+ caseId: string;
59
+ /** ISO 8601 or epoch ms: nothing is erased before it. */
60
+ executeAfter?: string | number;
61
+ reason?: string;
62
+ }
63
+ export interface PrivacyOrchestrator {
64
+ object: 'privacy_orchestrator';
65
+ configured: boolean;
66
+ enabled: boolean;
67
+ provider: string | null;
68
+ name: string | null;
69
+ case_url: string | null;
70
+ cancel_url: string | null;
71
+ auth_header: string;
72
+ auth_scheme: string;
73
+ api_key_set: boolean;
74
+ signing_secret_set: boolean;
75
+ use_partner_link: boolean;
76
+ open_closure_cases: boolean;
77
+ completion_webhook: Record<string, unknown> | null;
78
+ last_case_at: number | null;
79
+ last_error: string | null;
80
+ last_error_at: number | null;
81
+ presets: Array<Record<string, unknown>>;
82
+ /** Only on the write that minted it. */
83
+ signing_secret?: string;
84
+ /** Only on the write that created the completion endpoint. */
85
+ completion_webhook_secret?: string;
86
+ }
87
+ export interface PrivacyOrchestratorInput {
88
+ /** A preset id (`cookiemunch`, `custom`) or your own lower-case id. */
89
+ provider?: string;
90
+ name?: string;
91
+ enabled?: boolean;
92
+ case_url?: string | null;
93
+ /** Must contain `{id}`. */
94
+ cancel_url?: string | null;
95
+ auth_header?: string;
96
+ auth_scheme?: 'bearer' | 'raw';
97
+ api_key?: string | null;
98
+ /** Call through the partner link the orchestrator granted Atlas (partner id = provider). */
99
+ use_partner_link?: boolean;
100
+ open_closure_cases?: boolean;
101
+ sign_requests?: boolean;
102
+ completion_webhook_url?: string | null;
103
+ }
104
+ export declare function privacyResource(request: RequestFn): {
105
+ /** What this executor speaks (public). */
106
+ discover(): Promise<Record<string, unknown>>;
107
+ /** A ready-made orchestrator connection profile, e.g. `cookiemunch` (public). */
108
+ preset(id: string): Promise<Record<string, unknown>>;
109
+ /** Find a person: `atlas.sub` alone when present, then `atlas.ext`, then emails. */
110
+ lookup(body: {
111
+ emails?: string[];
112
+ atlas?: PrivacySubject;
113
+ }): Promise<PrivacyLookupResult>;
114
+ /** Open a request (or get the existing one for the same case). */
115
+ createRequest(body: CreatePrivacyRequestBody, idempotencyKey?: string): Promise<PrivacyRequest>;
116
+ getRequest(id: string): Promise<PrivacyRequest>;
117
+ /** Cancel before it runs: nothing is erased, the account stays. */
118
+ cancelRequest(id: string, idempotencyKey?: string): Promise<PrivacyRequest>;
119
+ orchestrator: {
120
+ get(): Promise<PrivacyOrchestrator>;
121
+ /** Connect or update; new secrets come back once. */
122
+ set(body: PrivacyOrchestratorInput): Promise<PrivacyOrchestrator>;
123
+ delete(): Promise<PrivacyOrchestrator & {
124
+ deleted: boolean;
125
+ }>;
126
+ };
127
+ };
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.privacyResource = privacyResource;
4
+ const request_1 = require("./request");
5
+ function privacyResource(request) {
6
+ return {
7
+ /** What this executor speaks (public). */
8
+ discover() {
9
+ return request({ method: 'GET', path: '/v1/privacy' });
10
+ },
11
+ /** A ready-made orchestrator connection profile, e.g. `cookiemunch` (public). */
12
+ preset(id) {
13
+ return request({ method: 'GET', path: `/v1/privacy/presets/${(0, request_1.enc)(id)}` });
14
+ },
15
+ /** Find a person: `atlas.sub` alone when present, then `atlas.ext`, then emails. */
16
+ lookup(body) {
17
+ return request({ method: 'POST', path: '/v1/privacy/lookup', body });
18
+ },
19
+ /** Open a request (or get the existing one for the same case). */
20
+ createRequest(body, idempotencyKey) {
21
+ return request({ method: 'POST', path: '/v1/privacy/requests', body, idempotencyKey });
22
+ },
23
+ getRequest(id) {
24
+ return request({ method: 'GET', path: `/v1/privacy/requests/${(0, request_1.enc)(id)}` });
25
+ },
26
+ /** Cancel before it runs: nothing is erased, the account stays. */
27
+ cancelRequest(id, idempotencyKey) {
28
+ return request({ method: 'POST', path: `/v1/privacy/requests/${(0, request_1.enc)(id)}/cancel`, idempotencyKey });
29
+ },
30
+ orchestrator: {
31
+ get() {
32
+ return request({ method: 'GET', path: '/v1/instance/privacy_orchestrator' });
33
+ },
34
+ /** Connect or update; new secrets come back once. */
35
+ set(body) {
36
+ return request({ method: 'PUT', path: '/v1/instance/privacy_orchestrator', body });
37
+ },
38
+ delete() {
39
+ return request({ method: 'DELETE', path: '/v1/instance/privacy_orchestrator' });
40
+ },
41
+ },
42
+ };
43
+ }
44
+ //# sourceMappingURL=privacy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"privacy.js","sourceRoot":"","sources":["../../src/client/privacy.ts"],"names":[],"mappings":";;AA8GA,0CAsCC;AApJD,uCAAgD;AA8GhD,SAAgB,eAAe,CAAC,OAAkB;IAChD,OAAO;QACL,0CAA0C;QAC1C,QAAQ;YACN,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC;QACzD,CAAC;QACD,iFAAiF;QACjF,MAAM,CAAC,EAAU;YACf,OAAO,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,uBAAuB,IAAA,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