@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,116 @@
1
+ import { z } from 'zod';
2
+ export declare const AUTHORIZATION_MODULE_FILE_PATTERN: RegExp;
3
+ export declare const AUTHORIZATION_MODULE_TEST_FILE_PATTERN: RegExp;
4
+ export declare const AuthorizationModuleDependencySchema: z.ZodObject<{
5
+ biome: z.ZodString;
6
+ minModuleVersion: z.ZodNumber;
7
+ }, z.core.$strict>;
8
+ export type AuthorizationModuleDependency = z.infer<typeof AuthorizationModuleDependencySchema>;
9
+ export declare const AuthorizationSearchableSchema: z.ZodObject<{
10
+ anchor: z.ZodOptional<z.ZodString>;
11
+ highCardinality: z.ZodBoolean;
12
+ }, z.core.$strict>;
13
+ export type AuthorizationSearchable = z.infer<typeof AuthorizationSearchableSchema>;
14
+ export declare enum AuthorizationMigrationStepKind {
15
+ RenameType = "rename-type",
16
+ RenameRelation = "rename-relation",
17
+ DropType = "drop-type",
18
+ DropRelation = "drop-relation",
19
+ NarrowRestriction = "narrow-restriction"
20
+ }
21
+ export declare const AuthorizationMigrationStepSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
22
+ kind: z.ZodLiteral<AuthorizationMigrationStepKind.RenameType>;
23
+ from: z.ZodString;
24
+ to: z.ZodString;
25
+ }, z.core.$strict>, z.ZodObject<{
26
+ kind: z.ZodLiteral<AuthorizationMigrationStepKind.RenameRelation>;
27
+ type: z.ZodString;
28
+ from: z.ZodString;
29
+ to: z.ZodString;
30
+ }, z.core.$strict>, z.ZodObject<{
31
+ kind: z.ZodLiteral<AuthorizationMigrationStepKind.DropType>;
32
+ type: z.ZodString;
33
+ }, z.core.$strict>, z.ZodObject<{
34
+ kind: z.ZodLiteral<AuthorizationMigrationStepKind.DropRelation>;
35
+ type: z.ZodString;
36
+ relation: z.ZodString;
37
+ }, z.core.$strict>, z.ZodObject<{
38
+ kind: z.ZodLiteral<AuthorizationMigrationStepKind.NarrowRestriction>;
39
+ type: z.ZodString;
40
+ relation: z.ZodString;
41
+ removed: z.ZodArray<z.ZodString>;
42
+ }, z.core.$strict>], "kind">;
43
+ export type AuthorizationMigrationStep = z.infer<typeof AuthorizationMigrationStepSchema>;
44
+ export declare const AuthorizationModuleMigrationSchema: z.ZodObject<{
45
+ from: z.ZodNumber;
46
+ steps: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
47
+ kind: z.ZodLiteral<AuthorizationMigrationStepKind.RenameType>;
48
+ from: z.ZodString;
49
+ to: z.ZodString;
50
+ }, z.core.$strict>, z.ZodObject<{
51
+ kind: z.ZodLiteral<AuthorizationMigrationStepKind.RenameRelation>;
52
+ type: z.ZodString;
53
+ from: z.ZodString;
54
+ to: z.ZodString;
55
+ }, z.core.$strict>, z.ZodObject<{
56
+ kind: z.ZodLiteral<AuthorizationMigrationStepKind.DropType>;
57
+ type: z.ZodString;
58
+ }, z.core.$strict>, z.ZodObject<{
59
+ kind: z.ZodLiteral<AuthorizationMigrationStepKind.DropRelation>;
60
+ type: z.ZodString;
61
+ relation: z.ZodString;
62
+ }, z.core.$strict>, z.ZodObject<{
63
+ kind: z.ZodLiteral<AuthorizationMigrationStepKind.NarrowRestriction>;
64
+ type: z.ZodString;
65
+ relation: z.ZodString;
66
+ removed: z.ZodArray<z.ZodString>;
67
+ }, z.core.$strict>], "kind">>;
68
+ }, z.core.$strict>;
69
+ export type AuthorizationModuleMigration = z.infer<typeof AuthorizationModuleMigrationSchema>;
70
+ export declare const AuthorizationModuleEnvelopeSchema: z.ZodObject<{
71
+ namespace: z.ZodOptional<z.ZodString>;
72
+ moduleVersion: z.ZodNumber;
73
+ platformGeneration: z.ZodString;
74
+ files: z.ZodArray<z.ZodString>;
75
+ tests: z.ZodString;
76
+ imports: z.ZodArray<z.ZodEnum<typeof import("./platform-authorization-modules").PlatformAuthorizationModule>>;
77
+ dependsOn: z.ZodArray<z.ZodObject<{
78
+ biome: z.ZodString;
79
+ minModuleVersion: z.ZodNumber;
80
+ }, z.core.$strict>>;
81
+ implements: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodEnum<typeof import("./platform-authorization-modules").XemaAuthorizationInterface>>>;
82
+ resourceTypes: z.ZodArray<z.ZodString>;
83
+ writableRelations: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>;
84
+ searchable: z.ZodRecord<z.ZodString, z.ZodObject<{
85
+ anchor: z.ZodOptional<z.ZodString>;
86
+ highCardinality: z.ZodBoolean;
87
+ }, z.core.$strict>>;
88
+ publicWildcards: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>;
89
+ migrations: z.ZodArray<z.ZodObject<{
90
+ from: z.ZodNumber;
91
+ steps: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
92
+ kind: z.ZodLiteral<AuthorizationMigrationStepKind.RenameType>;
93
+ from: z.ZodString;
94
+ to: z.ZodString;
95
+ }, z.core.$strict>, z.ZodObject<{
96
+ kind: z.ZodLiteral<AuthorizationMigrationStepKind.RenameRelation>;
97
+ type: z.ZodString;
98
+ from: z.ZodString;
99
+ to: z.ZodString;
100
+ }, z.core.$strict>, z.ZodObject<{
101
+ kind: z.ZodLiteral<AuthorizationMigrationStepKind.DropType>;
102
+ type: z.ZodString;
103
+ }, z.core.$strict>, z.ZodObject<{
104
+ kind: z.ZodLiteral<AuthorizationMigrationStepKind.DropRelation>;
105
+ type: z.ZodString;
106
+ relation: z.ZodString;
107
+ }, z.core.$strict>, z.ZodObject<{
108
+ kind: z.ZodLiteral<AuthorizationMigrationStepKind.NarrowRestriction>;
109
+ type: z.ZodString;
110
+ relation: z.ZodString;
111
+ removed: z.ZodArray<z.ZodString>;
112
+ }, z.core.$strict>], "kind">>;
113
+ }, z.core.$strict>>;
114
+ }, z.core.$strict>;
115
+ export type AuthorizationModuleEnvelope = z.infer<typeof AuthorizationModuleEnvelopeSchema>;
116
+ //# sourceMappingURL=authorization-module-envelope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorization-module-envelope.d.ts","sourceRoot":"","sources":["../../../src/authorization-module/lib/authorization-module-envelope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA+BxB,eAAO,MAAM,iCAAiC,QAAgC,CAAC;AAE/E,eAAO,MAAM,sCAAsC,QACd,CAAC;AAStC,eAAO,MAAM,mCAAmC;;;kBAKrC,CAAC;AACZ,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CACjD,OAAO,mCAAmC,CAC3C,CAAC;AAGF,eAAO,MAAM,6BAA6B;;;kBAiBtC,CAAC;AACL,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAC3C,OAAO,6BAA6B,CACrC,CAAC;AAOF,oBAAY,8BAA8B;IACxC,UAAU,gBAAgB;IAC1B,cAAc,oBAAoB;IAClC,QAAQ,cAAc;IACtB,YAAY,kBAAkB;IAC9B,iBAAiB,uBAAuB;CACzC;AAED,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;4BAsC3C,CAAC;AACH,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAC9C,OAAO,gCAAgC,CACxC,CAAC;AASF,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;kBAKpC,CAAC;AACZ,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAChD,OAAO,kCAAkC,CAC1C,CAAC;AAEF,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAgDnC,CAAC;AACZ,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAC/C,OAAO,iCAAiC,CACzC,CAAC"}
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthorizationModuleEnvelopeSchema = exports.AuthorizationModuleMigrationSchema = exports.AuthorizationMigrationStepSchema = exports.AuthorizationMigrationStepKind = exports.AuthorizationSearchableSchema = exports.AuthorizationModuleDependencySchema = exports.AUTHORIZATION_MODULE_TEST_FILE_PATTERN = exports.AUTHORIZATION_MODULE_FILE_PATTERN = void 0;
4
+ const zod_1 = require("zod");
5
+ const authorization_facts_1 = require("../../authorization-facts");
6
+ const platform_generation_1 = require("../../platform-generation");
7
+ const authorization_namespace_1 = require("./authorization-namespace");
8
+ const platform_authorization_modules_1 = require("./platform-authorization-modules");
9
+ const TypeNameSchema = zod_1.z.string().regex(/^[^:#@*\s]{1,254}$/);
10
+ const RelationNameSchema = zod_1.z.string().regex(/^[^:#@*\s]{1,50}$/);
11
+ exports.AUTHORIZATION_MODULE_FILE_PATTERN = /^[a-z0-9][a-z0-9._-]*\.fga$/;
12
+ exports.AUTHORIZATION_MODULE_TEST_FILE_PATTERN = /^[a-z0-9][a-z0-9._-]*\.fga\.yaml$/;
13
+ function uniqueArray(item, what) {
14
+ return zod_1.z.array(item).refine((values) => new Set(values).size === values.length, {
15
+ message: `${what} must not repeat an entry.`,
16
+ });
17
+ }
18
+ exports.AuthorizationModuleDependencySchema = zod_1.z
19
+ .object({
20
+ biome: authorization_namespace_1.AuthorizationBiomeIdSchema,
21
+ minModuleVersion: zod_1.z.number().int().positive(),
22
+ })
23
+ .strict();
24
+ exports.AuthorizationSearchableSchema = zod_1.z
25
+ .object({
26
+ anchor: TypeNameSchema.optional(),
27
+ highCardinality: zod_1.z.boolean(),
28
+ })
29
+ .strict()
30
+ .refine((s) => !s.highCardinality || s.anchor !== undefined, {
31
+ message: 'a high-cardinality searchable type must declare an anchor (D10).',
32
+ });
33
+ var AuthorizationMigrationStepKind;
34
+ (function (AuthorizationMigrationStepKind) {
35
+ AuthorizationMigrationStepKind["RenameType"] = "rename-type";
36
+ AuthorizationMigrationStepKind["RenameRelation"] = "rename-relation";
37
+ AuthorizationMigrationStepKind["DropType"] = "drop-type";
38
+ AuthorizationMigrationStepKind["DropRelation"] = "drop-relation";
39
+ AuthorizationMigrationStepKind["NarrowRestriction"] = "narrow-restriction";
40
+ })(AuthorizationMigrationStepKind || (exports.AuthorizationMigrationStepKind = AuthorizationMigrationStepKind = {}));
41
+ exports.AuthorizationMigrationStepSchema = zod_1.z.discriminatedUnion('kind', [
42
+ zod_1.z
43
+ .object({
44
+ kind: zod_1.z.literal(AuthorizationMigrationStepKind.RenameType),
45
+ from: TypeNameSchema,
46
+ to: TypeNameSchema,
47
+ })
48
+ .strict(),
49
+ zod_1.z
50
+ .object({
51
+ kind: zod_1.z.literal(AuthorizationMigrationStepKind.RenameRelation),
52
+ type: TypeNameSchema,
53
+ from: RelationNameSchema,
54
+ to: RelationNameSchema,
55
+ })
56
+ .strict(),
57
+ zod_1.z
58
+ .object({
59
+ kind: zod_1.z.literal(AuthorizationMigrationStepKind.DropType),
60
+ type: TypeNameSchema,
61
+ })
62
+ .strict(),
63
+ zod_1.z
64
+ .object({
65
+ kind: zod_1.z.literal(AuthorizationMigrationStepKind.DropRelation),
66
+ type: TypeNameSchema,
67
+ relation: RelationNameSchema,
68
+ })
69
+ .strict(),
70
+ zod_1.z
71
+ .object({
72
+ kind: zod_1.z.literal(AuthorizationMigrationStepKind.NarrowRestriction),
73
+ type: TypeNameSchema,
74
+ relation: RelationNameSchema,
75
+ removed: zod_1.z.array(zod_1.z.string().min(1)).min(1),
76
+ })
77
+ .strict(),
78
+ ]);
79
+ exports.AuthorizationModuleMigrationSchema = zod_1.z
80
+ .object({
81
+ from: zod_1.z.number().int().positive(),
82
+ steps: zod_1.z.array(exports.AuthorizationMigrationStepSchema).min(1),
83
+ })
84
+ .strict();
85
+ exports.AuthorizationModuleEnvelopeSchema = zod_1.z
86
+ .object({
87
+ namespace: zod_1.z.string().min(1).optional(),
88
+ moduleVersion: zod_1.z.number().int().positive(),
89
+ platformGeneration: platform_generation_1.PlatformGenerationDeclarationSchema,
90
+ files: uniqueArray(zod_1.z.string().regex(exports.AUTHORIZATION_MODULE_FILE_PATTERN), 'files').min(1),
91
+ tests: zod_1.z.string().regex(exports.AUTHORIZATION_MODULE_TEST_FILE_PATTERN),
92
+ imports: uniqueArray(platform_authorization_modules_1.PlatformAuthorizationModuleSchema, 'imports'),
93
+ dependsOn: zod_1.z
94
+ .array(exports.AuthorizationModuleDependencySchema)
95
+ .refine((deps) => new Set(deps.map((d) => d.biome)).size === deps.length, { message: 'dependsOn must not name a biome twice.' }),
96
+ implements: zod_1.z.record(TypeNameSchema, uniqueArray(platform_authorization_modules_1.XemaAuthorizationInterfaceSchema, 'implements').min(1)),
97
+ resourceTypes: uniqueArray(TypeNameSchema, 'resourceTypes').min(1),
98
+ writableRelations: authorization_facts_1.WritableRelationsSchema,
99
+ searchable: zod_1.z.record(TypeNameSchema, exports.AuthorizationSearchableSchema),
100
+ publicWildcards: zod_1.z.record(TypeNameSchema, uniqueArray(RelationNameSchema, 'publicWildcards').min(1)),
101
+ migrations: zod_1.z.array(exports.AuthorizationModuleMigrationSchema),
102
+ })
103
+ .strict();
104
+ //# sourceMappingURL=authorization-module-envelope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorization-module-envelope.js","sourceRoot":"","sources":["../../../src/authorization-module/lib/authorization-module-envelope.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,mEAAoE;AACpE,mEAAgF;AAEhF,uEAAuE;AACvE,qFAG0C;AAkB1C,MAAM,cAAc,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;AAC9D,MAAM,kBAAkB,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;AAGpD,QAAA,iCAAiC,GAAG,6BAA6B,CAAC;AAElE,QAAA,sCAAsC,GACjD,mCAAmC,C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@ -0,0 +1,23 @@
1
+ import { z } from 'zod';
2
+ export declare const AUTHORIZATION_BIOME_ID_PATTERN: RegExp;
3
+ export declare const XEMA_PLATFORM_NAMESPACE = "xema";
4
+ export declare const AUTHORIZATION_NAMESPACE_SEPARATOR = "_";
5
+ export declare const OPENFGA_DSL_RESERVED_WORDS: readonly string[];
6
+ export declare enum AuthorizationNamespaceRefusal {
7
+ Grammar = "grammar",
8
+ ReservedPlatformNamespace = "reserved_platform_namespace",
9
+ DslKeyword = "dsl_keyword"
10
+ }
11
+ export declare class AuthorizationNamespaceError extends Error {
12
+ readonly refusal: AuthorizationNamespaceRefusal;
13
+ readonly biomeId: string;
14
+ constructor(refusal: AuthorizationNamespaceRefusal, biomeId: string);
15
+ }
16
+ export declare function authorizationNamespaceRefusal(biomeId: string): AuthorizationNamespaceRefusal | null;
17
+ export declare const AuthorizationBiomeIdSchema: z.ZodString;
18
+ export declare function deriveAuthorizationNamespace(signedBiomeId: string): {
19
+ readonly moduleName: string;
20
+ readonly prefix: string;
21
+ };
22
+ export declare function namespaceOfAuthorizationName(name: string): string | null;
23
+ //# sourceMappingURL=authorization-namespace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorization-namespace.d.ts","sourceRoot":"","sources":["../../../src/authorization-module/lib/authorization-namespace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAsBxB,eAAO,MAAM,8BAA8B,QAAsB,CAAC;AAGlE,eAAO,MAAM,uBAAuB,SAAS,CAAC;AAG9C,eAAO,MAAM,iCAAiC,MAAM,CAAC;AAarD,eAAO,MAAM,0BAA0B,EAAE,SAAS,MAAM,EAkBtD,CAAC;AAGH,oBAAY,6BAA6B;IAEvC,OAAO,YAAY;IAEnB,yBAAyB,gCAAgC;IAEzD,UAAU,gBAAgB;CAC3B;AAED,qBAAa,2BAA4B,SAAQ,KAAK;IACpD,QAAQ,CAAC,OAAO,EAAE,6BAA6B,CAAC;IAChD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;gBAEb,OAAO,EAAE,6BAA6B,EAAE,OAAO,EAAE,MAAM;CAQpE;AAGD,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,MAAM,GACd,6BAA6B,GAAG,IAAI,CAWtC;AAED,eAAO,MAAM,0BAA0B,aAQrC,CAAC;AAMH,wBAAgB,4BAA4B,CAAC,aAAa,EAAE,MAAM,GAAG;IACnE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CASA;AAMD,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGxE"}
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthorizationBiomeIdSchema = exports.AuthorizationNamespaceError = exports.AuthorizationNamespaceRefusal = exports.OPENFGA_DSL_RESERVED_WORDS = exports.AUTHORIZATION_NAMESPACE_SEPARATOR = exports.XEMA_PLATFORM_NAMESPACE = exports.AUTHORIZATION_BIOME_ID_PATTERN = void 0;
4
+ exports.authorizationNamespaceRefusal = authorizationNamespaceRefusal;
5
+ exports.deriveAuthorizationNamespace = deriveAuthorizationNamespace;
6
+ exports.namespaceOfAuthorizationName = namespaceOfAuthorizationName;
7
+ const zod_1 = require("zod");
8
+ exports.AUTHORIZATION_BIOME_ID_PATTERN = /^[a-z][a-z0-9-]*$/;
9
+ exports.XEMA_PLATFORM_NAMESPACE = 'xema';
10
+ exports.AUTHORIZATION_NAMESPACE_SEPARATOR = '_';
11
+ exports.OPENFGA_DSL_RESERVED_WORDS = Object.freeze([
12
+ 'and',
13
+ 'condition',
14
+ 'define',
15
+ 'extend',
16
+ 'false',
17
+ 'from',
18
+ 'in',
19
+ 'model',
20
+ 'module',
21
+ 'null',
22
+ 'or',
23
+ 'relation',
24
+ 'relations',
25
+ 'schema',
26
+ 'true',
27
+ 'type',
28
+ 'with',
29
+ ]);
30
+ var AuthorizationNamespaceRefusal;
31
+ (function (AuthorizationNamespaceRefusal) {
32
+ AuthorizationNamespaceRefusal["Grammar"] = "grammar";
33
+ AuthorizationNamespaceRefusal["ReservedPlatformNamespace"] = "reserved_platform_namespace";
34
+ AuthorizationNamespaceRefusal["DslKeyword"] = "dsl_keyword";
35
+ })(AuthorizationNamespaceRefusal || (exports.AuthorizationNamespaceRefusal = AuthorizationNamespaceRefusal = {}));
36
+ class AuthorizationNamespaceError extends Error {
37
+ refusal;
38
+ biomeId;
39
+ constructor(refusal, biomeId) {
40
+ super(`biome id "${biomeId}" cannot be an authorization namespace (${refusal}): it must match \`[a-z][a-z0-9-]*\`, must not be the reserved \`${exports.XEMA_PLATFORM_NAMESPACE}\`, and must not be an OpenFGA DSL keyword.`);
41
+ this.name = 'AuthorizationNamespaceError';
42
+ this.refusal = refusal;
43
+ this.biomeId = biomeId;
44
+ }
45
+ }
46
+ exports.AuthorizationNamespaceError = AuthorizationNamespaceError;
47
+ function authorizationNamespaceRefusal(biomeId) {
48
+ if (!exports.AUTHORIZATION_BIOME_ID_PATTERN.test(biomeId)) {
49
+ return AuthorizationNamespaceRefusal.Grammar;
50
+ }
51
+ if (biomeId === exports.XEMA_PLATFORM_NAMESPACE) {
52
+ return AuthorizationNamespaceRefusal.ReservedPlatformNamespace;
53
+ }
54
+ if (exports.OPENFGA_DSL_RESERVED_WORDS.includes(biomeId)) {
55
+ return AuthorizationNamespaceRefusal.DslKeyword;
56
+ }
57
+ return null;
58
+ }
59
+ exports.AuthorizationBiomeIdSchema = zod_1.z.string().superRefine((id, ctx) => {
60
+ const refusal = authorizationNamespaceRefusal(id);
61
+ if (refusal !== null) {
62
+ ctx.addIssue({
63
+ code: 'custom',
64
+ message: new AuthorizationNamespaceError(refusal, id).message,
65
+ });
66
+ }
67
+ });
68
+ function deriveAuthorizationNamespace(signedBiomeId) {
69
+ const refusal = authorizationNamespaceRefusal(signedBiomeId);
70
+ if (refusal !== null) {
71
+ throw new AuthorizationNamespaceError(refusal, signedBiomeId);
72
+ }
73
+ return {
74
+ moduleName: signedBiomeId,
75
+ prefix: `${signedBiomeId}${exports.AUTHORIZATION_NAMESPACE_SEPARATOR}`,
76
+ };
77
+ }
78
+ function namespaceOfAuthorizationName(name) {
79
+ const index = name.indexOf(exports.AUTHORIZATION_NAMESPACE_SEPARATOR);
80
+ return index <= 0 ? null : name.slice(0, index);
81
+ }
82
+ //# sourceMappingURL=authorization-namespace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorization-namespace.js","sourceRoot":"","sources":["../../../src/authorization-module/lib/authorization-namespace.ts"],"names":[],"mappings":";;;AAsFA,sEAaC;AAgBD,oEAYC;AAMD,oEAGC;AAxID,6BAAwB;AAsBX,QAAA,8BAA8B,GAAG,mBAAmB,CAAC;AAGrD,QAAA,uBAAuB,GAAG,MAAM,CAAC;AAGjC,QAAA,iCAAiC,GAAG,GAAG,CAAC;AAaxC,QAAA,0BAA0B,GAAsB,MAAM,CAAC,MAAM,CAAC;IACzE,KAAK;IACL,WAAW;IACX,QAAQ;IACR,QAAQ;IACR,OAAO;IACP,MAAM;IACN,IAAI;IACJ,OAAO;IACP,QAAQ;IACR,MAAM;IACN,IAAI;IACJ,UAAU;IACV,WAAW;IACX,QAAQ;IACR,MAAM;IACN,MAAM;IACN,MAAM;CACP,CAAC,CAAC;AAGH,IAAY,6BAOX;AAPD,WAAY,6BAA6B;IAEvC,oDAAmB,CAAA;IAEnB,0FAAyD,CAAA;IAEzD,2DAA0B,CAAA;AAC5B,CAAC,EAPW,6BAA6B,6CAA7B,6BAA6B,QAOxC;AAED,MAAa,2BAA4B,SAAQ,KAAK;IAC3C,OAAO,CAAgC;IACvC,OAAO,CAAS;IAEzB,YAAY,OAAsC,EAAE,OAAe;QACjE,KAAK,CACH,aAAa,OAAO,2CAA2C,OAAO,oEAAoE,+BAAuB,6CAA6C,CAC/M,CAAC;QACF,IAAI,CAAC,IAAI,GAAG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AC;AAMD,SAAgB,4BAA4B,CAAC,IAAY;IACvD,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,yCAAiC,CAAC,CAAC;IAC9D,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AAClD,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { z } from 'zod';
2
+ export declare enum PlatformAuthorizationModule {
3
+ Core = "xema_core",
4
+ Capability = "xema_capability",
5
+ Sharing = "xema_sharing"
6
+ }
7
+ export declare const PlatformAuthorizationModuleSchema: z.ZodEnum<typeof PlatformAuthorizationModule>;
8
+ export declare const XEMA_PARENT_TYPES_SLOT = "${XEMA_PARENT_TYPES}";
9
+ export declare const XEMA_INHERITING_PLATFORM_TYPES: readonly ["project", "xema_artifact", "xema_session"];
10
+ export declare enum XemaAuthorizationInterface {
11
+ Parent = "xema.parent"
12
+ }
13
+ export declare const XemaAuthorizationInterfaceSchema: z.ZodEnum<typeof XemaAuthorizationInterface>;
14
+ export declare const XEMA_PARENT_INTERFACE_RELATIONS: readonly ["xema_read", "xema_write", "xema_admin"];
15
+ export declare const XEMA_AUTHORIZATION_INTERFACE_RELATIONS: Readonly<Record<XemaAuthorizationInterface, readonly string[]>>;
16
+ export declare const PLATFORM_AUTHORIZATION_EXPORTS: Readonly<Record<PlatformAuthorizationModule, Readonly<Record<string, readonly string[]>>>>;
17
+ //# sourceMappingURL=platform-authorization-modules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-authorization-modules.d.ts","sourceRoot":"","sources":["../../../src/authorization-module/lib/platform-authorization-modules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAuBxB,oBAAY,2BAA2B;IACrC,IAAI,cAAc;IAClB,UAAU,oBAAoB;IAC9B,OAAO,iBAAiB;CACzB;AAED,eAAO,MAAM,iCAAiC,+CAE7C,CAAC;AAQF,eAAO,MAAM,sBAAsB,yBAAyB,CAAC;AAG7D,eAAO,MAAM,8BAA8B,uDAIhC,CAAC;AAUZ,oBAAY,0BAA0B;IACpC,MAAM,gBAAgB;CACvB;AAED,eAAO,MAAM,gCAAgC,8CAE5C,CAAC;AAEF,eAAO,MAAM,+BAA+B,oDAIjC,CAAC;AAGZ,eAAO,MAAM,sCAAsC,EAAE,QAAQ,CAC3D,MAAM,CAAC,0BAA0B,EAAE,SAAS,MAAM,EAAE,CAAC,CAGrD,CAAC;AAYH,eAAO,MAAM,8BAA8B,EAAE,QAAQ,CACnD,MAAM,CAAC,2BAA2B,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,CAAC,CAehF,CAAC"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PLATFORM_AUTHORIZATION_EXPORTS = exports.XEMA_AUTHORIZATION_INTERFACE_RELATIONS = exports.XEMA_PARENT_INTERFACE_RELATIONS = exports.XemaAuthorizationInterfaceSchema = exports.XemaAuthorizationInterface = exports.XEMA_INHERITING_PLATFORM_TYPES = exports.XEMA_PARENT_TYPES_SLOT = exports.PlatformAuthorizationModuleSchema = exports.PlatformAuthorizationModule = void 0;
4
+ const zod_1 = require("zod");
5
+ var PlatformAuthorizationModule;
6
+ (function (PlatformAuthorizationModule) {
7
+ PlatformAuthorizationModule["Core"] = "xema_core";
8
+ PlatformAuthorizationModule["Capability"] = "xema_capability";
9
+ PlatformAuthorizationModule["Sharing"] = "xema_sharing";
10
+ })(PlatformAuthorizationModule || (exports.PlatformAuthorizationModule = PlatformAuthorizationModule = {}));
11
+ exports.PlatformAuthorizationModuleSchema = zod_1.z.nativeEnum(PlatformAuthorizationModule);
12
+ exports.XEMA_PARENT_TYPES_SLOT = '${XEMA_PARENT_TYPES}';
13
+ exports.XEMA_INHERITING_PLATFORM_TYPES = Object.freeze([
14
+ 'project',
15
+ 'xema_artifact',
16
+ 'xema_session',
17
+ ]);
18
+ var XemaAuthorizationInterface;
19
+ (function (XemaAuthorizationInterface) {
20
+ XemaAuthorizationInterface["Parent"] = "xema.parent";
21
+ })(XemaAuthorizationInterface || (exports.XemaAuthorizationInterface = XemaAuthorizationInterface = {}));
22
+ exports.XemaAuthorizationInterfaceSchema = zod_1.z.nativeEnum(XemaAuthorizationInterface);
23
+ exports.XEMA_PARENT_INTERFACE_RELATIONS = Object.freeze([
24
+ 'xema_read',
25
+ 'xema_write',
26
+ 'xema_admin',
27
+ ]);
28
+ exports.XEMA_AUTHORIZATION_INTERFACE_RELATIONS = Object.freeze({
29
+ [XemaAuthorizationInterface.Parent]: exports.XEMA_PARENT_INTERFACE_RELATIONS,
30
+ });
31
+ exports.PLATFORM_AUTHORIZATION_EXPORTS = Object.freeze({
32
+ [PlatformAuthorizationModule.Core]: Object.freeze({
33
+ user: Object.freeze([]),
34
+ agent: Object.freeze([]),
35
+ service: Object.freeze([]),
36
+ runner: Object.freeze([]),
37
+ app: Object.freeze([]),
38
+ 'external-subject': Object.freeze([]),
39
+ org: Object.freeze(['member', 'admin']),
40
+ team: Object.freeze(['member']),
41
+ role: Object.freeze(['assignee']),
42
+ }),
43
+ [PlatformAuthorizationModule.Capability]: Object.freeze({}),
44
+ [PlatformAuthorizationModule.Sharing]: Object.freeze({}),
45
+ });
46
+ //# sourceMappingURL=platform-authorization-modules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-authorization-modules.js","sourceRoot":"","sources":["../../../src/authorization-module/lib/platform-authorization-modules.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAuBxB,IAAY,2BAIX;AAJD,WAAY,2BAA2B;IACrC,iDAAkB,CAAA;IAClB,6DAA8B,CAAA;IAC9B,uDAAwB,CAAA;AAC1B,CAAC,EAJW,2BAA2B,2CAA3B,2BAA2B,QAItC;AAEY,QAAA,iCAAiC,GAAG,OAAC,CAAC,UAA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UAAU,CAAC,CAAC;KAClC,CAAC;IACF,CAAC,2BAA2B,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;IAC3D,CAAC,2BAA2B,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;CACzD,CAAC,CAAC"}
@@ -0,0 +1,23 @@
1
+ module xema_capability
2
+
3
+ # ═══════════════════════════════════════════════════════════════════════════
4
+ # xema_capability — the capability VERB grants.
5
+ #
6
+ # An object is `capability:<encoded capability ref>|<encoded environment>`
7
+ # (org-scoped grants prefix `<encoded org>|`; authorization-api builds the id).
8
+ # `granted_to` admits the verb outright; `granted_pending_approval` admits it
9
+ # only through the approval gate — the two are disjoint relations so a grant
10
+ # is in exactly one of them.
11
+ #
12
+ # `user:*` on `granted_to` is the public-grant idiom: a PLATFORM-owned
13
+ # wildcard, written only by authorization-api's grant door.
14
+ #
15
+ # Every request evaluates against the org's composed policy-set model, so
16
+ # this module is part of EVERY composition — the verb verdict and the
17
+ # instance relation are answered by one model.
18
+ # ═══════════════════════════════════════════════════════════════════════════
19
+
20
+ type capability
21
+ relations
22
+ define granted_to: [user, user:*, agent, app, service, runner, external-subject, role#assignee, team#member]
23
+ define granted_pending_approval: [user, agent, app, service, runner, external-subject, role#assignee, team#member]
@@ -0,0 +1,108 @@
1
+ # Standard OpenFGA tests (`fga model test`) for the xema_capability platform
2
+ # module, run against the BASE composition. Ports the capability-grant
3
+ # semantics authorization-api relies on: direct grants, team grants through
4
+ # nested sub-teams, role grants through team-held assignments, the public
5
+ # `user:*` grant, and the disjoint approval-gated relation.
6
+ name: xema_capability
7
+ model_file: ./fga.mod
8
+ tuples:
9
+ # direct user grant
10
+ - user: user:alice
11
+ relation: granted_to
12
+ object: capability:kb~3adoc.read@1|default
13
+ # team grant, reached through a nested sub-team
14
+ - user: team:parent#member
15
+ relation: granted_to
16
+ object: capability:kb~3adoc.write@1|default
17
+ - user: team:child
18
+ relation: sub_team
19
+ object: team:parent
20
+ - user: user:bob
21
+ relation: direct_member
22
+ object: team:child
23
+ # role grant, held by a team's members
24
+ - user: role:editors#assignee
25
+ relation: granted_to
26
+ object: capability:kb~3adoc.publish@1|default
27
+ - user: team:child#member
28
+ relation: assignee
29
+ object: role:editors
30
+ # public grant
31
+ - user: user:*
32
+ relation: granted_to
33
+ object: capability:catalog~3aread@1|default
34
+ # approval-gated grant
35
+ - user: agent:a1
36
+ relation: granted_pending_approval
37
+ object: capability:mail~3asend@1|default
38
+ # service and runner subjects
39
+ - user: service:svc1
40
+ relation: granted_to
41
+ object: capability:kb~3adoc.read@1|default
42
+ - user: runner:r1
43
+ relation: granted_to
44
+ object: capability:runner~3anoop.echo@1|default
45
+ tests:
46
+ - name: a direct grant admits only its subject
47
+ check:
48
+ - user: user:alice
49
+ object: capability:kb~3adoc.read@1|default
50
+ assertions:
51
+ granted_to: true
52
+ - user: user:bob
53
+ object: capability:kb~3adoc.read@1|default
54
+ assertions:
55
+ granted_to: false
56
+ - user: service:svc1
57
+ object: capability:kb~3adoc.read@1|default
58
+ assertions:
59
+ granted_to: true
60
+ - user: runner:r1
61
+ object: capability:runner~3anoop.echo@1|default
62
+ assertions:
63
+ granted_to: true
64
+ - name: a team grant reaches members of descendant teams
65
+ check:
66
+ - user: user:bob
67
+ object: capability:kb~3adoc.write@1|default
68
+ assertions:
69
+ granted_to: true
70
+ - user: user:alice
71
+ object: capability:kb~3adoc.write@1|default
72
+ assertions:
73
+ granted_to: false
74
+ - name: a role grant reaches the role's team-held assignees
75
+ check:
76
+ - user: user:bob
77
+ object: capability:kb~3adoc.publish@1|default
78
+ assertions:
79
+ granted_to: true
80
+ - user: user:alice
81
+ object: capability:kb~3adoc.publish@1|default
82
+ assertions:
83
+ granted_to: false
84
+ - name: the public grant admits every user and no other subject kind
85
+ check:
86
+ - user: user:anyone
87
+ object: capability:catalog~3aread@1|default
88
+ assertions:
89
+ granted_to: true
90
+ - user: agent:a1
91
+ object: capability:catalog~3aread@1|default
92
+ assertions:
93
+ granted_to: false
94
+ - name: approval-gated and granted are disjoint
95
+ check:
96
+ - user: agent:a1
97
+ object: capability:mail~3asend@1|default
98
+ assertions:
99
+ granted_pending_approval: true
100
+ granted_to: false
101
+ list_objects:
102
+ - user: user:bob
103
+ type: capability
104
+ assertions:
105
+ granted_to:
106
+ - capability:kb~3adoc.write@1|default
107
+ - capability:kb~3adoc.publish@1|default
108
+ - capability:catalog~3aread@1|default
@@ -0,0 +1,81 @@
1
+ module xema_core
2
+
3
+ # ═══════════════════════════════════════════════════════════════════════════
4
+ # xema_core — the platform's principals, its tenancy types, and the platform
5
+ # objects that INHERIT from biome objects.
6
+ #
7
+ # This file is a TEMPLATE. Each `${XEMA_PARENT_TYPES}` is filled by the
8
+ # composer with the sorted list of biome types whose envelopes declare
9
+ # `implements: ["xema.parent"]` (or removed, with its comma, when none does).
10
+ # A biome contributes a type NAME to a list; it never contributes text here.
11
+ #
12
+ # DEFAULT DENY. Org membership grants nothing by itself: a relation that
13
+ # admits org members says so (`org#member` as a direct subject type), and is
14
+ # evaluated by READING a tuple. `org#admin` is never written: the Super User
15
+ # reaches the PDP as a CONTEXTUAL tuple derived per request from the verified
16
+ # token (D2).
17
+ #
18
+ # `org` implements `xema.parent` as the ROOT parent: an object parented by the
19
+ # org (an org-level project, artifact or session) inherits only the org
20
+ # admin's authority — never the members'.
21
+ # ═══════════════════════════════════════════════════════════════════════════
22
+
23
+ type user
24
+ type agent
25
+ type service
26
+ type runner
27
+ type app
28
+ type external-subject
29
+
30
+ type org
31
+ relations
32
+ define member: [user, agent, app, service]
33
+ define admin: [user]
34
+ define xema_admin: admin
35
+ define xema_write: admin
36
+ define xema_read: admin
37
+
38
+ # Teams nest: `member` is the transitive closure over `sub_team`, so a grant to
39
+ # `team:<id>#member` reaches every member of every descendant team.
40
+ type team
41
+ relations
42
+ define parent: [org]
43
+ define sub_team: [team]
44
+ define admin: [user]
45
+ define direct_member: [user, agent, service, app, external-subject]
46
+ define member: direct_member or member from sub_team
47
+
48
+ type role
49
+ relations
50
+ define parent: [org]
51
+ define assignee: [user, agent, service, app, team#member]
52
+
53
+ type project
54
+ relations
55
+ define parent: [org, ${XEMA_PARENT_TYPES}]
56
+ define owner: [user, agent, service]
57
+ define admin: [user, agent, team#member, role#assignee]
58
+ define editor: [user, agent, team#member, role#assignee]
59
+ define viewer: [user, agent, team#member, role#assignee, org#member]
60
+ define xema_admin: owner or admin or xema_admin from parent
61
+ define xema_write: editor or xema_admin or xema_write from parent
62
+ define xema_read: viewer or xema_write or xema_read from parent
63
+
64
+ type xema_session
65
+ relations
66
+ define parent: [org, project, ${XEMA_PARENT_TYPES}]
67
+ define owner: [user, agent]
68
+ define participant: [user, agent]
69
+ define xema_admin: owner or xema_admin from parent
70
+ define xema_write: owner or xema_write from parent
71
+ define xema_read: owner or participant or xema_read from parent
72
+ define can_read: xema_read
73
+ define can_write: xema_write
74
+
75
+ type xema_artifact
76
+ relations
77
+ define parent: [org, project, xema_session, ${XEMA_PARENT_TYPES}]
78
+ define owner: [user, agent, service]
79
+ define can_delete: owner or xema_admin from parent
80
+ define can_write: owner or xema_write from parent
81
+ define can_read: owner or can_write or xema_read from parent