@oxy.so/services 15.1.4 → 15.1.6
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/bloom/Package.bloom +15 -0
- package/bloom/Resources/Localizable/ar-SA.json +108 -0
- package/bloom/Resources/Localizable/bn-BD.json +108 -0
- package/bloom/Resources/Localizable/ca-ES.json +111 -0
- package/bloom/Resources/Localizable/de-DE.json +108 -0
- package/bloom/Resources/Localizable/en-US.json +124 -0
- package/bloom/Resources/Localizable/es-ES.json +124 -0
- package/bloom/Resources/Localizable/fr-FR.json +108 -0
- package/bloom/Resources/Localizable/hi-IN.json +108 -0
- package/bloom/Resources/Localizable/id-ID.json +108 -0
- package/bloom/Resources/Localizable/it-IT.json +108 -0
- package/bloom/Resources/Localizable/ja-JP.json +108 -0
- package/bloom/Resources/Localizable/ko-KR.json +108 -0
- package/bloom/Resources/Localizable/pt-PT.json +108 -0
- package/bloom/Resources/Localizable/ru-RU.json +108 -0
- package/bloom/Resources/Localizable/tr-TR.json +108 -0
- package/bloom/Resources/Localizable/zh-CN.json +108 -0
- package/bloom/Sources/OxyAccountUI/SignInFlow.bloom +322 -0
- package/bloom/Sources/OxyAccountUI/SignInRules.bloom +135 -0
- package/bloom/Sources/OxyAccountUI/SignInService.bloom +141 -0
- package/bloom/Sources/OxyAccountUI/SignUpFlow.bloom +322 -0
- package/bloom/Sources/OxyAccountUI/SignUpRules.bloom +189 -0
- package/bloom/Sources/OxyAccountUIChecks/Checks.bloom +254 -0
- package/bloom/Sources/OxyAccountUIChecks/FakeAuth.bloom +123 -0
- package/bloom/Sources/OxyAccountUIChecks/SignUpChecks.bloom +193 -0
- package/lib/commonjs/ui/boot/runProviderColdBoot.js +43 -329
- package/lib/commonjs/ui/boot/runProviderColdBoot.js.map +1 -1
- package/lib/commonjs/ui/context/OxyContext.js +7 -1
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/oauth/applicationSessionLane.js +12 -25
- package/lib/commonjs/ui/oauth/applicationSessionLane.js.map +1 -1
- package/lib/commonjs/ui/session/tokenTransport.js +7 -69
- package/lib/commonjs/ui/session/tokenTransport.js.map +1 -1
- package/lib/module/ui/boot/runProviderColdBoot.js +43 -329
- package/lib/module/ui/boot/runProviderColdBoot.js.map +1 -1
- package/lib/module/ui/context/OxyContext.js +8 -2
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/oauth/applicationSessionLane.js +4 -23
- package/lib/module/ui/oauth/applicationSessionLane.js.map +1 -1
- package/lib/module/ui/session/tokenTransport.js +3 -68
- package/lib/module/ui/session/tokenTransport.js.map +1 -1
- package/lib/typescript/commonjs/ui/boot/runProviderColdBoot.d.ts +8 -31
- package/lib/typescript/commonjs/ui/boot/runProviderColdBoot.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/oauth/applicationSessionLane.d.ts +1 -5
- package/lib/typescript/commonjs/ui/oauth/applicationSessionLane.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/session/tokenTransport.d.ts +1 -33
- package/lib/typescript/commonjs/ui/session/tokenTransport.d.ts.map +1 -1
- package/lib/typescript/module/ui/boot/runProviderColdBoot.d.ts +8 -31
- package/lib/typescript/module/ui/boot/runProviderColdBoot.d.ts.map +1 -1
- package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/module/ui/oauth/applicationSessionLane.d.ts +1 -5
- package/lib/typescript/module/ui/oauth/applicationSessionLane.d.ts.map +1 -1
- package/lib/typescript/module/ui/session/tokenTransport.d.ts +1 -33
- package/lib/typescript/module/ui/session/tokenTransport.d.ts.map +1 -1
- package/package.json +10 -5
- package/src/ui/boot/runProviderColdBoot.ts +40 -364
- package/src/ui/context/OxyContext.tsx +8 -1
- package/src/ui/oauth/applicationSessionLane.ts +7 -35
- package/src/ui/session/tokenTransport.ts +3 -75
|
@@ -1,48 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { resolveApplicationSessionLane } from "../oauth/applicationSessionLane.js";
|
|
4
3
|
import { logger as loggerUtil } from '@oxy.so/core';
|
|
5
|
-
import { runSessionColdBoot } from '@oxy.so/core/session';
|
|
6
|
-
import { loadPersistedDeviceCredential } from "../utils/deviceCredential.js";
|
|
4
|
+
import { runSessionColdBoot, runWebSessionColdBoot } from '@oxy.so/core/session';
|
|
7
5
|
import { createPlatformSharedDeviceCredentialStore } from "../session/sharedDeviceCredentialStore.js";
|
|
8
6
|
import { tryCompleteOAuthReturn } from "../utils/oauthReturn.js";
|
|
9
7
|
import { isWebBrowser } from "../utils/isWebBrowser.js";
|
|
10
8
|
import { isNetConnectivityOnline } from "../utils/netConnectivity.js";
|
|
11
9
|
/**
|
|
12
|
-
*
|
|
13
|
-
* `
|
|
14
|
-
*/
|
|
15
|
-
function hasOAuthReturnOnUrl() {
|
|
16
|
-
const search = globalThis.location?.search;
|
|
17
|
-
if (!search) return false;
|
|
18
|
-
const params = new URLSearchParams(search);
|
|
19
|
-
return params.has('code') || params.has('error');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Whether this origin's own store holds anything a web boot could restore from:
|
|
24
|
-
* a warm access token to plant or a device secret to mint with. A presence
|
|
25
|
-
* check only — nothing read here is used, sent or synced before the
|
|
26
|
-
* classification allows it.
|
|
27
|
-
*/
|
|
28
|
-
async function hasRestorableState(store) {
|
|
29
|
-
const persisted = await store.load();
|
|
30
|
-
return Boolean(persisted?.accessToken || persisted?.deviceSecret);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/** How long the cold boot waits for the post-boot SessionClient handoff (ms). */
|
|
34
|
-
export const SESSION_HANDOFF_DEADLINE_MS = 6000;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* HARD overall deadline (ms) for the whole `runSessionColdBoot` step chain.
|
|
38
|
-
*
|
|
39
|
-
* Bounds time-to-route: routing gates on `isAuthResolved`, which resolves when
|
|
40
|
-
* the cold boot finishes, so a network step that never settles (a black-hole
|
|
41
|
-
* network that neither connects nor rejects) would otherwise hang routing
|
|
42
|
-
* indefinitely. 12s comfortably exceeds the healthy worst case of the
|
|
43
|
-
* sequential, single-attempt (`retry:false`), 5s-capped network steps, so it is
|
|
44
|
-
* INERT on healthy loads and only trips on a pathological network. Offline
|
|
45
|
-
* devices short-circuit far sooner via the connectivity hint below.
|
|
10
|
+
* HARD overall deadline (ms) for the whole `runSessionColdBoot` step chain; see
|
|
11
|
+
* `runWebSessionColdBoot` in `@oxy.so/core/session`, which owns the boot.
|
|
46
12
|
*/
|
|
47
13
|
export const COLD_BOOT_OVERALL_DEADLINE_MS = 12_000;
|
|
48
14
|
|
|
@@ -54,308 +20,56 @@ export const COLD_BOOT_OVERALL_DEADLINE_MS = 12_000;
|
|
|
54
20
|
const OFFLINE_PROBE_TIMEOUT_MS = 500;
|
|
55
21
|
|
|
56
22
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* error) resolves to `false` (assume online) so a flaky probe can never falsely
|
|
62
|
-
* skip a real sign-in. Never rejects. On web it reads `navigator.onLine`; on
|
|
63
|
-
* native it races `NetInfo.fetch()` against {@link OFFLINE_PROBE_TIMEOUT_MS},
|
|
64
|
-
* mirroring the existing NetInfo dynamic-import pattern in `OxyProvider`.
|
|
23
|
+
* The native half of the boot's connectivity probe: races `NetInfo.fetch()`
|
|
24
|
+
* against {@link OFFLINE_PROBE_TIMEOUT_MS}. `true` ONLY on an EXPLICIT
|
|
25
|
+
* disconnected verdict; a timeout or an unknown state is "online". A missing
|
|
26
|
+
* NetInfo rejects, which the boot also reads as "online".
|
|
65
27
|
*/
|
|
66
|
-
async function
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
setTimeout(() => resolve(null), OFFLINE_PROBE_TIMEOUT_MS);
|
|
76
|
-
})]);
|
|
77
|
-
// `null` ⇒ the probe timed out (unknown → assume online). Only an explicit
|
|
78
|
-
// disconnected verdict disables the network steps (the same rule as the
|
|
79
|
-
// online signal: `isConnected`, never the reachability probe).
|
|
80
|
-
return state !== null && !isNetConnectivityOnline(state);
|
|
81
|
-
} catch {
|
|
82
|
-
// NetInfo missing / probe threw — never block sign-in on a probe failure.
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
28
|
+
async function probeNetInfoOffline() {
|
|
29
|
+
const NetInfo = await import('@react-native-community/netinfo');
|
|
30
|
+
const state = await Promise.race([NetInfo.default.fetch(), new Promise(resolve => {
|
|
31
|
+
setTimeout(() => resolve(null), OFFLINE_PROBE_TIMEOUT_MS);
|
|
32
|
+
})]);
|
|
33
|
+
// `null` ⇒ the probe timed out (unknown → assume online). Only an explicit
|
|
34
|
+
// disconnected verdict disables the network steps (the same rule as the
|
|
35
|
+
// online signal: `isConnected`, never the reachability probe).
|
|
36
|
+
return state !== null && !isNetConnectivityOnline(state);
|
|
85
37
|
}
|
|
86
|
-
/** Starts the provider's fresh classification; a rejection is observed, not swallowed. */
|
|
87
|
-
function startClassification(opts) {
|
|
88
|
-
const classification = (async () => opts.resolveSessionLane?.() ?? resolveApplicationSessionLane(opts.oxyServices, opts.clientId))();
|
|
89
|
-
// Observed so a rejection that lands before it is awaited is not reported as
|
|
90
|
-
// unhandled; every caller still awaits it and sees the rejection.
|
|
91
|
-
classification.catch(() => undefined);
|
|
92
|
-
return classification;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/** What the device lanes made of this holder: a session, a verdict against it, or no answer. */
|
|
96
|
-
|
|
97
38
|
/**
|
|
98
|
-
*
|
|
99
|
-
* the
|
|
39
|
+
* Device-first cold boot for `@oxy.so/services` providers: core's
|
|
40
|
+
* `runWebSessionColdBoot` (the order, the deadlines, the verdicts) with this
|
|
41
|
+
* package's platform parts — the registry classifier, the native connectivity
|
|
42
|
+
* probe, the shared device credential slot and the OAuth return leg.
|
|
100
43
|
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* painted boot already resolved auth from the cache, so nothing waits on the
|
|
104
|
-
* handoff and the pure-local warm token is skipped: the check needs the mint's
|
|
105
|
-
* verdict, which a still-valid token cannot give.
|
|
44
|
+
* The boot NEVER navigates the top-level window; the OAuth return leg only
|
|
45
|
+
* consumes a code that is already in the address bar (#691 phase 7b).
|
|
106
46
|
*/
|
|
107
|
-
|
|
47
|
+
export function runProviderColdBoot(opts) {
|
|
108
48
|
const {
|
|
109
49
|
oxyServices,
|
|
110
|
-
authStore,
|
|
111
|
-
sessionMode = 'account',
|
|
112
|
-
identity,
|
|
113
|
-
sessionClient,
|
|
114
|
-
syncDeviceCredentialToHost,
|
|
115
|
-
commitSession,
|
|
116
|
-
markAuthResolved
|
|
117
|
-
} = opts;
|
|
118
|
-
await opts.beforeDeviceBoot?.();
|
|
119
|
-
|
|
120
|
-
// Best-effort connectivity probe up front: an EXPLICIT offline verdict skips
|
|
121
|
-
// the two doomed network steps so routing settles immediately instead of
|
|
122
|
-
// burning the overall deadline on a mint that cannot succeed. Any ambiguity
|
|
123
|
-
// resolves to "online" — the network steps still run.
|
|
124
|
-
const offline = await detectOfflineHint();
|
|
125
|
-
let outcome = 'unreachable';
|
|
126
|
-
let holderRejected = false;
|
|
127
|
-
await runSessionColdBoot({
|
|
128
|
-
oxy: oxyServices,
|
|
129
|
-
store: authStore,
|
|
130
|
-
platform: {
|
|
131
|
-
isWeb: isWebBrowser(),
|
|
132
|
-
isNative: !isWebBrowser()
|
|
133
|
-
},
|
|
134
|
-
sessionMode,
|
|
135
|
-
identity,
|
|
136
|
-
// The device-wide shared credential slot, enabling the `shared-device-adopt`
|
|
137
|
-
// lane: a newly installed official app joins this device's existing session
|
|
138
|
-
// instead of falling back to signing a challenge with the Commons identity
|
|
139
|
-
// key. `null` on web, where each origin is its own device by design; the
|
|
140
|
-
// core lane is also skipped outright in `sessionMode: 'identity'`.
|
|
141
|
-
// Off when the provider was given a platform's own store: the credential
|
|
142
|
-
// then lives there and nowhere else.
|
|
143
|
-
sharedDeviceCredential: opts.useSharedDeviceCredential === false ? undefined : createPlatformSharedDeviceCredentialStore() ?? undefined,
|
|
144
|
-
overallDeadlineMs: COLD_BOOT_OVERALL_DEADLINE_MS,
|
|
145
|
-
isOffline: () => offline,
|
|
146
|
-
requireServerVerdict: painted,
|
|
147
|
-
onHolderRejected: () => {
|
|
148
|
-
holderRejected = true;
|
|
149
|
-
},
|
|
150
|
-
onStepDeadline: stepId => {
|
|
151
|
-
loggerUtil.warn(`Cold-boot step "${stepId}" exceeded the ${COLD_BOOT_OVERALL_DEADLINE_MS}ms overall deadline — abandoned; routing proceeds signed-out`, {
|
|
152
|
-
component: 'runProviderColdBoot',
|
|
153
|
-
method: 'onStepDeadline'
|
|
154
|
-
});
|
|
155
|
-
},
|
|
156
|
-
onSession: async session => {
|
|
157
|
-
outcome = 'session';
|
|
158
|
-
// Mint already persisted `{deviceId, deviceSecret}` to the store; sync the
|
|
159
|
-
// in-memory SessionClient host so sockets + tab-focus re-mint can use it.
|
|
160
|
-
await syncDeviceCredentialToHost();
|
|
161
|
-
const handoff = commitSession({
|
|
162
|
-
sessionId: session.sessionId,
|
|
163
|
-
accessToken: session.accessToken,
|
|
164
|
-
userId: session.userId,
|
|
165
|
-
deviceState: session.state
|
|
166
|
-
}, {
|
|
167
|
-
activate: false
|
|
168
|
-
});
|
|
169
|
-
if (painted) {
|
|
170
|
-
// The account is already on screen; the commit refreshes its profile.
|
|
171
|
-
await handoff;
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
let handoffDeadlineId;
|
|
175
|
-
await Promise.race([handoff, new Promise(resolve => {
|
|
176
|
-
handoffDeadlineId = setTimeout(resolve, SESSION_HANDOFF_DEADLINE_MS);
|
|
177
|
-
})]).finally(() => {
|
|
178
|
-
if (handoffDeadlineId !== undefined) {
|
|
179
|
-
clearTimeout(handoffDeadlineId);
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
markAuthResolved();
|
|
183
|
-
},
|
|
184
|
-
onSignedOut: async () => {
|
|
185
|
-
outcome = holderRejected ? 'rejected' : 'unreachable';
|
|
186
|
-
await syncDeviceCredentialToHost();
|
|
187
|
-
// A painted session is the caller's to end or keep (see verifyCachedSession).
|
|
188
|
-
if (painted) return;
|
|
189
|
-
const cred = await loadPersistedDeviceCredential(authStore);
|
|
190
|
-
if (cred) {
|
|
191
|
-
try {
|
|
192
|
-
await sessionClient.start();
|
|
193
|
-
} catch (socketError) {
|
|
194
|
-
if (__DEV__) {
|
|
195
|
-
loggerUtil.debug('Device socket start failed (non-fatal)', {
|
|
196
|
-
component: 'runProviderColdBoot'
|
|
197
|
-
}, socketError);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
markAuthResolved();
|
|
202
|
-
},
|
|
203
|
-
onStepError: (id, error) => {
|
|
204
|
-
if (__DEV__) {
|
|
205
|
-
loggerUtil.debug(`Cold-boot step "${id}" errored (non-fatal, falling through)`, {
|
|
206
|
-
component: 'runProviderColdBoot'
|
|
207
|
-
}, error);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
await opts.afterDeviceBoot?.();
|
|
212
|
-
return outcome;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* The background check of a painted session: the registry's classification and
|
|
217
|
-
* a mint with this holder's own credential (whose commit refreshes the profile).
|
|
218
|
-
* Each is asked until the server answers it. A verdict against the session
|
|
219
|
-
* signs out at that moment; no answer keeps the cached session on screen and
|
|
220
|
-
* hands the caller a retry.
|
|
221
|
-
*/
|
|
222
|
-
async function verifyCachedSession(opts, verified, classification) {
|
|
223
|
-
if (!verified.lane) {
|
|
224
|
-
let lane = null;
|
|
225
|
-
try {
|
|
226
|
-
lane = await classification;
|
|
227
|
-
} catch {
|
|
228
|
-
// The registry could not be asked (offline, timeout, 5xx). That is no
|
|
229
|
-
// verdict on this app: the cached `device` classification stands until it
|
|
230
|
-
// answers.
|
|
231
|
-
}
|
|
232
|
-
if (lane === 'oauth') {
|
|
233
|
-
await opts.onCachedSessionRejected?.();
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
verified.lane = lane === 'device';
|
|
237
|
-
}
|
|
238
|
-
if (!verified.session) {
|
|
239
|
-
const outcome = await restoreDeviceSession(opts, true);
|
|
240
|
-
if (outcome === 'rejected') {
|
|
241
|
-
await opts.onCachedSessionRejected?.();
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
|
-
verified.session = outcome === 'session';
|
|
245
|
-
}
|
|
246
|
-
if (!verified.lane || !verified.session) {
|
|
247
|
-
opts.onCachedSessionUnconfirmed?.(() => verifyCachedSession(opts, verified, verified.lane ? Promise.resolve('device') : startClassification(opts)));
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Device-first cold boot for `@oxy.so/services` providers.
|
|
253
|
-
*
|
|
254
|
-
* A returning session saved on this device (account mode, the app last
|
|
255
|
-
* classified `device`, its profile cached) paints first, with no network, and
|
|
256
|
-
* is then checked in the background — see `paintCachedSession`. Otherwise, a
|
|
257
|
-
* first boot:
|
|
258
|
-
*
|
|
259
|
-
* Ordered pipeline:
|
|
260
|
-
* 1. Complete an OAuth authorization-code return already on the URL (web)
|
|
261
|
-
* 2. `runSessionColdBoot` — device-secret mint (+ the native Commons-proof lane,
|
|
262
|
-
* or the primary-identity-key lane in `sessionMode: 'identity'`)
|
|
263
|
-
*
|
|
264
|
-
* Step 1 is ACCOUNT-MODE ONLY: it commits whichever account the IdP resolves,
|
|
265
|
-
* which for an identity-bound client is somebody else's account by construction.
|
|
266
|
-
* In `'identity'` mode the boot is exactly step 2.
|
|
267
|
-
*
|
|
268
|
-
* The boot NEVER navigates the top-level window. There is no automatic
|
|
269
|
-
* `prompt=none` bounce to the IdP: a web origin with no local device credential
|
|
270
|
-
* resolves SIGNED OUT and waits for the user's next explicit "Continue with
|
|
271
|
-
* Oxy", which opens a popup from a real gesture (#691 phase 7b). Step 1 is not a
|
|
272
|
-
* navigation — it only consumes a code that is already in the address bar.
|
|
273
|
-
*/
|
|
274
|
-
export async function runProviderColdBoot(opts) {
|
|
275
|
-
const {
|
|
276
|
-
oxyServices,
|
|
277
|
-
authStore,
|
|
278
50
|
clientId,
|
|
279
51
|
authRedirectUri,
|
|
280
|
-
|
|
281
|
-
commitSession,
|
|
282
|
-
markAuthResolved,
|
|
283
|
-
setTokenReady
|
|
52
|
+
commitSession
|
|
284
53
|
} = opts;
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
session: false
|
|
304
|
-
}, classification);
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
// The verdict decides HOW a session is restored, never WHETHER there is one.
|
|
309
|
-
// A web origin with nothing to restore and no OAuth return on the URL ends
|
|
310
|
-
// signed out on either lane, so routing need not wait a network round trip
|
|
311
|
-
// for an answer that cannot change the outcome. The classification still
|
|
312
|
-
// completes below and still gates every later sign-in
|
|
313
|
-
// (`ensureDeviceSessionLane` shares this same in-flight lookup).
|
|
314
|
-
if (freshLaunch && isWebBrowser()) {
|
|
315
|
-
if (!(await hasRestorableState(authStore))) {
|
|
316
|
-
markAuthResolved();
|
|
317
|
-
const lane = await classification;
|
|
318
|
-
await opts.onClassified?.(lane);
|
|
319
|
-
if (lane === 'oauth') setTokenReady(true);
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
const lane = await classification;
|
|
324
|
-
await opts.onClassified?.(lane);
|
|
325
|
-
if (identityBound && lane !== 'device') return;
|
|
326
|
-
// The redirect transport's RETURN leg. An app reaches it whenever the browser
|
|
327
|
-
// BLOCKED the sign-in popup and `startWebOAuthSignIn` fell back to a
|
|
328
|
-
// full-page redirect (`popup-blocked` / `popup-navigation-failed`), so it is
|
|
329
|
-
// load-bearing even though nothing here ever starts a redirect. It consumes a
|
|
330
|
-
// code (or a stale OAuth `error`) already in the address bar and rewrites the
|
|
331
|
-
// URL via `history.replaceState`; it never begins a navigation.
|
|
332
|
-
const oauthCompleted = identityBound ? false : await tryCompleteOAuthReturn({
|
|
333
|
-
oxyServices,
|
|
334
|
-
clientId,
|
|
335
|
-
authRedirectUri,
|
|
336
|
-
commitSession: input => commitSession(input, {
|
|
337
|
-
activate: true,
|
|
338
|
-
oauth: true
|
|
339
|
-
})
|
|
340
|
-
});
|
|
341
|
-
if (oauthCompleted) {
|
|
342
|
-
setTokenReady(true);
|
|
343
|
-
markAuthResolved();
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
if (lane === 'oauth') {
|
|
347
|
-
setTokenReady(true);
|
|
348
|
-
return;
|
|
349
|
-
}
|
|
350
|
-
await restoreDeviceSession(opts, false);
|
|
351
|
-
} catch (error) {
|
|
352
|
-
if (__DEV__) {
|
|
353
|
-
loggerUtil.error('Cold boot error', error instanceof Error ? error : new Error(String(error)), {
|
|
354
|
-
component: 'runProviderColdBoot'
|
|
355
|
-
});
|
|
54
|
+
return runWebSessionColdBoot({
|
|
55
|
+
...opts,
|
|
56
|
+
overallDeadlineMs: COLD_BOOT_OVERALL_DEADLINE_MS,
|
|
57
|
+
platform: {
|
|
58
|
+
isWeb: isWebBrowser,
|
|
59
|
+
probeNativeOffline: probeNetInfoOffline,
|
|
60
|
+
completeOAuthReturn: () => tryCompleteOAuthReturn({
|
|
61
|
+
oxyServices,
|
|
62
|
+
clientId,
|
|
63
|
+
authRedirectUri,
|
|
64
|
+
commitSession: input => commitSession(input, {
|
|
65
|
+
activate: true,
|
|
66
|
+
oauth: true
|
|
67
|
+
})
|
|
68
|
+
}),
|
|
69
|
+
sharedDeviceCredential: createPlatformSharedDeviceCredentialStore,
|
|
70
|
+
runSessionColdBoot,
|
|
71
|
+
logger: loggerUtil
|
|
356
72
|
}
|
|
357
|
-
}
|
|
358
|
-
markAuthResolved();
|
|
359
|
-
}
|
|
73
|
+
});
|
|
360
74
|
}
|
|
361
75
|
//# sourceMappingURL=runProviderColdBoot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["logger","loggerUtil","runSessionColdBoot","runWebSessionColdBoot","createPlatformSharedDeviceCredentialStore","tryCompleteOAuthReturn","isWebBrowser","isNetConnectivityOnline","COLD_BOOT_OVERALL_DEADLINE_MS","OFFLINE_PROBE_TIMEOUT_MS","probeNetInfoOffline","NetInfo","state","Promise","race","default","fetch","resolve","setTimeout","runProviderColdBoot","opts","oxyServices","clientId","authRedirectUri","commitSession","overallDeadlineMs","platform","isWeb","probeNativeOffline","completeOAuthReturn","input","activate","oauth","sharedDeviceCredential"],"sourceRoot":"../../../../src","sources":["ui/boot/runProviderColdBoot.ts"],"mappings":";;AAAA,SAASA,MAAM,IAAIC,UAAU,QAA0B,cAAc;AACrE,SACEC,kBAAkB,EAClBC,qBAAqB,QAIhB,sBAAsB;AAE7B,SAASC,yCAAyC,QAAQ,2CAAwC;AAClG,SAASC,sBAAsB,QAAQ,yBAAsB;AAC7D,SAASC,YAAY,QAAQ,0BAAuB;AACpD,SAASC,uBAAuB,QAAQ,6BAA0B;AAGlE;AACA;AACA;AACA;AACA,OAAO,MAAMC,6BAA6B,GAAG,MAAM;;AAEnD;AACA;AACA;AACA;AACA;AACA,MAAMC,wBAAwB,GAAG,GAAG;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA,eAAeC,mBAAmBA,CAAA,EAAqB;EACrD,MAAMC,OAAO,GAAG,MAAM,MAAM,CAAC,iCAAiC,CAAC;EAC/D,MAAMC,KAAK,GAAG,MAAMC,OAAO,CAACC,IAAI,CAAC,CAC/BH,OAAO,CAACI,OAAO,CAACC,KAAK,CAAC,CAAC,EACvB,IAAIH,OAAO,CAAQI,OAAO,IAAK;IAC7BC,UAAU,CAAC,MAAMD,OAAO,CAAC,IAAI,CAAC,EAAER,wBAAwB,CAAC;EAC3D,CAAC,CAAC,CACH,CAAC;EACF;EACA;EACA;EACA,OAAOG,KAAK,KAAK,IAAI,IAAI,CAACL,uBAAuB,CAACK,KAAK,CAAC;AAC1D;AA0DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASO,mBAAmBA,CAACC,IAAgC,EAAiB;EACnF,MAAM;IAAEC,WAAW;IAAEC,QAAQ;IAAEC,eAAe;IAAEC;EAAc,CAAC,GAAGJ,IAAI;EACtE,OAAOjB,qBAAqB,CAAC;IAC3B,GAAGiB,IAAI;IACPK,iBAAiB,EAAEjB,6BAA6B;IAChDkB,QAAQ,EAAE;MACRC,KAAK,EAAErB,YAAY;MACnBsB,kBAAkB,EAAElB,mBAAmB;MACvCmB,mBAAmB,EAAEA,CAAA,KACnBxB,sBAAsB,CAAC;QACrBgB,WAAW;QACXC,QAAQ;QACRC,eAAe;QACfC,aAAa,EAAGM,KAAK,IAAKN,aAAa,CAACM,KAAK,EAAE;UAAEC,QAAQ,EAAE,IAAI;UAAEC,KAAK,EAAE;QAAK,CAAC;MAChF,CAAC,CAAC;MACJC,sBAAsB,EAAE7B,yCAAyC;MACjEF,kBAAkB;MAClBF,MAAM,EAAEC;IACV;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -9,7 +9,7 @@ import { useAccountData } from "../data/accountData.js";
|
|
|
9
9
|
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
10
10
|
import { AppState, Linking, Platform } from 'react-native';
|
|
11
11
|
import { OxyServices } from '@oxy.so/core';
|
|
12
|
-
import { refreshDeviceSecretArm, establishIdentitySession, createAuthRefreshHandler, startTokenRefreshScheduler, createAccountDialogController } from '@oxy.so/core/session';
|
|
12
|
+
import { refreshDeviceSecretArm, establishIdentitySession, createAuthRefreshHandler, startTokenRefreshScheduler, createAccountDialogController, saveWebSessionAccountSummary } from '@oxy.so/core/session';
|
|
13
13
|
import { logger as loggerUtil } from '@oxy.so/core';
|
|
14
14
|
import { registerAccountDialogControls, notifyAccountDialogVisibility } from "../navigation/accountDialogManager.js";
|
|
15
15
|
import { redirectToAuthorize } from "../components/oauthNavigation.js";
|
|
@@ -1114,13 +1114,18 @@ export const OxyRuntimeProvider = ({
|
|
|
1114
1114
|
// cold boot can paint it before the network answers. Only for a device-lane
|
|
1115
1115
|
// account session: an identity-bound client and an isolated OAuth session
|
|
1116
1116
|
// always boot through the network. A sign-out deletes it.
|
|
1117
|
+
// On the web the account's summary also goes where a page without React
|
|
1118
|
+
// reads it before its first draw (`peekWebSession`, core's web session):
|
|
1119
|
+
// `localStorage` is synchronous, the profile cache above is not.
|
|
1117
1120
|
const cachedAccountJsonRef = useRef(null);
|
|
1118
1121
|
useEffect(() => {
|
|
1119
1122
|
if (!cachedBoot || identity) return;
|
|
1123
|
+
const web = isWebBrowser() && usesSharedDeviceCredential;
|
|
1120
1124
|
if (user === null) {
|
|
1121
1125
|
if (cachedAccountJsonRef.current !== null) {
|
|
1122
1126
|
cachedAccountJsonRef.current = null;
|
|
1123
1127
|
void cachedBoot.clearAccount();
|
|
1128
|
+
if (web) saveWebSessionAccountSummary(null);
|
|
1124
1129
|
}
|
|
1125
1130
|
return;
|
|
1126
1131
|
}
|
|
@@ -1129,7 +1134,8 @@ export const OxyRuntimeProvider = ({
|
|
|
1129
1134
|
if (json === cachedAccountJsonRef.current) return;
|
|
1130
1135
|
cachedAccountJsonRef.current = json;
|
|
1131
1136
|
void cachedBoot.saveAccount(user);
|
|
1132
|
-
|
|
1137
|
+
if (web) saveWebSessionAccountSummary(user);
|
|
1138
|
+
}, [cachedBoot, identity, user, runtime, usesSharedDeviceCredential]);
|
|
1133
1139
|
|
|
1134
1140
|
// Paint the session saved on this device: the bearer it left (when still
|
|
1135
1141
|
// valid), the session mirror, the account from its cached profile, auth
|