@blazedpath/commons 0.2.2 → 0.3.1

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 (626) hide show
  1. package/README.md +4 -1
  2. package/dist/blz-base/health/index.d.ts +1 -0
  3. package/dist/blz-base/health/index.js +1 -0
  4. package/dist/blz-base/index.d.ts +108 -0
  5. package/dist/blz-base/index.js +1 -0
  6. package/dist/blz-cache/LruCache.d.ts +31 -0
  7. package/dist/blz-cache/LruCache.js +1 -0
  8. package/dist/blz-cache/index.d.ts +2 -0
  9. package/dist/blz-cache/index.js +1 -0
  10. package/dist/blz-config/index.d.ts +16 -0
  11. package/dist/blz-config/index.js +1 -0
  12. package/dist/blz-core/index.d.ts +32 -0
  13. package/dist/blz-core/index.js +1 -0
  14. package/dist/blz-cryptography/index.d.ts +2 -0
  15. package/dist/blz-cryptography/index.js +1 -0
  16. package/dist/blz-datetimes/index.d.ts +35 -0
  17. package/dist/blz-datetimes/index.js +1 -0
  18. package/dist/blz-file/fileService.d.ts +25 -0
  19. package/dist/blz-file/fileService.js +1 -0
  20. package/dist/blz-file/index.d.ts +2 -0
  21. package/dist/blz-file/index.js +1 -0
  22. package/dist/blz-file/index.test.js +1 -0
  23. package/dist/blz-file/lab.js +1 -0
  24. package/dist/blz-hazelcast/index.d.ts +25 -0
  25. package/dist/blz-hazelcast/index.js +1 -0
  26. package/dist/blz-hazelcast/lib/credentials.d.ts +10 -0
  27. package/dist/blz-hazelcast/lib/credentials.js +1 -0
  28. package/dist/blz-hazelcast/lib/credentialsFactory.d.ts +1 -0
  29. package/dist/blz-hazelcast/lib/credentialsFactory.js +1 -0
  30. package/dist/blz-hazelcast/lib/hazelcastCache.d.ts +27 -0
  31. package/dist/blz-hazelcast/lib/hazelcastCache.js +1 -0
  32. package/dist/blz-iterable/index.d.ts +49 -0
  33. package/dist/blz-iterable/index.js +1 -0
  34. package/dist/blz-json-schema/index.d.ts +1 -0
  35. package/dist/blz-json-schema/index.js +1 -0
  36. package/dist/blz-jwt/index.d.ts +12 -0
  37. package/dist/blz-jwt/index.js +1 -0
  38. package/dist/blz-kafka/index.d.ts +9 -0
  39. package/dist/blz-kafka/index.js +1 -0
  40. package/dist/blz-math/index.d.ts +22 -0
  41. package/dist/blz-math/index.js +1 -0
  42. package/dist/blz-mongodb/index.d.ts +28 -0
  43. package/dist/blz-mongodb/index.js +1 -0
  44. package/dist/blz-rds/__test__/scape.test.js +1 -0
  45. package/dist/blz-rds/blz-rds-executor.d.ts +4 -0
  46. package/dist/blz-rds/blz-rds-executor.js +1 -0
  47. package/dist/blz-rds/blz-rds-helper.d.ts +5 -0
  48. package/dist/blz-rds/blz-rds-helper.js +1 -0
  49. package/dist/blz-rds/commands/core/add.d.ts +2 -0
  50. package/dist/blz-rds/commands/core/add.js +1 -0
  51. package/dist/blz-rds/commands/core/and.d.ts +3 -0
  52. package/dist/blz-rds/commands/core/and.js +1 -0
  53. package/dist/blz-rds/commands/core/asc.d.ts +2 -0
  54. package/dist/blz-rds/commands/core/asc.js +1 -0
  55. package/dist/blz-rds/commands/core/avg.d.ts +2 -0
  56. package/dist/blz-rds/commands/core/avg.js +1 -0
  57. package/dist/blz-rds/commands/core/column-ref.d.ts +2 -0
  58. package/dist/blz-rds/commands/core/column-ref.js +1 -0
  59. package/dist/blz-rds/commands/core/count-distinct.d.ts +2 -0
  60. package/dist/blz-rds/commands/core/count-distinct.js +1 -0
  61. package/dist/blz-rds/commands/core/count.d.ts +2 -0
  62. package/dist/blz-rds/commands/core/count.js +1 -0
  63. package/dist/blz-rds/commands/core/decimal.d.ts +2 -0
  64. package/dist/blz-rds/commands/core/decimal.js +1 -0
  65. package/dist/blz-rds/commands/core/desc.d.ts +2 -0
  66. package/dist/blz-rds/commands/core/desc.js +1 -0
  67. package/dist/blz-rds/commands/core/distinct.d.ts +2 -0
  68. package/dist/blz-rds/commands/core/distinct.js +1 -0
  69. package/dist/blz-rds/commands/core/divide.d.ts +2 -0
  70. package/dist/blz-rds/commands/core/divide.js +1 -0
  71. package/dist/blz-rds/commands/core/embedded-exists.d.ts +3 -0
  72. package/dist/blz-rds/commands/core/embedded-exists.js +1 -0
  73. package/dist/blz-rds/commands/core/embedded-select.d.ts +2 -0
  74. package/dist/blz-rds/commands/core/embedded-select.js +1 -0
  75. package/dist/blz-rds/commands/core/equals.d.ts +3 -0
  76. package/dist/blz-rds/commands/core/equals.js +1 -0
  77. package/dist/blz-rds/commands/core/false.d.ts +2 -0
  78. package/dist/blz-rds/commands/core/false.js +1 -0
  79. package/dist/blz-rds/commands/core/greater-or-equal.d.ts +3 -0
  80. package/dist/blz-rds/commands/core/greater-or-equal.js +1 -0
  81. package/dist/blz-rds/commands/core/greater.d.ts +3 -0
  82. package/dist/blz-rds/commands/core/greater.js +1 -0
  83. package/dist/blz-rds/commands/core/in.d.ts +3 -0
  84. package/dist/blz-rds/commands/core/in.js +1 -0
  85. package/dist/blz-rds/commands/core/integer.d.ts +2 -0
  86. package/dist/blz-rds/commands/core/integer.js +1 -0
  87. package/dist/blz-rds/commands/core/is-not-null.d.ts +3 -0
  88. package/dist/blz-rds/commands/core/is-not-null.js +1 -0
  89. package/dist/blz-rds/commands/core/is-null-or-value.d.ts +3 -0
  90. package/dist/blz-rds/commands/core/is-null-or-value.js +1 -0
  91. package/dist/blz-rds/commands/core/is-null.d.ts +3 -0
  92. package/dist/blz-rds/commands/core/is-null.js +1 -0
  93. package/dist/blz-rds/commands/core/less-or-equal.d.ts +3 -0
  94. package/dist/blz-rds/commands/core/less-or-equal.js +1 -0
  95. package/dist/blz-rds/commands/core/less-unary.d.ts +2 -0
  96. package/dist/blz-rds/commands/core/less-unary.js +1 -0
  97. package/dist/blz-rds/commands/core/less.d.ts +3 -0
  98. package/dist/blz-rds/commands/core/less.js +1 -0
  99. package/dist/blz-rds/commands/core/like.d.ts +3 -0
  100. package/dist/blz-rds/commands/core/like.js +1 -0
  101. package/dist/blz-rds/commands/core/max.d.ts +2 -0
  102. package/dist/blz-rds/commands/core/max.js +1 -0
  103. package/dist/blz-rds/commands/core/min.d.ts +2 -0
  104. package/dist/blz-rds/commands/core/min.js +1 -0
  105. package/dist/blz-rds/commands/core/multiply.d.ts +2 -0
  106. package/dist/blz-rds/commands/core/multiply.js +1 -0
  107. package/dist/blz-rds/commands/core/not-equals.d.ts +3 -0
  108. package/dist/blz-rds/commands/core/not-equals.js +1 -0
  109. package/dist/blz-rds/commands/core/not-in.d.ts +3 -0
  110. package/dist/blz-rds/commands/core/not-in.js +1 -0
  111. package/dist/blz-rds/commands/core/not.d.ts +3 -0
  112. package/dist/blz-rds/commands/core/not.js +1 -0
  113. package/dist/blz-rds/commands/core/null.d.ts +2 -0
  114. package/dist/blz-rds/commands/core/null.js +1 -0
  115. package/dist/blz-rds/commands/core/nvl.d.ts +2 -0
  116. package/dist/blz-rds/commands/core/nvl.js +1 -0
  117. package/dist/blz-rds/commands/core/or.d.ts +3 -0
  118. package/dist/blz-rds/commands/core/or.js +1 -0
  119. package/dist/blz-rds/commands/core/parameter.d.ts +2 -0
  120. package/dist/blz-rds/commands/core/parameter.js +1 -0
  121. package/dist/blz-rds/commands/core/remainder.d.ts +2 -0
  122. package/dist/blz-rds/commands/core/remainder.js +1 -0
  123. package/dist/blz-rds/commands/core/string.d.ts +2 -0
  124. package/dist/blz-rds/commands/core/string.js +1 -0
  125. package/dist/blz-rds/commands/core/subtract.d.ts +2 -0
  126. package/dist/blz-rds/commands/core/subtract.js +1 -0
  127. package/dist/blz-rds/commands/core/sum.d.ts +2 -0
  128. package/dist/blz-rds/commands/core/sum.js +1 -0
  129. package/dist/blz-rds/commands/core/true.d.ts +2 -0
  130. package/dist/blz-rds/commands/core/true.js +1 -0
  131. package/dist/blz-rds/commands/core/tuple.d.ts +2 -0
  132. package/dist/blz-rds/commands/core/tuple.js +1 -0
  133. package/dist/blz-rds/commands/datetimes/add-days.d.ts +2 -0
  134. package/dist/blz-rds/commands/datetimes/add-days.js +1 -0
  135. package/dist/blz-rds/commands/datetimes/add-hours.d.ts +2 -0
  136. package/dist/blz-rds/commands/datetimes/add-hours.js +1 -0
  137. package/dist/blz-rds/commands/datetimes/add-milliseconds.d.ts +2 -0
  138. package/dist/blz-rds/commands/datetimes/add-milliseconds.js +1 -0
  139. package/dist/blz-rds/commands/datetimes/add-minutes.d.ts +2 -0
  140. package/dist/blz-rds/commands/datetimes/add-minutes.js +1 -0
  141. package/dist/blz-rds/commands/datetimes/add-months.d.ts +2 -0
  142. package/dist/blz-rds/commands/datetimes/add-months.js +1 -0
  143. package/dist/blz-rds/commands/datetimes/add-seconds.d.ts +2 -0
  144. package/dist/blz-rds/commands/datetimes/add-seconds.js +1 -0
  145. package/dist/blz-rds/commands/datetimes/add-years.d.ts +2 -0
  146. package/dist/blz-rds/commands/datetimes/add-years.js +1 -0
  147. package/dist/blz-rds/commands/datetimes/date-diff.d.ts +2 -0
  148. package/dist/blz-rds/commands/datetimes/date-diff.js +1 -0
  149. package/dist/blz-rds/commands/datetimes/date.d.ts +2 -0
  150. package/dist/blz-rds/commands/datetimes/date.js +1 -0
  151. package/dist/blz-rds/commands/datetimes/datetime-diff.d.ts +2 -0
  152. package/dist/blz-rds/commands/datetimes/datetime-diff.js +1 -0
  153. package/dist/blz-rds/commands/datetimes/datetime.d.ts +2 -0
  154. package/dist/blz-rds/commands/datetimes/datetime.js +1 -0
  155. package/dist/blz-rds/commands/datetimes/day.d.ts +2 -0
  156. package/dist/blz-rds/commands/datetimes/day.js +1 -0
  157. package/dist/blz-rds/commands/datetimes/hour.d.ts +2 -0
  158. package/dist/blz-rds/commands/datetimes/hour.js +1 -0
  159. package/dist/blz-rds/commands/datetimes/millisecond.d.ts +2 -0
  160. package/dist/blz-rds/commands/datetimes/millisecond.js +1 -0
  161. package/dist/blz-rds/commands/datetimes/minute.d.ts +2 -0
  162. package/dist/blz-rds/commands/datetimes/minute.js +1 -0
  163. package/dist/blz-rds/commands/datetimes/month-text.d.ts +2 -0
  164. package/dist/blz-rds/commands/datetimes/month-text.js +1 -0
  165. package/dist/blz-rds/commands/datetimes/month.d.ts +2 -0
  166. package/dist/blz-rds/commands/datetimes/month.js +1 -0
  167. package/dist/blz-rds/commands/datetimes/now.d.ts +2 -0
  168. package/dist/blz-rds/commands/datetimes/now.js +1 -0
  169. package/dist/blz-rds/commands/datetimes/second.d.ts +2 -0
  170. package/dist/blz-rds/commands/datetimes/second.js +1 -0
  171. package/dist/blz-rds/commands/datetimes/subtract-days.d.ts +2 -0
  172. package/dist/blz-rds/commands/datetimes/subtract-days.js +1 -0
  173. package/dist/blz-rds/commands/datetimes/subtract-hours.d.ts +2 -0
  174. package/dist/blz-rds/commands/datetimes/subtract-hours.js +1 -0
  175. package/dist/blz-rds/commands/datetimes/subtract-milliseconds.d.ts +2 -0
  176. package/dist/blz-rds/commands/datetimes/subtract-milliseconds.js +1 -0
  177. package/dist/blz-rds/commands/datetimes/subtract-minutes.d.ts +2 -0
  178. package/dist/blz-rds/commands/datetimes/subtract-minutes.js +1 -0
  179. package/dist/blz-rds/commands/datetimes/subtract-seconds.d.ts +2 -0
  180. package/dist/blz-rds/commands/datetimes/subtract-seconds.js +1 -0
  181. package/dist/blz-rds/commands/datetimes/time-diff.d.ts +2 -0
  182. package/dist/blz-rds/commands/datetimes/time-diff.js +1 -0
  183. package/dist/blz-rds/commands/datetimes/time.d.ts +2 -0
  184. package/dist/blz-rds/commands/datetimes/time.js +1 -0
  185. package/dist/blz-rds/commands/datetimes/today.d.ts +2 -0
  186. package/dist/blz-rds/commands/datetimes/today.js +1 -0
  187. package/dist/blz-rds/commands/datetimes/week-day-text.d.ts +2 -0
  188. package/dist/blz-rds/commands/datetimes/week-day-text.js +1 -0
  189. package/dist/blz-rds/commands/datetimes/week-day.d.ts +2 -0
  190. package/dist/blz-rds/commands/datetimes/week-day.js +1 -0
  191. package/dist/blz-rds/commands/datetimes/week.d.ts +2 -0
  192. package/dist/blz-rds/commands/datetimes/week.js +1 -0
  193. package/dist/blz-rds/commands/datetimes/year.d.ts +2 -0
  194. package/dist/blz-rds/commands/datetimes/year.js +1 -0
  195. package/dist/blz-rds/commands/math/abs.d.ts +2 -0
  196. package/dist/blz-rds/commands/math/abs.js +1 -0
  197. package/dist/blz-rds/commands/math/acos.d.ts +2 -0
  198. package/dist/blz-rds/commands/math/acos.js +1 -0
  199. package/dist/blz-rds/commands/math/asin.d.ts +2 -0
  200. package/dist/blz-rds/commands/math/asin.js +1 -0
  201. package/dist/blz-rds/commands/math/atan.d.ts +2 -0
  202. package/dist/blz-rds/commands/math/atan.js +1 -0
  203. package/dist/blz-rds/commands/math/atan2.d.ts +2 -0
  204. package/dist/blz-rds/commands/math/atan2.js +1 -0
  205. package/dist/blz-rds/commands/math/ceil.d.ts +2 -0
  206. package/dist/blz-rds/commands/math/ceil.js +1 -0
  207. package/dist/blz-rds/commands/math/cos.d.ts +2 -0
  208. package/dist/blz-rds/commands/math/cos.js +1 -0
  209. package/dist/blz-rds/commands/math/cosh.d.ts +2 -0
  210. package/dist/blz-rds/commands/math/cosh.js +1 -0
  211. package/dist/blz-rds/commands/math/exp.d.ts +2 -0
  212. package/dist/blz-rds/commands/math/exp.js +1 -0
  213. package/dist/blz-rds/commands/math/floor.d.ts +2 -0
  214. package/dist/blz-rds/commands/math/floor.js +1 -0
  215. package/dist/blz-rds/commands/math/log.d.ts +2 -0
  216. package/dist/blz-rds/commands/math/log.js +1 -0
  217. package/dist/blz-rds/commands/math/log10.d.ts +2 -0
  218. package/dist/blz-rds/commands/math/log10.js +1 -0
  219. package/dist/blz-rds/commands/math/pow.d.ts +2 -0
  220. package/dist/blz-rds/commands/math/pow.js +1 -0
  221. package/dist/blz-rds/commands/math/random.d.ts +2 -0
  222. package/dist/blz-rds/commands/math/random.js +1 -0
  223. package/dist/blz-rds/commands/math/round.d.ts +2 -0
  224. package/dist/blz-rds/commands/math/round.js +1 -0
  225. package/dist/blz-rds/commands/math/sign.d.ts +2 -0
  226. package/dist/blz-rds/commands/math/sign.js +1 -0
  227. package/dist/blz-rds/commands/math/sin.d.ts +2 -0
  228. package/dist/blz-rds/commands/math/sin.js +1 -0
  229. package/dist/blz-rds/commands/math/sinh.d.ts +2 -0
  230. package/dist/blz-rds/commands/math/sinh.js +1 -0
  231. package/dist/blz-rds/commands/math/sqrt.d.ts +2 -0
  232. package/dist/blz-rds/commands/math/sqrt.js +1 -0
  233. package/dist/blz-rds/commands/math/tan.d.ts +2 -0
  234. package/dist/blz-rds/commands/math/tan.js +1 -0
  235. package/dist/blz-rds/commands/math/tanh.d.ts +2 -0
  236. package/dist/blz-rds/commands/math/tanh.js +1 -0
  237. package/dist/blz-rds/commands/math/trunc.d.ts +2 -0
  238. package/dist/blz-rds/commands/math/trunc.js +1 -0
  239. package/dist/blz-rds/commands/strings/concat.d.ts +2 -0
  240. package/dist/blz-rds/commands/strings/concat.js +1 -0
  241. package/dist/blz-rds/commands/strings/contains.d.ts +3 -0
  242. package/dist/blz-rds/commands/strings/contains.js +1 -0
  243. package/dist/blz-rds/commands/strings/ends-with.d.ts +3 -0
  244. package/dist/blz-rds/commands/strings/ends-with.js +1 -0
  245. package/dist/blz-rds/commands/strings/index-of.d.ts +2 -0
  246. package/dist/blz-rds/commands/strings/index-of.js +1 -0
  247. package/dist/blz-rds/commands/strings/is-null-or-empty.d.ts +3 -0
  248. package/dist/blz-rds/commands/strings/is-null-or-empty.js +1 -0
  249. package/dist/blz-rds/commands/strings/is-null-or-white-space.d.ts +3 -0
  250. package/dist/blz-rds/commands/strings/is-null-or-white-space.js +1 -0
  251. package/dist/blz-rds/commands/strings/join.d.ts +2 -0
  252. package/dist/blz-rds/commands/strings/join.js +1 -0
  253. package/dist/blz-rds/commands/strings/last-index-of.d.ts +2 -0
  254. package/dist/blz-rds/commands/strings/last-index-of.js +1 -0
  255. package/dist/blz-rds/commands/strings/length.d.ts +2 -0
  256. package/dist/blz-rds/commands/strings/length.js +1 -0
  257. package/dist/blz-rds/commands/strings/pad-left.d.ts +2 -0
  258. package/dist/blz-rds/commands/strings/pad-left.js +1 -0
  259. package/dist/blz-rds/commands/strings/pad-right.d.ts +2 -0
  260. package/dist/blz-rds/commands/strings/pad-right.js +1 -0
  261. package/dist/blz-rds/commands/strings/replace.d.ts +2 -0
  262. package/dist/blz-rds/commands/strings/replace.js +1 -0
  263. package/dist/blz-rds/commands/strings/starts-with.d.ts +3 -0
  264. package/dist/blz-rds/commands/strings/starts-with.js +1 -0
  265. package/dist/blz-rds/commands/strings/substring.d.ts +2 -0
  266. package/dist/blz-rds/commands/strings/substring.js +1 -0
  267. package/dist/blz-rds/commands/strings/to-lower.d.ts +2 -0
  268. package/dist/blz-rds/commands/strings/to-lower.js +1 -0
  269. package/dist/blz-rds/commands/strings/to-upper.d.ts +2 -0
  270. package/dist/blz-rds/commands/strings/to-upper.js +1 -0
  271. package/dist/blz-rds/commands/strings/trim-end.d.ts +2 -0
  272. package/dist/blz-rds/commands/strings/trim-end.js +1 -0
  273. package/dist/blz-rds/commands/strings/trim-start.d.ts +2 -0
  274. package/dist/blz-rds/commands/strings/trim-start.js +1 -0
  275. package/dist/blz-rds/commands/strings/trim.d.ts +2 -0
  276. package/dist/blz-rds/commands/strings/trim.js +1 -0
  277. package/dist/blz-rds/index.d.ts +53 -0
  278. package/dist/blz-rds/index.js +1 -0
  279. package/dist/blz-rds-mysql/base.d.ts +83 -0
  280. package/dist/blz-rds-mysql/base.js +1 -0
  281. package/dist/blz-rds-mysql/connection-manager.d.ts +8 -0
  282. package/dist/blz-rds-mysql/connection-manager.js +1 -0
  283. package/dist/blz-rds-mysql/execute-bulk-insert.d.ts +2 -0
  284. package/dist/blz-rds-mysql/execute-bulk-insert.js +1 -0
  285. package/dist/blz-rds-mysql/execute-bulk-merge.d.ts +2 -0
  286. package/dist/blz-rds-mysql/execute-bulk-merge.js +1 -0
  287. package/dist/blz-rds-mysql/execute-non-query.d.ts +14 -0
  288. package/dist/blz-rds-mysql/execute-non-query.js +1 -0
  289. package/dist/blz-rds-mysql/execute-query.d.ts +11 -0
  290. package/dist/blz-rds-mysql/execute-query.js +1 -0
  291. package/dist/blz-rds-mysql/index.d.ts +9 -0
  292. package/dist/blz-rds-mysql/index.js +1 -0
  293. package/dist/blz-rds-mysql/stored-procedure.d.ts +19 -0
  294. package/dist/blz-rds-mysql/stored-procedure.js +1 -0
  295. package/dist/blz-rds-mysqlx/base.d.ts +83 -0
  296. package/dist/blz-rds-mysqlx/base.js +1 -0
  297. package/dist/blz-rds-mysqlx/connection-manager.d.ts +6 -0
  298. package/dist/blz-rds-mysqlx/connection-manager.js +1 -0
  299. package/dist/blz-rds-mysqlx/execute-bulk-insert.d.ts +2 -0
  300. package/dist/blz-rds-mysqlx/execute-bulk-insert.js +1 -0
  301. package/dist/blz-rds-mysqlx/execute-bulk-merge.d.ts +2 -0
  302. package/dist/blz-rds-mysqlx/execute-bulk-merge.js +1 -0
  303. package/dist/blz-rds-mysqlx/execute-non-query.d.ts +4 -0
  304. package/dist/blz-rds-mysqlx/execute-non-query.js +1 -0
  305. package/dist/blz-rds-mysqlx/execute-query.d.ts +7 -0
  306. package/dist/blz-rds-mysqlx/execute-query.js +1 -0
  307. package/dist/blz-rds-mysqlx/index.d.ts +9 -0
  308. package/dist/blz-rds-mysqlx/index.js +1 -0
  309. package/dist/blz-rds-mysqlx/stored-procedure.d.ts +20 -0
  310. package/dist/blz-rds-mysqlx/stored-procedure.js +1 -0
  311. package/dist/blz-rds-oracle/index.d.ts +25 -0
  312. package/dist/blz-rds-oracle/index.js +1 -0
  313. package/dist/blz-rds-postgres/base.d.ts +94 -0
  314. package/dist/blz-rds-postgres/base.js +1 -0
  315. package/dist/blz-rds-postgres/connection-manager.d.ts +6 -0
  316. package/dist/blz-rds-postgres/connection-manager.js +1 -0
  317. package/dist/blz-rds-postgres/execute-bulk-insert.d.ts +5 -0
  318. package/dist/blz-rds-postgres/execute-bulk-insert.js +1 -0
  319. package/dist/blz-rds-postgres/execute-bulk-merge.d.ts +4 -0
  320. package/dist/blz-rds-postgres/execute-bulk-merge.js +1 -0
  321. package/dist/blz-rds-postgres/execute-non-query.d.ts +12 -0
  322. package/dist/blz-rds-postgres/execute-non-query.js +1 -0
  323. package/dist/blz-rds-postgres/execute-query.d.ts +4 -0
  324. package/dist/blz-rds-postgres/execute-query.js +1 -0
  325. package/dist/blz-rds-postgres/index.d.ts +9 -0
  326. package/dist/blz-rds-postgres/index.js +1 -0
  327. package/dist/blz-rds-postgres/result-set.js +1 -0
  328. package/dist/blz-rds-postgres/stored-procedure.d.ts +19 -0
  329. package/dist/blz-rds-postgres/stored-procedure.js +1 -0
  330. package/dist/blz-redis/index.d.ts +31 -0
  331. package/dist/blz-redis/index.js +1 -0
  332. package/dist/blz-redis/lib/redisCache.d.ts +33 -0
  333. package/dist/blz-redis/lib/redisCache.js +1 -0
  334. package/dist/blz-regex/index.d.ts +3 -0
  335. package/dist/blz-regex/index.js +1 -0
  336. package/dist/blz-security/__test__/autorization.test.js +1 -0
  337. package/dist/blz-security/__test__/autorizationKpn.test.js +1 -0
  338. package/dist/blz-security/__test__/orderManagement.test.js +1 -0
  339. package/dist/blz-security/__test__/secureUrl.test.js +1 -0
  340. package/dist/blz-security/__test__/solveMergeRule.test.js +1 -0
  341. package/dist/blz-security/__test__/sqlInjectionGuard.test.js +1 -0
  342. package/dist/blz-security/__test__/xssGuard.test.js +1 -0
  343. package/dist/blz-security/authorizationService.d.ts +42 -0
  344. package/dist/blz-security/authorizationService.js +2 -0
  345. package/dist/blz-security/config/global.js +1 -0
  346. package/dist/blz-security/filescanner/index.d.ts +24 -0
  347. package/dist/blz-security/filescanner/index.js +1 -0
  348. package/dist/blz-security/helpers/consts.d.ts +28 -0
  349. package/dist/blz-security/helpers/consts.js +1 -0
  350. package/dist/blz-security/helpers/utils.d.ts +82 -0
  351. package/dist/blz-security/helpers/utils.js +1 -0
  352. package/dist/blz-security/implementations/cache.d.ts +58 -0
  353. package/dist/blz-security/implementations/cache.js +1 -0
  354. package/dist/blz-security/implementations/oidc.d.ts +100 -0
  355. package/dist/blz-security/implementations/oidc.js +1 -0
  356. package/dist/blz-security/implementations/pkceCacheStore.d.ts +2 -0
  357. package/dist/blz-security/implementations/pkceCacheStore.js +1 -0
  358. package/dist/blz-security/implementations/saml.js +1 -0
  359. package/dist/blz-security/implementations/uma.d.ts +31 -0
  360. package/dist/blz-security/implementations/uma.js +1 -0
  361. package/dist/blz-security/implementations/webAuthn.js +1 -0
  362. package/dist/blz-security/implementations/wstg.js +1 -0
  363. package/dist/blz-security/index.d.ts +4 -0
  364. package/dist/blz-security/index.js +2 -0
  365. package/dist/blz-security/lab/index.js +1 -0
  366. package/dist/blz-security/middleware/HapiServerAzureAd.d.ts +26 -0
  367. package/dist/blz-security/middleware/HapiServerAzureAd.js +1 -0
  368. package/dist/blz-security/middleware/HapiServerKeycloak.d.ts +47 -0
  369. package/dist/blz-security/middleware/HapiServerKeycloak.js +1 -0
  370. package/dist/blz-security/middleware/HapiServerSimToken.d.ts +13 -0
  371. package/dist/blz-security/middleware/HapiServerSimToken.js +1 -0
  372. package/dist/blz-security/middleware/hapi.d.ts +14 -0
  373. package/dist/blz-security/middleware/hapi.js +1 -0
  374. package/dist/blz-security/middleware/hapiServer.js +1 -0
  375. package/dist/blz-security/navigationMemoryRepository.d.ts +6 -0
  376. package/dist/blz-security/navigationMemoryRepository.js +1 -0
  377. package/dist/blz-security/navigationMongoDbRepository.d.ts +15 -0
  378. package/dist/blz-security/navigationMongoDbRepository.js +1 -0
  379. package/dist/blz-security/secureUrlService.d.ts +7 -0
  380. package/dist/blz-security/secureUrlService.js +1 -0
  381. package/dist/blz-security/securityService.d.ts +72 -0
  382. package/dist/blz-security/securityService.js +1 -0
  383. package/dist/blz-security/sqlInjectionGuard.d.ts +37 -0
  384. package/dist/blz-security/sqlInjectionGuard.js +1 -0
  385. package/dist/blz-security/xssGuard.d.ts +14 -0
  386. package/dist/blz-security/xssGuard.js +1 -0
  387. package/dist/blz-strings/index.d.ts +42 -0
  388. package/dist/blz-strings/index.js +1 -0
  389. package/dist/blz-uuid/index.d.ts +1 -0
  390. package/dist/blz-uuid/index.js +1 -0
  391. package/dist/blz-yaml/index.d.ts +2 -0
  392. package/dist/blz-yaml/index.js +1 -0
  393. package/dist/index.d.ts +34 -0
  394. package/dist/index.js +1 -0
  395. package/dist/process-managers/index.d.ts +25 -0
  396. package/dist/process-managers/index.js +1 -0
  397. package/package.json +52 -41
  398. package/blz-base/health/index.js +0 -215
  399. package/blz-base/index.js +0 -1466
  400. package/blz-cache/LruCache.js +0 -44
  401. package/blz-cache/index.js +0 -29
  402. package/blz-config/index.js +0 -434
  403. package/blz-core/index.js +0 -364
  404. package/blz-cryptography/index.js +0 -54
  405. package/blz-datetimes/index.js +0 -356
  406. package/blz-file/example.dat +0 -2545
  407. package/blz-file/fileService.js +0 -205
  408. package/blz-file/index.js +0 -94
  409. package/blz-file/index.test.js +0 -31
  410. package/blz-file/lab.js +0 -33
  411. package/blz-hazelcast/index.js +0 -189
  412. package/blz-hazelcast/lib/credentials.js +0 -25
  413. package/blz-hazelcast/lib/credentialsFactory.js +0 -12
  414. package/blz-hazelcast/lib/hazelcastCache.js +0 -234
  415. package/blz-iterable/index.js +0 -446
  416. package/blz-json-schema/index.js +0 -11
  417. package/blz-jwt/index.js +0 -121
  418. package/blz-kafka/index.js +0 -522
  419. package/blz-math/index.js +0 -131
  420. package/blz-mongodb/index.js +0 -326
  421. package/blz-rds/__test__/scape.test.js +0 -58
  422. package/blz-rds/blz-rds-executor.js +0 -578
  423. package/blz-rds/blz-rds-helper.js +0 -310
  424. package/blz-rds/commands/core/add.js +0 -13
  425. package/blz-rds/commands/core/and.js +0 -18
  426. package/blz-rds/commands/core/asc.js +0 -10
  427. package/blz-rds/commands/core/avg.js +0 -10
  428. package/blz-rds/commands/core/column-ref.js +0 -8
  429. package/blz-rds/commands/core/count-distinct.js +0 -10
  430. package/blz-rds/commands/core/count.js +0 -10
  431. package/blz-rds/commands/core/decimal.js +0 -8
  432. package/blz-rds/commands/core/desc.js +0 -10
  433. package/blz-rds/commands/core/distinct.js +0 -10
  434. package/blz-rds/commands/core/divide.js +0 -11
  435. package/blz-rds/commands/core/embedded-exists.js +0 -17
  436. package/blz-rds/commands/core/embedded-select.js +0 -17
  437. package/blz-rds/commands/core/equals.js +0 -9
  438. package/blz-rds/commands/core/false.js +0 -8
  439. package/blz-rds/commands/core/greater-or-equal.js +0 -9
  440. package/blz-rds/commands/core/greater.js +0 -9
  441. package/blz-rds/commands/core/in.js +0 -9
  442. package/blz-rds/commands/core/integer.js +0 -8
  443. package/blz-rds/commands/core/is-not-null.js +0 -11
  444. package/blz-rds/commands/core/is-null-or-value.js +0 -10
  445. package/blz-rds/commands/core/is-null.js +0 -11
  446. package/blz-rds/commands/core/less-or-equal.js +0 -9
  447. package/blz-rds/commands/core/less-unary.js +0 -12
  448. package/blz-rds/commands/core/less.js +0 -9
  449. package/blz-rds/commands/core/like.js +0 -12
  450. package/blz-rds/commands/core/max.js +0 -10
  451. package/blz-rds/commands/core/min.js +0 -10
  452. package/blz-rds/commands/core/multiply.js +0 -13
  453. package/blz-rds/commands/core/not-equals.js +0 -9
  454. package/blz-rds/commands/core/not-in.js +0 -9
  455. package/blz-rds/commands/core/not.js +0 -13
  456. package/blz-rds/commands/core/null.js +0 -8
  457. package/blz-rds/commands/core/nvl.js +0 -11
  458. package/blz-rds/commands/core/or.js +0 -13
  459. package/blz-rds/commands/core/parameter.js +0 -34
  460. package/blz-rds/commands/core/remainder.js +0 -16
  461. package/blz-rds/commands/core/string.js +0 -8
  462. package/blz-rds/commands/core/subtract.js +0 -13
  463. package/blz-rds/commands/core/sum.js +0 -10
  464. package/blz-rds/commands/core/true.js +0 -8
  465. package/blz-rds/commands/core/tuple.js +0 -13
  466. package/blz-rds/commands/datetimes/add-days.js +0 -11
  467. package/blz-rds/commands/datetimes/add-hours.js +0 -11
  468. package/blz-rds/commands/datetimes/add-milliseconds.js +0 -11
  469. package/blz-rds/commands/datetimes/add-minutes.js +0 -11
  470. package/blz-rds/commands/datetimes/add-months.js +0 -11
  471. package/blz-rds/commands/datetimes/add-seconds.js +0 -11
  472. package/blz-rds/commands/datetimes/add-years.js +0 -11
  473. package/blz-rds/commands/datetimes/date-diff.js +0 -11
  474. package/blz-rds/commands/datetimes/date.js +0 -12
  475. package/blz-rds/commands/datetimes/datetime-diff.js +0 -11
  476. package/blz-rds/commands/datetimes/datetime.js +0 -15
  477. package/blz-rds/commands/datetimes/day.js +0 -10
  478. package/blz-rds/commands/datetimes/hour.js +0 -10
  479. package/blz-rds/commands/datetimes/millisecond.js +0 -10
  480. package/blz-rds/commands/datetimes/minute.js +0 -10
  481. package/blz-rds/commands/datetimes/month-text.js +0 -10
  482. package/blz-rds/commands/datetimes/month.js +0 -10
  483. package/blz-rds/commands/datetimes/now.js +0 -9
  484. package/blz-rds/commands/datetimes/second.js +0 -10
  485. package/blz-rds/commands/datetimes/subtract-days.js +0 -11
  486. package/blz-rds/commands/datetimes/subtract-hours.js +0 -11
  487. package/blz-rds/commands/datetimes/subtract-milliseconds.js +0 -11
  488. package/blz-rds/commands/datetimes/subtract-minutes.js +0 -11
  489. package/blz-rds/commands/datetimes/subtract-seconds.js +0 -11
  490. package/blz-rds/commands/datetimes/time-diff.js +0 -11
  491. package/blz-rds/commands/datetimes/time.js +0 -13
  492. package/blz-rds/commands/datetimes/today.js +0 -9
  493. package/blz-rds/commands/datetimes/week-day-text.js +0 -10
  494. package/blz-rds/commands/datetimes/week-day.js +0 -10
  495. package/blz-rds/commands/datetimes/week.js +0 -10
  496. package/blz-rds/commands/datetimes/year.js +0 -10
  497. package/blz-rds/commands/math/abs.js +0 -10
  498. package/blz-rds/commands/math/acos.js +0 -10
  499. package/blz-rds/commands/math/asin.js +0 -10
  500. package/blz-rds/commands/math/atan.js +0 -10
  501. package/blz-rds/commands/math/atan2.js +0 -11
  502. package/blz-rds/commands/math/ceil.js +0 -10
  503. package/blz-rds/commands/math/cos.js +0 -10
  504. package/blz-rds/commands/math/cosh.js +0 -10
  505. package/blz-rds/commands/math/exp.js +0 -10
  506. package/blz-rds/commands/math/floor.js +0 -10
  507. package/blz-rds/commands/math/log.js +0 -18
  508. package/blz-rds/commands/math/log10.js +0 -10
  509. package/blz-rds/commands/math/pow.js +0 -11
  510. package/blz-rds/commands/math/random.js +0 -9
  511. package/blz-rds/commands/math/round.js +0 -18
  512. package/blz-rds/commands/math/sign.js +0 -10
  513. package/blz-rds/commands/math/sin.js +0 -10
  514. package/blz-rds/commands/math/sinh.js +0 -10
  515. package/blz-rds/commands/math/sqrt.js +0 -10
  516. package/blz-rds/commands/math/tan.js +0 -10
  517. package/blz-rds/commands/math/tanh.js +0 -10
  518. package/blz-rds/commands/math/trunc.js +0 -18
  519. package/blz-rds/commands/strings/concat.js +0 -20
  520. package/blz-rds/commands/strings/contains.js +0 -12
  521. package/blz-rds/commands/strings/ends-with.js +0 -12
  522. package/blz-rds/commands/strings/index-of.js +0 -11
  523. package/blz-rds/commands/strings/is-null-or-empty.js +0 -11
  524. package/blz-rds/commands/strings/is-null-or-white-space.js +0 -11
  525. package/blz-rds/commands/strings/join.js +0 -22
  526. package/blz-rds/commands/strings/last-index-of.js +0 -11
  527. package/blz-rds/commands/strings/length.js +0 -10
  528. package/blz-rds/commands/strings/pad-left.js +0 -20
  529. package/blz-rds/commands/strings/pad-right.js +0 -20
  530. package/blz-rds/commands/strings/replace.js +0 -12
  531. package/blz-rds/commands/strings/starts-with.js +0 -12
  532. package/blz-rds/commands/strings/substring.js +0 -12
  533. package/blz-rds/commands/strings/to-lower.js +0 -10
  534. package/blz-rds/commands/strings/to-upper.js +0 -10
  535. package/blz-rds/commands/strings/trim-end.js +0 -10
  536. package/blz-rds/commands/strings/trim-start.js +0 -10
  537. package/blz-rds/commands/strings/trim.js +0 -10
  538. package/blz-rds/index.js +0 -744
  539. package/blz-rds-mysql/base.js +0 -857
  540. package/blz-rds-mysql/connection-manager.js +0 -129
  541. package/blz-rds-mysql/execute-bulk-insert.js +0 -35
  542. package/blz-rds-mysql/execute-bulk-merge.js +0 -45
  543. package/blz-rds-mysql/execute-non-query.js +0 -34
  544. package/blz-rds-mysql/execute-query.js +0 -50
  545. package/blz-rds-mysql/index.js +0 -41
  546. package/blz-rds-mysql/stored-procedure.js +0 -207
  547. package/blz-rds-mysqlx/base.js +0 -846
  548. package/blz-rds-mysqlx/connection-manager.js +0 -141
  549. package/blz-rds-mysqlx/execute-bulk-insert.js +0 -35
  550. package/blz-rds-mysqlx/execute-bulk-merge.js +0 -45
  551. package/blz-rds-mysqlx/execute-non-query.js +0 -29
  552. package/blz-rds-mysqlx/execute-query.js +0 -39
  553. package/blz-rds-mysqlx/index.js +0 -41
  554. package/blz-rds-mysqlx/stored-procedure.js +0 -179
  555. package/blz-rds-oracle/index.js +0 -539
  556. package/blz-rds-postgres/base.js +0 -861
  557. package/blz-rds-postgres/connection-manager.js +0 -225
  558. package/blz-rds-postgres/execute-bulk-insert.js +0 -81
  559. package/blz-rds-postgres/execute-bulk-merge.js +0 -93
  560. package/blz-rds-postgres/execute-non-query.js +0 -23
  561. package/blz-rds-postgres/execute-query.js +0 -37
  562. package/blz-rds-postgres/index.js +0 -41
  563. package/blz-rds-postgres/result-set.js +0 -51
  564. package/blz-rds-postgres/stored-procedure.js +0 -116
  565. package/blz-redis/index.js +0 -217
  566. package/blz-redis/lib/redisCache.js +0 -265
  567. package/blz-regex/index.js +0 -25
  568. package/blz-security/.eslintrc.js +0 -15
  569. package/blz-security/__test__/AuthorizationKpn.yaml +0 -1149
  570. package/blz-security/__test__/FinancingSetting.yaml +0 -177
  571. package/blz-security/__test__/KpnConfigPortal.yaml +0 -330
  572. package/blz-security/__test__/OrderManagement.yaml +0 -5190
  573. package/blz-security/__test__/Security.yaml +0 -128
  574. package/blz-security/__test__/autorization.test.js +0 -105
  575. package/blz-security/__test__/autorizationKpn.test.js +0 -42
  576. package/blz-security/__test__/orderManagement.test.js +0 -26
  577. package/blz-security/__test__/secureUrl.test.js +0 -79
  578. package/blz-security/__test__/solveMergeRule.test.js +0 -109
  579. package/blz-security/__test__/sqlInjectionGuard.test.js +0 -203
  580. package/blz-security/__test__/xssGuard.test.js +0 -204
  581. package/blz-security/authorizationService.js +0 -537
  582. package/blz-security/config/global.js +0 -8
  583. package/blz-security/config/welcome +0 -8
  584. package/blz-security/doc/README.md +0 -75
  585. package/blz-security/filescanner/index.js +0 -46
  586. package/blz-security/helpers/consts.js +0 -229
  587. package/blz-security/helpers/utils.js +0 -267
  588. package/blz-security/implementations/cache.js +0 -90
  589. package/blz-security/implementations/oidc.js +0 -404
  590. package/blz-security/implementations/pkceCacheStore.js +0 -23
  591. package/blz-security/implementations/saml.js +0 -10
  592. package/blz-security/implementations/uma.js +0 -63
  593. package/blz-security/implementations/webAuthn.js +0 -9
  594. package/blz-security/implementations/wstg.js +0 -72
  595. package/blz-security/index.js +0 -77
  596. package/blz-security/lab/index.js +0 -43
  597. package/blz-security/middleware/HapiServerAzureAd.js +0 -681
  598. package/blz-security/middleware/HapiServerKeycloak.js +0 -876
  599. package/blz-security/middleware/HapiServerSimToken.js +0 -286
  600. package/blz-security/middleware/hapi.js +0 -555
  601. package/blz-security/middleware/hapiServer.js +0 -1008
  602. package/blz-security/navigationMemoryRepository.js +0 -15
  603. package/blz-security/navigationMongoDbRepository.js +0 -73
  604. package/blz-security/secureUrlService.js +0 -47
  605. package/blz-security/securityService.js +0 -413
  606. package/blz-security/sqlInjectionGuard.js +0 -162
  607. package/blz-security/templates/forbidden.html +0 -0
  608. package/blz-security/templates/session-iframe-azure-ad.html +0 -7
  609. package/blz-security/templates/session-iframe.html +0 -73
  610. package/blz-security/templates/unauthorized.html +0 -1
  611. package/blz-security/xssGuard.js +0 -87
  612. package/blz-strings/index.js +0 -167
  613. package/blz-uuid/index.js +0 -7
  614. package/blz-yaml/index.js +0 -19
  615. package/index.js +0 -84
  616. package/process-managers/index.js +0 -422
  617. /package/{blz-rds-mysql → dist/blz-rds-mysql}/syntaxis.json +0 -0
  618. /package/{blz-rds-mysqlx → dist/blz-rds-mysqlx}/syntaxis.json +0 -0
  619. /package/{blz-rds-oracle → dist/blz-rds-oracle}/syntaxis.json +0 -0
  620. /package/{blz-rds-postgres → dist/blz-rds-postgres}/syntaxis.json +0 -0
  621. /package/{blz-security → dist/blz-security}/lab/ConfigurationAdmin.agent.json +0 -0
  622. /package/{blz-security → dist/blz-security}/lab/frontend.json +0 -0
  623. /package/{blz-security → dist/blz-security}/lab/result.json +0 -0
  624. /package/{blz-security → dist/blz-security}/lab/resultOnWeb.json +0 -0
  625. /package/{blz-security → dist/blz-security}/lab/rules.json +0 -0
  626. /package/{blz-security → dist/blz-security}/lab/securityRules.json +0 -0
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env node
2
+ export = AuthorizationService;
3
+ declare class AuthorizationService {
4
+ constructor(utils: any, logger: any);
5
+ utils: any;
6
+ logger: any;
7
+ config: {
8
+ roles: any[];
9
+ permissions: any[];
10
+ };
11
+ WIDGET_SEPARATOR: string;
12
+ WIDGET_SEPARATOR_REPLACE: RegExp;
13
+ extendConfig(config: any): void;
14
+ extendPermission(config: any, permission: any): void;
15
+ extendRole(config: any, role: any): void;
16
+ importSecurityConfig(config: any): {
17
+ roles: any[];
18
+ permissions: any[];
19
+ };
20
+ getFrontendSecurityRules(roles: any, domains: any): any[];
21
+ getSecurityRules(roles: any, side: any, domains: any): any[];
22
+ getPermissions(): any[];
23
+ authorized(path: any, action: any, roles: any, domains: any): any;
24
+ checkAuthorize(path: any, action: any, roles: any, domains: any): any;
25
+ _getSecurityRulesByRole(roleId: any, side: any, domains: any): any;
26
+ _solveRulesByRole(config: any): void;
27
+ _solveMergeRulesByRole(config: any): void;
28
+ _solveRoleId(config: any): void;
29
+ _getRoles(roles: any): any;
30
+ _getBackendSecurityRules(roles: any, action: any, domains: any): any;
31
+ _solveMergeRule(rules: any, rule: any): any;
32
+ _cleanPath(fullUrl: any): any;
33
+ _cretaeExpression(route: any): any;
34
+ _replaceDynamicURLParts(route: any): {
35
+ regexp: any;
36
+ };
37
+ _findMatchedRoutes(url: any, routes?: any[]): any[];
38
+ _checkApi(path: any, action: any, roles: any, domains: any): boolean;
39
+ _checkPath(path: any, roles: any, domains: any): boolean;
40
+ _checkWidget(path: any, securityOption: any, roles: any, domains: any): any;
41
+ _validateAndNormalizeConfig(config: any): void;
42
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ module.exports=class{constructor(e,s){this.utils=e,this.logger=s,this.config={roles:[],permissions:[]},this.WIDGET_SEPARATOR="|",this.WIDGET_SEPARATOR_REPLACE=new RegExp(this.WIDGET_SEPARATOR+".*$")}extendConfig(e){for(const s of e.permissions)s.extends&&!s._completed&&this.extendPermission(e,s);for(const s of e.roles)s.extends&&!s._completed&&this.extendRole(e,s);for(const s of e.permissions)delete s._completed;for(const s of e.roles)delete s._completed}extendPermission(e,s){for(const t of s.extends){const n=e.permissions.find(e=>e.name===t);if(!n)throw new Error(`Permission ${s.name} extends ${t} but not exists`);if(n.extends&&n.extends.includes(n.name))throw new Error(`Permission ${s.name} extends ${n.name} but it is a circular reference`);n.extends&&!n._completed&&this.extendPermission(e,n);for(const e of n.rules){s.rules.find(s=>s.path===e.path&&s.actions===e.actions)||s.rules.push(e)}}s._completed=!0}extendRole(e,s){for(const t of s.extends){const n=e.roles.find(e=>e.name===t);if(!n)throw new Error(`Role ${s.name} extends ${t} but not exists`);if(n.extends&&n.extends.includes(n.name))throw new Error(`Rome ${s.name} extends ${n.name} but it is a circular reference`);n.extends&&!n._completed&&this.extendRole(e,n);for(const e of n.permissions)s.permissions.includes(e)||s.permissions.push(e)}s._completed=!0}importSecurityConfig(e){this._solveRoleId(e),this._validateAndNormalizeConfig(e),this.extendConfig(e),this._solveRulesByRole(e),this._solveMergeRulesByRole(e),this.config=e;let s=process.env.blz_defaultUserRole;return s&&(this.config.defaultUserRole=s),this.config}getFrontendSecurityRules(e,s){const t=this._getRoles(e),n=[];for(const e of t){const t=this._getSecurityRulesByRole(e,"frontend",s);for(const e of t){const s=n.find(s=>s.path===e.path&&s.actions===e.actions);s?!s.enable&&e.enable&&(s.enable=e.enable):n.push(e)}}const i=[];for(const e of n)if(e.actions&&""!==e.actions.trim()){const s=e.actions.split(",");for(const t of s)i.push({path:e.path.trim()+"|"+t.trim(),enable:e.enable})}for(const e of n)if(!e.actions||""===e.actions.trim()){const s=i.some(s=>s.path.split("|")[0]===e.path&&s.enable),t=i.find(s=>s.path===e.path&&(!s.actions||""===s.actions.trim()));t?t&&!t.enable&&s&&(t.enable=!0):i.push({path:e.path.trim(),enable:s||e.enable})}const o=new Map;i.forEach(e=>{if(o.has(e.path)){!o.get(e.path).enable&&e.enable&&o.set(e.path,e)}else o.set(e.path,e)});return Array.from(o.values())}getSecurityRules(e,s,t){const n=[];for(const i of e){const e=this._getSecurityRulesByRole(i,s,t);for(const s of e)n.map(e=>e.path).includes(s.path)||n.push(s)}return n}getPermissions(){return this.config&&this.config.permissions&&0!==this.config.permissions.length?this.config.permissions.filter(e=>e.visible||null===e.visible||void 0===e.visible).map(e=>e.name).sort():[]}authorized(e,s,t,n){return this.config.defaultUserRole&&t.push(this.config.defaultUserRole),e.startsWith("/api")?this._checkApi(e,s,t,n):s&&""!==s.trim()?this._checkWidget(e,s,t,n):this._checkPath(e,t,n)}checkAuthorize(e,s,t,n){const i=this.authorized(e,s,t,n);return null==i||i}_getSecurityRulesByRole(e,s,t){const n=this.config.roles.find(s=>s.externalId===e);if(!n||!n.rules)return[];const i=n.rules[s];return i?t&&0!==t.length?i.filter(e=>t.includes(e.domain)):i:[]}_solveRulesByRole(e){for(const s of e.roles){s.rules={backend:[],frontend:[]};for(const t of s.permissions){const n=e.permissions.find(e=>e.name===t);if(n)for(const e of n.rules){const t=n.domain||"default";if(e.path.startsWith("/api")){s.rules.backend.find(s=>s.path===e.path&&s.actions===e.actions&&s.enable===e.enable&&s.domain===t)||(e.domain=t,s.rules.backend.push(e))}else{s.rules.frontend.find(s=>s.path===e.path&&s.actions===e.actions&&s.enable===e.enable&&s.domain===t)||(e.domain=t,s.rules.frontend.push(e))}}}}}_solveMergeRulesByRole(e){for(const s of e.roles){for(const e of s.rules.frontend)s.rules.frontend=this._solveMergeRule(s.rules.frontend,e);for(const e of s.rules.backend)s.rules.backend=this._solveMergeRule(s.rules.backend,e)}}_solveRoleId(e){for(const s of e.roles)s.externalId||(s.externalId=s.name)}_getRoles(e){const s=e&&0!==e.length?e:this.config.roles.filter(e=>e.default).map(e=>e.name),t=this.config.roles.filter(e=>e.applyToAll);if(t&&t.length>0)for(const e of t)s.includes(e.name)||s.push(e.name);return s}_getBackendSecurityRules(e,s,t){let n=[];const i=this._getRoles(e);for(const e of i){const i=this._getSecurityRulesByRole(e,"backend",t).filter(e=>e.actions.includes("*")||e.actions.includes(s));for(const e of i)n=this._solveMergeRule(n,e)}return n.sort((e,s)=>e.path>s.path?1:-1)}_solveMergeRule(e,s){let t=JSON.parse(JSON.stringify(e));const n=t.filter(e=>e.path===s.path);if(0==n.length)t.push(s);else{if(n.some(e=>e.actions.includes("*")&&e.enable))return t;if(s.actions.includes("*")&&s.enable)t=t.filter(e=>e.path!==s.path),t.push(s);else if(s.actions.includes("*")&&!s.enable)t=t.filter(e=>!(e.path===s.path&&e.enable===s.enable)),t.push(s);else{if(!s.enable&&n.some(e=>e.actions.includes("*")&&!e.enable))return t;for(const e of s.actions.split(",")){const n=t.filter(e=>e.path===s.path);if(!n.some(t=>(t.actions.includes("*")||t.actions.includes(e))&&(t.enable||t.enable===s.enable)))if(n.some(t=>t.actions.includes(e)&&!t.enable&&s.enable)){const i=n.find(s=>s.actions.includes(e)&&!s.enable),o=i.actions.split(",").filter(s=>s!==e);0===o.length?t=t.filter(t=>!(t.path===s.path&&t.actions===e&&!t.enable)):i.actions=o.join(",");const r=n.find(e=>e.enable===s.enable);r?r.actions=r.actions+","+e:t.push({path:s.path,actions:e,enable:s.enable})}else if(n.some(t=>!t.actions.includes(e)&&t.enable===s.enable)){const t=n.find(e=>e.enable===s.enable);t.actions=t.actions+","+e}else{const i=n.find(e=>e.enable===s.enable);i?i.actions=i.actions+","+e:t.push({path:s.path,actions:e,enable:s.enable})}}}}return t}_cleanPath(e){const s=e.indexOf("?");return-1!==s?e.substring(0,s):e}_cretaeExpression(e){if(this.utils.isRegExp(e))return e;if(e.endsWith("/**")){const s=e.replace(/\|.*$/gm,"").replace(/\/\*\*$/,"");return new RegExp(`^${s}(/.*)?$`)}return e.replace(/\|.*$/gm,"").replace(/\/+$/,"").replace(/^\/+/,"^/")}_replaceDynamicURLParts(e){let s=null;return s=this.utils.isRegExp(e)?e:new RegExp(e.replace(/\*\*/gm,".*").replace(/\*/gm,function(e,s,t){return"."===t[s-1]?"*":"[^/]*"})+"$",""),{regexp:s}}_findMatchedRoutes(e,s=[]){const t=e.replace(/^\/+/,"/");return s.map(e=>{const s=this._cretaeExpression(e.path),{regexp:n}=this._replaceDynamicURLParts(s);return!!n.test(t)&&e}).filter(e=>e)}_checkApi(e,s,t,n){const i=this._cleanPath(e),o=s.toUpperCase(),r=this._getBackendSecurityRules(t,o,n),l=this._findMatchedRoutes(i,r),a=this.utils.chain(l).filter(e=>e.actions.includes("*")||e.actions.includes(o)).value(),c=a.some(e=>e.enable),f=a.some(e=>!e.enable);return!(!c&&(c||f))||(f?(this.logger.error(`can't access to ${s} ${e}`),!1):null)}_checkPath(e,s,t){const n=this.getFrontendSecurityRules(s,t),i=this.utils.chain(this._findMatchedRoutes(e,n)).value(),o=i.some(e=>e.enable),r=i.some(e=>!e.enable);return!(!o&&(o||r))||!r&&null}_checkWidget(e,s,t,n){const i=s.toUpperCase(),o=this.getFrontendSecurityRules(t,n),r=this.utils.chain(this._findMatchedRoutes(e,o)).filter(({path:e})=>e.includes(this.WIDGET_SEPARATOR)).filter(({path:e})=>{const s=e.substring(e.indexOf(this.WIDGET_SEPARATOR)+1).replace(/\*\*/gm,".*");return new RegExp(`^${s}$`,"gm").test(i)}).value();if(r.find(s=>s.path===e+"|**"&&s.enable))return!0;const l=r.find(s=>s.path===e+"|"+i);if(l)return l.enable;const a=this.utils.chain(r).reverse().first().value();return a?a.enable:null}_validateAndNormalizeConfig(e){if(!e)throw new Error("config is undefined");if(void 0===e.roles||null===e.roles||0===e.roles.length)throw new Error("config.roles is undefined");if(void 0===e.permissions||null===e.permissions||0===e.permissions.length)throw new Error("config.permissions is undefined");for(const s of e.permissions){if(!s.name)throw new Error("Permission has not name");s.rules||(s.rules=[]),s.visible||(s.visible=!0);for(const e of s.rules)if(void 0!==e.enable&&null!==e.enable||(e.enable=!0),void 0===e.actions||null===e.actions?e.actions=e.path.startsWith("/api")?"*":"":e.actions=e.actions.toUpperCase(),!e.path)throw new Error(`Rule in permission ${s.name} has not path`)}for(const s of e.roles)s.permissions||(s.permissions=[])}};
@@ -0,0 +1 @@
1
+ module.exports={startupBoxOptions:{padding:1,margin:1,borderStyle:"round",borderColor:"yellow"}};
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Scans a readable stream for viruses using ClamAV over TCP.
3
+ *
4
+ * @param {ReadableStream} stream - A Node.js readable stream to scan.
5
+ * @param {Object} [options]
6
+ * @param {number} [options.port=3310] - TCP port where clamd is listening.
7
+ * @param {string} [options.host='127.0.0.1'] - Clamd host.
8
+ * @param {number} [options.timeout=60000] - Timeout in milliseconds.
9
+ * @returns {Promise<{ clean: boolean, name: string }>} - Scan result.
10
+ */
11
+ export function scanStream(stream: ReadableStream, options?: {
12
+ port?: number;
13
+ host?: string;
14
+ timeout?: number;
15
+ }): Promise<{
16
+ clean: boolean;
17
+ name: string;
18
+ }>;
19
+ /**
20
+ * Checks if a file extension is allowed.
21
+ * @param {string} filename - Name of the file to check.
22
+ * @returns {boolean}
23
+ */
24
+ export function fileExtensionAllowed(filename: string): boolean;
@@ -0,0 +1 @@
1
+ const clamav=require("clamav.js"),path=require("path");async function scanStream(e,n={}){const t=n.port||3310,a=n.host||"127.0.0.1",o=n.timeout||6e4,r=clamav.createScanner(t,a,o);return new Promise((n,t)=>{r.scan(e,(e,a,o)=>{if(e)return t(e);n({clean:!o,name:a})})})}function fileExtensionAllowed(e){const n=path.extname(e).toLowerCase(),t=process.env.blz_fileScannerAllowedExtension;return!t||t.split(",").includes(n)}module.exports={scanStream:scanStream,fileExtensionAllowed:fileExtensionAllowed};
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @see https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
3
+ * @description Document listing OP endpoint URLs.
4
+ */
5
+ export const METADATA: {
6
+ name: string;
7
+ description: string;
8
+ type: string;
9
+ }[];
10
+ /**
11
+ * @see https://openid.net/specs/openid-connect-core-1_0.html
12
+ * @description OpenID Connect Core
13
+ * @version 1.0
14
+ * @param OP OpenId Provider
15
+ * @param RP Relying Party (Client)
16
+ */
17
+ /**
18
+ * @see https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig
19
+ * @description OP configuration document.
20
+ *
21
+ */
22
+ export const OIDC_DISCOVERY: "/.well-known/openid-configuration";
23
+ /**
24
+ * @description Encrypt with AES the word "BLAZEDPATH" with the same secret key in md5 and the output to be base64.
25
+ * @argument md5 E6F712AA790EE519C2E39177576CD0F0
26
+ * @argument output base64
27
+ */
28
+ export const SIGNATURE: "LSL/e9tVTTK5VovRt9qQgg==";
@@ -0,0 +1 @@
1
+ const OIDC_DISCOVERY="/.well-known/openid-configuration",SIGNATURE="LSL/e9tVTTK5VovRt9qQgg==",METADATA=[{name:"issuer",description:"URL using the https scheme with no query or fragment component that the OP asserts as its Issuer Identifier.",type:"REQUIRED"},{name:"authorization_endpoint",description:"URL of the OP OAuth 2.0 Authorization Endpoint.",type:"REQUIRED"},{name:"token_endpoint",description:"URL of the OP OAuth 2.0 Token Endpoint.",type:"REQUIRED"},{name:"userinfo_endpoint",description:"URL of the OP UserInfo Endpoint.",type:"RECOMMENDED"},{name:"jwks_uri",description:"URL of the OP JSON Web Key Set [JWK] document.",type:"REQUIRED"},{name:"registration_endpoint",description:"URL of the OP Dynamic Client Registration Endpoint.",type:"RECOMMENDED"},{name:"scopes_supported",description:"JSON array containing a list of the OAuth 2.0 [RFC6749] scope values that this server supports.",type:"RECOMMENDED"},{name:"response_types_supported",description:"JSON array containing a list of the OAuth 2.0 response_type values that this OP supports.",type:"REQUIRED"},{name:"response_modes_supported",description:"JSON array containing a list of the OAuth 2.0 response_mode values that this OP supports",type:"OPTIONAL"},{name:"grant_types_supported",description:"JSON array containing a list of the OAuth 2.0 Grant Type values that this OP supports.",type:"OPTIONAL"},{name:"acr_values_supported",description:"JSON array containing a list of the Authentication Context Class References that this OP supports.",type:"OPTIONAL"},{name:"subject_types_supported",description:"JSON array containing a list of the Subject Identifier types that this OP supports.",type:"REQUIRED"},{name:"id_token_signing_alg_values_supported",description:"JSON array containing a list of the JWS signing algorithms supported by the OP for the ID Token to encode the Claims in a JWT.",type:"REQUIRED"},{name:"id_token_encryption_alg_values_supported",description:"JSON array containing a list of the JWE encryption algorithms supported by the OP for the ID Token to encode the Claims in a JWT.",type:"OPTIONAL"},{name:"id_token_encryption_enc_values_supported",description:"JSON array containing a list of the JWE encryption algorithms supported by the OP for the ID Token to encode the Claims in a JWT.",type:"OPTIONAL"},{name:"userinfo_signing_alg_values_supported",description:"JSON array containing a list of the JWS [JWS] signing algorithms [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT.",type:"OPTIONAL"},{name:"userinfo_encryption_alg_values_supported",description:"JSON array containing a list of the JWE [JWE] encryption algorithms [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT ",type:"OPTIONAL"},{name:"userinfo_encryption_enc_values_supported",description:"JSON array containing a list of the JWE encryption algorithms [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT.",type:"OPTIONAL"},{name:"request_object_signing_alg_values_supported",description:"JSON array containing a list of the JWS signing algorithms supported by the OP for Request Objects.",type:"OPTIONAL"},{name:"request_object_encryption_alg_values_supported",description:"JSON array containing a list of the JWE encryption algorithms supported by the OP for Request Objects.",type:"OPTIONAL"},{name:"request_object_encryption_enc_values_supported",description:"JSON array containing a list of the JWE encryption algorithms supported by the OP for Request Objects",type:"OPTIONAL"},{name:"token_endpoint_auth_methods_supported",description:"JSON array containing a list of Client Authentication methods supported by this Token Endpoint.",type:"OPTIONAL"},{name:"token_endpoint_auth_signing_alg_values_supported",description:"JSON array containing a list of the JWS signing algorithms supported by the Token Endpoint for the signature on the JWT.",type:"OPTIONAL"},{name:"display_values_supported",description:"JSON array containing a list of the display parameter values that the OP supports",type:"OPTIONAL"},{name:"claim_types_supported",description:"JSON array containing a list of the Claim Types that the OP supports.",type:"OPTIONAL"},{name:"claims_supported",description:"JSON array containing a list of the Claim Names of the Claims that the OP may be able to supply values for.",type:"RECOMMENDED"},{name:"service_documentation",description:"URL of a page containing human-readable information that developers might want or need to know when using the OP.",type:"OPTIONAL"},{name:"claims_locales_supported",description:"Languages and scripts supported for values in Claims being returned.",type:"OPTIONAL"},{name:"ui_locales_supported",description:"Languages and scripts supported for the user interface.",type:"OPTIONAL"},{name:"claims_parameter_supported",description:"Boolean value specifying whether the OP supports use of the claims parameter.",type:"OPTIONAL"},{name:"request_parameter_supported",description:"Boolean value specifying whether the OP supports use of the request parameter.",type:"OPTIONAL"},{name:"request_uri_parameter_supported",description:"Boolean value specifying whether the OP supports use of the request_uri parameter.",type:"OPTIONAL"},{name:"require_request_uri_registration",description:"Boolean value specifying whether the OP requires any request_uri values used to be pre-registered using the request_uris registration parameter.",type:"OPTIONAL"},{name:"op_policy_uri",description:"URL that the OP provides to the person registering the Client to read about the OP requirements on how the Relying Party can use the data provided by the OP.",type:"OPTIONAL"},{name:"op_tos_uri",description:"URL that the OP provides to the person registering the Client to read about OP terms of service",type:"OPTIONAL"},{name:"check_session_iframe",description:"URL of an OP iframe that supports cross-origin communications for session state information with the RP Client",type:"OPTIONAL"},{name:"end_session_endpoint",description:"OAuth logout URI that the client can use to initiate logout on the server.",type:"OPTIONAL"},{name:"backchannel_logout_supported",description:"Boolean value specifying whether the OP supports back-channel logout.",type:"OPTIONAL"},{name:"backchannel_logout_session_supported",description:"Boolean value specifying whether the OP can pass a sid (session ID) Claim in the Logout Token to identify the RP session with the OP.",type:"OPTIONAL"}];module.exports={METADATA:METADATA,OIDC_DISCOVERY:OIDC_DISCOVERY,SIGNATURE:SIGNATURE};
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Handling exceptions
3
+ * @param {string} message
4
+ * @param {string} name
5
+ * @param {integer} code
6
+ */
7
+ export class Exception {
8
+ constructor(message: any, name: any, code: any);
9
+ message: any;
10
+ name: any;
11
+ code: any;
12
+ }
13
+ /**
14
+ * @name filePathList
15
+ * @api private
16
+ * @description Get list of files with path and folder name recursively.
17
+ * @param {String} path Absolute path of the folder to be analyzed.
18
+ * @param {String} folderName Name of the folder to compare recursively to get the files.
19
+ * @param {[]} listFiles List of files to be added after the recursive search criteria are met.
20
+ * @returns
21
+ */
22
+ export function filePathList(path: string, folderName: string, listFiles?: []): [];
23
+ export function getCookieName(cookieName?: string): string;
24
+ /**
25
+ * @name getFullUrl
26
+ * @api private
27
+ * @description Get full URL
28
+ * @param {*} request
29
+ * @returns
30
+ */
31
+ export function getFullUrl(request: any): string;
32
+ /**
33
+ * @name getHost
34
+ * @api private
35
+ * @description Get host URL
36
+ * @param {*} request
37
+ * @returns
38
+ */
39
+ export function getHost(request: any): any;
40
+ export function getMappingValues(data: any, mappings: any): {};
41
+ /**
42
+ * @name getPathname
43
+ * @api private
44
+ * @description Get pathname URL
45
+ * @param {*} request
46
+ * @returns
47
+ */
48
+ export function getPathname(request: any): any;
49
+ /**
50
+ * @name getProtocol
51
+ * @api private
52
+ * @description Get protocol URL
53
+ * @param {*} request
54
+ * @returns
55
+ */
56
+ export function getProtocol(request: any): any;
57
+ export function getRefreshTokenTolerance(defaultValue?: number): any;
58
+ /**
59
+ * @name Template
60
+ * @description Function to get the template through the key and context data.
61
+ * @api private
62
+ * @param {String} key
63
+ * @param {*} data Context data
64
+ * @returns {String} Template with html structure.
65
+ */
66
+ export function getTemplate(key: string, data: any): string;
67
+ export function getTokenTolerance(defaultValue?: number): any;
68
+ /**
69
+ * @name log
70
+ * @api private
71
+ * @Description Event logging function
72
+ * @param {*} Object with unstructured properties.
73
+ */
74
+ export function log({ inBox, color, message, withDateTime }: any): void;
75
+ /**
76
+ * Event tracing
77
+ * @param {string} logLevel INFO, ERROR or WARN
78
+ * @param {string} message Log message
79
+ */
80
+ export function trace(logLevel: string, message: string): void;
81
+ export function errorResponse(h: any, err: any, defaultCode?: number): any;
82
+ export function isBase64(str: any): boolean;
@@ -0,0 +1 @@
1
+ const Fs=require("fs"),Handlebars=require("handlebars"),Path=require("path"),jsonpath=require("jsonpath"),BlzConfig=require("../../blz-config/index"),hasTracing=process.env.TRACING||!1,getTemplate=(e,t)=>{let r=Path.join(Path.dirname(__dirname),"templates",`${e}.html`);if(!Fs.existsSync(r))throw new Exception(`The template doesn't exist with the key ${e}`,"TemplateError",404);return r=Fs.readFileSync(r,"utf-8"),Handlebars.compile(r)(t)};function log({inBox:e,color:t,message:r,withDateTime:o=!1}){r=`${o?`[${(new Date).toLocaleString()}]`:""} ${r}`,console.log(r)}const filePathList=(e,t,r=[])=>{if(Fs.existsSync(e))if(Fs.lstatSync(e).isDirectory()){const o=Fs.readdirSync(e).filter(t=>Fs.statSync(Path.join(e,t)).isDirectory());if(o&&o.length>0)for(const n in o){const s=o[n];if(s===t){Fs.readdirSync(Path.join(e,s)).filter(t=>Fs.statSync(Path.join(e,s,t)).isFile()).map(t=>r.push(Path.join(e,s,t)))}filePathList(Path.join(e,s),t,r)}}else r.push(e);return r},getFullUrl=e=>`${getProtocol(e)}://${getHost(e)}${getPathname(e)}`,getHost=e=>e.info.host,getPathname=e=>{const{pathname:t}=e.url;return t},getProtocol=e=>e.server.info.protocol,trace=(e,t)=>{if(process.env.TRACING||hasTracing){let r=null;switch(e){case"ERROR":r="red";break;case"WARN":r="yellow";break;default:r="green"}"object"==typeof t?Object.entries(t).map(e=>(e&&e[0]&&e[1]&&log({message:`${e[0]}: ${e[1]}`,withDateTime:!0,color:r}),e)):log({message:t,withDateTime:!0,color:r})}},getMappingValues=(e,t)=>{const r={};for(const o in t){const n=t[o];try{let t=jsonpath.query(e,n.path);if(void 0!==n.pathIndex&&(t=t[n.pathIndex]),n.regex){t=new RegExp(n.regex).exec(t),void 0!==n.regexGroup&&(t=t[n.regexGroup])}if(n.split&&(t=t.split(n.split)),n.replaceRules){const e=[];for(const r in t){const o=t[r],s=n.replaceRules.find(e=>e.oldValue===o);s&&e.push(s.newValue)}t=e}r[n.itemKey]=t}catch(e){throw new Error(`User info mapping ${JSON.stringify(n)} error: ${e}`)}}return r};class Exception{constructor(e,t,r){this.message=e,this.name=t,this.code=r}}const getTokenTolerance=function(e=30){return parseNumber(process.env.TOKEN_TOLERANCE,e)},getRefreshTokenTolerance=function(e=0){return parseNumber(process.env.REFRESH_TOKEN_TOLERANCE,e)},parseNumber=function(e,t){return e&&!isNaN(e)?Number(e):t},getCookieName=function(e=""){const t=BlzConfig.getConfig()||{};return(t.authServer&&t.authServer.sessionCookiesPrefix||"")+e},errorResponse=function(e,t,r=500){const{code:o,name:n,message:s}=t;return"production"===process.env.NODE_ENV?(trace("ERROR",{name:n,message:s}),e.response({name:n}).code(parseInt(o)||r).takeover()):e.response({name:n,message:s}).code(parseInt(o)||r).takeover()},isBase64=function(e){if("string"!=typeof e)return!1;if(!/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(e))return!1;try{const t=Buffer.from(e,"base64").toString("utf8");return Buffer.from(t,"utf8").toString("base64")===e.replace(/=*$/,"")}catch(e){return!1}};module.exports={Exception:Exception,filePathList:filePathList,getCookieName:getCookieName,getFullUrl:getFullUrl,getHost:getHost,getMappingValues:getMappingValues,getPathname:getPathname,getProtocol:getProtocol,getRefreshTokenTolerance:getRefreshTokenTolerance,getTemplate:getTemplate,getTokenTolerance:getTokenTolerance,log:log,trace:trace,errorResponse:errorResponse,isBase64:isBase64};
@@ -0,0 +1,58 @@
1
+ export class RedisCache {
2
+ constructor(cnx: any);
3
+ _cache: any;
4
+ /**
5
+ * @name set
6
+ * @api private
7
+ * @description Maximum age in ms.
8
+ * @param {*} key key to be cached.
9
+ * @param {*} value value to be cached.
10
+ * @param {*} maxAge Maximum age in ms.
11
+ */
12
+ set(key: any, value: any, maxAge: any): Promise<void>;
13
+ /**
14
+ * @name get
15
+ * @api private
16
+ * @description Get the value that was cached.
17
+ * @param {*} key
18
+ * @returns
19
+ */
20
+ get(key: any): Promise<any>;
21
+ /**
22
+ * @name del
23
+ * @api private
24
+ * @description It was removing the value that was in the cache.
25
+ * @param {*} key
26
+ * @returns
27
+ */
28
+ del(key: any): Promise<void>;
29
+ }
30
+ export class LruCache {
31
+ _cache: LRUCache<{}, {}, unknown>;
32
+ /**
33
+ * @name set
34
+ * @api private
35
+ * @description Maximum age in ms.
36
+ * @param {*} key key to be cached.
37
+ * @param {*} value value to be cached.
38
+ * @param {*} maxAge Maximum age in ms.
39
+ */
40
+ set(key: any, value: any, maxAge: any): Promise<void>;
41
+ /**
42
+ * @name get
43
+ * @api private
44
+ * @description Get the value that was cached.
45
+ * @param {*} key
46
+ * @returns
47
+ */
48
+ get(key: any): Promise<{}>;
49
+ /**
50
+ * @name del
51
+ * @api private
52
+ * @description It was removing the value that was in the cache.
53
+ * @param {*} key
54
+ * @returns
55
+ */
56
+ del(key: any): Promise<void>;
57
+ }
58
+ import { LRUCache } from "lru-cache";
@@ -0,0 +1 @@
1
+ const{LRUCache:LRUCache}=require("lru-cache"),IoRedis=require("ioredis");class LruCache{constructor(){this._cache=new LRUCache({max:500,maxSize:5e3,ttl:108e5,sizeCalculation:(e,c)=>1})}async set(e,c,a){this._cache.set(e,c,a)}async get(e){return this._cache.get(e)}async del(e){this._cache.delete(e)}}class RedisCache{constructor(e){this._cache=new IoRedis(e)}async set(e,c,a){const s=JSON.stringify(c);await this._cache.set(e,s,"EX",a/1e3)}async get(e){const c=await this._cache.get(e);return c?JSON.parse(c):c}async del(e){await this._cache.del(e)}}module.exports={RedisCache:RedisCache,LruCache:LruCache};
@@ -0,0 +1,100 @@
1
+ export class Oidc {
2
+ constructor(cache: any, config: any);
3
+ cache: any;
4
+ config: any;
5
+ oidcMetadataKey(): any;
6
+ oidcMetadata(): Promise<any>;
7
+ /**
8
+ * @name configuration
9
+ * @api public
10
+ * @param {String} uri OP configuration information
11
+ */
12
+ configuration(context: any): Promise<Iss>;
13
+ expiresIn(tokensSet: any): number;
14
+ expired(tokensSet: any): boolean;
15
+ /**
16
+ * @name tokenSet
17
+ * @generator PKCE is mandatory in OAuth 2.1.
18
+ * @see https://tools.ietf.org/html/draft-ietf-oauth-v2-1-02
19
+ * @see https://tools.ietf.org/html/rfc7636
20
+ */
21
+ tokenSet(): Promise<{
22
+ /**
23
+ * @name tokens
24
+ * @api public
25
+ * @param sessionState String that represents the End-User's login state at the OP.
26
+ * @returns Tokens set
27
+ */
28
+ tokens: (sessionState: any) => Promise<any>;
29
+ /**
30
+ * @name generate
31
+ * @api public
32
+ * @param {code, scope, redirect_uri}
33
+ * @description Generate token with authorization flow with PKCE.
34
+ */
35
+ generate: ({ code, scope, redirectUri, sid }: any) => Promise<any>;
36
+ /**
37
+ * @name userInfo
38
+ * @api public
39
+ * @param {String} sessionState
40
+ * @returns userInfo Returns previously consented user profile information to the RP.
41
+ * @see https://openid.net/specs/openid-connect-core-1_0.html#UserInfo
42
+ */
43
+ userInfo: (sessionState: string) => Promise<{
44
+ user_name: any;
45
+ }>;
46
+ }>;
47
+ getUseTokenType(): any;
48
+ getUseToken(sessionState: any): Promise<any>;
49
+ /**
50
+ * @name pkceCode
51
+ * @api public
52
+ * @description The properties "code_challenge" and "code_verifier" are adopted from the OAuth 2.0 extension
53
+ * known as "Proof-Key for Code Exchange", or PKCE [RFC7636].
54
+ * @see https://datatracker.ietf.org/doc/html/rfc7636
55
+ * @param {String} code
56
+ * @returns
57
+ */
58
+ pkceCode(code: string): Promise<any>;
59
+ /**
60
+ * @name authorizationUrl
61
+ * @api public
62
+ * @param {scope, redirect_uri}
63
+ * @returns authorization endpoint with PKCE
64
+ */
65
+ authorizationUrl({ scope, redirectUri, pkceCode }: any): Promise<any>;
66
+ /**
67
+ * @name endSessionUrl
68
+ * @api public
69
+ * @param {session_state, redirect_uri}
70
+ * @returns end session url
71
+ */
72
+ endSessionUrl({ sessionState, redirectUri }: session_state): Promise<any>;
73
+ /**
74
+ * @name client
75
+ * @api public
76
+ * @description set client ID and secret in metadata object
77
+ * @param {clientId, clientSecret}
78
+ */
79
+ client({ clientId, clientSecret }: any): Promise<void>;
80
+ jwt(): {
81
+ sign: ({ payload, secret, algorithm }: {
82
+ payload: any;
83
+ secret: any;
84
+ algorithm?: string;
85
+ }) => never;
86
+ };
87
+ }
88
+ /**
89
+ * @name Iss
90
+ * @api public
91
+ * @description Entity that issues a set of claims
92
+ */
93
+ declare class Iss {
94
+ /**
95
+ * @constructor
96
+ * @param {Object} metadata
97
+ */
98
+ constructor(metadata: any);
99
+ }
100
+ export {};
@@ -0,0 +1 @@
1
+ const CryptoJS=require("crypto-js"),{Issuer:Issuer,generators:generators,custom:custom}=require("openid-client"),Jsonwebtoken=require("jsonwebtoken"),JwksClient=require("jwks-rsa"),Uuid=require("uuid"),{METADATA:METADATA}=require("../helpers/consts"),{trace:trace,Exception:Exception,getTokenTolerance:getTokenTolerance}=require("../helpers/utils");let jwks,clientOidc;custom.setHttpOptionsDefaults({timeout:process.env.TIMEOUT_HTTP||3e4});class Iss{constructor(e){e.id_token_signing_alg_values_supported||(e.id_token_signing_alg_values_supported=["RS256"]),e.response_types_supported||(e.response_types_supported=["code","none","id_token","token","id_token token","code id_token","code token","code id_token token"]),e.subject_types_supported||(e.subject_types_supported=["public"]);const t=METADATA.filter(({type:e})=>"REQUIRED"===e),i=Object.entries(e);for(let e=0;e<i.length;e++)t.forEach((r,n)=>{i[e][0]===r.name&&i[e][1]&&t.splice(n,1)});if(t.length>0)throw new Exception(JSON.stringify(t),"ClaimError",403);jwks=JwksClient({cache:!0,rateLimit:!0,cacheMaxAge:6e4,jwksRequestsPerMinute:15,jwksUri:e.jwks_uri});const r=e.Client?e:new Issuer(e),n={client_id:e.clientId,response_type:"code"};e.clientSecret&&(n.client_secret=e.clientSecret),clientOidc=new r.Client(n)}}class Oidc{constructor(e,t){if(this.cache=e,this.config=t,this.config.authServer){if(this.config.authServer.PrivateKey&&this.config.authServer.PublicKey)this.config.authServer.PrivateKey=this.config.authServer.PrivateKey.replace(/\\n/g,"\n"),this.config.authServer.PublicKey=this.config.authServer.PublicKey.replace(/\\n/g,"\n");else{if(!process.env.PRIVATE_KEY||!process.env.PUBLIC_KEY)throw new Exception("Private and public keys are mandatory","AttributeError",403);this.config.authServer.PrivateKey=process.env.PRIVATE_KEY,this.config.authServer.PublicKey=process.env.PUBLIC_KEY}this.config.authServer.Signature||(process.env.OIDC_SIGNATURE?this.config.authServer.Signature=process.env.OIDC_SIGNATURE:this.config.authServer.Signature="--")}}oidcMetadataKey(){return this.config.authServer.sessionCookiesDomain||"oidcMetadata"}async oidcMetadata(){return await this.cache.get(this.oidcMetadataKey())}async configuration(e){let t=await this.cache.get(this.oidcMetadataKey());if("string"==typeof e&&!e.match(/(https?:\/\/.*):?(\d*)\/?(.*)/gi))throw new Exception("Wrong OpenId Provider configuration URI entered","AttributeError",403);return t&&t.issuer||(e.issuer?t={...t||{},...e}:(t=t||{},t.openid_configuration=e,t={...t,...await Issuer.discover(e)}),await this.cache.set(this.oidcMetadataKey(),t,864e5)),new Iss(t)}expiresIn(e){return Math.round((1e3*e.expires_at-Date.now())/1e3)}expired(e){return this.expiresIn(e)<getTokenTolerance()}async tokenSet(){return{tokens:async e=>{if(!e)throw new Exception("Session state is mandatory","AttributeError",404);const t=await this.cache.get(e);if(!t||!t.access_token)throw new Exception(`No token found fo session_state: ${e}`,"TokenError",403);if(this.expired(t)&&t.refresh_token){const[i,r]=await clientOidc.refresh(t.refresh_token,{exchangeBody:{client_id:clientOidc.clientId}}).then(e=>[null,e]).catch(e=>[e,null]);if(i||!r.access_token)throw await this.cache.del(e),new Exception(`Can not refresh token for session_state: ${e}`,"ExpirationError",403);return trace("INFO",`Refresh token for session_state: ${e}`),await this.cache.set(e,r,1e3*(r.refresh_expires_in||r.expires_in)),r}if(t.refresh_expires_in<getTokenTolerance())throw await this.cache.del(e),new Exception(`Token expired, remove session_state: ${e}`,"ExpirationError",403);return trace("INFO",`Get token of session_state: ${e}`),t},generate:async({code:e,scope:t="openid",redirectUri:i="",sid:r})=>{if(!r)throw new Exception("SID is mandatory","");const{codeVerifier:n}=await this.pkceCode(r),o=await clientOidc.callback(i,{grant_type:"authorization_code",code:e,scope:t,client_id:clientOidc.client_id,client_secret:clientOidc.client_secret||" ",redirect_uri:i},{code_verifier:n}).then(e=>e).catch(e=>e);if(o&&o.access_token){if(o.session_state=o.session_state||Uuid.v4(),o.refresh_expires_in<=getTokenTolerance(0))throw new Exception(`Invalid refresh token expiration ${o.refresh_expires_in}`,"ExpirationError",403);const e=1e3*(o.refresh_expires_in||o.expires_in);return e>0?(await this.cache.set(o.session_state,o,e),o):(trace("ERROR",`Expiration time: ${e}`),null)}if(o.message&&o.exp<=o.now)throw new Exception(o.message,"ExpirationError",403);throw new Exception(o.error_description||o.error||o.message,"TokenError",403)},userInfo:async e=>{const t=await this.cache.get(e);let i={};if(!t||!t.access_token)throw new Exception("Access token is mandatory","TokenError",401);if(i=clientOidc.issuer&&clientOidc.issuer.userinfo_endpoint?await clientOidc.userinfo(t.access_token).then(e=>e).catch(e=>e):Jsonwebtoken.decode(t.id_token),!i.user_name&&i.name&&(i.user_name=i.name),i.error)throw new Exception(i.error,"UserInfoError",403);return i}}}getUseTokenType(){return this.config.authServer.useTokenType||"access_token"}async getUseToken(e){const t=await this.tokenSet();if(t&&e){const i=await t.tokens(e);if(i)return i[this.getUseTokenType()]}return null}async pkceCode(e){if(!e){const e=generators.codeVerifier(),t={jti:Uuid.v4(),iat:Math.floor(Date.now()/1e3),typ:"Serialized-ID",state_checker:CryptoJS.AES.encrypt(JSON.stringify({codeVerifier:e,codeChallenge:generators.codeChallenge(e)}),this.config.authServer.Signature).toString()};return Jsonwebtoken.sign(t,this.config.authServer.PrivateKey,{expiresIn:"1m",algorithm:"RS256"})}try{const t=await Jsonwebtoken.verify(e,this.config.authServer.PublicKey,{algorithms:["RS256"]}),{state_checker:i}=t;return JSON.parse(CryptoJS.AES.decrypt(i,this.config.authServer.Signature).toString(CryptoJS.enc.Utf8))}catch(e){throw new Exception(e,"pkceCode",403)}}async authorizationUrl({scope:e="openid",redirectUri:t="",pkceCode:i}){const{codeChallenge:r}=await this.pkceCode(i),n=await this.cache.get(this.oidcMetadataKey());if(!clientOidc&&!n)throw new Exception("Unable to fetch configuration from identity provider","ConfigurationError",404);return await this.configuration(n.openid_configuration),clientOidc.authorizationUrl({scope:e,code_challenge:r,code_challenge_method:"S256",redirect_uri:t.replace(/\/(logout|invalid-session).*/gm,"/")})}async endSessionUrl({sessionState:e,redirectUri:t}){if(t=t.replace(/logout|invalid-session/gim,""),trace("INFO",`Logout session_state: ${e}`),e){const i=await this.cache.get(e);if(await this.cache.del(e),i)return clientOidc.endSessionUrl({id_token_hint:i.id_token,post_logout_redirect_uri:t,state:e})}if(!clientOidc)throw new Exception("Unable to fetch configuration from identity provider","ConfigurationError",404);return clientOidc.endSessionUrl({post_logout_redirect_uri:t})}async client({clientId:e,clientSecret:t}){if(!e)throw new Exception("Client ID is wrong","AttributeError",404);const i=await this.cache.get(this.oidcMetadataKey());t?await this.cache.set(this.oidcMetadataKey(),{...i||{},clientId:e,clientSecret:t},864e5):await this.cache.set(this.oidcMetadataKey(),{...i||{},clientId:e},864e5)}jwt(){return{sign:({payload:e,secret:t,algorithm:i="RS256"})=>Jsonwebtoken.sign(e,t,{algorithm:i})}}}module.exports={Oidc:Oidc};
@@ -0,0 +1,2 @@
1
+ export function saveVerifier(stateId: any, codeVerifier: any): void;
2
+ export function getVerifier(stateId: any): any;
@@ -0,0 +1 @@
1
+ const pkceStore=new Map;function saveVerifier(e,r){pkceStore.set(e,r),setTimeout(()=>{pkceStore.delete(e)},3e5)}function getVerifier(e){const r=pkceStore.get(e);return r&&pkceStore.delete(e),r}module.exports={saveVerifier:saveVerifier,getVerifier:getVerifier};
@@ -0,0 +1 @@
1
+ const SAML_todo="WIP - SAML implementation coming soon!";
@@ -0,0 +1,31 @@
1
+ export = Uma;
2
+ /**
3
+ * @param RPT Requesting Party Token
4
+ * @param PAT Protection API Token
5
+ * @param AS Authorization Server
6
+ * @param RS Resource Server
7
+ */
8
+ /**
9
+ * @name Uma
10
+ * @api public
11
+ * @description Managing access to protected resources.
12
+ */
13
+ declare class Uma {
14
+ /**
15
+ * @name permission
16
+ * @api public
17
+ * @description
18
+ * @returns
19
+ */
20
+ static permission(): Promise<{
21
+ /**
22
+ * @name ticket
23
+ * @api public
24
+ * @description Through grant type xx:uma-ticket, clients can send authorization
25
+ * requests and get an RPT with all permissions granted by auth server.
26
+ * @param {token_url, token, audience}
27
+ * @returns token
28
+ */
29
+ ticket: ({ tokenUrl, token, audience }: token_url) => Promise<any>;
30
+ }>;
31
+ }
@@ -0,0 +1 @@
1
+ const Got=require("got");class Uma{static async permission(){return{ticket:async({tokenUrl:t,token:e,audience:a})=>{const r=new URLSearchParams([["grant_type","urn:ietf:params:oauth:grant-type:uma-ticket"],["audience",a]]);let{body:n}=await Got.post(t,{headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/x-www-form-urlencoded"},body:r.toString()});return"string"==typeof n&&(n=JSON.parse(n)),n}}}}module.exports=Uma;
@@ -0,0 +1 @@
1
+ const WebAuthn_todo="WIP - WebAuthn implementation coming soon!";
@@ -0,0 +1 @@
1
+ const Fs=require("fs"),{filePathList:filePathList}=require("../helpers/utils"),{log:log}=require("../helpers/utils"),informationGathering=e=>({reviewLeakage:()=>{const t=filePathList(e,"public");for(let e=0;e<t.length;e+=1){const s=t[e];if([/^(.*\.((html?|(tp|ft)l|s?[c|a]ss|less|m?js(on)?)))$/gim].some(e=>e.test(s))){let e=/( )*<!--((.*)|[^<]*|[^!]*|[^-]*|[^>]*)-->\n*/gm,t=Fs.readFileSync(s,"utf8");[/^(.*\.((s?[c|a]ss|less)?))$/gim].some(e=>e.test(s))?e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//gm:[/^(.*\.((m?js(on)?)))$/gim].some(e=>e.test(s))&&(t.split(/\r?\n/).some(e=>e.length>250&&e.match(/class|Blz|function/gm))||(t=t.replace(/(?<=(("([^"\\]|\\.|\\\n)*"|'([^'\\]|\\.|\\\n)*'|`([^`\\]|\\.|\\\n)*`)|\/.*\/(g|m|i|y|u|s)+|\{|\}|\*\/|\)|;|\]|^|\r*))\/{2}[^'"].*/gm,"")),e=/(?<=[^'|"|`])\/\*[^*"^]*\*+(?:[^/*][^*]*\*+)*\//gm),t=t.replace(e,""),Fs.writeFileSync(s,t,"utf8"),log({message:`Applying rules to the file ${s}`,withDateTime:!0})}}return t}}),testing=e=>({fix:()=>{const t="string"==typeof e?e:e[Object.keys(e).find(t=>"string"==typeof e[t])];t&&[/^.*[/ | \\].*$/gm].some(e=>e.test(t))&&informationGathering(t).reviewLeakage()}});module.exports={testing:testing};
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ declare const _exports: SecurityService;
3
+ export = _exports;
4
+ import SecurityService = require("./securityService");
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ const AuthorizationService=require("./authorizationService"),SecurityService=require("./securityService"),SqlInjectionGuard=require("./sqlInjectionGuard"),XssGuard=require("./xssGuard"),SecureUrlService=require("./secureUrlService"),_=require("underscore"),logger=require("pino")();let navigationRepository=null;const createNavigationRepository=function(){if(process.env.NAVIGATION_INFO_MONGODB_URL&&process.env.NAVIGATION_INFO_MONGODB_DB&&process.env.NAVIGATION_INFO_MONGODB_COLLECTION){return new(require("./navigationMongoDbRepository"))(process.env.NAVIGATION_INFO_MONGODB_URL,process.env.NAVIGATION_INFO_MONGODB_DB,process.env.NAVIGATION_INFO_MONGODB_COLLECTION,process.env.NAVIGATION_INFO_MONGODB_CERTIFICATE)}logger.warn("MongoDB configuration is missing. Using in-memory repository.");return new(require("./navigationMemoryRepository"))};try{async function gracefulShutdown(){try{navigationRepository&&navigationRepository.close&&(await navigationRepository.close(),logger.info("Navigation repository connection closed."))}catch(e){logger.error("Error during shutdown:",e)}finally{process.exit(0)}}navigationRepository=createNavigationRepository(),process.on("SIGINT",gracefulShutdown)}catch(e){logger.error("Error during startup:",e),process.exit(1)}module.exports=new SecurityService(new AuthorizationService(_,logger),new SqlInjectionGuard(logger),new XssGuard(logger),navigationRepository,new SecureUrlService(logger),logger);
@@ -0,0 +1 @@
1
+ const{h3lp:h3lp}=require("h3lp"),Yaml=require("js-yaml"),path=require("path"),AuthorizationService=require("../authorizationService"),_=require("underscore"),logger=require("pino")();async function getAuthorizationService(e){const i=new AuthorizationService(_,logger),n=await h3lp.fs.read(path.join(__dirname,e)),r=(await Yaml.loadAll(n))[0];return i.importSecurityConfig(r),i}(async()=>{let e=null;const i=await getAuthorizationService("../__test__/AuthorizationKpn.yaml");e=i.checkAuthorize("/debtor/102592","dunning_CreateFinancingAgreement",["Collections.ViewOnly"],["agent"]),console.log(e),e=i.checkAuthorize("/debtor/102592","dunning_CreateFinancingAgreement",["Configuration.Admin"],["agent"]),console.log(e)})();
@@ -0,0 +1,26 @@
1
+ export class HapiServerAzureAd {
2
+ constructor(openIdConnect: any, cookiesName: any, cache: any);
3
+ openIdConnect: any;
4
+ COOKIE_NAMES: any;
5
+ activateTraceApiMethod: boolean;
6
+ queryStringLimit: any;
7
+ securityLoginTokenExpToleranceSeconds: number;
8
+ authServerConfig: any;
9
+ authServerFullLoginUrl: any;
10
+ cache: any;
11
+ clientJwk: jwksClient.JwksClient;
12
+ publicKeyFetch: (artifacts: any) => Promise<any>;
13
+ connect(_securityService: any, hapiServer: any, config: any): Promise<void>;
14
+ getRedirectUri(request: any, redirectPath: any): string;
15
+ getFullUrl(request: any): string;
16
+ getBaseUrl(request: any): string;
17
+ authenticate(h: any, scope: any): Promise<any>;
18
+ configurePlugins(server: any): Promise<void>;
19
+ decodeJwtToken(token: any): Promise<hapiJwt.HapiJwt.Artifacts<hapiJwt.HapiJwt.JwtRefs>>;
20
+ tokenAboutToExpire(token: any, minutesBeforeExpiration?: number): Promise<boolean>;
21
+ isRefreshTokenExpired(refreshToken: any): Promise<boolean>;
22
+ startupJwksClient(): Promise<void>;
23
+ startupPublickKeyFetch(): Promise<void>;
24
+ }
25
+ import jwksClient = require("jwks-rsa");
26
+ import hapiJwt = require("@hapi/jwt");
@@ -0,0 +1 @@
1
+ const Uma=require("../implementations/uma.js"),Jsonwebtoken=require("jsonwebtoken"),{Exception:Exception,getFullUrl:getFullUrl,getHost:getHost,getProtocol:getProtocol,getPathname:getPathname,getTemplate:getTemplate,getTokenTolerance:getTokenTolerance,trace:trace,errorResponse:errorResponse}=require("../helpers/utils.js"),hapiYar=require("@hapi/yar"),hapiJwt=require("@hapi/jwt"),hapiCookie=require("@hapi/cookie"),jwksClient=require("jwks-rsa"),{ConfidentialClientApplication:ConfidentialClientApplication}=require("@azure/msal-node"),crypto=require("crypto"),{saveVerifier:saveVerifier,getVerifier:getVerifier}=require("../implementations/pkceCacheStore.js");let securityService=null;class HapiServerAzureAd{constructor(e,t,r){this.openIdConnect=e,this.COOKIE_NAMES=t,this.activateTraceApiMethod=!1,this.queryStringLimit=null,this.securityLoginTokenExpToleranceSeconds=18e3,this.authServerConfig=null,this.authServerFullLoginUrl=null,this.cache=r,this.clientJwk=null,this.publicKeyFetch=null}async connect(e,t,r){this.authServerConfig=r,securityService=e;const{authServer:o,activateTraceApiMethod:a}=r;a&&(this.activateTraceApiMethod=a);const i={clearInvalid:!0,encoding:"base64",isSecure:!0,isHttpOnly:!0,isSameSite:"Lax",path:"/",strictHeader:!0};try{o.sessionCookiesDomain&&(i.domain=o.sessionCookiesDomain),i.isHttpOnly=o.isHttpOnlyForSessionState??!1,t.state(this.COOKIE_NAMES.SESSION_STATE,i),o.scope&&o.scope.split(" ").some(e=>"openid"===e)||(o.scope=`openid ${o.scope||""}`),o.tokenEndpoint&&!o.tokenEndpoint.match(/https.*/)&&(t.states.cookies[this.COOKIE_NAMES.SID].isSecure=!1,t.states.cookies[this.COOKIE_NAMES.SESSION_STATE].isSecure=!1)}catch(e){console.error("ERROR",`Exception ${e.message}`,e),trace("ERROR",e.stack)}this.configurePlugins(t),t.ext("onPreAuth",async(e,t)=>{let r=e.yar.get("jwtToken");if(r){if(await n.tokenAboutToExpire(r.token,10)){const o=await n.authServerConfig.authServer.msalClient.acquireTokenSilent({account:r.account,scopes:n.authServerConfig.authServer.scope.split(" ")??["user.read"]}),a={};if(!o||!o.idToken)return e.yar.set("userRelog",!0),a.account=r.account,e.yar.set("jwtToken",a),await e.yar.commit(t),delete e.headers.authorization,t.continue;a.tokenType="Bearer",a.token=o.idToken,a.tokenSubType="id_token",a.account=o.account,e.yar.set("jwtToken",a),await e.yar.commit(t)}switch(r.tokenType){case"Bearer":case"bearer":e.headers.authorization=`Bearer ${r.token}`}}return t.continue}),t.ext("onPreResponse",async(e,t)=>{const r=e.response;if(r.isBoom&&401===r.output.statusCode&&!e.path.startsWith("/auth/callback")){function o(e){return e.toString("base64").replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function a(){const e=o(crypto.randomBytes(32));return{verifier:e,challenge:o(crypto.createHash("sha256").update(e).digest())}}const i=a(),s=crypto.randomBytes(16).toString("hex");saveVerifier(s,i.verifier);const c=await this.authServerConfig.authServer.msalClient.getAuthCodeUrl({redirectUri:n.getRedirectUri(e,"auth/callback"),scopes:n.authServerConfig.authServer.scope.split(" ")??["user.read"],codeChallenge:i.challenge,codeChallengeMethod:"S256",responseMode:"form_post",state:s});let u=e.yar.get("userRelog");return e.yar.set("pkv",i.verifier),e.yar.commit(t),u&&"/"!==e.path?t.redirect("/"):t.redirect(c)}return t.continue}),t.route({method:"GET",path:"/auth/callback",options:{auth:!1},handler:async(e,t)=>{const r=e.query.code;if(!r)return t.response("Authorization code missing").code(400);try{let o=e.yar.get("pkv");const a=await n.authServerConfig.authServer.msalClient.acquireTokenByCode({code:r,redirectUri:n.getRedirectUri(e,"auth/callback"),scopes:n.authServerConfig.authServer.scope.split(" ")??["user.read"],codeVerifier:o});let i={tokenType:"Bearer",token:a.idToken,tokenSubType:"id_token",account:a.account};e.yar.set("jwtToken",i);let s=e.yar.get("originalUrlPathName")??"/";const c=e.query.session_state;switch(t.state(this.COOKIE_NAMES.SESSION_STATE,c),e.yar.clear("userRelog"),i.tokenType){case"Bearer":case"bearer":return e.yar.set("jwtToken",i),await e.yar.commit(t),t.redirect(s)}return await e.yar.commit(t),t.redirect("/")}catch(r){return e.yar.reset(),await e.yar.commit(t),delete e.headers.authorization,console.error("Failed to obtain jwt token: ",r.response?.data??r.message),t.response("Failed to authenticate").code(500).takeover()}}}),t.route({method:"POST",path:"/auth/callback",options:{auth:!1},handler:async(e,t)=>{const r=e.payload.code;if(!r)return t.response("Authorization code missing").code(400);try{const o=e.payload.state,a=getVerifier(o),i=await n.authServerConfig.authServer.msalClient.acquireTokenByCode({code:r,redirectUri:n.getRedirectUri(e,"auth/callback"),scopes:n.authServerConfig.authServer.scope.split(" ")??["user.read"],codeVerifier:a,responseMode:"form_post"});let s={tokenType:"Bearer",token:i.idToken,tokenSubType:"id_token",account:i.account};e.yar.set("jwtToken",s);let c=e.yar.get("originalUrlPathName")??"/";const u=e.payload.session_state;if(!u)return t.response("Session State missing").code(400);switch(t.state(this.COOKIE_NAMES.SESSION_STATE,u),e.yar.clear("userRelog"),s.tokenType){case"Bearer":case"bearer":return e.yar.set("jwtToken",s),await e.yar.commit(t),t.redirect(c)}return await e.yar.commit(t),t.redirect("/")}catch(r){return e.yar.reset(),await e.yar.commit(t),delete e.headers.authorization,console.error("Failed to obtain jwt token: ",r.response?.data??r.message),t.response("Failed to authenticate").code(500).takeover()}}});const n=this;t.route({method:"GET",path:"/get-authorization",handler:async(e,t)=>{try{const{session_state:r}=e.state;if(!r)throw new Exception("Azure get-authorization: Session cookie doesn't exist.","CookiesError",404);const a=await n.openIdConnect.tokenSet(),i=await a.tokens(r),s=await Uma.permission(),c=await s.ticket({tokenUrl:o.tokenEndpoint||o.tokenUrl,token:i.access_token,audience:o.clientId}),u=Jsonwebtoken.decode(c.access_token);return t.response(JSON.stringify(u.authorization)).takeover()}catch(e){return errorResponse(t,e,401)}}}),t.route({method:"GET",path:"/get-security-rules",handler:async(e,t)=>{try{const r=await securityService.getFrontendSecurityRules(e);return t.response(JSON.stringify(r)).takeover()}catch(e){return errorResponse(t,e,401)}}}),t.route({method:"GET",path:"/get-permissions",handler:async(e,t)=>{try{const e=await securityService.getPermissions();return t.response(JSON.stringify(e)).takeover()}catch(e){return errorResponse(t,e,401)}}}),t.route({method:"GET",path:"/check-authorize",handler:async(e,t)=>{try{const r=e.query.path,o=e.query.action,a=e.query.roles,i=e.query.domains;let n,s;n=Array.isArray(a)?a:"string"==typeof a?a.split(",").map(e=>e.trim()):[],s=Array.isArray(i)?i:"string"==typeof i?i.split(",").map(e=>e.trim()):[];const c=await securityService.checkAuthorize(r,o,n,s);return t.response(JSON.stringify(c)).takeover()}catch(e){return errorResponse(t,e,401)}}}),t.route({method:"GET",path:"/get-user-info",handler:async(e,t)=>{try{const r=await securityService.getUserInfo(e);return t.response(JSON.stringify(r)).takeover()}catch(e){return errorResponse(t,e,500)}}}),t.route({path:"/logout",method:"GET",options:{auth:!1},handler:async(e,t)=>{try{const r=encodeURIComponent(n.getBaseUrl(e)),o=`https://login.microsoftonline.com/${n.authServerConfig.authServer.tenantId}/oauth2/v2.0/logout?post_logout_redirect_uri=${r}`;return e.yar.clear("jwtToken"),e.yar.clear("userRelog"),t.redirect(o)}catch(e){return console.error("Error logging out:",e),t.response("Logout failed").code(500)}}}),t.route({path:"/check-session-iframe.html",method:"GET",options:{auth:!1},handler:async(e,t)=>{try{let r=getTemplate("session-iframe-azure-ad",{checkSessionUrl:n.getBaseUrl(e)+"check-session"});return t.response(r).header("Content-Type","text/html")}catch(e){return errorResponse(t,e,500)}}}),t.route({path:"/check-session",options:{auth:!1},method:"GET",handler:async(e,t)=>{let r=e.yar.get("jwtToken"),o={expired:!1};if(r&&(o.expired=await n.tokenAboutToExpire(r.token,.5),o.expired)){let t={redirectUri:n.getRedirectUri(e,"auth/callback"),scopes:n.authServerConfig.authServer.scope.split(" ")};o.redirectUrl=await n.authServerConfig.authServer.msalClient.getAuthCodeUrl(t),e.yar.clear("jwtToken"),e.yar.clear("userRelog")}return t.response(o)}})}getRedirectUri(e,t){const r=this.authServerConfig.url??this.getBaseUrl(e),o=t??this.getPathname(e);let a=new URL(o,r);return"localhost"!==a.hostname&&"127.0.0.1"!==a.hostname&&(a.protocol="https:"),a.toString()}getFullUrl(e){return`${getProtocol(e)}://${getHost(e)}${getPathname(e)}`}getBaseUrl(e){return`${getProtocol(e)}://${getHost(e)}/`}async authenticate(e,t){const{request:r}=e,o=await this.openIdConnect.pkceCode(),a=getFullUrl(r);let i=await this.openIdConnect.oidcMetadata();if(i&&i.openid_configuration||(i=await this.configuration(this.authServerConfig.authServer)),a.match(new RegExp(/^(https?:\/{2}.*):?(\d*)/.source+getHost(r)+/\/?$/.source))){const a=await this.openIdConnect.authorizationUrl({scope:t,redirectUri:this.getRedirectUri(r),pkceCode:o});return trace("INFO",`Authenticate redirecting to ${a}`),e.response().state(this.COOKIE_NAMES.SID,o).redirect(a).takeover()}if("/logout"===getPathname(r))return e.continue;{const t=await this.openIdConnect.tokenSet(),{state:o}=r;if(t&&o&&o[this.COOKIE_NAMES.SESSION_STATE]){const r=await t.tokens(o[this.COOKIE_NAMES.SESSION_STATE]);if(!r||r.refresh_expires_in<=getTokenTolerance(0))throw new Exception("Error when getting token","ExpirationError",403);return e.continue}return e.response().code(401).takeover()}}async configurePlugins(e){const t=process.env.blz_hapiYarPassword||"your-super-secure-yar-atleast-32-bytes-password";await e.register({plugin:hapiYar,options:{name:"yar_state",cookieOptions:{password:t,isSecure:!0,isHttpOnly:!0,isSameSite:"Lax",clearInvalid:!0,ignoreErrors:!0},storeBlank:!1,maxCookieSize:0}}),await e.register(hapiJwt);let r=!0;this.startupJwksClient(),this.startupPublickKeyFetch(),r=this.publicKeyFetch;const o=this.authServerConfig.authServer.issuer.match(/login\.microsoftonline\.com\/([^/]+)/)?.[1];this.authServerConfig.authServer.tenantId=o,this.authServerConfig.authServer.msalConfig={auth:{clientId:this.authServerConfig.authServer.clientId,authority:`https://login.microsoftonline.com/${o}`,clientSecret:this.authServerConfig.authServer.clientSecret}};const a=new ConfidentialClientApplication(this.authServerConfig.authServer.msalConfig);this.authServerConfig.authServer.msalClient=a,e.auth.strategy("jwtAuth","jwt",{keys:r,verify:{aud:this.authServerConfig.authServer.clientId,iss:this.authServerConfig.authServer.issuer,exp:!0,sub:!1},validate:!1}),await e.register(hapiCookie);const i=process.env.blz_hapiCookiePassword||"supersecretpasswordmustbeatleast32characterslong";e.auth.strategy("cookieAuth","cookie",{cookie:{name:"sid",password:i,isSecure:!0,isHttpOnly:!0,isSameSite:"Lax"},keepAlive:!0,redirectTo:!1}),e.auth.default({strategies:["jwtAuth","cookieAuth"]})}async decodeJwtToken(e){return hapiJwt.token.decode(e)}async tokenAboutToExpire(e,t=0){if(!e)return!0;return 1e3*hapiJwt.token.decode(e).decoded.payload.exp-Date.now()<=60*t*1e3}async isRefreshTokenExpired(e){try{const t=hapiJwt.token.decode(e),r=Math.floor(Date.now()/1e3);return!(t&&t.decoded&&t.decoded.payload&&t.decoded.payload.exp)||t.decoded.payload.exp<r}catch(e){return console.error("Failed to decode the token: Invalid Refresh token format",e),!0}}async startupJwksClient(){this.clientJwk=jwksClient({jwksUri:this.authServerConfig.authServer.jwksUri,cache:!0,rateLimit:!0,jwksRequestsPerMinute:10})}async startupPublickKeyFetch(){const e=async e=>new Promise((t,r)=>{this.clientJwk.getSigningKey(e,(e,o)=>{if(e)return r(e);const a=o.getPublicKey();t(a)})});this.publicKeyFetch=async t=>{const r=t.decoded.header.kid;return e(r)}}}module.exports={HapiServerAzureAd:HapiServerAzureAd};
@@ -0,0 +1,47 @@
1
+ export class HapiServerKeycloak {
2
+ constructor(openIdConnect: any, cookiesName: any, cache: any);
3
+ openIdConnect: any;
4
+ COOKIE_NAMES: any;
5
+ activateTraceApiMethod: boolean;
6
+ queryStringLimit: any;
7
+ securityLoginTokenExpToleranceSeconds: number;
8
+ authServerConfig: {};
9
+ authServerFullLoginUrl: any;
10
+ cache: any;
11
+ clientOidc: any;
12
+ clientJwk: jwksClient.JwksClient;
13
+ publicKeyFetch: (artifacts: any) => Promise<any>;
14
+ securityService: any;
15
+ securityUrlCookieKey: any;
16
+ generateGuid(): Promise<`${string}-${string}-${string}-${string}-${string}`>;
17
+ connect(_securityService: any, hapiServer: any, config: any): Promise<void>;
18
+ getFullKeycloakLoginUri(request: any, h: any): Promise<string>;
19
+ getRedirectUri(request: any): any;
20
+ getRedirectUriPath(request: any, redirectPath: any): string;
21
+ getFullUrl(request: any): string;
22
+ getBaseUrl(request: any): string;
23
+ authenticate(h: any, scope: any): Promise<any>;
24
+ configurePlugins(server: any): Promise<void>;
25
+ configuration(authServer: any): Promise<any>;
26
+ configuration(context: any): Promise<Iss>;
27
+ endSessionUrl(redirectUri: any, clientOidc: any): Promise<any>;
28
+ oidcMetadataKey(): any;
29
+ refreshToken(refreshToken: any): Promise<any>;
30
+ decodeJwtToken(token: any): Promise<hapiJwt.HapiJwt.Artifacts<hapiJwt.HapiJwt.JwtRefs>>;
31
+ tokenAboutToExpire(token: any, minutesBeforeExpiration?: number): Promise<boolean>;
32
+ isRefreshTokenExpired(refreshToken: any): Promise<boolean>;
33
+ startupJwksClient(): Promise<void>;
34
+ startupPublickKeyFetch(): Promise<void>;
35
+ }
36
+ import jwksClient = require("jwks-rsa");
37
+ declare class Iss {
38
+ /**
39
+ * @constructor
40
+ * @param {Object} metadata
41
+ */
42
+ constructor(metadata: any);
43
+ clientOidc: any;
44
+ #private;
45
+ }
46
+ import hapiJwt = require("@hapi/jwt");
47
+ export {};