@xemahq/contracts 0.31.0 → 0.33.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 (130) hide show
  1. package/dist/.source-stamp.json +2 -2
  2. package/dist/authorization-facts/index.d.ts +6 -0
  3. package/dist/authorization-facts/index.d.ts.map +1 -0
  4. package/dist/authorization-facts/index.js +22 -0
  5. package/dist/authorization-facts/index.js.map +1 -0
  6. package/dist/authorization-facts/lib/fact-tuple.d.ts +38 -0
  7. package/dist/authorization-facts/lib/fact-tuple.d.ts.map +1 -0
  8. package/dist/authorization-facts/lib/fact-tuple.js +48 -0
  9. package/dist/authorization-facts/lib/fact-tuple.js.map +1 -0
  10. package/dist/authorization-facts/lib/facts-apply.d.ts +244 -0
  11. package/dist/authorization-facts/lib/facts-apply.d.ts.map +1 -0
  12. package/dist/authorization-facts/lib/facts-apply.js +141 -0
  13. package/dist/authorization-facts/lib/facts-apply.js.map +1 -0
  14. package/dist/authorization-facts/lib/facts-snapshot.d.ts +70 -0
  15. package/dist/authorization-facts/lib/facts-snapshot.d.ts.map +1 -0
  16. package/dist/authorization-facts/lib/facts-snapshot.js +39 -0
  17. package/dist/authorization-facts/lib/facts-snapshot.js.map +1 -0
  18. package/dist/authorization-facts/lib/facts-writer-authority.d.ts +15 -0
  19. package/dist/authorization-facts/lib/facts-writer-authority.d.ts.map +1 -0
  20. package/dist/authorization-facts/lib/facts-writer-authority.js +55 -0
  21. package/dist/authorization-facts/lib/facts-writer-authority.js.map +1 -0
  22. package/dist/authorization-facts/lib/revoke-intent.d.ts +23 -0
  23. package/dist/authorization-facts/lib/revoke-intent.d.ts.map +1 -0
  24. package/dist/authorization-facts/lib/revoke-intent.js +37 -0
  25. package/dist/authorization-facts/lib/revoke-intent.js.map +1 -0
  26. package/dist/authorization-module/index.d.ts +6 -0
  27. package/dist/authorization-module/index.d.ts.map +1 -0
  28. package/dist/authorization-module/index.js +22 -0
  29. package/dist/authorization-module/index.js.map +1 -0
  30. package/dist/authorization-module/lib/authorization-composition-error.d.ts +45 -0
  31. package/dist/authorization-module/lib/authorization-composition-error.d.ts.map +1 -0
  32. package/dist/authorization-module/lib/authorization-composition-error.js +52 -0
  33. package/dist/authorization-module/lib/authorization-composition-error.js.map +1 -0
  34. package/dist/authorization-module/lib/authorization-module-contribution.d.ts +143 -0
  35. package/dist/authorization-module/lib/authorization-module-contribution.d.ts.map +1 -0
  36. package/dist/authorization-module/lib/authorization-module-contribution.js +111 -0
  37. package/dist/authorization-module/lib/authorization-module-contribution.js.map +1 -0
  38. package/dist/authorization-module/lib/authorization-module-envelope.d.ts +116 -0
  39. package/dist/authorization-module/lib/authorization-module-envelope.d.ts.map +1 -0
  40. package/dist/authorization-module/lib/authorization-module-envelope.js +104 -0
  41. package/dist/authorization-module/lib/authorization-module-envelope.js.map +1 -0
  42. package/dist/authorization-module/lib/authorization-namespace.d.ts +23 -0
  43. package/dist/authorization-module/lib/authorization-namespace.d.ts.map +1 -0
  44. package/dist/authorization-module/lib/authorization-namespace.js +82 -0
  45. package/dist/authorization-module/lib/authorization-namespace.js.map +1 -0
  46. package/dist/authorization-module/lib/platform-authorization-modules.d.ts +17 -0
  47. package/dist/authorization-module/lib/platform-authorization-modules.d.ts.map +1 -0
  48. package/dist/authorization-module/lib/platform-authorization-modules.js +46 -0
  49. package/dist/authorization-module/lib/platform-authorization-modules.js.map +1 -0
  50. package/dist/authorization-module/platform/xema_capability.fga +23 -0
  51. package/dist/authorization-module/platform/xema_capability.fga.yaml +108 -0
  52. package/dist/authorization-module/platform/xema_core.fga +81 -0
  53. package/dist/authorization-module/platform/xema_core.fga.yaml +121 -0
  54. package/dist/authorization-module/platform/xema_sharing.fga +113 -0
  55. package/dist/authorization-module/platform/xema_sharing.fga.yaml +67 -0
  56. package/dist/authorization-module/server/authorization-compatibility.d.ts +16 -0
  57. package/dist/authorization-module/server/authorization-compatibility.d.ts.map +1 -0
  58. package/dist/authorization-module/server/authorization-compatibility.js +94 -0
  59. package/dist/authorization-module/server/authorization-compatibility.js.map +1 -0
  60. package/dist/authorization-module/server/authorization-model-json.d.ts +65 -0
  61. package/dist/authorization-module/server/authorization-model-json.d.ts.map +1 -0
  62. package/dist/authorization-module/server/authorization-model-json.js +21 -0
  63. package/dist/authorization-module/server/authorization-model-json.js.map +1 -0
  64. package/dist/authorization-module/server/compose-authorization-base.d.ts +67 -0
  65. package/dist/authorization-module/server/compose-authorization-base.d.ts.map +1 -0
  66. package/dist/authorization-module/server/compose-authorization-base.js +511 -0
  67. package/dist/authorization-module/server/compose-authorization-base.js.map +1 -0
  68. package/dist/authorization-module/server/index.d.ts +5 -0
  69. package/dist/authorization-module/server/index.d.ts.map +1 -0
  70. package/dist/authorization-module/server/index.js +21 -0
  71. package/dist/authorization-module/server/index.js.map +1 -0
  72. package/dist/authorization-module/server/platform-module-files.d.ts +16 -0
  73. package/dist/authorization-module/server/platform-module-files.d.ts.map +1 -0
  74. package/dist/authorization-module/server/platform-module-files.js +42 -0
  75. package/dist/authorization-module/server/platform-module-files.js.map +1 -0
  76. package/dist/authzen/index.d.ts +7 -0
  77. package/dist/authzen/index.d.ts.map +1 -0
  78. package/dist/authzen/index.js +23 -0
  79. package/dist/authzen/index.js.map +1 -0
  80. package/dist/authzen/lib/authzen-entities.d.ts +40 -0
  81. package/dist/authzen/lib/authzen-entities.d.ts.map +1 -0
  82. package/dist/authzen/lib/authzen-entities.js +48 -0
  83. package/dist/authzen/lib/authzen-entities.js.map +1 -0
  84. package/dist/authzen/lib/authzen-evaluation.d.ts +101 -0
  85. package/dist/authzen/lib/authzen-evaluation.d.ts.map +1 -0
  86. package/dist/authzen/lib/authzen-evaluation.js +103 -0
  87. package/dist/authzen/lib/authzen-evaluation.js.map +1 -0
  88. package/dist/authzen/lib/authzen-metadata.d.ts +25 -0
  89. package/dist/authzen/lib/authzen-metadata.d.ts.map +1 -0
  90. package/dist/authzen/lib/authzen-metadata.js +54 -0
  91. package/dist/authzen/lib/authzen-metadata.js.map +1 -0
  92. package/dist/authzen/lib/authzen-search.d.ts +135 -0
  93. package/dist/authzen/lib/authzen-search.d.ts.map +1 -0
  94. package/dist/authzen/lib/authzen-search.js +89 -0
  95. package/dist/authzen/lib/authzen-search.js.map +1 -0
  96. package/dist/authzen/lib/authzen-snapshot.d.ts +47 -0
  97. package/dist/authzen/lib/authzen-snapshot.d.ts.map +1 -0
  98. package/dist/authzen/lib/authzen-snapshot.js +96 -0
  99. package/dist/authzen/lib/authzen-snapshot.js.map +1 -0
  100. package/dist/authzen/lib/xema-authzen-profile.d.ts +155 -0
  101. package/dist/authzen/lib/xema-authzen-profile.d.ts.map +1 -0
  102. package/dist/authzen/lib/xema-authzen-profile.js +152 -0
  103. package/dist/authzen/lib/xema-authzen-profile.js.map +1 -0
  104. package/dist/contribution/lib/contribution-kind.d.ts +1 -0
  105. package/dist/contribution/lib/contribution-kind.d.ts.map +1 -1
  106. package/dist/contribution/lib/contribution-kind.js +1 -0
  107. package/dist/contribution/lib/contribution-kind.js.map +1 -1
  108. package/dist/http/lib/problem-definition.d.ts +30 -11
  109. package/dist/http/lib/problem-definition.d.ts.map +1 -1
  110. package/dist/http/lib/problem-definition.js +33 -14
  111. package/dist/http/lib/problem-definition.js.map +1 -1
  112. package/dist/http/lib/problem-details.d.ts +1 -0
  113. package/dist/http/lib/problem-details.d.ts.map +1 -1
  114. package/dist/http/lib/problem-details.js +9 -3
  115. package/dist/http/lib/problem-details.js.map +1 -1
  116. package/dist/platform-generation/index.d.ts +2 -0
  117. package/dist/platform-generation/index.d.ts.map +1 -0
  118. package/dist/platform-generation/index.js +18 -0
  119. package/dist/platform-generation/index.js.map +1 -0
  120. package/dist/platform-generation/lib/platform-generation.d.ts +20 -0
  121. package/dist/platform-generation/lib/platform-generation.d.ts.map +1 -0
  122. package/dist/platform-generation/lib/platform-generation.js +77 -0
  123. package/dist/platform-generation/lib/platform-generation.js.map +1 -0
  124. package/dist/resource/lib/resource-kind-descriptor.d.ts.map +1 -1
  125. package/dist/resource/lib/resource-kind-descriptor.js.map +1 -1
  126. package/dist/resource/lib/resource-kind-registry.d.ts.map +1 -1
  127. package/dist/resource/lib/resource-kind-registry.js.map +1 -1
  128. package/dist/resource/lib/resource-ownership-contribution.d.ts.map +1 -1
  129. package/dist/resource/lib/resource-ownership-contribution.js.map +1 -1
  130. package/package.json +6 -4
@@ -0,0 +1,121 @@
1
+ # Standard OpenFGA tests (`fga model test`) for the xema_core platform module,
2
+ # run against the BASE composition (no biome module installed, so every
3
+ # parent slot is empty). `model_file` names the composed `fga.mod` the runner
4
+ # writes beside this file.
5
+ name: xema_core
6
+ model_file: ./fga.mod
7
+ tuples:
8
+ - user: org:org1
9
+ relation: parent
10
+ object: project:org1|p1
11
+ - user: user:bob
12
+ relation: viewer
13
+ object: project:org1|p1
14
+ - user: user:pat
15
+ relation: editor
16
+ object: project:org1|p1
17
+ - user: user:dave
18
+ relation: member
19
+ object: org:org1
20
+ - user: user:root
21
+ relation: admin
22
+ object: org:org1
23
+ - user: org:org2
24
+ relation: parent
25
+ object: xema_artifact:org2|a9
26
+ - user: project:org1|p1
27
+ relation: parent
28
+ object: xema_artifact:org1|a1
29
+ - user: org:org1
30
+ relation: parent
31
+ object: xema_artifact:org1|a2
32
+ - user: user:carol
33
+ relation: owner
34
+ object: xema_artifact:org1|a2
35
+ - user: project:org1|p1
36
+ relation: parent
37
+ object: xema_session:org1|s1
38
+ - user: user:erin
39
+ relation: participant
40
+ object: xema_session:org1|s1
41
+ - user: xema_session:org1|s1
42
+ relation: parent
43
+ object: xema_artifact:org1|a3
44
+ tests:
45
+ - name: an artifact inherits from its project, never copied
46
+ check:
47
+ - user: user:bob
48
+ object: xema_artifact:org1|a1
49
+ assertions:
50
+ can_read: true
51
+ can_write: false
52
+ can_delete: false
53
+ - user: user:pat
54
+ object: xema_artifact:org1|a1
55
+ assertions:
56
+ can_read: true
57
+ can_write: true
58
+ can_delete: false
59
+ list_objects:
60
+ - user: user:bob
61
+ type: xema_artifact
62
+ assertions:
63
+ can_read:
64
+ - xema_artifact:org1|a1
65
+ - xema_artifact:org1|a3
66
+ - name: org membership grants nothing by itself (default deny)
67
+ check:
68
+ - user: user:dave
69
+ object: xema_artifact:org1|a1
70
+ assertions:
71
+ can_read: false
72
+ - user: user:dave
73
+ object: xema_artifact:org1|a2
74
+ assertions:
75
+ can_read: false
76
+ - user: user:dave
77
+ object: project:org1|p1
78
+ assertions:
79
+ xema_read: false
80
+ # The PDP supplies `org#admin` as a CONTEXTUAL tuple derived per request
81
+ # (D2); `fga model test` has no contextual tuples, so the fact is stated as
82
+ # a fixture tuple here — the model's semantics given the fact are the same.
83
+ - name: the org admin (Super User) reaches every object parented under the org
84
+ check:
85
+ - user: user:root
86
+ object: xema_artifact:org1|a1
87
+ assertions:
88
+ can_read: true
89
+ can_write: true
90
+ can_delete: true
91
+ - user: user:root
92
+ object: xema_artifact:org1|a3
93
+ assertions:
94
+ can_read: true
95
+ - user: user:root
96
+ object: xema_artifact:org2|a9
97
+ assertions:
98
+ can_read: false
99
+ - name: an org-parented object admits only its owner and the org admin
100
+ check:
101
+ - user: user:carol
102
+ object: xema_artifact:org1|a2
103
+ assertions:
104
+ can_read: true
105
+ can_delete: true
106
+ - user: user:bob
107
+ object: xema_artifact:org1|a2
108
+ assertions:
109
+ can_read: false
110
+ - name: a session participant reads the session's artifacts and writes none
111
+ check:
112
+ - user: user:erin
113
+ object: xema_artifact:org1|a3
114
+ assertions:
115
+ can_read: true
116
+ can_write: false
117
+ - user: user:bob
118
+ object: xema_artifact:org1|a3
119
+ assertions:
120
+ can_read: true
121
+ can_write: false
@@ -0,0 +1,113 @@
1
+ module xema_sharing
2
+
3
+ # ═══════════════════════════════════════════════════════════════════════════
4
+ # xema_sharing — the first-party resource kinds as ordinary types.
5
+ #
6
+ # Replaces the generic `type resource` and its ordinal `shared_l1..l3` slots:
7
+ # each kind is its own type, so its relation set is visible in the model.
8
+ # The ladder is owner ⊂ manager ⊂ editor ⊂ viewer (each including the next).
9
+ #
10
+ # The three former visibility patterns become WHICH TUPLES EXIST:
11
+ # owner-only — owner tuples only;
12
+ # org-shared — an `org_viewer` tuple to `org:<id>#member`;
13
+ # explicit-share — named manager / editor / viewer tuples.
14
+ # Nothing short-circuits: org-shared is a tuple, read and revocable.
15
+ #
16
+ # A share may EXPIRE: `xema_share_not_expired` is evaluated against
17
+ # `current_time`, which the PDP supplies on every check — no sweeper.
18
+ #
19
+ # `project` is not here: it is an inheriting `xema_core` type and its
20
+ # sharing relations (viewer/editor/admin) live there.
21
+ # ═══════════════════════════════════════════════════════════════════════════
22
+
23
+ type xema_document
24
+ relations
25
+ define owner: [user, agent, service, external-subject, team#member, role#assignee]
26
+ define manager: [user, user with xema_share_not_expired, agent, agent with xema_share_not_expired, external-subject, external-subject with xema_share_not_expired, team#member, team#member with xema_share_not_expired, role#assignee, role#assignee with xema_share_not_expired] or owner
27
+ define editor: [user, user with xema_share_not_expired, agent, agent with xema_share_not_expired, external-subject, external-subject with xema_share_not_expired, team#member, team#member with xema_share_not_expired, role#assignee, role#assignee with xema_share_not_expired] or manager
28
+ define viewer: [user, user with xema_share_not_expired, agent, agent with xema_share_not_expired, external-subject, external-subject with xema_share_not_expired, team#member, team#member with xema_share_not_expired, role#assignee, role#assignee with xema_share_not_expired] or editor
29
+ define org_viewer: [org#member]
30
+ define can_manage: manager
31
+ define can_edit: editor
32
+ define can_view: viewer or org_viewer
33
+
34
+ type xema_mailbox
35
+ relations
36
+ define owner: [user, agent, service, external-subject, team#member, role#assignee]
37
+ define manager: [user, user with xema_share_not_expired, agent, agent with xema_share_not_expired, external-subject, external-subject with xema_share_not_expired, team#member, team#member with xema_share_not_expired, role#assignee, role#assignee with xema_share_not_expired] or owner
38
+ define editor: [user, user with xema_share_not_expired, agent, agent with xema_share_not_expired, external-subject, external-subject with xema_share_not_expired, team#member, team#member with xema_share_not_expired, role#assignee, role#assignee with xema_share_not_expired] or manager
39
+ define viewer: [user, user with xema_share_not_expired, agent, agent with xema_share_not_expired, external-subject, external-subject with xema_share_not_expired, team#member, team#member with xema_share_not_expired, role#assignee, role#assignee with xema_share_not_expired] or editor
40
+ define org_viewer: [org#member]
41
+ define can_manage: manager
42
+ define can_edit: editor
43
+ define can_view: viewer or org_viewer
44
+
45
+ type xema_portal
46
+ relations
47
+ define owner: [user, agent, service, external-subject, team#member, role#assignee]
48
+ define manager: [user, user with xema_share_not_expired, agent, agent with xema_share_not_expired, external-subject, external-subject with xema_share_not_expired, team#member, team#member with xema_share_not_expired, role#assignee, role#assignee with xema_share_not_expired] or owner
49
+ define editor: [user, user with xema_share_not_expired, agent, agent with xema_share_not_expired, external-subject, external-subject with xema_share_not_expired, team#member, team#member with xema_share_not_expired, role#assignee, role#assignee with xema_share_not_expired] or manager
50
+ define viewer: [user, user with xema_share_not_expired, agent, agent with xema_share_not_expired, external-subject, external-subject with xema_share_not_expired, team#member, team#member with xema_share_not_expired, role#assignee, role#assignee with xema_share_not_expired] or editor
51
+ define org_viewer: [org#member]
52
+ define can_manage: manager
53
+ define can_edit: editor
54
+ define can_view: viewer or org_viewer
55
+
56
+ type xema_connector-migration
57
+ relations
58
+ define owner: [user, agent, service, external-subject, team#member, role#assignee]
59
+ define manager: [user, user with xema_share_not_expired, agent, agent with xema_share_not_expired, external-subject, external-subject with xema_share_not_expired, team#member, team#member with xema_share_not_expired, role#assignee, role#assignee with xema_share_not_expired] or owner
60
+ define editor: [user, user with xema_share_not_expired, agent, agent with xema_share_not_expired, external-subject, external-subject with xema_share_not_expired, team#member, team#member with xema_share_not_expired, role#assignee, role#assignee with xema_share_not_expired] or manager
61
+ define viewer: [user, user with xema_share_not_expired, agent, agent with xema_share_not_expired, external-subject, external-subject with xema_share_not_expired, team#member, team#member with xema_share_not_expired, role#assignee, role#assignee with xema_share_not_expired] or editor
62
+ define org_viewer: [org#member]
63
+ define can_manage: manager
64
+ define can_edit: editor
65
+ define can_view: viewer or org_viewer
66
+
67
+ type xema_store-listing
68
+ relations
69
+ define owner: [user, agent, service, external-subject, team#member, role#assignee]
70
+ define manager: [user, user with xema_share_not_expired, agent, agent with xema_share_not_expired, external-subject, external-subject with xema_share_not_expired, team#member, team#member with xema_share_not_expired, role#assignee, role#assignee with xema_share_not_expired] or owner
71
+ define editor: [user, user with xema_share_not_expired, agent, agent with xema_share_not_expired, external-subject, external-subject with xema_share_not_expired, team#member, team#member with xema_share_not_expired, role#assignee, role#assignee with xema_share_not_expired] or manager
72
+ define viewer: [user, user with xema_share_not_expired, agent, agent with xema_share_not_expired, external-subject, external-subject with xema_share_not_expired, team#member, team#member with xema_share_not_expired, role#assignee, role#assignee with xema_share_not_expired] or editor
73
+ define org_viewer: [org#member]
74
+ define can_manage: manager
75
+ define can_edit: editor
76
+ define can_view: viewer or org_viewer
77
+
78
+ type xema_biome-lifecycle-approval
79
+ relations
80
+ define owner: [user, agent, service, external-subject, team#member, role#assignee]
81
+ define manager: [user, user with xema_share_not_expired, agent, agent with xema_share_not_expired, external-subject, external-subject with xema_share_not_expired, team#member, team#member with xema_share_not_expired, role#assignee, role#assignee with xema_share_not_expired] or owner
82
+ define editor: [user, user with xema_share_not_expired, agent, agent with xema_share_not_expired, external-subject, external-subject with xema_share_not_expired, team#member, team#member with xema_share_not_expired, role#assignee, role#assignee with xema_share_not_expired] or manager
83
+ define viewer: [user, user with xema_share_not_expired, agent, agent with xema_share_not_expired, external-subject, external-subject with xema_share_not_expired, team#member, team#member with xema_share_not_expired, role#assignee, role#assignee with xema_share_not_expired] or editor
84
+ define org_viewer: [org#member]
85
+ define can_manage: manager
86
+ define can_edit: editor
87
+ define can_view: viewer or org_viewer
88
+
89
+ type xema_memory
90
+ relations
91
+ define owner: [user, agent, service, external-subject, team#member, role#assignee]
92
+ define manager: [user, user with xema_share_not_expired, agent, agent with xema_share_not_expired, external-subject, external-subject with xema_share_not_expired, team#member, team#member with xema_share_not_expired, role#assignee, role#assignee with xema_share_not_expired] or owner
93
+ define editor: [user, user with xema_share_not_expired, agent, agent with xema_share_not_expired, external-subject, external-subject with xema_share_not_expired, team#member, team#member with xema_share_not_expired, role#assignee, role#assignee with xema_share_not_expired] or manager
94
+ define viewer: [user, user with xema_share_not_expired, agent, agent with xema_share_not_expired, external-subject, external-subject with xema_share_not_expired, team#member, team#member with xema_share_not_expired, role#assignee, role#assignee with xema_share_not_expired] or editor
95
+ define org_viewer: [org#member]
96
+ define can_manage: manager
97
+ define can_edit: editor
98
+ define can_view: viewer or org_viewer
99
+
100
+ type xema_capability-grant
101
+ relations
102
+ define owner: [user, agent, service, external-subject, team#member, role#assignee]
103
+ define manager: [user, user with xema_share_not_expired, agent, agent with xema_share_not_expired, external-subject, external-subject with xema_share_not_expired, team#member, team#member with xema_share_not_expired, role#assignee, role#assignee with xema_share_not_expired] or owner
104
+ define editor: [user, user with xema_share_not_expired, agent, agent with xema_share_not_expired, external-subject, external-subject with xema_share_not_expired, team#member, team#member with xema_share_not_expired, role#assignee, role#assignee with xema_share_not_expired] or manager
105
+ define viewer: [user, user with xema_share_not_expired, agent, agent with xema_share_not_expired, external-subject, external-subject with xema_share_not_expired, team#member, team#member with xema_share_not_expired, role#assignee, role#assignee with xema_share_not_expired] or editor
106
+ define org_viewer: [org#member]
107
+ define can_manage: manager
108
+ define can_edit: editor
109
+ define can_view: viewer or org_viewer
110
+
111
+ condition xema_share_not_expired(current_time: timestamp, expires_at: timestamp) {
112
+ current_time < expires_at
113
+ }
@@ -0,0 +1,67 @@
1
+ # Standard OpenFGA tests (`fga model test`) for the xema_sharing platform
2
+ # module, run against the BASE composition.
3
+ name: xema_sharing
4
+ model_file: ./fga.mod
5
+ tuples:
6
+ - user: user:alice
7
+ relation: owner
8
+ object: xema_document:org1|d1
9
+ - user: user:bob
10
+ relation: viewer
11
+ object: xema_document:org1|d1
12
+ - user: user:eve
13
+ relation: editor
14
+ object: xema_document:org1|d1
15
+ condition:
16
+ name: xema_share_not_expired
17
+ context:
18
+ expires_at: "2030-01-01T00:00:00Z"
19
+ - user: user:dave
20
+ relation: member
21
+ object: org:org1
22
+ - user: org:org1#member
23
+ relation: org_viewer
24
+ object: xema_document:org1|d2
25
+ - user: user:alice
26
+ relation: owner
27
+ object: xema_document:org1|d2
28
+ tests:
29
+ - name: the ladder — each level includes the next
30
+ check:
31
+ - user: user:alice
32
+ object: xema_document:org1|d1
33
+ assertions:
34
+ can_manage: true
35
+ can_edit: true
36
+ can_view: true
37
+ - user: user:bob
38
+ object: xema_document:org1|d1
39
+ assertions:
40
+ can_manage: false
41
+ can_edit: false
42
+ can_view: true
43
+ - name: a share expires in the authority, not by a sweeper
44
+ check:
45
+ - user: user:eve
46
+ object: xema_document:org1|d1
47
+ context:
48
+ current_time: "2029-12-31T23:59:59Z"
49
+ assertions:
50
+ can_edit: true
51
+ - user: user:eve
52
+ object: xema_document:org1|d1
53
+ context:
54
+ current_time: "2030-01-01T00:00:01Z"
55
+ assertions:
56
+ can_edit: false
57
+ - name: org-shared is a tuple, owner-only is the absence of one
58
+ check:
59
+ - user: user:dave
60
+ object: xema_document:org1|d2
61
+ assertions:
62
+ can_view: true
63
+ can_edit: false
64
+ - user: user:dave
65
+ object: xema_document:org1|d1
66
+ assertions:
67
+ can_view: false
@@ -0,0 +1,16 @@
1
+ import { type AuthorizationMigrationStep } from '../lib/authorization-module-envelope';
2
+ import { type FgaAuthorizationModel } from './authorization-model-json';
3
+ export interface AssignableSurfaceChange {
4
+ readonly step: AuthorizationMigrationStep;
5
+ readonly namespace: string | null;
6
+ }
7
+ export declare function diffAuthorizationAssignableSurface(adopted: FgaAuthorizationModel, next: FgaAuthorizationModel, namespaceOf: (type: string) => string | null): AssignableSurfaceChange[];
8
+ export declare function migrationStepCovers(declared: AuthorizationMigrationStep, observed: AuthorizationMigrationStep): boolean;
9
+ export interface AuthorizationForwardMigrationHook {
10
+ readonly namespace: string;
11
+ readonly fromModuleVersion: number;
12
+ readonly toModuleVersion: number;
13
+ readonly steps: readonly AuthorizationMigrationStep[];
14
+ }
15
+ export type AuthorizationForwardMigrationExecutor = (hook: AuthorizationForwardMigrationHook) => Promise<void>;
16
+ //# sourceMappingURL=authorization-compatibility.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorization-compatibility.d.ts","sourceRoot":"","sources":["../../../src/authorization-module/server/authorization-compatibility.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,0BAA0B,EAChC,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,4BAA4B,CAAC;AAYpC,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,IAAI,EAAE,0BAA0B,CAAC;IAE1C,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAwBD,wBAAgB,kCAAkC,CAChD,OAAO,EAAE,qBAAqB,EAC9B,IAAI,EAAE,qBAAqB,EAC3B,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,GAC3C,uBAAuB,EAAE,CA4C3B;AAOD,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,0BAA0B,EACpC,QAAQ,EAAE,0BAA0B,GACnC,OAAO,CAkCT;AASD,MAAM,WAAW,iCAAiC;IAChD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,SAAS,0BAA0B,EAAE,CAAC;CACvD;AAGD,MAAM,MAAM,qCAAqC,GAAG,CAClD,IAAI,EAAE,iCAAiC,KACpC,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.diffAuthorizationAssignableSurface = diffAuthorizationAssignableSurface;
4
+ exports.migrationStepCovers = migrationStepCovers;
5
+ const authorization_module_envelope_1 = require("../lib/authorization-module-envelope");
6
+ const authorization_model_json_1 = require("./authorization-model-json");
7
+ function assignableSurface(model) {
8
+ const surface = new Map();
9
+ for (const typeDefinition of model.type_definitions) {
10
+ const relations = new Map();
11
+ for (const relation of Object.keys(typeDefinition.relations ?? {})) {
12
+ const refs = (0, authorization_model_json_1.directlyRelatedTypes)(typeDefinition, relation);
13
+ if (refs.length > 0) {
14
+ relations.set(relation, new Set(refs.map(authorization_model_json_1.formatRelationReference)));
15
+ }
16
+ }
17
+ surface.set(typeDefinition.type, relations);
18
+ }
19
+ return surface;
20
+ }
21
+ function diffAuthorizationAssignableSurface(adopted, next, namespaceOf) {
22
+ const before = assignableSurface(adopted);
23
+ const after = assignableSurface(next);
24
+ const changes = [];
25
+ for (const type of [...before.keys()].sort()) {
26
+ const namespace = namespaceOf(type);
27
+ const beforeRelations = before.get(type);
28
+ const afterRelations = after.get(type);
29
+ if (afterRelations === undefined) {
30
+ changes.push({
31
+ namespace,
32
+ step: { kind: authorization_module_envelope_1.AuthorizationMigrationStepKind.DropType, type },
33
+ });
34
+ continue;
35
+ }
36
+ for (const relation of [...beforeRelations.keys()].sort()) {
37
+ const was = beforeRelations.get(relation);
38
+ const now = afterRelations.get(relation);
39
+ if (now === undefined) {
40
+ changes.push({
41
+ namespace,
42
+ step: {
43
+ kind: authorization_module_envelope_1.AuthorizationMigrationStepKind.DropRelation,
44
+ type,
45
+ relation,
46
+ },
47
+ });
48
+ continue;
49
+ }
50
+ const removed = [...was].filter((entry) => !now.has(entry)).sort();
51
+ if (removed.length > 0) {
52
+ changes.push({
53
+ namespace,
54
+ step: {
55
+ kind: authorization_module_envelope_1.AuthorizationMigrationStepKind.NarrowRestriction,
56
+ type,
57
+ relation,
58
+ removed,
59
+ },
60
+ });
61
+ }
62
+ }
63
+ }
64
+ return changes;
65
+ }
66
+ function migrationStepCovers(declared, observed) {
67
+ switch (observed.kind) {
68
+ case authorization_module_envelope_1.AuthorizationMigrationStepKind.DropType:
69
+ return ((declared.kind === authorization_module_envelope_1.AuthorizationMigrationStepKind.DropType &&
70
+ declared.type === observed.type) ||
71
+ (declared.kind === authorization_module_envelope_1.AuthorizationMigrationStepKind.RenameType &&
72
+ declared.from === observed.type));
73
+ case authorization_module_envelope_1.AuthorizationMigrationStepKind.DropRelation:
74
+ return ((declared.kind === authorization_module_envelope_1.AuthorizationMigrationStepKind.DropRelation &&
75
+ declared.type === observed.type &&
76
+ declared.relation === observed.relation) ||
77
+ (declared.kind === authorization_module_envelope_1.AuthorizationMigrationStepKind.RenameRelation &&
78
+ declared.type === observed.type &&
79
+ declared.from === observed.relation) ||
80
+ (declared.kind === authorization_module_envelope_1.AuthorizationMigrationStepKind.DropType &&
81
+ declared.type === observed.type) ||
82
+ (declared.kind === authorization_module_envelope_1.AuthorizationMigrationStepKind.RenameType &&
83
+ declared.from === observed.type));
84
+ case authorization_module_envelope_1.AuthorizationMigrationStepKind.NarrowRestriction:
85
+ return (declared.kind === authorization_module_envelope_1.AuthorizationMigrationStepKind.NarrowRestriction &&
86
+ declared.type === observed.type &&
87
+ declared.relation === observed.relation &&
88
+ observed.removed.every((entry) => declared.removed.includes(entry)));
89
+ case authorization_module_envelope_1.AuthorizationMigrationStepKind.RenameType:
90
+ case authorization_module_envelope_1.AuthorizationMigrationStepKind.RenameRelation:
91
+ return false;
92
+ }
93
+ }
94
+ //# sourceMappingURL=authorization-compatibility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorization-compatibility.js","sourceRoot":"","sources":["../../../src/authorization-module/server/authorization-compatibility.ts"],"names":[],"mappings":";;AAiDA,gFAgDC;AAOD,kDAqCC;AA7ID,wFAG8C;AAE9C,yEAIoC;AAkBpC,SAAS,iBAAiB,CACxB,KAA4B;IAE5B,MAAM,OAAO,GAAG,IAAI,GAAG,EAAoC,CAAC;IAC5D,KAAK,MAAM,cAAc,IAAI,KAAK,CAAC,gBAAgB,EAAE,CAAC;QACpD,MAAM,SAAS,GAAG,IAAI,GAAG,EAAuB,CAAC;QACjD,KAAK,MAAM,QAAQ,IAAI,MAAM,C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 readonly wildcard?: Record<string, never>;
8
+ readonly condition?: string;
9
+ }
10
+ export interface FgaRelationMetadata {
11
+ readonly directly_related_user_types?: readonly FgaRelationReference[];
12
+ readonly module?: string;
13
+ readonly source_info?: FgaSourceInfo;
14
+ }
15
+ export interface FgaUserset {
16
+ readonly this?: Record<string, never>;
17
+ readonly computedUserset?: {
18
+ readonly relation?: string;
19
+ };
20
+ readonly tupleToUserset?: {
21
+ readonly tupleset: {
22
+ readonly relation?: string;
23
+ };
24
+ readonly computedUserset: {
25
+ readonly relation?: string;
26
+ };
27
+ };
28
+ readonly union?: {
29
+ readonly child: readonly FgaUserset[];
30
+ };
31
+ readonly intersection?: {
32
+ readonly child: readonly FgaUserset[];
33
+ };
34
+ readonly difference?: {
35
+ readonly base: FgaUserset;
36
+ readonly subtract: FgaUserset;
37
+ };
38
+ }
39
+ export interface FgaTypeDefinition {
40
+ readonly type: string;
41
+ readonly relations?: Readonly<Record<string, FgaUserset>>;
42
+ readonly metadata?: {
43
+ readonly relations?: Readonly<Record<string, FgaRelationMetadata>>;
44
+ readonly module?: string;
45
+ readonly source_info?: FgaSourceInfo;
46
+ } | null;
47
+ }
48
+ export interface FgaCondition {
49
+ readonly name: string;
50
+ readonly expression: string;
51
+ readonly parameters?: Readonly<Record<string, unknown>>;
52
+ readonly metadata?: {
53
+ readonly module?: string;
54
+ readonly source_info?: FgaSourceInfo;
55
+ };
56
+ }
57
+ export interface FgaAuthorizationModel {
58
+ readonly schema_version: string;
59
+ readonly type_definitions: readonly FgaTypeDefinition[];
60
+ readonly conditions?: Readonly<Record<string, FgaCondition>>;
61
+ }
62
+ export declare const FGA_MODULAR_SCHEMA_VERSION = "1.2";
63
+ export declare function directlyRelatedTypes(typeDefinition: FgaTypeDefinition, relation: string): readonly FgaRelationReference[];
64
+ export declare function formatRelationReference(ref: FgaRelationReference): string;
65
+ //# sourceMappingURL=authorization-model-json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorization-model-json.d.ts","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;AAMhD,wBAAgB,oBAAoB,CAClC,cAAc,EAAE,iBAAiB,EACjC,QAAQ,EAAE,MAAM,GACf,SAAS,oBAAoB,EAAE,CAKjC;AAGD,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,oBAAoB,GAAG,MAAM,CAUzE"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FGA_MODULAR_SCHEMA_VERSION = void 0;
4
+ exports.directlyRelatedTypes = directlyRelatedTypes;
5
+ exports.formatRelationReference = formatRelationReference;
6
+ exports.FGA_MODULAR_SCHEMA_VERSION = '1.2';
7
+ function directlyRelatedTypes(typeDefinition, relation) {
8
+ return (typeDefinition.metadata?.relations?.[relation]
9
+ ?.directly_related_user_types ?? []);
10
+ }
11
+ function formatRelationReference(ref) {
12
+ const base = ref.wildcard !== undefined
13
+ ? `${ref.type}:*`
14
+ : ref.relation !== undefined
15
+ ? `${ref.type}#${ref.relation}`
16
+ : ref.type;
17
+ return ref.condition !== undefined && ref.condition !== ''
18
+ ? `${base} with ${ref.condition}`
19
+ : base;
20
+ }
21
+ //# sourceMappingURL=authorization-model-json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorization-model-json.js","sourceRoot":"","sources":["../../../src/authorization-module/server/authorization-model-json.ts"],"names":[],"mappings":";;;AAwEA,oDAQC;AAGD,0DAUC;AA3BY,QAAA,0BAA0B,GAAG,KAAK,CAAC;AAMhD,SAAgB,oBAAoB,CAClC,cAAiC,EACjC,QAAgB;IAEhB,OAAO,CACL,cAAc,CAAC,QAAQ,EAAE,SAAS,EAAE,CAAC,QAAQ,CAAC;QAC5C,EAAE,2BAA2B,IAAI,EAAE,CACtC,CAAC;AACJ,CAAC;AAGD,SAAgB,uBAAuB,CAAC,GAAyB;IAC/D,MAAM,IAAI,GACR,GAAG,CAAC,QAAQ,KAAK,SAAS;QACxB,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,IAAI;QACjB,CAAC,CAAC,GAAG,CAAC,QAAQ,KAAK,SAAS;YAC1B,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,QAAQ,EAAE;YAC/B,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC;IACjB,OAAO,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI,GAAG,CAAC,SAAS,KAAK,EAAE;QACxD,CAAC,CAAC,GAAG,IAAI,SAAS,GAAG,CAAC,SAAS,EAAE;QACjC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC"}
@@ -0,0 +1,67 @@
1
+ import { type AssignableSurfaceChange, type AuthorizationForwardMigrationHook } from './authorization-compatibility';
2
+ import { type FgaAuthorizationModel } from './authorization-model-json';
3
+ import { type PlatformAuthorizationModuleFiles } from './platform-module-files';
4
+ export interface AuthorizationModuleInput {
5
+ readonly signedBiomeId: string;
6
+ readonly signedBiomeVersion: string;
7
+ readonly manifest: unknown;
8
+ }
9
+ export declare function authorizationModuleInputFromContribution(contribution: {
10
+ readonly owner: {
11
+ readonly id: string;
12
+ readonly version: string;
13
+ };
14
+ readonly manifest: unknown;
15
+ }): AuthorizationModuleInput;
16
+ export interface AdoptedAuthorizationModule {
17
+ readonly moduleVersion: number;
18
+ readonly contentHash: string;
19
+ }
20
+ export interface AdoptedAuthorizationBase {
21
+ readonly model: FgaAuthorizationModel;
22
+ readonly modules: Readonly<Record<string, AdoptedAuthorizationModule>>;
23
+ }
24
+ export interface AuthorizationCompositionBudgets {
25
+ readonly maxModelBytes: number;
26
+ readonly maxTypeDefinitions: number;
27
+ }
28
+ export declare const DEFAULT_AUTHORIZATION_COMPOSITION_BUDGETS: AuthorizationCompositionBudgets;
29
+ export interface AuthorizationCompositionGovernance {
30
+ readonly admitUnconditionedPublicWildcards: boolean;
31
+ }
32
+ export declare const DEFAULT_AUTHORIZATION_COMPOSITION_GOVERNANCE: AuthorizationCompositionGovernance;
33
+ export interface ComposeAuthorizationBaseInput {
34
+ readonly modules: readonly AuthorizationModuleInput[];
35
+ readonly currentPlatformGeneration: string;
36
+ readonly adopted?: AdoptedAuthorizationBase;
37
+ readonly governance?: AuthorizationCompositionGovernance;
38
+ readonly budgets?: Partial<AuthorizationCompositionBudgets>;
39
+ readonly platformModules?: readonly PlatformAuthorizationModuleFiles[];
40
+ }
41
+ export interface ComposedFile {
42
+ readonly name: string;
43
+ readonly contents: string;
44
+ }
45
+ export interface ComposedAuthorizationModule {
46
+ readonly namespace: string;
47
+ readonly moduleVersion: number;
48
+ readonly contentHash: string;
49
+ readonly signedBiomeVersion: string;
50
+ }
51
+ export interface ComposedAuthorizationBase {
52
+ readonly model: FgaAuthorizationModel;
53
+ readonly modelHash: string;
54
+ readonly modelBytes: number;
55
+ readonly files: readonly ComposedFile[];
56
+ readonly testFiles: readonly (ComposedFile & {
57
+ readonly owner: string;
58
+ })[];
59
+ readonly modules: readonly ComposedAuthorizationModule[];
60
+ readonly parentImplementers: readonly string[];
61
+ readonly platformSurfaceChanges: readonly AssignableSurfaceChange[];
62
+ readonly removedNamespaces: readonly string[];
63
+ readonly migrationHooks: readonly AuthorizationForwardMigrationHook[];
64
+ }
65
+ export declare const FGA_MOD_FILE_NAME = "fga.mod";
66
+ export declare function composeAuthorizationBase(input: ComposeAuthorizationBaseInput): ComposedAuthorizationBase;
67
+ //# sourceMappingURL=compose-authorization-base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compose-authorization-base.d.ts","sourceRoot":"","sources":["../../../src/authorization-module/server/compose-authorization-base.ts"],"names":[],"mappings":"AA6BA,OAAO,EAGL,KAAK,uBAAuB,EAC5B,KAAK,iCAAiC,EACvC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAGL,KAAK,qBAAqB,EAE3B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAGL,KAAK,gCAAgC,EACtC,MAAM,yBAAyB,CAAC;AA0CjC,MAAM,WAAW,wBAAwB;IAEvC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAE/B,QA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