@xemahq/contracts 0.32.0 → 0.34.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 (126) 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 +46 -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 +53 -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 +19 -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 +48 -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 +82 -0
  53. package/dist/authorization-module/platform/xema_core.fga.yaml +123 -0
  54. package/dist/authorization-module/platform/xema_sharing.fga +138 -0
  55. package/dist/authorization-module/platform/xema_sharing.fga.yaml +112 -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 +520 -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/biome/lib/biome-generated-index.d.ts +1 -0
  105. package/dist/biome/lib/biome-generated-index.d.ts.map +1 -1
  106. package/dist/biome/lib/biome-generated-index.js +2 -0
  107. package/dist/biome/lib/biome-generated-index.js.map +1 -1
  108. package/dist/contribution/lib/contribution-kind.d.ts +1 -0
  109. package/dist/contribution/lib/contribution-kind.d.ts.map +1 -1
  110. package/dist/contribution/lib/contribution-kind.js +1 -0
  111. package/dist/contribution/lib/contribution-kind.js.map +1 -1
  112. package/dist/platform-generation/index.d.ts +2 -0
  113. package/dist/platform-generation/index.d.ts.map +1 -0
  114. package/dist/platform-generation/index.js +18 -0
  115. package/dist/platform-generation/index.js.map +1 -0
  116. package/dist/platform-generation/lib/platform-generation.d.ts +20 -0
  117. package/dist/platform-generation/lib/platform-generation.d.ts.map +1 -0
  118. package/dist/platform-generation/lib/platform-generation.js +77 -0
  119. package/dist/platform-generation/lib/platform-generation.js.map +1 -0
  120. package/dist/resource/lib/resource-kind-descriptor.d.ts.map +1 -1
  121. package/dist/resource/lib/resource-kind-descriptor.js.map +1 -1
  122. package/dist/resource/lib/resource-kind-registry.d.ts.map +1 -1
  123. package/dist/resource/lib/resource-kind-registry.js.map +1 -1
  124. package/dist/resource/lib/resource-ownership-contribution.d.ts.map +1 -1
  125. package/dist/resource/lib/resource-ownership-contribution.js.map +1 -1
  126. package/package.json +6 -4
@@ -0,0 +1,123 @@
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
+ xema_read: true
52
+ can_write: false
53
+ can_delete: false
54
+ - user: user:pat
55
+ object: xema_artifact:org1|a1
56
+ assertions:
57
+ can_read: true
58
+ can_write: true
59
+ can_delete: false
60
+ list_objects:
61
+ - user: user:bob
62
+ type: xema_artifact
63
+ assertions:
64
+ can_read:
65
+ - xema_artifact:org1|a1
66
+ - xema_artifact:org1|a3
67
+ - name: org membership grants nothing by itself (default deny)
68
+ check:
69
+ - user: user:dave
70
+ object: xema_artifact:org1|a1
71
+ assertions:
72
+ can_read: false
73
+ xema_read: false
74
+ - user: user:dave
75
+ object: xema_artifact:org1|a2
76
+ assertions:
77
+ can_read: false
78
+ - user: user:dave
79
+ object: project:org1|p1
80
+ assertions:
81
+ xema_read: false
82
+ # The PDP supplies `org#admin` as a CONTEXTUAL tuple derived per request
83
+ # (D2); `fga model test` has no contextual tuples, so the fact is stated as
84
+ # a fixture tuple here — the model's semantics given the fact are the same.
85
+ - name: the org admin (Super User) reaches every object parented under the org
86
+ check:
87
+ - user: user:root
88
+ object: xema_artifact:org1|a1
89
+ assertions:
90
+ can_read: true
91
+ can_write: true
92
+ can_delete: true
93
+ - user: user:root
94
+ object: xema_artifact:org1|a3
95
+ assertions:
96
+ can_read: true
97
+ - user: user:root
98
+ object: xema_artifact:org2|a9
99
+ assertions:
100
+ can_read: false
101
+ - name: an org-parented object admits only its owner and the org admin
102
+ check:
103
+ - user: user:carol
104
+ object: xema_artifact:org1|a2
105
+ assertions:
106
+ can_read: true
107
+ can_delete: true
108
+ - user: user:bob
109
+ object: xema_artifact:org1|a2
110
+ assertions:
111
+ can_read: false
112
+ - name: a session participant reads the session's artifacts and writes none
113
+ check:
114
+ - user: user:erin
115
+ object: xema_artifact:org1|a3
116
+ assertions:
117
+ can_read: true
118
+ can_write: false
119
+ - user: user:bob
120
+ object: xema_artifact:org1|a3
121
+ assertions:
122
+ can_read: true
123
+ can_write: false
@@ -0,0 +1,138 @@
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
+ # ONE READ VERB: every type defines `xema_read` (= `can_view`), the same verb
20
+ # the inheriting `xema_core` types define, so the PDP asks one question for
21
+ # "may read" whatever the kind. The composer refuses a platform resource type
22
+ # without it.
23
+ #
24
+ # `project` is not here: it is an inheriting `xema_core` type and its
25
+ # sharing relations (viewer/editor/admin) live there.
26
+ # ═══════════════════════════════════════════════════════════════════════════
27
+
28
+ type xema_document
29
+ relations
30
+ define owner: [user, agent, service, external-subject, team#member, role#assignee]
31
+ 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
32
+ 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
33
+ 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
34
+ define org_viewer: [org#member]
35
+ define can_manage: manager
36
+ define can_edit: editor
37
+ define can_view: viewer or org_viewer
38
+ define xema_read: can_view
39
+
40
+ type xema_mailbox
41
+ relations
42
+ define owner: [user, agent, service, external-subject, team#member, role#assignee]
43
+ 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
44
+ 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
45
+ 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
46
+ define org_viewer: [org#member]
47
+ define can_manage: manager
48
+ define can_edit: editor
49
+ define can_view: viewer or org_viewer
50
+ define xema_read: can_view
51
+
52
+ type xema_portal
53
+ relations
54
+ define owner: [user, agent, service, external-subject, team#member, role#assignee]
55
+ 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
56
+ 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
57
+ 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
58
+ define org_viewer: [org#member]
59
+ define can_manage: manager
60
+ define can_edit: editor
61
+ define can_view: viewer or org_viewer
62
+ define xema_read: can_view
63
+
64
+ type xema_connector-migration
65
+ relations
66
+ define owner: [user, agent, service, external-subject, team#member, role#assignee]
67
+ 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
68
+ 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
69
+ 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
70
+ define org_viewer: [org#member]
71
+ define can_manage: manager
72
+ define can_edit: editor
73
+ define can_view: viewer or org_viewer
74
+ define xema_read: can_view
75
+
76
+ type xema_store-listing
77
+ relations
78
+ define owner: [user, agent, service, external-subject, team#member, role#assignee]
79
+ 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
80
+ 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
81
+ 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
82
+ define org_viewer: [org#member]
83
+ define can_manage: manager
84
+ define can_edit: editor
85
+ define can_view: viewer or org_viewer
86
+ define xema_read: can_view
87
+
88
+ type xema_biome-lifecycle-approval
89
+ relations
90
+ define owner: [user, agent, service, external-subject, team#member, role#assignee]
91
+ 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
92
+ 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
93
+ 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
94
+ define org_viewer: [org#member]
95
+ define can_manage: manager
96
+ define can_edit: editor
97
+ define can_view: viewer or org_viewer
98
+ define xema_read: can_view
99
+
100
+ type xema_memory
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
+ define xema_read: can_view
111
+
112
+ type xema_capability-grant
113
+ relations
114
+ define owner: [user, agent, service, external-subject, team#member, role#assignee]
115
+ 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
116
+ 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
117
+ 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
118
+ define org_viewer: [org#member]
119
+ define can_manage: manager
120
+ define can_edit: editor
121
+ define can_view: viewer or org_viewer
122
+ define xema_read: can_view
123
+
124
+ type xema_output-route
125
+ relations
126
+ define owner: [user, agent, service, external-subject, team#member, role#assignee]
127
+ 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
128
+ 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
129
+ 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
130
+ define org_viewer: [org#member]
131
+ define can_manage: manager
132
+ define can_edit: editor
133
+ define can_view: viewer or org_viewer
134
+ define xema_read: can_view
135
+
136
+ condition xema_share_not_expired(current_time: timestamp, expires_at: timestamp) {
137
+ current_time < expires_at
138
+ }
@@ -0,0 +1,112 @@
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
+ - user: user:olga
29
+ relation: owner
30
+ object: xema_output-route:org1|r1
31
+ - user: team:ops#member
32
+ relation: viewer
33
+ object: xema_output-route:org1|r1
34
+ - user: user:tom
35
+ relation: direct_member
36
+ object: team:ops
37
+ tests:
38
+ - name: the ladder — each level includes the next
39
+ check:
40
+ - user: user:alice
41
+ object: xema_document:org1|d1
42
+ assertions:
43
+ can_manage: true
44
+ can_edit: true
45
+ can_view: true
46
+ - user: user:bob
47
+ object: xema_document:org1|d1
48
+ assertions:
49
+ can_manage: false
50
+ can_edit: false
51
+ can_view: true
52
+ - name: one read verb — xema_read answers exactly what can_view answers
53
+ check:
54
+ - user: user:bob
55
+ object: xema_document:org1|d1
56
+ assertions:
57
+ xema_read: true
58
+ - user: user:dave
59
+ object: xema_document:org1|d2
60
+ assertions:
61
+ xema_read: true
62
+ - user: user:dave
63
+ object: xema_document:org1|d1
64
+ assertions:
65
+ xema_read: false
66
+ - name: output routes share through the same ladder, team shares included
67
+ check:
68
+ - user: user:olga
69
+ object: xema_output-route:org1|r1
70
+ assertions:
71
+ can_manage: true
72
+ xema_read: true
73
+ - user: user:tom
74
+ object: xema_output-route:org1|r1
75
+ assertions:
76
+ xema_read: true
77
+ can_edit: false
78
+ - user: user:dave
79
+ object: xema_output-route:org1|r1
80
+ assertions:
81
+ xema_read: false
82
+ list_objects:
83
+ - user: user:tom
84
+ type: xema_output-route
85
+ assertions:
86
+ xema_read:
87
+ - xema_output-route:org1|r1
88
+ - name: a share expires in the authority, not by a sweeper
89
+ check:
90
+ - user: user:eve
91
+ object: xema_document:org1|d1
92
+ context:
93
+ current_time: "2029-12-31T23:59:59Z"
94
+ assertions:
95
+ can_edit: true
96
+ - user: user:eve
97
+ object: xema_document:org1|d1
98
+ context:
99
+ current_time: "2030-01-01T00:00:01Z"
100
+ assertions:
101
+ can_edit: false
102
+ - name: org-shared is a tuple, owner-only is the absence of one
103
+ check:
104
+ - user: user:dave
105
+ object: xema_document:org1|d2
106
+ assertions:
107
+ can_view: true
108
+ can_edit: false
109
+ - user: user:dave
110
+ object: xema_document:org1|d1
111
+ assertions:
112
+ 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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c;YAEhD,OAAO,KAAK,CAAC;IACjB,CAAC;AACH,CAAC"}
@@ -0,0 +1,65 @@
1
+ export interface FgaSourceInfo {
2
+ readonly file?: string;
3
+ }
4
+ export interface FgaRelationReference {
5
+ readonly type: string;
6
+ readonly relation?: string;
7
+ 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","sourceRoot":"","sources":["../../../src/authorization-module/server/authorization-model-json.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC1C,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,2BAA2B,CAAC,EAAE,SAAS,oBAAoB,EAAE,CAAC;IACvE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,CAAC,EAAE,aAAa,CAAC;CACtC;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACtC,QAAQ,CAAC,eAAe,CAAC,EAAE;QAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1D,QAAQ,CAAC,cAAc,CAAC,EAAE;QACxB,QAAQ,CAAC,QAAQ,EAAE;YAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;QAClD,QAAQ,CAAC,eAAe,EAAE;YAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;KAC1D,CAAC;IACF,QAAQ,CAAC,KAAK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,SAAS,iBAAiB,EAAE,CAAC;IACxD,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;CAC9D;AAGD,eAAO,MAAM,0BAA0B,QAAQ,CAAC;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