@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.
Files changed (60) hide show
  1. package/bloom/Package.bloom +15 -0
  2. package/bloom/Resources/Localizable/ar-SA.json +108 -0
  3. package/bloom/Resources/Localizable/bn-BD.json +108 -0
  4. package/bloom/Resources/Localizable/ca-ES.json +111 -0
  5. package/bloom/Resources/Localizable/de-DE.json +108 -0
  6. package/bloom/Resources/Localizable/en-US.json +124 -0
  7. package/bloom/Resources/Localizable/es-ES.json +124 -0
  8. package/bloom/Resources/Localizable/fr-FR.json +108 -0
  9. package/bloom/Resources/Localizable/hi-IN.json +108 -0
  10. package/bloom/Resources/Localizable/id-ID.json +108 -0
  11. package/bloom/Resources/Localizable/it-IT.json +108 -0
  12. package/bloom/Resources/Localizable/ja-JP.json +108 -0
  13. package/bloom/Resources/Localizable/ko-KR.json +108 -0
  14. package/bloom/Resources/Localizable/pt-PT.json +108 -0
  15. package/bloom/Resources/Localizable/ru-RU.json +108 -0
  16. package/bloom/Resources/Localizable/tr-TR.json +108 -0
  17. package/bloom/Resources/Localizable/zh-CN.json +108 -0
  18. package/bloom/Sources/OxyAccountUI/SignInFlow.bloom +322 -0
  19. package/bloom/Sources/OxyAccountUI/SignInRules.bloom +135 -0
  20. package/bloom/Sources/OxyAccountUI/SignInService.bloom +141 -0
  21. package/bloom/Sources/OxyAccountUI/SignUpFlow.bloom +322 -0
  22. package/bloom/Sources/OxyAccountUI/SignUpRules.bloom +189 -0
  23. package/bloom/Sources/OxyAccountUIChecks/Checks.bloom +254 -0
  24. package/bloom/Sources/OxyAccountUIChecks/FakeAuth.bloom +123 -0
  25. package/bloom/Sources/OxyAccountUIChecks/SignUpChecks.bloom +193 -0
  26. package/lib/commonjs/ui/boot/runProviderColdBoot.js +43 -329
  27. package/lib/commonjs/ui/boot/runProviderColdBoot.js.map +1 -1
  28. package/lib/commonjs/ui/context/OxyContext.js +7 -1
  29. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  30. package/lib/commonjs/ui/oauth/applicationSessionLane.js +12 -25
  31. package/lib/commonjs/ui/oauth/applicationSessionLane.js.map +1 -1
  32. package/lib/commonjs/ui/session/tokenTransport.js +7 -69
  33. package/lib/commonjs/ui/session/tokenTransport.js.map +1 -1
  34. package/lib/module/ui/boot/runProviderColdBoot.js +43 -329
  35. package/lib/module/ui/boot/runProviderColdBoot.js.map +1 -1
  36. package/lib/module/ui/context/OxyContext.js +8 -2
  37. package/lib/module/ui/context/OxyContext.js.map +1 -1
  38. package/lib/module/ui/oauth/applicationSessionLane.js +4 -23
  39. package/lib/module/ui/oauth/applicationSessionLane.js.map +1 -1
  40. package/lib/module/ui/session/tokenTransport.js +3 -68
  41. package/lib/module/ui/session/tokenTransport.js.map +1 -1
  42. package/lib/typescript/commonjs/ui/boot/runProviderColdBoot.d.ts +8 -31
  43. package/lib/typescript/commonjs/ui/boot/runProviderColdBoot.d.ts.map +1 -1
  44. package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
  45. package/lib/typescript/commonjs/ui/oauth/applicationSessionLane.d.ts +1 -5
  46. package/lib/typescript/commonjs/ui/oauth/applicationSessionLane.d.ts.map +1 -1
  47. package/lib/typescript/commonjs/ui/session/tokenTransport.d.ts +1 -33
  48. package/lib/typescript/commonjs/ui/session/tokenTransport.d.ts.map +1 -1
  49. package/lib/typescript/module/ui/boot/runProviderColdBoot.d.ts +8 -31
  50. package/lib/typescript/module/ui/boot/runProviderColdBoot.d.ts.map +1 -1
  51. package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
  52. package/lib/typescript/module/ui/oauth/applicationSessionLane.d.ts +1 -5
  53. package/lib/typescript/module/ui/oauth/applicationSessionLane.d.ts.map +1 -1
  54. package/lib/typescript/module/ui/session/tokenTransport.d.ts +1 -33
  55. package/lib/typescript/module/ui/session/tokenTransport.d.ts.map +1 -1
  56. package/package.json +10 -5
  57. package/src/ui/boot/runProviderColdBoot.ts +40 -364
  58. package/src/ui/context/OxyContext.tsx +8 -1
  59. package/src/ui/oauth/applicationSessionLane.ts +7 -35
  60. 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
- * Whether the URL carries an OAuth return (`?code=` or `?error=`) for
13
- * `tryCompleteOAuthReturn` to consume. Reads the address bar only.
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
- * Best-effort, FAST connectivity probe run once before the cold boot.
58
- *
59
- * Returns `true` ONLY on an EXPLICIT disconnected verdict; every ambiguous
60
- * outcome (probe timeout, unknown/`null` state, NetInfo unavailable, a thrown
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 detectOfflineHint() {
67
- try {
68
- if (isWebBrowser()) {
69
- const online = globalThis.navigator?.onLine;
70
- // Only an explicit `false` is an offline verdict; `undefined` ⇒ assume online.
71
- return online === false;
72
- }
73
- const NetInfo = await import('@react-native-community/netinfo');
74
- const state = await Promise.race([NetInfo.default.fetch(), new Promise(resolve => {
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
- * The device lanes of the boot (`runSessionColdBoot`), for a first boot or for
99
- * the background check of a painted one.
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
- * A first boot (`painted: false`) is on the critical path: its committed
102
- * session resolves auth, bounded by {@link SESSION_HANDOFF_DEADLINE_MS}. A
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
- async function restoreDeviceSession(opts, painted) {
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
- sessionMode = 'account',
281
- commitSession,
282
- markAuthResolved,
283
- setTokenReady
52
+ commitSession
284
53
  } = opts;
285
- const identityBound = sessionMode === 'identity';
286
- setTokenReady(false);
287
- try {
288
- // Classification precedes every USE of a local secret, the shared credential
289
- // and the identity key. Unavailable registry metadata fails closed on a first
290
- // boot, including offline. It starts now, before anything else, so its round
291
- // trip overlaps the local work below.
292
- const classification = startClassification(opts);
293
-
294
- // A returning session saved on this device paints at once from the cache:
295
- // the account, its cached content, auth resolved, no network on the way.
296
- // The classification and the session are then checked in the background,
297
- // and a verdict against either signs out at that moment. Identity-bound
298
- // clients and OAuth returns keep the path below.
299
- const freshLaunch = !identityBound && !hasOAuthReturnOnUrl();
300
- if (freshLaunch && (await opts.paintCachedSession?.())) {
301
- await verifyCachedSession(opts, {
302
- lane: false,
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
- } finally {
358
- markAuthResolved();
359
- }
73
+ });
360
74
  }
361
75
  //# sourceMappingURL=runProviderColdBoot.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["resolveApplicationSessionLane","logger","loggerUtil","runSessionColdBoot","loadPersistedDeviceCredential","createPlatformSharedDeviceCredentialStore","tryCompleteOAuthReturn","isWebBrowser","isNetConnectivityOnline","hasOAuthReturnOnUrl","search","globalThis","location","params","URLSearchParams","has","hasRestorableState","store","persisted","load","Boolean","accessToken","deviceSecret","SESSION_HANDOFF_DEADLINE_MS","COLD_BOOT_OVERALL_DEADLINE_MS","OFFLINE_PROBE_TIMEOUT_MS","detectOfflineHint","online","navigator","onLine","NetInfo","state","Promise","race","default","fetch","resolve","setTimeout","startClassification","opts","classification","resolveSessionLane","oxyServices","clientId","catch","undefined","restoreDeviceSession","painted","authStore","sessionMode","identity","sessionClient","syncDeviceCredentialToHost","commitSession","markAuthResolved","beforeDeviceBoot","offline","outcome","holderRejected","oxy","platform","isWeb","isNative","sharedDeviceCredential","useSharedDeviceCredential","overallDeadlineMs","isOffline","requireServerVerdict","onHolderRejected","onStepDeadline","stepId","warn","component","method","onSession","session","handoff","sessionId","userId","deviceState","activate","handoffDeadlineId","finally","clearTimeout","onSignedOut","cred","start","socketError","__DEV__","debug","onStepError","id","error","afterDeviceBoot","verifyCachedSession","verified","lane","onCachedSessionRejected","onCachedSessionUnconfirmed","runProviderColdBoot","authRedirectUri","setTokenReady","identityBound","freshLaunch","paintCachedSession","onClassified","oauthCompleted","input","oauth","Error","String"],"sourceRoot":"../../../../src","sources":["ui/boot/runProviderColdBoot.ts"],"mappings":";;AAAA,SAASA,6BAA6B,QAAQ,oCAAiC;AAC/E,SAASC,MAAM,IAAIC,UAAU,QAA0B,cAAc;AACrE,SACEC,kBAAkB,QAIb,sBAAsB;AAE7B,SAASC,6BAA6B,QAAQ,8BAA2B;AACzE,SAASC,yCAAyC,QAAQ,2CAAwC;AAClG,SAASC,sBAAsB,QAAQ,yBAAsB;AAC7D,SAASC,YAAY,QAAQ,0BAAuB;AACpD,SAASC,uBAAuB,QAAQ,6BAA0B;AAGlE;AACA;AACA;AACA;AACA,SAASC,mBAAmBA,CAAA,EAAY;EACtC,MAAMC,MAAM,GAAIC,UAAU,CAAwCC,QAAQ,EAAEF,MAAM;EAClF,IAAI,CAACA,MAAM,EAAE,OAAO,KAAK;EACzB,MAAMG,MAAM,GAAG,IAAIC,eAAe,CAACJ,MAAM,CAAC;EAC1C,OAAOG,MAAM,CAACE,GAAG,CAAC,MAAM,CAAC,IAAIF,MAAM,CAACE,GAAG,CAAC,OAAO,CAAC;AAClD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAeC,kBAAkBA,CAACC,KAAqB,EAAoB;EACzE,MAAMC,SAAS,GAAG,MAAMD,KAAK,CAACE,IAAI,CAAC,CAAC;EACpC,OAAOC,OAAO,CAACF,SAAS,EAAEG,WAAW,IAAIH,SAAS,EAAEI,YAAY,CAAC;AACnE;;AAEA;AACA,OAAO,MAAMC,2BAA2B,GAAG,IAAI;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,6BAA6B,GAAG,MAAM;;AAEnD;AACA;AACA;AACA;AACA;AACA,MAAMC,wBAAwB,GAAG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AAsB,CAAC;MAC3BoC,WAAW;MACXC,QAAQ;MACRyD,eAAe;MACf/C,aAAa,EAAGsD,KAAK,IAAKtD,aAAa,CAACsD,KAAK,EAAE;QAAE3B,QAAQ,EAAE,IAAI;QAAE4B,KAAK,EAAE;MAAK,CAAC;IAChF,CAAC,CAAC;IACN,IAAIF,cAAc,EAAE;MAClBL,aAAa,CAAC,IAAI,CAAC;MACnB/C,gBAAgB,CAAC,CAAC;MAClB;IACF;IAEA,IAAI0C,IAAI,KAAK,OAAO,EAAE;MACpBK,aAAa,CAAC,IAAI,CAAC;MACnB;IACF;IAEA,MAAMvD,oBAAoB,CAACP,IAAI,EAAE,KAAK,CAAC;EACzC,CAAC,CAAC,OAAOqD,KAAK,EAAE;IACd,IAAIJ,OAAO,EAAE;MACXtF,UAAU,CAAC0F,KAAK,CACd,iBAAiB,EACjBA,KAAK,YAAYiB,KAAK,GAAGjB,KAAK,GAAG,IAAIiB,KAAK,CAACC,MAAM,CAAClB,KAAK,CAAC,CAAC,EACzD;QAAEpB,SAAS,EAAE;MAAsB,CACrC,CAAC;IACH;EACF,CAAC,SAAS;IACRlB,gBAAgB,CAAC,CAAC;EACpB;AACF","ignoreList":[]}
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,sBAA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AQ,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
- }, [cachedBoot, identity, user, runtime]);
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