@oxy.so/services 1.0.3 → 1.2.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 (163) hide show
  1. package/lib/commonjs/index.js.map +1 -1
  2. package/lib/commonjs/ui/components/LanguageBridge.js +51 -0
  3. package/lib/commonjs/ui/components/LanguageBridge.js.map +1 -0
  4. package/lib/commonjs/ui/components/OxyAuthChooser.js +95 -140
  5. package/lib/commonjs/ui/components/OxyAuthChooser.js.map +1 -1
  6. package/lib/commonjs/ui/components/OxyConsentScreen.js +132 -2
  7. package/lib/commonjs/ui/components/OxyConsentScreen.js.map +1 -1
  8. package/lib/commonjs/ui/components/OxyProvider.js +19 -1
  9. package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
  10. package/lib/commonjs/ui/components/authChooser/AccountsMenuView.js +8 -1
  11. package/lib/commonjs/ui/components/authChooser/AccountsMenuView.js.map +1 -1
  12. package/lib/commonjs/ui/components/authChooser/SignInEntryView.js +35 -25
  13. package/lib/commonjs/ui/components/authChooser/SignInEntryView.js.map +1 -1
  14. package/lib/commonjs/ui/components/authChooser/SignInRequestView.js +2 -3
  15. package/lib/commonjs/ui/components/authChooser/SignInRequestView.js.map +1 -1
  16. package/lib/commonjs/ui/components/authChooser/SignUpView.js +12 -127
  17. package/lib/commonjs/ui/components/authChooser/SignUpView.js.map +1 -1
  18. package/lib/commonjs/ui/components/authChooser/signInFailureMessage.js +40 -0
  19. package/lib/commonjs/ui/components/authChooser/signInFailureMessage.js.map +1 -0
  20. package/lib/commonjs/ui/components/authChooser/types.js +4 -6
  21. package/lib/commonjs/ui/components/authChooser/types.js.map +1 -1
  22. package/lib/commonjs/ui/context/hooks/useAuthOperations.js +15 -2
  23. package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -1
  24. package/lib/commonjs/ui/hooks/accountDialogSnapshot.js +3 -1
  25. package/lib/commonjs/ui/hooks/accountDialogSnapshot.js.map +1 -1
  26. package/lib/commonjs/ui/hooks/useProfileEditing.js +14 -0
  27. package/lib/commonjs/ui/hooks/useProfileEditing.js.map +1 -1
  28. package/lib/commonjs/ui/screens/EditProfileFieldScreen.js +225 -9
  29. package/lib/commonjs/ui/screens/EditProfileFieldScreen.js.map +1 -1
  30. package/lib/commonjs/ui/screens/ManageAccountScreen.js +10 -0
  31. package/lib/commonjs/ui/screens/ManageAccountScreen.js.map +1 -1
  32. package/lib/module/index.js.map +1 -1
  33. package/lib/module/ui/components/LanguageBridge.js +47 -0
  34. package/lib/module/ui/components/LanguageBridge.js.map +1 -0
  35. package/lib/module/ui/components/OxyAuthChooser.js +97 -142
  36. package/lib/module/ui/components/OxyAuthChooser.js.map +1 -1
  37. package/lib/module/ui/components/OxyConsentScreen.js +132 -2
  38. package/lib/module/ui/components/OxyConsentScreen.js.map +1 -1
  39. package/lib/module/ui/components/OxyProvider.js +19 -1
  40. package/lib/module/ui/components/OxyProvider.js.map +1 -1
  41. package/lib/module/ui/components/authChooser/AccountsMenuView.js +8 -1
  42. package/lib/module/ui/components/authChooser/AccountsMenuView.js.map +1 -1
  43. package/lib/module/ui/components/authChooser/SignInEntryView.js +35 -25
  44. package/lib/module/ui/components/authChooser/SignInEntryView.js.map +1 -1
  45. package/lib/module/ui/components/authChooser/SignInRequestView.js +2 -3
  46. package/lib/module/ui/components/authChooser/SignInRequestView.js.map +1 -1
  47. package/lib/module/ui/components/authChooser/SignUpView.js +14 -129
  48. package/lib/module/ui/components/authChooser/SignUpView.js.map +1 -1
  49. package/lib/module/ui/components/authChooser/signInFailureMessage.js +36 -0
  50. package/lib/module/ui/components/authChooser/signInFailureMessage.js.map +1 -0
  51. package/lib/module/ui/components/authChooser/types.js +4 -6
  52. package/lib/module/ui/components/authChooser/types.js.map +1 -1
  53. package/lib/module/ui/context/hooks/useAuthOperations.js +15 -2
  54. package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -1
  55. package/lib/module/ui/hooks/accountDialogSnapshot.js +3 -1
  56. package/lib/module/ui/hooks/accountDialogSnapshot.js.map +1 -1
  57. package/lib/module/ui/hooks/useProfileEditing.js +14 -0
  58. package/lib/module/ui/hooks/useProfileEditing.js.map +1 -1
  59. package/lib/module/ui/screens/EditProfileFieldScreen.js +225 -9
  60. package/lib/module/ui/screens/EditProfileFieldScreen.js.map +1 -1
  61. package/lib/module/ui/screens/ManageAccountScreen.js +12 -2
  62. package/lib/module/ui/screens/ManageAccountScreen.js.map +1 -1
  63. package/lib/typescript/commonjs/index.d.ts +2 -2
  64. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  65. package/lib/typescript/commonjs/ui/components/LanguageBridge.d.ts +19 -0
  66. package/lib/typescript/commonjs/ui/components/LanguageBridge.d.ts.map +1 -0
  67. package/lib/typescript/commonjs/ui/components/OxyAuthChooser.d.ts +3 -4
  68. package/lib/typescript/commonjs/ui/components/OxyAuthChooser.d.ts.map +1 -1
  69. package/lib/typescript/commonjs/ui/components/OxyConsentScreen.d.ts +17 -1
  70. package/lib/typescript/commonjs/ui/components/OxyConsentScreen.d.ts.map +1 -1
  71. package/lib/typescript/commonjs/ui/components/OxyProvider.d.ts +14 -0
  72. package/lib/typescript/commonjs/ui/components/OxyProvider.d.ts.map +1 -1
  73. package/lib/typescript/commonjs/ui/components/authChooser/AccountsMenuView.d.ts.map +1 -1
  74. package/lib/typescript/commonjs/ui/components/authChooser/SignInEntryView.d.ts +11 -12
  75. package/lib/typescript/commonjs/ui/components/authChooser/SignInEntryView.d.ts.map +1 -1
  76. package/lib/typescript/commonjs/ui/components/authChooser/SignInRequestView.d.ts.map +1 -1
  77. package/lib/typescript/commonjs/ui/components/authChooser/SignUpView.d.ts +10 -13
  78. package/lib/typescript/commonjs/ui/components/authChooser/SignUpView.d.ts.map +1 -1
  79. package/lib/typescript/commonjs/ui/components/authChooser/signInFailureMessage.d.ts +16 -0
  80. package/lib/typescript/commonjs/ui/components/authChooser/signInFailureMessage.d.ts.map +1 -0
  81. package/lib/typescript/commonjs/ui/components/authChooser/types.d.ts +11 -13
  82. package/lib/typescript/commonjs/ui/components/authChooser/types.d.ts.map +1 -1
  83. package/lib/typescript/commonjs/ui/context/OxyContext.d.ts +1 -1
  84. package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
  85. package/lib/typescript/commonjs/ui/context/hooks/useAuthOperations.d.ts +3 -2
  86. package/lib/typescript/commonjs/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
  87. package/lib/typescript/commonjs/ui/context/oxyContextTypes.d.ts +20 -2
  88. package/lib/typescript/commonjs/ui/context/oxyContextTypes.d.ts.map +1 -1
  89. package/lib/typescript/commonjs/ui/hooks/accountDialogSnapshot.d.ts.map +1 -1
  90. package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts +3 -0
  91. package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
  92. package/lib/typescript/commonjs/ui/hooks/useProfileEditing.d.ts +1 -0
  93. package/lib/typescript/commonjs/ui/hooks/useProfileEditing.d.ts.map +1 -1
  94. package/lib/typescript/commonjs/ui/screens/EditProfileFieldScreen.d.ts.map +1 -1
  95. package/lib/typescript/commonjs/ui/screens/ManageAccountScreen.d.ts.map +1 -1
  96. package/lib/typescript/commonjs/ui/types/navigation.d.ts +29 -0
  97. package/lib/typescript/commonjs/ui/types/navigation.d.ts.map +1 -1
  98. package/lib/typescript/module/index.d.ts +2 -2
  99. package/lib/typescript/module/index.d.ts.map +1 -1
  100. package/lib/typescript/module/ui/components/LanguageBridge.d.ts +19 -0
  101. package/lib/typescript/module/ui/components/LanguageBridge.d.ts.map +1 -0
  102. package/lib/typescript/module/ui/components/OxyAuthChooser.d.ts +3 -4
  103. package/lib/typescript/module/ui/components/OxyAuthChooser.d.ts.map +1 -1
  104. package/lib/typescript/module/ui/components/OxyConsentScreen.d.ts +17 -1
  105. package/lib/typescript/module/ui/components/OxyConsentScreen.d.ts.map +1 -1
  106. package/lib/typescript/module/ui/components/OxyProvider.d.ts +14 -0
  107. package/lib/typescript/module/ui/components/OxyProvider.d.ts.map +1 -1
  108. package/lib/typescript/module/ui/components/authChooser/AccountsMenuView.d.ts.map +1 -1
  109. package/lib/typescript/module/ui/components/authChooser/SignInEntryView.d.ts +11 -12
  110. package/lib/typescript/module/ui/components/authChooser/SignInEntryView.d.ts.map +1 -1
  111. package/lib/typescript/module/ui/components/authChooser/SignInRequestView.d.ts.map +1 -1
  112. package/lib/typescript/module/ui/components/authChooser/SignUpView.d.ts +10 -13
  113. package/lib/typescript/module/ui/components/authChooser/SignUpView.d.ts.map +1 -1
  114. package/lib/typescript/module/ui/components/authChooser/signInFailureMessage.d.ts +16 -0
  115. package/lib/typescript/module/ui/components/authChooser/signInFailureMessage.d.ts.map +1 -0
  116. package/lib/typescript/module/ui/components/authChooser/types.d.ts +11 -13
  117. package/lib/typescript/module/ui/components/authChooser/types.d.ts.map +1 -1
  118. package/lib/typescript/module/ui/context/OxyContext.d.ts +1 -1
  119. package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
  120. package/lib/typescript/module/ui/context/hooks/useAuthOperations.d.ts +3 -2
  121. package/lib/typescript/module/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
  122. package/lib/typescript/module/ui/context/oxyContextTypes.d.ts +20 -2
  123. package/lib/typescript/module/ui/context/oxyContextTypes.d.ts.map +1 -1
  124. package/lib/typescript/module/ui/hooks/accountDialogSnapshot.d.ts.map +1 -1
  125. package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts +3 -0
  126. package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
  127. package/lib/typescript/module/ui/hooks/useProfileEditing.d.ts +1 -0
  128. package/lib/typescript/module/ui/hooks/useProfileEditing.d.ts.map +1 -1
  129. package/lib/typescript/module/ui/screens/EditProfileFieldScreen.d.ts.map +1 -1
  130. package/lib/typescript/module/ui/screens/ManageAccountScreen.d.ts.map +1 -1
  131. package/lib/typescript/module/ui/types/navigation.d.ts +29 -0
  132. package/lib/typescript/module/ui/types/navigation.d.ts.map +1 -1
  133. package/package.json +5 -4
  134. package/src/index.ts +2 -1
  135. package/src/ui/components/LanguageBridge.tsx +44 -0
  136. package/src/ui/components/OxyAuthChooser.tsx +106 -156
  137. package/src/ui/components/OxyConsentScreen.tsx +127 -0
  138. package/src/ui/components/OxyProvider.tsx +17 -0
  139. package/src/ui/components/__tests__/LanguageBridge.test.tsx +81 -0
  140. package/src/ui/components/__tests__/OxyConsentScreen.test.tsx +32 -0
  141. package/src/ui/components/authChooser/AccountsMenuView.tsx +7 -0
  142. package/src/ui/components/authChooser/SignInEntryView.tsx +41 -44
  143. package/src/ui/components/authChooser/SignInRequestView.tsx +1 -4
  144. package/src/ui/components/authChooser/SignUpView.tsx +16 -114
  145. package/src/ui/components/authChooser/signInFailureMessage.ts +39 -0
  146. package/src/ui/components/authChooser/types.ts +11 -13
  147. package/src/ui/context/OxyContext.tsx +1 -1
  148. package/src/ui/context/hooks/useAuthOperations.ts +10 -5
  149. package/src/ui/context/oxyContextTypes.ts +16 -2
  150. package/src/ui/hooks/accountDialogSnapshot.ts +2 -0
  151. package/src/ui/hooks/useProfileEditing.ts +15 -0
  152. package/src/ui/screens/EditProfileFieldScreen.tsx +202 -7
  153. package/src/ui/screens/ManageAccountScreen.tsx +12 -0
  154. package/src/ui/types/navigation.ts +30 -0
  155. package/lib/commonjs/ui/components/authChooser/useUsernameAvailability.js +0 -50
  156. package/lib/commonjs/ui/components/authChooser/useUsernameAvailability.js.map +0 -1
  157. package/lib/module/ui/components/authChooser/useUsernameAvailability.js +0 -46
  158. package/lib/module/ui/components/authChooser/useUsernameAvailability.js.map +0 -1
  159. package/lib/typescript/commonjs/ui/components/authChooser/useUsernameAvailability.d.ts +0 -16
  160. package/lib/typescript/commonjs/ui/components/authChooser/useUsernameAvailability.d.ts.map +0 -1
  161. package/lib/typescript/module/ui/components/authChooser/useUsernameAvailability.d.ts +0 -16
  162. package/lib/typescript/module/ui/components/authChooser/useUsernameAvailability.d.ts.map +0 -1
  163. package/src/ui/components/authChooser/useUsernameAvailability.ts +0 -60
@@ -1,60 +0,0 @@
1
- /**
2
- * Debounced username-availability check over the existing SDK method.
3
- *
4
- * One responsibility: turn keystrokes into an `idle | checking | available |
5
- * taken` verdict without racing. A sequence guard drops superseded responses,
6
- * and a NETWORK failure resets the (now stale) verdict and toasts — it never
7
- * paints an inline error inside the dialog (owner mandate).
8
- */
9
-
10
- import { useCallback, useRef, useState } from 'react';
11
- import { toast } from '@oxy.so/bloom/toast';
12
- import type { OxyServices } from '@oxy.so/core';
13
- import type { Translate } from './types';
14
-
15
- export type UsernameStatus = 'idle' | 'checking' | 'available' | 'taken';
16
-
17
- /** Keystrokes settle for this long before a check is issued. */
18
- const DEBOUNCE_MS = 400;
19
- /** Shorter than this and there is nothing worth asking the server about. */
20
- const MIN_USERNAME_LENGTH = 3;
21
-
22
- export function useUsernameAvailability(
23
- oxyServices: OxyServices,
24
- t: Translate,
25
- ): {
26
- status: UsernameStatus;
27
- check: (value: string) => void;
28
- } {
29
- const [status, setStatus] = useState<UsernameStatus>('idle');
30
- const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
31
- const requestSeqRef = useRef(0);
32
-
33
- const check = useCallback(
34
- (value: string) => {
35
- if (timerRef.current) clearTimeout(timerRef.current);
36
- const seq = ++requestSeqRef.current;
37
- if (!value || value.length < MIN_USERNAME_LENGTH) {
38
- setStatus('idle');
39
- return;
40
- }
41
- setStatus('checking');
42
- timerRef.current = setTimeout(() => {
43
- void oxyServices
44
- .checkUsernameAvailability(value)
45
- .then((result) => {
46
- if (seq !== requestSeqRef.current) return; // superseded by a newer check
47
- setStatus(result.available ? 'available' : 'taken');
48
- })
49
- .catch(() => {
50
- if (seq !== requestSeqRef.current) return;
51
- setStatus('idle');
52
- toast.error(t('accounts.create.username.checkFailed'));
53
- });
54
- }, DEBOUNCE_MS);
55
- },
56
- [oxyServices, t],
57
- );
58
-
59
- return { status, check };
60
- }