2022-11-03 16:35:53 -04:00
/******/ ( ( ) => { // webpackBootstrap
/******/ var _ _webpack _modules _ _ = ( {
2022-01-16 11:27:57 -05:00
2022-11-03 16:35:53 -04:00
/***/ 7351 :
/***/ ( function ( _ _unused _webpack _module , exports , _ _nccwpck _require _ _ ) {
2022-10-05 11:29:30 -04:00
"use strict" ;
2022-11-03 16:35:53 -04:00
var _ _createBinding = ( this && this . _ _createBinding ) || ( Object . create ? ( function ( o , m , k , k2 ) {
if ( k2 === undefined ) k2 = k ;
Object . defineProperty ( o , k2 , { enumerable : true , get : function ( ) { return m [ k ] ; } } ) ;
} ) : ( function ( o , m , k , k2 ) {
if ( k2 === undefined ) k2 = k ;
o [ k2 ] = m [ k ] ;
} ) ) ;
var _ _setModuleDefault = ( this && this . _ _setModuleDefault ) || ( Object . create ? ( function ( o , v ) {
Object . defineProperty ( o , "default" , { enumerable : true , value : v } ) ;
} ) : function ( o , v ) {
o [ "default" ] = v ;
2022-10-05 11:29:30 -04:00
} ) ;
2022-11-03 16:35:53 -04:00
var _ _importStar = ( this && this . _ _importStar ) || function ( mod ) {
if ( mod && mod . _ _esModule ) return mod ;
var result = { } ;
if ( mod != null ) for ( var k in mod ) if ( k !== "default" && Object . hasOwnProperty . call ( mod , k ) ) _ _createBinding ( result , mod , k ) ;
_ _setModuleDefault ( result , mod ) ;
return result ;
} ;
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
exports . issue = exports . issueCommand = void 0 ;
const os = _ _importStar ( _ _nccwpck _require _ _ ( 2037 ) ) ;
const utils _1 = _ _nccwpck _require _ _ ( 5278 ) ;
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Commands
2020-02-24 04:23:15 -05:00
*
2022-11-03 16:35:53 -04:00
* Command Format :
* : : name key = value , key = value : : message
*
* Examples :
* : : warning : : This is the message
* : : set - env name = MY _VAR : : some value
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
function issueCommand ( command , properties , message ) {
const cmd = new Command ( command , properties , message ) ;
process . stdout . write ( cmd . toString ( ) + os . EOL ) ;
}
exports . issueCommand = issueCommand ;
function issue ( name , message = '' ) {
issueCommand ( name , { } , message ) ;
}
exports . issue = issue ;
const CMD _STRING = '::' ;
class Command {
constructor ( command , properties , message ) {
if ( ! command ) {
command = 'missing.command' ;
}
this . command = command ;
this . properties = properties ;
this . message = message ;
}
toString ( ) {
let cmdStr = CMD _STRING + this . command ;
if ( this . properties && Object . keys ( this . properties ) . length > 0 ) {
cmdStr += ' ' ;
let first = true ;
for ( const key in this . properties ) {
if ( this . properties . hasOwnProperty ( key ) ) {
const val = this . properties [ key ] ;
if ( val ) {
if ( first ) {
first = false ;
}
else {
cmdStr += ',' ;
}
cmdStr += ` ${ key } = ${ escapeProperty ( val ) } ` ;
}
}
}
}
cmdStr += ` ${ CMD _STRING } ${ escapeData ( this . message ) } ` ;
return cmdStr ;
}
}
function escapeData ( s ) {
return utils _1 . toCommandValue ( s )
. replace ( /%/g , '%25' )
. replace ( /\r/g , '%0D' )
. replace ( /\n/g , '%0A' ) ;
}
function escapeProperty ( s ) {
return utils _1 . toCommandValue ( s )
. replace ( /%/g , '%25' )
. replace ( /\r/g , '%0D' )
. replace ( /\n/g , '%0A' )
. replace ( /:/g , '%3A' )
. replace ( /,/g , '%2C' ) ;
}
//# sourceMappingURL=command.js.map
2020-02-24 04:23:15 -05:00
/***/ } ) ,
2022-11-03 16:35:53 -04:00
/***/ 2186 :
/***/ ( function ( _ _unused _webpack _module , exports , _ _nccwpck _require _ _ ) {
2020-02-24 04:23:15 -05:00
"use strict" ;
2022-11-03 16:35:53 -04:00
var _ _createBinding = ( this && this . _ _createBinding ) || ( Object . create ? ( function ( o , m , k , k2 ) {
if ( k2 === undefined ) k2 = k ;
Object . defineProperty ( o , k2 , { enumerable : true , get : function ( ) { return m [ k ] ; } } ) ;
} ) : ( function ( o , m , k , k2 ) {
if ( k2 === undefined ) k2 = k ;
o [ k2 ] = m [ k ] ;
} ) ) ;
var _ _setModuleDefault = ( this && this . _ _setModuleDefault ) || ( Object . create ? ( function ( o , v ) {
Object . defineProperty ( o , "default" , { enumerable : true , value : v } ) ;
} ) : function ( o , v ) {
o [ "default" ] = v ;
} ) ;
var _ _importStar = ( this && this . _ _importStar ) || function ( mod ) {
if ( mod && mod . _ _esModule ) return mod ;
var result = { } ;
if ( mod != null ) for ( var k in mod ) if ( k !== "default" && Object . hasOwnProperty . call ( mod , k ) ) _ _createBinding ( result , mod , k ) ;
_ _setModuleDefault ( result , mod ) ;
return result ;
} ;
var _ _awaiter = ( this && this . _ _awaiter ) || function ( thisArg , _arguments , P , generator ) {
function adopt ( value ) { return value instanceof P ? value : new P ( function ( resolve ) { resolve ( value ) ; } ) ; }
return new ( P || ( P = Promise ) ) ( function ( resolve , reject ) {
function fulfilled ( value ) { try { step ( generator . next ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
function rejected ( value ) { try { step ( generator [ "throw" ] ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
function step ( result ) { result . done ? resolve ( result . value ) : adopt ( result . value ) . then ( fulfilled , rejected ) ; }
step ( ( generator = generator . apply ( thisArg , _arguments || [ ] ) ) . next ( ) ) ;
} ) ;
} ;
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
exports . getIDToken = exports . getState = exports . saveState = exports . group = exports . endGroup = exports . startGroup = exports . info = exports . notice = exports . warning = exports . error = exports . debug = exports . isDebug = exports . setFailed = exports . setCommandEcho = exports . setOutput = exports . getBooleanInput = exports . getMultilineInput = exports . getInput = exports . addPath = exports . setSecret = exports . exportVariable = exports . ExitCode = void 0 ;
const command _1 = _ _nccwpck _require _ _ ( 7351 ) ;
const file _command _1 = _ _nccwpck _require _ _ ( 717 ) ;
const utils _1 = _ _nccwpck _require _ _ ( 5278 ) ;
const os = _ _importStar ( _ _nccwpck _require _ _ ( 2037 ) ) ;
const path = _ _importStar ( _ _nccwpck _require _ _ ( 1017 ) ) ;
const oidc _utils _1 = _ _nccwpck _require _ _ ( 8041 ) ;
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* The code to exit an action
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
var ExitCode ;
( function ( ExitCode ) {
/ * *
* A code indicating that the action was successful
* /
ExitCode [ ExitCode [ "Success" ] = 0 ] = "Success" ;
/ * *
* A code indicating that the action was a failure
* /
ExitCode [ ExitCode [ "Failure" ] = 1 ] = "Failure" ;
} ) ( ExitCode = exports . ExitCode || ( exports . ExitCode = { } ) ) ;
//-----------------------------------------------------------------------
// Variables
//-----------------------------------------------------------------------
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Sets env variable for this action and future actions in the job
* @ param name the name of the variable to set
* @ param val the value of the variable . Non - string values will be converted to a string via JSON . stringify
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function exportVariable ( name , val ) {
const convertedVal = utils _1 . toCommandValue ( val ) ;
process . env [ name ] = convertedVal ;
const filePath = process . env [ 'GITHUB_ENV' ] || '' ;
if ( filePath ) {
return file _command _1 . issueFileCommand ( 'ENV' , file _command _1 . prepareKeyValueMessage ( name , val ) ) ;
}
command _1 . issueCommand ( 'set-env' , { name } , convertedVal ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
exports . exportVariable = exportVariable ;
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Registers a secret which will get masked from logs
* @ param secret value of the secret
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
function setSecret ( secret ) {
command _1 . issueCommand ( 'add-mask' , { } , secret ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
exports . setSecret = setSecret ;
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Prepends inputPath to the PATH ( for this action and future actions )
* @ param inputPath
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
function addPath ( inputPath ) {
const filePath = process . env [ 'GITHUB_PATH' ] || '' ;
if ( filePath ) {
file _command _1 . issueFileCommand ( 'PATH' , inputPath ) ;
}
else {
command _1 . issueCommand ( 'add-path' , { } , inputPath ) ;
}
process . env [ 'PATH' ] = ` ${ inputPath } ${ path . delimiter } ${ process . env [ 'PATH' ] } ` ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
exports . addPath = addPath ;
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Gets the value of an input .
* Unless trimWhitespace is set to false in InputOptions , the value is also trimmed .
* Returns an empty string if the value is not defined .
2020-02-24 04:23:15 -05:00
*
2022-11-03 16:35:53 -04:00
* @ param name name of the input to get
* @ param options optional . See InputOptions .
* @ returns string
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
function getInput ( name , options ) {
const val = process . env [ ` INPUT_ ${ name . replace ( / /g , '_' ) . toUpperCase ( ) } ` ] || '' ;
if ( options && options . required && ! val ) {
throw new Error ( ` Input required and not supplied: ${ name } ` ) ;
}
if ( options && options . trimWhitespace === false ) {
return val ;
}
return val . trim ( ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
exports . getInput = getInput ;
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Gets the values of an multiline input . Each value is also trimmed .
*
* @ param name name of the input to get
* @ param options optional . See InputOptions .
* @ returns string [ ]
2020-02-24 04:23:15 -05:00
*
* /
2022-11-03 16:35:53 -04:00
function getMultilineInput ( name , options ) {
const inputs = getInput ( name , options )
. split ( '\n' )
. filter ( x => x !== '' ) ;
if ( options && options . trimWhitespace === false ) {
return inputs ;
}
return inputs . map ( input => input . trim ( ) ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
exports . getMultilineInput = getMultilineInput ;
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Gets the input value of the boolean type in the YAML 1.2 "core schema" specification .
* Support boolean input list : ` true | True | TRUE | false | False | FALSE ` .
* The return value is also in boolean type .
* ref : https : //yaml.org/spec/1.2/spec.html#id2804923
2020-02-24 04:23:15 -05:00
*
2022-11-03 16:35:53 -04:00
* @ param name name of the input to get
* @ param options optional . See InputOptions .
* @ returns boolean
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
function getBooleanInput ( name , options ) {
const trueValue = [ 'true' , 'True' , 'TRUE' ] ;
const falseValue = [ 'false' , 'False' , 'FALSE' ] ;
const val = getInput ( name , options ) ;
if ( trueValue . includes ( val ) )
return true ;
if ( falseValue . includes ( val ) )
return false ;
throw new TypeError ( ` Input does not meet YAML 1.2 "Core Schema" specification: ${ name } \n ` +
` Support boolean input list: \` true | True | TRUE | false | False | FALSE \` ` ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
exports . getBooleanInput = getBooleanInput ;
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Sets the value of an output .
2020-02-24 04:23:15 -05:00
*
2022-11-03 16:35:53 -04:00
* @ param name name of the output to set
* @ param value value to store . Non - string values will be converted to a string via JSON . stringify
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setOutput ( name , value ) {
const filePath = process . env [ 'GITHUB_OUTPUT' ] || '' ;
if ( filePath ) {
return file _command _1 . issueFileCommand ( 'OUTPUT' , file _command _1 . prepareKeyValueMessage ( name , value ) ) ;
}
process . stdout . write ( os . EOL ) ;
command _1 . issueCommand ( 'set-output' , { name } , utils _1 . toCommandValue ( value ) ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
exports . setOutput = setOutput ;
2020-10-01 16:20:08 -04:00
/ * *
2022-11-03 16:35:53 -04:00
* Enables or disables the echoing of commands into stdout for the rest of the step .
* Echoing is disabled by default if ACTIONS _STEP _DEBUG is not set .
2020-10-01 16:20:08 -04:00
*
* /
2022-11-03 16:35:53 -04:00
function setCommandEcho ( enabled ) {
command _1 . issue ( 'echo' , enabled ? 'on' : 'off' ) ;
2020-10-01 16:20:08 -04:00
}
2022-11-03 16:35:53 -04:00
exports . setCommandEcho = setCommandEcho ;
//-----------------------------------------------------------------------
// Results
//-----------------------------------------------------------------------
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Sets the action status to failed .
* When the action exits it will be with an exit code of 1
* @ param message add error issue message
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
function setFailed ( message ) {
process . exitCode = ExitCode . Failure ;
error ( message ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
exports . setFailed = setFailed ;
//-----------------------------------------------------------------------
// Logging Commands
//-----------------------------------------------------------------------
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Gets whether Actions Step Debug is on or not
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
function isDebug ( ) {
return process . env [ 'RUNNER_DEBUG' ] === '1' ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
exports . isDebug = isDebug ;
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Writes debug message to user log
* @ param message debug message
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
function debug ( message ) {
command _1 . issueCommand ( 'debug' , { } , message ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
exports . debug = debug ;
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Adds an error issue
* @ param message error issue message . Errors will be converted to string via toString ( )
* @ param properties optional properties to add to the annotation .
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
function error ( message , properties = { } ) {
command _1 . issueCommand ( 'error' , utils _1 . toCommandProperties ( properties ) , message instanceof Error ? message . toString ( ) : message ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
exports . error = error ;
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Adds a warning issue
* @ param message warning issue message . Errors will be converted to string via toString ( )
* @ param properties optional properties to add to the annotation .
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
function warning ( message , properties = { } ) {
command _1 . issueCommand ( 'warning' , utils _1 . toCommandProperties ( properties ) , message instanceof Error ? message . toString ( ) : message ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
exports . warning = warning ;
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Adds a notice issue
* @ param message notice issue message . Errors will be converted to string via toString ( )
* @ param properties optional properties to add to the annotation .
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
function notice ( message , properties = { } ) {
command _1 . issueCommand ( 'notice' , utils _1 . toCommandProperties ( properties ) , message instanceof Error ? message . toString ( ) : message ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
exports . notice = notice ;
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Writes info to log with console . log .
* @ param message info message
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
function info ( message ) {
process . stdout . write ( message + os . EOL ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
exports . info = info ;
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Begin an output group .
2020-02-24 04:23:15 -05:00
*
2022-11-03 16:35:53 -04:00
* Output until the next ` groupEnd ` will be foldable in this group
2020-02-24 04:23:15 -05:00
*
2022-11-03 16:35:53 -04:00
* @ param name The name of the output group
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
function startGroup ( name ) {
command _1 . issue ( 'group' , name ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
exports . startGroup = startGroup ;
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* End an output group .
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
function endGroup ( ) {
command _1 . issue ( 'endgroup' ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
exports . endGroup = endGroup ;
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Wrap an asynchronous function call in a group .
2020-02-24 04:23:15 -05:00
*
2022-11-03 16:35:53 -04:00
* Returns the same type as the function itself .
2020-02-24 04:23:15 -05:00
*
2022-11-03 16:35:53 -04:00
* @ param name The name of the group
* @ param fn The function to wrap in the group
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
function group ( name , fn ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
startGroup ( name ) ;
let result ;
try {
result = yield fn ( ) ;
}
finally {
endGroup ( ) ;
}
return result ;
} ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
exports . group = group ;
//-----------------------------------------------------------------------
// Wrapper action state
//-----------------------------------------------------------------------
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Saves state for current action , the state can only be retrieved by this action ' s post job execution .
2020-02-24 04:23:15 -05:00
*
2022-11-03 16:35:53 -04:00
* @ param name name of the state to store
* @ param value value to store . Non - string values will be converted to a string via JSON . stringify
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function saveState ( name , value ) {
const filePath = process . env [ 'GITHUB_STATE' ] || '' ;
if ( filePath ) {
return file _command _1 . issueFileCommand ( 'STATE' , file _command _1 . prepareKeyValueMessage ( name , value ) ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
command _1 . issueCommand ( 'save-state' , { name } , utils _1 . toCommandValue ( value ) ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
exports . saveState = saveState ;
2020-10-01 16:20:08 -04:00
/ * *
2022-11-03 16:35:53 -04:00
* Gets the value of an state set by this action ' s main execution .
2020-10-01 16:20:08 -04:00
*
2022-11-03 16:35:53 -04:00
* @ param name name of the state to get
* @ returns string
2020-10-01 16:20:08 -04:00
* /
2022-11-03 16:35:53 -04:00
function getState ( name ) {
return process . env [ ` STATE_ ${ name } ` ] || '' ;
2020-10-01 16:20:08 -04:00
}
2022-11-03 16:35:53 -04:00
exports . getState = getState ;
function getIDToken ( aud ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return yield oidc _utils _1 . OidcClient . getIDToken ( aud ) ;
} ) ;
2022-10-05 11:29:30 -04:00
}
2022-11-03 16:35:53 -04:00
exports . getIDToken = getIDToken ;
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Summary exports
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
var summary _1 = _ _nccwpck _require _ _ ( 1327 ) ;
Object . defineProperty ( exports , "summary" , ( { enumerable : true , get : function ( ) { return summary _1 . summary ; } } ) ) ;
2021-09-09 08:42:30 -04:00
/ * *
2022-11-03 16:35:53 -04:00
* @ deprecated use core . summary
2021-09-09 08:42:30 -04:00
* /
2022-11-03 16:35:53 -04:00
var summary _2 = _ _nccwpck _require _ _ ( 1327 ) ;
Object . defineProperty ( exports , "markdownSummary" , ( { enumerable : true , get : function ( ) { return summary _2 . markdownSummary ; } } ) ) ;
2021-01-24 07:14:13 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Path exports
2021-01-24 07:14:13 -05:00
* /
2022-11-03 16:35:53 -04:00
var path _utils _1 = _ _nccwpck _require _ _ ( 2981 ) ;
Object . defineProperty ( exports , "toPosixPath" , ( { enumerable : true , get : function ( ) { return path _utils _1 . toPosixPath ; } } ) ) ;
Object . defineProperty ( exports , "toWin32Path" , ( { enumerable : true , get : function ( ) { return path _utils _1 . toWin32Path ; } } ) ) ;
Object . defineProperty ( exports , "toPlatformPath" , ( { enumerable : true , get : function ( ) { return path _utils _1 . toPlatformPath ; } } ) ) ;
//# sourceMappingURL=core.js.map
2021-01-24 07:14:13 -05:00
2020-10-01 16:20:08 -04:00
/***/ } ) ,
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/***/ 717 :
/***/ ( function ( _ _unused _webpack _module , exports , _ _nccwpck _require _ _ ) {
2020-02-24 04:23:15 -05:00
2020-10-01 16:20:08 -04:00
"use strict" ;
2020-02-24 04:23:15 -05:00
2020-10-01 16:20:08 -04:00
// For internal use, subject to change.
2021-09-09 08:42:30 -04:00
var _ _createBinding = ( this && this . _ _createBinding ) || ( Object . create ? ( function ( o , m , k , k2 ) {
if ( k2 === undefined ) k2 = k ;
Object . defineProperty ( o , k2 , { enumerable : true , get : function ( ) { return m [ k ] ; } } ) ;
} ) : ( function ( o , m , k , k2 ) {
if ( k2 === undefined ) k2 = k ;
o [ k2 ] = m [ k ] ;
} ) ) ;
var _ _setModuleDefault = ( this && this . _ _setModuleDefault ) || ( Object . create ? ( function ( o , v ) {
Object . defineProperty ( o , "default" , { enumerable : true , value : v } ) ;
} ) : function ( o , v ) {
o [ "default" ] = v ;
} ) ;
2020-10-01 16:20:08 -04:00
var _ _importStar = ( this && this . _ _importStar ) || function ( mod ) {
if ( mod && mod . _ _esModule ) return mod ;
var result = { } ;
2021-09-09 08:42:30 -04:00
if ( mod != null ) for ( var k in mod ) if ( k !== "default" && Object . hasOwnProperty . call ( mod , k ) ) _ _createBinding ( result , mod , k ) ;
_ _setModuleDefault ( result , mod ) ;
2020-10-01 16:20:08 -04:00
return result ;
2020-02-24 04:23:15 -05:00
} ;
2022-11-03 16:35:53 -04:00
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
2022-10-05 11:29:30 -04:00
exports . prepareKeyValueMessage = exports . issueFileCommand = void 0 ;
2020-10-01 16:20:08 -04:00
// We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */
2022-11-03 16:35:53 -04:00
const fs = _ _importStar ( _ _nccwpck _require _ _ ( 7147 ) ) ;
const os = _ _importStar ( _ _nccwpck _require _ _ ( 2037 ) ) ;
const uuid _1 = _ _nccwpck _require _ _ ( 5840 ) ;
const utils _1 = _ _nccwpck _require _ _ ( 5278 ) ;
2022-10-05 11:29:30 -04:00
function issueFileCommand ( command , message ) {
2020-10-01 16:20:08 -04:00
const filePath = process . env [ ` GITHUB_ ${ command } ` ] ;
if ( ! filePath ) {
throw new Error ( ` Unable to find environment variable for file command ${ command } ` ) ;
}
if ( ! fs . existsSync ( filePath ) ) {
throw new Error ( ` Missing file at path: ${ filePath } ` ) ;
}
fs . appendFileSync ( filePath , ` ${ utils _1 . toCommandValue ( message ) } ${ os . EOL } ` , {
encoding : 'utf8'
} ) ;
2020-02-24 04:23:15 -05:00
}
2022-10-05 11:29:30 -04:00
exports . issueFileCommand = issueFileCommand ;
function prepareKeyValueMessage ( key , value ) {
const delimiter = ` ghadelimiter_ ${ uuid _1 . v4 ( ) } ` ;
const convertedValue = utils _1 . toCommandValue ( value ) ;
// These should realistically never happen, but just in case someone finds a
// way to exploit uuid generation let's not allow keys or values that contain
// the delimiter.
if ( key . includes ( delimiter ) ) {
throw new Error ( ` Unexpected input: name should not contain the delimiter " ${ delimiter } " ` ) ;
}
if ( convertedValue . includes ( delimiter ) ) {
throw new Error ( ` Unexpected input: value should not contain the delimiter " ${ delimiter } " ` ) ;
}
return ` ${ key } << ${ delimiter } ${ os . EOL } ${ convertedValue } ${ os . EOL } ${ delimiter } ` ;
}
exports . prepareKeyValueMessage = prepareKeyValueMessage ;
2020-10-01 16:20:08 -04:00
//# sourceMappingURL=file-command.js.map
2020-02-24 04:23:15 -05:00
2021-01-05 12:57:45 -05:00
/***/ } ) ,
2022-11-03 16:35:53 -04:00
/***/ 8041 :
/***/ ( function ( _ _unused _webpack _module , exports , _ _nccwpck _require _ _ ) {
2021-01-05 12:57:45 -05:00
"use strict" ;
2022-11-03 16:35:53 -04:00
var _ _awaiter = ( this && this . _ _awaiter ) || function ( thisArg , _arguments , P , generator ) {
function adopt ( value ) { return value instanceof P ? value : new P ( function ( resolve ) { resolve ( value ) ; } ) ; }
return new ( P || ( P = Promise ) ) ( function ( resolve , reject ) {
function fulfilled ( value ) { try { step ( generator . next ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
function rejected ( value ) { try { step ( generator [ "throw" ] ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
function step ( result ) { result . done ? resolve ( result . value ) : adopt ( result . value ) . then ( fulfilled , rejected ) ; }
step ( ( generator = generator . apply ( thisArg , _arguments || [ ] ) ) . next ( ) ) ;
} ) ;
2021-01-05 12:57:45 -05:00
} ;
2022-11-03 16:35:53 -04:00
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
exports . OidcClient = void 0 ;
const http _client _1 = _ _nccwpck _require _ _ ( 6255 ) ;
const auth _1 = _ _nccwpck _require _ _ ( 5526 ) ;
const core _1 = _ _nccwpck _require _ _ ( 2186 ) ;
class OidcClient {
static createHttpClient ( allowRetry = true , maxRetry = 10 ) {
const requestOptions = {
allowRetries : allowRetry ,
maxRetries : maxRetry
} ;
return new http _client _1 . HttpClient ( 'actions/oidc-client' , [ new auth _1 . BearerCredentialHandler ( OidcClient . getRequestToken ( ) ) ] , requestOptions ) ;
2021-09-09 08:42:30 -04:00
}
2022-11-03 16:35:53 -04:00
static getRequestToken ( ) {
const token = process . env [ 'ACTIONS_ID_TOKEN_REQUEST_TOKEN' ] ;
if ( ! token ) {
throw new Error ( 'Unable to get ACTIONS_ID_TOKEN_REQUEST_TOKEN env variable' ) ;
}
return token ;
2021-09-09 08:42:30 -04:00
}
2022-11-03 16:35:53 -04:00
static getIDTokenUrl ( ) {
const runtimeUrl = process . env [ 'ACTIONS_ID_TOKEN_REQUEST_URL' ] ;
if ( ! runtimeUrl ) {
throw new Error ( 'Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable' ) ;
}
return runtimeUrl ;
2021-09-09 08:42:30 -04:00
}
2022-11-03 16:35:53 -04:00
static getCall ( id _token _url ) {
var _a ;
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
const httpclient = OidcClient . createHttpClient ( ) ;
const res = yield httpclient
. getJson ( id _token _url )
. catch ( error => {
throw new Error ( ` Failed to get ID Token. \n
Error Code : $ { error . statusCode } \ n
Error Message : $ { error . result . message } ` );
} ) ;
const id _token = ( _a = res . result ) === null || _a === void 0 ? void 0 : _a . value ;
if ( ! id _token ) {
throw new Error ( 'Response json body do not have ID Token field' ) ;
}
return id _token ;
} ) ;
2021-09-09 08:42:30 -04:00
}
2022-11-03 16:35:53 -04:00
static getIDToken ( audience ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
try {
// New ID Token is requested from action service
let id _token _url = OidcClient . getIDTokenUrl ( ) ;
if ( audience ) {
const encodedAudience = encodeURIComponent ( audience ) ;
id _token _url = ` ${ id _token _url } &audience= ${ encodedAudience } ` ;
}
core _1 . debug ( ` ID token url is ${ id _token _url } ` ) ;
const id _token = yield OidcClient . getCall ( id _token _url ) ;
core _1 . setSecret ( id _token ) ;
return id _token ;
}
catch ( error ) {
throw new Error ( ` Error message: ${ error . message } ` ) ;
}
} ) ;
2021-09-09 08:42:30 -04:00
}
}
2022-11-03 16:35:53 -04:00
exports . OidcClient = OidcClient ;
//# sourceMappingURL=oidc-utils.js.map
2021-09-09 08:42:30 -04:00
2020-02-24 04:23:15 -05:00
/***/ } ) ,
2022-11-03 16:35:53 -04:00
/***/ 2981 :
/***/ ( function ( _ _unused _webpack _module , exports , _ _nccwpck _require _ _ ) {
2020-02-24 04:23:15 -05:00
"use strict" ;
2022-11-03 16:35:53 -04:00
var _ _createBinding = ( this && this . _ _createBinding ) || ( Object . create ? ( function ( o , m , k , k2 ) {
if ( k2 === undefined ) k2 = k ;
Object . defineProperty ( o , k2 , { enumerable : true , get : function ( ) { return m [ k ] ; } } ) ;
} ) : ( function ( o , m , k , k2 ) {
if ( k2 === undefined ) k2 = k ;
o [ k2 ] = m [ k ] ;
} ) ) ;
var _ _setModuleDefault = ( this && this . _ _setModuleDefault ) || ( Object . create ? ( function ( o , v ) {
Object . defineProperty ( o , "default" , { enumerable : true , value : v } ) ;
} ) : function ( o , v ) {
o [ "default" ] = v ;
} ) ;
var _ _importStar = ( this && this . _ _importStar ) || function ( mod ) {
if ( mod && mod . _ _esModule ) return mod ;
var result = { } ;
if ( mod != null ) for ( var k in mod ) if ( k !== "default" && Object . hasOwnProperty . call ( mod , k ) ) _ _createBinding ( result , mod , k ) ;
_ _setModuleDefault ( result , mod ) ;
return result ;
2020-02-24 04:23:15 -05:00
} ;
2022-11-03 16:35:53 -04:00
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
exports . toPlatformPath = exports . toWin32Path = exports . toPosixPath = void 0 ;
const path = _ _importStar ( _ _nccwpck _require _ _ ( 1017 ) ) ;
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* toPosixPath converts the given path to the posix form . On Windows , \ \ will be
* replaced with / .
2020-02-24 04:23:15 -05:00
*
2022-11-03 16:35:53 -04:00
* @ param pth . Path to transform .
* @ return string Posix path .
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
function toPosixPath ( pth ) {
return pth . replace ( /[\\]/g , '/' ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
exports . toPosixPath = toPosixPath ;
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* toWin32Path converts the given path to the win32 form . On Linux , / w i l l b e
* replaced with \ \ .
*
* @ param pth . Path to transform .
* @ return string Win32 path .
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
function toWin32Path ( pth ) {
return pth . replace ( /[/]/g , '\\' ) ;
}
exports . toWin32Path = toWin32Path ;
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* toPlatformPath converts the given path to a platform - specific path . It does
* this by replacing instances of / a n d \ w i t h t h e p l a t f o r m - s p e c i f i c p a t h
* separator .
*
* @ param pth The path to platformize .
* @ return string The platform - specific path .
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
function toPlatformPath ( pth ) {
return pth . replace ( /[/\\]/g , path . sep ) ;
}
exports . toPlatformPath = toPlatformPath ;
//# sourceMappingURL=path-utils.js.map
2020-02-24 04:23:15 -05:00
2022-01-16 11:27:57 -05:00
/***/ } ) ,
2022-11-03 16:35:53 -04:00
/***/ 1327 :
/***/ ( function ( _ _unused _webpack _module , exports , _ _nccwpck _require _ _ ) {
2022-01-16 11:27:57 -05:00
"use strict" ;
2022-11-03 16:35:53 -04:00
var _ _awaiter = ( this && this . _ _awaiter ) || function ( thisArg , _arguments , P , generator ) {
function adopt ( value ) { return value instanceof P ? value : new P ( function ( resolve ) { resolve ( value ) ; } ) ; }
return new ( P || ( P = Promise ) ) ( function ( resolve , reject ) {
function fulfilled ( value ) { try { step ( generator . next ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
function rejected ( value ) { try { step ( generator [ "throw" ] ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
function step ( result ) { result . done ? resolve ( result . value ) : adopt ( result . value ) . then ( fulfilled , rejected ) ; }
step ( ( generator = generator . apply ( thisArg , _arguments || [ ] ) ) . next ( ) ) ;
} ) ;
} ;
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
exports . summary = exports . markdownSummary = exports . SUMMARY _DOCS _URL = exports . SUMMARY _ENV _VAR = void 0 ;
const os _1 = _ _nccwpck _require _ _ ( 2037 ) ;
const fs _1 = _ _nccwpck _require _ _ ( 7147 ) ;
const { access , appendFile , writeFile } = fs _1 . promises ;
exports . SUMMARY _ENV _VAR = 'GITHUB_STEP_SUMMARY' ;
exports . SUMMARY _DOCS _URL = 'https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary' ;
class Summary {
constructor ( ) {
this . _buffer = '' ;
2022-01-16 11:27:57 -05:00
}
2022-11-03 16:35:53 -04:00
/ * *
* Finds the summary file path from the environment , rejects if env var is not found or file does not exist
* Also checks r / w permissions .
*
* @ returns step summary file path
* /
filePath ( ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
if ( this . _filePath ) {
return this . _filePath ;
}
const pathFromEnv = process . env [ exports . SUMMARY _ENV _VAR ] ;
if ( ! pathFromEnv ) {
throw new Error ( ` Unable to find environment variable for $ ${ exports . SUMMARY _ENV _VAR } . Check if your runtime environment supports job summaries. ` ) ;
}
try {
yield access ( pathFromEnv , fs _1 . constants . R _OK | fs _1 . constants . W _OK ) ;
}
catch ( _a ) {
throw new Error ( ` Unable to access summary file: ' ${ pathFromEnv } '. Check if the file has correct read/write permissions. ` ) ;
}
this . _filePath = pathFromEnv ;
return this . _filePath ;
} ) ;
2022-01-16 11:27:57 -05:00
}
2022-11-03 16:35:53 -04:00
/ * *
* Wraps content in an HTML tag , adding any HTML attributes
*
* @ param { string } tag HTML tag to wrap
* @ param { string | null } content content within the tag
* @ param { [ attribute : string ] : string } attrs key - value list of HTML attributes to add
*
* @ returns { string } content wrapped in HTML element
* /
wrap ( tag , content , attrs = { } ) {
const htmlAttrs = Object . entries ( attrs )
. map ( ( [ key , value ] ) => ` ${ key } =" ${ value } " ` )
. join ( '' ) ;
if ( ! content ) {
return ` < ${ tag } ${ htmlAttrs } > ` ;
}
return ` < ${ tag } ${ htmlAttrs } > ${ content } </ ${ tag } > ` ;
2022-01-16 11:27:57 -05:00
}
2022-11-03 16:35:53 -04:00
/ * *
* Writes text in the buffer to the summary buffer file and empties buffer . Will append by default .
*
* @ param { SummaryWriteOptions } [ options ] ( optional ) options for write operation
*
* @ returns { Promise < Summary > } summary instance
* /
write ( options ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
const overwrite = ! ! ( options === null || options === void 0 ? void 0 : options . overwrite ) ;
const filePath = yield this . filePath ( ) ;
const writeFunc = overwrite ? writeFile : appendFile ;
yield writeFunc ( filePath , this . _buffer , { encoding : 'utf8' } ) ;
return this . emptyBuffer ( ) ;
} ) ;
2022-01-16 11:27:57 -05:00
}
2022-11-03 16:35:53 -04:00
/ * *
* Clears the summary buffer and wipes the summary file
*
* @ returns { Summary } summary instance
* /
clear ( ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return this . emptyBuffer ( ) . write ( { overwrite : true } ) ;
} ) ;
2022-01-16 11:27:57 -05:00
}
2022-11-03 16:35:53 -04:00
/ * *
* Returns the current summary buffer as a string
*
* @ returns { string } string of summary buffer
* /
stringify ( ) {
return this . _buffer ;
2022-01-16 11:27:57 -05:00
}
2022-11-03 16:35:53 -04:00
/ * *
* If the summary buffer is empty
*
* @ returns { boolen } true if the buffer is empty
* /
isEmptyBuffer ( ) {
return this . _buffer . length === 0 ;
}
/ * *
* Resets the summary buffer without writing to summary file
*
* @ returns { Summary } summary instance
* /
emptyBuffer ( ) {
this . _buffer = '' ;
return this ;
}
/ * *
* Adds raw text to the summary buffer
*
* @ param { string } text content to add
* @ param { boolean } [ addEOL = false ] ( optional ) append an EOL to the raw text ( default : false )
*
* @ returns { Summary } summary instance
* /
addRaw ( text , addEOL = false ) {
this . _buffer += text ;
return addEOL ? this . addEOL ( ) : this ;
}
/ * *
* Adds the operating system - specific end - of - line marker to the buffer
*
* @ returns { Summary } summary instance
* /
addEOL ( ) {
return this . addRaw ( os _1 . EOL ) ;
}
/ * *
* Adds an HTML codeblock to the summary buffer
*
* @ param { string } code content to render within fenced code block
* @ param { string } lang ( optional ) language to syntax highlight code
*
* @ returns { Summary } summary instance
* /
addCodeBlock ( code , lang ) {
const attrs = Object . assign ( { } , ( lang && { lang } ) ) ;
const element = this . wrap ( 'pre' , this . wrap ( 'code' , code ) , attrs ) ;
return this . addRaw ( element ) . addEOL ( ) ;
}
/ * *
* Adds an HTML list to the summary buffer
*
* @ param { string [ ] } items list of items to render
* @ param { boolean } [ ordered = false ] ( optional ) if the rendered list should be ordered or not ( default : false )
*
* @ returns { Summary } summary instance
* /
addList ( items , ordered = false ) {
const tag = ordered ? 'ol' : 'ul' ;
const listItems = items . map ( item => this . wrap ( 'li' , item ) ) . join ( '' ) ;
const element = this . wrap ( tag , listItems ) ;
return this . addRaw ( element ) . addEOL ( ) ;
}
/ * *
* Adds an HTML table to the summary buffer
*
* @ param { SummaryTableCell [ ] } rows table rows
*
* @ returns { Summary } summary instance
* /
addTable ( rows ) {
const tableBody = rows
. map ( row => {
const cells = row
. map ( cell => {
if ( typeof cell === 'string' ) {
return this . wrap ( 'td' , cell ) ;
}
const { header , data , colspan , rowspan } = cell ;
const tag = header ? 'th' : 'td' ;
const attrs = Object . assign ( Object . assign ( { } , ( colspan && { colspan } ) ) , ( rowspan && { rowspan } ) ) ;
return this . wrap ( tag , data , attrs ) ;
} )
. join ( '' ) ;
return this . wrap ( 'tr' , cells ) ;
} )
. join ( '' ) ;
const element = this . wrap ( 'table' , tableBody ) ;
return this . addRaw ( element ) . addEOL ( ) ;
}
/ * *
* Adds a collapsable HTML details element to the summary buffer
*
* @ param { string } label text for the closed state
* @ param { string } content collapsable content
*
* @ returns { Summary } summary instance
* /
addDetails ( label , content ) {
const element = this . wrap ( 'details' , this . wrap ( 'summary' , label ) + content ) ;
return this . addRaw ( element ) . addEOL ( ) ;
}
/ * *
* Adds an HTML image tag to the summary buffer
*
* @ param { string } src path to the image you to embed
* @ param { string } alt text description of the image
* @ param { SummaryImageOptions } options ( optional ) addition image attributes
*
* @ returns { Summary } summary instance
* /
addImage ( src , alt , options ) {
const { width , height } = options || { } ;
const attrs = Object . assign ( Object . assign ( { } , ( width && { width } ) ) , ( height && { height } ) ) ;
const element = this . wrap ( 'img' , null , Object . assign ( { src , alt } , attrs ) ) ;
return this . addRaw ( element ) . addEOL ( ) ;
}
/ * *
* Adds an HTML section heading element
*
* @ param { string } text heading text
* @ param { number | string } [ level = 1 ] ( optional ) the heading level , default : 1
*
* @ returns { Summary } summary instance
* /
addHeading ( text , level ) {
const tag = ` h ${ level } ` ;
const allowedTag = [ 'h1' , 'h2' , 'h3' , 'h4' , 'h5' , 'h6' ] . includes ( tag )
? tag
: 'h1' ;
const element = this . wrap ( allowedTag , text ) ;
return this . addRaw ( element ) . addEOL ( ) ;
}
/ * *
* Adds an HTML thematic break ( < hr > ) to the summary buffer
*
* @ returns { Summary } summary instance
* /
addSeparator ( ) {
const element = this . wrap ( 'hr' , null ) ;
return this . addRaw ( element ) . addEOL ( ) ;
}
/ * *
* Adds an HTML line break ( < br > ) to the summary buffer
*
* @ returns { Summary } summary instance
* /
addBreak ( ) {
const element = this . wrap ( 'br' , null ) ;
return this . addRaw ( element ) . addEOL ( ) ;
}
/ * *
* Adds an HTML blockquote to the summary buffer
*
* @ param { string } text quote text
* @ param { string } cite ( optional ) citation url
*
* @ returns { Summary } summary instance
* /
addQuote ( text , cite ) {
const attrs = Object . assign ( { } , ( cite && { cite } ) ) ;
const element = this . wrap ( 'blockquote' , text , attrs ) ;
return this . addRaw ( element ) . addEOL ( ) ;
}
/ * *
* Adds an HTML anchor tag to the summary buffer
*
* @ param { string } text link text / content
* @ param { string } href hyperlink
*
* @ returns { Summary } summary instance
* /
addLink ( text , href ) {
const element = this . wrap ( 'a' , text , { href } ) ;
return this . addRaw ( element ) . addEOL ( ) ;
}
}
const _summary = new Summary ( ) ;
/ * *
* @ deprecated use ` core.summary `
* /
exports . markdownSummary = _summary ;
exports . summary = _summary ;
//# sourceMappingURL=summary.js.map
2022-01-16 11:27:57 -05:00
2022-11-03 16:35:53 -04:00
/***/ } ) ,
2022-01-16 11:27:57 -05:00
2022-11-03 16:35:53 -04:00
/***/ 5278 :
/***/ ( ( _ _unused _webpack _module , exports ) => {
2022-01-16 11:27:57 -05:00
2022-11-03 16:35:53 -04:00
"use strict" ;
2022-01-16 11:27:57 -05:00
2022-11-03 16:35:53 -04:00
// We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
exports . toCommandProperties = exports . toCommandValue = void 0 ;
/ * *
* Sanitizes an input into a string so it can be passed into issueCommand safely
* @ param input input to sanitize into a string
* /
function toCommandValue ( input ) {
if ( input === null || input === undefined ) {
return '' ;
}
else if ( typeof input === 'string' || input instanceof String ) {
return input ;
}
return JSON . stringify ( input ) ;
2022-01-16 11:27:57 -05:00
}
2022-11-03 16:35:53 -04:00
exports . toCommandValue = toCommandValue ;
/ * *
*
* @ param annotationProperties
* @ returns The command properties to send with the actual annotation command
* See IssueCommandProperties : https : //github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646
* /
function toCommandProperties ( annotationProperties ) {
if ( ! Object . keys ( annotationProperties ) . length ) {
return { } ;
}
2022-01-16 11:27:57 -05:00
return {
2022-11-03 16:35:53 -04:00
title : annotationProperties . title ,
file : annotationProperties . file ,
line : annotationProperties . startLine ,
endLine : annotationProperties . endLine ,
col : annotationProperties . startColumn ,
endColumn : annotationProperties . endColumn
2022-01-16 11:27:57 -05:00
} ;
}
2022-11-03 16:35:53 -04:00
exports . toCommandProperties = toCommandProperties ;
//# sourceMappingURL=utils.js.map
2022-01-16 11:27:57 -05:00
2022-11-03 16:35:53 -04:00
/***/ } ) ,
/***/ 5526 :
/***/ ( function ( _ _unused _webpack _module , exports ) {
"use strict" ;
var _ _awaiter = ( this && this . _ _awaiter ) || function ( thisArg , _arguments , P , generator ) {
function adopt ( value ) { return value instanceof P ? value : new P ( function ( resolve ) { resolve ( value ) ; } ) ; }
return new ( P || ( P = Promise ) ) ( function ( resolve , reject ) {
function fulfilled ( value ) { try { step ( generator . next ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
function rejected ( value ) { try { step ( generator [ "throw" ] ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
function step ( result ) { result . done ? resolve ( result . value ) : adopt ( result . value ) . then ( fulfilled , rejected ) ; }
step ( ( generator = generator . apply ( thisArg , _arguments || [ ] ) ) . next ( ) ) ;
} ) ;
} ;
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
exports . PersonalAccessTokenCredentialHandler = exports . BearerCredentialHandler = exports . BasicCredentialHandler = void 0 ;
class BasicCredentialHandler {
constructor ( username , password ) {
this . username = username ;
this . password = password ;
}
prepareRequest ( options ) {
if ( ! options . headers ) {
throw Error ( 'The request has no headers' ) ;
2022-01-16 11:27:57 -05:00
}
2022-11-03 16:35:53 -04:00
options . headers [ 'Authorization' ] = ` Basic ${ Buffer . from ( ` ${ this . username } : ${ this . password } ` ) . toString ( 'base64' ) } ` ;
}
// This handler cannot handle 401
canHandleAuthentication ( ) {
return false ;
}
handleAuthentication ( ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
throw new Error ( 'not implemented' ) ;
} ) ;
2022-01-16 11:27:57 -05:00
}
}
2022-11-03 16:35:53 -04:00
exports . BasicCredentialHandler = BasicCredentialHandler ;
class BearerCredentialHandler {
constructor ( token ) {
this . token = token ;
}
// currently implements pre-authorization
// TODO: support preAuth = false where it hooks on 401
prepareRequest ( options ) {
if ( ! options . headers ) {
throw Error ( 'The request has no headers' ) ;
}
options . headers [ 'Authorization' ] = ` Bearer ${ this . token } ` ;
}
// This handler cannot handle 401
canHandleAuthentication ( ) {
return false ;
}
handleAuthentication ( ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
throw new Error ( 'not implemented' ) ;
} ) ;
2022-01-16 11:27:57 -05:00
}
}
2022-11-03 16:35:53 -04:00
exports . BearerCredentialHandler = BearerCredentialHandler ;
class PersonalAccessTokenCredentialHandler {
constructor ( token ) {
this . token = token ;
}
// currently implements pre-authorization
// TODO: support preAuth = false where it hooks on 401
prepareRequest ( options ) {
if ( ! options . headers ) {
throw Error ( 'The request has no headers' ) ;
}
options . headers [ 'Authorization' ] = ` Basic ${ Buffer . from ( ` PAT: ${ this . token } ` ) . toString ( 'base64' ) } ` ;
}
// This handler cannot handle 401
canHandleAuthentication ( ) {
return false ;
}
handleAuthentication ( ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
throw new Error ( 'not implemented' ) ;
} ) ;
2021-01-24 07:14:13 -05:00
}
}
2022-11-03 16:35:53 -04:00
exports . PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler ;
//# sourceMappingURL=auth.js.map
2021-01-24 07:14:13 -05:00
/***/ } ) ,
2022-11-03 16:35:53 -04:00
/***/ 6255 :
/***/ ( function ( _ _unused _webpack _module , exports , _ _nccwpck _require _ _ ) {
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
"use strict" ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
/* eslint-disable @typescript-eslint/no-explicit-any */
var _ _createBinding = ( this && this . _ _createBinding ) || ( Object . create ? ( function ( o , m , k , k2 ) {
if ( k2 === undefined ) k2 = k ;
Object . defineProperty ( o , k2 , { enumerable : true , get : function ( ) { return m [ k ] ; } } ) ;
} ) : ( function ( o , m , k , k2 ) {
if ( k2 === undefined ) k2 = k ;
o [ k2 ] = m [ k ] ;
} ) ) ;
var _ _setModuleDefault = ( this && this . _ _setModuleDefault ) || ( Object . create ? ( function ( o , v ) {
Object . defineProperty ( o , "default" , { enumerable : true , value : v } ) ;
} ) : function ( o , v ) {
o [ "default" ] = v ;
2021-01-24 07:14:13 -05:00
} ) ;
2022-11-03 16:35:53 -04:00
var _ _importStar = ( this && this . _ _importStar ) || function ( mod ) {
if ( mod && mod . _ _esModule ) return mod ;
var result = { } ;
if ( mod != null ) for ( var k in mod ) if ( k !== "default" && Object . hasOwnProperty . call ( mod , k ) ) _ _createBinding ( result , mod , k ) ;
_ _setModuleDefault ( result , mod ) ;
return result ;
2021-01-24 07:14:13 -05:00
} ;
2022-11-03 16:35:53 -04:00
var _ _awaiter = ( this && this . _ _awaiter ) || function ( thisArg , _arguments , P , generator ) {
function adopt ( value ) { return value instanceof P ? value : new P ( function ( resolve ) { resolve ( value ) ; } ) ; }
return new ( P || ( P = Promise ) ) ( function ( resolve , reject ) {
function fulfilled ( value ) { try { step ( generator . next ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
function rejected ( value ) { try { step ( generator [ "throw" ] ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
function step ( result ) { result . done ? resolve ( result . value ) : adopt ( result . value ) . then ( fulfilled , rejected ) ; }
step ( ( generator = generator . apply ( thisArg , _arguments || [ ] ) ) . next ( ) ) ;
} ) ;
2021-01-24 07:14:13 -05:00
} ;
2022-11-03 16:35:53 -04:00
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
exports . HttpClient = exports . isHttps = exports . HttpClientResponse = exports . HttpClientError = exports . getProxyUrl = exports . MediaTypes = exports . Headers = exports . HttpCodes = void 0 ;
const http = _ _importStar ( _ _nccwpck _require _ _ ( 3685 ) ) ;
const https = _ _importStar ( _ _nccwpck _require _ _ ( 5687 ) ) ;
const pm = _ _importStar ( _ _nccwpck _require _ _ ( 9835 ) ) ;
const tunnel = _ _importStar ( _ _nccwpck _require _ _ ( 4294 ) ) ;
var HttpCodes ;
( function ( HttpCodes ) {
HttpCodes [ HttpCodes [ "OK" ] = 200 ] = "OK" ;
HttpCodes [ HttpCodes [ "MultipleChoices" ] = 300 ] = "MultipleChoices" ;
HttpCodes [ HttpCodes [ "MovedPermanently" ] = 301 ] = "MovedPermanently" ;
HttpCodes [ HttpCodes [ "ResourceMoved" ] = 302 ] = "ResourceMoved" ;
HttpCodes [ HttpCodes [ "SeeOther" ] = 303 ] = "SeeOther" ;
HttpCodes [ HttpCodes [ "NotModified" ] = 304 ] = "NotModified" ;
HttpCodes [ HttpCodes [ "UseProxy" ] = 305 ] = "UseProxy" ;
HttpCodes [ HttpCodes [ "SwitchProxy" ] = 306 ] = "SwitchProxy" ;
HttpCodes [ HttpCodes [ "TemporaryRedirect" ] = 307 ] = "TemporaryRedirect" ;
HttpCodes [ HttpCodes [ "PermanentRedirect" ] = 308 ] = "PermanentRedirect" ;
HttpCodes [ HttpCodes [ "BadRequest" ] = 400 ] = "BadRequest" ;
HttpCodes [ HttpCodes [ "Unauthorized" ] = 401 ] = "Unauthorized" ;
HttpCodes [ HttpCodes [ "PaymentRequired" ] = 402 ] = "PaymentRequired" ;
HttpCodes [ HttpCodes [ "Forbidden" ] = 403 ] = "Forbidden" ;
HttpCodes [ HttpCodes [ "NotFound" ] = 404 ] = "NotFound" ;
HttpCodes [ HttpCodes [ "MethodNotAllowed" ] = 405 ] = "MethodNotAllowed" ;
HttpCodes [ HttpCodes [ "NotAcceptable" ] = 406 ] = "NotAcceptable" ;
HttpCodes [ HttpCodes [ "ProxyAuthenticationRequired" ] = 407 ] = "ProxyAuthenticationRequired" ;
HttpCodes [ HttpCodes [ "RequestTimeout" ] = 408 ] = "RequestTimeout" ;
HttpCodes [ HttpCodes [ "Conflict" ] = 409 ] = "Conflict" ;
HttpCodes [ HttpCodes [ "Gone" ] = 410 ] = "Gone" ;
HttpCodes [ HttpCodes [ "TooManyRequests" ] = 429 ] = "TooManyRequests" ;
HttpCodes [ HttpCodes [ "InternalServerError" ] = 500 ] = "InternalServerError" ;
HttpCodes [ HttpCodes [ "NotImplemented" ] = 501 ] = "NotImplemented" ;
HttpCodes [ HttpCodes [ "BadGateway" ] = 502 ] = "BadGateway" ;
HttpCodes [ HttpCodes [ "ServiceUnavailable" ] = 503 ] = "ServiceUnavailable" ;
HttpCodes [ HttpCodes [ "GatewayTimeout" ] = 504 ] = "GatewayTimeout" ;
} ) ( HttpCodes = exports . HttpCodes || ( exports . HttpCodes = { } ) ) ;
var Headers ;
( function ( Headers ) {
Headers [ "Accept" ] = "accept" ;
Headers [ "ContentType" ] = "content-type" ;
} ) ( Headers = exports . Headers || ( exports . Headers = { } ) ) ;
var MediaTypes ;
( function ( MediaTypes ) {
MediaTypes [ "ApplicationJson" ] = "application/json" ;
} ) ( MediaTypes = exports . MediaTypes || ( exports . MediaTypes = { } ) ) ;
2021-01-24 07:14:13 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Returns the proxy URL , depending upon the supplied url and proxy environment variables .
* @ param serverUrl The server URL where the request will be sent . For example , https : //api.github.com
2021-01-24 07:14:13 -05:00
* /
2022-11-03 16:35:53 -04:00
function getProxyUrl ( serverUrl ) {
const proxyUrl = pm . getProxyUrl ( new URL ( serverUrl ) ) ;
return proxyUrl ? proxyUrl . href : '' ;
}
exports . getProxyUrl = getProxyUrl ;
const HttpRedirectCodes = [
HttpCodes . MovedPermanently ,
HttpCodes . ResourceMoved ,
HttpCodes . SeeOther ,
HttpCodes . TemporaryRedirect ,
HttpCodes . PermanentRedirect
] ;
const HttpResponseRetryCodes = [
HttpCodes . BadGateway ,
HttpCodes . ServiceUnavailable ,
HttpCodes . GatewayTimeout
] ;
const RetryableHttpVerbs = [ 'OPTIONS' , 'GET' , 'DELETE' , 'HEAD' ] ;
const ExponentialBackoffCeiling = 10 ;
const ExponentialBackoffTimeSlice = 5 ;
class HttpClientError extends Error {
constructor ( message , statusCode ) {
super ( message ) ;
this . name = 'HttpClientError' ;
this . statusCode = statusCode ;
Object . setPrototypeOf ( this , HttpClientError . prototype ) ;
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
}
exports . HttpClientError = HttpClientError ;
class HttpClientResponse {
constructor ( message ) {
this . message = message ;
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
readBody ( ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return new Promise ( ( resolve ) => _ _awaiter ( this , void 0 , void 0 , function * ( ) {
let output = Buffer . alloc ( 0 ) ;
this . message . on ( 'data' , ( chunk ) => {
output = Buffer . concat ( [ output , chunk ] ) ;
} ) ;
this . message . on ( 'end' , ( ) => {
resolve ( output . toString ( ) ) ;
} ) ;
} ) ) ;
} ) ;
2021-01-24 07:14:13 -05:00
}
}
2022-11-03 16:35:53 -04:00
exports . HttpClientResponse = HttpClientResponse ;
function isHttps ( requestUrl ) {
const parsedUrl = new URL ( requestUrl ) ;
return parsedUrl . protocol === 'https:' ;
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
exports . isHttps = isHttps ;
class HttpClient {
constructor ( userAgent , handlers , requestOptions ) {
this . _ignoreSslError = false ;
this . _allowRedirects = true ;
this . _allowRedirectDowngrade = false ;
this . _maxRedirects = 50 ;
this . _allowRetries = false ;
this . _maxRetries = 1 ;
this . _keepAlive = false ;
this . _disposed = false ;
this . userAgent = userAgent ;
this . handlers = handlers || [ ] ;
this . requestOptions = requestOptions ;
if ( requestOptions ) {
if ( requestOptions . ignoreSslError != null ) {
this . _ignoreSslError = requestOptions . ignoreSslError ;
}
this . _socketTimeout = requestOptions . socketTimeout ;
if ( requestOptions . allowRedirects != null ) {
this . _allowRedirects = requestOptions . allowRedirects ;
}
if ( requestOptions . allowRedirectDowngrade != null ) {
this . _allowRedirectDowngrade = requestOptions . allowRedirectDowngrade ;
}
if ( requestOptions . maxRedirects != null ) {
this . _maxRedirects = Math . max ( requestOptions . maxRedirects , 0 ) ;
}
if ( requestOptions . keepAlive != null ) {
this . _keepAlive = requestOptions . keepAlive ;
}
if ( requestOptions . allowRetries != null ) {
this . _allowRetries = requestOptions . allowRetries ;
}
if ( requestOptions . maxRetries != null ) {
this . _maxRetries = requestOptions . maxRetries ;
}
2022-07-19 04:27:31 -04:00
}
}
2022-11-03 16:35:53 -04:00
options ( requestUrl , additionalHeaders ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return this . request ( 'OPTIONS' , requestUrl , null , additionalHeaders || { } ) ;
} ) ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
get ( requestUrl , additionalHeaders ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return this . request ( 'GET' , requestUrl , null , additionalHeaders || { } ) ;
} ) ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
del ( requestUrl , additionalHeaders ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return this . request ( 'DELETE' , requestUrl , null , additionalHeaders || { } ) ;
} ) ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
post ( requestUrl , data , additionalHeaders ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return this . request ( 'POST' , requestUrl , data , additionalHeaders || { } ) ;
} ) ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
patch ( requestUrl , data , additionalHeaders ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return this . request ( 'PATCH' , requestUrl , data , additionalHeaders || { } ) ;
} ) ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
put ( requestUrl , data , additionalHeaders ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return this . request ( 'PUT' , requestUrl , data , additionalHeaders || { } ) ;
} ) ;
2022-10-05 11:29:30 -04:00
}
2022-11-03 16:35:53 -04:00
head ( requestUrl , additionalHeaders ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return this . request ( 'HEAD' , requestUrl , null , additionalHeaders || { } ) ;
} ) ;
2022-10-05 11:29:30 -04:00
}
2022-11-03 16:35:53 -04:00
sendStream ( verb , requestUrl , stream , additionalHeaders ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return this . request ( verb , requestUrl , stream , additionalHeaders ) ;
} ) ;
2022-10-05 11:29:30 -04:00
}
2022-11-03 16:35:53 -04:00
/ * *
* Gets a typed object from an endpoint
* Be aware that not found returns a null . Other errors ( 4 xx , 5 xx ) reject the promise
* /
getJson ( requestUrl , additionalHeaders = { } ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
additionalHeaders [ Headers . Accept ] = this . _getExistingOrDefaultHeader ( additionalHeaders , Headers . Accept , MediaTypes . ApplicationJson ) ;
const res = yield this . get ( requestUrl , additionalHeaders ) ;
return this . _processResponse ( res , this . requestOptions ) ;
} ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
postJson ( requestUrl , obj , additionalHeaders = { } ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
const data = JSON . stringify ( obj , null , 2 ) ;
additionalHeaders [ Headers . Accept ] = this . _getExistingOrDefaultHeader ( additionalHeaders , Headers . Accept , MediaTypes . ApplicationJson ) ;
additionalHeaders [ Headers . ContentType ] = this . _getExistingOrDefaultHeader ( additionalHeaders , Headers . ContentType , MediaTypes . ApplicationJson ) ;
const res = yield this . post ( requestUrl , data , additionalHeaders ) ;
return this . _processResponse ( res , this . requestOptions ) ;
} ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
putJson ( requestUrl , obj , additionalHeaders = { } ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
const data = JSON . stringify ( obj , null , 2 ) ;
additionalHeaders [ Headers . Accept ] = this . _getExistingOrDefaultHeader ( additionalHeaders , Headers . Accept , MediaTypes . ApplicationJson ) ;
additionalHeaders [ Headers . ContentType ] = this . _getExistingOrDefaultHeader ( additionalHeaders , Headers . ContentType , MediaTypes . ApplicationJson ) ;
const res = yield this . put ( requestUrl , data , additionalHeaders ) ;
return this . _processResponse ( res , this . requestOptions ) ;
} ) ;
2021-09-09 08:42:30 -04:00
}
2022-11-03 16:35:53 -04:00
patchJson ( requestUrl , obj , additionalHeaders = { } ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
const data = JSON . stringify ( obj , null , 2 ) ;
additionalHeaders [ Headers . Accept ] = this . _getExistingOrDefaultHeader ( additionalHeaders , Headers . Accept , MediaTypes . ApplicationJson ) ;
additionalHeaders [ Headers . ContentType ] = this . _getExistingOrDefaultHeader ( additionalHeaders , Headers . ContentType , MediaTypes . ApplicationJson ) ;
const res = yield this . patch ( requestUrl , data , additionalHeaders ) ;
return this . _processResponse ( res , this . requestOptions ) ;
} ) ;
2021-09-09 08:42:30 -04:00
}
2022-11-03 16:35:53 -04:00
/ * *
* Makes a raw http request .
* All other methods such as get , post , patch , and request ultimately call this .
* Prefer get , del , post and patch
* /
request ( verb , requestUrl , data , headers ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
if ( this . _disposed ) {
throw new Error ( 'Client has already been disposed.' ) ;
}
const parsedUrl = new URL ( requestUrl ) ;
let info = this . _prepareRequest ( verb , parsedUrl , headers ) ;
// Only perform retries on reads since writes may not be idempotent.
const maxTries = this . _allowRetries && RetryableHttpVerbs . includes ( verb )
? this . _maxRetries + 1
: 1 ;
let numTries = 0 ;
let response ;
do {
response = yield this . requestRaw ( info , data ) ;
// Check if it's an authentication challenge
if ( response &&
response . message &&
response . message . statusCode === HttpCodes . Unauthorized ) {
let authenticationHandler ;
for ( const handler of this . handlers ) {
if ( handler . canHandleAuthentication ( response ) ) {
authenticationHandler = handler ;
break ;
}
}
if ( authenticationHandler ) {
return authenticationHandler . handleAuthentication ( this , info , data ) ;
}
else {
// We have received an unauthorized response but have no handlers to handle it.
// Let the response return to the caller.
return response ;
}
}
let redirectsRemaining = this . _maxRedirects ;
while ( response . message . statusCode &&
HttpRedirectCodes . includes ( response . message . statusCode ) &&
this . _allowRedirects &&
redirectsRemaining > 0 ) {
const redirectUrl = response . message . headers [ 'location' ] ;
if ( ! redirectUrl ) {
// if there's no location to redirect to, we won't
break ;
}
const parsedRedirectUrl = new URL ( redirectUrl ) ;
if ( parsedUrl . protocol === 'https:' &&
parsedUrl . protocol !== parsedRedirectUrl . protocol &&
! this . _allowRedirectDowngrade ) {
throw new Error ( 'Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.' ) ;
}
// we need to finish reading the response before reassigning response
// which will leak the open socket.
yield response . readBody ( ) ;
// strip authorization header if redirected to a different hostname
if ( parsedRedirectUrl . hostname !== parsedUrl . hostname ) {
for ( const header in headers ) {
// header names are case insensitive
if ( header . toLowerCase ( ) === 'authorization' ) {
delete headers [ header ] ;
}
}
}
// let's make the request with the new redirectUrl
info = this . _prepareRequest ( verb , parsedRedirectUrl , headers ) ;
response = yield this . requestRaw ( info , data ) ;
redirectsRemaining -- ;
}
if ( ! response . message . statusCode ||
! HttpResponseRetryCodes . includes ( response . message . statusCode ) ) {
// If not a retry code, return immediately instead of retrying
return response ;
}
numTries += 1 ;
if ( numTries < maxTries ) {
yield response . readBody ( ) ;
yield this . _performExponentialBackoff ( numTries ) ;
}
} while ( numTries < maxTries ) ;
return response ;
} ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
/ * *
* Needs to be called if keepAlive is set to true in request options .
* /
dispose ( ) {
if ( this . _agent ) {
this . _agent . destroy ( ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
this . _disposed = true ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
/ * *
* Raw request .
* @ param info
* @ param data
* /
requestRaw ( info , data ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return new Promise ( ( resolve , reject ) => {
function callbackForResult ( err , res ) {
if ( err ) {
reject ( err ) ;
}
else if ( ! res ) {
// If `err` is not passed, then `res` must be passed.
reject ( new Error ( 'Unknown error' ) ) ;
}
else {
resolve ( res ) ;
}
}
this . requestRawWithCallback ( info , data , callbackForResult ) ;
} ) ;
} ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
/ * *
* Raw request with callback .
* @ param info
* @ param data
* @ param onResult
* /
requestRawWithCallback ( info , data , onResult ) {
if ( typeof data === 'string' ) {
if ( ! info . options . headers ) {
info . options . headers = { } ;
}
info . options . headers [ 'Content-Length' ] = Buffer . byteLength ( data , 'utf8' ) ;
}
let callbackCalled = false ;
function handleResult ( err , res ) {
if ( ! callbackCalled ) {
callbackCalled = true ;
onResult ( err , res ) ;
}
}
const req = info . httpModule . request ( info . options , ( msg ) => {
const res = new HttpClientResponse ( msg ) ;
handleResult ( undefined , res ) ;
} ) ;
let socket ;
req . on ( 'socket' , sock => {
socket = sock ;
} ) ;
// If we ever get disconnected, we want the socket to timeout eventually
req . setTimeout ( this . _socketTimeout || 3 * 60000 , ( ) => {
if ( socket ) {
socket . end ( ) ;
}
handleResult ( new Error ( ` Request timeout: ${ info . options . path } ` ) ) ;
} ) ;
req . on ( 'error' , function ( err ) {
// err has statusCode property
// res should have headers
handleResult ( err ) ;
} ) ;
if ( data && typeof data === 'string' ) {
req . write ( data , 'utf8' ) ;
}
if ( data && typeof data !== 'string' ) {
data . on ( 'close' , function ( ) {
req . end ( ) ;
} ) ;
data . pipe ( req ) ;
}
else {
req . end ( ) ;
}
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
/ * *
* Gets an http agent . This function is useful when you need an http agent that handles
* routing through a proxy server - depending upon the url and proxy environment variables .
* @ param serverUrl The server URL where the request will be sent . For example , https : //api.github.com
* /
getAgent ( serverUrl ) {
const parsedUrl = new URL ( serverUrl ) ;
return this . _getAgent ( parsedUrl ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
_prepareRequest ( method , requestUrl , headers ) {
const info = { } ;
info . parsedUrl = requestUrl ;
const usingSsl = info . parsedUrl . protocol === 'https:' ;
info . httpModule = usingSsl ? https : http ;
const defaultPort = usingSsl ? 443 : 80 ;
info . options = { } ;
info . options . host = info . parsedUrl . hostname ;
info . options . port = info . parsedUrl . port
? parseInt ( info . parsedUrl . port )
: defaultPort ;
info . options . path =
( info . parsedUrl . pathname || '' ) + ( info . parsedUrl . search || '' ) ;
info . options . method = method ;
info . options . headers = this . _mergeHeaders ( headers ) ;
if ( this . userAgent != null ) {
info . options . headers [ 'user-agent' ] = this . userAgent ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
info . options . agent = this . _getAgent ( info . parsedUrl ) ;
// gives handlers an opportunity to participate
if ( this . handlers ) {
for ( const handler of this . handlers ) {
handler . prepareRequest ( info . options ) ;
}
}
return info ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
_mergeHeaders ( headers ) {
if ( this . requestOptions && this . requestOptions . headers ) {
return Object . assign ( { } , lowercaseKeys ( this . requestOptions . headers ) , lowercaseKeys ( headers || { } ) ) ;
}
return lowercaseKeys ( headers || { } ) ;
}
_getExistingOrDefaultHeader ( additionalHeaders , header , _default ) {
let clientHeader ;
if ( this . requestOptions && this . requestOptions . headers ) {
clientHeader = lowercaseKeys ( this . requestOptions . headers ) [ header ] ;
}
return additionalHeaders [ header ] || clientHeader || _default ;
}
_getAgent ( parsedUrl ) {
let agent ;
const proxyUrl = pm . getProxyUrl ( parsedUrl ) ;
const useProxy = proxyUrl && proxyUrl . hostname ;
if ( this . _keepAlive && useProxy ) {
agent = this . _proxyAgent ;
}
if ( this . _keepAlive && ! useProxy ) {
agent = this . _agent ;
}
// if agent is already assigned use that agent.
if ( agent ) {
return agent ;
}
const usingSsl = parsedUrl . protocol === 'https:' ;
let maxSockets = 100 ;
if ( this . requestOptions ) {
maxSockets = this . requestOptions . maxSockets || http . globalAgent . maxSockets ;
}
// This is `useProxy` again, but we need to check `proxyURl` directly for TypeScripts's flow analysis.
if ( proxyUrl && proxyUrl . hostname ) {
const agentOptions = {
maxSockets ,
keepAlive : this . _keepAlive ,
proxy : Object . assign ( Object . assign ( { } , ( ( proxyUrl . username || proxyUrl . password ) && {
proxyAuth : ` ${ proxyUrl . username } : ${ proxyUrl . password } `
} ) ) , { host : proxyUrl . hostname , port : proxyUrl . port } )
} ;
let tunnelAgent ;
const overHttps = proxyUrl . protocol === 'https:' ;
if ( usingSsl ) {
tunnelAgent = overHttps ? tunnel . httpsOverHttps : tunnel . httpsOverHttp ;
}
else {
tunnelAgent = overHttps ? tunnel . httpOverHttps : tunnel . httpOverHttp ;
}
agent = tunnelAgent ( agentOptions ) ;
this . _proxyAgent = agent ;
}
// if reusing agent across request and tunneling agent isn't assigned create a new agent
if ( this . _keepAlive && ! agent ) {
const options = { keepAlive : this . _keepAlive , maxSockets } ;
agent = usingSsl ? new https . Agent ( options ) : new http . Agent ( options ) ;
this . _agent = agent ;
}
// if not using private agent and tunnel agent isn't setup then use global agent
if ( ! agent ) {
agent = usingSsl ? https . globalAgent : http . globalAgent ;
}
if ( usingSsl && this . _ignoreSslError ) {
// we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process
// http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options
// we have to cast it to any and change it directly
agent . options = Object . assign ( agent . options || { } , {
rejectUnauthorized : false
} ) ;
}
return agent ;
}
_performExponentialBackoff ( retryNumber ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
retryNumber = Math . min ( ExponentialBackoffCeiling , retryNumber ) ;
const ms = ExponentialBackoffTimeSlice * Math . pow ( 2 , retryNumber ) ;
return new Promise ( resolve => setTimeout ( ( ) => resolve ( ) , ms ) ) ;
} ) ;
}
_processResponse ( res , options ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return new Promise ( ( resolve , reject ) => _ _awaiter ( this , void 0 , void 0 , function * ( ) {
const statusCode = res . message . statusCode || 0 ;
const response = {
statusCode ,
result : null ,
headers : { }
} ;
// not found leads to null obj returned
if ( statusCode === HttpCodes . NotFound ) {
resolve ( response ) ;
}
// get the result from the body
function dateTimeDeserializer ( key , value ) {
if ( typeof value === 'string' ) {
const a = new Date ( value ) ;
if ( ! isNaN ( a . valueOf ( ) ) ) {
return a ;
}
}
return value ;
}
let obj ;
let contents ;
try {
contents = yield res . readBody ( ) ;
if ( contents && contents . length > 0 ) {
if ( options && options . deserializeDates ) {
obj = JSON . parse ( contents , dateTimeDeserializer ) ;
}
else {
obj = JSON . parse ( contents ) ;
}
response . result = obj ;
}
response . headers = res . message . headers ;
}
catch ( err ) {
// Invalid resource (contents not json); leaving result obj null
}
// note that 3xx redirects are handled by the http layer.
if ( statusCode > 299 ) {
let msg ;
// if exception/error in body, attempt to get better error
if ( obj && obj . message ) {
msg = obj . message ;
}
else if ( contents && contents . length > 0 ) {
// it may be the case that the exception is in the body message as string
msg = contents ;
}
else {
msg = ` Failed request: ( ${ statusCode } ) ` ;
}
const err = new HttpClientError ( msg , statusCode ) ;
err . result = response . result ;
reject ( err ) ;
}
else {
resolve ( response ) ;
}
} ) ) ;
} ) ;
}
}
exports . HttpClient = HttpClient ;
const lowercaseKeys = ( obj ) => Object . keys ( obj ) . reduce ( ( c , k ) => ( ( c [ k . toLowerCase ( ) ] = obj [ k ] ) , c ) , { } ) ;
//# sourceMappingURL=index.js.map
2020-02-24 04:23:15 -05:00
2020-07-30 12:27:27 -04:00
/***/ } ) ,
2022-11-03 16:35:53 -04:00
/***/ 9835 :
/***/ ( ( _ _unused _webpack _module , exports ) => {
2020-07-30 12:27:27 -04:00
2022-11-03 16:35:53 -04:00
"use strict" ;
2020-07-30 12:27:27 -04:00
2022-11-03 16:35:53 -04:00
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
exports . checkBypass = exports . getProxyUrl = void 0 ;
function getProxyUrl ( reqUrl ) {
const usingSsl = reqUrl . protocol === 'https:' ;
if ( checkBypass ( reqUrl ) ) {
return undefined ;
}
const proxyVar = ( ( ) => {
if ( usingSsl ) {
return process . env [ 'https_proxy' ] || process . env [ 'HTTPS_PROXY' ] ;
}
else {
return process . env [ 'http_proxy' ] || process . env [ 'HTTP_PROXY' ] ;
}
} ) ( ) ;
if ( proxyVar ) {
return new URL ( proxyVar ) ;
}
else {
return undefined ;
}
2020-07-30 12:27:27 -04:00
}
2022-11-03 16:35:53 -04:00
exports . getProxyUrl = getProxyUrl ;
function checkBypass ( reqUrl ) {
if ( ! reqUrl . hostname ) {
return false ;
}
const noProxy = process . env [ 'no_proxy' ] || process . env [ 'NO_PROXY' ] || '' ;
if ( ! noProxy ) {
return false ;
}
// Determine the request port
let reqPort ;
if ( reqUrl . port ) {
reqPort = Number ( reqUrl . port ) ;
}
else if ( reqUrl . protocol === 'http:' ) {
reqPort = 80 ;
}
else if ( reqUrl . protocol === 'https:' ) {
reqPort = 443 ;
}
// Format the request hostname and hostname with port
const upperReqHosts = [ reqUrl . hostname . toUpperCase ( ) ] ;
if ( typeof reqPort === 'number' ) {
upperReqHosts . push ( ` ${ upperReqHosts [ 0 ] } : ${ reqPort } ` ) ;
}
// Compare request host against noproxy
for ( const upperNoProxyItem of noProxy
. split ( ',' )
. map ( x => x . trim ( ) . toUpperCase ( ) )
. filter ( x => x ) ) {
if ( upperReqHosts . some ( x => x === upperNoProxyItem ) ) {
return true ;
}
}
return false ;
2020-07-30 12:27:27 -04:00
}
2022-11-03 16:35:53 -04:00
exports . checkBypass = checkBypass ;
//# sourceMappingURL=proxy.js.map
2020-07-30 12:27:27 -04:00
2020-02-24 04:23:15 -05:00
/***/ } ) ,
2022-11-03 16:35:53 -04:00
/***/ 4812 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
module . exports =
{
parallel : _ _nccwpck _require _ _ ( 8210 ) ,
serial : _ _nccwpck _require _ _ ( 445 ) ,
serialOrdered : _ _nccwpck _require _ _ ( 3578 )
} ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/***/ } ) ,
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/***/ 1700 :
/***/ ( ( module ) => {
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
// API
module . exports = abort ;
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Aborts leftover active jobs
2020-02-24 04:23:15 -05:00
*
2022-11-03 16:35:53 -04:00
* @ param { object } state - current state object
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
function abort ( state )
{
Object . keys ( state . jobs ) . forEach ( clean . bind ( state ) ) ;
// reset leftover jobs
state . jobs = { } ;
}
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Cleans up leftover job by invoking abort function for the provided job id
2020-02-24 04:23:15 -05:00
*
2022-11-03 16:35:53 -04:00
* @ this state
* @ param { string | number } key - job id to abort
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
function clean ( key )
{
if ( typeof this . jobs [ key ] == 'function' )
{
this . jobs [ key ] ( ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
}
/***/ } ) ,
/***/ 2794 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
var defer = _ _nccwpck _require _ _ ( 5295 ) ;
// API
module . exports = async ;
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Runs provided callback asynchronously
* even if callback itself is not
2020-02-24 04:23:15 -05:00
*
2022-11-03 16:35:53 -04:00
* @ param { function } callback - callback to invoke
* @ returns { function } - augmented callback
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
function async ( callback )
{
var isAsync = false ;
// check if async happened
defer ( function ( ) { isAsync = true ; } ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
return function async _callback ( err , result )
{
if ( isAsync )
{
callback ( err , result ) ;
}
else
{
defer ( function nextTick _callback ( )
{
callback ( err , result ) ;
} ) ;
}
} ;
}
2020-02-24 04:23:15 -05:00
2022-10-05 11:29:30 -04:00
/***/ } ) ,
2022-11-03 16:35:53 -04:00
/***/ 5295 :
/***/ ( ( module ) => {
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
module . exports = defer ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
/ * *
* Runs provided function on next iteration of the event loop
*
* @ param { function } fn - function to run
* /
function defer ( fn )
{
var nextTick = typeof setImmediate == 'function'
? setImmediate
: (
typeof process == 'object' && typeof process . nextTick == 'function'
? process . nextTick
: null
) ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
if ( nextTick )
{
nextTick ( fn ) ;
}
else
{
setTimeout ( fn , 0 ) ;
}
}
2022-01-16 11:27:57 -05:00
2022-11-03 16:35:53 -04:00
/***/ } ) ,
2022-01-16 11:27:57 -05:00
2022-11-03 16:35:53 -04:00
/***/ 9023 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
2022-01-16 11:27:57 -05:00
2022-11-03 16:35:53 -04:00
var async = _ _nccwpck _require _ _ ( 2794 )
, abort = _ _nccwpck _require _ _ ( 1700 )
;
2022-01-16 11:27:57 -05:00
2022-11-03 16:35:53 -04:00
// API
module . exports = iterate ;
2022-01-16 11:27:57 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Iterates over each job object
2022-01-16 11:27:57 -05:00
*
2022-11-03 16:35:53 -04:00
* @ param { array | object } list - array or object ( named list ) to iterate over
* @ param { function } iterator - iterator to run
* @ param { object } state - current job status
* @ param { function } callback - invoked when all elements processed
2022-01-16 11:27:57 -05:00
* /
2022-11-03 16:35:53 -04:00
function iterate ( list , iterator , state , callback )
{
// store current index
var key = state [ 'keyedList' ] ? state [ 'keyedList' ] [ state . index ] : state . index ;
2022-01-16 11:27:57 -05:00
2022-11-03 16:35:53 -04:00
state . jobs [ key ] = runJob ( iterator , key , list [ key ] , function ( error , output )
{
// don't repeat yourself
// skip secondary callbacks
if ( ! ( key in state . jobs ) )
{
return ;
2022-01-16 11:27:57 -05:00
}
2022-11-03 16:35:53 -04:00
// clean up jobs
delete state . jobs [ key ] ;
2022-01-16 11:27:57 -05:00
2022-11-03 16:35:53 -04:00
if ( error )
{
// don't process rest of the results
// stop still active jobs
// and reset the list
abort ( state ) ;
}
else
{
state . results [ key ] = output ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
// return salvaged results
callback ( error , state . results ) ;
} ) ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
/ * *
* Runs iterator over provided job element
*
* @ param { function } iterator - iterator to invoke
* @ param { string | number } key - key / index of the element in the list of jobs
* @ param { mixed } item - job description
* @ param { function } callback - invoked after iterator is done with the job
* @ returns { function | mixed } - job abort function or something else
* /
function runJob ( iterator , key , item , callback )
2021-01-24 07:14:13 -05:00
{
2022-11-03 16:35:53 -04:00
var aborter ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
// allow shortcut if iterator expects only two arguments
if ( iterator . length == 2 )
{
aborter = iterator ( item , async ( callback ) ) ;
}
// otherwise go with full three arguments
else
{
aborter = iterator ( item , key , async ( callback ) ) ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
return aborter ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/***/ } ) ,
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/***/ 2474 :
/***/ ( ( module ) => {
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
// API
module . exports = state ;
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Creates initial state object
* for iteration over list
2020-02-24 04:23:15 -05:00
*
2022-11-03 16:35:53 -04:00
* @ param { array | object } list - list to iterate over
* @ param { function | null } sortMethod - function to use for keys sort ,
* or ` null ` to keep them as is
* @ returns { object } - initial state object
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
function state ( list , sortMethod )
{
var isNamedList = ! Array . isArray ( list )
, initState =
{
index : 0 ,
keyedList : isNamedList || sortMethod ? Object . keys ( list ) : null ,
jobs : { } ,
results : isNamedList ? { } : [ ] ,
size : isNamedList ? Object . keys ( list ) . length : list . length
}
;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( sortMethod )
{
// sort array keys based on it's values
// sort object's keys just on own merit
initState . keyedList . sort ( isNamedList ? sortMethod : function ( a , b )
{
return sortMethod ( list [ a ] , list [ b ] ) ;
} ) ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
return initState ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
/***/ } ) ,
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/***/ 7942 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
var abort = _ _nccwpck _require _ _ ( 1700 )
, async = _ _nccwpck _require _ _ ( 2794 )
;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
// API
module . exports = terminator ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/ * *
* Terminates jobs in the attached state context
*
* @ this AsyncKitState #
* @ param { function } callback - final callback to invoke after termination
* /
function terminator ( callback )
{
if ( ! Object . keys ( this . jobs ) . length )
{
return ;
}
2021-01-05 12:57:45 -05:00
2022-11-03 16:35:53 -04:00
// fast forward iteration index
this . index = this . size ;
// abort jobs
abort ( this ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
// send back results we have so far
async ( callback ) ( null , this . results ) ;
}
2020-02-24 04:23:15 -05:00
2020-07-30 12:27:27 -04:00
/***/ } ) ,
2022-11-03 16:35:53 -04:00
/***/ 8210 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
2020-07-30 12:27:27 -04:00
2022-11-03 16:35:53 -04:00
var iterate = _ _nccwpck _require _ _ ( 9023 )
, initState = _ _nccwpck _require _ _ ( 2474 )
, terminator = _ _nccwpck _require _ _ ( 7942 )
;
2022-11-01 05:01:33 -04:00
2022-11-03 16:35:53 -04:00
// Public API
module . exports = parallel ;
2022-11-01 05:01:33 -04:00
2021-03-19 12:28:53 -04:00
/ * *
2022-11-03 16:35:53 -04:00
* Runs iterator over provided array elements in parallel
2021-03-19 12:28:53 -04:00
*
2022-11-03 16:35:53 -04:00
* @ param { array | object } list - array or object ( named list ) to iterate over
* @ param { function } iterator - iterator to run
* @ param { function } callback - invoked when all elements processed
* @ returns { function } - jobs terminator
2021-03-19 12:28:53 -04:00
* /
2022-11-03 16:35:53 -04:00
function parallel ( list , iterator , callback )
{
var state = initState ( list ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
while ( state . index < ( state [ 'keyedList' ] || list ) . length )
{
iterate ( list , iterator , state , function ( error , result )
{
if ( error )
{
callback ( error , result ) ;
return ;
2021-01-24 07:14:13 -05:00
}
2022-02-09 22:14:07 -05:00
2022-11-03 16:35:53 -04:00
// looks like it's the last one
if ( Object . keys ( state . jobs ) . length === 0 )
{
callback ( null , state . results ) ;
return ;
2022-11-01 05:01:33 -04:00
}
2022-11-03 16:35:53 -04:00
} ) ;
2022-11-01 05:01:33 -04:00
2022-11-03 16:35:53 -04:00
state . index ++ ;
}
2020-07-30 12:27:27 -04:00
2022-11-03 16:35:53 -04:00
return terminator . bind ( state , callback ) ;
}
2021-01-24 07:52:05 -05:00
2020-07-30 12:27:27 -04:00
2022-11-03 16:35:53 -04:00
/***/ } ) ,
2020-07-30 12:27:27 -04:00
2022-11-03 16:35:53 -04:00
/***/ 445 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
2020-07-30 12:27:27 -04:00
2022-11-03 16:35:53 -04:00
var serialOrdered = _ _nccwpck _require _ _ ( 3578 ) ;
// Public API
module . exports = serial ;
2020-07-30 12:27:27 -04:00
2021-03-19 12:28:53 -04:00
/ * *
2022-11-03 16:35:53 -04:00
* Runs iterator over provided array elements in series
2021-03-19 12:28:53 -04:00
*
2022-11-03 16:35:53 -04:00
* @ param { array | object } list - array or object ( named list ) to iterate over
* @ param { function } iterator - iterator to run
* @ param { function } callback - invoked when all elements processed
* @ returns { function } - jobs terminator
2021-03-19 12:28:53 -04:00
* /
2022-11-03 16:35:53 -04:00
function serial ( list , iterator , callback )
{
return serialOrdered ( list , iterator , null , callback ) ;
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
/***/ } ) ,
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
/***/ 3578 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
var iterate = _ _nccwpck _require _ _ ( 9023 )
, initState = _ _nccwpck _require _ _ ( 2474 )
, terminator = _ _nccwpck _require _ _ ( 7942 )
;
// Public API
module . exports = serialOrdered ;
// sorting helpers
module . exports . ascending = ascending ;
module . exports . descending = descending ;
2021-01-24 07:14:13 -05:00
2021-03-19 12:28:53 -04:00
/ * *
2022-11-03 16:35:53 -04:00
* Runs iterator over provided sorted array elements in series
2021-03-19 12:28:53 -04:00
*
2022-11-03 16:35:53 -04:00
* @ param { array | object } list - array or object ( named list ) to iterate over
* @ param { function } iterator - iterator to run
* @ param { function } sortMethod - custom sort function
* @ param { function } callback - invoked when all elements processed
* @ returns { function } - jobs terminator
2021-03-19 12:28:53 -04:00
* /
2022-11-03 16:35:53 -04:00
function serialOrdered ( list , iterator , sortMethod , callback )
{
var state = initState ( list , sortMethod ) ;
2021-01-24 07:52:05 -05:00
2022-11-03 16:35:53 -04:00
iterate ( list , iterator , state , function iteratorHandler ( error , result )
{
if ( error )
{
callback ( error , result ) ;
return ;
}
2021-01-24 07:52:05 -05:00
2022-11-03 16:35:53 -04:00
state . index ++ ;
// are we there yet?
if ( state . index < ( state [ 'keyedList' ] || list ) . length )
{
iterate ( list , iterator , state , iteratorHandler ) ;
return ;
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
// done here
callback ( null , state . results ) ;
} ) ;
return terminator . bind ( state , callback ) ;
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
/ *
* -- Sort methods
* /
2022-02-09 22:14:07 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* sort helper to sort array elements in ascending order
2022-02-09 22:14:07 -05:00
*
2022-11-03 16:35:53 -04:00
* @ param { mixed } a - an item to compare
* @ param { mixed } b - an item to compare
* @ returns { number } - comparison result
2022-02-09 22:14:07 -05:00
* /
2022-11-03 16:35:53 -04:00
function ascending ( a , b )
{
return a < b ? - 1 : a > b ? 1 : 0 ;
2022-02-09 22:14:07 -05:00
}
2021-03-19 12:28:53 -04:00
/ * *
2022-11-03 16:35:53 -04:00
* sort helper to sort array elements in descending order
2021-03-19 12:28:53 -04:00
*
2022-11-03 16:35:53 -04:00
* @ param { mixed } a - an item to compare
* @ param { mixed } b - an item to compare
* @ returns { number } - comparison result
2021-03-19 12:28:53 -04:00
* /
2022-11-03 16:35:53 -04:00
function descending ( a , b )
{
return - 1 * ascending ( a , b ) ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
/***/ } ) ,
2020-07-30 12:27:27 -04:00
2022-11-03 16:35:53 -04:00
/***/ 5443 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
2020-07-30 12:27:27 -04:00
2022-11-03 16:35:53 -04:00
var util = _ _nccwpck _require _ _ ( 3837 ) ;
var Stream = ( _ _nccwpck _require _ _ ( 2781 ) . Stream ) ;
var DelayedStream = _ _nccwpck _require _ _ ( 8611 ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
module . exports = CombinedStream ;
function CombinedStream ( ) {
this . writable = false ;
this . readable = true ;
this . dataSize = 0 ;
this . maxDataSize = 2 * 1024 * 1024 ;
this . pauseStreams = true ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
this . _released = false ;
this . _streams = [ ] ;
this . _currentStream = null ;
this . _insideLoop = false ;
this . _pendingNext = false ;
}
util . inherits ( CombinedStream , Stream ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
CombinedStream . create = function ( options ) {
var combinedStream = new this ( ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
options = options || { } ;
for ( var option in options ) {
combinedStream [ option ] = options [ option ] ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
return combinedStream ;
} ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
CombinedStream . isStreamLike = function ( stream ) {
return ( typeof stream !== 'function' )
&& ( typeof stream !== 'string' )
&& ( typeof stream !== 'boolean' )
&& ( typeof stream !== 'number' )
&& ( ! Buffer . isBuffer ( stream ) ) ;
} ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
CombinedStream . prototype . append = function ( stream ) {
var isStreamLike = CombinedStream . isStreamLike ( stream ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( isStreamLike ) {
if ( ! ( stream instanceof DelayedStream ) ) {
var newStream = DelayedStream . create ( stream , {
maxDataSize : Infinity ,
pauseStream : this . pauseStreams ,
} ) ;
stream . on ( 'data' , this . _checkDataSize . bind ( this ) ) ;
stream = newStream ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
this . _handleErrors ( stream ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( this . pauseStreams ) {
stream . pause ( ) ;
}
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
this . _streams . push ( stream ) ;
return this ;
} ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
CombinedStream . prototype . pipe = function ( dest , options ) {
Stream . prototype . pipe . call ( this , dest , options ) ;
this . resume ( ) ;
return dest ;
2020-02-24 04:23:15 -05:00
} ;
2022-11-03 16:35:53 -04:00
CombinedStream . prototype . _getNext = function ( ) {
this . _currentStream = null ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( this . _insideLoop ) {
this . _pendingNext = true ;
return ; // defer call
}
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
this . _insideLoop = true ;
try {
do {
this . _pendingNext = false ;
this . _realGetNext ( ) ;
} while ( this . _pendingNext ) ;
} finally {
this . _insideLoop = false ;
}
} ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
CombinedStream . prototype . _realGetNext = function ( ) {
var stream = this . _streams . shift ( ) ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
if ( typeof stream == 'undefined' ) {
this . end ( ) ;
return ;
}
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
if ( typeof stream !== 'function' ) {
this . _pipeNext ( stream ) ;
return ;
}
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
var getStream = stream ;
getStream ( function ( stream ) {
var isStreamLike = CombinedStream . isStreamLike ( stream ) ;
if ( isStreamLike ) {
stream . on ( 'data' , this . _checkDataSize . bind ( this ) ) ;
this . _handleErrors ( stream ) ;
}
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
this . _pipeNext ( stream ) ;
} . bind ( this ) ) ;
} ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
CombinedStream . prototype . _pipeNext = function ( stream ) {
this . _currentStream = stream ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
var isStreamLike = CombinedStream . isStreamLike ( stream ) ;
if ( isStreamLike ) {
stream . on ( 'end' , this . _getNext . bind ( this ) ) ;
stream . pipe ( this , { end : false } ) ;
return ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
var value = stream ;
this . write ( value ) ;
this . _getNext ( ) ;
} ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
CombinedStream . prototype . _handleErrors = function ( stream ) {
var self = this ;
stream . on ( 'error' , function ( err ) {
self . _emitError ( err ) ;
} ) ;
} ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
CombinedStream . prototype . write = function ( data ) {
this . emit ( 'data' , data ) ;
} ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
CombinedStream . prototype . pause = function ( ) {
if ( ! this . pauseStreams ) {
return ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( this . pauseStreams && this . _currentStream && typeof ( this . _currentStream . pause ) == 'function' ) this . _currentStream . pause ( ) ;
this . emit ( 'pause' ) ;
} ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
CombinedStream . prototype . resume = function ( ) {
if ( ! this . _released ) {
this . _released = true ;
this . writable = true ;
this . _getNext ( ) ;
}
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
if ( this . pauseStreams && this . _currentStream && typeof ( this . _currentStream . resume ) == 'function' ) this . _currentStream . resume ( ) ;
this . emit ( 'resume' ) ;
} ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
CombinedStream . prototype . end = function ( ) {
this . _reset ( ) ;
this . emit ( 'end' ) ;
} ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
CombinedStream . prototype . destroy = function ( ) {
this . _reset ( ) ;
this . emit ( 'close' ) ;
} ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
CombinedStream . prototype . _reset = function ( ) {
this . writable = false ;
this . _streams = [ ] ;
this . _currentStream = null ;
} ;
CombinedStream . prototype . _checkDataSize = function ( ) {
this . _updateDataSize ( ) ;
if ( this . dataSize <= this . maxDataSize ) {
return ;
2022-10-05 11:29:30 -04:00
}
2022-11-03 16:35:53 -04:00
var message =
'DelayedStream#maxDataSize of ' + this . maxDataSize + ' bytes exceeded.' ;
this . _emitError ( new Error ( message ) ) ;
} ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
CombinedStream . prototype . _updateDataSize = function ( ) {
this . dataSize = 0 ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
var self = this ;
this . _streams . forEach ( function ( stream ) {
if ( ! stream . dataSize ) {
return ;
}
self . dataSize += stream . dataSize ;
} ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( this . _currentStream && this . _currentStream . dataSize ) {
this . dataSize += this . _currentStream . dataSize ;
}
} ;
2022-01-16 11:27:57 -05:00
2022-11-03 16:35:53 -04:00
CombinedStream . prototype . _emitError = function ( err ) {
this . _reset ( ) ;
this . emit ( 'error' , err ) ;
} ;
2020-02-24 04:23:15 -05:00
2022-10-05 11:29:30 -04:00
/***/ } ) ,
2022-11-03 16:35:53 -04:00
/***/ 8611 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
var Stream = ( _ _nccwpck _require _ _ ( 2781 ) . Stream ) ;
var util = _ _nccwpck _require _ _ ( 3837 ) ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
module . exports = DelayedStream ;
function DelayedStream ( ) {
this . source = null ;
this . dataSize = 0 ;
this . maxDataSize = 1024 * 1024 ;
this . pauseStream = true ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
this . _maxDataSizeExceeded = false ;
this . _released = false ;
this . _bufferedEvents = [ ] ;
}
util . inherits ( DelayedStream , Stream ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
DelayedStream . create = function ( source , options ) {
var delayedStream = new this ( ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
options = options || { } ;
for ( var option in options ) {
delayedStream [ option ] = options [ option ] ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
delayedStream . source = source ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
var realEmit = source . emit ;
source . emit = function ( ) {
delayedStream . _handleEmit ( arguments ) ;
return realEmit . apply ( source , arguments ) ;
} ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
source . on ( 'error' , function ( ) { } ) ;
if ( delayedStream . pauseStream ) {
source . pause ( ) ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
return delayedStream ;
} ;
Object . defineProperty ( DelayedStream . prototype , 'readable' , {
configurable : true ,
enumerable : true ,
get : function ( ) {
return this . source . readable ;
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
} ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
DelayedStream . prototype . setEncoding = function ( ) {
return this . source . setEncoding . apply ( this . source , arguments ) ;
} ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
DelayedStream . prototype . resume = function ( ) {
if ( ! this . _released ) {
this . release ( ) ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
this . source . resume ( ) ;
} ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
DelayedStream . prototype . pause = function ( ) {
this . source . pause ( ) ;
} ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
DelayedStream . prototype . release = function ( ) {
this . _released = true ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
this . _bufferedEvents . forEach ( function ( args ) {
this . emit . apply ( this , args ) ;
} . bind ( this ) ) ;
this . _bufferedEvents = [ ] ;
2020-02-24 04:23:15 -05:00
} ;
2022-11-03 16:35:53 -04:00
DelayedStream . prototype . pipe = function ( ) {
var r = Stream . prototype . pipe . apply ( this , arguments ) ;
this . resume ( ) ;
return r ;
2022-07-19 04:27:31 -04:00
} ;
2022-11-03 16:35:53 -04:00
DelayedStream . prototype . _handleEmit = function ( args ) {
if ( this . _released ) {
this . emit . apply ( this , args ) ;
return ;
}
if ( args [ 0 ] === 'data' ) {
this . dataSize += args [ 1 ] . length ;
this . _checkIfMaxDataSizeExceeded ( ) ;
}
this . _bufferedEvents . push ( args ) ;
} ;
DelayedStream . prototype . _checkIfMaxDataSizeExceeded = function ( ) {
if ( this . _maxDataSizeExceeded ) {
return ;
}
if ( this . dataSize <= this . maxDataSize ) {
return ;
}
this . _maxDataSizeExceeded = true ;
var message =
'DelayedStream#maxDataSize of ' + this . maxDataSize + ' bytes exceeded.'
this . emit ( 'error' , new Error ( message ) ) ;
} ;
/***/ } ) ,
/***/ 1133 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
var debug ;
module . exports = function ( ) {
if ( ! debug ) {
try {
/* eslint global-require: off */
debug = _ _nccwpck _require _ _ ( 9975 ) ( "follow-redirects" ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
catch ( error ) { /* */ }
if ( typeof debug !== "function" ) {
debug = function ( ) { /* */ } ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
}
debug . apply ( null , arguments ) ;
} ;
/***/ } ) ,
/***/ 7707 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
var url = _ _nccwpck _require _ _ ( 7310 ) ;
var URL = url . URL ;
var http = _ _nccwpck _require _ _ ( 3685 ) ;
var https = _ _nccwpck _require _ _ ( 5687 ) ;
var Writable = ( _ _nccwpck _require _ _ ( 2781 ) . Writable ) ;
var assert = _ _nccwpck _require _ _ ( 9491 ) ;
var debug = _ _nccwpck _require _ _ ( 1133 ) ;
// Create handlers that pass events from native requests
var events = [ "abort" , "aborted" , "connect" , "error" , "socket" , "timeout" ] ;
var eventHandlers = Object . create ( null ) ;
events . forEach ( function ( event ) {
eventHandlers [ event ] = function ( arg1 , arg2 , arg3 ) {
this . _redirectable . emit ( event , arg1 , arg2 , arg3 ) ;
} ;
} ) ;
var InvalidUrlError = createErrorType (
"ERR_INVALID_URL" ,
"Invalid URL" ,
TypeError
) ;
// Error types with codes
var RedirectionError = createErrorType (
"ERR_FR_REDIRECTION_FAILURE" ,
"Redirected request failed"
) ;
var TooManyRedirectsError = createErrorType (
"ERR_FR_TOO_MANY_REDIRECTS" ,
"Maximum number of redirects exceeded"
) ;
var MaxBodyLengthExceededError = createErrorType (
"ERR_FR_MAX_BODY_LENGTH_EXCEEDED" ,
"Request body larger than maxBodyLength limit"
) ;
var WriteAfterEndError = createErrorType (
"ERR_STREAM_WRITE_AFTER_END" ,
"write after end"
) ;
// An HTTP(S) request that can be redirected
function RedirectableRequest ( options , responseCallback ) {
// Initialize the request
Writable . call ( this ) ;
this . _sanitizeOptions ( options ) ;
this . _options = options ;
this . _ended = false ;
this . _ending = false ;
this . _redirectCount = 0 ;
this . _redirects = [ ] ;
this . _requestBodyLength = 0 ;
this . _requestBodyBuffers = [ ] ;
// Attach a callback if passed
if ( responseCallback ) {
this . on ( "response" , responseCallback ) ;
}
// React to responses of native requests
var self = this ;
this . _onNativeResponse = function ( response ) {
self . _processResponse ( response ) ;
} ;
// Perform the first request
this . _performRequest ( ) ;
}
RedirectableRequest . prototype = Object . create ( Writable . prototype ) ;
RedirectableRequest . prototype . abort = function ( ) {
abortRequest ( this . _currentRequest ) ;
this . emit ( "abort" ) ;
} ;
// Writes buffered data to the current native request
RedirectableRequest . prototype . write = function ( data , encoding , callback ) {
// Writing is not allowed if end has been called
if ( this . _ending ) {
throw new WriteAfterEndError ( ) ;
}
// Validate input and shift parameters if necessary
if ( ! isString ( data ) && ! isBuffer ( data ) ) {
throw new TypeError ( "data should be a string, Buffer or Uint8Array" ) ;
}
if ( isFunction ( encoding ) ) {
callback = encoding ;
encoding = null ;
}
// Ignore empty buffers, since writing them doesn't invoke the callback
// https://github.com/nodejs/node/issues/22066
if ( data . length === 0 ) {
if ( callback ) {
callback ( ) ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
return ;
}
// Only write when we don't exceed the maximum body length
if ( this . _requestBodyLength + data . length <= this . _options . maxBodyLength ) {
this . _requestBodyLength += data . length ;
this . _requestBodyBuffers . push ( { data : data , encoding : encoding } ) ;
this . _currentRequest . write ( data , encoding , callback ) ;
}
// Error when we exceed the maximum body length
else {
this . emit ( "error" , new MaxBodyLengthExceededError ( ) ) ;
this . abort ( ) ;
}
} ;
// Ends the current native request
RedirectableRequest . prototype . end = function ( data , encoding , callback ) {
// Shift parameters if necessary
if ( isFunction ( data ) ) {
callback = data ;
data = encoding = null ;
}
else if ( isFunction ( encoding ) ) {
callback = encoding ;
encoding = null ;
}
// Write data if needed and end
if ( ! data ) {
this . _ended = this . _ending = true ;
this . _currentRequest . end ( null , null , callback ) ;
}
else {
var self = this ;
var currentRequest = this . _currentRequest ;
this . write ( data , encoding , function ( ) {
self . _ended = true ;
currentRequest . end ( null , null , callback ) ;
} ) ;
this . _ending = true ;
}
} ;
// Sets a header value on the current native request
RedirectableRequest . prototype . setHeader = function ( name , value ) {
this . _options . headers [ name ] = value ;
this . _currentRequest . setHeader ( name , value ) ;
} ;
// Clears a header value on the current native request
RedirectableRequest . prototype . removeHeader = function ( name ) {
delete this . _options . headers [ name ] ;
this . _currentRequest . removeHeader ( name ) ;
} ;
// Global timeout for all underlying requests
RedirectableRequest . prototype . setTimeout = function ( msecs , callback ) {
var self = this ;
// Destroys the socket on timeout
function destroyOnTimeout ( socket ) {
socket . setTimeout ( msecs ) ;
socket . removeListener ( "timeout" , socket . destroy ) ;
socket . addListener ( "timeout" , socket . destroy ) ;
}
// Sets up a timer to trigger a timeout event
function startTimer ( socket ) {
if ( self . _timeout ) {
clearTimeout ( self . _timeout ) ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
self . _timeout = setTimeout ( function ( ) {
self . emit ( "timeout" ) ;
clearTimer ( ) ;
} , msecs ) ;
destroyOnTimeout ( socket ) ;
}
// Stops a timeout from triggering
function clearTimer ( ) {
// Clear the timeout
if ( self . _timeout ) {
clearTimeout ( self . _timeout ) ;
self . _timeout = null ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
// Clean up all attached listeners
self . removeListener ( "abort" , clearTimer ) ;
self . removeListener ( "error" , clearTimer ) ;
self . removeListener ( "response" , clearTimer ) ;
if ( callback ) {
self . removeListener ( "timeout" , callback ) ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
if ( ! self . socket ) {
self . _currentRequest . removeListener ( "socket" , startTimer ) ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
}
// Attach callback if passed
if ( callback ) {
this . on ( "timeout" , callback ) ;
}
// Start the timer if or when the socket is opened
if ( this . socket ) {
startTimer ( this . socket ) ;
}
else {
this . _currentRequest . once ( "socket" , startTimer ) ;
}
// Clean up on events
this . on ( "socket" , destroyOnTimeout ) ;
this . on ( "abort" , clearTimer ) ;
this . on ( "error" , clearTimer ) ;
this . on ( "response" , clearTimer ) ;
return this ;
} ;
// Proxy all other public ClientRequest methods
[
"flushHeaders" , "getHeader" ,
"setNoDelay" , "setSocketKeepAlive" ,
] . forEach ( function ( method ) {
RedirectableRequest . prototype [ method ] = function ( a , b ) {
return this . _currentRequest [ method ] ( a , b ) ;
} ;
} ) ;
// Proxy all public ClientRequest properties
[ "aborted" , "connection" , "socket" ] . forEach ( function ( property ) {
Object . defineProperty ( RedirectableRequest . prototype , property , {
get : function ( ) { return this . _currentRequest [ property ] ; } ,
} ) ;
} ) ;
RedirectableRequest . prototype . _sanitizeOptions = function ( options ) {
// Ensure headers are always present
if ( ! options . headers ) {
options . headers = { } ;
}
// Since http.request treats host as an alias of hostname,
// but the url module interprets host as hostname plus port,
// eliminate the host property to avoid confusion.
if ( options . host ) {
// Use hostname if set, because it has precedence
if ( ! options . hostname ) {
options . hostname = options . host ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
delete options . host ;
}
// Complete the URL object when necessary
if ( ! options . pathname && options . path ) {
var searchPos = options . path . indexOf ( "?" ) ;
if ( searchPos < 0 ) {
options . pathname = options . path ;
}
else {
options . pathname = options . path . substring ( 0 , searchPos ) ;
options . search = options . path . substring ( searchPos ) ;
}
}
} ;
// Executes the next native request (initial or redirect)
RedirectableRequest . prototype . _performRequest = function ( ) {
// Load the native protocol
var protocol = this . _options . protocol ;
var nativeProtocol = this . _options . nativeProtocols [ protocol ] ;
if ( ! nativeProtocol ) {
this . emit ( "error" , new TypeError ( "Unsupported protocol " + protocol ) ) ;
return ;
}
// If specified, use the agent corresponding to the protocol
// (HTTP and HTTPS use different types of agents)
if ( this . _options . agents ) {
var scheme = protocol . slice ( 0 , - 1 ) ;
this . _options . agent = this . _options . agents [ scheme ] ;
}
// Create the native request and set up its event handlers
var request = this . _currentRequest =
nativeProtocol . request ( this . _options , this . _onNativeResponse ) ;
request . _redirectable = this ;
for ( var event of events ) {
request . on ( event , eventHandlers [ event ] ) ;
}
// RFC7230§5.3.1: When making a request directly to an origin server, […]
// a client MUST send only the absolute path […] as the request-target.
this . _currentUrl = /^\// . test ( this . _options . path ) ?
url . format ( this . _options ) :
// When making a request to a proxy, […]
// a client MUST send the target URI in absolute-form […].
this . _options . path ;
// End a redirected request
// (The first request must be ended explicitly with RedirectableRequest#end)
if ( this . _isRedirect ) {
// Write the request entity and end
var i = 0 ;
var self = this ;
var buffers = this . _requestBodyBuffers ;
( function writeNext ( error ) {
// Only write if this request has not been redirected yet
/* istanbul ignore else */
if ( request === self . _currentRequest ) {
// Report any write errors
/* istanbul ignore if */
if ( error ) {
self . emit ( "error" , error ) ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
// Write the next buffer if there are still left
else if ( i < buffers . length ) {
var buffer = buffers [ i ++ ] ;
/* istanbul ignore else */
if ( ! request . finished ) {
request . write ( buffer . data , buffer . encoding , writeNext ) ;
}
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
// End the request if `end` has been called on us
else if ( self . _ended ) {
request . end ( ) ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
}
} ( ) ) ;
}
} ;
// Processes a response from the current native request
RedirectableRequest . prototype . _processResponse = function ( response ) {
// Store the redirected response
var statusCode = response . statusCode ;
if ( this . _options . trackRedirects ) {
this . _redirects . push ( {
url : this . _currentUrl ,
headers : response . headers ,
statusCode : statusCode ,
} ) ;
}
// RFC7231§6.4: The 3xx (Redirection) class of status code indicates
// that further action needs to be taken by the user agent in order to
// fulfill the request. If a Location header field is provided,
// the user agent MAY automatically redirect its request to the URI
// referenced by the Location field value,
// even if the specific status code is not understood.
// If the response is not a redirect; return it as-is
var location = response . headers . location ;
if ( ! location || this . _options . followRedirects === false ||
statusCode < 300 || statusCode >= 400 ) {
response . responseUrl = this . _currentUrl ;
response . redirects = this . _redirects ;
this . emit ( "response" , response ) ;
// Clean up
this . _requestBodyBuffers = [ ] ;
return ;
}
// The response is a redirect, so abort the current request
abortRequest ( this . _currentRequest ) ;
// Discard the remainder of the response to avoid waiting for data
response . destroy ( ) ;
// RFC7231§6.4: A client SHOULD detect and intervene
// in cyclical redirections (i.e., "infinite" redirection loops).
if ( ++ this . _redirectCount > this . _options . maxRedirects ) {
this . emit ( "error" , new TooManyRedirectsError ( ) ) ;
return ;
}
// Store the request headers if applicable
var requestHeaders ;
var beforeRedirect = this . _options . beforeRedirect ;
if ( beforeRedirect ) {
requestHeaders = Object . assign ( {
// The Host header was set by nativeProtocol.request
Host : response . req . getHeader ( "host" ) ,
} , this . _options . headers ) ;
}
// RFC7231§6.4: Automatic redirection needs to done with
// care for methods not known to be safe, […]
// RFC7231§6.4.2– 3: For historical reasons, a user agent MAY change
// the request method from POST to GET for the subsequent request.
var method = this . _options . method ;
if ( ( statusCode === 301 || statusCode === 302 ) && this . _options . method === "POST" ||
// RFC7231§6.4.4: The 303 (See Other) status code indicates that
// the server is redirecting the user agent to a different resource […]
// A user agent can perform a retrieval request targeting that URI
// (a GET or HEAD request if using HTTP) […]
( statusCode === 303 ) && ! /^(?:GET|HEAD)$/ . test ( this . _options . method ) ) {
this . _options . method = "GET" ;
// Drop a possible entity and headers related to it
this . _requestBodyBuffers = [ ] ;
removeMatchingHeaders ( /^content-/i , this . _options . headers ) ;
}
// Drop the Host header, as the redirect might lead to a different host
var currentHostHeader = removeMatchingHeaders ( /^host$/i , this . _options . headers ) ;
// If the redirect is relative, carry over the host of the last request
var currentUrlParts = url . parse ( this . _currentUrl ) ;
var currentHost = currentHostHeader || currentUrlParts . host ;
var currentUrl = /^\w+:/ . test ( location ) ? this . _currentUrl :
url . format ( Object . assign ( currentUrlParts , { host : currentHost } ) ) ;
// Determine the URL of the redirection
var redirectUrl ;
try {
redirectUrl = url . resolve ( currentUrl , location ) ;
}
catch ( cause ) {
this . emit ( "error" , new RedirectionError ( { cause : cause } ) ) ;
return ;
}
// Create the redirected request
debug ( "redirecting to" , redirectUrl ) ;
this . _isRedirect = true ;
var redirectUrlParts = url . parse ( redirectUrl ) ;
Object . assign ( this . _options , redirectUrlParts ) ;
// Drop confidential headers when redirecting to a less secure protocol
// or to a different domain that is not a superdomain
if ( redirectUrlParts . protocol !== currentUrlParts . protocol &&
redirectUrlParts . protocol !== "https:" ||
redirectUrlParts . host !== currentHost &&
! isSubdomain ( redirectUrlParts . host , currentHost ) ) {
removeMatchingHeaders ( /^(?:authorization|cookie)$/i , this . _options . headers ) ;
}
// Evaluate the beforeRedirect callback
if ( isFunction ( beforeRedirect ) ) {
var responseDetails = {
headers : response . headers ,
statusCode : statusCode ,
} ;
var requestDetails = {
url : currentUrl ,
method : method ,
headers : requestHeaders ,
} ;
try {
beforeRedirect ( this . _options , responseDetails , requestDetails ) ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
catch ( err ) {
this . emit ( "error" , err ) ;
return ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
this . _sanitizeOptions ( this . _options ) ;
}
// Perform the redirected request
try {
this . _performRequest ( ) ;
}
catch ( cause ) {
this . emit ( "error" , new RedirectionError ( { cause : cause } ) ) ;
}
} ;
// Wraps the key/value object of protocols with redirect functionality
function wrap ( protocols ) {
// Default settings
var exports = {
maxRedirects : 21 ,
maxBodyLength : 10 * 1024 * 1024 ,
} ;
// Wrap each protocol
var nativeProtocols = { } ;
Object . keys ( protocols ) . forEach ( function ( scheme ) {
var protocol = scheme + ":" ;
var nativeProtocol = nativeProtocols [ protocol ] = protocols [ scheme ] ;
var wrappedProtocol = exports [ scheme ] = Object . create ( nativeProtocol ) ;
// Executes a request, following redirects
function request ( input , options , callback ) {
// Parse parameters
if ( isString ( input ) ) {
var parsed ;
try {
parsed = urlToOptions ( new URL ( input ) ) ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
catch ( err ) {
/* istanbul ignore next */
parsed = url . parse ( input ) ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
if ( ! isString ( parsed . protocol ) ) {
throw new InvalidUrlError ( { input } ) ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
input = parsed ;
}
else if ( URL && ( input instanceof URL ) ) {
input = urlToOptions ( input ) ;
}
else {
callback = options ;
options = input ;
input = { protocol : protocol } ;
}
if ( isFunction ( options ) ) {
callback = options ;
options = null ;
}
// Set defaults
options = Object . assign ( {
maxRedirects : exports . maxRedirects ,
maxBodyLength : exports . maxBodyLength ,
} , input , options ) ;
options . nativeProtocols = nativeProtocols ;
if ( ! isString ( options . host ) && ! isString ( options . hostname ) ) {
options . hostname = "::1" ;
}
assert . equal ( options . protocol , protocol , "protocol mismatch" ) ;
debug ( "options" , options ) ;
return new RedirectableRequest ( options , callback ) ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
// Executes a GET request, following redirects
function get ( input , options , callback ) {
var wrappedRequest = wrappedProtocol . request ( input , options , callback ) ;
wrappedRequest . end ( ) ;
return wrappedRequest ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
// Expose the properties on the wrapped protocol
Object . defineProperties ( wrappedProtocol , {
request : { value : request , configurable : true , enumerable : true , writable : true } ,
get : { value : get , configurable : true , enumerable : true , writable : true } ,
} ) ;
} ) ;
return exports ;
}
/* istanbul ignore next */
function noop ( ) { /* empty */ }
// from https://github.com/nodejs/node/blob/master/lib/internal/url.js
function urlToOptions ( urlObject ) {
var options = {
protocol : urlObject . protocol ,
hostname : urlObject . hostname . startsWith ( "[" ) ?
/* istanbul ignore next */
urlObject . hostname . slice ( 1 , - 1 ) :
urlObject . hostname ,
hash : urlObject . hash ,
search : urlObject . search ,
pathname : urlObject . pathname ,
path : urlObject . pathname + urlObject . search ,
href : urlObject . href ,
} ;
if ( urlObject . port !== "" ) {
options . port = Number ( urlObject . port ) ;
}
return options ;
}
function removeMatchingHeaders ( regex , headers ) {
var lastValue ;
for ( var header in headers ) {
if ( regex . test ( header ) ) {
lastValue = headers [ header ] ;
delete headers [ header ] ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
}
return ( lastValue === null || typeof lastValue === "undefined" ) ?
undefined : String ( lastValue ) . trim ( ) ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
function createErrorType ( code , message , baseClass ) {
// Create constructor
function CustomError ( properties ) {
Error . captureStackTrace ( this , this . constructor ) ;
Object . assign ( this , properties || { } ) ;
this . code = code ;
this . message = this . cause ? message + ": " + this . cause . message : message ;
}
// Attach constructor and set default properties
CustomError . prototype = new ( baseClass || Error ) ( ) ;
CustomError . prototype . constructor = CustomError ;
CustomError . prototype . name = "Error [" + code + "]" ;
return CustomError ;
}
function abortRequest ( request ) {
for ( var event of events ) {
request . removeListener ( event , eventHandlers [ event ] ) ;
}
request . on ( "error" , noop ) ;
request . abort ( ) ;
}
function isSubdomain ( subdomain , domain ) {
assert ( isString ( subdomain ) && isString ( domain ) ) ;
var dot = subdomain . length - domain . length - 1 ;
return dot > 0 && subdomain [ dot ] === "." && subdomain . endsWith ( domain ) ;
}
function isString ( value ) {
return typeof value === "string" || value instanceof String ;
}
function isFunction ( value ) {
return typeof value === "function" ;
}
function isBuffer ( value ) {
return typeof value === "object" && ( "length" in value ) ;
}
// Exports
module . exports = wrap ( { http : http , https : https } ) ;
module . exports . wrap = wrap ;
/***/ } ) ,
/***/ 4334 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
var CombinedStream = _ _nccwpck _require _ _ ( 5443 ) ;
var util = _ _nccwpck _require _ _ ( 3837 ) ;
var path = _ _nccwpck _require _ _ ( 1017 ) ;
var http = _ _nccwpck _require _ _ ( 3685 ) ;
var https = _ _nccwpck _require _ _ ( 5687 ) ;
var parseUrl = ( _ _nccwpck _require _ _ ( 7310 ) . parse ) ;
var fs = _ _nccwpck _require _ _ ( 7147 ) ;
var Stream = ( _ _nccwpck _require _ _ ( 2781 ) . Stream ) ;
var mime = _ _nccwpck _require _ _ ( 3583 ) ;
var asynckit = _ _nccwpck _require _ _ ( 4812 ) ;
var populate = _ _nccwpck _require _ _ ( 7142 ) ;
// Public API
module . exports = FormData ;
// make it a Stream
util . inherits ( FormData , CombinedStream ) ;
/ * *
* Create readable "multipart/form-data" streams .
* Can be used to submit forms
* and file uploads to other web applications .
*
* @ constructor
* @ param { Object } options - Properties to be added / overriden for FormData and CombinedStream
* /
function FormData ( options ) {
if ( ! ( this instanceof FormData ) ) {
return new FormData ( options ) ;
}
this . _overheadLength = 0 ;
this . _valueLength = 0 ;
this . _valuesToMeasure = [ ] ;
CombinedStream . call ( this ) ;
options = options || { } ;
for ( var option in options ) {
this [ option ] = options [ option ] ;
}
}
FormData . LINE _BREAK = '\r\n' ;
FormData . DEFAULT _CONTENT _TYPE = 'application/octet-stream' ;
FormData . prototype . append = function ( field , value , options ) {
options = options || { } ;
// allow filename as single option
if ( typeof options == 'string' ) {
options = { filename : options } ;
}
var append = CombinedStream . prototype . append . bind ( this ) ;
// all that streamy business can't handle numbers
if ( typeof value == 'number' ) {
value = '' + value ;
}
// https://github.com/felixge/node-form-data/issues/38
if ( util . isArray ( value ) ) {
// Please convert your array into string
// the way web server expects it
this . _error ( new Error ( 'Arrays are not supported.' ) ) ;
return ;
}
var header = this . _multiPartHeader ( field , value , options ) ;
var footer = this . _multiPartFooter ( ) ;
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
append ( header ) ;
append ( value ) ;
append ( footer ) ;
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
// pass along options.knownLength
this . _trackLength ( header , value , options ) ;
} ;
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
FormData . prototype . _trackLength = function ( header , value , options ) {
var valueLength = 0 ;
// used w/ getLengthSync(), when length is known.
// e.g. for streaming directly from a remote server,
// w/ a known file a size, and not wanting to wait for
// incoming file to finish to get its size.
if ( options . knownLength != null ) {
valueLength += + options . knownLength ;
} else if ( Buffer . isBuffer ( value ) ) {
valueLength = value . length ;
} else if ( typeof value === 'string' ) {
valueLength = Buffer . byteLength ( value ) ;
}
this . _valueLength += valueLength ;
// @check why add CRLF? does this account for custom/multiple CRLFs?
this . _overheadLength +=
Buffer . byteLength ( header ) +
FormData . LINE _BREAK . length ;
// empty or either doesn't have path or not an http response or not a stream
if ( ! value || ( ! value . path && ! ( value . readable && value . hasOwnProperty ( 'httpVersion' ) ) && ! ( value instanceof Stream ) ) ) {
return ;
}
// no need to bother with the length
if ( ! options . knownLength ) {
this . _valuesToMeasure . push ( value ) ;
}
2022-07-19 04:27:31 -04:00
} ;
2022-11-03 16:35:53 -04:00
FormData . prototype . _lengthRetriever = function ( value , callback ) {
if ( value . hasOwnProperty ( 'fd' ) ) {
// take read range into a account
// `end` = Infinity – > read file till the end
//
// TODO: Looks like there is bug in Node fs.createReadStream
// it doesn't respect `end` options without `start` options
// Fix it when node fixes it.
// https://github.com/joyent/node/issues/7819
if ( value . end != undefined && value . end != Infinity && value . start != undefined ) {
// when end specified
// no need to calculate range
// inclusive, starts with 0
callback ( null , value . end + 1 - ( value . start ? value . start : 0 ) ) ;
// not that fast snoopy
} else {
// still need to fetch file size from fs
fs . stat ( value . path , function ( err , stat ) {
var fileSize ;
if ( err ) {
callback ( err ) ;
return ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
// update final size based on the range options
fileSize = stat . size - ( value . start ? value . start : 0 ) ;
callback ( null , fileSize ) ;
} ) ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
// or http response
} else if ( value . hasOwnProperty ( 'httpVersion' ) ) {
callback ( null , + value . headers [ 'content-length' ] ) ;
// or request stream http://github.com/mikeal/request
} else if ( value . hasOwnProperty ( 'httpModule' ) ) {
// wait till response come back
value . on ( 'response' , function ( response ) {
value . pause ( ) ;
callback ( null , + response . headers [ 'content-length' ] ) ;
} ) ;
value . resume ( ) ;
// something else
} else {
callback ( 'Unknown stream' ) ;
}
} ;
FormData . prototype . _multiPartHeader = function ( field , value , options ) {
// custom header specified (as string)?
// it becomes responsible for boundary
// (e.g. to handle extra CRLFs on .NET servers)
if ( typeof options . header == 'string' ) {
return options . header ;
}
var contentDisposition = this . _getContentDisposition ( value , options ) ;
var contentType = this . _getContentType ( value , options ) ;
var contents = '' ;
var headers = {
// add custom disposition as third element or keep it two elements if not
'Content-Disposition' : [ 'form-data' , 'name="' + field + '"' ] . concat ( contentDisposition || [ ] ) ,
// if no content type. allow it to be empty array
'Content-Type' : [ ] . concat ( contentType || [ ] )
} ;
// allow custom headers.
if ( typeof options . header == 'object' ) {
populate ( headers , options . header ) ;
}
var header ;
for ( var prop in headers ) {
if ( ! headers . hasOwnProperty ( prop ) ) continue ;
header = headers [ prop ] ;
// skip nullish headers.
if ( header == null ) {
continue ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
// convert all headers to arrays.
if ( ! Array . isArray ( header ) ) {
header = [ header ] ;
}
// add non-empty headers.
if ( header . length ) {
contents += prop + ': ' + header . join ( '; ' ) + FormData . LINE _BREAK ;
}
}
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
return '--' + this . getBoundary ( ) + FormData . LINE _BREAK + contents + FormData . LINE _BREAK ;
} ;
FormData . prototype . _getContentDisposition = function ( value , options ) {
var filename
, contentDisposition
;
if ( typeof options . filepath === 'string' ) {
// custom filepath for relative paths
filename = path . normalize ( options . filepath ) . replace ( /\\/g , '/' ) ;
} else if ( options . filename || value . name || value . path ) {
// custom filename take precedence
// formidable and the browser add a name property
// fs- and request- streams have path property
filename = path . basename ( options . filename || value . name || value . path ) ;
} else if ( value . readable && value . hasOwnProperty ( 'httpVersion' ) ) {
// or try http response
filename = path . basename ( value . client . _httpMessage . path || '' ) ;
}
if ( filename ) {
contentDisposition = 'filename="' + filename + '"' ;
}
return contentDisposition ;
} ;
FormData . prototype . _getContentType = function ( value , options ) {
// use custom content-type above all
var contentType = options . contentType ;
2020-10-01 16:20:08 -04:00
2022-11-03 16:35:53 -04:00
// or try `name` from formidable, browser
if ( ! contentType && value . name ) {
contentType = mime . lookup ( value . name ) ;
}
2020-10-01 16:20:08 -04:00
2022-11-03 16:35:53 -04:00
// or try `path` from fs-, request- streams
if ( ! contentType && value . path ) {
contentType = mime . lookup ( value . path ) ;
}
2020-10-01 16:20:08 -04:00
2022-11-03 16:35:53 -04:00
// or if it's http-reponse
if ( ! contentType && value . readable && value . hasOwnProperty ( 'httpVersion' ) ) {
contentType = value . headers [ 'content-type' ] ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
// or guess it from the filepath or filename
if ( ! contentType && ( options . filepath || options . filename ) ) {
contentType = mime . lookup ( options . filepath || options . filename ) ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
// fallback to the default content type if `value` is not simple value
if ( ! contentType && typeof value == 'object' ) {
contentType = FormData . DEFAULT _CONTENT _TYPE ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
return contentType ;
} ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
FormData . prototype . _multiPartFooter = function ( ) {
return function ( next ) {
var footer = FormData . LINE _BREAK ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
var lastPart = ( this . _streams . length === 0 ) ;
if ( lastPart ) {
footer += this . _lastBoundary ( ) ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
next ( footer ) ;
} . bind ( this ) ;
} ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
FormData . prototype . _lastBoundary = function ( ) {
return '--' + this . getBoundary ( ) + '--' + FormData . LINE _BREAK ;
} ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
FormData . prototype . getHeaders = function ( userHeaders ) {
var header ;
var formHeaders = {
'content-type' : 'multipart/form-data; boundary=' + this . getBoundary ( )
} ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
for ( header in userHeaders ) {
if ( userHeaders . hasOwnProperty ( header ) ) {
formHeaders [ header . toLowerCase ( ) ] = userHeaders [ header ] ;
}
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
return formHeaders ;
} ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
FormData . prototype . setBoundary = function ( boundary ) {
this . _boundary = boundary ;
} ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
FormData . prototype . getBoundary = function ( ) {
if ( ! this . _boundary ) {
this . _generateBoundary ( ) ;
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
return this . _boundary ;
} ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
FormData . prototype . getBuffer = function ( ) {
var dataBuffer = new Buffer . alloc ( 0 ) ;
var boundary = this . getBoundary ( ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
// Create the form content. Add Line breaks to the end of data.
for ( var i = 0 , len = this . _streams . length ; i < len ; i ++ ) {
if ( typeof this . _streams [ i ] !== 'function' ) {
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
// Add content to the buffer.
if ( Buffer . isBuffer ( this . _streams [ i ] ) ) {
dataBuffer = Buffer . concat ( [ dataBuffer , this . _streams [ i ] ] ) ;
} else {
dataBuffer = Buffer . concat ( [ dataBuffer , Buffer . from ( this . _streams [ i ] ) ] ) ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
// Add break after content.
if ( typeof this . _streams [ i ] !== 'string' || this . _streams [ i ] . substring ( 2 , boundary . length + 2 ) !== boundary ) {
dataBuffer = Buffer . concat ( [ dataBuffer , Buffer . from ( FormData . LINE _BREAK ) ] ) ;
}
}
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
// Add the footer and return the Buffer object.
return Buffer . concat ( [ dataBuffer , Buffer . from ( this . _lastBoundary ( ) ) ] ) ;
} ;
FormData . prototype . _generateBoundary = function ( ) {
// This generates a 50 character boundary similar to those used by Firefox.
// They are optimized for boyer-moore parsing.
var boundary = '--------------------------' ;
for ( var i = 0 ; i < 24 ; i ++ ) {
boundary += Math . floor ( Math . random ( ) * 10 ) . toString ( 16 ) ;
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
this . _boundary = boundary ;
} ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
// Note: getLengthSync DOESN'T calculate streams length
// As workaround one can calculate file size manually
// and add it as knownLength option
FormData . prototype . getLengthSync = function ( ) {
var knownLength = this . _overheadLength + this . _valueLength ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
// Don't get confused, there are 3 "internal" streams for each keyval pair
// so it basically checks if there is any value added to the form
if ( this . _streams . length ) {
knownLength += this . _lastBoundary ( ) . length ;
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
// https://github.com/form-data/form-data/issues/40
if ( ! this . hasKnownLength ( ) ) {
// Some async length retrievers are present
// therefore synchronous length calculation is false.
// Please use getLength(callback) to get proper length
this . _error ( new Error ( 'Cannot calculate proper length in synchronous way.' ) ) ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
return knownLength ;
} ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
// Public API to check if length of added values is known
// https://github.com/form-data/form-data/issues/196
// https://github.com/form-data/form-data/issues/262
FormData . prototype . hasKnownLength = function ( ) {
var hasKnownLength = true ;
if ( this . _valuesToMeasure . length ) {
hasKnownLength = false ;
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
return hasKnownLength ;
} ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
FormData . prototype . getLength = function ( cb ) {
var knownLength = this . _overheadLength + this . _valueLength ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
if ( this . _streams . length ) {
knownLength += this . _lastBoundary ( ) . length ;
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
if ( ! this . _valuesToMeasure . length ) {
process . nextTick ( cb . bind ( this , null , knownLength ) ) ;
return ;
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
asynckit . parallel ( this . _valuesToMeasure , this . _lengthRetriever , function ( err , values ) {
if ( err ) {
cb ( err ) ;
return ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
values . forEach ( function ( length ) {
knownLength += length ;
} ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
cb ( null , knownLength ) ;
} ) ;
} ;
FormData . prototype . submit = function ( params , cb ) {
var request
, options
, defaults = { method : 'post' }
;
// parse provided url if it's string
// or treat it as options object
if ( typeof params == 'string' ) {
params = parseUrl ( params ) ;
options = populate ( {
port : params . port ,
path : params . pathname ,
host : params . hostname ,
protocol : params . protocol
} , defaults ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
// use custom params
} else {
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
options = populate ( params , defaults ) ;
// if no port provided use default one
if ( ! options . port ) {
options . port = options . protocol == 'https:' ? 443 : 80 ;
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
// put that good code in getHeaders to some use
options . headers = this . getHeaders ( params . headers ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
// https if specified, fallback to http in any other case
if ( options . protocol == 'https:' ) {
request = https . request ( options ) ;
} else {
request = http . request ( options ) ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
// get content length and fire away
this . getLength ( function ( err , length ) {
if ( err && err !== 'Unknown stream' ) {
this . _error ( err ) ;
return ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
// add content length
if ( length ) {
request . setHeader ( 'Content-Length' , length ) ;
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
this . pipe ( request ) ;
if ( cb ) {
var onResponse ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
var callback = function ( error , responce ) {
request . removeListener ( 'error' , callback ) ;
request . removeListener ( 'response' , onResponse ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
return cb . call ( this , error , responce ) ;
} ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
onResponse = callback . bind ( this , null ) ;
2021-03-19 12:28:53 -04:00
2022-11-03 16:35:53 -04:00
request . on ( 'error' , callback ) ;
request . on ( 'response' , onResponse ) ;
2021-03-19 12:28:53 -04:00
}
2022-11-03 16:35:53 -04:00
} . bind ( this ) ) ;
return request ;
} ;
FormData . prototype . _error = function ( err ) {
if ( ! this . error ) {
this . error = err ;
this . pause ( ) ;
this . emit ( 'error' , err ) ;
2021-03-19 12:28:53 -04:00
}
2022-11-03 16:35:53 -04:00
} ;
FormData . prototype . toString = function ( ) {
return '[object FormData]' ;
2021-03-19 12:28:53 -04:00
} ;
2021-01-24 07:14:13 -05:00
2022-10-05 11:29:30 -04:00
/***/ } ) ,
2022-11-03 16:35:53 -04:00
/***/ 7142 :
/***/ ( ( module ) => {
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
// populates missing values
module . exports = function ( dst , src ) {
Object . keys ( src ) . forEach ( function ( prop )
{
dst [ prop ] = dst [ prop ] || src [ prop ] ;
} ) ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
return dst ;
} ;
2022-10-05 11:29:30 -04:00
2021-01-24 07:14:13 -05:00
/***/ } ) ,
2022-11-03 16:35:53 -04:00
/***/ 7426 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
/ * !
* mime - db
* Copyright ( c ) 2014 Jonathan Ong
* Copyright ( c ) 2015 - 2022 Douglas Christopher Wilson
* MIT Licensed
2021-09-09 08:42:30 -04:00
* /
2022-11-03 16:35:53 -04:00
2021-09-09 08:42:30 -04:00
/ * *
2022-11-03 16:35:53 -04:00
* Module exports .
2021-09-09 08:42:30 -04:00
* /
2022-11-03 16:35:53 -04:00
module . exports = _ _nccwpck _require _ _ ( 3765 )
/***/ } ) ,
/***/ 3583 :
/***/ ( ( _ _unused _webpack _module , exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
/ * !
* mime - types
* Copyright ( c ) 2014 Jonathan Ong
* Copyright ( c ) 2015 Douglas Christopher Wilson
* MIT Licensed
* /
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Module dependencies .
* @ private
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
var db = _ _nccwpck _require _ _ ( 7426 )
var extname = ( _ _nccwpck _require _ _ ( 1017 ) . extname )
2020-10-01 16:20:08 -04:00
/ * *
2022-11-03 16:35:53 -04:00
* Module variables .
* @ private
2020-10-01 16:20:08 -04:00
* /
2022-11-03 16:35:53 -04:00
var EXTRACT _TYPE _REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/
var TEXT _TYPE _REGEXP = /^text\//i
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Module exports .
* @ public
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
exports . charset = charset
exports . charsets = { lookup : charset }
exports . contentType = contentType
exports . extension = extension
exports . extensions = Object . create ( null )
exports . lookup = lookup
exports . types = Object . create ( null )
// Populate the extensions/types maps
populateMaps ( exports . extensions , exports . types )
2020-10-01 16:20:08 -04:00
/ * *
2022-11-03 16:35:53 -04:00
* Get the default charset for a MIME type .
*
* @ param { string } type
* @ return { boolean | string }
2020-10-01 16:20:08 -04:00
* /
2022-11-03 16:35:53 -04:00
function charset ( type ) {
if ( ! type || typeof type !== 'string' ) {
return false
}
// TODO: use media-typer
var match = EXTRACT _TYPE _REGEXP . exec ( type )
var mime = match && db [ match [ 1 ] . toLowerCase ( ) ]
if ( mime && mime . charset ) {
return mime . charset
}
// default text/* to utf-8
if ( match && TEXT _TYPE _REGEXP . test ( match [ 1 ] ) ) {
return 'UTF-8'
}
return false
2020-10-01 16:20:08 -04:00
}
2022-11-03 16:35:53 -04:00
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Create a full Content - Type header given a MIME type or extension .
*
* @ param { string } str
* @ return { boolean | string }
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
function contentType ( str ) {
// TODO: should this even be in this module?
if ( ! str || typeof str !== 'string' ) {
return false
}
var mime = str . indexOf ( '/' ) === - 1
? exports . lookup ( str )
: str
if ( ! mime ) {
return false
}
// TODO: use content-type or other module
if ( mime . indexOf ( 'charset' ) === - 1 ) {
var charset = exports . charset ( mime )
if ( charset ) mime += '; charset=' + charset . toLowerCase ( )
}
return mime
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Get the default extension for a MIME type .
*
* @ param { string } type
* @ return { boolean | string }
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
function extension ( type ) {
if ( ! type || typeof type !== 'string' ) {
return false
}
// TODO: use media-typer
var match = EXTRACT _TYPE _REGEXP . exec ( type )
// get extensions
var exts = match && exports . extensions [ match [ 1 ] . toLowerCase ( ) ]
if ( ! exts || ! exts . length ) {
return false
}
return exts [ 0 ]
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Lookup the MIME type for a file path / extension .
*
* @ param { string } path
* @ return { boolean | string }
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
function lookup ( path ) {
if ( ! path || typeof path !== 'string' ) {
return false
}
// get the extension ("ext" or ".ext" or full path)
var extension = extname ( 'x.' + path )
. toLowerCase ( )
. substr ( 1 )
if ( ! extension ) {
return false
}
return exports . types [ extension ] || false
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
2021-09-09 08:42:30 -04:00
/ * *
2022-11-03 16:35:53 -04:00
* Populate the extensions and types maps .
* @ private
2021-09-09 08:42:30 -04:00
* /
2022-11-03 16:35:53 -04:00
function populateMaps ( extensions , types ) {
// source preference (least -> most)
var preference = [ 'nginx' , 'apache' , undefined , 'iana' ]
Object . keys ( db ) . forEach ( function forEachMimeType ( type ) {
var mime = db [ type ]
var exts = mime . extensions
if ( ! exts || ! exts . length ) {
return
}
// mime -> extensions
extensions [ type ] = exts
// extension -> mime
for ( var i = 0 ; i < exts . length ; i ++ ) {
var extension = exts [ i ]
if ( types [ extension ] ) {
var from = preference . indexOf ( db [ types [ extension ] ] . source )
var to = preference . indexOf ( mime . source )
if ( types [ extension ] !== 'application/octet-stream' &&
( from > to || ( from === to && types [ extension ] . substr ( 0 , 12 ) === 'application/' ) ) ) {
// skip the remapping
continue
}
}
// set the extension -> mime
types [ extension ] = type
}
} )
2021-09-09 08:42:30 -04:00
}
2022-11-03 16:35:53 -04:00
/***/ } ) ,
/***/ 3329 :
/***/ ( ( _ _unused _webpack _module , exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
var parseUrl = ( _ _nccwpck _require _ _ ( 7310 ) . parse ) ;
var DEFAULT _PORTS = {
ftp : 21 ,
gopher : 70 ,
http : 80 ,
https : 443 ,
ws : 80 ,
wss : 443 ,
} ;
var stringEndsWith = String . prototype . endsWith || function ( s ) {
return s . length <= this . length &&
this . indexOf ( s , this . length - s . length ) !== - 1 ;
} ;
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* @ param { string | object } url - The URL , or the result from url . parse .
* @ return { string } The URL of the proxy that should handle the request to the
* given URL . If no proxy is set , this will be an empty string .
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
function getProxyForUrl ( url ) {
var parsedUrl = typeof url === 'string' ? parseUrl ( url ) : url || { } ;
var proto = parsedUrl . protocol ;
var hostname = parsedUrl . host ;
var port = parsedUrl . port ;
if ( typeof hostname !== 'string' || ! hostname || typeof proto !== 'string' ) {
return '' ; // Don't proxy URLs without a valid scheme or host.
}
proto = proto . split ( ':' , 1 ) [ 0 ] ;
// Stripping ports in this way instead of using parsedUrl.hostname to make
// sure that the brackets around IPv6 addresses are kept.
hostname = hostname . replace ( /:\d*$/ , '' ) ;
port = parseInt ( port ) || DEFAULT _PORTS [ proto ] || 0 ;
if ( ! shouldProxy ( hostname , port ) ) {
return '' ; // Don't proxy URLs that match NO_PROXY.
}
var proxy =
getEnv ( 'npm_config_' + proto + '_proxy' ) ||
getEnv ( proto + '_proxy' ) ||
getEnv ( 'npm_config_proxy' ) ||
getEnv ( 'all_proxy' ) ;
if ( proxy && proxy . indexOf ( '://' ) === - 1 ) {
// Missing scheme in proxy, default to the requested URL's scheme.
proxy = proto + '://' + proxy ;
}
return proxy ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Determines whether a given URL should be proxied .
2020-02-24 04:23:15 -05:00
*
2022-11-03 16:35:53 -04:00
* @ param { string } hostname - The host name of the URL .
* @ param { number } port - The effective port of the URL .
* @ returns { boolean } Whether the given URL should be proxied .
* @ private
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
function shouldProxy ( hostname , port ) {
var NO _PROXY =
( getEnv ( 'npm_config_no_proxy' ) || getEnv ( 'no_proxy' ) ) . toLowerCase ( ) ;
if ( ! NO _PROXY ) {
return true ; // Always proxy if NO_PROXY is not set.
}
if ( NO _PROXY === '*' ) {
return false ; // Never proxy if wildcard is set.
}
return NO _PROXY . split ( /[,\s]/ ) . every ( function ( proxy ) {
if ( ! proxy ) {
return true ; // Skip zero-length hosts.
}
var parsedProxy = proxy . match ( /^(.+):(\d+)$/ ) ;
var parsedProxyHostname = parsedProxy ? parsedProxy [ 1 ] : proxy ;
var parsedProxyPort = parsedProxy ? parseInt ( parsedProxy [ 2 ] ) : 0 ;
if ( parsedProxyPort && parsedProxyPort !== port ) {
return true ; // Skip if ports don't match.
}
if ( ! /^[.*]/ . test ( parsedProxyHostname ) ) {
// No wildcards, so stop proxying if there is an exact match.
return hostname !== parsedProxyHostname ;
}
if ( parsedProxyHostname . charAt ( 0 ) === '*' ) {
// Remove leading wildcard.
parsedProxyHostname = parsedProxyHostname . slice ( 1 ) ;
}
// Stop proxying if the hostname ends with the no_proxy host.
return ! stringEndsWith . call ( hostname , parsedProxyHostname ) ;
} ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Get the value for an environment variable .
*
* @ param { string } key - The name of the environment variable .
* @ return { string } The value of the environment variable .
* @ private
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
function getEnv ( key ) {
return process . env [ key . toLowerCase ( ) ] || process . env [ key . toUpperCase ( ) ] || '' ;
}
exports . getProxyForUrl = getProxyForUrl ;
/***/ } ) ,
/***/ 4294 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
module . exports = _ _nccwpck _require _ _ ( 4219 ) ;
/***/ } ) ,
/***/ 4219 :
/***/ ( ( _ _unused _webpack _module , exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
var net = _ _nccwpck _require _ _ ( 1808 ) ;
var tls = _ _nccwpck _require _ _ ( 4404 ) ;
var http = _ _nccwpck _require _ _ ( 3685 ) ;
var https = _ _nccwpck _require _ _ ( 5687 ) ;
var events = _ _nccwpck _require _ _ ( 2361 ) ;
var assert = _ _nccwpck _require _ _ ( 9491 ) ;
var util = _ _nccwpck _require _ _ ( 3837 ) ;
exports . httpOverHttp = httpOverHttp ;
exports . httpsOverHttp = httpsOverHttp ;
exports . httpOverHttps = httpOverHttps ;
exports . httpsOverHttps = httpsOverHttps ;
function httpOverHttp ( options ) {
var agent = new TunnelingAgent ( options ) ;
agent . request = http . request ;
return agent ;
}
function httpsOverHttp ( options ) {
var agent = new TunnelingAgent ( options ) ;
agent . request = http . request ;
agent . createSocket = createSecureSocket ;
agent . defaultPort = 443 ;
return agent ;
}
function httpOverHttps ( options ) {
var agent = new TunnelingAgent ( options ) ;
agent . request = https . request ;
return agent ;
}
function httpsOverHttps ( options ) {
var agent = new TunnelingAgent ( options ) ;
agent . request = https . request ;
agent . createSocket = createSecureSocket ;
agent . defaultPort = 443 ;
return agent ;
}
function TunnelingAgent ( options ) {
var self = this ;
self . options = options || { } ;
self . proxyOptions = self . options . proxy || { } ;
self . maxSockets = self . options . maxSockets || http . Agent . defaultMaxSockets ;
self . requests = [ ] ;
self . sockets = [ ] ;
self . on ( 'free' , function onFree ( socket , host , port , localAddress ) {
var options = toOptions ( host , port , localAddress ) ;
for ( var i = 0 , len = self . requests . length ; i < len ; ++ i ) {
var pending = self . requests [ i ] ;
if ( pending . host === options . host && pending . port === options . port ) {
// Detect the request to connect same origin server,
// reuse the connection.
self . requests . splice ( i , 1 ) ;
pending . request . onSocket ( socket ) ;
return ;
}
}
socket . destroy ( ) ;
self . removeSocket ( socket ) ;
} ) ;
}
util . inherits ( TunnelingAgent , events . EventEmitter ) ;
TunnelingAgent . prototype . addRequest = function addRequest ( req , host , port , localAddress ) {
var self = this ;
var options = mergeOptions ( { request : req } , self . options , toOptions ( host , port , localAddress ) ) ;
if ( self . sockets . length >= this . maxSockets ) {
// We are over limit so we'll add it to the queue.
self . requests . push ( options ) ;
return ;
}
// If we are under maxSockets create a new one.
self . createSocket ( options , function ( socket ) {
socket . on ( 'free' , onFree ) ;
socket . on ( 'close' , onCloseOrRemove ) ;
socket . on ( 'agentRemove' , onCloseOrRemove ) ;
req . onSocket ( socket ) ;
function onFree ( ) {
self . emit ( 'free' , socket , options ) ;
}
function onCloseOrRemove ( err ) {
self . removeSocket ( socket ) ;
socket . removeListener ( 'free' , onFree ) ;
socket . removeListener ( 'close' , onCloseOrRemove ) ;
socket . removeListener ( 'agentRemove' , onCloseOrRemove ) ;
}
} ) ;
} ;
TunnelingAgent . prototype . createSocket = function createSocket ( options , cb ) {
var self = this ;
var placeholder = { } ;
self . sockets . push ( placeholder ) ;
var connectOptions = mergeOptions ( { } , self . proxyOptions , {
method : 'CONNECT' ,
path : options . host + ':' + options . port ,
agent : false ,
headers : {
host : options . host + ':' + options . port
}
} ) ;
if ( options . localAddress ) {
connectOptions . localAddress = options . localAddress ;
}
if ( connectOptions . proxyAuth ) {
connectOptions . headers = connectOptions . headers || { } ;
connectOptions . headers [ 'Proxy-Authorization' ] = 'Basic ' +
new Buffer ( connectOptions . proxyAuth ) . toString ( 'base64' ) ;
}
debug ( 'making CONNECT request' ) ;
var connectReq = self . request ( connectOptions ) ;
connectReq . useChunkedEncodingByDefault = false ; // for v0.6
connectReq . once ( 'response' , onResponse ) ; // for v0.6
connectReq . once ( 'upgrade' , onUpgrade ) ; // for v0.6
connectReq . once ( 'connect' , onConnect ) ; // for v0.7 or later
connectReq . once ( 'error' , onError ) ;
connectReq . end ( ) ;
function onResponse ( res ) {
// Very hacky. This is necessary to avoid http-parser leaks.
res . upgrade = true ;
}
function onUpgrade ( res , socket , head ) {
// Hacky.
process . nextTick ( function ( ) {
onConnect ( res , socket , head ) ;
} ) ;
}
function onConnect ( res , socket , head ) {
connectReq . removeAllListeners ( ) ;
socket . removeAllListeners ( ) ;
if ( res . statusCode !== 200 ) {
debug ( 'tunneling socket could not be established, statusCode=%d' ,
res . statusCode ) ;
socket . destroy ( ) ;
var error = new Error ( 'tunneling socket could not be established, ' +
'statusCode=' + res . statusCode ) ;
error . code = 'ECONNRESET' ;
options . request . emit ( 'error' , error ) ;
self . removeSocket ( placeholder ) ;
return ;
}
if ( head . length > 0 ) {
debug ( 'got illegal response body from proxy' ) ;
socket . destroy ( ) ;
var error = new Error ( 'got illegal response body from proxy' ) ;
error . code = 'ECONNRESET' ;
options . request . emit ( 'error' , error ) ;
self . removeSocket ( placeholder ) ;
return ;
}
debug ( 'tunneling connection has established' ) ;
self . sockets [ self . sockets . indexOf ( placeholder ) ] = socket ;
return cb ( socket ) ;
}
function onError ( cause ) {
connectReq . removeAllListeners ( ) ;
debug ( 'tunneling socket could not be established, cause=%s\n' ,
cause . message , cause . stack ) ;
var error = new Error ( 'tunneling socket could not be established, ' +
'cause=' + cause . message ) ;
error . code = 'ECONNRESET' ;
options . request . emit ( 'error' , error ) ;
self . removeSocket ( placeholder ) ;
}
} ;
TunnelingAgent . prototype . removeSocket = function removeSocket ( socket ) {
var pos = this . sockets . indexOf ( socket )
if ( pos === - 1 ) {
return ;
}
this . sockets . splice ( pos , 1 ) ;
var pending = this . requests . shift ( ) ;
if ( pending ) {
// If we have pending requests and a socket gets closed a new one
// needs to be created to take over in the pool for the one that closed.
this . createSocket ( pending , function ( socket ) {
pending . request . onSocket ( socket ) ;
} ) ;
}
} ;
function createSecureSocket ( options , cb ) {
var self = this ;
TunnelingAgent . prototype . createSocket . call ( self , options , function ( socket ) {
var hostHeader = options . request . getHeader ( 'host' ) ;
var tlsOptions = mergeOptions ( { } , self . options , {
socket : socket ,
servername : hostHeader ? hostHeader . replace ( /:.*$/ , '' ) : options . host
} ) ;
// 0 is dummy port for v0.6
var secureSocket = tls . connect ( 0 , tlsOptions ) ;
self . sockets [ self . sockets . indexOf ( socket ) ] = secureSocket ;
cb ( secureSocket ) ;
} ) ;
}
function toOptions ( host , port , localAddress ) {
if ( typeof host === 'string' ) { // since v0.10
return {
host : host ,
port : port ,
localAddress : localAddress
} ;
}
return host ; // for v0.11 or later
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
function mergeOptions ( target ) {
for ( var i = 1 , len = arguments . length ; i < len ; ++ i ) {
var overrides = arguments [ i ] ;
if ( typeof overrides === 'object' ) {
var keys = Object . keys ( overrides ) ;
for ( var j = 0 , keyLen = keys . length ; j < keyLen ; ++ j ) {
var k = keys [ j ] ;
if ( overrides [ k ] !== undefined ) {
target [ k ] = overrides [ k ] ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
}
}
}
return target ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
var debug ;
if ( process . env . NODE _DEBUG && /\btunnel\b/ . test ( process . env . NODE _DEBUG ) ) {
debug = function ( ) {
var args = Array . prototype . slice . call ( arguments ) ;
if ( typeof args [ 0 ] === 'string' ) {
args [ 0 ] = 'TUNNEL: ' + args [ 0 ] ;
} else {
args . unshift ( 'TUNNEL:' ) ;
2022-10-05 11:29:30 -04:00
}
2022-11-03 16:35:53 -04:00
console . error . apply ( console , args ) ;
}
} else {
debug = function ( ) { } ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
exports . debug = debug ; // for test
/***/ } ) ,
/***/ 5840 :
/***/ ( ( _ _unused _webpack _module , exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , ( {
value : true
} ) ) ;
Object . defineProperty ( exports , "v1" , ( {
enumerable : true ,
get : function ( ) {
return _v . default ;
}
} ) ) ;
Object . defineProperty ( exports , "v3" , ( {
enumerable : true ,
get : function ( ) {
return _v2 . default ;
}
} ) ) ;
Object . defineProperty ( exports , "v4" , ( {
enumerable : true ,
get : function ( ) {
return _v3 . default ;
}
} ) ) ;
Object . defineProperty ( exports , "v5" , ( {
enumerable : true ,
get : function ( ) {
return _v4 . default ;
}
} ) ) ;
Object . defineProperty ( exports , "NIL" , ( {
enumerable : true ,
get : function ( ) {
return _nil . default ;
}
} ) ) ;
Object . defineProperty ( exports , "version" , ( {
enumerable : true ,
get : function ( ) {
return _version . default ;
}
} ) ) ;
Object . defineProperty ( exports , "validate" , ( {
enumerable : true ,
get : function ( ) {
return _validate . default ;
}
} ) ) ;
Object . defineProperty ( exports , "stringify" , ( {
enumerable : true ,
get : function ( ) {
return _stringify . default ;
}
} ) ) ;
Object . defineProperty ( exports , "parse" , ( {
enumerable : true ,
get : function ( ) {
return _parse . default ;
}
} ) ) ;
var _v = _interopRequireDefault ( _ _nccwpck _require _ _ ( 8628 ) ) ;
var _v2 = _interopRequireDefault ( _ _nccwpck _require _ _ ( 6409 ) ) ;
var _v3 = _interopRequireDefault ( _ _nccwpck _require _ _ ( 5122 ) ) ;
var _v4 = _interopRequireDefault ( _ _nccwpck _require _ _ ( 9120 ) ) ;
var _nil = _interopRequireDefault ( _ _nccwpck _require _ _ ( 5332 ) ) ;
var _version = _interopRequireDefault ( _ _nccwpck _require _ _ ( 1595 ) ) ;
var _validate = _interopRequireDefault ( _ _nccwpck _require _ _ ( 6900 ) ) ;
var _stringify = _interopRequireDefault ( _ _nccwpck _require _ _ ( 8950 ) ) ;
var _parse = _interopRequireDefault ( _ _nccwpck _require _ _ ( 2746 ) ) ;
function _interopRequireDefault ( obj ) { return obj && obj . _ _esModule ? obj : { default : obj } ; }
/***/ } ) ,
/***/ 4569 :
/***/ ( ( _ _unused _webpack _module , exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , ( {
value : true
} ) ) ;
exports [ "default" ] = void 0 ;
var _crypto = _interopRequireDefault ( _ _nccwpck _require _ _ ( 6113 ) ) ;
function _interopRequireDefault ( obj ) { return obj && obj . _ _esModule ? obj : { default : obj } ; }
function md5 ( bytes ) {
if ( Array . isArray ( bytes ) ) {
bytes = Buffer . from ( bytes ) ;
} else if ( typeof bytes === 'string' ) {
bytes = Buffer . from ( bytes , 'utf8' ) ;
}
return _crypto . default . createHash ( 'md5' ) . update ( bytes ) . digest ( ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
var _default = md5 ;
exports [ "default" ] = _default ;
/***/ } ) ,
/***/ 5332 :
/***/ ( ( _ _unused _webpack _module , exports ) => {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , ( {
value : true
} ) ) ;
exports [ "default" ] = void 0 ;
var _default = '00000000-0000-0000-0000-000000000000' ;
exports [ "default" ] = _default ;
/***/ } ) ,
/***/ 2746 :
/***/ ( ( _ _unused _webpack _module , exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , ( {
value : true
} ) ) ;
exports [ "default" ] = void 0 ;
var _validate = _interopRequireDefault ( _ _nccwpck _require _ _ ( 6900 ) ) ;
function _interopRequireDefault ( obj ) { return obj && obj . _ _esModule ? obj : { default : obj } ; }
function parse ( uuid ) {
if ( ! ( 0 , _validate . default ) ( uuid ) ) {
throw TypeError ( 'Invalid UUID' ) ;
}
let v ;
const arr = new Uint8Array ( 16 ) ; // Parse ########-....-....-....-............
arr [ 0 ] = ( v = parseInt ( uuid . slice ( 0 , 8 ) , 16 ) ) >>> 24 ;
arr [ 1 ] = v >>> 16 & 0xff ;
arr [ 2 ] = v >>> 8 & 0xff ;
arr [ 3 ] = v & 0xff ; // Parse ........-####-....-....-............
arr [ 4 ] = ( v = parseInt ( uuid . slice ( 9 , 13 ) , 16 ) ) >>> 8 ;
arr [ 5 ] = v & 0xff ; // Parse ........-....-####-....-............
arr [ 6 ] = ( v = parseInt ( uuid . slice ( 14 , 18 ) , 16 ) ) >>> 8 ;
arr [ 7 ] = v & 0xff ; // Parse ........-....-....-####-............
arr [ 8 ] = ( v = parseInt ( uuid . slice ( 19 , 23 ) , 16 ) ) >>> 8 ;
arr [ 9 ] = v & 0xff ; // Parse ........-....-....-....-############
// (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
arr [ 10 ] = ( v = parseInt ( uuid . slice ( 24 , 36 ) , 16 ) ) / 0x10000000000 & 0xff ;
arr [ 11 ] = v / 0x100000000 & 0xff ;
arr [ 12 ] = v >>> 24 & 0xff ;
arr [ 13 ] = v >>> 16 & 0xff ;
arr [ 14 ] = v >>> 8 & 0xff ;
arr [ 15 ] = v & 0xff ;
return arr ;
}
var _default = parse ;
exports [ "default" ] = _default ;
/***/ } ) ,
/***/ 814 :
/***/ ( ( _ _unused _webpack _module , exports ) => {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , ( {
value : true
} ) ) ;
exports [ "default" ] = void 0 ;
var _default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i ;
exports [ "default" ] = _default ;
/***/ } ) ,
/***/ 807 :
/***/ ( ( _ _unused _webpack _module , exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , ( {
value : true
} ) ) ;
exports [ "default" ] = rng ;
var _crypto = _interopRequireDefault ( _ _nccwpck _require _ _ ( 6113 ) ) ;
function _interopRequireDefault ( obj ) { return obj && obj . _ _esModule ? obj : { default : obj } ; }
const rnds8Pool = new Uint8Array ( 256 ) ; // # of random values to pre-allocate
let poolPtr = rnds8Pool . length ;
function rng ( ) {
if ( poolPtr > rnds8Pool . length - 16 ) {
_crypto . default . randomFillSync ( rnds8Pool ) ;
poolPtr = 0 ;
}
return rnds8Pool . slice ( poolPtr , poolPtr += 16 ) ;
2022-01-16 11:27:57 -05:00
}
2020-02-24 04:23:15 -05:00
/***/ } ) ,
2022-11-03 16:35:53 -04:00
/***/ 5274 :
/***/ ( ( _ _unused _webpack _module , exports , _ _nccwpck _require _ _ ) => {
2022-10-05 11:29:30 -04:00
"use strict" ;
2022-11-03 16:35:53 -04:00
Object . defineProperty ( exports , "__esModule" , ( {
2022-10-05 11:29:30 -04:00
value : true
2022-11-03 16:35:53 -04:00
} ) ) ;
exports [ "default" ] = void 0 ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
var _crypto = _interopRequireDefault ( _ _nccwpck _require _ _ ( 6113 ) ) ;
2022-10-05 11:29:30 -04:00
function _interopRequireDefault ( obj ) { return obj && obj . _ _esModule ? obj : { default : obj } ; }
function sha1 ( bytes ) {
if ( Array . isArray ( bytes ) ) {
bytes = Buffer . from ( bytes ) ;
} else if ( typeof bytes === 'string' ) {
bytes = Buffer . from ( bytes , 'utf8' ) ;
}
return _crypto . default . createHash ( 'sha1' ) . update ( bytes ) . digest ( ) ;
}
var _default = sha1 ;
2022-11-03 16:35:53 -04:00
exports [ "default" ] = _default ;
2022-10-05 11:29:30 -04:00
/***/ } ) ,
2022-11-03 16:35:53 -04:00
/***/ 8950 :
/***/ ( ( _ _unused _webpack _module , exports , _ _nccwpck _require _ _ ) => {
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
"use strict" ;
Object . defineProperty ( exports , "__esModule" , ( {
value : true
} ) ) ;
exports [ "default" ] = void 0 ;
var _validate = _interopRequireDefault ( _ _nccwpck _require _ _ ( 6900 ) ) ;
function _interopRequireDefault ( obj ) { return obj && obj . _ _esModule ? obj : { default : obj } ; }
2021-01-24 07:14:13 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Convert array of 16 byte values to UUID string format of the form :
* XXXXXXXX - XXXX - XXXX - XXXX - XXXXXXXXXXXX
2021-01-24 07:14:13 -05:00
* /
2022-11-03 16:35:53 -04:00
const byteToHex = [ ] ;
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
for ( let i = 0 ; i < 256 ; ++ i ) {
byteToHex . push ( ( i + 0x100 ) . toString ( 16 ) . substr ( 1 ) ) ;
}
function stringify ( arr , offset = 0 ) {
// Note: Be careful editing this code! It's been tuned for performance
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
const uuid = ( byteToHex [ arr [ offset + 0 ] ] + byteToHex [ arr [ offset + 1 ] ] + byteToHex [ arr [ offset + 2 ] ] + byteToHex [ arr [ offset + 3 ] ] + '-' + byteToHex [ arr [ offset + 4 ] ] + byteToHex [ arr [ offset + 5 ] ] + '-' + byteToHex [ arr [ offset + 6 ] ] + byteToHex [ arr [ offset + 7 ] ] + '-' + byteToHex [ arr [ offset + 8 ] ] + byteToHex [ arr [ offset + 9 ] ] + '-' + byteToHex [ arr [ offset + 10 ] ] + byteToHex [ arr [ offset + 11 ] ] + byteToHex [ arr [ offset + 12 ] ] + byteToHex [ arr [ offset + 13 ] ] + byteToHex [ arr [ offset + 14 ] ] + byteToHex [ arr [ offset + 15 ] ] ) . toLowerCase ( ) ; // Consistency check for valid UUID. If this throws, it's likely due to one
// of the following:
// - One or more input array values don't map to a hex octet (leading to
// "undefined" in the uuid)
// - Invalid input values for the RFC `version` or `variant` fields
if ( ! ( 0 , _validate . default ) ( uuid ) ) {
throw TypeError ( 'Stringified UUID is invalid' ) ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
return uuid ;
}
var _default = stringify ;
exports [ "default" ] = _default ;
/***/ } ) ,
/***/ 8628 :
/***/ ( ( _ _unused _webpack _module , exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , ( {
value : true
} ) ) ;
exports [ "default" ] = void 0 ;
var _rng = _interopRequireDefault ( _ _nccwpck _require _ _ ( 807 ) ) ;
var _stringify = _interopRequireDefault ( _ _nccwpck _require _ _ ( 8950 ) ) ;
function _interopRequireDefault ( obj ) { return obj && obj . _ _esModule ? obj : { default : obj } ; }
// **`v1()` - Generate time-based UUID**
//
// Inspired by https://github.com/LiosK/UUID.js
// and http://docs.python.org/library/uuid.html
let _nodeId ;
let _clockseq ; // Previous uuid creation time
let _lastMSecs = 0 ;
let _lastNSecs = 0 ; // See https://github.com/uuidjs/uuid for API details
function v1 ( options , buf , offset ) {
let i = buf && offset || 0 ;
const b = buf || new Array ( 16 ) ;
options = options || { } ;
let node = options . node || _nodeId ;
let clockseq = options . clockseq !== undefined ? options . clockseq : _clockseq ; // node and clockseq need to be initialized to random values if they're not
// specified. We do this lazily to minimize issues related to insufficient
// system entropy. See #189
if ( node == null || clockseq == null ) {
const seedBytes = options . random || ( options . rng || _rng . default ) ( ) ;
if ( node == null ) {
// Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
node = _nodeId = [ seedBytes [ 0 ] | 0x01 , seedBytes [ 1 ] , seedBytes [ 2 ] , seedBytes [ 3 ] , seedBytes [ 4 ] , seedBytes [ 5 ] ] ;
}
if ( clockseq == null ) {
// Per 4.2.2, randomize (14 bit) clockseq
clockseq = _clockseq = ( seedBytes [ 6 ] << 8 | seedBytes [ 7 ] ) & 0x3fff ;
}
} // UUID timestamps are 100 nano-second units since the Gregorian epoch,
// (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
// time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
// (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
let msecs = options . msecs !== undefined ? options . msecs : Date . now ( ) ; // Per 4.2.1.2, use count of uuid's generated during the current clock
// cycle to simulate higher resolution clock
let nsecs = options . nsecs !== undefined ? options . nsecs : _lastNSecs + 1 ; // Time since last uuid creation (in msecs)
const dt = msecs - _lastMSecs + ( nsecs - _lastNSecs ) / 10000 ; // Per 4.2.1.2, Bump clockseq on clock regression
if ( dt < 0 && options . clockseq === undefined ) {
clockseq = clockseq + 1 & 0x3fff ;
} // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
// time interval
if ( ( dt < 0 || msecs > _lastMSecs ) && options . nsecs === undefined ) {
nsecs = 0 ;
} // Per 4.2.1.2 Throw error if too many uuids are requested
if ( nsecs >= 10000 ) {
throw new Error ( "uuid.v1(): Can't create more than 10M uuids/sec" ) ;
}
_lastMSecs = msecs ;
_lastNSecs = nsecs ;
_clockseq = clockseq ; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
msecs += 12219292800000 ; // `time_low`
const tl = ( ( msecs & 0xfffffff ) * 10000 + nsecs ) % 0x100000000 ;
b [ i ++ ] = tl >>> 24 & 0xff ;
b [ i ++ ] = tl >>> 16 & 0xff ;
b [ i ++ ] = tl >>> 8 & 0xff ;
b [ i ++ ] = tl & 0xff ; // `time_mid`
const tmh = msecs / 0x100000000 * 10000 & 0xfffffff ;
b [ i ++ ] = tmh >>> 8 & 0xff ;
b [ i ++ ] = tmh & 0xff ; // `time_high_and_version`
b [ i ++ ] = tmh >>> 24 & 0xf | 0x10 ; // include version
b [ i ++ ] = tmh >>> 16 & 0xff ; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
b [ i ++ ] = clockseq >>> 8 | 0x80 ; // `clock_seq_low`
b [ i ++ ] = clockseq & 0xff ; // `node`
for ( let n = 0 ; n < 6 ; ++ n ) {
b [ i + n ] = node [ n ] ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
return buf || ( 0 , _stringify . default ) ( b ) ;
2022-01-16 11:27:57 -05:00
}
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
var _default = v1 ;
exports [ "default" ] = _default ;
2022-07-19 04:27:31 -04:00
/***/ } ) ,
2022-11-03 16:35:53 -04:00
/***/ 6409 :
/***/ ( ( _ _unused _webpack _module , exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , ( {
value : true
} ) ) ;
exports [ "default" ] = void 0 ;
var _v = _interopRequireDefault ( _ _nccwpck _require _ _ ( 5998 ) ) ;
var _md = _interopRequireDefault ( _ _nccwpck _require _ _ ( 4569 ) ) ;
function _interopRequireDefault ( obj ) { return obj && obj . _ _esModule ? obj : { default : obj } ; }
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
const v3 = ( 0 , _v . default ) ( 'v3' , 0x30 , _md . default ) ;
var _default = v3 ;
exports [ "default" ] = _default ;
2022-07-19 04:27:31 -04:00
/***/ } ) ,
2022-11-03 16:35:53 -04:00
/***/ 5998 :
/***/ ( ( _ _unused _webpack _module , exports , _ _nccwpck _require _ _ ) => {
2022-07-19 04:27:31 -04:00
"use strict" ;
2022-11-03 16:35:53 -04:00
Object . defineProperty ( exports , "__esModule" , ( {
value : true
} ) ) ;
exports [ "default" ] = _default ;
exports . URL = exports . DNS = void 0 ;
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
var _stringify = _interopRequireDefault ( _ _nccwpck _require _ _ ( 8950 ) ) ;
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
var _parse = _interopRequireDefault ( _ _nccwpck _require _ _ ( 2746 ) ) ;
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
function _interopRequireDefault ( obj ) { return obj && obj . _ _esModule ? obj : { default : obj } ; }
function stringToBytes ( str ) {
str = unescape ( encodeURIComponent ( str ) ) ; // UTF8 escape
const bytes = [ ] ;
for ( let i = 0 ; i < str . length ; ++ i ) {
bytes . push ( str . charCodeAt ( i ) ) ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
return bytes ;
2022-01-16 11:27:57 -05:00
}
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8' ;
exports . DNS = DNS ;
const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8' ;
exports . URL = URL ;
function _default ( name , version , hashfunc ) {
function generateUUID ( value , namespace , buf , offset ) {
if ( typeof value === 'string' ) {
value = stringToBytes ( value ) ;
}
if ( typeof namespace === 'string' ) {
namespace = ( 0 , _parse . default ) ( namespace ) ;
}
if ( namespace . length !== 16 ) {
throw TypeError ( 'Namespace must be array-like (16 iterable integer values, 0-255)' ) ;
} // Compute hash of namespace and value, Per 4.3
// Future: Use spread syntax when supported on all platforms, e.g. `bytes =
// hashfunc([...namespace, ... value])`
let bytes = new Uint8Array ( 16 + value . length ) ;
bytes . set ( namespace ) ;
bytes . set ( value , namespace . length ) ;
bytes = hashfunc ( bytes ) ;
bytes [ 6 ] = bytes [ 6 ] & 0x0f | version ;
bytes [ 8 ] = bytes [ 8 ] & 0x3f | 0x80 ;
if ( buf ) {
offset = offset || 0 ;
for ( let i = 0 ; i < 16 ; ++ i ) {
buf [ offset + i ] = bytes [ i ] ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
return buf ;
2022-01-16 11:27:57 -05:00
}
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
return ( 0 , _stringify . default ) ( bytes ) ;
} // Function#name is not settable on some platforms (#270)
try {
generateUUID . name = name ; // eslint-disable-next-line no-empty
} catch ( err ) { } // For CommonJS default export support
generateUUID . DNS = DNS ;
generateUUID . URL = URL ;
return generateUUID ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
/***/ } ) ,
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
/***/ 5122 :
/***/ ( ( _ _unused _webpack _module , exports , _ _nccwpck _require _ _ ) => {
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
"use strict" ;
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
Object . defineProperty ( exports , "__esModule" , ( {
value : true
} ) ) ;
exports [ "default" ] = void 0 ;
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
var _rng = _interopRequireDefault ( _ _nccwpck _require _ _ ( 807 ) ) ;
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
var _stringify = _interopRequireDefault ( _ _nccwpck _require _ _ ( 8950 ) ) ;
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
function _interopRequireDefault ( obj ) { return obj && obj . _ _esModule ? obj : { default : obj } ; }
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
function v4 ( options , buf , offset ) {
options = options || { } ;
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
const rnds = options . random || ( options . rng || _rng . default ) ( ) ; // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
rnds [ 6 ] = rnds [ 6 ] & 0x0f | 0x40 ;
rnds [ 8 ] = rnds [ 8 ] & 0x3f | 0x80 ; // Copy bytes to buffer, if provided
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
if ( buf ) {
offset = offset || 0 ;
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
for ( let i = 0 ; i < 16 ; ++ i ) {
buf [ offset + i ] = rnds [ i ] ;
}
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
return buf ;
}
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
return ( 0 , _stringify . default ) ( rnds ) ;
}
2022-01-16 11:27:57 -05:00
2022-11-03 16:35:53 -04:00
var _default = v4 ;
exports [ "default" ] = _default ;
2022-01-16 11:27:57 -05:00
2021-01-24 07:14:13 -05:00
/***/ } ) ,
2022-11-03 16:35:53 -04:00
/***/ 9120 :
/***/ ( ( _ _unused _webpack _module , exports , _ _nccwpck _require _ _ ) => {
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
"use strict" ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
Object . defineProperty ( exports , "__esModule" , ( {
value : true
} ) ) ;
exports [ "default" ] = void 0 ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
var _v = _interopRequireDefault ( _ _nccwpck _require _ _ ( 5998 ) ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
var _sha = _interopRequireDefault ( _ _nccwpck _require _ _ ( 5274 ) ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
function _interopRequireDefault ( obj ) { return obj && obj . _ _esModule ? obj : { default : obj } ; }
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
const v5 = ( 0 , _v . default ) ( 'v5' , 0x50 , _sha . default ) ;
var _default = v5 ;
exports [ "default" ] = _default ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
/***/ } ) ,
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
/***/ 6900 :
/***/ ( ( _ _unused _webpack _module , exports , _ _nccwpck _require _ _ ) => {
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
"use strict" ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
Object . defineProperty ( exports , "__esModule" , ( {
value : true
} ) ) ;
exports [ "default" ] = void 0 ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
var _regex = _interopRequireDefault ( _ _nccwpck _require _ _ ( 814 ) ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
function _interopRequireDefault ( obj ) { return obj && obj . _ _esModule ? obj : { default : obj } ; }
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
function validate ( uuid ) {
return typeof uuid === 'string' && _regex . default . test ( uuid ) ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
var _default = validate ;
exports [ "default" ] = _default ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
/***/ } ) ,
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
/***/ 1595 :
/***/ ( ( _ _unused _webpack _module , exports , _ _nccwpck _require _ _ ) => {
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
"use strict" ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
Object . defineProperty ( exports , "__esModule" , ( {
value : true
} ) ) ;
exports [ "default" ] = void 0 ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
var _validate = _interopRequireDefault ( _ _nccwpck _require _ _ ( 6900 ) ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
function _interopRequireDefault ( obj ) { return obj && obj . _ _esModule ? obj : { default : obj } ; }
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
function version ( uuid ) {
if ( ! ( 0 , _validate . default ) ( uuid ) ) {
throw TypeError ( 'Invalid UUID' ) ;
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
return parseInt ( uuid . substr ( 14 , 1 ) , 16 ) ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
var _default = version ;
exports [ "default" ] = _default ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
/***/ } ) ,
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
/***/ 8169 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
2021-01-24 07:14:13 -05:00
2022-11-04 05:28:14 -04:00
"use strict" ;
2022-11-03 16:35:53 -04:00
const core = _ _nccwpck _require _ _ ( 2186 ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
class GithubActions {
debug ( message ) {
core . debug ( message )
2021-01-24 07:14:13 -05:00
}
2023-02-04 07:28:08 -05:00
info ( message ) {
core . info ( message )
}
2022-11-03 16:35:53 -04:00
warning ( message ) {
core . warning ( message )
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
setOutput ( name , output ) {
core . setOutput ( name , output )
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
setFailed ( message ) {
core . setFailed ( message )
}
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
class LogActions {
2023-02-04 07:28:08 -05:00
info ( message ) {
console . info ( message )
}
2022-11-03 16:35:53 -04:00
debug ( message ) {
console . info ( message )
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
warning ( message ) {
console . warn ( message )
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
setOutput ( name , output ) {
console . log ( name , output )
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
setFailed ( message ) {
console . error ( message )
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
module . exports = { GithubActions , LogActions }
2021-01-24 07:14:13 -05:00
2023-02-04 07:28:08 -05:00
/***/ } ) ,
/***/ 6733 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
const axios = _ _nccwpck _require _ _ ( 8757 ) ;
const fs = _ _nccwpck _require _ _ ( 7147 ) ;
const { GithubActions } = _ _nccwpck _require _ _ ( 8169 ) ;
/ * *
* @ param { string } filePath
* @ param { GithubActions } actions
*
* @ returns { ( response : axios . AxiosResponse ) => void }
* /
const createPersistHandler = ( filePath , actions ) => ( response ) => {
let data = response . data
if ( typeof data == 'object' ) {
data = JSON . stringify ( data )
}
fs . writeFile ( filePath , data , err => {
if ( ! err ) {
actions . info ( ` response persisted successfully at ${ filePath } ` )
return
}
actions . warning ( JSON . stringify ( { message : error . message , data : response . data } ) )
} )
}
module . exports = { createPersistHandler }
2020-02-24 04:23:15 -05:00
/***/ } ) ,
2022-11-03 16:35:53 -04:00
/***/ 9082 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
2020-02-24 04:23:15 -05:00
2022-11-04 05:28:14 -04:00
"use strict" ;
2022-11-03 16:35:53 -04:00
const axios = _ _nccwpck _require _ _ ( 8757 ) ;
const FormData = _ _nccwpck _require _ _ ( 4334 )
const fs = _ _nccwpck _require _ _ ( 7147 )
const url = _ _nccwpck _require _ _ ( 7310 ) ;
2023-02-04 07:28:08 -05:00
const { GithubActions } = _ _nccwpck _require _ _ ( 8169 ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
const METHOD _GET = 'GET'
const METHOD _POST = 'POST'
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
const HEADER _CONTENT _TYPE = 'Content-Type'
2020-10-01 16:20:08 -04:00
2022-11-03 16:35:53 -04:00
const CONTENT _TYPE _URLENCODED = 'application/x-www-form-urlencoded'
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/ * *
* @ param { Object } param0
* @ param { string } param0 . method HTTP Method
* @ param { axios . AxiosRequestConfig } param0 . instanceConfig
* @ param { string } param0 . data Request Body as string , default { }
* @ param { string } param0 . files Map of Request Files ( name : absolute path ) as JSON String , default : { }
* @ param { string } param0 . file Single request file ( absolute path )
2023-02-04 07:28:08 -05:00
* @ param { GithubActions } param0 . actions
2022-11-03 16:35:53 -04:00
* @ param { number [ ] } param0 . ignoredCodes Prevent Action to fail if the API response with one of this StatusCodes
* @ param { boolean } param0 . preventFailureOnNoResponse Prevent Action to fail if the API respond without Response
* @ param { boolean } param0 . escapeData Escape unescaped JSON content in data
*
2023-02-04 07:28:08 -05:00
* @ returns { Promise < axios . AxiosResponse > }
2022-11-03 16:35:53 -04:00
* /
const request = async ( { method , instanceConfig , data , files , file , actions , ignoredCodes , preventFailureOnNoResponse , escapeData } ) => {
try {
if ( escapeData ) {
data = data . replace ( /"[^"]*"/g , ( match ) => {
return match . replace ( /[\n\r]\s*/g , "\\n" ) ;
} ) ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( method === METHOD _GET ) {
data = undefined ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( files && files !== '{}' ) {
let filesJson = convertToJSON ( files )
let dataJson = convertToJSON ( data )
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( Object . keys ( filesJson ) . length > 0 ) {
try {
data = convertToFormData ( dataJson , filesJson )
instanceConfig = await updateConfig ( instanceConfig , data , actions )
} catch ( error ) {
2023-02-04 07:28:08 -05:00
actions . setFailed ( JSON . stringify ( { message : ` Unable to convert Data and Files into FormData: ${ error . message } ` , data : dataJson , files : filesJson } ) )
2022-11-03 16:35:53 -04:00
return
}
}
}
2021-03-19 12:28:53 -04:00
2022-11-03 16:35:53 -04:00
// Only consider file if neither data nor files provided
if ( ( ! data || data === '{}' ) && ( ! files || files === '{}' ) && file ) {
data = fs . createReadStream ( file )
updateConfigForFile ( instanceConfig , file , actions )
}
2020-10-01 16:20:08 -04:00
2022-11-03 16:35:53 -04:00
if ( instanceConfig . headers [ HEADER _CONTENT _TYPE ] === CONTENT _TYPE _URLENCODED ) {
let dataJson = convertToJSON ( data )
if ( typeof dataJson === 'object' && Object . keys ( dataJson ) . length ) {
data = ( new url . URLSearchParams ( dataJson ) ) . toString ( ) ;
}
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
const requestData = {
method ,
data ,
maxContentLength : Infinity ,
maxBodyLength : Infinity
}
actions . debug ( 'Instance Configuration: ' + JSON . stringify ( instanceConfig ) )
2023-02-04 07:28:08 -05:00
/** @type {axios.AxiosInstance} */
2022-11-03 16:35:53 -04:00
const instance = axios . create ( instanceConfig ) ;
actions . debug ( 'Request Data: ' + JSON . stringify ( requestData ) )
const response = await instance . request ( requestData )
actions . setOutput ( 'response' , JSON . stringify ( response . data ) )
actions . setOutput ( 'headers' , response . headers )
2023-02-04 07:28:08 -05:00
return response
2022-11-03 16:35:53 -04:00
} catch ( error ) {
if ( ( typeof error === 'object' ) && ( error . isAxiosError === true ) ) {
const { name , message , code , response } = error
actions . setOutput ( 'requestError' , JSON . stringify ( { name , message , code , status : response && response . status ? response . status : null } ) ) ;
}
if ( error . response && ignoredCodes . includes ( error . response . status ) ) {
actions . warning ( JSON . stringify ( { code : error . response . status , message : error . response . data } ) )
} else if ( error . response ) {
actions . setFailed ( JSON . stringify ( { code : error . response . status , message : error . response . data } ) )
} else if ( error . request && ! preventFailureOnNoResponse ) {
actions . setFailed ( JSON . stringify ( { error : "no response received" } ) ) ;
} else if ( error . request && preventFailureOnNoResponse ) {
actions . warning ( JSON . stringify ( error ) ) ;
} else {
actions . setFailed ( JSON . stringify ( { message : error . message , data } ) ) ;
2020-02-24 04:23:15 -05:00
}
}
2022-11-03 16:35:53 -04:00
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/ * *
* @ param { string } value
*
* @ returns { Object }
* /
const convertToJSON = ( value ) => {
try {
return JSON . parse ( value ) || { }
} catch ( e ) {
return { }
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
}
/ * *
* @ param { Object } data
* @ param { Object } files
*
* @ returns { FormData }
* /
const convertToFormData = ( data , files ) => {
2022-11-04 05:28:14 -04:00
const formData = new FormData ( )
2022-11-03 16:35:53 -04:00
for ( const [ key , value ] of Object . entries ( data ) ) {
formData . append ( key , value )
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
for ( const [ key , value ] of Object . entries ( files ) ) {
formData . append ( key , fs . createReadStream ( value ) )
2020-10-01 16:20:08 -04:00
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
return formData
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/ * *
* @ param { { baseURL : string ; timeout : number ; headers : { [ name : string ] : string } } } instanceConfig
* @ param { FormData } formData
* @ param { * } actions
*
* @ returns { Promise < { baseURL : string ; timeout : number ; headers : { [ name : string ] : string } } > }
* /
const updateConfig = async ( instanceConfig , formData , actions ) => {
try {
const formHeaders = formData . getHeaders ( )
const contentType = formHeaders [ 'content-type' ]
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
delete formHeaders [ 'content-type' ]
2021-03-19 12:28:53 -04:00
2022-11-03 16:35:53 -04:00
return {
... instanceConfig ,
headers : {
... instanceConfig . headers ,
... formHeaders ,
'Content-Length' : await contentLength ( formData ) ,
'Content-Type' : contentType
}
}
} catch ( error ) {
actions . setFailed ( { message : ` Unable to read Content-Length: ${ error . message } ` , data , files } )
2021-09-09 08:42:30 -04:00
}
2022-11-03 16:35:53 -04:00
}
2021-09-09 08:42:30 -04:00
2022-11-03 16:35:53 -04:00
/ * *
* @ param instanceConfig
* @ param filePath
* @ param { * } actions
*
* @ returns { { baseURL : string ; timeout : number ; headers : { [ name : string ] : string } } }
* /
const updateConfigForFile = ( instanceConfig , filePath , actions ) => {
try {
const { size } = fs . statSync ( filePath )
return {
... instanceConfig ,
headers : {
... instanceConfig . headers ,
'Content-Length' : size ,
'Content-Type' : 'application/octet-stream'
}
2021-03-19 12:28:53 -04:00
}
2022-11-03 16:35:53 -04:00
} catch ( error ) {
actions . setFailed ( { message : ` Unable to read Content-Length: ${ error . message } ` , data , files } )
2021-03-19 12:28:53 -04:00
}
2022-11-03 16:35:53 -04:00
}
2021-03-19 12:28:53 -04:00
2022-11-03 16:35:53 -04:00
/ * *
* @ param { FormData } formData
*
* @ returns { Promise < number > }
* /
const contentLength = ( formData ) => new Promise ( ( resolve , reject ) => {
formData . getLength ( ( err , length ) => {
if ( err ) {
reject ( err )
return
2022-01-16 11:27:57 -05:00
}
2022-11-03 16:35:53 -04:00
resolve ( length )
} )
} )
2020-10-01 16:20:08 -04:00
2022-11-03 16:35:53 -04:00
module . exports = {
request ,
METHOD _POST ,
METHOD _GET ,
}
2022-01-16 11:27:57 -05:00
2020-10-01 16:20:08 -04:00
2022-11-03 16:35:53 -04:00
/***/ } ) ,
2020-10-01 16:20:08 -04:00
2022-11-03 16:35:53 -04:00
/***/ 9975 :
/***/ ( ( module ) => {
2020-10-01 16:20:08 -04:00
2022-11-03 16:35:53 -04:00
module . exports = eval ( "require" ) ( "debug" ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/***/ } ) ,
2020-10-01 16:20:08 -04:00
2022-11-03 16:35:53 -04:00
/***/ 9491 :
/***/ ( ( module ) => {
2020-10-01 16:20:08 -04:00
2022-11-03 16:35:53 -04:00
"use strict" ;
module . exports = require ( "assert" ) ;
2020-10-01 16:20:08 -04:00
2022-11-03 16:35:53 -04:00
/***/ } ) ,
2020-10-01 16:20:08 -04:00
2022-11-03 16:35:53 -04:00
/***/ 6113 :
/***/ ( ( module ) => {
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
"use strict" ;
module . exports = require ( "crypto" ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/***/ } ) ,
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/***/ 2361 :
/***/ ( ( module ) => {
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
"use strict" ;
module . exports = require ( "events" ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/***/ } ) ,
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/***/ 7147 :
/***/ ( ( module ) => {
2022-03-04 05:20:10 -05:00
2022-11-03 16:35:53 -04:00
"use strict" ;
module . exports = require ( "fs" ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/***/ } ) ,
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/***/ 3685 :
/***/ ( ( module ) => {
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
"use strict" ;
module . exports = require ( "http" ) ;
2020-10-01 16:20:08 -04:00
2022-11-03 16:35:53 -04:00
/***/ } ) ,
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
/***/ 5687 :
/***/ ( ( module ) => {
2020-10-01 16:20:08 -04:00
2022-11-03 16:35:53 -04:00
"use strict" ;
module . exports = require ( "https" ) ;
2022-03-04 05:20:10 -05:00
2022-11-03 16:35:53 -04:00
/***/ } ) ,
2022-03-04 05:20:10 -05:00
2022-11-03 16:35:53 -04:00
/***/ 1808 :
/***/ ( ( module ) => {
2022-03-04 05:20:10 -05:00
2022-11-03 16:35:53 -04:00
"use strict" ;
module . exports = require ( "net" ) ;
2022-03-04 05:20:10 -05:00
2022-11-03 16:35:53 -04:00
/***/ } ) ,
2022-03-04 05:20:10 -05:00
2022-11-03 16:35:53 -04:00
/***/ 2037 :
/***/ ( ( module ) => {
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
"use strict" ;
module . exports = require ( "os" ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/***/ } ) ,
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/***/ 1017 :
/***/ ( ( module ) => {
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
"use strict" ;
module . exports = require ( "path" ) ;
2020-10-01 16:20:08 -04:00
2022-11-03 16:35:53 -04:00
/***/ } ) ,
2020-10-01 16:20:08 -04:00
2022-11-03 16:35:53 -04:00
/***/ 2781 :
/***/ ( ( module ) => {
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
"use strict" ;
module . exports = require ( "stream" ) ;
2020-12-16 15:37:11 -05:00
2022-11-03 16:35:53 -04:00
/***/ } ) ,
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/***/ 4404 :
/***/ ( ( module ) => {
2020-10-01 16:20:08 -04:00
2022-11-03 16:35:53 -04:00
"use strict" ;
module . exports = require ( "tls" ) ;
/***/ } ) ,
/***/ 7310 :
/***/ ( ( module ) => {
"use strict" ;
module . exports = require ( "url" ) ;
/***/ } ) ,
/***/ 3837 :
/***/ ( ( module ) => {
"use strict" ;
module . exports = require ( "util" ) ;
/***/ } ) ,
/***/ 9796 :
/***/ ( ( module ) => {
"use strict" ;
module . exports = require ( "zlib" ) ;
/***/ } ) ,
/***/ 8757 :
/***/ ( ( module , _ _unused _webpack _exports , _ _nccwpck _require _ _ ) => {
"use strict" ;
2023-02-04 07:28:08 -05:00
// Axios v1.3.2 Copyright (c) 2023 Matt Zabriskie and contributors
2022-11-03 16:35:53 -04:00
const FormData$1 = _ _nccwpck _require _ _ ( 4334 ) ;
const url = _ _nccwpck _require _ _ ( 7310 ) ;
const proxyFromEnv = _ _nccwpck _require _ _ ( 3329 ) ;
const http = _ _nccwpck _require _ _ ( 3685 ) ;
const https = _ _nccwpck _require _ _ ( 5687 ) ;
2023-02-04 07:28:08 -05:00
const util = _ _nccwpck _require _ _ ( 3837 ) ;
2022-11-03 16:35:53 -04:00
const followRedirects = _ _nccwpck _require _ _ ( 7707 ) ;
const zlib = _ _nccwpck _require _ _ ( 9796 ) ;
const stream = _ _nccwpck _require _ _ ( 2781 ) ;
const EventEmitter = _ _nccwpck _require _ _ ( 2361 ) ;
function _interopDefaultLegacy ( e ) { return e && typeof e === 'object' && 'default' in e ? e : { 'default' : e } ; }
const FormData _ _default = /*#__PURE__*/ _interopDefaultLegacy ( FormData$1 ) ;
const url _ _default = /*#__PURE__*/ _interopDefaultLegacy ( url ) ;
const http _ _default = /*#__PURE__*/ _interopDefaultLegacy ( http ) ;
const https _ _default = /*#__PURE__*/ _interopDefaultLegacy ( https ) ;
2023-02-04 07:28:08 -05:00
const util _ _default = /*#__PURE__*/ _interopDefaultLegacy ( util ) ;
2022-11-03 16:35:53 -04:00
const followRedirects _ _default = /*#__PURE__*/ _interopDefaultLegacy ( followRedirects ) ;
const zlib _ _default = /*#__PURE__*/ _interopDefaultLegacy ( zlib ) ;
const stream _ _default = /*#__PURE__*/ _interopDefaultLegacy ( stream ) ;
const EventEmitter _ _default = /*#__PURE__*/ _interopDefaultLegacy ( EventEmitter ) ;
function bind ( fn , thisArg ) {
return function wrap ( ) {
return fn . apply ( thisArg , arguments ) ;
2020-10-01 16:20:08 -04:00
} ;
}
2022-11-03 16:35:53 -04:00
// utils is a library of generic helper functions non-specific to axios
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
const { toString } = Object . prototype ;
const { getPrototypeOf } = Object ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
const kindOf = ( cache => thing => {
const str = toString . call ( thing ) ;
return cache [ str ] || ( cache [ str ] = str . slice ( 8 , - 1 ) . toLowerCase ( ) ) ;
} ) ( Object . create ( null ) ) ;
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
const kindOfTest = ( type ) => {
type = type . toLowerCase ( ) ;
return ( thing ) => kindOf ( thing ) === type
} ;
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
const typeOfTest = type => thing => typeof thing === type ;
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
/ * *
* Determine if a value is an Array
*
* @ param { Object } val The value to test
*
* @ returns { boolean } True if value is an Array , otherwise false
* /
const { isArray } = Array ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
/ * *
* Determine if a value is undefined
*
* @ param { * } val The value to test
*
* @ returns { boolean } True if the value is undefined , otherwise false
* /
const isUndefined = typeOfTest ( 'undefined' ) ;
/ * *
* Determine if a value is a Buffer
*
* @ param { * } val The value to test
*
* @ returns { boolean } True if value is a Buffer , otherwise false
* /
function isBuffer ( val ) {
return val !== null && ! isUndefined ( val ) && val . constructor !== null && ! isUndefined ( val . constructor )
&& isFunction ( val . constructor . isBuffer ) && val . constructor . isBuffer ( val ) ;
2022-10-05 11:29:30 -04:00
}
2022-11-03 16:35:53 -04:00
/ * *
* Determine if a value is an ArrayBuffer
*
* @ param { * } val The value to test
*
* @ returns { boolean } True if value is an ArrayBuffer , otherwise false
* /
const isArrayBuffer = kindOfTest ( 'ArrayBuffer' ) ;
/ * *
* Determine if a value is a view on an ArrayBuffer
*
* @ param { * } val The value to test
*
* @ returns { boolean } True if value is a view on an ArrayBuffer , otherwise false
* /
function isArrayBufferView ( val ) {
let result ;
if ( ( typeof ArrayBuffer !== 'undefined' ) && ( ArrayBuffer . isView ) ) {
result = ArrayBuffer . isView ( val ) ;
} else {
result = ( val ) && ( val . buffer ) && ( isArrayBuffer ( val . buffer ) ) ;
}
return result ;
2022-10-05 11:29:30 -04:00
}
2022-11-03 16:35:53 -04:00
/ * *
* Determine if a value is a String
*
* @ param { * } val The value to test
*
* @ returns { boolean } True if value is a String , otherwise false
* /
const isString = typeOfTest ( 'string' ) ;
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
/ * *
* Determine if a value is a Function
*
* @ param { * } val The value to test
* @ returns { boolean } True if value is a Function , otherwise false
* /
const isFunction = typeOfTest ( 'function' ) ;
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
/ * *
* Determine if a value is a Number
*
* @ param { * } val The value to test
*
* @ returns { boolean } True if value is a Number , otherwise false
* /
const isNumber = typeOfTest ( 'number' ) ;
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
/ * *
* Determine if a value is an Object
*
* @ param { * } thing The value to test
*
* @ returns { boolean } True if value is an Object , otherwise false
* /
const isObject = ( thing ) => thing !== null && typeof thing === 'object' ;
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
/ * *
* Determine if a value is a Boolean
*
* @ param { * } thing The value to test
* @ returns { boolean } True if value is a Boolean , otherwise false
* /
const isBoolean = thing => thing === true || thing === false ;
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
/ * *
* Determine if a value is a plain Object
*
* @ param { * } val The value to test
*
* @ returns { boolean } True if value is a plain Object , otherwise false
* /
const isPlainObject = ( val ) => {
if ( kindOf ( val ) !== 'object' ) {
return false ;
}
const prototype = getPrototypeOf ( val ) ;
return ( prototype === null || prototype === Object . prototype || Object . getPrototypeOf ( prototype ) === null ) && ! ( Symbol . toStringTag in val ) && ! ( Symbol . iterator in val ) ;
2022-07-19 04:27:31 -04:00
} ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/ * *
* Determine if a value is a Date
*
* @ param { * } val The value to test
*
* @ returns { boolean } True if value is a Date , otherwise false
* /
const isDate = kindOfTest ( 'Date' ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/ * *
* Determine if a value is a File
*
* @ param { * } val The value to test
*
* @ returns { boolean } True if value is a File , otherwise false
* /
const isFile = kindOfTest ( 'File' ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/ * *
* Determine if a value is a Blob
*
* @ param { * } val The value to test
*
* @ returns { boolean } True if value is a Blob , otherwise false
* /
const isBlob = kindOfTest ( 'Blob' ) ;
/ * *
* Determine if a value is a FileList
*
* @ param { * } val The value to test
*
* @ returns { boolean } True if value is a File , otherwise false
* /
const isFileList = kindOfTest ( 'FileList' ) ;
/ * *
* Determine if a value is a Stream
*
* @ param { * } val The value to test
*
* @ returns { boolean } True if value is a Stream , otherwise false
* /
const isStream = ( val ) => isObject ( val ) && isFunction ( val . pipe ) ;
/ * *
* Determine if a value is a FormData
*
* @ param { * } thing The value to test
*
* @ returns { boolean } True if value is an FormData , otherwise false
* /
const isFormData = ( thing ) => {
const pattern = '[object FormData]' ;
return thing && (
( typeof FormData === 'function' && thing instanceof FormData ) ||
toString . call ( thing ) === pattern ||
( isFunction ( thing . toString ) && thing . toString ( ) === pattern )
) ;
} ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/ * *
* Determine if a value is a URLSearchParams object
*
* @ param { * } val The value to test
*
* @ returns { boolean } True if value is a URLSearchParams object , otherwise false
* /
const isURLSearchParams = kindOfTest ( 'URLSearchParams' ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/ * *
* Trim excess whitespace off the beginning and end of a string
*
* @ param { String } str The String to trim
*
* @ returns { String } The String freed of excess whitespace
* /
const trim = ( str ) => str . trim ?
str . trim ( ) : str . replace ( /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g , '' ) ;
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Iterate over an Array or an Object invoking a function for each item .
2020-02-24 04:23:15 -05:00
*
2022-11-03 16:35:53 -04:00
* If ` obj ` is an Array callback will be called passing
* the value , index , and complete array for each item .
*
* If 'obj' is an Object callback will be called passing
* the value , key , and complete object for each property .
*
* @ param { Object | Array } obj The object to iterate
* @ param { Function } fn The callback to invoke for each item
*
* @ param { Boolean } [ allOwnKeys = false ]
2023-02-04 07:28:08 -05:00
* @ returns { any }
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
function forEach ( obj , fn , { allOwnKeys = false } = { } ) {
// Don't bother if no value provided
if ( obj === null || typeof obj === 'undefined' ) {
return ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
let i ;
let l ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
// Force an array if not already something iterable
if ( typeof obj !== 'object' ) {
/*eslint no-param-reassign:0*/
obj = [ obj ] ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
if ( isArray ( obj ) ) {
// Iterate over array values
for ( i = 0 , l = obj . length ; i < l ; i ++ ) {
fn . call ( null , obj [ i ] , i , obj ) ;
}
} else {
// Iterate over object keys
const keys = allOwnKeys ? Object . getOwnPropertyNames ( obj ) : Object . keys ( obj ) ;
const len = keys . length ;
let key ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
for ( i = 0 ; i < len ; i ++ ) {
key = keys [ i ] ;
fn . call ( null , obj [ key ] , key , obj ) ;
}
}
}
2021-01-24 07:14:13 -05:00
2023-02-04 07:28:08 -05:00
function findKey ( obj , key ) {
key = key . toLowerCase ( ) ;
const keys = Object . keys ( obj ) ;
let i = keys . length ;
let _key ;
while ( i -- > 0 ) {
_key = keys [ i ] ;
if ( key === _key . toLowerCase ( ) ) {
return _key ;
}
}
return null ;
}
const _global = ( ( ) => {
/*eslint no-undef:0*/
if ( typeof globalThis !== "undefined" ) return globalThis ;
return typeof self !== "undefined" ? self : ( typeof window !== 'undefined' ? window : global )
} ) ( ) ;
const isContextDefined = ( context ) => ! isUndefined ( context ) && context !== _global ;
2021-01-24 07:14:13 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Accepts varargs expecting each argument to be an object , then
* immutably merges the properties of each object and returns result .
2021-01-24 07:14:13 -05:00
*
2022-11-03 16:35:53 -04:00
* When multiple objects contain the same key the later object in
* the arguments list will take precedence .
*
* Example :
*
* ` ` ` js
* var result = merge ( { foo : 123 } , { foo : 456 } ) ;
* console . log ( result . foo ) ; // outputs 456
* ` ` `
*
* @ param { Object } obj1 Object to merge
*
* @ returns { Object } Result of all merge properties
2021-01-24 07:14:13 -05:00
* /
2022-11-03 16:35:53 -04:00
function merge ( /* obj1, obj2, obj3, ... */ ) {
2023-02-04 07:28:08 -05:00
const { caseless } = isContextDefined ( this ) && this || { } ;
2022-11-03 16:35:53 -04:00
const result = { } ;
const assignValue = ( val , key ) => {
2023-02-04 07:28:08 -05:00
const targetKey = caseless && findKey ( result , key ) || key ;
if ( isPlainObject ( result [ targetKey ] ) && isPlainObject ( val ) ) {
result [ targetKey ] = merge ( result [ targetKey ] , val ) ;
2022-11-03 16:35:53 -04:00
} else if ( isPlainObject ( val ) ) {
2023-02-04 07:28:08 -05:00
result [ targetKey ] = merge ( { } , val ) ;
2022-11-03 16:35:53 -04:00
} else if ( isArray ( val ) ) {
2023-02-04 07:28:08 -05:00
result [ targetKey ] = val . slice ( ) ;
2022-11-03 16:35:53 -04:00
} else {
2023-02-04 07:28:08 -05:00
result [ targetKey ] = val ;
2022-11-03 16:35:53 -04:00
}
} ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
for ( let i = 0 , l = arguments . length ; i < l ; i ++ ) {
arguments [ i ] && forEach ( arguments [ i ] , assignValue ) ;
}
return result ;
2021-01-24 07:14:13 -05:00
}
/ * *
2022-11-03 16:35:53 -04:00
* Extends object a by mutably adding to it the properties of object b .
2021-01-24 07:14:13 -05:00
*
2022-11-03 16:35:53 -04:00
* @ param { Object } a The object to be extended
* @ param { Object } b The object to copy properties from
* @ param { Object } thisArg The object to bind function to
*
* @ param { Boolean } [ allOwnKeys ]
* @ returns { Object } The resulting value of object a
2021-01-24 07:14:13 -05:00
* /
2022-11-03 16:35:53 -04:00
const extend = ( a , b , thisArg , { allOwnKeys } = { } ) => {
forEach ( b , ( val , key ) => {
if ( thisArg && isFunction ( val ) ) {
a [ key ] = bind ( val , thisArg ) ;
} else {
a [ key ] = val ;
}
} , { allOwnKeys } ) ;
return a ;
} ;
/ * *
* Remove byte order marker . This catches EF BB BF ( the UTF - 8 BOM )
*
* @ param { string } content with BOM
*
* @ returns { string } content value without BOM
* /
const stripBOM = ( content ) => {
if ( content . charCodeAt ( 0 ) === 0xFEFF ) {
content = content . slice ( 1 ) ;
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
return content ;
} ;
/ * *
* Inherit the prototype methods from one constructor into another
* @ param { function } constructor
* @ param { function } superConstructor
* @ param { object } [ props ]
* @ param { object } [ descriptors ]
*
* @ returns { void }
* /
const inherits = ( constructor , superConstructor , props , descriptors ) => {
constructor . prototype = Object . create ( superConstructor . prototype , descriptors ) ;
constructor . prototype . constructor = constructor ;
Object . defineProperty ( constructor , 'super' , {
value : superConstructor . prototype
} ) ;
props && Object . assign ( constructor . prototype , props ) ;
} ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
/ * *
* Resolve object with deep prototype chain to a flat object
* @ param { Object } sourceObj source object
* @ param { Object } [ destObj ]
* @ param { Function | Boolean } [ filter ]
* @ param { Function } [ propFilter ]
*
* @ returns { Object }
* /
const toFlatObject = ( sourceObj , destObj , filter , propFilter ) => {
let props ;
let i ;
let prop ;
const merged = { } ;
destObj = destObj || { } ;
// eslint-disable-next-line no-eq-null,eqeqeq
if ( sourceObj == null ) return destObj ;
do {
props = Object . getOwnPropertyNames ( sourceObj ) ;
i = props . length ;
while ( i -- > 0 ) {
prop = props [ i ] ;
if ( ( ! propFilter || propFilter ( prop , sourceObj , destObj ) ) && ! merged [ prop ] ) {
destObj [ prop ] = sourceObj [ prop ] ;
merged [ prop ] = true ;
}
}
sourceObj = filter !== false && getPrototypeOf ( sourceObj ) ;
} while ( sourceObj && ( ! filter || filter ( sourceObj , destObj ) ) && sourceObj !== Object . prototype ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
return destObj ;
} ;
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
/ * *
* Determines whether a string ends with the characters of a specified string
*
* @ param { String } str
* @ param { String } searchString
* @ param { Number } [ position = 0 ]
*
* @ returns { boolean }
* /
const endsWith = ( str , searchString , position ) => {
str = String ( str ) ;
if ( position === undefined || position > str . length ) {
position = str . length ;
}
position -= searchString . length ;
const lastIndex = str . indexOf ( searchString , position ) ;
return lastIndex !== - 1 && lastIndex === position ;
} ;
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
/ * *
* Returns new array from array like object or null if failed
*
* @ param { * } [ thing ]
*
* @ returns { ? Array }
* /
const toArray = ( thing ) => {
if ( ! thing ) return null ;
if ( isArray ( thing ) ) return thing ;
let i = thing . length ;
if ( ! isNumber ( i ) ) return null ;
const arr = new Array ( i ) ;
while ( i -- > 0 ) {
arr [ i ] = thing [ i ] ;
}
return arr ;
2022-07-19 04:27:31 -04:00
} ;
2022-11-03 16:35:53 -04:00
2022-07-19 04:27:31 -04:00
/ * *
2022-11-03 16:35:53 -04:00
* Checking if the Uint8Array exists and if it does , it returns a function that checks if the
* thing passed in is an instance of Uint8Array
2022-07-19 04:27:31 -04:00
*
2022-11-03 16:35:53 -04:00
* @ param { TypedArray }
*
* @ returns { Array }
2022-07-19 04:27:31 -04:00
* /
2022-11-03 16:35:53 -04:00
// eslint-disable-next-line func-names
const isTypedArray = ( TypedArray => {
// eslint-disable-next-line func-names
return thing => {
return TypedArray && thing instanceof TypedArray ;
} ;
} ) ( typeof Uint8Array !== 'undefined' && getPrototypeOf ( Uint8Array ) ) ;
2022-07-19 04:27:31 -04:00
/ * *
2022-11-03 16:35:53 -04:00
* For each entry in the object , call the function with the key and value .
2022-07-19 04:27:31 -04:00
*
2022-11-03 16:35:53 -04:00
* @ param { Object < any , any > } obj - The object to iterate over .
* @ param { Function } fn - The function to call for each entry .
*
* @ returns { void }
2022-07-19 04:27:31 -04:00
* /
2022-11-03 16:35:53 -04:00
const forEachEntry = ( obj , fn ) => {
const generator = obj && obj [ Symbol . iterator ] ;
const iterator = generator . call ( obj ) ;
let result ;
while ( ( result = iterator . next ( ) ) && ! result . done ) {
const pair = result . value ;
fn . call ( obj , pair [ 0 ] , pair [ 1 ] ) ;
}
} ;
2022-07-19 04:27:31 -04:00
/ * *
2022-11-03 16:35:53 -04:00
* It takes a regular expression and a string , and returns an array of all the matches
2022-07-19 04:27:31 -04:00
*
2022-11-03 16:35:53 -04:00
* @ param { string } regExp - The regular expression to match against .
* @ param { string } str - The string to search .
*
* @ returns { Array < boolean > }
2022-07-19 04:27:31 -04:00
* /
2022-11-03 16:35:53 -04:00
const matchAll = ( regExp , str ) => {
let matches ;
const arr = [ ] ;
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
while ( ( matches = regExp . exec ( str ) ) !== null ) {
arr . push ( matches ) ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
return arr ;
} ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
const isHTMLForm = kindOfTest ( 'HTMLFormElement' ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
const toCamelCase = str => {
2023-02-04 07:28:08 -05:00
return str . toLowerCase ( ) . replace ( /[-_\s]([a-z\d])(\w*)/g ,
2022-11-03 16:35:53 -04:00
function replacer ( m , p1 , p2 ) {
return p1 . toUpperCase ( ) + p2 ;
}
) ;
} ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/* Creating a function that will check if an object has a property. */
const hasOwnProperty = ( ( { hasOwnProperty } ) => ( obj , prop ) => hasOwnProperty . call ( obj , prop ) ) ( Object . prototype ) ;
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Determine if a value is a RegExp object
2020-02-24 04:23:15 -05:00
*
2022-11-03 16:35:53 -04:00
* @ param { * } val The value to test
*
* @ returns { boolean } True if value is a RegExp object , otherwise false
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
const isRegExp = kindOfTest ( 'RegExp' ) ;
const reduceDescriptors = ( obj , reducer ) => {
const descriptors = Object . getOwnPropertyDescriptors ( obj ) ;
const reducedDescriptors = { } ;
forEach ( descriptors , ( descriptor , name ) => {
if ( reducer ( descriptor , name , obj ) !== false ) {
reducedDescriptors [ name ] = descriptor ;
}
2020-02-24 04:23:15 -05:00
} ) ;
2022-11-03 16:35:53 -04:00
Object . defineProperties ( obj , reducedDescriptors ) ;
2020-02-24 04:23:15 -05:00
} ;
2022-11-03 16:35:53 -04:00
/ * *
* Makes all methods read - only
* @ param { Object } obj
* /
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
const freezeMethods = ( obj ) => {
reduceDescriptors ( obj , ( descriptor , name ) => {
2023-02-04 07:28:08 -05:00
// skip restricted props in strict mode
if ( isFunction ( obj ) && [ 'arguments' , 'caller' , 'callee' ] . indexOf ( name ) !== - 1 ) {
return false ;
}
2022-11-03 16:35:53 -04:00
const value = obj [ name ] ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( ! isFunction ( value ) ) return ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
descriptor . enumerable = false ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( 'writable' in descriptor ) {
descriptor . writable = false ;
return ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( ! descriptor . set ) {
descriptor . set = ( ) => {
2023-02-04 07:28:08 -05:00
throw Error ( 'Can not rewrite read-only method \'' + name + '\'' ) ;
2022-11-03 16:35:53 -04:00
} ;
}
} ) ;
2020-02-24 04:23:15 -05:00
} ;
2022-11-03 16:35:53 -04:00
const toObjectSet = ( arrayOrString , delimiter ) => {
const obj = { } ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
const define = ( arr ) => {
arr . forEach ( value => {
obj [ value ] = true ;
} ) ;
} ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
isArray ( arrayOrString ) ? define ( arrayOrString ) : define ( String ( arrayOrString ) . split ( delimiter ) ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
return obj ;
} ;
const noop = ( ) => { } ;
const toFiniteNumber = ( value , defaultValue ) => {
value = + value ;
return Number . isFinite ( value ) ? value : defaultValue ;
} ;
2023-02-04 07:28:08 -05:00
const ALPHA = 'abcdefghijklmnopqrstuvwxyz' ;
const DIGIT = '0123456789' ;
const ALPHABET = {
DIGIT ,
ALPHA ,
ALPHA _DIGIT : ALPHA + ALPHA . toUpperCase ( ) + DIGIT
} ;
const generateString = ( size = 16 , alphabet = ALPHABET . ALPHA _DIGIT ) => {
let str = '' ;
const { length } = alphabet ;
while ( size -- ) {
str += alphabet [ Math . random ( ) * length | 0 ] ;
}
return str ;
} ;
/ * *
* If the thing is a FormData object , return true , otherwise return false .
*
* @ param { unknown } thing - The thing to check .
*
* @ returns { boolean }
* /
function isSpecCompliantForm ( thing ) {
return ! ! ( thing && isFunction ( thing . append ) && thing [ Symbol . toStringTag ] === 'FormData' && thing [ Symbol . iterator ] ) ;
}
const toJSONObject = ( obj ) => {
const stack = new Array ( 10 ) ;
const visit = ( source , i ) => {
if ( isObject ( source ) ) {
if ( stack . indexOf ( source ) >= 0 ) {
return ;
}
if ( ! ( 'toJSON' in source ) ) {
stack [ i ] = source ;
const target = isArray ( source ) ? [ ] : { } ;
forEach ( source , ( value , key ) => {
const reducedValue = visit ( value , i + 1 ) ;
! isUndefined ( reducedValue ) && ( target [ key ] = reducedValue ) ;
} ) ;
stack [ i ] = undefined ;
return target ;
}
}
return source ;
} ;
return visit ( obj , 0 ) ;
} ;
2022-11-03 16:35:53 -04:00
const utils = {
isArray ,
isArrayBuffer ,
isBuffer ,
isFormData ,
isArrayBufferView ,
isString ,
isNumber ,
isBoolean ,
isObject ,
isPlainObject ,
isUndefined ,
isDate ,
isFile ,
isBlob ,
isRegExp ,
isFunction ,
isStream ,
isURLSearchParams ,
isTypedArray ,
isFileList ,
forEach ,
merge ,
extend ,
trim ,
stripBOM ,
inherits ,
toFlatObject ,
kindOf ,
kindOfTest ,
endsWith ,
toArray ,
forEachEntry ,
matchAll ,
isHTMLForm ,
hasOwnProperty ,
hasOwnProp : hasOwnProperty , // an alias to avoid ESLint no-prototype-builtins detection
reduceDescriptors ,
freezeMethods ,
toObjectSet ,
toCamelCase ,
noop ,
2023-02-04 07:28:08 -05:00
toFiniteNumber ,
findKey ,
global : _global ,
isContextDefined ,
ALPHABET ,
generateString ,
isSpecCompliantForm ,
toJSONObject
2022-11-03 16:35:53 -04:00
} ;
/ * *
* Create an Error with the specified message , config , error code , request and response .
*
* @ param { string } message The error message .
* @ param { string } [ code ] The error code ( for example , 'ECONNABORTED' ) .
* @ param { Object } [ config ] The config .
* @ param { Object } [ request ] The request .
* @ param { Object } [ response ] The response .
*
* @ returns { Error } The created error .
* /
function AxiosError ( message , code , config , request , response ) {
Error . call ( this ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( Error . captureStackTrace ) {
Error . captureStackTrace ( this , this . constructor ) ;
} else {
this . stack = ( new Error ( ) ) . stack ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
this . message = message ;
this . name = 'AxiosError' ;
code && ( this . code = code ) ;
config && ( this . config = config ) ;
request && ( this . request = request ) ;
response && ( this . response = response ) ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
utils . inherits ( AxiosError , Error , {
toJSON : function toJSON ( ) {
return {
// Standard
message : this . message ,
name : this . name ,
// Microsoft
description : this . description ,
number : this . number ,
// Mozilla
fileName : this . fileName ,
lineNumber : this . lineNumber ,
columnNumber : this . columnNumber ,
stack : this . stack ,
// Axios
2023-02-04 07:28:08 -05:00
config : utils . toJSONObject ( this . config ) ,
2022-11-03 16:35:53 -04:00
code : this . code ,
status : this . response && this . response . status ? this . response . status : null
} ;
}
} ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
const prototype$1 = AxiosError . prototype ;
const descriptors = { } ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
[
'ERR_BAD_OPTION_VALUE' ,
'ERR_BAD_OPTION' ,
'ECONNABORTED' ,
'ETIMEDOUT' ,
'ERR_NETWORK' ,
'ERR_FR_TOO_MANY_REDIRECTS' ,
'ERR_DEPRECATED' ,
'ERR_BAD_RESPONSE' ,
'ERR_BAD_REQUEST' ,
'ERR_CANCELED' ,
'ERR_NOT_SUPPORT' ,
'ERR_INVALID_URL'
// eslint-disable-next-line func-names
] . forEach ( code => {
descriptors [ code ] = { value : code } ;
} ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
Object . defineProperties ( AxiosError , descriptors ) ;
Object . defineProperty ( prototype$1 , 'isAxiosError' , { value : true } ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
// eslint-disable-next-line func-names
AxiosError . from = ( error , code , config , request , response , customProps ) => {
const axiosError = Object . create ( prototype$1 ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
utils . toFlatObject ( error , axiosError , function filter ( obj ) {
return obj !== Error . prototype ;
} , prop => {
return prop !== 'isAxiosError' ;
} ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
AxiosError . call ( axiosError , error . message , code , config , request , response ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
axiosError . cause = error ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
axiosError . name = error . name ;
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
customProps && Object . assign ( axiosError , customProps ) ;
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
return axiosError ;
2022-07-19 04:27:31 -04:00
} ;
2022-11-03 16:35:53 -04:00
/ * *
* Determines if the given thing is a array or js object .
*
* @ param { string } thing - The object or array to be visited .
*
* @ returns { boolean }
* /
function isVisitable ( thing ) {
return utils . isPlainObject ( thing ) || utils . isArray ( thing ) ;
}
/ * *
* It removes the brackets from the end of a string
*
* @ param { string } key - The key of the parameter .
*
* @ returns { string } the key without the brackets .
* /
function removeBrackets ( key ) {
return utils . endsWith ( key , '[]' ) ? key . slice ( 0 , - 2 ) : key ;
}
/ * *
* It takes a path , a key , and a boolean , and returns a string
*
* @ param { string } path - The path to the current key .
* @ param { string } key - The key of the current object being iterated over .
* @ param { string } dots - If true , the key will be rendered with dots instead of brackets .
*
* @ returns { string } The path to the current key .
* /
function renderKey ( path , key , dots ) {
if ( ! path ) return key ;
return path . concat ( key ) . map ( function each ( token , i ) {
// eslint-disable-next-line no-param-reassign
token = removeBrackets ( token ) ;
return ! dots && i ? '[' + token + ']' : token ;
} ) . join ( dots ? '.' : '' ) ;
}
/ * *
* If the array is an array and none of its elements are visitable , then it ' s a flat array .
*
* @ param { Array < any > } arr - The array to check
*
* @ returns { boolean }
* /
function isFlatArray ( arr ) {
return utils . isArray ( arr ) && ! arr . some ( isVisitable ) ;
}
const predicates = utils . toFlatObject ( utils , { } , null , function filter ( prop ) {
return /^is[A-Z]/ . test ( prop ) ;
} ) ;
/ * *
* Convert a data object to FormData
*
* @ param { Object } obj
* @ param { ? Object } [ formData ]
* @ param { ? Object } [ options ]
* @ param { Function } [ options . visitor ]
* @ param { Boolean } [ options . metaTokens = true ]
* @ param { Boolean } [ options . dots = false ]
* @ param { ? Boolean } [ options . indexes = false ]
*
* @ returns { Object }
* * /
/ * *
* It converts an object into a FormData object
*
* @ param { Object < any , any > } obj - The object to convert to form data .
* @ param { string } formData - The FormData object to append to .
* @ param { Object < string , any > } options
*
* @ returns
* /
function toFormData ( obj , formData , options ) {
if ( ! utils . isObject ( obj ) ) {
throw new TypeError ( 'target must be an object' ) ;
}
// eslint-disable-next-line no-param-reassign
formData = formData || new ( FormData _ _default [ "default" ] || FormData ) ( ) ;
// eslint-disable-next-line no-param-reassign
options = utils . toFlatObject ( options , {
metaTokens : true ,
dots : false ,
indexes : false
} , false , function defined ( option , source ) {
// eslint-disable-next-line no-eq-null,eqeqeq
return ! utils . isUndefined ( source [ option ] ) ;
} ) ;
const metaTokens = options . metaTokens ;
// eslint-disable-next-line no-use-before-define
const visitor = options . visitor || defaultVisitor ;
const dots = options . dots ;
const indexes = options . indexes ;
const _Blob = options . Blob || typeof Blob !== 'undefined' && Blob ;
2023-02-04 07:28:08 -05:00
const useBlob = _Blob && utils . isSpecCompliantForm ( formData ) ;
2022-11-03 16:35:53 -04:00
if ( ! utils . isFunction ( visitor ) ) {
throw new TypeError ( 'visitor must be a function' ) ;
}
function convertValue ( value ) {
if ( value === null ) return '' ;
if ( utils . isDate ( value ) ) {
return value . toISOString ( ) ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
if ( ! useBlob && utils . isBlob ( value ) ) {
throw new AxiosError ( 'Blob is not supported. Use a Buffer instead.' ) ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
if ( utils . isArrayBuffer ( value ) || utils . isTypedArray ( value ) ) {
return useBlob && typeof Blob === 'function' ? new Blob ( [ value ] ) : Buffer . from ( value ) ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
return value ;
}
/ * *
* Default visitor .
*
* @ param { * } value
* @ param { String | Number } key
* @ param { Array < String | Number > } path
* @ this { FormData }
*
* @ returns { boolean } return true to visit the each prop of the value recursively
* /
function defaultVisitor ( value , key , path ) {
let arr = value ;
if ( value && ! path && typeof value === 'object' ) {
if ( utils . endsWith ( key , '{}' ) ) {
// eslint-disable-next-line no-param-reassign
key = metaTokens ? key : key . slice ( 0 , - 2 ) ;
// eslint-disable-next-line no-param-reassign
value = JSON . stringify ( value ) ;
} else if (
( utils . isArray ( value ) && isFlatArray ( value ) ) ||
2023-02-04 07:28:08 -05:00
( ( utils . isFileList ( value ) || utils . endsWith ( key , '[]' ) ) && ( arr = utils . toArray ( value ) )
2022-11-03 16:35:53 -04:00
) ) {
// eslint-disable-next-line no-param-reassign
key = removeBrackets ( key ) ;
arr . forEach ( function each ( el , index ) {
! ( utils . isUndefined ( el ) || el === null ) && formData . append (
// eslint-disable-next-line no-nested-ternary
indexes === true ? renderKey ( [ key ] , index , dots ) : ( indexes === null ? key : key + '[]' ) ,
convertValue ( el )
) ;
} ) ;
return false ;
}
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
if ( isVisitable ( value ) ) {
return true ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
formData . append ( renderKey ( path , key , dots ) , convertValue ( value ) ) ;
return false ;
}
const stack = [ ] ;
const exposedHelpers = Object . assign ( predicates , {
defaultVisitor ,
convertValue ,
isVisitable
} ) ;
function build ( value , path ) {
if ( utils . isUndefined ( value ) ) return ;
if ( stack . indexOf ( value ) !== - 1 ) {
throw Error ( 'Circular reference detected in ' + path . join ( '.' ) ) ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
stack . push ( value ) ;
utils . forEach ( value , function each ( el , key ) {
const result = ! ( utils . isUndefined ( el ) || el === null ) && visitor . call (
formData , el , utils . isString ( key ) ? key . trim ( ) : key , path , exposedHelpers
) ;
if ( result === true ) {
build ( el , path ? path . concat ( key ) : [ key ] ) ;
}
} ) ;
stack . pop ( ) ;
}
if ( ! utils . isObject ( obj ) ) {
throw new TypeError ( 'data must be an object' ) ;
}
build ( obj ) ;
return formData ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
2022-07-19 04:27:31 -04:00
/ * *
2022-11-03 16:35:53 -04:00
* It encodes a string by replacing all characters that are not in the unreserved set with
* their percent - encoded equivalents
*
* @ param { string } str - The string to encode .
*
* @ returns { string } The encoded string .
2022-07-19 04:27:31 -04:00
* /
2022-11-03 16:35:53 -04:00
function encode$1 ( str ) {
const charMap = {
'!' : '%21' ,
"'" : '%27' ,
'(' : '%28' ,
')' : '%29' ,
'~' : '%7E' ,
'%20' : '+' ,
'%00' : '\x00'
} ;
return encodeURIComponent ( str ) . replace ( /[!'()~]|%20|%00/g , function replacer ( match ) {
return charMap [ match ] ;
} ) ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
/ * *
* It takes a params object and converts it to a FormData object
*
* @ param { Object < string , any > } params - The parameters to be converted to a FormData object .
* @ param { Object < string , any > } options - The options object passed to the Axios constructor .
*
* @ returns { void }
* /
function AxiosURLSearchParams ( params , options ) {
this . _pairs = [ ] ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
params && toFormData ( params , this , options ) ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
const prototype = AxiosURLSearchParams . prototype ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
prototype . append = function append ( name , value ) {
this . _pairs . push ( [ name , value ] ) ;
} ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
prototype . toString = function toString ( encoder ) {
const _encode = encoder ? function ( value ) {
return encoder . call ( this , value , encode$1 ) ;
} : encode$1 ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
return this . _pairs . map ( function each ( pair ) {
return _encode ( pair [ 0 ] ) + '=' + _encode ( pair [ 1 ] ) ;
} , '' ) . join ( '&' ) ;
} ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/ * *
* It replaces all instances of the characters ` : ` , ` $ ` , ` , ` , ` + ` , ` [ ` , and ` ] ` with their
* URI encoded counterparts
*
* @ param { string } val The value to be encoded .
*
* @ returns { string } The encoded value .
* /
function encode ( val ) {
return encodeURIComponent ( val ) .
replace ( /%3A/gi , ':' ) .
replace ( /%24/g , '$' ) .
replace ( /%2C/gi , ',' ) .
replace ( /%20/g , '+' ) .
replace ( /%5B/gi , '[' ) .
replace ( /%5D/gi , ']' ) ;
}
2020-02-24 04:23:15 -05:00
2021-01-05 12:57:45 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Build a URL by appending params to the end
2021-01-05 12:57:45 -05:00
*
2022-11-03 16:35:53 -04:00
* @ param { string } url The base of the url ( e . g . , http : //www.google.com)
* @ param { object } [ params ] The params to be appended
* @ param { ? object } options
*
* @ returns { string } The formatted url
2021-01-05 12:57:45 -05:00
* /
2022-11-03 16:35:53 -04:00
function buildURL ( url , params , options ) {
/*eslint no-param-reassign:0*/
if ( ! params ) {
return url ;
}
const _encode = options && options . encode || encode ;
const serializeFn = options && options . serialize ;
2021-01-05 12:57:45 -05:00
2022-11-03 16:35:53 -04:00
let serializedParams ;
if ( serializeFn ) {
serializedParams = serializeFn ( params , options ) ;
} else {
serializedParams = utils . isURLSearchParams ( params ) ?
params . toString ( ) :
new AxiosURLSearchParams ( params , options ) . toString ( _encode ) ;
2021-01-05 12:57:45 -05:00
}
2022-11-03 16:35:53 -04:00
if ( serializedParams ) {
const hashmarkIndex = url . indexOf ( "#" ) ;
if ( hashmarkIndex !== - 1 ) {
url = url . slice ( 0 , hashmarkIndex ) ;
}
url += ( url . indexOf ( '?' ) === - 1 ? '?' : '&' ) + serializedParams ;
}
return url ;
2021-01-05 12:57:45 -05:00
}
2022-11-03 16:35:53 -04:00
class InterceptorManager {
constructor ( ) {
this . handlers = [ ] ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/ * *
* Add a new interceptor to the stack
*
* @ param { Function } fulfilled The function to handle ` then ` for a ` Promise `
* @ param { Function } rejected The function to handle ` reject ` for a ` Promise `
*
* @ return { Number } An ID used to remove interceptor later
* /
use ( fulfilled , rejected , options ) {
this . handlers . push ( {
fulfilled ,
rejected ,
synchronous : options ? options . synchronous : false ,
runWhen : options ? options . runWhen : null
} ) ;
return this . handlers . length - 1 ;
}
/ * *
* Remove an interceptor from the stack
*
* @ param { Number } id The ID that was returned by ` use `
*
* @ returns { Boolean } ` true ` if the interceptor was removed , ` false ` otherwise
* /
eject ( id ) {
if ( this . handlers [ id ] ) {
this . handlers [ id ] = null ;
}
}
/ * *
* Clear all interceptors from the stack
*
* @ returns { void }
* /
clear ( ) {
if ( this . handlers ) {
this . handlers = [ ] ;
}
}
/ * *
* Iterate over all the registered interceptors
*
* This method is particularly useful for skipping over any
* interceptors that may have become ` null ` calling ` eject ` .
*
* @ param { Function } fn The function to call for each interceptor
*
* @ returns { void }
* /
forEach ( fn ) {
utils . forEach ( this . handlers , function forEachHandler ( h ) {
if ( h !== null ) {
fn ( h ) ;
2021-09-09 08:42:30 -04:00
}
2022-11-03 16:35:53 -04:00
} ) ;
}
}
2023-02-04 07:28:08 -05:00
const InterceptorManager$1 = InterceptorManager ;
2022-11-03 16:35:53 -04:00
const transitionalDefaults = {
silentJSONParsing : true ,
forcedJSONParsing : true ,
clarifyTimeoutError : false
} ;
const URLSearchParams = url _ _default [ "default" ] . URLSearchParams ;
const platform = {
isNode : true ,
classes : {
URLSearchParams ,
FormData : FormData _ _default [ "default" ] ,
Blob : typeof Blob !== 'undefined' && Blob || null
} ,
protocols : [ 'http' , 'https' , 'file' , 'data' ]
} ;
function toURLEncodedForm ( data , options ) {
return toFormData ( data , new platform . classes . URLSearchParams ( ) , Object . assign ( {
visitor : function ( value , key , path , helpers ) {
if ( utils . isBuffer ( value ) ) {
this . append ( key , value . toString ( 'base64' ) ) ;
return false ;
}
return helpers . defaultVisitor . apply ( this , arguments ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
} , options ) ) ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/ * *
* It takes a string like ` foo[x][y][z] ` and returns an array like ` ['foo', 'x', 'y', 'z']
*
* @ param { string } name - The name of the property to get .
*
* @ returns An array of strings .
* /
function parsePropPath ( name ) {
// foo[x][y][z]
// foo.x.y.z
// foo-x-y-z
// foo x y z
return utils . matchAll ( /\w+|\[(\w*)]/g , name ) . map ( match => {
return match [ 0 ] === '[]' ? '' : match [ 1 ] || match [ 0 ] ;
} ) ;
}
/ * *
* Convert an array to an object .
*
* @ param { Array < any > } arr - The array to convert to an object .
*
* @ returns An object with the same keys and values as the array .
* /
function arrayToObject ( arr ) {
const obj = { } ;
const keys = Object . keys ( arr ) ;
let i ;
const len = keys . length ;
let key ;
for ( i = 0 ; i < len ; i ++ ) {
key = keys [ i ] ;
obj [ key ] = arr [ key ] ;
}
return obj ;
}
/ * *
* It takes a FormData object and returns a JavaScript object
*
* @ param { string } formData The FormData object to convert to JSON .
*
* @ returns { Object < string , any > | null } The converted object .
* /
function formDataToJSON ( formData ) {
function buildPath ( path , value , target , index ) {
let name = path [ index ++ ] ;
const isNumericKey = Number . isFinite ( + name ) ;
const isLast = index >= path . length ;
name = ! name && utils . isArray ( target ) ? target . length : name ;
if ( isLast ) {
if ( utils . hasOwnProp ( target , name ) ) {
target [ name ] = [ target [ name ] , value ] ;
2020-02-24 04:23:15 -05:00
} else {
2022-11-03 16:35:53 -04:00
target [ name ] = value ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
return ! isNumericKey ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
if ( ! target [ name ] || ! utils . isObject ( target [ name ] ) ) {
target [ name ] = [ ] ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
const result = buildPath ( path , value , target [ name ] , index ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( result && utils . isArray ( target [ name ] ) ) {
target [ name ] = arrayToObject ( target [ name ] ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
return ! isNumericKey ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( utils . isFormData ( formData ) && utils . isFunction ( formData . entries ) ) {
const obj = { } ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
utils . forEachEntry ( formData , ( name , value ) => {
buildPath ( parsePropPath ( name ) , value , obj , 0 ) ;
} ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
return obj ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
return null ;
}
2020-02-24 04:23:15 -05:00
2023-02-04 07:28:08 -05:00
const DEFAULT _CONTENT _TYPE = {
'Content-Type' : undefined
} ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/ * *
2023-02-04 07:28:08 -05:00
* It takes a string , tries to parse it , and if it fails , it returns the stringified version
* of the input
2022-11-03 16:35:53 -04:00
*
2023-02-04 07:28:08 -05:00
* @ param { any } rawValue - The value to be stringified .
* @ param { Function } parser - A function that parses a string into a JavaScript object .
* @ param { Function } encoder - A function that takes a value and returns a string .
2022-11-03 16:35:53 -04:00
*
2023-02-04 07:28:08 -05:00
* @ returns { string } A stringified version of the rawValue .
2022-11-03 16:35:53 -04:00
* /
2023-02-04 07:28:08 -05:00
function stringifySafely ( rawValue , parser , encoder ) {
if ( utils . isString ( rawValue ) ) {
try {
( parser || JSON . parse ) ( rawValue ) ;
return utils . trim ( rawValue ) ;
} catch ( e ) {
if ( e . name !== 'SyntaxError' ) {
throw e ;
}
}
2022-11-03 16:35:53 -04:00
}
2020-02-24 04:23:15 -05:00
2023-02-04 07:28:08 -05:00
return ( encoder || JSON . stringify ) ( rawValue ) ;
2022-11-03 16:35:53 -04:00
}
2020-02-24 04:23:15 -05:00
2023-02-04 07:28:08 -05:00
const defaults = {
2020-02-24 04:23:15 -05:00
2023-02-04 07:28:08 -05:00
transitional : transitionalDefaults ,
2020-10-01 16:20:08 -04:00
2023-02-04 07:28:08 -05:00
adapter : [ 'xhr' , 'http' ] ,
2020-10-01 16:20:08 -04:00
2023-02-04 07:28:08 -05:00
transformRequest : [ function transformRequest ( data , headers ) {
const contentType = headers . getContentType ( ) || '' ;
const hasJSONContentType = contentType . indexOf ( 'application/json' ) > - 1 ;
const isObjectPayload = utils . isObject ( data ) ;
2020-10-01 16:20:08 -04:00
2023-02-04 07:28:08 -05:00
if ( isObjectPayload && utils . isHTMLForm ( data ) ) {
data = new FormData ( data ) ;
}
2020-02-24 04:23:15 -05:00
2023-02-04 07:28:08 -05:00
const isFormData = utils . isFormData ( data ) ;
2020-02-24 04:23:15 -05:00
2023-02-04 07:28:08 -05:00
if ( isFormData ) {
if ( ! hasJSONContentType ) {
return data ;
}
return hasJSONContentType ? JSON . stringify ( formDataToJSON ( data ) ) : data ;
}
2020-02-24 04:23:15 -05:00
2023-02-04 07:28:08 -05:00
if ( utils . isArrayBuffer ( data ) ||
utils . isBuffer ( data ) ||
utils . isStream ( data ) ||
utils . isFile ( data ) ||
utils . isBlob ( data )
) {
return data ;
}
if ( utils . isArrayBufferView ( data ) ) {
return data . buffer ;
}
if ( utils . isURLSearchParams ( data ) ) {
headers . setContentType ( 'application/x-www-form-urlencoded;charset=utf-8' , false ) ;
return data . toString ( ) ;
2022-11-03 16:35:53 -04:00
}
2020-02-24 04:23:15 -05:00
2023-02-04 07:28:08 -05:00
let isFileList ;
2020-02-24 04:23:15 -05:00
2023-02-04 07:28:08 -05:00
if ( isObjectPayload ) {
if ( contentType . indexOf ( 'application/x-www-form-urlencoded' ) > - 1 ) {
return toURLEncodedForm ( data , this . formSerializer ) . toString ( ) ;
2020-02-24 04:23:15 -05:00
}
2023-02-04 07:28:08 -05:00
if ( ( isFileList = utils . isFileList ( data ) ) || contentType . indexOf ( 'multipart/form-data' ) > - 1 ) {
const _FormData = this . env && this . env . FormData ;
return toFormData (
isFileList ? { 'files[]' : data } : data ,
_FormData && new _FormData ( ) ,
this . formSerializer
) ;
}
2022-11-03 16:35:53 -04:00
}
2020-02-24 04:23:15 -05:00
2023-02-04 07:28:08 -05:00
if ( isObjectPayload || hasJSONContentType ) {
headers . setContentType ( 'application/json' , false ) ;
return stringifySafely ( data ) ;
}
return data ;
} ] ,
transformResponse : [ function transformResponse ( data ) {
const transitional = this . transitional || defaults . transitional ;
const forcedJSONParsing = transitional && transitional . forcedJSONParsing ;
const JSONRequested = this . responseType === 'json' ;
if ( data && utils . isString ( data ) && ( ( forcedJSONParsing && ! this . responseType ) || JSONRequested ) ) {
const silentJSONParsing = transitional && transitional . silentJSONParsing ;
const strictJSONParsing = ! silentJSONParsing && JSONRequested ;
try {
return JSON . parse ( data ) ;
} catch ( e ) {
if ( strictJSONParsing ) {
if ( e . name === 'SyntaxError' ) {
throw AxiosError . from ( e , AxiosError . ERR _BAD _RESPONSE , this , null , this . response ) ;
}
throw e ;
}
}
}
return data ;
} ] ,
/ * *
* A timeout in milliseconds to abort a request . If set to 0 ( default ) a
* timeout is not created .
* /
timeout : 0 ,
xsrfCookieName : 'XSRF-TOKEN' ,
xsrfHeaderName : 'X-XSRF-TOKEN' ,
maxContentLength : - 1 ,
maxBodyLength : - 1 ,
env : {
FormData : platform . classes . FormData ,
Blob : platform . classes . Blob
} ,
validateStatus : function validateStatus ( status ) {
return status >= 200 && status < 300 ;
} ,
headers : {
common : {
'Accept' : 'application/json, text/plain, */*'
}
2022-11-03 16:35:53 -04:00
}
2023-02-04 07:28:08 -05:00
} ;
2021-09-09 08:42:30 -04:00
2023-02-04 07:28:08 -05:00
utils . forEach ( [ 'delete' , 'get' , 'head' ] , function forEachMethodNoData ( method ) {
defaults . headers [ method ] = { } ;
} ) ;
utils . forEach ( [ 'post' , 'put' , 'patch' ] , function forEachMethodWithData ( method ) {
defaults . headers [ method ] = utils . merge ( DEFAULT _CONTENT _TYPE ) ;
} ) ;
const defaults$1 = defaults ;
2021-09-09 08:42:30 -04:00
2022-11-03 16:35:53 -04:00
// RawAxiosHeaders whose duplicates are ignored by node
// c.f. https://nodejs.org/api/http.html#http_message_headers
const ignoreDuplicateOf = utils . toObjectSet ( [
'age' , 'authorization' , 'content-length' , 'content-type' , 'etag' ,
'expires' , 'from' , 'host' , 'if-modified-since' , 'if-unmodified-since' ,
'last-modified' , 'location' , 'max-forwards' , 'proxy-authorization' ,
'referer' , 'retry-after' , 'user-agent'
] ) ;
2021-09-09 08:42:30 -04:00
2022-11-03 16:35:53 -04:00
/ * *
* Parse headers into an object
*
* ` ` `
* Date : Wed , 27 Aug 2014 08 : 58 : 49 GMT
* Content - Type : application / json
* Connection : keep - alive
* Transfer - Encoding : chunked
* ` ` `
*
* @ param { String } rawHeaders Headers needing to be parsed
*
* @ returns { Object } Headers parsed into an object
* /
const parseHeaders = rawHeaders => {
const parsed = { } ;
let key ;
let val ;
let i ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
rawHeaders && rawHeaders . split ( '\n' ) . forEach ( function parser ( line ) {
i = line . indexOf ( ':' ) ;
key = line . substring ( 0 , i ) . trim ( ) . toLowerCase ( ) ;
val = line . substring ( i + 1 ) . trim ( ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( ! key || ( parsed [ key ] && ignoreDuplicateOf [ key ] ) ) {
return ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
if ( key === 'set-cookie' ) {
if ( parsed [ key ] ) {
parsed [ key ] . push ( val ) ;
} else {
parsed [ key ] = [ val ] ;
}
2020-02-24 04:23:15 -05:00
} else {
2022-11-03 16:35:53 -04:00
parsed [ key ] = parsed [ key ] ? parsed [ key ] + ', ' + val : val ;
2020-02-24 04:23:15 -05:00
}
} ) ;
2020-03-25 06:23:19 -04:00
2022-11-03 16:35:53 -04:00
return parsed ;
} ;
2020-03-25 06:23:19 -04:00
2022-11-03 16:35:53 -04:00
const $internals = Symbol ( 'internals' ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
function normalizeHeader ( header ) {
return header && String ( header ) . trim ( ) . toLowerCase ( ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
function normalizeValue ( value ) {
if ( value === false || value == null ) {
return value ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
return utils . isArray ( value ) ? value . map ( normalizeValue ) : String ( value ) ;
2022-07-19 04:27:31 -04:00
}
2022-11-03 16:35:53 -04:00
function parseTokens ( str ) {
const tokens = Object . create ( null ) ;
const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g ;
let match ;
2022-07-19 04:27:31 -04:00
2022-11-03 16:35:53 -04:00
while ( ( match = tokensRE . exec ( str ) ) ) {
tokens [ match [ 1 ] ] = match [ 2 ] ;
2022-07-19 04:27:31 -04:00
}
2021-03-19 12:28:53 -04:00
2022-11-03 16:35:53 -04:00
return tokens ;
2021-03-19 12:28:53 -04:00
}
2023-02-04 07:28:08 -05:00
function isValidHeaderName ( str ) {
return /^[-_a-zA-Z]+$/ . test ( str . trim ( ) ) ;
}
2022-11-03 16:35:53 -04:00
function matchHeaderValue ( context , value , header , filter ) {
if ( utils . isFunction ( filter ) ) {
return filter . call ( this , value , header ) ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( ! utils . isString ( value ) ) return ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( utils . isString ( filter ) ) {
return value . indexOf ( filter ) !== - 1 ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( utils . isRegExp ( filter ) ) {
return filter . test ( value ) ;
}
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
function formatHeader ( header ) {
return header . trim ( )
. toLowerCase ( ) . replace ( /([a-z\d])(\w*)/g , ( w , char , str ) => {
return char . toUpperCase ( ) + str ;
} ) ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
function buildAccessors ( obj , header ) {
const accessorName = utils . toCamelCase ( ' ' + header ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
[ 'get' , 'set' , 'has' ] . forEach ( methodName => {
Object . defineProperty ( obj , methodName + accessorName , {
value : function ( arg1 , arg2 , arg3 ) {
return this [ methodName ] . call ( this , header , arg1 , arg2 , arg3 ) ;
} ,
configurable : true
} ) ;
} ) ;
}
2020-02-24 04:23:15 -05:00
2023-02-04 07:28:08 -05:00
class AxiosHeaders {
constructor ( headers ) {
headers && this . set ( headers ) ;
2022-11-03 16:35:53 -04:00
}
2020-02-24 04:23:15 -05:00
2023-02-04 07:28:08 -05:00
set ( header , valueOrRewrite , rewrite ) {
2022-11-03 16:35:53 -04:00
const self = this ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
function setHeader ( _value , _header , _rewrite ) {
const lHeader = normalizeHeader ( _header ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( ! lHeader ) {
throw new Error ( 'header name must be a non-empty string' ) ;
2020-02-24 04:23:15 -05:00
}
2023-02-04 07:28:08 -05:00
const key = utils . findKey ( self , lHeader ) ;
2020-02-24 04:23:15 -05:00
2023-02-04 07:28:08 -05:00
if ( ! key || self [ key ] === undefined || _rewrite === true || ( _rewrite === undefined && self [ key ] !== false ) ) {
self [ key || _header ] = normalizeValue ( _value ) ;
2022-11-03 16:35:53 -04:00
}
}
2022-10-05 11:29:30 -04:00
2023-02-04 07:28:08 -05:00
const setHeaders = ( headers , _rewrite ) =>
utils . forEach ( headers , ( _value , _header ) => setHeader ( _value , _header , _rewrite ) ) ;
if ( utils . isPlainObject ( header ) || header instanceof this . constructor ) {
setHeaders ( header , valueOrRewrite ) ;
} else if ( utils . isString ( header ) && ( header = header . trim ( ) ) && ! isValidHeaderName ( header ) ) {
setHeaders ( parseHeaders ( header ) , valueOrRewrite ) ;
2022-11-03 16:35:53 -04:00
} else {
2023-02-04 07:28:08 -05:00
header != null && setHeader ( valueOrRewrite , header , rewrite ) ;
2022-11-03 16:35:53 -04:00
}
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
return this ;
2023-02-04 07:28:08 -05:00
}
2022-10-05 11:29:30 -04:00
2023-02-04 07:28:08 -05:00
get ( header , parser ) {
2022-11-03 16:35:53 -04:00
header = normalizeHeader ( header ) ;
2022-10-05 11:29:30 -04:00
2023-02-04 07:28:08 -05:00
if ( header ) {
const key = utils . findKey ( this , header ) ;
2022-10-05 11:29:30 -04:00
2023-02-04 07:28:08 -05:00
if ( key ) {
const value = this [ key ] ;
2022-10-05 11:29:30 -04:00
2023-02-04 07:28:08 -05:00
if ( ! parser ) {
return value ;
}
2022-10-05 11:29:30 -04:00
2023-02-04 07:28:08 -05:00
if ( parser === true ) {
return parseTokens ( value ) ;
}
2022-10-05 11:29:30 -04:00
2023-02-04 07:28:08 -05:00
if ( utils . isFunction ( parser ) ) {
return parser . call ( this , value , key ) ;
}
2022-10-05 11:29:30 -04:00
2023-02-04 07:28:08 -05:00
if ( utils . isRegExp ( parser ) ) {
return parser . exec ( value ) ;
}
2022-10-05 11:29:30 -04:00
2023-02-04 07:28:08 -05:00
throw new TypeError ( 'parser must be boolean|regexp|function' ) ;
2022-11-03 16:35:53 -04:00
}
}
2023-02-04 07:28:08 -05:00
}
2020-02-24 04:23:15 -05:00
2023-02-04 07:28:08 -05:00
has ( header , matcher ) {
2022-11-03 16:35:53 -04:00
header = normalizeHeader ( header ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( header ) {
2023-02-04 07:28:08 -05:00
const key = utils . findKey ( this , header ) ;
2020-02-24 04:23:15 -05:00
2023-02-04 07:28:08 -05:00
return ! ! ( key && this [ key ] !== undefined && ( ! matcher || matchHeaderValue ( this , this [ key ] , key , matcher ) ) ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
return false ;
2023-02-04 07:28:08 -05:00
}
2020-02-24 04:23:15 -05:00
2023-02-04 07:28:08 -05:00
delete ( header , matcher ) {
2022-11-03 16:35:53 -04:00
const self = this ;
let deleted = false ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
function deleteHeader ( _header ) {
_header = normalizeHeader ( _header ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( _header ) {
2023-02-04 07:28:08 -05:00
const key = utils . findKey ( self , _header ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( key && ( ! matcher || matchHeaderValue ( self , self [ key ] , key , matcher ) ) ) {
delete self [ key ] ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
deleted = true ;
}
}
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( utils . isArray ( header ) ) {
header . forEach ( deleteHeader ) ;
} else {
deleteHeader ( header ) ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
return deleted ;
2023-02-04 07:28:08 -05:00
}
2022-10-05 11:29:30 -04:00
2023-02-04 07:28:08 -05:00
clear ( matcher ) {
const keys = Object . keys ( this ) ;
let i = keys . length ;
let deleted = false ;
2022-10-05 11:29:30 -04:00
2023-02-04 07:28:08 -05:00
while ( i -- ) {
const key = keys [ i ] ;
if ( ! matcher || matchHeaderValue ( this , this [ key ] , key , matcher ) ) {
delete this [ key ] ;
deleted = true ;
}
}
return deleted ;
}
normalize ( format ) {
2022-11-03 16:35:53 -04:00
const self = this ;
const headers = { } ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
utils . forEach ( this , ( value , header ) => {
2023-02-04 07:28:08 -05:00
const key = utils . findKey ( headers , header ) ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
if ( key ) {
self [ key ] = normalizeValue ( value ) ;
delete self [ header ] ;
return ;
}
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
const normalized = format ? formatHeader ( header ) : String ( header ) . trim ( ) ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
if ( normalized !== header ) {
delete self [ header ] ;
}
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
self [ normalized ] = normalizeValue ( value ) ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
headers [ normalized ] = true ;
} ) ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
return this ;
2023-02-04 07:28:08 -05:00
}
concat ( ... targets ) {
return this . constructor . concat ( this , ... targets ) ;
}
2022-10-05 11:29:30 -04:00
2023-02-04 07:28:08 -05:00
toJSON ( asStrings ) {
2022-11-03 16:35:53 -04:00
const obj = Object . create ( null ) ;
2022-10-05 11:29:30 -04:00
2023-02-04 07:28:08 -05:00
utils . forEach ( this , ( value , header ) => {
value != null && value !== false && ( obj [ header ] = asStrings && utils . isArray ( value ) ? value . join ( ', ' ) : value ) ;
} ) ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
return obj ;
}
2022-10-05 11:29:30 -04:00
2023-02-04 07:28:08 -05:00
[ Symbol . iterator ] ( ) {
return Object . entries ( this . toJSON ( ) ) [ Symbol . iterator ] ( ) ;
}
toString ( ) {
return Object . entries ( this . toJSON ( ) ) . map ( ( [ header , value ] ) => header + ': ' + value ) . join ( '\n' ) ;
}
get [ Symbol . toStringTag ] ( ) {
return 'AxiosHeaders' ;
}
static from ( thing ) {
2022-11-03 16:35:53 -04:00
return thing instanceof this ? thing : new this ( thing ) ;
2023-02-04 07:28:08 -05:00
}
2022-10-05 11:29:30 -04:00
2023-02-04 07:28:08 -05:00
static concat ( first , ... targets ) {
const computed = new this ( first ) ;
targets . forEach ( ( target ) => computed . set ( target ) ) ;
return computed ;
}
static accessor ( header ) {
2022-11-03 16:35:53 -04:00
const internals = this [ $internals ] = ( this [ $internals ] = {
accessors : { }
} ) ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
const accessors = internals . accessors ;
const prototype = this . prototype ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
function defineAccessor ( _header ) {
const lHeader = normalizeHeader ( _header ) ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
if ( ! accessors [ lHeader ] ) {
buildAccessors ( prototype , _header ) ;
accessors [ lHeader ] = true ;
}
}
2022-01-16 11:27:57 -05:00
2022-11-03 16:35:53 -04:00
utils . isArray ( header ) ? header . forEach ( defineAccessor ) : defineAccessor ( header ) ;
2022-01-16 11:27:57 -05:00
2022-11-03 16:35:53 -04:00
return this ;
}
2023-02-04 07:28:08 -05:00
}
2022-01-16 11:27:57 -05:00
2023-02-04 07:28:08 -05:00
AxiosHeaders . accessor ( [ 'Content-Type' , 'Content-Length' , 'Accept' , 'Accept-Encoding' , 'User-Agent' , 'Authorization' ] ) ;
2022-11-03 16:35:53 -04:00
utils . freezeMethods ( AxiosHeaders . prototype ) ;
utils . freezeMethods ( AxiosHeaders ) ;
2023-02-04 07:28:08 -05:00
const AxiosHeaders$1 = AxiosHeaders ;
/ * *
* Transform the data for a request or a response
*
* @ param { Array | Function } fns A single function or Array of functions
* @ param { ? Object } response The response object
*
* @ returns { * } The resulting transformed data
* /
function transformData ( fns , response ) {
const config = this || defaults$1 ;
const context = response || config ;
const headers = AxiosHeaders$1 . from ( context . headers ) ;
let data = context . data ;
utils . forEach ( fns , function transform ( fn ) {
data = fn . call ( config , data , headers . normalize ( ) , response ? response . status : undefined ) ;
} ) ;
headers . normalize ( ) ;
return data ;
}
function isCancel ( value ) {
return ! ! ( value && value . _ _CANCEL _ _ ) ;
}
/ * *
* A ` CanceledError ` is an object that is thrown when an operation is canceled .
*
* @ param { string = } message The message .
* @ param { Object = } config The config .
* @ param { Object = } request The request .
*
* @ returns { CanceledError } The created error .
* /
function CanceledError ( message , config , request ) {
// eslint-disable-next-line no-eq-null,eqeqeq
AxiosError . call ( this , message == null ? 'canceled' : message , AxiosError . ERR _CANCELED , config , request ) ;
this . name = 'CanceledError' ;
}
utils . inherits ( CanceledError , AxiosError , {
_ _CANCEL _ _ : true
} ) ;
/ * *
* Resolve or reject a Promise based on response status .
*
* @ param { Function } resolve A function that resolves the promise .
* @ param { Function } reject A function that rejects the promise .
* @ param { object } response The response .
*
* @ returns { object } The response .
* /
function settle ( resolve , reject , response ) {
const validateStatus = response . config . validateStatus ;
if ( ! response . status || ! validateStatus || validateStatus ( response . status ) ) {
resolve ( response ) ;
} else {
reject ( new AxiosError (
'Request failed with status code ' + response . status ,
[ AxiosError . ERR _BAD _REQUEST , AxiosError . ERR _BAD _RESPONSE ] [ Math . floor ( response . status / 100 ) - 4 ] ,
response . config ,
response . request ,
response
) ) ;
}
}
/ * *
* Determines whether the specified URL is absolute
*
* @ param { string } url The URL to test
*
* @ returns { boolean } True if the specified URL is absolute , otherwise false
* /
function isAbsoluteURL ( url ) {
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
// by any combination of letters, digits, plus, period, or hyphen.
return /^([a-z][a-z\d+\-.]*:)?\/\//i . test ( url ) ;
}
/ * *
* Creates a new URL by combining the specified URLs
*
* @ param { string } baseURL The base URL
* @ param { string } relativeURL The relative URL
*
* @ returns { string } The combined URL
* /
function combineURLs ( baseURL , relativeURL ) {
return relativeURL
? baseURL . replace ( /\/+$/ , '' ) + '/' + relativeURL . replace ( /^\/+/ , '' )
: baseURL ;
}
/ * *
* Creates a new URL by combining the baseURL with the requestedURL ,
* only when the requestedURL is not already an absolute URL .
* If the requestURL is absolute , this function returns the requestedURL untouched .
*
* @ param { string } baseURL The base URL
* @ param { string } requestedURL Absolute or relative URL to combine
*
* @ returns { string } The combined full path
* /
function buildFullPath ( baseURL , requestedURL ) {
if ( baseURL && ! isAbsoluteURL ( requestedURL ) ) {
return combineURLs ( baseURL , requestedURL ) ;
}
return requestedURL ;
}
const VERSION = "1.3.2" ;
function parseProtocol ( url ) {
const match = /^([-+\w]{1,25})(:?\/\/|:)/ . exec ( url ) ;
return match && match [ 1 ] || '' ;
}
const DATA _URL _PATTERN = /^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/ ;
/ * *
* Parse data uri to a Buffer or Blob
*
* @ param { String } uri
* @ param { ? Boolean } asBlob
* @ param { ? Object } options
* @ param { ? Function } options . Blob
*
* @ returns { Buffer | Blob }
* /
function fromDataURI ( uri , asBlob , options ) {
const _Blob = options && options . Blob || platform . classes . Blob ;
const protocol = parseProtocol ( uri ) ;
if ( asBlob === undefined && _Blob ) {
asBlob = true ;
}
if ( protocol === 'data' ) {
uri = protocol . length ? uri . slice ( protocol . length + 1 ) : uri ;
const match = DATA _URL _PATTERN . exec ( uri ) ;
if ( ! match ) {
throw new AxiosError ( 'Invalid URL' , AxiosError . ERR _INVALID _URL ) ;
}
const mime = match [ 1 ] ;
const isBase64 = match [ 2 ] ;
const body = match [ 3 ] ;
const buffer = Buffer . from ( decodeURIComponent ( body ) , isBase64 ? 'base64' : 'utf8' ) ;
if ( asBlob ) {
if ( ! _Blob ) {
throw new AxiosError ( 'Blob is not supported' , AxiosError . ERR _NOT _SUPPORT ) ;
}
return new _Blob ( [ buffer ] , { type : mime } ) ;
}
return buffer ;
}
throw new AxiosError ( 'Unsupported protocol ' + protocol , AxiosError . ERR _NOT _SUPPORT ) ;
}
2022-11-03 16:35:53 -04:00
/ * *
* Throttle decorator
* @ param { Function } fn
* @ param { Number } freq
* @ return { Function }
* /
function throttle ( fn , freq ) {
let timestamp = 0 ;
const threshold = 1000 / freq ;
let timer = null ;
return function throttled ( force , args ) {
const now = Date . now ( ) ;
if ( force || now - timestamp > threshold ) {
if ( timer ) {
clearTimeout ( timer ) ;
timer = null ;
}
timestamp = now ;
return fn . apply ( null , args ) ;
2022-01-16 11:27:57 -05:00
}
2022-11-03 16:35:53 -04:00
if ( ! timer ) {
timer = setTimeout ( ( ) => {
timer = null ;
timestamp = Date . now ( ) ;
return fn . apply ( null , args ) ;
} , threshold - ( now - timestamp ) ) ;
2022-01-16 11:27:57 -05:00
}
2022-11-03 16:35:53 -04:00
} ;
2022-01-16 11:27:57 -05:00
}
2022-11-03 16:35:53 -04:00
/ * *
* Calculate data maxRate
* @ param { Number } [ samplesCount = 10 ]
* @ param { Number } [ min = 1000 ]
* @ returns { Function }
* /
function speedometer ( samplesCount , min ) {
samplesCount = samplesCount || 10 ;
const bytes = new Array ( samplesCount ) ;
const timestamps = new Array ( samplesCount ) ;
let head = 0 ;
let tail = 0 ;
let firstSampleTS ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
min = min !== undefined ? min : 1000 ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
return function push ( chunkLength ) {
const now = Date . now ( ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
const startedAt = timestamps [ tail ] ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
if ( ! firstSampleTS ) {
firstSampleTS = now ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
bytes [ head ] = chunkLength ;
timestamps [ head ] = now ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
let i = tail ;
let bytesCount = 0 ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
while ( i !== head ) {
bytesCount += bytes [ i ++ ] ;
i = i % samplesCount ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
head = ( head + 1 ) % samplesCount ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
if ( head === tail ) {
tail = ( tail + 1 ) % samplesCount ;
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
if ( now - firstSampleTS < min ) {
return ;
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
const passed = startedAt && now - startedAt ;
2023-02-04 07:28:08 -05:00
return passed ? Math . round ( bytesCount * 1000 / passed ) : undefined ;
2021-01-24 07:14:13 -05:00
} ;
}
2022-11-03 16:35:53 -04:00
const kInternals = Symbol ( 'internals' ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
class AxiosTransformStream extends stream _ _default [ "default" ] . Transform {
constructor ( options ) {
options = utils . toFlatObject ( options , {
maxRate : 0 ,
chunkSize : 64 * 1024 ,
minChunkSize : 100 ,
timeWindow : 500 ,
ticksRate : 2 ,
samplesCount : 15
} , null , ( prop , source ) => {
return ! utils . isUndefined ( source [ prop ] ) ;
} ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
super ( {
readableHighWaterMark : options . chunkSize
} ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
const self = this ;
const internals = this [ kInternals ] = {
length : options . length ,
timeWindow : options . timeWindow ,
ticksRate : options . ticksRate ,
chunkSize : options . chunkSize ,
maxRate : options . maxRate ,
minChunkSize : options . minChunkSize ,
bytesSeen : 0 ,
isCaptured : false ,
notifiedBytesLoaded : 0 ,
ts : Date . now ( ) ,
bytes : 0 ,
onReadCallback : null
} ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
const _speedometer = speedometer ( internals . ticksRate * options . samplesCount , internals . timeWindow ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
this . on ( 'newListener' , event => {
if ( event === 'progress' ) {
if ( ! internals . isCaptured ) {
internals . isCaptured = true ;
}
}
} ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
let bytesNotified = 0 ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
internals . updateProgress = throttle ( function throttledHandler ( ) {
const totalBytes = internals . length ;
const bytesTransferred = internals . bytesSeen ;
const progressBytes = bytesTransferred - bytesNotified ;
if ( ! progressBytes || self . destroyed ) return ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
const rate = _speedometer ( progressBytes ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
bytesNotified = bytesTransferred ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
process . nextTick ( ( ) => {
self . emit ( 'progress' , {
'loaded' : bytesTransferred ,
'total' : totalBytes ,
'progress' : totalBytes ? ( bytesTransferred / totalBytes ) : undefined ,
'bytes' : progressBytes ,
'rate' : rate ? rate : undefined ,
'estimated' : rate && totalBytes && bytesTransferred <= totalBytes ?
( totalBytes - bytesTransferred ) / rate : undefined
} ) ;
} ) ;
} , internals . ticksRate ) ;
const onFinish = ( ) => {
internals . updateProgress ( true ) ;
} ;
this . once ( 'end' , onFinish ) ;
this . once ( 'error' , onFinish ) ;
}
_read ( size ) {
const internals = this [ kInternals ] ;
if ( internals . onReadCallback ) {
internals . onReadCallback ( ) ;
}
return super . _read ( size ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
_transform ( chunk , encoding , callback ) {
const self = this ;
const internals = this [ kInternals ] ;
const maxRate = internals . maxRate ;
const readableHighWaterMark = this . readableHighWaterMark ;
const timeWindow = internals . timeWindow ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
const divider = 1000 / timeWindow ;
const bytesThreshold = ( maxRate / divider ) ;
const minChunkSize = internals . minChunkSize !== false ? Math . max ( internals . minChunkSize , bytesThreshold * 0.01 ) : 0 ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
function pushChunk ( _chunk , _callback ) {
const bytes = Buffer . byteLength ( _chunk ) ;
internals . bytesSeen += bytes ;
internals . bytes += bytes ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( internals . isCaptured ) {
internals . updateProgress ( ) ;
}
2021-09-09 08:42:30 -04:00
2022-11-03 16:35:53 -04:00
if ( self . push ( _chunk ) ) {
process . nextTick ( _callback ) ;
} else {
internals . onReadCallback = ( ) => {
internals . onReadCallback = null ;
process . nextTick ( _callback ) ;
} ;
}
2021-09-09 08:42:30 -04:00
}
2022-11-03 16:35:53 -04:00
const transformChunk = ( _chunk , _callback ) => {
const chunkSize = Buffer . byteLength ( _chunk ) ;
let chunkRemainder = null ;
let maxChunkSize = readableHighWaterMark ;
let bytesLeft ;
let passed = 0 ;
2021-09-09 08:42:30 -04:00
2022-11-03 16:35:53 -04:00
if ( maxRate ) {
const now = Date . now ( ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( ! internals . ts || ( passed = ( now - internals . ts ) ) >= timeWindow ) {
internals . ts = now ;
bytesLeft = bytesThreshold - internals . bytes ;
internals . bytes = bytesLeft < 0 ? - bytesLeft : 0 ;
passed = 0 ;
}
2021-09-09 08:42:30 -04:00
2022-11-03 16:35:53 -04:00
bytesLeft = bytesThreshold - internals . bytes ;
}
2021-09-09 08:42:30 -04:00
2022-11-03 16:35:53 -04:00
if ( maxRate ) {
if ( bytesLeft <= 0 ) {
// next time window
return setTimeout ( ( ) => {
_callback ( null , _chunk ) ;
} , timeWindow - passed ) ;
}
2021-09-09 08:42:30 -04:00
2022-11-03 16:35:53 -04:00
if ( bytesLeft < maxChunkSize ) {
maxChunkSize = bytesLeft ;
}
}
2021-09-09 08:42:30 -04:00
2022-11-03 16:35:53 -04:00
if ( maxChunkSize && chunkSize > maxChunkSize && ( chunkSize - maxChunkSize ) > minChunkSize ) {
chunkRemainder = _chunk . subarray ( maxChunkSize ) ;
_chunk = _chunk . subarray ( 0 , maxChunkSize ) ;
}
2021-09-09 08:42:30 -04:00
2022-11-03 16:35:53 -04:00
pushChunk ( _chunk , chunkRemainder ? ( ) => {
process . nextTick ( _callback , null , chunkRemainder ) ;
} : _callback ) ;
} ;
2021-09-09 08:42:30 -04:00
2022-11-03 16:35:53 -04:00
transformChunk ( chunk , function transformNextChunk ( err , _chunk ) {
if ( err ) {
return callback ( err ) ;
}
2021-09-09 08:42:30 -04:00
2022-11-03 16:35:53 -04:00
if ( _chunk ) {
transformChunk ( _chunk , transformNextChunk ) ;
} else {
callback ( null ) ;
}
} ) ;
2021-09-09 08:42:30 -04:00
}
2022-11-03 16:35:53 -04:00
setLength ( length ) {
this [ kInternals ] . length = + length ;
return this ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
}
2020-02-24 04:23:15 -05:00
2023-02-04 07:28:08 -05:00
const AxiosTransformStream$1 = AxiosTransformStream ;
const { asyncIterator } = Symbol ;
const readBlob = async function * ( blob ) {
if ( blob . stream ) {
yield * blob . stream ( ) ;
} else if ( blob . arrayBuffer ) {
yield await blob . arrayBuffer ( ) ;
} else if ( blob [ asyncIterator ] ) {
yield * blob [ asyncIterator ] ( ) ;
} else {
yield blob ;
}
} ;
const readBlob$1 = readBlob ;
const BOUNDARY _ALPHABET = utils . ALPHABET . ALPHA _DIGIT + '-_' ;
const textEncoder = new util . TextEncoder ( ) ;
const CRLF = '\r\n' ;
const CRLF _BYTES = textEncoder . encode ( CRLF ) ;
const CRLF _BYTES _COUNT = 2 ;
class FormDataPart {
constructor ( name , value ) {
const { escapeName } = this . constructor ;
const isStringValue = utils . isString ( value ) ;
let headers = ` Content-Disposition: form-data; name=" ${ escapeName ( name ) } " ${
! isStringValue && value . name ? ` ; filename=" ${ escapeName ( value . name ) } " ` : ''
} $ { CRLF } ` ;
if ( isStringValue ) {
value = textEncoder . encode ( String ( value ) . replace ( /\r?\n|\r\n?/g , CRLF ) ) ;
} else {
headers += ` Content-Type: ${ value . type || "application/octet-stream" } ${ CRLF } ` ;
}
this . headers = textEncoder . encode ( headers + CRLF ) ;
this . contentLength = isStringValue ? value . byteLength : value . size ;
this . size = this . headers . byteLength + this . contentLength + CRLF _BYTES _COUNT ;
this . name = name ;
this . value = value ;
}
async * encode ( ) {
yield this . headers ;
const { value } = this ;
if ( utils . isTypedArray ( value ) ) {
yield value ;
} else {
yield * readBlob$1 ( value ) ;
}
yield CRLF _BYTES ;
}
static escapeName ( name ) {
return String ( name ) . replace ( /[\r\n"]/g , ( match ) => ( {
'\r' : '%0D' ,
'\n' : '%0A' ,
'"' : '%22' ,
} [ match ] ) ) ;
}
}
const formDataToStream = ( form , headersHandler , options ) => {
const {
tag = 'form-data-boundary' ,
size = 25 ,
boundary = tag + '-' + utils . generateString ( size , BOUNDARY _ALPHABET )
} = options || { } ;
if ( ! utils . isFormData ( form ) ) {
throw TypeError ( 'FormData instance required' ) ;
}
if ( boundary . length < 1 || boundary . length > 70 ) {
throw Error ( 'boundary must be 10-70 characters long' )
}
const boundaryBytes = textEncoder . encode ( '--' + boundary + CRLF ) ;
const footerBytes = textEncoder . encode ( '--' + boundary + '--' + CRLF + CRLF ) ;
let contentLength = footerBytes . byteLength ;
const parts = Array . from ( form . entries ( ) ) . map ( ( [ name , value ] ) => {
const part = new FormDataPart ( name , value ) ;
contentLength += part . size ;
return part ;
} ) ;
contentLength += boundaryBytes . byteLength * parts . length ;
contentLength = utils . toFiniteNumber ( contentLength ) ;
const computedHeaders = {
'Content-Type' : ` multipart/form-data; boundary= ${ boundary } `
} ;
if ( Number . isFinite ( contentLength ) ) {
computedHeaders [ 'Content-Length' ] = contentLength ;
}
headersHandler && headersHandler ( computedHeaders ) ;
return stream . Readable . from ( ( async function * ( ) {
for ( const part of parts ) {
yield boundaryBytes ;
yield * part . encode ( ) ;
}
yield footerBytes ;
} ) ( ) ) ;
} ;
const formDataToStream$1 = formDataToStream ;
class ZlibHeaderTransformStream extends stream _ _default [ "default" ] . Transform {
_ _transform ( chunk , encoding , callback ) {
this . push ( chunk ) ;
callback ( ) ;
}
_transform ( chunk , encoding , callback ) {
if ( chunk . length !== 0 ) {
this . _transform = this . _ _transform ;
// Add Default Compression headers if no zlib headers are present
if ( chunk [ 0 ] !== 120 ) { // Hex: 78
const header = Buffer . alloc ( 2 ) ;
header [ 0 ] = 120 ; // Hex: 78
header [ 1 ] = 156 ; // Hex: 9C
this . push ( header , encoding ) ;
}
}
this . _ _transform ( chunk , encoding , callback ) ;
}
}
const ZlibHeaderTransformStream$1 = ZlibHeaderTransformStream ;
const zlibOptions = {
flush : zlib _ _default [ "default" ] . constants . Z _SYNC _FLUSH ,
finishFlush : zlib _ _default [ "default" ] . constants . Z _SYNC _FLUSH
} ;
const brotliOptions = {
flush : zlib _ _default [ "default" ] . constants . BROTLI _OPERATION _FLUSH ,
finishFlush : zlib _ _default [ "default" ] . constants . BROTLI _OPERATION _FLUSH
} ;
2022-11-03 16:35:53 -04:00
const isBrotliSupported = utils . isFunction ( zlib _ _default [ "default" ] . createBrotliDecompress ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
const { http : httpFollow , https : httpsFollow } = followRedirects _ _default [ "default" ] ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
const isHttps = /https:?/ ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
const supportedProtocols = platform . protocols . map ( protocol => {
return protocol + ':' ;
2020-02-24 04:23:15 -05:00
} ) ;
2022-11-03 16:35:53 -04:00
/ * *
* If the proxy or config beforeRedirects functions are defined , call them with the options
* object .
*
* @ param { Object < string , any > } options - The options object that was passed to the request .
*
* @ returns { Object < string , any > }
* /
function dispatchBeforeRedirect ( options ) {
if ( options . beforeRedirects . proxy ) {
options . beforeRedirects . proxy ( options ) ;
}
if ( options . beforeRedirects . config ) {
options . beforeRedirects . config ( options ) ;
}
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/ * *
* If the proxy or config afterRedirects functions are defined , call them with the options
*
* @ param { http . ClientRequestArgs } options
* @ param { AxiosProxyConfig } configProxy configuration from Axios options object
* @ param { string } location
*
* @ returns { http . ClientRequestArgs }
* /
function setProxy ( options , configProxy , location ) {
let proxy = configProxy ;
if ( ! proxy && proxy !== false ) {
const proxyUrl = proxyFromEnv . getProxyForUrl ( location ) ;
if ( proxyUrl ) {
proxy = new URL ( proxyUrl ) ;
}
}
if ( proxy ) {
// Basic proxy authorization
if ( proxy . username ) {
proxy . auth = ( proxy . username || '' ) + ':' + ( proxy . password || '' ) ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( proxy . auth ) {
// Support proxy auth object form
if ( proxy . auth . username || proxy . auth . password ) {
proxy . auth = ( proxy . auth . username || '' ) + ':' + ( proxy . auth . password || '' ) ;
}
const base64 = Buffer
. from ( proxy . auth , 'utf8' )
. toString ( 'base64' ) ;
options . headers [ 'Proxy-Authorization' ] = 'Basic ' + base64 ;
}
2022-01-16 11:27:57 -05:00
2022-11-03 16:35:53 -04:00
options . headers . host = options . hostname + ( options . port ? ':' + options . port : '' ) ;
const proxyHost = proxy . hostname || proxy . host ;
options . hostname = proxyHost ;
// Replace 'host' since options is not a URL object
options . host = proxyHost ;
options . port = proxy . port ;
options . path = location ;
if ( proxy . protocol ) {
options . protocol = proxy . protocol . includes ( ':' ) ? proxy . protocol : ` ${ proxy . protocol } : ` ;
}
}
2022-01-16 11:27:57 -05:00
2022-11-03 16:35:53 -04:00
options . beforeRedirects . proxy = function beforeRedirect ( redirectOptions ) {
// Configure proxy for redirected request, passing the original config proxy to apply
// the exact same logic as if the redirected request was performed by axios directly.
setProxy ( redirectOptions , configProxy , redirectOptions . href ) ;
} ;
}
2022-01-16 11:27:57 -05:00
2023-02-04 07:28:08 -05:00
const isHttpAdapterSupported = typeof process !== 'undefined' && utils . kindOf ( process ) === 'process' ;
2022-11-03 16:35:53 -04:00
/*eslint consistent-return:0*/
2023-02-04 07:28:08 -05:00
const httpAdapter = isHttpAdapterSupported && function httpAdapter ( config ) {
/*eslint no-async-promise-executor:0*/
return new Promise ( async function dispatchHttpRequest ( resolvePromise , rejectPromise ) {
2022-11-03 16:35:53 -04:00
let data = config . data ;
const responseType = config . responseType ;
const responseEncoding = config . responseEncoding ;
const method = config . method . toUpperCase ( ) ;
let isFinished ;
let isDone ;
let rejected = false ;
let req ;
// temporary internal emitter until the AxiosRequest class will be implemented
const emitter = new EventEmitter _ _default [ "default" ] ( ) ;
function onFinished ( ) {
if ( isFinished ) return ;
isFinished = true ;
if ( config . cancelToken ) {
config . cancelToken . unsubscribe ( abort ) ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( config . signal ) {
config . signal . removeEventListener ( 'abort' , abort ) ;
}
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
emitter . removeAllListeners ( ) ;
}
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
function done ( value , isRejected ) {
if ( isDone ) return ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
isDone = true ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
if ( isRejected ) {
rejected = true ;
onFinished ( ) ;
}
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
isRejected ? rejectPromise ( value ) : resolvePromise ( value ) ;
}
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
const resolve = function resolve ( value ) {
done ( value ) ;
} ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
const reject = function reject ( value ) {
done ( value , true ) ;
} ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
function abort ( reason ) {
emitter . emit ( 'abort' , ! reason || reason . type ? new CanceledError ( null , config , req ) : reason ) ;
}
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
emitter . once ( 'abort' , reject ) ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
if ( config . cancelToken || config . signal ) {
config . cancelToken && config . cancelToken . subscribe ( abort ) ;
if ( config . signal ) {
config . signal . aborted ? abort ( ) : config . signal . addEventListener ( 'abort' , abort ) ;
}
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
// Parse url
const fullPath = buildFullPath ( config . baseURL , config . url ) ;
2023-02-04 07:28:08 -05:00
const parsed = new URL ( fullPath , 'http://localhost' ) ;
2022-11-03 16:35:53 -04:00
const protocol = parsed . protocol || supportedProtocols [ 0 ] ;
if ( protocol === 'data:' ) {
let convertedData ;
if ( method !== 'GET' ) {
return settle ( resolve , reject , {
status : 405 ,
statusText : 'method not allowed' ,
headers : { } ,
config
} ) ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
try {
convertedData = fromDataURI ( config . url , responseType === 'blob' , {
Blob : config . env && config . env . Blob
} ) ;
} catch ( err ) {
throw AxiosError . from ( err , AxiosError . ERR _BAD _REQUEST , config ) ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( responseType === 'text' ) {
convertedData = convertedData . toString ( responseEncoding ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( ! responseEncoding || responseEncoding === 'utf8' ) {
2023-02-04 07:28:08 -05:00
convertedData = utils . stripBOM ( convertedData ) ;
2022-11-03 16:35:53 -04:00
}
} else if ( responseType === 'stream' ) {
convertedData = stream _ _default [ "default" ] . Readable . from ( convertedData ) ;
}
2020-10-01 16:20:08 -04:00
2022-11-03 16:35:53 -04:00
return settle ( resolve , reject , {
data : convertedData ,
status : 200 ,
statusText : 'OK' ,
2023-02-04 07:28:08 -05:00
headers : new AxiosHeaders$1 ( ) ,
2022-11-03 16:35:53 -04:00
config
} ) ;
2020-10-01 16:20:08 -04:00
}
2022-11-03 16:35:53 -04:00
if ( supportedProtocols . indexOf ( protocol ) === - 1 ) {
return reject ( new AxiosError (
'Unsupported protocol ' + protocol ,
AxiosError . ERR _BAD _REQUEST ,
config
) ) ;
2020-10-01 16:20:08 -04:00
}
2020-02-24 04:23:15 -05:00
2023-02-04 07:28:08 -05:00
const headers = AxiosHeaders$1 . from ( config . headers ) . normalize ( ) ;
2022-11-03 16:35:53 -04:00
// Set User-Agent (required by some servers)
// See https://github.com/axios/axios/issues/69
// User-Agent is specified; handle case where no UA header is desired
// Only set header if it hasn't been set in config
headers . set ( 'User-Agent' , 'axios/' + VERSION , false ) ;
const onDownloadProgress = config . onDownloadProgress ;
const onUploadProgress = config . onUploadProgress ;
const maxRate = config . maxRate ;
let maxUploadRate = undefined ;
let maxDownloadRate = undefined ;
2023-02-04 07:28:08 -05:00
// support for spec compliant FormData objects
if ( utils . isSpecCompliantForm ( data ) ) {
const userBoundary = headers . getContentType ( /boundary=([-_\w\d]{10,70})/i ) ;
data = formDataToStream$1 ( data , ( formHeaders ) => {
headers . set ( formHeaders ) ;
} , {
tag : ` axios- ${ VERSION } -boundary ` ,
boundary : userBoundary && userBoundary [ 1 ] || undefined
} ) ;
// support for https://www.npmjs.com/package/form-data api
} else if ( utils . isFormData ( data ) && utils . isFunction ( data . getHeaders ) ) {
2022-11-03 16:35:53 -04:00
headers . set ( data . getHeaders ( ) ) ;
2023-02-04 07:28:08 -05:00
if ( ! headers . hasContentLength ( ) ) {
try {
const knownLength = await util _ _default [ "default" ] . promisify ( data . getLength ) . call ( data ) ;
headers . setContentLength ( knownLength ) ;
/*eslint no-empty:0*/
} catch ( e ) {
}
}
} else if ( utils . isBlob ( data ) ) {
data . size && headers . setContentType ( data . type || 'application/octet-stream' ) ;
headers . setContentLength ( data . size || 0 ) ;
data = stream _ _default [ "default" ] . Readable . from ( readBlob$1 ( data ) ) ;
2022-11-03 16:35:53 -04:00
} else if ( data && ! utils . isStream ( data ) ) {
if ( Buffer . isBuffer ( data ) ) ; else if ( utils . isArrayBuffer ( data ) ) {
data = Buffer . from ( new Uint8Array ( data ) ) ;
} else if ( utils . isString ( data ) ) {
data = Buffer . from ( data , 'utf-8' ) ;
} else {
return reject ( new AxiosError (
'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream' ,
AxiosError . ERR _BAD _REQUEST ,
config
) ) ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
// Add Content-Length header if data exists
2023-02-04 07:28:08 -05:00
headers . setContentLength ( data . length , false ) ;
2020-10-01 16:20:08 -04:00
2022-11-03 16:35:53 -04:00
if ( config . maxBodyLength > - 1 && data . length > config . maxBodyLength ) {
return reject ( new AxiosError (
'Request body larger than maxBodyLength limit' ,
AxiosError . ERR _BAD _REQUEST ,
config
) ) ;
}
2020-02-24 04:23:15 -05:00
}
2023-02-04 07:28:08 -05:00
const contentLength = utils . toFiniteNumber ( headers . getContentLength ( ) ) ;
2022-11-03 16:35:53 -04:00
if ( utils . isArray ( maxRate ) ) {
maxUploadRate = maxRate [ 0 ] ;
maxDownloadRate = maxRate [ 1 ] ;
} else {
maxUploadRate = maxDownloadRate = maxRate ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
if ( data && ( onUploadProgress || maxUploadRate ) ) {
if ( ! utils . isStream ( data ) ) {
data = stream _ _default [ "default" ] . Readable . from ( data , { objectMode : false } ) ;
}
2020-02-24 04:23:15 -05:00
2023-02-04 07:28:08 -05:00
data = stream _ _default [ "default" ] . pipeline ( [ data , new AxiosTransformStream$1 ( {
length : contentLength ,
2022-11-03 16:35:53 -04:00
maxRate : utils . toFiniteNumber ( maxUploadRate )
} ) ] , utils . noop ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
onUploadProgress && data . on ( 'progress' , progress => {
onUploadProgress ( Object . assign ( progress , {
upload : true
} ) ) ;
} ) ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
// HTTP basic authentication
let auth = undefined ;
if ( config . auth ) {
const username = config . auth . username || '' ;
const password = config . auth . password || '' ;
auth = username + ':' + password ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( ! auth && parsed . username ) {
const urlUsername = parsed . username ;
const urlPassword = parsed . password ;
auth = urlUsername + ':' + urlPassword ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
auth && headers . delete ( 'authorization' ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
let path ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
try {
path = buildURL (
parsed . pathname + parsed . search ,
config . params ,
config . paramsSerializer
) . replace ( /^\?/ , '' ) ;
} catch ( err ) {
const customErr = new Error ( err . message ) ;
customErr . config = config ;
customErr . url = config . url ;
customErr . exists = true ;
return reject ( customErr ) ;
}
2023-02-04 07:28:08 -05:00
headers . set (
'Accept-Encoding' ,
'gzip, compress, deflate' + ( isBrotliSupported ? ', br' : '' ) , false
) ;
2022-11-03 16:35:53 -04:00
const options = {
path ,
method : method ,
headers : headers . toJSON ( ) ,
agents : { http : config . httpAgent , https : config . httpsAgent } ,
auth ,
protocol ,
beforeRedirect : dispatchBeforeRedirect ,
beforeRedirects : { }
} ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( config . socketPath ) {
options . socketPath = config . socketPath ;
} else {
options . hostname = parsed . hostname ;
options . port = parsed . port ;
setProxy ( options , config . proxy , protocol + '//' + parsed . hostname + ( parsed . port ? ':' + parsed . port : '' ) + options . path ) ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
let transport ;
const isHttpsRequest = isHttps . test ( options . protocol ) ;
options . agent = isHttpsRequest ? config . httpsAgent : config . httpAgent ;
if ( config . transport ) {
transport = config . transport ;
} else if ( config . maxRedirects === 0 ) {
transport = isHttpsRequest ? https _ _default [ "default" ] : http _ _default [ "default" ] ;
} else {
if ( config . maxRedirects ) {
options . maxRedirects = config . maxRedirects ;
}
if ( config . beforeRedirect ) {
options . beforeRedirects . config = config . beforeRedirect ;
}
transport = isHttpsRequest ? httpsFollow : httpFollow ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( config . maxBodyLength > - 1 ) {
options . maxBodyLength = config . maxBodyLength ;
} else {
// follow-redirects does not skip comparison, so it should always succeed for axios -1 unlimited
options . maxBodyLength = Infinity ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( config . insecureHTTPParser ) {
options . insecureHTTPParser = config . insecureHTTPParser ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
// Create the request
req = transport . request ( options , function handleResponse ( res ) {
if ( req . destroyed ) return ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
const streams = [ res ] ;
2020-02-24 04:23:15 -05:00
2023-02-04 07:28:08 -05:00
const responseLength = + res . headers [ 'content-length' ] ;
if ( onDownloadProgress ) {
const transformStream = new AxiosTransformStream$1 ( {
length : utils . toFiniteNumber ( responseLength ) ,
maxRate : utils . toFiniteNumber ( maxDownloadRate )
} ) ;
onDownloadProgress && transformStream . on ( 'progress' , progress => {
onDownloadProgress ( Object . assign ( progress , {
download : true
} ) ) ;
} ) ;
streams . push ( transformStream ) ;
}
// decompress the response body transparently if required
2022-11-03 16:35:53 -04:00
let responseStream = res ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
// return the last request in case of redirects
const lastRequest = res . req || req ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
// if decompress disabled we should not decompress
2023-02-04 07:28:08 -05:00
if ( config . decompress !== false && res . headers [ 'content-encoding' ] ) {
2022-11-03 16:35:53 -04:00
// if no content, but headers still say that it is encoded,
// remove the header not confuse downstream operations
2023-02-04 07:28:08 -05:00
if ( method === 'HEAD' || res . statusCode === 204 ) {
2022-11-03 16:35:53 -04:00
delete res . headers [ 'content-encoding' ] ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
switch ( res . headers [ 'content-encoding' ] ) {
/*eslint default-case:0*/
case 'gzip' :
2023-02-04 07:28:08 -05:00
case 'x-gzip' :
2022-11-03 16:35:53 -04:00
case 'compress' :
2023-02-04 07:28:08 -05:00
case 'x-compress' :
// add the unzipper to the body stream processing pipeline
streams . push ( zlib _ _default [ "default" ] . createUnzip ( zlibOptions ) ) ;
// remove the content-encoding in order to not confuse downstream operations
delete res . headers [ 'content-encoding' ] ;
break ;
2022-11-03 16:35:53 -04:00
case 'deflate' :
2023-02-04 07:28:08 -05:00
streams . push ( new ZlibHeaderTransformStream$1 ( ) ) ;
2022-11-03 16:35:53 -04:00
// add the unzipper to the body stream processing pipeline
2023-02-04 07:28:08 -05:00
streams . push ( zlib _ _default [ "default" ] . createUnzip ( zlibOptions ) ) ;
2022-11-03 16:35:53 -04:00
// remove the content-encoding in order to not confuse downstream operations
delete res . headers [ 'content-encoding' ] ;
break ;
case 'br' :
if ( isBrotliSupported ) {
2023-02-04 07:28:08 -05:00
streams . push ( zlib _ _default [ "default" ] . createBrotliDecompress ( brotliOptions ) ) ;
2022-11-03 16:35:53 -04:00
delete res . headers [ 'content-encoding' ] ;
}
}
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
responseStream = streams . length > 1 ? stream _ _default [ "default" ] . pipeline ( streams , utils . noop ) : streams [ 0 ] ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
const offListeners = stream _ _default [ "default" ] . finished ( responseStream , ( ) => {
offListeners ( ) ;
onFinished ( ) ;
} ) ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
const response = {
status : res . statusCode ,
statusText : res . statusMessage ,
2023-02-04 07:28:08 -05:00
headers : new AxiosHeaders$1 ( res . headers ) ,
2022-11-03 16:35:53 -04:00
config ,
request : lastRequest
} ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
if ( responseType === 'stream' ) {
response . data = responseStream ;
settle ( resolve , reject , response ) ;
} else {
const responseBuffer = [ ] ;
let totalResponseBytes = 0 ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
responseStream . on ( 'data' , function handleStreamData ( chunk ) {
responseBuffer . push ( chunk ) ;
totalResponseBytes += chunk . length ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
// make sure the content length is not over the maxContentLength if specified
if ( config . maxContentLength > - 1 && totalResponseBytes > config . maxContentLength ) {
// stream.destroy() emit aborted event before calling reject() on Node.js v16
rejected = true ;
responseStream . destroy ( ) ;
reject ( new AxiosError ( 'maxContentLength size of ' + config . maxContentLength + ' exceeded' ,
AxiosError . ERR _BAD _RESPONSE , config , lastRequest ) ) ;
}
} ) ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
responseStream . on ( 'aborted' , function handlerStreamAborted ( ) {
if ( rejected ) {
return ;
}
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
const err = new AxiosError (
'maxContentLength size of ' + config . maxContentLength + ' exceeded' ,
AxiosError . ERR _BAD _RESPONSE ,
config ,
lastRequest
) ;
responseStream . destroy ( err ) ;
reject ( err ) ;
} ) ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
responseStream . on ( 'error' , function handleStreamError ( err ) {
if ( req . destroyed ) return ;
reject ( AxiosError . from ( err , null , config , lastRequest ) ) ;
} ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
responseStream . on ( 'end' , function handleStreamEnd ( ) {
try {
let responseData = responseBuffer . length === 1 ? responseBuffer [ 0 ] : Buffer . concat ( responseBuffer ) ;
if ( responseType !== 'arraybuffer' ) {
responseData = responseData . toString ( responseEncoding ) ;
if ( ! responseEncoding || responseEncoding === 'utf8' ) {
responseData = utils . stripBOM ( responseData ) ;
}
}
response . data = responseData ;
} catch ( err ) {
reject ( AxiosError . from ( err , null , config , response . request , response ) ) ;
}
settle ( resolve , reject , response ) ;
} ) ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
emitter . once ( 'abort' , err => {
if ( ! responseStream . destroyed ) {
responseStream . emit ( 'error' , err ) ;
responseStream . destroy ( ) ;
}
} ) ;
} ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
emitter . once ( 'abort' , err => {
reject ( err ) ;
req . destroy ( err ) ;
} ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
// Handle errors
req . on ( 'error' , function handleRequestError ( err ) {
// @todo remove
// if (req.aborted && err.code !== AxiosError.ERR_FR_TOO_MANY_REDIRECTS) return;
reject ( AxiosError . from ( err , null , config , req ) ) ;
} ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
// set tcp keep alive to prevent drop connection by peer
req . on ( 'socket' , function handleRequestSocket ( socket ) {
// default interval of sending ack packet is 1 minute
socket . setKeepAlive ( true , 1000 * 60 ) ;
} ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
// Handle request timeout
if ( config . timeout ) {
// This is forcing a int timeout to avoid problems if the `req` interface doesn't handle other types.
const timeout = parseInt ( config . timeout , 10 ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( isNaN ( timeout ) ) {
reject ( new AxiosError (
'error trying to parse `config.timeout` to int' ,
AxiosError . ERR _BAD _OPTION _VALUE ,
config ,
req
) ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
return ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
// Sometime, the response will be very slow, and does not respond, the connect event will be block by event loop system.
// And timer callback will be fired, and abort() will be invoked before connection, then get "socket hang up" and code ECONNRESET.
// At this time, if we have a large number of request, nodejs will hang up some socket on background. and the number will up and up.
// And then these socket which be hang up will devouring CPU little by little.
// ClientRequest.setTimeout will be fired on the specify milliseconds, and can make sure that abort() will be fired after connect.
req . setTimeout ( timeout , function handleRequestTimeout ( ) {
if ( isDone ) return ;
let timeoutErrorMessage = config . timeout ? 'timeout of ' + config . timeout + 'ms exceeded' : 'timeout exceeded' ;
const transitional = config . transitional || transitionalDefaults ;
if ( config . timeoutErrorMessage ) {
timeoutErrorMessage = config . timeoutErrorMessage ;
}
reject ( new AxiosError (
timeoutErrorMessage ,
transitional . clarifyTimeoutError ? AxiosError . ETIMEDOUT : AxiosError . ECONNABORTED ,
config ,
req
) ) ;
abort ( ) ;
} ) ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
// Send the request
if ( utils . isStream ( data ) ) {
let ended = false ;
let errored = false ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
data . on ( 'end' , ( ) => {
ended = true ;
} ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
data . once ( 'error' , err => {
errored = true ;
req . destroy ( err ) ;
} ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
data . on ( 'close' , ( ) => {
if ( ! ended && ! errored ) {
abort ( new CanceledError ( 'Request stream has been aborted' , config , req ) ) ;
}
} ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
data . pipe ( req ) ;
} else {
req . end ( data ) ;
}
} ) ;
2023-02-04 07:28:08 -05:00
} ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
const cookies = platform . isStandardBrowserEnv ?
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
// Standard browser envs support document.cookie
( function standardBrowserEnv ( ) {
return {
write : function write ( name , value , expires , path , domain , secure ) {
const cookie = [ ] ;
cookie . push ( name + '=' + encodeURIComponent ( value ) ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( utils . isNumber ( expires ) ) {
cookie . push ( 'expires=' + new Date ( expires ) . toGMTString ( ) ) ;
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
if ( utils . isString ( path ) ) {
cookie . push ( 'path=' + path ) ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( utils . isString ( domain ) ) {
cookie . push ( 'domain=' + domain ) ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( secure === true ) {
cookie . push ( 'secure' ) ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
document . cookie = cookie . join ( '; ' ) ;
} ,
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
read : function read ( name ) {
const match = document . cookie . match ( new RegExp ( '(^|;\\s*)(' + name + ')=([^;]*)' ) ) ;
return ( match ? decodeURIComponent ( match [ 3 ] ) : null ) ;
} ,
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
remove : function remove ( name ) {
this . write ( name , '' , Date . now ( ) - 86400000 ) ;
}
} ;
} ) ( ) :
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
// Non standard browser env (web workers, react-native) lack needed support.
( function nonStandardBrowserEnv ( ) {
return {
write : function write ( ) { } ,
read : function read ( ) { return null ; } ,
remove : function remove ( ) { }
} ;
} ) ( ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
const isURLSameOrigin = platform . isStandardBrowserEnv ?
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
// Standard browser envs have full support of the APIs needed to test
// whether the request URL is of the same origin as current location.
( function standardBrowserEnv ( ) {
const msie = /(msie|trident)/i . test ( navigator . userAgent ) ;
const urlParsingNode = document . createElement ( 'a' ) ;
let originURL ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/ * *
* Parse a URL to discover it ' s components
*
* @ param { String } url The URL to be parsed
* @ returns { Object }
* /
function resolveURL ( url ) {
let href = url ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( msie ) {
// IE needs attribute set twice to normalize properties
urlParsingNode . setAttribute ( 'href' , href ) ;
href = urlParsingNode . href ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
urlParsingNode . setAttribute ( 'href' , href ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
return {
href : urlParsingNode . href ,
protocol : urlParsingNode . protocol ? urlParsingNode . protocol . replace ( /:$/ , '' ) : '' ,
host : urlParsingNode . host ,
search : urlParsingNode . search ? urlParsingNode . search . replace ( /^\?/ , '' ) : '' ,
hash : urlParsingNode . hash ? urlParsingNode . hash . replace ( /^#/ , '' ) : '' ,
hostname : urlParsingNode . hostname ,
port : urlParsingNode . port ,
pathname : ( urlParsingNode . pathname . charAt ( 0 ) === '/' ) ?
urlParsingNode . pathname :
'/' + urlParsingNode . pathname
} ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
originURL = resolveURL ( window . location . href ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/ * *
* Determine if a URL shares the same origin as the current location
*
* @ param { String } requestURL The URL to test
* @ returns { boolean } True if URL shares the same origin , otherwise false
* /
return function isURLSameOrigin ( requestURL ) {
const parsed = ( utils . isString ( requestURL ) ) ? resolveURL ( requestURL ) : requestURL ;
return ( parsed . protocol === originURL . protocol &&
parsed . host === originURL . host ) ;
} ;
} ) ( ) :
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
// Non standard browser envs (web workers, react-native) lack needed support.
( function nonStandardBrowserEnv ( ) {
return function isURLSameOrigin ( ) {
return true ;
} ;
} ) ( ) ;
function progressEventReducer ( listener , isDownloadStream ) {
let bytesNotified = 0 ;
const _speedometer = speedometer ( 50 , 250 ) ;
return e => {
const loaded = e . loaded ;
const total = e . lengthComputable ? e . total : undefined ;
const progressBytes = loaded - bytesNotified ;
const rate = _speedometer ( progressBytes ) ;
const inRange = loaded <= total ;
bytesNotified = loaded ;
const data = {
loaded ,
total ,
progress : total ? ( loaded / total ) : undefined ,
bytes : progressBytes ,
rate : rate ? rate : undefined ,
2023-02-04 07:28:08 -05:00
estimated : rate && total && inRange ? ( total - loaded ) / rate : undefined ,
event : e
2022-11-03 16:35:53 -04:00
} ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
data [ isDownloadStream ? 'download' : 'upload' ] = true ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
listener ( data ) ;
} ;
}
2021-01-24 07:14:13 -05:00
2023-02-04 07:28:08 -05:00
const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined' ;
const xhrAdapter = isXHRAdapterSupported && function ( config ) {
2022-11-03 16:35:53 -04:00
return new Promise ( function dispatchXhrRequest ( resolve , reject ) {
let requestData = config . data ;
2023-02-04 07:28:08 -05:00
const requestHeaders = AxiosHeaders$1 . from ( config . headers ) . normalize ( ) ;
2022-11-03 16:35:53 -04:00
const responseType = config . responseType ;
let onCanceled ;
function done ( ) {
if ( config . cancelToken ) {
config . cancelToken . unsubscribe ( onCanceled ) ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
if ( config . signal ) {
config . signal . removeEventListener ( 'abort' , onCanceled ) ;
}
2021-01-24 07:14:13 -05:00
}
2023-02-04 07:28:08 -05:00
if ( utils . isFormData ( requestData ) && ( platform . isStandardBrowserEnv || platform . isStandardBrowserWebWorkerEnv ) ) {
2022-11-03 16:35:53 -04:00
requestHeaders . setContentType ( false ) ; // Let the browser set it
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
let request = new XMLHttpRequest ( ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
// HTTP basic authentication
if ( config . auth ) {
const username = config . auth . username || '' ;
const password = config . auth . password ? unescape ( encodeURIComponent ( config . auth . password ) ) : '' ;
requestHeaders . set ( 'Authorization' , 'Basic ' + btoa ( username + ':' + password ) ) ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
const fullPath = buildFullPath ( config . baseURL , config . url ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
request . open ( config . method . toUpperCase ( ) , buildURL ( fullPath , config . params , config . paramsSerializer ) , true ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
// Set the request timeout in MS
request . timeout = config . timeout ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
function onloadend ( ) {
if ( ! request ) {
return ;
}
// Prepare the response
2023-02-04 07:28:08 -05:00
const responseHeaders = AxiosHeaders$1 . from (
2022-11-03 16:35:53 -04:00
'getAllResponseHeaders' in request && request . getAllResponseHeaders ( )
) ;
2023-02-04 07:28:08 -05:00
const responseData = ! responseType || responseType === 'text' || responseType === 'json' ?
2022-11-03 16:35:53 -04:00
request . responseText : request . response ;
const response = {
data : responseData ,
status : request . status ,
statusText : request . statusText ,
headers : responseHeaders ,
config ,
request
} ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
settle ( function _resolve ( value ) {
resolve ( value ) ;
done ( ) ;
} , function _reject ( err ) {
reject ( err ) ;
done ( ) ;
} , response ) ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
// Clean up request
request = null ;
}
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
if ( 'onloadend' in request ) {
// Use onloadend if available
request . onloadend = onloadend ;
} else {
// Listen for ready state to emulate onloadend
request . onreadystatechange = function handleLoad ( ) {
if ( ! request || request . readyState !== 4 ) {
return ;
}
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
// The request errored out and we didn't get a response, this will be
// handled by onerror instead
// With one exception: request that using file: protocol, most browsers
// will return status as 0 even though it's a successful request
if ( request . status === 0 && ! ( request . responseURL && request . responseURL . indexOf ( 'file:' ) === 0 ) ) {
return ;
}
// readystate handler is calling before onerror or ontimeout handlers,
// so we should call onloadend on the next 'tick'
setTimeout ( onloadend ) ;
} ;
}
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
// Handle browser request cancellation (as opposed to a manual cancellation)
request . onabort = function handleAbort ( ) {
if ( ! request ) {
return ;
}
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
reject ( new AxiosError ( 'Request aborted' , AxiosError . ECONNABORTED , config , request ) ) ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
// Clean up request
request = null ;
} ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
// Handle low level network errors
request . onerror = function handleError ( ) {
// Real errors are hidden from us by the browser
// onerror should only fire if it's a network error
reject ( new AxiosError ( 'Network Error' , AxiosError . ERR _NETWORK , config , request ) ) ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
// Clean up request
request = null ;
} ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
// Handle timeout
request . ontimeout = function handleTimeout ( ) {
let timeoutErrorMessage = config . timeout ? 'timeout of ' + config . timeout + 'ms exceeded' : 'timeout exceeded' ;
const transitional = config . transitional || transitionalDefaults ;
if ( config . timeoutErrorMessage ) {
timeoutErrorMessage = config . timeoutErrorMessage ;
}
reject ( new AxiosError (
timeoutErrorMessage ,
transitional . clarifyTimeoutError ? AxiosError . ETIMEDOUT : AxiosError . ECONNABORTED ,
config ,
request ) ) ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
// Clean up request
request = null ;
} ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
// Add xsrf header
// This is only done if running in a standard browser environment.
// Specifically not if we're in a web worker, or react-native.
if ( platform . isStandardBrowserEnv ) {
// Add xsrf header
const xsrfValue = ( config . withCredentials || isURLSameOrigin ( fullPath ) )
&& config . xsrfCookieName && cookies . read ( config . xsrfCookieName ) ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
if ( xsrfValue ) {
requestHeaders . set ( config . xsrfHeaderName , xsrfValue ) ;
}
}
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
// Remove Content-Type if data is undefined
requestData === undefined && requestHeaders . setContentType ( null ) ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
// Add headers to the request
if ( 'setRequestHeader' in request ) {
utils . forEach ( requestHeaders . toJSON ( ) , function setRequestHeader ( val , key ) {
request . setRequestHeader ( key , val ) ;
} ) ;
2022-10-05 11:29:30 -04:00
}
2022-11-03 16:35:53 -04:00
// Add withCredentials to request if needed
if ( ! utils . isUndefined ( config . withCredentials ) ) {
request . withCredentials = ! ! config . withCredentials ;
2022-10-05 11:29:30 -04:00
}
2022-11-03 16:35:53 -04:00
// Add responseType to request if needed
if ( responseType && responseType !== 'json' ) {
request . responseType = config . responseType ;
}
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
// Handle progress if needed
if ( typeof config . onDownloadProgress === 'function' ) {
request . addEventListener ( 'progress' , progressEventReducer ( config . onDownloadProgress , true ) ) ;
}
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
// Not all browsers support upload events
if ( typeof config . onUploadProgress === 'function' && request . upload ) {
request . upload . addEventListener ( 'progress' , progressEventReducer ( config . onUploadProgress ) ) ;
}
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
if ( config . cancelToken || config . signal ) {
// Handle cancellation
// eslint-disable-next-line func-names
onCanceled = cancel => {
if ( ! request ) {
return ;
}
reject ( ! cancel || cancel . type ? new CanceledError ( null , config , request ) : cancel ) ;
request . abort ( ) ;
request = null ;
} ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
config . cancelToken && config . cancelToken . subscribe ( onCanceled ) ;
if ( config . signal ) {
config . signal . aborted ? onCanceled ( ) : config . signal . addEventListener ( 'abort' , onCanceled ) ;
}
}
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
const protocol = parseProtocol ( fullPath ) ;
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
if ( protocol && platform . protocols . indexOf ( protocol ) === - 1 ) {
reject ( new AxiosError ( 'Unsupported protocol ' + protocol + ':' , AxiosError . ERR _BAD _REQUEST , config ) ) ;
return ;
}
2022-10-05 11:29:30 -04:00
2022-11-03 16:35:53 -04:00
// Send the request
request . send ( requestData || null ) ;
} ) ;
2023-02-04 07:28:08 -05:00
} ;
2022-10-05 11:29:30 -04:00
2023-02-04 07:28:08 -05:00
const knownAdapters = {
2022-11-03 16:35:53 -04:00
http : httpAdapter ,
xhr : xhrAdapter
} ;
2022-10-05 11:29:30 -04:00
2023-02-04 07:28:08 -05:00
utils . forEach ( knownAdapters , ( fn , value ) => {
if ( fn ) {
2022-11-03 16:35:53 -04:00
try {
2023-02-04 07:28:08 -05:00
Object . defineProperty ( fn , 'name' , { value } ) ;
2022-11-03 16:35:53 -04:00
} catch ( e ) {
2023-02-04 07:28:08 -05:00
// eslint-disable-next-line no-empty
2022-11-03 16:35:53 -04:00
}
2023-02-04 07:28:08 -05:00
Object . defineProperty ( fn , 'adapterName' , { value } ) ;
2021-01-24 07:14:13 -05:00
}
2023-02-04 07:28:08 -05:00
} ) ;
2021-01-24 07:14:13 -05:00
2023-02-04 07:28:08 -05:00
const adapters = {
getAdapter : ( adapters ) => {
adapters = utils . isArray ( adapters ) ? adapters : [ adapters ] ;
2021-01-24 07:14:13 -05:00
2023-02-04 07:28:08 -05:00
const { length } = adapters ;
let nameOrAdapter ;
let adapter ;
2021-01-24 07:14:13 -05:00
2023-02-04 07:28:08 -05:00
for ( let i = 0 ; i < length ; i ++ ) {
nameOrAdapter = adapters [ i ] ;
if ( ( adapter = utils . isString ( nameOrAdapter ) ? knownAdapters [ nameOrAdapter . toLowerCase ( ) ] : nameOrAdapter ) ) {
break ;
2022-11-03 16:35:53 -04:00
}
}
2021-01-24 07:14:13 -05:00
2023-02-04 07:28:08 -05:00
if ( ! adapter ) {
if ( adapter === false ) {
throw new AxiosError (
` Adapter ${ nameOrAdapter } is not supported by the environment ` ,
'ERR_NOT_SUPPORT'
2022-11-03 16:35:53 -04:00
) ;
}
2021-01-24 07:14:13 -05:00
2023-02-04 07:28:08 -05:00
throw new Error (
utils . hasOwnProp ( knownAdapters , nameOrAdapter ) ?
` Adapter ' ${ nameOrAdapter } ' is not available in the build ` :
` Unknown adapter ' ${ nameOrAdapter } ' `
) ;
2022-11-03 16:35:53 -04:00
}
2021-01-24 07:14:13 -05:00
2023-02-04 07:28:08 -05:00
if ( ! utils . isFunction ( adapter ) ) {
throw new TypeError ( 'adapter is not a function' ) ;
2021-01-24 07:14:13 -05:00
}
2023-02-04 07:28:08 -05:00
return adapter ;
2022-11-03 16:35:53 -04:00
} ,
2023-02-04 07:28:08 -05:00
adapters : knownAdapters
2022-11-03 16:35:53 -04:00
} ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
/ * *
* Throws a ` CanceledError ` if cancellation has been requested .
*
* @ param { Object } config The config that is to be used for the request
*
* @ returns { void }
* /
function throwIfCancellationRequested ( config ) {
if ( config . cancelToken ) {
config . cancelToken . throwIfRequested ( ) ;
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
if ( config . signal && config . signal . aborted ) {
2023-02-04 07:28:08 -05:00
throw new CanceledError ( null , config ) ;
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
/ * *
* Dispatch a request to the server using the configured adapter .
*
* @ param { object } config The config that is to be used for the request
*
* @ returns { Promise } The Promise to be fulfilled
* /
function dispatchRequest ( config ) {
throwIfCancellationRequested ( config ) ;
2021-01-24 07:14:13 -05:00
2023-02-04 07:28:08 -05:00
config . headers = AxiosHeaders$1 . from ( config . headers ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
// Transform request data
config . data = transformData . call (
config ,
config . transformRequest
) ;
2021-01-24 07:14:13 -05:00
2023-02-04 07:28:08 -05:00
if ( [ 'post' , 'put' , 'patch' ] . indexOf ( config . method ) !== - 1 ) {
config . headers . setContentType ( 'application/x-www-form-urlencoded' , false ) ;
}
const adapter = adapters . getAdapter ( config . adapter || defaults$1 . adapter ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
return adapter ( config ) . then ( function onAdapterResolution ( response ) {
throwIfCancellationRequested ( config ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
// Transform response data
response . data = transformData . call (
config ,
config . transformResponse ,
response
) ;
2021-01-24 07:14:13 -05:00
2023-02-04 07:28:08 -05:00
response . headers = AxiosHeaders$1 . from ( response . headers ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
return response ;
} , function onAdapterRejection ( reason ) {
if ( ! isCancel ( reason ) ) {
throwIfCancellationRequested ( config ) ;
// Transform response data
if ( reason && reason . response ) {
reason . response . data = transformData . call (
config ,
config . transformResponse ,
reason . response
) ;
2023-02-04 07:28:08 -05:00
reason . response . headers = AxiosHeaders$1 . from ( reason . response . headers ) ;
2022-11-03 16:35:53 -04:00
}
}
return Promise . reject ( reason ) ;
} ) ;
}
2023-02-04 07:28:08 -05:00
const headersToObject = ( thing ) => thing instanceof AxiosHeaders$1 ? thing . toJSON ( ) : thing ;
2022-11-03 16:35:53 -04:00
/ * *
* Config - specific merge - function which creates a new config - object
* by merging two configuration objects together .
*
* @ param { Object } config1
* @ param { Object } config2
*
* @ returns { Object } New object resulting from merging config2 to config1
* /
function mergeConfig ( config1 , config2 ) {
// eslint-disable-next-line no-param-reassign
config2 = config2 || { } ;
const config = { } ;
2023-02-04 07:28:08 -05:00
function getMergedValue ( target , source , caseless ) {
2022-11-03 16:35:53 -04:00
if ( utils . isPlainObject ( target ) && utils . isPlainObject ( source ) ) {
2023-02-04 07:28:08 -05:00
return utils . merge . call ( { caseless } , target , source ) ;
2022-11-03 16:35:53 -04:00
} else if ( utils . isPlainObject ( source ) ) {
return utils . merge ( { } , source ) ;
} else if ( utils . isArray ( source ) ) {
return source . slice ( ) ;
}
return source ;
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
// eslint-disable-next-line consistent-return
2023-02-04 07:28:08 -05:00
function mergeDeepProperties ( a , b , caseless ) {
if ( ! utils . isUndefined ( b ) ) {
return getMergedValue ( a , b , caseless ) ;
} else if ( ! utils . isUndefined ( a ) ) {
return getMergedValue ( undefined , a , caseless ) ;
2022-11-03 16:35:53 -04:00
}
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
// eslint-disable-next-line consistent-return
2023-02-04 07:28:08 -05:00
function valueFromConfig2 ( a , b ) {
if ( ! utils . isUndefined ( b ) ) {
return getMergedValue ( undefined , b ) ;
2022-11-03 16:35:53 -04:00
}
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
// eslint-disable-next-line consistent-return
2023-02-04 07:28:08 -05:00
function defaultToConfig2 ( a , b ) {
if ( ! utils . isUndefined ( b ) ) {
return getMergedValue ( undefined , b ) ;
} else if ( ! utils . isUndefined ( a ) ) {
return getMergedValue ( undefined , a ) ;
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
// eslint-disable-next-line consistent-return
2023-02-04 07:28:08 -05:00
function mergeDirectKeys ( a , b , prop ) {
2022-11-03 16:35:53 -04:00
if ( prop in config2 ) {
2023-02-04 07:28:08 -05:00
return getMergedValue ( a , b ) ;
2022-11-03 16:35:53 -04:00
} else if ( prop in config1 ) {
2023-02-04 07:28:08 -05:00
return getMergedValue ( undefined , a ) ;
2022-11-03 16:35:53 -04:00
}
}
const mergeMap = {
2023-02-04 07:28:08 -05:00
url : valueFromConfig2 ,
method : valueFromConfig2 ,
data : valueFromConfig2 ,
baseURL : defaultToConfig2 ,
transformRequest : defaultToConfig2 ,
transformResponse : defaultToConfig2 ,
paramsSerializer : defaultToConfig2 ,
timeout : defaultToConfig2 ,
timeoutMessage : defaultToConfig2 ,
withCredentials : defaultToConfig2 ,
adapter : defaultToConfig2 ,
responseType : defaultToConfig2 ,
xsrfCookieName : defaultToConfig2 ,
xsrfHeaderName : defaultToConfig2 ,
onUploadProgress : defaultToConfig2 ,
onDownloadProgress : defaultToConfig2 ,
decompress : defaultToConfig2 ,
maxContentLength : defaultToConfig2 ,
maxBodyLength : defaultToConfig2 ,
beforeRedirect : defaultToConfig2 ,
transport : defaultToConfig2 ,
httpAgent : defaultToConfig2 ,
httpsAgent : defaultToConfig2 ,
cancelToken : defaultToConfig2 ,
socketPath : defaultToConfig2 ,
responseEncoding : defaultToConfig2 ,
validateStatus : mergeDirectKeys ,
headers : ( a , b ) => mergeDeepProperties ( headersToObject ( a ) , headersToObject ( b ) , true )
2022-11-03 16:35:53 -04:00
} ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
utils . forEach ( Object . keys ( config1 ) . concat ( Object . keys ( config2 ) ) , function computeConfigValue ( prop ) {
const merge = mergeMap [ prop ] || mergeDeepProperties ;
2023-02-04 07:28:08 -05:00
const configValue = merge ( config1 [ prop ] , config2 [ prop ] , prop ) ;
2022-11-03 16:35:53 -04:00
( utils . isUndefined ( configValue ) && merge !== mergeDirectKeys ) || ( config [ prop ] = configValue ) ;
} ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
return config ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
const validators$1 = { } ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
// eslint-disable-next-line func-names
[ 'object' , 'boolean' , 'number' , 'function' , 'string' , 'symbol' ] . forEach ( ( type , i ) => {
validators$1 [ type ] = function validator ( thing ) {
return typeof thing === type || 'a' + ( i < 1 ? 'n ' : ' ' ) + type ;
} ;
} ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
const deprecatedWarnings = { } ;
2021-02-19 06:51:47 -05:00
2022-11-03 16:35:53 -04:00
/ * *
* Transitional option validator
*
* @ param { function | boolean ? } validator - set to false if the transitional option has been removed
* @ param { string ? } version - deprecated version / removed since version
* @ param { string ? } message - some message with additional info
*
* @ returns { function }
* /
validators$1 . transitional = function transitional ( validator , version , message ) {
function formatMessage ( opt , desc ) {
return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + ( message ? '. ' + message : '' ) ;
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
// eslint-disable-next-line func-names
return ( value , opt , opts ) => {
if ( validator === false ) {
throw new AxiosError (
formatMessage ( opt , ' has been removed' + ( version ? ' in ' + version : '' ) ) ,
AxiosError . ERR _DEPRECATED
) ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
if ( version && ! deprecatedWarnings [ opt ] ) {
deprecatedWarnings [ opt ] = true ;
// eslint-disable-next-line no-console
console . warn (
formatMessage (
opt ,
' has been deprecated since v' + version + ' and will be removed in the near future'
)
) ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
return validator ? validator ( value , opt , opts ) : true ;
} ;
} ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
/ * *
* Assert object ' s properties type
*
* @ param { object } options
* @ param { object } schema
* @ param { boolean ? } allowUnknown
*
* @ returns { object }
* /
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
function assertOptions ( options , schema , allowUnknown ) {
if ( typeof options !== 'object' ) {
throw new AxiosError ( 'options must be an object' , AxiosError . ERR _BAD _OPTION _VALUE ) ;
}
const keys = Object . keys ( options ) ;
let i = keys . length ;
while ( i -- > 0 ) {
const opt = keys [ i ] ;
const validator = schema [ opt ] ;
if ( validator ) {
const value = options [ opt ] ;
const result = value === undefined || validator ( value , opt , options ) ;
if ( result !== true ) {
throw new AxiosError ( 'option ' + opt + ' must be ' + result , AxiosError . ERR _BAD _OPTION _VALUE ) ;
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
continue ;
}
if ( allowUnknown !== true ) {
throw new AxiosError ( 'Unknown option ' + opt , AxiosError . ERR _BAD _OPTION ) ;
2021-01-24 07:14:13 -05:00
}
}
2022-11-03 16:35:53 -04:00
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
const validator = {
assertOptions ,
validators : validators$1
2021-01-24 07:14:13 -05:00
} ;
2022-11-03 16:35:53 -04:00
const validators = validator . validators ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
/ * *
* Create a new instance of Axios
*
* @ param { Object } instanceConfig The default config for the instance
*
* @ return { Axios } A new instance of Axios
* /
class Axios {
constructor ( instanceConfig ) {
this . defaults = instanceConfig ;
this . interceptors = {
2023-02-04 07:28:08 -05:00
request : new InterceptorManager$1 ( ) ,
response : new InterceptorManager$1 ( )
2022-11-03 16:35:53 -04:00
} ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
/ * *
* Dispatch a request
*
* @ param { String | Object } configOrUrl The config specific for this request ( merged with this . defaults )
* @ param { ? Object } config
*
* @ returns { Promise } The Promise to be fulfilled
* /
request ( configOrUrl , config ) {
/*eslint no-param-reassign:0*/
// Allow for axios('example/url'[, config]) a la fetch API
if ( typeof configOrUrl === 'string' ) {
config = config || { } ;
config . url = configOrUrl ;
} else {
config = configOrUrl || { } ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
config = mergeConfig ( this . defaults , config ) ;
2021-01-24 07:14:13 -05:00
2023-02-04 07:28:08 -05:00
const { transitional , paramsSerializer , headers } = config ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
if ( transitional !== undefined ) {
validator . assertOptions ( transitional , {
silentJSONParsing : validators . transitional ( validators . boolean ) ,
forcedJSONParsing : validators . transitional ( validators . boolean ) ,
clarifyTimeoutError : validators . transitional ( validators . boolean )
} , false ) ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
if ( paramsSerializer !== undefined ) {
validator . assertOptions ( paramsSerializer , {
encode : validators . function ,
serialize : validators . function
} , true ) ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
// Set config.method
config . method = ( config . method || this . defaults . method || 'get' ) . toLowerCase ( ) ;
2021-01-24 07:14:13 -05:00
2023-02-04 07:28:08 -05:00
let contextHeaders ;
2022-11-03 16:35:53 -04:00
// Flatten headers
2023-02-04 07:28:08 -05:00
contextHeaders = headers && utils . merge (
headers . common ,
headers [ config . method ]
2022-11-03 16:35:53 -04:00
) ;
2021-01-24 07:14:13 -05:00
2023-02-04 07:28:08 -05:00
contextHeaders && utils . forEach (
2022-11-03 16:35:53 -04:00
[ 'delete' , 'get' , 'head' , 'post' , 'put' , 'patch' , 'common' ] ,
2023-02-04 07:28:08 -05:00
( method ) => {
delete headers [ method ] ;
2022-11-03 16:35:53 -04:00
}
) ;
2021-01-24 07:14:13 -05:00
2023-02-04 07:28:08 -05:00
config . headers = AxiosHeaders$1 . concat ( contextHeaders , headers ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
// filter out skipped interceptors
const requestInterceptorChain = [ ] ;
let synchronousRequestInterceptors = true ;
this . interceptors . request . forEach ( function unshiftRequestInterceptors ( interceptor ) {
if ( typeof interceptor . runWhen === 'function' && interceptor . runWhen ( config ) === false ) {
return ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor . synchronous ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
requestInterceptorChain . unshift ( interceptor . fulfilled , interceptor . rejected ) ;
2021-01-24 07:14:13 -05:00
} ) ;
2022-11-03 16:35:53 -04:00
const responseInterceptorChain = [ ] ;
this . interceptors . response . forEach ( function pushResponseInterceptors ( interceptor ) {
responseInterceptorChain . push ( interceptor . fulfilled , interceptor . rejected ) ;
} ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
let promise ;
let i = 0 ;
let len ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
if ( ! synchronousRequestInterceptors ) {
const chain = [ dispatchRequest . bind ( this ) , undefined ] ;
chain . unshift . apply ( chain , requestInterceptorChain ) ;
chain . push . apply ( chain , responseInterceptorChain ) ;
len = chain . length ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
promise = Promise . resolve ( config ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
while ( i < len ) {
promise = promise . then ( chain [ i ++ ] , chain [ i ++ ] ) ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
return promise ;
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
len = requestInterceptorChain . length ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
let newConfig = config ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
i = 0 ;
while ( i < len ) {
const onFulfilled = requestInterceptorChain [ i ++ ] ;
const onRejected = requestInterceptorChain [ i ++ ] ;
try {
newConfig = onFulfilled ( newConfig ) ;
} catch ( error ) {
onRejected . call ( this , error ) ;
break ;
}
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
try {
promise = dispatchRequest . call ( this , newConfig ) ;
} catch ( error ) {
return Promise . reject ( error ) ;
2021-09-09 08:42:30 -04:00
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
i = 0 ;
len = responseInterceptorChain . length ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
while ( i < len ) {
promise = promise . then ( responseInterceptorChain [ i ++ ] , responseInterceptorChain [ i ++ ] ) ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
return promise ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
getUri ( config ) {
config = mergeConfig ( this . defaults , config ) ;
const fullPath = buildFullPath ( config . baseURL , config . url ) ;
return buildURL ( fullPath , config . params , config . paramsSerializer ) ;
}
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
// Provide aliases for supported request methods
utils . forEach ( [ 'delete' , 'get' , 'head' , 'options' ] , function forEachMethodNoData ( method ) {
/*eslint func-names:0*/
Axios . prototype [ method ] = function ( url , config ) {
return this . request ( mergeConfig ( config || { } , {
method ,
url ,
data : ( config || { } ) . data
} ) ) ;
} ;
} ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
utils . forEach ( [ 'post' , 'put' , 'patch' ] , function forEachMethodWithData ( method ) {
/*eslint func-names:0*/
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
function generateHTTPMethod ( isForm ) {
return function httpMethod ( url , data , config ) {
return this . request ( mergeConfig ( config || { } , {
method ,
headers : isForm ? {
'Content-Type' : 'multipart/form-data'
} : { } ,
url ,
data
} ) ) ;
} ;
2021-01-24 07:14:13 -05:00
}
2022-11-03 16:35:53 -04:00
Axios . prototype [ method ] = generateHTTPMethod ( ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
Axios . prototype [ method + 'Form' ] = generateHTTPMethod ( true ) ;
} ) ;
2021-01-24 07:14:13 -05:00
2023-02-04 07:28:08 -05:00
const Axios$1 = Axios ;
2022-11-03 16:35:53 -04:00
/ * *
* A ` CancelToken ` is an object that can be used to request cancellation of an operation .
*
* @ param { Function } executor The executor function .
*
* @ returns { CancelToken }
* /
class CancelToken {
constructor ( executor ) {
if ( typeof executor !== 'function' ) {
throw new TypeError ( 'executor must be a function.' ) ;
}
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
let resolvePromise ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
this . promise = new Promise ( function promiseExecutor ( resolve ) {
resolvePromise = resolve ;
} ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
const token = this ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
// eslint-disable-next-line func-names
this . promise . then ( cancel => {
if ( ! token . _listeners ) return ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
let i = token . _listeners . length ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
while ( i -- > 0 ) {
token . _listeners [ i ] ( cancel ) ;
}
token . _listeners = null ;
} ) ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
// eslint-disable-next-line func-names
this . promise . then = onfulfilled => {
let _resolve ;
// eslint-disable-next-line func-names
const promise = new Promise ( resolve => {
token . subscribe ( resolve ) ;
_resolve = resolve ;
} ) . then ( onfulfilled ) ;
promise . cancel = function reject ( ) {
token . unsubscribe ( _resolve ) ;
} ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
return promise ;
} ;
2021-01-24 07:14:13 -05:00
2022-11-03 16:35:53 -04:00
executor ( function cancel ( message , config , request ) {
if ( token . reason ) {
// Cancellation has already been requested
return ;
}
2022-11-03 15:46:35 -04:00
2022-11-03 16:35:53 -04:00
token . reason = new CanceledError ( message , config , request ) ;
resolvePromise ( token . reason ) ;
} ) ;
}
2022-11-03 15:46:35 -04:00
2022-11-03 16:35:53 -04:00
/ * *
* Throws a ` CanceledError ` if cancellation has been requested .
* /
throwIfRequested ( ) {
if ( this . reason ) {
throw this . reason ;
}
}
2022-11-03 15:46:35 -04:00
2022-11-03 16:35:53 -04:00
/ * *
* Subscribe to the cancel signal
* /
2022-11-03 15:46:35 -04:00
2022-11-03 16:35:53 -04:00
subscribe ( listener ) {
if ( this . reason ) {
listener ( this . reason ) ;
return ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( this . _listeners ) {
this . _listeners . push ( listener ) ;
} else {
this . _listeners = [ listener ] ;
}
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/ * *
* Unsubscribe from the cancel signal
* /
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
unsubscribe ( listener ) {
if ( ! this . _listeners ) {
return ;
}
const index = this . _listeners . indexOf ( listener ) ;
if ( index !== - 1 ) {
this . _listeners . splice ( index , 1 ) ;
}
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
/ * *
* Returns an object that contains a new ` CancelToken ` and a function that , when called ,
* cancels the ` CancelToken ` .
* /
static source ( ) {
let cancel ;
const token = new CancelToken ( function executor ( c ) {
cancel = c ;
} ) ;
return {
token ,
cancel
} ;
}
}
2020-02-24 04:23:15 -05:00
2023-02-04 07:28:08 -05:00
const CancelToken$1 = CancelToken ;
2020-02-24 04:23:15 -05:00
/ * *
2022-11-03 16:35:53 -04:00
* Syntactic sugar for invoking a function and expanding an array for arguments .
*
* Common use case would be to use ` Function.prototype.apply ` .
*
* ` ` ` js
* function f ( x , y , z ) { }
* var args = [ 1 , 2 , 3 ] ;
* f . apply ( null , args ) ;
* ` ` `
*
* With ` spread ` this example can be re - written .
*
* ` ` ` js
* spread ( function ( x , y , z ) { } ) ( [ 1 , 2 , 3 ] ) ;
* ` ` `
*
* @ param { Function } callback
*
* @ returns { Function }
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
function spread ( callback ) {
return function wrap ( arr ) {
return callback . apply ( null , arr ) ;
} ;
2020-02-24 04:23:15 -05:00
}
/ * *
2022-11-03 16:35:53 -04:00
* Determines whether the payload is an error thrown by Axios
2020-02-24 04:23:15 -05:00
*
2022-11-03 16:35:53 -04:00
* @ param { * } payload The value to test
*
* @ returns { boolean } True if the payload is an error thrown by Axios , otherwise false
2020-02-24 04:23:15 -05:00
* /
2022-11-03 16:35:53 -04:00
function isAxiosError ( payload ) {
return utils . isObject ( payload ) && ( payload . isAxiosError === true ) ;
}
2020-02-24 04:23:15 -05:00
2023-02-04 07:28:08 -05:00
const HttpStatusCode = {
Continue : 100 ,
SwitchingProtocols : 101 ,
Processing : 102 ,
EarlyHints : 103 ,
Ok : 200 ,
Created : 201 ,
Accepted : 202 ,
NonAuthoritativeInformation : 203 ,
NoContent : 204 ,
ResetContent : 205 ,
PartialContent : 206 ,
MultiStatus : 207 ,
AlreadyReported : 208 ,
ImUsed : 226 ,
MultipleChoices : 300 ,
MovedPermanently : 301 ,
Found : 302 ,
SeeOther : 303 ,
NotModified : 304 ,
UseProxy : 305 ,
Unused : 306 ,
TemporaryRedirect : 307 ,
PermanentRedirect : 308 ,
BadRequest : 400 ,
Unauthorized : 401 ,
PaymentRequired : 402 ,
Forbidden : 403 ,
NotFound : 404 ,
MethodNotAllowed : 405 ,
NotAcceptable : 406 ,
ProxyAuthenticationRequired : 407 ,
RequestTimeout : 408 ,
Conflict : 409 ,
Gone : 410 ,
LengthRequired : 411 ,
PreconditionFailed : 412 ,
PayloadTooLarge : 413 ,
UriTooLong : 414 ,
UnsupportedMediaType : 415 ,
RangeNotSatisfiable : 416 ,
ExpectationFailed : 417 ,
ImATeapot : 418 ,
MisdirectedRequest : 421 ,
UnprocessableEntity : 422 ,
Locked : 423 ,
FailedDependency : 424 ,
TooEarly : 425 ,
UpgradeRequired : 426 ,
PreconditionRequired : 428 ,
TooManyRequests : 429 ,
RequestHeaderFieldsTooLarge : 431 ,
UnavailableForLegalReasons : 451 ,
InternalServerError : 500 ,
NotImplemented : 501 ,
BadGateway : 502 ,
ServiceUnavailable : 503 ,
GatewayTimeout : 504 ,
HttpVersionNotSupported : 505 ,
VariantAlsoNegotiates : 506 ,
InsufficientStorage : 507 ,
LoopDetected : 508 ,
NotExtended : 510 ,
NetworkAuthenticationRequired : 511 ,
} ;
Object . entries ( HttpStatusCode ) . forEach ( ( [ key , value ] ) => {
HttpStatusCode [ value ] = key ;
} ) ;
const HttpStatusCode$1 = HttpStatusCode ;
2022-11-03 16:35:53 -04:00
/ * *
* Create an instance of Axios
*
* @ param { Object } defaultConfig The default config for the instance
*
* @ returns { Axios } A new instance of Axios
* /
function createInstance ( defaultConfig ) {
2023-02-04 07:28:08 -05:00
const context = new Axios$1 ( defaultConfig ) ;
const instance = bind ( Axios$1 . prototype . request , context ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
// Copy axios.prototype to instance
2023-02-04 07:28:08 -05:00
utils . extend ( instance , Axios$1 . prototype , context , { allOwnKeys : true } ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
// Copy context to instance
utils . extend ( instance , context , null , { allOwnKeys : true } ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
// Factory for creating new instances
instance . create = function create ( instanceConfig ) {
return createInstance ( mergeConfig ( defaultConfig , instanceConfig ) ) ;
} ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
return instance ;
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
// Create the default instance to be exported
2023-02-04 07:28:08 -05:00
const axios = createInstance ( defaults$1 ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
// Expose Axios class to allow class inheritance
2023-02-04 07:28:08 -05:00
axios . Axios = Axios$1 ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
// Expose Cancel & CancelToken
axios . CanceledError = CanceledError ;
2023-02-04 07:28:08 -05:00
axios . CancelToken = CancelToken$1 ;
2022-11-03 16:35:53 -04:00
axios . isCancel = isCancel ;
axios . VERSION = VERSION ;
axios . toFormData = toFormData ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
// Expose AxiosError class
axios . AxiosError = AxiosError ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
// alias for CanceledError for backward compatibility
axios . Cancel = axios . CanceledError ;
// Expose all/spread
axios . all = function all ( promises ) {
return Promise . all ( promises ) ;
} ;
axios . spread = spread ;
// Expose isAxiosError
axios . isAxiosError = isAxiosError ;
2023-02-04 07:28:08 -05:00
// Expose mergeConfig
axios . mergeConfig = mergeConfig ;
axios . AxiosHeaders = AxiosHeaders$1 ;
axios . formToJSON = thing => formDataToJSON ( utils . isHTMLForm ( thing ) ? new FormData ( thing ) : thing ) ;
axios . HttpStatusCode = HttpStatusCode$1 ;
axios . default = axios ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
module . exports = axios ;
//# sourceMappingURL=axios.cjs.map
2020-02-24 04:23:15 -05:00
/***/ } ) ,
2022-11-03 16:35:53 -04:00
/***/ 3765 :
/***/ ( ( module ) => {
2020-02-24 04:23:15 -05:00
"use strict" ;
2022-11-03 16:35:53 -04:00
module . exports = JSON . parse ( ' { "application/1d-interleaved-parityfec" : { "source" : "iana" } , "application/3gpdash-qoe-report+xml" : { "source" : "iana" , "charset" : "UTF-8" , "compressible" : true } , "application/3gpp-ims+xml" : { "source" : "iana" , "compressible" : true } , "application/3gpphal+json" : { "source" : "iana" , "compressible" : true } , "application/3gpphalforms+json" : { "source" : "iana" , "compressible" : true } , "application/a2l" : { "source" : "iana" } , "application/ace+cbor" : { "source" : "iana" } , "application/activemessage" : { "source" : "iana" } , "application/activity+json" : { "source" : "iana" , "compressible" : true } , "application/alto-costmap+json" : { "source" : "iana" , "compressible" : true } , "application/alto-costmapfilter+json" : { "source" : "iana" , "compressible" : true } , "application/alto-directory+json" : { "source" : "iana" , "compressible" : true } , "application/alto-endpointcost+json" : { "source" : "iana" , "compressible" : true } , "application/alto-endpointcostparams+json" : { "source" : "iana" , "compressible" : true } , "application/alto-endpointprop+json" : { "source" : "iana" , "compressible" : true } , "application/alto-endpointpropparams+json" : { "source" : "iana" , "compressible" : true } , "application/alto-error+json" : { "source" : "iana" , "compressible" : true } , "application/alto-networkmap+json" : { "source" : "iana" , "compressible" : true } , "application/alto-networkmapfilter+json" : { "source" : "iana" , "compressible" : true } , "application/alto-updatestreamcontrol+json" : { "source" : "iana" , "compressible" : true } , "application/alto-updatestreamparams+json" : { "source" : "iana" , "compressible" : true } , "application/aml" : { "source" : "iana" } , "application/andrew-inset" : { "source" : "iana" , "extensions" : [ "ez" ] } , "application/applefile" : { "source" : "iana" } , "application/applixware" : { "source" : "apache" , "extensions" : [ "aw" ] } , "application/at+jwt" : { "source" : "iana" } , "application/atf" : { "source" : "iana" } , "application/atfx" : { "source" : "iana" } , "application/atom+xml" : { "source" : "iana" , "compressible" : true , "extensions" : [ "atom" ] } , "application/atomcat+xml" : { "source" : "iana" , "compressible" : true , "extensions" : [ "atomcat" ] } , "application/atomdeleted+xml" : { "source" : "iana" , "compressible" : true , "extensions" : [ "atomdeleted" ] } , "application/atomicmail" : { "source" : "iana" } , "application/atomsvc+xml" : { "source" : "iana" , "compressible" : true , "extensions" : [ "atomsvc" ] } , "application/atsc-dwd+xml" : { "source" : "iana" , "compressible" : true , "extensions" : [ "dwd" ] } , "application/atsc-dynamic-event-message" : { "source" : "iana" } , "application/atsc-held+xml" : { "source" : "iana" , "compressible" : true , "extensions" : [ "held" ] } , "application/atsc-rdt+json" : { "source" : "iana" , "compressible" : true } , "application/atsc-rsat+xml" : { "source" : "iana" , "compressible" : true , "extensions" : [ "rsat" ] } , "application/atxml" : { "source" : "iana" } , "application/auth-policy+xml" : { "source" : "iana" , "compressible" : true } , "application/bacnet-xdd+zip" : { "source" : "iana" , "compressible" : false } , "application/batch-smtp" : { "source" : "iana" } , "application/bdoc" : { "compressible" : false , "extensions" : [ "bdoc" ] } , "application/beep+xml" : { "source" : "iana" , "charset" : "UTF-8" , "compressible" : true } , "application/calendar+json" : { "source" : "iana" , "compressible" : true } , "application/calendar+xml" : { "source" : "iana" , "compressible" : true , "extensions" : [ "xcs" ] } , "application/call-completion" : { "source" : "iana" } , "application/cals-1840" : { "source" : "iana" } , "application/captive+json" : { "source" : "iana" , "compressible" : true } , "application/cbor" : { "source" : "iana" } , "application/cbor-seq" : { "source" : "iana" } , "application/cccex" : { "source" : "iana" } , "application/ccmp+xml" : { "source" : "iana" , "compressible" : true } , "application/ccxml+xml" : { "source" : "iana" , "compressible" : true , "extensions" : [ "ccxml" ] } , "application/cdfx+xml" : { "source" : "iana" , "compressible" : true , "extensions" : [ "cdfx" ] } , "application/cdmi-capability" : { "source" : "iana" , "extensions" : [ "cdmia" ] } , "application/cdmi-container" : { "source" : "iana" , "extensions" : [ "cdmic" ] } , "application/cdmi-domain" : { "source" : "iana" , "extensions" : [ "cdmid" ] } , "application/cdmi-object" : { "source" : "iana" , "extensions" : [ "cdmio" ] } , "application/cdmi-queue" : { "source" : "iana" , "extensions" : [ "cdmiq" ] } , "application/cdni" : { "source" : "iana" } , "application/cea" : { "source" : "iana" } , "application/cea-2018+xml" : { "source" : "iana" , "compressible" : true } , " application / c
/***/ } )
/******/ } ) ;
/************************************************************************/
/******/ // The module cache
/******/ var _ _webpack _module _cache _ _ = { } ;
/******/
/******/ // The require function
/******/ function _ _nccwpck _require _ _ ( moduleId ) {
/******/ // Check if module is in cache
/******/ var cachedModule = _ _webpack _module _cache _ _ [ moduleId ] ;
/******/ if ( cachedModule !== undefined ) {
/******/ return cachedModule . exports ;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = _ _webpack _module _cache _ _ [ moduleId ] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports : { }
/******/ } ;
/******/
/******/ // Execute the module function
/******/ var threw = true ;
/******/ try {
/******/ _ _webpack _modules _ _ [ moduleId ] . call ( module . exports , module , module . exports , _ _nccwpck _require _ _ ) ;
/******/ threw = false ;
/******/ } finally {
/******/ if ( threw ) delete _ _webpack _module _cache _ _ [ moduleId ] ;
/******/ }
/******/
/******/ // Return the exports of the module
/******/ return module . exports ;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat */
/******/
/******/ if ( typeof _ _nccwpck _require _ _ !== 'undefined' ) _ _nccwpck _require _ _ . ab = _ _dirname + "/" ;
/******/
/************************************************************************/
var _ _webpack _exports _ _ = { } ;
2022-11-04 05:28:14 -04:00
// This entry need to be wrapped in an IIFE because it need to be in strict mode.
2022-11-03 16:35:53 -04:00
( ( ) => {
2022-11-04 05:28:14 -04:00
"use strict" ;
2022-11-03 16:35:53 -04:00
const core = _ _nccwpck _require _ _ ( 2186 ) ;
const axios = _ _nccwpck _require _ _ ( 8757 ) ;
const https = _ _nccwpck _require _ _ ( 5687 ) ;
const { request , METHOD _POST } = _ _nccwpck _require _ _ ( 9082 ) ;
const { GithubActions } = _ _nccwpck _require _ _ ( 8169 ) ;
2023-02-04 07:28:08 -05:00
const { createPersistHandler } = _ _nccwpck _require _ _ ( 6733 ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
let customHeaders = { }
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
if ( ! ! core . getInput ( 'customHeaders' ) ) {
try {
customHeaders = JSON . parse ( core . getInput ( 'customHeaders' ) ) ;
} catch ( error ) {
core . error ( 'Could not parse customHeaders string value' )
}
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
const headers = { 'Content-Type' : core . getInput ( 'contentType' ) || 'application/json' }
if ( ! ! core . getInput ( 'bearerToken' ) ) {
headers [ 'Authorization' ] = ` Bearer ${ core . getInput ( 'bearerToken' ) } ` ;
}
/** @type {axios.AxiosRequestConfig} */
const instanceConfig = {
baseURL : core . getInput ( 'url' , { required : true } ) ,
timeout : parseInt ( core . getInput ( 'timeout' ) || 5000 , 10 ) ,
headers : { ... headers , ... customHeaders }
}
if ( ! ! core . getInput ( 'httpsCA' ) ) {
instanceConfig . httpsAgent = new https . Agent ( { ca : core . getInput ( 'httpsCA' ) } )
}
if ( ! ! core . getInput ( 'username' ) || ! ! core . getInput ( 'password' ) ) {
core . debug ( 'Add BasicHTTP Auth config' )
instanceConfig . auth = {
username : core . getInput ( 'username' ) ,
password : core . getInput ( 'password' )
2020-02-24 04:23:15 -05:00
}
2022-11-03 16:35:53 -04:00
}
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
const data = core . getInput ( 'data' ) || '{}' ;
const files = core . getInput ( 'files' ) || '{}' ;
const file = core . getInput ( 'file' )
2023-02-04 07:28:08 -05:00
const responseFile = core . getInput ( 'responseFile' )
2022-11-03 16:35:53 -04:00
const method = core . getInput ( 'method' ) || METHOD _POST ;
const preventFailureOnNoResponse = core . getInput ( 'preventFailureOnNoResponse' ) === 'true' ;
const escapeData = core . getInput ( 'escapeData' ) === 'true' ;
2020-02-24 04:23:15 -05:00
2023-02-04 07:28:08 -05:00
const ignoreStatusCodes = core . getInput ( 'ignoreStatusCodes' ) ;
let ignoredCodes = [ ] ;
2022-11-03 16:35:53 -04:00
if ( typeof ignoreStatusCodes === 'string' && ignoreStatusCodes . length > 0 ) {
ignoredCodes = ignoreStatusCodes . split ( ',' ) . map ( statusCode => parseInt ( statusCode . trim ( ) ) )
}
2023-02-04 07:28:08 -05:00
const handler = [ ] ;
const actions = new GithubActions ( ) ;
if ( ! ! responseFile ) {
handler . push ( createPersistHandler ( responseFile , actions ) )
}
request ( { data , method , instanceConfig , preventFailureOnNoResponse , escapeData , files , file , ignoredCodes , actions } ) . then ( response => {
if ( typeof response == 'object' ) {
handler . forEach ( h => h ( response ) )
}
} )
2022-11-03 16:35:53 -04:00
} ) ( ) ;
2020-02-24 04:23:15 -05:00
2022-11-03 16:35:53 -04:00
module . exports = _ _webpack _exports _ _ ;
/******/ } ) ( )
;