@oxy.so/services 14.10.0 → 14.11.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 +10 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/ui/boot/runProviderColdBoot.js +3 -1
- package/lib/commonjs/ui/boot/runProviderColdBoot.js.map +1 -1
- package/lib/commonjs/ui/components/OxyProvider.js +52 -18
- package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
- package/lib/commonjs/ui/context/OxyContext.js +15 -5
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/context/OxyHostedContext.js +515 -0
- package/lib/commonjs/ui/context/OxyHostedContext.js.map +1 -0
- package/lib/commonjs/ui/context/oxyRuntimeContext.js.map +1 -1
- package/lib/commonjs/ui/hooks/useAuth.js +13 -2
- package/lib/commonjs/ui/hooks/useAuth.js.map +1 -1
- package/lib/commonjs/ui/hooks/useOxyEvent.js +9 -5
- package/lib/commonjs/ui/hooks/useOxyEvent.js.map +1 -1
- package/lib/commonjs/ui/session/hostSession.js +474 -0
- package/lib/commonjs/ui/session/hostSession.js.map +1 -0
- package/lib/module/index.js +3 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/ui/boot/runProviderColdBoot.js +3 -1
- package/lib/module/ui/boot/runProviderColdBoot.js.map +1 -1
- package/lib/module/ui/components/OxyProvider.js +53 -19
- package/lib/module/ui/components/OxyProvider.js.map +1 -1
- package/lib/module/ui/context/OxyContext.js +15 -5
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/context/OxyHostedContext.js +510 -0
- package/lib/module/ui/context/OxyHostedContext.js.map +1 -0
- package/lib/module/ui/context/oxyRuntimeContext.js.map +1 -1
- package/lib/module/ui/hooks/useAuth.js +13 -2
- package/lib/module/ui/hooks/useAuth.js.map +1 -1
- package/lib/module/ui/hooks/useOxyEvent.js +9 -5
- package/lib/module/ui/hooks/useOxyEvent.js.map +1 -1
- package/lib/module/ui/session/hostSession.js +467 -0
- package/lib/module/ui/session/hostSession.js.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +1 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/boot/runProviderColdBoot.d.ts +6 -0
- package/lib/typescript/commonjs/ui/boot/runProviderColdBoot.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/OxyProvider.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/context/OxyHostedContext.d.ts +40 -0
- package/lib/typescript/commonjs/ui/context/OxyHostedContext.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/context/oxyContextTypes.d.ts +19 -2
- package/lib/typescript/commonjs/ui/context/oxyContextTypes.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/context/oxyRuntimeContext.d.ts +6 -0
- package/lib/typescript/commonjs/ui/context/oxyRuntimeContext.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/useAuth.d.ts +3 -0
- package/lib/typescript/commonjs/ui/hooks/useAuth.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/useOxyEvent.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/session/hostSession.d.ts +69 -0
- package/lib/typescript/commonjs/ui/session/hostSession.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/types/navigation.d.ts +24 -1
- package/lib/typescript/commonjs/ui/types/navigation.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/utils/identityCrypto.d.ts +9 -0
- package/lib/typescript/commonjs/ui/utils/identityCrypto.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +1 -0
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/ui/boot/runProviderColdBoot.d.ts +6 -0
- package/lib/typescript/module/ui/boot/runProviderColdBoot.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/OxyProvider.d.ts.map +1 -1
- package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/module/ui/context/OxyHostedContext.d.ts +40 -0
- package/lib/typescript/module/ui/context/OxyHostedContext.d.ts.map +1 -0
- package/lib/typescript/module/ui/context/oxyContextTypes.d.ts +19 -2
- package/lib/typescript/module/ui/context/oxyContextTypes.d.ts.map +1 -1
- package/lib/typescript/module/ui/context/oxyRuntimeContext.d.ts +6 -0
- package/lib/typescript/module/ui/context/oxyRuntimeContext.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/useAuth.d.ts +3 -0
- package/lib/typescript/module/ui/hooks/useAuth.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/useOxyEvent.d.ts.map +1 -1
- package/lib/typescript/module/ui/session/hostSession.d.ts +69 -0
- package/lib/typescript/module/ui/session/hostSession.d.ts.map +1 -0
- package/lib/typescript/module/ui/types/navigation.d.ts +24 -1
- package/lib/typescript/module/ui/types/navigation.d.ts.map +1 -1
- package/lib/typescript/module/ui/utils/identityCrypto.d.ts +9 -0
- package/lib/typescript/module/ui/utils/identityCrypto.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +3 -0
- package/src/ui/boot/runProviderColdBoot.ts +12 -1
- package/src/ui/components/OxyProvider.tsx +77 -34
- package/src/ui/context/OxyContext.tsx +19 -4
- package/src/ui/context/OxyHostedContext.tsx +678 -0
- package/src/ui/context/oxyContextTypes.ts +21 -2
- package/src/ui/context/oxyRuntimeContext.ts +9 -1
- package/src/ui/hooks/useAuth.ts +13 -1
- package/src/ui/hooks/useOxyEvent.ts +8 -5
- package/src/ui/session/hostSession.ts +515 -0
- package/src/ui/types/navigation.ts +24 -1
|
@@ -0,0 +1,510 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The provider's runtime on a platform that holds the Oxy session (ADR 0058
|
|
5
|
+
* decision 1): OxyOS's Bloom host, Astro's verified pages.
|
|
6
|
+
*
|
|
7
|
+
* `OxyProvider` mounts this instead of `OxyRuntimeProvider` when, at mount, a
|
|
8
|
+
* session host is registered (`@oxy.so/core/host`) and `sessionMode` is
|
|
9
|
+
* `'account'`. The hooks and the context are the same; the session source is
|
|
10
|
+
* the host:
|
|
11
|
+
*
|
|
12
|
+
* - WIRED: the token (`session/hostSession.ts`), the account from the host's
|
|
13
|
+
* snapshot, every API namespace, `createLinkedClient`, the user socket
|
|
14
|
+
* (bearer only, `user:<id>`), the account cache, the language.
|
|
15
|
+
* - SKIPPED: the auth-state store (nothing persisted), every cold-boot lane,
|
|
16
|
+
* the OAuth return lane, the identity pin, `SessionClient` and the device
|
|
17
|
+
* directory, the switcher, `setDeviceCredentialProvider`, the browser bridge,
|
|
18
|
+
* the background credential, the account dialog's sign-in screens. Nothing
|
|
19
|
+
* here calls `/session/device/*`.
|
|
20
|
+
* - HANDED OVER: `signIn()`, `openAccountDialog()`, a switch and `logout()`
|
|
21
|
+
* call `host.request(...)` and change nothing themselves; the result comes
|
|
22
|
+
* back as a snapshot.
|
|
23
|
+
*
|
|
24
|
+
* A host with a contract this SDK does not know leaves the app signed out:
|
|
25
|
+
* the platform holds the session and forbids a second credential.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';
|
|
29
|
+
import { OxyServices, logger as loggerUtil } from '@oxy.so/core';
|
|
30
|
+
import { createUserEventSocket } from '@oxy.so/core/session';
|
|
31
|
+
import { useQueryClient } from '@tanstack/react-query';
|
|
32
|
+
import { installNativeAssetFiles } from '../utils/nativeAssetFiles';
|
|
33
|
+
import { hasKnownSubjectMismatch, useKnownBearerSubject } from "../hooks/useKnownBearerSubject.js";
|
|
34
|
+
import { createOxyRuntime, OxyRuntimeHandleProvider, useRuntimeSnapshot } from "../runtime/index.js";
|
|
35
|
+
import { bindAuthStoreToRuntime } from "../stores/authStore.js";
|
|
36
|
+
import { resetSessionScopedStores } from "../stores/resetSessionScopedStores.js";
|
|
37
|
+
import { ASSET_DOWNLOAD_URLS_QUERY_KEY } from "../hooks/useResolvedFileUrls.js";
|
|
38
|
+
import { clearQueryCache } from "../hooks/queryClient.js";
|
|
39
|
+
import { createAccountQueryPersistence } from "../hooks/accountQueryPersistence.js";
|
|
40
|
+
import { useEntryLink } from "../hooks/useEntryLink.js";
|
|
41
|
+
import { useLanguageManagement } from "../hooks/useLanguageManagement.js";
|
|
42
|
+
import { useAvatarPicker } from "../hooks/useAvatarPicker.js";
|
|
43
|
+
import { useFollow } from "../hooks/useFollow.js";
|
|
44
|
+
import { getStorageKeys, createMemoryStorage, createPlatformStorage } from "../utils/storageHelpers.js";
|
|
45
|
+
import { showBottomSheet as globalShowBottomSheet } from "../navigation/bottomSheetManager.js";
|
|
46
|
+
import { registerAccountDialogControls, notifyAccountDialogVisibility } from "../navigation/accountDialogManager.js";
|
|
47
|
+
import { createHostSession, HostedSessionError } from "../session/hostSession.js";
|
|
48
|
+
import { AppAssertionProvider } from "../appAssertion/AppAssertionContext.js";
|
|
49
|
+
import { OxyRuntimeContext, OxyAuthActionsContext } from "./oxyRuntimeContext.js";
|
|
50
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
51
|
+
/** The device-session seam of the runtime, empty: a hosted app has no device. */
|
|
52
|
+
const NO_DEVICE = {
|
|
53
|
+
getState: () => null,
|
|
54
|
+
getDirectory: () => null,
|
|
55
|
+
subscribe: () => () => undefined,
|
|
56
|
+
refreshDirectory: async () => undefined,
|
|
57
|
+
activateContext: async () => {
|
|
58
|
+
throw new HostedSessionError('activateContext');
|
|
59
|
+
},
|
|
60
|
+
signOutContext: async () => {
|
|
61
|
+
throw new HostedSessionError('signOutContext');
|
|
62
|
+
},
|
|
63
|
+
signOutPrincipal: async () => {
|
|
64
|
+
throw new HostedSessionError('signOutPrincipal');
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const NO_DEVICE_HOST = {
|
|
68
|
+
setCurrentAccountId: () => undefined
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Which of the platform's screens an `openAccountDialog(view)` asks for: its
|
|
73
|
+
* sign-in when signed out; while signed in, every view of the dialog — the
|
|
74
|
+
* switcher, "add an account", a sign-in for another account — is the
|
|
75
|
+
* platform's account switch.
|
|
76
|
+
*/
|
|
77
|
+
function requestForDialog(signedIn) {
|
|
78
|
+
return signedIn ? 'switch_account' : 'sign_in';
|
|
79
|
+
}
|
|
80
|
+
export const OxyHostedRuntimeProvider = ({
|
|
81
|
+
children,
|
|
82
|
+
session,
|
|
83
|
+
oxyServices: providedOxyServices,
|
|
84
|
+
baseURL,
|
|
85
|
+
authWebUrl,
|
|
86
|
+
authRedirectUri,
|
|
87
|
+
storageKeyPrefix = 'oxy_session',
|
|
88
|
+
clientId: clientIdProp,
|
|
89
|
+
webAuthMode = 'popup',
|
|
90
|
+
legacyLanguageKeys,
|
|
91
|
+
captureCampaignAttribution = false,
|
|
92
|
+
platformStorage,
|
|
93
|
+
accountQueries,
|
|
94
|
+
onAuthStateChange,
|
|
95
|
+
onError
|
|
96
|
+
}) => {
|
|
97
|
+
const oxyServicesRef = useRef(null);
|
|
98
|
+
if (!oxyServicesRef.current) {
|
|
99
|
+
if (providedOxyServices) {
|
|
100
|
+
oxyServicesRef.current = providedOxyServices;
|
|
101
|
+
} else if (baseURL) {
|
|
102
|
+
oxyServicesRef.current = new OxyServices({
|
|
103
|
+
baseURL,
|
|
104
|
+
authWebUrl,
|
|
105
|
+
authRedirectUri,
|
|
106
|
+
enableCache: false
|
|
107
|
+
});
|
|
108
|
+
} else {
|
|
109
|
+
throw new Error('Either oxyServices or baseURL must be provided to OxyProvider');
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const oxyServices = oxyServicesRef.current;
|
|
113
|
+
useLayoutEffect(() => installNativeAssetFiles(oxyServices), [oxyServices]);
|
|
114
|
+
const logger = useCallback((message, err) => {
|
|
115
|
+
if (__DEV__) {
|
|
116
|
+
loggerUtil.warn(message, {
|
|
117
|
+
component: 'OxyHostedContext'
|
|
118
|
+
}, err);
|
|
119
|
+
}
|
|
120
|
+
}, []);
|
|
121
|
+
const subjectChangeRef = useRef(() => undefined);
|
|
122
|
+
const runtimeRef = useRef(null);
|
|
123
|
+
if (!runtimeRef.current) {
|
|
124
|
+
runtimeRef.current = createOxyRuntime({
|
|
125
|
+
oxyServices,
|
|
126
|
+
sessionClient: NO_DEVICE,
|
|
127
|
+
sessionClientHost: NO_DEVICE_HOST,
|
|
128
|
+
identity: null,
|
|
129
|
+
onSubjectChange: transition => subjectChangeRef.current(transition),
|
|
130
|
+
onDeviceEmpty: async () => undefined,
|
|
131
|
+
logger
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
const runtime = runtimeRef.current;
|
|
135
|
+
const host = 'host' in session ? session.host : null;
|
|
136
|
+
|
|
137
|
+
// The user socket: the app token's `user:<id>` room, nothing of the device.
|
|
138
|
+
const userSocketRef = useRef(null);
|
|
139
|
+
if (host && !userSocketRef.current) {
|
|
140
|
+
userSocketRef.current = createUserEventSocket({
|
|
141
|
+
baseURL: oxyServices.baseURL,
|
|
142
|
+
getAccessToken: () => oxyServices.session.accessToken
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
const userSocket = userSocketRef.current;
|
|
146
|
+
const hostSessionRef = useRef(null);
|
|
147
|
+
if (host && !hostSessionRef.current) {
|
|
148
|
+
hostSessionRef.current = createHostSession({
|
|
149
|
+
host,
|
|
150
|
+
oxyServices,
|
|
151
|
+
runtime,
|
|
152
|
+
logger,
|
|
153
|
+
onTokenChange: kind => {
|
|
154
|
+
if (kind === 'account') userSocketRef.current?.restart();else userSocketRef.current?.sync();
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
const hostSession = hostSessionRef.current;
|
|
159
|
+
const snapshot = useRuntimeSnapshot(runtime);
|
|
160
|
+
const {
|
|
161
|
+
account: user,
|
|
162
|
+
sessions,
|
|
163
|
+
activeSessionId,
|
|
164
|
+
isLoading,
|
|
165
|
+
tokenReady,
|
|
166
|
+
hasAccessToken
|
|
167
|
+
} = snapshot;
|
|
168
|
+
const authResolved = snapshot.authResolved;
|
|
169
|
+
const isAuthenticated = user !== null;
|
|
170
|
+
const bearerSubject = useKnownBearerSubject(oxyServices);
|
|
171
|
+
const subjectMismatch = hasKnownSubjectMismatch(user?.id, bearerSubject);
|
|
172
|
+
const error = snapshot.error?.message ?? null;
|
|
173
|
+
useEffect(() => bindAuthStoreToRuntime(runtime), [runtime]);
|
|
174
|
+
const storageKeys = useMemo(() => getStorageKeys(storageKeyPrefix), [storageKeyPrefix]);
|
|
175
|
+
const clientId = useMemo(() => {
|
|
176
|
+
const trimmed = clientIdProp?.trim();
|
|
177
|
+
return trimmed ? trimmed : null;
|
|
178
|
+
}, [clientIdProp]);
|
|
179
|
+
const queryClient = useQueryClient();
|
|
180
|
+
const accountQueryPersistenceRef = useRef(null);
|
|
181
|
+
if (accountQueryPersistenceRef.current === null) {
|
|
182
|
+
accountQueryPersistenceRef.current = createAccountQueryPersistence(queryClient, accountQueries);
|
|
183
|
+
}
|
|
184
|
+
const accountQueryPersistence = accountQueryPersistenceRef.current;
|
|
185
|
+
useEffect(() => {
|
|
186
|
+
accountQueryPersistence.attach();
|
|
187
|
+
return () => accountQueryPersistence.detach();
|
|
188
|
+
}, [accountQueryPersistence]);
|
|
189
|
+
const isAccountCacheReady = useSyncExternalStore(accountQueryPersistence.subscribe, accountQueryPersistence.isReady, accountQueryPersistence.isReady);
|
|
190
|
+
|
|
191
|
+
// Display and cache storage (the query cache, the language, the campaign).
|
|
192
|
+
// Never a credential: a hosted provider persists no auth state at all.
|
|
193
|
+
const [storage, setStorage] = useState(null);
|
|
194
|
+
useEffect(() => {
|
|
195
|
+
if (platformStorage === null) return;
|
|
196
|
+
let mounted = true;
|
|
197
|
+
const storagePromise = platformStorage ? Promise.resolve(platformStorage) : createPlatformStorage();
|
|
198
|
+
storagePromise.then(storageInstance => {
|
|
199
|
+
accountQueryPersistence.setStorage(storageInstance);
|
|
200
|
+
if (mounted) {
|
|
201
|
+
setStorage(storageInstance);
|
|
202
|
+
runtime.setStorageReady(true);
|
|
203
|
+
}
|
|
204
|
+
}).catch(err => {
|
|
205
|
+
const memoryStorage = createMemoryStorage();
|
|
206
|
+
accountQueryPersistence.setStorage(memoryStorage);
|
|
207
|
+
if (mounted) {
|
|
208
|
+
setStorage(memoryStorage);
|
|
209
|
+
runtime.setStorageReady(true);
|
|
210
|
+
logger('Failed to initialize storage', err);
|
|
211
|
+
onError?.({
|
|
212
|
+
message: 'Failed to initialize storage',
|
|
213
|
+
code: 'STORAGE_INIT_ERROR',
|
|
214
|
+
status: 500
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
return () => {
|
|
219
|
+
mounted = false;
|
|
220
|
+
};
|
|
221
|
+
}, [accountQueryPersistence, logger, onError, platformStorage, runtime]);
|
|
222
|
+
|
|
223
|
+
// Follow the host once the account cache can be activated. With a host this
|
|
224
|
+
// SDK cannot speak to, resolve signed out and stay there.
|
|
225
|
+
const storageAvailable = storage !== null;
|
|
226
|
+
useEffect(() => {
|
|
227
|
+
if (!storageAvailable) return undefined;
|
|
228
|
+
if (!hostSession) {
|
|
229
|
+
runtime.markAuthResolved();
|
|
230
|
+
return undefined;
|
|
231
|
+
}
|
|
232
|
+
return hostSession.start();
|
|
233
|
+
}, [storageAvailable, hostSession, runtime]);
|
|
234
|
+
useEffect(() => () => {
|
|
235
|
+
userSocket?.stop();
|
|
236
|
+
}, [userSocket]);
|
|
237
|
+
const onAuthStateChangeRef = useRef(onAuthStateChange);
|
|
238
|
+
useEffect(() => {
|
|
239
|
+
onAuthStateChangeRef.current = onAuthStateChange;
|
|
240
|
+
}, [onAuthStateChange]);
|
|
241
|
+
const userId = user?.id ?? null;
|
|
242
|
+
const reportedUserIdRef = useRef(undefined);
|
|
243
|
+
useEffect(() => {
|
|
244
|
+
if (!authResolved || reportedUserIdRef.current === userId) return;
|
|
245
|
+
reportedUserIdRef.current = userId;
|
|
246
|
+
onAuthStateChangeRef.current?.(runtime.getSnapshot().account);
|
|
247
|
+
}, [authResolved, userId, runtime]);
|
|
248
|
+
const entryLink = useEntryLink({
|
|
249
|
+
storage,
|
|
250
|
+
storageKey: `${storageKeyPrefix}_campaign_attribution`,
|
|
251
|
+
captureCampaign: captureCampaignAttribution,
|
|
252
|
+
onError: logger
|
|
253
|
+
});
|
|
254
|
+
const {
|
|
255
|
+
currentLanguage,
|
|
256
|
+
isLanguageReady,
|
|
257
|
+
languages: currentLanguages,
|
|
258
|
+
metadata: currentLanguageMetadata,
|
|
259
|
+
languageName: currentLanguageName,
|
|
260
|
+
nativeLanguageName: currentNativeLanguageName,
|
|
261
|
+
setLanguage,
|
|
262
|
+
setLanguages
|
|
263
|
+
} = useLanguageManagement({
|
|
264
|
+
storage,
|
|
265
|
+
languageKey: storageKeys.language,
|
|
266
|
+
entryUrl: entryLink.url,
|
|
267
|
+
entryLinkReady: entryLink.ready,
|
|
268
|
+
legacyLanguageKeys,
|
|
269
|
+
user,
|
|
270
|
+
onError,
|
|
271
|
+
logger
|
|
272
|
+
});
|
|
273
|
+
const canUsePrivateApi = authResolved && isAuthenticated && tokenReady && hasAccessToken && !subjectMismatch;
|
|
274
|
+
const isPrivateApiPending = !authResolved || isAuthenticated && (!tokenReady || !hasAccessToken || subjectMismatch);
|
|
275
|
+
|
|
276
|
+
// ── The platform's requests ─────────────────────────────────────────────
|
|
277
|
+
const request = useCallback(async action => {
|
|
278
|
+
if (!hostSession) return;
|
|
279
|
+
await hostSession.request(action);
|
|
280
|
+
}, [hostSession]);
|
|
281
|
+
const signIn = useCallback(async () => {
|
|
282
|
+
await request('sign_in');
|
|
283
|
+
const account = runtime.getSnapshot().account;
|
|
284
|
+
if (account) return account;
|
|
285
|
+
throw new HostedSessionError('signIn');
|
|
286
|
+
}, [request, runtime]);
|
|
287
|
+
const openAccountDialog = useCallback(_view => {
|
|
288
|
+
const signedIn = runtime.getSnapshot().account !== null;
|
|
289
|
+
void request(requestForDialog(signedIn)).catch(requestError => {
|
|
290
|
+
logger('The platform could not show its account UI', requestError);
|
|
291
|
+
});
|
|
292
|
+
}, [request, runtime, logger]);
|
|
293
|
+
const closeAccountDialog = useCallback(() => undefined, []);
|
|
294
|
+
useEffect(() => registerAccountDialogControls({
|
|
295
|
+
open: openAccountDialog,
|
|
296
|
+
close: closeAccountDialog
|
|
297
|
+
}), [openAccountDialog, closeAccountDialog]);
|
|
298
|
+
useEffect(() => {
|
|
299
|
+
notifyAccountDialogVisibility(false);
|
|
300
|
+
}, []);
|
|
301
|
+
const logout = useCallback(async () => {
|
|
302
|
+
try {
|
|
303
|
+
await request('sign_out');
|
|
304
|
+
return {
|
|
305
|
+
status: 'requested'
|
|
306
|
+
};
|
|
307
|
+
} catch (logoutError) {
|
|
308
|
+
return {
|
|
309
|
+
status: 'failed',
|
|
310
|
+
error: logoutError
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
}, [request]);
|
|
314
|
+
const manageAccount = useCallback(async () => {
|
|
315
|
+
await request('manage_account');
|
|
316
|
+
}, [request]);
|
|
317
|
+
const switchToAccount = useCallback(async _accountId => {
|
|
318
|
+
await request('switch_account');
|
|
319
|
+
}, [request]);
|
|
320
|
+
const switchSession = useCallback(async _sessionId => {
|
|
321
|
+
await request('switch_account');
|
|
322
|
+
throw new HostedSessionError('switchSession');
|
|
323
|
+
}, [request]);
|
|
324
|
+
const refreshSessions = useCallback(async () => {
|
|
325
|
+
await hostSession?.refresh();
|
|
326
|
+
}, [hostSession]);
|
|
327
|
+
const platformOwns = useCallback(operation => () => Promise.reject(new HostedSessionError(operation)), []);
|
|
328
|
+
const handleWebSession = useMemo(() => platformOwns('handleWebSession'), [platformOwns]);
|
|
329
|
+
const getDeviceSessions = useMemo(() => platformOwns('getDeviceSessions'), [platformOwns]);
|
|
330
|
+
const updateDeviceName = useMemo(() => platformOwns('updateDeviceName'), [platformOwns]);
|
|
331
|
+
const startWebOAuthSignIn = useCallback(async () => ({
|
|
332
|
+
status: 'unsupported',
|
|
333
|
+
reason: 'no-browser'
|
|
334
|
+
}), []);
|
|
335
|
+
const startNativeOAuthSignIn = useCallback(async () => ({
|
|
336
|
+
status: 'unsupported',
|
|
337
|
+
reason: 'unsupported-platform'
|
|
338
|
+
}), []);
|
|
339
|
+
const requestOAuthConsent = useCallback(async () => ({
|
|
340
|
+
status: 'unsupported',
|
|
341
|
+
reason: 'unsupported-platform'
|
|
342
|
+
}), []);
|
|
343
|
+
|
|
344
|
+
// A hosted app holds no identity key and never signs in with one.
|
|
345
|
+
const hasIdentity = useCallback(async () => false, []);
|
|
346
|
+
const getPublicKey = useCallback(async () => null, []);
|
|
347
|
+
|
|
348
|
+
// Nothing of the session is local, so there is nothing local to clear.
|
|
349
|
+
const clearSessionState = useCallback(async () => undefined, []);
|
|
350
|
+
const clearAllAccountData = useCallback(async () => {
|
|
351
|
+
queryClient.clear();
|
|
352
|
+
if (storage) {
|
|
353
|
+
try {
|
|
354
|
+
await clearQueryCache(storage);
|
|
355
|
+
} catch (clearError) {
|
|
356
|
+
logger('Failed to clear persisted query cache', clearError);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
oxyServices.cache.clear();
|
|
360
|
+
}, [queryClient, storage, logger, oxyServices]);
|
|
361
|
+
|
|
362
|
+
// ── The account graph: read through the API, switched by the platform ────
|
|
363
|
+
const [accounts, setAccounts] = useState([]);
|
|
364
|
+
const refreshAccounts = useCallback(async () => {
|
|
365
|
+
if (!runtime.getSnapshot().account || !oxyServices.session.accessToken) {
|
|
366
|
+
setAccounts([]);
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
try {
|
|
370
|
+
setAccounts(await oxyServices.accounts.list());
|
|
371
|
+
} catch (listError) {
|
|
372
|
+
logger('Failed to load accounts', listError);
|
|
373
|
+
}
|
|
374
|
+
}, [runtime, oxyServices, logger]);
|
|
375
|
+
useEffect(() => {
|
|
376
|
+
if (canUsePrivateApi) void refreshAccounts();else if (userId === null) setAccounts([]);
|
|
377
|
+
}, [canUsePrivateApi, userId, refreshAccounts]);
|
|
378
|
+
const createAccount = useCallback(async data => {
|
|
379
|
+
const account = await oxyServices.accounts.create(data);
|
|
380
|
+
await refreshAccounts();
|
|
381
|
+
return account;
|
|
382
|
+
}, [oxyServices, refreshAccounts]);
|
|
383
|
+
const handleSubjectChange = useCallback(({
|
|
384
|
+
previous,
|
|
385
|
+
next
|
|
386
|
+
}) => {
|
|
387
|
+
accountQueryPersistence.activate(next);
|
|
388
|
+
if (previous === null) return;
|
|
389
|
+
resetSessionScopedStores();
|
|
390
|
+
if (next === null) return;
|
|
391
|
+
queryClient.removeQueries({
|
|
392
|
+
queryKey: [ASSET_DOWNLOAD_URLS_QUERY_KEY]
|
|
393
|
+
});
|
|
394
|
+
queryClient.invalidateQueries();
|
|
395
|
+
}, [accountQueryPersistence, queryClient]);
|
|
396
|
+
useEffect(() => {
|
|
397
|
+
subjectChangeRef.current = handleSubjectChange;
|
|
398
|
+
}, [handleSubjectChange]);
|
|
399
|
+
const showBottomSheet = useCallback(screenOrConfig => {
|
|
400
|
+
globalShowBottomSheet(screenOrConfig);
|
|
401
|
+
}, []);
|
|
402
|
+
const {
|
|
403
|
+
openAvatarPicker
|
|
404
|
+
} = useAvatarPicker({
|
|
405
|
+
oxyServices,
|
|
406
|
+
currentLanguage,
|
|
407
|
+
activeSessionId,
|
|
408
|
+
queryClient
|
|
409
|
+
});
|
|
410
|
+
const onServerEvent = useCallback((event, listener) => userSocket ? userSocket.onServerEvent(event, listener) : () => undefined, [userSocket]);
|
|
411
|
+
const contextValue = useMemo(() => ({
|
|
412
|
+
user,
|
|
413
|
+
sessions,
|
|
414
|
+
activeSessionId,
|
|
415
|
+
isAuthenticated,
|
|
416
|
+
isLoading,
|
|
417
|
+
isTokenReady: tokenReady,
|
|
418
|
+
hasAccessToken,
|
|
419
|
+
canUsePrivateApi,
|
|
420
|
+
isPrivateApiPending,
|
|
421
|
+
isAuthResolved: authResolved,
|
|
422
|
+
isStorageReady: snapshot.storageReady,
|
|
423
|
+
isAccountCacheReady,
|
|
424
|
+
sessionMode: 'account',
|
|
425
|
+
webAuthMode,
|
|
426
|
+
error,
|
|
427
|
+
currentLanguage,
|
|
428
|
+
isLanguageReady: isLanguageReady && entryLink.campaignReady,
|
|
429
|
+
campaignAttribution: entryLink.campaignAttribution,
|
|
430
|
+
currentLanguages,
|
|
431
|
+
currentLanguageMetadata,
|
|
432
|
+
currentLanguageName,
|
|
433
|
+
currentNativeLanguageName,
|
|
434
|
+
hasIdentity,
|
|
435
|
+
getPublicKey,
|
|
436
|
+
signIn,
|
|
437
|
+
revokeSuspiciousSignIn: manageAccount,
|
|
438
|
+
handleWebSession,
|
|
439
|
+
startWebOAuthSignIn,
|
|
440
|
+
startNativeOAuthSignIn,
|
|
441
|
+
requestOAuthConsent,
|
|
442
|
+
logout,
|
|
443
|
+
logoutAll: manageAccount,
|
|
444
|
+
switchSession,
|
|
445
|
+
removeSession: logout,
|
|
446
|
+
refreshSessions,
|
|
447
|
+
setLanguage,
|
|
448
|
+
setLanguages,
|
|
449
|
+
getDeviceSessions,
|
|
450
|
+
logoutAllDeviceSessions: manageAccount,
|
|
451
|
+
updateDeviceName,
|
|
452
|
+
clearSessionState,
|
|
453
|
+
clearAllAccountData,
|
|
454
|
+
storageKeyPrefix,
|
|
455
|
+
clientId,
|
|
456
|
+
oxyServices,
|
|
457
|
+
sessionClient: null,
|
|
458
|
+
onServerEvent,
|
|
459
|
+
useFollow,
|
|
460
|
+
showBottomSheet,
|
|
461
|
+
openAvatarPicker,
|
|
462
|
+
accountDialogController: null,
|
|
463
|
+
isAccountDialogOpen: false,
|
|
464
|
+
openAccountDialog,
|
|
465
|
+
closeAccountDialog,
|
|
466
|
+
accounts,
|
|
467
|
+
switchToAccount,
|
|
468
|
+
refreshAccounts,
|
|
469
|
+
createAccount
|
|
470
|
+
}), [user, sessions, activeSessionId, isAuthenticated, isLoading, tokenReady, hasAccessToken, canUsePrivateApi, isPrivateApiPending, authResolved, snapshot.storageReady, isAccountCacheReady, webAuthMode, error, currentLanguage, isLanguageReady, entryLink.campaignReady, entryLink.campaignAttribution, currentLanguages, currentLanguageMetadata, currentLanguageName, currentNativeLanguageName, hasIdentity, getPublicKey, signIn, manageAccount, handleWebSession, startWebOAuthSignIn, startNativeOAuthSignIn, requestOAuthConsent, logout, switchSession, refreshSessions, setLanguage, setLanguages, getDeviceSessions, updateDeviceName, clearSessionState, clearAllAccountData, storageKeyPrefix, clientId, oxyServices, onServerEvent, showBottomSheet, openAvatarPicker, openAccountDialog, closeAccountDialog, accounts, switchToAccount, refreshAccounts, createAccount]);
|
|
471
|
+
const authActionsValue = useMemo(() => ({
|
|
472
|
+
ensureDeviceSessionLane: () => undefined,
|
|
473
|
+
hostRequest: request,
|
|
474
|
+
signIn,
|
|
475
|
+
logout,
|
|
476
|
+
logoutAll: manageAccount,
|
|
477
|
+
refreshSessions,
|
|
478
|
+
oxyServices,
|
|
479
|
+
switchToAccount,
|
|
480
|
+
hasIdentity,
|
|
481
|
+
getPublicKey,
|
|
482
|
+
showBottomSheet,
|
|
483
|
+
openAvatarPicker,
|
|
484
|
+
openAccountDialog
|
|
485
|
+
}), [request, signIn, logout, manageAccount, refreshSessions, oxyServices, switchToAccount, hasIdentity, getPublicKey, showBottomSheet, openAvatarPicker, openAccountDialog]);
|
|
486
|
+
|
|
487
|
+
// App assertions (ADR 0045) prove the app by its platform's integrity check;
|
|
488
|
+
// a hosted app's proof is its host token (ADR 0058 2.7), a lane the assertion
|
|
489
|
+
// manager does not speak yet. Until it does, no assertion is attempted here
|
|
490
|
+
// rather than one through the wrong platform's lane.
|
|
491
|
+
return /*#__PURE__*/_jsx(OxyRuntimeHandleProvider, {
|
|
492
|
+
value: runtime,
|
|
493
|
+
children: /*#__PURE__*/_jsx(OxyAuthActionsContext.Provider, {
|
|
494
|
+
value: authActionsValue,
|
|
495
|
+
children: /*#__PURE__*/_jsx(OxyRuntimeContext.Provider, {
|
|
496
|
+
value: contextValue,
|
|
497
|
+
children: /*#__PURE__*/_jsx(AppAssertionProvider, {
|
|
498
|
+
oxyServices: oxyServices,
|
|
499
|
+
clientId: clientId,
|
|
500
|
+
userId: null,
|
|
501
|
+
sessionId: null,
|
|
502
|
+
storage: storage,
|
|
503
|
+
storageKeyPrefix: storageKeyPrefix,
|
|
504
|
+
children: children
|
|
505
|
+
})
|
|
506
|
+
})
|
|
507
|
+
})
|
|
508
|
+
});
|
|
509
|
+
};
|
|
510
|
+
//# sourceMappingURL=OxyHostedContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useCallback","useEffect","useLayoutEffect","useMemo","useRef","useState","useSyncExternalStore","OxyServices","logger","loggerUtil","createUserEventSocket","useQueryClient","installNativeAssetFiles","hasKnownSubjectMismatch","useKnownBearerSubject","createOxyRuntime","OxyRuntimeHandleProvider","useRuntimeSnapshot","bindAuthStoreToRuntime","resetSessionScopedStores","ASSET_DOWNLOAD_URLS_QUERY_KEY","clearQueryCache","createAccountQueryPersistence","useEntryLink","useLanguageManagement","useAvatarPicker","useFollow","getStorageKeys","createMemoryStorage","createPlatformStorage","showBottomSheet","globalShowBottomSheet","registerAccountDialogControls","notifyAccountDialogVisibility","createHostSession","HostedSessionError","AppAssertionProvider","OxyRuntimeContext","OxyAuthActionsContext","jsx","_jsx","NO_DEVICE","getState","getDirectory","subscribe","undefined","refreshDirectory","activateContext","signOutContext","signOutPrincipal","NO_DEVICE_HOST","setCurrentAccountId","requestForDialog","signedIn","OxyHostedRuntimeProvider","children","session","oxyServices","providedOxyServices","baseURL","authWebUrl","authRedirectUri","storageKeyPrefix","clientId","clientIdProp","webAuthMode","legacyLanguageKeys","captureCampaignAttribution","platformStorage","accountQueries","onAuthStateChange","onError","oxyServicesRef","current","enableCache","Error","message","err","__DEV__","warn","component","subjectChangeRef","runtimeRef","sessionClient","sessionClientHost","identity","onSubjectChange","transition","onDeviceEmpty","runtime","host","userSocketRef","getAccessToken","accessToken","userSocket","hostSessionRef","onTokenChange","kind","restart","sync","hostSession","snapshot","account","user","sessions","activeSessionId","isLoading","tokenReady","hasAccessToken","authResolved","isAuthenticated","bearerSubject","subjectMismatch","id","error","storageKeys","trimmed","trim","queryClient","accountQueryPersistenceRef","accountQueryPersistence","attach","detach","isAccountCacheReady","isReady","storage","setStorage","mounted","storagePromise","Promise","resolve","then","storageInstance","setStorageReady","catch","memoryStorage","code","status","storageAvailable","markAuthResolved","start","stop","onAuthStateChangeRef","userId","reportedUserIdRef","getSnapshot","entryLink","storageKey","captureCampaign","currentLanguage","isLanguageReady","languages","currentLanguages","metadata","currentLanguageMetadata","languageName","currentLanguageName","nativeLanguageName","currentNativeLanguageName","setLanguage","setLanguages","languageKey","language","entryUrl","url","entryLinkReady","ready","canUsePrivateApi","isPrivateApiPending","request","action","signIn","openAccountDialog","_view","requestError","closeAccountDialog","open","close","logout","logoutError","manageAccount","switchToAccount","_accountId","switchSession","_sessionId","refreshSessions","refresh","platformOwns","operation","reject","handleWebSession","getDeviceSessions","updateDeviceName","startWebOAuthSignIn","reason","startNativeOAuthSignIn","requestOAuthConsent","hasIdentity","getPublicKey","clearSessionState","clearAllAccountData","clear","clearError","cache","accounts","setAccounts","refreshAccounts","list","listError","createAccount","data","create","handleSubjectChange","previous","next","activate","removeQueries","queryKey","invalidateQueries","screenOrConfig","openAvatarPicker","onServerEvent","event","listener","contextValue","isTokenReady","isAuthResolved","isStorageReady","storageReady","sessionMode","campaignReady","campaignAttribution","revokeSuspiciousSignIn","logoutAll","removeSession","logoutAllDeviceSessions","accountDialogController","isAccountDialogOpen","authActionsValue","ensureDeviceSessionLane","hostRequest","value","Provider","sessionId"],"sourceRoot":"../../../../src","sources":["ui/context/OxyHostedContext.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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C,CACG;IAAC,CACC;EAAC,CACT,CAAC;AAE/B,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createContext","useContext","OxyRuntimeContext","PROVIDER_MISSING_ERROR_MESSAGE","OxyProviderMissingError","Error","code","constructor","name","useOxy","context","useOptionalOxy","OxyAuthActionsContext","useOxyAuthActions","actions"],"sourceRoot":"../../../../src","sources":["ui/context/oxyRuntimeContext.ts"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,UAAU,QAAQ,OAAO;
|
|
1
|
+
{"version":3,"names":["createContext","useContext","OxyRuntimeContext","PROVIDER_MISSING_ERROR_MESSAGE","OxyProviderMissingError","Error","code","constructor","name","useOxy","context","useOptionalOxy","OxyAuthActionsContext","useOxyAuthActions","actions"],"sourceRoot":"../../../../src","sources":["ui/context/oxyRuntimeContext.ts"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,UAAU,QAAQ,OAAO;AAIjD,OAAO,MAAMC,iBAAiB,gBAAGF,aAAa,CAAyB,IAAI,CAAC;AAE5E,MAAMG,8BAA8B,GAClC,oGAAoG,GACpG,sGAAsG;AAExG,OAAO,MAAMC,uBAAuB,SAASC,KAAK,CAAC;EACxCC,IAAI,GAAG,sBAAsB;EAEtCC,WAAWA,CAAA,EAAG;IACZ,KAAK,CAACJ,8BAA8B,CAAC;IACrC,IAAI,CAACK,IAAI,GAAG,yBAAyB;EACvC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,MAAM,GAAGA,CAAA,KAAuB;EAC3C,MAAMC,OAAO,GAAGT,UAAU,CAACC,iBAAiB,CAAC;EAC7C,IAAI,CAACQ,OAAO,EAAE;IACZ,MAAM,IAAIN,uBAAuB,CAAC,CAAC;EACrC;EACA,OAAOM,OAAO;AAChB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,cAAc,GAAGA,CAAA,KAA8BV,UAAU,CAACC,iBAAiB,CAAC;AAwBzF,OAAO,MAAMU,qBAAqB,gBAAGZ,aAAa,CAAoC,IAAI,CAAC;;AAE3F;AACA,OAAO,MAAMa,iBAAiB,GAAGA,CAAA,KAAkC;EACjE,MAAMC,OAAO,GAAGb,UAAU,CAACW,qBAAqB,CAAC;EACjD,IAAI,CAACE,OAAO,EAAE;IACZ,MAAM,IAAIV,uBAAuB,CAAC,CAAC;EACrC;EACA,OAAOU,OAAO;AAChB,CAAC","ignoreList":[]}
|
|
@@ -81,11 +81,20 @@ export function useAuth() {
|
|
|
81
81
|
showBottomSheet,
|
|
82
82
|
openAvatarPicker,
|
|
83
83
|
openAccountDialog,
|
|
84
|
-
ensureDeviceSessionLane
|
|
84
|
+
ensureDeviceSessionLane,
|
|
85
|
+
hostRequest
|
|
85
86
|
} = useOxyAuthActions();
|
|
86
87
|
const bearerSubject = useKnownBearerSubject(oxyServices);
|
|
87
88
|
const subjectMismatch = hasKnownSubjectMismatch(user?.id, bearerSubject);
|
|
88
89
|
const signIn = useCallback(async publicKey => {
|
|
90
|
+
// A platform holds the session (ADR 0058): its own sign-in UI, never this
|
|
91
|
+
// app's, and never a key of this app's.
|
|
92
|
+
if (hostRequest) {
|
|
93
|
+
await hostRequest('sign_in');
|
|
94
|
+
return {
|
|
95
|
+
status: 'dialog-opened'
|
|
96
|
+
};
|
|
97
|
+
}
|
|
89
98
|
const classification = ensureDeviceSessionLane();
|
|
90
99
|
if (classification) await classification;
|
|
91
100
|
// Native: sign in directly with the cryptographic identity when a public key
|
|
@@ -118,8 +127,10 @@ export function useAuth() {
|
|
|
118
127
|
return {
|
|
119
128
|
status: 'dialog-opened'
|
|
120
129
|
};
|
|
121
|
-
}, [oxySignIn, hasIdentity, getPublicKey, openAccountDialog, ensureDeviceSessionLane]);
|
|
130
|
+
}, [oxySignIn, hasIdentity, getPublicKey, openAccountDialog, ensureDeviceSessionLane, hostRequest]);
|
|
122
131
|
const signOut = useCallback(async () => {
|
|
132
|
+
// `requested` (a session host) resolves: the platform decides, and its
|
|
133
|
+
// answer arrives as the session changes.
|
|
123
134
|
const result = await logout();
|
|
124
135
|
if (result.status === 'failed') throw result.error;
|
|
125
136
|
}, [logout]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["hasKnownSubjectMismatch","useKnownBearerSubject","useCallback","useOxyAuthActions","isWebBrowser","useOxyRuntime","useRuntimeSelector","selectAuthState","snapshot","user","account","isAuthenticated","isLoading","isReady","tokenReady","hasAccessToken","canUsePrivateApi","authResolved","isPrivateApiPending","isAuthResolved","error","message","authStatesEqual","left","right","useAuth","runtime","signIn","oxySignIn","logout","logoutAll","refreshSessions","oxyServices","switchToAccount","hasIdentity","getPublicKey","showBottomSheet","openAvatarPicker","openAccountDialog","ensureDeviceSessionLane","bearerSubject","subjectMismatch","id","publicKey","
|
|
1
|
+
{"version":3,"names":["hasKnownSubjectMismatch","useKnownBearerSubject","useCallback","useOxyAuthActions","isWebBrowser","useOxyRuntime","useRuntimeSelector","selectAuthState","snapshot","user","account","isAuthenticated","isLoading","isReady","tokenReady","hasAccessToken","canUsePrivateApi","authResolved","isPrivateApiPending","isAuthResolved","error","message","authStatesEqual","left","right","useAuth","runtime","signIn","oxySignIn","logout","logoutAll","refreshSessions","oxyServices","switchToAccount","hasIdentity","getPublicKey","showBottomSheet","openAvatarPicker","openAccountDialog","ensureDeviceSessionLane","hostRequest","bearerSubject","subjectMismatch","id","publicKey","status","classification","hasExisting","existingKey","signOut","result","signOutAll","refresh"],"sourceRoot":"../../../../src","sources":["ui/hooks/useAuth.ts"],"mappings":";;AAAA,SAASA,uBAAuB,EAAEC,qBAAqB,QAAQ,4BAAyB;AACxF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASC,WAAW,QAAQ,OAAO;AACnC,SAASC,iBAAiB,QAAQ,iCAA8B;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C,eAAe;IACfG,eAAe;IACfC;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -11,15 +11,19 @@ import { useOxy } from "../context/oxyRuntimeContext.js";
|
|
|
11
11
|
*/
|
|
12
12
|
export function useOxyEvent(event, handler) {
|
|
13
13
|
const {
|
|
14
|
-
sessionClient
|
|
14
|
+
sessionClient,
|
|
15
|
+
onServerEvent
|
|
15
16
|
} = useOxy();
|
|
16
17
|
const handlerRef = useRef(handler);
|
|
17
18
|
handlerRef.current = handler;
|
|
18
19
|
useEffect(() => {
|
|
19
|
-
|
|
20
|
-
return sessionClient.onServerEvent(event, payload => {
|
|
20
|
+
const listener = payload => {
|
|
21
21
|
handlerRef.current(payload);
|
|
22
|
-
}
|
|
23
|
-
|
|
22
|
+
};
|
|
23
|
+
// A session host's user socket, else the device session's socket.
|
|
24
|
+
if (onServerEvent) return onServerEvent(event, listener);
|
|
25
|
+
if (!sessionClient) return;
|
|
26
|
+
return sessionClient.onServerEvent(event, listener);
|
|
27
|
+
}, [sessionClient, onServerEvent, event]);
|
|
24
28
|
}
|
|
25
29
|
//# sourceMappingURL=useOxyEvent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useRef","useOxy","useOxyEvent","event","handler","sessionClient","handlerRef","current","
|
|
1
|
+
{"version":3,"names":["useEffect","useRef","useOxy","useOxyEvent","event","handler","sessionClient","onServerEvent","handlerRef","current","listener","payload"],"sourceRoot":"../../../../src","sources":["ui/hooks/useOxyEvent.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAEzC,SAASC,MAAM,QAAQ,iCAA8B;;AAErD;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CAACC,KAAa,EAAEC,OAAmC,EAAQ;EACpF,MAAM;IAAEC,aAAa;IAAEC;EAAc,CAAC,GAAGL,MAAM,CAAC,CAAC;EACjD,MAAMM,UAAU,GAAGP,MAAM,CAACI,OAAO,CAAC;EAClCG,UAAU,CAACC,OAAO,GAAGJ,OAAO;EAE5BL,SAAS,CAAC,MAAM;IACd,MAAMU,QAAQ,GAAIC,OAAgB,IAAK;MACrCH,UAAU,CAACC,OAAO,CAACE,OAAO,CAAC;IAC7B,CAAC;IACD;IACA,IAAIJ,aAAa,EAAE,OAAOA,aAAa,CAACH,KAAK,EAAEM,QAAQ,CAAC;IACxD,IAAI,CAACJ,aAAa,EAAE;IACpB,OAAOA,aAAa,CAACC,aAAa,CAACH,KAAK,EAAEM,QAAQ,CAAC;EACrD,CAAC,EAAE,CAACJ,aAAa,EAAEC,aAAa,EAAEH,KAAK,CAAC,CAAC;AAC3C","ignoreList":[]}
|