@empire-builder-kit/nx 1.0.0-beta.10

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 (243) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +5 -0
  3. package/README.md +34 -0
  4. package/executors.json +74 -0
  5. package/generators.json +40 -0
  6. package/migrations/standard-pre-v1-to-v1.md +11 -0
  7. package/package.json +80 -0
  8. package/src/blueprints/execution.d.ts +31 -0
  9. package/src/blueprints/execution.js +166 -0
  10. package/src/blueprints/execution.js.map +1 -0
  11. package/src/blueprints/index.d.ts +5 -0
  12. package/src/blueprints/index.js +9 -0
  13. package/src/blueprints/index.js.map +1 -0
  14. package/src/blueprints/inputs.d.ts +43 -0
  15. package/src/blueprints/inputs.js +103 -0
  16. package/src/blueprints/inputs.js.map +1 -0
  17. package/src/blueprints/manifest.d.ts +281 -0
  18. package/src/blueprints/manifest.js +441 -0
  19. package/src/blueprints/manifest.js.map +1 -0
  20. package/src/blueprints/resolver.d.ts +28 -0
  21. package/src/blueprints/resolver.js +218 -0
  22. package/src/blueprints/resolver.js.map +1 -0
  23. package/src/blueprints/transitions.d.ts +20 -0
  24. package/src/blueprints/transitions.js +61 -0
  25. package/src/blueprints/transitions.js.map +1 -0
  26. package/src/executors/deploy/deploy.d.ts +4 -0
  27. package/src/executors/deploy/deploy.js +6 -0
  28. package/src/executors/deploy/deploy.js.map +1 -0
  29. package/src/executors/deployment-plan/deployment-plan.d.ts +9 -0
  30. package/src/executors/deployment-plan/deployment-plan.js +50 -0
  31. package/src/executors/deployment-plan/deployment-plan.js.map +1 -0
  32. package/src/executors/deployment-plan/schema.json +24 -0
  33. package/src/executors/dev/dev.d.ts +4 -0
  34. package/src/executors/dev/dev.js +6 -0
  35. package/src/executors/dev/dev.js.map +1 -0
  36. package/src/executors/dev-doctor/dev-doctor.d.ts +31 -0
  37. package/src/executors/dev-doctor/dev-doctor.js +260 -0
  38. package/src/executors/dev-doctor/dev-doctor.js.map +1 -0
  39. package/src/executors/dev-doctor/schema.json +17 -0
  40. package/src/executors/dev-setup/dev-setup.d.ts +11 -0
  41. package/src/executors/dev-setup/dev-setup.js +454 -0
  42. package/src/executors/dev-setup/dev-setup.js.map +1 -0
  43. package/src/executors/dev-setup/schema.json +16 -0
  44. package/src/executors/fleet/fleet.d.ts +62 -0
  45. package/src/executors/fleet/fleet.js +613 -0
  46. package/src/executors/fleet/fleet.js.map +1 -0
  47. package/src/executors/fleet/schema.json +37 -0
  48. package/src/executors/foundation-preflight/foundation-preflight.d.ts +15 -0
  49. package/src/executors/foundation-preflight/foundation-preflight.js +116 -0
  50. package/src/executors/foundation-preflight/foundation-preflight.js.map +1 -0
  51. package/src/executors/foundation-preflight/schema.json +31 -0
  52. package/src/executors/foundation-profile-preflight/foundation-profile-preflight.d.ts +8 -0
  53. package/src/executors/foundation-profile-preflight/foundation-profile-preflight.js +41 -0
  54. package/src/executors/foundation-profile-preflight/foundation-profile-preflight.js.map +1 -0
  55. package/src/executors/foundation-profile-preflight/schema.json +21 -0
  56. package/src/executors/foundation-remove-preflight/foundation-remove-preflight.d.ts +13 -0
  57. package/src/executors/foundation-remove-preflight/foundation-remove-preflight.js +69 -0
  58. package/src/executors/foundation-remove-preflight/foundation-remove-preflight.js.map +1 -0
  59. package/src/executors/foundation-remove-preflight/schema.json +17 -0
  60. package/src/executors/github-bootstrap/github-bootstrap.d.ts +8 -0
  61. package/src/executors/github-bootstrap/github-bootstrap.js +30 -0
  62. package/src/executors/github-bootstrap/github-bootstrap.js.map +1 -0
  63. package/src/executors/github-bootstrap/schema.json +25 -0
  64. package/src/executors/refresh/refresh.d.ts +4 -0
  65. package/src/executors/refresh/refresh.js +6 -0
  66. package/src/executors/refresh/refresh.js.map +1 -0
  67. package/src/executors/remove/remove.d.ts +4 -0
  68. package/src/executors/remove/remove.js +6 -0
  69. package/src/executors/remove/remove.js.map +1 -0
  70. package/src/executors/sst-lifecycle/run-sst-command.d.ts +31 -0
  71. package/src/executors/sst-lifecycle/run-sst-command.js +226 -0
  72. package/src/executors/sst-lifecycle/run-sst-command.js.map +1 -0
  73. package/src/executors/sst-lifecycle/schema.json +45 -0
  74. package/src/executors/unlock/unlock.d.ts +4 -0
  75. package/src/executors/unlock/unlock.js +6 -0
  76. package/src/executors/unlock/unlock.js.map +1 -0
  77. package/src/executors/work-markers/schema.json +14 -0
  78. package/src/executors/work-markers/work-markers.d.ts +6 -0
  79. package/src/executors/work-markers/work-markers.js +20 -0
  80. package/src/executors/work-markers/work-markers.js.map +1 -0
  81. package/src/foundation/aurora-logical-database.d.ts +76 -0
  82. package/src/foundation/aurora-logical-database.js +419 -0
  83. package/src/foundation/aurora-logical-database.js.map +1 -0
  84. package/src/foundation/discovery.d.ts +55 -0
  85. package/src/foundation/discovery.js +55 -0
  86. package/src/foundation/discovery.js.map +1 -0
  87. package/src/foundation/index.d.ts +6 -0
  88. package/src/foundation/index.js +10 -0
  89. package/src/foundation/index.js.map +1 -0
  90. package/src/foundation/local-database-contract.d.ts +30 -0
  91. package/src/foundation/local-database-contract.js +75 -0
  92. package/src/foundation/local-database-contract.js.map +1 -0
  93. package/src/foundation/preflight.d.ts +31 -0
  94. package/src/foundation/preflight.js +114 -0
  95. package/src/foundation/preflight.js.map +1 -0
  96. package/src/foundation/provision-database-bindings.d.ts +30 -0
  97. package/src/foundation/provision-database-bindings.js +113 -0
  98. package/src/foundation/provision-database-bindings.js.map +1 -0
  99. package/src/foundation/provision-logical-database.d.ts +26 -0
  100. package/src/foundation/provision-logical-database.js +163 -0
  101. package/src/foundation/provision-logical-database.js.map +1 -0
  102. package/src/foundation/requirements.d.ts +37 -0
  103. package/src/foundation/requirements.js +141 -0
  104. package/src/foundation/requirements.js.map +1 -0
  105. package/src/foundation/stages.d.ts +14 -0
  106. package/src/foundation/stages.js +51 -0
  107. package/src/foundation/stages.js.map +1 -0
  108. package/src/generators/function/function.d.ts +13 -0
  109. package/src/generators/function/function.js +71 -0
  110. package/src/generators/function/function.js.map +1 -0
  111. package/src/generators/function/schema.d.ts +5 -0
  112. package/src/generators/function/schema.json +20 -0
  113. package/src/generators/job/job.d.ts +4 -0
  114. package/src/generators/job/job.js +5 -0
  115. package/src/generators/job/job.js.map +1 -0
  116. package/src/generators/preset/generator.d.ts +5 -0
  117. package/src/generators/preset/generator.js +41 -0
  118. package/src/generators/preset/generator.js.map +1 -0
  119. package/src/generators/preset/schema.d.ts +4 -0
  120. package/src/generators/preset/schema.json +22 -0
  121. package/src/generators/preset/workspace-files.d.ts +18 -0
  122. package/src/generators/preset/workspace-files.js +1605 -0
  123. package/src/generators/preset/workspace-files.js.map +1 -0
  124. package/src/generators/repository-policy/repository-policy.d.ts +4 -0
  125. package/src/generators/repository-policy/repository-policy.js +107 -0
  126. package/src/generators/repository-policy/repository-policy.js.map +1 -0
  127. package/src/generators/repository-policy/schema.d.ts +18 -0
  128. package/src/generators/repository-policy/schema.json +46 -0
  129. package/src/generators/service/service.d.ts +4 -0
  130. package/src/generators/service/service.js +5 -0
  131. package/src/generators/service/service.js.map +1 -0
  132. package/src/generators/slice/schema.d.ts +7 -0
  133. package/src/generators/slice/schema.json +38 -0
  134. package/src/generators/slice/slice.d.ts +26 -0
  135. package/src/generators/slice/slice.js +1698 -0
  136. package/src/generators/slice/slice.js.map +1 -0
  137. package/src/generators/upgrade/schema.d.ts +8 -0
  138. package/src/generators/upgrade/schema.json +31 -0
  139. package/src/generators/upgrade/upgrade.d.ts +27 -0
  140. package/src/generators/upgrade/upgrade.js +682 -0
  141. package/src/generators/upgrade/upgrade.js.map +1 -0
  142. package/src/generators/workload/schema.d.ts +6 -0
  143. package/src/generators/workload/schema.json +21 -0
  144. package/src/generators/workload/workload.d.ts +16 -0
  145. package/src/generators/workload/workload.js +157 -0
  146. package/src/generators/workload/workload.js.map +1 -0
  147. package/src/git-policy/action-pins.d.ts +28 -0
  148. package/src/git-policy/action-pins.js +35 -0
  149. package/src/git-policy/action-pins.js.map +1 -0
  150. package/src/git-policy/github-bootstrap.d.ts +23 -0
  151. package/src/git-policy/github-bootstrap.js +759 -0
  152. package/src/git-policy/github-bootstrap.js.map +1 -0
  153. package/src/git-policy/index.d.ts +3 -0
  154. package/src/git-policy/index.js +7 -0
  155. package/src/git-policy/index.js.map +1 -0
  156. package/src/git-policy/routing.d.ts +15 -0
  157. package/src/git-policy/routing.js +77 -0
  158. package/src/git-policy/routing.js.map +1 -0
  159. package/src/index.d.ts +8 -0
  160. package/src/index.js +12 -0
  161. package/src/index.js.map +1 -0
  162. package/src/local-dev/contracts.d.ts +31 -0
  163. package/src/local-dev/contracts.js +126 -0
  164. package/src/local-dev/contracts.js.map +1 -0
  165. package/src/local-dev/effects.d.ts +16 -0
  166. package/src/local-dev/effects.js +63 -0
  167. package/src/local-dev/effects.js.map +1 -0
  168. package/src/local-dev/gateway-daemon.d.ts +4 -0
  169. package/src/local-dev/gateway-daemon.js +39 -0
  170. package/src/local-dev/gateway-daemon.js.map +1 -0
  171. package/src/local-dev/gateway.d.ts +60 -0
  172. package/src/local-dev/gateway.js +368 -0
  173. package/src/local-dev/gateway.js.map +1 -0
  174. package/src/local-dev/identity.d.ts +16 -0
  175. package/src/local-dev/identity.js +101 -0
  176. package/src/local-dev/identity.js.map +1 -0
  177. package/src/local-dev/index.d.ts +7 -0
  178. package/src/local-dev/index.js +11 -0
  179. package/src/local-dev/index.js.map +1 -0
  180. package/src/local-dev/portless.d.ts +15 -0
  181. package/src/local-dev/portless.js +115 -0
  182. package/src/local-dev/portless.js.map +1 -0
  183. package/src/local-dev/ports.d.ts +10 -0
  184. package/src/local-dev/ports.js +39 -0
  185. package/src/local-dev/ports.js.map +1 -0
  186. package/src/local-dev/proxy.d.ts +37 -0
  187. package/src/local-dev/proxy.js +271 -0
  188. package/src/local-dev/proxy.js.map +1 -0
  189. package/src/local-dev/tls.d.ts +24 -0
  190. package/src/local-dev/tls.js +294 -0
  191. package/src/local-dev/tls.js.map +1 -0
  192. package/src/ownership/composition.d.ts +16 -0
  193. package/src/ownership/composition.js +125 -0
  194. package/src/ownership/composition.js.map +1 -0
  195. package/src/ownership/foundation-record.d.ts +66 -0
  196. package/src/ownership/foundation-record.js +108 -0
  197. package/src/ownership/foundation-record.js.map +1 -0
  198. package/src/ownership/hash.d.ts +2 -0
  199. package/src/ownership/hash.js +10 -0
  200. package/src/ownership/hash.js.map +1 -0
  201. package/src/ownership/index.d.ts +6 -0
  202. package/src/ownership/index.js +10 -0
  203. package/src/ownership/index.js.map +1 -0
  204. package/src/ownership/json-ownership.d.ts +13 -0
  205. package/src/ownership/json-ownership.js +147 -0
  206. package/src/ownership/json-ownership.js.map +1 -0
  207. package/src/ownership/record.d.ts +186 -0
  208. package/src/ownership/record.js +336 -0
  209. package/src/ownership/record.js.map +1 -0
  210. package/src/ownership/workspace-record.d.ts +66 -0
  211. package/src/ownership/workspace-record.js +108 -0
  212. package/src/ownership/workspace-record.js.map +1 -0
  213. package/src/repository-policy/aurora-preflight.d.ts +15 -0
  214. package/src/repository-policy/aurora-preflight.js +45 -0
  215. package/src/repository-policy/aurora-preflight.js.map +1 -0
  216. package/src/repository-policy/deployment-plan.d.ts +24 -0
  217. package/src/repository-policy/deployment-plan.js +124 -0
  218. package/src/repository-policy/deployment-plan.js.map +1 -0
  219. package/src/repository-policy/foundation-profile.d.ts +20 -0
  220. package/src/repository-policy/foundation-profile.js +45 -0
  221. package/src/repository-policy/foundation-profile.js.map +1 -0
  222. package/src/repository-policy/index.d.ts +4 -0
  223. package/src/repository-policy/index.js +8 -0
  224. package/src/repository-policy/index.js.map +1 -0
  225. package/src/repository-policy/policy.d.ts +59 -0
  226. package/src/repository-policy/policy.js +274 -0
  227. package/src/repository-policy/policy.js.map +1 -0
  228. package/src/schemas/blueprint-input-schema-v1.json +23 -0
  229. package/src/schemas/blueprint-v1.json +186 -0
  230. package/src/schemas/foundation-ownership-v2.json +42 -0
  231. package/src/schemas/foundation-requirement-v1.json +32 -0
  232. package/src/schemas/generated-ownership-v2.json +117 -0
  233. package/src/schemas/repository-policy-v1.json +58 -0
  234. package/src/schemas/workspace-ownership-v2.json +42 -0
  235. package/src/validation.d.ts +14 -0
  236. package/src/validation.js +14 -0
  237. package/src/validation.js.map +1 -0
  238. package/src/work-markers/index.d.ts +1 -0
  239. package/src/work-markers/index.js +5 -0
  240. package/src/work-markers/index.js.map +1 -0
  241. package/src/work-markers/work-markers.d.ts +39 -0
  242. package/src/work-markers/work-markers.js +359 -0
  243. package/src/work-markers/work-markers.js.map +1 -0
@@ -0,0 +1,294 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultLocalDevAppData = defaultLocalDevAppData;
4
+ exports.localTlsPaths = localTlsPaths;
5
+ exports.createLocalIpcPath = createLocalIpcPath;
6
+ exports.assertPrivateKeyPermissions = assertPrivateKeyPermissions;
7
+ exports.createLocalTlsState = createLocalTlsState;
8
+ exports.removeLocalTlsState = removeLocalTlsState;
9
+ const node_child_process_1 = require("node:child_process");
10
+ const node_crypto_1 = require("node:crypto");
11
+ const node_fs_1 = require("node:fs");
12
+ const node_os_1 = require("node:os");
13
+ const node_path_1 = require("node:path");
14
+ const identity_js_1 = require("./identity.js");
15
+ function defaultLocalDevAppData(environment = process.env) {
16
+ if ((0, node_os_1.platform)() === 'win32') {
17
+ const base = environment.LOCALAPPDATA;
18
+ if (!base)
19
+ throw new Error('LOCALAPPDATA is required for EBK machine state.');
20
+ return (0, node_path_1.join)(base, 'Empire Builder Kit');
21
+ }
22
+ if ((0, node_os_1.platform)() === 'darwin') {
23
+ return (0, node_path_1.join)((0, node_os_1.homedir)(), 'Library', 'Application Support', 'Empire Builder Kit');
24
+ }
25
+ return (0, node_path_1.join)(environment.XDG_DATA_HOME ?? (0, node_path_1.join)((0, node_os_1.homedir)(), '.local', 'share'), 'empire-builder-kit');
26
+ }
27
+ function localTlsPaths(appData = defaultLocalDevAppData()) {
28
+ return {
29
+ appData,
30
+ capability: (0, node_path_1.join)(appData, 'gateway.capability'),
31
+ intermediateCertificate: (0, node_path_1.join)(appData, 'intermediate.pem'),
32
+ intermediateKey: (0, node_path_1.join)(appData, 'intermediate-key.pem'),
33
+ leafCertificate: (0, node_path_1.join)(appData, 'leaf.pem'),
34
+ leafKey: (0, node_path_1.join)(appData, 'leaf-key.pem'),
35
+ rootCertificate: (0, node_path_1.join)(appData, 'root.pem'),
36
+ rootKey: (0, node_path_1.join)(appData, 'root-key.pem'),
37
+ gatewayPid: (0, node_path_1.join)(appData, 'gateway.pid'),
38
+ gatewayState: (0, node_path_1.join)(appData, 'gateway.json'),
39
+ gatewaySocket: createLocalIpcPath(appData, 'gateway-v1'),
40
+ };
41
+ }
42
+ function createLocalIpcPath(base, identity) {
43
+ const digest = (0, node_crypto_1.createHash)('sha256')
44
+ .update(`${base}\0${identity}`)
45
+ .digest('hex')
46
+ .slice(0, 16);
47
+ if ((0, node_os_1.platform)() === 'win32') {
48
+ return `\\\\.\\pipe\\ebk-${identity.replace(/[^a-zA-Z0-9-]/g, '-').slice(0, 24)}-${digest}`;
49
+ }
50
+ let directory = base;
51
+ while (true) {
52
+ const candidate = (0, node_path_1.join)(directory, `.ebk-${identity}-${digest}.sock`);
53
+ // Darwin's sockaddr_un path is 104 bytes including the terminator. Keep
54
+ // margin for UTF-8 paths and other Unix implementations.
55
+ if (Buffer.byteLength(candidate) <= 95 &&
56
+ ((0, node_fs_1.existsSync)(directory) || directory === base)) {
57
+ return candidate;
58
+ }
59
+ const parent = (0, node_path_1.dirname)(directory);
60
+ if (parent === directory) {
61
+ throw new Error('Unable to derive a portable local IPC socket path.');
62
+ }
63
+ directory = parent;
64
+ }
65
+ }
66
+ function openssl(args, cwd) {
67
+ (0, node_child_process_1.execFileSync)('openssl', args, { cwd, stdio: 'pipe' });
68
+ }
69
+ const WINDOWS_HARDEN_ACL = String.raw `
70
+ $ErrorActionPreference = 'Stop'
71
+ $path = $env:EBK_PRIVATE_PATH
72
+ $kind = $env:EBK_PRIVATE_KIND
73
+ $identity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
74
+ if ($kind -eq 'directory') {
75
+ $info = [System.IO.DirectoryInfo]::new($path)
76
+ } else {
77
+ $info = [System.IO.FileInfo]::new($path)
78
+ }
79
+ $acl = $info.GetAccessControl()
80
+ $acl.SetAccessRuleProtection($true, $false)
81
+ foreach ($rule in @($acl.Access)) {
82
+ [void]$acl.RemoveAccessRuleSpecific($rule)
83
+ }
84
+ if ($kind -eq 'directory') {
85
+ $rule = [System.Security.AccessControl.FileSystemAccessRule]::new(
86
+ $identity.User,
87
+ [System.Security.AccessControl.FileSystemRights]::FullControl,
88
+ [System.Security.AccessControl.InheritanceFlags]'ContainerInherit,ObjectInherit',
89
+ [System.Security.AccessControl.PropagationFlags]::None,
90
+ [System.Security.AccessControl.AccessControlType]::Allow
91
+ )
92
+ } else {
93
+ $rule = [System.Security.AccessControl.FileSystemAccessRule]::new(
94
+ $identity.User,
95
+ [System.Security.AccessControl.FileSystemRights]::FullControl,
96
+ [System.Security.AccessControl.AccessControlType]::Allow
97
+ )
98
+ }
99
+ $acl.AddAccessRule($rule)
100
+ $info.SetAccessControl($acl)
101
+ `;
102
+ const WINDOWS_ASSERT_PRIVATE_ACL = String.raw `
103
+ $ErrorActionPreference = 'Stop'
104
+ $path = $env:EBK_PRIVATE_PATH
105
+ $identity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
106
+ $info = [System.IO.FileInfo]::new($path)
107
+ $acl = $info.GetAccessControl()
108
+ if (-not $acl.AreAccessRulesProtected) {
109
+ throw 'ACL inheritance is enabled.'
110
+ }
111
+ $allowRules = @($acl.Access | Where-Object {
112
+ $_.AccessControlType -eq [System.Security.AccessControl.AccessControlType]::Allow
113
+ })
114
+ $unsafeRules = @($allowRules | Where-Object {
115
+ $_.IdentityReference.Translate([System.Security.Principal.SecurityIdentifier]).Value -ne $identity.User.Value
116
+ })
117
+ $selfRules = @($allowRules | Where-Object {
118
+ $_.IdentityReference.Translate([System.Security.Principal.SecurityIdentifier]).Value -eq $identity.User.Value
119
+ })
120
+ if ($unsafeRules.Count -ne 0 -or $selfRules.Count -eq 0) {
121
+ throw 'ACL grants access beyond the current user or omits the current user.'
122
+ }
123
+ `;
124
+ function windowsPowerShell(script, environment) {
125
+ const executable = (0, node_path_1.join)(process.env.SystemRoot ?? 'C:\\Windows', 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe');
126
+ const encodedCommand = Buffer.from(script, 'utf16le').toString('base64');
127
+ (0, node_child_process_1.execFileSync)(executable, [
128
+ '-NoLogo',
129
+ '-NoProfile',
130
+ '-NonInteractive',
131
+ '-EncodedCommand',
132
+ encodedCommand,
133
+ ], {
134
+ env: { ...process.env, ...environment },
135
+ stdio: 'pipe',
136
+ timeout: 15_000,
137
+ windowsHide: true,
138
+ });
139
+ }
140
+ function hardenPrivatePath(path, kind) {
141
+ if ((0, node_os_1.platform)() === 'win32') {
142
+ windowsPowerShell(WINDOWS_HARDEN_ACL, {
143
+ EBK_PRIVATE_KIND: kind,
144
+ EBK_PRIVATE_PATH: path,
145
+ });
146
+ return;
147
+ }
148
+ (0, node_fs_1.chmodSync)(path, kind === 'directory' ? 0o700 : 0o600);
149
+ }
150
+ function assertPrivateKeyPermissions(path) {
151
+ if ((0, node_os_1.platform)() === 'win32') {
152
+ try {
153
+ windowsPowerShell(WINDOWS_ASSERT_PRIVATE_ACL, {
154
+ EBK_PRIVATE_PATH: path,
155
+ });
156
+ }
157
+ catch {
158
+ throw new Error(`${path} must have an inheritance-disabled ACL granting access only to the current user.`);
159
+ }
160
+ return;
161
+ }
162
+ const mode = (0, node_fs_1.statSync)(path).mode & 0o777;
163
+ if ((mode & 0o077) !== 0) {
164
+ throw new Error(`${path} must not be readable or writable by group or other users.`);
165
+ }
166
+ }
167
+ function createLocalTlsState(options) {
168
+ const paths = localTlsPaths(options.appData);
169
+ const hostSuffix = (0, identity_js_1.normalizeFleetHostSuffix)(options.hostSuffix);
170
+ if ((0, node_fs_1.existsSync)(paths.rootCertificate) && !options.force) {
171
+ throw new Error(`EBK local TLS state already exists at ${paths.appData}; use the explicit upgrade path to replace it.`);
172
+ }
173
+ if (options.force)
174
+ (0, node_fs_1.rmSync)(paths.appData, { force: true, recursive: true });
175
+ (0, node_fs_1.mkdirSync)(paths.appData, { mode: 0o700, recursive: true });
176
+ hardenPrivatePath(paths.appData, 'directory');
177
+ const intermediateExt = (0, node_path_1.join)(paths.appData, 'intermediate.ext');
178
+ const leafExt = (0, node_path_1.join)(paths.appData, 'leaf.ext');
179
+ (0, node_fs_1.writeFileSync)(intermediateExt, `basicConstraints=critical,CA:TRUE,pathlen:0\nkeyUsage=critical,keyCertSign,cRLSign\nnameConstraints=critical,permitted;DNS:.${hostSuffix},permitted;DNS:*.${hostSuffix},excluded;IP:0.0.0.0/0.0.0.0,excluded;IP:0:0:0:0:0:0:0:0/0:0:0:0:0:0:0:0\nsubjectKeyIdentifier=hash\nauthorityKeyIdentifier=keyid,issuer\n`, { mode: 0o600 });
180
+ (0, node_fs_1.writeFileSync)(leafExt, `basicConstraints=critical,CA:FALSE\nkeyUsage=critical,digitalSignature,keyEncipherment\nextendedKeyUsage=serverAuth\nsubjectAltName=DNS:*.${hostSuffix}\nauthorityKeyIdentifier=keyid,issuer\n`, { mode: 0o600 });
181
+ try {
182
+ openssl(['genrsa', '-out', paths.rootKey, '3072'], paths.appData);
183
+ openssl([
184
+ 'req',
185
+ '-x509',
186
+ '-new',
187
+ '-key',
188
+ paths.rootKey,
189
+ '-sha256',
190
+ '-days',
191
+ '3650',
192
+ '-subj',
193
+ '/CN=Empire Builder Kit Local Root',
194
+ '-out',
195
+ paths.rootCertificate,
196
+ '-addext',
197
+ 'basicConstraints=critical,CA:TRUE,pathlen:1',
198
+ '-addext',
199
+ 'keyUsage=critical,keyCertSign,cRLSign',
200
+ '-addext',
201
+ 'subjectKeyIdentifier=hash',
202
+ ], paths.appData);
203
+ openssl(['genrsa', '-out', paths.intermediateKey, '3072'], paths.appData);
204
+ openssl([
205
+ 'req',
206
+ '-new',
207
+ '-key',
208
+ paths.intermediateKey,
209
+ '-subj',
210
+ '/CN=Empire Builder Kit Local Intermediate',
211
+ '-out',
212
+ 'intermediate.csr',
213
+ ], paths.appData);
214
+ openssl([
215
+ 'x509',
216
+ '-req',
217
+ '-in',
218
+ 'intermediate.csr',
219
+ '-CA',
220
+ paths.rootCertificate,
221
+ '-CAkey',
222
+ paths.rootKey,
223
+ '-CAcreateserial',
224
+ '-out',
225
+ paths.intermediateCertificate,
226
+ '-days',
227
+ '1825',
228
+ '-sha256',
229
+ '-extfile',
230
+ intermediateExt,
231
+ ], paths.appData);
232
+ openssl(['genrsa', '-out', paths.leafKey, '2048'], paths.appData);
233
+ openssl([
234
+ 'req',
235
+ '-new',
236
+ '-key',
237
+ paths.leafKey,
238
+ '-subj',
239
+ `/CN=gateway.${hostSuffix}`,
240
+ '-out',
241
+ 'leaf.csr',
242
+ ], paths.appData);
243
+ openssl([
244
+ 'x509',
245
+ '-req',
246
+ '-in',
247
+ 'leaf.csr',
248
+ '-CA',
249
+ paths.intermediateCertificate,
250
+ '-CAkey',
251
+ paths.intermediateKey,
252
+ '-CAcreateserial',
253
+ '-out',
254
+ 'leaf-only.pem',
255
+ '-days',
256
+ '397',
257
+ '-sha256',
258
+ '-extfile',
259
+ leafExt,
260
+ ], paths.appData);
261
+ (0, node_fs_1.writeFileSync)(paths.leafCertificate, `${(0, node_fs_1.readFileSync)((0, node_path_1.join)(paths.appData, 'leaf-only.pem'), 'utf8').trim()}\n${(0, node_fs_1.readFileSync)(paths.intermediateCertificate, 'utf8').trim()}\n`, { mode: 0o600 });
262
+ (0, node_fs_1.writeFileSync)(paths.capability, `${options.capability}\n`, { mode: 0o600 });
263
+ hardenPrivatePath(paths.intermediateKey, 'file');
264
+ hardenPrivatePath(paths.leafKey, 'file');
265
+ hardenPrivatePath(paths.capability, 'file');
266
+ assertPrivateKeyPermissions(paths.intermediateKey);
267
+ assertPrivateKeyPermissions(paths.leafKey);
268
+ }
269
+ finally {
270
+ (0, node_fs_1.rmSync)(paths.rootKey, { force: true });
271
+ for (const file of [
272
+ 'intermediate.ext',
273
+ 'leaf.ext',
274
+ 'intermediate.csr',
275
+ 'leaf.csr',
276
+ 'leaf-only.pem',
277
+ 'root.srl',
278
+ 'intermediate.srl',
279
+ ]) {
280
+ (0, node_fs_1.rmSync)((0, node_path_1.join)(paths.appData, file), { force: true });
281
+ }
282
+ }
283
+ if ((0, node_fs_1.existsSync)(paths.rootKey)) {
284
+ throw new Error('Root signing key must not remain in gateway runtime state.');
285
+ }
286
+ return paths;
287
+ }
288
+ function removeLocalTlsState(appData = defaultLocalDevAppData()) {
289
+ const socket = localTlsPaths(appData).gatewaySocket;
290
+ if ((0, node_os_1.platform)() !== 'win32')
291
+ (0, node_fs_1.rmSync)(socket, { force: true });
292
+ (0, node_fs_1.rmSync)(appData, { force: true, recursive: true });
293
+ }
294
+ //# sourceMappingURL=tls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tls.js","sourceRoot":"","sources":["../../../../../packages/nx/src/local-dev/tls.ts"],"names":[],"mappings":";;AA6BA,wDAqBC;AAED,sCAgBC;AAED,gDAyBC;AAwGD,kEAmBC;AAED,kDA0JC;AAED,kDAIC;AA5XD,2DAAkD;AAClD,6CAAyC;AACzC,qCAQiB;AACjB,qCAA4C;AAC5C,yCAA0C;AAC1C,+CAAyD;AAgBzD,SAAgB,sBAAsB,CACpC,cAAiC,OAAO,CAAC,GAAG;IAE5C,IAAI,IAAA,kBAAQ,GAAE,KAAK,OAAO,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,WAAW,CAAC,YAAY,CAAC;QACtC,IAAI,CAAC,IAAI;YACP,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACrE,OAAO,IAAA,gBAAI,EAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;IAC1C,CAAC;IACD,IAAI,IAAA,kBAAQ,GAAE,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,IAAA,gBAAI,E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;YACf,UAAU;YACV,kBAAkB;SACnB,EAAE,CAAC;YACF,IAAA,gBAAM,EAAC,IAAA,gBAAI,EAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;IACD,IAAI,IAAA,oBAAU,EAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CACb,4DAA4D,CAC7D,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAgB,mBAAmB,CAAC,OAAO,GAAG,sBAAsB,EAAE;IACpE,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC;IACpD,IAAI,IAAA,kBAAQ,GAAE,KAAK,OAAO;QAAE,IAAA,gBAAM,EAAC,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5D,IAAA,gBAAM,EAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AACpD,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { Tree } from '@nx/devkit';
2
+ import { type GeneratedPathMode } from './record.js';
3
+ export interface CompositionOwnedPath {
4
+ managedJsonPointers?: string[];
5
+ mode?: GeneratedPathMode;
6
+ path: string;
7
+ }
8
+ export interface RecordCompositionOwnershipOptions {
9
+ paths: CompositionOwnedPath[];
10
+ projects?: string[];
11
+ slice: string;
12
+ }
13
+ export declare function restampProductSliceOwnership(tree: Tree, slice: string): void;
14
+ export declare function restampFoundationOwnership(tree: Tree): void;
15
+ export declare function restampWorkspaceOwnership(tree: Tree): void;
16
+ export declare function recordCompositionOwnership(tree: Tree, options: RecordCompositionOwnershipOptions): void;
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.restampProductSliceOwnership = restampProductSliceOwnership;
4
+ exports.restampFoundationOwnership = restampFoundationOwnership;
5
+ exports.restampWorkspaceOwnership = restampWorkspaceOwnership;
6
+ exports.recordCompositionOwnership = recordCompositionOwnership;
7
+ const node_path_1 = require("node:path");
8
+ const json_ownership_js_1 = require("./json-ownership.js");
9
+ const foundation_record_js_1 = require("./foundation-record.js");
10
+ const record_js_1 = require("./record.js");
11
+ const workspace_record_js_1 = require("./workspace-record.js");
12
+ function json(value) {
13
+ return `${JSON.stringify(value, null, 2)}\n`;
14
+ }
15
+ function restampProductSliceOwnership(tree, slice) {
16
+ const root = node_path_1.posix.join('packages', slice);
17
+ const ownershipPath = node_path_1.posix.join(root, '.ebk/ownership.json');
18
+ const source = tree.read(ownershipPath, 'utf8');
19
+ if (source === null) {
20
+ throw new Error(`Product Slice ownership metadata is missing at ${ownershipPath}.`);
21
+ }
22
+ const result = (0, record_js_1.validateGeneratedOwnershipRecord)(JSON.parse(source));
23
+ if (!result.valid) {
24
+ throw new Error('Product Slice ownership metadata is invalid after generation.');
25
+ }
26
+ tree.write(ownershipPath, json({
27
+ ...result.value,
28
+ paths: result.value.paths.map((entry) => {
29
+ const contents = tree.read(node_path_1.posix.join(root, entry.path), 'utf8');
30
+ if (contents === null) {
31
+ throw new Error(`Generated owned path does not exist: ${entry.path}.`);
32
+ }
33
+ return { ...entry, sha256: (0, json_ownership_js_1.hashOwnedContent)(contents, entry) };
34
+ }),
35
+ }));
36
+ }
37
+ function restampFoundationOwnership(tree) {
38
+ const root = 'packages/foundation';
39
+ const ownershipPath = node_path_1.posix.join(root, '.ebk/ownership.json');
40
+ const source = tree.read(ownershipPath, 'utf8');
41
+ if (source === null) {
42
+ throw new Error('Standard Foundation ownership metadata is missing.');
43
+ }
44
+ const result = (0, foundation_record_js_1.validateFoundationOwnershipRecord)(JSON.parse(source));
45
+ if (!result.valid) {
46
+ throw new Error('Standard Foundation ownership metadata is invalid after generation.');
47
+ }
48
+ tree.write(ownershipPath, json({
49
+ ...result.value,
50
+ paths: result.value.paths.map((entry) => {
51
+ const contents = tree.read(node_path_1.posix.join(root, entry.path), 'utf8');
52
+ if (contents === null) {
53
+ throw new Error(`Generated Foundation path does not exist: ${entry.path}.`);
54
+ }
55
+ return { ...entry, sha256: (0, json_ownership_js_1.hashOwnedContent)(contents, entry) };
56
+ }),
57
+ }));
58
+ }
59
+ function restampWorkspaceOwnership(tree) {
60
+ const ownershipPath = '.ebk/ownership.json';
61
+ const source = tree.read(ownershipPath, 'utf8');
62
+ if (source === null) {
63
+ throw new Error('Workspace ownership metadata is missing.');
64
+ }
65
+ const result = (0, workspace_record_js_1.validateWorkspaceOwnershipRecord)(JSON.parse(source));
66
+ if (!result.valid) {
67
+ throw new Error('Workspace ownership metadata is invalid after generation.');
68
+ }
69
+ tree.write(ownershipPath, json({
70
+ ...result.value,
71
+ paths: result.value.paths.map((entry) => {
72
+ const contents = tree.read(entry.path, 'utf8');
73
+ if (contents === null) {
74
+ throw new Error(`Generated workspace path does not exist: ${entry.path}.`);
75
+ }
76
+ return { ...entry, sha256: (0, json_ownership_js_1.hashOwnedContent)(contents, entry) };
77
+ }),
78
+ }));
79
+ }
80
+ function recordCompositionOwnership(tree, options) {
81
+ const root = node_path_1.posix.join('packages', options.slice);
82
+ const ownershipPath = node_path_1.posix.join(root, '.ebk/ownership.json');
83
+ const source = tree.read(ownershipPath, 'utf8');
84
+ if (source === null) {
85
+ throw new Error(`Product Slice ownership metadata is missing at ${ownershipPath}.`);
86
+ }
87
+ let parsed;
88
+ try {
89
+ parsed = JSON.parse(source);
90
+ }
91
+ catch (error) {
92
+ throw new Error(`Product Slice ownership metadata is not valid JSON: ${error instanceof Error ? error.message : String(error)}`);
93
+ }
94
+ const result = (0, record_js_1.validateGeneratedOwnershipRecord)(parsed);
95
+ if (!result.valid) {
96
+ throw new Error(`Product Slice ownership metadata is invalid:\n${result.issues
97
+ .map((issue) => `- ${issue.path}: ${issue.message}`)
98
+ .join('\n')}`);
99
+ }
100
+ const paths = new Map(result.value.paths.map((entry) => [entry.path, entry]));
101
+ for (const owned of options.paths) {
102
+ const contents = tree.read(node_path_1.posix.join(root, owned.path), 'utf8');
103
+ if (contents === null) {
104
+ throw new Error(`Composed owned path does not exist: ${owned.path}.`);
105
+ }
106
+ const previous = paths.get(owned.path);
107
+ const managedJsonPointers = owned.managedJsonPointers ?? previous?.managedJsonPointers;
108
+ paths.set(owned.path, {
109
+ ...(managedJsonPointers ? { managedJsonPointers } : {}),
110
+ mode: owned.mode ?? 'managed',
111
+ origin: previous?.origin ?? 'composition',
112
+ path: owned.path,
113
+ sha256: (0, json_ownership_js_1.hashOwnedContent)(contents, { managedJsonPointers }),
114
+ });
115
+ }
116
+ const ownership = {
117
+ ...result.value,
118
+ paths: [...paths.values()].sort((left, right) => left.path.localeCompare(right.path)),
119
+ projects: [
120
+ ...new Set([...result.value.projects, ...(options.projects ?? [])]),
121
+ ].sort(),
122
+ };
123
+ tree.write(ownershipPath, json(ownership));
124
+ }
125
+ //# sourceMappingURL=composition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composition.js","sourceRoot":"","sources":["../../../../../packages/nx/src/ownership/composition.ts"],"names":[],"mappings":";;AA0BA,oEA8BC;AAED,gEA4BC;AAED,8DA2BC;AAED,gEA0DC;AA9KD,yCAAkC;AAClC,2DAAuD;AACvD,iEAA2E;AAC3E,2CAGqB;AACrB,+DAAyE;AAczE,SAAS,IAAI,CAAC,KAAc;IAC1B,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;AAC/C,CAAC;AAED,SAAgB,4BAA4B,CAAC,IAAU,EAAE,KAAa;IACpE,MAAM,IAAI,GAAG,iBAAK,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAC3C,MAAM,aAAa,GAAG,iBAAK,CAAC,IAAI,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAAC;IAC9D,MAAM,MAAM,GAAG,IAAI,CAAC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,CAAC,CAAC,EAAE,CAAC;YACvD,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,SAAS;YAC7B,MAAM,EAAE,QAAQ,EAAE,MAAM,IAAI,aAAa;YACzC,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,MAAM,EAAE,IAAA,oCAAgB,EAAC,QAAQ,EAAE,EAAE,mBAAmB,EAAE,CAAC;SAC5D,CAAC,CAAC;IACL,CAAC;IAED,MAAM,SAAS,GAAG;QAChB,GAAG,MAAM,CAAC,KAAK;QACf,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAC9C,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CACpC;QACD,QAAQ,EAAE;YACR,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,CAAC;SACpE,CAAC,IAAI,EAAE;KACT,CAAC;IACF,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,66 @@
1
+ import { type ValidationResult } from '../validation.js';
2
+ import { type GeneratedPathOwnership } from './record.js';
3
+ export declare const FOUNDATION_OWNERSHIP_SCHEMA_VERSION: 2;
4
+ export interface FoundationOwnershipRecord {
5
+ frameworkVersion: string;
6
+ kind: 'foundation';
7
+ paths: GeneratedPathOwnership[];
8
+ schemaVersion: typeof FOUNDATION_OWNERSHIP_SCHEMA_VERSION;
9
+ }
10
+ export declare function validateFoundationOwnershipRecord(value: unknown): ValidationResult<FoundationOwnershipRecord>;
11
+ export declare const foundationOwnershipSchema: {
12
+ readonly $id: "https://empirebuilderkit.dev/schemas/foundation-ownership-v2.json";
13
+ readonly $schema: "https://json-schema.org/draft/2020-12/schema";
14
+ readonly additionalProperties: false;
15
+ readonly properties: {
16
+ readonly frameworkVersion: {
17
+ readonly minLength: 1;
18
+ readonly type: "string";
19
+ };
20
+ readonly kind: {
21
+ readonly const: "foundation";
22
+ };
23
+ readonly paths: {
24
+ readonly items: {
25
+ readonly additionalProperties: false;
26
+ readonly properties: {
27
+ readonly managedJsonPointers: {
28
+ readonly items: {
29
+ readonly pattern: "^(?:/(?:[^~/]|~[01])*)+$";
30
+ readonly type: "string";
31
+ };
32
+ readonly minItems: 1;
33
+ readonly type: "array";
34
+ readonly uniqueItems: true;
35
+ };
36
+ readonly mode: {
37
+ readonly enum: readonly ["managed", "seeded"];
38
+ };
39
+ readonly origin: {
40
+ readonly const: "framework";
41
+ };
42
+ readonly path: {
43
+ readonly minLength: 1;
44
+ readonly not: {
45
+ readonly pattern: "(^[\\\\/])|(^|[\\\\/])\\.\\.([\\\\/]|$)";
46
+ };
47
+ readonly type: "string";
48
+ };
49
+ readonly sha256: {
50
+ readonly pattern: "^[a-f0-9]{64}$";
51
+ readonly type: "string";
52
+ };
53
+ };
54
+ readonly required: readonly ["path", "mode", "origin", "sha256"];
55
+ readonly type: "object";
56
+ };
57
+ readonly type: "array";
58
+ };
59
+ readonly schemaVersion: {
60
+ readonly const: 2;
61
+ };
62
+ };
63
+ readonly required: readonly ["schemaVersion", "kind", "frameworkVersion", "paths"];
64
+ readonly title: "Empire Builder Kit Standard Foundation Ownership Record v2";
65
+ readonly type: "object";
66
+ };
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.foundationOwnershipSchema = exports.FOUNDATION_OWNERSHIP_SCHEMA_VERSION = void 0;
4
+ exports.validateFoundationOwnershipRecord = validateFoundationOwnershipRecord;
5
+ const validation_js_1 = require("../validation.js");
6
+ const record_js_1 = require("./record.js");
7
+ const hash_js_1 = require("./hash.js");
8
+ exports.FOUNDATION_OWNERSHIP_SCHEMA_VERSION = 2;
9
+ function isSafeWorkspacePath(value) {
10
+ return (value !== '' &&
11
+ !value.startsWith('/') &&
12
+ !value.startsWith('\\') &&
13
+ !value.split(/[\\/]/).includes('..'));
14
+ }
15
+ function validateFoundationOwnershipRecord(value) {
16
+ if (!(0, validation_js_1.isRecord)(value)) {
17
+ return {
18
+ valid: false,
19
+ issues: [{ message: 'must be an object', path: 'ownership' }],
20
+ };
21
+ }
22
+ const issues = [];
23
+ if (value.schemaVersion !== exports.FOUNDATION_OWNERSHIP_SCHEMA_VERSION) {
24
+ issues.push({ message: 'must equal 2', path: 'ownership.schemaVersion' });
25
+ }
26
+ if (value.kind !== 'foundation') {
27
+ issues.push({ message: 'must equal foundation', path: 'ownership.kind' });
28
+ }
29
+ if (typeof value.frameworkVersion !== 'string' ||
30
+ value.frameworkVersion.trim() === '') {
31
+ issues.push({
32
+ message: 'must be a non-empty string',
33
+ path: 'ownership.frameworkVersion',
34
+ });
35
+ }
36
+ if (!Array.isArray(value.paths)) {
37
+ issues.push({ message: 'must be an array', path: 'ownership.paths' });
38
+ }
39
+ else {
40
+ value.paths.forEach((entry, index) => {
41
+ const entryPath = `ownership.paths[${index}]`;
42
+ if (!(0, validation_js_1.isRecord)(entry)) {
43
+ issues.push({ message: 'must be an object', path: entryPath });
44
+ return;
45
+ }
46
+ if (typeof entry.path !== 'string' || !isSafeWorkspacePath(entry.path)) {
47
+ issues.push({
48
+ message: 'must be a safe Foundation-relative path',
49
+ path: `${entryPath}.path`,
50
+ });
51
+ }
52
+ if (!record_js_1.GENERATED_PATH_MODES.includes(entry.mode)) {
53
+ issues.push({
54
+ message: 'must equal managed or seeded',
55
+ path: `${entryPath}.mode`,
56
+ });
57
+ }
58
+ if (entry.origin !== 'framework') {
59
+ issues.push({
60
+ message: 'must equal framework',
61
+ path: `${entryPath}.origin`,
62
+ });
63
+ }
64
+ if (typeof entry.sha256 !== 'string' ||
65
+ !hash_js_1.GENERATED_CONTENT_HASH_PATTERN.test(entry.sha256)) {
66
+ issues.push({
67
+ message: 'must be a lowercase SHA-256 digest',
68
+ path: `${entryPath}.sha256`,
69
+ });
70
+ }
71
+ (0, record_js_1.validateManagedJsonPointers)(entry, entryPath, issues);
72
+ });
73
+ }
74
+ return (0, validation_js_1.validationResult)(value, issues);
75
+ }
76
+ exports.foundationOwnershipSchema = {
77
+ $id: 'https://empirebuilderkit.dev/schemas/foundation-ownership-v2.json',
78
+ $schema: 'https://json-schema.org/draft/2020-12/schema',
79
+ additionalProperties: false,
80
+ properties: {
81
+ frameworkVersion: { minLength: 1, type: 'string' },
82
+ kind: { const: 'foundation' },
83
+ paths: {
84
+ items: {
85
+ additionalProperties: false,
86
+ properties: {
87
+ managedJsonPointers: record_js_1.managedJsonPointersSchema,
88
+ mode: { enum: [...record_js_1.GENERATED_PATH_MODES] },
89
+ origin: { const: 'framework' },
90
+ path: {
91
+ minLength: 1,
92
+ not: { pattern: '(^[\\\\/])|(^|[\\\\/])\\.\\.([\\\\/]|$)' },
93
+ type: 'string',
94
+ },
95
+ sha256: { pattern: '^[a-f0-9]{64}$', type: 'string' },
96
+ },
97
+ required: ['path', 'mode', 'origin', 'sha256'],
98
+ type: 'object',
99
+ },
100
+ type: 'array',
101
+ },
102
+ schemaVersion: { const: exports.FOUNDATION_OWNERSHIP_SCHEMA_VERSION },
103
+ },
104
+ required: ['schemaVersion', 'kind', 'frameworkVersion', 'paths'],
105
+ title: 'Empire Builder Kit Standard Foundation Ownership Record v2',
106
+ type: 'object',
107
+ };
108
+ //# sourceMappingURL=foundation-record.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"foundation-record.js","sourceRoot":"","sources":["../../../../../packages/nx/src/ownership/foundation-record.ts"],"names":[],"mappings":";;;AAiCA,8EAmEC;AApGD,oDAK0B;AAC1B,2CAMqB;AACrB,uCAA2D;AAE9C,QAAA,mCAAmC,GAAG,CAAU,CAAC;AAS9D,SAAS,mBAAmB,CAAC,KAAa;IACxC,OAAO,CACL,KAAK,KAAK,EAAE;QACZ,CAAC,KA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function hashGeneratedContent(contents: string): string;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GENERATED_CONTENT_HASH_PATTERN = void 0;
4
+ exports.hashGeneratedContent = hashGeneratedContent;
5
+ const node_crypto_1 = require("node:crypto");
6
+ exports.GENERATED_CONTENT_HASH_PATTERN = /^[a-f0-9]{64}$/;
7
+ function hashGeneratedContent(contents) {
8
+ return (0, node_crypto_1.createHash)('sha256').update(contents, 'utf8').digest('hex');
9
+ }
10
+ //# sourceMappingURL=hash.js.map