@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.
Files changed (84) hide show
  1. package/lib/commonjs/index.js +19 -0
  2. package/lib/commonjs/index.js.map +1 -1
  3. package/lib/commonjs/ui/components/OxyAuthChooser.js +5 -2
  4. package/lib/commonjs/ui/components/OxyAuthChooser.js.map +1 -1
  5. package/lib/commonjs/ui/components/OxySurfaceFrame.js +28 -0
  6. package/lib/commonjs/ui/components/OxySurfaceFrame.js.map +1 -0
  7. package/lib/commonjs/ui/components/signIn/OxySignInPanel.js +8 -5
  8. package/lib/commonjs/ui/components/signIn/OxySignInPanel.js.map +1 -1
  9. package/lib/commonjs/ui/components/signIn/signInMethods.js +12 -10
  10. package/lib/commonjs/ui/components/signIn/signInMethods.js.map +1 -1
  11. package/lib/commonjs/ui/context/OxyContext.js +4 -3
  12. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  13. package/lib/commonjs/ui/hooks/useSurfaceFrameWidth.js +3 -0
  14. package/lib/commonjs/ui/hooks/useSurfaceFrameWidth.js.map +1 -1
  15. package/lib/commonjs/ui/utils/deliveryPlatform.js +8 -4
  16. package/lib/commonjs/ui/utils/deliveryPlatform.js.map +1 -1
  17. package/lib/commonjs/ui/utils/signInDevice.js +32 -0
  18. package/lib/commonjs/ui/utils/signInDevice.js.map +1 -0
  19. package/lib/module/index.js +6 -0
  20. package/lib/module/index.js.map +1 -1
  21. package/lib/module/ui/components/OxyAuthChooser.js +5 -2
  22. package/lib/module/ui/components/OxyAuthChooser.js.map +1 -1
  23. package/lib/module/ui/components/OxySurfaceFrame.js +23 -0
  24. package/lib/module/ui/components/OxySurfaceFrame.js.map +1 -0
  25. package/lib/module/ui/components/signIn/OxySignInPanel.js +8 -5
  26. package/lib/module/ui/components/signIn/OxySignInPanel.js.map +1 -1
  27. package/lib/module/ui/components/signIn/signInMethods.js +12 -10
  28. package/lib/module/ui/components/signIn/signInMethods.js.map +1 -1
  29. package/lib/module/ui/context/OxyContext.js +4 -3
  30. package/lib/module/ui/context/OxyContext.js.map +1 -1
  31. package/lib/module/ui/hooks/useSurfaceFrameWidth.js +3 -0
  32. package/lib/module/ui/hooks/useSurfaceFrameWidth.js.map +1 -1
  33. package/lib/module/ui/utils/deliveryPlatform.js +8 -4
  34. package/lib/module/ui/utils/deliveryPlatform.js.map +1 -1
  35. package/lib/module/ui/utils/signInDevice.js +28 -0
  36. package/lib/module/ui/utils/signInDevice.js.map +1 -0
  37. package/lib/typescript/commonjs/index.d.ts +4 -0
  38. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  39. package/lib/typescript/commonjs/ui/components/OxyAuthChooser.d.ts +5 -2
  40. package/lib/typescript/commonjs/ui/components/OxyAuthChooser.d.ts.map +1 -1
  41. package/lib/typescript/commonjs/ui/components/OxySurfaceFrame.d.ts +18 -0
  42. package/lib/typescript/commonjs/ui/components/OxySurfaceFrame.d.ts.map +1 -0
  43. package/lib/typescript/commonjs/ui/components/signIn/OxySignInPanel.d.ts +4 -2
  44. package/lib/typescript/commonjs/ui/components/signIn/OxySignInPanel.d.ts.map +1 -1
  45. package/lib/typescript/commonjs/ui/components/signIn/signInMethods.d.ts +15 -12
  46. package/lib/typescript/commonjs/ui/components/signIn/signInMethods.d.ts.map +1 -1
  47. package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
  48. package/lib/typescript/commonjs/ui/hooks/useSurfaceFrameWidth.d.ts +3 -0
  49. package/lib/typescript/commonjs/ui/hooks/useSurfaceFrameWidth.d.ts.map +1 -1
  50. package/lib/typescript/commonjs/ui/utils/deliveryPlatform.d.ts +4 -2
  51. package/lib/typescript/commonjs/ui/utils/deliveryPlatform.d.ts.map +1 -1
  52. package/lib/typescript/commonjs/ui/utils/identityCrypto.d.ts +7 -0
  53. package/lib/typescript/commonjs/ui/utils/identityCrypto.d.ts.map +1 -1
  54. package/lib/typescript/commonjs/ui/utils/signInDevice.d.ts +21 -0
  55. package/lib/typescript/commonjs/ui/utils/signInDevice.d.ts.map +1 -0
  56. package/lib/typescript/module/index.d.ts +4 -0
  57. package/lib/typescript/module/index.d.ts.map +1 -1
  58. package/lib/typescript/module/ui/components/OxyAuthChooser.d.ts +5 -2
  59. package/lib/typescript/module/ui/components/OxyAuthChooser.d.ts.map +1 -1
  60. package/lib/typescript/module/ui/components/OxySurfaceFrame.d.ts +18 -0
  61. package/lib/typescript/module/ui/components/OxySurfaceFrame.d.ts.map +1 -0
  62. package/lib/typescript/module/ui/components/signIn/OxySignInPanel.d.ts +4 -2
  63. package/lib/typescript/module/ui/components/signIn/OxySignInPanel.d.ts.map +1 -1
  64. package/lib/typescript/module/ui/components/signIn/signInMethods.d.ts +15 -12
  65. package/lib/typescript/module/ui/components/signIn/signInMethods.d.ts.map +1 -1
  66. package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
  67. package/lib/typescript/module/ui/hooks/useSurfaceFrameWidth.d.ts +3 -0
  68. package/lib/typescript/module/ui/hooks/useSurfaceFrameWidth.d.ts.map +1 -1
  69. package/lib/typescript/module/ui/utils/deliveryPlatform.d.ts +4 -2
  70. package/lib/typescript/module/ui/utils/deliveryPlatform.d.ts.map +1 -1
  71. package/lib/typescript/module/ui/utils/identityCrypto.d.ts +7 -0
  72. package/lib/typescript/module/ui/utils/identityCrypto.d.ts.map +1 -1
  73. package/lib/typescript/module/ui/utils/signInDevice.d.ts +21 -0
  74. package/lib/typescript/module/ui/utils/signInDevice.d.ts.map +1 -0
  75. package/package.json +3 -3
  76. package/src/index.ts +9 -0
  77. package/src/ui/components/OxyAuthChooser.tsx +5 -2
  78. package/src/ui/components/OxySurfaceFrame.tsx +25 -0
  79. package/src/ui/components/signIn/OxySignInPanel.tsx +8 -5
  80. package/src/ui/components/signIn/signInMethods.ts +16 -13
  81. package/src/ui/context/OxyContext.tsx +4 -3
  82. package/src/ui/hooks/useSurfaceFrameWidth.ts +3 -0
  83. package/src/ui/utils/deliveryPlatform.ts +8 -4
  84. 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. On
12
- * native it is "Continue with Oxy" ("Get Commons" without Commons).
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 { isWebBrowser } from '../../utils/isWebBrowser';
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
- web: isWebBrowser(),
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={Platform.OS === 'web'}
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 where it runs. Every
3
- * surface also takes an email or username (`OxySignInPanel`), in place:
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
- * - the web: the embedded QR (the split card's right column from `md`, with
6
- * "Continue with Oxy" below `md`, where the screen is the phone that would
7
- * scan it);
8
- * - native: "Continue with Oxy", and "Get Commons" on a device that has no
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` — the web: the embedded QR from `md`, "Continue with Oxy" below.
16
- * `continue` — native "Continue with Oxy": Oxy picks the route (shared
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` — native, and Commons is not installed here.
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
- /** Rendering in a browser (react-native-web), not a native app. */
28
- web: boolean;
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.web) return { commons: 'qr' };
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
- // Native-only probe so the controller can detect an installed Commons and
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: isWebBrowser() ? undefined : (url) => Linking.canOpenURL(url),
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 { isWebBrowser } from './isWebBrowser';
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
- * - Native (Expo/RN) is always `'mobile'`: it is an Oxy app installed on a
43
- * phone/tablet, exactly the case where a verified Commons link can resolve
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
- if (!isWebBrowser()) return 'mobile';
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
+ }