@contember/engine-tenant-api 1.2.1 → 1.3.0-alpha.2

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 (325) hide show
  1. package/dist/src/TenantContainer.d.ts +1 -1
  2. package/dist/src/TenantContainer.d.ts.map +1 -1
  3. package/dist/src/TenantContainer.js +2 -0
  4. package/dist/src/TenantContainer.js.map +1 -1
  5. package/dist/src/bin/runMigrations.d.ts +2 -0
  6. package/dist/src/bin/runMigrations.d.ts.map +1 -0
  7. package/dist/src/bin/runMigrations.js +28 -0
  8. package/dist/src/bin/runMigrations.js.map +1 -0
  9. package/dist/src/migrations/2018-08-02-174310-init.d.ts +3 -0
  10. package/dist/src/migrations/2018-08-02-174310-init.d.ts.map +1 -0
  11. package/dist/src/migrations/2018-08-02-174310-init.js +64 -0
  12. package/dist/src/migrations/2018-08-02-174310-init.js.map +1 -0
  13. package/dist/src/migrations/2018-09-03-140621-identity-project.d.ts +3 -0
  14. package/dist/src/migrations/2018-09-03-140621-identity-project.d.ts.map +1 -0
  15. package/dist/src/migrations/2018-09-03-140621-identity-project.js +33 -0
  16. package/dist/src/migrations/2018-09-03-140621-identity-project.js.map +1 -0
  17. package/dist/src/migrations/2018-10-26-165450-setup-api-key.d.ts +3 -0
  18. package/dist/src/migrations/2018-10-26-165450-setup-api-key.d.ts.map +1 -0
  19. package/dist/src/migrations/2018-10-26-165450-setup-api-key.js +27 -0
  20. package/dist/src/migrations/2018-10-26-165450-setup-api-key.js.map +1 -0
  21. package/dist/src/migrations/2018-10-26-175155-variables.d.ts +3 -0
  22. package/dist/src/migrations/2018-10-26-175155-variables.d.ts.map +1 -0
  23. package/dist/src/migrations/2018-10-26-175155-variables.js +23 -0
  24. package/dist/src/migrations/2018-10-26-175155-variables.js.map +1 -0
  25. package/dist/src/migrations/2019-02-18-110949-project-slug.d.ts +3 -0
  26. package/dist/src/migrations/2019-02-18-110949-project-slug.d.ts.map +1 -0
  27. package/dist/src/migrations/2019-02-18-110949-project-slug.js +18 -0
  28. package/dist/src/migrations/2019-02-18-110949-project-slug.js.map +1 -0
  29. package/dist/src/migrations/2019-02-18-160155-session-expiration.d.ts +3 -0
  30. package/dist/src/migrations/2019-02-18-160155-session-expiration.d.ts.map +1 -0
  31. package/dist/src/migrations/2019-02-18-160155-session-expiration.js +11 -0
  32. package/dist/src/migrations/2019-02-18-160155-session-expiration.js.map +1 -0
  33. package/dist/src/migrations/2019-05-03-163729-api-key-disabled-at.d.ts +3 -0
  34. package/dist/src/migrations/2019-05-03-163729-api-key-disabled-at.d.ts.map +1 -0
  35. package/dist/src/migrations/2019-05-03-163729-api-key-disabled-at.js +18 -0
  36. package/dist/src/migrations/2019-05-03-163729-api-key-disabled-at.js.map +1 -0
  37. package/dist/src/migrations/2019-08-14-153300-project-slug-unique.d.ts +3 -0
  38. package/dist/src/migrations/2019-08-14-153300-project-slug-unique.d.ts.map +1 -0
  39. package/dist/src/migrations/2019-08-14-153300-project-slug-unique.js +11 -0
  40. package/dist/src/migrations/2019-08-14-153300-project-slug-unique.js.map +1 -0
  41. package/dist/src/migrations/2019-09-06-111000-membership.d.ts +3 -0
  42. package/dist/src/migrations/2019-09-06-111000-membership.d.ts.map +1 -0
  43. package/dist/src/migrations/2019-09-06-111000-membership.js +51 -0
  44. package/dist/src/migrations/2019-09-06-111000-membership.js.map +1 -0
  45. package/dist/src/migrations/2019-09-06-111001-drop-old-member.d.ts +3 -0
  46. package/dist/src/migrations/2019-09-06-111001-drop-old-member.d.ts.map +1 -0
  47. package/dist/src/migrations/2019-09-06-111001-drop-old-member.js +11 -0
  48. package/dist/src/migrations/2019-09-06-111001-drop-old-member.js.map +1 -0
  49. package/dist/src/migrations/2020-01-29-idenity-note.d.ts +3 -0
  50. package/dist/src/migrations/2020-01-29-idenity-note.d.ts.map +1 -0
  51. package/dist/src/migrations/2020-01-29-idenity-note.js +18 -0
  52. package/dist/src/migrations/2020-01-29-idenity-note.js.map +1 -0
  53. package/dist/src/migrations/2020-04-17-fix-person-index.d.ts +3 -0
  54. package/dist/src/migrations/2020-04-17-fix-person-index.d.ts.map +1 -0
  55. package/dist/src/migrations/2020-04-17-fix-person-index.js +12 -0
  56. package/dist/src/migrations/2020-04-17-fix-person-index.js.map +1 -0
  57. package/dist/src/migrations/2020-05-01-170000-api-key-index.d.ts +3 -0
  58. package/dist/src/migrations/2020-05-01-170000-api-key-index.d.ts.map +1 -0
  59. package/dist/src/migrations/2020-05-01-170000-api-key-index.js +10 -0
  60. package/dist/src/migrations/2020-05-01-170000-api-key-index.js.map +1 -0
  61. package/dist/src/migrations/2020-06-08-134000-tenant-credentials.d.ts.map +1 -1
  62. package/dist/src/migrations/2020-06-08-134000-tenant-credentials.js +2 -50
  63. package/dist/src/migrations/2020-06-08-134000-tenant-credentials.js.map +1 -1
  64. package/dist/src/migrations/2020-08-07-110000-person-otp.d.ts +3 -0
  65. package/dist/src/migrations/2020-08-07-110000-person-otp.d.ts.map +1 -0
  66. package/dist/src/migrations/2020-08-07-110000-person-otp.js +12 -0
  67. package/dist/src/migrations/2020-08-07-110000-person-otp.js.map +1 -0
  68. package/dist/src/migrations/2020-08-17-162200-mail-templates.d.ts +3 -0
  69. package/dist/src/migrations/2020-08-17-162200-mail-templates.d.ts.map +1 -0
  70. package/dist/src/migrations/2020-08-17-162200-mail-templates.js +23 -0
  71. package/dist/src/migrations/2020-08-17-162200-mail-templates.js.map +1 -0
  72. package/dist/src/migrations/2020-08-21-143400-person-password-reset.d.ts +3 -0
  73. package/dist/src/migrations/2020-08-21-143400-person-password-reset.d.ts.map +1 -0
  74. package/dist/src/migrations/2020-08-21-143400-person-password-reset.js +23 -0
  75. package/dist/src/migrations/2020-08-21-143400-person-password-reset.js.map +1 -0
  76. package/dist/src/migrations/2020-09-07-094200-identity-provider.d.ts +3 -0
  77. package/dist/src/migrations/2020-09-07-094200-identity-provider.d.ts.map +1 -0
  78. package/dist/src/migrations/2020-09-07-094200-identity-provider.js +17 -0
  79. package/dist/src/migrations/2020-09-07-094200-identity-provider.js.map +1 -0
  80. package/dist/src/migrations/2021-03-28-134000-timestamp.d.ts +3 -0
  81. package/dist/src/migrations/2021-03-28-134000-timestamp.d.ts.map +1 -0
  82. package/dist/src/migrations/2021-03-28-134000-timestamp.js +27 -0
  83. package/dist/src/migrations/2021-03-28-134000-timestamp.js.map +1 -0
  84. package/dist/src/migrations/2021-07-26-105000-project-config.d.ts +3 -0
  85. package/dist/src/migrations/2021-07-26-105000-project-config.d.ts.map +1 -0
  86. package/dist/src/migrations/2021-07-26-105000-project-config.js +12 -0
  87. package/dist/src/migrations/2021-07-26-105000-project-config.js.map +1 -0
  88. package/dist/src/migrations/2021-07-26-132000-project-secrets.d.ts +3 -0
  89. package/dist/src/migrations/2021-07-26-132000-project-secrets.d.ts.map +1 -0
  90. package/dist/src/migrations/2021-07-26-132000-project-secrets.js +24 -0
  91. package/dist/src/migrations/2021-07-26-132000-project-secrets.js.map +1 -0
  92. package/dist/src/migrations/2021-07-27-174000-project-alias-index.d.ts +3 -0
  93. package/dist/src/migrations/2021-07-27-174000-project-alias-index.d.ts.map +1 -0
  94. package/dist/src/migrations/2021-07-27-174000-project-alias-index.js +10 -0
  95. package/dist/src/migrations/2021-07-27-174000-project-alias-index.js.map +1 -0
  96. package/dist/src/migrations/2021-11-24-130000-person-password-null.d.ts +3 -0
  97. package/dist/src/migrations/2021-11-24-130000-person-password-null.d.ts.map +1 -0
  98. package/dist/src/migrations/2021-11-24-130000-person-password-null.js +10 -0
  99. package/dist/src/migrations/2021-11-24-130000-person-password-null.js.map +1 -0
  100. package/dist/src/migrations/2021-11-24-161500-mail-template-project-null.d.ts +3 -0
  101. package/dist/src/migrations/2021-11-24-161500-mail-template-project-null.d.ts.map +1 -0
  102. package/dist/src/migrations/2021-11-24-161500-mail-template-project-null.js +18 -0
  103. package/dist/src/migrations/2021-11-24-161500-mail-template-project-null.js.map +1 -0
  104. package/dist/src/migrations/2022-01-04-144000-person-unique-identity.d.ts +3 -0
  105. package/dist/src/migrations/2022-01-04-144000-person-unique-identity.d.ts.map +1 -0
  106. package/dist/src/migrations/2022-01-04-144000-person-unique-identity.js +11 -0
  107. package/dist/src/migrations/2022-01-04-144000-person-unique-identity.js.map +1 -0
  108. package/dist/src/migrations/2022-02-09-111800-fix-crypted.d.ts +3 -0
  109. package/dist/src/migrations/2022-02-09-111800-fix-crypted.d.ts.map +1 -0
  110. package/dist/src/migrations/2022-02-09-111800-fix-crypted.js +22 -0
  111. package/dist/src/migrations/2022-02-09-111800-fix-crypted.js.map +1 -0
  112. package/dist/src/migrations/2022-02-11-153000-idp-auto-sign-up.d.ts +3 -0
  113. package/dist/src/migrations/2022-02-11-153000-idp-auto-sign-up.d.ts.map +1 -0
  114. package/dist/src/migrations/2022-02-11-153000-idp-auto-sign-up.js +11 -0
  115. package/dist/src/migrations/2022-02-11-153000-idp-auto-sign-up.js.map +1 -0
  116. package/dist/src/migrations/2022-06-29-105000-person-idp.d.ts +3 -0
  117. package/dist/src/migrations/2022-06-29-105000-person-idp.d.ts.map +1 -0
  118. package/dist/src/migrations/2022-06-29-105000-person-idp.js +23 -0
  119. package/dist/src/migrations/2022-06-29-105000-person-idp.js.map +1 -0
  120. package/dist/src/migrations/2022-07-07-135000-person-email-opt-uniq.d.ts +3 -0
  121. package/dist/src/migrations/2022-07-07-135000-person-email-opt-uniq.d.ts.map +1 -0
  122. package/dist/src/migrations/2022-07-07-135000-person-email-opt-uniq.js +12 -0
  123. package/dist/src/migrations/2022-07-07-135000-person-email-opt-uniq.js.map +1 -0
  124. package/dist/src/migrations/2022-07-07-141000-person-display-name.d.ts +3 -0
  125. package/dist/src/migrations/2022-07-07-141000-person-display-name.d.ts.map +1 -0
  126. package/dist/src/migrations/2022-07-07-141000-person-display-name.js +13 -0
  127. package/dist/src/migrations/2022-07-07-141000-person-display-name.js.map +1 -0
  128. package/dist/src/migrations/2022-07-14-145000-person-login-options.d.ts +3 -0
  129. package/dist/src/migrations/2022-07-14-145000-person-login-options.d.ts.map +1 -0
  130. package/dist/src/migrations/2022-07-14-145000-person-login-options.js +15 -0
  131. package/dist/src/migrations/2022-07-14-145000-person-login-options.js.map +1 -0
  132. package/dist/src/migrations/2022-11-08-project-update-notification.d.ts +3 -0
  133. package/dist/src/migrations/2022-11-08-project-update-notification.d.ts.map +1 -0
  134. package/dist/src/migrations/2022-11-08-project-update-notification.js +64 -0
  135. package/dist/src/migrations/2022-11-08-project-update-notification.js.map +1 -0
  136. package/dist/src/migrations/runner.d.ts +1 -1
  137. package/dist/src/migrations/runner.d.ts.map +1 -1
  138. package/dist/src/migrations/runner.js +68 -5
  139. package/dist/src/migrations/runner.js.map +1 -1
  140. package/dist/src/migrations/snapshot-factory.d.ts +5 -0
  141. package/dist/src/migrations/snapshot-factory.d.ts.map +1 -0
  142. package/dist/src/migrations/snapshot-factory.js +18 -0
  143. package/dist/src/migrations/snapshot-factory.js.map +1 -0
  144. package/dist/src/migrations/snapshot.d.ts +4 -0
  145. package/dist/src/migrations/snapshot.d.ts.map +1 -0
  146. package/dist/src/migrations/snapshot.js +202 -0
  147. package/dist/src/migrations/snapshot.js.map +1 -0
  148. package/dist/src/migrations/tenantCredentials.d.ts +4 -0
  149. package/dist/src/migrations/tenantCredentials.d.ts.map +1 -0
  150. package/dist/src/migrations/tenantCredentials.js +57 -0
  151. package/dist/src/migrations/tenantCredentials.js.map +1 -0
  152. package/dist/src/migrations/types.d.ts +2 -0
  153. package/dist/src/migrations/types.d.ts.map +1 -1
  154. package/dist/src/model/commands/idp/UpdateIdpCommand.d.ts +1 -0
  155. package/dist/src/model/commands/idp/UpdateIdpCommand.d.ts.map +1 -1
  156. package/dist/src/model/queries/membership/ProjectMembersQuery.d.ts +3 -3
  157. package/dist/src/model/queries/membership/ProjectMembersQuery.d.ts.map +1 -1
  158. package/dist/src/model/queries/membership/ProjectMembersQuery.js +22 -10
  159. package/dist/src/model/queries/membership/ProjectMembersQuery.js.map +1 -1
  160. package/dist/src/model/service/IDPSignInManager.d.ts +3 -3
  161. package/dist/src/model/service/IDPSignInManager.d.ts.map +1 -1
  162. package/dist/src/model/service/IDPSignInManager.js +13 -5
  163. package/dist/src/model/service/IDPSignInManager.js.map +1 -1
  164. package/dist/src/model/service/ProjectMemberManager.d.ts +2 -2
  165. package/dist/src/model/service/ProjectMemberManager.d.ts.map +1 -1
  166. package/dist/src/model/service/ProjectMemberManager.js +2 -2
  167. package/dist/src/model/service/ProjectMemberManager.js.map +1 -1
  168. package/dist/src/model/service/idp/IDPHandlerRegistry.d.ts +2 -2
  169. package/dist/src/model/service/idp/IDPHandlerRegistry.d.ts.map +1 -1
  170. package/dist/src/model/service/idp/IDPHandlerRegistry.js.map +1 -1
  171. package/dist/src/model/service/idp/IDPManager.d.ts.map +1 -1
  172. package/dist/src/model/service/idp/IDPManager.js +7 -2
  173. package/dist/src/model/service/idp/IDPManager.js.map +1 -1
  174. package/dist/src/model/service/idp/IdentityProviderHandler.d.ts +6 -9
  175. package/dist/src/model/service/idp/IdentityProviderHandler.d.ts.map +1 -1
  176. package/dist/src/model/service/idp/index.d.ts +3 -1
  177. package/dist/src/model/service/idp/index.d.ts.map +1 -1
  178. package/dist/src/model/service/idp/index.js +3 -1
  179. package/dist/src/model/service/idp/index.js.map +1 -1
  180. package/dist/src/model/service/idp/providers/AppleProvider.d.ts +29 -0
  181. package/dist/src/model/service/idp/providers/AppleProvider.d.ts.map +1 -0
  182. package/dist/src/model/service/idp/providers/AppleProvider.js +79 -0
  183. package/dist/src/model/service/idp/providers/AppleProvider.js.map +1 -0
  184. package/dist/src/model/service/idp/providers/FacebookProvider.d.ts +27 -0
  185. package/dist/src/model/service/idp/providers/FacebookProvider.d.ts.map +1 -0
  186. package/dist/src/model/service/idp/providers/FacebookProvider.js +137 -0
  187. package/dist/src/model/service/idp/providers/FacebookProvider.js.map +1 -0
  188. package/dist/src/model/service/idp/providers/OIDCHelpers.d.ts +10 -0
  189. package/dist/src/model/service/idp/providers/OIDCHelpers.d.ts.map +1 -0
  190. package/dist/src/model/service/idp/providers/OIDCHelpers.js +56 -0
  191. package/dist/src/model/service/idp/providers/OIDCHelpers.js.map +1 -0
  192. package/dist/src/model/service/idp/providers/OIDCProvider.d.ts +19 -0
  193. package/dist/src/model/service/idp/providers/OIDCProvider.d.ts.map +1 -0
  194. package/dist/src/model/service/idp/providers/OIDCProvider.js +40 -0
  195. package/dist/src/model/service/idp/providers/OIDCProvider.js.map +1 -0
  196. package/dist/src/model/service/idp/providers/OIDCTypes.d.ts +62 -0
  197. package/dist/src/model/service/idp/providers/OIDCTypes.d.ts.map +1 -0
  198. package/dist/src/model/service/idp/providers/OIDCTypes.js +56 -0
  199. package/dist/src/model/service/idp/providers/OIDCTypes.js.map +1 -0
  200. package/dist/src/model/service/idp/providers/helpers.d.ts +3 -0
  201. package/dist/src/model/service/idp/providers/helpers.d.ts.map +1 -0
  202. package/dist/src/model/service/idp/providers/helpers.js +40 -0
  203. package/dist/src/model/service/idp/providers/helpers.js.map +1 -0
  204. package/dist/src/model/utils/DatabaseContext.d.ts +1 -0
  205. package/dist/src/model/utils/DatabaseContext.d.ts.map +1 -1
  206. package/dist/src/model/utils/DatabaseContext.js +5 -0
  207. package/dist/src/model/utils/DatabaseContext.js.map +1 -1
  208. package/dist/src/resolvers/mutation/idp/UpdateIDPMutationResolver.d.ts.map +1 -1
  209. package/dist/src/resolvers/mutation/idp/UpdateIDPMutationResolver.js +4 -3
  210. package/dist/src/resolvers/mutation/idp/UpdateIDPMutationResolver.js.map +1 -1
  211. package/dist/src/resolvers/mutation/person/IDPMutationResolver.d.ts.map +1 -1
  212. package/dist/src/resolvers/mutation/person/IDPMutationResolver.js +10 -3
  213. package/dist/src/resolvers/mutation/person/IDPMutationResolver.js.map +1 -1
  214. package/dist/src/resolvers/types/ProjectTypeResolver.d.ts.map +1 -1
  215. package/dist/src/resolvers/types/ProjectTypeResolver.js +14 -6
  216. package/dist/src/resolvers/types/ProjectTypeResolver.js.map +1 -1
  217. package/dist/src/schema/index.d.ts +26 -8
  218. package/dist/src/schema/index.d.ts.map +1 -1
  219. package/dist/src/schema/index.js +1 -0
  220. package/dist/src/schema/index.js.map +1 -1
  221. package/dist/src/schema/tenant.graphql.d.ts.map +1 -1
  222. package/dist/src/schema/tenant.graphql.js +32 -6
  223. package/dist/src/schema/tenant.graphql.js.map +1 -1
  224. package/dist/src/tsconfig.tsbuildinfo +1 -1
  225. package/dist/tests/cases/integration/db/invite.test.js +2 -2
  226. package/dist/tests/cases/integration/db/unmanagedInvite.test.js +2 -2
  227. package/dist/{src → tests/cases}/migrations/2020-06-08-134000-tenant-credentials.test.d.ts +1 -1
  228. package/dist/tests/cases/migrations/2020-06-08-134000-tenant-credentials.test.d.ts.map +1 -0
  229. package/dist/{src → tests/cases}/migrations/2020-06-08-134000-tenant-credentials.test.js +19 -9
  230. package/dist/tests/cases/migrations/2020-06-08-134000-tenant-credentials.test.js.map +1 -0
  231. package/dist/tests/src/IdPMock.d.ts +4 -4
  232. package/dist/tests/src/IdPMock.d.ts.map +1 -1
  233. package/dist/tests/src/IdPMock.js +2 -2
  234. package/dist/tests/src/IdPMock.js.map +1 -1
  235. package/dist/tests/tsconfig.tsbuildinfo +1 -1
  236. package/package.json +14 -13
  237. package/src/TenantContainer.ts +4 -2
  238. package/src/bin/runMigrations.ts +32 -0
  239. package/src/migrations/{2018-08-02-174310-init.sql → 2018-08-02-174310-init.ts} +8 -1
  240. package/src/migrations/{2018-09-03-140621-identity-project.sql → 2018-09-03-140621-identity-project.ts} +8 -0
  241. package/src/migrations/{2018-10-26-165450-setup-api-key.sql → 2018-10-26-165450-setup-api-key.ts} +8 -0
  242. package/src/migrations/{2018-10-26-175155-variables.sql → 2018-10-26-175155-variables.ts} +7 -0
  243. package/src/migrations/{2019-02-18-110949-project-slug.sql → 2019-02-18-110949-project-slug.ts} +8 -0
  244. package/src/migrations/2019-02-18-160155-session-expiration.ts +10 -0
  245. package/src/migrations/{2019-05-03-163729-api-key-disabled-at.sql → 2019-05-03-163729-api-key-disabled-at.ts} +8 -0
  246. package/src/migrations/2019-08-14-153300-project-slug-unique.ts +10 -0
  247. package/src/migrations/{2019-09-06-111000-membership.sql → 2019-09-06-111000-membership.ts} +8 -0
  248. package/src/migrations/2019-09-06-111001-drop-old-member.ts +10 -0
  249. package/src/migrations/2020-01-29-idenity-note.ts +18 -0
  250. package/src/migrations/2020-04-17-fix-person-index.ts +12 -0
  251. package/src/migrations/2020-05-01-170000-api-key-index.ts +10 -0
  252. package/src/migrations/2020-06-08-134000-tenant-credentials.ts +3 -54
  253. package/src/migrations/2020-08-07-110000-person-otp.ts +12 -0
  254. package/src/migrations/{2020-08-17-162200-mail-templates.sql → 2020-08-17-162200-mail-templates.ts} +8 -0
  255. package/src/migrations/{2020-08-21-143400-person-password-reset.sql → 2020-08-21-143400-person-password-reset.ts} +8 -0
  256. package/src/migrations/{2020-09-07-094200-identity-provider.sql → 2020-09-07-094200-identity-provider.ts} +8 -0
  257. package/src/migrations/{2021-03-28-134000-timestamp.sql → 2021-03-28-134000-timestamp.ts} +9 -0
  258. package/src/migrations/2021-07-26-105000-project-config.ts +12 -0
  259. package/src/migrations/{2021-07-26-132000-project-secrets.sql → 2021-07-26-132000-project-secrets.ts} +8 -0
  260. package/src/migrations/2021-07-27-174000-project-alias-index.ts +10 -0
  261. package/src/migrations/2021-11-24-130000-person-password-null.ts +10 -0
  262. package/src/migrations/{2021-11-24-161500-mail-template-project-null.sql → 2021-11-24-161500-mail-template-project-null.ts} +8 -0
  263. package/src/migrations/2022-01-04-144000-person-unique-identity.ts +10 -0
  264. package/src/migrations/{2022-02-09-111800-fix-crypted.sql → 2022-02-09-111800-fix-crypted.ts} +8 -0
  265. package/src/migrations/2022-02-11-153000-idp-auto-sign-up.ts +10 -0
  266. package/src/migrations/{2022-06-29-105000-person-idp.sql → 2022-06-29-105000-person-idp.ts} +8 -0
  267. package/src/migrations/2022-07-07-135000-person-email-opt-uniq.ts +11 -0
  268. package/src/migrations/2022-07-07-141000-person-display-name.ts +13 -0
  269. package/src/migrations/{2022-07-14-145000-person-login-options.sql → 2022-07-14-145000-person-login-options.ts} +9 -0
  270. package/src/migrations/2022-11-08-project-update-notification.ts +64 -0
  271. package/src/migrations/runner.ts +72 -8
  272. package/src/migrations/snapshot-factory.ts +21 -0
  273. package/src/migrations/snapshot-template-end.txt +10 -0
  274. package/src/migrations/snapshot-template-start.txt +6 -0
  275. package/src/migrations/snapshot.ts +202 -0
  276. package/src/migrations/tenantCredentials.ts +58 -0
  277. package/src/migrations/types.ts +3 -0
  278. package/src/model/commands/idp/UpdateIdpCommand.ts +1 -0
  279. package/src/model/queries/membership/ProjectMembersQuery.ts +23 -14
  280. package/src/model/service/IDPSignInManager.ts +13 -10
  281. package/src/model/service/ProjectMemberManager.ts +3 -3
  282. package/src/model/service/idp/IDPHandlerRegistry.ts +3 -3
  283. package/src/model/service/idp/IDPManager.ts +6 -2
  284. package/src/model/service/idp/IdentityProviderHandler.ts +7 -15
  285. package/src/model/service/idp/index.ts +3 -1
  286. package/src/model/service/idp/providers/AppleProvider.ts +65 -0
  287. package/src/model/service/idp/providers/FacebookProvider.ts +125 -0
  288. package/src/model/service/idp/providers/OIDCHelpers.ts +54 -0
  289. package/src/model/service/idp/providers/OIDCProvider.ts +40 -0
  290. package/src/model/service/idp/providers/OIDCTypes.ts +61 -0
  291. package/src/model/service/idp/providers/helpers.ts +12 -0
  292. package/src/model/utils/DatabaseContext.ts +6 -0
  293. package/src/resolvers/mutation/idp/UpdateIDPMutationResolver.ts +1 -0
  294. package/src/resolvers/mutation/person/IDPMutationResolver.ts +9 -7
  295. package/src/resolvers/types/ProjectTypeResolver.ts +9 -2
  296. package/src/schema/index.ts +28 -8
  297. package/src/schema/tenant.graphql.ts +32 -6
  298. package/src/tsconfig.json +10 -30
  299. package/tests/cases/integration/db/invite.test.ts +2 -2
  300. package/tests/cases/integration/db/unmanagedInvite.test.ts +2 -2
  301. package/{src → tests/cases}/migrations/2020-06-08-134000-tenant-credentials.test.ts +17 -9
  302. package/tests/src/IdPMock.ts +4 -4
  303. package/tests/tsconfig.json +2 -6
  304. package/tsconfig.json +2 -6
  305. package/dist/src/migrations/2020-06-08-134000-tenant-credentials.test.d.ts.map +0 -1
  306. package/dist/src/migrations/2020-06-08-134000-tenant-credentials.test.js.map +0 -1
  307. package/dist/src/model/service/idp/OIDCProvider.d.ts +0 -25
  308. package/dist/src/model/service/idp/OIDCProvider.d.ts.map +0 -1
  309. package/dist/src/model/service/idp/OIDCProvider.js +0 -108
  310. package/dist/src/model/service/idp/OIDCProvider.js.map +0 -1
  311. package/src/migrations/2019-02-18-160155-session-expiration.sql +0 -2
  312. package/src/migrations/2019-08-14-153300-project-slug-unique.sql +0 -2
  313. package/src/migrations/2019-09-06-111001-drop-old-member.sql +0 -2
  314. package/src/migrations/2020-01-29-idenity-note.sql +0 -9
  315. package/src/migrations/2020-04-17-fix-person-index.sql +0 -3
  316. package/src/migrations/2020-05-01-170000-api-key-index.sql +0 -1
  317. package/src/migrations/2020-08-07-110000-person-otp.sql +0 -3
  318. package/src/migrations/2021-07-26-105000-project-config.sql +0 -3
  319. package/src/migrations/2021-07-27-174000-project-alias-index.sql +0 -1
  320. package/src/migrations/2021-11-24-130000-person-password-null.sql +0 -1
  321. package/src/migrations/2022-01-04-144000-person-unique-identity.sql +0 -2
  322. package/src/migrations/2022-02-11-153000-idp-auto-sign-up.sql +0 -2
  323. package/src/migrations/2022-07-07-135000-person-email-opt-uniq.sql +0 -3
  324. package/src/migrations/2022-07-07-141000-person-display-name.sql +0 -4
  325. package/src/model/service/idp/OIDCProvider.ts +0 -100
@@ -28,12 +28,23 @@ const schema: DocumentNode = gql`
28
28
  changePassword(personId: String!, password: String!): ChangePasswordResponse
29
29
  changeMyPassword(currentPassword: String!, newPassword: String!): ChangeMyPasswordResponse
30
30
 
31
- initSignInIDP(identityProvider: String!, redirectUrl: String!): InitSignInIDPResponse
32
- signInIDP(identityProvider: String!, idpResponse: IDPResponseInput!, redirectUrl: String!, sessionData: Json!, expiration: Int): SignInIDPResponse
31
+ initSignInIDP(
32
+ identityProvider: String!,
33
+ data: Json
34
+ redirectUrl: String @deprecated(reason: "use data.redirectUrl")
35
+ ): InitSignInIDPResponse
36
+ signInIDP(
37
+ identityProvider: String!,
38
+ data: Json,
39
+ expiration: Int
40
+ idpResponse: IDPResponseInput, @deprecated(reason: "pass idpResponse.url as data.url")
41
+ redirectUrl: String @deprecated(reason: "use data.redirectUrl"),
42
+ sessionData: Json @deprecated(reason: "use data.sessionData"),
43
+ ): SignInIDPResponse
33
44
 
34
45
  # IDP management
35
46
  addIDP(identityProvider: String!, type: String!, configuration: Json!, options: IDPOptions): AddIDPResponse
36
- updateIDP(identityProvider: String!, configuration: Json, options: IDPOptions): UpdateIDPResponse
47
+ updateIDP(identityProvider: String!, type: String, configuration: Json, options: IDPOptions): UpdateIDPResponse
37
48
  disableIDP(identityProvider: String!): DisableIDPResponse
38
49
  enableIDP(identityProvider: String!): EnableIDPResponse
39
50
 
@@ -78,10 +89,10 @@ const schema: DocumentNode = gql`
78
89
  updateProject(projectSlug: String!, name: String, config: Json, mergeConfig: Boolean): UpdateProjectResponse
79
90
 
80
91
  addProjectMailTemplate(template: MailTemplate!): AddMailTemplateResponse
81
- @deprecated(reason: "use addMailtemplate")
92
+ @deprecated(reason: "use addMailTemplate")
82
93
 
83
94
  removeProjectMailTemplate(templateIdentifier: MailTemplateIdentifier!): RemoveMailTemplateResponse
84
- @deprecated(reason: "use removeMailtemplate")
95
+ @deprecated(reason: "use removeMailTemplate")
85
96
 
86
97
  }
87
98
 
@@ -242,6 +253,7 @@ const schema: DocumentNode = gql`
242
253
 
243
254
  enum InitSignInIDPErrorCode {
244
255
  PROVIDER_NOT_FOUND
256
+ IDP_VALIDATION_FAILED
245
257
  }
246
258
 
247
259
  input IDPResponseInput {
@@ -607,7 +619,21 @@ const schema: DocumentNode = gql`
607
619
  slug: String!
608
620
  config: Json!
609
621
  roles: [RoleDefinition!]!
610
- members(memberType: MemberType): [ProjectIdentityRelation!]!
622
+ members(
623
+ input: ProjectMembersInput,
624
+ memberType: MemberType @deprecated(reason: "Use args")
625
+ ): [ProjectIdentityRelation!]!
626
+ }
627
+
628
+ input ProjectMembersInput {
629
+ limit: Int
630
+ offset: Int
631
+ filter: ProjectMembersFilter
632
+ }
633
+
634
+ input ProjectMembersFilter {
635
+ memberType: MemberType
636
+ email: String
611
637
  }
612
638
 
613
639
  enum MemberType {
package/src/tsconfig.json CHANGED
@@ -5,35 +5,15 @@
5
5
  "esModuleInterop": true
6
6
  },
7
7
  "references": [
8
- {
9
- "path": "../../authorization/src"
10
- },
11
- {
12
- "path": "../../config-loader/src"
13
- },
14
- {
15
- "path": "../../database/src"
16
- },
17
- {
18
- "path": "../../database-migrations/src"
19
- },
20
- {
21
- "path": "../../dic/src"
22
- },
23
- {
24
- "path": "../../logger/src"
25
- },
26
- {
27
- "path": "../../graphql-utils/src"
28
- },
29
- {
30
- "path": "../../schema/src"
31
- },
32
- {
33
- "path": "../../schema-utils/src"
34
- },
35
- {
36
- "path": "../../typesafe/src"
37
- }
8
+ { "path": "../../authorization/src" },
9
+ { "path": "../../config-loader/src" },
10
+ { "path": "../../database/src" },
11
+ { "path": "../../database-migrations/src" },
12
+ { "path": "../../dic/src" },
13
+ { "path": "../../logger/src" },
14
+ { "path": "../../graphql-utils/src" },
15
+ { "path": "../../schema/src" },
16
+ { "path": "../../schema-utils/src" },
17
+ { "path": "../../typesafe/src" }
38
18
  ]
39
19
  }
@@ -40,13 +40,13 @@ test('admin can invite a user with a membership', testTenantDb(async ({ tester }
40
40
  }
41
41
  }
42
42
  `)
43
- assert.equal(identity, testUuid(2))
43
+ assert.equal(identity, testUuid(5))
44
44
  assert.deepStrictEqual(resultListMembers.data, {
45
45
  projectBySlug: {
46
46
  members: [
47
47
  {
48
48
  identity: {
49
- id: testUuid(2),
49
+ id: testUuid(5),
50
50
  },
51
51
  memberships: [
52
52
  {
@@ -27,9 +27,9 @@ test('does not send an email and sets given password', testTenantDb(async ({ tes
27
27
  errors: [],
28
28
  result: {
29
29
  person: {
30
- id: testUuid(3),
30
+ id: testUuid(6),
31
31
  identity: {
32
- id: testUuid(2),
32
+ id: testUuid(5),
33
33
  },
34
34
  },
35
35
  },
@@ -1,7 +1,9 @@
1
- import migration from './2020-06-08-134000-tenant-credentials'
1
+ import migration from '../../../src/migrations/2020-06-08-134000-tenant-credentials'
2
2
  import { createMigrationBuilder } from '@contember/database-migrations'
3
3
  import { test, assert } from 'vitest'
4
4
 
5
+ let uuidNum = 0
6
+ export const testUuid = () => '123e4567-e89b-12d3-a456-' + (uuidNum++).toString().padStart(12, '0')
5
7
  test('generate sql with root token and login token', async () => {
6
8
  const builder = createMigrationBuilder()
7
9
  await migration(builder, {
@@ -9,23 +11,26 @@ test('generate sql with root token and login token', async () => {
9
11
  loginTokenHash: '936a185caaa266bb9cbe981e9e05cb78cd732b0b3280eb944412bb6f8f8f07af',
10
12
  rootTokenHash: 'c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2',
11
13
  }),
14
+ providers: {
15
+ uuid: testUuid,
16
+ },
12
17
  })
13
18
  assert.equal(
14
19
  builder.getSql(),
15
20
  `
16
21
  WITH identity AS (
17
22
  INSERT INTO identity(id, parent_id, roles, description, created_at)
18
- VALUES (public."uuid_generate_v4"(), NULL, '["login"]'::JSONB, 'Login key', now()) RETURNING id
23
+ VALUES ($pga$123e4567-e89b-12d3-a456-000000000000$pga$, NULL, '["login"]'::JSONB, 'Login key', now()) RETURNING id
19
24
  )
20
25
  INSERT INTO api_key (id, token_hash, type, identity_id, disabled_at, expires_at, expiration, created_at)
21
- SELECT public."uuid_generate_v4"(), $pga$936a185caaa266bb9cbe981e9e05cb78cd732b0b3280eb944412bb6f8f8f07af$pga$, 'permanent', identity.id, NULL, NULL, NULL, now()
26
+ SELECT $pga$123e4567-e89b-12d3-a456-000000000001$pga$, $pga$936a185caaa266bb9cbe981e9e05cb78cd732b0b3280eb944412bb6f8f8f07af$pga$, 'permanent', identity.id, NULL, NULL, NULL, now()
22
27
  FROM identity
23
28
  ;
24
29
 
25
30
  WITH identity AS (
26
31
  INSERT INTO identity(id, parent_id, roles, description, created_at)
27
32
  VALUES (
28
- public."uuid_generate_v4"(),
33
+ $pga$123e4567-e89b-12d3-a456-000000000002$pga$,
29
34
  NULL,
30
35
  '["super_admin"]'::JSONB
31
36
  || (CASE WHEN NULL IS NOT NULL THEN '["person"]'::JSONB ELSE '[]'::JSONB END),
@@ -35,14 +40,14 @@ test('generate sql with root token and login token', async () => {
35
40
  ),
36
41
  person AS (
37
42
  INSERT INTO person(id, email, password_hash, identity_id)
38
- SELECT public."uuid_generate_v4"(), NULL, NULL, identity.id
43
+ SELECT $pga$123e4567-e89b-12d3-a456-000000000003$pga$, NULL, NULL, identity.id
39
44
  FROM identity
40
45
  WHERE NULL IS NOT NULL
41
46
  RETURNING id
42
47
  ),
43
48
  api_key AS (
44
49
  INSERT INTO api_key (id, token_hash, type, identity_id, disabled_at, expires_at, expiration, created_at)
45
- SELECT public."uuid_generate_v4"(), $pga$c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2$pga$, 'permanent', identity.id, NULL, NULL, NULL, now()
50
+ SELECT $pga$123e4567-e89b-12d3-a456-000000000004$pga$, $pga$c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2$pga$, 'permanent', identity.id, NULL, NULL, NULL, now()
46
51
  FROM identity WHERE $pga$c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2$pga$ IS NOT NULL
47
52
  RETURNING id
48
53
  )
@@ -60,6 +65,9 @@ test('generate sql with both root user and token', async () => {
60
65
  rootTokenHash: 'd96f62ea0f2f543aa7822a58114f75dbcc05bdf970fb15eb55eea836a1439e43',
61
66
  rootEmail: 'john@doe.com',
62
67
  }),
68
+ providers: {
69
+ uuid: testUuid,
70
+ },
63
71
  })
64
72
  assert.equal(
65
73
  builder.getSql(),
@@ -67,7 +75,7 @@ test('generate sql with both root user and token', async () => {
67
75
  WITH identity AS (
68
76
  INSERT INTO identity(id, parent_id, roles, description, created_at)
69
77
  VALUES (
70
- public."uuid_generate_v4"(),
78
+ $pga$123e4567-e89b-12d3-a456-000000000005$pga$,
71
79
  NULL,
72
80
  '["super_admin"]'::JSONB
73
81
  || (CASE WHEN $pga$john@doe.com$pga$ IS NOT NULL THEN '["person"]'::JSONB ELSE '[]'::JSONB END),
@@ -77,14 +85,14 @@ test('generate sql with both root user and token', async () => {
77
85
  ),
78
86
  person AS (
79
87
  INSERT INTO person(id, email, password_hash, identity_id)
80
- SELECT public."uuid_generate_v4"(), $pga$john@doe.com$pga$, $pga$pwd-bcrypted$pga$, identity.id
88
+ SELECT $pga$123e4567-e89b-12d3-a456-000000000006$pga$, $pga$john@doe.com$pga$, $pga$pwd-bcrypted$pga$, identity.id
81
89
  FROM identity
82
90
  WHERE $pga$john@doe.com$pga$ IS NOT NULL
83
91
  RETURNING id
84
92
  ),
85
93
  api_key AS (
86
94
  INSERT INTO api_key (id, token_hash, type, identity_id, disabled_at, expires_at, expiration, created_at)
87
- SELECT public."uuid_generate_v4"(), $pga$d96f62ea0f2f543aa7822a58114f75dbcc05bdf970fb15eb55eea836a1439e43$pga$, 'permanent', identity.id, NULL, NULL, NULL, now()
95
+ SELECT $pga$123e4567-e89b-12d3-a456-000000000007$pga$, $pga$d96f62ea0f2f543aa7822a58114f75dbcc05bdf970fb15eb55eea836a1439e43$pga$, 'permanent', identity.id, NULL, NULL, NULL, now()
88
96
  FROM identity WHERE $pga$d96f62ea0f2f543aa7822a58114f75dbcc05bdf970fb15eb55eea836a1439e43$pga$ IS NOT NULL
89
97
  RETURNING id
90
98
  )
@@ -1,14 +1,14 @@
1
- import { IdentityProviderHandler, IDPClaim, IDPResponse, InitIDPAuthResult } from '../../src'
1
+ import { IdentityProviderHandler, IDPClaim, InitIDPAuthResult } from '../../src'
2
2
 
3
- export class IdPMock implements IdentityProviderHandler<any, any> {
4
- initAuth(configuration: any, redirectUrl: string): Promise<InitIDPAuthResult<any>> {
3
+ export class IdPMock implements IdentityProviderHandler<any> {
4
+ initAuth(configuration: any, data: unknown): Promise<InitIDPAuthResult> {
5
5
  return Promise.resolve({
6
6
  authUrl: 'http://localhost',
7
7
  sessionData: { foo: 'bar' },
8
8
  })
9
9
  }
10
10
 
11
- processResponse(configuration: any, redirectUrl: string, idpResponse: IDPResponse, sessionData: any): Promise<IDPClaim> {
11
+ processResponse(configuration: any, responseData: any): Promise<IDPClaim> {
12
12
  return Promise.resolve({
13
13
  externalIdentifier: configuration.externalIdentifier,
14
14
  email: configuration.email,
@@ -5,11 +5,7 @@
5
5
  "esModuleInterop": true
6
6
  },
7
7
  "references": [
8
- {
9
- "path": "../src"
10
- },
11
- {
12
- "path": "../../engine-api-tester/src"
13
- }
8
+ { "path": "../src" },
9
+ { "path": "../../engine-api-tester/src" }
14
10
  ]
15
11
  }
package/tsconfig.json CHANGED
@@ -2,11 +2,7 @@
2
2
  "files": [],
3
3
  "include": [],
4
4
  "references": [
5
- {
6
- "path": "./src"
7
- },
8
- {
9
- "path": "./tests"
10
- }
5
+ { "path": "./src" },
6
+ { "path": "./tests" }
11
7
  ]
12
8
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"2020-06-08-134000-tenant-credentials.test.d.ts","sourceRoot":"","sources":["../../../src/migrations/2020-06-08-134000-tenant-credentials.test.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"2020-06-08-134000-tenant-credentials.test.js","sourceRoot":"","sources":["../../../src/migrations/2020-06-08-134000-tenant-credentials.test.ts"],"names":[],"mappings":";;;;;AAAA,mHAA8D;AAC9D,wEAAuE;AACvE,mCAAqC;AAErC,IAAA,aAAI,EAAC,8CAA8C,EAAE,KAAK,IAAI,EAAE;IAC/D,MAAM,OAAO,GAAG,IAAA,4CAAsB,GAAE,CAAA;IACxC,MAAM,IAAA,+CAAS,EAAC,OAAO,EAAE;QACxB,cAAc,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;YAC5B,cAAc,EAAE,kEAAkE;YAClF,aAAa,EAAE,kEAAkE;SACjF,CAAC;KACF,CAAC,CAAA;IACF,eAAM,CAAC,KAAK,CACX,OAAO,CAAC,MAAM,EAAE,EAChB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCD,CACC,CAAA;AACF,CAAC,CAAC,CAAA;AAEF,IAAA,aAAI,EAAC,4CAA4C,EAAE,KAAK,IAAI,EAAE;IAC7D,MAAM,OAAO,GAAG,IAAA,4CAAsB,GAAE,CAAA;IACxC,MAAM,IAAA,+CAAS,EAAC,OAAO,EAAE;QACxB,cAAc,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;YAC5B,oBAAoB,EAAE,cAAc;YACpC,aAAa,EAAE,kEAAkE;YACjF,SAAS,EAAE,cAAc;SACzB,CAAC;KACF,CAAC,CAAA;IACF,eAAM,CAAC,KAAK,CACX,OAAO,CAAC,MAAM,EAAE,EAChB;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BD,CACC,CAAA;AACF,CAAC,CAAC,CAAA"}
@@ -1,25 +0,0 @@
1
- import * as Typesafe from '@contember/typesafe';
2
- import { ResponseType } from 'openid-client';
3
- import { IdentityProviderHandler, IDPClaim, IDPResponse, InitIDPAuthResult } from './IdentityProviderHandler';
4
- export declare type OIDCConfiguration = ReturnType<typeof OIDCConfigurationSchema>;
5
- export interface SessionData {
6
- nonce: string;
7
- state: string;
8
- }
9
- declare const OIDCConfigurationSchema: Typesafe.Type<{
10
- readonly url: string;
11
- readonly clientId: string;
12
- readonly clientSecret: string;
13
- } & {
14
- readonly responseType?: ResponseType | undefined;
15
- readonly claims?: string | undefined;
16
- }>;
17
- export declare class OIDCProvider implements IdentityProviderHandler<SessionData, OIDCConfiguration> {
18
- private issuerCache;
19
- initAuth(configuration: OIDCConfiguration, redirectUrl: string): Promise<InitIDPAuthResult<SessionData>>;
20
- processResponse(configuration: OIDCConfiguration, redirectUrl: string, idpResponse: IDPResponse, sessionData: SessionData): Promise<IDPClaim>;
21
- validateConfiguration(config: unknown): OIDCConfiguration;
22
- private createOIDCClient;
23
- }
24
- export {};
25
- //# sourceMappingURL=OIDCProvider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OIDCProvider.d.ts","sourceRoot":"","sources":["../../../../../src/model/service/idp/OIDCProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAA8C,YAAY,EAAE,MAAM,eAAe,CAAA;AAExF,OAAO,EAAE,uBAAuB,EAAE,QAAQ,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAQ7G,oBAAY,iBAAiB,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAE1E,MAAM,WAAW,WAAW;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACb;AAED,QAAA,MAAM,uBAAuB;;;;;;;EAU5B,CAAA;AAED,qBAAa,YAAa,YAAW,uBAAuB,CAAC,WAAW,EAAE,iBAAiB,CAAC;IAC3F,OAAO,CAAC,WAAW,CAAqC;IAE3C,QAAQ,CACpB,aAAa,EAAE,iBAAiB,EAChC,WAAW,EAAE,MAAM,GACjB,OAAO,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;IAgB7B,eAAe,CAC3B,aAAa,EAAE,iBAAiB,EAChC,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW,GACtB,OAAO,CAAC,QAAQ,CAAC;IAsBb,qBAAqB,CAAC,MAAM,EAAE,OAAO,GAAG,iBAAiB;YAWlD,gBAAgB;CAS9B"}
@@ -1,108 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.OIDCProvider = void 0;
27
- const Typesafe = __importStar(require("@contember/typesafe"));
28
- const openid_client_1 = require("openid-client");
29
- const IDPResponseError_1 = require("./IDPResponseError");
30
- const IDPValidationError_1 = require("./IDPValidationError");
31
- const InvalidIDPConfigurationError_1 = require("./InvalidIDPConfigurationError");
32
- openid_client_1.custom.setHttpOptionsDefaults({
33
- timeout: 5000,
34
- });
35
- const OIDCConfigurationSchema = Typesafe.intersection(Typesafe.object({
36
- url: Typesafe.string,
37
- clientId: Typesafe.string,
38
- clientSecret: Typesafe.string,
39
- }), Typesafe.partial({
40
- responseType: Typesafe.enumeration('code', 'code id_token', 'code id_token token', 'code token', 'id_token', 'id_token token', 'none'),
41
- claims: Typesafe.string,
42
- }));
43
- class OIDCProvider {
44
- constructor() {
45
- this.issuerCache = {};
46
- }
47
- async initAuth(configuration, redirectUrl) {
48
- var _a;
49
- const client = await this.createOIDCClient(configuration);
50
- const nonce = openid_client_1.generators.nonce();
51
- const state = openid_client_1.generators.state();
52
- const url = client.authorizationUrl({
53
- redirect_uri: redirectUrl,
54
- scope: (_a = configuration.claims) !== null && _a !== void 0 ? _a : 'openid email',
55
- nonce,
56
- state,
57
- });
58
- return {
59
- authUrl: url,
60
- sessionData: { nonce, state },
61
- };
62
- }
63
- async processResponse(configuration, redirectUrl, idpResponse, sessionData) {
64
- const client = await this.createOIDCClient(configuration);
65
- const params = client.callbackParams(idpResponse.url);
66
- try {
67
- const result = await client.callback(redirectUrl, params, sessionData);
68
- const claims = result.claims();
69
- return {
70
- externalIdentifier: claims.sub,
71
- email: claims.email,
72
- name: claims.name,
73
- };
74
- }
75
- catch (e) {
76
- if (e instanceof openid_client_1.errors.RPError) {
77
- throw new IDPValidationError_1.IDPValidationError(e.message);
78
- }
79
- if (e instanceof openid_client_1.errors.OPError) {
80
- throw new IDPResponseError_1.IDPResponseError(e.message);
81
- }
82
- throw e;
83
- }
84
- }
85
- validateConfiguration(config) {
86
- try {
87
- return OIDCConfigurationSchema(config);
88
- }
89
- catch (e) {
90
- if (e instanceof Typesafe.ParseError) {
91
- throw new InvalidIDPConfigurationError_1.InvalidIDPConfigurationError(e.message);
92
- }
93
- throw e;
94
- }
95
- }
96
- async createOIDCClient(configuration) {
97
- var _a;
98
- var _b, _c;
99
- (_a = (_b = this.issuerCache)[_c = configuration.url]) !== null && _a !== void 0 ? _a : (_b[_c] = await openid_client_1.Issuer.discover(configuration.url));
100
- return new this.issuerCache[configuration.url].Client({
101
- client_id: configuration.clientId,
102
- client_secret: configuration.clientSecret,
103
- response_types: [configuration.responseType || 'code'],
104
- });
105
- }
106
- }
107
- exports.OIDCProvider = OIDCProvider;
108
- //# sourceMappingURL=OIDCProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OIDCProvider.js","sourceRoot":"","sources":["../../../../../src/model/service/idp/OIDCProvider.ts"],"names":[],"mappings":"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"}
@@ -1,2 +0,0 @@
1
- ALTER TABLE "api_key"
2
- ADD COLUMN expiration INT DEFAULT NULL;
@@ -1,2 +0,0 @@
1
- CREATE UNIQUE INDEX "project_slug"
2
- ON "project"("slug");
@@ -1,2 +0,0 @@
1
- DROP TABLE project_member;
2
- DROP TABLE project_member_variable;
@@ -1,9 +0,0 @@
1
- ALTER TABLE identity
2
- ADD COLUMN description TEXT,
3
- ADD COLUMN created_at TIMESTAMP;
4
-
5
- UPDATE identity
6
- SET created_at = NOW();
7
-
8
- ALTER TABLE identity
9
- ALTER created_at SET NOT NULL;
@@ -1,3 +0,0 @@
1
- DROP INDEX "person_identity_id";
2
-
3
- CREATE INDEX "person_identity_id" ON "person" USING btree ("identity_id");
@@ -1 +0,0 @@
1
- CREATE UNIQUE INDEX api_key_token_hash ON api_key(token_hash)
@@ -1,3 +0,0 @@
1
- ALTER TABLE "person"
2
- ADD COLUMN otp_uri TEXT DEFAULT NULL,
3
- ADD COLUMN otp_activated_at TIMESTAMP DEFAULT NULL
@@ -1,3 +0,0 @@
1
- ALTER TABLE project
2
- ADD COLUMN config JSONB NOT NULL DEFAULT '{}'::JSONB,
3
- add column updated_at timestamptz not null DEFAULT now();
@@ -1 +0,0 @@
1
- CREATE INDEX project_alias ON project USING gin ((config -> 'alias'));
@@ -1 +0,0 @@
1
- ALTER TABLE person ALTER COLUMN password_hash DROP NOT NULL;
@@ -1,2 +0,0 @@
1
- ALTER TABLE person
2
- ADD UNIQUE (identity_id);
@@ -1,2 +0,0 @@
1
- ALTER TABLE identity_provider
2
- ADD COLUMN auto_sign_up BOOLEAN NOT NULL DEFAULT FALSE;
@@ -1,3 +0,0 @@
1
- ALTER TABLE person
2
- ALTER email DROP NOT NULL,
3
- ADD CONSTRAINT email_unique UNIQUE (email);
@@ -1,4 +0,0 @@
1
- ALTER TABLE person
2
- ADD name TEXT;
3
- UPDATE person
4
- SET name = SPLIT_PART(email, '@', 1);
@@ -1,100 +0,0 @@
1
- import * as Typesafe from '@contember/typesafe'
2
- import { Client, custom, errors, generators, Issuer, ResponseType } from 'openid-client'
3
- import { IDPResponseError } from './IDPResponseError'
4
- import { IdentityProviderHandler, IDPClaim, IDPResponse, InitIDPAuthResult } from './IdentityProviderHandler'
5
- import { IDPValidationError } from './IDPValidationError'
6
- import { InvalidIDPConfigurationError } from './InvalidIDPConfigurationError'
7
-
8
- custom.setHttpOptionsDefaults({
9
- timeout: 5000,
10
- })
11
-
12
- export type OIDCConfiguration = ReturnType<typeof OIDCConfigurationSchema>
13
-
14
- export interface SessionData {
15
- nonce: string
16
- state: string
17
- }
18
-
19
- const OIDCConfigurationSchema = Typesafe.intersection(
20
- Typesafe.object({
21
- url: Typesafe.string,
22
- clientId: Typesafe.string,
23
- clientSecret: Typesafe.string,
24
- }),
25
- Typesafe.partial({
26
- responseType: Typesafe.enumeration<ResponseType>('code', 'code id_token', 'code id_token token', 'code token', 'id_token', 'id_token token', 'none'),
27
- claims: Typesafe.string,
28
- }),
29
- )
30
-
31
- export class OIDCProvider implements IdentityProviderHandler<SessionData, OIDCConfiguration> {
32
- private issuerCache: Record<string, Issuer<Client>> = {}
33
-
34
- public async initAuth(
35
- configuration: OIDCConfiguration,
36
- redirectUrl: string,
37
- ): Promise<InitIDPAuthResult<SessionData>> {
38
- const client = await this.createOIDCClient(configuration)
39
- const nonce = generators.nonce()
40
- const state = generators.state()
41
- const url = client.authorizationUrl({
42
- redirect_uri: redirectUrl,
43
- scope: configuration.claims ?? 'openid email',
44
- nonce,
45
- state,
46
- })
47
- return {
48
- authUrl: url,
49
- sessionData: { nonce, state },
50
- }
51
- }
52
-
53
- public async processResponse(
54
- configuration: OIDCConfiguration,
55
- redirectUrl: string,
56
- idpResponse: IDPResponse,
57
- sessionData: SessionData,
58
- ): Promise<IDPClaim> {
59
- const client = await this.createOIDCClient(configuration)
60
- const params = client.callbackParams(idpResponse.url)
61
- try {
62
- const result = await client.callback(redirectUrl, params, sessionData)
63
- const claims = result.claims()
64
- return {
65
- externalIdentifier: claims.sub,
66
- email: claims.email,
67
- name: claims.name,
68
- }
69
- } catch (e) {
70
- if (e instanceof errors.RPError) {
71
- throw new IDPValidationError(e.message)
72
- }
73
- if (e instanceof errors.OPError) {
74
- throw new IDPResponseError(e.message)
75
- }
76
- throw e
77
- }
78
- }
79
-
80
- public validateConfiguration(config: unknown): OIDCConfiguration {
81
- try {
82
- return OIDCConfigurationSchema(config)
83
- } catch (e) {
84
- if (e instanceof Typesafe.ParseError) {
85
- throw new InvalidIDPConfigurationError(e.message)
86
- }
87
- throw e
88
- }
89
- }
90
-
91
- private async createOIDCClient(configuration: OIDCConfiguration): Promise<Client> {
92
- this.issuerCache[configuration.url] ??= await Issuer.discover(configuration.url)
93
-
94
- return new this.issuerCache[configuration.url].Client({
95
- client_id: configuration.clientId,
96
- client_secret: configuration.clientSecret,
97
- response_types: [configuration.responseType || 'code'],
98
- })
99
- }
100
- }