@oxyhq/core 10.1.2 → 10.1.4
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/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/session/accountDialogController.js +25 -7
- package/dist/cjs/utils/textNormalization.js +0 -28
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/session/accountDialogController.js +25 -7
- package/dist/esm/utils/textNormalization.js +0 -28
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/models/interfaces.d.ts +0 -1
- package/package.json +1 -1
- package/src/models/interfaces.ts +0 -1
- package/src/session/__tests__/accountDialogController.test.ts +36 -0
- package/src/session/accountDialogController.ts +23 -7
- package/src/utils/textNormalization.ts +0 -30
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
* builds the hand-off URL; device-first convergence syncs the session back.
|
|
27
27
|
*/
|
|
28
28
|
import { logger } from '../utils/loggerUtils.js';
|
|
29
|
+
import { extractErrorStatus } from '../utils/errorUtils.js';
|
|
29
30
|
import { CENTRAL_IDP_APEX } from '../utils/authWebUrl.js';
|
|
30
31
|
import { generateOAuthState, generatePkcePair, normalizeOAuthRedirectUri, persistOAuthHandshake, } from '../utils/oauthPkce.js';
|
|
31
32
|
import { projectSwitchableAccounts, switchableAccountIds, } from './accountProjection.js';
|
|
@@ -241,10 +242,20 @@ export class AccountDialogController {
|
|
|
241
242
|
graph = await this.oxyServices.listAccounts();
|
|
242
243
|
}
|
|
243
244
|
catch (error) {
|
|
244
|
-
// A
|
|
245
|
-
//
|
|
246
|
-
|
|
247
|
-
|
|
245
|
+
// A 401 here is the EXPECTED signed-out edge, not a failure: the bearer was
|
|
246
|
+
// stale/revoked, so `HttpService` already cleared it and emitted
|
|
247
|
+
// `onTokensChanged(null)`, which drops the graph via `reconcileAuth`. Log at
|
|
248
|
+
// debug and leave the dialog error-free — a signed-out device with zero
|
|
249
|
+
// accounts is a normal state, not a warning. Any other error (network, 5xx,
|
|
250
|
+
// malformed) IS unexpected: surface it and warn while keeping the prior graph
|
|
251
|
+
// so device rows still render.
|
|
252
|
+
if (extractErrorStatus(error) === 401) {
|
|
253
|
+
logger.debug('[AccountDialogController] listAccounts unauthorized (signed out)', { component: 'AccountDialogController' }, error);
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
this.error = errorMessage(error);
|
|
257
|
+
logger.warn('[AccountDialogController] listAccounts failed', { component: 'AccountDialogController' }, error);
|
|
258
|
+
}
|
|
248
259
|
}
|
|
249
260
|
if (seq !== this.refreshSeq)
|
|
250
261
|
return; // superseded by a newer refresh
|
|
@@ -284,9 +295,16 @@ export class AccountDialogController {
|
|
|
284
295
|
profiles = await this.oxyServices.getUsersByIds(ids);
|
|
285
296
|
}
|
|
286
297
|
catch (error) {
|
|
287
|
-
//
|
|
288
|
-
//
|
|
289
|
-
|
|
298
|
+
// A 401 is the EXPECTED signed-out edge (stale/cleared bearer) — log at debug.
|
|
299
|
+
// `getUsersByIds` already swallows per-chunk failures and returns `[]`, so any
|
|
300
|
+
// OTHER error here is an unexpected total failure worth a warn. Either way keep
|
|
301
|
+
// the prior profile map.
|
|
302
|
+
if (extractErrorStatus(error) === 401) {
|
|
303
|
+
logger.debug('[AccountDialogController] getUsersByIds unauthorized (signed out)', { component: 'AccountDialogController' }, error);
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
logger.warn('[AccountDialogController] getUsersByIds failed', { component: 'AccountDialogController' }, error);
|
|
307
|
+
}
|
|
290
308
|
return;
|
|
291
309
|
}
|
|
292
310
|
if (seq !== this.refreshSeq)
|
|
@@ -42,28 +42,6 @@
|
|
|
42
42
|
* the display-name character policy). These functions do exactly one thing:
|
|
43
43
|
* normalize whitespace and Unicode form.
|
|
44
44
|
*/
|
|
45
|
-
/**
|
|
46
|
-
* Characters that make a value ineligible for the zero-work fast path, and the
|
|
47
|
-
* whitespace shapes that a normalized INLINE value can never contain.
|
|
48
|
-
*
|
|
49
|
-
* A value that matches nothing here is, by construction, already normalized:
|
|
50
|
-
* it holds only printable ASCII (which is NFC-stable, so `normalize('NFC')`
|
|
51
|
-
* would be a no-op), its only whitespace is the plain space, it has no leading
|
|
52
|
-
* or trailing space, and no run of two spaces. Returning it untouched skips
|
|
53
|
-
* three string allocations — worth it because the common case in the feed
|
|
54
|
-
* hydration hot path is text that is already clean.
|
|
55
|
-
*
|
|
56
|
-
* Non-global (safe for repeated `.test()`; a global regex is stateful).
|
|
57
|
-
*/
|
|
58
|
-
const INLINE_NEEDS_NORMALIZATION = /[^\x20-\x7E]|^ | $| {2}/;
|
|
59
|
-
/**
|
|
60
|
-
* Same idea as {@link INLINE_NEEDS_NORMALIZATION}, for MULTILINE values: `\n`
|
|
61
|
-
* joins the printable-ASCII fast-path alphabet, and the additional shapes a
|
|
62
|
-
* normalized body can never contain are a space adjacent to a line break — on
|
|
63
|
-
* either side, since every line is trimmed — and a run of three line breaks
|
|
64
|
-
* (more than one blank line).
|
|
65
|
-
*/
|
|
66
|
-
const MULTILINE_NEEDS_NORMALIZATION = /[^\x20-\x7E\n]|^[ \n]|[ \n]$| {2}| \n|\n |\n{3}/;
|
|
67
45
|
/** Any run of whitespace, including tabs, line breaks and Unicode spaces. */
|
|
68
46
|
const ANY_WHITESPACE_RUN = /\s+/g;
|
|
69
47
|
/**
|
|
@@ -125,9 +103,6 @@ const EXCESS_BLANK_LINES = /\n{3,}/g;
|
|
|
125
103
|
* Idempotent: `f(f(x)) === f(x)`.
|
|
126
104
|
*/
|
|
127
105
|
export function normalizeInlineText(value) {
|
|
128
|
-
if (!INLINE_NEEDS_NORMALIZATION.test(value)) {
|
|
129
|
-
return value;
|
|
130
|
-
}
|
|
131
106
|
return value.normalize('NFC').replace(ANY_WHITESPACE_RUN, ' ').trim();
|
|
132
107
|
}
|
|
133
108
|
/**
|
|
@@ -163,9 +138,6 @@ export function normalizeInlineText(value) {
|
|
|
163
138
|
* Idempotent: `f(f(x)) === f(x)`.
|
|
164
139
|
*/
|
|
165
140
|
export function normalizeMultilineText(value) {
|
|
166
|
-
if (!MULTILINE_NEEDS_NORMALIZATION.test(value)) {
|
|
167
|
-
return value;
|
|
168
|
-
}
|
|
169
141
|
return value
|
|
170
142
|
.normalize('NFC')
|
|
171
143
|
.replace(LINE_BREAK_FORMS, '\n')
|