@oxyhq/core 1.2.4 → 1.2.5

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.
@@ -105,12 +105,20 @@ function OxyServicesFedCMMixin(Base) {
105
105
  }
106
106
  catch (error) {
107
107
  debug.log('Interactive sign-in failed:', error);
108
+ const errorMessage = error instanceof Error ? error.message : String(error);
108
109
  if (error.name === 'AbortError') {
109
110
  throw new OxyServices_errors_1.OxyAuthenticationError('Sign-in was cancelled by user');
110
111
  }
111
112
  if (error.name === 'NetworkError') {
112
113
  throw new OxyServices_errors_1.OxyAuthenticationError('Network error during sign-in. Please check your connection.');
113
114
  }
115
+ if (errorMessage.includes('multiple accounts')) {
116
+ throw new OxyServices_errors_1.OxyAuthenticationError('Please sign out and sign in again to use FedCM with a single account');
117
+ }
118
+ if (errorMessage.includes('retrieving a token') || errorMessage.includes('Error retrieving')) {
119
+ debug.error('FedCM token retrieval error - this may be a browser or IdP configuration issue');
120
+ throw new OxyServices_errors_1.OxyAuthenticationError('Authentication failed. Please try again or use an alternative sign-in method.');
121
+ }
114
122
  throw error;
115
123
  }
116
124
  }
@@ -170,7 +178,17 @@ function OxyServicesFedCMMixin(Base) {
170
178
  catch (silentError) {
171
179
  const errorName = silentError instanceof Error ? silentError.name : 'Unknown';
172
180
  const errorMessage = silentError instanceof Error ? silentError.message : String(silentError);
173
- debug.log('Silent SSO: Silent mediation failed:', { name: errorName, message: errorMessage });
181
+ // Handle specific FedCM errors with better logging
182
+ if (errorMessage.includes('multiple accounts')) {
183
+ debug.log('Silent SSO: User has used multiple accounts - silent mediation not available');
184
+ debug.log('Silent SSO: User needs to explicitly sign in to choose account');
185
+ }
186
+ else if (errorMessage.includes('conditions')) {
187
+ debug.log('Silent SSO: Conditions not met (user may not be logged in at IdP or not in approved_clients)');
188
+ }
189
+ else {
190
+ debug.log('Silent SSO: Silent mediation failed:', { name: errorName, message: errorMessage });
191
+ }
174
192
  return null;
175
193
  }
176
194
  if (!credential || !credential.token) {
@@ -101,12 +101,20 @@ export function OxyServicesFedCMMixin(Base) {
101
101
  }
102
102
  catch (error) {
103
103
  debug.log('Interactive sign-in failed:', error);
104
+ const errorMessage = error instanceof Error ? error.message : String(error);
104
105
  if (error.name === 'AbortError') {
105
106
  throw new OxyAuthenticationError('Sign-in was cancelled by user');
106
107
  }
107
108
  if (error.name === 'NetworkError') {
108
109
  throw new OxyAuthenticationError('Network error during sign-in. Please check your connection.');
109
110
  }
111
+ if (errorMessage.includes('multiple accounts')) {
112
+ throw new OxyAuthenticationError('Please sign out and sign in again to use FedCM with a single account');
113
+ }
114
+ if (errorMessage.includes('retrieving a token') || errorMessage.includes('Error retrieving')) {
115
+ debug.error('FedCM token retrieval error - this may be a browser or IdP configuration issue');
116
+ throw new OxyAuthenticationError('Authentication failed. Please try again or use an alternative sign-in method.');
117
+ }
110
118
  throw error;
111
119
  }
112
120
  }
@@ -166,7 +174,17 @@ export function OxyServicesFedCMMixin(Base) {
166
174
  catch (silentError) {
167
175
  const errorName = silentError instanceof Error ? silentError.name : 'Unknown';
168
176
  const errorMessage = silentError instanceof Error ? silentError.message : String(silentError);
169
- debug.log('Silent SSO: Silent mediation failed:', { name: errorName, message: errorMessage });
177
+ // Handle specific FedCM errors with better logging
178
+ if (errorMessage.includes('multiple accounts')) {
179
+ debug.log('Silent SSO: User has used multiple accounts - silent mediation not available');
180
+ debug.log('Silent SSO: User needs to explicitly sign in to choose account');
181
+ }
182
+ else if (errorMessage.includes('conditions')) {
183
+ debug.log('Silent SSO: Conditions not met (user may not be logged in at IdP or not in approved_clients)');
184
+ }
185
+ else {
186
+ debug.log('Silent SSO: Silent mediation failed:', { name: errorName, message: errorMessage });
187
+ }
170
188
  return null;
171
189
  }
172
190
  if (!credential || !credential.token) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxyhq/core",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "description": "OxyHQ SDK Foundation — API client, authentication, cryptographic identity, and shared utilities",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -131,12 +131,21 @@ export function OxyServicesFedCMMixin<T extends typeof OxyServicesBase>(Base: T)
131
131
  return session;
132
132
  } catch (error) {
133
133
  debug.log('Interactive sign-in failed:', error);
134
+ const errorMessage = error instanceof Error ? error.message : String(error);
135
+
134
136
  if ((error as any).name === 'AbortError') {
135
137
  throw new OxyAuthenticationError('Sign-in was cancelled by user');
136
138
  }
137
139
  if ((error as any).name === 'NetworkError') {
138
140
  throw new OxyAuthenticationError('Network error during sign-in. Please check your connection.');
139
141
  }
142
+ if (errorMessage.includes('multiple accounts')) {
143
+ throw new OxyAuthenticationError('Please sign out and sign in again to use FedCM with a single account');
144
+ }
145
+ if (errorMessage.includes('retrieving a token') || errorMessage.includes('Error retrieving')) {
146
+ debug.error('FedCM token retrieval error - this may be a browser or IdP configuration issue');
147
+ throw new OxyAuthenticationError('Authentication failed. Please try again or use an alternative sign-in method.');
148
+ }
140
149
  throw error;
141
150
  }
142
151
  }
@@ -201,7 +210,17 @@ export function OxyServicesFedCMMixin<T extends typeof OxyServicesBase>(Base: T)
201
210
  } catch (silentError) {
202
211
  const errorName = silentError instanceof Error ? silentError.name : 'Unknown';
203
212
  const errorMessage = silentError instanceof Error ? silentError.message : String(silentError);
204
- debug.log('Silent SSO: Silent mediation failed:', { name: errorName, message: errorMessage });
213
+
214
+ // Handle specific FedCM errors with better logging
215
+ if (errorMessage.includes('multiple accounts')) {
216
+ debug.log('Silent SSO: User has used multiple accounts - silent mediation not available');
217
+ debug.log('Silent SSO: User needs to explicitly sign in to choose account');
218
+ } else if (errorMessage.includes('conditions')) {
219
+ debug.log('Silent SSO: Conditions not met (user may not be logged in at IdP or not in approved_clients)');
220
+ } else {
221
+ debug.log('Silent SSO: Silent mediation failed:', { name: errorName, message: errorMessage });
222
+ }
223
+
205
224
  return null;
206
225
  }
207
226