@oxyhq/core 3.17.0 → 3.18.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.auth.js +6 -2
- package/dist/cjs/mixins/OxyServices.links.js +6 -2
- package/dist/cjs/mixins/OxyServices.sso.js +5 -2
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/mixins/OxyServices.auth.js +6 -2
- package/dist/esm/mixins/OxyServices.links.js +6 -2
- package/dist/esm/mixins/OxyServices.sso.js +5 -2
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/mixins/OxyServices.links.d.ts +5 -1
- package/dist/types/models/interfaces.d.ts +4 -2
- package/package.json +1 -1
- package/src/mixins/OxyServices.auth.ts +6 -2
- package/src/mixins/OxyServices.links.ts +8 -4
- package/src/mixins/OxyServices.sso.ts +5 -2
- package/src/mixins/__tests__/OxyServices.links.test.ts +8 -8
- package/src/models/interfaces.ts +4 -2
|
@@ -694,7 +694,9 @@ function OxyServicesAuthMixin(Base) {
|
|
|
694
694
|
continue;
|
|
695
695
|
}
|
|
696
696
|
const userId = e.user.id ?? e.user._id;
|
|
697
|
-
|
|
697
|
+
// `name.displayName` is optional on the contract — do NOT drop no-name
|
|
698
|
+
// accounts. Only an absent userId or username makes the entry unusable.
|
|
699
|
+
if (!userId || !e.user.username) {
|
|
698
700
|
continue;
|
|
699
701
|
}
|
|
700
702
|
if (typeof e.authuser !== 'number') {
|
|
@@ -708,7 +710,9 @@ function OxyServicesAuthMixin(Base) {
|
|
|
708
710
|
user: {
|
|
709
711
|
id: userId,
|
|
710
712
|
username: e.user.username,
|
|
711
|
-
name
|
|
713
|
+
// `name.displayName` is optional; carry whatever structured name the
|
|
714
|
+
// server sent (possibly an empty object) and let consumers fall back.
|
|
715
|
+
name: e.user.name ?? {},
|
|
712
716
|
avatar: e.user.avatar ?? null,
|
|
713
717
|
email: e.user.email,
|
|
714
718
|
color: e.user.color ?? null,
|
|
@@ -38,11 +38,15 @@ function OxyServicesLinksMixin(Base) {
|
|
|
38
38
|
* Resolve multiple link previews via `POST /links/previews` (body `{ urls }`).
|
|
39
39
|
*
|
|
40
40
|
* Inputs are de-duplicated and split into chunks of {@link LINK_PREVIEWS_CHUNK_SIZE}
|
|
41
|
-
* (the server-side cap). Chunks run concurrently and their
|
|
41
|
+
* (the server-side cap). Chunks run concurrently and their result maps are
|
|
42
42
|
* merged into a single result keyed by the REQUESTED url (the exact string
|
|
43
43
|
* passed in `urls`) — matching the batch contract — so a caller can always
|
|
44
44
|
* look its own input back up.
|
|
45
45
|
*
|
|
46
|
+
* `makeRequest` unwraps the API's top-level `{ data }` envelope (same as
|
|
47
|
+
* `getUsersByIds`'s `makeServiceRequest<User[]>`), so each chunk response is
|
|
48
|
+
* already the `Record<url, LinkPreview>` map — merge it directly.
|
|
49
|
+
*
|
|
46
50
|
* An empty / whitespace-only input resolves immediately with `{}` and
|
|
47
51
|
* performs no network call. A failure in any chunk surfaces (via
|
|
48
52
|
* `handleError`) rather than being swallowed.
|
|
@@ -58,7 +62,7 @@ function OxyServicesLinksMixin(Base) {
|
|
|
58
62
|
}
|
|
59
63
|
try {
|
|
60
64
|
const responses = await Promise.all(chunks.map((chunk) => this.makeRequest('POST', '/links/previews', { urls: chunk }, { cache: false })));
|
|
61
|
-
return responses.reduce((merged, response) => Object.assign(merged, response
|
|
65
|
+
return responses.reduce((merged, response) => Object.assign(merged, response ?? {}), {});
|
|
62
66
|
}
|
|
63
67
|
catch (error) {
|
|
64
68
|
throw this.handleError(error);
|
|
@@ -142,13 +142,16 @@ function OxyServicesSsoMixin(Base) {
|
|
|
142
142
|
throw this.handleError(new Error('SSO exchange returned no sessionId'));
|
|
143
143
|
}
|
|
144
144
|
const userId = payload.user?.id ?? payload.user?._id;
|
|
145
|
-
if (!userId || typeof payload.user?.username !== 'string'
|
|
145
|
+
if (!userId || typeof payload.user?.username !== 'string') {
|
|
146
146
|
throw this.handleError(new Error('SSO exchange returned an invalid user'));
|
|
147
147
|
}
|
|
148
148
|
const user = {
|
|
149
149
|
id: userId,
|
|
150
150
|
username: payload.user.username,
|
|
151
|
-
name
|
|
151
|
+
// `name.displayName` is optional on the contract. A no-name user is
|
|
152
|
+
// valid; carry whatever structured name the server sent (possibly an
|
|
153
|
+
// empty object) and let consumers fall back to a handle.
|
|
154
|
+
name: payload.user.name ?? {},
|
|
152
155
|
avatar: payload.user.avatar,
|
|
153
156
|
};
|
|
154
157
|
// Plant the access token exactly like exchangeIdTokenForSession does.
|