-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new isPlatformBrokerAvailable() API #7632
base: dev
Are you sure you want to change the base?
Conversation
logLevel: LogLevel.Trace, | ||
}; | ||
|
||
const temporaryLogger = new Logger( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: you can just call this logger
clientId: "test-clientid", | ||
}, | ||
}; | ||
const temporaryTelemetryClient: IPerformanceClient = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: just call this performanceClient
// Check if DOM platform API is supported | ||
|
||
// @ts-ignore | ||
if (window.navigator?.platformAuthentication) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also check that window is defined and return false if not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, may be also a trace statement. Do we identify non-DOM environments today in logs?
/** | ||
* Public method to indicate whether platform broker is available to make native token request. | ||
*/ | ||
export async function isPlatformBrokerAvailable( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we put this in a new file under the broker
folder instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay sure, I can just add it to the new Handler file that goes under broker that will handle DOM requests.
// @ts-ignore | ||
if (window.navigator?.platformAuthentication) { | ||
const supportedContracts = | ||
// @ts-ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why ts-ignore?
const supportedContracts = | ||
// @ts-ignore | ||
await window.navigator.platformAuthentication.getSupportedContracts( | ||
"MicrosoftEntra" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is our latest on constants for min file optimizations? Do we directly use strings? If these are standardized, I would like a constant defined elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I will add it as a constant
@@ -348,7 +430,8 @@ export class StandardController implements IController { | |||
|
|||
if (allowPlatformBroker) { | |||
try { | |||
this.nativeExtensionProvider = | |||
// check if platform authentication is available via DOM or browser extension and create relevant handlers | |||
this.platformAuthProvider = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So is the plan to expand createProvider
to include DOM API calls?
@@ -156,7 +238,7 @@ export class StandardController implements IController { | |||
>; | |||
|
|||
// Native Extension Provider | |||
protected nativeExtensionProvider: NativeMessageHandler | undefined; | |||
protected platformAuthProvider: NativeMessageHandler | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably should be either NativeMessageHandler
or DOMHandler
correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't changed the type yet because I just wanted to test isPlatformAvailable() API e2e first. I was thinking of changing the implementation to Map<String, NativeMessageHandler | DOMHandler>
like we discussed before but tied to Standard controller instead of being a global variable.
This PR adds a new public facing API isPlatformBrokerAvailable() that lets the client app check if platform broker is available for to acquire tokens natively. The method checks if brokering is available via DOM APIs or the browser extension.