@oxyhq/core 1.11.6 → 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/AuthManager.js +22 -2
- 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/AuthManager.js +22 -2
- 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/AuthManager.d.ts +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/AuthManager.ts +22 -2
- 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
|
@@ -38,6 +38,12 @@ function OxyServicesFedCMMixin(Base) {
|
|
|
38
38
|
constructor(...args) {
|
|
39
39
|
super(...args);
|
|
40
40
|
}
|
|
41
|
+
/** Resolved FedCM config URL: derived from config.authWebUrl or uses the static default */
|
|
42
|
+
get fedcmConfigUrl() {
|
|
43
|
+
return this.config.authWebUrl
|
|
44
|
+
? `${this.config.authWebUrl}/fedcm.json`
|
|
45
|
+
: this.constructor.DEFAULT_CONFIG_URL;
|
|
46
|
+
}
|
|
41
47
|
/**
|
|
42
48
|
* Check if FedCM is supported in the current browser
|
|
43
49
|
*/
|
|
@@ -89,7 +95,7 @@ function OxyServicesFedCMMixin(Base) {
|
|
|
89
95
|
// Request credential from browser's native identity flow
|
|
90
96
|
// mode: 'button' signals this is a user-gesture-initiated flow (Chrome 125+)
|
|
91
97
|
const credential = await this.requestIdentityCredential({
|
|
92
|
-
configURL: this.
|
|
98
|
+
configURL: this.fedcmConfigUrl,
|
|
93
99
|
clientId,
|
|
94
100
|
nonce,
|
|
95
101
|
context: options.context,
|
|
@@ -179,7 +185,7 @@ function OxyServicesFedCMMixin(Base) {
|
|
|
179
185
|
const nonce = this.generateNonce();
|
|
180
186
|
debug.log('Silent SSO: Attempting silent mediation...', loginHint ? `(hint: ${loginHint})` : '');
|
|
181
187
|
credential = await this.requestIdentityCredential({
|
|
182
|
-
configURL: this.
|
|
188
|
+
configURL: this.fedcmConfigUrl,
|
|
183
189
|
clientId,
|
|
184
190
|
nonce,
|
|
185
191
|
loginHint,
|
|
@@ -393,7 +399,7 @@ function OxyServicesFedCMMixin(Base) {
|
|
|
393
399
|
if ('IdentityCredential' in window && 'disconnect' in window.IdentityCredential) {
|
|
394
400
|
const clientId = this.getClientId();
|
|
395
401
|
await window.IdentityCredential.disconnect({
|
|
396
|
-
configURL: this.
|
|
402
|
+
configURL: this.fedcmConfigUrl,
|
|
397
403
|
clientId,
|
|
398
404
|
accountHint: accountHint || '*',
|
|
399
405
|
});
|
|
@@ -412,7 +418,7 @@ function OxyServicesFedCMMixin(Base) {
|
|
|
412
418
|
getFedCMConfig() {
|
|
413
419
|
return {
|
|
414
420
|
enabled: this.isFedCMSupported(),
|
|
415
|
-
configURL: this.
|
|
421
|
+
configURL: this.fedcmConfigUrl,
|
|
416
422
|
clientId: this.getClientId(),
|
|
417
423
|
};
|
|
418
424
|
}
|
|
@@ -477,6 +483,7 @@ function OxyServicesFedCMMixin(Base) {
|
|
|
477
483
|
}
|
|
478
484
|
}
|
|
479
485
|
},
|
|
486
|
+
_a.DEFAULT_AUTH_URL = 'https://auth.oxy.so',
|
|
480
487
|
_a.DEFAULT_CONFIG_URL = 'https://auth.oxy.so/fedcm.json',
|
|
481
488
|
_a.FEDCM_TIMEOUT = 15000 // 15 seconds for interactive
|
|
482
489
|
,
|
|
@@ -33,6 +33,10 @@ function OxyServicesPopupAuthMixin(Base) {
|
|
|
33
33
|
constructor(...args) {
|
|
34
34
|
super(...args);
|
|
35
35
|
}
|
|
36
|
+
/** Resolved auth URL: config.authWebUrl takes precedence over the static default */
|
|
37
|
+
get authUrl() {
|
|
38
|
+
return this.config.authWebUrl || this.constructor.DEFAULT_AUTH_URL;
|
|
39
|
+
}
|
|
36
40
|
/**
|
|
37
41
|
* Sign in using popup window
|
|
38
42
|
*
|
|
@@ -75,7 +79,7 @@ function OxyServicesPopupAuthMixin(Base) {
|
|
|
75
79
|
state,
|
|
76
80
|
nonce,
|
|
77
81
|
clientId: window.location.origin,
|
|
78
|
-
redirectUri: `${this.
|
|
82
|
+
redirectUri: `${this.authUrl}/auth/callback`,
|
|
79
83
|
});
|
|
80
84
|
const popup = this.openCenteredPopup(authUrl, 'Oxy Sign In', width, height);
|
|
81
85
|
if (!popup) {
|
|
@@ -163,7 +167,7 @@ function OxyServicesPopupAuthMixin(Base) {
|
|
|
163
167
|
iframe.style.width = '0';
|
|
164
168
|
iframe.style.height = '0';
|
|
165
169
|
iframe.style.border = 'none';
|
|
166
|
-
const silentUrl = `${this.
|
|
170
|
+
const silentUrl = `${this.authUrl}/auth/silent?` + `client_id=${encodeURIComponent(clientId)}&` + `nonce=${nonce}`;
|
|
167
171
|
iframe.src = silentUrl;
|
|
168
172
|
document.body.appendChild(iframe);
|
|
169
173
|
try {
|
|
@@ -214,7 +218,7 @@ function OxyServicesPopupAuthMixin(Base) {
|
|
|
214
218
|
reject(new OxyServices_errors_1.OxyAuthenticationError('Authentication timeout'));
|
|
215
219
|
}, timeout);
|
|
216
220
|
const messageHandler = (event) => {
|
|
217
|
-
const authUrl = this.
|
|
221
|
+
const authUrl = this.authUrl;
|
|
218
222
|
// Log all messages for debugging
|
|
219
223
|
if (event.data && typeof event.data === 'object' && event.data.type) {
|
|
220
224
|
debug.log('Message received:', {
|
|
@@ -286,7 +290,7 @@ function OxyServicesPopupAuthMixin(Base) {
|
|
|
286
290
|
}, timeout);
|
|
287
291
|
const messageHandler = (event) => {
|
|
288
292
|
// Verify origin
|
|
289
|
-
if (event.origin !== this.
|
|
293
|
+
if (event.origin !== this.authUrl) {
|
|
290
294
|
return;
|
|
291
295
|
}
|
|
292
296
|
const { type, session } = event.data;
|
|
@@ -309,7 +313,7 @@ function OxyServicesPopupAuthMixin(Base) {
|
|
|
309
313
|
* @private
|
|
310
314
|
*/
|
|
311
315
|
buildAuthUrl(params) {
|
|
312
|
-
const url = new URL(`${this.
|
|
316
|
+
const url = new URL(`${this.authUrl}/${params.mode}`);
|
|
313
317
|
url.searchParams.set('response_type', 'token');
|
|
314
318
|
url.searchParams.set('client_id', params.clientId);
|
|
315
319
|
url.searchParams.set('redirect_uri', params.redirectUri);
|
|
@@ -370,7 +374,7 @@ function OxyServicesPopupAuthMixin(Base) {
|
|
|
370
374
|
}
|
|
371
375
|
}
|
|
372
376
|
},
|
|
373
|
-
_a.
|
|
377
|
+
_a.DEFAULT_AUTH_URL = 'https://auth.oxy.so',
|
|
374
378
|
_a.POPUP_WIDTH = 500,
|
|
375
379
|
_a.POPUP_HEIGHT = 700,
|
|
376
380
|
_a.POPUP_TIMEOUT = 60000 // 1 minute
|
|
@@ -33,6 +33,10 @@ function OxyServicesRedirectAuthMixin(Base) {
|
|
|
33
33
|
constructor(...args) {
|
|
34
34
|
super(...args);
|
|
35
35
|
}
|
|
36
|
+
/** Resolved auth URL: config.authWebUrl takes precedence over the static default */
|
|
37
|
+
get authUrl() {
|
|
38
|
+
return this.config.authWebUrl || this.constructor.DEFAULT_AUTH_URL;
|
|
39
|
+
}
|
|
36
40
|
/**
|
|
37
41
|
* Sign in using full page redirect
|
|
38
42
|
*
|
|
@@ -228,7 +232,7 @@ function OxyServicesRedirectAuthMixin(Base) {
|
|
|
228
232
|
* @private
|
|
229
233
|
*/
|
|
230
234
|
buildAuthUrl(params) {
|
|
231
|
-
const url = new URL(`${this.
|
|
235
|
+
const url = new URL(`${this.authUrl}/${params.mode}`);
|
|
232
236
|
url.searchParams.set('redirect_uri', params.redirectUri);
|
|
233
237
|
url.searchParams.set('state', params.state);
|
|
234
238
|
url.searchParams.set('nonce', params.nonce);
|
|
@@ -345,7 +349,7 @@ function OxyServicesRedirectAuthMixin(Base) {
|
|
|
345
349
|
window.history.replaceState({}, '', url.toString());
|
|
346
350
|
}
|
|
347
351
|
},
|
|
348
|
-
_a.
|
|
352
|
+
_a.DEFAULT_AUTH_URL = 'https://auth.oxy.so',
|
|
349
353
|
_a.TOKEN_STORAGE_KEY = 'oxy_access_token',
|
|
350
354
|
_a.SESSION_STORAGE_KEY = 'oxy_session_id',
|
|
351
355
|
_a.STATE_STORAGE_KEY = 'oxy_auth_state',
|
|
@@ -107,6 +107,18 @@ function OxyServicesUserMixin(Base) {
|
|
|
107
107
|
return await this.makeRequest('GET', '/profiles/recommendations', params, { cache: true });
|
|
108
108
|
}, 'getProfileRecommendations');
|
|
109
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Get profiles similar to a given user, based on co-follower overlap.
|
|
112
|
+
*/
|
|
113
|
+
async getSimilarProfiles(userId, limit) {
|
|
114
|
+
const params = {};
|
|
115
|
+
if (limit)
|
|
116
|
+
params.limit = String(limit);
|
|
117
|
+
return await this.makeRequest('GET', `/profiles/${userId}/similar`, params, {
|
|
118
|
+
cache: true,
|
|
119
|
+
cacheTTL: 5 * 60 * 1000, // 5 min cache
|
|
120
|
+
});
|
|
121
|
+
}
|
|
110
122
|
/**
|
|
111
123
|
* Get user by ID
|
|
112
124
|
*/
|