@boxyhq/saml-jackson 1.32.0 → 1.33.1-beta.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 (332) hide show
  1. package/dist/controller/api.js +17 -7
  2. package/dist/controller/api.js.map +1 -1
  3. package/dist/controller/connection/oidc.js +17 -7
  4. package/dist/controller/connection/oidc.js.map +1 -1
  5. package/dist/controller/connection/saml.js +17 -7
  6. package/dist/controller/connection/saml.js.map +1 -1
  7. package/dist/controller/logout.js +17 -7
  8. package/dist/controller/logout.js.map +1 -1
  9. package/dist/controller/oauth/oidc-client.d.ts +9 -4
  10. package/dist/controller/oauth/oidc-client.js +80 -11
  11. package/dist/controller/oauth/oidc-client.js.map +1 -1
  12. package/dist/controller/oauth/oidc-issuer.d.ts +2 -0
  13. package/dist/controller/oauth/oidc-issuer.js +25 -0
  14. package/dist/controller/oauth/oidc-issuer.js.map +1 -0
  15. package/dist/controller/oauth.js +97 -46
  16. package/dist/controller/oauth.js.map +1 -1
  17. package/dist/controller/setup-link.js +17 -7
  18. package/dist/controller/setup-link.js.map +1 -1
  19. package/dist/controller/sso-handler.d.ts +10 -2
  20. package/dist/controller/sso-handler.js +34 -12
  21. package/dist/controller/sso-handler.js.map +1 -1
  22. package/dist/controller/utils.d.ts +5 -3
  23. package/dist/controller/utils.js +27 -9
  24. package/dist/controller/utils.js.map +1 -1
  25. package/dist/db/db.js +17 -7
  26. package/dist/db/db.js.map +1 -1
  27. package/dist/db/dynamoDb.js +17 -7
  28. package/dist/db/dynamoDb.js.map +1 -1
  29. package/dist/db/mem.js +17 -7
  30. package/dist/db/mem.js.map +1 -1
  31. package/dist/db/mongo.js +17 -7
  32. package/dist/db/mongo.js.map +1 -1
  33. package/dist/db/redis.js +17 -7
  34. package/dist/db/redis.js.map +1 -1
  35. package/dist/db/sql/sql.js +17 -7
  36. package/dist/db/sql/sql.js.map +1 -1
  37. package/dist/db/store.js +17 -7
  38. package/dist/db/store.js.map +1 -1
  39. package/dist/directory-sync/batch-events/queue.js +17 -7
  40. package/dist/directory-sync/batch-events/queue.js.map +1 -1
  41. package/dist/directory-sync/scim/DirectoryConfig.js +17 -7
  42. package/dist/directory-sync/scim/DirectoryConfig.js.map +1 -1
  43. package/dist/directory-sync/scim/Groups.js +17 -7
  44. package/dist/directory-sync/scim/Groups.js.map +1 -1
  45. package/dist/ee/identity-federation/idp-login.js +20 -14
  46. package/dist/ee/identity-federation/idp-login.js.map +1 -1
  47. package/dist/ee/identity-federation/sso.js +16 -11
  48. package/dist/ee/identity-federation/sso.js.map +1 -1
  49. package/dist/event/axios.d.ts +2 -1
  50. package/dist/index.js +17 -7
  51. package/dist/index.js.map +1 -1
  52. package/dist/loadConnection.js +17 -7
  53. package/dist/loadConnection.js.map +1 -1
  54. package/dist/saml/lib.js +17 -7
  55. package/dist/saml/lib.js.map +1 -1
  56. package/dist/saml/x509.js +17 -7
  57. package/dist/saml/x509.js.map +1 -1
  58. package/dist/src/controller/admin.d.ts +27 -0
  59. package/dist/src/controller/admin.js +60 -0
  60. package/dist/src/controller/admin.js.map +1 -0
  61. package/dist/src/controller/analytics.d.ts +16 -0
  62. package/dist/src/controller/analytics.js +79 -0
  63. package/dist/src/controller/analytics.js.map +1 -0
  64. package/dist/src/controller/api.d.ts +557 -0
  65. package/dist/src/controller/api.js +806 -0
  66. package/dist/src/controller/api.js.map +1 -0
  67. package/dist/src/controller/connection/oidc.d.ts +7 -0
  68. package/dist/src/controller/connection/oidc.js +181 -0
  69. package/dist/src/controller/connection/oidc.js.map +1 -0
  70. package/dist/src/controller/connection/saml.d.ts +7 -0
  71. package/dist/src/controller/connection/saml.js +250 -0
  72. package/dist/src/controller/connection/saml.js.map +1 -0
  73. package/dist/src/controller/error.d.ts +10 -0
  74. package/dist/src/controller/error.js +13 -0
  75. package/dist/src/controller/error.js.map +1 -0
  76. package/dist/src/controller/health-check.d.ts +11 -0
  77. package/dist/src/controller/health-check.js +51 -0
  78. package/dist/src/controller/health-check.js.map +1 -0
  79. package/dist/src/controller/logout.d.ts +18 -0
  80. package/dist/src/controller/logout.js +132 -0
  81. package/dist/src/controller/logout.js.map +1 -0
  82. package/dist/src/controller/oauth/allowed.d.ts +1 -0
  83. package/dist/src/controller/oauth/allowed.js +30 -0
  84. package/dist/src/controller/oauth/allowed.js.map +1 -0
  85. package/dist/src/controller/oauth/code-verifier.d.ts +1 -0
  86. package/dist/src/controller/oauth/code-verifier.js +8 -0
  87. package/dist/src/controller/oauth/code-verifier.js.map +1 -0
  88. package/dist/src/controller/oauth/oidc-client.d.ts +12 -0
  89. package/dist/src/controller/oauth/oidc-client.js +89 -0
  90. package/dist/src/controller/oauth/oidc-client.js.map +1 -0
  91. package/dist/src/controller/oauth/redirect.d.ts +1 -0
  92. package/dist/src/controller/oauth/redirect.js +13 -0
  93. package/dist/src/controller/oauth/redirect.js.map +1 -0
  94. package/dist/src/controller/oauth.d.ts +142 -0
  95. package/dist/src/controller/oauth.js +1112 -0
  96. package/dist/src/controller/oauth.js.map +1 -0
  97. package/dist/src/controller/oidc-discovery.d.ts +22 -0
  98. package/dist/src/controller/oidc-discovery.js +47 -0
  99. package/dist/src/controller/oidc-discovery.js.map +1 -0
  100. package/dist/src/controller/setup-link.d.ts +307 -0
  101. package/dist/src/controller/setup-link.js +462 -0
  102. package/dist/src/controller/setup-link.js.map +1 -0
  103. package/dist/src/controller/sp-config.d.ts +22 -0
  104. package/dist/src/controller/sp-config.js +89 -0
  105. package/dist/src/controller/sp-config.js.map +1 -0
  106. package/dist/src/controller/sso-handler.d.ts +66 -0
  107. package/dist/src/controller/sso-handler.js +306 -0
  108. package/dist/src/controller/sso-handler.js.map +1 -0
  109. package/dist/src/controller/utils.d.ts +84 -0
  110. package/dist/src/controller/utils.js +328 -0
  111. package/dist/src/controller/utils.js.map +1 -0
  112. package/dist/src/cron/lock.d.ts +18 -0
  113. package/dist/src/cron/lock.js +98 -0
  114. package/dist/src/cron/lock.js.map +1 -0
  115. package/dist/src/db/db.d.ts +5 -0
  116. package/dist/src/db/db.js +178 -0
  117. package/dist/src/db/db.js.map +1 -0
  118. package/dist/src/db/defaultDb.d.ts +2 -0
  119. package/dist/src/db/defaultDb.js +18 -0
  120. package/dist/src/db/defaultDb.js.map +1 -0
  121. package/dist/src/db/dynamoDb.d.ts +19 -0
  122. package/dist/src/db/dynamoDb.js +320 -0
  123. package/dist/src/db/dynamoDb.js.map +1 -0
  124. package/dist/src/db/encrypter.d.ts +3 -0
  125. package/dist/src/db/encrypter.js +22 -0
  126. package/dist/src/db/encrypter.js.map +1 -0
  127. package/dist/src/db/mem.d.ts +23 -0
  128. package/dist/src/db/mem.js +186 -0
  129. package/dist/src/db/mem.js.map +1 -0
  130. package/dist/src/db/mongo.d.ts +22 -0
  131. package/dist/src/db/mongo.js +177 -0
  132. package/dist/src/db/mongo.js.map +1 -0
  133. package/dist/src/db/planetscale/entity/JacksonIndex.d.ts +5 -0
  134. package/dist/src/db/planetscale/entity/JacksonIndex.js +32 -0
  135. package/dist/src/db/planetscale/entity/JacksonIndex.js.map +1 -0
  136. package/dist/src/db/planetscale/entity/JacksonStore.d.ts +9 -0
  137. package/dist/src/db/planetscale/entity/JacksonStore.js +63 -0
  138. package/dist/src/db/planetscale/entity/JacksonStore.js.map +1 -0
  139. package/dist/src/db/planetscale/entity/JacksonTTL.d.ts +4 -0
  140. package/dist/src/db/planetscale/entity/JacksonTTL.js +27 -0
  141. package/dist/src/db/planetscale/entity/JacksonTTL.js.map +1 -0
  142. package/dist/src/db/redis.d.ts +18 -0
  143. package/dist/src/db/redis.js +214 -0
  144. package/dist/src/db/redis.js.map +1 -0
  145. package/dist/src/db/sql/entity/JacksonIndex.d.ts +7 -0
  146. package/dist/src/db/sql/entity/JacksonIndex.js +39 -0
  147. package/dist/src/db/sql/entity/JacksonIndex.js.map +1 -0
  148. package/dist/src/db/sql/entity/JacksonStore.d.ts +9 -0
  149. package/dist/src/db/sql/entity/JacksonStore.js +61 -0
  150. package/dist/src/db/sql/entity/JacksonStore.js.map +1 -0
  151. package/dist/src/db/sql/entity/JacksonTTL.d.ts +4 -0
  152. package/dist/src/db/sql/entity/JacksonTTL.js +27 -0
  153. package/dist/src/db/sql/entity/JacksonTTL.js.map +1 -0
  154. package/dist/src/db/sql/mariadb/entity/JacksonIndex.d.ts +7 -0
  155. package/dist/src/db/sql/mariadb/entity/JacksonIndex.js +39 -0
  156. package/dist/src/db/sql/mariadb/entity/JacksonIndex.js.map +1 -0
  157. package/dist/src/db/sql/mariadb/entity/JacksonStore.d.ts +9 -0
  158. package/dist/src/db/sql/mariadb/entity/JacksonStore.js +63 -0
  159. package/dist/src/db/sql/mariadb/entity/JacksonStore.js.map +1 -0
  160. package/dist/src/db/sql/mariadb/entity/JacksonTTL.d.ts +4 -0
  161. package/dist/src/db/sql/mariadb/entity/JacksonTTL.js +27 -0
  162. package/dist/src/db/sql/mariadb/entity/JacksonTTL.js.map +1 -0
  163. package/dist/src/db/sql/mssql/entity/JacksonIndex.d.ts +7 -0
  164. package/dist/src/db/sql/mssql/entity/JacksonIndex.js +39 -0
  165. package/dist/src/db/sql/mssql/entity/JacksonIndex.js.map +1 -0
  166. package/dist/src/db/sql/mssql/entity/JacksonStore.d.ts +9 -0
  167. package/dist/src/db/sql/mssql/entity/JacksonStore.js +61 -0
  168. package/dist/src/db/sql/mssql/entity/JacksonStore.js.map +1 -0
  169. package/dist/src/db/sql/mssql/entity/JacksonTTL.d.ts +4 -0
  170. package/dist/src/db/sql/mssql/entity/JacksonTTL.js +27 -0
  171. package/dist/src/db/sql/mssql/entity/JacksonTTL.js.map +1 -0
  172. package/dist/src/db/sql/mssql.d.ts +1 -0
  173. package/dist/src/db/sql/mssql.js +44 -0
  174. package/dist/src/db/sql/mssql.js.map +1 -0
  175. package/dist/src/db/sql/sql.d.ts +32 -0
  176. package/dist/src/db/sql/sql.js +318 -0
  177. package/dist/src/db/sql/sql.js.map +1 -0
  178. package/dist/src/db/sql/sqlite/entity/JacksonIndex.d.ts +7 -0
  179. package/dist/src/db/sql/sqlite/entity/JacksonIndex.js +39 -0
  180. package/dist/src/db/sql/sqlite/entity/JacksonIndex.js.map +1 -0
  181. package/dist/src/db/sql/sqlite/entity/JacksonStore.d.ts +9 -0
  182. package/dist/src/db/sql/sqlite/entity/JacksonStore.js +61 -0
  183. package/dist/src/db/sql/sqlite/entity/JacksonStore.js.map +1 -0
  184. package/dist/src/db/sql/sqlite/entity/JacksonTTL.d.ts +4 -0
  185. package/dist/src/db/sql/sqlite/entity/JacksonTTL.js +27 -0
  186. package/dist/src/db/sql/sqlite/entity/JacksonTTL.js.map +1 -0
  187. package/dist/src/db/store.d.ts +5 -0
  188. package/dist/src/db/store.js +65 -0
  189. package/dist/src/db/store.js.map +1 -0
  190. package/dist/src/db/utils.d.ts +16 -0
  191. package/dist/src/db/utils.js +28 -0
  192. package/dist/src/db/utils.js.map +1 -0
  193. package/dist/src/directory-sync/batch-events/queue.d.ts +40 -0
  194. package/dist/src/directory-sync/batch-events/queue.js +225 -0
  195. package/dist/src/directory-sync/batch-events/queue.js.map +1 -0
  196. package/dist/src/directory-sync/index.d.ts +27 -0
  197. package/dist/src/directory-sync/index.js +97 -0
  198. package/dist/src/directory-sync/index.js.map +1 -0
  199. package/dist/src/directory-sync/non-scim/google/api.d.ts +36 -0
  200. package/dist/src/directory-sync/non-scim/google/api.js +143 -0
  201. package/dist/src/directory-sync/non-scim/google/api.js.map +1 -0
  202. package/dist/src/directory-sync/non-scim/google/index.d.ts +12 -0
  203. package/dist/src/directory-sync/non-scim/google/index.js +10 -0
  204. package/dist/src/directory-sync/non-scim/google/index.js.map +1 -0
  205. package/dist/src/directory-sync/non-scim/google/oauth.d.ts +27 -0
  206. package/dist/src/directory-sync/non-scim/google/oauth.js +105 -0
  207. package/dist/src/directory-sync/non-scim/google/oauth.js.map +1 -0
  208. package/dist/src/directory-sync/non-scim/index.d.ts +24 -0
  209. package/dist/src/directory-sync/non-scim/index.js +85 -0
  210. package/dist/src/directory-sync/non-scim/index.js.map +1 -0
  211. package/dist/src/directory-sync/non-scim/syncGroupMembers.d.ts +23 -0
  212. package/dist/src/directory-sync/non-scim/syncGroupMembers.js +105 -0
  213. package/dist/src/directory-sync/non-scim/syncGroupMembers.js.map +1 -0
  214. package/dist/src/directory-sync/non-scim/syncGroups.d.ts +24 -0
  215. package/dist/src/directory-sync/non-scim/syncGroups.js +120 -0
  216. package/dist/src/directory-sync/non-scim/syncGroups.js.map +1 -0
  217. package/dist/src/directory-sync/non-scim/syncUsers.d.ts +24 -0
  218. package/dist/src/directory-sync/non-scim/syncUsers.js +120 -0
  219. package/dist/src/directory-sync/non-scim/syncUsers.js.map +1 -0
  220. package/dist/src/directory-sync/non-scim/utils.d.ts +36 -0
  221. package/dist/src/directory-sync/non-scim/utils.js +109 -0
  222. package/dist/src/directory-sync/non-scim/utils.js.map +1 -0
  223. package/dist/src/directory-sync/request.d.ts +14 -0
  224. package/dist/src/directory-sync/request.js +29 -0
  225. package/dist/src/directory-sync/request.js.map +1 -0
  226. package/dist/src/directory-sync/scim/Base.d.ts +12 -0
  227. package/dist/src/directory-sync/scim/Base.js +23 -0
  228. package/dist/src/directory-sync/scim/Base.js.map +1 -0
  229. package/dist/src/directory-sync/scim/DirectoryConfig.d.ts +343 -0
  230. package/dist/src/directory-sync/scim/DirectoryConfig.js +580 -0
  231. package/dist/src/directory-sync/scim/DirectoryConfig.js.map +1 -0
  232. package/dist/src/directory-sync/scim/DirectoryGroups.d.ts +28 -0
  233. package/dist/src/directory-sync/scim/DirectoryGroups.js +252 -0
  234. package/dist/src/directory-sync/scim/DirectoryGroups.js.map +1 -0
  235. package/dist/src/directory-sync/scim/DirectoryUsers.d.ts +25 -0
  236. package/dist/src/directory-sync/scim/DirectoryUsers.js +193 -0
  237. package/dist/src/directory-sync/scim/DirectoryUsers.js.map +1 -0
  238. package/dist/src/directory-sync/scim/Groups.d.ts +166 -0
  239. package/dist/src/directory-sync/scim/Groups.js +348 -0
  240. package/dist/src/directory-sync/scim/Groups.js.map +1 -0
  241. package/dist/src/directory-sync/scim/Users.d.ts +99 -0
  242. package/dist/src/directory-sync/scim/Users.js +215 -0
  243. package/dist/src/directory-sync/scim/Users.js.map +1 -0
  244. package/dist/src/directory-sync/scim/WebhookEventsLogger.d.ts +101 -0
  245. package/dist/src/directory-sync/scim/WebhookEventsLogger.js +165 -0
  246. package/dist/src/directory-sync/scim/WebhookEventsLogger.js.map +1 -0
  247. package/dist/src/directory-sync/scim/transform.d.ts +6 -0
  248. package/dist/src/directory-sync/scim/transform.js +37 -0
  249. package/dist/src/directory-sync/scim/transform.js.map +1 -0
  250. package/dist/src/directory-sync/scim/utils.d.ts +33 -0
  251. package/dist/src/directory-sync/scim/utils.js +129 -0
  252. package/dist/src/directory-sync/scim/utils.js.map +1 -0
  253. package/dist/src/directory-sync/types.d.ts +195 -0
  254. package/dist/src/directory-sync/types.js +10 -0
  255. package/dist/src/directory-sync/types.js.map +1 -0
  256. package/dist/src/directory-sync/utils.d.ts +19 -0
  257. package/dist/src/directory-sync/utils.js +56 -0
  258. package/dist/src/directory-sync/utils.js.map +1 -0
  259. package/dist/src/ee/branding/index.d.ts +17 -0
  260. package/dist/src/ee/branding/index.js +49 -0
  261. package/dist/src/ee/branding/index.js.map +1 -0
  262. package/dist/src/ee/common/checkLicense.d.ts +3 -0
  263. package/dist/src/ee/common/checkLicense.js +23 -0
  264. package/dist/src/ee/common/checkLicense.js.map +1 -0
  265. package/dist/src/ee/identity-federation/app.d.ts +328 -0
  266. package/dist/src/ee/identity-federation/app.js +532 -0
  267. package/dist/src/ee/identity-federation/app.js.map +1 -0
  268. package/dist/src/ee/identity-federation/idp-login.d.ts +18 -0
  269. package/dist/src/ee/identity-federation/idp-login.js +98 -0
  270. package/dist/src/ee/identity-federation/idp-login.js.map +1 -0
  271. package/dist/src/ee/identity-federation/index.d.ts +15 -0
  272. package/dist/src/ee/identity-federation/index.js +43 -0
  273. package/dist/src/ee/identity-federation/index.js.map +1 -0
  274. package/dist/src/ee/identity-federation/sso.d.ts +24 -0
  275. package/dist/src/ee/identity-federation/sso.js +124 -0
  276. package/dist/src/ee/identity-federation/sso.js.map +1 -0
  277. package/dist/src/ee/identity-federation/types.d.ts +38 -0
  278. package/dist/src/ee/identity-federation/types.js +2 -0
  279. package/dist/src/ee/identity-federation/types.js.map +1 -0
  280. package/dist/src/ee/ory/ory.d.ts +18 -0
  281. package/dist/src/ee/ory/ory.js +195 -0
  282. package/dist/src/ee/ory/ory.js.map +1 -0
  283. package/dist/src/ee/product/index.d.ts +14 -0
  284. package/dist/src/ee/product/index.js +45 -0
  285. package/dist/src/ee/product/index.js.map +1 -0
  286. package/dist/src/event/axios.d.ts +2 -0
  287. package/dist/src/event/axios.js +27 -0
  288. package/dist/src/event/axios.js.map +1 -0
  289. package/dist/src/event/index.d.ts +11 -0
  290. package/dist/src/event/index.js +53 -0
  291. package/dist/src/event/index.js.map +1 -0
  292. package/dist/src/event/types.d.ts +21 -0
  293. package/dist/src/event/types.js +2 -0
  294. package/dist/src/event/types.js.map +1 -0
  295. package/dist/src/event/utils.d.ts +4 -0
  296. package/dist/src/event/utils.js +33 -0
  297. package/dist/src/event/utils.js.map +1 -0
  298. package/dist/src/event/webhook.d.ts +3 -0
  299. package/dist/src/event/webhook.js +34 -0
  300. package/dist/src/event/webhook.js.map +1 -0
  301. package/dist/src/index.d.ts +35 -0
  302. package/dist/src/index.js +161 -0
  303. package/dist/src/index.js.map +1 -0
  304. package/dist/src/loadConnection.d.ts +4 -0
  305. package/dist/src/loadConnection.js +38 -0
  306. package/dist/src/loadConnection.js.map +1 -0
  307. package/dist/src/opentelemetry/metrics.d.ts +14 -0
  308. package/dist/src/opentelemetry/metrics.js +64 -0
  309. package/dist/src/opentelemetry/metrics.js.map +1 -0
  310. package/dist/src/saml/claims.d.ts +12 -0
  311. package/dist/src/saml/claims.js +57 -0
  312. package/dist/src/saml/claims.js.map +1 -0
  313. package/dist/src/saml/lib.d.ts +8 -0
  314. package/dist/src/saml/lib.js +29 -0
  315. package/dist/src/saml/lib.js.map +1 -0
  316. package/dist/src/saml/x509.d.ts +9 -0
  317. package/dist/src/saml/x509.js +93 -0
  318. package/dist/src/saml/x509.js.map +1 -0
  319. package/dist/src/sso-traces/index.d.ts +114 -0
  320. package/dist/src/sso-traces/index.js +229 -0
  321. package/dist/src/sso-traces/index.js.map +1 -0
  322. package/dist/src/sso-traces/types.d.ts +44 -0
  323. package/dist/src/sso-traces/types.js +2 -0
  324. package/dist/src/sso-traces/types.js.map +1 -0
  325. package/dist/src/typings.d.ts +540 -0
  326. package/dist/src/typings.js +5 -0
  327. package/dist/src/typings.js.map +1 -0
  328. package/dist/typeorm.d.ts +3 -0
  329. package/dist/typeorm.js +58 -0
  330. package/dist/typeorm.js.map +1 -0
  331. package/dist/typings.d.ts +1 -1
  332. package/package.json +13 -13
@@ -0,0 +1,132 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import crypto from 'crypto';
11
+ import { promisify } from 'util';
12
+ import { deflateRaw } from 'zlib';
13
+ import * as dbutils from '../db/utils';
14
+ import saml from '@boxyhq/saml20';
15
+ import { JacksonError } from './error';
16
+ import * as redirect from './oauth/redirect';
17
+ import { IndexNames } from './utils';
18
+ import { getDefaultCertificate } from '../saml/x509';
19
+ const deflateRawAsync = promisify(deflateRaw);
20
+ const relayStatePrefix = 'boxyhq_jackson_';
21
+ const logoutXPath = "/*[local-name(.)='LogoutRequest']";
22
+ export class LogoutController {
23
+ constructor({ connectionStore, sessionStore, opts }) {
24
+ this.opts = opts;
25
+ this.connectionStore = connectionStore;
26
+ this.sessionStore = sessionStore;
27
+ }
28
+ // Create SLO Request
29
+ createRequest(_a) {
30
+ return __awaiter(this, arguments, void 0, function* ({ nameId, tenant, product, redirectUrl }) {
31
+ let samlConnection = null;
32
+ if (tenant && product) {
33
+ const samlConnections = (yield this.connectionStore.getByIndex({
34
+ name: IndexNames.TenantProduct,
35
+ value: dbutils.keyFromParts(tenant, product),
36
+ })).data;
37
+ if (!samlConnections || samlConnections.length === 0) {
38
+ throw new JacksonError('SAML connection not found.', 403);
39
+ }
40
+ samlConnection = samlConnections[0];
41
+ }
42
+ if (!samlConnection) {
43
+ throw new JacksonError('SAML connection not found.', 403);
44
+ }
45
+ const { idpMetadata: { slo, provider }, } = samlConnection;
46
+ const { privateKey, publicKey } = yield getDefaultCertificate();
47
+ if ('redirectUrl' in slo === false && 'postUrl' in slo === false) {
48
+ throw new JacksonError(`${provider} doesn't support SLO or disabled by IdP.`, 400);
49
+ }
50
+ const { id, xml } = saml.createLogoutRequest({
51
+ nameId,
52
+ providerName: this.opts.samlAudience,
53
+ sloUrl: slo.redirectUrl,
54
+ });
55
+ const sessionId = crypto.randomBytes(16).toString('hex');
56
+ let logoutUrl = null;
57
+ let logoutForm = null;
58
+ const relayState = relayStatePrefix + sessionId;
59
+ const signedXML = yield signXML(xml, privateKey, publicKey);
60
+ yield this.sessionStore.put(sessionId, {
61
+ id,
62
+ redirectUrl,
63
+ });
64
+ // HTTP-Redirect binding
65
+ if ('redirectUrl' in slo) {
66
+ logoutUrl = redirect.success(slo.redirectUrl, {
67
+ SAMLRequest: Buffer.from(yield deflateRawAsync(signedXML)).toString('base64'),
68
+ RelayState: relayState,
69
+ });
70
+ }
71
+ // HTTP-POST binding
72
+ if ('postUrl' in slo) {
73
+ logoutForm = saml.createPostForm(slo.postUrl, [
74
+ {
75
+ name: 'RelayState',
76
+ value: relayState,
77
+ },
78
+ {
79
+ name: 'SAMLRequest',
80
+ value: Buffer.from(signedXML).toString('base64'),
81
+ },
82
+ ]);
83
+ }
84
+ return { logoutUrl, logoutForm };
85
+ });
86
+ }
87
+ // Handle SLO Response
88
+ handleResponse(_a) {
89
+ return __awaiter(this, arguments, void 0, function* ({ SAMLResponse, RelayState }) {
90
+ var _b;
91
+ const rawResponse = Buffer.from(SAMLResponse, 'base64').toString();
92
+ const sessionId = RelayState.replace(relayStatePrefix, '');
93
+ const session = yield this.sessionStore.get(sessionId);
94
+ if (!session) {
95
+ throw new JacksonError('Unable to validate state from the origin request.', 403);
96
+ }
97
+ const parsedResponse = yield saml.parseLogoutResponse(rawResponse);
98
+ if (parsedResponse.status !== 'urn:oasis:names:tc:SAML:2.0:status:Success') {
99
+ throw new JacksonError(`SLO failed with status ${parsedResponse.status}.`, 400);
100
+ }
101
+ if (parsedResponse.inResponseTo !== session.id) {
102
+ throw new JacksonError(`SLO failed with mismatched request ID.`, 400);
103
+ }
104
+ const samlConnections = (yield this.connectionStore.getByIndex({
105
+ name: IndexNames.EntityID,
106
+ value: parsedResponse.issuer,
107
+ })).data;
108
+ if (!samlConnections || samlConnections.length === 0) {
109
+ throw new JacksonError('SAML connection not found.', 403);
110
+ }
111
+ const { idpMetadata, defaultRedirectUrl } = samlConnections[0];
112
+ if (!(yield saml.validateSignature(rawResponse, null, idpMetadata.thumbprint))) {
113
+ throw new JacksonError('Invalid signature.', 403);
114
+ }
115
+ try {
116
+ yield this.sessionStore.delete(sessionId);
117
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
118
+ }
119
+ catch (_err) {
120
+ // Ignore
121
+ }
122
+ return {
123
+ redirectUrl: (_b = session.redirectUrl) !== null && _b !== void 0 ? _b : defaultRedirectUrl,
124
+ };
125
+ });
126
+ }
127
+ }
128
+ // Sign the XML
129
+ const signXML = (xml, signingKey, publicKey) => __awaiter(void 0, void 0, void 0, function* () {
130
+ return yield saml.sign(xml, signingKey, publicKey, logoutXPath);
131
+ });
132
+ //# sourceMappingURL=logout.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AAe;AACf,MAAM,OAAO,GAAG,CAAO,GAAW,EAAE,UAAkB,EAAE,SAAiB,EAAmB,EAAE;IAC5F,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;AAClE,CAAC,CAAA,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const redirect: (redirectUrl: string, redirectUrls: string[]) => boolean;
@@ -0,0 +1,30 @@
1
+ const redirectUrlPlaceholder = 'http://_boxyhq_redirect_not_in_use';
2
+ export const redirect = (redirectUrl, redirectUrls) => {
3
+ // Don't allow redirect to URL placeholder
4
+ if (redirectUrl === redirectUrlPlaceholder) {
5
+ return false;
6
+ }
7
+ const url = new URL(redirectUrl);
8
+ for (const idx in redirectUrls) {
9
+ const rUrl = new URL(redirectUrls[idx]);
10
+ let hostname = url.hostname;
11
+ let hostNameAllowed = rUrl.hostname;
12
+ // allow subdomain globbing *.example.com only
13
+ try {
14
+ if (rUrl.hostname.startsWith('*.')) {
15
+ hostNameAllowed = rUrl.hostname.slice(2);
16
+ hostname = hostname.slice(hostname.indexOf('.') + 1);
17
+ }
18
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
19
+ }
20
+ catch (e) {
21
+ // no-op
22
+ }
23
+ // TODO: Check pathname, for now pathname is ignored
24
+ if (rUrl.protocol === url.protocol && hostNameAllowed === hostname && rUrl.port === url.port) {
25
+ return true;
26
+ }
27
+ }
28
+ return false;
29
+ };
30
+ //# sourceMappingURL=allowed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"allowed.js","sourceRoot":"","sources":["../../../../src/controller/oauth/allowed.ts"],"names":[],"mappings":"AAAA,MAAM,sBAAsB,GAAG,oCAAoC,CAAC;AAEpE,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,WAAmB,EAAE,YAAsB,EAAW,EAAE;IAC/E,0CAA0C;IAC1C,IAAI,WAAW,KAAK,sBAAsB,EAAE,CAAC;QAC3C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,GAAG,GAAQ,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC;IAEtC,KAAK,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;QAC/B,MAAM,IAAI,GAAQ,IAAI,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;QAE7C,IAAI,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;QAC5B,IAAI,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC;QAEpC,8CAA8C;QAC9C,IAAI,CAAC;YACH,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;gBACnC,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBACzC,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;YACvD,CAAC;YACD,6DAA6D;QAC/D,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,QAAQ;QACV,CAAC;QAED,oDAAoD;QAEpD,IAAI,IAAI,CAAC,QAAQ,KAAK,GAAG,CAAC,QAAQ,IAAI,eAAe,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,EAAE,CAAC;YAC7F,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const encode: (code_challenge: string) => string;
@@ -0,0 +1,8 @@
1
+ import crypto from 'crypto';
2
+ const transformBase64 = (input) => {
3
+ return input.replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_');
4
+ };
5
+ export const encode = (code_challenge) => {
6
+ return transformBase64(crypto.createHash('sha256').update(code_challenge).digest('base64'));
7
+ };
8
+ //# sourceMappingURL=code-verifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-verifier.js","sourceRoot":"","sources":["../../../../src/controller/oauth/code-verifier.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,eAAe,GAAG,CAAC,KAAa,EAAU,EAAE;IAChD,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACzE,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,cAAsB,EAAU,EAAE;IACvD,OAAO,eAAe,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC9F,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { ServerMetadata, Configuration } from 'openid-client' with { 'resolution-mode': 'import' };
2
+ import { SSOTrace, SSOTracesInstance } from '../../typings';
3
+ export declare const oidcClientConfig: ({ discoveryUrl, metadata, clientId, clientSecret, ssoTraces, }: {
4
+ discoveryUrl?: string;
5
+ metadata?: ServerMetadata;
6
+ clientId: string;
7
+ clientSecret: string;
8
+ ssoTraces: {
9
+ instance: SSOTracesInstance;
10
+ context: SSOTrace["context"];
11
+ };
12
+ }) => Promise<Configuration>;
@@ -0,0 +1,89 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import * as http from 'http';
11
+ import * as https from 'https';
12
+ import { JacksonError } from '../error';
13
+ import { URL } from 'url';
14
+ const createCustomFetch = (ssoTraces) => {
15
+ return (url, options) => __awaiter(void 0, void 0, void 0, function* () {
16
+ return new Promise((resolve, reject) => {
17
+ const parsedUrl = new URL(url);
18
+ const requestOptions = {
19
+ hostname: parsedUrl.hostname,
20
+ port: parsedUrl.port,
21
+ path: parsedUrl.pathname + parsedUrl.search,
22
+ method: options.method || 'GET',
23
+ headers: options.headers,
24
+ };
25
+ const request = parsedUrl.protocol === 'https:' ? https.request : http.request;
26
+ const req = request(requestOptions, (res) => {
27
+ let data = '';
28
+ res.on('data', (chunk) => {
29
+ data += chunk;
30
+ });
31
+ res.on('end', () => {
32
+ const response = new Response(data, {
33
+ status: res.statusCode,
34
+ statusText: res.statusMessage,
35
+ headers: new Headers(res.headers),
36
+ });
37
+ resolve(response);
38
+ });
39
+ });
40
+ req.on('error', (error) => {
41
+ ssoTraces.instance.saveTrace({
42
+ error: `Fetch failed for OIDC IdP endpoint: ${parsedUrl.toString()}`,
43
+ context: ssoTraces.context,
44
+ });
45
+ reject(error);
46
+ });
47
+ if (options.body) {
48
+ let body;
49
+ let contentType;
50
+ if (options.body instanceof URLSearchParams) {
51
+ body = options.body.toString();
52
+ contentType = 'application/x-www-form-urlencoded';
53
+ }
54
+ else {
55
+ body = options.body;
56
+ }
57
+ if (contentType) {
58
+ req.setHeader('content-type', contentType);
59
+ }
60
+ req.write(body);
61
+ }
62
+ req.end();
63
+ });
64
+ });
65
+ };
66
+ export const oidcClientConfig = (_a) => __awaiter(void 0, [_a], void 0, function* ({ discoveryUrl, metadata, clientId, clientSecret, ssoTraces, }) {
67
+ const url = discoveryUrl ? new URL(discoveryUrl) : new URL(metadata.issuer);
68
+ const isLocalhost = url.hostname === 'localhost';
69
+ const customFetchWithSsoTraces = createCustomFetch(ssoTraces);
70
+ const client = yield import('openid-client');
71
+ if (discoveryUrl) {
72
+ return yield client.discovery(url, clientId, clientSecret, undefined, isLocalhost
73
+ ? {
74
+ execute: [client.allowInsecureRequests],
75
+ [client.customFetch]: customFetchWithSsoTraces,
76
+ }
77
+ : { [client.customFetch]: customFetchWithSsoTraces });
78
+ }
79
+ if (metadata) {
80
+ const config = new client.Configuration(metadata, clientId, clientSecret);
81
+ config[client.customFetch] = customFetchWithSsoTraces;
82
+ if (isLocalhost) {
83
+ client.allowInsecureRequests(config);
84
+ }
85
+ return config;
86
+ }
87
+ throw new JacksonError('Neither "discoveryUrl" nor "metadata" set for the OIDC provider', 500);
88
+ });
89
+ //# sourceMappingURL=oidc-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oidc-client.js","sourceRoot":"","sources":["../../../../src/controller/oauth/oidc-client.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAG1B,MAAM,iBAAiB,GAAG,CAAC,SAAwE,EAAE,EAAE;IACrG,OAAO,CAAO,GAAgB,EAAE,OAAoB,EAAqB,EAAE;QACzE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;YAE/B,MAAM,cAAc,GAAyB;gBAC3C,QAAQ,EAAE,SAAS,CAAC,QAAQ;gBAC5B,IAAI,EAAE,SAAS,CAAC,IAAI;gBACpB,IAAI,EAAE,SAAS,CAAC,QAAQ,GAAG,SAAS,CAAC,MAAM;gBAC3C,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,KAAK;gBAC/B,OAAO,EAAE,OAAO,CAAC,OAAmC;aACrD,CAAC;YACF,MAAM,OAAO,GAAG,SAAS,CAAC,QAAQ,KAAK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Q,EAAE,YAAY,CAAC,CAAC;QAC1E,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,wBAAwB,CAAC;QACtD,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;QACvC,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,MAAM,IAAI,YAAY,CAAC,iEAAiE,EAAE,GAAG,CAAC,CAAC;AACjG,CAAC,CAAA,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const success: (redirectUrl: string, params: Record<string, string | string[] | undefined>) => string;
@@ -0,0 +1,13 @@
1
+ export const success = (redirectUrl, params) => {
2
+ const url = new URL(redirectUrl);
3
+ for (const [key, value] of Object.entries(params)) {
4
+ if (Array.isArray(value)) {
5
+ value.forEach((v) => url.searchParams.append(key, v));
6
+ }
7
+ else if (value !== undefined) {
8
+ url.searchParams.set(key, value);
9
+ }
10
+ }
11
+ return url.href;
12
+ };
13
+ //# sourceMappingURL=redirect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redirect.js","sourceRoot":"","sources":["../../../../src/controller/oauth/redirect.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,WAAmB,EACnB,MAAqD,EAC7C,EAAE;IACV,MAAM,GAAG,GAAQ,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC;IAEtC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QACxD,CAAC;aAAM,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YAC/B,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAC,IAAI,CAAC;AAClB,CAAC,CAAC"}
@@ -0,0 +1,142 @@
1
+ import type { IOAuthController, OAuthReq, OAuthTokenReq, OAuthTokenRes, Profile, SAMLResponsePayload, OIDCAuthzResponsePayload } from '../typings';
2
+ export declare class OAuthController implements IOAuthController {
3
+ private connectionStore;
4
+ private sessionStore;
5
+ private codeStore;
6
+ private tokenStore;
7
+ private ssoTraces;
8
+ private opts;
9
+ private ssoHandler;
10
+ private idFedApp;
11
+ constructor({ connectionStore, sessionStore, codeStore, tokenStore, ssoTraces, opts, idFedApp }: {
12
+ connectionStore: any;
13
+ sessionStore: any;
14
+ codeStore: any;
15
+ tokenStore: any;
16
+ ssoTraces: any;
17
+ opts: any;
18
+ idFedApp: any;
19
+ });
20
+ authorize(body: OAuthReq): Promise<{
21
+ redirect_url?: string;
22
+ authorize_form?: string;
23
+ }>;
24
+ samlResponse(body: SAMLResponsePayload): Promise<{
25
+ redirect_url?: string;
26
+ app_select_form?: string;
27
+ response_form?: string;
28
+ }>;
29
+ oidcAuthzResponse(body: OIDCAuthzResponsePayload): Promise<{
30
+ redirect_url?: string;
31
+ response_form?: string;
32
+ }>;
33
+ private _buildAuthorizationCode;
34
+ /**
35
+ * @swagger
36
+ *
37
+ * /oauth/token:
38
+ * post:
39
+ * summary: Code exchange
40
+ * operationId: oauth-code-exchange
41
+ * tags:
42
+ * - OAuth
43
+ * consumes:
44
+ * - application/x-www-form-urlencoded
45
+ * parameters:
46
+ * - name: grant_type
47
+ * in: formData
48
+ * type: string
49
+ * description: Grant type should be 'authorization_code'
50
+ * default: authorization_code
51
+ * required: true
52
+ * - name: client_id
53
+ * in: formData
54
+ * type: string
55
+ * description: Use the client_id returned by the SAML connection API
56
+ * required: true
57
+ * - name: client_secret
58
+ * in: formData
59
+ * type: string
60
+ * description: Use the client_secret returned by the SAML connection API
61
+ * required: true
62
+ * - name: code_verifier
63
+ * in: formData
64
+ * type: string
65
+ * description: code_verifier against the code_challenge in the authz request (relevant to PKCE flow)
66
+ * - name: redirect_uri
67
+ * in: formData
68
+ * type: string
69
+ * description: Redirect URI
70
+ * required: true
71
+ * - name: code
72
+ * in: formData
73
+ * type: string
74
+ * description: Code
75
+ * required: true
76
+ * responses:
77
+ * '200':
78
+ * description: Success
79
+ * schema:
80
+ * type: object
81
+ * properties:
82
+ * access_token:
83
+ * type: string
84
+ * token_type:
85
+ * type: string
86
+ * expires_in:
87
+ * type: string
88
+ * example:
89
+ * access_token: 8958e13053832b5af58fdf2ee83f35f5d013dc74
90
+ * token_type: bearer
91
+ * expires_in: 300
92
+ */
93
+ token(body: OAuthTokenReq, authHeader?: string | null): Promise<OAuthTokenRes>;
94
+ /**
95
+ * @swagger
96
+ *
97
+ * /oauth/userinfo:
98
+ * get:
99
+ * summary: Get profile
100
+ * operationId: oauth-get-profile
101
+ * tags:
102
+ * - OAuth
103
+ * responses:
104
+ * '200':
105
+ * description: Success
106
+ * schema:
107
+ * type: object
108
+ * properties:
109
+ * id:
110
+ * type: string
111
+ * email:
112
+ * type: string
113
+ * firstName:
114
+ * type: string
115
+ * lastName:
116
+ * type: string
117
+ * roles:
118
+ * type: array
119
+ * items:
120
+ * type: string
121
+ * groups:
122
+ * type: array
123
+ * items:
124
+ * type: string
125
+ * raw:
126
+ * type: object
127
+ * requested:
128
+ * type: object
129
+ * example:
130
+ * id: 32b5af58fdf
131
+ * email: jackson@coolstartup.com
132
+ * firstName: SAML
133
+ * lastName: Jackson
134
+ * raw: {
135
+ *
136
+ * }
137
+ * requested: {
138
+ *
139
+ * }
140
+ */
141
+ userInfo(token: string): Promise<Profile>;
142
+ }