@oxy.so/services 1.1.0 → 2.0.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 (176) hide show
  1. package/README.md +1 -1
  2. package/lib/commonjs/ui/components/BenefitList.js +93 -0
  3. package/lib/commonjs/ui/components/BenefitList.js.map +1 -0
  4. package/lib/commonjs/ui/components/FollowTargetButton.js +1 -1
  5. package/lib/commonjs/ui/components/FollowTargetButton.js.map +1 -1
  6. package/lib/commonjs/ui/components/OxyAuthChooser.js +95 -140
  7. package/lib/commonjs/ui/components/OxyAuthChooser.js.map +1 -1
  8. package/lib/commonjs/ui/components/authChooser/AccountsMenuView.js +8 -1
  9. package/lib/commonjs/ui/components/authChooser/AccountsMenuView.js.map +1 -1
  10. package/lib/commonjs/ui/components/authChooser/SignInEntryView.js +35 -25
  11. package/lib/commonjs/ui/components/authChooser/SignInEntryView.js.map +1 -1
  12. package/lib/commonjs/ui/components/authChooser/SignInRequestView.js +2 -3
  13. package/lib/commonjs/ui/components/authChooser/SignInRequestView.js.map +1 -1
  14. package/lib/commonjs/ui/components/authChooser/SignUpView.js +12 -127
  15. package/lib/commonjs/ui/components/authChooser/SignUpView.js.map +1 -1
  16. package/lib/commonjs/ui/components/authChooser/signInFailureMessage.js +40 -0
  17. package/lib/commonjs/ui/components/authChooser/signInFailureMessage.js.map +1 -0
  18. package/lib/commonjs/ui/components/authChooser/types.js +4 -6
  19. package/lib/commonjs/ui/components/authChooser/types.js.map +1 -1
  20. package/lib/commonjs/ui/context/OxyContext.js +1 -17
  21. package/lib/commonjs/ui/context/OxyContext.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/context/passkeyFlow.js +2 -28
  25. package/lib/commonjs/ui/context/passkeyFlow.js.map +1 -1
  26. package/lib/commonjs/ui/hooks/accountDialogSnapshot.js +3 -1
  27. package/lib/commonjs/ui/hooks/accountDialogSnapshot.js.map +1 -1
  28. package/lib/commonjs/ui/hooks/useProfileEditing.js +14 -0
  29. package/lib/commonjs/ui/hooks/useProfileEditing.js.map +1 -1
  30. package/lib/commonjs/ui/screens/AccountVerificationScreen.js +10 -10
  31. package/lib/commonjs/ui/screens/AccountVerificationScreen.js.map +1 -1
  32. package/lib/commonjs/ui/screens/EditProfileFieldScreen.js +225 -9
  33. package/lib/commonjs/ui/screens/EditProfileFieldScreen.js.map +1 -1
  34. package/lib/commonjs/ui/screens/LearnMoreUsernamesScreen.js +6 -6
  35. package/lib/commonjs/ui/screens/LearnMoreUsernamesScreen.js.map +1 -1
  36. package/lib/commonjs/ui/screens/ManageAccountScreen.js +10 -0
  37. package/lib/commonjs/ui/screens/ManageAccountScreen.js.map +1 -1
  38. package/lib/commonjs/ui/screens/PremiumSubscriptionScreen.js +5 -5
  39. package/lib/commonjs/ui/screens/PremiumSubscriptionScreen.js.map +1 -1
  40. package/lib/commonjs/ui/screens/trust/TrustAboutScreen.js +13 -13
  41. package/lib/commonjs/ui/screens/trust/TrustAboutScreen.js.map +1 -1
  42. package/lib/module/ui/components/BenefitList.js +89 -0
  43. package/lib/module/ui/components/BenefitList.js.map +1 -0
  44. package/lib/module/ui/components/FollowTargetButton.js +1 -1
  45. package/lib/module/ui/components/FollowTargetButton.js.map +1 -1
  46. package/lib/module/ui/components/OxyAuthChooser.js +97 -142
  47. package/lib/module/ui/components/OxyAuthChooser.js.map +1 -1
  48. package/lib/module/ui/components/authChooser/AccountsMenuView.js +8 -1
  49. package/lib/module/ui/components/authChooser/AccountsMenuView.js.map +1 -1
  50. package/lib/module/ui/components/authChooser/SignInEntryView.js +35 -25
  51. package/lib/module/ui/components/authChooser/SignInEntryView.js.map +1 -1
  52. package/lib/module/ui/components/authChooser/SignInRequestView.js +2 -3
  53. package/lib/module/ui/components/authChooser/SignInRequestView.js.map +1 -1
  54. package/lib/module/ui/components/authChooser/SignUpView.js +14 -129
  55. package/lib/module/ui/components/authChooser/SignUpView.js.map +1 -1
  56. package/lib/module/ui/components/authChooser/signInFailureMessage.js +36 -0
  57. package/lib/module/ui/components/authChooser/signInFailureMessage.js.map +1 -0
  58. package/lib/module/ui/components/authChooser/types.js +4 -6
  59. package/lib/module/ui/components/authChooser/types.js.map +1 -1
  60. package/lib/module/ui/context/OxyContext.js +2 -18
  61. package/lib/module/ui/context/OxyContext.js.map +1 -1
  62. package/lib/module/ui/context/hooks/useAuthOperations.js +15 -2
  63. package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -1
  64. package/lib/module/ui/context/passkeyFlow.js +2 -27
  65. package/lib/module/ui/context/passkeyFlow.js.map +1 -1
  66. package/lib/module/ui/hooks/accountDialogSnapshot.js +3 -1
  67. package/lib/module/ui/hooks/accountDialogSnapshot.js.map +1 -1
  68. package/lib/module/ui/hooks/useProfileEditing.js +14 -0
  69. package/lib/module/ui/hooks/useProfileEditing.js.map +1 -1
  70. package/lib/module/ui/screens/AccountVerificationScreen.js +6 -6
  71. package/lib/module/ui/screens/AccountVerificationScreen.js.map +1 -1
  72. package/lib/module/ui/screens/EditProfileFieldScreen.js +225 -9
  73. package/lib/module/ui/screens/EditProfileFieldScreen.js.map +1 -1
  74. package/lib/module/ui/screens/LearnMoreUsernamesScreen.js +6 -6
  75. package/lib/module/ui/screens/LearnMoreUsernamesScreen.js.map +1 -1
  76. package/lib/module/ui/screens/ManageAccountScreen.js +12 -2
  77. package/lib/module/ui/screens/ManageAccountScreen.js.map +1 -1
  78. package/lib/module/ui/screens/PremiumSubscriptionScreen.js +1 -1
  79. package/lib/module/ui/screens/PremiumSubscriptionScreen.js.map +1 -1
  80. package/lib/module/ui/screens/trust/TrustAboutScreen.js +7 -7
  81. package/lib/module/ui/screens/trust/TrustAboutScreen.js.map +1 -1
  82. package/lib/typescript/commonjs/index.d.ts +1 -1
  83. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  84. package/lib/typescript/commonjs/ui/components/BenefitList.d.ts +25 -0
  85. package/lib/typescript/commonjs/ui/components/BenefitList.d.ts.map +1 -0
  86. package/lib/typescript/commonjs/ui/components/OxyAuthChooser.d.ts +3 -4
  87. package/lib/typescript/commonjs/ui/components/OxyAuthChooser.d.ts.map +1 -1
  88. package/lib/typescript/commonjs/ui/components/authChooser/AccountsMenuView.d.ts.map +1 -1
  89. package/lib/typescript/commonjs/ui/components/authChooser/SignInEntryView.d.ts +11 -12
  90. package/lib/typescript/commonjs/ui/components/authChooser/SignInEntryView.d.ts.map +1 -1
  91. package/lib/typescript/commonjs/ui/components/authChooser/SignInRequestView.d.ts.map +1 -1
  92. package/lib/typescript/commonjs/ui/components/authChooser/SignUpView.d.ts +10 -13
  93. package/lib/typescript/commonjs/ui/components/authChooser/SignUpView.d.ts.map +1 -1
  94. package/lib/typescript/commonjs/ui/components/authChooser/signInFailureMessage.d.ts +16 -0
  95. package/lib/typescript/commonjs/ui/components/authChooser/signInFailureMessage.d.ts.map +1 -0
  96. package/lib/typescript/commonjs/ui/components/authChooser/types.d.ts +11 -13
  97. package/lib/typescript/commonjs/ui/components/authChooser/types.d.ts.map +1 -1
  98. package/lib/typescript/commonjs/ui/context/OxyContext.d.ts +1 -1
  99. package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
  100. package/lib/typescript/commonjs/ui/context/hooks/useAuthOperations.d.ts +3 -2
  101. package/lib/typescript/commonjs/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
  102. package/lib/typescript/commonjs/ui/context/oxyContextTypes.d.ts +20 -10
  103. package/lib/typescript/commonjs/ui/context/oxyContextTypes.d.ts.map +1 -1
  104. package/lib/typescript/commonjs/ui/context/passkeyFlow.d.ts +2 -21
  105. package/lib/typescript/commonjs/ui/context/passkeyFlow.d.ts.map +1 -1
  106. package/lib/typescript/commonjs/ui/hooks/accountDialogSnapshot.d.ts.map +1 -1
  107. package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts +3 -0
  108. package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
  109. package/lib/typescript/commonjs/ui/hooks/useProfileEditing.d.ts +1 -0
  110. package/lib/typescript/commonjs/ui/hooks/useProfileEditing.d.ts.map +1 -1
  111. package/lib/typescript/commonjs/ui/screens/EditProfileFieldScreen.d.ts.map +1 -1
  112. package/lib/typescript/commonjs/ui/screens/ManageAccountScreen.d.ts.map +1 -1
  113. package/lib/typescript/module/index.d.ts +1 -1
  114. package/lib/typescript/module/index.d.ts.map +1 -1
  115. package/lib/typescript/module/ui/components/BenefitList.d.ts +25 -0
  116. package/lib/typescript/module/ui/components/BenefitList.d.ts.map +1 -0
  117. package/lib/typescript/module/ui/components/OxyAuthChooser.d.ts +3 -4
  118. package/lib/typescript/module/ui/components/OxyAuthChooser.d.ts.map +1 -1
  119. package/lib/typescript/module/ui/components/authChooser/AccountsMenuView.d.ts.map +1 -1
  120. package/lib/typescript/module/ui/components/authChooser/SignInEntryView.d.ts +11 -12
  121. package/lib/typescript/module/ui/components/authChooser/SignInEntryView.d.ts.map +1 -1
  122. package/lib/typescript/module/ui/components/authChooser/SignInRequestView.d.ts.map +1 -1
  123. package/lib/typescript/module/ui/components/authChooser/SignUpView.d.ts +10 -13
  124. package/lib/typescript/module/ui/components/authChooser/SignUpView.d.ts.map +1 -1
  125. package/lib/typescript/module/ui/components/authChooser/signInFailureMessage.d.ts +16 -0
  126. package/lib/typescript/module/ui/components/authChooser/signInFailureMessage.d.ts.map +1 -0
  127. package/lib/typescript/module/ui/components/authChooser/types.d.ts +11 -13
  128. package/lib/typescript/module/ui/components/authChooser/types.d.ts.map +1 -1
  129. package/lib/typescript/module/ui/context/OxyContext.d.ts +1 -1
  130. package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
  131. package/lib/typescript/module/ui/context/hooks/useAuthOperations.d.ts +3 -2
  132. package/lib/typescript/module/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
  133. package/lib/typescript/module/ui/context/oxyContextTypes.d.ts +20 -10
  134. package/lib/typescript/module/ui/context/oxyContextTypes.d.ts.map +1 -1
  135. package/lib/typescript/module/ui/context/passkeyFlow.d.ts +2 -21
  136. package/lib/typescript/module/ui/context/passkeyFlow.d.ts.map +1 -1
  137. package/lib/typescript/module/ui/hooks/accountDialogSnapshot.d.ts.map +1 -1
  138. package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts +3 -0
  139. package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
  140. package/lib/typescript/module/ui/hooks/useProfileEditing.d.ts +1 -0
  141. package/lib/typescript/module/ui/hooks/useProfileEditing.d.ts.map +1 -1
  142. package/lib/typescript/module/ui/screens/EditProfileFieldScreen.d.ts.map +1 -1
  143. package/lib/typescript/module/ui/screens/ManageAccountScreen.d.ts.map +1 -1
  144. package/package.json +6 -6
  145. package/src/index.ts +1 -1
  146. package/src/ui/components/BenefitList.tsx +111 -0
  147. package/src/ui/components/FollowTargetButton.tsx +1 -1
  148. package/src/ui/components/OxyAuthChooser.tsx +106 -156
  149. package/src/ui/components/authChooser/AccountsMenuView.tsx +7 -0
  150. package/src/ui/components/authChooser/SignInEntryView.tsx +41 -44
  151. package/src/ui/components/authChooser/SignInRequestView.tsx +1 -4
  152. package/src/ui/components/authChooser/SignUpView.tsx +16 -114
  153. package/src/ui/components/authChooser/signInFailureMessage.ts +39 -0
  154. package/src/ui/components/authChooser/types.ts +11 -13
  155. package/src/ui/context/OxyContext.tsx +2 -20
  156. package/src/ui/context/__tests__/passkeyFlow.test.ts +2 -65
  157. package/src/ui/context/hooks/useAuthOperations.ts +10 -5
  158. package/src/ui/context/oxyContextTypes.ts +16 -8
  159. package/src/ui/context/passkeyFlow.ts +2 -39
  160. package/src/ui/hooks/accountDialogSnapshot.ts +2 -0
  161. package/src/ui/hooks/useProfileEditing.ts +15 -0
  162. package/src/ui/screens/AccountVerificationScreen.tsx +6 -6
  163. package/src/ui/screens/EditProfileFieldScreen.tsx +202 -7
  164. package/src/ui/screens/LearnMoreUsernamesScreen.tsx +6 -6
  165. package/src/ui/screens/ManageAccountScreen.tsx +12 -0
  166. package/src/ui/screens/PremiumSubscriptionScreen.tsx +1 -1
  167. package/src/ui/screens/trust/TrustAboutScreen.tsx +7 -7
  168. package/lib/commonjs/ui/components/authChooser/useUsernameAvailability.js +0 -50
  169. package/lib/commonjs/ui/components/authChooser/useUsernameAvailability.js.map +0 -1
  170. package/lib/module/ui/components/authChooser/useUsernameAvailability.js +0 -46
  171. package/lib/module/ui/components/authChooser/useUsernameAvailability.js.map +0 -1
  172. package/lib/typescript/commonjs/ui/components/authChooser/useUsernameAvailability.d.ts +0 -16
  173. package/lib/typescript/commonjs/ui/components/authChooser/useUsernameAvailability.d.ts.map +0 -1
  174. package/lib/typescript/module/ui/components/authChooser/useUsernameAvailability.d.ts +0 -16
  175. package/lib/typescript/module/ui/components/authChooser/useUsernameAvailability.d.ts.map +0 -1
  176. 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
- }