@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.
@@ -144,9 +144,11 @@ function OxyServicesFedCMMixin(Base) {
144
144
  debug.log('Interactive sign-in: Got credential, exchanging for session');
145
145
  // Exchange FedCM ID token for Oxy session
146
146
  const session = await this.exchangeIdTokenForSession(credential.token);
147
- // Store access token in HttpService (extract from response or get from session)
148
- if (session && session.accessToken) {
149
- this.httpService.setTokens(session.accessToken);
147
+ // Store access token in HttpService. `accessToken`/`refreshToken` are
148
+ // declared optional on SessionLoginResponse; default the refresh token to
149
+ // an empty string when the exchange did not return one.
150
+ if (session?.accessToken) {
151
+ this.httpService.setTokens(session.accessToken, session.refreshToken ?? '');
150
152
  }
151
153
  // Store the user ID as loginHint for future FedCM requests
152
154
  if (session?.user?.id) {
@@ -158,10 +160,13 @@ function OxyServicesFedCMMixin(Base) {
158
160
  catch (error) {
159
161
  debug.log('Interactive sign-in failed:', error);
160
162
  const errorMessage = error instanceof Error ? error.message : String(error);
161
- if (error.name === 'AbortError') {
163
+ // FedCM aborts/network failures surface as DOMException/Error instances,
164
+ // both of which carry a `name`. Anything else has no meaningful name.
165
+ const errorName = error instanceof Error ? error.name : '';
166
+ if (errorName === 'AbortError') {
162
167
  throw new OxyServices_errors_1.OxyAuthenticationError('Sign-in was cancelled by user');
163
168
  }
164
- if (error.name === 'NetworkError') {
169
+ if (errorName === 'NetworkError') {
165
170
  throw new OxyServices_errors_1.OxyAuthenticationError('Network error during sign-in. Please check your connection.');
166
171
  }
167
172
  if (errorMessage.includes('multiple accounts')) {
@@ -273,9 +278,11 @@ function OxyServicesFedCMMixin(Base) {
273
278
  debug.error('Silent SSO: Exchange returned session without user:', session);
274
279
  return null;
275
280
  }
276
- // Set the access token
281
+ // Set the access token. `accessToken`/`refreshToken` are declared optional
282
+ // on SessionLoginResponse; default the refresh token to an empty string when
283
+ // the exchange did not return one.
277
284
  if (session.accessToken) {
278
- this.httpService.setTokens(session.accessToken);
285
+ this.httpService.setTokens(session.accessToken, session.refreshToken ?? '');
279
286
  debug.log('Silent SSO: Access token set');
280
287
  }
281
288
  else {
@@ -461,9 +468,15 @@ function OxyServicesFedCMMixin(Base) {
461
468
  return;
462
469
  }
463
470
  try {
464
- if ('IdentityCredential' in window && 'disconnect' in window.IdentityCredential) {
471
+ // The DOM lib does not declare the global `IdentityCredential` interface
472
+ // object (with its static `disconnect`) in every TypeScript version we
473
+ // build against. Read it off `window` through the minimal structural type
474
+ // (not `any`), guarding that `disconnect` is actually present at runtime.
475
+ const fedCMWindow = window;
476
+ const identityCredential = fedCMWindow.IdentityCredential;
477
+ if (identityCredential && typeof identityCredential.disconnect === 'function') {
465
478
  const clientId = this.getClientId();
466
- await window.IdentityCredential.disconnect({
479
+ await identityCredential.disconnect({
467
480
  configURL: this.resolveFedcmConfigUrl(),
468
481
  clientId,
469
482
  accountHint: accountHint || '*',