@toa.io/extensions.exposition 1.0.0-alpha.4 → 1.0.0-alpha.40

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 (396) hide show
  1. package/components/context.toa.yaml +2 -2
  2. package/components/identity.bans/manifest.toa.yaml +15 -7
  3. package/components/identity.bans/operations/transit.d.ts +14 -0
  4. package/components/identity.bans/operations/transit.js +11 -0
  5. package/components/identity.bans/operations/transit.js.map +1 -0
  6. package/components/identity.bans/operations/tsconfig.tsbuildinfo +1 -0
  7. package/components/identity.bans/source/transit.ts +21 -0
  8. package/components/identity.bans/tsconfig.json +9 -0
  9. package/components/identity.basic/manifest.toa.yaml +22 -9
  10. package/components/identity.basic/operations/authenticate.d.ts +5 -1
  11. package/components/identity.basic/operations/authenticate.js +5 -2
  12. package/components/identity.basic/operations/authenticate.js.map +1 -1
  13. package/components/identity.basic/operations/incept.d.ts +12 -0
  14. package/components/identity.basic/operations/incept.js +26 -0
  15. package/components/identity.basic/operations/incept.js.map +1 -0
  16. package/components/identity.basic/operations/transit.d.ts +4 -4
  17. package/components/identity.basic/operations/transit.js +5 -3
  18. package/components/identity.basic/operations/transit.js.map +1 -1
  19. package/components/identity.basic/operations/tsconfig.tsbuildinfo +1 -1
  20. package/components/identity.basic/operations/types.d.ts +8 -4
  21. package/components/identity.basic/source/authenticate.ts +16 -5
  22. package/components/identity.basic/source/incept.ts +38 -0
  23. package/components/identity.basic/source/transit.ts +8 -6
  24. package/components/identity.basic/source/types.ts +8 -4
  25. package/components/identity.federation/manifest.toa.yaml +28 -22
  26. package/components/identity.federation/operations/authenticate.d.ts +2 -2
  27. package/components/identity.federation/operations/authenticate.js +3 -10
  28. package/components/identity.federation/operations/authenticate.js.map +1 -1
  29. package/components/identity.federation/operations/incept.d.ts +11 -0
  30. package/components/identity.federation/operations/{create.js → incept.js} +6 -7
  31. package/components/identity.federation/operations/incept.js.map +1 -0
  32. package/components/identity.federation/operations/lib/jwt.d.ts +4 -5
  33. package/components/identity.federation/operations/lib/jwt.js +3 -3
  34. package/components/identity.federation/operations/lib/jwt.js.map +1 -1
  35. package/components/identity.federation/operations/tsconfig.tsbuildinfo +1 -1
  36. package/components/identity.federation/operations/types/configuration.d.ts +14 -0
  37. package/components/identity.federation/operations/types/configuration.js +3 -0
  38. package/components/identity.federation/operations/types/configuration.js.map +1 -0
  39. package/components/identity.federation/operations/{types.d.ts → types/context.d.ts} +13 -6
  40. package/components/identity.federation/operations/types/context.js +3 -0
  41. package/components/identity.federation/operations/types/context.js.map +1 -0
  42. package/components/identity.federation/operations/types/entity.d.ts +6 -0
  43. package/components/identity.federation/operations/{types.js → types/entity.js} +1 -1
  44. package/components/identity.federation/operations/types/entity.js.map +1 -0
  45. package/components/identity.federation/operations/types/index.d.ts +3 -0
  46. package/components/identity.federation/operations/types/index.js +20 -0
  47. package/components/identity.federation/operations/types/index.js.map +1 -0
  48. package/components/identity.federation/source/authenticate.ts +5 -18
  49. package/components/identity.federation/source/{create.ts → incept.ts} +10 -9
  50. package/components/identity.federation/source/lib/jwt.test.ts +2 -2
  51. package/components/identity.federation/source/lib/jwt.ts +7 -8
  52. package/components/identity.federation/source/types/configuration.ts +15 -0
  53. package/components/identity.federation/source/{types.ts → types/context.ts} +15 -5
  54. package/components/identity.federation/source/types/entity.ts +6 -0
  55. package/components/identity.federation/source/types/index.ts +3 -0
  56. package/components/identity.federation/tsconfig.json +2 -2
  57. package/components/identity.roles/manifest.toa.yaml +18 -6
  58. package/components/identity.roles/operations/grant.d.ts +10 -0
  59. package/components/identity.roles/operations/grant.js +21 -0
  60. package/components/identity.roles/operations/grant.js.map +1 -0
  61. package/components/identity.roles/operations/lib/Entity.d.ts +5 -0
  62. package/components/identity.roles/operations/lib/Entity.js +3 -0
  63. package/components/identity.roles/operations/lib/Entity.js.map +1 -0
  64. package/components/identity.roles/operations/list.d.ts +1 -4
  65. package/components/identity.roles/operations/list.js.map +1 -1
  66. package/components/identity.roles/operations/principal.d.ts +4 -6
  67. package/components/identity.roles/operations/principal.js +6 -1
  68. package/components/identity.roles/operations/principal.js.map +1 -1
  69. package/components/identity.roles/operations/tsconfig.tsbuildinfo +1 -1
  70. package/components/identity.roles/source/grant.ts +32 -0
  71. package/components/identity.roles/source/lib/Entity.ts +5 -0
  72. package/components/identity.roles/source/list.ts +2 -4
  73. package/components/identity.roles/source/principal.ts +10 -8
  74. package/components/identity.tokens/manifest.toa.yaml +19 -5
  75. package/components/identity.tokens/operations/authenticate.d.ts +2 -2
  76. package/components/identity.tokens/operations/authenticate.js +10 -4
  77. package/components/identity.tokens/operations/authenticate.js.map +1 -1
  78. package/components/identity.tokens/operations/decrypt.js +1 -0
  79. package/components/identity.tokens/operations/decrypt.js.map +1 -1
  80. package/components/identity.tokens/operations/encrypt.js +5 -1
  81. package/components/identity.tokens/operations/encrypt.js.map +1 -1
  82. package/components/identity.tokens/operations/tsconfig.tsbuildinfo +1 -1
  83. package/components/identity.tokens/operations/types.d.ts +8 -2
  84. package/components/identity.tokens/receivers/identity.bans.created.js +3 -0
  85. package/components/identity.tokens/source/authenticate.test.ts +11 -4
  86. package/components/identity.tokens/source/authenticate.ts +12 -5
  87. package/components/identity.tokens/source/decrypt.test.ts +5 -3
  88. package/components/identity.tokens/source/decrypt.ts +9 -8
  89. package/components/identity.tokens/source/encrypt.test.ts +26 -2
  90. package/components/identity.tokens/source/encrypt.ts +5 -1
  91. package/components/identity.tokens/source/types.ts +9 -2
  92. package/components/octets.storage/manifest.toa.yaml +0 -7
  93. package/documentation/access.md +27 -16
  94. package/documentation/authorities.md +53 -0
  95. package/documentation/cache.md +8 -1
  96. package/documentation/components.md +47 -22
  97. package/documentation/identity.md +17 -22
  98. package/documentation/io.md +56 -0
  99. package/documentation/protocol.md +3 -0
  100. package/documentation/query.md +17 -11
  101. package/documentation/require.md +15 -0
  102. package/documentation/tree.md +22 -4
  103. package/documentation/vary.md +14 -14
  104. package/features/access.feature +89 -47
  105. package/features/annotation.feature +2 -0
  106. package/features/authorities.basic.feature +141 -0
  107. package/features/authorities.feature +32 -0
  108. package/features/authorities.federation.feature +99 -0
  109. package/features/authorities.tokens.feature +118 -0
  110. package/features/body.feature +4 -0
  111. package/features/cache.feature +112 -5
  112. package/features/cors.feature +7 -2
  113. package/features/debug.feature +34 -0
  114. package/features/directives.feature +5 -0
  115. package/features/dynamic.feature +18 -7
  116. package/features/errors.feature +18 -4
  117. package/features/etag.feature +18 -1
  118. package/features/identity.bans.feature +137 -0
  119. package/features/identity.basic.feature +142 -19
  120. package/features/identity.feature +7 -2
  121. package/features/identity.federation.feature +67 -14
  122. package/features/identity.roles.feature +220 -4
  123. package/features/identity.tokens.feature +57 -4
  124. package/features/io.feature +205 -0
  125. package/features/octets.entries.feature +10 -0
  126. package/features/octets.feature +60 -64
  127. package/features/octets.meta.feature +7 -3
  128. package/features/octets.workflows.feature +14 -0
  129. package/features/probes.feature +14 -0
  130. package/features/{queries.feature → query.feature} +50 -3
  131. package/features/require.feature +67 -0
  132. package/features/response.feature +12 -3
  133. package/features/routes.feature +25 -12
  134. package/features/steps/Database.ts +17 -10
  135. package/features/steps/Gateway.ts +23 -6
  136. package/features/steps/IdP.ts +28 -23
  137. package/features/steps/components/echo/manifest.toa.yaml +5 -1
  138. package/features/steps/components/echo/operations/identity.js +7 -0
  139. package/features/steps/components/pots/manifest.toa.yaml +2 -0
  140. package/features/steps/components/users.properties/manifest.toa.yaml +2 -1
  141. package/features/streams.feature +1 -0
  142. package/features/timing.feature +27 -1
  143. package/features/vary.feature +105 -3
  144. package/package.json +12 -11
  145. package/readme.md +19 -14
  146. package/schemas/annotation.cos.yaml +1 -1
  147. package/schemas/io/input.cos.yaml +3 -0
  148. package/schemas/io/message.cos.yaml +5 -0
  149. package/schemas/io/output.cos.yaml +5 -0
  150. package/source/Annotation.ts +3 -3
  151. package/source/Context.ts +6 -4
  152. package/source/Directive.test.ts +4 -4
  153. package/source/Directive.ts +11 -38
  154. package/source/Endpoint.ts +43 -8
  155. package/source/Factory.ts +11 -7
  156. package/source/Gateway.ts +16 -44
  157. package/source/HTTP/Context.ts +24 -2
  158. package/source/HTTP/Server.ts +56 -43
  159. package/source/HTTP/exceptions.ts +7 -1
  160. package/source/HTTP/messages.ts +1 -1
  161. package/source/Mapping.ts +6 -1
  162. package/source/Query.test.ts +1 -1
  163. package/source/Query.ts +35 -24
  164. package/source/RTD/Context.ts +7 -10
  165. package/source/RTD/Directives.ts +28 -4
  166. package/source/RTD/Endpoint.ts +6 -4
  167. package/source/RTD/Match.ts +2 -7
  168. package/source/RTD/Method.ts +7 -13
  169. package/source/RTD/Node.ts +13 -14
  170. package/source/RTD/Tree.ts +17 -16
  171. package/source/RTD/factory.ts +3 -6
  172. package/source/Tenant.ts +0 -8
  173. package/source/deployment.ts +32 -22
  174. package/source/directives/auth/Authorization.ts +38 -19
  175. package/source/directives/auth/Delegate.ts +42 -0
  176. package/source/directives/auth/Incept.ts +3 -2
  177. package/source/directives/auth/Role.test.ts +53 -6
  178. package/source/directives/auth/Role.ts +22 -14
  179. package/source/directives/auth/types.ts +1 -1
  180. package/source/directives/cache/Cache.ts +15 -8
  181. package/source/directives/cache/Control.ts +42 -16
  182. package/source/directives/cors/CORS.ts +13 -7
  183. package/source/directives/dev/Development.ts +4 -4
  184. package/source/directives/index.ts +6 -4
  185. package/source/directives/io/Directive.ts +11 -0
  186. package/source/directives/io/IO.ts +43 -0
  187. package/source/directives/io/Input.ts +50 -0
  188. package/source/directives/io/Message.ts +1 -0
  189. package/source/directives/io/Output.ts +69 -0
  190. package/source/directives/io/index.ts +3 -0
  191. package/source/directives/io/schemas.ts +12 -0
  192. package/source/directives/octets/Context.ts +4 -3
  193. package/source/directives/octets/Delete.ts +4 -2
  194. package/source/directives/octets/Directive.ts +10 -0
  195. package/source/directives/octets/Fetch.ts +4 -3
  196. package/source/directives/octets/List.ts +4 -2
  197. package/source/directives/octets/Octets.ts +6 -8
  198. package/source/directives/octets/Store.ts +12 -4
  199. package/source/directives/octets/Workflow.ts +10 -3
  200. package/source/directives/octets/types.ts +0 -7
  201. package/source/directives/require/Directive.ts +5 -0
  202. package/source/directives/require/Headers.ts +20 -0
  203. package/source/directives/require/Require.ts +28 -0
  204. package/source/directives/require/index.ts +3 -0
  205. package/source/directives/vary/Directive.ts +2 -1
  206. package/source/directives/vary/Embed.ts +14 -8
  207. package/source/directives/vary/Vary.ts +7 -5
  208. package/source/directives/vary/embeddings/Authority.ts +8 -0
  209. package/source/directives/vary/embeddings/Embedding.ts +2 -1
  210. package/source/directives/vary/embeddings/Header.ts +8 -6
  211. package/source/directives/vary/embeddings/Language.ts +1 -1
  212. package/source/directives/vary/embeddings/Parameter.ts +14 -0
  213. package/source/directives/vary/embeddings/index.ts +6 -4
  214. package/source/exceptions.ts +22 -11
  215. package/source/root.ts +5 -0
  216. package/source/schemas.ts +1 -1
  217. package/transpiled/Annotation.d.ts +3 -3
  218. package/transpiled/Context.d.ts +6 -4
  219. package/transpiled/Directive.d.ts +4 -17
  220. package/transpiled/Directive.js +4 -7
  221. package/transpiled/Directive.js.map +1 -1
  222. package/transpiled/Endpoint.d.ts +5 -3
  223. package/transpiled/Endpoint.js +30 -5
  224. package/transpiled/Endpoint.js.map +1 -1
  225. package/transpiled/Factory.js +9 -4
  226. package/transpiled/Factory.js.map +1 -1
  227. package/transpiled/Gateway.d.ts +1 -4
  228. package/transpiled/Gateway.js +10 -26
  229. package/transpiled/Gateway.js.map +1 -1
  230. package/transpiled/HTTP/Context.d.ts +8 -1
  231. package/transpiled/HTTP/Context.js +15 -2
  232. package/transpiled/HTTP/Context.js.map +1 -1
  233. package/transpiled/HTTP/Server.d.ts +13 -2
  234. package/transpiled/HTTP/Server.js +41 -35
  235. package/transpiled/HTTP/Server.js.map +1 -1
  236. package/transpiled/HTTP/exceptions.d.ts +4 -1
  237. package/transpiled/HTTP/exceptions.js +7 -1
  238. package/transpiled/HTTP/exceptions.js.map +1 -1
  239. package/transpiled/HTTP/messages.js +1 -1
  240. package/transpiled/HTTP/messages.js.map +1 -1
  241. package/transpiled/Mapping.js +4 -1
  242. package/transpiled/Mapping.js.map +1 -1
  243. package/transpiled/Query.d.ts +1 -0
  244. package/transpiled/Query.js +21 -20
  245. package/transpiled/Query.js.map +1 -1
  246. package/transpiled/RTD/Context.d.ts +7 -6
  247. package/transpiled/RTD/Directives.d.ts +19 -4
  248. package/transpiled/RTD/Endpoint.d.ts +6 -4
  249. package/transpiled/RTD/Match.d.ts +2 -4
  250. package/transpiled/RTD/Method.d.ts +7 -7
  251. package/transpiled/RTD/Method.js.map +1 -1
  252. package/transpiled/RTD/Node.d.ts +4 -6
  253. package/transpiled/RTD/Node.js +2 -1
  254. package/transpiled/RTD/Node.js.map +1 -1
  255. package/transpiled/RTD/Tree.d.ts +6 -6
  256. package/transpiled/RTD/Tree.js +4 -1
  257. package/transpiled/RTD/Tree.js.map +1 -1
  258. package/transpiled/RTD/factory.d.ts +2 -4
  259. package/transpiled/RTD/factory.js +1 -1
  260. package/transpiled/RTD/factory.js.map +1 -1
  261. package/transpiled/Tenant.d.ts +0 -1
  262. package/transpiled/Tenant.js +0 -6
  263. package/transpiled/Tenant.js.map +1 -1
  264. package/transpiled/deployment.d.ts +1 -1
  265. package/transpiled/deployment.js +28 -20
  266. package/transpiled/deployment.js.map +1 -1
  267. package/transpiled/directives/auth/Authorization.d.ts +2 -3
  268. package/transpiled/directives/auth/Authorization.js +26 -12
  269. package/transpiled/directives/auth/Authorization.js.map +1 -1
  270. package/transpiled/directives/auth/Delegate.d.ts +10 -0
  271. package/transpiled/directives/auth/Delegate.js +34 -0
  272. package/transpiled/directives/auth/Delegate.js.map +1 -0
  273. package/transpiled/directives/auth/Incept.js +3 -2
  274. package/transpiled/directives/auth/Incept.js.map +1 -1
  275. package/transpiled/directives/auth/Role.d.ts +4 -1
  276. package/transpiled/directives/auth/Role.js +20 -14
  277. package/transpiled/directives/auth/Role.js.map +1 -1
  278. package/transpiled/directives/cache/Cache.d.ts +5 -5
  279. package/transpiled/directives/cache/Cache.js +10 -4
  280. package/transpiled/directives/cache/Cache.js.map +1 -1
  281. package/transpiled/directives/cache/Control.d.ts +2 -1
  282. package/transpiled/directives/cache/Control.js +29 -12
  283. package/transpiled/directives/cache/Control.js.map +1 -1
  284. package/transpiled/directives/cors/CORS.d.ts +2 -3
  285. package/transpiled/directives/cors/CORS.js +13 -7
  286. package/transpiled/directives/cors/CORS.js.map +1 -1
  287. package/transpiled/directives/dev/Development.d.ts +3 -3
  288. package/transpiled/directives/dev/Development.js +1 -1
  289. package/transpiled/directives/dev/Development.js.map +1 -1
  290. package/transpiled/directives/index.d.ts +2 -2
  291. package/transpiled/directives/index.js +5 -3
  292. package/transpiled/directives/index.js.map +1 -1
  293. package/transpiled/directives/io/Directive.d.ts +8 -0
  294. package/transpiled/directives/io/Directive.js +3 -0
  295. package/transpiled/directives/io/Directive.js.map +1 -0
  296. package/transpiled/directives/io/IO.d.ts +9 -0
  297. package/transpiled/directives/io/IO.js +33 -0
  298. package/transpiled/directives/io/IO.js.map +1 -0
  299. package/transpiled/directives/io/Input.d.ts +11 -0
  300. package/transpiled/directives/{octets/Permute.js → io/Input.js} +33 -26
  301. package/transpiled/directives/io/Input.js.map +1 -0
  302. package/transpiled/directives/io/Message.d.ts +1 -0
  303. package/transpiled/directives/io/Message.js +3 -0
  304. package/transpiled/directives/io/Message.js.map +1 -0
  305. package/transpiled/directives/io/Output.d.ts +13 -0
  306. package/transpiled/directives/io/Output.js +76 -0
  307. package/transpiled/directives/io/Output.js.map +1 -0
  308. package/transpiled/directives/io/index.d.ts +2 -0
  309. package/transpiled/directives/io/index.js +6 -0
  310. package/transpiled/directives/io/index.js.map +1 -0
  311. package/transpiled/directives/io/schemas.d.ts +7 -0
  312. package/transpiled/directives/io/schemas.js +14 -0
  313. package/transpiled/directives/io/schemas.js.map +1 -0
  314. package/transpiled/directives/octets/Context.d.ts +3 -3
  315. package/transpiled/directives/octets/Context.js +4 -2
  316. package/transpiled/directives/octets/Context.js.map +1 -1
  317. package/transpiled/directives/octets/Delete.d.ts +3 -2
  318. package/transpiled/directives/octets/Delete.js +3 -1
  319. package/transpiled/directives/octets/Delete.js.map +1 -1
  320. package/transpiled/directives/octets/Directive.d.ts +8 -0
  321. package/transpiled/directives/octets/Directive.js +8 -0
  322. package/transpiled/directives/octets/Directive.js.map +1 -0
  323. package/transpiled/directives/octets/Fetch.d.ts +3 -2
  324. package/transpiled/directives/octets/Fetch.js +3 -1
  325. package/transpiled/directives/octets/Fetch.js.map +1 -1
  326. package/transpiled/directives/octets/List.d.ts +3 -2
  327. package/transpiled/directives/octets/List.js +3 -1
  328. package/transpiled/directives/octets/List.js.map +1 -1
  329. package/transpiled/directives/octets/Octets.d.ts +4 -4
  330. package/transpiled/directives/octets/Octets.js +2 -4
  331. package/transpiled/directives/octets/Octets.js.map +1 -1
  332. package/transpiled/directives/octets/Store.d.ts +3 -2
  333. package/transpiled/directives/octets/Store.js +10 -3
  334. package/transpiled/directives/octets/Store.js.map +1 -1
  335. package/transpiled/directives/octets/Workflow.d.ts +3 -2
  336. package/transpiled/directives/octets/Workflow.js +9 -2
  337. package/transpiled/directives/octets/Workflow.js.map +1 -1
  338. package/transpiled/directives/octets/types.d.ts +0 -5
  339. package/transpiled/directives/require/Directive.d.ts +4 -0
  340. package/transpiled/directives/require/Directive.js +3 -0
  341. package/transpiled/directives/require/Directive.js.map +1 -0
  342. package/transpiled/directives/require/Headers.d.ts +7 -0
  343. package/transpiled/directives/require/Headers.js +19 -0
  344. package/transpiled/directives/require/Headers.js.map +1 -0
  345. package/transpiled/directives/require/Require.d.ts +9 -0
  346. package/transpiled/directives/require/Require.js +27 -0
  347. package/transpiled/directives/require/Require.js.map +1 -0
  348. package/transpiled/directives/require/index.d.ts +2 -0
  349. package/transpiled/directives/require/index.js +6 -0
  350. package/transpiled/directives/require/index.js.map +1 -0
  351. package/transpiled/directives/vary/Directive.d.ts +2 -1
  352. package/transpiled/directives/vary/Embed.d.ts +2 -1
  353. package/transpiled/directives/vary/Embed.js +8 -6
  354. package/transpiled/directives/vary/Embed.js.map +1 -1
  355. package/transpiled/directives/vary/Vary.d.ts +3 -3
  356. package/transpiled/directives/vary/Vary.js +3 -3
  357. package/transpiled/directives/vary/Vary.js.map +1 -1
  358. package/transpiled/directives/vary/embeddings/Authority.d.ts +5 -0
  359. package/transpiled/directives/vary/embeddings/Authority.js +10 -0
  360. package/transpiled/directives/vary/embeddings/Authority.js.map +1 -0
  361. package/transpiled/directives/vary/embeddings/Embedding.d.ts +2 -1
  362. package/transpiled/directives/vary/embeddings/Header.js +8 -6
  363. package/transpiled/directives/vary/embeddings/Header.js.map +1 -1
  364. package/transpiled/directives/vary/embeddings/Language.js +1 -1
  365. package/transpiled/directives/vary/embeddings/Language.js.map +1 -1
  366. package/transpiled/directives/vary/embeddings/Parameter.d.ts +7 -0
  367. package/transpiled/directives/vary/embeddings/Parameter.js +14 -0
  368. package/transpiled/directives/vary/embeddings/Parameter.js.map +1 -0
  369. package/transpiled/directives/vary/embeddings/index.d.ts +2 -2
  370. package/transpiled/directives/vary/embeddings/index.js +8 -4
  371. package/transpiled/directives/vary/embeddings/index.js.map +1 -1
  372. package/transpiled/exceptions.d.ts +3 -2
  373. package/transpiled/exceptions.js +13 -7
  374. package/transpiled/exceptions.js.map +1 -1
  375. package/transpiled/root.js +5 -0
  376. package/transpiled/root.js.map +1 -1
  377. package/transpiled/schemas.d.ts +1 -1
  378. package/transpiled/schemas.js +2 -2
  379. package/transpiled/schemas.js.map +1 -1
  380. package/transpiled/tsconfig.tsbuildinfo +1 -1
  381. package/components/identity.basic/operations/create.d.ts +0 -10
  382. package/components/identity.basic/operations/create.js +0 -10
  383. package/components/identity.basic/operations/create.js.map +0 -1
  384. package/components/identity.basic/source/create.ts +0 -18
  385. package/components/identity.federation/operations/create.d.ts +0 -10
  386. package/components/identity.federation/operations/create.js.map +0 -1
  387. package/components/identity.federation/operations/schemas.d.ts +0 -59
  388. package/components/identity.federation/operations/schemas.js +0 -9
  389. package/components/identity.federation/operations/schemas.js.map +0 -1
  390. package/components/identity.federation/operations/types.js.map +0 -1
  391. package/components/identity.federation/source/schemas.ts +0 -61
  392. package/components/octets.storage/operations/permute.js +0 -7
  393. package/source/HTTP/Server.test.ts +0 -126
  394. package/source/directives/octets/Permute.ts +0 -43
  395. package/transpiled/directives/octets/Permute.d.ts +0 -10
  396. package/transpiled/directives/octets/Permute.js.map +0 -1
@@ -1,7 +1,22 @@
1
+ import type { Parameter } from './Match';
1
2
  import type * as syntax from './syntax';
2
- export interface Directives<TDirective = any> {
3
- merge: (directive: TDirective) => void;
3
+ import type { Context, OutgoingMessage } from '../HTTP';
4
+ import type { Output } from '../io';
5
+ export interface Directives {
6
+ preflight: (context: Context, parameters: Parameter[]) => Promise<Output>;
7
+ settle: (context: Context, response: OutgoingMessage) => Promise<void>;
4
8
  }
5
- export interface DirectivesFactory<T = any> {
6
- create: (directives: syntax.Directive[]) => T;
9
+ export interface DirectiveFactory {
10
+ create: (directives: syntax.Directive[]) => Directives;
11
+ }
12
+ export interface DirectiveSet {
13
+ family: DirectiveFamily;
14
+ directives: any[];
15
+ }
16
+ export interface DirectiveFamily<TDirective = any, TExtension = any> {
17
+ readonly name: string;
18
+ readonly mandatory: boolean;
19
+ create: (name: string, ...rest: any[]) => TDirective;
20
+ preflight?: (directives: TDirective[], request: Context & TExtension, parameters: Parameter[]) => Output | Promise<Output>;
21
+ settle?: (directives: TDirective[], request: Context & TExtension, response: OutgoingMessage) => void | Promise<void>;
7
22
  }
@@ -1,9 +1,11 @@
1
1
  import { type Context } from './Context';
2
+ import type * as http from '../HTTP';
2
3
  import type * as syntax from './syntax';
3
- export interface Endpoint<T extends Endpoint = any> {
4
- call: T['call'];
4
+ import type * as RTD from './index';
5
+ export interface Endpoint {
6
+ call: (context: http.Context, parameters: RTD.Parameter[]) => Promise<http.OutgoingMessage>;
5
7
  close: () => Promise<void>;
6
8
  }
7
- export interface EndpointsFactory<T extends Endpoint<T> = any> {
8
- create: (method: syntax.Method, context: Context) => T;
9
+ export interface EndpointsFactory {
10
+ create: (method: syntax.Method, context: Context) => Endpoint;
9
11
  }
@@ -1,8 +1,6 @@
1
1
  import { type Node } from './Node';
2
- import { type Directives } from './Directives';
3
- import { type Endpoint } from './Endpoint';
4
- export interface Match<TEndpoint extends Endpoint<TEndpoint> = any, TDirectives extends Directives<TDirectives> = any> {
5
- node: Node<TEndpoint, TDirectives>;
2
+ export interface Match {
3
+ node: Node;
6
4
  parameters: Parameter[];
7
5
  }
8
6
  export interface Parameter {
@@ -1,9 +1,9 @@
1
- import { type Directives } from './Directives';
2
- import { type Endpoint } from './Endpoint';
3
- export declare class Method<TEndpoint extends Endpoint<TEndpoint> = any, TDirectives extends Directives<TDirectives> = any> {
4
- readonly endpoint: TEndpoint | null;
5
- readonly directives: TDirectives;
6
- constructor(endpoint: TEndpoint | null, directives: TDirectives);
1
+ import type { Endpoint } from './Endpoint';
2
+ import type { Directives } from './Directives';
3
+ export declare class Method {
4
+ readonly endpoint: Endpoint | null;
5
+ readonly directives: Directives;
6
+ constructor(endpoint: Endpoint | null, directives: Directives);
7
7
  close(): Promise<void>;
8
8
  }
9
- export type Methods<TEndpoint extends Endpoint<TEndpoint> = any, TDirectives extends Directives<TDirectives> = any> = Record<string, Method<TEndpoint, TDirectives>>;
9
+ export type Methods = Record<string, Method>;
@@ -1 +1 @@
1
- {"version":3,"file":"Method.js","sourceRoot":"","sources":["../../source/RTD/Method.ts"],"names":[],"mappings":";;;AAGA,MAAa,MAAM;IAID,QAAQ,CAAkB;IAC1B,UAAU,CAAa;IAEvC,YAAoB,QAA0B,EAAE,UAAuB;QACrE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;IAEM,KAAK,CAAC,KAAK;QAChB,MAAM,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAA;IAC9B,CAAC;CACF;AAfD,wBAeC"}
1
+ {"version":3,"file":"Method.js","sourceRoot":"","sources":["../../source/RTD/Method.ts"],"names":[],"mappings":";;;AAGA,MAAa,MAAM;IACD,QAAQ,CAAiB;IACzB,UAAU,CAAY;IAEtC,YAAoB,QAAyB,EAAE,UAAsB;QACnE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;IAEM,KAAK,CAAC,KAAK;QAChB,MAAM,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAA;IAC9B,CAAC;CACF;AAZD,wBAYC"}
@@ -1,16 +1,14 @@
1
1
  import { type Route } from './Route';
2
2
  import { type Methods } from './Method';
3
3
  import { type Match, type Parameter } from './Match';
4
- import { type Directives } from './Directives';
5
- import { type Endpoint } from './Endpoint';
6
- export declare class Node<TEndpoint extends Endpoint<TEndpoint> = any, TDirectives extends Directives<TDirectives> = any> {
4
+ export declare class Node {
7
5
  intermediate: boolean;
8
- methods: Methods<TEndpoint, TDirectives>;
6
+ methods: Methods;
9
7
  private readonly protected;
10
8
  private routes;
11
- constructor(routes: Route[], methods: Methods<TEndpoint, TDirectives>, properties: Properties);
9
+ constructor(routes: Route[], methods: Methods, properties: Properties);
12
10
  match(fragments: string[], parameters?: Parameter[]): Match | null;
13
- merge(node: Node<TEndpoint, TDirectives>): void;
11
+ merge(node: Node): void;
14
12
  private replace;
15
13
  private append;
16
14
  private mergeRoute;
@@ -34,7 +34,8 @@ class Node {
34
34
  this.routes = node.routes;
35
35
  this.methods = node.methods;
36
36
  for (const method of methods)
37
- void method.close(); // race condition is really unlikely
37
+ void method.close();
38
+ // race condition is really unlikely
38
39
  }
39
40
  append(node) {
40
41
  for (const route of node.routes)
@@ -1 +1 @@
1
- {"version":3,"file":"Node.js","sourceRoot":"","sources":["../../source/RTD/Node.ts"],"names":[],"mappings":";;;AAMA,MAAa,IAAI;IAIR,YAAY,CAAS;IACrB,OAAO,CAAiC;IAC9B,SAAS,CAAS;IAC3B,MAA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CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;YACvD,IAAI,IAAI,IAAI,IAAI,CAAC,OAAO;gBACtB,OAAO,CAAC,IAAI,CAAC,sCAAsC,IAAI,oBAAoB,CAAC,CAAA;;gBAE5E,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,CAAA;IACjC,CAAC;IAEO,UAAU,CAAE,SAAgB;QAClC,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM;YAC7B,IAAI,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC5B,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;gBAEtB,OAAM;YACR,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IAC7B,CAAC;IAEO,IAAI;QACV,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,CAAC,CAAA;IACvD,CAAC;CACF;AA3ED,oBA2EC"}
@@ -1,14 +1,14 @@
1
- import { type Match } from './Match';
2
- import { type Directives, type DirectivesFactory } from './Directives';
3
- import { type Endpoint, type EndpointsFactory } from './Endpoint';
1
+ import type { Match } from './Match';
2
+ import type { DirectiveFactory } from './Directives';
3
+ import type { EndpointsFactory } from './Endpoint';
4
4
  import type * as syntax from './syntax';
5
- export declare class Tree<TEndpoint extends Endpoint<TEndpoint> = any, TDirectives extends Directives<TDirectives> = any> {
5
+ export declare class Tree {
6
6
  private readonly root;
7
7
  private readonly trunk;
8
8
  private readonly endpoints;
9
9
  private readonly directives;
10
- constructor(node: syntax.Node, endpoints: EndpointsFactory, directives: DirectivesFactory);
11
- match(path: string): Match<TEndpoint, TDirectives> | null;
10
+ constructor(node: syntax.Node, endpoints: EndpointsFactory, directives: DirectiveFactory);
11
+ match(path: string): Match | null;
12
12
  merge(node: syntax.Node, extension: any): void;
13
13
  private createNode;
14
14
  }
@@ -16,7 +16,10 @@ class Tree {
16
16
  }
17
17
  match(path) {
18
18
  if (path === '/')
19
- return { node: this.trunk, parameters: [] };
19
+ return {
20
+ node: this.trunk,
21
+ parameters: []
22
+ };
20
23
  const fragments = (0, segment_1.fragment)(path);
21
24
  return this.trunk.match(fragments);
22
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Tree.js","sourceRoot":"","sources":["../../source/RTD/Tree.ts"],"names":[],"mappings":";;;AACA,uCAAsC;AACtC,uCAAoC;AAOpC,MAAa,IAAI;IAIE,IAAI,CAAa;IACjB,KAAK,CAA8B;IACnC,SAAS,CAA6B;IACtC,UAAU,CAAmB;IAE9C,YACC,IAAiB,EAAE,SAA2B,EAAE,UAA6B;QAC5E,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;QAC7C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAEM,KAAK,CAAE,IAAY;QACxB,IAAI,IAAI,KAAK,GAAG;YACd,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,CAAA;QAE7C,MAAM,SAAS,GAAG,IAAA,kBAAQ,EAAC,IAAI,CAAC,CAAA;QAEhC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;IACpC,CAAC;IAEM,KAAK,CAAE,IAAiB,EAAE,SAAc;QAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;QAE3D,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IAC1B,CAAC;IAEO,UAAU,CAAE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EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;QAE3D,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IAC1B,CAAC;IAEO,UAAU,CACjB,IAAiB,EAAE,OAAgB,EAAE,SAAe;QACnD,MAAM,OAAO,GAAY;YACvB,SAAS,EAAE,OAAO;YAClB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,UAAU,EAAE;gBACV,OAAO,EAAE,IAAI,CAAC,UAAU;gBACxB,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,IAAI,EAAE;aACnC;YACD,SAAS;SACV,CAAA;QAED,OAAO,IAAA,oBAAU,EAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAClC,CAAC;CACF;AA9CD,oBA8CC;AAED,MAAM,SAAS,GAAG,IAAI,CAAA"}
@@ -1,6 +1,4 @@
1
1
  import { Node } from './Node';
2
- import { type Context } from './Context';
3
- import { type Endpoint } from './Endpoint';
4
- import { type Directives } from './Directives';
2
+ import type { Context } from './Context';
5
3
  import type * as syntax from './syntax';
6
- export declare function createNode<TEndpoint extends Endpoint, TDirectives extends Directives>(node: syntax.Node, context: Context): Node<TEndpoint, TDirectives>;
4
+ export declare function createNode(node: syntax.Node, context: Context): Node;
@@ -26,7 +26,7 @@ function createRoute(route, context) {
26
26
  return new Route_1.Route(segments, node);
27
27
  }
28
28
  function createMethod(method, context) {
29
- const stack = context.directives.stack.concat(method.directives.reverse());
29
+ const stack = method.directives.concat(context.directives.stack);
30
30
  const directives = context.directives.factory.create(stack);
31
31
  const endpoint = method.mapping?.endpoint === undefined
32
32
  ? null
@@ -1 +1 @@
1
- {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../source/RTD/factory.ts"],"names":[],"mappings":";;;AAAA,iCAA8C;AAC9C,mCAA+B;AAE/B,uCAAmC;AACnC,qCAA+C;AAK/C,SAAgB,UAAU,CACzB,IAAiB,EAAE,OAAgB;IAClC,IAAI,IAAI,CAAC,QAAQ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EAAE,CAAA;IAEjF,OAAO,IAAI,WAAI,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,CAAC,CAAA;AAC9C,CAAC;AAfD,gCAeC;AAED,SAAS,WAAW,CAAE,KAAmB,EAAE,OAAgB;IACzD,MAAM,KAAK,GAAG,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IAC9C,MAAM,QAAQ,GAAG,IAAA,iBAAO,EAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IACpC,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAE5C,OAAO,CAAC,UAAU,CAAC,KAAK,GAAG,KAAK,CAAA,CAAC,UAAU;IAE3C,OAAO,IAAI,aAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;AAClC,CAAC;AAED,SAAS,YAAY,CAAE,MAAqB,EAAE,OAAgB;IAC5D,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;IAChE,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAE3D,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,EAAE,QAAQ,KAAK,SAAS;QACrD,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAE7C,OAAO,IAAI,eAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;AACzC,CAAC"}
@@ -6,7 +6,6 @@ export declare class Tenant extends Connector {
6
6
  private readonly branch;
7
7
  constructor(broadcast: Broadcast, locator: Locator, node: RTD.Node);
8
8
  open(): Promise<void>;
9
- dispose(): Promise<void>;
10
9
  private expose;
11
10
  }
12
11
  type Broadcast = bindings.Broadcast<Label>;
@@ -19,12 +19,6 @@ class Tenant extends core_1.Connector {
19
19
  async open() {
20
20
  await this.expose();
21
21
  await this.broadcast.receive('ping', this.expose.bind(this));
22
- console.info('Exposition Tenant for ' +
23
- `'${this.branch.namespace}.${this.branch.component}' has started.`);
24
- }
25
- async dispose() {
26
- console.info('Exposition Tenant for ' +
27
- `'${this.branch.namespace}.${this.branch.component}' has been stopped.`);
28
22
  }
29
23
  async expose() {
30
24
  await this.broadcast.transmit('expose', this.branch);
@@ -1 +1 @@
1
- {"version":3,"file":"Tenant.js","sourceRoot":"","sources":["../source/Tenant.ts"],"names":[],"mappings":";;;AAAA,uCAAqE;AAKrE,MAAa,MAAO,SAAQ,gBAAS;IAClB,SAAS,CAAW;IACpB,MAAM,CAAQ;IAE/B,YAAoB,SAAoB,EAAE,OAAgB,EAAE,IAAc;QACxE,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAE1B,IAAI,CAAC,MAAM,GAAG;YACZ,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,SAAS,EAAE,OAAO,CAAC,IAAI;YACvB,QAAQ,EAAE,OAAO,CAAC,SAAS,KAAK,UAAU;YAC1C,IAAI;SACL,CAAA;QAED,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IACzB,CAAC;IAEe,KAAK,CAAC,IAAI;QACxB,MAAM,IAAI,CAAC,MAAM,EAAE,CAAA;QACnB,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;QAE5D,OAAO,CAAC,IAAI,CAAC,wBAAwB;YACnC,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,gBAAgB,CAAC,CAAA;IACvE,CAAC;IAEe,KAAK,CAAC,OAAO;QAC3B,OAAO,CAAC,IAAI,CAAC,wBAAwB;YACnC,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,qBAAqB,CAAC,CAAA;IAC5E,CAAC;IAEO,KAAK,CAAC,MAAM;QAClB,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IACtD,CAAC;CACF;AAnCD,wBAmCC"}
1
+ {"version":3,"file":"Tenant.js","sourceRoot":"","sources":["../source/Tenant.ts"],"names":[],"mappings":";;;AAAA,uCAAqE;AAKrE,MAAa,MAAO,SAAQ,gBAAS;IAClB,SAAS,CAAW;IACpB,MAAM,CAAQ;IAE/B,YAAoB,SAAoB,EAAE,OAAgB,EAAE,IAAc;QACxE,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAE1B,IAAI,CAAC,MAAM,GAAG;YACZ,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,SAAS,EAAE,OAAO,CAAC,IAAI;YACvB,QAAQ,EAAE,OAAO,CAAC,SAAS,KAAK,UAAU;YAC1C,IAAI;SACL,CAAA;QAED,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IACzB,CAAC;IAEe,KAAK,CAAC,IAAI;QACxB,MAAM,IAAI,CAAC,MAAM,EAAE,CAAA;QACnB,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IAC9D,CAAC;IAEO,KAAK,CAAC,MAAM;QAClB,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IACtD,CAAC;CACF;AA3BD,wBA2BC"}
@@ -1,3 +1,3 @@
1
1
  import { type Dependency } from '@toa.io/operations';
2
2
  import { type Annotation } from './Annotation';
3
- export declare function deployment(_: unknown, annotation: Annotation | undefined): Dependency;
3
+ export declare function deployment(_: unknown, annotation?: Annotation): Dependency;
@@ -22,30 +22,37 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
25
28
  Object.defineProperty(exports, "__esModule", { value: true });
26
29
  exports.deployment = void 0;
30
+ const node_assert_1 = __importDefault(require("node:assert"));
27
31
  const generic_1 = require("@toa.io/generic");
28
32
  const schemas = __importStar(require("./schemas"));
29
33
  const Directive_1 = require("./Directive");
30
34
  const Composition_1 = require("./Composition");
31
35
  const syntax_1 = require("./RTD/syntax");
36
+ const Server_1 = require("./HTTP/Server");
32
37
  function deployment(_, annotation) {
38
+ node_assert_1.default.ok(annotation !== undefined, 'Exposition context annotation is required');
39
+ schemas.annotation.validate(annotation);
33
40
  const labels = (0, Composition_1.components)().labels;
34
41
  const service = {
35
42
  group: 'exposition',
36
43
  name: 'gateway',
37
- port: 8000,
44
+ port: Server_1.PORT,
38
45
  // eslint-disable-next-line @typescript-eslint/no-var-requires
39
46
  version: require('../package.json').version,
40
47
  variables: [],
41
- components: labels
48
+ components: labels,
49
+ ingress: { hosts: [] },
50
+ probe: {
51
+ path: '/.ready',
52
+ port: Server_1.PORT,
53
+ delay: Server_1.DELAY
54
+ }
42
55
  };
43
- if (annotation?.host !== undefined)
44
- service.ingress = {
45
- host: annotation.host,
46
- class: annotation.class,
47
- annotations: annotation.annotations
48
- };
49
56
  if (annotation?.['/'] !== undefined) {
50
57
  const tree = (0, syntax_1.parse)(annotation['/'], Directive_1.shortcuts);
51
58
  service.variables.push({
@@ -53,18 +60,19 @@ function deployment(_, annotation) {
53
60
  value: (0, generic_1.encode)(tree)
54
61
  });
55
62
  }
56
- if (annotation?.debug === true)
57
- service.variables.push({
58
- name: 'TOA_EXPOSITION_DEBUG',
59
- value: '1'
60
- });
61
- if (annotation?.trace === true)
62
- service.variables.push({
63
- name: 'TOA_EXPOSITION_TRACE',
64
- value: '1'
65
- });
66
- if (annotation !== undefined)
67
- schemas.annotaion.validate(annotation);
63
+ const { debug, trace, authorities } = annotation;
64
+ service.ingress.hosts = Object.values(authorities);
65
+ service.ingress.class = annotation.class;
66
+ service.ingress.annotations = annotation.annotations;
67
+ const properties = { authorities };
68
+ if (debug === true)
69
+ properties.debug = true;
70
+ if (trace === true)
71
+ properties.trace = true;
72
+ service.variables.push({
73
+ name: 'TOA_EXPOSITION_PROPERTIES',
74
+ value: (0, generic_1.encode)(properties)
75
+ });
68
76
  return { services: [service] };
69
77
  }
70
78
  exports.deployment = deployment;
@@ -1 +1 @@
1
- {"version":3,"file":"deployment.js","sourceRoot":"","sources":["../source/deployment.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6CAAwC;AAExC,mDAAoC;AACpC,2CAAuC;AACvC,+CAA0C;AAC1C,yCAAoC;AAEpC,SAAgB,UAAU,CAAE,CAAU,EAAE,UAAkC;IACxE,MAAM,MAAM,GAAG,IAAA,wBAAU,GAAE,CAAC,MAAM,CAAA;IAElC,MAAM,OAAO,GAAY;QACvB,KAAK,EAAE,YAAY;QACnB,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,IAAI;QACV,8DAA8D;QAC9D,OAAO,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC,OAAO;QAC3C,SAAS,EAAE,EAAE;QACb,UAAU,EAAE,MAAM;KACnB,CAAA;IAED,IAAI,UAAU,EAAE,IAAI,KAAK,SAAS;QAChC,OAAO,CAAC,OAAO,GAAG;YAChB,IAAI,EAAE,UAAU,CAAC,IAAI;YACrB,KAAK,EAAE,UAAU,CAAC,KAAK;YACvB,WAAW,EAAE,UAAU,CAAC,WAAW;SACpC,CAAA;IAEH,IAAI,UAAU,EAAE,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE,CAAC;QACpC,MAAM,IAAI,GAAG,IAAA,cAAK,EAAC,UAAU,CAAC,GAAG,CAAC,EAAE,qBAAS,CA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AAC;AAnDD,gCAmDC"}
@@ -1,10 +1,9 @@
1
1
  import * as http from '../../HTTP';
2
2
  import type { Output } from '../../io';
3
3
  import type { Remotes } from '../../Remotes';
4
- import type { Family } from '../../Directive';
5
- import type { Parameter } from '../../RTD';
4
+ import type { Parameter, DirectiveFamily } from '../../RTD';
6
5
  import type { Directive, Extension, Input } from './types';
7
- export declare class Authorization implements Family<Directive, Extension> {
6
+ export declare class Authorization implements DirectiveFamily<Directive, Extension> {
8
7
  readonly depends: string[];
9
8
  readonly name: string;
10
9
  readonly mandatory: boolean;
@@ -36,8 +36,9 @@ const Role_1 = require("./Role");
36
36
  const Rule_1 = require("./Rule");
37
37
  const Incept_1 = require("./Incept");
38
38
  const Echo_1 = require("./Echo");
39
- const split_1 = require("./split");
40
39
  const Scheme_1 = require("./Scheme");
40
+ const Delegate_1 = require("./Delegate");
41
+ const split_1 = require("./split");
41
42
  const schemes_1 = require("./schemes");
42
43
  class Authorization {
43
44
  depends = ['Vary'];
@@ -48,14 +49,22 @@ class Authorization {
48
49
  tokens = null;
49
50
  bans = null;
50
51
  create(name, value, remotes) {
51
- node_assert_1.default.ok(name in CLASSES, `Directive '${name}' is not provided by the '${this.name}' family.`);
52
- const Class = CLASSES[name];
52
+ node_assert_1.default.ok(name in constructors, `Directive 'auth:${name}' is not implemented.`);
53
+ const Class = constructors[name];
53
54
  for (const name of REMOTES)
54
55
  this.discovery[name] ??= remotes.discover('identity', name);
55
- return (0, matchacho_1.match)(Class, Role_1.Role, () => new Role_1.Role(value, this.discovery.roles), Rule_1.Rule, () => new Rule_1.Rule(value, this.create.bind(this)), Incept_1.Incept, () => new Incept_1.Incept(value, this.discovery), () => new Class(value));
56
+ return (0, matchacho_1.match)(Class, Role_1.Role, () => new Role_1.Role(value, this.discovery.roles), Rule_1.Rule, () => new Rule_1.Rule(value, this.create.bind(this)), Incept_1.Incept, () => new Incept_1.Incept(value, this.discovery), Delegate_1.Delegate, () => new Delegate_1.Delegate(value, this.discovery.roles), () => new Class(value));
56
57
  }
57
58
  async preflight(directives, input, parameters) {
58
- const identity = await this.resolve(input.request.headers.authorization);
59
+ /**
60
+ * Some authentication scheme providers may create identity during authentication;
61
+ * therefore, we need to skip the authentication process if the Incept directive is present.
62
+ *
63
+ * If the provided credentials already exist,
64
+ * the inception will cause a unique constraint violation on the settle stage.
65
+ */
66
+ const inception = directives.reduce((yes, directive) => yes || directive instanceof Incept_1.Incept, false);
67
+ const identity = inception ? null : await this.resolve(input.authority, input.request.headers.authorization);
59
68
  input.identity = identity;
60
69
  for (const directive of directives) {
61
70
  const allow = await directive.authorize(identity, input, parameters);
@@ -79,13 +88,14 @@ class Authorization {
79
88
  if (identity.roles === undefined)
80
89
  await Role_1.Role.set(identity, this.discovery.roles);
81
90
  this.tokens ??= await this.discovery.tokens;
82
- const token = await this.tokens.invoke('encrypt', { input: { identity } });
91
+ const token = await this.tokens.invoke('encrypt', {
92
+ input: { authority: request.authority, identity }
93
+ });
83
94
  const authorization = `Token ${token}`;
84
- if (response.headers === undefined)
85
- response.headers = new Headers();
95
+ response.headers ??= new Headers();
86
96
  response.headers.set('authorization', authorization);
87
97
  }
88
- async resolve(authorization) {
98
+ async resolve(authority, authorization) {
89
99
  if (authorization === undefined)
90
100
  return null;
91
101
  const [scheme, credentials] = (0, split_1.split)(authorization);
@@ -94,7 +104,10 @@ class Authorization {
94
104
  throw new http.Unauthorized(`Unknown authentication scheme '${scheme}'.`);
95
105
  this.schemes[scheme] ??= await this.discovery[provider];
96
106
  const result = await this.schemes[scheme].invoke('authenticate', {
97
- input: credentials
107
+ input: {
108
+ authority,
109
+ credentials
110
+ }
98
111
  });
99
112
  if (result instanceof Error)
100
113
  return null;
@@ -112,14 +125,15 @@ class Authorization {
112
125
  }
113
126
  }
114
127
  exports.Authorization = Authorization;
115
- const CLASSES = {
128
+ const constructors = {
116
129
  anonymous: Anonymous_1.Anonymous,
117
130
  id: Id_1.Id,
118
131
  role: Role_1.Role,
119
132
  rule: Rule_1.Rule,
120
133
  incept: Incept_1.Incept,
121
134
  scheme: Scheme_1.Scheme,
122
- echo: Echo_1.Echo
135
+ echo: Echo_1.Echo,
136
+ delegate: Delegate_1.Delegate
123
137
  };
124
138
  const REMOTES = ['basic', 'federation', 'tokens', 'roles', 'bans'];
125
139
  //# sourceMappingURL=Authorization.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Authorization.js","sourceRoot":"","sources":["../../../source/directives/auth/Authorization.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAgC;AAChC,yCAAiC;AACjC,iDAAkC;AAClC,2CAAuC;AACvC,6BAAyB;AACzB,iCAA6B;AAC7B,iCAA6B;AAC7B,qCAAiC;AACjC,iCAA6B;AAC7B,mCAA+B;AAC/B,qCAAiC;AACjC,uCAA8C;AAkB9C,MAAa,aAAa;IACR,OAAO,GAAa,CAAC,MAAM,CAAC,CAAA;IAC5B,IAAI,GAAW,MAAM,CAAA;IACrB,SAAS,GAAY,IAAI,CAAA;IAExB,OAAO,GAAG,EAAwB,CAAA;IAClC,SAAS,GAAG,EAA0B,CAAA;IAC/C,MAAM,GAAqB,IAAI,CAAA;IAC/B,IAAI,GAAqB,IAAI,CAAA;IAE9B,MAAM,CAAE,IAAY,EAAE,KAAU,EAAE,OAAgB;QACvD,qBAAM,CAAC,EAAE,CAAC,IAAI,IAAI,OAAO,EACvB,cAAc,IAAI,6BAA6B,IAAI,CAAC,IAAI,WAAW,CAAC,CAAA;QAEtE,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;QAE3B,KAAK,MAAM,IAAI,IAAI,OAAO;YACxB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;QAE7D,OAAO,IAAA,iBAAK,EAAC,KAAK,EAChB,WAAI,EAAE,GAAG,EAAE,CAAC,IAAI,WAAI,CAAC,KAA0B,EAAE,IAAI,CAAC,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AM,YAAY,KAAK;YAAE,OAAO,IAAI,CAAA;QAExC,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAA;QAEhC,IAAI,MAAM,KAAK,iBAAO,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAAE,MAAM,IAAI,IAAI,CAAC,YAAY,EAAE,CAAA;QAEtF,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAA;QACxB,QAAQ,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAA;QAEjC,OAAO,QAAQ,CAAA;IACjB,CAAC;IAEO,KAAK,CAAC,MAAM,CAAE,QAAkB;QACtC,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAA;QAEvC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAM,SAAS,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;QAElF,OAAO,GAAG,CAAC,MAAM,CAAA;IACnB,CAAC;CACF;AA1HD,sCA0HC;AAED,MAAM,YAAY,GAAkE;IAClF,SAAS,EAAE,qBAAS;IACpB,EAAE,EAAE,OAAE;IACN,IAAI,EAAE,WAAI;IACV,IAAI,EAAE,WAAI;IACV,MAAM,EAAE,eAAM;IACd,MAAM,EAAE,eAAM;IACd,IAAI,EAAE,WAAI;IACV,QAAQ,EAAE,mBAAQ;CACnB,CAAA;AAED,MAAM,OAAO,GAAa,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { type Directive, type Identity } from './types';
2
+ import type { Component } from '@toa.io/core';
3
+ import type { Input } from '../../io';
4
+ export declare class Delegate implements Directive {
5
+ private readonly property;
6
+ private readonly discovery;
7
+ constructor(property: string, discovery: Promise<Component>);
8
+ authorize(identity: Identity | null, context: Input): Promise<boolean>;
9
+ private embed;
10
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Delegate = void 0;
4
+ const HTTP_1 = require("../../HTTP");
5
+ const Role_1 = require("./Role");
6
+ class Delegate {
7
+ property;
8
+ discovery;
9
+ constructor(property, discovery) {
10
+ this.property = property;
11
+ this.discovery = discovery;
12
+ }
13
+ async authorize(identity, context) {
14
+ if (identity === null)
15
+ return false;
16
+ if (identity.roles === undefined)
17
+ await Role_1.Role.set(identity, this.discovery);
18
+ context.pipelines.body.push((body) => this.embed(body, identity));
19
+ return true;
20
+ }
21
+ embed(body, identity) {
22
+ if (body === undefined)
23
+ body = {};
24
+ check(body);
25
+ body[this.property] = structuredClone(identity);
26
+ return body;
27
+ }
28
+ }
29
+ exports.Delegate = Delegate;
30
+ function check(body) {
31
+ if (typeof body !== 'object' || body === null)
32
+ throw new HTTP_1.BadRequest('Invalid request body');
33
+ }
34
+ //# sourceMappingURL=Delegate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Delegate.js","sourceRoot":"","sources":["../../../source/directives/auth/Delegate.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AAEvC,iCAA6B;AAI7B,MAAa,QAAQ;IACF,QAAQ,CAAQ;IAChB,SAAS,CAAoB;IAE9C,YAAoB,QAAgB,EAAE,SAA6B;QACjE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IAEM,KAAK,CAAC,SAAS,CAAE,QAAyB,EAAE,OAAc;QAC/D,IAAI,QAAQ,KAAK,IAAI;YACnB,OAAO,KAAK,CAAA;QAEd,IAAI,QAAQ,CAAC,KAAK,KAAK,SAAS;YAC9B,MAAM,WAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;QAE1C,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAA;QAEjE,OAAO,IAAI,CAAA;IACb,CAAC;IAEO,KAAK,CAAE,IAAa,EAAE,QAAkB;QAC9C,IAAI,IAAI,KAAK,SAAS;YACpB,IAAI,GAAG,EAAE,CAAA;QAEX,KAAK,CAAC,IAAI,CAAC,CAAA;QACX,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAA;QAE/C,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AA9BD,4BA8BC;AAED,SAAS,KAAK,CAAE,IAAa;IAC3B,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI;QAC3C,MAAM,IAAI,iBAAU,CAAC,sBAAsB,CAAC,CAAA;AAChD,CAAC"}
@@ -47,14 +47,15 @@ class Incept {
47
47
  const provider = schemes_1.PROVIDERS[scheme];
48
48
  this.schemes[scheme] ??= await this.discovery[provider];
49
49
  const identity = await this.schemes[scheme]
50
- .invoke('create', {
50
+ .invoke('incept', {
51
51
  input: {
52
+ authority: input.authority,
52
53
  id,
53
54
  credentials
54
55
  }
55
56
  });
56
57
  if (identity instanceof Error)
57
- throw new http.Conflict(identity);
58
+ throw new http.UnprocessableEntity(identity);
58
59
  input.identity = identity;
59
60
  input.identity.scheme = scheme;
60
61
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Incept.js","sourceRoot":"","sources":["../../../source/directives/auth/Incept.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,iDAAkC;AAElC,mCAA+B;AAC/B,uCAAqC;AAErC,MAAa,MAAM;IACA,QAAQ,CAAQ;IAChB,SAAS,CAAW;IACpB,OAAO,GAAY,EAAwB,CAAA;IAE5D,YAAoB,QAAgB,EAAE,SAAoB;QACxD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,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AC,QAAQ,CAAC,CAAA;QAE9C,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACzB,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAA;IAChC,CAAC;CACF;AAzCD,wBAyCC"}
@@ -1,11 +1,14 @@
1
1
  import { type Component } from '@toa.io/core';
2
2
  import { type Directive, type Identity } from './types';
3
+ import type { Parameter } from '../../RTD';
3
4
  export declare class Role implements Directive {
4
5
  static remote: Component | null;
5
6
  private readonly roles;
6
7
  private readonly discovery;
8
+ private readonly dynamic;
7
9
  constructor(roles: string | string[], discovery: Promise<Component>);
8
10
  static set(identity: Identity, discovery: Promise<Component>): Promise<void>;
9
- authorize(identity: Identity | null): Promise<boolean>;
11
+ authorize(identity: Identity | null, _: unknown, parameters: Parameter[]): Promise<boolean>;
10
12
  private match;
13
+ private substitute;
11
14
  }
@@ -1,13 +1,19 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.Role = void 0;
7
+ const node_assert_1 = __importDefault(require("node:assert"));
4
8
  class Role {
5
9
  static remote = null;
6
10
  roles;
7
11
  discovery;
12
+ dynamic;
8
13
  constructor(roles, discovery) {
9
14
  this.roles = typeof roles === 'string' ? [roles] : roles;
10
15
  this.discovery = discovery;
16
+ this.dynamic = this.roles.some((role) => role.includes('{'));
11
17
  }
12
18
  static async set(identity, discovery) {
13
19
  this.remote ??= await discovery;
@@ -17,30 +23,30 @@ class Role {
17
23
  };
18
24
  identity.roles = await this.remote.invoke('list', { query });
19
25
  }
20
- async authorize(identity) {
26
+ async authorize(identity, _, parameters) {
21
27
  if (identity === null)
22
28
  return false;
23
29
  await Role.set(identity, this.discovery);
24
- if (identity.roles === undefined)
30
+ if (identity.roles.length === 0) // Role.set()
25
31
  return false;
26
- return this.match(identity.roles);
32
+ return this.match(identity.roles, parameters);
27
33
  }
28
- match(roles) {
34
+ match(roles, parameters) {
35
+ const required = this.dynamic ? this.substitute(parameters) : this.roles;
29
36
  for (const role of roles) {
30
- const index = this.roles.findIndex((expected) => compare(expected, role));
31
- if (index !== -1)
37
+ const ok = required.some((expected) => expected === role || expected.startsWith(role + ':'));
38
+ if (ok)
32
39
  return true;
33
40
  }
34
41
  return false;
35
42
  }
43
+ substitute(parameters) {
44
+ return this.roles.map((role) => role.replaceAll(/{(\w+)}/g, (_, key) => {
45
+ const value = parameters.find((parameter) => parameter.name === key)?.value;
46
+ node_assert_1.default.ok(value !== undefined, `Role '${role}' requires '${key}' route parameter.`);
47
+ return value;
48
+ }));
49
+ }
36
50
  }
37
51
  exports.Role = Role;
38
- function compare(expected, actual) {
39
- const exp = expected.split(':');
40
- const act = actual.split(':');
41
- for (let i = 0; i < act.length; i++)
42
- if (exp[i] !== act[i])
43
- return false;
44
- return true;
45
- }
46
52
  //# sourceMappingURL=Role.js.map