@oxyhq/core 1.11.19 → 1.11.20
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 +17 -2
- package/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/mixins/OxyServices.fedcm.js +22 -9
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/mixins/OxyServices.fedcm.js +22 -9
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/mixins/OxyServices.fedcm.d.ts +9 -4
- package/package.json +1 -1
- package/src/mixins/OxyServices.fedcm.ts +52 -14
|
@@ -140,9 +140,11 @@ export function OxyServicesFedCMMixin(Base) {
|
|
|
140
140
|
debug.log('Interactive sign-in: Got credential, exchanging for session');
|
|
141
141
|
// Exchange FedCM ID token for Oxy session
|
|
142
142
|
const session = await this.exchangeIdTokenForSession(credential.token);
|
|
143
|
-
// Store access token in HttpService
|
|
144
|
-
|
|
145
|
-
|
|
143
|
+
// Store access token in HttpService. `accessToken`/`refreshToken` are
|
|
144
|
+
// declared optional on SessionLoginResponse; default the refresh token to
|
|
145
|
+
// an empty string when the exchange did not return one.
|
|
146
|
+
if (session?.accessToken) {
|
|
147
|
+
this.httpService.setTokens(session.accessToken, session.refreshToken ?? '');
|
|
146
148
|
}
|
|
147
149
|
// Store the user ID as loginHint for future FedCM requests
|
|
148
150
|
if (session?.user?.id) {
|
|
@@ -154,10 +156,13 @@ export function OxyServicesFedCMMixin(Base) {
|
|
|
154
156
|
catch (error) {
|
|
155
157
|
debug.log('Interactive sign-in failed:', error);
|
|
156
158
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
157
|
-
|
|
159
|
+
// FedCM aborts/network failures surface as DOMException/Error instances,
|
|
160
|
+
// both of which carry a `name`. Anything else has no meaningful name.
|
|
161
|
+
const errorName = error instanceof Error ? error.name : '';
|
|
162
|
+
if (errorName === 'AbortError') {
|
|
158
163
|
throw new OxyAuthenticationError('Sign-in was cancelled by user');
|
|
159
164
|
}
|
|
160
|
-
if (
|
|
165
|
+
if (errorName === 'NetworkError') {
|
|
161
166
|
throw new OxyAuthenticationError('Network error during sign-in. Please check your connection.');
|
|
162
167
|
}
|
|
163
168
|
if (errorMessage.includes('multiple accounts')) {
|
|
@@ -269,9 +274,11 @@ export function OxyServicesFedCMMixin(Base) {
|
|
|
269
274
|
debug.error('Silent SSO: Exchange returned session without user:', session);
|
|
270
275
|
return null;
|
|
271
276
|
}
|
|
272
|
-
// Set the access token
|
|
277
|
+
// Set the access token. `accessToken`/`refreshToken` are declared optional
|
|
278
|
+
// on SessionLoginResponse; default the refresh token to an empty string when
|
|
279
|
+
// the exchange did not return one.
|
|
273
280
|
if (session.accessToken) {
|
|
274
|
-
this.httpService.setTokens(session.accessToken);
|
|
281
|
+
this.httpService.setTokens(session.accessToken, session.refreshToken ?? '');
|
|
275
282
|
debug.log('Silent SSO: Access token set');
|
|
276
283
|
}
|
|
277
284
|
else {
|
|
@@ -457,9 +464,15 @@ export function OxyServicesFedCMMixin(Base) {
|
|
|
457
464
|
return;
|
|
458
465
|
}
|
|
459
466
|
try {
|
|
460
|
-
|
|
467
|
+
// The DOM lib does not declare the global `IdentityCredential` interface
|
|
468
|
+
// object (with its static `disconnect`) in every TypeScript version we
|
|
469
|
+
// build against. Read it off `window` through the minimal structural type
|
|
470
|
+
// (not `any`), guarding that `disconnect` is actually present at runtime.
|
|
471
|
+
const fedCMWindow = window;
|
|
472
|
+
const identityCredential = fedCMWindow.IdentityCredential;
|
|
473
|
+
if (identityCredential && typeof identityCredential.disconnect === 'function') {
|
|
461
474
|
const clientId = this.getClientId();
|
|
462
|
-
await
|
|
475
|
+
await identityCredential.disconnect({
|
|
463
476
|
configURL: this.resolveFedcmConfigUrl(),
|
|
464
477
|
clientId,
|
|
465
478
|
accountHint: accountHint || '*',
|