@oxy.so/services 15.0.0 → 15.0.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.
- package/android/src/main/java/so/oxy/security/OxyCallerPolicy.kt +0 -2
- package/lib/commonjs/ui/components/OxyProvider.js +8 -1
- package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
- package/lib/commonjs/ui/components/accountDialogHost.js +48 -0
- package/lib/commonjs/ui/components/accountDialogHost.js.map +1 -0
- package/lib/commonjs/ui/components/authChooser/primitives.js +5 -3
- package/lib/commonjs/ui/components/authChooser/primitives.js.map +1 -1
- package/lib/commonjs/ui/components/signIn/InlineCommonsQr.js +28 -25
- package/lib/commonjs/ui/components/signIn/InlineCommonsQr.js.map +1 -1
- package/lib/commonjs/ui/components/signIn/OxySignInPanel.js +63 -23
- package/lib/commonjs/ui/components/signIn/OxySignInPanel.js.map +1 -1
- package/lib/commonjs/ui/components/signIn/OxySignUpPanel.js +94 -26
- package/lib/commonjs/ui/components/signIn/OxySignUpPanel.js.map +1 -1
- package/lib/commonjs/ui/hooks/useUsernameAvailability.js +21 -7
- package/lib/commonjs/ui/hooks/useUsernameAvailability.js.map +1 -1
- package/lib/commonjs/ui/oauth/browserBridge.js +15 -1
- package/lib/commonjs/ui/oauth/browserBridge.js.map +1 -1
- package/lib/commonjs/ui/screens/OxyOneScreen.js +2 -2
- package/lib/commonjs/ui/screens/OxyOneScreen.js.map +1 -1
- package/lib/commonjs/ui/utils/handlePreview.js +20 -0
- package/lib/commonjs/ui/utils/handlePreview.js.map +1 -0
- package/lib/commonjs/ui/utils/usernameLookupBudget.js +95 -0
- package/lib/commonjs/ui/utils/usernameLookupBudget.js.map +1 -0
- package/lib/module/ui/components/OxyProvider.js +8 -1
- package/lib/module/ui/components/OxyProvider.js.map +1 -1
- package/lib/module/ui/components/accountDialogHost.js +42 -0
- package/lib/module/ui/components/accountDialogHost.js.map +1 -0
- package/lib/module/ui/components/authChooser/primitives.js +5 -3
- package/lib/module/ui/components/authChooser/primitives.js.map +1 -1
- package/lib/module/ui/components/signIn/InlineCommonsQr.js +28 -25
- package/lib/module/ui/components/signIn/InlineCommonsQr.js.map +1 -1
- package/lib/module/ui/components/signIn/OxySignInPanel.js +64 -24
- package/lib/module/ui/components/signIn/OxySignInPanel.js.map +1 -1
- package/lib/module/ui/components/signIn/OxySignUpPanel.js +95 -27
- package/lib/module/ui/components/signIn/OxySignUpPanel.js.map +1 -1
- package/lib/module/ui/hooks/useUsernameAvailability.js +21 -7
- package/lib/module/ui/hooks/useUsernameAvailability.js.map +1 -1
- package/lib/module/ui/oauth/browserBridge.js +14 -0
- package/lib/module/ui/oauth/browserBridge.js.map +1 -1
- package/lib/module/ui/screens/OxyOneScreen.js +2 -2
- package/lib/module/ui/screens/OxyOneScreen.js.map +1 -1
- package/lib/module/ui/utils/handlePreview.js +16 -0
- package/lib/module/ui/utils/handlePreview.js.map +1 -0
- package/lib/module/ui/utils/usernameLookupBudget.js +88 -0
- package/lib/module/ui/utils/usernameLookupBudget.js.map +1 -0
- package/lib/typescript/commonjs/ui/components/OxyProvider.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/accountDialogHost.d.ts +24 -0
- package/lib/typescript/commonjs/ui/components/accountDialogHost.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/authChooser/primitives.d.ts +5 -3
- package/lib/typescript/commonjs/ui/components/authChooser/primitives.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/signIn/InlineCommonsQr.d.ts +6 -0
- package/lib/typescript/commonjs/ui/components/signIn/InlineCommonsQr.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/signIn/OxySignInPanel.d.ts +4 -2
- package/lib/typescript/commonjs/ui/components/signIn/OxySignInPanel.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/signIn/OxySignUpPanel.d.ts +12 -2
- package/lib/typescript/commonjs/ui/components/signIn/OxySignUpPanel.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/useUsernameAvailability.d.ts +15 -1
- package/lib/typescript/commonjs/ui/hooks/useUsernameAvailability.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/oauth/browserBridge.d.ts +4 -0
- package/lib/typescript/commonjs/ui/oauth/browserBridge.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/types/navigation.d.ts +14 -0
- package/lib/typescript/commonjs/ui/types/navigation.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/utils/handlePreview.d.ts +10 -0
- package/lib/typescript/commonjs/ui/utils/handlePreview.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/utils/usernameLookupBudget.d.ts +36 -0
- package/lib/typescript/commonjs/ui/utils/usernameLookupBudget.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/OxyProvider.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/accountDialogHost.d.ts +24 -0
- package/lib/typescript/module/ui/components/accountDialogHost.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/authChooser/primitives.d.ts +5 -3
- package/lib/typescript/module/ui/components/authChooser/primitives.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/signIn/InlineCommonsQr.d.ts +6 -0
- package/lib/typescript/module/ui/components/signIn/InlineCommonsQr.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/signIn/OxySignInPanel.d.ts +4 -2
- package/lib/typescript/module/ui/components/signIn/OxySignInPanel.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/signIn/OxySignUpPanel.d.ts +12 -2
- package/lib/typescript/module/ui/components/signIn/OxySignUpPanel.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/useUsernameAvailability.d.ts +15 -1
- package/lib/typescript/module/ui/hooks/useUsernameAvailability.d.ts.map +1 -1
- package/lib/typescript/module/ui/oauth/browserBridge.d.ts +4 -0
- package/lib/typescript/module/ui/oauth/browserBridge.d.ts.map +1 -1
- package/lib/typescript/module/ui/types/navigation.d.ts +14 -0
- package/lib/typescript/module/ui/types/navigation.d.ts.map +1 -1
- package/lib/typescript/module/ui/utils/handlePreview.d.ts +10 -0
- package/lib/typescript/module/ui/utils/handlePreview.d.ts.map +1 -0
- package/lib/typescript/module/ui/utils/usernameLookupBudget.d.ts +36 -0
- package/lib/typescript/module/ui/utils/usernameLookupBudget.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/ui/components/OxyProvider.tsx +11 -1
- package/src/ui/components/accountDialogHost.tsx +54 -0
- package/src/ui/components/authChooser/primitives.tsx +5 -3
- package/src/ui/components/signIn/InlineCommonsQr.tsx +24 -18
- package/src/ui/components/signIn/OxySignInPanel.tsx +64 -22
- package/src/ui/components/signIn/OxySignUpPanel.tsx +115 -26
- package/src/ui/hooks/useUsernameAvailability.ts +42 -7
- package/src/ui/oauth/__tests__/browserBridge.test.ts +6 -0
- package/src/ui/oauth/browserBridge.ts +13 -0
- package/src/ui/screens/OxyOneScreen.tsx +2 -2
- package/src/ui/types/navigation.ts +14 -0
- package/src/ui/utils/handlePreview.ts +16 -0
- package/src/ui/utils/usernameLookupBudget.ts +91 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the hosting app told the account dialog about itself.
|
|
3
|
+
*
|
|
4
|
+
* Both fields are optional. Without an app name the sign-in line stays
|
|
5
|
+
* generic, and without a handle template signup shows no profile preview.
|
|
6
|
+
* `OxyProvider` sets this; a screen mounted on its own (auth.oxy.so's
|
|
7
|
+
* `/login`) can pass the same facts as props, which win.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { createContext, useContext, useMemo, type ReactNode } from 'react';
|
|
11
|
+
|
|
12
|
+
export interface AccountDialogHost {
|
|
13
|
+
/** The app this dialog signs into, when the host named it. */
|
|
14
|
+
appName?: string | null;
|
|
15
|
+
/**
|
|
16
|
+
* Preview of the public profile a new username becomes. `{username}` is
|
|
17
|
+
* replaced with the typed handle. The host writes its own origin.
|
|
18
|
+
*/
|
|
19
|
+
handlePreviewTemplate?: string | null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const EMPTY_ACCOUNT_DIALOG_HOST: AccountDialogHost = {
|
|
23
|
+
appName: null,
|
|
24
|
+
handlePreviewTemplate: null,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const AccountDialogHostContext = createContext<AccountDialogHost>(EMPTY_ACCOUNT_DIALOG_HOST);
|
|
28
|
+
|
|
29
|
+
function blankToNull(value: string | null | undefined): string | null {
|
|
30
|
+
const trimmed = value?.trim();
|
|
31
|
+
return trimmed ? trimmed : null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const AccountDialogHostProvider: React.FC<AccountDialogHost & { children: ReactNode }> = ({
|
|
35
|
+
appName,
|
|
36
|
+
handlePreviewTemplate,
|
|
37
|
+
children,
|
|
38
|
+
}) => {
|
|
39
|
+
const value = useMemo<AccountDialogHost>(
|
|
40
|
+
() => ({
|
|
41
|
+
appName: blankToNull(appName),
|
|
42
|
+
handlePreviewTemplate: blankToNull(handlePreviewTemplate),
|
|
43
|
+
}),
|
|
44
|
+
[appName, handlePreviewTemplate],
|
|
45
|
+
);
|
|
46
|
+
return (
|
|
47
|
+
<AccountDialogHostContext.Provider value={value}>{children}</AccountDialogHostContext.Provider>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/** The hosting app's name and profile-preview template, or neither. */
|
|
52
|
+
export function useAccountDialogHost(): AccountDialogHost {
|
|
53
|
+
return useContext(AccountDialogHostContext);
|
|
54
|
+
}
|
|
@@ -12,9 +12,11 @@ import { authChooserStyles as styles } from './styles';
|
|
|
12
12
|
* A SUBORDINATE action: a small centred text link, never a button.
|
|
13
13
|
*
|
|
14
14
|
* This is the single visual grammar for everything that is not the surface's one
|
|
15
|
-
* primary action (issue #691) —
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* primary action (issue #691) — every alternative revealed behind "Having trouble?".
|
|
16
|
+
* Keeping them all on one component is what stops an alternative from quietly
|
|
17
|
+
* growing into a co-equal button again. "Create account" on the sign-in screen is
|
|
18
|
+
* the exception: it is a full-width button, because a text link was too easy for
|
|
19
|
+
* a new person to miss.
|
|
18
20
|
*
|
|
19
21
|
* Bloom's plain `Button` in the secondary link tone at `sm`: no fill or border, the
|
|
20
22
|
* secondary text colour, underlined under a pointer, and Bloom's link hit slop
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
import type React from 'react';
|
|
17
17
|
import { useEffect, useState } from 'react';
|
|
18
|
-
import {
|
|
18
|
+
import { StyleSheet, View } from 'react-native';
|
|
19
19
|
import QRCode from 'react-native-qrcode-svg';
|
|
20
20
|
import { Button } from '@oxy.so/bloom/button';
|
|
21
21
|
import { RiCheckboxCircleLine } from '@oxy.so/bloom/icons/RiCheckboxCircleLine';
|
|
@@ -35,6 +35,12 @@ const PLATE_PADDING = 8;
|
|
|
35
35
|
const PLATE_SIZE = QR_SIZE + PLATE_PADDING * 2;
|
|
36
36
|
/** The spinner while a code is on its way: React Native's `large` indicator size. */
|
|
37
37
|
const SPINNER_SIZE = 36;
|
|
38
|
+
/**
|
|
39
|
+
* The caption over the photo carousel. 16px white on a dark plate: the old
|
|
40
|
+
* 12px white line with a text shadow was not readable on the photos.
|
|
41
|
+
*/
|
|
42
|
+
export const QR_CAPTION_FONT_SIZE = 16;
|
|
43
|
+
export const QR_CAPTION_SCRIM = 'rgba(0, 0, 0, 0.78)';
|
|
38
44
|
|
|
39
45
|
export const InlineCommonsQr: React.FC<{ controller: AccountDialogController | null }> = ({
|
|
40
46
|
controller,
|
|
@@ -110,16 +116,17 @@ export const InlineCommonsQr: React.FC<{ controller: AccountDialogController | n
|
|
|
110
116
|
}}
|
|
111
117
|
>
|
|
112
118
|
<View style={[styles.plate, { borderColor: theme.colors.border }]}>{plate}</View>
|
|
113
|
-
<
|
|
119
|
+
<View style={styles.captionPlate} testID="signin-qr-caption">
|
|
120
|
+
<Text style={styles.caption}>{t('signin.qr.caption')}</Text>
|
|
121
|
+
</View>
|
|
114
122
|
</View>
|
|
115
123
|
);
|
|
116
124
|
};
|
|
117
125
|
|
|
118
126
|
const styles = StyleSheet.create({
|
|
119
127
|
block: {
|
|
120
|
-
width: PLATE_SIZE,
|
|
121
128
|
alignItems: 'center',
|
|
122
|
-
gap:
|
|
129
|
+
gap: 10,
|
|
123
130
|
},
|
|
124
131
|
plate: {
|
|
125
132
|
width: PLATE_SIZE,
|
|
@@ -131,21 +138,20 @@ const styles = StyleSheet.create({
|
|
|
131
138
|
alignItems: 'center',
|
|
132
139
|
justifyContent: 'center',
|
|
133
140
|
},
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
141
|
+
// A dark plate, not a 12px white line over the photo: the carousel behind
|
|
142
|
+
// this caption changes, and a shadow on the glyphs was not enough to read.
|
|
143
|
+
captionPlate: {
|
|
144
|
+
maxWidth: 260,
|
|
145
|
+
backgroundColor: QR_CAPTION_SCRIM,
|
|
146
|
+
borderRadius: 10,
|
|
147
|
+
paddingVertical: 8,
|
|
148
|
+
paddingHorizontal: 12,
|
|
138
149
|
},
|
|
139
|
-
|
|
150
|
+
caption: {
|
|
140
151
|
color: '#FFFFFF',
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
textShadowColor: 'rgba(0, 0, 0, 0.6)',
|
|
146
|
-
textShadowOffset: { width: 0, height: 1 },
|
|
147
|
-
textShadowRadius: 4,
|
|
148
|
-
},
|
|
149
|
-
}),
|
|
152
|
+
fontSize: QR_CAPTION_FONT_SIZE,
|
|
153
|
+
lineHeight: 22,
|
|
154
|
+
fontWeight: '600',
|
|
155
|
+
textAlign: 'center',
|
|
150
156
|
},
|
|
151
157
|
});
|
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
* differs (`host`). Sign-in happens IN it, on every origin: no window opens.
|
|
5
5
|
*
|
|
6
6
|
* picker a returning device: "Choose an account", then "Use another account"
|
|
7
|
-
* identifier the header
|
|
8
|
-
*
|
|
7
|
+
* identifier the header (what an Oxy account is, naming the host app when the
|
|
8
|
+
* dialog knows it), the Commons way in, and "Email or username"
|
|
9
|
+
* with its Continue, then a Create account button. On the web,
|
|
10
|
+
* from `md`, the screen is Bloom `AuthCard`'s
|
|
9
11
|
* split card and the Commons way in is the embedded QR over its
|
|
10
12
|
* photo carousel, in the right column (the account dialog grows to
|
|
11
13
|
* that card); below `md` it is "Continue with Oxy" at the top. A
|
|
@@ -29,7 +31,7 @@
|
|
|
29
31
|
|
|
30
32
|
import type React from 'react';
|
|
31
33
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
32
|
-
import { Linking, Platform,
|
|
34
|
+
import { Linking, Platform, StyleSheet, View } from 'react-native';
|
|
33
35
|
import { AuthMediaCarousel } from '@oxy.so/bloom/auth-card';
|
|
34
36
|
import { Button } from '@oxy.so/bloom/button';
|
|
35
37
|
import { Divider } from '@oxy.so/bloom/divider';
|
|
@@ -61,6 +63,7 @@ import { useSurfaceFrameWidth } from '../../hooks/useSurfaceFrameWidth';
|
|
|
61
63
|
import { getCommonsAcquisitionUrl } from '../../utils/commonsStoreLinks';
|
|
62
64
|
import { resolveSignInDevice } from '../../utils/signInDevice';
|
|
63
65
|
import { SubtleLink } from '../authChooser/primitives';
|
|
66
|
+
import { useAccountDialogHost } from '../accountDialogHost';
|
|
64
67
|
import { SIGN_IN_SLIDES } from './artwork';
|
|
65
68
|
import { InlineCommonsQr } from './InlineCommonsQr';
|
|
66
69
|
import { OxyAccountPicker } from './OxyAccountPicker';
|
|
@@ -147,6 +150,9 @@ export const OxySignInPanel: React.FC<OxySignInPanelProps> = ({
|
|
|
147
150
|
}) => {
|
|
148
151
|
const theme = useTheme();
|
|
149
152
|
const { t } = useI18n();
|
|
153
|
+
const hostDialog = useAccountDialogHost();
|
|
154
|
+
// A prop wins; otherwise the hosting app's `OxyProvider`. Blank names none.
|
|
155
|
+
const resolvedAppName = (appName ?? hostDialog.appName)?.trim() || null;
|
|
150
156
|
const {
|
|
151
157
|
accountDialogController: controller,
|
|
152
158
|
openAccountDialog,
|
|
@@ -528,7 +534,7 @@ export const OxySignInPanel: React.FC<OxySignInPanelProps> = ({
|
|
|
528
534
|
return (
|
|
529
535
|
<OxyAccountPicker
|
|
530
536
|
principals={principals}
|
|
531
|
-
appName={
|
|
537
|
+
appName={resolvedAppName}
|
|
532
538
|
signedOut={!snapshot.hasSession}
|
|
533
539
|
pendingContextId={snapshot.activatingContextId}
|
|
534
540
|
isLoading={snapshot.activatingContextId !== null}
|
|
@@ -781,9 +787,12 @@ export const OxySignInPanel: React.FC<OxySignInPanelProps> = ({
|
|
|
781
787
|
const title = adding ? t('signin.addAccountTitle') : t('signin.title');
|
|
782
788
|
const description = adding
|
|
783
789
|
? t('signin.addAccountSubtitle')
|
|
784
|
-
:
|
|
785
|
-
? t('signin.subtitleToApp', { app:
|
|
790
|
+
: resolvedAppName
|
|
791
|
+
? t('signin.subtitleToApp', { app: resolvedAppName })
|
|
786
792
|
: t('signin.subtitle');
|
|
793
|
+
const oneAccount = resolvedAppName
|
|
794
|
+
? t('signin.oneAccountInApp', { app: resolvedAppName })
|
|
795
|
+
: t('signin.oneAccount');
|
|
787
796
|
|
|
788
797
|
const continueWithOxyButton = (
|
|
789
798
|
<Button
|
|
@@ -801,7 +810,22 @@ export const OxySignInPanel: React.FC<OxySignInPanelProps> = ({
|
|
|
801
810
|
|
|
802
811
|
form = (
|
|
803
812
|
<OxyAuthScreen inSplit={splits}>
|
|
804
|
-
<OxyAuthScreenHeader
|
|
813
|
+
<OxyAuthScreenHeader
|
|
814
|
+
title={title}
|
|
815
|
+
description={
|
|
816
|
+
<View style={styles.intro}>
|
|
817
|
+
<Text style={[styles.introLine, { color: theme.colors.textSecondary }]}>
|
|
818
|
+
{description}
|
|
819
|
+
</Text>
|
|
820
|
+
<Text
|
|
821
|
+
testID="signin-one-account"
|
|
822
|
+
style={[styles.oneAccount, { color: theme.colors.textSecondary }]}
|
|
823
|
+
>
|
|
824
|
+
{oneAccount}
|
|
825
|
+
</Text>
|
|
826
|
+
</View>
|
|
827
|
+
}
|
|
828
|
+
/>
|
|
805
829
|
|
|
806
830
|
{/* The Commons way in, then the email. On the web from `md` the QR
|
|
807
831
|
beside the form IS the Commons way in; below `md` this screen is
|
|
@@ -855,17 +879,6 @@ export const OxySignInPanel: React.FC<OxySignInPanelProps> = ({
|
|
|
855
879
|
autoFocus={device !== 'phone'}
|
|
856
880
|
testID="signin-identifier"
|
|
857
881
|
/>
|
|
858
|
-
<Text style={[styles.note, styles.noAccount, { color: theme.colors.textSecondary }]}>
|
|
859
|
-
{t('signin.noAccount')}{' '}
|
|
860
|
-
<RNText
|
|
861
|
-
accessibilityRole="link"
|
|
862
|
-
onPress={onCreateAccount}
|
|
863
|
-
style={[styles.noAccountLink, { color: theme.colors.text }]}
|
|
864
|
-
testID="create-account-link"
|
|
865
|
-
>
|
|
866
|
-
{t('signin.createAccount')}
|
|
867
|
-
</RNText>
|
|
868
|
-
</Text>
|
|
869
882
|
{rateLimitNotice}
|
|
870
883
|
<AccountFlowAction
|
|
871
884
|
label={t('signin.actions.continue')}
|
|
@@ -874,6 +887,22 @@ export const OxySignInPanel: React.FC<OxySignInPanelProps> = ({
|
|
|
874
887
|
disabled={rateLimitSeconds > 0}
|
|
875
888
|
testID="signin-identifier-continue"
|
|
876
889
|
/>
|
|
890
|
+
<View style={styles.createAccount}>
|
|
891
|
+
<Text style={[styles.createAccountPrompt, { color: theme.colors.textSecondary }]}>
|
|
892
|
+
{t('signin.noAccount')}
|
|
893
|
+
</Text>
|
|
894
|
+
<Button
|
|
895
|
+
appearance="outline"
|
|
896
|
+
tone="neutral"
|
|
897
|
+
size="lg"
|
|
898
|
+
fullWidth
|
|
899
|
+
onPress={onCreateAccount}
|
|
900
|
+
accessibilityLabel={t('signin.createAccount')}
|
|
901
|
+
testID="create-account-link"
|
|
902
|
+
>
|
|
903
|
+
{t('signin.createAccount')}
|
|
904
|
+
</Button>
|
|
905
|
+
</View>
|
|
877
906
|
</View>
|
|
878
907
|
<OxyAuthTerms />
|
|
879
908
|
</OxyAuthScreen>
|
|
@@ -911,10 +940,23 @@ const styles = StyleSheet.create({
|
|
|
911
940
|
lineHeight: 20,
|
|
912
941
|
textAlign: 'center',
|
|
913
942
|
},
|
|
914
|
-
|
|
915
|
-
|
|
943
|
+
intro: {
|
|
944
|
+
gap: 8,
|
|
945
|
+
},
|
|
946
|
+
introLine: {
|
|
947
|
+
fontSize: 18,
|
|
948
|
+
lineHeight: 28,
|
|
916
949
|
},
|
|
917
|
-
|
|
918
|
-
|
|
950
|
+
oneAccount: {
|
|
951
|
+
fontSize: 16,
|
|
952
|
+
lineHeight: 24,
|
|
953
|
+
},
|
|
954
|
+
createAccount: {
|
|
955
|
+
gap: 8,
|
|
956
|
+
},
|
|
957
|
+
createAccountPrompt: {
|
|
958
|
+
fontSize: 16,
|
|
959
|
+
lineHeight: 22,
|
|
960
|
+
textAlign: 'center',
|
|
919
961
|
},
|
|
920
962
|
});
|
|
@@ -10,16 +10,20 @@
|
|
|
10
10
|
* The email is confirmed before the account exists, and it is how the account
|
|
11
11
|
* signs in (a code or a link each time). A password and an authenticator app
|
|
12
12
|
* are added later, in the account's security settings. Commons stays the way to
|
|
13
|
-
* hold your own key:
|
|
14
|
-
* makes the account self-custodied
|
|
13
|
+
* hold your own key: the username step says what that means, then "Create it in
|
|
14
|
+
* Commons instead" — and linking Commons later makes the account self-custodied
|
|
15
|
+
* and deletes the email. A host may preview the profile the username becomes
|
|
16
|
+
* (`handlePreviewTemplate`); this screen never names an app's domain itself.
|
|
15
17
|
*/
|
|
16
18
|
|
|
17
19
|
import type React from 'react';
|
|
18
20
|
import { useEffect, useState } from 'react';
|
|
19
|
-
import { Linking, Platform, View } from 'react-native';
|
|
21
|
+
import { Linking, Platform, StyleSheet, View } from 'react-native';
|
|
20
22
|
import { DatePicker } from '@oxy.so/bloom/date-picker';
|
|
21
23
|
import { TextFieldLabel } from '@oxy.so/bloom/text-field';
|
|
24
|
+
import { useTheme } from '@oxy.so/bloom/theme';
|
|
22
25
|
import { toast } from '@oxy.so/bloom/toast';
|
|
26
|
+
import { Text } from '@oxy.so/bloom/typography';
|
|
23
27
|
import type { EmailVerificationConfirmResponse } from '@oxy.so/contracts';
|
|
24
28
|
import {
|
|
25
29
|
MIN_BIRTH_YEAR,
|
|
@@ -33,11 +37,18 @@ import {
|
|
|
33
37
|
import { useOxy } from '../../context/oxyRuntimeContext';
|
|
34
38
|
import { useAccountDialogSnapshot } from '../../hooks/accountDialogSnapshot';
|
|
35
39
|
import { useI18n } from '../../hooks/useI18n';
|
|
40
|
+
import { useUsernameAvailability } from '../../hooks/useUsernameAvailability';
|
|
36
41
|
import { getCommonsAcquisitionUrl } from '../../utils/commonsStoreLinks';
|
|
37
42
|
import { isWebBrowser } from '../../utils/isWebBrowser';
|
|
38
43
|
import { fromCalendarDate, toCalendarDate } from '../../utils/calendarDate';
|
|
44
|
+
import { renderHandlePreview } from '../../utils/handlePreview';
|
|
45
|
+
import {
|
|
46
|
+
shareUsernameLookup,
|
|
47
|
+
usernameLookupCooldownSeconds,
|
|
48
|
+
} from '../../utils/usernameLookupBudget';
|
|
39
49
|
import { checkUsernameDraft, describeUsernameRefusal } from '../../utils/usernamePolicy';
|
|
40
50
|
import { SubtleLink } from '../authChooser/primitives';
|
|
51
|
+
import { useAccountDialogHost } from '../accountDialogHost';
|
|
41
52
|
import { OxyAuthScreen, OxyAuthScreenHeader, OxyAuthTerms } from './OxyAuthScreen';
|
|
42
53
|
import { readSignInFlow, writeSignInFlow } from './signInFlowStore';
|
|
43
54
|
import {
|
|
@@ -70,6 +81,14 @@ export interface OxySignUpPanelProps {
|
|
|
70
81
|
* this screen (`signInFlowStore`). `page` — a page of its own.
|
|
71
82
|
*/
|
|
72
83
|
host?: 'dialog' | 'page';
|
|
84
|
+
/**
|
|
85
|
+
* Preview of the public profile this username becomes. `{username}` is
|
|
86
|
+
* replaced with the typed handle. The host writes its own origin, for
|
|
87
|
+
* example `{base}/@{username}` with that base already filled in. Omitted,
|
|
88
|
+
* the screen uses the template from `OxyProvider`, or shows none. Wins over
|
|
89
|
+
* the provider when both are set.
|
|
90
|
+
*/
|
|
91
|
+
handlePreviewTemplate?: string | null;
|
|
73
92
|
}
|
|
74
93
|
|
|
75
94
|
/** What the dialog keeps of this screen across a remount. */
|
|
@@ -86,8 +105,11 @@ export const OxySignUpPanel: React.FC<OxySignUpPanelProps> = ({
|
|
|
86
105
|
onSignedIn,
|
|
87
106
|
onSignIn,
|
|
88
107
|
host = 'page',
|
|
108
|
+
handlePreviewTemplate,
|
|
89
109
|
}) => {
|
|
110
|
+
const theme = useTheme();
|
|
90
111
|
const { t } = useI18n();
|
|
112
|
+
const hostDialog = useAccountDialogHost();
|
|
91
113
|
const {
|
|
92
114
|
oxyServices,
|
|
93
115
|
handleWebSession,
|
|
@@ -104,6 +126,22 @@ export const OxySignUpPanel: React.FC<OxySignUpPanelProps> = ({
|
|
|
104
126
|
const [dateOfBirth, setDateOfBirth] = useState(saved?.dateOfBirth ?? '');
|
|
105
127
|
const [pending, setPending] = useState(false);
|
|
106
128
|
const [error, setError] = useState<string | null>(null);
|
|
129
|
+
// A new account is not the one already signed in on this device, so a matching
|
|
130
|
+
// handle is checked rather than treated as "unchanged".
|
|
131
|
+
const availability = useUsernameAvailability(username, step.name === 'username', {
|
|
132
|
+
matchCurrentUser: false,
|
|
133
|
+
// Preview lookups share the ten-a-minute quota with the check below.
|
|
134
|
+
reserveSubmit: true,
|
|
135
|
+
});
|
|
136
|
+
const previewTemplate = (handlePreviewTemplate ?? hostDialog.handlePreviewTemplate)?.trim() || '';
|
|
137
|
+
const handlePreview = renderHandlePreview(previewTemplate, username);
|
|
138
|
+
const liveTaken =
|
|
139
|
+
!error && availability.status === 'taken' && availability.candidate === username.trim();
|
|
140
|
+
const showAvailable =
|
|
141
|
+
!error &&
|
|
142
|
+
availability.status === 'available' &&
|
|
143
|
+
availability.candidate === username.trim() &&
|
|
144
|
+
username.trim().length > 0;
|
|
107
145
|
|
|
108
146
|
useEffect(() => {
|
|
109
147
|
writeSignInFlow(flowOwner, SIGN_UP_FLOW_KEY, {
|
|
@@ -141,9 +179,23 @@ export const OxySignUpPanel: React.FC<OxySignUpPanelProps> = ({
|
|
|
141
179
|
}
|
|
142
180
|
const handle = draft.username;
|
|
143
181
|
setUsername(handle);
|
|
182
|
+
// The live check already answered for this exact handle.
|
|
183
|
+
if (availability.status === 'taken' && availability.candidate === handle) {
|
|
184
|
+
setError(t('signup.username.taken'));
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
144
187
|
run(async () => {
|
|
145
|
-
|
|
146
|
-
|
|
188
|
+
// Reuses the preview's answer for this exact handle, or the one lookup
|
|
189
|
+
// the preview left unused. Past that, wait out the window — sending
|
|
190
|
+
// would be refused and the refusal would count too.
|
|
191
|
+
const outcome = await shareUsernameLookup(handle, 'submit', (name) =>
|
|
192
|
+
oxyServices.auth.checkUsername(name),
|
|
193
|
+
);
|
|
194
|
+
if (outcome === 'deferred') {
|
|
195
|
+
setError(t('signin.errors.rateLimited', { seconds: usernameLookupCooldownSeconds() }));
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
if (!outcome.available) throw new UsernameTakenError();
|
|
147
199
|
setStep({ name: 'birthdate' });
|
|
148
200
|
});
|
|
149
201
|
};
|
|
@@ -344,33 +396,57 @@ export const OxySignUpPanel: React.FC<OxySignUpPanelProps> = ({
|
|
|
344
396
|
<OxyAuthScreen>
|
|
345
397
|
<OxyAuthScreenHeader title={t('signup.title')} description={t('signup.subtitle')} />
|
|
346
398
|
{progress(0)}
|
|
347
|
-
<
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
399
|
+
<View style={styles.usernameBlock}>
|
|
400
|
+
<AccountFlowField
|
|
401
|
+
label={t('signup.username.label')}
|
|
402
|
+
value={username}
|
|
403
|
+
onChange={(value) => {
|
|
404
|
+
setUsername(stripDisallowedUsernameCharacters(value));
|
|
405
|
+
if (error) setError(null);
|
|
406
|
+
}}
|
|
407
|
+
onSubmit={submitUsername}
|
|
408
|
+
error={error ?? (liveTaken ? t('signup.username.taken') : null)}
|
|
409
|
+
disabled={pending}
|
|
410
|
+
placeholder={t('signup.username.placeholder')}
|
|
411
|
+
hint={t('usernamePolicy.hint')}
|
|
412
|
+
maxLength={USERNAME_MAX_LENGTH}
|
|
413
|
+
autoComplete="username"
|
|
414
|
+
testID="signup-username"
|
|
415
|
+
/>
|
|
416
|
+
{showAvailable ? (
|
|
417
|
+
<Text
|
|
418
|
+
testID="signup-username-status"
|
|
419
|
+
accessibilityLiveRegion="polite"
|
|
420
|
+
style={[styles.status, { color: theme.colors.success }]}
|
|
421
|
+
>
|
|
422
|
+
{t('signup.username.available')}
|
|
423
|
+
</Text>
|
|
424
|
+
) : null}
|
|
425
|
+
{handlePreview ? (
|
|
426
|
+
<Text
|
|
427
|
+
testID="signup-handle-preview"
|
|
428
|
+
style={[styles.status, { color: theme.colors.textSecondary }]}
|
|
429
|
+
>
|
|
430
|
+
{handlePreview}
|
|
431
|
+
</Text>
|
|
432
|
+
) : null}
|
|
433
|
+
</View>
|
|
363
434
|
<AccountFlowAction
|
|
364
435
|
label={t('signin.actions.continue')}
|
|
365
436
|
onPress={submitUsername}
|
|
366
437
|
pending={pending}
|
|
367
438
|
testID="signup-username-continue"
|
|
368
439
|
/>
|
|
369
|
-
<
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
440
|
+
<View style={styles.commons}>
|
|
441
|
+
<AccountFlowNote testID="signup-commons-note">
|
|
442
|
+
{t('signup.commonsSubtitle')}
|
|
443
|
+
</AccountFlowNote>
|
|
444
|
+
<SubtleLink
|
|
445
|
+
label={t('signup.createInCommons')}
|
|
446
|
+
onPress={createInCommons}
|
|
447
|
+
testID="signup-commons-instead"
|
|
448
|
+
/>
|
|
449
|
+
</View>
|
|
374
450
|
<SubtleLink
|
|
375
451
|
label={t('signup.backToSignInLink')}
|
|
376
452
|
onPress={onSignIn}
|
|
@@ -384,3 +460,16 @@ export const OxySignUpPanel: React.FC<OxySignUpPanelProps> = ({
|
|
|
384
460
|
|
|
385
461
|
/** The username was taken between typing it and creating the account. */
|
|
386
462
|
class UsernameTakenError extends Error {}
|
|
463
|
+
|
|
464
|
+
const styles = StyleSheet.create({
|
|
465
|
+
usernameBlock: {
|
|
466
|
+
gap: 8,
|
|
467
|
+
},
|
|
468
|
+
status: {
|
|
469
|
+
fontSize: 16,
|
|
470
|
+
lineHeight: 22,
|
|
471
|
+
},
|
|
472
|
+
commons: {
|
|
473
|
+
gap: 8,
|
|
474
|
+
},
|
|
475
|
+
});
|
|
@@ -1,19 +1,44 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
2
|
import { useOxy } from '../context/oxyRuntimeContext';
|
|
3
|
+
import { shareUsernameLookup } from '../utils/usernameLookupBudget';
|
|
3
4
|
import { checkUsernameDraft } from '../utils/usernamePolicy';
|
|
4
5
|
import { useI18n } from './useI18n';
|
|
5
6
|
|
|
6
|
-
type CheckResult = {
|
|
7
|
+
type CheckResult = {
|
|
8
|
+
candidate: string;
|
|
9
|
+
status: 'available' | 'taken' | 'error' | 'deferred';
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export interface UsernameAvailabilityOptions {
|
|
13
|
+
/**
|
|
14
|
+
* When true (the default), a handle that already belongs to the signed-in
|
|
15
|
+
* account is "unchanged" and is not sent to the server. Signup passes false:
|
|
16
|
+
* a new account needs its own free handle, even on a device that is signed in.
|
|
17
|
+
*/
|
|
18
|
+
matchCurrentUser?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Count preview lookups against the production ten-a-minute quota and stop
|
|
21
|
+
* one short of it. Signup sets this so Continue still has a lookup left.
|
|
22
|
+
* Profile editing leaves it off: saving there does not look the name up again.
|
|
23
|
+
*/
|
|
24
|
+
reserveSubmit?: boolean;
|
|
25
|
+
}
|
|
7
26
|
|
|
8
27
|
/** Debounced server check; a response only applies to the draft that requested it. */
|
|
9
|
-
export function useUsernameAvailability(
|
|
28
|
+
export function useUsernameAvailability(
|
|
29
|
+
value: string,
|
|
30
|
+
enabled: boolean,
|
|
31
|
+
options?: UsernameAvailabilityOptions,
|
|
32
|
+
) {
|
|
10
33
|
const { oxyServices, user } = useOxy();
|
|
11
34
|
const { t } = useI18n();
|
|
35
|
+
const matchCurrentUser = options?.matchCurrentUser !== false;
|
|
36
|
+
const reserveSubmit = options?.reserveSubmit === true;
|
|
12
37
|
const candidate = value.trim();
|
|
13
38
|
// The policy of the signed-in account's kind: a bot's handle ends in `bot`.
|
|
14
39
|
const checked = enabled ? checkUsernameDraft(candidate, t, user?.kind) : null;
|
|
15
40
|
const invalid = checked && !checked.ok ? checked.error : undefined;
|
|
16
|
-
const unchanged = candidate.toLowerCase() === user?.username?.toLowerCase();
|
|
41
|
+
const unchanged = matchCurrentUser && candidate.toLowerCase() === user?.username?.toLowerCase();
|
|
17
42
|
const [result, setResult] = useState<CheckResult>();
|
|
18
43
|
const [attempt, setAttempt] = useState(0);
|
|
19
44
|
|
|
@@ -23,9 +48,19 @@ export function useUsernameAvailability(value: string, enabled: boolean) {
|
|
|
23
48
|
setResult(undefined);
|
|
24
49
|
let active = true;
|
|
25
50
|
const timer = setTimeout(() => {
|
|
26
|
-
|
|
27
|
-
(
|
|
28
|
-
|
|
51
|
+
const lookup = reserveSubmit
|
|
52
|
+
? shareUsernameLookup(candidate, 'background', (name) =>
|
|
53
|
+
oxyServices.auth.checkUsername(name),
|
|
54
|
+
)
|
|
55
|
+
: oxyServices.auth.checkUsername(candidate).then(({ available }) => ({ available }));
|
|
56
|
+
void lookup.then(
|
|
57
|
+
(outcome) => {
|
|
58
|
+
if (!active) return;
|
|
59
|
+
if (outcome === 'deferred') {
|
|
60
|
+
setResult({ candidate, status: 'deferred' });
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
setResult({ candidate, status: outcome.available ? 'available' : 'taken' });
|
|
29
64
|
},
|
|
30
65
|
() => {
|
|
31
66
|
if (active) setResult({ candidate, status: 'error' });
|
|
@@ -36,7 +71,7 @@ export function useUsernameAvailability(value: string, enabled: boolean) {
|
|
|
36
71
|
active = false;
|
|
37
72
|
clearTimeout(timer);
|
|
38
73
|
};
|
|
39
|
-
}, [candidate, enabled, invalid, unchanged, oxyServices, attempt]);
|
|
74
|
+
}, [candidate, enabled, invalid, unchanged, oxyServices, attempt, reserveSubmit]);
|
|
40
75
|
|
|
41
76
|
const status = !enabled
|
|
42
77
|
? 'idle'
|
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { createHash } from 'node:crypto';
|
|
7
7
|
import { OxyServices } from '@oxy.so/core';
|
|
8
|
+
import { logger } from '@oxy.so/core';
|
|
8
9
|
import {
|
|
10
|
+
BRIDGE_UNREACHABLE_WARNING,
|
|
9
11
|
OXY_BRIDGE_CODE_MESSAGE_TYPE,
|
|
10
12
|
OXY_BRIDGE_ERROR_MESSAGE_TYPE,
|
|
11
13
|
OXY_BRIDGE_WINDOW_NAME,
|
|
@@ -196,9 +198,13 @@ describe('runBrowserBridge', () => {
|
|
|
196
198
|
clientId: 'c',
|
|
197
199
|
redirectUri: APP,
|
|
198
200
|
});
|
|
201
|
+
const warn = jest.spyOn(logger, 'warn').mockImplementation(() => undefined);
|
|
199
202
|
await navigated(popup);
|
|
200
203
|
popup.close();
|
|
201
204
|
expect(await result).toEqual({ ok: false, reason: 'closed' });
|
|
205
|
+
// oxy#2368: a severed opener looks exactly like this, so it says so.
|
|
206
|
+
expect(warn).toHaveBeenCalledWith(BRIDGE_UNREACHABLE_WARNING, { component: 'browserBridge' });
|
|
207
|
+
expect(BRIDGE_UNREACHABLE_WARNING).toContain('same-origin-allow-popups');
|
|
202
208
|
|
|
203
209
|
popup = fakePopup();
|
|
204
210
|
result = runBrowserBridge({
|
|
@@ -39,6 +39,12 @@ export const OXY_BRIDGE_WINDOW_NAME = 'oxy-bridge';
|
|
|
39
39
|
*/
|
|
40
40
|
export const DEFAULT_BRIDGE_TIMEOUT_MS = 15_000;
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* What a bridge window that closed without answering logs. Exported for tests.
|
|
44
|
+
*/
|
|
45
|
+
export const BRIDGE_UNREACHABLE_WARNING =
|
|
46
|
+
"The browser bridge window closed without answering, so this app signs in on a device of its own and the browser's shared session never sees the account. If this page sends `Cross-Origin-Opener-Policy: same-origin`, the bridge cannot reach window.opener: send `same-origin-allow-popups` (the `@oxy.so/core/server` default, ADR 0029 D2).";
|
|
47
|
+
|
|
42
48
|
const CLOSE_POLL_INTERVAL_MS = 250;
|
|
43
49
|
const CLOSE_GRACE_MS = 300;
|
|
44
50
|
|
|
@@ -190,6 +196,13 @@ export async function runBrowserBridge(
|
|
|
190
196
|
expectedState: state,
|
|
191
197
|
timeoutMs: options.timeoutMs ?? DEFAULT_BRIDGE_TIMEOUT_MS,
|
|
192
198
|
});
|
|
199
|
+
if (verdict.kind === 'closed') {
|
|
200
|
+
// Nobody closes a 1x1 window that answers in a few hundred ms. A window
|
|
201
|
+
// that is gone before it answered is almost always an opener the page's
|
|
202
|
+
// own `Cross-Origin-Opener-Policy: same-origin` severed (oxy#2368): the
|
|
203
|
+
// bridge got its code and had nobody to post it to.
|
|
204
|
+
logger.warn(BRIDGE_UNREACHABLE_WARNING, { component: 'browserBridge' });
|
|
205
|
+
}
|
|
193
206
|
if (verdict.kind !== 'code') return { ok: false, reason: verdict.kind };
|
|
194
207
|
|
|
195
208
|
try {
|
|
@@ -27,8 +27,8 @@ import { useSurfaceHeader } from '../hooks/useSurfaceHeader';
|
|
|
27
27
|
|
|
28
28
|
const apps = {
|
|
29
29
|
personal: ['alia', 'mention', 'inbox', 'noted', 'clarity', 'homiio'],
|
|
30
|
-
creator: ['alia', 'mention', 'inbox', 'noted', 'clarity', '
|
|
31
|
-
business: ['alia', 'mention', 'inbox', 'noted', 'clarity'
|
|
30
|
+
creator: ['alia', 'mention', 'inbox', 'noted', 'clarity', 'mercaria'],
|
|
31
|
+
business: ['alia', 'mention', 'inbox', 'noted', 'clarity'],
|
|
32
32
|
} as const;
|
|
33
33
|
|
|
34
34
|
/** The shared Bloom presentation, populated with Oxy's approved commercial terms.
|