1
1
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
2
// See LICENSE in the project root for license information.
3
3
4
- import { ColorValue , IColorableSequence , ITerminal , TextAttribute } from '@rushstack/node-core-library' ;
4
+ import { Colors , IColorableSequence , ITerminal } from '@rushstack/node-core-library' ;
5
5
import * as crypto from 'crypto' ;
6
6
import * as fetch from 'node-fetch' ;
7
7
@@ -14,7 +14,7 @@ const HOST_HEADER_NAME: 'host' = 'host';
14
14
const SECURITY_TOKEN_HEADER_NAME : 'x-amz-security-token' = 'x-amz-security-token' ;
15
15
16
16
/**
17
- * Credentials for authorizaing and signing requests to an Amazon S3 endpoint.
17
+ * Credentials for authorizing and signing requests to an Amazon S3 endpoint.
18
18
*
19
19
* @public
20
20
*/
@@ -65,7 +65,7 @@ export class AmazonS3Client {
65
65
66
66
// https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html#create-signature-presign-entire-payload
67
67
// We want to keep all slashes non encoded
68
- public static URIEncode ( input : string ) : string {
68
+ public static UriEncode ( input : string ) : string {
69
69
let output : string = '' ;
70
70
for ( let i : number = 0 ; i < input . length ; i += 1 ) {
71
71
const ch : string = input [ i ] ;
@@ -148,8 +148,8 @@ export class AmazonS3Client {
148
148
149
149
// the host can be e.g. https://s3.aws.com or http://localhost:9000
150
150
const host : string = this . _s3Endpoint . replace ( protocolRegex , '' ) ;
151
- const canonicalUri : string = AmazonS3Client . URIEncode ( `/${ objectName } ` ) ;
152
- this . _writeDebugLine ( { text : 'Canonical URI: ' , textAttributes : [ TextAttribute . Bold ] } , canonicalUri ) ;
151
+ const canonicalUri : string = AmazonS3Client . UriEncode ( `/${ objectName } ` ) ;
152
+ this . _writeDebugLine ( Colors . bold ( 'Canonical URI: ' ) , canonicalUri ) ;
153
153
154
154
if ( this . _credentials ) {
155
155
// Compute the authorization header. See https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html
@@ -248,14 +248,11 @@ export class AmazonS3Client {
248
248
249
249
const url : string = `${ this . _s3Endpoint } ${ canonicalUri } ` ;
250
250
251
- this . _writeDebugLine ( {
252
- text : 'Sending request to S3' ,
253
- textAttributes : [ TextAttribute . Bold , TextAttribute . Underline ]
254
- } ) ;
255
- this . _writeDebugLine ( { text : 'HOST: ' , textAttributes : [ TextAttribute . Bold ] } , url ) ;
256
- this . _writeDebugLine ( { text : 'Headers: ' , textAttributes : [ TextAttribute . Bold ] } ) ;
251
+ this . _writeDebugLine ( Colors . bold ( Colors . underline ( 'Sending request to S3' ) ) ) ;
252
+ this . _writeDebugLine ( Colors . bold ( 'HOST: ' ) , url ) ;
253
+ this . _writeDebugLine ( Colors . bold ( 'Headers: ' ) ) ;
257
254
headers . forEach ( ( value , name ) => {
258
- this . _writeDebugLine ( { text : `\t${ name } : ${ value } ` , foregroundColor : ColorValue . Cyan } ) ;
255
+ this . _writeDebugLine ( Colors . cyan ( `\t${ name } : ${ value } ` ) ) ;
259
256
} ) ;
260
257
261
258
const response : fetch . Response = await this . _webClient . fetchAsync ( url , webFetchOptions ) ;
0 commit comments