@oxyhq/core 1.11.24 → 2.0.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/README.md +5 -6
- package/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/AuthManager.js +678 -4
- package/dist/cjs/AuthManagerTypes.js +13 -0
- package/dist/cjs/CrossDomainAuth.js +45 -3
- package/dist/cjs/OxyServices.base.js +16 -0
- package/dist/cjs/i18n/locales/ar-SA.json +83 -0
- package/dist/cjs/i18n/locales/ca-ES.json +83 -0
- package/dist/cjs/i18n/locales/de-DE.json +83 -0
- package/dist/cjs/i18n/locales/en-US.json +83 -0
- package/dist/cjs/i18n/locales/es-ES.json +99 -4
- package/dist/cjs/i18n/locales/fr-FR.json +83 -0
- package/dist/cjs/i18n/locales/it-IT.json +83 -0
- package/dist/cjs/i18n/locales/ja-JP.json +83 -0
- package/dist/cjs/i18n/locales/ko-KR.json +83 -0
- package/dist/cjs/i18n/locales/locales/ar-SA.json +83 -1
- package/dist/cjs/i18n/locales/locales/ca-ES.json +83 -1
- package/dist/cjs/i18n/locales/locales/de-DE.json +83 -1
- package/dist/cjs/i18n/locales/locales/en-US.json +83 -0
- package/dist/cjs/i18n/locales/locales/es-ES.json +99 -4
- package/dist/cjs/i18n/locales/locales/fr-FR.json +83 -1
- package/dist/cjs/i18n/locales/locales/it-IT.json +83 -1
- package/dist/cjs/i18n/locales/locales/ja-JP.json +200 -117
- package/dist/cjs/i18n/locales/locales/ko-KR.json +83 -1
- package/dist/cjs/i18n/locales/locales/pt-PT.json +83 -1
- package/dist/cjs/i18n/locales/locales/zh-CN.json +83 -1
- package/dist/cjs/i18n/locales/pt-PT.json +83 -0
- package/dist/cjs/i18n/locales/zh-CN.json +83 -0
- package/dist/cjs/index.js +114 -57
- package/dist/cjs/mixins/OxyServices.auth.js +235 -0
- package/dist/cjs/mixins/OxyServices.fedcm.js +36 -0
- package/dist/cjs/mixins/OxyServices.popup.js +61 -1
- package/dist/cjs/mixins/OxyServices.user.js +18 -0
- package/dist/cjs/utils/accountUtils.js +64 -1
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/AuthManager.js +678 -4
- package/dist/esm/AuthManagerTypes.js +12 -0
- package/dist/esm/CrossDomainAuth.js +45 -3
- package/dist/esm/OxyServices.base.js +16 -0
- package/dist/esm/i18n/locales/ar-SA.json +83 -0
- package/dist/esm/i18n/locales/ca-ES.json +83 -0
- package/dist/esm/i18n/locales/de-DE.json +83 -0
- package/dist/esm/i18n/locales/en-US.json +83 -0
- package/dist/esm/i18n/locales/es-ES.json +99 -4
- package/dist/esm/i18n/locales/fr-FR.json +83 -0
- package/dist/esm/i18n/locales/it-IT.json +83 -0
- package/dist/esm/i18n/locales/ja-JP.json +83 -0
- package/dist/esm/i18n/locales/ko-KR.json +83 -0
- package/dist/esm/i18n/locales/locales/ar-SA.json +83 -1
- package/dist/esm/i18n/locales/locales/ca-ES.json +83 -1
- package/dist/esm/i18n/locales/locales/de-DE.json +83 -1
- package/dist/esm/i18n/locales/locales/en-US.json +83 -0
- package/dist/esm/i18n/locales/locales/es-ES.json +99 -4
- package/dist/esm/i18n/locales/locales/fr-FR.json +83 -1
- package/dist/esm/i18n/locales/locales/it-IT.json +83 -1
- package/dist/esm/i18n/locales/locales/ja-JP.json +200 -117
- package/dist/esm/i18n/locales/locales/ko-KR.json +83 -1
- package/dist/esm/i18n/locales/locales/pt-PT.json +83 -1
- package/dist/esm/i18n/locales/locales/zh-CN.json +83 -1
- package/dist/esm/i18n/locales/pt-PT.json +83 -0
- package/dist/esm/i18n/locales/zh-CN.json +83 -0
- package/dist/esm/index.js +69 -26
- package/dist/esm/mixins/OxyServices.auth.js +235 -0
- package/dist/esm/mixins/OxyServices.fedcm.js +36 -0
- package/dist/esm/mixins/OxyServices.popup.js +61 -1
- package/dist/esm/mixins/OxyServices.user.js +18 -0
- package/dist/esm/utils/accountUtils.js +61 -0
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/AuthManager.d.ts +243 -3
- package/dist/types/AuthManagerTypes.d.ts +68 -0
- package/dist/types/CrossDomainAuth.d.ts +23 -0
- package/dist/types/OxyServices.base.d.ts +14 -0
- package/dist/types/OxyServices.d.ts +7 -0
- package/dist/types/index.d.ts +28 -17
- package/dist/types/mixins/OxyServices.analytics.d.ts +1 -0
- package/dist/types/mixins/OxyServices.appData.d.ts +1 -0
- package/dist/types/mixins/OxyServices.assets.d.ts +4 -1
- package/dist/types/mixins/OxyServices.auth.d.ts +73 -1
- package/dist/types/mixins/OxyServices.contacts.d.ts +1 -0
- package/dist/types/mixins/OxyServices.developer.d.ts +1 -0
- package/dist/types/mixins/OxyServices.devices.d.ts +1 -0
- package/dist/types/mixins/OxyServices.features.d.ts +2 -5
- package/dist/types/mixins/OxyServices.fedcm.d.ts +34 -0
- package/dist/types/mixins/OxyServices.karma.d.ts +1 -0
- package/dist/types/mixins/OxyServices.language.d.ts +1 -0
- package/dist/types/mixins/OxyServices.location.d.ts +1 -0
- package/dist/types/mixins/OxyServices.managedAccounts.d.ts +1 -0
- package/dist/types/mixins/OxyServices.payment.d.ts +1 -0
- package/dist/types/mixins/OxyServices.popup.d.ts +40 -0
- package/dist/types/mixins/OxyServices.privacy.d.ts +1 -0
- package/dist/types/mixins/OxyServices.redirect.d.ts +1 -0
- package/dist/types/mixins/OxyServices.security.d.ts +1 -0
- package/dist/types/mixins/OxyServices.topics.d.ts +1 -0
- package/dist/types/mixins/OxyServices.user.d.ts +16 -1
- package/dist/types/mixins/OxyServices.utility.d.ts +1 -0
- package/dist/types/models/interfaces.d.ts +98 -0
- package/dist/types/models/session.d.ts +8 -0
- package/dist/types/utils/accountUtils.d.ts +33 -0
- package/package.json +9 -18
- package/src/AuthManager.ts +776 -7
- package/src/AuthManagerTypes.ts +72 -0
- package/src/CrossDomainAuth.ts +54 -3
- package/src/OxyServices.base.ts +17 -0
- package/src/OxyServices.ts +7 -0
- package/src/__tests__/authManager.cookiePath.test.ts +339 -0
- package/src/__tests__/authManager.security.test.ts +342 -0
- package/src/__tests__/crossDomainAuth.test.ts +191 -0
- package/src/i18n/locales/ar-SA.json +83 -1
- package/src/i18n/locales/ca-ES.json +83 -1
- package/src/i18n/locales/de-DE.json +83 -1
- package/src/i18n/locales/en-US.json +83 -0
- package/src/i18n/locales/es-ES.json +99 -4
- package/src/i18n/locales/fr-FR.json +83 -1
- package/src/i18n/locales/it-IT.json +83 -1
- package/src/i18n/locales/ja-JP.json +200 -117
- package/src/i18n/locales/ko-KR.json +83 -1
- package/src/i18n/locales/pt-PT.json +83 -1
- package/src/i18n/locales/zh-CN.json +83 -1
- package/src/index.ts +295 -112
- package/src/mixins/OxyServices.auth.ts +268 -1
- package/src/mixins/OxyServices.fedcm.ts +63 -0
- package/src/mixins/OxyServices.popup.ts +79 -1
- package/src/mixins/OxyServices.user.ts +33 -1
- package/src/mixins/__tests__/popup.test.ts +307 -0
- package/src/mixins/__tests__/sessionBaseUrl.test.ts +61 -0
- package/src/models/interfaces.ts +116 -0
- package/src/models/session.ts +8 -0
- package/src/utils/accountUtils.ts +84 -0
- package/dist/cjs/crypto/index.js +0 -22
- package/dist/cjs/shared/index.js +0 -70
- package/dist/cjs/utils/index.js +0 -26
- package/dist/esm/crypto/index.js +0 -13
- package/dist/esm/shared/index.js +0 -31
- package/dist/esm/utils/index.js +0 -7
- package/dist/types/crypto/index.d.ts +0 -11
- package/dist/types/shared/index.d.ts +0 -28
- package/dist/types/utils/index.d.ts +0 -6
- package/src/crypto/index.ts +0 -30
- package/src/shared/index.ts +0 -82
- package/src/utils/index.ts +0 -21
|
@@ -215,6 +215,24 @@ export function OxyServicesUserMixin(Base) {
|
|
|
215
215
|
throw this.handleError(error);
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* Update the authenticated user's notification preferences.
|
|
220
|
+
*
|
|
221
|
+
* Thin wrapper over `updateProfile` that constrains the patch to known
|
|
222
|
+
* notification channels — same persistence path, same cache invalidation,
|
|
223
|
+
* but type-safe at the call site.
|
|
224
|
+
*/
|
|
225
|
+
async updateNotificationPreferences(preferences) {
|
|
226
|
+
return this.updateProfile({ notificationPreferences: preferences });
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Update the authenticated user's general preferences (language, theme,
|
|
230
|
+
* reduce-motion, timezone). Persisted on the User document via
|
|
231
|
+
* `PUT /users/me` — same cache-invalidation behaviour as `updateProfile`.
|
|
232
|
+
*/
|
|
233
|
+
async updateUserPreferences(preferences) {
|
|
234
|
+
return this.updateProfile({ userPreferences: preferences });
|
|
235
|
+
}
|
|
218
236
|
/**
|
|
219
237
|
* Request account verification
|
|
220
238
|
*/
|
|
@@ -108,3 +108,64 @@ export const createQuickAccount = (sessionId, userData, existingAccount, getFile
|
|
|
108
108
|
avatarUrl,
|
|
109
109
|
};
|
|
110
110
|
};
|
|
111
|
+
/**
|
|
112
|
+
* Merge a fresh `/auth/refresh-all` snapshot into an existing QuickAccount
|
|
113
|
+
* list, preserving any cached fields (`avatarUrl`) for slots that didn't
|
|
114
|
+
* change. The fresh response is canonical: the resulting list contains EXACTLY
|
|
115
|
+
* the slots present in `fresh`, sorted by `authuser` ascending. Stale stored
|
|
116
|
+
* accounts that no longer appear in `fresh` are dropped (the server already
|
|
117
|
+
* authoritatively cleared the corresponding cookie).
|
|
118
|
+
*
|
|
119
|
+
* @param stored Previously persisted QuickAccount list (any order).
|
|
120
|
+
* @param fresh Server's authoritative refresh-all response.
|
|
121
|
+
* @returns Canonical merged list, sorted by `authuser` asc.
|
|
122
|
+
*/
|
|
123
|
+
export const mergeAccountsFromRefreshAll = (stored, fresh) => {
|
|
124
|
+
const storedByAuthuser = new Map();
|
|
125
|
+
if (stored) {
|
|
126
|
+
for (const account of stored) {
|
|
127
|
+
if (typeof account.authuser === 'number') {
|
|
128
|
+
storedByAuthuser.set(account.authuser, account);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
const merged = fresh.map((entry) => {
|
|
133
|
+
const previous = storedByAuthuser.get(entry.authuser);
|
|
134
|
+
// `entry.user` is null on the SDK legacy-fallback path; preserve any
|
|
135
|
+
// previously cached identity for that slot rather than overwriting
|
|
136
|
+
// it with blanks, and let the AuthManager's getCurrentUser() hydration
|
|
137
|
+
// refresh it on the next snapshot.
|
|
138
|
+
const wireUser = entry.user;
|
|
139
|
+
const username = wireUser?.username ?? previous?.username ?? '';
|
|
140
|
+
const displayName = getAccountDisplayName({
|
|
141
|
+
name: wireUser?.name,
|
|
142
|
+
username,
|
|
143
|
+
});
|
|
144
|
+
const avatar = wireUser?.avatar ?? previous?.avatar ?? undefined;
|
|
145
|
+
const avatarUrl = previous && previous.avatar === avatar ? previous.avatarUrl : undefined;
|
|
146
|
+
return {
|
|
147
|
+
sessionId: entry.sessionId,
|
|
148
|
+
userId: wireUser?.id ?? previous?.userId,
|
|
149
|
+
username,
|
|
150
|
+
displayName,
|
|
151
|
+
avatar,
|
|
152
|
+
avatarUrl,
|
|
153
|
+
authuser: entry.authuser,
|
|
154
|
+
color: wireUser?.color ?? previous?.color ?? null,
|
|
155
|
+
};
|
|
156
|
+
});
|
|
157
|
+
merged.sort((a, b) => {
|
|
158
|
+
const aIdx = a.authuser ?? Number.POSITIVE_INFINITY;
|
|
159
|
+
const bIdx = b.authuser ?? Number.POSITIVE_INFINITY;
|
|
160
|
+
return aIdx - bIdx;
|
|
161
|
+
});
|
|
162
|
+
return merged;
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* Return the account's preferred Bloom color preset, or `null` if it has no
|
|
166
|
+
* preference. Centralises the `color ?? null` normalisation so consumers can
|
|
167
|
+
* drive per-account theming without duplicating the nullish-handling.
|
|
168
|
+
*/
|
|
169
|
+
export const getAccountColor = (account) => {
|
|
170
|
+
return account.color ?? null;
|
|
171
|
+
};
|