Description
m365 login --authType deviceCode crashes with TypeError: Expected a 'target' when autoOpenLinksInBrowser is true, because MSAL's DeviceCodeResponse.verificationUri can be undefined at runtime. Similarly crashes with copyDeviceCodeToClipboard enabled when response.userCode is undefined.
Steps to reproduce
m365 cli config set --key autoOpenLinksInBrowser --value true
m365 login --authType deviceCode
Expected results
Device code login proceeds, optionally opening browser if URI is available.
Actual results
TypeError: Expected a `target`
at open (node_modules/open/index.js:315:9)
at Auth.processDeviceCodeCallback
Proposed solution
Guard browserUtil.open() and clipboardy.writeSync() calls with null checks on response.verificationUri and response.userCode.