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