@rpcbase/client 0.227.0 → 0.231.0

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 (237) hide show
  1. package/package.json +11 -113
  2. package/src/apiClient/getServerApiClient.ts +131 -0
  3. package/src/apiClient/index.ts +86 -0
  4. package/src/index.ts +3 -0
  5. package/src/initClient.ts +32 -0
  6. package/src/types.ts +7 -0
  7. package/AppProvider/AnalyticsContainer.js +0 -56
  8. package/AppProvider/debug.js +0 -4
  9. package/AppProvider/index.tsx +0 -79
  10. package/access-control/ACLForm/components/GrantField/OpSelector.tsx +0 -129
  11. package/access-control/ACLForm/components/GrantField/ResourceSelector.tsx +0 -86
  12. package/access-control/ACLForm/components/GrantField/UsersSelector.tsx +0 -96
  13. package/access-control/ACLForm/components/GrantField/grant-field.scss +0 -26
  14. package/access-control/ACLForm/components/GrantField/icons/CheckMark.tsx +0 -16
  15. package/access-control/ACLForm/components/GrantField/icons/CollapseArrow.tsx +0 -14
  16. package/access-control/ACLForm/components/GrantField/icons/ExpandArrow.tsx +0 -14
  17. package/access-control/ACLForm/components/GrantField/index.tsx +0 -91
  18. package/access-control/ACLForm/components/GrantsList.tsx +0 -48
  19. package/access-control/ACLForm/components/RoleForm.tsx +0 -134
  20. package/access-control/ACLForm/components/RoleView.tsx +0 -115
  21. package/access-control/ACLForm/components/RolesList.tsx +0 -79
  22. package/access-control/ACLForm/components/constants.tsx +0 -1
  23. package/access-control/ACLForm/components/resolver.ts +0 -57
  24. package/access-control/ACLForm/components/role-form.scss +0 -19
  25. package/access-control/ACLForm/index.tsx +0 -48
  26. package/access-control/ACLModal/acl-modal.scss +0 -7
  27. package/access-control/ACLModal/index.tsx +0 -66
  28. package/access-control/PolicyEditor/TargetSelector/QueryBuilder.tsx +0 -48
  29. package/access-control/PolicyEditor/TargetSelector/index.tsx +0 -5
  30. package/access-control/PolicyEditor/TargetSelector/query-builder.scss +0 -9
  31. package/access-control/PolicyEditor/index.tsx +0 -165
  32. package/access-control/index.ts +0 -3
  33. package/apiClient.js +0 -15
  34. package/auth/authProps.js +0 -8
  35. package/auth/components/AccountsList/AccountListItem.js +0 -61
  36. package/auth/components/AccountsList/account-list-item.scss +0 -5
  37. package/auth/components/AccountsList/index.js +0 -17
  38. package/auth/components/Footer/index.js +0 -11
  39. package/auth/components/ForgotPassword/forgot-password.scss +0 -37
  40. package/auth/components/ForgotPassword/index.js +0 -114
  41. package/auth/components/SetNewPassword/index.js +0 -130
  42. package/auth/components/SetNewPassword/set-new-password.scss +0 -47
  43. package/auth/components/SignIn/SignInEmailForm.tsx +0 -115
  44. package/auth/components/SignIn/index.js +0 -69
  45. package/auth/components/SignIn/sign-in.scss +0 -56
  46. package/auth/components/SignOut/index.js +0 -144
  47. package/auth/components/SignOut/sign-out.scss +0 -34
  48. package/auth/components/SignUp/SignUpEmailForm.tsx +0 -98
  49. package/auth/components/SignUp/index.js +0 -66
  50. package/auth/components/SignUp/sign-up.scss +0 -56
  51. package/auth/getTenantId.js +0 -12
  52. package/auth/getUid.js +0 -11
  53. package/auth/helpers/redirectSignIn.native.js +0 -9
  54. package/auth/helpers/redirectSignIn.web.js +0 -7
  55. package/auth/index.js +0 -146
  56. package/auth/signOut.js +0 -20
  57. package/auth/useAuthRouter.js +0 -56
  58. package/env.d.ts +0 -3
  59. package/firebase/index.js +0 -1
  60. package/firebase/sw.js +0 -1
  61. package/form/FileInput/FileUploadContext.tsx +0 -162
  62. package/form/FileInput/FileUploadForm/index.tsx +0 -139
  63. package/form/FileInput/FileUploadForm/usePreventUnload.js +0 -21
  64. package/form/FileInput/UploadButton.tsx +0 -23
  65. package/form/FileInput/constants.ts +0 -16
  66. package/form/FileInput/file-input.scss +0 -1
  67. package/form/FileInput/index.tsx +0 -21
  68. package/form/FileInput/upload-worker/get_file_hash.js +0 -63
  69. package/form/FileInput/upload-worker/index.js +0 -16
  70. package/form/FileInput/upload-worker/no_compress_exts.ts +0 -33
  71. package/form/FileInput/upload-worker/upload_file.js +0 -129
  72. package/form/Form.tsx +0 -23
  73. package/form/Input.tsx +0 -62
  74. package/form/SubmitButton/index.tsx +0 -58
  75. package/form/hook-form.tsx +0 -7
  76. package/form/index.tsx +0 -5
  77. package/getBaseUrl.js +0 -14
  78. package/getObjectId.ts +0 -31
  79. package/hashState.js +0 -158
  80. package/helpers/createBatcher/index.js +0 -36
  81. package/helpers/getInitials.js +0 -39
  82. package/helpers/onReady.js +0 -15
  83. package/helpers/post.js +0 -18
  84. package/helpers/postRPC.js +0 -42
  85. package/helpers/useRPC.js +0 -41
  86. package/helpers/useStoredValue/batchedGetStoredValues.js +0 -30
  87. package/helpers/useStoredValue/index.js +0 -107
  88. package/helpers/useStoredValue/setStoredValues.js +0 -14
  89. package/i18n/en/rb.nav.json +0 -13
  90. package/i18n/en/rb.sign_in.json +0 -11
  91. package/i18n/en/rb.sign_out.json +0 -5
  92. package/i18n/fr/rb.sign_in.json +0 -11
  93. package/i18n/fr/rb.sign_out.json +0 -5
  94. package/i18n/index.js +0 -63
  95. package/index.js +0 -6
  96. package/isEqualValues.js +0 -47
  97. package/jest.config.js +0 -16
  98. package/notifications/Notification/index.js +0 -36
  99. package/notifications/Notification/notification.scss +0 -1
  100. package/notifications/NotificationItem/HeaderStatus.js +0 -93
  101. package/notifications/NotificationItem/index.js +0 -65
  102. package/notifications/NotificationItem/notification-item.scss +0 -25
  103. package/notifications/NotificationsContainer/index.js +0 -37
  104. package/notifications/NotificationsContainer/notifications-container.scss +0 -38
  105. package/notifications/NotificationsContainer/useLLTs.js +0 -28
  106. package/notifications/NotificationsContext/index.js +0 -71
  107. package/notifications/NotificationsContext/useNotificationsList.js +0 -75
  108. package/notifications/NotificationsSettingsModal/SettingsForm.js +0 -52
  109. package/notifications/NotificationsSettingsModal/index.js +0 -48
  110. package/notifications/NotificationsSettingsModal/notifications-settings.scss +0 -1
  111. package/notifications/config.js +0 -1
  112. package/notifications/index.js +0 -4
  113. package/page.js +0 -9
  114. package/publish-output.txt +0 -0
  115. package/rpc.js +0 -32
  116. package/rr-trace/get_fingerprint.js +0 -10
  117. package/rr-trace/get_perf_vitals.js +0 -24
  118. package/rr-trace/get_session_id.js +0 -29
  119. package/rr-trace/index.js +0 -138
  120. package/rr-trace/write_session_data.js +0 -86
  121. package/rts/boot.js +0 -3
  122. package/rts/getUseDocument.js +0 -21
  123. package/rts/getUseQuery/index.js +0 -233
  124. package/rts/getUseQuery/useData.js +0 -55
  125. package/rts/index.js +0 -10
  126. package/rts/rts.js +0 -243
  127. package/rts/signout.ts +0 -8
  128. package/rts/store/constants.js +0 -3
  129. package/rts/store/debug.js +0 -24
  130. package/rts/store/get_collection.js +0 -55
  131. package/rts/store/index.js +0 -100
  132. package/rts/store/replace_query_keys.js +0 -30
  133. package/rts/store/satisfies_projection.js +0 -32
  134. package/rts/store/update_docs.js +0 -47
  135. package/storage/index.jest.js +0 -15
  136. package/storage/index.native.js +0 -38
  137. package/storage/index.web.js +0 -25
  138. package/types.ts +0 -6
  139. package/ui/ActivityIndicator/index.js +0 -113
  140. package/ui/Avatar/index.native.js +0 -31
  141. package/ui/Avatar/index.web.js +0 -37
  142. package/ui/Avatar/styles.js +0 -41
  143. package/ui/ErrorBoundary/index.js +0 -12
  144. package/ui/ExpandableFloatView/exp.scss +0 -15
  145. package/ui/ExpandableFloatView/index.tsx +0 -123
  146. package/ui/ExpandableFloatView/useBackdrop.js +0 -45
  147. package/ui/LottiePlayer/LottiePlayer.js +0 -4
  148. package/ui/LottiePlayer/index.js +0 -8
  149. package/ui/Modal/HashStateModal.js +0 -30
  150. package/ui/Modal/Modal.js +0 -93
  151. package/ui/Modal/ModalForm/AlertBanner.js +0 -82
  152. package/ui/Modal/ModalForm/index.js +0 -188
  153. package/ui/Modal/ModalForm/modal-form.scss +0 -63
  154. package/ui/Modal/index.js +0 -10
  155. package/ui/Modal/modal.scss +0 -101
  156. package/ui/Modal/withHashStateModal.js +0 -24
  157. package/ui/RedboxError/index.js +0 -3
  158. package/ui/Search/SearchHistory/index.js +0 -45
  159. package/ui/Search/SearchHistory/search-history.scss +0 -9
  160. package/ui/Search/SearchHistory/useSearchHistory.tsx +0 -57
  161. package/ui/Search/SearchResults/index.tsx +0 -90
  162. package/ui/Search/index.tsx +0 -298
  163. package/ui/Search/search.scss +0 -0
  164. package/ui/SelectPills/index.tsx +0 -96
  165. package/ui/SelectPills/select-pills.scss +0 -66
  166. package/ui/Tabs/index.tsx +0 -161
  167. package/ui/Tabs/tabs.scss +0 -53
  168. package/ui/Tree/index.js +0 -257
  169. package/ui/Tree/model.js +0 -71
  170. package/ui/Tree/node.js +0 -112
  171. package/ui/Tree/tree.scss +0 -98
  172. package/ui/UserAvatar/default_colors.json +0 -82
  173. package/ui/UserAvatar/index.js +0 -55
  174. package/ui/View/index.tsx +0 -17
  175. package/ui/View/index.web.js +0 -44
  176. package/ui/animations/checkmark.json +0 -1
  177. package/ui/helpers/SizeContext/index.tsx +0 -11
  178. package/ui/helpers/helpers.scss +0 -61
  179. package/ui/helpers/index.ts +0 -6
  180. package/ui/helpers/stopEventPropagation.js +0 -5
  181. package/ui/helpers/useActiveListItemIndex/index.tsx +0 -45
  182. package/ui/helpers/useScrollSelectorIntoView/index.tsx +0 -14
  183. package/ui/helpers/useThrottledMeasure/index.js +0 -47
  184. package/ui/helpers/withSuspense/index.js +0 -37
  185. package/ui/icons/AddAccount.tsx +0 -5
  186. package/ui/icons/Billing.tsx +0 -6
  187. package/ui/icons/Close.tsx +0 -14
  188. package/ui/icons/Organization.tsx +0 -5
  189. package/ui/icons/Signout.tsx +0 -5
  190. package/ui/icons/index.tsx +0 -6
  191. package/ui/nav/AccountsDropdown/SwitchAccounts.tsx +0 -28
  192. package/ui/nav/AccountsDropdown/accounts-dropdown.scss +0 -51
  193. package/ui/nav/AccountsDropdown/index.tsx +0 -90
  194. package/ui/nav/AccountsToggle/index.tsx +0 -24
  195. package/ui/nav/ContentView/ContentViewContext.ts +0 -23
  196. package/ui/nav/ContentView/index.tsx +0 -115
  197. package/ui/nav/HeaderContainer/header.scss +0 -52
  198. package/ui/nav/HeaderContainer/index.tsx +0 -23
  199. package/ui/nav/HeaderContainer/variables.scss +0 -1
  200. package/ui/nav/MorphingDropdown/MorphingDropdownContext.tsx +0 -151
  201. package/ui/nav/MorphingDropdown/MorphingDropdownMenu.tsx +0 -38
  202. package/ui/nav/MorphingDropdown/MorphingDropdownPortal.tsx +0 -166
  203. package/ui/nav/MorphingDropdown/MorphingDropdownToggle.tsx +0 -34
  204. package/ui/nav/MorphingDropdown/index.tsx +0 -16
  205. package/ui/nav/MorphingDropdown/morphing-dropdown.scss +0 -35
  206. package/ui/nav/NotificationsDropdown/index.tsx +0 -52
  207. package/ui/nav/NotificationsDropdown/notifications-dropdown.scss +0 -5
  208. package/ui/nav/NotificationsToggle/NotificationsGlyph.tsx +0 -54
  209. package/ui/nav/NotificationsToggle/index.tsx +0 -12
  210. package/ui/nav/NotificationsToggle/notification-animation.json +0 -1
  211. package/ui/nav/NotificationsToggle/notifications-toggle.scss +0 -26
  212. package/ui/nav/SidebarContainer/index.tsx +0 -48
  213. package/ui/nav/SidebarContainer/sidebar-container.scss +0 -21
  214. package/ui/nav/SlideoutContainer/components/Body.tsx +0 -19
  215. package/ui/nav/SlideoutContainer/components/Header.tsx +0 -23
  216. package/ui/nav/SlideoutContainer/components/Wrapper.tsx +0 -46
  217. package/ui/nav/SlideoutContainer/index.tsx +0 -50
  218. package/ui/nav/SlideoutContainer/slideout-container.scss +0 -40
  219. package/ui/nav/index.ts +0 -13
  220. package/ui/oauth/GitHub.js +0 -38
  221. package/ui/oauth/getGitHubSigninUrl.js +0 -30
  222. package/ui/oauth/index.js +0 -9
  223. package/ui/oauth/oauth.scss +0 -16
  224. package/ui/sortable-hoc/AutoScroller.js +0 -76
  225. package/ui/sortable-hoc/DragHandle.js +0 -31
  226. package/ui/sortable-hoc/Manager.js +0 -54
  227. package/ui/sortable-hoc/README.md +0 -1
  228. package/ui/sortable-hoc/SortableContainer/defaultGetHelperDimensions.js +0 -7
  229. package/ui/sortable-hoc/SortableContainer/defaultShouldCancelStart.js +0 -24
  230. package/ui/sortable-hoc/SortableContainer/index.js +0 -994
  231. package/ui/sortable-hoc/SortableContainer/props.js +0 -81
  232. package/ui/sortable-hoc/SortableElement.js +0 -111
  233. package/ui/sortable-hoc/SortableHandle.js +0 -45
  234. package/ui/sortable-hoc/drag-handle.scss +0 -14
  235. package/ui/sortable-hoc/index.js +0 -9
  236. package/ui/sortable-hoc/utils.js +0 -292
  237. package/ui/springs.ts +0 -17
@@ -1,114 +0,0 @@
1
- /* @flow */
2
- import {useState, useEffect} from "react"
3
- import {useHash} from "react-use"
4
- import {ActivityIndicator} from "react-native"
5
- import isEmail from "validator/lib/isEmail"
6
-
7
- import post from "../../../helpers/post"
8
-
9
- import {Footer} from "../Footer"
10
-
11
- import "./forgot-password.scss"
12
-
13
- export const ForgotPassword = ({name, logo}) => {
14
- const [hash, setHash] = useHash()
15
-
16
- const [isLoading, setIsLoading] = useState(false)
17
- const [isSuccess, setIsSuccess] = useState(false)
18
- const [errors, setErrors] = useState()
19
-
20
- const [email, setEmail] = useState("")
21
-
22
- useEffect(() => {
23
- if (hash?.length > 1) {
24
- const val = hash.slice(1)
25
-
26
- const decoded = atob(val)
27
- if (isEmail(decoded)) {
28
- setEmail(decoded)
29
- // remove the hash
30
- // isn't there a better way
31
- // fixes go back twice on change password
32
- history.replaceState(
33
- "",
34
- document.title,
35
- window.location.pathname + window.location.search
36
- )
37
- }
38
- }
39
- }, [hash])
40
-
41
- const onSubmit = async(e) => {
42
- e.preventDefault()
43
- setIsLoading(true)
44
- const res = await post("/rb-api/v1/auth/reset_password", {email})
45
- setIsLoading(false)
46
-
47
- if (res.status === "ok") {
48
- setErrors(null)
49
- setIsSuccess(true)
50
- } else {
51
- setErrors(res.errors)
52
- }
53
- }
54
-
55
- const onChangeEmail = (e) => setEmail(e.target.value)
56
-
57
- return (
58
- <div id="forgot-password-wrapper">
59
- <div className="form-forgot text-center px-4 py-4 shadow-lg">
60
- <div>
61
- <div className="d-flex align-items-center justify-content-center">
62
- {logo}
63
- </div>
64
-
65
- <hr />
66
-
67
- <h1 className="h4 mt-3 mb-3 fw-normal">Reset your password</h1>
68
-
69
- {isSuccess && (
70
- <p className="text-success text-start">
71
- If there is an account linked to this email, instructions to reset the password will be sent shortly
72
- </p>
73
- )}
74
-
75
- <form onSubmit={onSubmit}>
76
-
77
- {errors?.form && (
78
- <p className="text-danger">{errors.form}</p>
79
- )}
80
-
81
- <div className="text-start form-floating mb-4">
82
- <input type="email"
83
- disabled={isSuccess}
84
- className="form-control"
85
- id="input-email"
86
- placeholder="name@example.com"
87
- value={email}
88
- onChange={onChangeEmail} />
89
- <label htmlFor="input-email">Email Address</label>
90
- </div>
91
-
92
-
93
- <button id={"btn-submit"}
94
- type="submit"
95
- disabled={isLoading || isSuccess}
96
- className="w-100 btn btn-lg btn-primary"
97
- onClick={onSubmit}>
98
- <div className="d-flex flex-row align-items-center justify-content-center">
99
- {isLoading && (
100
- <div className="me-2"><ActivityIndicator color="#FFFFFF" /></div>
101
- )}
102
- Reset my Password
103
- </div>
104
- </button>
105
-
106
- </form>
107
-
108
- </div>
109
- </div>
110
-
111
- <Footer name={name} />
112
- </div>
113
- )
114
- }
@@ -1,130 +0,0 @@
1
- /* @flow */
2
- import {useState, useEffect} from "react"
3
- import {useSearchParam} from "react-use"
4
- import {ActivityIndicator} from "react-native"
5
-
6
- import post from "../../../helpers/post"
7
-
8
- import {Footer} from "../Footer"
9
-
10
- import "./set-new-password.scss"
11
-
12
- export const SetNewPassword = ({name, logo}) => {
13
- const [isLoading, setIsLoading] = useState(false)
14
- const [error, setError] = useState()
15
- const [isSuccess, setIsSuccess] = useState(false)
16
-
17
- const [password1, setPassword1] = useState("")
18
- const [password2, setPassword2] = useState("")
19
-
20
- const user_id = useSearchParam("uid")
21
- const token = useSearchParam("token")
22
-
23
- const onSubmit = async(e) => {
24
- e.preventDefault()
25
-
26
- if (password1.length < 12) {
27
- setError("Your password is too short")
28
- return
29
- }
30
-
31
- if (password1 !== password2) {
32
- setError("Passwords do not match")
33
- return
34
- }
35
-
36
- setIsLoading(true)
37
- setError(null)
38
-
39
- const password = password1
40
- const res = await post("/rb-api/v1/auth/set_new_password", {
41
- user_id,
42
- token,
43
- password,
44
- })
45
-
46
- setIsLoading(false)
47
-
48
- if (res.status === "ok") {
49
- setIsSuccess(true)
50
- } else {
51
- setError(res.message)
52
- }
53
- }
54
-
55
- const onChangePassword1 = (e) => setPassword1(e.target.value)
56
- const onChangePassword2 = (e) => setPassword2(e.target.value)
57
-
58
- return (
59
- <div id="set-new-password-wrapper">
60
- <div className="form-set-new-password text-center px-4 py-4 shadow-lg">
61
- <div>
62
- <div className="d-flex align-items-center justify-content-center">
63
- {logo}
64
- </div>
65
-
66
- <hr />
67
-
68
- <h1 className="h4 mt-3 mb-3 fw-normal">New Password</h1>
69
- <p className="text-start text-muted">
70
- Passwords must use at least 12 characters
71
- </p>
72
-
73
- {error && (
74
- <p className="text-start text-danger">{error}</p>
75
- )}
76
-
77
- {isSuccess && (
78
- <p className="text-start text-success">
79
- Your new password has successfully been set, you may now <a href="/signin">sign in</a> to your account
80
- </p>
81
- )}
82
-
83
-
84
- <form onSubmit={onSubmit}>
85
-
86
- <div className="form-floating text-start">
87
- <input type="password"
88
- className="form-control"
89
- id="input-password1"
90
- autoFocus
91
- placeholder="Password"
92
- disabled={isLoading || isSuccess}
93
- value={password1}
94
- onChange={onChangePassword1} />
95
- <label htmlFor="input-password1">Password</label>
96
- </div>
97
-
98
- <div className="form-floating text-start">
99
- <input type="password"
100
- className="form-control"
101
- id="input-password2"
102
- placeholder="Confirm Password"
103
- disabled={isLoading || isSuccess}
104
- value={password2}
105
- onChange={onChangePassword2} />
106
- <label htmlFor="input-password2">Confirm Password</label>
107
- </div>
108
-
109
- <button id={"btn-submit"}
110
- type="submit"
111
- disabled={isLoading || isSuccess}
112
- className="w-100 btn btn-lg btn-primary mt-4"
113
- onClick={onSubmit}>
114
- <div className="d-flex flex-row align-items-center justify-content-center">
115
- {isLoading && (
116
- <div className="me-2"><ActivityIndicator color="#FFFFFF" /></div>
117
- )}
118
- Set new Password
119
- </div>
120
- </button>
121
-
122
- </form>
123
-
124
- </div>
125
- </div>
126
-
127
- <Footer name={name} />
128
- </div>
129
- )
130
- }
@@ -1,47 +0,0 @@
1
- @import "helpers";
2
-
3
- #set-new-password-wrapper {
4
- height: 100%;
5
- display: flex;
6
- flex-direction: column;
7
- align-items: center;
8
- padding-top: 40px;
9
- padding-bottom: 40px;
10
- // background-color: var(--bs-secondary);
11
- background-color: $gray-500;
12
-
13
- hr {
14
- background-color: $gray-500;
15
- }
16
-
17
- footer {
18
- color: $light !important;
19
- border-top: none !important;
20
- padding-top: 0 !important;
21
- margin-bottom: 0 !important;
22
- }
23
-
24
- .form-set-new-password {
25
- width: 100%;
26
- max-width: 380px;
27
- margin: auto;
28
- background-color: $light;
29
- border-radius: 22px;
30
- // border: 1px solid $gray-600;
31
- }
32
-
33
- .form-set-new-password .form-floating:focus-within {
34
- z-index: 2;
35
- }
36
-
37
- .form-set-new-password #input-password1 {
38
- margin-bottom: -1px;
39
- border-bottom-right-radius: 0;
40
- border-bottom-left-radius: 0;
41
- }
42
-
43
- .form-set-new-password #input-password2 {
44
- border-top-left-radius: 0;
45
- border-top-right-radius: 0;
46
- }
47
- }
@@ -1,115 +0,0 @@
1
- import assert from "assert"
2
- import debug from "debug"
3
- import {useState, useEffect} from "react"
4
- import {useTranslation} from "react-i18next"
5
- import useSearchParam from "react-use/lib/useSearchParam"
6
- import isEmail from "validator/lib/isEmail"
7
-
8
- import page from "../../../page"
9
- import post from "../../../helpers/post"
10
- import {reconnect as rts_reconnect} from "../../../rts/rts"
11
- import {setIsSignedIn, setUid, setTenantId} from "../../index"
12
-
13
-
14
- const log = debug("rb:auth:signin")
15
-
16
- export const SignInEmailForm = ({onSuccess, onSuccessRedirect}) => {
17
- const {t} = useTranslation("rb.sign_in", {useSuspense: false})
18
-
19
- const redirect = useSearchParam("redirect")
20
-
21
- const [isLoading, setIsLoading] = useState(false)
22
-
23
- const [email, setEmail] = useState("")
24
- const [password, setPassword] = useState("")
25
- const [forgotUrlParam, setForgotUrlParam] = useState(null)
26
-
27
- const [errors, setErrors] = useState()
28
-
29
- useEffect(() => {
30
- if (isEmail(email)) {
31
- setForgotUrlParam(btoa(email))
32
- } else {
33
- setForgotUrlParam("")
34
- }
35
- }, [email])
36
-
37
- const onSubmit = async(e) => {
38
- e.preventDefault()
39
- setIsLoading(true)
40
- const res = await post("/rb-api/v1/auth/sign_in", {email, password})
41
- setIsLoading(false)
42
-
43
- // success
44
- if (res.status === "ok") {
45
- log("signed in res: ok", res)
46
- log("redirect to:", redirect || onSuccessRedirect)
47
- const {user_id} = res
48
- assert(res.user_id, "missing user_id")
49
-
50
- setUid(user_id)
51
- const tenantId = user_id.slice(8, 16)
52
- setTenantId(tenantId)
53
- setIsSignedIn(true)
54
-
55
- // we must now reconnect on the websocket as we now have a new cookie
56
- rts_reconnect(tenantId, user_id)
57
- onSuccess()
58
- if (redirect) {
59
- page(redirect)
60
- } else {
61
- page(onSuccessRedirect)
62
- }
63
- // errors
64
- } else {
65
- log("sign in error", res)
66
-
67
- setErrors(res.errors)
68
- }
69
- }
70
-
71
- const onChangeEmail = (e) => {
72
- setEmail(e.target.value)
73
- }
74
-
75
- const onChangePassword = (e) => {
76
- setPassword(e.target.value)
77
- }
78
-
79
-
80
- return (
81
- <form onSubmit={onSubmit}>
82
-
83
- {errors?.form && (
84
- <p className="text-danger">{errors.form}</p>
85
- )}
86
-
87
- <div className="form-floating text-start">
88
- <input type="email"
89
- className="form-control"
90
- id="input-email"
91
- placeholder={t("email_placeholder")}
92
- value={email}
93
- onChange={onChangeEmail} />
94
- <label htmlFor="input-email">{t("email_address")}</label>
95
- </div>
96
-
97
- <div className="form-floating text-start">
98
- <input type="password"
99
- className="form-control"
100
- id="input-password"
101
- placeholder={t("password")}
102
- value={password}
103
- onChange={onChangePassword} />
104
- <label htmlFor="input-password">{t("password")}</label>
105
- </div>
106
-
107
- <div className="mt-2 text-start w-100">
108
- <a href={`/forgot-password${forgotUrlParam && `#${forgotUrlParam}`}`}>{t("forgot_password")}</a>
109
- </div>
110
-
111
- <button className="mt-4 mb-3 w-100 btn btn-lg btn-primary" type="submit" onClick={onSubmit}>{t("submit_btn")}</button>
112
- {isLoading && "loading..."}
113
- </form>
114
- )
115
- }
@@ -1,69 +0,0 @@
1
- /* @flow */
2
- import assert from "assert"
3
- import {useTranslation} from "react-i18next"
4
- import authConfig from "@rpcbase/dot-rb/auth"
5
-
6
- import {AUTH_BUTTONS} from "../../../ui/oauth"
7
- import {Footer} from "../Footer"
8
-
9
- import {SignInEmailForm} from "./SignInEmailForm"
10
-
11
- import "./sign-in.scss"
12
-
13
-
14
- const hasOAuth = authConfig.oauth_providers?.length > 0
15
- const hasEmail = authConfig.has_email_signup
16
-
17
- export const SignIn = ({
18
- name,
19
- logo,
20
- onSuccessRedirect = "/",
21
- onSuccess = () => null,
22
- }) => {
23
- const {t} = useTranslation("rb.sign_in", {useSuspense: false})
24
-
25
- return (
26
- <div id="sign-in-wrapper">
27
- <div className="form-signin text-center px-4 py-4 shadow-lg">
28
- <div>
29
- <div className="d-flex align-items-center justify-content-center">
30
- {logo}
31
- </div>
32
-
33
- <hr />
34
-
35
- <h1 className="h4 mt-3 mb-3 fw-normal">{t("title")}</h1>
36
- <p className="text-start text-muted">
37
- {t("dont_have_account")}
38
- <a href="/signup" className="ms-1">{t("sign_up_here")}</a>
39
- </p>
40
-
41
- {hasEmail && (
42
- <SignInEmailForm
43
- onSuccess={onSuccess}
44
- onSuccessRedirect={onSuccessRedirect}
45
- />
46
- )}
47
-
48
- {hasEmail && hasOAuth && (
49
- <>
50
- <hr />
51
- <p className="text-muted">{t("or")}</p>
52
- </>
53
- )}
54
-
55
- {hasOAuth && authConfig.oauth_providers.map((provider, index) => {
56
- const Comp = AUTH_BUTTONS[provider.id]
57
- assert(Comp, `unable to find oauth button for provider: ${JSON.stringify(provider)}`)
58
-
59
- return <Comp key={`${provider.id}-${index}`} text={t("submit_btn")} className="w-100 justify-content-center" />
60
- })}
61
-
62
-
63
- </div>
64
- </div>
65
-
66
- <Footer name={name} />
67
- </div>
68
- )
69
- }
@@ -1,56 +0,0 @@
1
- @import "helpers";
2
-
3
- #sign-in-wrapper {
4
- height: 100%;
5
- display: flex;
6
- flex-direction: column;
7
- align-items: center;
8
- padding-top: 40px;
9
- padding-bottom: 40px;
10
- background-color: $gray-500;
11
-
12
- hr {
13
- background-color: $gray-500;
14
- }
15
-
16
- footer {
17
- color: $light !important;
18
- border-top: none !important;
19
- padding-top: 0 !important;
20
- margin-bottom: 0 !important;
21
- }
22
-
23
-
24
- .form-signin {
25
- width: 100%;
26
- max-width: 380px;
27
- margin: auto;
28
- background-color: $light;
29
- border-radius: 22px;
30
- // border: 1px solid $gray-600;
31
- }
32
-
33
- .form-signin .checkbox {
34
- font-weight: 400;
35
- }
36
-
37
- .form-signin .form-floating:focus-within {
38
- z-index: 2;
39
- }
40
-
41
- .form-signin input[type="email"] {
42
- margin-bottom: -1px;
43
- border-bottom-right-radius: 0;
44
- border-bottom-left-radius: 0;
45
- }
46
-
47
- input:-webkit-autofill::first-line {
48
- // color: red;
49
- }
50
-
51
- .form-signin #input-password {
52
- margin-bottom: 10px;
53
- border-top-left-radius: 0;
54
- border-top-right-radius: 0;
55
- }
56
- }
@@ -1,144 +0,0 @@
1
- /* @flow */
2
- import assert from "assert"
3
- import {useState, useEffect} from "react"
4
- import Alert from "react-bootstrap/Alert"
5
- import {useTranslation} from "react-i18next"
6
-
7
- import authConfig from "@rpcbase/dot-rb/auth"
8
-
9
- import {signOut} from "../../signOut"
10
-
11
- import post from "../../../helpers/post"
12
-
13
- import {AccountListItem} from "../AccountsList/AccountListItem"
14
- import {Footer} from "../Footer"
15
-
16
- import "./sign-out.scss"
17
- import { useNotifications } from "../../../notifications"
18
-
19
- // TODO: rts_disconnect
20
- // TODO: clear cache + db
21
- const hasMultiAccounts = authConfig.has_multi_accounts
22
-
23
- export const SignOut = ({
24
- logo,
25
- name,
26
- onSignOutSuccess = () => null
27
- }) => {
28
- const {t} = useTranslation("rb.sign_out", {useSuspense: false})
29
-
30
- const {addNotification} = useNotifications()
31
-
32
- const [isSignedOut, setIsSignedOut] = useState(false)
33
-
34
- const [accounts, setAccounts] = useState()
35
- const [selectedAccounts, setSelectedAccounts] = useState([])
36
-
37
-
38
- useEffect(() => {
39
- if (!hasMultiAccounts) return
40
-
41
- const load = async() => {
42
- const res = await post("/rb-api/v1/auth/get_accounts")
43
- assert(res.status === "ok")
44
- setAccounts(res.accounts)
45
- }
46
-
47
- load()
48
- }, [])
49
-
50
- const onSignOut = async() => {
51
- // TODO: NYI handle sign out from multiple accounts here
52
- const res = await post("/rb-api/v1/auth/sign_out")
53
- if (res.status === "ok") {
54
- signOut()
55
- setIsSignedOut(true)
56
-
57
- const toast = addNotification({
58
- // id: `create-template-${Date.now()}`,
59
- loading: false,
60
- title: "Signed out",
61
- message: "You have been signed out click here to sign back in",
62
- })
63
-
64
- onSignOutSuccess()
65
- } else {
66
- throw new Error("unable to sign out")
67
- }
68
- }
69
-
70
- const onSubmit = () => {
71
- onSignOut()
72
- }
73
-
74
- const message = hasMultiAccounts ? "Select accounts to sign out of:" : t("click_here_signout")
75
-
76
- return (
77
- <div id="sign-out-wrapper">
78
-
79
- {isSignedOut && (
80
- <Alert variant="light" transition data-bs-theme="dark" style={{maxWidth: 260, position: "absolute"}} onClose={() => setIsSignedOut(false)} dismissible>
81
- Signed out successfully
82
- </Alert>
83
- )}
84
-
85
- <div className="form-signout text-center px-4 py-4 shadow-lg">
86
-
87
- <div className="d-flex align-items-center justify-content-center">
88
- {logo}
89
- </div>
90
-
91
- <hr />
92
-
93
- <h1 className="h4 mt-3 mb-3 fw-normal">{t("title")}</h1>
94
-
95
- <p className="text-start text-muted">
96
- {message}
97
- </p>
98
-
99
- {hasMultiAccounts && Array.isArray(accounts) && accounts.length > 0 && (
100
- <ul className="list-group text-start">
101
- {accounts.map((acc, index) => {
102
- const id = `acc-${acc.user_id}-${index}`
103
-
104
- const onChange = (e) => {
105
- if (e.target.checked) {
106
- setSelectedAccounts((prev) => [...prev, acc.user_id])
107
- } else {
108
- setSelectedAccounts((prev) => [...prev.filter((v) => v !== acc.user_id)])
109
- }
110
- }
111
-
112
- const checked = selectedAccounts.includes(acc.user_id)
113
-
114
- return (
115
- <li key={id} className="list-group-item">
116
- <input className="form-check-input me-3" type="checkbox" value="" checked={checked} onChange={onChange} id={id} />
117
- <label className="form-check-label stretched-link" for={id}>
118
- <AccountListItem
119
- account={acc}
120
- // onClick={onClickAccount}
121
- />
122
- </label>
123
- </li>
124
- )
125
- })}
126
- </ul>
127
- )}
128
-
129
- <button className={cx("mb-3 w-100 btn btn-lg btn-primary", hasMultiAccounts ? "mt-4" : "mt-1")} type="submit" onClick={onSubmit}>Sign Out</button>
130
-
131
- {hasMultiAccounts && Array.isArray(accounts) && accounts.length === 0 && (
132
- <p className="text-start text-muted">
133
- You aren't signed in to any accounts<br />
134
- Go to: <a href="/signin">/signin</a>
135
- </p>
136
- )}
137
-
138
- </div>
139
-
140
- <Footer name={name} />
141
-
142
- </div>
143
- )
144
- }