@oxy.so/services 14.13.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/ios/OxyIdentityModule.swift +38 -3
- 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/session/sharedDeviceCredentialStore.js +22 -2
- package/lib/commonjs/ui/session/sharedDeviceCredentialStore.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/session/sharedDeviceCredentialStore.js +23 -3
- package/lib/module/ui/session/sharedDeviceCredentialStore.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/session/sharedDeviceCredentialStore.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/session/sharedDeviceCredentialStore.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 +4 -4
- 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/session/__tests__/sharedDeviceCredentialStore.test.ts +74 -7
- package/src/ui/session/sharedDeviceCredentialStore.ts +26 -5
- package/src/ui/utils/deliveryPlatform.ts +8 -4
- package/src/ui/utils/signInDevice.ts +28 -0
|
@@ -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,
|
|
@@ -87,17 +87,40 @@ function loadStore(
|
|
|
87
87
|
broker?: BrokerModule | null;
|
|
88
88
|
/** What `resolveKeychainAccess` answers (an Error: throws); default: a build without the probe. */
|
|
89
89
|
access?: KeychainAccess | Error;
|
|
90
|
+
/**
|
|
91
|
+
* The OxyIdentity native read that never prompts (R6-16): `(key, service,
|
|
92
|
+
* group)`. Absent: a native module that predates it.
|
|
93
|
+
*/
|
|
94
|
+
nativeRead?: (
|
|
95
|
+
key: string,
|
|
96
|
+
service: string | undefined,
|
|
97
|
+
group: string,
|
|
98
|
+
) => Promise<string | null>;
|
|
90
99
|
} = {},
|
|
91
100
|
): SharedDeviceCredentialStore | null {
|
|
92
101
|
jest.resetModules();
|
|
93
102
|
const access: KeychainAccess | Error = seams.access ?? { mode: 'ungrouped' };
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
103
|
+
const nativeRead = seams.nativeRead;
|
|
104
|
+
jest.doMock('@oxy.so/core/session', () => {
|
|
105
|
+
const actual = jest.requireActual('@oxy.so/core/session');
|
|
106
|
+
return {
|
|
107
|
+
...actual,
|
|
108
|
+
resolveKeychainAccess: async () => {
|
|
109
|
+
if (access instanceof Error) throw access;
|
|
110
|
+
return access;
|
|
111
|
+
},
|
|
112
|
+
// Core's reader with the native read the module would load on a device.
|
|
113
|
+
readSharedWithoutInteraction: async (
|
|
114
|
+
store: { getItemAsync(key: string, options?: object): Promise<string | null> },
|
|
115
|
+
key: string,
|
|
116
|
+
options: { keychainService?: string },
|
|
117
|
+
shared: { accessGroup?: string },
|
|
118
|
+
) =>
|
|
119
|
+
nativeRead && shared.accessGroup
|
|
120
|
+
? nativeRead(key, options.keychainService, shared.accessGroup)
|
|
121
|
+
: actual.readSharedWithoutInteraction(store, key, options, shared),
|
|
122
|
+
};
|
|
123
|
+
});
|
|
101
124
|
jest.doMock('expo-modules-core', () => ({
|
|
102
125
|
requireOptionalNativeModule: () => seams.broker ?? null,
|
|
103
126
|
requireNativeModule: () => {
|
|
@@ -224,6 +247,50 @@ describe('iOS keychain-group slot', () => {
|
|
|
224
247
|
expect(secureStore.calls.length).toBeGreaterThan(2);
|
|
225
248
|
});
|
|
226
249
|
|
|
250
|
+
test('reads never prompt: they go through the non-interactive native read, not expo-secure-store (R6-16)', async () => {
|
|
251
|
+
// Any Oxy app can plant `oxy_device_session:auth` in the shared group;
|
|
252
|
+
// expo-secure-store's read would try it and show Face ID in every app.
|
|
253
|
+
const secureStore = makeSecureStoreMock();
|
|
254
|
+
const reads: Array<[string, string | undefined, string]> = [];
|
|
255
|
+
const store = loadStore('ios', {
|
|
256
|
+
secureStore,
|
|
257
|
+
access: {
|
|
258
|
+
mode: 'grouped',
|
|
259
|
+
prefix: 'ABCDE12345.',
|
|
260
|
+
defaultGroup: 'ABCDE12345.group.so.oxy.shared',
|
|
261
|
+
role: 'member',
|
|
262
|
+
},
|
|
263
|
+
nativeRead: async (key, service, group) => {
|
|
264
|
+
reads.push([key, service, group]);
|
|
265
|
+
return secureStore.items.get(key) ?? null;
|
|
266
|
+
},
|
|
267
|
+
});
|
|
268
|
+
await expect(store?.read()).resolves.toEqual({ state: 'absent' });
|
|
269
|
+
await expect(store?.publish(CRED)).resolves.toBe(true);
|
|
270
|
+
await expect(store?.read()).resolves.toEqual({ state: 'present', credential: CRED });
|
|
271
|
+
expect(reads).toEqual(
|
|
272
|
+
Array(3).fill([STORAGE_KEY, 'oxy_device_session', 'ABCDE12345.group.so.oxy.shared']),
|
|
273
|
+
);
|
|
274
|
+
// expo-secure-store only WROTE; it never read.
|
|
275
|
+
expect(secureStore.calls.map((call) => call.key)).toEqual([STORAGE_KEY]);
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
test('a locked keychain (the native read throws) is unavailable, never absent', async () => {
|
|
279
|
+
const store = loadStore('ios', {
|
|
280
|
+
secureStore: makeSecureStoreMock(),
|
|
281
|
+
access: {
|
|
282
|
+
mode: 'grouped',
|
|
283
|
+
prefix: 'ABCDE12345.',
|
|
284
|
+
defaultGroup: 'ABCDE12345.group.so.oxy.shared',
|
|
285
|
+
role: 'member',
|
|
286
|
+
},
|
|
287
|
+
nativeRead: async () => {
|
|
288
|
+
throw new Error('keychain locked');
|
|
289
|
+
},
|
|
290
|
+
});
|
|
291
|
+
expect((await store?.read())?.state).toBe('unavailable');
|
|
292
|
+
});
|
|
293
|
+
|
|
227
294
|
test('a build without the keychain probe names no group (its one group is its default)', async () => {
|
|
228
295
|
const secureStore = makeSecureStoreMock();
|
|
229
296
|
const store = loadStore('ios', { secureStore });
|
|
@@ -43,6 +43,7 @@ import type { SecureStoreOptions } from 'expo-secure-store';
|
|
|
43
43
|
import {
|
|
44
44
|
keychainAccessGroupValue,
|
|
45
45
|
normalizeSharedDeviceSessionRead,
|
|
46
|
+
readSharedWithoutInteraction,
|
|
46
47
|
resolveKeychainAccess,
|
|
47
48
|
type SharedDeviceCredential,
|
|
48
49
|
type SharedDeviceCredentialRead,
|
|
@@ -167,6 +168,29 @@ async function sharedGroupOptions(): Promise<SecureStoreOptions> {
|
|
|
167
168
|
};
|
|
168
169
|
}
|
|
169
170
|
|
|
171
|
+
/**
|
|
172
|
+
* Read the credential item WITHOUT user interaction (security review R6-16).
|
|
173
|
+
* Every Oxy app can write the shared group, so any of them can plant an
|
|
174
|
+
* `oxy_device_session:auth` copy (an item stored with `requireAuthentication`);
|
|
175
|
+
* expo-secure-store's own read tries that copy and would show a Face ID prompt
|
|
176
|
+
* in every Oxy app at cold boot. `readSharedWithoutInteraction` reads only the
|
|
177
|
+
* `:no-auth` and legacy copies, with interaction refused; a native module that
|
|
178
|
+
* predates it reads through expo-secure-store as before. A locked keychain
|
|
179
|
+
* still THROWS (services' native read since 14.14.0), which is `unavailable`.
|
|
180
|
+
*/
|
|
181
|
+
async function readSharedItem(
|
|
182
|
+
store: KeychainGroupStore,
|
|
183
|
+
options: SecureStoreOptions,
|
|
184
|
+
): Promise<string | null> {
|
|
185
|
+
const { accessGroup, ...rest } = options;
|
|
186
|
+
return readSharedWithoutInteraction(
|
|
187
|
+
store,
|
|
188
|
+
SHARED_DEVICE_SESSION_STORAGE_KEY,
|
|
189
|
+
rest,
|
|
190
|
+
accessGroup ? { accessGroup } : {},
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
|
|
170
194
|
function createKeychainGroupCredentialStore(): SharedDeviceCredentialStore {
|
|
171
195
|
return {
|
|
172
196
|
read: async (): Promise<SharedDeviceCredentialRead> => {
|
|
@@ -176,10 +200,7 @@ function createKeychainGroupCredentialStore(): SharedDeviceCredentialStore {
|
|
|
176
200
|
}
|
|
177
201
|
let raw: string | null;
|
|
178
202
|
try {
|
|
179
|
-
raw = await store
|
|
180
|
-
SHARED_DEVICE_SESSION_STORAGE_KEY,
|
|
181
|
-
await sharedGroupOptions(),
|
|
182
|
-
);
|
|
203
|
+
raw = await readSharedItem(store, await sharedGroupOptions());
|
|
183
204
|
} catch (error) {
|
|
184
205
|
return { state: 'unavailable', cause: error };
|
|
185
206
|
}
|
|
@@ -214,7 +235,7 @@ function createKeychainGroupCredentialStore(): SharedDeviceCredentialStore {
|
|
|
214
235
|
// landed under the access group (a missing entitlement is the usual
|
|
215
236
|
// cause), and a phantom credential would send a fresh install into a mint
|
|
216
237
|
// that can never succeed.
|
|
217
|
-
return (await store
|
|
238
|
+
return (await readSharedItem(store, readOptions)) === value;
|
|
218
239
|
} catch {
|
|
219
240
|
return false;
|
|
220
241
|
}
|
|
@@ -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
|
+
}
|