@atlasauth/backend 0.25.0 → 0.27.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 (115) hide show
  1. package/CHANGELOG.md +42 -1
  2. package/dist/client/abac.d.ts +454 -0
  3. package/dist/client/abac.js +123 -0
  4. package/dist/client/abac.js.map +1 -1
  5. package/dist/client/access-policies.d.ts +84 -2
  6. package/dist/client/access-policies.js +8 -0
  7. package/dist/client/access-policies.js.map +1 -1
  8. package/dist/client/actions.d.ts +1 -1
  9. package/dist/client/actions.js.map +1 -1
  10. package/dist/client/agent-platform.d.ts +294 -0
  11. package/dist/client/agent-platform.js +132 -0
  12. package/dist/client/agent-platform.js.map +1 -0
  13. package/dist/client/analytics-reports.d.ts +1 -1
  14. package/dist/client/app-catalog.d.ts +60 -1
  15. package/dist/client/app-catalog.js +32 -2
  16. package/dist/client/app-catalog.js.map +1 -1
  17. package/dist/client/authz-decisions.d.ts +154 -0
  18. package/dist/client/authz-decisions.js +53 -0
  19. package/dist/client/authz-decisions.js.map +1 -0
  20. package/dist/client/connections.d.ts +519 -0
  21. package/dist/client/connections.js +171 -0
  22. package/dist/client/connections.js.map +1 -0
  23. package/dist/client/custom-oauth-providers.d.ts +15 -0
  24. package/dist/client/custom-oauth-providers.js.map +1 -1
  25. package/dist/client/desktop-mfa.d.ts +141 -0
  26. package/dist/client/desktop-mfa.js +58 -0
  27. package/dist/client/desktop-mfa.js.map +1 -0
  28. package/dist/client/devices.d.ts +130 -0
  29. package/dist/client/devices.js +54 -0
  30. package/dist/client/devices.js.map +1 -1
  31. package/dist/client/email-templates.d.ts +1 -1
  32. package/dist/client/email-templates.js.map +1 -1
  33. package/dist/client/fga.d.ts +301 -5
  34. package/dist/client/fga.js +81 -1
  35. package/dist/client/fga.js.map +1 -1
  36. package/dist/client/iga.d.ts +436 -0
  37. package/dist/client/iga.js +82 -0
  38. package/dist/client/iga.js.map +1 -0
  39. package/dist/client/index.d.ts +3767 -2443
  40. package/dist/client/index.js +51 -0
  41. package/dist/client/index.js.map +1 -1
  42. package/dist/client/least-privilege.d.ts +95 -0
  43. package/dist/client/least-privilege.js +28 -0
  44. package/dist/client/least-privilege.js.map +1 -0
  45. package/dist/client/log-streams.d.ts +1 -1
  46. package/dist/client/managed-grants.d.ts +52 -0
  47. package/dist/client/managed-grants.js +28 -0
  48. package/dist/client/managed-grants.js.map +1 -0
  49. package/dist/client/mcp-gateways.d.ts +220 -2
  50. package/dist/client/mcp-gateways.js +74 -0
  51. package/dist/client/mcp-gateways.js.map +1 -1
  52. package/dist/client/messaging.d.ts +11 -2
  53. package/dist/client/messaging.js.map +1 -1
  54. package/dist/client/oauth-clients.d.ts +4 -0
  55. package/dist/client/oauth-clients.js.map +1 -1
  56. package/dist/client/oauth-protocols.d.ts +116 -0
  57. package/dist/client/oauth-protocols.js +54 -0
  58. package/dist/client/oauth-protocols.js.map +1 -0
  59. package/dist/client/oauth-providers.d.ts +4 -4
  60. package/dist/client/openfga.d.ts +90 -3
  61. package/dist/client/openfga.js +27 -1
  62. package/dist/client/openfga.js.map +1 -1
  63. package/dist/client/org-ldap-connections.d.ts +3 -0
  64. package/dist/client/org-ldap-connections.js.map +1 -1
  65. package/dist/client/organizations.d.ts +14 -0
  66. package/dist/client/organizations.js.map +1 -1
  67. package/dist/client/policy-bundles.d.ts +105 -0
  68. package/dist/client/policy-bundles.js +38 -0
  69. package/dist/client/policy-bundles.js.map +1 -0
  70. package/dist/client/resources.d.ts +1 -0
  71. package/dist/client/resources.js.map +1 -1
  72. package/dist/client/risk-containment.d.ts +244 -0
  73. package/dist/client/risk-containment.js +120 -0
  74. package/dist/client/risk-containment.js.map +1 -0
  75. package/dist/client/saml-idp.d.ts +183 -0
  76. package/dist/client/saml-idp.js +71 -0
  77. package/dist/client/saml-idp.js.map +1 -0
  78. package/dist/client/scim-provisioning.d.ts +100 -4
  79. package/dist/client/scim-provisioning.js +30 -0
  80. package/dist/client/scim-provisioning.js.map +1 -1
  81. package/dist/client/scim-tokens.d.ts +34 -0
  82. package/dist/client/scim-tokens.js +17 -0
  83. package/dist/client/scim-tokens.js.map +1 -1
  84. package/dist/client/service-connectors.d.ts +1 -1
  85. package/dist/client/ssf.d.ts +31 -1
  86. package/dist/client/ssf.js +17 -0
  87. package/dist/client/ssf.js.map +1 -1
  88. package/dist/client/users.d.ts +9 -0
  89. package/dist/client/users.js +9 -0
  90. package/dist/client/users.js.map +1 -1
  91. package/dist/client/vault.d.ts +54 -0
  92. package/dist/client/vault.js +30 -0
  93. package/dist/client/vault.js.map +1 -1
  94. package/dist/client/vc.d.ts +62 -2
  95. package/dist/client/vc.js +15 -0
  96. package/dist/client/vc.js.map +1 -1
  97. package/dist/client/workflows.d.ts +182 -3
  98. package/dist/client/workflows.js +34 -0
  99. package/dist/client/workflows.js.map +1 -1
  100. package/dist/index.d.ts +5 -2
  101. package/dist/index.js +6 -1
  102. package/dist/index.js.map +1 -1
  103. package/dist/oauth-resource.d.ts +30 -3
  104. package/dist/oauth-resource.js +43 -2
  105. package/dist/oauth-resource.js.map +1 -1
  106. package/dist/policy-bundle.d.ts +110 -0
  107. package/dist/policy-bundle.js +289 -0
  108. package/dist/policy-bundle.js.map +1 -0
  109. package/dist/txn-token.d.ts +36 -0
  110. package/dist/txn-token.js +30 -0
  111. package/dist/txn-token.js.map +1 -0
  112. package/dist/uma.d.ts +77 -0
  113. package/dist/uma.js +95 -0
  114. package/dist/uma.js.map +1 -0
  115. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,6 +1,47 @@
1
1
  # @atlasauth/backend changelog
2
2
 
3
- ## Unreleased
3
+ ## 0.27.0 — 2026-10-28
4
+
5
+ - SAML IdP (service providers, artifacts, attribute queries), WS-Federation, outbound provisioning connectors, SCIM custom resources and cloud access targets
6
+ - OpenID provider: per-client signing/encryption, op key rotation, token-exchange profiles, refresh-token search and bulk revoke, federation resolve, verifiable-credential deferred issuance and presentation requests; `requireAcr`/`maxAge` step-up on access-token verification and `verifyTransactionToken`
7
+ - Conditional access depth: report-only and impact replay, device assurance policies and pull integrations, risky users, containment, temporary access passes, email risk, authenticator policies
8
+ - Workflows, chat integrations (Slack/Teams approvals), eligible access and activation, staged and recurring reviews, bundles, administrative units, organization application access and B2B connections
9
+ - MCP gateway v2 (upstreams, packs, pins, user auth), connection actions and triggers, agent lifecycle and reviews, telemetry export
10
+ - Authorization: tuple expiry, decision points, Cedar JSON and token authorization, FGA assertions/materializations/bulk import, customer-managed keys, coupons, credits, user merge, audit retention
11
+ - Device-bound SSO registrations; SMTP2GO email transport
12
+
13
+ ## 0.26.0 — 2026-10-27
14
+
15
+ ### Added
16
+
17
+ - `iga` client resource: identity governance (access catalog, access requests and approvals, grants, delegations, separation-of-duties rules, joiner/mover/leaver lifecycle, certification campaigns).
18
+ - `desktopMfa` client resource: the desktop login MFA policy, enrolment codes and enrolled devices (`getPolicy`, `updatePolicy`, `createEnrolmentCode`, `listDevices`, `getDevice`, `revokeDevice`, `revokeOfflineCache`, `deleteDevice`).
19
+ - `managedGrants` client resource (`list`, `get`, `narrow`, `revoke`): the OpenID Grant Management grants each OAuth client holds for each user.
20
+ - `leastPrivilege` client resource (`report`, `get`, `exportCsv`, and applying the narrower grants with a `dryRun` preview): what each secret key, OAuth client, MCP gateway and agent holds against what it used.
21
+ - `mcpGateways` gains `abac` (policy checks on every tool call) and `budgets` (`list`, `create`, `get`, `update`, `delete`, `usage`).
22
+ - `fga.settings.get` / `fga.settings.update`: the instance's FGA result-cache lifetime, default consistency mode and tuple change-log retention.
23
+
24
+ - `connections.token` now caches per client until shortly before `expires_at` and takes `minTtlSeconds`; new `connections.refreshToken` (force-refresh after a provider 401, with `staleAccessToken`), `connections.tokens` (batch read of up to 100), `connections.importConnections` and `connections.exportConnections` (sealed to your public key); `connections.delete(id, { revoke: true })`. `Connection` gains `refresh_failures`, `next_refresh_at` and a typed `last_error` with the provider's code and HTTP status.
25
+ - `connections.revoke` returns `provider_revoked`, `provider_status`, `provider_error` and `local_cleared`.
26
+ - Webhook event types `connection.refresh_failed`, `connection.reauthorization_required`, `connection.revoked`, `connection.scopes_changed`, `connection.recovered`.
27
+ - Connections: `setCredentials`, `rotateCredentials`, `secretVersions`, `secret` (scope `connections:secret_read`), `oauth1Sign`, `webhooks.verify` and `webhooks.*Endpoint`; `token()` takes `subject` for delegated tokens; `Connection` reports `secret_expires_at`, `previous_valid_until` and `allowed_methods`.
28
+ - `connections` client resource: `create`, `list`, `get`, `update` (including `owner` to transfer), `delete`, `connect`, `revoke`, `token` (needs the `connections:token` scope) and `oauthClients` (`set`, `list`, `get`, `delete`), with `host_params`, `environment` and the captured token fields typed.
29
+ - ABAC data filtering: `abac.partialEvaluate` (the policies as a filter over an unknown resource or principal, with relationship conditions resolved and optional SQL or Prisma output) and `abac.accessibleResources` (the resources a principal may act on, paged). The filter helpers `evalFilter`, `filterToSql`, `filterToPrisma` and `filterToDrizzle` are exported.
30
+ - AuthZEN 1.0 search: `abac.authzenSearchSubject`, `authzenSearchResource` and `authzenSearchAction`.
31
+ - ABAC authoring: `abac.templates`, `abac.links`, `abac.schema` (`get`, `set`, `delete`, `validate`), `abac.diff` and `abac.diffSources`; `abac.test` results carry `coverage`.
32
+ - `fga.listObjects` and the resource-role `accessible` call take `limit` and `starting_after`; `listObjects` returns `has_more` and `next_cursor`.
33
+ - `authzDecisions` client resource (`list`, `iterate`, `get`, `stats`, `settings.get/update`): the authorization decision log and its capture settings.
34
+ - `policyBundles` client resource (`export`, `list`, `current`, `get`, `verify`, `import` with `dry_run` / `prune`) and `verifyPolicyBundle`, which verifies a signed policy bundle offline against your instance JWKS and returns its policies and FGA models.
35
+ - `fga.listUsers` / `fga.listAllUsers` and `openfga.listUsers` / `openfga.listAllUsers`: who has a relation on an object (users, usersets, the `type:*` wildcard with `excluded_users`), paged.
36
+ - `fga.readChanges` and `openfga.readChanges`: the tuple change log, resumable with `continuation_token`.
37
+ - Tuple conditions: `condition` on tuple keys and `context` on `check`, `batchCheck` items, `listObjects` and `listUsers`.
38
+ - `consistency` / `consistency_token` on queries; writes and queries return a `consistency_token`.
39
+ - Desktop login MFA passkeys: `DesktopPasskey` and the policy fields `passkey_scope`, `passkey_rp_id` and `passkey_require_uv`.
40
+ - Connections: `token_family` on connections and `split_tenants` on connect, so one grant covering several accounts (Xero organisations) becomes one connection per account sharing one token set.
41
+ - Custom OAuth providers: `revocation_endpoint`, `host_params_schema` and `data_only` (connect-time host templates for data-only providers).
42
+ - OAuth clients: `claims_redirect_uris` for UMA 2.0 claims gathering.
43
+ - Shared Signals receivers: the `sync_posture` action records device posture without touching sessions.
44
+ - Verifiable credentials: mdoc issuer revocation checks (`revocation_policy`: off, best_effort or required).
4
45
 
5
46
  ## 0.25.0 — 2026-10-26
6
47
 
@@ -1,5 +1,6 @@
1
1
  import { type RequestFn } from './request';
2
2
  import type { ListPage } from './types';
3
+ import type { Filter, SqlColumn, SqlDialect } from '@atlasauth/authz';
3
4
  export interface AbacPolicyTestCase {
4
5
  name: string;
5
6
  /** principal, action, resource, context and optional entities. */
@@ -63,6 +64,43 @@ export interface AbacDecision {
63
64
  decision: 'allow' | 'deny';
64
65
  reasons: string[];
65
66
  errors: string[];
67
+ /** `@annotations` of the policies that decided it, when any carry them. */
68
+ annotations?: Array<{
69
+ policy: string;
70
+ annotations: Record<string, string>;
71
+ }>;
72
+ }
73
+ export interface AbacCoverageClause {
74
+ kind: 'when' | 'unless';
75
+ index: number;
76
+ line: number | null;
77
+ true: number;
78
+ false: number;
79
+ error: number;
80
+ }
81
+ /** Which rules and `when`/`unless` clauses the test cases exercised. */
82
+ export interface AbacCoverage {
83
+ object: 'abac_coverage';
84
+ tests: number;
85
+ rules: Array<{
86
+ rule: number;
87
+ effect: 'permit' | 'forbid';
88
+ line: number | null;
89
+ in_scope: number;
90
+ matched: number;
91
+ status: 'covered' | 'partial' | 'untouched';
92
+ clauses: AbacCoverageClause[];
93
+ }>;
94
+ summary: {
95
+ rules: number;
96
+ reached: number;
97
+ matched: number;
98
+ clauses: number;
99
+ clauses_both_ways: number;
100
+ percent: number;
101
+ };
102
+ /** What to add a test for, one sentence each. */
103
+ gaps: string[];
66
104
  }
67
105
  export interface AbacTestRun {
68
106
  object: 'abac_policy_test_run';
@@ -73,6 +111,169 @@ export interface AbacTestRun {
73
111
  actual: 'allow' | 'deny';
74
112
  passed: boolean;
75
113
  }>;
114
+ coverage: AbacCoverage;
115
+ }
116
+ export interface AbacEntityRef {
117
+ type: string;
118
+ id: string;
119
+ }
120
+ /** A policy template: source with `?principal` / `?resource` slots, filled by links. */
121
+ export interface AbacPolicyTemplate {
122
+ object: 'abac_policy_template';
123
+ id: string;
124
+ name: string;
125
+ description: string | null;
126
+ source: string;
127
+ version: number;
128
+ slots: Array<'?principal' | '?resource'>;
129
+ fga_store_id: string | null;
130
+ link_count: number;
131
+ /** On an update that changed `source`: the links that now evaluate the new source. */
132
+ links_updated?: number;
133
+ created_at: number;
134
+ updated_at: number;
135
+ }
136
+ export interface CreateAbacTemplateBody {
137
+ name: string;
138
+ source: string;
139
+ description?: string | null;
140
+ fga_store_id?: string | null;
141
+ }
142
+ export interface AbacPolicyLink {
143
+ object: 'abac_policy_link';
144
+ id: string;
145
+ name: string;
146
+ template_id: string;
147
+ template_name: string | null;
148
+ /** The template version the link follows (always the latest). */
149
+ template_version: number | null;
150
+ principal: AbacEntityRef | null;
151
+ resource: AbacEntityRef | null;
152
+ enabled: boolean;
153
+ /** The policy source the link evaluates: the template with its slots filled. */
154
+ source: string;
155
+ created_at: number;
156
+ updated_at: number;
157
+ }
158
+ export interface CreateAbacLinkBody {
159
+ template_id: string;
160
+ name: string;
161
+ principal?: AbacEntityRef | null;
162
+ resource?: AbacEntityRef | null;
163
+ enabled?: boolean;
164
+ }
165
+ export type AbacSchemaType = {
166
+ type: 'boolean' | 'long' | 'string';
167
+ } | {
168
+ type: 'set';
169
+ element: AbacSchemaType;
170
+ } | {
171
+ type: 'entity';
172
+ name: string;
173
+ } | {
174
+ type: 'record';
175
+ attributes: Record<string, AbacSchemaType & {
176
+ required?: boolean;
177
+ }>;
178
+ };
179
+ /** The entity schema policies are type-checked against when saved. */
180
+ export interface AbacSchemaDocument {
181
+ entity_types: Record<string, {
182
+ attributes?: Record<string, AbacSchemaType & {
183
+ required?: boolean;
184
+ }>;
185
+ member_of?: string[];
186
+ }>;
187
+ actions?: Record<string, {
188
+ applies_to?: {
189
+ principal_types: string[];
190
+ resource_types: string[];
191
+ context?: Record<string, AbacSchemaType & {
192
+ required?: boolean;
193
+ }>;
194
+ };
195
+ member_of?: string[];
196
+ }>;
197
+ }
198
+ export interface AbacPolicyIssue {
199
+ severity: 'error' | 'warning';
200
+ /** 1-based position of the policy in the source (0 for a syntax error). */
201
+ policy: number;
202
+ rule: 'permit' | 'forbid';
203
+ clause?: {
204
+ kind: 'when' | 'unless';
205
+ index: number;
206
+ };
207
+ message: string;
208
+ offset?: number;
209
+ line?: number;
210
+ column?: number;
211
+ source_name?: string;
212
+ }
213
+ export interface AbacSchemaState {
214
+ object: 'abac_schema';
215
+ schema: AbacSchemaDocument | null;
216
+ version: number;
217
+ updated_at: number | null;
218
+ /** On a save: the errors the schema would give the policies and links already stored. */
219
+ policy_issues?: AbacPolicyIssue[];
220
+ }
221
+ export interface AbacValidation {
222
+ object: 'abac_validation';
223
+ valid: boolean;
224
+ schema_checked: boolean;
225
+ issues: AbacPolicyIssue[];
226
+ }
227
+ export interface AbacDiffChange {
228
+ request: Record<string, unknown>;
229
+ before: 'allow' | 'deny';
230
+ after: 'allow' | 'deny';
231
+ /** Present when a version uses `fga.check`: the assumption the change holds under. */
232
+ assuming?: {
233
+ fga_check: boolean;
234
+ };
235
+ }
236
+ export interface AbacPolicyDiff {
237
+ object: 'abac_policy_diff';
238
+ policy_id?: string;
239
+ from?: number;
240
+ to?: number;
241
+ text: {
242
+ identical: boolean;
243
+ added: number;
244
+ removed: number;
245
+ lines: Array<{
246
+ type: 'context' | 'add' | 'remove';
247
+ text: string;
248
+ before_line?: number;
249
+ after_line?: number;
250
+ }>;
251
+ };
252
+ /** The requests whose decision changes; null when `semantic` was false. */
253
+ semantic: {
254
+ enumerated: number;
255
+ space: number;
256
+ exhaustive: boolean;
257
+ changed: number;
258
+ newly_allowed: number;
259
+ newly_denied: number;
260
+ by_action: Record<string, {
261
+ newly_allowed: number;
262
+ newly_denied: number;
263
+ }>;
264
+ changes: AbacDiffChange[];
265
+ truncated: boolean;
266
+ } | null;
267
+ }
268
+ export interface AbacDiffOptions {
269
+ from?: number;
270
+ to?: number;
271
+ /** false returns only the text diff. */
272
+ semantic?: boolean;
273
+ /** Requests to compare; the space is sampled beyond this. Default 5000. */
274
+ max_requests?: number;
275
+ /** Changed requests to list. Default 50. */
276
+ max_changes?: number;
76
277
  }
77
278
  export interface AuthzenEvaluation {
78
279
  subject?: {
@@ -91,6 +292,111 @@ export interface AuthzenEvaluation {
91
292
  };
92
293
  context?: Record<string, unknown>;
93
294
  }
295
+ /** An entity for partial evaluation: an unknown one needs only its `type`. */
296
+ export interface AbacPartialEntity {
297
+ type: string;
298
+ id?: string;
299
+ attributes?: Record<string, unknown>;
300
+ parents?: string[];
301
+ }
302
+ export interface AbacPartialBody {
303
+ principal: AbacPartialEntity;
304
+ action: string;
305
+ resource: AbacPartialEntity;
306
+ context?: Record<string, unknown>;
307
+ entities?: AbacEntity[];
308
+ policy_ids?: string[];
309
+ /** Which entity's attributes are unknown. Default `['resource']`. */
310
+ unknowns?: Array<'principal' | 'resource'>;
311
+ /** Replace relationship (`fga.check`) conditions with the ids the FGA store returns. Default true. */
312
+ resolve_relations?: boolean;
313
+ /** Ask for a ready-made query: parameterised SQL (field-to-column map) and/or a Prisma where object. */
314
+ output?: {
315
+ sql?: {
316
+ columns: Record<string, SqlColumn>;
317
+ dialect?: SqlDialect;
318
+ param_offset?: number;
319
+ };
320
+ prisma?: {
321
+ fields: Record<string, string>;
322
+ };
323
+ };
324
+ }
325
+ export interface AbacResidual {
326
+ object: 'abac_residual';
327
+ /** `allow` / `deny` when the filter is constant, else `conditional`. */
328
+ decision: 'allow' | 'deny' | 'conditional';
329
+ /** The condition on the unknown entity under which the request is allowed. */
330
+ filter: Filter;
331
+ permit: Filter;
332
+ forbid: Filter;
333
+ unknowns: Array<'principal' | 'resource'>;
334
+ relations_resolved: boolean;
335
+ sql?: {
336
+ text: string;
337
+ params: unknown[];
338
+ };
339
+ prisma?: Record<string, unknown>;
340
+ }
341
+ export interface AbacAccessibleBody {
342
+ principal: AbacPartialEntity;
343
+ action: string;
344
+ /** The Atlas resource type key; policies see its PascalCase form. */
345
+ resource_type: string;
346
+ context?: Record<string, unknown>;
347
+ entities?: AbacEntity[];
348
+ /** Resources to filter instead of the Atlas ones. */
349
+ candidates?: Array<{
350
+ id: string;
351
+ attributes?: Record<string, unknown>;
352
+ parents?: string[];
353
+ }>;
354
+ policy_ids?: string[];
355
+ limit?: number;
356
+ starting_after?: string;
357
+ }
358
+ export interface AbacAccessibleList {
359
+ object: 'list';
360
+ data: Array<{
361
+ object: 'abac_resource';
362
+ type: string;
363
+ id: string;
364
+ }>;
365
+ has_more: boolean;
366
+ next_cursor: string | null;
367
+ total: number;
368
+ evaluated: number;
369
+ /** `residual` when one filter was applied to every candidate; `per_resource` when each had to be evaluated. */
370
+ method: 'residual' | 'per_resource';
371
+ }
372
+ /** AuthZEN 1.0 search request: leave the `id` out of the entity you are looking for. */
373
+ export interface AuthzenSearchRequest {
374
+ subject?: {
375
+ type: string;
376
+ id?: string;
377
+ properties?: Record<string, unknown>;
378
+ };
379
+ resource?: {
380
+ type: string;
381
+ id?: string;
382
+ properties?: Record<string, unknown>;
383
+ };
384
+ action?: {
385
+ name: string;
386
+ properties?: Record<string, unknown>;
387
+ };
388
+ context?: Record<string, unknown>;
389
+ page?: {
390
+ limit?: number;
391
+ token?: string;
392
+ };
393
+ }
394
+ export interface AuthzenSearchPage {
395
+ /** Empty on the last page. */
396
+ next_token: string;
397
+ count: number;
398
+ total: number;
399
+ }
94
400
  /** ABAC policies and the policy decision point (including the AuthZEN endpoints). */
95
401
  export declare function abacResource(request: RequestFn): {
96
402
  list(): Promise<ListPage<AbacPolicy>>;
@@ -109,8 +415,140 @@ export declare function abacResource(request: RequestFn): {
109
415
  source?: string;
110
416
  tests?: AbacPolicyTestCase[];
111
417
  }): Promise<AbacTestRun>;
418
+ /** Cedar JSON policy format: export policy text, import JSON (optionally creating the policy with `name`). */
419
+ cedar: {
420
+ export(source: string): Promise<{
421
+ object: "cedar_json_policies";
422
+ policies: Array<Record<string, unknown>>;
423
+ }>;
424
+ import(body: {
425
+ policies: Array<Record<string, unknown>>;
426
+ name?: string;
427
+ fga_store_id?: string | null;
428
+ }): Promise<{
429
+ object: "cedar_source";
430
+ source: string;
431
+ policies: number;
432
+ } | AbacPolicy>;
433
+ forPolicy(id: string): Promise<{
434
+ object: "cedar_json_policies";
435
+ policies: Array<Record<string, unknown>>;
436
+ }>;
437
+ };
438
+ /** How access-token claims become a policy principal and its parents (used by {@link authorizeToken}). */
439
+ tokenMapping: {
440
+ get(): Promise<AbacTokenMapping>;
441
+ put(body: Partial<Omit<AbacTokenMapping, "object">>): Promise<AbacTokenMapping>;
442
+ };
443
+ /** Decide for the principal an access token stands for (verified first; an invalid token is a 401). */
444
+ authorizeToken(body: {
445
+ access_token: string;
446
+ action: string;
447
+ resource: {
448
+ type: string;
449
+ id: string;
450
+ attributes?: Record<string, unknown>;
451
+ };
452
+ context?: Record<string, unknown>;
453
+ entities?: AbacEntity[];
454
+ policy_ids?: string[];
455
+ }): Promise<AbacDecision & {
456
+ principal: {
457
+ type: string;
458
+ id: string;
459
+ parents: string[];
460
+ };
461
+ issuer: "atlas" | "trusted";
462
+ }>;
112
463
  /** May `principal` perform `action` on `resource`? */
113
464
  evaluate(body: AbacEvaluateBody): Promise<AbacDecision>;
465
+ /**
466
+ * Partial evaluation (data filtering): the condition under which the request is allowed when
467
+ * an entity is unknown, as a filter AST and, on request, parameterised SQL or a Prisma object.
468
+ */
469
+ partialEvaluate(body: AbacPartialBody): Promise<AbacResidual>;
470
+ /** The resources of a type a principal may perform an action on, one page at a time. */
471
+ accessibleResources(body: AbacAccessibleBody): Promise<AbacAccessibleList>;
472
+ /** Policy templates: policy source with `?principal` / `?resource` slots that links fill with entities. */
473
+ templates: {
474
+ list(): Promise<ListPage<AbacPolicyTemplate>>;
475
+ get(id: string): Promise<AbacPolicyTemplate>;
476
+ create(body: CreateAbacTemplateBody, idempotencyKey?: string): Promise<AbacPolicyTemplate>;
477
+ /** A new `source` reaches every link at once; it is refused if a link could no longer be filled in or would fail the schema. */
478
+ update(id: string, body: Partial<CreateAbacTemplateBody>): Promise<AbacPolicyTemplate>;
479
+ /** A template with links is refused unless `force` (which deletes the links too). */
480
+ delete(id: string, opts?: {
481
+ force?: boolean;
482
+ }): Promise<{
483
+ object: "abac_policy_template";
484
+ id: string;
485
+ deleted: true;
486
+ links_deleted: number;
487
+ }>;
488
+ };
489
+ /** Links: a template with its slots filled by entities. A link is evaluated from the template's current source. */
490
+ links: {
491
+ list(query?: {
492
+ template_id?: string;
493
+ }): Promise<ListPage<AbacPolicyLink>>;
494
+ get(id: string): Promise<AbacPolicyLink>;
495
+ create(body: CreateAbacLinkBody, idempotencyKey?: string): Promise<AbacPolicyLink>;
496
+ update(id: string, body: Partial<Omit<CreateAbacLinkBody, "template_id">>): Promise<AbacPolicyLink>;
497
+ delete(id: string): Promise<{
498
+ object: "abac_policy_link";
499
+ id: string;
500
+ deleted: true;
501
+ }>;
502
+ };
503
+ /** The entity schema: once set, policies and templates are type-checked when saved. */
504
+ schema: {
505
+ get(): Promise<AbacSchemaState>;
506
+ /** Saves the schema and reports the errors it would give the policies already stored (`policy_issues`). */
507
+ set(schema: AbacSchemaDocument): Promise<AbacSchemaState>;
508
+ delete(): Promise<{
509
+ object: "abac_schema";
510
+ deleted: true;
511
+ }>;
512
+ /** Type-check draft source against the saved schema (or `schema`) without saving anything. */
513
+ validate(body: {
514
+ source: string;
515
+ schema?: AbacSchemaDocument;
516
+ template?: boolean;
517
+ }): Promise<AbacValidation>;
518
+ };
519
+ /** Compare two versions of a policy: the text, and the requests whose decision changes. */
520
+ diff(id: string, opts?: AbacDiffOptions): Promise<AbacPolicyDiff>;
521
+ /** The same comparison for two sources you send, without saving. */
522
+ diffSources(body: {
523
+ before: string;
524
+ after: string;
525
+ semantic?: boolean;
526
+ max_requests?: number;
527
+ max_changes?: number;
528
+ }): Promise<AbacPolicyDiff>;
529
+ /** AuthZEN 1.0 Subject Search: the subjects of a type that may perform the action on the resource. */
530
+ authzenSearchSubject(body: AuthzenSearchRequest): Promise<{
531
+ results: Array<{
532
+ type: string;
533
+ id: string;
534
+ }>;
535
+ page: AuthzenSearchPage;
536
+ }>;
537
+ /** AuthZEN 1.0 Resource Search: the resources of a type the subject may perform the action on. */
538
+ authzenSearchResource(body: AuthzenSearchRequest): Promise<{
539
+ results: Array<{
540
+ type: string;
541
+ id: string;
542
+ }>;
543
+ page: AuthzenSearchPage;
544
+ }>;
545
+ /** AuthZEN 1.0 Action Search: the actions the subject may perform on the resource. */
546
+ authzenSearchAction(body: AuthzenSearchRequest): Promise<{
547
+ results: Array<{
548
+ name: string;
549
+ }>;
550
+ page: AuthzenSearchPage;
551
+ }>;
114
552
  /** Convenience: the boolean answer to {@link evaluate}. */
115
553
  isAllowed(body: AbacEvaluateBody): Promise<boolean>;
116
554
  /** AuthZEN 1.0 Access Evaluation. */
@@ -130,3 +568,19 @@ export declare function abacResource(request: RequestFn): {
130
568
  }>;
131
569
  }>;
132
570
  };
571
+ export { FilterCompileError, evalFilter, filterToDrizzle, filterToPrisma, filterToSql, type DrizzleOps, type DrizzleOptions, type Filter, type FilterRows, type PrismaOptions, type SqlColumn, type SqlDialect, type SqlFragment, type SqlOptions, } from '@atlasauth/authz';
572
+ export interface AbacTokenMapping {
573
+ object: 'abac_token_mapping';
574
+ principal_type: string;
575
+ id_claim: string;
576
+ parents: Array<{
577
+ claim: string;
578
+ type: string;
579
+ }>;
580
+ attribute_claims: string[];
581
+ trusted_issuers: Array<{
582
+ issuer: string;
583
+ jwks_uri: string;
584
+ audience?: string;
585
+ }>;
586
+ }
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.filterToSql = exports.filterToPrisma = exports.filterToDrizzle = exports.evalFilter = exports.FilterCompileError = void 0;
3
4
  exports.abacResource = abacResource;
4
5
  const request_1 = require("./request");
5
6
  /** ABAC policies and the policy decision point (including the AuthZEN endpoints). */
@@ -27,10 +28,125 @@ function abacResource(request) {
27
28
  test(id, body = {}) {
28
29
  return request({ method: 'POST', path: `/v1/abac_policies/${(0, request_1.enc)(id)}/test`, body });
29
30
  },
31
+ /** Cedar JSON policy format: export policy text, import JSON (optionally creating the policy with `name`). */
32
+ cedar: {
33
+ export(source) {
34
+ return request({ method: 'POST', path: '/v1/abac/cedar/export', body: { source } });
35
+ },
36
+ import(body) {
37
+ return request({ method: 'POST', path: '/v1/abac/cedar/import', body });
38
+ },
39
+ forPolicy(id) {
40
+ return request({ method: 'GET', path: `/v1/abac_policies/${(0, request_1.enc)(id)}/cedar_json` });
41
+ },
42
+ },
43
+ /** How access-token claims become a policy principal and its parents (used by {@link authorizeToken}). */
44
+ tokenMapping: {
45
+ get() {
46
+ return request({ method: 'GET', path: '/v1/abac/token_mapping' });
47
+ },
48
+ put(body) {
49
+ return request({ method: 'PUT', path: '/v1/abac/token_mapping', body });
50
+ },
51
+ },
52
+ /** Decide for the principal an access token stands for (verified first; an invalid token is a 401). */
53
+ authorizeToken(body) {
54
+ return request({ method: 'POST', path: '/v1/abac/authorize_token', body });
55
+ },
30
56
  /** May `principal` perform `action` on `resource`? */
31
57
  evaluate(body) {
32
58
  return request({ method: 'POST', path: '/v1/abac/evaluate', body });
33
59
  },
60
+ /**
61
+ * Partial evaluation (data filtering): the condition under which the request is allowed when
62
+ * an entity is unknown, as a filter AST and, on request, parameterised SQL or a Prisma object.
63
+ */
64
+ partialEvaluate(body) {
65
+ return request({ method: 'POST', path: '/v1/abac/partial_evaluate', body });
66
+ },
67
+ /** The resources of a type a principal may perform an action on, one page at a time. */
68
+ accessibleResources(body) {
69
+ return request({ method: 'POST', path: '/v1/abac/accessible_resources', body });
70
+ },
71
+ /** Policy templates: policy source with `?principal` / `?resource` slots that links fill with entities. */
72
+ templates: {
73
+ list() {
74
+ return request({ method: 'GET', path: '/v1/abac_templates' });
75
+ },
76
+ get(id) {
77
+ return request({ method: 'GET', path: `/v1/abac_templates/${(0, request_1.enc)(id)}` });
78
+ },
79
+ create(body, idempotencyKey) {
80
+ return request({ method: 'POST', path: '/v1/abac_templates', body, idempotencyKey });
81
+ },
82
+ /** A new `source` reaches every link at once; it is refused if a link could no longer be filled in or would fail the schema. */
83
+ update(id, body) {
84
+ return request({ method: 'PATCH', path: `/v1/abac_templates/${(0, request_1.enc)(id)}`, body });
85
+ },
86
+ /** A template with links is refused unless `force` (which deletes the links too). */
87
+ delete(id, opts = {}) {
88
+ return request({ method: 'DELETE', path: `/v1/abac_templates/${(0, request_1.enc)(id)}${opts.force ? '?force=true' : ''}` });
89
+ },
90
+ },
91
+ /** Links: a template with its slots filled by entities. A link is evaluated from the template's current source. */
92
+ links: {
93
+ list(query = {}) {
94
+ return request({ method: 'GET', path: `/v1/abac_policy_links${query.template_id ? `?template_id=${(0, request_1.enc)(query.template_id)}` : ''}` });
95
+ },
96
+ get(id) {
97
+ return request({ method: 'GET', path: `/v1/abac_policy_links/${(0, request_1.enc)(id)}` });
98
+ },
99
+ create(body, idempotencyKey) {
100
+ return request({ method: 'POST', path: '/v1/abac_policy_links', body, idempotencyKey });
101
+ },
102
+ update(id, body) {
103
+ return request({ method: 'PATCH', path: `/v1/abac_policy_links/${(0, request_1.enc)(id)}`, body });
104
+ },
105
+ delete(id) {
106
+ return request({ method: 'DELETE', path: `/v1/abac_policy_links/${(0, request_1.enc)(id)}` });
107
+ },
108
+ },
109
+ /** The entity schema: once set, policies and templates are type-checked when saved. */
110
+ schema: {
111
+ get() {
112
+ return request({ method: 'GET', path: '/v1/abac_schema' });
113
+ },
114
+ /** Saves the schema and reports the errors it would give the policies already stored (`policy_issues`). */
115
+ set(schema) {
116
+ return request({ method: 'PUT', path: '/v1/abac_schema', body: { schema } });
117
+ },
118
+ delete() {
119
+ return request({ method: 'DELETE', path: '/v1/abac_schema' });
120
+ },
121
+ /** Type-check draft source against the saved schema (or `schema`) without saving anything. */
122
+ validate(body) {
123
+ return request({ method: 'POST', path: '/v1/abac_schema/validate', body });
124
+ },
125
+ },
126
+ /** Compare two versions of a policy: the text, and the requests whose decision changes. */
127
+ diff(id, opts = {}) {
128
+ const qs = Object.entries(opts)
129
+ .filter(([, v]) => v !== undefined)
130
+ .map(([k, v]) => `${k}=${encodeURIComponent(String(v))}`)
131
+ .join('&');
132
+ return request({ method: 'GET', path: `/v1/abac_policies/${(0, request_1.enc)(id)}/diff${qs ? `?${qs}` : ''}` });
133
+ },
134
+ /** The same comparison for two sources you send, without saving. */
135
+ diffSources(body) {
136
+ return request({ method: 'POST', path: '/v1/abac/diff', body });
137
+ },
138
+ /** AuthZEN 1.0 Subject Search: the subjects of a type that may perform the action on the resource. */
139
+ authzenSearchSubject(body) {
140
+ return request({ method: 'POST', path: '/v1/authzen/access/v1/search/subject', body });
141
+ },
142
+ /** AuthZEN 1.0 Resource Search: the resources of a type the subject may perform the action on. */
143
+ authzenSearchResource(body) {
144
+ return request({ method: 'POST', path: '/v1/authzen/access/v1/search/resource', body });
145
+ },
146
+ /** AuthZEN 1.0 Action Search: the actions the subject may perform on the resource. */
147
+ authzenSearchAction(body) {
148
+ return request({ method: 'POST', path: '/v1/authzen/access/v1/search/action', body });
149
+ },
34
150
  /** Convenience: the boolean answer to {@link evaluate}. */
35
151
  async isAllowed(body) {
36
152
  return (await request({ method: 'POST', path: '/v1/abac/evaluate', body })).decision === 'allow';
@@ -45,4 +161,11 @@ function abacResource(request) {
45
161
  },
46
162
  };
47
163
  }
164
+ // The residual-filter helpers: evaluate a filter in memory, or compile it for SQL, Prisma or Drizzle.
165
+ var authz_1 = require("@atlasauth/authz");
166
+ Object.defineProperty(exports, "FilterCompileError", { enumerable: true, get: function () { return authz_1.FilterCompileError; } });
167
+ Object.defineProperty(exports, "evalFilter", { enumerable: true, get: function () { return authz_1.evalFilter; } });
168
+ Object.defineProperty(exports, "filterToDrizzle", { enumerable: true, get: function () { return authz_1.filterToDrizzle; } });
169
+ Object.defineProperty(exports, "filterToPrisma", { enumerable: true, get: function () { return authz_1.filterToPrisma; } });
170
+ Object.defineProperty(exports, "filterToSql", { enumerable: true, get: function () { return authz_1.filterToSql; } });
48
171
  //# sourceMappingURL=abac.js.map