@contember/react-client-tenant 2.0.0-alpha.9 → 2.0.0-beta.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 (401) hide show
  1. package/dist/development/index.cjs +24 -0
  2. package/dist/development/index.cjs.map +1 -1
  3. package/dist/development/index.js +24 -0
  4. package/dist/development/index.js.map +1 -1
  5. package/dist/development/src/components/IdentityProvider.cjs.map +1 -1
  6. package/dist/development/src/components/IdentityProvider.js.map +1 -1
  7. package/dist/development/src/components/IdentityState.cjs.map +1 -1
  8. package/dist/development/src/components/IdentityState.js.map +1 -1
  9. package/dist/development/src/components/forms/ChangeMyPasswordForm.cjs.map +1 -1
  10. package/dist/development/src/components/forms/ChangeMyPasswordForm.js.map +1 -1
  11. package/dist/development/src/components/forms/CreateApiKeyForm.cjs.map +1 -1
  12. package/dist/development/src/components/forms/CreateApiKeyForm.js.map +1 -1
  13. package/dist/development/src/components/forms/CreateSessionTokenForm.cjs.map +1 -1
  14. package/dist/development/src/components/forms/CreateSessionTokenForm.js.map +1 -1
  15. package/dist/development/src/components/forms/InviteForm.cjs.map +1 -1
  16. package/dist/development/src/components/forms/InviteForm.js.map +1 -1
  17. package/dist/development/src/components/forms/LoginForm.cjs +1 -1
  18. package/dist/development/src/components/forms/LoginForm.cjs.map +1 -1
  19. package/dist/development/src/components/forms/LoginForm.js +1 -1
  20. package/dist/development/src/components/forms/LoginForm.js.map +1 -1
  21. package/dist/development/src/components/forms/OtpConfirmForm.cjs.map +1 -1
  22. package/dist/development/src/components/forms/OtpConfirmForm.js.map +1 -1
  23. package/dist/development/src/components/forms/OtpPrepareForm.cjs.map +1 -1
  24. package/dist/development/src/components/forms/OtpPrepareForm.js.map +1 -1
  25. package/dist/development/src/components/forms/PasswordResetForm.cjs +2 -1
  26. package/dist/development/src/components/forms/PasswordResetForm.cjs.map +1 -1
  27. package/dist/development/src/components/forms/PasswordResetForm.js +2 -1
  28. package/dist/development/src/components/forms/PasswordResetForm.js.map +1 -1
  29. package/dist/development/src/components/forms/PasswordResetRequestForm.cjs.map +1 -1
  30. package/dist/development/src/components/forms/PasswordResetRequestForm.js.map +1 -1
  31. package/dist/development/src/components/forms/PasswordlessSignInForm.cjs +79 -0
  32. package/dist/development/src/components/forms/PasswordlessSignInForm.cjs.map +1 -0
  33. package/dist/development/src/components/forms/PasswordlessSignInForm.js +79 -0
  34. package/dist/development/src/components/forms/PasswordlessSignInForm.js.map +1 -0
  35. package/dist/development/src/components/forms/PasswordlessSignInInitForm.cjs +54 -0
  36. package/dist/development/src/components/forms/PasswordlessSignInInitForm.cjs.map +1 -0
  37. package/dist/development/src/components/forms/PasswordlessSignInInitForm.js +54 -0
  38. package/dist/development/src/components/forms/PasswordlessSignInInitForm.js.map +1 -0
  39. package/dist/development/src/components/forms/TenantForm.cjs.map +1 -1
  40. package/dist/development/src/components/forms/TenantForm.js.map +1 -1
  41. package/dist/development/src/components/forms/UpdateProjectMemberForm.cjs.map +1 -1
  42. package/dist/development/src/components/forms/UpdateProjectMemberForm.js.map +1 -1
  43. package/dist/development/src/components/idp/IDP.cjs.map +1 -1
  44. package/dist/development/src/components/idp/IDP.js.map +1 -1
  45. package/dist/development/src/components/idp/IDPInitTrigger.cjs.map +1 -1
  46. package/dist/development/src/components/idp/IDPInitTrigger.js.map +1 -1
  47. package/dist/development/src/components/idp/IDPState.cjs.map +1 -1
  48. package/dist/development/src/components/idp/IDPState.js.map +1 -1
  49. package/dist/development/src/components/triggers/DisableOtpTrigger.cjs.map +1 -1
  50. package/dist/development/src/components/triggers/DisableOtpTrigger.js.map +1 -1
  51. package/dist/development/src/components/triggers/LogoutTrigger.cjs.map +1 -1
  52. package/dist/development/src/components/triggers/LogoutTrigger.js.map +1 -1
  53. package/dist/development/src/components/triggers/RemoveProjectMemberTrigger.cjs.map +1 -1
  54. package/dist/development/src/components/triggers/RemoveProjectMemberTrigger.js.map +1 -1
  55. package/dist/development/src/components/triggers/TenantActionTrigger.cjs.map +1 -1
  56. package/dist/development/src/components/triggers/TenantActionTrigger.js.map +1 -1
  57. package/dist/development/src/consts.cjs +5 -0
  58. package/dist/development/src/consts.cjs.map +1 -0
  59. package/dist/development/src/consts.js +5 -0
  60. package/dist/development/src/consts.js.map +1 -0
  61. package/dist/development/src/contexts.cjs.map +1 -1
  62. package/dist/development/src/hooks/mutations/apiKey/useCreateSessionTokenMutation.cjs +1 -1
  63. package/dist/development/src/hooks/mutations/apiKey/useCreateSessionTokenMutation.cjs.map +1 -1
  64. package/dist/development/src/hooks/mutations/apiKey/useCreateSessionTokenMutation.js +1 -1
  65. package/dist/development/src/hooks/mutations/apiKey/useCreateSessionTokenMutation.js.map +1 -1
  66. package/dist/development/src/hooks/mutations/auth/useSignInMutation.cjs +1 -1
  67. package/dist/development/src/hooks/mutations/auth/useSignInMutation.cjs.map +1 -1
  68. package/dist/development/src/hooks/mutations/auth/useSignInMutation.js +1 -1
  69. package/dist/development/src/hooks/mutations/auth/useSignInMutation.js.map +1 -1
  70. package/dist/development/src/hooks/mutations/idp/useInitSignInIDPMutation.cjs +1 -1
  71. package/dist/development/src/hooks/mutations/idp/useInitSignInIDPMutation.cjs.map +1 -1
  72. package/dist/development/src/hooks/mutations/idp/useInitSignInIDPMutation.js +1 -1
  73. package/dist/development/src/hooks/mutations/idp/useInitSignInIDPMutation.js.map +1 -1
  74. package/dist/development/src/hooks/mutations/idp/useSignInIdpMutation.cjs +1 -1
  75. package/dist/development/src/hooks/mutations/idp/useSignInIdpMutation.cjs.map +1 -1
  76. package/dist/development/src/hooks/mutations/idp/useSignInIdpMutation.js +1 -1
  77. package/dist/development/src/hooks/mutations/idp/useSignInIdpMutation.js.map +1 -1
  78. package/dist/development/src/hooks/mutations/invite/useInviteMutation.cjs +1 -1
  79. package/dist/development/src/hooks/mutations/invite/useInviteMutation.cjs.map +1 -1
  80. package/dist/development/src/hooks/mutations/invite/useInviteMutation.js +1 -1
  81. package/dist/development/src/hooks/mutations/invite/useInviteMutation.js.map +1 -1
  82. package/dist/development/src/hooks/mutations/passwordReset/useCreateResetPasswordRequestMutation.cjs.map +1 -1
  83. package/dist/development/src/hooks/mutations/passwordReset/useResetPasswordMutation.cjs.map +1 -1
  84. package/dist/development/src/hooks/mutations/passwordless/useActivatePasswordlessOtpMutation.cjs +31 -0
  85. package/dist/development/src/hooks/mutations/passwordless/useActivatePasswordlessOtpMutation.cjs.map +1 -0
  86. package/dist/development/src/hooks/mutations/passwordless/useActivatePasswordlessOtpMutation.js +14 -0
  87. package/dist/development/src/hooks/mutations/passwordless/useActivatePasswordlessOtpMutation.js.map +1 -0
  88. package/dist/development/src/hooks/mutations/passwordless/useDisableMyPasswordlessMutation.cjs +28 -0
  89. package/dist/development/src/hooks/mutations/passwordless/useDisableMyPasswordlessMutation.cjs.map +1 -0
  90. package/dist/development/src/hooks/mutations/passwordless/useDisableMyPasswordlessMutation.js +11 -0
  91. package/dist/development/src/hooks/mutations/passwordless/useDisableMyPasswordlessMutation.js.map +1 -0
  92. package/dist/development/src/hooks/mutations/passwordless/useEnableMyPasswordlessMutation.cjs +28 -0
  93. package/dist/development/src/hooks/mutations/passwordless/useEnableMyPasswordlessMutation.cjs.map +1 -0
  94. package/dist/development/src/hooks/mutations/passwordless/useEnableMyPasswordlessMutation.js +11 -0
  95. package/dist/development/src/hooks/mutations/passwordless/useEnableMyPasswordlessMutation.js.map +1 -0
  96. package/dist/development/src/hooks/mutations/passwordless/useInitSignInPasswordlessMutation.cjs +32 -0
  97. package/dist/development/src/hooks/mutations/passwordless/useInitSignInPasswordlessMutation.cjs.map +1 -0
  98. package/dist/development/src/hooks/mutations/passwordless/useInitSignInPasswordlessMutation.js +15 -0
  99. package/dist/development/src/hooks/mutations/passwordless/useInitSignInPasswordlessMutation.js.map +1 -0
  100. package/dist/development/src/hooks/mutations/passwordless/useSignInPasswordlessMutation.cjs +32 -0
  101. package/dist/development/src/hooks/mutations/passwordless/useSignInPasswordlessMutation.cjs.map +1 -0
  102. package/dist/development/src/hooks/mutations/passwordless/useSignInPasswordlessMutation.js +15 -0
  103. package/dist/development/src/hooks/mutations/passwordless/useSignInPasswordlessMutation.js.map +1 -0
  104. package/dist/development/src/hooks/mutations/profile/useChangeMyProfile.cjs +29 -0
  105. package/dist/development/src/hooks/mutations/profile/useChangeMyProfile.cjs.map +1 -0
  106. package/dist/development/src/hooks/mutations/profile/useChangeMyProfile.js +12 -0
  107. package/dist/development/src/hooks/mutations/profile/useChangeMyProfile.js.map +1 -0
  108. package/dist/development/src/hooks/mutations/profile/useChangeProfile.cjs +29 -0
  109. package/dist/development/src/hooks/mutations/profile/useChangeProfile.cjs.map +1 -0
  110. package/dist/development/src/hooks/mutations/profile/useChangeProfile.js +12 -0
  111. package/dist/development/src/hooks/mutations/profile/useChangeProfile.js.map +1 -0
  112. package/dist/development/src/hooks/queries/useMeQuery.cjs +1 -1
  113. package/dist/development/src/hooks/queries/useMeQuery.cjs.map +1 -1
  114. package/dist/development/src/hooks/queries/useMeQuery.js +1 -1
  115. package/dist/development/src/hooks/queries/useMeQuery.js.map +1 -1
  116. package/dist/development/src/hooks/queries/useProjectMembersQuery.cjs +1 -1
  117. package/dist/development/src/hooks/queries/useProjectMembersQuery.cjs.map +1 -1
  118. package/dist/development/src/hooks/queries/useProjectMembersQuery.js +1 -1
  119. package/dist/development/src/hooks/queries/useProjectMembersQuery.js.map +1 -1
  120. package/dist/development/src/hooks/queries/useProjectMembershipsQuery.cjs.map +1 -1
  121. package/dist/development/src/hooks/queries/useProjectMembershipsQuery.js.map +1 -1
  122. package/dist/development/src/hooks/queries/useProjectRolesDefinitionQuery.cjs.map +1 -1
  123. package/dist/development/src/hooks/queries/useProjectRolesDefinitionQuery.js.map +1 -1
  124. package/dist/development/src/hooks/useFetchIdentity.cjs +2 -2
  125. package/dist/development/src/hooks/useFetchIdentity.cjs.map +1 -1
  126. package/dist/development/src/hooks/useFetchIdentity.js +3 -3
  127. package/dist/development/src/hooks/useFetchIdentity.js.map +1 -1
  128. package/dist/development/src/hooks/useLogout.cjs.map +1 -1
  129. package/dist/development/src/hooks/useLogout.js.map +1 -1
  130. package/dist/development/src/hooks/usePasswordlessOtpActivator.cjs +53 -0
  131. package/dist/development/src/hooks/usePasswordlessOtpActivator.cjs.map +1 -0
  132. package/dist/development/src/hooks/usePasswordlessOtpActivator.js +53 -0
  133. package/dist/development/src/hooks/usePasswordlessOtpActivator.js.map +1 -0
  134. package/dist/development/src/hooks/useTenantApi.cjs.map +1 -1
  135. package/dist/development/src/hooks/useTenantApi.js.map +1 -1
  136. package/dist/development/src/hooks/useTenantMutation.cjs.map +1 -1
  137. package/dist/development/src/hooks/useTenantMutation.js.map +1 -1
  138. package/dist/development/src/hooks/useTenantQueryLoader.cjs.map +1 -1
  139. package/dist/development/src/hooks/useTenantQueryLoader.js.map +1 -1
  140. package/dist/development/src/internal/hooks/useHandleIDPResponse.cjs +1 -1
  141. package/dist/development/src/internal/hooks/useHandleIDPResponse.cjs.map +1 -1
  142. package/dist/development/src/internal/hooks/useHandleIDPResponse.js +1 -1
  143. package/dist/development/src/internal/hooks/useHandleIDPResponse.js.map +1 -1
  144. package/dist/development/src/internal/hooks/useIDPAutoInit.cjs.map +1 -1
  145. package/dist/development/src/internal/hooks/useIDPAutoInit.js.map +1 -1
  146. package/dist/development/src/internal/hooks/useIDPStateStore.cjs.map +1 -1
  147. package/dist/development/src/internal/hooks/useIDPStateStore.js.map +1 -1
  148. package/dist/development/src/internal/hooks/useInitIDPRedirect.cjs.map +1 -1
  149. package/dist/development/src/internal/hooks/useInitIDPRedirect.js.map +1 -1
  150. package/dist/development/src/internal/hooks/useLogoutInternal.cjs.map +1 -1
  151. package/dist/development/src/internal/hooks/useLogoutInternal.js.map +1 -1
  152. package/dist/development/src/internal/hooks/useRedirectToBacklink.cjs.map +1 -1
  153. package/dist/development/src/internal/hooks/useRedirectToBacklink.js.map +1 -1
  154. package/dist/development/src/internal/utils/hashing.cjs +8 -0
  155. package/dist/development/src/internal/utils/hashing.cjs.map +1 -0
  156. package/dist/development/src/internal/utils/hashing.js +8 -0
  157. package/dist/development/src/internal/utils/hashing.js.map +1 -0
  158. package/dist/development/src/internal/utils/randomInt.cjs +29 -0
  159. package/dist/development/src/internal/utils/randomInt.cjs.map +1 -0
  160. package/dist/development/src/internal/utils/randomInt.js +29 -0
  161. package/dist/development/src/internal/utils/randomInt.js.map +1 -0
  162. package/dist/production/index.cjs +24 -0
  163. package/dist/production/index.cjs.map +1 -1
  164. package/dist/production/index.js +24 -0
  165. package/dist/production/index.js.map +1 -1
  166. package/dist/production/src/components/IdentityProvider.cjs.map +1 -1
  167. package/dist/production/src/components/IdentityProvider.js.map +1 -1
  168. package/dist/production/src/components/IdentityState.cjs.map +1 -1
  169. package/dist/production/src/components/IdentityState.js.map +1 -1
  170. package/dist/production/src/components/forms/ChangeMyPasswordForm.cjs.map +1 -1
  171. package/dist/production/src/components/forms/ChangeMyPasswordForm.js.map +1 -1
  172. package/dist/production/src/components/forms/CreateApiKeyForm.cjs.map +1 -1
  173. package/dist/production/src/components/forms/CreateApiKeyForm.js.map +1 -1
  174. package/dist/production/src/components/forms/CreateSessionTokenForm.cjs.map +1 -1
  175. package/dist/production/src/components/forms/CreateSessionTokenForm.js.map +1 -1
  176. package/dist/production/src/components/forms/InviteForm.cjs.map +1 -1
  177. package/dist/production/src/components/forms/InviteForm.js.map +1 -1
  178. package/dist/production/src/components/forms/LoginForm.cjs +1 -1
  179. package/dist/production/src/components/forms/LoginForm.cjs.map +1 -1
  180. package/dist/production/src/components/forms/LoginForm.js +1 -1
  181. package/dist/production/src/components/forms/LoginForm.js.map +1 -1
  182. package/dist/production/src/components/forms/OtpConfirmForm.cjs.map +1 -1
  183. package/dist/production/src/components/forms/OtpConfirmForm.js.map +1 -1
  184. package/dist/production/src/components/forms/OtpPrepareForm.cjs.map +1 -1
  185. package/dist/production/src/components/forms/OtpPrepareForm.js.map +1 -1
  186. package/dist/production/src/components/forms/PasswordResetForm.cjs +2 -1
  187. package/dist/production/src/components/forms/PasswordResetForm.cjs.map +1 -1
  188. package/dist/production/src/components/forms/PasswordResetForm.js +2 -1
  189. package/dist/production/src/components/forms/PasswordResetForm.js.map +1 -1
  190. package/dist/production/src/components/forms/PasswordResetRequestForm.cjs.map +1 -1
  191. package/dist/production/src/components/forms/PasswordResetRequestForm.js.map +1 -1
  192. package/dist/production/src/components/forms/PasswordlessSignInForm.cjs +71 -0
  193. package/dist/production/src/components/forms/PasswordlessSignInForm.cjs.map +1 -0
  194. package/dist/production/src/components/forms/PasswordlessSignInForm.js +71 -0
  195. package/dist/production/src/components/forms/PasswordlessSignInForm.js.map +1 -0
  196. package/dist/production/src/components/forms/PasswordlessSignInInitForm.cjs +46 -0
  197. package/dist/production/src/components/forms/PasswordlessSignInInitForm.cjs.map +1 -0
  198. package/dist/production/src/components/forms/PasswordlessSignInInitForm.js +46 -0
  199. package/dist/production/src/components/forms/PasswordlessSignInInitForm.js.map +1 -0
  200. package/dist/production/src/components/forms/TenantForm.cjs.map +1 -1
  201. package/dist/production/src/components/forms/TenantForm.js.map +1 -1
  202. package/dist/production/src/components/forms/UpdateProjectMemberForm.cjs.map +1 -1
  203. package/dist/production/src/components/forms/UpdateProjectMemberForm.js.map +1 -1
  204. package/dist/production/src/components/idp/IDP.cjs.map +1 -1
  205. package/dist/production/src/components/idp/IDP.js.map +1 -1
  206. package/dist/production/src/components/idp/IDPInitTrigger.cjs.map +1 -1
  207. package/dist/production/src/components/idp/IDPInitTrigger.js.map +1 -1
  208. package/dist/production/src/components/idp/IDPState.cjs.map +1 -1
  209. package/dist/production/src/components/idp/IDPState.js.map +1 -1
  210. package/dist/production/src/components/triggers/DisableOtpTrigger.cjs.map +1 -1
  211. package/dist/production/src/components/triggers/DisableOtpTrigger.js.map +1 -1
  212. package/dist/production/src/components/triggers/LogoutTrigger.cjs.map +1 -1
  213. package/dist/production/src/components/triggers/LogoutTrigger.js.map +1 -1
  214. package/dist/production/src/components/triggers/RemoveProjectMemberTrigger.cjs.map +1 -1
  215. package/dist/production/src/components/triggers/RemoveProjectMemberTrigger.js.map +1 -1
  216. package/dist/production/src/components/triggers/TenantActionTrigger.cjs.map +1 -1
  217. package/dist/production/src/components/triggers/TenantActionTrigger.js.map +1 -1
  218. package/dist/production/src/consts.cjs +5 -0
  219. package/dist/production/src/consts.cjs.map +1 -0
  220. package/dist/production/src/consts.js +5 -0
  221. package/dist/production/src/consts.js.map +1 -0
  222. package/dist/production/src/contexts.cjs.map +1 -1
  223. package/dist/production/src/hooks/mutations/apiKey/useCreateSessionTokenMutation.cjs +1 -1
  224. package/dist/production/src/hooks/mutations/apiKey/useCreateSessionTokenMutation.cjs.map +1 -1
  225. package/dist/production/src/hooks/mutations/apiKey/useCreateSessionTokenMutation.js +1 -1
  226. package/dist/production/src/hooks/mutations/apiKey/useCreateSessionTokenMutation.js.map +1 -1
  227. package/dist/production/src/hooks/mutations/auth/useSignInMutation.cjs +1 -1
  228. package/dist/production/src/hooks/mutations/auth/useSignInMutation.cjs.map +1 -1
  229. package/dist/production/src/hooks/mutations/auth/useSignInMutation.js +1 -1
  230. package/dist/production/src/hooks/mutations/auth/useSignInMutation.js.map +1 -1
  231. package/dist/production/src/hooks/mutations/idp/useInitSignInIDPMutation.cjs +1 -1
  232. package/dist/production/src/hooks/mutations/idp/useInitSignInIDPMutation.cjs.map +1 -1
  233. package/dist/production/src/hooks/mutations/idp/useInitSignInIDPMutation.js +1 -1
  234. package/dist/production/src/hooks/mutations/idp/useInitSignInIDPMutation.js.map +1 -1
  235. package/dist/production/src/hooks/mutations/idp/useSignInIdpMutation.cjs +1 -1
  236. package/dist/production/src/hooks/mutations/idp/useSignInIdpMutation.cjs.map +1 -1
  237. package/dist/production/src/hooks/mutations/idp/useSignInIdpMutation.js +1 -1
  238. package/dist/production/src/hooks/mutations/idp/useSignInIdpMutation.js.map +1 -1
  239. package/dist/production/src/hooks/mutations/invite/useInviteMutation.cjs +1 -1
  240. package/dist/production/src/hooks/mutations/invite/useInviteMutation.cjs.map +1 -1
  241. package/dist/production/src/hooks/mutations/invite/useInviteMutation.js +1 -1
  242. package/dist/production/src/hooks/mutations/invite/useInviteMutation.js.map +1 -1
  243. package/dist/production/src/hooks/mutations/passwordReset/useCreateResetPasswordRequestMutation.cjs.map +1 -1
  244. package/dist/production/src/hooks/mutations/passwordReset/useResetPasswordMutation.cjs.map +1 -1
  245. package/dist/production/src/hooks/mutations/passwordless/useActivatePasswordlessOtpMutation.cjs +31 -0
  246. package/dist/production/src/hooks/mutations/passwordless/useActivatePasswordlessOtpMutation.cjs.map +1 -0
  247. package/dist/production/src/hooks/mutations/passwordless/useActivatePasswordlessOtpMutation.js +14 -0
  248. package/dist/production/src/hooks/mutations/passwordless/useActivatePasswordlessOtpMutation.js.map +1 -0
  249. package/dist/production/src/hooks/mutations/passwordless/useDisableMyPasswordlessMutation.cjs +28 -0
  250. package/dist/production/src/hooks/mutations/passwordless/useDisableMyPasswordlessMutation.cjs.map +1 -0
  251. package/dist/production/src/hooks/mutations/passwordless/useDisableMyPasswordlessMutation.js +11 -0
  252. package/dist/production/src/hooks/mutations/passwordless/useDisableMyPasswordlessMutation.js.map +1 -0
  253. package/dist/production/src/hooks/mutations/passwordless/useEnableMyPasswordlessMutation.cjs +28 -0
  254. package/dist/production/src/hooks/mutations/passwordless/useEnableMyPasswordlessMutation.cjs.map +1 -0
  255. package/dist/production/src/hooks/mutations/passwordless/useEnableMyPasswordlessMutation.js +11 -0
  256. package/dist/production/src/hooks/mutations/passwordless/useEnableMyPasswordlessMutation.js.map +1 -0
  257. package/dist/production/src/hooks/mutations/passwordless/useInitSignInPasswordlessMutation.cjs +32 -0
  258. package/dist/production/src/hooks/mutations/passwordless/useInitSignInPasswordlessMutation.cjs.map +1 -0
  259. package/dist/production/src/hooks/mutations/passwordless/useInitSignInPasswordlessMutation.js +15 -0
  260. package/dist/production/src/hooks/mutations/passwordless/useInitSignInPasswordlessMutation.js.map +1 -0
  261. package/dist/production/src/hooks/mutations/passwordless/useSignInPasswordlessMutation.cjs +32 -0
  262. package/dist/production/src/hooks/mutations/passwordless/useSignInPasswordlessMutation.cjs.map +1 -0
  263. package/dist/production/src/hooks/mutations/passwordless/useSignInPasswordlessMutation.js +15 -0
  264. package/dist/production/src/hooks/mutations/passwordless/useSignInPasswordlessMutation.js.map +1 -0
  265. package/dist/production/src/hooks/mutations/profile/useChangeMyProfile.cjs +29 -0
  266. package/dist/production/src/hooks/mutations/profile/useChangeMyProfile.cjs.map +1 -0
  267. package/dist/production/src/hooks/mutations/profile/useChangeMyProfile.js +12 -0
  268. package/dist/production/src/hooks/mutations/profile/useChangeMyProfile.js.map +1 -0
  269. package/dist/production/src/hooks/mutations/profile/useChangeProfile.cjs +29 -0
  270. package/dist/production/src/hooks/mutations/profile/useChangeProfile.cjs.map +1 -0
  271. package/dist/production/src/hooks/mutations/profile/useChangeProfile.js +12 -0
  272. package/dist/production/src/hooks/mutations/profile/useChangeProfile.js.map +1 -0
  273. package/dist/production/src/hooks/queries/useMeQuery.cjs +1 -1
  274. package/dist/production/src/hooks/queries/useMeQuery.cjs.map +1 -1
  275. package/dist/production/src/hooks/queries/useMeQuery.js +1 -1
  276. package/dist/production/src/hooks/queries/useMeQuery.js.map +1 -1
  277. package/dist/production/src/hooks/queries/useProjectMembersQuery.cjs +1 -1
  278. package/dist/production/src/hooks/queries/useProjectMembersQuery.cjs.map +1 -1
  279. package/dist/production/src/hooks/queries/useProjectMembersQuery.js +1 -1
  280. package/dist/production/src/hooks/queries/useProjectMembersQuery.js.map +1 -1
  281. package/dist/production/src/hooks/queries/useProjectMembershipsQuery.cjs.map +1 -1
  282. package/dist/production/src/hooks/queries/useProjectMembershipsQuery.js.map +1 -1
  283. package/dist/production/src/hooks/queries/useProjectRolesDefinitionQuery.cjs.map +1 -1
  284. package/dist/production/src/hooks/queries/useProjectRolesDefinitionQuery.js.map +1 -1
  285. package/dist/production/src/hooks/useFetchIdentity.cjs +2 -2
  286. package/dist/production/src/hooks/useFetchIdentity.cjs.map +1 -1
  287. package/dist/production/src/hooks/useFetchIdentity.js +3 -3
  288. package/dist/production/src/hooks/useFetchIdentity.js.map +1 -1
  289. package/dist/production/src/hooks/useLogout.cjs.map +1 -1
  290. package/dist/production/src/hooks/useLogout.js.map +1 -1
  291. package/dist/production/src/hooks/usePasswordlessOtpActivator.cjs +53 -0
  292. package/dist/production/src/hooks/usePasswordlessOtpActivator.cjs.map +1 -0
  293. package/dist/production/src/hooks/usePasswordlessOtpActivator.js +53 -0
  294. package/dist/production/src/hooks/usePasswordlessOtpActivator.js.map +1 -0
  295. package/dist/production/src/hooks/useTenantApi.cjs.map +1 -1
  296. package/dist/production/src/hooks/useTenantApi.js.map +1 -1
  297. package/dist/production/src/hooks/useTenantMutation.cjs.map +1 -1
  298. package/dist/production/src/hooks/useTenantMutation.js.map +1 -1
  299. package/dist/production/src/hooks/useTenantQueryLoader.cjs.map +1 -1
  300. package/dist/production/src/hooks/useTenantQueryLoader.js.map +1 -1
  301. package/dist/production/src/internal/hooks/useHandleIDPResponse.cjs +1 -1
  302. package/dist/production/src/internal/hooks/useHandleIDPResponse.cjs.map +1 -1
  303. package/dist/production/src/internal/hooks/useHandleIDPResponse.js +1 -1
  304. package/dist/production/src/internal/hooks/useHandleIDPResponse.js.map +1 -1
  305. package/dist/production/src/internal/hooks/useIDPAutoInit.cjs.map +1 -1
  306. package/dist/production/src/internal/hooks/useIDPAutoInit.js.map +1 -1
  307. package/dist/production/src/internal/hooks/useIDPStateStore.cjs.map +1 -1
  308. package/dist/production/src/internal/hooks/useIDPStateStore.js.map +1 -1
  309. package/dist/production/src/internal/hooks/useInitIDPRedirect.cjs.map +1 -1
  310. package/dist/production/src/internal/hooks/useInitIDPRedirect.js.map +1 -1
  311. package/dist/production/src/internal/hooks/useLogoutInternal.cjs.map +1 -1
  312. package/dist/production/src/internal/hooks/useLogoutInternal.js.map +1 -1
  313. package/dist/production/src/internal/hooks/useRedirectToBacklink.cjs.map +1 -1
  314. package/dist/production/src/internal/hooks/useRedirectToBacklink.js.map +1 -1
  315. package/dist/production/src/internal/utils/hashing.cjs +8 -0
  316. package/dist/production/src/internal/utils/hashing.cjs.map +1 -0
  317. package/dist/production/src/internal/utils/hashing.js +8 -0
  318. package/dist/production/src/internal/utils/hashing.js.map +1 -0
  319. package/dist/production/src/internal/utils/randomInt.cjs +29 -0
  320. package/dist/production/src/internal/utils/randomInt.cjs.map +1 -0
  321. package/dist/production/src/internal/utils/randomInt.js +29 -0
  322. package/dist/production/src/internal/utils/randomInt.js.map +1 -0
  323. package/dist/types/components/forms/PasswordlessSignInForm.d.ts +22 -0
  324. package/dist/types/components/forms/PasswordlessSignInForm.d.ts.map +1 -0
  325. package/dist/types/components/forms/PasswordlessSignInInitForm.d.ts +20 -0
  326. package/dist/types/components/forms/PasswordlessSignInInitForm.d.ts.map +1 -0
  327. package/dist/types/components/forms/index.d.ts +2 -0
  328. package/dist/types/components/forms/index.d.ts.map +1 -1
  329. package/dist/types/consts.d.ts +2 -0
  330. package/dist/types/consts.d.ts.map +1 -0
  331. package/dist/types/hooks/index.d.ts +1 -0
  332. package/dist/types/hooks/index.d.ts.map +1 -1
  333. package/dist/types/hooks/mutations/apiKey/useCreateSessionTokenMutation.d.ts +0 -6
  334. package/dist/types/hooks/mutations/apiKey/useCreateSessionTokenMutation.d.ts.map +1 -1
  335. package/dist/types/hooks/mutations/auth/useSignInMutation.d.ts +0 -6
  336. package/dist/types/hooks/mutations/auth/useSignInMutation.d.ts.map +1 -1
  337. package/dist/types/hooks/mutations/idp/useSignInIdpMutation.d.ts +6 -6
  338. package/dist/types/hooks/mutations/idp/useSignInIdpMutation.d.ts.map +1 -1
  339. package/dist/types/hooks/mutations/index.d.ts +2 -0
  340. package/dist/types/hooks/mutations/index.d.ts.map +1 -1
  341. package/dist/types/hooks/mutations/invite/useInviteMutation.d.ts +0 -6
  342. package/dist/types/hooks/mutations/invite/useInviteMutation.d.ts.map +1 -1
  343. package/dist/types/hooks/mutations/passwordless/index.d.ts +6 -0
  344. package/dist/types/hooks/mutations/passwordless/index.d.ts.map +1 -0
  345. package/dist/types/hooks/mutations/passwordless/useActivatePasswordlessOtpMutation.d.ts +8 -0
  346. package/dist/types/hooks/mutations/passwordless/useActivatePasswordlessOtpMutation.d.ts.map +1 -0
  347. package/dist/types/hooks/mutations/passwordless/useDisableMyPasswordlessMutation.d.ts +3 -0
  348. package/dist/types/hooks/mutations/passwordless/useDisableMyPasswordlessMutation.d.ts.map +1 -0
  349. package/dist/types/hooks/mutations/passwordless/useEnableMyPasswordlessMutation.d.ts +3 -0
  350. package/dist/types/hooks/mutations/passwordless/useEnableMyPasswordlessMutation.d.ts.map +1 -0
  351. package/dist/types/hooks/mutations/passwordless/useInitSignInPasswordlessMutation.d.ts +19 -0
  352. package/dist/types/hooks/mutations/passwordless/useInitSignInPasswordlessMutation.d.ts.map +1 -0
  353. package/dist/types/hooks/mutations/passwordless/useSignInPasswordlessMutation.d.ts +34 -0
  354. package/dist/types/hooks/mutations/passwordless/useSignInPasswordlessMutation.d.ts.map +1 -0
  355. package/dist/types/hooks/mutations/profile/index.d.ts +3 -0
  356. package/dist/types/hooks/mutations/profile/index.d.ts.map +1 -0
  357. package/dist/types/hooks/mutations/profile/useChangeMyProfile.d.ts +21 -0
  358. package/dist/types/hooks/mutations/profile/useChangeMyProfile.d.ts.map +1 -0
  359. package/dist/types/hooks/mutations/profile/useChangeProfile.d.ts +23 -0
  360. package/dist/types/hooks/mutations/profile/useChangeProfile.d.ts.map +1 -0
  361. package/dist/types/hooks/usePasswordlessOtpActivator.d.ts +19 -0
  362. package/dist/types/hooks/usePasswordlessOtpActivator.d.ts.map +1 -0
  363. package/dist/types/hooks/useTenantMutation.d.ts.map +1 -1
  364. package/dist/types/internal/utils/hashing.d.ts +2 -0
  365. package/dist/types/internal/utils/hashing.d.ts.map +1 -0
  366. package/dist/types/internal/utils/randomInt.d.ts +3 -0
  367. package/dist/types/internal/utils/randomInt.d.ts.map +1 -0
  368. package/dist/types/tsconfig.tsbuildinfo +1 -1
  369. package/dist/types/types/Identity.d.ts +1 -0
  370. package/dist/types/types/Identity.d.ts.map +1 -1
  371. package/package.json +8 -7
  372. package/src/components/forms/LoginForm.tsx +1 -1
  373. package/src/components/forms/PasswordResetForm.tsx +1 -0
  374. package/src/components/forms/PasswordlessSignInForm.tsx +102 -0
  375. package/src/components/forms/PasswordlessSignInInitForm.tsx +68 -0
  376. package/src/components/forms/index.ts +2 -0
  377. package/src/consts.ts +1 -0
  378. package/src/hooks/index.ts +1 -0
  379. package/src/hooks/mutations/apiKey/useCreateSessionTokenMutation.tsx +1 -1
  380. package/src/hooks/mutations/auth/useSignInMutation.ts +1 -1
  381. package/src/hooks/mutations/idp/useInitSignInIDPMutation.ts +1 -1
  382. package/src/hooks/mutations/idp/useSignInIdpMutation.ts +1 -1
  383. package/src/hooks/mutations/index.ts +2 -0
  384. package/src/hooks/mutations/invite/useInviteMutation.tsx +1 -1
  385. package/src/hooks/mutations/passwordless/index.ts +5 -0
  386. package/src/hooks/mutations/passwordless/useActivatePasswordlessOtpMutation.ts +19 -0
  387. package/src/hooks/mutations/passwordless/useDisableMyPasswordlessMutation.ts +14 -0
  388. package/src/hooks/mutations/passwordless/useEnableMyPasswordlessMutation.ts +14 -0
  389. package/src/hooks/mutations/passwordless/useInitSignInPasswordlessMutation.ts +22 -0
  390. package/src/hooks/mutations/passwordless/useSignInPasswordlessMutation.ts +24 -0
  391. package/src/hooks/mutations/profile/index.ts +2 -0
  392. package/src/hooks/mutations/profile/useChangeMyProfile.ts +13 -0
  393. package/src/hooks/mutations/profile/useChangeProfile.ts +13 -0
  394. package/src/hooks/queries/useMeQuery.ts +1 -1
  395. package/src/hooks/queries/useProjectMembersQuery.ts +1 -1
  396. package/src/hooks/useFetchIdentity.ts +3 -3
  397. package/src/hooks/usePasswordlessOtpActivator.ts +66 -0
  398. package/src/internal/hooks/useHandleIDPResponse.ts +1 -1
  399. package/src/internal/utils/hashing.ts +4 -0
  400. package/src/internal/utils/randomInt.ts +30 -0
  401. package/src/types/Identity.ts +1 -0
@@ -1,5 +1,6 @@
1
1
  export interface Identity {
2
2
  readonly id: string;
3
+ readonly roles: readonly string[];
3
4
  readonly person?: Person;
4
5
  readonly projects: IdentityProject[];
5
6
  readonly permissions: {
@@ -1 +1 @@
1
- {"version":3,"file":"Identity.d.ts","sourceRoot":"","sources":["../../../src/types/Identity.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,QAAQ,EAAE,eAAe,EAAE,CAAA;IACpC,QAAQ,CAAC,WAAW,EAAE;QACrB,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAA;KAClC,CAAA;CACD;AAED,MAAM,WAAW,MAAM;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAA;CAC5B;AAED,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CACjC"}
1
+ {"version":3,"file":"Identity.d.ts","sourceRoot":"","sources":["../../../src/types/Identity.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,QAAQ,EAAE,eAAe,EAAE,CAAA;IACpC,QAAQ,CAAC,WAAW,EAAE;QACrB,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAA;KAClC,CAAA;CACD;AAED,MAAM,WAAW,MAAM;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAA;CAC5B;AAED,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CACjC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@contember/react-client-tenant",
3
3
  "license": "Apache-2.0",
4
- "version": "2.0.0-alpha.9",
4
+ "version": "2.0.0-beta.2",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "main": "./dist/production/index.js",
@@ -11,6 +11,7 @@
11
11
  "types": "./dist/types/index.d.ts",
12
12
  "development": "./dist/development/index.js",
13
13
  "production": "./dist/production/index.js",
14
+ "typescript": "./src/index.ts",
14
15
  "default": "./dist/production/index.js"
15
16
  },
16
17
  "require": {
@@ -33,11 +34,11 @@
33
34
  "directory": "packages/react-client-tenant"
34
35
  },
35
36
  "dependencies": {
36
- "@contember/graphql-client-tenant": "2.0.0-alpha.9",
37
- "@contember/react-client": "2.0.0-alpha.9",
38
- "@contember/react-utils": "2.0.0-alpha.9",
39
- "@radix-ui/primitive": "^1.0.1",
40
- "@radix-ui/react-slot": "^1.0.2",
37
+ "@contember/graphql-client-tenant": "2.0.0-beta.2",
38
+ "@contember/react-client": "2.0.0-beta.2",
39
+ "@contember/react-utils": "2.0.0-beta.2",
40
+ "@radix-ui/primitive": "^1.1.0",
41
+ "@radix-ui/react-slot": "^1.1.0",
41
42
  "graphql-ts-client-api": "^3.1.17"
42
43
  },
43
44
  "peerDependencies": {
@@ -48,4 +49,4 @@
48
49
  "react": "^18.3.1",
49
50
  "react-dom": "^18.3.1"
50
51
  }
51
- }
52
+ }
@@ -41,7 +41,7 @@ const headers = {
41
41
  'X-Contember-Token-Path': 'data.mutation.result.token',
42
42
  }
43
43
 
44
- const DEFAULT_LOGIN_EXPIRATION = 14 * 24 * 3600 // 14 days
44
+ const DEFAULT_LOGIN_EXPIRATION = 14 * 24 * 60 // 14 days
45
45
 
46
46
  export const LoginForm = ({ children, expiration = DEFAULT_LOGIN_EXPIRATION, onSuccess }: LoginFormProps) => {
47
47
  const login = useSignInMutation({ headers })
@@ -77,4 +77,5 @@ const errorToField: Record<TenantApi.ResetPasswordErrorCode, keyof PasswordReset
77
77
  TOKEN_EXPIRED: 'token',
78
78
  TOKEN_NOT_FOUND: 'token',
79
79
  TOKEN_USED: 'token',
80
+ TOKEN_INVALID: 'token',
80
81
  }
@@ -0,0 +1,102 @@
1
+ import { ReactElement, useCallback, useMemo } from 'react'
2
+ import * as TenantApi from '@contember/graphql-client-tenant'
3
+ import { TenantForm } from './TenantForm'
4
+ import { FormContextValue, FormError, FormState } from '../../types/forms'
5
+ import { useForm } from '../../contexts'
6
+ import { SignInPasswordlessMutationResult, useSignInPasswordlessMutation } from '../../hooks'
7
+ import { useRedirectToBacklinkCallback } from '../../internal/hooks/useRedirectToBacklink'
8
+ import { useSetSessionToken } from '@contember/react-client'
9
+
10
+ export type PasswordlessSignInFormValues = {
11
+ token: string
12
+ otpToken: string
13
+ }
14
+
15
+ export type PasswordlessSignInFormErrorCode =
16
+ | TenantApi.SignInPasswordlessErrorCode
17
+ | 'FIELD_REQUIRED'
18
+ | 'INVALID_VALUE'
19
+ | 'UNKNOWN_ERROR'
20
+
21
+ export type PasswordlessSignInFormState =
22
+ | FormState
23
+ | 'otp-required'
24
+
25
+ export type PasswordlessSignInFormError = FormError<PasswordlessSignInFormValues, PasswordlessSignInFormErrorCode>
26
+
27
+ export type PasswordlessSignInFormContextValue = FormContextValue<PasswordlessSignInFormValues, PasswordlessSignInFormErrorCode, PasswordlessSignInFormState>
28
+
29
+
30
+ export interface PasswordlessSignInFormProps {
31
+ requestId: string
32
+ validationType: TenantApi.PasswordlessValidationType
33
+ token?: string
34
+ expiration?: number
35
+ children: ReactElement
36
+ onSuccess?: () => void
37
+ }
38
+
39
+ export const usePasswordlessSignInForm = useForm as () => PasswordlessSignInFormContextValue
40
+
41
+ const headers = {
42
+ 'X-Contember-Token-Path': 'data.mutation.result.token',
43
+ }
44
+ const DEFAULT_LOGIN_EXPIRATION = 14 * 24 * 60 // 14 days
45
+
46
+ export const PasswordlessSignInForm = ({ children, onSuccess, requestId, validationType, token, expiration = DEFAULT_LOGIN_EXPIRATION }: PasswordlessSignInFormProps) => {
47
+
48
+ const signIn = useSignInPasswordlessMutation({ headers })
49
+ const redirectToBacklink = useRedirectToBacklinkCallback()
50
+ const setSessionToken = useSetSessionToken()
51
+ return (
52
+ <TenantForm<PasswordlessSignInFormContextValue, SignInPasswordlessMutationResult>
53
+ onSuccess={args => {
54
+ onSuccess?.()
55
+ setSessionToken(args.result.token)
56
+ redirectToBacklink()
57
+ }}
58
+ errorMapping={errorToField}
59
+ initialValues={useMemo(() => ({
60
+ token: token ?? '',
61
+ otpToken: '',
62
+ }), [token])}
63
+ validate={({ values, state }) => {
64
+ if (!values.token) {
65
+ return [{ code: 'FIELD_REQUIRED', field: 'token' }]
66
+ }
67
+ if (!values.otpToken && state === 'otp-required') {
68
+ return [{ code: 'FIELD_REQUIRED', field: 'otpToken' }]
69
+ } else if (values.otpToken && !values.otpToken.match(/^\d{6}$/)) {
70
+ return [{ code: 'INVALID_VALUE', field: 'otpToken' }]
71
+ }
72
+ return []
73
+ }}
74
+ execute={useCallback(async ({ values }) => {
75
+ const result = await signIn({
76
+ requestId,
77
+ expiration,
78
+ token: values.token,
79
+ mfaOtp: values.otpToken || undefined,
80
+ validationType,
81
+ })
82
+ if (!result.ok && result.error === 'OTP_REQUIRED') {
83
+ return { ...result, state: 'otp-required' }
84
+ }
85
+
86
+ return result
87
+ }, [expiration, requestId, signIn, validationType])}
88
+ >
89
+ {children}
90
+ </TenantForm>
91
+ )
92
+
93
+ }
94
+ const errorToField: Record<TenantApi.SignInPasswordlessErrorCode, keyof PasswordlessSignInFormValues | undefined> = {
95
+ PERSON_DISABLED: undefined,
96
+ TOKEN_EXPIRED: 'token',
97
+ TOKEN_NOT_FOUND: 'token',
98
+ TOKEN_USED: 'token',
99
+ TOKEN_INVALID: 'token',
100
+ INVALID_OTP_TOKEN: 'otpToken',
101
+ OTP_REQUIRED: undefined,
102
+ }
@@ -0,0 +1,68 @@
1
+ import { ReactElement, useCallback, useMemo } from 'react'
2
+ import * as TenantApi from '@contember/graphql-client-tenant'
3
+ import { TenantForm } from './TenantForm'
4
+ import { FormContextValue, FormError, FormState } from '../../types/forms'
5
+ import { useForm } from '../../contexts'
6
+ import { InitSignInPasswordlessMutationResult, useInitSignInPasswordlessMutation } from '../../hooks'
7
+ import { PASSWORDLESS_REQUEST_STORAGE_KEY } from '../../consts'
8
+
9
+ export type PasswordlessSignInInitFormValues = {
10
+ email: string
11
+ }
12
+
13
+ export type PasswordlessSignInInitFormErrorCode =
14
+ | TenantApi.InitSignInPasswordlessErrorCode
15
+ | 'FIELD_REQUIRED'
16
+ | 'INVALID_VALUE'
17
+ | 'UNKNOWN_ERROR'
18
+
19
+ export type PasswordlessSignInInitFormState = FormState
20
+
21
+ export type PasswordlessSignInInitFormError = FormError<PasswordlessSignInInitFormValues, PasswordlessSignInInitFormErrorCode>
22
+
23
+ export type PasswordlessSignInInitFormContextValue = FormContextValue<PasswordlessSignInInitFormValues, PasswordlessSignInInitFormErrorCode>
24
+
25
+
26
+ export interface PasswordlessSignInInitFormProps {
27
+ children: ReactElement
28
+ onSuccess?: (args: { result: InitSignInPasswordlessMutationResult }) => void
29
+ }
30
+
31
+ export const usePasswordlessSignInInitForm = useForm as () => PasswordlessSignInInitFormContextValue
32
+
33
+ export const PasswordlessSignInInitForm = ({ children, onSuccess }: PasswordlessSignInInitFormProps) => {
34
+
35
+ const initSignIn = useInitSignInPasswordlessMutation()
36
+ return (
37
+ <TenantForm<PasswordlessSignInInitFormContextValue, InitSignInPasswordlessMutationResult>
38
+ onSuccess={res => {
39
+ localStorage.setItem(PASSWORDLESS_REQUEST_STORAGE_KEY, res.result.requestId)
40
+ onSuccess?.(res)
41
+ }}
42
+ errorMapping={errorToField}
43
+ initialValues={useMemo(() => ({
44
+ email: '',
45
+ }), [])}
46
+ validate={({ values }) => {
47
+ if (!values.email) {
48
+ return [{ code: 'FIELD_REQUIRED', field: 'email' }]
49
+ } else if (!values.email.match(/^.+@.+$/)) {
50
+ return [{ code: 'INVALID_VALUE', field: 'email' }]
51
+ }
52
+ return []
53
+ }}
54
+ execute={useCallback(async ({ values }) => {
55
+ return await initSignIn({
56
+ email: values.email,
57
+ })
58
+ }, [initSignIn])}
59
+ >
60
+ {children}
61
+ </TenantForm>
62
+ )
63
+
64
+ }
65
+ const errorToField: Record<TenantApi.InitSignInPasswordlessErrorCode, keyof PasswordlessSignInInitFormValues | undefined> = {
66
+ PERSON_NOT_FOUND: 'email',
67
+ PASSWORDLESS_DISABLED: undefined,
68
+ }
@@ -5,6 +5,8 @@ export * from './InviteForm'
5
5
  export * from './LoginForm'
6
6
  export * from './PasswordResetForm'
7
7
  export * from './PasswordResetRequestForm'
8
+ export * from './PasswordlessSignInForm'
9
+ export * from './PasswordlessSignInInitForm'
8
10
  export * from './OtpPrepareForm'
9
11
  export * from './OtpConfirmForm'
10
12
  export * from './UpdateProjectMemberForm'
package/src/consts.ts ADDED
@@ -0,0 +1 @@
1
+ export const PASSWORDLESS_REQUEST_STORAGE_KEY = 'passwordless_request'
@@ -5,3 +5,4 @@ export * from './useLogout'
5
5
  export * from './useTenantApi'
6
6
  export * from './useTenantQueryLoader'
7
7
  export * from './useTenantMutation'
8
+ export * from './usePasswordlessOtpActivator'
@@ -2,7 +2,7 @@ import * as TenantApi from '@contember/graphql-client-tenant'
2
2
  import { ModelType } from 'graphql-ts-client-api'
3
3
  import { createTenantMutation } from '../../useTenantMutation'
4
4
 
5
- const createSessionTokenMutationResult = TenantApi.createSessionTokenResult$.token.person(TenantApi.person$$)
5
+ const createSessionTokenMutationResult = TenantApi.createSessionTokenResult$.token.person(TenantApi.person$.id.email.name)
6
6
 
7
7
  export type CreateSessionTokenMutationResult = ModelType<typeof createSessionTokenMutationResult>
8
8
 
@@ -3,7 +3,7 @@ import { LoginToken } from '../../useTenantApi'
3
3
  import { ModelType } from 'graphql-ts-client-api'
4
4
  import { createTenantMutation } from '../../useTenantMutation'
5
5
 
6
- const signInResultFragment = TenantApi.signInResult$$.person(TenantApi.person$$)
6
+ const signInResultFragment = TenantApi.signInResult$$.person(TenantApi.person$.id.email.name)
7
7
 
8
8
  export type SignInMutationResult = ModelType<typeof signInResultFragment>
9
9
 
@@ -20,7 +20,7 @@ const InitSignInIDPMutation = TenantApi
20
20
  TenantApi
21
21
  .initSignInIDPResponse$$
22
22
  .error(TenantApi.initSignInIDPError$$)
23
- .result(TenantApi.initSignInIDPResult$$),
23
+ .result(TenantApi.initSignInIDPResult$.authUrl.sessionData),
24
24
  options => options.alias('mutation'),
25
25
  )
26
26
 
@@ -3,7 +3,7 @@ import { LoginToken } from '../../useTenantApi'
3
3
  import { createTenantMutation } from '../../useTenantMutation'
4
4
  import { ModelType } from 'graphql-ts-client-api'
5
5
 
6
- const signInIdpFragment = TenantApi.signInIDPResult$$.person(TenantApi.person$$)
6
+ const signInIdpFragment = TenantApi.signInIDPResult$$.person(TenantApi.person$.id.email.name)
7
7
 
8
8
  export type SignInIDPMutationResult = ModelType<typeof signInIdpFragment>
9
9
 
@@ -3,5 +3,7 @@ export * from './auth'
3
3
  export * from './invite'
4
4
  export * from './idp'
5
5
  export * from './memberships'
6
+ export * from './passwordless'
6
7
  export * from './otp'
7
8
  export * from './passwordReset'
9
+ export * from './profile'
@@ -3,7 +3,7 @@ import { ModelType } from 'graphql-ts-client-api'
3
3
  import { createTenantMutation } from '../../useTenantMutation'
4
4
 
5
5
  const inviteMutationResult = TenantApi.inviteResult$$
6
- .person(TenantApi.person$$.identity(TenantApi.identity$$))
6
+ .person(TenantApi.person$.id.email.name.identity(TenantApi.identity$$))
7
7
 
8
8
  export type InviteMutationResult = ModelType<typeof inviteMutationResult>
9
9
 
@@ -0,0 +1,5 @@
1
+ export * from './useActivatePasswordlessOtpMutation'
2
+ export * from './useDisableMyPasswordlessMutation'
3
+ export * from './useEnableMyPasswordlessMutation'
4
+ export * from './useSignInPasswordlessMutation'
5
+ export * from './useInitSignInPasswordlessMutation'
@@ -0,0 +1,19 @@
1
+ import * as TenantApi from '@contember/graphql-client-tenant'
2
+ import { LoginToken } from '../../useTenantApi'
3
+ import { createTenantMutation } from '../../useTenantMutation'
4
+
5
+
6
+ const ActivatePasswordlessOtpMutation = TenantApi
7
+ .mutation$
8
+ .activatePasswordlessOtp(
9
+ TenantApi
10
+ .activatePasswordlessOtpResponse$$
11
+ .error(TenantApi.activatePasswordlessOtpError$$),
12
+ options => options.alias('mutation'),
13
+ )
14
+
15
+ export const useActivatePasswordlessOtpMutation = createTenantMutation(ActivatePasswordlessOtpMutation, {
16
+ apiToken: LoginToken,
17
+ })
18
+
19
+ export type ActivatePasswordlessOtpMutationVariables = Parameters<ReturnType<typeof useActivatePasswordlessOtpMutation>>[0]
@@ -0,0 +1,14 @@
1
+ import * as TenantApi from '@contember/graphql-client-tenant'
2
+ import { createTenantMutation } from '../../useTenantMutation'
3
+
4
+
5
+ const DisableMyPasswordlessMutation = TenantApi
6
+ .mutation$
7
+ .disableMyPasswordless(
8
+ TenantApi
9
+ .toggleMyPasswordlessResponse$$
10
+ .error(TenantApi.toggleMyPasswordlessError$$),
11
+ options => options.alias('mutation'),
12
+ )
13
+
14
+ export const useDisableMyPasswordlessMutation = createTenantMutation(DisableMyPasswordlessMutation)
@@ -0,0 +1,14 @@
1
+ import * as TenantApi from '@contember/graphql-client-tenant'
2
+ import { createTenantMutation } from '../../useTenantMutation'
3
+
4
+
5
+ const EnableMyPasswordlessMutation = TenantApi
6
+ .mutation$
7
+ .enableMyPasswordless(
8
+ TenantApi
9
+ .toggleMyPasswordlessResponse$$
10
+ .error(TenantApi.toggleMyPasswordlessError$$),
11
+ options => options.alias('mutation'),
12
+ )
13
+
14
+ export const useEnableMyPasswordlessMutation = createTenantMutation(EnableMyPasswordlessMutation)
@@ -0,0 +1,22 @@
1
+ import * as TenantApi from '@contember/graphql-client-tenant'
2
+ import { LoginToken } from '../../useTenantApi'
3
+ import { createTenantMutation } from '../../useTenantMutation'
4
+ import { ModelType } from 'graphql-ts-client-api'
5
+
6
+ const InitSignInPasswordlessMutationResult = TenantApi.initSignInPasswordlessResult$$
7
+ export type InitSignInPasswordlessMutationResult = ModelType<typeof InitSignInPasswordlessMutationResult>
8
+ const InitSignInPasswordlessMutation = TenantApi
9
+ .mutation$
10
+ .initSignInPasswordless(
11
+ TenantApi
12
+ .initSignInPasswordlessResponse$$
13
+ .error(TenantApi.initSignInPasswordlessError$$)
14
+ .result(InitSignInPasswordlessMutationResult),
15
+ options => options.alias('mutation'),
16
+ )
17
+
18
+ export const useInitSignInPasswordlessMutation = createTenantMutation(InitSignInPasswordlessMutation, {
19
+ apiToken: LoginToken,
20
+ })
21
+
22
+ export type InitSignInPasswordlessMutationVariables = Parameters<ReturnType<typeof useInitSignInPasswordlessMutation>>[0]
@@ -0,0 +1,24 @@
1
+ import * as TenantApi from '@contember/graphql-client-tenant'
2
+ import { LoginToken } from '../../useTenantApi'
3
+ import { createTenantMutation } from '../../useTenantMutation'
4
+ import { ModelType } from 'graphql-ts-client-api'
5
+
6
+ const signInResultFragment = TenantApi.signInPasswordlessResult$$.person(TenantApi.person$.id.email.name)
7
+
8
+ export type SignInPasswordlessMutationResult = ModelType<typeof signInResultFragment>
9
+
10
+ const SignInPasswordlessMutation = TenantApi
11
+ .mutation$
12
+ .signInPasswordless(
13
+ TenantApi
14
+ .signInPasswordlessResponse$$
15
+ .error(TenantApi.signInPasswordlessError$$)
16
+ .result(signInResultFragment),
17
+ options => options.alias('mutation'),
18
+ )
19
+
20
+ export const useSignInPasswordlessMutation = createTenantMutation(SignInPasswordlessMutation, {
21
+ apiToken: LoginToken,
22
+ })
23
+
24
+ export type SignInPasswordlessMutationVariables = Parameters<ReturnType<typeof useSignInPasswordlessMutation>>[0]
@@ -0,0 +1,2 @@
1
+ export * from './useChangeProfile'
2
+ export * from './useChangeMyProfile'
@@ -0,0 +1,13 @@
1
+ import * as TenantApi from '@contember/graphql-client-tenant'
2
+ import { createTenantMutation } from '../../useTenantMutation'
3
+
4
+ export const changeMyProfile = TenantApi.mutation$
5
+ .changeMyProfile(
6
+ TenantApi
7
+ .changeMyProfileResponse$$
8
+ .error(TenantApi.changeMyProfileError$$),
9
+ options => options.alias('mutation'),
10
+ )
11
+
12
+ export const useChangeMyProfileMutation = createTenantMutation(changeMyProfile)
13
+ export type ChangeMyProfileMutationVariables = Parameters<ReturnType<typeof useChangeMyProfileMutation>>[0]
@@ -0,0 +1,13 @@
1
+ import * as TenantApi from '@contember/graphql-client-tenant'
2
+ import { createTenantMutation } from '../../useTenantMutation'
3
+
4
+ export const changeProfile = TenantApi.mutation$
5
+ .changeProfile(
6
+ TenantApi
7
+ .changeProfileResponse$$
8
+ .error(TenantApi.changeProfileError$$),
9
+ options => options.alias('mutation'),
10
+ )
11
+
12
+ export const useChangeProfileMutation = createTenantMutation(changeProfile)
13
+ export type ChangeProfileMutationVariables = Parameters<ReturnType<typeof useChangeProfileMutation>>[0]
@@ -5,7 +5,7 @@ import { useCallback } from 'react'
5
5
 
6
6
  const identityFragment = TenantApi
7
7
  .identity$$
8
- .person(TenantApi.person$$)
8
+ .person(TenantApi.person$.id.email.name.otpEnabled)
9
9
  .projects(TenantApi
10
10
  .identityProjectRelation$
11
11
  .project(TenantApi.project$$)
@@ -6,7 +6,7 @@ import { useCallback } from 'react'
6
6
  const projectIdentityRelationFragment = TenantApi
7
7
  .projectIdentityRelation$
8
8
  .identity(TenantApi.identity$$
9
- .person(TenantApi.person$$)
9
+ .person(TenantApi.person$.id.email.name.otpEnabled)
10
10
  .apiKey(TenantApi.apiKey$$)
11
11
  ,
12
12
  )
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useMemo, useState } from 'react'
2
2
  import { Identity, IdentityMethods, IdentityStateValue } from '../types'
3
- import { useSessionToken } from '@contember/react-client'
3
+ import { GraphQlClientError, useSessionToken } from '@contember/react-client'
4
4
  import { useLogoutInternal } from '../internal/hooks/useLogoutInternal'
5
5
  import { useMeQuery } from './queries'
6
6
 
@@ -25,6 +25,7 @@ export const useFetchIdentity = (): [{ state: IdentityStateValue; identity: Iden
25
25
  state: 'success',
26
26
  identity: {
27
27
  id: response.id,
28
+ roles: response.roles ?? [],
28
29
  person: person ?? undefined,
29
30
  projects: projects.map(it => ({
30
31
  name: it.project.name,
@@ -36,9 +37,8 @@ export const useFetchIdentity = (): [{ state: IdentityStateValue; identity: Iden
36
37
  })
37
38
  } catch (e) {
38
39
  console.error(e)
39
- if (typeof e === 'object' && e !== null && 'status' in e && (e as { status?: unknown }).status === 401) {
40
+ if (e instanceof GraphQlClientError && e.response?.status === 401) {
40
41
  logout({ noRedirect: true })
41
- setIdentityState({ state: 'cleared', identity: undefined })
42
42
  } else {
43
43
  setIdentityState({ state: 'failed', identity: undefined })
44
44
  }
@@ -0,0 +1,66 @@
1
+ import { useEffect, useState } from 'react'
2
+ import { PASSWORDLESS_REQUEST_STORAGE_KEY } from '../consts'
3
+ import { useActivatePasswordlessOtpMutation } from './mutations'
4
+ import { randomString } from '../internal/utils/randomInt'
5
+ import { calculateHash } from '../internal/utils/hashing'
6
+ import { ActivatePasswordlessOtpErrorCode } from '@contember/graphql-client-tenant'
7
+
8
+ const usePasswordlessParams = (): {localStorageRequestId: string | null; urlRequestId: string | null; urlToken: string | null} => {
9
+ const localStorageValue = localStorage.getItem(PASSWORDLESS_REQUEST_STORAGE_KEY) ?? null
10
+ const urlParams = new URLSearchParams(window.location.search)
11
+ const requestId = urlParams.get('request_id')
12
+ const token = urlParams.get('token')
13
+
14
+ return { localStorageRequestId: localStorageValue, urlRequestId: requestId, urlToken: token }
15
+ }
16
+
17
+ export type PasswordlessResponseHandlerState =
18
+ | { type: 'empty' }
19
+ | { type: 'otp_activating' }
20
+ | { type: 'otp_activated'; otp: string }
21
+ | { type: 'otp_activation_failed'; error: ActivatePasswordlessOtpErrorCode | 'UNKNOWN_ERROR'}
22
+ | { type: 'can_proceed_to_login' }
23
+
24
+ export const usePasswordlessOtpActivator = ({ otpLength = 6, otpChars = '0123456789ABCDEF' }: {
25
+ otpLength?: number
26
+ otpChars?: string
27
+ } = {}) => {
28
+ const { localStorageRequestId, urlRequestId, urlToken } = usePasswordlessParams()
29
+ const activateOtp = useActivatePasswordlessOtpMutation()
30
+
31
+ const [state, setState] = useState<PasswordlessResponseHandlerState>(() => {
32
+ if (urlRequestId && urlToken) {
33
+ if (localStorageRequestId !== urlRequestId) {
34
+ return { type: 'otp_activating' }
35
+ } else {
36
+ return { type: 'can_proceed_to_login' }
37
+ }
38
+ }
39
+ return { type: 'empty' }
40
+ })
41
+
42
+ useEffect(() => {
43
+ (async () => {
44
+ if (state.type === 'otp_activating') {
45
+ const otpCode = randomString(otpLength, otpChars)
46
+ try {
47
+ const result = await activateOtp({
48
+ requestId: urlRequestId!,
49
+ token: urlToken!,
50
+ otpHash: await calculateHash('SHA-256', otpCode),
51
+ })
52
+ if (!result.ok) {
53
+ setState({ type: 'otp_activation_failed', error: result.error })
54
+ } else {
55
+ setState({ type: 'otp_activated', otp: otpCode })
56
+ }
57
+ } catch (e) {
58
+ console.error(e)
59
+ setState({ type: 'otp_activation_failed', error: 'UNKNOWN_ERROR' })
60
+ }
61
+ }
62
+ })()
63
+ }, [activateOtp, localStorageRequestId, otpChars, otpLength, state.type, urlRequestId, urlToken])
64
+
65
+ return state
66
+ }
@@ -18,7 +18,7 @@ const headers = {
18
18
  'X-Contember-Token-Path': 'data.mutation.result.token',
19
19
  }
20
20
 
21
- const DEFAULT_LOGIN_EXPIRATION = 14 * 24 * 3600 // 14 days
21
+ const DEFAULT_LOGIN_EXPIRATION = 14 * 24 * 60 // 14 days
22
22
 
23
23
  export const useHandleIDPResponse = ({ onLogin, expiration = DEFAULT_LOGIN_EXPIRATION, setState, hasOauthResponse }: UseHandleIDPResponseProps): void => {
24
24
  const idpSignIn = useSignInIDPMutation({ headers })
@@ -0,0 +1,4 @@
1
+ export const calculateHash = async (algo: AlgorithmIdentifier, message: string): Promise<string> => {
2
+ const hashBuffer = await crypto.subtle.digest(algo, new TextEncoder().encode(message))
3
+ return Array.from(new Uint8Array(hashBuffer)).map(b => b.toString(16).padStart(2, '0')).join('')
4
+ }
@@ -0,0 +1,30 @@
1
+ export const randomInt = (min: number, max: number) => {
2
+ if (min >= max) {
3
+ throw new Error('The min value must be less than the max value.')
4
+ }
5
+
6
+ if (max > 0xFFFFFFFF) {
7
+ throw new Error('The max value exceeds the limit for this implementation.')
8
+ }
9
+
10
+ const range = max - min + 1
11
+ const maxValidValue = Math.floor(0xFFFFFFFF / range) * range
12
+ let randomInt
13
+
14
+ do {
15
+ const array = new Uint32Array(1)
16
+ window.crypto.getRandomValues(array)
17
+ randomInt = array[0]
18
+ } while (randomInt >= maxValidValue)
19
+
20
+ return min + (randomInt % range)
21
+ }
22
+
23
+
24
+ export const randomString = (length: number, charset: string): string => {
25
+ let result = ''
26
+ for (let i = 0; i < length; i++) {
27
+ result += charset[randomInt(0, charset.length - 1)]
28
+ }
29
+ return result
30
+ }
@@ -1,5 +1,6 @@
1
1
  export interface Identity {
2
2
  readonly id: string
3
+ readonly roles: readonly string[]
3
4
  readonly person?: Person
4
5
  readonly projects: IdentityProject[]
5
6
  readonly permissions: {