1- import { assert , assertGuardEquals , tags } from 'typia' ;
1+ import { assert , assertGuardEquals } from 'typia' ;
22import { AzureIdentityAuthenticationProvider } from "@microsoft/kiota-authentication-azure" ;
33import { FetchRequestAdapter } from "@microsoft/kiota-http-fetchlibrary" ;
44import type { TokenCredential } from "@azure/core-auth" ;
@@ -10,17 +10,18 @@ export type * from './sdk/models/index.js';
1010/**
1111 * Function that initializes the SHIELD SDK.
1212 * @param credential Configured authentication session from Entra ID.
13+ * @param baseUrl Root of the URL that should have endpoints appended to it by the query building system.
1314 * @returns Configured API client that is able to make requests against the specified SHIELD instance.
1415 */
15- export default function shieldClientFactory ( credential : TokenCredential , baseUrl : string & tags . Format < 'hostname' > ) {
16+ export default function shieldClientFactory ( credential : TokenCredential , baseUrl : URL ) {
1617 // #region Input Validation
1718 assert ( credential ) ;
1819
1920 assertGuardEquals ( baseUrl ) ;
2021 // #endregion Input Validation
2122
2223 /** List of hosts that are allowed when making API calls, this is used to prevent token leaks to threat actors. */
23- const allowedHostList = new Set ( [ baseUrl ] ) ;
24+ const allowedHostList = new Set ( [ baseUrl . host ] ) ;
2425
2526 /** Authentication system that will be used to configure the SDK client. */
2627 const authProvider = new AzureIdentityAuthenticationProvider ( credential , void 0 , void 0 , allowedHostList ) ;
@@ -29,7 +30,7 @@ export default function shieldClientFactory(credential: TokenCredential, baseUrl
2930 const shieldAdapter = new FetchRequestAdapter ( authProvider ) ;
3031
3132 // Set the base URL to be what is provided, since the host name is unique every deployment
32- shieldAdapter . baseUrl = baseUrl . startsWith ( 'localhost ') ? `http:// ${ baseUrl } ` : `https:// ${ baseUrl } ` ;
33+ shieldAdapter . baseUrl = baseUrl . href . endsWith ( '/ ') ? baseUrl . href . substring ( 0 , baseUrl . href . length - 1 ) : baseUrl . href ;
3334
3435 /** Instance of the API client that can be used for SHIELD access. */
3536 return createShieldClient ( shieldAdapter ) ;
0 commit comments