@@ -5,40 +5,23 @@ import { IRequestOptions } from "azure-devops-node-api/interfaces/common/VsoBase
55import * as tl from 'vsts-task-lib/task' ;
66import * as locationUtility from "packaging-common/locationUtilities" ;
77
8- // TODO Remove this once this bug is resolved: https://github.com/Microsoft/typed-rest-client/issues/126
9- export class BearerHandlerForPresignedUrls extends BearerCredentialHandler {
10- prepareRequest ( options ) {
11- // If we have a presigned blobstore url, don't add auth header
12- if ( this . isPreSignedUrl ( options ) ) {
13- delete options . headers [ "Authorization" ] ;
14- delete options . headers [ "X-TFS-FedAuthRedirect" ] ;
15- } else {
16- options . headers [ "Authorization" ] = "Bearer " + this . token ;
17- options . headers [ "X-TFS-FedAuthRedirect" ] = "Suppress" ;
18- }
19- }
20-
21- isPreSignedUrl ( options : any ) : boolean {
22- return (
23- options . host &&
24- options . host . endsWith ( "blob.core.windows.net" ) &&
25- options . path &&
26- options . path . includes ( "&sig=" )
27- ) ;
28- }
29- }
30-
318export function getConnection ( areaId : string , collectionUrl : string ) : Promise < WebApi > {
329 var accessToken = locationUtility . getSystemAccessToken ( ) ;
10+ var presignedUrlPatterns : RegExp [ ] = [
11+ new RegExp ( '.*blob\.core\.windows\.net.*' ) , // blobstore redirect
12+ new RegExp ( '.*vsblob\.vsassets\.io.*' ) // edge caching enabled blob
13+ ] ;
14+
3315 return locationUtility
3416 . getServiceUriFromAreaId ( collectionUrl , accessToken , areaId )
3517 . then ( url => {
3618 const options : IRequestOptions = {
3719 proxy : tl . getHttpProxyConfiguration ( url ) ,
3820 maxRetries : 5 ,
39- allowRetries : true
21+ allowRetries : true ,
22+ presignedUrlPatterns : presignedUrlPatterns
4023 } ;
41- return new WebApi ( url , new BearerHandlerForPresignedUrls ( accessToken ) , options ) ;
24+ return new WebApi ( url , new BearerCredentialHandler ( accessToken ) , options ) ;
4225 } )
4326 . catch ( error => {
4427 throw error ;
0 commit comments