@microsoft/vscode-azext-azureauth 6.0.0-alpha.4 → 6.0.0-alpha.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.
@@ -115,12 +115,18 @@ class AzureSubscriptionProviderBase {
115
115
  // If silent, suppress with normal timeout
116
116
  this.silenceRefreshEvents();
117
117
  }
118
- const session = await (0, getSessionFromVSCode_1.getSessionFromVSCode)(undefined, tenant?.tenantId, {
119
- account: tenant?.account,
120
- clearSessionPreference: options.clearSessionPreference ?? AzureSubscriptionProviderRequestOptions_1.DefaultSignInOptions.clearSessionPreference,
121
- createIfNone: prompt,
122
- silent: !prompt,
123
- });
118
+ let session;
119
+ try {
120
+ session = await (0, getSessionFromVSCode_1.getSessionFromVSCode)(undefined, tenant?.tenantId, {
121
+ account: tenant?.account,
122
+ clearSessionPreference: options.clearSessionPreference ?? AzureSubscriptionProviderRequestOptions_1.DefaultSignInOptions.clearSessionPreference,
123
+ createIfNone: prompt,
124
+ silent: !prompt,
125
+ });
126
+ }
127
+ catch (err) {
128
+ throw maybeImproveSignInError(err, tenant?.tenantId);
129
+ }
124
130
  if (prompt) {
125
131
  // Interactive sign in can take a while, so silence events for a bit longer
126
132
  this.silenceRefreshEvents();
@@ -368,13 +374,13 @@ class AzureSubscriptionProviderBase {
368
374
  };
369
375
  }
370
376
  log(message) {
371
- this.logger?.debug(`[auth] ${message}`);
377
+ this.logger?.info(`[auth] ${message}`);
372
378
  }
373
379
  logForAccount(account, message) {
374
- this.logger?.debug(`[auth] [account: ${(0, screen_1.screen)(account)}] ${message}`);
380
+ this.logger?.info(`[auth] [account: ${(0, screen_1.screen)(account)}] ${message}`);
375
381
  }
376
382
  logForTenant(tenant, message) {
377
- this.logger?.debug(`[auth] [account: ${(0, screen_1.screen)(tenant.account)}] [tenant: ${(0, screen_1.screen)(tenant)}] ${message}`);
383
+ this.logger?.info(`[auth] [account: ${(0, screen_1.screen)(tenant.account)}] [tenant: ${(0, screen_1.screen)(tenant)}] ${message}`);
378
384
  }
379
385
  warnForAccount(account, message) {
380
386
  this.logger?.warn(`[auth] [account: ${(0, screen_1.screen)(account)}] ${message}`);
@@ -426,4 +432,28 @@ class AzureSubscriptionProviderBase {
426
432
  }
427
433
  }
428
434
  exports.AzureSubscriptionProviderBase = AzureSubscriptionProviderBase;
435
+ /**
436
+ * Inspects an error thrown during sign-in and returns a more user-friendly
437
+ * error when possible (e.g. native broker errors), otherwise returns the
438
+ * original error unchanged.
439
+ */
440
+ function maybeImproveSignInError(err, tenantId) {
441
+ if (!(err instanceof Error)) {
442
+ return err;
443
+ }
444
+ const message = err.message;
445
+ // The native MSAL broker surfaces opaque "platform_broker_error" messages
446
+ // that don't tell the user what went wrong. Re-wrap with actionable text.
447
+ if (message.includes('platform_broker_error')) {
448
+ const tenantHint = tenantId
449
+ ? vscode.l10n.t(' for tenant "{0}"', tenantId)
450
+ : '';
451
+ const improved = new Error(vscode.l10n.t('Sign-in failed{0}. The tenant may have expired or is no longer valid. Please verify the tenant is still active and try again.', tenantHint), { cause: err });
452
+ if (err.stack && improved.stack) {
453
+ improved.stack += `\nCaused by: ${err.stack}`;
454
+ }
455
+ return improved;
456
+ }
457
+ return err;
458
+ }
429
459
  //# sourceMappingURL=AzureSubscriptionProviderBase.js.map
@@ -79,12 +79,18 @@ export class AzureSubscriptionProviderBase {
79
79
  // If silent, suppress with normal timeout
80
80
  this.silenceRefreshEvents();
81
81
  }
82
- const session = await getSessionFromVSCode(undefined, tenant?.tenantId, {
83
- account: tenant?.account,
84
- clearSessionPreference: options.clearSessionPreference ?? DefaultSignInOptions.clearSessionPreference,
85
- createIfNone: prompt,
86
- silent: !prompt,
87
- });
82
+ let session;
83
+ try {
84
+ session = await getSessionFromVSCode(undefined, tenant?.tenantId, {
85
+ account: tenant?.account,
86
+ clearSessionPreference: options.clearSessionPreference ?? DefaultSignInOptions.clearSessionPreference,
87
+ createIfNone: prompt,
88
+ silent: !prompt,
89
+ });
90
+ }
91
+ catch (err) {
92
+ throw maybeImproveSignInError(err, tenant?.tenantId);
93
+ }
88
94
  if (prompt) {
89
95
  // Interactive sign in can take a while, so silence events for a bit longer
90
96
  this.silenceRefreshEvents();
@@ -332,13 +338,13 @@ export class AzureSubscriptionProviderBase {
332
338
  };
333
339
  }
334
340
  log(message) {
335
- this.logger?.debug(`[auth] ${message}`);
341
+ this.logger?.info(`[auth] ${message}`);
336
342
  }
337
343
  logForAccount(account, message) {
338
- this.logger?.debug(`[auth] [account: ${screen(account)}] ${message}`);
344
+ this.logger?.info(`[auth] [account: ${screen(account)}] ${message}`);
339
345
  }
340
346
  logForTenant(tenant, message) {
341
- this.logger?.debug(`[auth] [account: ${screen(tenant.account)}] [tenant: ${screen(tenant)}] ${message}`);
347
+ this.logger?.info(`[auth] [account: ${screen(tenant.account)}] [tenant: ${screen(tenant)}] ${message}`);
342
348
  }
343
349
  warnForAccount(account, message) {
344
350
  this.logger?.warn(`[auth] [account: ${screen(account)}] ${message}`);
@@ -389,4 +395,28 @@ export class AzureSubscriptionProviderBase {
389
395
  throw err;
390
396
  }
391
397
  }
398
+ /**
399
+ * Inspects an error thrown during sign-in and returns a more user-friendly
400
+ * error when possible (e.g. native broker errors), otherwise returns the
401
+ * original error unchanged.
402
+ */
403
+ function maybeImproveSignInError(err, tenantId) {
404
+ if (!(err instanceof Error)) {
405
+ return err;
406
+ }
407
+ const message = err.message;
408
+ // The native MSAL broker surfaces opaque "platform_broker_error" messages
409
+ // that don't tell the user what went wrong. Re-wrap with actionable text.
410
+ if (message.includes('platform_broker_error')) {
411
+ const tenantHint = tenantId
412
+ ? vscode.l10n.t(' for tenant "{0}"', tenantId)
413
+ : '';
414
+ const improved = new Error(vscode.l10n.t('Sign-in failed{0}. The tenant may have expired or is no longer valid. Please verify the tenant is still active and try again.', tenantHint), { cause: err });
415
+ if (err.stack && improved.stack) {
416
+ improved.stack += `\nCaused by: ${err.stack}`;
417
+ }
418
+ return improved;
419
+ }
420
+ return err;
421
+ }
392
422
  //# sourceMappingURL=AzureSubscriptionProviderBase.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@microsoft/vscode-azext-azureauth",
3
3
  "author": "Microsoft Corporation",
4
- "version": "6.0.0-alpha.4",
4
+ "version": "6.0.0-alpha.5",
5
5
  "description": "Azure authentication helpers for Visual Studio Code",
6
6
  "tags": [
7
7
  "azure",