@idp.global/sdk 19.5.0 → 19.6.0

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.
@@ -231,16 +231,20 @@ export class RelyingPartyProviderDouble implements IOidcProvider {
231
231
 
232
232
  public async completeAuthorization(optionsArg: IOidcCompletionOptions): Promise<IOidcCompletion> {
233
233
  if (!this.#discovered) {
234
- throw new OidcCompletionError('token_exchange', notDiscovered());
234
+ throw new OidcCompletionError('token_exchange', notDiscovered(), { code: 'provider_unreachable' });
235
235
  }
236
236
  const code = optionsArg.callbackUrl.searchParams.get('code') ?? '';
237
237
  const issued = this.#codes.get(code);
238
238
  this.#codes.delete(code);
239
239
  if (!issued || issued.state !== optionsArg.state) {
240
- throw new OidcCompletionError('token_exchange', new Error('unknown, used or foreign code'));
240
+ // what idp.global's token endpoint answers for such a code
241
+ throw new OidcCompletionError('token_exchange', new Error('unknown, used or foreign code'), {
242
+ code: 'token_exchange_refused',
243
+ oauthError: 'invalid_grant',
244
+ });
241
245
  }
242
246
  if (issued.nonce !== optionsArg.nonce) {
243
- throw new OidcCompletionError('token_validation', new Error('nonce mismatch'));
247
+ throw new OidcCompletionError('token_validation', new Error('nonce mismatch'), { code: 'login_mismatch' });
244
248
  }
245
249
  this.completions.push({ subject: issued.subject, state: issued.state });
246
250
  if (this.completionFailure) {