Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "error surfacing changes",
"packageName": "@azure/msal-common",
"email": "akaliugonna@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "enable passing of redirect uri",
"packageName": "@azure/msal-node",
"email": "akaliugonna@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "error surfacing changes",
"packageName": "@azure/msal-node-extensions",
"email": "akaliugonna@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Surface Errors from MsalRuntime with Interaction Required #7961",
"packageName": "@azure/msal-node-extensions",
"email": "akaliugonna@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Bump msal-node-runtime to v0.19.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file can be removed since there's another bumping to v0.20.0.

"packageName": "@azure/msal-node-extensions",
"email": "akaliugonna@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "enable passing of redirect uri",
"packageName": "@azure/msal-node-extensions",
"email": "akaliugonna@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Bump msal-node-runtime to v0.20.0",
"packageName": "@azure/msal-node-extensions",
"email": "akaliugonna@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "broker redirect uri changes",
"packageName": "@azure/msal-node",
"email": "akaliugonna@microsoft.com",
"dependentChangeType": "patch"
}
3 changes: 3 additions & 0 deletions docs/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ This error occurs when MSAL.js surpasses the allotted storage limit when attempt

- The nested app auth bridge is disabled.

### `platform_broker_error`
- An error occurred in the native broker. See the platformBrokerError property for details.

## Client configuration errors

### `redirect_uri_empty`
Expand Down
2 changes: 1 addition & 1 deletion extensions/msal-node-extensions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
},
"dependencies": {
"@azure/msal-common": "16.0.0-alpha.0",
"@azure/msal-node-runtime": "^0.18.1",
"@azure/msal-node-runtime": "^0.20.0",
"keytar": "^7.8.0"
},
"devDependencies": {
Expand Down
68 changes: 47 additions & 21 deletions extensions/msal-node-extensions/src/broker/NativeBrokerPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
InteractionRequiredAuthError,
Logger,
LoggerOptions,
PlatformBrokerError,
NativeRequest,
NativeSignOutRequest,
ServerError,
Expand All @@ -36,7 +37,6 @@ import {
LogLevel as MsalRuntimeLogLevel,
} from "@azure/msal-node-runtime";
import { ErrorCodes } from "../utils/Constants.js";
import { NativeAuthError } from "../error/NativeAuthError.js";
import { version, name } from "../packageMetadata.js";

export class NativeBrokerPlugin implements INativeBrokerPlugin {
Expand Down Expand Up @@ -192,10 +192,16 @@ export class NativeBrokerPlugin implements INativeBrokerPlugin {
request.correlationId
);
const platformRequest = request;
if (!platformRequest.redirectUri) {
platformRequest.redirectUri =
this.chooseRedirectUriByPlatform(platformRequest);
this.logger.info(
"NativeBrokerPlugin - No Redirect URI provided, using default",
platformRequest.correlationId
);
}
const authParams = this.generateRequestParameters(platformRequest);
const account = await this.getAccount(platformRequest);
platformRequest.redirectUri =
this.chooseRedirectUriByPlatform(platformRequest);

return new Promise(
(resolve: (value: AuthenticationResult) => void, reject) => {
Expand Down Expand Up @@ -250,9 +256,15 @@ export class NativeBrokerPlugin implements INativeBrokerPlugin {
request.correlationId
);
const platformRequest = request;
if (!platformRequest.redirectUri) {
platformRequest.redirectUri =
this.chooseRedirectUriByPlatform(platformRequest);
this.logger.info(
"NativeBrokerPlugin - No Redirect URI provided, using default",
platformRequest.correlationId
);
}
const authParams = this.generateRequestParameters(platformRequest);
platformRequest.redirectUri =
this.chooseRedirectUriByPlatform(platformRequest);
const account = await this.getAccount(platformRequest);
const windowHandle = providedWindowHandle || Buffer.from([0]);

Expand Down Expand Up @@ -462,9 +474,7 @@ export class NativeBrokerPlugin implements INativeBrokerPlugin {
request.authority
);

authParams.SetRedirectUri(
this.chooseRedirectUriByPlatform(request)
);
authParams.SetRedirectUri(request.redirectUri);
authParams.SetRequestedScopes(request.scopes.join(" "));

if (request.claims) {
Expand Down Expand Up @@ -639,54 +649,70 @@ export class NativeBrokerPlugin implements INativeBrokerPlugin {
);
}

private wrapError(error: unknown): NativeAuthError | Object | null {
private wrapError(error: unknown): PlatformBrokerError | Object | null {
if (
error &&
typeof error === "object" &&
this.isMsalRuntimeError(error)
) {
const { errorCode, errorStatus, errorContext, errorTag } =
error as MsalRuntimeError;

const msalNodeRuntimeError = new PlatformBrokerError(
ErrorStatus[errorStatus],
errorContext,
errorCode,
errorTag
);

let wrappedError;

switch (errorStatus) {
case ErrorStatus.InteractionRequired:
case ErrorStatus.AccountUnusable:
return new InteractionRequiredAuthError(
wrappedError = new InteractionRequiredAuthError(
ErrorCodes.INTERATION_REQUIRED_ERROR_CODE,
errorContext
msalNodeRuntimeError.message
);
break;
case ErrorStatus.NoNetwork:
case ErrorStatus.NetworkTemporarilyUnavailable:
return createClientAuthError(
wrappedError = createClientAuthError(
ClientAuthErrorCodes.noNetworkConnectivity
);
break;
case ErrorStatus.ServerTemporarilyUnavailable:
return new ServerError(
wrappedError = new ServerError(
ErrorCodes.SERVER_UNAVAILABLE,
errorContext
);
break;
case ErrorStatus.UserCanceled:
return createClientAuthError(
wrappedError = createClientAuthError(
ClientAuthErrorCodes.userCanceled
);
break;
case ErrorStatus.AuthorityUntrusted:
return createClientConfigurationError(
wrappedError = createClientConfigurationError(
ClientConfigurationErrorCodes.untrustedAuthority
);
break;
case ErrorStatus.UserSwitched:
// Not an error case, if there's customer demand we can surface this as a response property
return null;
case ErrorStatus.AccountNotFound:
return createClientAuthError(
wrappedError = createClientAuthError(
ClientAuthErrorCodes.noAccountFound
);
break;
default:
return new NativeAuthError(
ErrorStatus[errorStatus],
errorContext,
errorCode,
errorTag
wrappedError = createClientAuthError(
ClientAuthErrorCodes.platformBrokerError
);
}

wrappedError.platformBrokerError = msalNodeRuntimeError;
return wrappedError;
}
throw error;
}
Expand Down
24 changes: 0 additions & 24 deletions extensions/msal-node-extensions/src/error/NativeAuthError.ts

This file was deleted.

Loading
Loading