@opensoha/contracts 0.1.25 → 0.1.27

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 (200) hide show
  1. package/COMPATIBILITY.md +34 -0
  2. package/README.md +1 -1
  3. package/agent/environment/export.go +1 -0
  4. package/agent/environment/protocol_test.go +1 -1
  5. package/agent/guest/protocol_test.go +2 -2
  6. package/auth/catalog_generated.go +2 -2
  7. package/auth/permission-catalog.json +481 -1
  8. package/compat/json-schema-ecosystem-0.1.0.json +1 -1
  9. package/compat/openapi-loose-boundaries-0.1.0.json +1 -1
  10. package/delivery/document.schema.json +127 -9
  11. package/endpointcontrol/decode.go +64 -0
  12. package/endpointcontrol/models.go +138 -0
  13. package/endpointcontrol/models_test.go +51 -0
  14. package/endpointcontrol/protocol.schema.json +397 -0
  15. package/examples/relations_compat_test.go +18 -0
  16. package/fixtures/json-schema/endpoint-controls/invalid/controls.json +16 -0
  17. package/fixtures/json-schema/endpoint-controls/invalid/missing-channel-decision.json +15 -0
  18. package/fixtures/json-schema/endpoint-controls/invalid/receipt-content.json +36 -0
  19. package/fixtures/json-schema/endpoint-controls/valid/controls.json +16 -0
  20. package/fixtures/json-schema/endpoint-controls/valid/receipt.json +35 -0
  21. package/fixtures/json-schema/network-runtime-protocol/invalid/eap-activate-bad-fingerprint.json +14 -0
  22. package/fixtures/json-schema/network-runtime-protocol/invalid/eap-gateway-request.json +14 -0
  23. package/fixtures/json-schema/network-runtime-protocol/invalid/eap-private-key-request.json +15 -0
  24. package/fixtures/json-schema/network-runtime-protocol/invalid/eap-profile-without-eap-credential.json +22 -0
  25. package/fixtures/json-schema/network-runtime-protocol/invalid/endpoint-dns-observation.json +25 -0
  26. package/fixtures/json-schema/network-runtime-protocol/invalid/gateway-presence.json +22 -0
  27. package/fixtures/json-schema/network-runtime-protocol/invalid/mihomo-protection-zero-version.json +45 -0
  28. package/fixtures/json-schema/network-runtime-protocol/invalid/presence-raw-key.json +23 -0
  29. package/fixtures/json-schema/network-runtime-protocol/invalid/presence-zero-sequence.json +22 -0
  30. package/fixtures/json-schema/network-runtime-protocol/invalid/workload-wide-vpn.json +17 -0
  31. package/fixtures/json-schema/network-runtime-protocol/valid/eap-certificate-activate.json +14 -0
  32. package/fixtures/json-schema/network-runtime-protocol/valid/eap-certificate-request.json +14 -0
  33. package/fixtures/json-schema/network-runtime-protocol/valid/eap-profile-enrollment.json +24 -0
  34. package/fixtures/json-schema/network-runtime-protocol/valid/endpoint-presence.json +22 -0
  35. package/fixtures/json-schema/network-runtime-protocol/valid/ipv6-configuration.json +102 -0
  36. package/fixtures/json-schema/network-runtime-protocol/valid/mihomo-protected-policy.json +45 -0
  37. package/fixtures/json-schema/network-runtime-protocol/valid/site-dns-ipv6.json +25 -0
  38. package/fixtures/json-schema/network-runtime-protocol/valid/workload-direct-ztna.json +20 -0
  39. package/fixtures/openapi/DLPShadowDecision/invalid/step-up-type.json +14 -0
  40. package/fixtures/openapi/DLPShadowDecision/valid/archive-v2.json +14 -0
  41. package/fixtures/openapi/DLPShadowDecision/valid/step-up.json +14 -0
  42. package/fixtures/openapi/DLPShadowInput/invalid/self-reported-result.json +7 -0
  43. package/fixtures/openapi/DLPShadowInput/invalid/too-many-samples.json +14 -0
  44. package/fixtures/openapi/DLPShadowInput/valid/bounded.json +7 -0
  45. package/fixtures/openapi/DeliveryDocument/invalid/migration-missing-guide-build-template.json +30 -0
  46. package/fixtures/openapi/DeliveryDocument/invalid/migration-missing-guide-deployment-template.json +30 -0
  47. package/fixtures/openapi/DeliveryDocument/invalid/migration-missing-guide-workflow-template.json +27 -0
  48. package/fixtures/openapi/DeliveryDocument/valid/migration-build-template.json +31 -0
  49. package/fixtures/openapi/DeliveryDocument/valid/migration-deployment-template.json +31 -0
  50. package/fixtures/openapi/DeliveryDocument/valid/migration-workflow-template.json +28 -0
  51. package/fixtures/openapi/DeliveryPlanInput/invalid/manual-plan.json +7 -0
  52. package/fixtures/openapi/DeliveryPlanInput/valid/manual-plan.json +6 -0
  53. package/fixtures/openapi/DeliveryTargetInput/invalid/candidate-on-runtime-deploy.json +9 -0
  54. package/fixtures/openapi/DeliveryTargetInput/invalid/config-update-missing-service.json +7 -0
  55. package/fixtures/openapi/DeliveryTargetInput/valid/template-configuration-only.json +8 -0
  56. package/fixtures/openapi/DeliveryTargetInput/valid/template-configuration-without-runtime-environment.json +1 -0
  57. package/fixtures/openapi/DockerVolumeDLPAppealInput/invalid/p4-response.json +3 -0
  58. package/fixtures/openapi/DockerVolumeDLPAppealInput/valid/p4-response.json +3 -0
  59. package/fixtures/openapi/DockerVolumeDLPAppealReviewInput/invalid/p4-response.json +5 -0
  60. package/fixtures/openapi/DockerVolumeDLPAppealReviewInput/valid/p4-response.json +5 -0
  61. package/fixtures/openapi/DockerVolumeDLPAuthorizationInput/invalid/p4-response.json +3 -0
  62. package/fixtures/openapi/DockerVolumeDLPAuthorizationInput/valid/p4-response.json +3 -0
  63. package/fixtures/openapi/DockerVolumeDLPContent/invalid/archive-unsupported-channel.json +9 -0
  64. package/fixtures/openapi/DockerVolumeDLPContent/invalid/p4.json +6 -0
  65. package/fixtures/openapi/DockerVolumeDLPContent/invalid/step-up-audit.json +9 -0
  66. package/fixtures/openapi/DockerVolumeDLPContent/invalid/unavailable-engine.json +9 -0
  67. package/fixtures/openapi/DockerVolumeDLPContent/invalid/unknown-data-level.json +12 -0
  68. package/fixtures/openapi/DockerVolumeDLPContent/valid/classified-rule.json +16 -0
  69. package/fixtures/openapi/DockerVolumeDLPContent/valid/p4.json +8 -0
  70. package/fixtures/openapi/DockerVolumeDLPContent/valid/step-up.json +9 -0
  71. package/fixtures/openapi/DockerVolumeDLPDecision/invalid/p4.json +9 -0
  72. package/fixtures/openapi/DockerVolumeDLPDecision/invalid/step-up-type.json +12 -0
  73. package/fixtures/openapi/DockerVolumeDLPDecision/valid/archive-v2.json +12 -0
  74. package/fixtures/openapi/DockerVolumeDLPDecision/valid/p4.json +11 -0
  75. package/fixtures/openapi/DockerVolumeDLPDecision/valid/step-up.json +12 -0
  76. package/fixtures/openapi/DockerVolumeDLPSaveInput/invalid/p4.json +11 -0
  77. package/fixtures/openapi/DockerVolumeDLPSaveInput/valid/p4.json +11 -0
  78. package/fixtures/openapi/DockerVolumeFileReadInput/invalid/p4-response.json +5 -0
  79. package/fixtures/openapi/DockerVolumeFileReadInput/valid/p4-response.json +4 -0
  80. package/fixtures/openapi/EndpointDeviceInput/invalid/reported-management.json +5 -0
  81. package/fixtures/openapi/EndpointDeviceInput/valid/management-state.json +5 -0
  82. package/fixtures/openapi/EndpointDeviceRegistrationInput/invalid/self-promote-management.json +5 -0
  83. package/fixtures/openapi/KubernetesImportCandidateListEnvelope/invalid/source-with-spec.json +33 -0
  84. package/fixtures/openapi/KubernetesImportCandidateListEnvelope/invalid/source-without-uid.json +29 -0
  85. package/fixtures/openapi/KubernetesImportCandidateListEnvelope/valid/stable-source.json +30 -0
  86. package/fixtures/openapi/KubernetesPod/invalid/pod-uid.json +9 -0
  87. package/fixtures/openapi/KubernetesPod/valid/pod-uid.json +9 -0
  88. package/fixtures/openapi/KubernetesPodDetail/invalid/pod-uid.json +6 -0
  89. package/fixtures/openapi/KubernetesPodDetail/valid/pod-uid.json +6 -0
  90. package/fixtures/openapi/KubernetesServiceImportRequest/invalid/empty-source-uid.json +48 -0
  91. package/fixtures/openapi/KubernetesServiceImportRequest/valid/pinned-workloads-and-cr.json +48 -0
  92. package/fixtures/openapi/ManagedContentPasteInput/invalid/boundary.json +5 -0
  93. package/fixtures/openapi/ManagedContentPasteInput/valid/boundary.json +6 -0
  94. package/fixtures/openapi/ManagedContentPolicy/invalid/self-reported-allow.json +8 -0
  95. package/fixtures/openapi/ManagedContentPolicy/invalid/step-up-audit.json +8 -0
  96. package/fixtures/openapi/ManagedContentPolicy/invalid/unknown-extractor.json +8 -0
  97. package/fixtures/openapi/ManagedContentPolicy/valid/archive-v2.json +8 -0
  98. package/fixtures/openapi/ManagedContentPolicy/valid/network-and-level.json +10 -0
  99. package/fixtures/openapi/ManagedContentPolicy/valid/step-up.json +8 -0
  100. package/fixtures/openapi/ManagedContentReviewInput/invalid/boundary.json +5 -0
  101. package/fixtures/openapi/ManagedContentReviewInput/valid/boundary.json +5 -0
  102. package/fixtures/openapi/ManagedContentSaveInput/invalid/boundary.json +14 -0
  103. package/fixtures/openapi/ManagedContentSaveInput/valid/boundary.json +16 -0
  104. package/fixtures/openapi/ManagedContentUploadInput/invalid/boundary.json +7 -0
  105. package/fixtures/openapi/ManagedContentUploadInput/valid/boundary.json +6 -0
  106. package/fixtures/openapi/ManifestExecutionTaskPayload/invalid/initialization.json +7 -0
  107. package/fixtures/openapi/ManifestExecutionTaskPayload/valid/initialization.json +7 -0
  108. package/fixtures/openapi/ManifestRootResource/invalid/root.json +1 -0
  109. package/fixtures/openapi/ManifestRootResource/valid/root.json +1 -0
  110. package/fixtures/openapi/NetworkAccessPolicyInput/invalid/unknown-management-state.json +35 -0
  111. package/fixtures/openapi/NetworkAccessPolicyInput/valid/managed-device.json +35 -0
  112. package/fixtures/openapi/NetworkAdmissionPreviewRequest/invalid/deviceId-characters.json +4 -0
  113. package/fixtures/openapi/NetworkAdmissionPreviewRequest/invalid/nasBindingId-characters.json +4 -0
  114. package/fixtures/openapi/NetworkAdmissionPreviewRequest/invalid/subject-override.json +1 -0
  115. package/fixtures/openapi/NetworkAdmissionPreviewRequest/valid/device-nas.json +1 -0
  116. package/fixtures/openapi/NetworkAdmissionPreviewResult/invalid/missing-attributeVersion.json +13 -0
  117. package/fixtures/openapi/NetworkAdmissionPreviewResult/invalid/missing-evaluatedAt.json +13 -0
  118. package/fixtures/openapi/NetworkAdmissionPreviewResult/valid/versioned.json +14 -0
  119. package/fixtures/openapi/NetworkConflictAnalysisRequest/invalid/missing-runtime-ranges.json +1 -0
  120. package/fixtures/openapi/NetworkConflictAnalysisRequest/invalid/unknown-source-type.json +9 -0
  121. package/fixtures/openapi/NetworkConflictAnalysisRequest/valid/empty-runtime-ranges.json +3 -0
  122. package/fixtures/openapi/NetworkConflictAnalysisRequest/{invalid → valid}/ipv6-range.json +1 -1
  123. package/fixtures/openapi/NetworkEAPServerTrust/invalid/no-server-validation.json +5 -0
  124. package/fixtures/openapi/NetworkEAPServerTrust/valid/named-server.json +9 -0
  125. package/fixtures/openapi/NetworkEndpointResponsePolicyInput/invalid/all-sites-implicit.json +45 -0
  126. package/fixtures/openapi/NetworkEndpointResponsePolicyInput/invalid/unbounded-stages.json +54 -0
  127. package/fixtures/openapi/NetworkEndpointResponsePolicyInput/invalid/zero-heartbeat.json +47 -0
  128. package/fixtures/openapi/NetworkEndpointResponsePolicyInput/valid/staged-protection.json +47 -0
  129. package/fixtures/openapi/NetworkEndpointResponseRestoreInput/invalid/missing-reason.json +3 -0
  130. package/fixtures/openapi/NetworkEndpointResponseRestoreInput/valid/expected-current.json +4 -0
  131. package/fixtures/openapi/NetworkPolicyPreviewResult/invalid/attribute-version.json +1 -0
  132. package/fixtures/openapi/NetworkPolicyPreviewResult/valid/admission-version.json +1 -0
  133. package/fixtures/openapi/NetworkPolicySubjects/invalid/duplicate-role.json +1 -0
  134. package/fixtures/openapi/NetworkPolicySubjects/invalid/role-characters.json +5 -0
  135. package/fixtures/openapi/NetworkPolicySubjects/valid/role-bound.json +1 -0
  136. package/fixtures/openapi/NetworkProxyConfigurationInput/invalid/missing-content.json +1 -0
  137. package/fixtures/openapi/NetworkProxyConfigurationPatchInput/invalid/bad-binding-id.json +9 -0
  138. package/fixtures/openapi/NetworkProxyConfigurationPatchInput/invalid/empty-content.json +1 -0
  139. package/fixtures/openapi/NetworkProxyConfigurationPatchInput/valid/binding-only.json +11 -0
  140. package/fixtures/openapi/NetworkProxyConfigurationPatchInput/valid/clear-binding-disabled.json +5 -0
  141. package/fixtures/openapi/NetworkProxyConfigurationPatchInput/valid/enabled.json +1 -0
  142. package/fixtures/openapi/NetworkSiteInput/invalid/unknown-governance.json +6 -0
  143. package/fixtures/openapi/NetworkSiteInput/valid/restricted-unmanaged.json +6 -0
  144. package/fixtures/openapi/ResourceRelationConfig/invalid/executable-rule.json +17 -0
  145. package/fixtures/openapi/ResourceRelationConfig/valid/unknown-kind.json +13 -0
  146. package/fixtures/openapi/ServiceDeploymentTemplateInput/invalid/migration-missing-guide-valid-yaml.json +38 -0
  147. package/fixtures/openapi/ServiceDeploymentTemplateInput/valid/migration-valid-yaml.json +39 -0
  148. package/fixtures/openapi/TemplateMigrationAssessment/invalid/initialization.json +9 -0
  149. package/fixtures/openapi/TemplateMigrationAssessment/valid/initialization.json +9 -0
  150. package/fixtures/openapi/TemplateMigrationPolicy/invalid/blank-guide.json +5 -0
  151. package/fixtures/openapi/TemplateMigrationPolicy/invalid/missing-guide.json +4 -0
  152. package/fixtures/openapi/TemplateMigrationPolicy/invalid/unknown-escape-hatch.json +6 -0
  153. package/fixtures/openapi/TemplateMigrationPolicy/valid/legacy-safe.json +4 -0
  154. package/fixtures/openapi/TemplateMigrationPolicy/valid/ordered-data-change.json +5 -0
  155. package/fixtures/openapi/TemplateUpdateBatchInput/invalid/duplicate-candidates.json +11 -0
  156. package/fixtures/openapi/TemplateUpdateBatchInput/invalid/empty-identities.json +10 -0
  157. package/fixtures/openapi/TemplateUpdateBatchInput/valid/staged-adoption.json +10 -0
  158. package/fixtures/openapi/TemplateUpdatePolicyInput/invalid/unknown-mode.json +8 -0
  159. package/fixtures/openapi/TemplateUpdatePolicyInput/valid/explicit-automatic.json +8 -0
  160. package/fixtures/openapi/TemplateUpdatePreviewInput/invalid/empty-identities.json +10 -0
  161. package/fixtures/openapi/TemplateUpdatePreviewInput/invalid/empty-targets.json +6 -0
  162. package/fixtures/openapi/TemplateUpdatePreviewInput/valid/cross-version-manual.json +14 -0
  163. package/gen/go/sohaapi/client.go +1 -1
  164. package/gen/go/sohaapi/client_test.go +2 -2
  165. package/gen/go/sohaapi/import_source_compat_test.go +12 -0
  166. package/gen/go/sohaapi/proxy_configuration_test.go +38 -0
  167. package/gen/go/sohaapi/types.go +3760 -345
  168. package/gen/ts/sohaapi/index.ts +5573 -181
  169. package/go.mod +2 -2
  170. package/helmrelease/delivery.go +4 -1
  171. package/helmrelease/initialization.go +10 -0
  172. package/helmrelease/runtime/delivery.go +40 -10
  173. package/helmrelease/runtime/delivery_test.go +4 -0
  174. package/helmrelease/runtime/initialization.go +186 -0
  175. package/helmrelease/runtime/initialization_test.go +203 -0
  176. package/network/README.md +34 -0
  177. package/network/network-radius-accounting.schema.json +4 -1
  178. package/network/network-runtime-protocol.schema.json +2166 -317
  179. package/network/proxy-runtime.schema.json +482 -67
  180. package/openapi/network_control_test.go +64 -0
  181. package/openapi/soha-api.json +53524 -43459
  182. package/openapi/soha-api.yaml +26431 -20491
  183. package/openapi/spec_generated.go +3 -3
  184. package/openapi/spec_test.go +42 -0
  185. package/package.json +6 -3
  186. package/proxytransport/handler.go +271 -0
  187. package/proxytransport/probe.go +30 -0
  188. package/proxytransport/scope.go +89 -0
  189. package/proxytransport/transport_test.go +60 -0
  190. package/resource/models.go +2 -0
  191. package/resource/relations.go +225 -0
  192. package/resource/relations_test.go +47 -0
  193. package/resource/root_cr.go +38 -0
  194. package/resource/runtime/argocd_integration_test.go +1 -1
  195. package/resource/runtime/initialization.go +66 -0
  196. package/resource/runtime/initialization_test.go +80 -0
  197. package/resource/runtime/relations.go +161 -0
  198. package/resource/runtime/relations_test.go +100 -0
  199. package/resource/runtime/root_cr.go +79 -0
  200. package/resource/runtime/root_cr_test.go +118 -0
@@ -5,109 +5,524 @@
5
5
  "description": "Messages on the authenticated proxy runtime channel. Configuration content is delivered only to the enrolled runtime and is never returned by management reads.",
6
6
  "type": "object",
7
7
  "additionalProperties": false,
8
- "required": ["schemaVersion", "runtimeId", "messageType", "occurredAt", "payload"],
8
+ "required": [
9
+ "schemaVersion",
10
+ "runtimeId",
11
+ "messageType",
12
+ "occurredAt",
13
+ "payload"
14
+ ],
9
15
  "properties": {
10
- "schemaVersion": { "const": "proxy-runtime/v1alpha1" },
11
- "runtimeId": { "$ref": "#/$defs/Identifier" },
12
- "messageType": { "enum": ["configuration.desired", "configuration.applied", "observation", "connections.snapshot", "connection.close.request", "connection.close.result"] },
13
- "occurredAt": { "type": "string", "format": "date-time" },
16
+ "schemaVersion": {
17
+ "const": "proxy-runtime/v1alpha1"
18
+ },
19
+ "runtimeId": {
20
+ "$ref": "#/$defs/Identifier"
21
+ },
22
+ "messageType": {
23
+ "enum": [
24
+ "configuration.desired",
25
+ "configuration.applied",
26
+ "observation",
27
+ "connections.snapshot",
28
+ "connection.close.request",
29
+ "connection.close.result"
30
+ ]
31
+ },
32
+ "occurredAt": {
33
+ "type": "string",
34
+ "format": "date-time"
35
+ },
14
36
  "payload": {
15
37
  "oneOf": [
16
- { "$ref": "#/$defs/ConfigurationDesired" },
17
- { "$ref": "#/$defs/ConfigurationApplied" },
18
- { "$ref": "#/$defs/Observation" },
19
- { "$ref": "#/$defs/ConnectionsSnapshot" },
20
- { "$ref": "#/$defs/ConnectionCloseRequest" },
21
- { "$ref": "#/$defs/ConnectionCloseResult" }
38
+ {
39
+ "$ref": "#/$defs/ConfigurationDesired"
40
+ },
41
+ {
42
+ "$ref": "#/$defs/ConfigurationApplied"
43
+ },
44
+ {
45
+ "$ref": "#/$defs/Observation"
46
+ },
47
+ {
48
+ "$ref": "#/$defs/ConnectionsSnapshot"
49
+ },
50
+ {
51
+ "$ref": "#/$defs/ConnectionCloseRequest"
52
+ },
53
+ {
54
+ "$ref": "#/$defs/ConnectionCloseResult"
55
+ }
22
56
  ]
23
57
  }
24
58
  },
25
59
  "allOf": [
26
- { "if": { "properties": { "messageType": { "const": "configuration.desired" } }, "required": ["messageType"] }, "then": { "properties": { "payload": { "$ref": "#/$defs/ConfigurationDesired" } } } },
27
- { "if": { "properties": { "messageType": { "const": "configuration.applied" } }, "required": ["messageType"] }, "then": { "properties": { "payload": { "$ref": "#/$defs/ConfigurationApplied" } } } },
28
- { "if": { "properties": { "messageType": { "const": "observation" } }, "required": ["messageType"] }, "then": { "properties": { "payload": { "$ref": "#/$defs/Observation" } } } },
29
- { "if": { "properties": { "messageType": { "const": "connections.snapshot" } }, "required": ["messageType"] }, "then": { "properties": { "payload": { "$ref": "#/$defs/ConnectionsSnapshot" } } } },
30
- { "if": { "properties": { "messageType": { "const": "connection.close.request" } }, "required": ["messageType"] }, "then": { "properties": { "payload": { "$ref": "#/$defs/ConnectionCloseRequest" } } } },
31
- { "if": { "properties": { "messageType": { "const": "connection.close.result" } }, "required": ["messageType"] }, "then": { "properties": { "payload": { "$ref": "#/$defs/ConnectionCloseResult" } } } }
60
+ {
61
+ "if": {
62
+ "properties": {
63
+ "messageType": {
64
+ "const": "configuration.desired"
65
+ }
66
+ },
67
+ "required": [
68
+ "messageType"
69
+ ]
70
+ },
71
+ "then": {
72
+ "properties": {
73
+ "payload": {
74
+ "$ref": "#/$defs/ConfigurationDesired"
75
+ }
76
+ }
77
+ }
78
+ },
79
+ {
80
+ "if": {
81
+ "properties": {
82
+ "messageType": {
83
+ "const": "configuration.applied"
84
+ }
85
+ },
86
+ "required": [
87
+ "messageType"
88
+ ]
89
+ },
90
+ "then": {
91
+ "properties": {
92
+ "payload": {
93
+ "$ref": "#/$defs/ConfigurationApplied"
94
+ }
95
+ }
96
+ }
97
+ },
98
+ {
99
+ "if": {
100
+ "properties": {
101
+ "messageType": {
102
+ "const": "observation"
103
+ }
104
+ },
105
+ "required": [
106
+ "messageType"
107
+ ]
108
+ },
109
+ "then": {
110
+ "properties": {
111
+ "payload": {
112
+ "$ref": "#/$defs/Observation"
113
+ }
114
+ }
115
+ }
116
+ },
117
+ {
118
+ "if": {
119
+ "properties": {
120
+ "messageType": {
121
+ "const": "connections.snapshot"
122
+ }
123
+ },
124
+ "required": [
125
+ "messageType"
126
+ ]
127
+ },
128
+ "then": {
129
+ "properties": {
130
+ "payload": {
131
+ "$ref": "#/$defs/ConnectionsSnapshot"
132
+ }
133
+ }
134
+ }
135
+ },
136
+ {
137
+ "if": {
138
+ "properties": {
139
+ "messageType": {
140
+ "const": "connection.close.request"
141
+ }
142
+ },
143
+ "required": [
144
+ "messageType"
145
+ ]
146
+ },
147
+ "then": {
148
+ "properties": {
149
+ "payload": {
150
+ "$ref": "#/$defs/ConnectionCloseRequest"
151
+ }
152
+ }
153
+ }
154
+ },
155
+ {
156
+ "if": {
157
+ "properties": {
158
+ "messageType": {
159
+ "const": "connection.close.result"
160
+ }
161
+ },
162
+ "required": [
163
+ "messageType"
164
+ ]
165
+ },
166
+ "then": {
167
+ "properties": {
168
+ "payload": {
169
+ "$ref": "#/$defs/ConnectionCloseResult"
170
+ }
171
+ }
172
+ }
173
+ }
32
174
  ],
33
175
  "$defs": {
34
- "Identifier": { "type": "string", "minLength": 1, "maxLength": 128, "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$" },
35
- "Engine": { "enum": ["mihomo", "sing-box", "v2ray"] },
36
- "Hash": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
176
+ "Identifier": {
177
+ "type": "string",
178
+ "minLength": 1,
179
+ "maxLength": 128,
180
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
181
+ },
182
+ "Engine": {
183
+ "enum": [
184
+ "mihomo",
185
+ "sing-box",
186
+ "v2ray"
187
+ ]
188
+ },
189
+ "Hash": {
190
+ "type": "string",
191
+ "pattern": "^sha256:[a-f0-9]{64}$"
192
+ },
37
193
  "ConfigurationDesired": {
38
- "type": "object", "additionalProperties": false,
39
- "required": ["revision", "engine", "enabled", "contentHash", "content", "validUntil"],
194
+ "type": "object",
195
+ "additionalProperties": false,
196
+ "required": [
197
+ "revision",
198
+ "engine",
199
+ "enabled",
200
+ "contentHash",
201
+ "content",
202
+ "validUntil"
203
+ ],
40
204
  "properties": {
41
- "revision": { "type": "integer", "minimum": 1 },
42
- "engine": { "$ref": "#/$defs/Engine" },
43
- "enabled": { "type": "boolean" },
44
- "contentHash": { "$ref": "#/$defs/Hash" },
45
- "content": { "type": "string", "minLength": 1, "maxLength": 1048576, "writeOnly": true },
46
- "validUntil": { "type": "string", "format": "date-time" }
205
+ "revision": {
206
+ "type": "integer",
207
+ "minimum": 1
208
+ },
209
+ "engine": {
210
+ "$ref": "#/$defs/Engine"
211
+ },
212
+ "enabled": {
213
+ "type": "boolean"
214
+ },
215
+ "contentHash": {
216
+ "$ref": "#/$defs/Hash"
217
+ },
218
+ "content": {
219
+ "type": "string",
220
+ "minLength": 1,
221
+ "maxLength": 1048576,
222
+ "writeOnly": true
223
+ },
224
+ "validUntil": {
225
+ "type": "string",
226
+ "format": "date-time"
227
+ },
228
+ "binding": {
229
+ "$ref": "#/$defs/Binding"
230
+ },
231
+ "protection": {
232
+ "$ref": "#/$defs/Protection"
233
+ }
47
234
  }
48
235
  },
49
236
  "ConfigurationApplied": {
50
- "type": "object", "additionalProperties": false,
51
- "required": ["revision", "status", "readbackHash"],
237
+ "type": "object",
238
+ "additionalProperties": false,
239
+ "required": [
240
+ "revision",
241
+ "status",
242
+ "readbackHash"
243
+ ],
52
244
  "properties": {
53
- "revision": { "type": "integer", "minimum": 1 },
54
- "status": { "enum": ["applied", "rejected", "rolled-back"] },
55
- "readbackHash": { "$ref": "#/$defs/Hash" },
56
- "reasonCode": { "type": "string", "minLength": 1, "maxLength": 128 }
245
+ "revision": {
246
+ "type": "integer",
247
+ "minimum": 1
248
+ },
249
+ "status": {
250
+ "enum": [
251
+ "applied",
252
+ "rejected",
253
+ "rolled-back"
254
+ ]
255
+ },
256
+ "readbackHash": {
257
+ "$ref": "#/$defs/Hash"
258
+ },
259
+ "reasonCode": {
260
+ "type": "string",
261
+ "minLength": 1,
262
+ "maxLength": 128
263
+ }
57
264
  }
58
265
  },
59
266
  "Observation": {
60
- "type": "object", "additionalProperties": false,
61
- "required": ["engine", "engineVersion", "health", "capabilities", "uptimeSeconds", "uploadTotal", "downloadTotal"],
267
+ "type": "object",
268
+ "additionalProperties": false,
269
+ "required": [
270
+ "engine",
271
+ "engineVersion",
272
+ "health",
273
+ "capabilities",
274
+ "uptimeSeconds",
275
+ "uploadTotal",
276
+ "downloadTotal"
277
+ ],
62
278
  "properties": {
63
- "engine": { "$ref": "#/$defs/Engine" },
64
- "engineVersion": { "type": "string", "minLength": 1, "maxLength": 64 },
65
- "health": { "enum": ["healthy", "degraded", "unhealthy"] },
66
- "capabilities": { "type": "array", "maxItems": 3, "uniqueItems": true, "items": { "enum": ["traffic", "connections", "close_connection"] } },
67
- "reasonCode": { "type": "string", "minLength": 1, "maxLength": 128 },
68
- "uptimeSeconds": { "type": "integer", "minimum": 0 },
69
- "uploadTotal": { "type": "integer", "minimum": 0, "maximum": 9223372036854775807 },
70
- "downloadTotal": { "type": "integer", "minimum": 0, "maximum": 9223372036854775807 },
71
- "activeConnections": { "type": "integer", "minimum": 0, "maximum": 1000000 }
279
+ "engine": {
280
+ "$ref": "#/$defs/Engine"
281
+ },
282
+ "engineVersion": {
283
+ "type": "string",
284
+ "minLength": 1,
285
+ "maxLength": 64
286
+ },
287
+ "health": {
288
+ "enum": [
289
+ "healthy",
290
+ "degraded",
291
+ "unhealthy"
292
+ ]
293
+ },
294
+ "capabilities": {
295
+ "type": "array",
296
+ "maxItems": 6,
297
+ "uniqueItems": true,
298
+ "items": {
299
+ "enum": [
300
+ "traffic",
301
+ "connections",
302
+ "close_connection",
303
+ "protected_destinations_v1",
304
+ "protection_rules_readback",
305
+ "guarded_dns_tcp_v1"
306
+ ]
307
+ }
308
+ },
309
+ "reasonCode": {
310
+ "type": "string",
311
+ "minLength": 1,
312
+ "maxLength": 128
313
+ },
314
+ "uptimeSeconds": {
315
+ "type": "integer",
316
+ "minimum": 0
317
+ },
318
+ "uploadTotal": {
319
+ "type": "integer",
320
+ "minimum": 0,
321
+ "maximum": 9223372036854775807
322
+ },
323
+ "downloadTotal": {
324
+ "type": "integer",
325
+ "minimum": 0,
326
+ "maximum": 9223372036854775807
327
+ },
328
+ "activeConnections": {
329
+ "type": "integer",
330
+ "minimum": 0,
331
+ "maximum": 1000000
332
+ }
72
333
  }
73
334
  },
74
335
  "Connection": {
75
- "type": "object", "additionalProperties": false,
76
- "required": ["id", "destination", "network", "uploadBytes", "downloadBytes"],
336
+ "type": "object",
337
+ "additionalProperties": false,
338
+ "required": [
339
+ "id",
340
+ "destination",
341
+ "network",
342
+ "uploadBytes",
343
+ "downloadBytes"
344
+ ],
77
345
  "properties": {
78
- "id": { "$ref": "#/$defs/Identifier" },
79
- "destination": { "type": "string", "minLength": 1, "maxLength": 253 },
80
- "network": { "enum": ["tcp", "udp", "other"] },
81
- "uploadBytes": { "type": "integer", "minimum": 0 },
82
- "downloadBytes": { "type": "integer", "minimum": 0 },
83
- "startedAt": { "type": "string", "format": "date-time" }
346
+ "id": {
347
+ "$ref": "#/$defs/Identifier"
348
+ },
349
+ "destination": {
350
+ "type": "string",
351
+ "minLength": 1,
352
+ "maxLength": 253
353
+ },
354
+ "network": {
355
+ "enum": [
356
+ "tcp",
357
+ "udp",
358
+ "other"
359
+ ]
360
+ },
361
+ "uploadBytes": {
362
+ "type": "integer",
363
+ "minimum": 0
364
+ },
365
+ "downloadBytes": {
366
+ "type": "integer",
367
+ "minimum": 0
368
+ },
369
+ "startedAt": {
370
+ "type": "string",
371
+ "format": "date-time"
372
+ }
84
373
  }
85
374
  },
86
375
  "ConnectionsSnapshot": {
87
- "type": "object", "additionalProperties": false,
88
- "required": ["engine", "connections"],
376
+ "type": "object",
377
+ "additionalProperties": false,
378
+ "required": [
379
+ "engine",
380
+ "connections"
381
+ ],
89
382
  "properties": {
90
- "engine": { "enum": ["mihomo", "sing-box"] },
91
- "connections": { "type": "array", "maxItems": 200, "items": { "$ref": "#/$defs/Connection" } }
383
+ "engine": {
384
+ "enum": [
385
+ "mihomo",
386
+ "sing-box"
387
+ ]
388
+ },
389
+ "connections": {
390
+ "type": "array",
391
+ "maxItems": 200,
392
+ "items": {
393
+ "$ref": "#/$defs/Connection"
394
+ }
395
+ }
92
396
  }
93
397
  },
94
398
  "ConnectionCloseRequest": {
95
- "type": "object", "additionalProperties": false,
96
- "required": ["commandId", "connectionId", "expiresAt"],
399
+ "type": "object",
400
+ "additionalProperties": false,
401
+ "required": [
402
+ "commandId",
403
+ "connectionId",
404
+ "expiresAt"
405
+ ],
97
406
  "properties": {
98
- "commandId": { "$ref": "#/$defs/Identifier" },
99
- "connectionId": { "$ref": "#/$defs/Identifier" },
100
- "expiresAt": { "type": "string", "format": "date-time" }
407
+ "commandId": {
408
+ "$ref": "#/$defs/Identifier"
409
+ },
410
+ "connectionId": {
411
+ "$ref": "#/$defs/Identifier"
412
+ },
413
+ "expiresAt": {
414
+ "type": "string",
415
+ "format": "date-time"
416
+ }
101
417
  }
102
418
  },
103
419
  "ConnectionCloseResult": {
104
- "type": "object", "additionalProperties": false,
105
- "required": ["commandId", "status"],
420
+ "type": "object",
421
+ "additionalProperties": false,
422
+ "required": [
423
+ "commandId",
424
+ "status"
425
+ ],
106
426
  "properties": {
107
- "commandId": { "$ref": "#/$defs/Identifier" },
108
- "status": { "enum": ["closed", "not-found", "failed"] },
109
- "reasonCode": { "type": "string", "minLength": 1, "maxLength": 128 }
427
+ "commandId": {
428
+ "$ref": "#/$defs/Identifier"
429
+ },
430
+ "status": {
431
+ "enum": [
432
+ "closed",
433
+ "not-found",
434
+ "failed"
435
+ ]
436
+ },
437
+ "reasonCode": {
438
+ "type": "string",
439
+ "minLength": 1,
440
+ "maxLength": 128
441
+ }
110
442
  }
443
+ },
444
+ "Binding": {
445
+ "type": "object",
446
+ "additionalProperties": false,
447
+ "required": [
448
+ "siteId",
449
+ "deviceId",
450
+ "resourceIds"
451
+ ],
452
+ "properties": {
453
+ "siteId": {
454
+ "$ref": "#/$defs/Identifier"
455
+ },
456
+ "deviceId": {
457
+ "$ref": "#/$defs/Identifier"
458
+ },
459
+ "resourceIds": {
460
+ "type": "array",
461
+ "maxItems": 128,
462
+ "uniqueItems": true,
463
+ "items": {
464
+ "$ref": "#/$defs/Identifier"
465
+ }
466
+ }
467
+ }
468
+ },
469
+ "Protection": {
470
+ "type": "object",
471
+ "additionalProperties": false,
472
+ "required": [
473
+ "policyVersion",
474
+ "cidrs",
475
+ "hosts"
476
+ ],
477
+ "properties": {
478
+ "policyVersion": {
479
+ "type": "integer",
480
+ "minimum": 1
481
+ },
482
+ "cidrs": {
483
+ "type": "array",
484
+ "maxItems": 4096,
485
+ "uniqueItems": true,
486
+ "items": {
487
+ "allOf": [
488
+ {
489
+ "$ref": "#/$defs/IPCIDR"
490
+ },
491
+ {
492
+ "not": {
493
+ "enum": [
494
+ "0.0.0.0/0",
495
+ "::/0"
496
+ ]
497
+ }
498
+ }
499
+ ]
500
+ }
501
+ },
502
+ "hosts": {
503
+ "type": "array",
504
+ "maxItems": 2048,
505
+ "uniqueItems": true,
506
+ "items": {
507
+ "type": "string",
508
+ "minLength": 1,
509
+ "maxLength": 253,
510
+ "pattern": "^(?:[A-Za-z0-9](?:[A-Za-z0-9.-]{0,251}[A-Za-z0-9])?|[A-Za-z0-9])$"
511
+ }
512
+ }
513
+ }
514
+ },
515
+ "IPv4CIDR": {
516
+ "type": "string",
517
+ "maxLength": 18,
518
+ "pattern": "^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])/(?:[0-9]|[12][0-9]|3[0-2])$",
519
+ "description": "Canonical IPv4 CIDR; use IPCIDR for either supported address family."
520
+ },
521
+ "IPCIDR": {
522
+ "type": "string",
523
+ "maxLength": 64,
524
+ "pattern": "^(?:(?:(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])\\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])/(?:[1-9]|[12][0-9]|3[0-2])|(?:(?:(?:0|[1-9a-f][0-9a-f]{0,3}):){7}(?:0|[1-9a-f][0-9a-f]{0,3})|(?:(?:0|[1-9a-f][0-9a-f]{0,3}):){1,7}:|(?:(?:0|[1-9a-f][0-9a-f]{0,3}):){1,6}:(?:0|[1-9a-f][0-9a-f]{0,3})|(?:(?:0|[1-9a-f][0-9a-f]{0,3}):){1,5}(?::(?:0|[1-9a-f][0-9a-f]{0,3})){1,2}|(?:(?:0|[1-9a-f][0-9a-f]{0,3}):){1,4}(?::(?:0|[1-9a-f][0-9a-f]{0,3})){1,3}|(?:(?:0|[1-9a-f][0-9a-f]{0,3}):){1,3}(?::(?:0|[1-9a-f][0-9a-f]{0,3})){1,4}|(?:(?:0|[1-9a-f][0-9a-f]{0,3}):){1,2}(?::(?:0|[1-9a-f][0-9a-f]{0,3})){1,5}|(?:0|[1-9a-f][0-9a-f]{0,3}):(?:(?::(?:0|[1-9a-f][0-9a-f]{0,3})){1,6})|:(?:(?::(?:0|[1-9a-f][0-9a-f]{0,3})){1,7}|:))/(?:[1-9]|[1-9][0-9]|1[01][0-9]|12[0-8]))$",
525
+ "description": "Non-default IPv4 or IPv6 CIDR syntax. Core additionally validates canonical network-address bits and compressed address spelling with netip."
111
526
  }
112
527
  }
113
528
  }
@@ -0,0 +1,64 @@
1
+ package openapi
2
+
3
+ import (
4
+ "encoding/json"
5
+ "strings"
6
+ "testing"
7
+ )
8
+
9
+ func TestEndpointChannelControlTransport(t *testing.T) {
10
+ type server struct {
11
+ URL string `json:"url"`
12
+ }
13
+ type operation struct {
14
+ Servers []server `json:"servers"`
15
+ Security []map[string][]string `json:"security"`
16
+ }
17
+ var document struct {
18
+ Servers []server `json:"servers"`
19
+ Paths map[string]struct {
20
+ Servers []server `json:"servers"`
21
+ Get operation `json:"get"`
22
+ Post operation `json:"post"`
23
+ } `json:"paths"`
24
+ Components struct {
25
+ SecuritySchemes map[string]struct {
26
+ Type string `json:"type"`
27
+ } `json:"securitySchemes"`
28
+ } `json:"components"`
29
+ }
30
+ if err := json.Unmarshal(JSON(), &document); err != nil {
31
+ t.Fatal(err)
32
+ }
33
+ for _, suffix := range []string{"", "/receipt"} {
34
+ path := "/network-control/v1/runtimes/{runtimeID}/channel-controls" + suffix
35
+ t.Run(path, func(t *testing.T) {
36
+ item, ok := document.Paths[path]
37
+ if !ok {
38
+ t.Fatal("missing runtime channel control operation")
39
+ }
40
+ op := item.Get
41
+ if suffix != "" {
42
+ op = item.Post
43
+ }
44
+ servers := op.Servers
45
+ if len(servers) == 0 {
46
+ servers = item.Servers
47
+ }
48
+ if len(servers) == 0 {
49
+ servers = document.Servers
50
+ }
51
+ if len(servers) != 1 || strings.TrimSuffix(servers[0].URL, "/")+path != "/api"+path {
52
+ t.Errorf("effective server %v does not target the independent /api/network-control/v1 listener", servers)
53
+ }
54
+ if len(op.Security) != 1 || len(op.Security[0]) != 1 {
55
+ t.Fatal("runtime operations must explicitly require one certificate scheme, without a Bearer alternative")
56
+ }
57
+ for name, scopes := range op.Security[0] {
58
+ if len(scopes) != 0 || document.Components.SecuritySchemes[name].Type != "mutualTLS" {
59
+ t.Errorf("runtime operation requires %q, want a mutualTLS security scheme", name)
60
+ }
61
+ }
62
+ })
63
+ }
64
+ }