@oxy.so/services 14.14.0 → 14.15.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.
- package/lib/commonjs/index.js +19 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/ui/components/OxyAuthChooser.js +5 -2
- package/lib/commonjs/ui/components/OxyAuthChooser.js.map +1 -1
- package/lib/commonjs/ui/components/OxySurfaceFrame.js +28 -0
- package/lib/commonjs/ui/components/OxySurfaceFrame.js.map +1 -0
- package/lib/commonjs/ui/components/signIn/OxySignInPanel.js +8 -5
- package/lib/commonjs/ui/components/signIn/OxySignInPanel.js.map +1 -1
- package/lib/commonjs/ui/components/signIn/signInMethods.js +12 -10
- package/lib/commonjs/ui/components/signIn/signInMethods.js.map +1 -1
- package/lib/commonjs/ui/context/OxyContext.js +4 -3
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/hooks/useSurfaceFrameWidth.js +3 -0
- package/lib/commonjs/ui/hooks/useSurfaceFrameWidth.js.map +1 -1
- package/lib/commonjs/ui/utils/deliveryPlatform.js +8 -4
- package/lib/commonjs/ui/utils/deliveryPlatform.js.map +1 -1
- package/lib/commonjs/ui/utils/signInDevice.js +32 -0
- package/lib/commonjs/ui/utils/signInDevice.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/ui/components/OxyAuthChooser.js +5 -2
- package/lib/module/ui/components/OxyAuthChooser.js.map +1 -1
- package/lib/module/ui/components/OxySurfaceFrame.js +23 -0
- package/lib/module/ui/components/OxySurfaceFrame.js.map +1 -0
- package/lib/module/ui/components/signIn/OxySignInPanel.js +8 -5
- package/lib/module/ui/components/signIn/OxySignInPanel.js.map +1 -1
- package/lib/module/ui/components/signIn/signInMethods.js +12 -10
- package/lib/module/ui/components/signIn/signInMethods.js.map +1 -1
- package/lib/module/ui/context/OxyContext.js +4 -3
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/hooks/useSurfaceFrameWidth.js +3 -0
- package/lib/module/ui/hooks/useSurfaceFrameWidth.js.map +1 -1
- package/lib/module/ui/utils/deliveryPlatform.js +8 -4
- package/lib/module/ui/utils/deliveryPlatform.js.map +1 -1
- package/lib/module/ui/utils/signInDevice.js +28 -0
- package/lib/module/ui/utils/signInDevice.js.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +4 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/OxyAuthChooser.d.ts +5 -2
- package/lib/typescript/commonjs/ui/components/OxyAuthChooser.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/OxySurfaceFrame.d.ts +18 -0
- package/lib/typescript/commonjs/ui/components/OxySurfaceFrame.d.ts.map +1 -0
- 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/signInMethods.d.ts +15 -12
- package/lib/typescript/commonjs/ui/components/signIn/signInMethods.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/useSurfaceFrameWidth.d.ts +3 -0
- package/lib/typescript/commonjs/ui/hooks/useSurfaceFrameWidth.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/utils/deliveryPlatform.d.ts +4 -2
- package/lib/typescript/commonjs/ui/utils/deliveryPlatform.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/utils/identityCrypto.d.ts +7 -0
- package/lib/typescript/commonjs/ui/utils/identityCrypto.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/utils/signInDevice.d.ts +21 -0
- package/lib/typescript/commonjs/ui/utils/signInDevice.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +4 -0
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/OxyAuthChooser.d.ts +5 -2
- package/lib/typescript/module/ui/components/OxyAuthChooser.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/OxySurfaceFrame.d.ts +18 -0
- package/lib/typescript/module/ui/components/OxySurfaceFrame.d.ts.map +1 -0
- 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/signInMethods.d.ts +15 -12
- package/lib/typescript/module/ui/components/signIn/signInMethods.d.ts.map +1 -1
- package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/useSurfaceFrameWidth.d.ts +3 -0
- package/lib/typescript/module/ui/hooks/useSurfaceFrameWidth.d.ts.map +1 -1
- package/lib/typescript/module/ui/utils/deliveryPlatform.d.ts +4 -2
- package/lib/typescript/module/ui/utils/deliveryPlatform.d.ts.map +1 -1
- package/lib/typescript/module/ui/utils/identityCrypto.d.ts +7 -0
- package/lib/typescript/module/ui/utils/identityCrypto.d.ts.map +1 -1
- package/lib/typescript/module/ui/utils/signInDevice.d.ts +21 -0
- package/lib/typescript/module/ui/utils/signInDevice.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/index.ts +9 -0
- package/src/ui/components/OxyAuthChooser.tsx +5 -2
- package/src/ui/components/OxySurfaceFrame.tsx +25 -0
- package/src/ui/components/signIn/OxySignInPanel.tsx +8 -5
- package/src/ui/components/signIn/signInMethods.ts +16 -13
- package/src/ui/context/OxyContext.tsx +4 -3
- package/src/ui/hooks/useSurfaceFrameWidth.ts +3 -0
- package/src/ui/utils/deliveryPlatform.ts +8 -4
- package/src/ui/utils/signInDevice.ts +28 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A platform's own card around the account chooser (`OxyAuthChooser`), as the
|
|
3
|
+
* account dialog is the card around it in an app: OxyOS's login screen shows
|
|
4
|
+
* the SDK's sign-in on a card of its own (OxyOS ADR 0020, decision 4).
|
|
5
|
+
*
|
|
6
|
+
* Inside it the chooser's screens ask for the width their views need exactly as
|
|
7
|
+
* they ask the account dialog (`useSurfaceFrameWidth`: the sign-in's split card,
|
|
8
|
+
* with the Commons QR, asks for 880 from `md`; `null` when no longer needed).
|
|
9
|
+
* The platform sizes its card to the width asked, up to what its screen has.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type React from 'react';
|
|
13
|
+
import { SurfaceFrameWidthContext } from '../hooks/useSurfaceFrameWidth';
|
|
14
|
+
|
|
15
|
+
export interface OxySurfaceFrameProps {
|
|
16
|
+
/** The width (px, the card's own padding included) a screen inside asks for; `null` for the card's own. */
|
|
17
|
+
onMaxWidthChange: (maxWidth: number | null) => void;
|
|
18
|
+
children: React.ReactNode;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const OxySurfaceFrame: React.FC<OxySurfaceFrameProps> = ({ onMaxWidthChange, children }) => (
|
|
22
|
+
<SurfaceFrameWidthContext.Provider value={onMaxWidthChange}>
|
|
23
|
+
{children}
|
|
24
|
+
</SurfaceFrameWidthContext.Provider>
|
|
25
|
+
);
|
|
@@ -8,8 +8,10 @@
|
|
|
8
8
|
* Continue. On the web, from `md`, the screen is Bloom `AuthCard`'s
|
|
9
9
|
* split card and the Commons way in is the embedded QR over its
|
|
10
10
|
* photo carousel, in the right column (the account dialog grows to
|
|
11
|
-
* that card); below `md` it is "Continue with Oxy" at the top.
|
|
12
|
-
* native
|
|
11
|
+
* that card); below `md` it is "Continue with Oxy" at the top. A
|
|
12
|
+
* native app on a computer (OxyOS, macOS) is the same as the web:
|
|
13
|
+
* it shows the QR a phone scans. On a phone it is "Continue with
|
|
14
|
+
* Oxy" ("Get Commons" without Commons).
|
|
13
15
|
* check-email one email carries a code and a link. The code is typed here: 6
|
|
14
16
|
* digits, or — "Does your code have letters?" — the 10-character
|
|
15
17
|
* long code an account past its daily guessing ceiling is sent
|
|
@@ -59,7 +61,7 @@ import { useDeviceSwitcher } from '../../hooks/useDeviceSwitcher';
|
|
|
59
61
|
import { useI18n } from '../../hooks/useI18n';
|
|
60
62
|
import { useSurfaceFrameWidth } from '../../hooks/useSurfaceFrameWidth';
|
|
61
63
|
import { getCommonsAcquisitionUrl } from '../../utils/commonsStoreLinks';
|
|
62
|
-
import {
|
|
64
|
+
import { resolveSignInDevice } from '../../utils/signInDevice';
|
|
63
65
|
import { SubtleLink } from '../authChooser/primitives';
|
|
64
66
|
import { SIGN_IN_SLIDES } from './artwork';
|
|
65
67
|
import { InlineCommonsQr } from './InlineCommonsQr';
|
|
@@ -150,8 +152,9 @@ export const OxySignInPanel: React.FC<OxySignInPanelProps> = ({
|
|
|
150
152
|
const snapshot = useAccountDialogSnapshot(controller);
|
|
151
153
|
const { principals, activeContext } = useDeviceSwitcher();
|
|
152
154
|
|
|
155
|
+
const device = resolveSignInDevice();
|
|
153
156
|
const methods = resolveSignInMethods({
|
|
154
|
-
|
|
157
|
+
device,
|
|
155
158
|
commonsAvailability: snapshot.commonsAvailability,
|
|
156
159
|
});
|
|
157
160
|
|
|
@@ -826,7 +829,7 @@ export const OxySignInPanel: React.FC<OxySignInPanelProps> = ({
|
|
|
826
829
|
autoComplete="username"
|
|
827
830
|
keyboardType="email-address"
|
|
828
831
|
maxLength={SIGN_IN_IDENTIFIER_MAX_LENGTH}
|
|
829
|
-
autoFocus={
|
|
832
|
+
autoFocus={device !== 'phone'}
|
|
830
833
|
testID="signin-identifier"
|
|
831
834
|
/>
|
|
832
835
|
<Text style={[styles.note, styles.noAccount, { color: theme.colors.textSecondary }]}>
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Which Commons way in a sign-in surface offers, from
|
|
3
|
-
* surface also takes an email or username
|
|
2
|
+
* Which Commons way in a sign-in surface offers, from the device it runs on
|
|
3
|
+
* (`resolveSignInDevice`). Every surface also takes an email or username
|
|
4
|
+
* (`OxySignInPanel`), in place:
|
|
4
5
|
*
|
|
5
|
-
* -
|
|
6
|
-
* "Continue with Oxy" below `md`, where the
|
|
7
|
-
*
|
|
8
|
-
* -
|
|
6
|
+
* - a browser or a computer: the embedded QR a phone scans (the split card's
|
|
7
|
+
* right column from `md`, with "Continue with Oxy" below `md`, where the
|
|
8
|
+
* screen is as narrow as a phone's);
|
|
9
|
+
* - a phone: "Continue with Oxy", and "Get Commons" on a phone that has no
|
|
9
10
|
* Commons to continue with.
|
|
10
11
|
*/
|
|
11
12
|
|
|
12
13
|
import type { CommonsAvailability } from '@oxy.so/core/session';
|
|
14
|
+
import type { SignInDevice } from '../../utils/signInDevice';
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
|
-
* `qr` —
|
|
16
|
-
*
|
|
17
|
+
* `qr` — a browser or a computer: the embedded QR from `md`,
|
|
18
|
+
* "Continue with Oxy" below.
|
|
19
|
+
* `continue` — a phone's "Continue with Oxy": Oxy picks the route (shared
|
|
17
20
|
* keychain, Commons on this device, a push, or the QR view).
|
|
18
|
-
* `get-commons` —
|
|
21
|
+
* `get-commons` — a phone, and Commons is not installed on it.
|
|
19
22
|
*/
|
|
20
23
|
export type CommonsEntry = 'qr' | 'continue' | 'get-commons';
|
|
21
24
|
|
|
@@ -24,13 +27,13 @@ export interface SignInMethods {
|
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
export interface SignInSurfaceFacts {
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
/** The controller's native probe for an installed Commons. */
|
|
30
|
+
/** What the surface runs on (`resolveSignInDevice`). */
|
|
31
|
+
device: SignInDevice;
|
|
32
|
+
/** The controller's native probe for an installed Commons (phones only). */
|
|
30
33
|
commonsAvailability: CommonsAvailability;
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
export function resolveSignInMethods(facts: SignInSurfaceFacts): SignInMethods {
|
|
34
|
-
if (facts.
|
|
37
|
+
if (facts.device !== 'phone') return { commons: 'qr' };
|
|
35
38
|
return { commons: facts.commonsAvailability === 'unavailable' ? 'get-commons' : 'continue' };
|
|
36
39
|
}
|
|
@@ -62,6 +62,7 @@ import {
|
|
|
62
62
|
import { isWebBrowser } from '../utils/isWebBrowser';
|
|
63
63
|
import { loadIdentityCrypto } from '../utils/identityCrypto';
|
|
64
64
|
import { resolveDeliveryPlatform } from '../utils/deliveryPlatform';
|
|
65
|
+
import { resolveSignInDevice } from '../utils/signInDevice';
|
|
65
66
|
import { runProviderColdBoot } from '../boot/runProviderColdBoot';
|
|
66
67
|
import { resolveApplicationSessionLane } from '../oauth/applicationSessionLane';
|
|
67
68
|
import { handleAuthError } from '../utils/errorHandlers';
|
|
@@ -1095,12 +1096,12 @@ export const OxyRuntimeProvider: React.FC<OxyRuntimeProviderProps> = ({
|
|
|
1095
1096
|
}
|
|
1096
1097
|
void Linking.openURL(url);
|
|
1097
1098
|
},
|
|
1098
|
-
//
|
|
1099
|
+
// A phone's probe so the controller can detect an installed Commons and
|
|
1099
1100
|
// deep-link straight into its approve screen (keeping the QR/polling live
|
|
1100
1101
|
// as fallback). `undefined` on web mirrors the `openUrl` split — the
|
|
1101
1102
|
// controller short-circuits, so `redirectToAuthorize` never runs for the
|
|
1102
|
-
// `oxycommons://` payload.
|
|
1103
|
-
canOpenApp:
|
|
1103
|
+
// `oxycommons://` payload — and on a computer, which Commons never runs on.
|
|
1104
|
+
canOpenApp: resolveSignInDevice() === 'phone' ? (url) => Linking.canOpenURL(url) : undefined,
|
|
1104
1105
|
// Which surface a sign-in starts from — a FACT only this consumer can
|
|
1105
1106
|
// supply (headless core never touches a platform global). It decides
|
|
1106
1107
|
// whether automatic delivery may take the same-device Commons deep link;
|
|
@@ -7,6 +7,9 @@ import { createContext, useContext, useLayoutEffect } from 'react';
|
|
|
7
7
|
* a screen whose views need different widths (the account dialog: the 420 menu,
|
|
8
8
|
* the sign-in's 880 split card) hands its width to that host rather than
|
|
9
9
|
* declaring a second frame. A change morphs the centered card to it.
|
|
10
|
+
*
|
|
11
|
+
* A platform that shows the account chooser on a card of its own (OxyOS's
|
|
12
|
+
* login screen, `OxySurfaceFrame`) provides it too: that card is the surface.
|
|
10
13
|
*/
|
|
11
14
|
export const SurfaceFrameWidthContext = createContext<((maxWidth: number | null) => void) | null>(
|
|
12
15
|
null,
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
import type { CommonsDeliveryPlatform } from '@oxy.so/core';
|
|
23
|
-
import {
|
|
23
|
+
import { resolveSignInDevice } from './signInDevice';
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* The `navigator.userAgentData` slice this module reads. Declared locally
|
|
@@ -39,15 +39,19 @@ type NavigatorWithUserAgentData = Navigator & {
|
|
|
39
39
|
/**
|
|
40
40
|
* Which surface this app is running on, as `selectCommonsDelivery` models it.
|
|
41
41
|
*
|
|
42
|
-
* -
|
|
43
|
-
*
|
|
42
|
+
* - A native app on a phone or tablet (`resolveSignInDevice`: iOS, Android)
|
|
43
|
+
* is `'mobile'`: exactly the case where a verified Commons link can resolve
|
|
44
44
|
* on this very device.
|
|
45
|
+
* - A native app on a computer (react-native-macos, OxyOS) is `'desktop'`:
|
|
46
|
+
* Commons is a phone's, so no link to it resolves here.
|
|
45
47
|
* - A web browser is classified from the signals above.
|
|
46
48
|
* - Anything else — a browser-like environment with neither signal — is
|
|
47
49
|
* `'unknown'`, a first-class value that never opts into the deep link.
|
|
48
50
|
*/
|
|
49
51
|
export function resolveDeliveryPlatform(): CommonsDeliveryPlatform {
|
|
50
|
-
|
|
52
|
+
const device = resolveSignInDevice();
|
|
53
|
+
if (device === 'phone') return 'mobile';
|
|
54
|
+
if (device === 'computer') return 'desktop';
|
|
51
55
|
|
|
52
56
|
const nav: NavigatorWithUserAgentData | undefined =
|
|
53
57
|
typeof navigator === 'undefined' ? undefined : navigator;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What kind of device an Oxy sign-in runs on. The sign-in screen and its
|
|
3
|
+
* Commons delivery decide by it (`resolveSignInMethods`,
|
|
4
|
+
* `resolveDeliveryPlatform`):
|
|
5
|
+
*
|
|
6
|
+
* - `browser` — react-native-web in a browser, on a phone or a computer
|
|
7
|
+
* (`resolveDeliveryPlatform` tells those apart);
|
|
8
|
+
* - `phone` — a native app on a phone or tablet (iOS, Android): the device
|
|
9
|
+
* Commons lives on, and the one that scans a QR;
|
|
10
|
+
* - `computer` — a native app on a computer (react-native-macos, OxyOS, any
|
|
11
|
+
* other desktop platform): no Commons to continue with and no
|
|
12
|
+
* camera to scan with. Like a browser on a computer, it SHOWS
|
|
13
|
+
* the QR a phone scans.
|
|
14
|
+
*
|
|
15
|
+
* A native platform is a phone only by name (`ios`, `android`); every other
|
|
16
|
+
* one is a computer, so a desktop platform the SDK does not know yet gets the
|
|
17
|
+
* QR rather than a "Continue with Oxy" that has nowhere to go.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { Platform } from 'react-native';
|
|
21
|
+
import { isWebBrowser } from './isWebBrowser';
|
|
22
|
+
|
|
23
|
+
export type SignInDevice = 'browser' | 'phone' | 'computer';
|
|
24
|
+
|
|
25
|
+
export function resolveSignInDevice(): SignInDevice {
|
|
26
|
+
if (isWebBrowser()) return 'browser';
|
|
27
|
+
return Platform.OS === 'ios' || Platform.OS === 'android' ? 'phone' : 'computer';
|
|
28
|
+
}
|