@oxyhq/core 12.4.1 → 12.5.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/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/mixins/OxyServices.user.js +11 -0
- package/dist/cjs/server/safeFetch.js +4 -4
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/mixins/OxyServices.user.js +11 -0
- package/dist/esm/server/safeFetch.js +4 -4
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/mixins/OxyServices.user.d.ts +10 -1
- package/dist/types/models/interfaces.d.ts +15 -1
- package/dist/types/server/safeFetch.d.ts +2 -0
- package/package.json +2 -2
- package/src/mixins/OxyServices.user.ts +15 -0
- package/src/models/interfaces.ts +20 -1
- package/src/server/safeFetch.ts +6 -1
|
@@ -437,6 +437,17 @@ export function OxyServicesUserMixin(Base) {
|
|
|
437
437
|
async updateUserPreferences(preferences) {
|
|
438
438
|
return this.updateProfile({ userPreferences: preferences });
|
|
439
439
|
}
|
|
440
|
+
/**
|
|
441
|
+
* Update the authenticated user's portable theme preference (light/dark/
|
|
442
|
+
* system + Bloom color-preset key). Persisted on the User document via the
|
|
443
|
+
* SAME `PUT /users/me` settings path as the other preferences — same cache
|
|
444
|
+
* invalidation — so the next cold boot serves it on the self/session payload
|
|
445
|
+
* with no extra network call. The full object is written (both `mode` and
|
|
446
|
+
* `colorPreset` are required by the API).
|
|
447
|
+
*/
|
|
448
|
+
async updateThemePreference(themePreference) {
|
|
449
|
+
return this.updateProfile({ themePreference });
|
|
450
|
+
}
|
|
440
451
|
/**
|
|
441
452
|
* Request account verification
|
|
442
453
|
*/
|
|
@@ -372,7 +372,7 @@ function buildRequestOptions(target, pinnedIp, pinnedFamily, method, headers, si
|
|
|
372
372
|
};
|
|
373
373
|
}
|
|
374
374
|
/** Perform a single upstream request (no auto-redirect). */
|
|
375
|
-
function fetchOnce(options, isHttps, headersTimeoutMs) {
|
|
375
|
+
function fetchOnce(options, isHttps, headersTimeoutMs, body) {
|
|
376
376
|
return new Promise((resolve, reject) => {
|
|
377
377
|
const transport = isHttps ? https : http;
|
|
378
378
|
const req = transport.request(options, (res) => resolve(res));
|
|
@@ -380,7 +380,7 @@ function fetchOnce(options, isHttps, headersTimeoutMs) {
|
|
|
380
380
|
req.destroy(new UpstreamError('upstream headers timeout'));
|
|
381
381
|
});
|
|
382
382
|
req.on('error', (err) => reject(err));
|
|
383
|
-
req.end();
|
|
383
|
+
req.end(body);
|
|
384
384
|
});
|
|
385
385
|
}
|
|
386
386
|
/**
|
|
@@ -395,7 +395,7 @@ function fetchOnce(options, isHttps, headersTimeoutMs) {
|
|
|
395
395
|
* @throws {UpstreamError} on redirect-loop / malformed-redirect / timeout.
|
|
396
396
|
*/
|
|
397
397
|
export async function safeFetch(rawUrl, options = {}) {
|
|
398
|
-
const { method = 'GET', headers: callerHeaders, maxRedirects = MAX_REDIRECTS, headersTimeoutMs = UPSTREAM_HEADERS_TIMEOUT_MS, signal, } = options;
|
|
398
|
+
const { method = 'GET', headers: callerHeaders, body, maxRedirects = MAX_REDIRECTS, headersTimeoutMs = UPSTREAM_HEADERS_TIMEOUT_MS, signal, } = options;
|
|
399
399
|
// Normalize a case-insensitive header map and ensure a User-Agent default.
|
|
400
400
|
const baseHeaders = {};
|
|
401
401
|
if (callerHeaders) {
|
|
@@ -418,7 +418,7 @@ export async function safeFetch(rawUrl, options = {}) {
|
|
|
418
418
|
}
|
|
419
419
|
const target = new URL(currentUrl);
|
|
420
420
|
const requestOptions = buildRequestOptions(target, guard.ip, guard.family, method, baseHeaders, signal);
|
|
421
|
-
const response = await fetchOnce(requestOptions, target.protocol === 'https:', headersTimeoutMs);
|
|
421
|
+
const response = await fetchOnce(requestOptions, target.protocol === 'https:', headersTimeoutMs, body);
|
|
422
422
|
const status = response.statusCode ?? 0;
|
|
423
423
|
if (REDIRECT_STATUS_CODES.has(status)) {
|
|
424
424
|
const location = response.headers.location;
|