@oxyhq/core 1.11.7 → 1.11.8
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.fedcm.js +11 -4
- package/dist/cjs/mixins/OxyServices.popup.js +10 -6
- package/dist/cjs/mixins/OxyServices.redirect.js +6 -2
- package/dist/cjs/mixins/OxyServices.user.js +12 -0
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/mixins/OxyServices.fedcm.js +11 -4
- package/dist/esm/mixins/OxyServices.popup.js +10 -6
- package/dist/esm/mixins/OxyServices.redirect.js +6 -2
- package/dist/esm/mixins/OxyServices.user.js +12 -0
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/mixins/OxyServices.fedcm.d.ts +3 -0
- package/dist/types/mixins/OxyServices.popup.d.ts +3 -1
- package/dist/types/mixins/OxyServices.redirect.d.ts +3 -1
- package/dist/types/mixins/OxyServices.user.d.ts +4 -0
- package/package.json +1 -1
- package/src/mixins/OxyServices.fedcm.ts +12 -4
- package/src/mixins/OxyServices.popup.ts +11 -6
- package/src/mixins/OxyServices.redirect.ts +7 -2
- package/src/mixins/OxyServices.user.ts +12 -0
|
@@ -34,6 +34,12 @@ export function OxyServicesFedCMMixin(Base) {
|
|
|
34
34
|
constructor(...args) {
|
|
35
35
|
super(...args);
|
|
36
36
|
}
|
|
37
|
+
/** Resolved FedCM config URL: derived from config.authWebUrl or uses the static default */
|
|
38
|
+
get fedcmConfigUrl() {
|
|
39
|
+
return this.config.authWebUrl
|
|
40
|
+
? `${this.config.authWebUrl}/fedcm.json`
|
|
41
|
+
: this.constructor.DEFAULT_CONFIG_URL;
|
|
42
|
+
}
|
|
37
43
|
/**
|
|
38
44
|
* Check if FedCM is supported in the current browser
|
|
39
45
|
*/
|
|
@@ -85,7 +91,7 @@ export function OxyServicesFedCMMixin(Base) {
|
|
|
85
91
|
// Request credential from browser's native identity flow
|
|
86
92
|
// mode: 'button' signals this is a user-gesture-initiated flow (Chrome 125+)
|
|
87
93
|
const credential = await this.requestIdentityCredential({
|
|
88
|
-
configURL: this.
|
|
94
|
+
configURL: this.fedcmConfigUrl,
|
|
89
95
|
clientId,
|
|
90
96
|
nonce,
|
|
91
97
|
context: options.context,
|
|
@@ -175,7 +181,7 @@ export function OxyServicesFedCMMixin(Base) {
|
|
|
175
181
|
const nonce = this.generateNonce();
|
|
176
182
|
debug.log('Silent SSO: Attempting silent mediation...', loginHint ? `(hint: ${loginHint})` : '');
|
|
177
183
|
credential = await this.requestIdentityCredential({
|
|
178
|
-
configURL: this.
|
|
184
|
+
configURL: this.fedcmConfigUrl,
|
|
179
185
|
clientId,
|
|
180
186
|
nonce,
|
|
181
187
|
loginHint,
|
|
@@ -389,7 +395,7 @@ export function OxyServicesFedCMMixin(Base) {
|
|
|
389
395
|
if ('IdentityCredential' in window && 'disconnect' in window.IdentityCredential) {
|
|
390
396
|
const clientId = this.getClientId();
|
|
391
397
|
await window.IdentityCredential.disconnect({
|
|
392
|
-
configURL: this.
|
|
398
|
+
configURL: this.fedcmConfigUrl,
|
|
393
399
|
clientId,
|
|
394
400
|
accountHint: accountHint || '*',
|
|
395
401
|
});
|
|
@@ -408,7 +414,7 @@ export function OxyServicesFedCMMixin(Base) {
|
|
|
408
414
|
getFedCMConfig() {
|
|
409
415
|
return {
|
|
410
416
|
enabled: this.isFedCMSupported(),
|
|
411
|
-
configURL: this.
|
|
417
|
+
configURL: this.fedcmConfigUrl,
|
|
412
418
|
clientId: this.getClientId(),
|
|
413
419
|
};
|
|
414
420
|
}
|
|
@@ -473,6 +479,7 @@ export function OxyServicesFedCMMixin(Base) {
|
|
|
473
479
|
}
|
|
474
480
|
}
|
|
475
481
|
},
|
|
482
|
+
_a.DEFAULT_AUTH_URL = 'https://auth.oxy.so',
|
|
476
483
|
_a.DEFAULT_CONFIG_URL = 'https://auth.oxy.so/fedcm.json',
|
|
477
484
|
_a.FEDCM_TIMEOUT = 15000 // 15 seconds for interactive
|
|
478
485
|
,
|
|
@@ -29,6 +29,10 @@ export function OxyServicesPopupAuthMixin(Base) {
|
|
|
29
29
|
constructor(...args) {
|
|
30
30
|
super(...args);
|
|
31
31
|
}
|
|
32
|
+
/** Resolved auth URL: config.authWebUrl takes precedence over the static default */
|
|
33
|
+
get authUrl() {
|
|
34
|
+
return this.config.authWebUrl || this.constructor.DEFAULT_AUTH_URL;
|
|
35
|
+
}
|
|
32
36
|
/**
|
|
33
37
|
* Sign in using popup window
|
|
34
38
|
*
|
|
@@ -71,7 +75,7 @@ export function OxyServicesPopupAuthMixin(Base) {
|
|
|
71
75
|
state,
|
|
72
76
|
nonce,
|
|
73
77
|
clientId: window.location.origin,
|
|
74
|
-
redirectUri: `${this.
|
|
78
|
+
redirectUri: `${this.authUrl}/auth/callback`,
|
|
75
79
|
});
|
|
76
80
|
const popup = this.openCenteredPopup(authUrl, 'Oxy Sign In', width, height);
|
|
77
81
|
if (!popup) {
|
|
@@ -159,7 +163,7 @@ export function OxyServicesPopupAuthMixin(Base) {
|
|
|
159
163
|
iframe.style.width = '0';
|
|
160
164
|
iframe.style.height = '0';
|
|
161
165
|
iframe.style.border = 'none';
|
|
162
|
-
const silentUrl = `${this.
|
|
166
|
+
const silentUrl = `${this.authUrl}/auth/silent?` + `client_id=${encodeURIComponent(clientId)}&` + `nonce=${nonce}`;
|
|
163
167
|
iframe.src = silentUrl;
|
|
164
168
|
document.body.appendChild(iframe);
|
|
165
169
|
try {
|
|
@@ -210,7 +214,7 @@ export function OxyServicesPopupAuthMixin(Base) {
|
|
|
210
214
|
reject(new OxyAuthenticationError('Authentication timeout'));
|
|
211
215
|
}, timeout);
|
|
212
216
|
const messageHandler = (event) => {
|
|
213
|
-
const authUrl = this.
|
|
217
|
+
const authUrl = this.authUrl;
|
|
214
218
|
// Log all messages for debugging
|
|
215
219
|
if (event.data && typeof event.data === 'object' && event.data.type) {
|
|
216
220
|
debug.log('Message received:', {
|
|
@@ -282,7 +286,7 @@ export function OxyServicesPopupAuthMixin(Base) {
|
|
|
282
286
|
}, timeout);
|
|
283
287
|
const messageHandler = (event) => {
|
|
284
288
|
// Verify origin
|
|
285
|
-
if (event.origin !== this.
|
|
289
|
+
if (event.origin !== this.authUrl) {
|
|
286
290
|
return;
|
|
287
291
|
}
|
|
288
292
|
const { type, session } = event.data;
|
|
@@ -305,7 +309,7 @@ export function OxyServicesPopupAuthMixin(Base) {
|
|
|
305
309
|
* @private
|
|
306
310
|
*/
|
|
307
311
|
buildAuthUrl(params) {
|
|
308
|
-
const url = new URL(`${this.
|
|
312
|
+
const url = new URL(`${this.authUrl}/${params.mode}`);
|
|
309
313
|
url.searchParams.set('response_type', 'token');
|
|
310
314
|
url.searchParams.set('client_id', params.clientId);
|
|
311
315
|
url.searchParams.set('redirect_uri', params.redirectUri);
|
|
@@ -366,7 +370,7 @@ export function OxyServicesPopupAuthMixin(Base) {
|
|
|
366
370
|
}
|
|
367
371
|
}
|
|
368
372
|
},
|
|
369
|
-
_a.
|
|
373
|
+
_a.DEFAULT_AUTH_URL = 'https://auth.oxy.so',
|
|
370
374
|
_a.POPUP_WIDTH = 500,
|
|
371
375
|
_a.POPUP_HEIGHT = 700,
|
|
372
376
|
_a.POPUP_TIMEOUT = 60000 // 1 minute
|
|
@@ -29,6 +29,10 @@ export function OxyServicesRedirectAuthMixin(Base) {
|
|
|
29
29
|
constructor(...args) {
|
|
30
30
|
super(...args);
|
|
31
31
|
}
|
|
32
|
+
/** Resolved auth URL: config.authWebUrl takes precedence over the static default */
|
|
33
|
+
get authUrl() {
|
|
34
|
+
return this.config.authWebUrl || this.constructor.DEFAULT_AUTH_URL;
|
|
35
|
+
}
|
|
32
36
|
/**
|
|
33
37
|
* Sign in using full page redirect
|
|
34
38
|
*
|
|
@@ -224,7 +228,7 @@ export function OxyServicesRedirectAuthMixin(Base) {
|
|
|
224
228
|
* @private
|
|
225
229
|
*/
|
|
226
230
|
buildAuthUrl(params) {
|
|
227
|
-
const url = new URL(`${this.
|
|
231
|
+
const url = new URL(`${this.authUrl}/${params.mode}`);
|
|
228
232
|
url.searchParams.set('redirect_uri', params.redirectUri);
|
|
229
233
|
url.searchParams.set('state', params.state);
|
|
230
234
|
url.searchParams.set('nonce', params.nonce);
|
|
@@ -341,7 +345,7 @@ export function OxyServicesRedirectAuthMixin(Base) {
|
|
|
341
345
|
window.history.replaceState({}, '', url.toString());
|
|
342
346
|
}
|
|
343
347
|
},
|
|
344
|
-
_a.
|
|
348
|
+
_a.DEFAULT_AUTH_URL = 'https://auth.oxy.so',
|
|
345
349
|
_a.TOKEN_STORAGE_KEY = 'oxy_access_token',
|
|
346
350
|
_a.SESSION_STORAGE_KEY = 'oxy_session_id',
|
|
347
351
|
_a.STATE_STORAGE_KEY = 'oxy_auth_state',
|
|
@@ -104,6 +104,18 @@ export function OxyServicesUserMixin(Base) {
|
|
|
104
104
|
return await this.makeRequest('GET', '/profiles/recommendations', params, { cache: true });
|
|
105
105
|
}, 'getProfileRecommendations');
|
|
106
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Get profiles similar to a given user, based on co-follower overlap.
|
|
109
|
+
*/
|
|
110
|
+
async getSimilarProfiles(userId, limit) {
|
|
111
|
+
const params = {};
|
|
112
|
+
if (limit)
|
|
113
|
+
params.limit = String(limit);
|
|
114
|
+
return await this.makeRequest('GET', `/profiles/${userId}/similar`, params, {
|
|
115
|
+
cache: true,
|
|
116
|
+
cacheTTL: 5 * 60 * 1000, // 5 min cache
|
|
117
|
+
});
|
|
118
|
+
}
|
|
107
119
|
/**
|
|
108
120
|
* Get user by ID
|
|
109
121
|
*/
|