Skip to content

Commit e9126bc

Browse files
committed
1 parent 8e6fa7a commit e9126bc

File tree

14 files changed

+266
-147
lines changed

14 files changed

+266
-147
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "error surfacing changes",
4+
"packageName": "@azure/msal-common",
5+
"email": "akaliugonna@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "error surfacing changes",
4+
"packageName": "@azure/msal-node-extensions",
5+
"email": "akaliugonna@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}

docs/errors.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ This error occurs when MSAL.js surpasses the allotted storage limit when attempt
172172

173173
- The nested app auth bridge is disabled.
174174

175+
### `platform_broker_error`
176+
- An error occurred in the native broker. See the platformBrokerError property for details.
177+
175178
## Client configuration errors
176179

177180
### `redirect_uri_empty`

extensions/msal-node-extensions/src/broker/NativeBrokerPlugin.ts

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
InteractionRequiredAuthError,
1818
Logger,
1919
LoggerOptions,
20+
PlatformBrokerError,
2021
NativeRequest,
2122
NativeSignOutRequest,
2223
ServerError,
@@ -36,8 +37,6 @@ import {
3637
LogLevel as MsalRuntimeLogLevel,
3738
} from "@azure/msal-node-runtime";
3839
import { ErrorCodes } from "../utils/Constants.js";
39-
import { StringUtils } from "../utils/StringUtils.js";
40-
import { NativeAuthError } from "../error/NativeAuthError.js";
4140
import { version, name } from "../packageMetadata.js";
4241

4342
export class NativeBrokerPlugin implements INativeBrokerPlugin {
@@ -650,58 +649,70 @@ export class NativeBrokerPlugin implements INativeBrokerPlugin {
650649
);
651650
}
652651

653-
private wrapError(error: unknown): NativeAuthError | Object | null {
652+
private wrapError(error: unknown): PlatformBrokerError | Object | null {
654653
if (
655654
error &&
656655
typeof error === "object" &&
657656
this.isMsalRuntimeError(error)
658657
) {
659658
const { errorCode, errorStatus, errorContext, errorTag } =
660659
error as MsalRuntimeError;
661-
const tagString = StringUtils.tagToString(errorTag);
662-
const enhancedErrorContext = errorContext
663-
? `${errorContext} (Error Code: ${errorCode}, Tag: ${tagString})`
664-
: `(Error Code: ${errorCode}, Tag: ${tagString})`;
660+
661+
const msalNodeRuntimeError = new PlatformBrokerError(
662+
ErrorStatus[errorStatus],
663+
errorContext,
664+
errorCode,
665+
errorTag
666+
);
667+
668+
let wrappedError;
669+
665670
switch (errorStatus) {
666671
case ErrorStatus.InteractionRequired:
667672
case ErrorStatus.AccountUnusable:
668-
return new InteractionRequiredAuthError(
673+
wrappedError = new InteractionRequiredAuthError(
669674
ErrorCodes.INTERATION_REQUIRED_ERROR_CODE,
670-
enhancedErrorContext
675+
msalNodeRuntimeError.message
671676
);
677+
break;
672678
case ErrorStatus.NoNetwork:
673679
case ErrorStatus.NetworkTemporarilyUnavailable:
674-
return createClientAuthError(
680+
wrappedError = createClientAuthError(
675681
ClientAuthErrorCodes.noNetworkConnectivity
676682
);
683+
break;
677684
case ErrorStatus.ServerTemporarilyUnavailable:
678-
return new ServerError(
685+
wrappedError = new ServerError(
679686
ErrorCodes.SERVER_UNAVAILABLE,
680687
errorContext
681688
);
689+
break;
682690
case ErrorStatus.UserCanceled:
683-
return createClientAuthError(
691+
wrappedError = createClientAuthError(
684692
ClientAuthErrorCodes.userCanceled
685693
);
694+
break;
686695
case ErrorStatus.AuthorityUntrusted:
687-
return createClientConfigurationError(
696+
wrappedError = createClientConfigurationError(
688697
ClientConfigurationErrorCodes.untrustedAuthority
689698
);
699+
break;
690700
case ErrorStatus.UserSwitched:
691701
// Not an error case, if there's customer demand we can surface this as a response property
692702
return null;
693703
case ErrorStatus.AccountNotFound:
694-
return createClientAuthError(
704+
wrappedError = createClientAuthError(
695705
ClientAuthErrorCodes.noAccountFound
696706
);
707+
break;
697708
default:
698-
return new NativeAuthError(
699-
ErrorStatus[errorStatus],
700-
enhancedErrorContext,
701-
errorCode,
702-
errorTag
709+
wrappedError = createClientAuthError(
710+
ClientAuthErrorCodes.platformBrokerError
703711
);
704712
}
713+
714+
wrappedError.platformBrokerError = msalNodeRuntimeError;
715+
return wrappedError;
705716
}
706717
throw error;
707718
}

extensions/msal-node-extensions/src/error/NativeAuthError.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

extensions/msal-node-extensions/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@ export { CrossPlatformLockOptions } from "./lock/CrossPlatformLockOptions.js";
1414
export { PersistenceCreator } from "./persistence/PersistenceCreator.js";
1515
export { IPersistenceConfiguration } from "./persistence/IPersistenceConfiguration.js";
1616
export { Environment } from "./utils/Environment.js";
17-
export { StringUtils } from "./utils/StringUtils.js";
1817
export { NativeBrokerPlugin } from "./broker/NativeBrokerPlugin.js";

extensions/msal-node-extensions/src/utils/StringUtils.ts

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)