2020-05-03 14:46:05 -04:00
module . exports =
2020-09-06 16:03:16 -04:00
/******/ ( ( ) => { // webpackBootstrap
/******/ var _ _webpack _modules _ _ = ( {
2021-10-15 08:08:03 -04:00
/***/ 3842 :
2020-09-06 16:03:16 -04:00
/***/ ( function ( _ _unused _webpack _module , exports , _ _webpack _require _ _ ) {
"use strict" ;
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 . prototype . 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 } ) ) ;
2021-05-09 05:15:20 -04:00
exports . setOutput = exports . getInputs = void 0 ;
2021-10-15 08:08:03 -04:00
const core = _ _importStar ( _ _webpack _require _ _ ( 2186 ) ) ;
const command _1 = _ _webpack _require _ _ ( 7351 ) ;
2020-09-06 16:03:16 -04:00
function getInputs ( ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return {
2021-09-04 19:12:28 -04:00
gpgPrivateKey : core . getInput ( 'gpg_private_key' , { required : true } ) ,
2020-09-06 16:03:16 -04:00
passphrase : core . getInput ( 'passphrase' ) ,
2021-09-04 19:12:28 -04:00
gitConfigGlobal : core . getBooleanInput ( 'git_config_global' ) ,
gitUserSigningkey : core . getBooleanInput ( 'git_user_signingkey' ) ,
gitCommitGpgsign : core . getBooleanInput ( 'git_commit_gpgsign' ) ,
gitTagGpgsign : core . getBooleanInput ( 'git_tag_gpgsign' ) ,
gitPushGpgsign : core . getInput ( 'git_push_gpgsign' ) || 'if-asked' ,
gitCommitterName : core . getInput ( 'git_committer_name' ) ,
gitCommitterEmail : core . getInput ( 'git_committer_email' ) ,
2021-10-15 07:40:04 -04:00
workdir : core . getInput ( 'workdir' ) || '.' ,
fingerprint : core . getInput ( 'fingerprint' )
2020-09-06 16:03:16 -04:00
} ;
} ) ;
}
exports . getInputs = getInputs ;
2021-05-09 05:15:20 -04:00
// FIXME: Temp fix https://github.com/actions/toolkit/issues/777
function setOutput ( name , value ) {
command _1 . issueCommand ( 'set-output' , { name } , value ) ;
}
exports . setOutput = setOutput ;
2020-09-06 16:03:16 -04:00
//# sourceMappingURL=context.js.map
/***/ } ) ,
2021-10-15 08:08:03 -04:00
/***/ 3374 :
2020-09-06 16:03:16 -04:00
/***/ ( function ( _ _unused _webpack _module , exports , _ _webpack _require _ _ ) {
"use strict" ;
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 . prototype . 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 . setConfig = void 0 ;
2021-10-15 08:08:03 -04:00
const exec = _ _importStar ( _ _webpack _require _ _ ( 1514 ) ) ;
2020-09-06 16:03:16 -04:00
const git = ( args = [ ] ) => _ _awaiter ( void 0 , void 0 , void 0 , function * ( ) {
2021-08-10 03:00:29 -04:00
return yield exec
. getExecOutput ( ` git ` , args , {
ignoreReturnCode : true ,
silent : true
} )
. then ( res => {
if ( res . stderr . length > 0 && res . exitCode != 0 ) {
2020-09-06 16:03:16 -04:00
throw new Error ( res . stderr ) ;
}
return res . stdout . trim ( ) ;
} ) ;
} ) ;
2021-08-10 03:28:13 -04:00
function setConfig ( key , value , global ) {
2020-09-06 16:03:16 -04:00
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
2021-08-10 03:28:13 -04:00
let args = [ 'config' ] ;
if ( global ) {
args . push ( '--global' ) ;
}
args . push ( key , value ) ;
yield git ( args ) ;
2020-09-06 16:03:16 -04:00
} ) ;
}
exports . setConfig = setConfig ;
//# sourceMappingURL=git.js.map
/***/ } ) ,
2020-05-03 14:46:05 -04:00
2021-10-15 08:08:03 -04:00
/***/ 9060 :
2020-09-06 16:03:16 -04:00
/***/ ( function ( _ _unused _webpack _module , exports , _ _webpack _require _ _ ) {
2020-05-04 10:17:14 -04:00
"use strict" ;
2020-08-21 07:35:04 -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 = { } ;
2020-09-06 16:03:16 -04:00
if ( mod != null ) for ( var k in mod ) if ( k !== "default" && Object . prototype . hasOwnProperty . call ( mod , k ) ) _ _createBinding ( result , mod , k ) ;
2020-08-21 07:35:04 -04:00
_ _setModuleDefault ( result , mod ) ;
return result ;
} ;
2020-05-04 10:17:14 -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 ( ) ) ;
} ) ;
} ;
2020-09-06 16:03:16 -04:00
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
2020-09-03 15:32:38 -04:00
exports . killAgent = exports . deleteKey = exports . presetPassphrase = exports . configureAgent = exports . getKeygrips = exports . importKey = exports . getDirs = exports . getVersion = exports . agentConfig = void 0 ;
2021-10-15 08:08:03 -04:00
const exec = _ _importStar ( _ _webpack _require _ _ ( 1514 ) ) ;
const fs = _ _importStar ( _ _webpack _require _ _ ( 5747 ) ) ;
const path = _ _importStar ( _ _webpack _require _ _ ( 5622 ) ) ;
const os = _ _importStar ( _ _webpack _require _ _ ( 2087 ) ) ;
const openpgp = _ _importStar ( _ _webpack _require _ _ ( 4666 ) ) ;
2020-08-21 07:35:04 -04:00
exports . agentConfig = ` default-cache-ttl 7200
max - cache - ttl 31536000
allow - preset - passphrase ` ;
const getGnupgHome = ( ) => _ _awaiter ( void 0 , void 0 , void 0 , function * ( ) {
if ( process . env . GNUPGHOME ) {
return process . env . GNUPGHOME ;
}
let homedir = path . join ( process . env . HOME || '' , '.gnupg' ) ;
if ( os . platform ( ) == 'win32' && ! process . env . HOME ) {
homedir = path . join ( process . env . USERPROFILE || '' , '.gnupg' ) ;
}
return homedir ;
} ) ;
const gpgConnectAgent = ( command ) => _ _awaiter ( void 0 , void 0 , void 0 , function * ( ) {
2021-08-10 03:00:29 -04:00
return yield exec
. getExecOutput ( ` gpg-connect-agent " ${ command } " /bye ` , [ ] , {
ignoreReturnCode : true ,
silent : true
} )
. then ( res => {
if ( res . stderr . length > 0 && res . exitCode != 0 ) {
2020-08-21 07:35:04 -04:00
throw new Error ( res . stderr ) ;
2020-05-04 10:17:14 -04:00
}
2020-08-21 07:35:04 -04:00
for ( let line of res . stdout . replace ( /\r/g , '' ) . trim ( ) . split ( /\n/g ) ) {
if ( line . startsWith ( 'ERR' ) ) {
throw new Error ( line ) ;
2020-05-04 10:17:14 -04:00
}
}
2020-08-21 07:35:04 -04:00
return res . stdout . trim ( ) ;
2020-05-04 10:17:14 -04:00
} ) ;
2020-08-21 07:35:04 -04:00
} ) ;
2021-01-29 06:29:31 -05:00
exports . getVersion = ( ) => _ _awaiter ( void 0 , void 0 , void 0 , function * ( ) {
2021-08-10 03:00:29 -04:00
return yield exec
. getExecOutput ( 'gpg' , [ '--version' ] , {
ignoreReturnCode : true ,
silent : true
} )
. then ( res => {
if ( res . stderr . length > 0 && res . exitCode != 0 ) {
2020-08-21 07:35:04 -04:00
throw new Error ( res . stderr ) ;
2020-05-04 10:17:14 -04:00
}
2020-08-21 07:35:04 -04:00
let gnupgVersion = '' ;
let libgcryptVersion = '' ;
for ( let line of res . stdout . replace ( /\r/g , '' ) . trim ( ) . split ( /\n/g ) ) {
if ( line . startsWith ( 'gpg (GnuPG) ' ) ) {
gnupgVersion = line . substr ( 'gpg (GnuPG) ' . length ) . trim ( ) ;
2020-05-04 10:17:14 -04:00
}
2020-08-21 07:35:04 -04:00
else if ( line . startsWith ( 'gpg (GnuPG/MacGPG2) ' ) ) {
gnupgVersion = line . substr ( 'gpg (GnuPG/MacGPG2) ' . length ) . trim ( ) ;
2020-05-04 10:17:14 -04:00
}
2020-08-21 07:35:04 -04:00
else if ( line . startsWith ( 'libgcrypt ' ) ) {
libgcryptVersion = line . substr ( 'libgcrypt ' . length ) . trim ( ) ;
2020-05-04 10:17:14 -04:00
}
}
2020-08-21 07:35:04 -04:00
return {
gnupg : gnupgVersion ,
libgcrypt : libgcryptVersion
} ;
2020-05-04 10:17:14 -04:00
} ) ;
2020-08-21 07:35:04 -04:00
} ) ;
2021-01-29 06:29:31 -05:00
exports . getDirs = ( ) => _ _awaiter ( void 0 , void 0 , void 0 , function * ( ) {
2021-08-10 03:00:29 -04:00
return yield exec
. getExecOutput ( 'gpgconf' , [ '--list-dirs' ] , {
ignoreReturnCode : true ,
silent : true
} )
. then ( res => {
if ( res . stderr . length > 0 && res . exitCode != 0 ) {
2020-08-21 07:35:04 -04:00
throw new Error ( res . stderr ) ;
2020-05-04 10:17:14 -04:00
}
2020-08-21 07:35:04 -04:00
let libdir = '' ;
let libexecdir = '' ;
let datadir = '' ;
let homedir = '' ;
for ( let line of res . stdout . replace ( /\r/g , '' ) . trim ( ) . split ( /\n/g ) ) {
if ( line . startsWith ( 'libdir:' ) ) {
libdir = line . substr ( 'libdir:' . length ) . replace ( '%3a' , ':' ) . trim ( ) ;
2020-05-04 10:17:14 -04:00
}
2020-08-21 07:35:04 -04:00
else if ( line . startsWith ( 'libexecdir:' ) ) {
libexecdir = line . substr ( 'libexecdir:' . length ) . replace ( '%3a' , ':' ) . trim ( ) ;
2020-05-04 10:17:14 -04:00
}
2020-08-21 07:35:04 -04:00
else if ( line . startsWith ( 'datadir:' ) ) {
datadir = line . substr ( 'datadir:' . length ) . replace ( '%3a' , ':' ) . trim ( ) ;
2020-05-04 10:17:14 -04:00
}
2020-08-21 07:35:04 -04:00
else if ( line . startsWith ( 'homedir:' ) ) {
homedir = line . substr ( 'homedir:' . length ) . replace ( '%3a' , ':' ) . trim ( ) ;
2020-05-04 10:17:14 -04:00
}
}
2020-08-21 07:35:04 -04:00
return {
libdir : libdir ,
libexecdir : libexecdir ,
datadir : datadir ,
homedir : homedir
} ;
} ) ;
} ) ;
2021-01-29 06:29:31 -05:00
exports . importKey = ( key ) => _ _awaiter ( void 0 , void 0 , void 0 , function * ( ) {
2020-08-21 07:35:04 -04:00
const keyFolder = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , 'ghaction-import-gpg-' ) ) ;
const keyPath = ` ${ keyFolder } /key.pgp ` ;
fs . writeFileSync ( keyPath , ( yield openpgp . isArmored ( key ) ) ? key : Buffer . from ( key , 'base64' ) . toString ( ) , { mode : 0o600 } ) ;
return yield exec
2021-08-10 03:00:29 -04:00
. getExecOutput ( 'gpg' , [ '--import' , '--batch' , '--yes' , keyPath ] , {
ignoreReturnCode : true ,
silent : true
} )
2020-08-21 07:35:04 -04:00
. then ( res => {
2021-08-10 03:00:29 -04:00
if ( res . stderr . length > 0 && res . exitCode != 0 ) {
2020-08-21 07:35:04 -04:00
throw new Error ( res . stderr ) ;
}
if ( res . stderr != '' ) {
return res . stderr . trim ( ) ;
2020-05-04 10:17:14 -04:00
}
2020-08-21 07:35:04 -04:00
return res . stdout . trim ( ) ;
} )
. finally ( ( ) => {
fs . unlinkSync ( keyPath ) ;
2020-05-04 10:17:14 -04:00
} ) ;
2020-08-21 07:35:04 -04:00
} ) ;
2021-01-29 06:29:31 -05:00
exports . getKeygrips = ( fingerprint ) => _ _awaiter ( void 0 , void 0 , void 0 , function * ( ) {
2021-08-10 03:00:29 -04:00
return yield exec
. getExecOutput ( 'gpg' , [ '--batch' , '--with-colons' , '--with-keygrip' , '--list-secret-keys' , fingerprint ] , {
ignoreReturnCode : true ,
silent : true
} )
. then ( res => {
2020-09-03 15:32:38 -04:00
let keygrips = [ ] ;
2020-08-21 07:35:04 -04:00
for ( let line of res . stdout . replace ( /\r/g , '' ) . trim ( ) . split ( /\n/g ) ) {
if ( line . startsWith ( 'grp' ) ) {
2020-09-03 15:32:38 -04:00
keygrips . push ( line . replace ( /(grp|:)/g , '' ) . trim ( ) ) ;
2020-05-04 10:17:14 -04:00
}
}
2020-09-03 15:32:38 -04:00
return keygrips ;
2020-05-04 10:17:14 -04:00
} ) ;
2020-08-21 07:35:04 -04:00
} ) ;
2021-01-29 06:29:31 -05:00
exports . configureAgent = ( config ) => _ _awaiter ( void 0 , void 0 , void 0 , function * ( ) {
2020-08-21 07:35:04 -04:00
const gpgAgentConf = path . join ( yield getGnupgHome ( ) , 'gpg-agent.conf' ) ;
yield fs . writeFile ( gpgAgentConf , config , function ( err ) {
if ( err )
throw err ;
} ) ;
yield gpgConnectAgent ( 'RELOADAGENT' ) ;
} ) ;
2021-01-29 06:29:31 -05:00
exports . presetPassphrase = ( keygrip , passphrase ) => _ _awaiter ( void 0 , void 0 , void 0 , function * ( ) {
2020-08-21 07:35:04 -04:00
const hexPassphrase = Buffer . from ( passphrase , 'utf8' ) . toString ( 'hex' ) . toUpperCase ( ) ;
yield gpgConnectAgent ( ` PRESET_PASSPHRASE ${ keygrip } -1 ${ hexPassphrase } ` ) ;
return yield gpgConnectAgent ( ` KEYINFO ${ keygrip } ` ) ;
} ) ;
2021-01-29 06:29:31 -05:00
exports . deleteKey = ( fingerprint ) => _ _awaiter ( void 0 , void 0 , void 0 , function * ( ) {
2021-08-10 03:00:29 -04:00
yield exec
. getExecOutput ( 'gpg' , [ '--batch' , '--yes' , '--delete-secret-keys' , fingerprint ] , {
ignoreReturnCode : true ,
silent : true
} )
. then ( res => {
if ( res . stderr . length > 0 && res . exitCode != 0 ) {
2020-08-21 07:35:04 -04:00
throw new Error ( res . stderr ) ;
2020-05-04 10:17:14 -04:00
}
2020-08-21 07:35:04 -04:00
} ) ;
2021-08-10 03:00:29 -04:00
yield exec
. getExecOutput ( 'gpg' , [ '--batch' , '--yes' , '--delete-keys' , fingerprint ] , {
ignoreReturnCode : true ,
silent : true
} )
. then ( res => {
if ( res . stderr . length > 0 && res . exitCode != 0 ) {
2020-08-21 07:35:04 -04:00
throw new Error ( res . stderr ) ;
2020-05-04 10:17:14 -04:00
}
} ) ;
2020-08-21 07:35:04 -04:00
} ) ;
2021-01-29 06:29:31 -05:00
exports . killAgent = ( ) => _ _awaiter ( void 0 , void 0 , void 0 , function * ( ) {
2020-08-21 07:35:04 -04:00
yield gpgConnectAgent ( 'KILLAGENT' ) ;
} ) ;
//# sourceMappingURL=gpg.js.map
/***/ } ) ,
2021-10-15 08:08:03 -04:00
/***/ 3109 :
2020-09-06 16:03:16 -04:00
/***/ ( function ( _ _unused _webpack _module , exports , _ _webpack _require _ _ ) {
2020-05-04 10:17:14 -04:00
"use strict" ;
2020-08-21 07:35:04 -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 = { } ;
2020-09-06 16:03:16 -04:00
if ( mod != null ) for ( var k in mod ) if ( k !== "default" && Object . prototype . hasOwnProperty . call ( mod , k ) ) _ _createBinding ( result , mod , k ) ;
2020-08-21 07:35:04 -04:00
_ _setModuleDefault ( result , mod ) ;
return result ;
} ;
2020-05-04 10:17:14 -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 ( ) ) ;
} ) ;
} ;
2020-09-06 16:03:16 -04:00
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
2021-10-15 08:08:03 -04:00
const core = _ _importStar ( _ _webpack _require _ _ ( 2186 ) ) ;
const context = _ _importStar ( _ _webpack _require _ _ ( 3842 ) ) ;
const git = _ _importStar ( _ _webpack _require _ _ ( 3374 ) ) ;
const gpg = _ _importStar ( _ _webpack _require _ _ ( 9060 ) ) ;
const openpgp = _ _importStar ( _ _webpack _require _ _ ( 4666 ) ) ;
const stateHelper = _ _importStar ( _ _webpack _require _ _ ( 8647 ) ) ;
2020-08-21 07:35:04 -04:00
function run ( ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
2020-05-04 10:17:14 -04:00
try {
2020-09-06 16:03:16 -04:00
let inputs = yield context . getInputs ( ) ;
if ( inputs . workdir && inputs . workdir !== '.' ) {
core . info ( ` 📂 Using ${ inputs . workdir } as working directory... ` ) ;
process . chdir ( inputs . workdir ) ;
2020-08-28 16:30:49 -04:00
}
2020-08-21 07:35:04 -04:00
const version = yield gpg . getVersion ( ) ;
const dirs = yield gpg . getDirs ( ) ;
2021-09-04 19:00:24 -04:00
yield core . group ( ` GnuPG info ` , ( ) => _ _awaiter ( this , void 0 , void 0 , function * ( ) {
2021-08-10 02:46:50 -04:00
core . info ( ` Version : ${ version . gnupg } (libgcrypt ${ version . libgcrypt } ) ` ) ;
core . info ( ` Libdir : ${ dirs . libdir } ` ) ;
core . info ( ` Libexecdir : ${ dirs . libexecdir } ` ) ;
core . info ( ` Datadir : ${ dirs . datadir } ` ) ;
core . info ( ` Homedir : ${ dirs . homedir } ` ) ;
} ) ) ;
2020-09-06 16:03:16 -04:00
const privateKey = yield openpgp . readPrivateKey ( inputs . gpgPrivateKey ) ;
2021-09-04 19:00:24 -04:00
yield core . group ( ` GPG private key info ` , ( ) => _ _awaiter ( this , void 0 , void 0 , function * ( ) {
2021-08-10 02:46:50 -04:00
core . info ( ` Fingerprint : ${ privateKey . fingerprint } ` ) ;
core . info ( ` KeyID : ${ privateKey . keyID } ` ) ;
core . info ( ` Name : ${ privateKey . name } ` ) ;
core . info ( ` Email : ${ privateKey . email } ` ) ;
core . info ( ` CreationTime : ${ privateKey . creationTime } ` ) ;
} ) ) ;
2021-10-15 07:40:04 -04:00
let fingerprint = privateKey . fingerprint ;
if ( inputs . fingerprint ) {
fingerprint = inputs . fingerprint ;
}
stateHelper . setFingerprint ( fingerprint ) ;
yield core . group ( ` Fingerprint to use ` , ( ) => _ _awaiter ( this , void 0 , void 0 , function * ( ) {
core . info ( fingerprint ) ;
} ) ) ;
2021-09-04 19:00:24 -04:00
yield core . group ( ` Importing GPG private key ` , ( ) => _ _awaiter ( this , void 0 , void 0 , function * ( ) {
2021-08-10 02:46:50 -04:00
yield gpg . importKey ( inputs . gpgPrivateKey ) . then ( stdout => {
core . info ( stdout ) ;
} ) ;
} ) ) ;
2020-09-06 16:03:16 -04:00
if ( inputs . passphrase ) {
2021-09-04 19:00:24 -04:00
core . info ( 'Configuring GnuPG agent' ) ;
2020-08-21 07:35:04 -04:00
yield gpg . configureAgent ( gpg . agentConfig ) ;
2021-09-04 19:00:24 -04:00
yield core . group ( ` Getting keygrips ` , ( ) => _ _awaiter ( this , void 0 , void 0 , function * ( ) {
2021-10-15 07:40:04 -04:00
for ( let keygrip of yield gpg . getKeygrips ( fingerprint ) ) {
2021-09-04 19:00:24 -04:00
core . info ( ` Presetting passphrase for ${ keygrip } ` ) ;
2021-08-10 02:46:50 -04:00
yield gpg . presetPassphrase ( keygrip , inputs . passphrase ) . then ( stdout => {
core . debug ( stdout ) ;
} ) ;
}
} ) ) ;
2020-05-04 10:17:14 -04:00
}
2021-10-15 07:40:04 -04:00
yield core . group ( ` Setting outputs ` , ( ) => _ _awaiter ( this , void 0 , void 0 , function * ( ) {
core . info ( ` fingerprint= ${ fingerprint } ` ) ;
context . setOutput ( 'fingerprint' , fingerprint ) ;
core . info ( ` keyid= ${ privateKey . keyID } ` ) ;
context . setOutput ( 'keyid' , privateKey . keyID ) ;
core . info ( ` name= ${ privateKey . name } ` ) ;
context . setOutput ( 'name' , privateKey . name ) ;
core . info ( ` email= ${ privateKey . email } ` ) ;
context . setOutput ( 'email' , privateKey . email ) ;
} ) ) ;
2020-09-06 16:03:16 -04:00
if ( inputs . gitUserSigningkey ) {
2021-09-04 19:00:24 -04:00
core . info ( 'Setting GPG signing keyID for this Git repository' ) ;
2021-08-10 03:28:13 -04:00
yield git . setConfig ( 'user.signingkey' , privateKey . keyID , inputs . gitConfigGlobal ) ;
2020-09-06 16:03:16 -04:00
const userEmail = inputs . gitCommitterEmail || privateKey . email ;
const userName = inputs . gitCommitterName || privateKey . name ;
if ( userEmail != privateKey . email ) {
2020-11-24 07:03:54 -05:00
core . setFailed ( ` Committer email " ${ inputs . gitCommitterEmail } " (name: " ${ inputs . gitCommitterName } ") does not match GPG private key email " ${ privateKey . email } " (name: " ${ privateKey . name } ") ` ) ;
2020-05-04 10:17:14 -04:00
return ;
}
2021-09-04 19:00:24 -04:00
core . info ( ` Configuring Git committer ( ${ userName } < ${ userEmail } >) ` ) ;
2021-08-10 03:28:13 -04:00
yield git . setConfig ( 'user.name' , userName , inputs . gitConfigGlobal ) ;
yield git . setConfig ( 'user.email' , userEmail , inputs . gitConfigGlobal ) ;
2020-09-06 16:03:16 -04:00
if ( inputs . gitCommitGpgsign ) {
2021-09-04 19:00:24 -04:00
core . info ( 'Sign all commits automatically' ) ;
2021-08-10 03:28:13 -04:00
yield git . setConfig ( 'commit.gpgsign' , 'true' , inputs . gitConfigGlobal ) ;
2020-08-21 07:35:04 -04:00
}
2020-09-06 16:03:16 -04:00
if ( inputs . gitTagGpgsign ) {
2021-09-04 19:00:24 -04:00
core . info ( 'Sign all tags automatically' ) ;
2021-08-10 03:28:13 -04:00
yield git . setConfig ( 'tag.gpgsign' , 'true' , inputs . gitConfigGlobal ) ;
2020-08-21 07:35:04 -04:00
}
2020-09-06 16:03:16 -04:00
if ( inputs . gitPushGpgsign ) {
2021-09-04 19:00:24 -04:00
core . info ( 'Sign all pushes automatically' ) ;
2021-08-10 03:28:13 -04:00
yield git . setConfig ( 'push.gpgsign' , inputs . gitPushGpgsign , inputs . gitConfigGlobal ) ;
2020-05-04 10:17:14 -04:00
}
}
}
2020-08-21 07:35:04 -04:00
catch ( error ) {
core . setFailed ( error . message ) ;
}
2020-05-04 10:17:14 -04:00
} ) ;
}
2020-08-21 07:35:04 -04:00
function cleanup ( ) {
2020-05-04 10:17:14 -04:00
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
2021-10-15 07:40:04 -04:00
if ( stateHelper . fingerprint . length <= 0 ) {
core . debug ( 'Fingerprint is not defined. Skipping cleanup.' ) ;
2020-08-21 07:35:04 -04:00
return ;
2020-05-04 10:17:14 -04:00
}
2020-08-21 07:35:04 -04:00
try {
2021-09-04 19:00:24 -04:00
core . info ( 'Removing keys' ) ;
2021-10-15 07:40:04 -04:00
yield gpg . deleteKey ( stateHelper . fingerprint ) ;
2021-09-04 19:00:24 -04:00
core . info ( 'Killing GnuPG agent' ) ;
2020-08-21 07:35:04 -04:00
yield gpg . killAgent ( ) ;
2020-05-04 10:17:14 -04:00
}
2020-08-21 07:35:04 -04:00
catch ( error ) {
core . warning ( error . message ) ;
2020-05-04 10:17:14 -04:00
}
} ) ;
}
2020-08-21 07:35:04 -04:00
if ( ! stateHelper . IsPost ) {
run ( ) ;
2020-05-04 10:17:14 -04:00
}
2020-08-21 07:35:04 -04:00
else {
cleanup ( ) ;
2020-05-04 10:17:14 -04:00
}
2020-08-21 07:35:04 -04:00
//# sourceMappingURL=main.js.map
/***/ } ) ,
2021-10-15 08:08:03 -04:00
/***/ 4666 :
2020-09-06 16:03:16 -04:00
/***/ ( function ( _ _unused _webpack _module , exports , _ _webpack _require _ _ ) {
2020-08-21 07:35:04 -04:00
2020-09-06 16:03:16 -04:00
"use strict" ;
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 . prototype . 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 ( ) ) ;
} ) ;
} ;
var _ _importDefault = ( this && this . _ _importDefault ) || function ( mod ) {
return ( mod && mod . _ _esModule ) ? mod : { "default" : mod } ;
} ;
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
exports . isArmored = exports . generateKeyPair = exports . readPrivateKey = void 0 ;
2021-10-15 08:08:03 -04:00
const openpgp = _ _importStar ( _ _webpack _require _ _ ( 7946 ) ) ;
const addressparser _1 = _ _importDefault ( _ _webpack _require _ _ ( 2764 ) ) ;
2021-01-29 06:29:31 -05:00
exports . readPrivateKey = ( key ) => _ _awaiter ( void 0 , void 0 , void 0 , function * ( ) {
2021-09-04 19:00:24 -04:00
const privateKey = yield openpgp . readKey ( {
armoredKey : ( yield exports . isArmored ( key ) ) ? key : Buffer . from ( key , 'base64' ) . toString ( )
} ) ;
2020-09-06 16:03:16 -04:00
const address = yield privateKey . getPrimaryUser ( ) . then ( primaryUser => {
2021-09-04 19:00:24 -04:00
var _a ;
return addressparser _1 . default ( ( _a = primaryUser . user . userID ) === null || _a === void 0 ? void 0 : _a . userID ) [ 0 ] ;
2020-09-06 16:03:16 -04:00
} ) ;
return {
fingerprint : privateKey . getFingerprint ( ) . toUpperCase ( ) ,
2021-10-15 07:40:04 -04:00
keyID : privateKey . getKeyID ( ) . toHex ( ) . toUpperCase ( ) ,
2020-09-06 16:03:16 -04:00
name : address . name ,
email : address . address ,
creationTime : privateKey . getCreationTime ( )
} ;
} ) ;
2021-09-04 19:00:24 -04:00
exports . generateKeyPair = ( name , email , passphrase , type ) => _ _awaiter ( void 0 , void 0 , void 0 , function * ( ) {
2020-09-06 16:03:16 -04:00
const keyPair = yield openpgp . generateKey ( {
2021-09-04 19:00:24 -04:00
userIDs : [ { name : name , email : email } ] ,
passphrase : passphrase ,
type : type
2020-09-06 16:03:16 -04:00
} ) ;
return {
2021-09-04 19:00:24 -04:00
publicKey : keyPair . publicKey . replace ( /\r\n/g , '\n' ) . trim ( ) ,
privateKey : keyPair . privateKey . replace ( /\r\n/g , '\n' ) . trim ( )
2020-09-06 16:03:16 -04:00
} ;
} ) ;
2021-01-29 06:29:31 -05:00
exports . isArmored = ( text ) => _ _awaiter ( void 0 , void 0 , void 0 , function * ( ) {
2020-09-06 16:03:16 -04:00
return text . trimLeft ( ) . startsWith ( '---' ) ;
} ) ;
//# sourceMappingURL=openpgp.js.map
2020-05-04 10:17:14 -04:00
/***/ } ) ,
2021-10-15 08:08:03 -04:00
/***/ 8647 :
2020-09-06 16:03:16 -04:00
/***/ ( function ( _ _unused _webpack _module , exports , _ _webpack _require _ _ ) {
2020-05-03 14:46:05 -04:00
"use strict" ;
2020-09-06 16:03:16 -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 . prototype . hasOwnProperty . call ( mod , k ) ) _ _createBinding ( result , mod , k ) ;
_ _setModuleDefault ( result , mod ) ;
return result ;
} ;
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
2021-10-15 07:40:04 -04:00
exports . setFingerprint = exports . fingerprint = exports . IsPost = void 0 ;
2021-10-15 08:08:03 -04:00
const core = _ _importStar ( _ _webpack _require _ _ ( 2186 ) ) ;
2020-09-06 16:03:16 -04:00
exports . IsPost = ! ! process . env [ 'STATE_isPost' ] ;
2021-10-15 07:40:04 -04:00
exports . fingerprint = process . env [ 'STATE_fingerprint' ] || '' ;
function setFingerprint ( fingerprint ) {
core . saveState ( 'fingerprint' , fingerprint ) ;
2020-09-06 16:03:16 -04:00
}
2021-10-15 07:40:04 -04:00
exports . setFingerprint = setFingerprint ;
2020-09-06 16:03:16 -04:00
if ( ! exports . IsPost ) {
core . saveState ( 'isPost' , 'true' ) ;
}
//# sourceMappingURL=state-helper.js.map
/***/ } ) ,
2021-10-15 08:08:03 -04:00
/***/ 7351 :
2020-09-06 16:03:16 -04:00
/***/ ( function ( _ _unused _webpack _module , exports , _ _webpack _require _ _ ) {
"use strict" ;
2021-08-10 02:35:00 -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-09-06 16:03:16 -04:00
var _ _importStar = ( this && this . _ _importStar ) || function ( mod ) {
if ( mod && mod . _ _esModule ) return mod ;
var result = { } ;
2021-08-10 02:35:00 -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-09-06 16:03:16 -04:00
return result ;
} ;
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
2021-08-10 02:35:00 -04:00
exports . issue = exports . issueCommand = void 0 ;
2021-10-15 08:08:03 -04:00
const os = _ _importStar ( _ _webpack _require _ _ ( 2087 ) ) ;
const utils _1 = _ _webpack _require _ _ ( 5278 ) ;
2020-09-06 16:03:16 -04:00
/ * *
* Commands
*
* Command Format :
* : : name key = value , key = value : : message
*
* Examples :
* : : warning : : This is the message
* : : set - env name = MY _VAR : : some value
* /
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 ;
2020-05-03 14:46:05 -04:00
}
2020-09-06 16:03:16 -04:00
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 ;
2020-05-03 14:46:05 -04:00
}
2020-09-06 16:03:16 -04:00
}
function escapeData ( s ) {
2020-10-01 14:00:57 -04:00
return utils _1 . toCommandValue ( s )
2020-09-06 16:03:16 -04:00
. replace ( /%/g , '%25' )
. replace ( /\r/g , '%0D' )
. replace ( /\n/g , '%0A' ) ;
}
function escapeProperty ( s ) {
2020-10-01 14:00:57 -04:00
return utils _1 . toCommandValue ( s )
2020-09-06 16:03:16 -04:00
. replace ( /%/g , '%25' )
. replace ( /\r/g , '%0D' )
. replace ( /\n/g , '%0A' )
. replace ( /:/g , '%3A' )
. replace ( /,/g , '%2C' ) ;
}
//# sourceMappingURL=command.js.map
/***/ } ) ,
2021-10-15 08:08:03 -04:00
/***/ 2186 :
2020-09-06 16:03:16 -04:00
/***/ ( function ( _ _unused _webpack _module , exports , _ _webpack _require _ _ ) {
"use strict" ;
2021-08-10 02:35:00 -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-09-06 16:03:16 -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 } ) ) ;
2021-10-15 08:08:03 -04:00
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 = _ _webpack _require _ _ ( 7351 ) ;
2020-10-01 14:00:57 -04:00
const file _command _1 = _ _webpack _require _ _ ( 717 ) ;
2021-10-15 08:08:03 -04:00
const utils _1 = _ _webpack _require _ _ ( 5278 ) ;
const os = _ _importStar ( _ _webpack _require _ _ ( 2087 ) ) ;
const path = _ _importStar ( _ _webpack _require _ _ ( 5622 ) ) ;
const oidc _utils _1 = _ _webpack _require _ _ ( 8041 ) ;
2020-09-06 16:03:16 -04:00
/ * *
* The code to exit an action
* /
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
//-----------------------------------------------------------------------
/ * *
* 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
* /
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function exportVariable ( name , val ) {
2020-10-01 14:00:57 -04:00
const convertedVal = utils _1 . toCommandValue ( val ) ;
2020-09-06 16:03:16 -04:00
process . env [ name ] = convertedVal ;
2020-10-01 14:00:57 -04:00
const filePath = process . env [ 'GITHUB_ENV' ] || '' ;
if ( filePath ) {
const delimiter = '_GitHubActionsFileCommandDelimeter_' ;
const commandValue = ` ${ name } << ${ delimiter } ${ os . EOL } ${ convertedVal } ${ os . EOL } ${ delimiter } ` ;
file _command _1 . issueCommand ( 'ENV' , commandValue ) ;
}
else {
command _1 . issueCommand ( 'set-env' , { name } , convertedVal ) ;
}
2020-09-06 16:03:16 -04:00
}
exports . exportVariable = exportVariable ;
/ * *
* Registers a secret which will get masked from logs
* @ param secret value of the secret
* /
function setSecret ( secret ) {
command _1 . issueCommand ( 'add-mask' , { } , secret ) ;
}
exports . setSecret = setSecret ;
/ * *
* Prepends inputPath to the PATH ( for this action and future actions )
* @ param inputPath
* /
function addPath ( inputPath ) {
2020-10-01 14:00:57 -04:00
const filePath = process . env [ 'GITHUB_PATH' ] || '' ;
if ( filePath ) {
file _command _1 . issueCommand ( 'PATH' , inputPath ) ;
}
else {
command _1 . issueCommand ( 'add-path' , { } , inputPath ) ;
}
2020-09-06 16:03:16 -04:00
process . env [ 'PATH' ] = ` ${ inputPath } ${ path . delimiter } ${ process . env [ 'PATH' ] } ` ;
}
exports . addPath = addPath ;
/ * *
2021-08-10 02:35:00 -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-09-06 16:03:16 -04:00
*
* @ param name name of the input to get
* @ param options optional . See InputOptions .
* @ returns string
* /
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 } ` ) ;
}
2021-08-10 02:35:00 -04:00
if ( options && options . trimWhitespace === false ) {
return val ;
}
2020-09-06 16:03:16 -04:00
return val . trim ( ) ;
}
exports . getInput = getInput ;
2021-08-10 02:35:00 -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 [ ]
*
* /
function getMultilineInput ( name , options ) {
const inputs = getInput ( name , options )
. split ( '\n' )
. filter ( x => x !== '' ) ;
return inputs ;
}
exports . getMultilineInput = getMultilineInput ;
/ * *
* 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
*
* @ param name name of the input to get
* @ param options optional . See InputOptions .
* @ returns boolean
* /
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 \` ` ) ;
}
exports . getBooleanInput = getBooleanInput ;
2020-09-06 16:03:16 -04:00
/ * *
* Sets the value of an output .
*
* @ 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
* /
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setOutput ( name , value ) {
2021-05-09 05:07:52 -04:00
process . stdout . write ( os . EOL ) ;
2020-09-06 16:03:16 -04:00
command _1 . issueCommand ( 'set-output' , { name } , value ) ;
}
exports . setOutput = setOutput ;
/ * *
* 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 .
*
* /
function setCommandEcho ( enabled ) {
command _1 . issue ( 'echo' , enabled ? 'on' : 'off' ) ;
}
exports . setCommandEcho = setCommandEcho ;
//-----------------------------------------------------------------------
// Results
//-----------------------------------------------------------------------
/ * *
* 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
* /
function setFailed ( message ) {
process . exitCode = ExitCode . Failure ;
error ( message ) ;
}
exports . setFailed = setFailed ;
//-----------------------------------------------------------------------
// Logging Commands
//-----------------------------------------------------------------------
/ * *
* Gets whether Actions Step Debug is on or not
* /
function isDebug ( ) {
return process . env [ 'RUNNER_DEBUG' ] === '1' ;
}
exports . isDebug = isDebug ;
/ * *
* Writes debug message to user log
* @ param message debug message
* /
function debug ( message ) {
command _1 . issueCommand ( 'debug' , { } , message ) ;
}
exports . debug = debug ;
/ * *
* Adds an error issue
* @ param message error issue message . Errors will be converted to string via toString ( )
2021-09-04 19:21:08 -04:00
* @ param properties optional properties to add to the annotation .
2020-09-06 16:03:16 -04:00
* /
2021-09-04 19:21:08 -04:00
function error ( message , properties = { } ) {
command _1 . issueCommand ( 'error' , utils _1 . toCommandProperties ( properties ) , message instanceof Error ? message . toString ( ) : message ) ;
2020-09-06 16:03:16 -04:00
}
exports . error = error ;
/ * *
2021-09-04 19:21:08 -04:00
* Adds a warning issue
2020-09-06 16:03:16 -04:00
* @ param message warning issue message . Errors will be converted to string via toString ( )
2021-09-04 19:21:08 -04:00
* @ param properties optional properties to add to the annotation .
2020-09-06 16:03:16 -04:00
* /
2021-09-04 19:21:08 -04:00
function warning ( message , properties = { } ) {
command _1 . issueCommand ( 'warning' , utils _1 . toCommandProperties ( properties ) , message instanceof Error ? message . toString ( ) : message ) ;
2020-09-06 16:03:16 -04:00
}
exports . warning = warning ;
2021-09-04 19:21:08 -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 .
* /
function notice ( message , properties = { } ) {
command _1 . issueCommand ( 'notice' , utils _1 . toCommandProperties ( properties ) , message instanceof Error ? message . toString ( ) : message ) ;
}
exports . notice = notice ;
2020-09-06 16:03:16 -04:00
/ * *
* Writes info to log with console . log .
* @ param message info message
* /
function info ( message ) {
process . stdout . write ( message + os . EOL ) ;
}
exports . info = info ;
/ * *
* Begin an output group .
*
* Output until the next ` groupEnd ` will be foldable in this group
*
* @ param name The name of the output group
* /
function startGroup ( name ) {
command _1 . issue ( 'group' , name ) ;
}
exports . startGroup = startGroup ;
/ * *
* End an output group .
* /
function endGroup ( ) {
command _1 . issue ( 'endgroup' ) ;
}
exports . endGroup = endGroup ;
/ * *
* Wrap an asynchronous function call in a group .
*
* Returns the same type as the function itself .
*
* @ param name The name of the group
* @ param fn The function to wrap in the group
* /
function group ( name , fn ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
startGroup ( name ) ;
let result ;
try {
result = yield fn ( ) ;
}
finally {
endGroup ( ) ;
}
return result ;
} ) ;
}
exports . group = group ;
//-----------------------------------------------------------------------
// Wrapper action state
//-----------------------------------------------------------------------
/ * *
* Saves state for current action , the state can only be retrieved by this action ' s post job execution .
*
* @ 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
* /
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function saveState ( name , value ) {
command _1 . issueCommand ( 'save-state' , { name } , value ) ;
}
exports . saveState = saveState ;
/ * *
* Gets the value of an state set by this action ' s main execution .
*
* @ param name name of the state to get
* @ returns string
* /
function getState ( name ) {
return process . env [ ` STATE_ ${ name } ` ] || '' ;
}
exports . getState = getState ;
2021-10-15 08:08:03 -04:00
function getIDToken ( aud ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return yield oidc _utils _1 . OidcClient . getIDToken ( aud ) ;
} ) ;
}
exports . getIDToken = getIDToken ;
2020-09-06 16:03:16 -04:00
//# sourceMappingURL=core.js.map
/***/ } ) ,
2020-10-01 14:00:57 -04:00
/***/ 717 :
/***/ ( function ( _ _unused _webpack _module , exports , _ _webpack _require _ _ ) {
"use strict" ;
// For internal use, subject to change.
2021-08-10 02:35:00 -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 14:00:57 -04:00
var _ _importStar = ( this && this . _ _importStar ) || function ( mod ) {
if ( mod && mod . _ _esModule ) return mod ;
var result = { } ;
2021-08-10 02:35:00 -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 14:00:57 -04:00
return result ;
} ;
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
2021-08-10 02:35:00 -04:00
exports . issueCommand = void 0 ;
2020-10-01 14:00:57 -04:00
// We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */
2021-10-15 08:08:03 -04:00
const fs = _ _importStar ( _ _webpack _require _ _ ( 5747 ) ) ;
const os = _ _importStar ( _ _webpack _require _ _ ( 2087 ) ) ;
const utils _1 = _ _webpack _require _ _ ( 5278 ) ;
2020-10-01 14:00:57 -04:00
function issueCommand ( command , message ) {
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'
} ) ;
}
exports . issueCommand = issueCommand ;
//# sourceMappingURL=file-command.js.map
/***/ } ) ,
2021-10-15 08:08:03 -04:00
/***/ 8041 :
/***/ ( function ( _ _unused _webpack _module , exports , _ _webpack _require _ _ ) {
"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 . OidcClient = void 0 ;
const http _client _1 = _ _webpack _require _ _ ( 9925 ) ;
const auth _1 = _ _webpack _require _ _ ( 3702 ) ;
const core _1 = _ _webpack _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 ) ;
}
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 ;
}
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 ;
}
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 ;
} ) ;
}
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 } ` ) ;
}
} ) ;
}
}
exports . OidcClient = OidcClient ;
//# sourceMappingURL=oidc-utils.js.map
/***/ } ) ,
/***/ 5278 :
2020-10-01 14:00:57 -04:00
/***/ ( ( _ _unused _webpack _module , exports ) => {
"use strict" ;
// We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
2021-09-04 19:21:08 -04:00
exports . toCommandProperties = exports . toCommandValue = void 0 ;
2020-10-01 14:00:57 -04:00
/ * *
* 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 ) ;
}
exports . toCommandValue = toCommandValue ;
2021-09-04 19:21:08 -04:00
/ * *
*
* @ 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 { } ;
}
return {
title : annotationProperties . title ,
2021-10-15 08:08:03 -04:00
file : annotationProperties . file ,
2021-09-04 19:21:08 -04:00
line : annotationProperties . startLine ,
endLine : annotationProperties . endLine ,
col : annotationProperties . startColumn ,
endColumn : annotationProperties . endColumn
} ;
}
exports . toCommandProperties = toCommandProperties ;
2020-10-01 14:00:57 -04:00
//# sourceMappingURL=utils.js.map
/***/ } ) ,
2021-10-15 08:08:03 -04:00
/***/ 1514 :
2020-09-06 16:03:16 -04:00
/***/ ( function ( _ _unused _webpack _module , exports , _ _webpack _require _ _ ) {
"use strict" ;
2021-08-10 02:31:09 -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-09-06 16:03:16 -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 } ) ) ;
2021-08-10 02:31:09 -04:00
exports . getExecOutput = exports . exec = void 0 ;
2021-10-15 08:08:03 -04:00
const string _decoder _1 = _ _webpack _require _ _ ( 4304 ) ;
const tr = _ _importStar ( _ _webpack _require _ _ ( 8159 ) ) ;
2020-09-06 16:03:16 -04:00
/ * *
* Exec a command .
* Output will be streamed to the live console .
* Returns promise with return code
*
* @ param commandLine command to execute ( can include additional args ) . Must be correctly escaped .
* @ param args optional arguments for tool . Escaping is handled by the lib .
* @ param options optional exec options . See ExecOptions
* @ returns Promise < number > exit code
* /
function exec ( commandLine , args , options ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
const commandArgs = tr . argStringToArray ( commandLine ) ;
if ( commandArgs . length === 0 ) {
throw new Error ( ` Parameter 'commandLine' cannot be null or empty. ` ) ;
}
// Path to tool to execute should be first arg
const toolPath = commandArgs [ 0 ] ;
args = commandArgs . slice ( 1 ) . concat ( args || [ ] ) ;
const runner = new tr . ToolRunner ( toolPath , args , options ) ;
return runner . exec ( ) ;
} ) ;
}
exports . exec = exec ;
2021-08-10 02:31:09 -04:00
/ * *
* Exec a command and get the output .
* Output will be streamed to the live console .
* Returns promise with the exit code and collected stdout and stderr
*
* @ param commandLine command to execute ( can include additional args ) . Must be correctly escaped .
* @ param args optional arguments for tool . Escaping is handled by the lib .
* @ param options optional exec options . See ExecOptions
* @ returns Promise < ExecOutput > exit code , stdout , and stderr
* /
function getExecOutput ( commandLine , args , options ) {
var _a , _b ;
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
let stdout = '' ;
let stderr = '' ;
//Using string decoder covers the case where a mult-byte character is split
const stdoutDecoder = new string _decoder _1 . StringDecoder ( 'utf8' ) ;
const stderrDecoder = new string _decoder _1 . StringDecoder ( 'utf8' ) ;
const originalStdoutListener = ( _a = options === null || options === void 0 ? void 0 : options . listeners ) === null || _a === void 0 ? void 0 : _a . stdout ;
const originalStdErrListener = ( _b = options === null || options === void 0 ? void 0 : options . listeners ) === null || _b === void 0 ? void 0 : _b . stderr ;
const stdErrListener = ( data ) => {
stderr += stderrDecoder . write ( data ) ;
if ( originalStdErrListener ) {
originalStdErrListener ( data ) ;
}
} ;
const stdOutListener = ( data ) => {
stdout += stdoutDecoder . write ( data ) ;
if ( originalStdoutListener ) {
originalStdoutListener ( data ) ;
}
} ;
const listeners = Object . assign ( Object . assign ( { } , options === null || options === void 0 ? void 0 : options . listeners ) , { stdout : stdOutListener , stderr : stdErrListener } ) ;
const exitCode = yield exec ( commandLine , args , Object . assign ( Object . assign ( { } , options ) , { listeners } ) ) ;
//flush any remaining characters
stdout += stdoutDecoder . end ( ) ;
stderr += stderrDecoder . end ( ) ;
return {
exitCode ,
stdout ,
stderr
} ;
} ) ;
}
exports . getExecOutput = getExecOutput ;
2020-09-06 16:03:16 -04:00
//# sourceMappingURL=exec.js.map
/***/ } ) ,
2021-10-15 08:08:03 -04:00
/***/ 8159 :
2020-09-06 16:03:16 -04:00
/***/ ( function ( _ _unused _webpack _module , exports , _ _webpack _require _ _ ) {
"use strict" ;
2021-08-10 02:31:09 -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-09-06 16:03:16 -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 } ) ) ;
2021-08-10 02:31:09 -04:00
exports . argStringToArray = exports . ToolRunner = void 0 ;
2021-10-15 08:08:03 -04:00
const os = _ _importStar ( _ _webpack _require _ _ ( 2087 ) ) ;
const events = _ _importStar ( _ _webpack _require _ _ ( 8614 ) ) ;
const child = _ _importStar ( _ _webpack _require _ _ ( 3129 ) ) ;
const path = _ _importStar ( _ _webpack _require _ _ ( 5622 ) ) ;
const io = _ _importStar ( _ _webpack _require _ _ ( 7436 ) ) ;
const ioUtil = _ _importStar ( _ _webpack _require _ _ ( 1962 ) ) ;
const timers _1 = _ _webpack _require _ _ ( 8213 ) ;
2020-09-06 16:03:16 -04:00
/* eslint-disable @typescript-eslint/unbound-method */
const IS _WINDOWS = process . platform === 'win32' ;
/ *
* Class for running command line tools . Handles quoting and arg parsing in a platform agnostic way .
* /
class ToolRunner extends events . EventEmitter {
constructor ( toolPath , args , options ) {
super ( ) ;
if ( ! toolPath ) {
throw new Error ( "Parameter 'toolPath' cannot be null or empty." ) ;
}
this . toolPath = toolPath ;
this . args = args || [ ] ;
this . options = options || { } ;
}
_debug ( message ) {
if ( this . options . listeners && this . options . listeners . debug ) {
this . options . listeners . debug ( message ) ;
}
}
_getCommandString ( options , noPrefix ) {
const toolPath = this . _getSpawnFileName ( ) ;
const args = this . _getSpawnArgs ( options ) ;
let cmd = noPrefix ? '' : '[command]' ; // omit prefix when piped to a second tool
if ( IS _WINDOWS ) {
// Windows + cmd file
if ( this . _isCmdFile ( ) ) {
cmd += toolPath ;
for ( const a of args ) {
cmd += ` ${ a } ` ;
}
}
// Windows + verbatim
else if ( options . windowsVerbatimArguments ) {
cmd += ` " ${ toolPath } " ` ;
for ( const a of args ) {
cmd += ` ${ a } ` ;
}
}
// Windows (regular)
else {
cmd += this . _windowsQuoteCmdArg ( toolPath ) ;
for ( const a of args ) {
cmd += ` ${ this . _windowsQuoteCmdArg ( a ) } ` ;
}
}
}
else {
// OSX/Linux - this can likely be improved with some form of quoting.
// creating processes on Unix is fundamentally different than Windows.
// on Unix, execvp() takes an arg array.
cmd += toolPath ;
for ( const a of args ) {
cmd += ` ${ a } ` ;
}
}
return cmd ;
}
_processLineBuffer ( data , strBuffer , onLine ) {
try {
let s = strBuffer + data . toString ( ) ;
let n = s . indexOf ( os . EOL ) ;
while ( n > - 1 ) {
const line = s . substring ( 0 , n ) ;
onLine ( line ) ;
// the rest of the string ...
s = s . substring ( n + os . EOL . length ) ;
n = s . indexOf ( os . EOL ) ;
}
2021-08-10 02:31:09 -04:00
return s ;
2020-09-06 16:03:16 -04:00
}
catch ( err ) {
// streaming lines to console is best effort. Don't fail a build.
this . _debug ( ` error processing line. Failed with error ${ err } ` ) ;
2021-08-10 02:31:09 -04:00
return '' ;
2020-09-06 16:03:16 -04:00
}
}
_getSpawnFileName ( ) {
if ( IS _WINDOWS ) {
if ( this . _isCmdFile ( ) ) {
return process . env [ 'COMSPEC' ] || 'cmd.exe' ;
}
}
return this . toolPath ;
}
_getSpawnArgs ( options ) {
if ( IS _WINDOWS ) {
if ( this . _isCmdFile ( ) ) {
let argline = ` /D /S /C " ${ this . _windowsQuoteCmdArg ( this . toolPath ) } ` ;
for ( const a of this . args ) {
argline += ' ' ;
argline += options . windowsVerbatimArguments
? a
: this . _windowsQuoteCmdArg ( a ) ;
}
argline += '"' ;
return [ argline ] ;
}
}
return this . args ;
}
_endsWith ( str , end ) {
return str . endsWith ( end ) ;
}
_isCmdFile ( ) {
const upperToolPath = this . toolPath . toUpperCase ( ) ;
return ( this . _endsWith ( upperToolPath , '.CMD' ) ||
this . _endsWith ( upperToolPath , '.BAT' ) ) ;
}
_windowsQuoteCmdArg ( arg ) {
// for .exe, apply the normal quoting rules that libuv applies
if ( ! this . _isCmdFile ( ) ) {
return this . _uvQuoteCmdArg ( arg ) ;
}
// otherwise apply quoting rules specific to the cmd.exe command line parser.
// the libuv rules are generic and are not designed specifically for cmd.exe
// command line parser.
//
// for a detailed description of the cmd.exe command line parser, refer to
// http://stackoverflow.com/questions/4094699/how-does-the-windows-command-interpreter-cmd-exe-parse-scripts/7970912#7970912
// need quotes for empty arg
if ( ! arg ) {
return '""' ;
}
// determine whether the arg needs to be quoted
const cmdSpecialChars = [
' ' ,
'\t' ,
'&' ,
'(' ,
')' ,
'[' ,
']' ,
'{' ,
'}' ,
'^' ,
'=' ,
';' ,
'!' ,
"'" ,
'+' ,
',' ,
'`' ,
'~' ,
'|' ,
'<' ,
'>' ,
'"'
] ;
let needsQuotes = false ;
for ( const char of arg ) {
if ( cmdSpecialChars . some ( x => x === char ) ) {
needsQuotes = true ;
break ;
}
}
// short-circuit if quotes not needed
if ( ! needsQuotes ) {
return arg ;
}
// the following quoting rules are very similar to the rules that by libuv applies.
//
// 1) wrap the string in quotes
//
// 2) double-up quotes - i.e. " => ""
//
// this is different from the libuv quoting rules. libuv replaces " with \", which unfortunately
// doesn't work well with a cmd.exe command line.
//
// note, replacing " with "" also works well if the arg is passed to a downstream .NET console app.
// for example, the command line:
// foo.exe "myarg:""my val"""
// is parsed by a .NET console app into an arg array:
// [ "myarg:\"my val\"" ]
// which is the same end result when applying libuv quoting rules. although the actual
// command line from libuv quoting rules would look like:
// foo.exe "myarg:\"my val\""
//
// 3) double-up slashes that precede a quote,
// e.g. hello \world => "hello \world"
// hello\"world => "hello\\""world"
// hello\\"world => "hello\\\\""world"
// hello world\ => "hello world\\"
//
// technically this is not required for a cmd.exe command line, or the batch argument parser.
// the reasons for including this as a .cmd quoting rule are:
//
// a) this is optimized for the scenario where the argument is passed from the .cmd file to an
// external program. many programs (e.g. .NET console apps) rely on the slash-doubling rule.
//
// b) it's what we've been doing previously (by deferring to node default behavior) and we
// haven't heard any complaints about that aspect.
//
// note, a weakness of the quoting rules chosen here, is that % is not escaped. in fact, % cannot be
// escaped when used on the command line directly - even though within a .cmd file % can be escaped
// by using %%.
//
// the saving grace is, on the command line, %var% is left as-is if var is not defined. this contrasts
// the line parsing rules within a .cmd file, where if var is not defined it is replaced with nothing.
//
// one option that was explored was replacing % with ^% - i.e. %var% => ^%var^%. this hack would
// often work, since it is unlikely that var^ would exist, and the ^ character is removed when the
// variable is used. the problem, however, is that ^ is not removed when %* is used to pass the args
// to an external program.
//
// an unexplored potential solution for the % escaping problem, is to create a wrapper .cmd file.
// % can be escaped within a .cmd file.
let reverse = '"' ;
let quoteHit = true ;
for ( let i = arg . length ; i > 0 ; i -- ) {
// walk the string in reverse
reverse += arg [ i - 1 ] ;
if ( quoteHit && arg [ i - 1 ] === '\\' ) {
reverse += '\\' ; // double the slash
}
else if ( arg [ i - 1 ] === '"' ) {
quoteHit = true ;
reverse += '"' ; // double the quote
}
else {
quoteHit = false ;
}
}
reverse += '"' ;
return reverse
. split ( '' )
. reverse ( )
. join ( '' ) ;
}
_uvQuoteCmdArg ( arg ) {
// Tool runner wraps child_process.spawn() and needs to apply the same quoting as
// Node in certain cases where the undocumented spawn option windowsVerbatimArguments
// is used.
//
// Since this function is a port of quote_cmd_arg from Node 4.x (technically, lib UV,
// see https://github.com/nodejs/node/blob/v4.x/deps/uv/src/win/process.c for details),
// pasting copyright notice from Node within this function:
//
// Copyright Joyent, Inc. and other Node contributors. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
if ( ! arg ) {
// Need double quotation for empty argument
return '""' ;
}
if ( ! arg . includes ( ' ' ) && ! arg . includes ( '\t' ) && ! arg . includes ( '"' ) ) {
// No quotation needed
return arg ;
}
if ( ! arg . includes ( '"' ) && ! arg . includes ( '\\' ) ) {
// No embedded double quotes or backslashes, so I can just wrap
// quote marks around the whole thing.
return ` " ${ arg } " ` ;
}
// Expected input/output:
// input : hello"world
// output: "hello\"world"
// input : hello""world
// output: "hello\"\"world"
// input : hello\world
// output: hello\world
// input : hello\\world
// output: hello\\world
// input : hello\"world
// output: "hello\\\"world"
// input : hello\\"world
// output: "hello\\\\\"world"
// input : hello world\
// output: "hello world\\" - note the comment in libuv actually reads "hello world\"
// but it appears the comment is wrong, it should be "hello world\\"
let reverse = '"' ;
let quoteHit = true ;
for ( let i = arg . length ; i > 0 ; i -- ) {
// walk the string in reverse
reverse += arg [ i - 1 ] ;
if ( quoteHit && arg [ i - 1 ] === '\\' ) {
reverse += '\\' ;
}
else if ( arg [ i - 1 ] === '"' ) {
quoteHit = true ;
reverse += '\\' ;
}
else {
quoteHit = false ;
}
}
reverse += '"' ;
return reverse
. split ( '' )
. reverse ( )
. join ( '' ) ;
}
_cloneExecOptions ( options ) {
options = options || { } ;
const result = {
cwd : options . cwd || process . cwd ( ) ,
env : options . env || process . env ,
silent : options . silent || false ,
windowsVerbatimArguments : options . windowsVerbatimArguments || false ,
failOnStdErr : options . failOnStdErr || false ,
ignoreReturnCode : options . ignoreReturnCode || false ,
delay : options . delay || 10000
} ;
result . outStream = options . outStream || process . stdout ;
result . errStream = options . errStream || process . stderr ;
return result ;
}
_getSpawnOptions ( options , toolPath ) {
options = options || { } ;
const result = { } ;
result . cwd = options . cwd ;
result . env = options . env ;
result [ 'windowsVerbatimArguments' ] =
options . windowsVerbatimArguments || this . _isCmdFile ( ) ;
if ( options . windowsVerbatimArguments ) {
result . argv0 = ` " ${ toolPath } " ` ;
}
return result ;
}
/ * *
* Exec a tool .
* Output will be streamed to the live console .
* Returns promise with return code
*
* @ param tool path to tool to exec
* @ param options optional exec options . See ExecOptions
* @ returns number
* /
exec ( ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
// root the tool path if it is unrooted and contains relative pathing
if ( ! ioUtil . isRooted ( this . toolPath ) &&
( this . toolPath . includes ( '/' ) ||
( IS _WINDOWS && this . toolPath . includes ( '\\' ) ) ) ) {
// prefer options.cwd if it is specified, however options.cwd may also need to be rooted
this . toolPath = path . resolve ( process . cwd ( ) , this . options . cwd || process . cwd ( ) , this . toolPath ) ;
}
// if the tool is only a file name, then resolve it from the PATH
// otherwise verify it exists (add extension on Windows if necessary)
this . toolPath = yield io . which ( this . toolPath , true ) ;
2021-08-10 02:31:09 -04:00
return new Promise ( ( resolve , reject ) => _ _awaiter ( this , void 0 , void 0 , function * ( ) {
2020-09-06 16:03:16 -04:00
this . _debug ( ` exec tool: ${ this . toolPath } ` ) ;
this . _debug ( 'arguments:' ) ;
for ( const arg of this . args ) {
this . _debug ( ` ${ arg } ` ) ;
}
const optionsNonNull = this . _cloneExecOptions ( this . options ) ;
if ( ! optionsNonNull . silent && optionsNonNull . outStream ) {
optionsNonNull . outStream . write ( this . _getCommandString ( optionsNonNull ) + os . EOL ) ;
}
const state = new ExecState ( optionsNonNull , this . toolPath ) ;
state . on ( 'debug' , ( message ) => {
this . _debug ( message ) ;
} ) ;
2021-08-10 02:31:09 -04:00
if ( this . options . cwd && ! ( yield ioUtil . exists ( this . options . cwd ) ) ) {
return reject ( new Error ( ` The cwd: ${ this . options . cwd } does not exist! ` ) ) ;
}
2020-09-06 16:03:16 -04:00
const fileName = this . _getSpawnFileName ( ) ;
const cp = child . spawn ( fileName , this . _getSpawnArgs ( optionsNonNull ) , this . _getSpawnOptions ( this . options , fileName ) ) ;
2021-08-10 02:31:09 -04:00
let stdbuffer = '' ;
2020-09-06 16:03:16 -04:00
if ( cp . stdout ) {
cp . stdout . on ( 'data' , ( data ) => {
if ( this . options . listeners && this . options . listeners . stdout ) {
this . options . listeners . stdout ( data ) ;
}
if ( ! optionsNonNull . silent && optionsNonNull . outStream ) {
optionsNonNull . outStream . write ( data ) ;
}
2021-08-10 02:31:09 -04:00
stdbuffer = this . _processLineBuffer ( data , stdbuffer , ( line ) => {
2020-09-06 16:03:16 -04:00
if ( this . options . listeners && this . options . listeners . stdline ) {
this . options . listeners . stdline ( line ) ;
}
} ) ;
} ) ;
}
2021-08-10 02:31:09 -04:00
let errbuffer = '' ;
2020-09-06 16:03:16 -04:00
if ( cp . stderr ) {
cp . stderr . on ( 'data' , ( data ) => {
state . processStderr = true ;
if ( this . options . listeners && this . options . listeners . stderr ) {
this . options . listeners . stderr ( data ) ;
}
if ( ! optionsNonNull . silent &&
optionsNonNull . errStream &&
optionsNonNull . outStream ) {
const s = optionsNonNull . failOnStdErr
? optionsNonNull . errStream
: optionsNonNull . outStream ;
s . write ( data ) ;
}
2021-08-10 02:31:09 -04:00
errbuffer = this . _processLineBuffer ( data , errbuffer , ( line ) => {
2020-09-06 16:03:16 -04:00
if ( this . options . listeners && this . options . listeners . errline ) {
this . options . listeners . errline ( line ) ;
}
} ) ;
} ) ;
}
cp . on ( 'error' , ( err ) => {
state . processError = err . message ;
state . processExited = true ;
state . processClosed = true ;
state . CheckComplete ( ) ;
} ) ;
cp . on ( 'exit' , ( code ) => {
state . processExitCode = code ;
state . processExited = true ;
this . _debug ( ` Exit code ${ code } received from tool ' ${ this . toolPath } ' ` ) ;
state . CheckComplete ( ) ;
} ) ;
cp . on ( 'close' , ( code ) => {
state . processExitCode = code ;
state . processExited = true ;
state . processClosed = true ;
this . _debug ( ` STDIO streams have closed for tool ' ${ this . toolPath } ' ` ) ;
state . CheckComplete ( ) ;
} ) ;
state . on ( 'done' , ( error , exitCode ) => {
if ( stdbuffer . length > 0 ) {
this . emit ( 'stdline' , stdbuffer ) ;
}
if ( errbuffer . length > 0 ) {
this . emit ( 'errline' , errbuffer ) ;
}
cp . removeAllListeners ( ) ;
if ( error ) {
reject ( error ) ;
}
else {
resolve ( exitCode ) ;
}
} ) ;
if ( this . options . input ) {
if ( ! cp . stdin ) {
throw new Error ( 'child process missing stdin' ) ;
}
cp . stdin . end ( this . options . input ) ;
}
2021-08-10 02:31:09 -04:00
} ) ) ;
2020-09-06 16:03:16 -04:00
} ) ;
}
}
exports . ToolRunner = ToolRunner ;
/ * *
* Convert an arg string to an array of args . Handles escaping
*
* @ param argString string of arguments
* @ returns string [ ] array of arguments
* /
function argStringToArray ( argString ) {
const args = [ ] ;
let inQuotes = false ;
let escaped = false ;
let arg = '' ;
function append ( c ) {
// we only escape double quotes.
if ( escaped && c !== '"' ) {
arg += '\\' ;
}
arg += c ;
escaped = false ;
}
for ( let i = 0 ; i < argString . length ; i ++ ) {
const c = argString . charAt ( i ) ;
if ( c === '"' ) {
if ( ! escaped ) {
inQuotes = ! inQuotes ;
}
else {
append ( c ) ;
}
continue ;
}
if ( c === '\\' && escaped ) {
append ( c ) ;
continue ;
}
if ( c === '\\' && inQuotes ) {
escaped = true ;
continue ;
}
if ( c === ' ' && ! inQuotes ) {
if ( arg . length > 0 ) {
args . push ( arg ) ;
arg = '' ;
}
continue ;
}
append ( c ) ;
}
if ( arg . length > 0 ) {
args . push ( arg . trim ( ) ) ;
}
return args ;
}
exports . argStringToArray = argStringToArray ;
class ExecState extends events . EventEmitter {
constructor ( options , toolPath ) {
super ( ) ;
this . processClosed = false ; // tracks whether the process has exited and stdio is closed
this . processError = '' ;
this . processExitCode = 0 ;
this . processExited = false ; // tracks whether the process has exited
this . processStderr = false ; // tracks whether stderr was written to
this . delay = 10000 ; // 10 seconds
this . done = false ;
this . timeout = null ;
if ( ! toolPath ) {
throw new Error ( 'toolPath must not be empty' ) ;
}
this . options = options ;
this . toolPath = toolPath ;
if ( options . delay ) {
this . delay = options . delay ;
}
}
CheckComplete ( ) {
if ( this . done ) {
return ;
}
if ( this . processClosed ) {
this . _setResult ( ) ;
}
else if ( this . processExited ) {
2021-08-10 02:31:09 -04:00
this . timeout = timers _1 . setTimeout ( ExecState . HandleTimeout , this . delay , this ) ;
2020-09-06 16:03:16 -04:00
}
}
_debug ( message ) {
this . emit ( 'debug' , message ) ;
}
_setResult ( ) {
// determine whether there is an error
let error ;
if ( this . processExited ) {
if ( this . processError ) {
error = new Error ( ` There was an error when attempting to execute the process ' ${ this . toolPath } '. This may indicate the process failed to start. Error: ${ this . processError } ` ) ;
}
else if ( this . processExitCode !== 0 && ! this . options . ignoreReturnCode ) {
error = new Error ( ` The process ' ${ this . toolPath } ' failed with exit code ${ this . processExitCode } ` ) ;
}
else if ( this . processStderr && this . options . failOnStdErr ) {
error = new Error ( ` The process ' ${ this . toolPath } ' failed because one or more lines were written to the STDERR stream ` ) ;
}
}
// clear the timeout
if ( this . timeout ) {
clearTimeout ( this . timeout ) ;
this . timeout = null ;
}
this . done = true ;
this . emit ( 'done' , error , this . processExitCode ) ;
}
static HandleTimeout ( state ) {
if ( state . done ) {
return ;
}
if ( ! state . processClosed && state . processExited ) {
const message = ` The STDIO streams did not close within ${ state . delay /
1000 } seconds of the exit event from process '${state.toolPath}' . This may indicate a child process inherited the STDIO streams and has not yet exited . ` ;
state . _debug ( message ) ;
}
state . _setResult ( ) ;
}
}
//# sourceMappingURL=toolrunner.js.map
/***/ } ) ,
2021-10-15 08:08:03 -04:00
/***/ 3702 :
/***/ ( ( _ _unused _webpack _module , exports ) => {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
class BasicCredentialHandler {
constructor ( username , password ) {
this . username = username ;
this . password = password ;
}
prepareRequest ( options ) {
options . headers [ 'Authorization' ] =
'Basic ' +
Buffer . from ( this . username + ':' + this . password ) . toString ( 'base64' ) ;
}
// This handler cannot handle 401
canHandleAuthentication ( response ) {
return false ;
}
handleAuthentication ( httpClient , requestInfo , objs ) {
return null ;
}
}
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 ) {
options . headers [ 'Authorization' ] = 'Bearer ' + this . token ;
}
// This handler cannot handle 401
canHandleAuthentication ( response ) {
return false ;
}
handleAuthentication ( httpClient , requestInfo , objs ) {
return null ;
}
}
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 ) {
options . headers [ 'Authorization' ] =
'Basic ' + Buffer . from ( 'PAT:' + this . token ) . toString ( 'base64' ) ;
}
// This handler cannot handle 401
canHandleAuthentication ( response ) {
return false ;
}
handleAuthentication ( httpClient , requestInfo , objs ) {
return null ;
}
}
exports . PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler ;
/***/ } ) ,
/***/ 9925 :
/***/ ( ( _ _unused _webpack _module , exports , _ _webpack _require _ _ ) => {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
const http = _ _webpack _require _ _ ( 8605 ) ;
const https = _ _webpack _require _ _ ( 7211 ) ;
const pm = _ _webpack _require _ _ ( 6443 ) ;
let tunnel ;
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 = { } ) ) ;
/ * *
* 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
* /
function getProxyUrl ( serverUrl ) {
let 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 ) ;
}
}
exports . HttpClientError = HttpClientError ;
class HttpClientResponse {
constructor ( message ) {
this . message = message ;
}
readBody ( ) {
return new Promise ( async ( resolve , reject ) => {
let output = Buffer . alloc ( 0 ) ;
this . message . on ( 'data' , ( chunk ) => {
output = Buffer . concat ( [ output , chunk ] ) ;
} ) ;
this . message . on ( 'end' , ( ) => {
resolve ( output . toString ( ) ) ;
} ) ;
} ) ;
}
}
exports . HttpClientResponse = HttpClientResponse ;
function isHttps ( requestUrl ) {
let parsedUrl = new URL ( requestUrl ) ;
return parsedUrl . protocol === 'https:' ;
}
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 ;
}
}
}
options ( requestUrl , additionalHeaders ) {
return this . request ( 'OPTIONS' , requestUrl , null , additionalHeaders || { } ) ;
}
get ( requestUrl , additionalHeaders ) {
return this . request ( 'GET' , requestUrl , null , additionalHeaders || { } ) ;
}
del ( requestUrl , additionalHeaders ) {
return this . request ( 'DELETE' , requestUrl , null , additionalHeaders || { } ) ;
}
post ( requestUrl , data , additionalHeaders ) {
return this . request ( 'POST' , requestUrl , data , additionalHeaders || { } ) ;
}
patch ( requestUrl , data , additionalHeaders ) {
return this . request ( 'PATCH' , requestUrl , data , additionalHeaders || { } ) ;
}
put ( requestUrl , data , additionalHeaders ) {
return this . request ( 'PUT' , requestUrl , data , additionalHeaders || { } ) ;
}
head ( requestUrl , additionalHeaders ) {
return this . request ( 'HEAD' , requestUrl , null , additionalHeaders || { } ) ;
}
sendStream ( verb , requestUrl , stream , additionalHeaders ) {
return this . request ( verb , requestUrl , stream , additionalHeaders ) ;
}
/ * *
* Gets a typed object from an endpoint
* Be aware that not found returns a null . Other errors ( 4 xx , 5 xx ) reject the promise
* /
async getJson ( requestUrl , additionalHeaders = { } ) {
additionalHeaders [ Headers . Accept ] = this . _getExistingOrDefaultHeader ( additionalHeaders , Headers . Accept , MediaTypes . ApplicationJson ) ;
let res = await this . get ( requestUrl , additionalHeaders ) ;
return this . _processResponse ( res , this . requestOptions ) ;
}
async postJson ( requestUrl , obj , additionalHeaders = { } ) {
let 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 ) ;
let res = await this . post ( requestUrl , data , additionalHeaders ) ;
return this . _processResponse ( res , this . requestOptions ) ;
}
async putJson ( requestUrl , obj , additionalHeaders = { } ) {
let 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 ) ;
let res = await this . put ( requestUrl , data , additionalHeaders ) ;
return this . _processResponse ( res , this . requestOptions ) ;
}
async patchJson ( requestUrl , obj , additionalHeaders = { } ) {
let 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 ) ;
let res = await this . patch ( requestUrl , data , additionalHeaders ) ;
return this . _processResponse ( res , this . requestOptions ) ;
}
/ * *
* Makes a raw http request .
* All other methods such as get , post , patch , and request ultimately call this .
* Prefer get , del , post and patch
* /
async request ( verb , requestUrl , data , headers ) {
if ( this . _disposed ) {
throw new Error ( 'Client has already been disposed.' ) ;
}
let parsedUrl = new URL ( requestUrl ) ;
let info = this . _prepareRequest ( verb , parsedUrl , headers ) ;
// Only perform retries on reads since writes may not be idempotent.
let maxTries = this . _allowRetries && RetryableHttpVerbs . indexOf ( verb ) != - 1
? this . _maxRetries + 1
: 1 ;
let numTries = 0 ;
let response ;
while ( numTries < maxTries ) {
response = await this . requestRaw ( info , data ) ;
// Check if it's an authentication challenge
if ( response &&
response . message &&
response . message . statusCode === HttpCodes . Unauthorized ) {
let authenticationHandler ;
for ( let i = 0 ; i < this . handlers . length ; i ++ ) {
if ( this . handlers [ i ] . canHandleAuthentication ( response ) ) {
authenticationHandler = this . handlers [ i ] ;
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 ( HttpRedirectCodes . indexOf ( response . message . statusCode ) != - 1 &&
this . _allowRedirects &&
redirectsRemaining > 0 ) {
const redirectUrl = response . message . headers [ 'location' ] ;
if ( ! redirectUrl ) {
// if there's no location to redirect to, we won't
break ;
}
let 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.
await response . readBody ( ) ;
// strip authorization header if redirected to a different hostname
if ( parsedRedirectUrl . hostname !== parsedUrl . hostname ) {
for ( let 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 = await this . requestRaw ( info , data ) ;
redirectsRemaining -- ;
}
if ( HttpResponseRetryCodes . indexOf ( response . message . statusCode ) == - 1 ) {
// If not a retry code, return immediately instead of retrying
return response ;
}
numTries += 1 ;
if ( numTries < maxTries ) {
await response . readBody ( ) ;
await this . _performExponentialBackoff ( numTries ) ;
}
}
return response ;
}
/ * *
* Needs to be called if keepAlive is set to true in request options .
* /
dispose ( ) {
if ( this . _agent ) {
this . _agent . destroy ( ) ;
}
this . _disposed = true ;
}
/ * *
* Raw request .
* @ param info
* @ param data
* /
requestRaw ( info , data ) {
return new Promise ( ( resolve , reject ) => {
let callbackForResult = function ( err , res ) {
if ( err ) {
reject ( err ) ;
}
resolve ( res ) ;
} ;
this . requestRawWithCallback ( info , data , callbackForResult ) ;
} ) ;
}
/ * *
* Raw request with callback .
* @ param info
* @ param data
* @ param onResult
* /
requestRawWithCallback ( info , data , onResult ) {
let socket ;
if ( typeof data === 'string' ) {
info . options . headers [ 'Content-Length' ] = Buffer . byteLength ( data , 'utf8' ) ;
}
let callbackCalled = false ;
let handleResult = ( err , res ) => {
if ( ! callbackCalled ) {
callbackCalled = true ;
onResult ( err , res ) ;
}
} ;
let req = info . httpModule . request ( info . options , ( msg ) => {
let res = new HttpClientResponse ( msg ) ;
handleResult ( null , res ) ;
} ) ;
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 ) , null ) ;
} ) ;
req . on ( 'error' , function ( err ) {
// err has statusCode property
// res should have headers
handleResult ( err , null ) ;
} ) ;
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 ( ) ;
}
}
/ * *
* 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 ) {
let parsedUrl = new URL ( serverUrl ) ;
return this . _getAgent ( parsedUrl ) ;
}
_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 ;
}
info . options . agent = this . _getAgent ( info . parsedUrl ) ;
// gives handlers an opportunity to participate
if ( this . handlers ) {
this . handlers . forEach ( handler => {
handler . prepareRequest ( info . options ) ;
} ) ;
}
return info ;
}
_mergeHeaders ( headers ) {
const lowercaseKeys = obj => Object . keys ( obj ) . reduce ( ( c , k ) => ( ( c [ k . toLowerCase ( ) ] = obj [ k ] ) , c ) , { } ) ;
if ( this . requestOptions && this . requestOptions . headers ) {
return Object . assign ( { } , lowercaseKeys ( this . requestOptions . headers ) , lowercaseKeys ( headers ) ) ;
}
return lowercaseKeys ( headers || { } ) ;
}
_getExistingOrDefaultHeader ( additionalHeaders , header , _default ) {
const lowercaseKeys = obj => Object . keys ( obj ) . reduce ( ( c , k ) => ( ( c [ k . toLowerCase ( ) ] = obj [ k ] ) , c ) , { } ) ;
let clientHeader ;
if ( this . requestOptions && this . requestOptions . headers ) {
clientHeader = lowercaseKeys ( this . requestOptions . headers ) [ header ] ;
}
return additionalHeaders [ header ] || clientHeader || _default ;
}
_getAgent ( parsedUrl ) {
let agent ;
let proxyUrl = pm . getProxyUrl ( parsedUrl ) ;
let 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 ;
}
if ( useProxy ) {
// If using proxy, need tunnel
if ( ! tunnel ) {
tunnel = _ _webpack _require _ _ ( 4294 ) ;
}
const agentOptions = {
maxSockets : maxSockets ,
keepAlive : this . _keepAlive ,
proxy : {
... ( ( 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 : 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 ) {
retryNumber = Math . min ( ExponentialBackoffCeiling , retryNumber ) ;
const ms = ExponentialBackoffTimeSlice * Math . pow ( 2 , retryNumber ) ;
return new Promise ( resolve => setTimeout ( ( ) => resolve ( ) , ms ) ) ;
}
static dateTimeDeserializer ( key , value ) {
if ( typeof value === 'string' ) {
let a = new Date ( value ) ;
if ( ! isNaN ( a . valueOf ( ) ) ) {
return a ;
}
}
return value ;
}
async _processResponse ( res , options ) {
return new Promise ( async ( resolve , reject ) => {
const statusCode = res . message . statusCode ;
const response = {
statusCode : statusCode ,
result : null ,
headers : { }
} ;
// not found leads to null obj returned
if ( statusCode == HttpCodes . NotFound ) {
resolve ( response ) ;
}
let obj ;
let contents ;
// get the result from the body
try {
contents = await res . readBody ( ) ;
if ( contents && contents . length > 0 ) {
if ( options && options . deserializeDates ) {
obj = JSON . parse ( contents , HttpClient . 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 + ')' ;
}
let err = new HttpClientError ( msg , statusCode ) ;
err . result = response . result ;
reject ( err ) ;
}
else {
resolve ( response ) ;
}
} ) ;
}
}
exports . HttpClient = HttpClient ;
/***/ } ) ,
/***/ 6443 :
/***/ ( ( _ _unused _webpack _module , exports ) => {
"use strict" ;
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
function getProxyUrl ( reqUrl ) {
let usingSsl = reqUrl . protocol === 'https:' ;
let proxyUrl ;
if ( checkBypass ( reqUrl ) ) {
return proxyUrl ;
}
let proxyVar ;
if ( usingSsl ) {
proxyVar = process . env [ 'https_proxy' ] || process . env [ 'HTTPS_PROXY' ] ;
}
else {
proxyVar = process . env [ 'http_proxy' ] || process . env [ 'HTTP_PROXY' ] ;
}
if ( proxyVar ) {
proxyUrl = new URL ( proxyVar ) ;
}
return proxyUrl ;
}
exports . getProxyUrl = getProxyUrl ;
function checkBypass ( reqUrl ) {
if ( ! reqUrl . hostname ) {
return false ;
}
let 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
let upperReqHosts = [ reqUrl . hostname . toUpperCase ( ) ] ;
if ( typeof reqPort === 'number' ) {
upperReqHosts . push ( ` ${ upperReqHosts [ 0 ] } : ${ reqPort } ` ) ;
}
// Compare request host against noproxy
for ( let upperNoProxyItem of noProxy
. split ( ',' )
. map ( x => x . trim ( ) . toUpperCase ( ) )
. filter ( x => x ) ) {
if ( upperReqHosts . some ( x => x === upperNoProxyItem ) ) {
return true ;
}
}
return false ;
}
exports . checkBypass = checkBypass ;
/***/ } ) ,
/***/ 1962 :
2020-09-06 16:03:16 -04:00
/***/ ( function ( _ _unused _webpack _module , exports , _ _webpack _require _ _ ) {
"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 ( ) ) ;
} ) ;
} ;
var _a ;
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
2021-10-15 08:08:03 -04:00
const assert _1 = _ _webpack _require _ _ ( 2357 ) ;
const fs = _ _webpack _require _ _ ( 5747 ) ;
const path = _ _webpack _require _ _ ( 5622 ) ;
2020-09-06 16:03:16 -04:00
_a = fs . promises , exports . chmod = _a . chmod , exports . copyFile = _a . copyFile , exports . lstat = _a . lstat , exports . mkdir = _a . mkdir , exports . readdir = _a . readdir , exports . readlink = _a . readlink , exports . rename = _a . rename , exports . rmdir = _a . rmdir , exports . stat = _a . stat , exports . symlink = _a . symlink , exports . unlink = _a . unlink ;
exports . IS _WINDOWS = process . platform === 'win32' ;
function exists ( fsPath ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
try {
yield exports . stat ( fsPath ) ;
}
catch ( err ) {
if ( err . code === 'ENOENT' ) {
return false ;
}
throw err ;
}
return true ;
} ) ;
}
exports . exists = exists ;
function isDirectory ( fsPath , useStat = false ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
const stats = useStat ? yield exports . stat ( fsPath ) : yield exports . lstat ( fsPath ) ;
return stats . isDirectory ( ) ;
} ) ;
}
exports . isDirectory = isDirectory ;
/ * *
* On OSX / Linux , true if path starts with '/' . On Windows , true for paths like :
* \ , \ hello , \ \ hello \ share , C : , and C : \ hello ( and corresponding alternate separator cases ) .
* /
function isRooted ( p ) {
p = normalizeSeparators ( p ) ;
if ( ! p ) {
throw new Error ( 'isRooted() parameter "p" cannot be empty' ) ;
}
if ( exports . IS _WINDOWS ) {
return ( p . startsWith ( '\\' ) || /^[A-Z]:/i . test ( p ) // e.g. \ or \hello or \\hello
) ; // e.g. C: or C:\hello
}
return p . startsWith ( '/' ) ;
}
exports . isRooted = isRooted ;
/ * *
* Recursively create a directory at ` fsPath ` .
*
* This implementation is optimistic , meaning it attempts to create the full
* path first , and backs up the path stack from there .
*
* @ param fsPath The path to create
* @ param maxDepth The maximum recursion depth
* @ param depth The current recursion depth
* /
function mkdirP ( fsPath , maxDepth = 1000 , depth = 1 ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
assert _1 . ok ( fsPath , 'a path argument must be provided' ) ;
fsPath = path . resolve ( fsPath ) ;
if ( depth >= maxDepth )
return exports . mkdir ( fsPath ) ;
try {
yield exports . mkdir ( fsPath ) ;
return ;
}
catch ( err ) {
switch ( err . code ) {
case 'ENOENT' : {
yield mkdirP ( path . dirname ( fsPath ) , maxDepth , depth + 1 ) ;
yield exports . mkdir ( fsPath ) ;
return ;
}
default : {
let stats ;
try {
stats = yield exports . stat ( fsPath ) ;
}
catch ( err2 ) {
throw err ;
}
if ( ! stats . isDirectory ( ) )
throw err ;
}
}
}
} ) ;
}
exports . mkdirP = mkdirP ;
/ * *
* Best effort attempt to determine whether a file exists and is executable .
* @ param filePath file path to check
* @ param extensions additional file extensions to try
* @ return if file exists and is executable , returns the file path . otherwise empty string .
* /
function tryGetExecutablePath ( filePath , extensions ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
let stats = undefined ;
try {
// test file exists
stats = yield exports . stat ( filePath ) ;
}
catch ( err ) {
if ( err . code !== 'ENOENT' ) {
// eslint-disable-next-line no-console
console . log ( ` Unexpected error attempting to determine if executable file exists ' ${ filePath } ': ${ err } ` ) ;
}
}
if ( stats && stats . isFile ( ) ) {
if ( exports . IS _WINDOWS ) {
// on Windows, test for valid extension
const upperExt = path . extname ( filePath ) . toUpperCase ( ) ;
if ( extensions . some ( validExt => validExt . toUpperCase ( ) === upperExt ) ) {
return filePath ;
}
}
else {
if ( isUnixExecutable ( stats ) ) {
return filePath ;
}
}
}
// try each extension
const originalFilePath = filePath ;
for ( const extension of extensions ) {
filePath = originalFilePath + extension ;
stats = undefined ;
try {
stats = yield exports . stat ( filePath ) ;
}
catch ( err ) {
if ( err . code !== 'ENOENT' ) {
// eslint-disable-next-line no-console
console . log ( ` Unexpected error attempting to determine if executable file exists ' ${ filePath } ': ${ err } ` ) ;
}
}
if ( stats && stats . isFile ( ) ) {
if ( exports . IS _WINDOWS ) {
// preserve the case of the actual file (since an extension was appended)
try {
const directory = path . dirname ( filePath ) ;
const upperName = path . basename ( filePath ) . toUpperCase ( ) ;
for ( const actualName of yield exports . readdir ( directory ) ) {
if ( upperName === actualName . toUpperCase ( ) ) {
filePath = path . join ( directory , actualName ) ;
break ;
}
}
}
catch ( err ) {
// eslint-disable-next-line no-console
console . log ( ` Unexpected error attempting to determine the actual case of the file ' ${ filePath } ': ${ err } ` ) ;
}
return filePath ;
}
else {
if ( isUnixExecutable ( stats ) ) {
return filePath ;
}
}
}
}
return '' ;
} ) ;
}
exports . tryGetExecutablePath = tryGetExecutablePath ;
function normalizeSeparators ( p ) {
p = p || '' ;
if ( exports . IS _WINDOWS ) {
// convert slashes on Windows
p = p . replace ( /\//g , '\\' ) ;
// remove redundant slashes
return p . replace ( /\\\\+/g , '\\' ) ;
}
// remove redundant slashes
return p . replace ( /\/\/+/g , '/' ) ;
}
// on Mac/Linux, test the execute bit
// R W X R W X R W X
// 256 128 64 32 16 8 4 2 1
function isUnixExecutable ( stats ) {
return ( ( stats . mode & 1 ) > 0 ||
( ( stats . mode & 8 ) > 0 && stats . gid === process . getgid ( ) ) ||
( ( stats . mode & 64 ) > 0 && stats . uid === process . getuid ( ) ) ) ;
}
//# sourceMappingURL=io-util.js.map
/***/ } ) ,
2021-10-15 08:08:03 -04:00
/***/ 7436 :
2020-09-06 16:03:16 -04:00
/***/ ( function ( _ _unused _webpack _module , exports , _ _webpack _require _ _ ) {
"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 } ) ) ;
2021-10-15 08:08:03 -04:00
const childProcess = _ _webpack _require _ _ ( 3129 ) ;
const path = _ _webpack _require _ _ ( 5622 ) ;
const util _1 = _ _webpack _require _ _ ( 1669 ) ;
const ioUtil = _ _webpack _require _ _ ( 1962 ) ;
2020-09-06 16:03:16 -04:00
const exec = util _1 . promisify ( childProcess . exec ) ;
/ * *
* Copies a file or folder .
* Based off of shelljs - https : //github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js
*
* @ param source source path
* @ param dest destination path
* @ param options optional . See CopyOptions .
* /
function cp ( source , dest , options = { } ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
const { force , recursive } = readCopyOptions ( options ) ;
const destStat = ( yield ioUtil . exists ( dest ) ) ? yield ioUtil . stat ( dest ) : null ;
// Dest is an existing file, but not forcing
if ( destStat && destStat . isFile ( ) && ! force ) {
return ;
}
// If dest is an existing directory, should copy inside.
const newDest = destStat && destStat . isDirectory ( )
? path . join ( dest , path . basename ( source ) )
: dest ;
if ( ! ( yield ioUtil . exists ( source ) ) ) {
throw new Error ( ` no such file or directory: ${ source } ` ) ;
}
const sourceStat = yield ioUtil . stat ( source ) ;
if ( sourceStat . isDirectory ( ) ) {
if ( ! recursive ) {
throw new Error ( ` Failed to copy. ${ source } is a directory, but tried to copy without recursive flag. ` ) ;
}
else {
yield cpDirRecursive ( source , newDest , 0 , force ) ;
}
}
else {
if ( path . relative ( source , newDest ) === '' ) {
// a file cannot be copied to itself
throw new Error ( ` ' ${ newDest } ' and ' ${ source } ' are the same file ` ) ;
}
yield copyFile ( source , newDest , force ) ;
}
} ) ;
}
exports . cp = cp ;
/ * *
* Moves a path .
*
* @ param source source path
* @ param dest destination path
* @ param options optional . See MoveOptions .
* /
function mv ( source , dest , options = { } ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
if ( yield ioUtil . exists ( dest ) ) {
let destExists = true ;
if ( yield ioUtil . isDirectory ( dest ) ) {
// If dest is directory copy src into dest
dest = path . join ( dest , path . basename ( source ) ) ;
destExists = yield ioUtil . exists ( dest ) ;
}
if ( destExists ) {
if ( options . force == null || options . force ) {
yield rmRF ( dest ) ;
}
else {
throw new Error ( 'Destination already exists' ) ;
}
}
}
yield mkdirP ( path . dirname ( dest ) ) ;
yield ioUtil . rename ( source , dest ) ;
} ) ;
}
exports . mv = mv ;
/ * *
* Remove a path recursively with force
*
* @ param inputPath path to remove
* /
function rmRF ( inputPath ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
if ( ioUtil . IS _WINDOWS ) {
// Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another
// program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del.
try {
if ( yield ioUtil . isDirectory ( inputPath , true ) ) {
yield exec ( ` rd /s /q " ${ inputPath } " ` ) ;
}
else {
yield exec ( ` del /f /a " ${ inputPath } " ` ) ;
}
}
catch ( err ) {
// if you try to delete a file that doesn't exist, desired result is achieved
// other errors are valid
if ( err . code !== 'ENOENT' )
throw err ;
}
// Shelling out fails to remove a symlink folder with missing source, this unlink catches that
try {
yield ioUtil . unlink ( inputPath ) ;
}
catch ( err ) {
// if you try to delete a file that doesn't exist, desired result is achieved
// other errors are valid
if ( err . code !== 'ENOENT' )
throw err ;
}
}
else {
let isDir = false ;
try {
isDir = yield ioUtil . isDirectory ( inputPath ) ;
}
catch ( err ) {
// if you try to delete a file that doesn't exist, desired result is achieved
// other errors are valid
if ( err . code !== 'ENOENT' )
throw err ;
return ;
}
if ( isDir ) {
yield exec ( ` rm -rf " ${ inputPath } " ` ) ;
}
else {
yield ioUtil . unlink ( inputPath ) ;
}
}
} ) ;
}
exports . rmRF = rmRF ;
/ * *
* Make a directory . Creates the full path with folders in between
* Will throw if it fails
*
* @ param fsPath path to create
* @ returns Promise < void >
* /
function mkdirP ( fsPath ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
yield ioUtil . mkdirP ( fsPath ) ;
} ) ;
}
exports . mkdirP = mkdirP ;
/ * *
* Returns path of a tool had the tool actually been invoked . Resolves via paths .
* If you check and the tool does not exist , it will throw .
*
* @ param tool name of the tool
* @ param check whether to check if tool exists
* @ returns Promise < string > path to tool
* /
function which ( tool , check ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
if ( ! tool ) {
throw new Error ( "parameter 'tool' is required" ) ;
}
// recursive when check=true
if ( check ) {
const result = yield which ( tool , false ) ;
if ( ! result ) {
if ( ioUtil . IS _WINDOWS ) {
throw new Error ( ` Unable to locate executable file: ${ tool } . Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file. ` ) ;
}
else {
throw new Error ( ` Unable to locate executable file: ${ tool } . Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable. ` ) ;
}
}
}
try {
// build the list of extensions to try
const extensions = [ ] ;
if ( ioUtil . IS _WINDOWS && process . env . PATHEXT ) {
for ( const extension of process . env . PATHEXT . split ( path . delimiter ) ) {
if ( extension ) {
extensions . push ( extension ) ;
}
}
}
// if it's rooted, return it if exists. otherwise return empty.
if ( ioUtil . isRooted ( tool ) ) {
const filePath = yield ioUtil . tryGetExecutablePath ( tool , extensions ) ;
if ( filePath ) {
return filePath ;
}
return '' ;
}
// if any path separators, return empty
if ( tool . includes ( '/' ) || ( ioUtil . IS _WINDOWS && tool . includes ( '\\' ) ) ) {
return '' ;
}
// build the list of directories
//
// Note, technically "where" checks the current directory on Windows. From a toolkit perspective,
// it feels like we should not do this. Checking the current directory seems like more of a use
// case of a shell, and the which() function exposed by the toolkit should strive for consistency
// across platforms.
const directories = [ ] ;
if ( process . env . PATH ) {
for ( const p of process . env . PATH . split ( path . delimiter ) ) {
if ( p ) {
directories . push ( p ) ;
}
}
}
// return the first match
for ( const directory of directories ) {
const filePath = yield ioUtil . tryGetExecutablePath ( directory + path . sep + tool , extensions ) ;
if ( filePath ) {
return filePath ;
}
}
return '' ;
}
catch ( err ) {
throw new Error ( ` which failed with message ${ err . message } ` ) ;
}
} ) ;
}
exports . which = which ;
function readCopyOptions ( options ) {
const force = options . force == null ? true : options . force ;
const recursive = Boolean ( options . recursive ) ;
return { force , recursive } ;
}
function cpDirRecursive ( sourceDir , destDir , currentDepth , force ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
// Ensure there is not a run away recursive copy
if ( currentDepth >= 255 )
return ;
currentDepth ++ ;
yield mkdirP ( destDir ) ;
const files = yield ioUtil . readdir ( sourceDir ) ;
for ( const fileName of files ) {
const srcFile = ` ${ sourceDir } / ${ fileName } ` ;
const destFile = ` ${ destDir } / ${ fileName } ` ;
const srcFileStat = yield ioUtil . lstat ( srcFile ) ;
if ( srcFileStat . isDirectory ( ) ) {
// Recurse
yield cpDirRecursive ( srcFile , destFile , currentDepth , force ) ;
}
else {
yield copyFile ( srcFile , destFile , force ) ;
}
}
// Change the mode for the newly created directory
yield ioUtil . chmod ( destDir , ( yield ioUtil . stat ( sourceDir ) ) . mode ) ;
} ) ;
}
// Buffered file copy
function copyFile ( srcFile , destFile , force ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
if ( ( yield ioUtil . lstat ( srcFile ) ) . isSymbolicLink ( ) ) {
// unlink/re-link it
try {
yield ioUtil . lstat ( destFile ) ;
yield ioUtil . unlink ( destFile ) ;
}
catch ( e ) {
// Try to override file permission
if ( e . code === 'EPERM' ) {
yield ioUtil . chmod ( destFile , '0666' ) ;
yield ioUtil . unlink ( destFile ) ;
}
// other errors = it doesn't exist, no work to do
}
// Copy over symlink
const symlinkFull = yield ioUtil . readlink ( srcFile ) ;
yield ioUtil . symlink ( symlinkFull , destFile , ioUtil . IS _WINDOWS ? 'junction' : null ) ;
}
else if ( ! ( yield ioUtil . exists ( destFile ) ) || force ) {
yield ioUtil . copyFile ( srcFile , destFile ) ;
}
} ) ;
}
//# sourceMappingURL=io.js.map
/***/ } ) ,
2021-10-15 08:08:03 -04:00
/***/ 2764 :
2020-09-06 16:03:16 -04:00
/***/ ( ( module ) => {
"use strict" ;
// expose to the world
module . exports = addressparser ;
/ * *
* Parses structured e - mail addresses from an address field
*
* Example :
*
* 'Name <address@domain>'
*
* will be converted to
*
* [ { name : 'Name' , address : 'address@domain' } ]
*
* @ param { String } str Address field
* @ return { Array } An array of address objects
* /
function addressparser ( str ) {
var tokenizer = new Tokenizer ( str ) ;
var tokens = tokenizer . tokenize ( ) ;
var addresses = [ ] ;
var address = [ ] ;
var parsedAddresses = [ ] ;
tokens . forEach ( function ( token ) {
if ( token . type === 'operator' && ( token . value === ',' || token . value === ';' ) ) {
if ( address . length ) {
addresses . push ( address ) ;
}
address = [ ] ;
} else {
address . push ( token ) ;
}
} ) ;
if ( address . length ) {
addresses . push ( address ) ;
}
addresses . forEach ( function ( address ) {
address = _handleAddress ( address ) ;
if ( address . length ) {
parsedAddresses = parsedAddresses . concat ( address ) ;
}
} ) ;
return parsedAddresses ;
}
/ * *
* Converts tokens for a single address into an address object
*
* @ param { Array } tokens Tokens object
* @ return { Object } Address object
* /
function _handleAddress ( tokens ) {
var token ;
var isGroup = false ;
var state = 'text' ;
var address ;
var addresses = [ ] ;
var data = {
address : [ ] ,
comment : [ ] ,
group : [ ] ,
text : [ ]
} ;
var i ;
var len ;
// Filter out <addresses>, (comments) and regular text
for ( i = 0 , len = tokens . length ; i < len ; i ++ ) {
token = tokens [ i ] ;
if ( token . type === 'operator' ) {
switch ( token . value ) {
case '<' :
state = 'address' ;
break ;
case '(' :
state = 'comment' ;
break ;
case ':' :
state = 'group' ;
isGroup = true ;
break ;
default :
state = 'text' ;
}
} else if ( token . value ) {
if ( state === 'address' ) {
// handle use case where unquoted name includes a "<"
// Apple Mail truncates everything between an unexpected < and an address
// and so will we
token . value = token . value . replace ( /^[^<]*<\s*/ , '' ) ;
}
data [ state ] . push ( token . value ) ;
}
}
// If there is no text but a comment, replace the two
if ( ! data . text . length && data . comment . length ) {
data . text = data . comment ;
data . comment = [ ] ;
}
if ( isGroup ) {
// http://tools.ietf.org/html/rfc2822#appendix-A.1.3
data . text = data . text . join ( ' ' ) ;
addresses . push ( {
name : data . text || ( address && address . name ) ,
group : data . group . length ? addressparser ( data . group . join ( ',' ) ) : [ ]
} ) ;
} else {
// If no address was found, try to detect one from regular text
if ( ! data . address . length && data . text . length ) {
for ( i = data . text . length - 1 ; i >= 0 ; i -- ) {
if ( data . text [ i ] . match ( /^[^@\s]+@[^@\s]+$/ ) ) {
data . address = data . text . splice ( i , 1 ) ;
break ;
}
}
var _regexHandler = function ( address ) {
if ( ! data . address . length ) {
data . address = [ address . trim ( ) ] ;
return ' ' ;
} else {
return address ;
}
} ;
// still no address
if ( ! data . address . length ) {
for ( i = data . text . length - 1 ; i >= 0 ; i -- ) {
// fixed the regex to parse email address correctly when email address has more than one @
data . text [ i ] = data . text [ i ] . replace ( /\s*\b[^@\s]+@[^\s]+\b\s*/ , _regexHandler ) . trim ( ) ;
if ( data . address . length ) {
break ;
}
}
}
}
// If there's still is no text but a comment exixts, replace the two
if ( ! data . text . length && data . comment . length ) {
data . text = data . comment ;
data . comment = [ ] ;
}
// Keep only the first address occurence, push others to regular text
if ( data . address . length > 1 ) {
data . text = data . text . concat ( data . address . splice ( 1 ) ) ;
}
// Join values with spaces
data . text = data . text . join ( ' ' ) ;
data . address = data . address . join ( ' ' ) ;
if ( ! data . address && isGroup ) {
return [ ] ;
} else {
address = {
address : data . address || data . text || '' ,
name : data . text || data . address || ''
} ;
if ( address . address === address . name ) {
if ( ( address . address || '' ) . match ( /@/ ) ) {
address . name = '' ;
} else {
address . address = '' ;
}
}
addresses . push ( address ) ;
}
}
return addresses ;
}
/ * *
* Creates a Tokenizer object for tokenizing address field strings
*
* @ constructor
* @ param { String } str Address field string
* /
function Tokenizer ( str ) {
this . str = ( str || '' ) . toString ( ) ;
this . operatorCurrent = '' ;
this . operatorExpecting = '' ;
this . node = null ;
this . escaped = false ;
this . list = [ ] ;
}
/ * *
* Operator tokens and which tokens are expected to end the sequence
* /
Tokenizer . prototype . operators = {
'"' : '"' ,
'(' : ')' ,
'<' : '>' ,
',' : '' ,
':' : ';' ,
// Semicolons are not a legal delimiter per the RFC2822 grammar other
// than for terminating a group, but they are also not valid for any
// other use in this context. Given that some mail clients have
// historically allowed the semicolon as a delimiter equivalent to the
// comma in their UI, it makes sense to treat them the same as a comma
// when used outside of a group.
';' : ''
} ;
/ * *
* Tokenizes the original input string
*
* @ return { Array } An array of operator | text tokens
* /
Tokenizer . prototype . tokenize = function ( ) {
var chr , list = [ ] ;
for ( var i = 0 , len = this . str . length ; i < len ; i ++ ) {
chr = this . str . charAt ( i ) ;
this . checkChar ( chr ) ;
}
this . list . forEach ( function ( node ) {
node . value = ( node . value || '' ) . toString ( ) . trim ( ) ;
if ( node . value ) {
list . push ( node ) ;
}
} ) ;
return list ;
} ;
/ * *
* Checks if a character is an operator or text and acts accordingly
*
* @ param { String } chr Character from the address field
* /
Tokenizer . prototype . checkChar = function ( chr ) {
if ( ( chr in this . operators || chr === '\\' ) && this . escaped ) {
this . escaped = false ;
} else if ( this . operatorExpecting && chr === this . operatorExpecting ) {
this . node = {
type : 'operator' ,
value : chr
} ;
this . list . push ( this . node ) ;
this . node = null ;
this . operatorExpecting = '' ;
this . escaped = false ;
return ;
} else if ( ! this . operatorExpecting && chr in this . operators ) {
this . node = {
type : 'operator' ,
value : chr
} ;
this . list . push ( this . node ) ;
this . node = null ;
this . operatorExpecting = this . operators [ chr ] ;
this . escaped = false ;
return ;
}
if ( ! this . escaped && chr === '\\' ) {
this . escaped = true ;
return ;
}
if ( ! this . node ) {
this . node = {
type : 'text' ,
value : ''
} ;
this . list . push ( this . node ) ;
}
if ( this . escaped && chr !== '\\' ) {
this . node . value += '\\' ;
}
this . node . value += chr ;
this . escaped = false ;
} ;
/***/ } ) ,
2021-10-15 08:08:03 -04:00
/***/ 5435 :
2021-09-04 19:00:24 -04:00
/***/ ( ( _ _unused _webpack _module , exports , _ _webpack _require _ _ ) => {
2020-09-06 16:03:16 -04:00
"use strict" ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
const asn1 = exports ;
2020-05-03 14:46:05 -04:00
2021-10-15 08:08:03 -04:00
asn1 . bignum = _ _webpack _require _ _ ( 6641 ) ;
2020-05-03 14:46:05 -04:00
2021-10-15 08:08:03 -04:00
asn1 . define = _ _webpack _require _ _ ( 5245 ) . define ;
asn1 . base = _ _webpack _require _ _ ( 8096 ) ;
asn1 . constants = _ _webpack _require _ _ ( 3371 ) ;
asn1 . decoders = _ _webpack _require _ _ ( 4952 ) ;
asn1 . encoders = _ _webpack _require _ _ ( 9083 ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
/***/ } ) ,
2020-05-03 14:46:05 -04:00
2021-10-15 08:08:03 -04:00
/***/ 5245 :
2021-09-04 19:00:24 -04:00
/***/ ( ( _ _unused _webpack _module , exports , _ _webpack _require _ _ ) => {
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
"use strict" ;
2020-05-03 14:46:05 -04:00
2021-10-15 08:08:03 -04:00
const encoders = _ _webpack _require _ _ ( 9083 ) ;
const decoders = _ _webpack _require _ _ ( 4952 ) ;
const inherits = _ _webpack _require _ _ ( 4124 ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
const api = exports ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
api . define = function define ( name , body ) {
return new Entity ( name , body ) ;
} ;
function Entity ( name , body ) {
this . name = name ;
this . body = body ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
this . decoders = { } ;
this . encoders = { } ;
}
Entity . prototype . _createNamed = function createNamed ( Base ) {
const name = this . name ;
function Generated ( entity ) {
this . _initNamed ( entity , name ) ;
2020-05-03 14:46:05 -04:00
}
2021-09-04 19:00:24 -04:00
inherits ( Generated , Base ) ;
Generated . prototype . _initNamed = function _initNamed ( entity , name ) {
Base . call ( this , entity , name ) ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
return new Generated ( this ) ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Entity . prototype . _getDecoder = function _getDecoder ( enc ) {
enc = enc || 'der' ;
// Lazily create decoder
if ( ! this . decoders . hasOwnProperty ( enc ) )
this . decoders [ enc ] = this . _createNamed ( decoders [ enc ] ) ;
return this . decoders [ enc ] ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Entity . prototype . decode = function decode ( data , enc , options ) {
return this . _getDecoder ( enc ) . decode ( data , options ) ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Entity . prototype . _getEncoder = function _getEncoder ( enc ) {
enc = enc || 'der' ;
// Lazily create encoder
if ( ! this . encoders . hasOwnProperty ( enc ) )
this . encoders [ enc ] = this . _createNamed ( encoders [ enc ] ) ;
return this . encoders [ enc ] ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Entity . prototype . encode = function encode ( data , enc , /* internal */ reporter ) {
return this . _getEncoder ( enc ) . encode ( data , reporter ) ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
/***/ } ) ,
2020-05-03 14:46:05 -04:00
2021-10-15 08:08:03 -04:00
/***/ 5298 :
2021-09-04 19:00:24 -04:00
/***/ ( ( _ _unused _webpack _module , exports , _ _webpack _require _ _ ) => {
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
"use strict" ;
2020-05-03 14:46:05 -04:00
2021-10-15 08:08:03 -04:00
const inherits = _ _webpack _require _ _ ( 4124 ) ;
const Reporter = _ _webpack _require _ _ ( 3744 ) /* .Reporter */ . b ;
const Buffer = _ _webpack _require _ _ ( 5118 ) . Buffer ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
function DecoderBuffer ( base , options ) {
Reporter . call ( this , options ) ;
if ( ! Buffer . isBuffer ( base ) ) {
this . error ( 'Input not Buffer' ) ;
return ;
}
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
this . base = base ;
this . offset = 0 ;
this . length = base . length ;
}
inherits ( DecoderBuffer , Reporter ) ;
exports . C = DecoderBuffer ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
DecoderBuffer . isDecoderBuffer = function isDecoderBuffer ( data ) {
if ( data instanceof DecoderBuffer ) {
return true ;
}
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
// Or accept compatible API
const isCompatible = typeof data === 'object' &&
Buffer . isBuffer ( data . base ) &&
data . constructor . name === 'DecoderBuffer' &&
typeof data . offset === 'number' &&
typeof data . length === 'number' &&
typeof data . save === 'function' &&
typeof data . restore === 'function' &&
typeof data . isEmpty === 'function' &&
typeof data . readUInt8 === 'function' &&
typeof data . skip === 'function' &&
typeof data . raw === 'function' ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
return isCompatible ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
DecoderBuffer . prototype . save = function save ( ) {
return { offset : this . offset , reporter : Reporter . prototype . save . call ( this ) } ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
DecoderBuffer . prototype . restore = function restore ( save ) {
// Return skipped data
const res = new DecoderBuffer ( this . base ) ;
res . offset = save . offset ;
res . length = this . offset ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
this . offset = save . offset ;
Reporter . prototype . restore . call ( this , save . reporter ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
return res ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
DecoderBuffer . prototype . isEmpty = function isEmpty ( ) {
return this . offset === this . length ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
DecoderBuffer . prototype . readUInt8 = function readUInt8 ( fail ) {
if ( this . offset + 1 <= this . length )
return this . base . readUInt8 ( this . offset ++ , true ) ;
else
return this . error ( fail || 'DecoderBuffer overrun' ) ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
DecoderBuffer . prototype . skip = function skip ( bytes , fail ) {
if ( ! ( this . offset + bytes <= this . length ) )
return this . error ( fail || 'DecoderBuffer overrun' ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
const res = new DecoderBuffer ( this . base ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
// Share reporter state
res . _reporterState = this . _reporterState ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
res . offset = this . offset ;
res . length = this . offset + bytes ;
this . offset += bytes ;
return res ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
DecoderBuffer . prototype . raw = function raw ( save ) {
return this . base . slice ( save ? save . offset : this . offset , this . length ) ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
function EncoderBuffer ( value , reporter ) {
if ( Array . isArray ( value ) ) {
this . length = 0 ;
this . value = value . map ( function ( item ) {
if ( ! EncoderBuffer . isEncoderBuffer ( item ) )
item = new EncoderBuffer ( item , reporter ) ;
this . length += item . length ;
return item ;
} , this ) ;
} else if ( typeof value === 'number' ) {
if ( ! ( 0 <= value && value <= 0xff ) )
return reporter . error ( 'non-byte EncoderBuffer value' ) ;
this . value = value ;
this . length = 1 ;
} else if ( typeof value === 'string' ) {
this . value = value ;
this . length = Buffer . byteLength ( value ) ;
} else if ( Buffer . isBuffer ( value ) ) {
this . value = value ;
this . length = value . length ;
} else {
return reporter . error ( 'Unsupported type: ' + typeof value ) ;
}
}
exports . R = EncoderBuffer ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
EncoderBuffer . isEncoderBuffer = function isEncoderBuffer ( data ) {
if ( data instanceof EncoderBuffer ) {
return true ;
}
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
// Or accept compatible API
const isCompatible = typeof data === 'object' &&
data . constructor . name === 'EncoderBuffer' &&
typeof data . length === 'number' &&
typeof data . join === 'function' ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
return isCompatible ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
EncoderBuffer . prototype . join = function join ( out , offset ) {
if ( ! out )
out = Buffer . alloc ( this . length ) ;
if ( ! offset )
offset = 0 ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
if ( this . length === 0 )
return out ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
if ( Array . isArray ( this . value ) ) {
this . value . forEach ( function ( item ) {
item . join ( out , offset ) ;
offset += item . length ;
} ) ;
} else {
if ( typeof this . value === 'number' )
out [ offset ] = this . value ;
else if ( typeof this . value === 'string' )
out . write ( this . value , offset ) ;
else if ( Buffer . isBuffer ( this . value ) )
this . value . copy ( out , offset ) ;
offset += this . length ;
}
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
return out ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
/***/ } ) ,
2020-05-03 14:46:05 -04:00
2021-10-15 08:08:03 -04:00
/***/ 8096 :
2021-09-04 19:00:24 -04:00
/***/ ( ( _ _unused _webpack _module , exports , _ _webpack _require _ _ ) => {
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
"use strict" ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
const base = exports ;
2020-05-03 14:46:05 -04:00
2021-10-15 08:08:03 -04:00
base . Reporter = _ _webpack _require _ _ ( 3744 ) /* .Reporter */ . b ;
base . DecoderBuffer = _ _webpack _require _ _ ( 5298 ) /* .DecoderBuffer */ . C ;
base . EncoderBuffer = _ _webpack _require _ _ ( 5298 ) /* .EncoderBuffer */ . R ;
base . Node = _ _webpack _require _ _ ( 842 ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
/***/ } ) ,
2020-05-03 14:46:05 -04:00
2021-10-15 08:08:03 -04:00
/***/ 842 :
2021-09-04 19:00:24 -04:00
/***/ ( ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) => {
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
"use strict" ;
2020-05-03 14:46:05 -04:00
2021-10-15 08:08:03 -04:00
const Reporter = _ _webpack _require _ _ ( 3744 ) /* .Reporter */ . b ;
const EncoderBuffer = _ _webpack _require _ _ ( 5298 ) /* .EncoderBuffer */ . R ;
const DecoderBuffer = _ _webpack _require _ _ ( 5298 ) /* .DecoderBuffer */ . C ;
2021-09-04 19:00:24 -04:00
const assert = _ _webpack _require _ _ ( 910 ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
// Supported tags
const tags = [
'seq' , 'seqof' , 'set' , 'setof' , 'objid' , 'bool' ,
'gentime' , 'utctime' , 'null_' , 'enum' , 'int' , 'objDesc' ,
'bitstr' , 'bmpstr' , 'charstr' , 'genstr' , 'graphstr' , 'ia5str' , 'iso646str' ,
'numstr' , 'octstr' , 'printstr' , 't61str' , 'unistr' , 'utf8str' , 'videostr'
] ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
// Public methods list
const methods = [
'key' , 'obj' , 'use' , 'optional' , 'explicit' , 'implicit' , 'def' , 'choice' ,
'any' , 'contains'
] . concat ( tags ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
// Overrided methods list
const overrided = [
'_peekTag' , '_decodeTag' , '_use' ,
'_decodeStr' , '_decodeObjid' , '_decodeTime' ,
'_decodeNull' , '_decodeInt' , '_decodeBool' , '_decodeList' ,
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
'_encodeComposite' , '_encodeStr' , '_encodeObjid' , '_encodeTime' ,
'_encodeNull' , '_encodeInt' , '_encodeBool'
] ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
function Node ( enc , parent , name ) {
const state = { } ;
this . _baseState = state ;
state . name = name ;
state . enc = enc ;
state . parent = parent || null ;
state . children = null ;
// State
state . tag = null ;
state . args = null ;
state . reverseArgs = null ;
state . choice = null ;
state . optional = false ;
state . any = false ;
state . obj = false ;
state . use = null ;
state . useDecoder = null ;
state . key = null ;
state [ 'default' ] = null ;
state . explicit = null ;
state . implicit = null ;
state . contains = null ;
// Should create new instance on each method
if ( ! state . parent ) {
state . children = [ ] ;
this . _wrap ( ) ;
}
}
module . exports = Node ;
const stateProps = [
'enc' , 'parent' , 'children' , 'tag' , 'args' , 'reverseArgs' , 'choice' ,
'optional' , 'any' , 'obj' , 'use' , 'alteredUse' , 'key' , 'default' , 'explicit' ,
'implicit' , 'contains'
] ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Node . prototype . clone = function clone ( ) {
const state = this . _baseState ;
const cstate = { } ;
stateProps . forEach ( function ( prop ) {
cstate [ prop ] = state [ prop ] ;
} ) ;
const res = new this . constructor ( cstate . parent ) ;
res . _baseState = cstate ;
return res ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Node . prototype . _wrap = function wrap ( ) {
const state = this . _baseState ;
methods . forEach ( function ( method ) {
this [ method ] = function _wrappedMethod ( ) {
const clone = new this . constructor ( this ) ;
state . children . push ( clone ) ;
return clone [ method ] . apply ( clone , arguments ) ;
} ;
} , this ) ;
} ;
Node . prototype . _init = function init ( body ) {
const state = this . _baseState ;
assert ( state . parent === null ) ;
body . call ( this ) ;
// Filter children
state . children = state . children . filter ( function ( child ) {
return child . _baseState . parent === this ;
} , this ) ;
assert . equal ( state . children . length , 1 , 'Root node can have only one child' ) ;
} ;
Node . prototype . _useArgs = function useArgs ( args ) {
const state = this . _baseState ;
// Filter children and args
const children = args . filter ( function ( arg ) {
return arg instanceof this . constructor ;
} , this ) ;
args = args . filter ( function ( arg ) {
return ! ( arg instanceof this . constructor ) ;
} , this ) ;
if ( children . length !== 0 ) {
assert ( state . children === null ) ;
state . children = children ;
// Replace parent to maintain backward link
children . forEach ( function ( child ) {
child . _baseState . parent = this ;
} , this ) ;
}
if ( args . length !== 0 ) {
assert ( state . args === null ) ;
state . args = args ;
state . reverseArgs = args . map ( function ( arg ) {
if ( typeof arg !== 'object' || arg . constructor !== Object )
return arg ;
const res = { } ;
Object . keys ( arg ) . forEach ( function ( key ) {
if ( key == ( key | 0 ) )
key |= 0 ;
const value = arg [ key ] ;
res [ value ] = key ;
} ) ;
return res ;
} ) ;
}
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
//
// Overrided methods
//
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
overrided . forEach ( function ( method ) {
Node . prototype [ method ] = function _overrided ( ) {
const state = this . _baseState ;
throw new Error ( method + ' not implemented for encoding: ' + state . enc ) ;
} ;
} ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
//
// Public methods
//
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
tags . forEach ( function ( tag ) {
Node . prototype [ tag ] = function _tagMethod ( ) {
const state = this . _baseState ;
const args = Array . prototype . slice . call ( arguments ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
assert ( state . tag === null ) ;
state . tag = tag ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
this . _useArgs ( args ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
return this ;
} ;
} ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Node . prototype . use = function use ( item ) {
assert ( item ) ;
const state = this . _baseState ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
assert ( state . use === null ) ;
state . use = item ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
return this ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Node . prototype . optional = function optional ( ) {
const state = this . _baseState ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
state . optional = true ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
return this ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Node . prototype . def = function def ( val ) {
const state = this . _baseState ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
assert ( state [ 'default' ] === null ) ;
state [ 'default' ] = val ;
state . optional = true ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
return this ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Node . prototype . explicit = function explicit ( num ) {
const state = this . _baseState ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
assert ( state . explicit === null && state . implicit === null ) ;
state . explicit = num ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
return this ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Node . prototype . implicit = function implicit ( num ) {
const state = this . _baseState ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
assert ( state . explicit === null && state . implicit === null ) ;
state . implicit = num ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
return this ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Node . prototype . obj = function obj ( ) {
const state = this . _baseState ;
const args = Array . prototype . slice . call ( arguments ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
state . obj = true ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
if ( args . length !== 0 )
this . _useArgs ( args ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
return this ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Node . prototype . key = function key ( newKey ) {
const state = this . _baseState ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
assert ( state . key === null ) ;
state . key = newKey ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
return this ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Node . prototype . any = function any ( ) {
const state = this . _baseState ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
state . any = true ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
return this ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Node . prototype . choice = function choice ( obj ) {
const state = this . _baseState ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
assert ( state . choice === null ) ;
state . choice = obj ;
this . _useArgs ( Object . keys ( obj ) . map ( function ( key ) {
return obj [ key ] ;
} ) ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
return this ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Node . prototype . contains = function contains ( item ) {
const state = this . _baseState ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
assert ( state . use === null ) ;
state . contains = item ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
return this ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
//
// Decoding
//
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Node . prototype . _decode = function decode ( input , options ) {
const state = this . _baseState ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
// Decode root node
if ( state . parent === null )
return input . wrapResult ( state . children [ 0 ] . _decode ( input , options ) ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
let result = state [ 'default' ] ;
let present = true ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
let prevKey = null ;
if ( state . key !== null )
prevKey = input . enterKey ( state . key ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
// Check if tag is there
if ( state . optional ) {
let tag = null ;
if ( state . explicit !== null )
tag = state . explicit ;
else if ( state . implicit !== null )
tag = state . implicit ;
else if ( state . tag !== null )
tag = state . tag ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
if ( tag === null && ! state . any ) {
// Trial and Error
const save = input . save ( ) ;
try {
if ( state . choice === null )
this . _decodeGeneric ( state . tag , input , options ) ;
else
this . _decodeChoice ( input , options ) ;
present = true ;
} catch ( e ) {
present = false ;
}
input . restore ( save ) ;
} else {
present = this . _peekTag ( input , tag , state . any ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
if ( input . isError ( present ) )
return present ;
}
}
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
// Push object on stack
let prevObj ;
if ( state . obj && present )
prevObj = input . enterObject ( ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
if ( present ) {
// Unwrap explicit values
if ( state . explicit !== null ) {
const explicit = this . _decodeTag ( input , state . explicit ) ;
if ( input . isError ( explicit ) )
return explicit ;
input = explicit ;
}
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
const start = input . offset ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
// Unwrap implicit and normal values
if ( state . use === null && state . choice === null ) {
let save ;
if ( state . any )
save = input . save ( ) ;
const body = this . _decodeTag (
input ,
state . implicit !== null ? state . implicit : state . tag ,
state . any
) ;
if ( input . isError ( body ) )
return body ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
if ( state . any )
result = input . raw ( save ) ;
else
input = body ;
2020-05-03 14:46:05 -04:00
}
2021-09-04 19:00:24 -04:00
if ( options && options . track && state . tag !== null )
options . track ( input . path ( ) , start , input . length , 'tagged' ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
if ( options && options . track && state . tag !== null )
options . track ( input . path ( ) , input . offset , input . length , 'content' ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
// Select proper method for tag
if ( state . any ) {
// no-op
} else if ( state . choice === null ) {
result = this . _decodeGeneric ( state . tag , input , options ) ;
} else {
result = this . _decodeChoice ( input , options ) ;
}
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
if ( input . isError ( result ) )
return result ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
// Decode children
if ( ! state . any && state . choice === null && state . children !== null ) {
state . children . forEach ( function decodeChildren ( child ) {
// NOTE: We are ignoring errors here, to let parser continue with other
// parts of encoded data
child . _decode ( input , options ) ;
} ) ;
2020-05-03 14:46:05 -04:00
}
2021-09-04 19:00:24 -04:00
// Decode contained/encoded by schema, only in bit or octet strings
if ( state . contains && ( state . tag === 'octstr' || state . tag === 'bitstr' ) ) {
const data = new DecoderBuffer ( result ) ;
result = this . _getUse ( state . contains , input . _reporterState . obj )
. _decode ( data , options ) ;
2020-05-03 14:46:05 -04:00
}
2021-09-04 19:00:24 -04:00
}
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
// Pop object
if ( state . obj && present )
result = input . leaveObject ( prevObj ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
// Set key
if ( state . key !== null && ( result !== null || present === true ) )
input . leaveKey ( prevKey , state . key , result ) ;
else if ( prevKey !== null )
input . exitKey ( prevKey ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
return result ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Node . prototype . _decodeGeneric = function decodeGeneric ( tag , input , options ) {
const state = this . _baseState ;
if ( tag === 'seq' || tag === 'set' )
return null ;
if ( tag === 'seqof' || tag === 'setof' )
return this . _decodeList ( input , tag , state . args [ 0 ] , options ) ;
else if ( /str$/ . test ( tag ) )
return this . _decodeStr ( input , tag , options ) ;
else if ( tag === 'objid' && state . args )
return this . _decodeObjid ( input , state . args [ 0 ] , state . args [ 1 ] , options ) ;
else if ( tag === 'objid' )
return this . _decodeObjid ( input , null , null , options ) ;
else if ( tag === 'gentime' || tag === 'utctime' )
return this . _decodeTime ( input , tag , options ) ;
else if ( tag === 'null_' )
return this . _decodeNull ( input , options ) ;
else if ( tag === 'bool' )
return this . _decodeBool ( input , options ) ;
else if ( tag === 'objDesc' )
return this . _decodeStr ( input , tag , options ) ;
else if ( tag === 'int' || tag === 'enum' )
return this . _decodeInt ( input , state . args && state . args [ 0 ] , options ) ;
if ( state . use !== null ) {
return this . _getUse ( state . use , input . _reporterState . obj )
. _decode ( input , options ) ;
} else {
return input . error ( 'unknown tag: ' + tag ) ;
}
} ;
Node . prototype . _getUse = function _getUse ( entity , obj ) {
const state = this . _baseState ;
// Create altered use decoder if implicit is set
state . useDecoder = this . _use ( entity , obj ) ;
assert ( state . useDecoder . _baseState . parent === null ) ;
state . useDecoder = state . useDecoder . _baseState . children [ 0 ] ;
if ( state . implicit !== state . useDecoder . _baseState . implicit ) {
state . useDecoder = state . useDecoder . clone ( ) ;
state . useDecoder . _baseState . implicit = state . implicit ;
}
return state . useDecoder ;
} ;
Node . prototype . _decodeChoice = function decodeChoice ( input , options ) {
const state = this . _baseState ;
let result = null ;
let match = false ;
Object . keys ( state . choice ) . some ( function ( key ) {
const save = input . save ( ) ;
const node = state . choice [ key ] ;
try {
const value = node . _decode ( input , options ) ;
if ( input . isError ( value ) )
return false ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
result = { type : key , value : value } ;
match = true ;
} catch ( e ) {
input . restore ( save ) ;
return false ;
2020-05-03 14:46:05 -04:00
}
2021-09-04 19:00:24 -04:00
return true ;
} , this ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
if ( ! match )
return input . error ( 'Choice not matched' ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
return result ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
//
// Encoding
//
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Node . prototype . _createEncoderBuffer = function createEncoderBuffer ( data ) {
return new EncoderBuffer ( data , this . reporter ) ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Node . prototype . _encode = function encode ( data , reporter , parent ) {
const state = this . _baseState ;
if ( state [ 'default' ] !== null && state [ 'default' ] === data )
return ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
const result = this . _encodeValue ( data , reporter , parent ) ;
if ( result === undefined )
return ;
if ( this . _skipDefault ( result , reporter , parent ) )
return ;
return result ;
} ;
Node . prototype . _encodeValue = function encode ( data , reporter , parent ) {
const state = this . _baseState ;
// Decode root node
if ( state . parent === null )
return state . children [ 0 ] . _encode ( data , reporter || new Reporter ( ) ) ;
let result = null ;
// Set reporter to share it with a child class
this . reporter = reporter ;
// Check if data is there
if ( state . optional && data === undefined ) {
if ( state [ 'default' ] !== null )
data = state [ 'default' ] ;
else
return ;
}
// Encode children first
let content = null ;
let primitive = false ;
if ( state . any ) {
// Anything that was given is translated to buffer
result = this . _createEncoderBuffer ( data ) ;
} else if ( state . choice ) {
result = this . _encodeChoice ( data , reporter ) ;
} else if ( state . contains ) {
content = this . _getUse ( state . contains , parent ) . _encode ( data , reporter ) ;
primitive = true ;
} else if ( state . children ) {
content = state . children . map ( function ( child ) {
if ( child . _baseState . tag === 'null_' )
return child . _encode ( null , reporter , data ) ;
if ( child . _baseState . key === null )
return reporter . error ( 'Child should have a key' ) ;
const prevKey = reporter . enterKey ( child . _baseState . key ) ;
if ( typeof data !== 'object' )
return reporter . error ( 'Child expected, but input is not object' ) ;
const res = child . _encode ( data [ child . _baseState . key ] , reporter , data ) ;
reporter . leaveKey ( prevKey ) ;
return res ;
} , this ) . filter ( function ( child ) {
return child ;
} ) ;
content = this . _createEncoderBuffer ( content ) ;
} else {
if ( state . tag === 'seqof' || state . tag === 'setof' ) {
// TODO(indutny): this should be thrown on DSL level
if ( ! ( state . args && state . args . length === 1 ) )
return reporter . error ( 'Too many args for : ' + state . tag ) ;
if ( ! Array . isArray ( data ) )
return reporter . error ( 'seqof/setof, but data is not Array' ) ;
const child = this . clone ( ) ;
child . _baseState . implicit = null ;
content = this . _createEncoderBuffer ( data . map ( function ( item ) {
const state = this . _baseState ;
return this . _getUse ( state . args [ 0 ] , data ) . _encode ( item , reporter ) ;
} , child ) ) ;
} else if ( state . use !== null ) {
result = this . _getUse ( state . use , parent ) . _encode ( data , reporter ) ;
} else {
content = this . _encodePrimitive ( state . tag , data ) ;
primitive = true ;
}
}
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
// Encode data itself
if ( ! state . any && state . choice === null ) {
const tag = state . implicit !== null ? state . implicit : state . tag ;
const cls = state . implicit === null ? 'universal' : 'context' ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
if ( tag === null ) {
if ( state . use === null )
reporter . error ( 'Tag could be omitted only for .use()' ) ;
} else {
if ( state . use === null )
result = this . _encodeComposite ( tag , primitive , cls , content ) ;
2020-05-03 14:46:05 -04:00
}
2021-09-04 19:00:24 -04:00
}
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
// Wrap in explicit
if ( state . explicit !== null )
result = this . _encodeComposite ( state . explicit , false , 'context' , result ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
return result ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Node . prototype . _encodeChoice = function encodeChoice ( data , reporter ) {
const state = this . _baseState ;
const node = state . choice [ data . type ] ;
if ( ! node ) {
assert (
false ,
data . type + ' not found in ' +
JSON . stringify ( Object . keys ( state . choice ) ) ) ;
}
return node . _encode ( data . value , reporter ) ;
} ;
Node . prototype . _encodePrimitive = function encodePrimitive ( tag , data ) {
const state = this . _baseState ;
if ( /str$/ . test ( tag ) )
return this . _encodeStr ( data , tag ) ;
else if ( tag === 'objid' && state . args )
return this . _encodeObjid ( data , state . reverseArgs [ 0 ] , state . args [ 1 ] ) ;
else if ( tag === 'objid' )
return this . _encodeObjid ( data , null , null ) ;
else if ( tag === 'gentime' || tag === 'utctime' )
return this . _encodeTime ( data , tag ) ;
else if ( tag === 'null_' )
return this . _encodeNull ( ) ;
else if ( tag === 'int' || tag === 'enum' )
return this . _encodeInt ( data , state . args && state . reverseArgs [ 0 ] ) ;
else if ( tag === 'bool' )
return this . _encodeBool ( data ) ;
else if ( tag === 'objDesc' )
return this . _encodeStr ( data , tag ) ;
else
throw new Error ( 'Unsupported tag: ' + tag ) ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Node . prototype . _isNumstr = function isNumstr ( str ) {
return /^[0-9 ]*$/ . test ( str ) ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Node . prototype . _isPrintstr = function isPrintstr ( str ) {
return /^[A-Za-z0-9 '()+,-./:=?]*$/ . test ( str ) ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
/***/ } ) ,
2020-05-03 14:46:05 -04:00
2021-10-15 08:08:03 -04:00
/***/ 3744 :
2021-09-04 19:00:24 -04:00
/***/ ( ( _ _unused _webpack _module , exports , _ _webpack _require _ _ ) => {
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
"use strict" ;
2020-05-03 14:46:05 -04:00
2021-10-15 08:08:03 -04:00
const inherits = _ _webpack _require _ _ ( 4124 ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
function Reporter ( options ) {
this . _reporterState = {
obj : null ,
path : [ ] ,
options : options || { } ,
errors : [ ]
} ;
}
exports . b = Reporter ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Reporter . prototype . isError = function isError ( obj ) {
return obj instanceof ReporterError ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Reporter . prototype . save = function save ( ) {
const state = this . _reporterState ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
return { obj : state . obj , pathLen : state . path . length } ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Reporter . prototype . restore = function restore ( data ) {
const state = this . _reporterState ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
state . obj = data . obj ;
state . path = state . path . slice ( 0 , data . pathLen ) ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Reporter . prototype . enterKey = function enterKey ( key ) {
return this . _reporterState . path . push ( key ) ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Reporter . prototype . exitKey = function exitKey ( index ) {
const state = this . _reporterState ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
state . path = state . path . slice ( 0 , index - 1 ) ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Reporter . prototype . leaveKey = function leaveKey ( index , key , value ) {
const state = this . _reporterState ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
this . exitKey ( index ) ;
if ( state . obj !== null )
state . obj [ key ] = value ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Reporter . prototype . path = function path ( ) {
return this . _reporterState . path . join ( '/' ) ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Reporter . prototype . enterObject = function enterObject ( ) {
const state = this . _reporterState ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
const prev = state . obj ;
state . obj = { } ;
return prev ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Reporter . prototype . leaveObject = function leaveObject ( prev ) {
const state = this . _reporterState ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
const now = state . obj ;
state . obj = prev ;
return now ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Reporter . prototype . error = function error ( msg ) {
let err ;
const state = this . _reporterState ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
const inherited = msg instanceof ReporterError ;
if ( inherited ) {
err = msg ;
} else {
err = new ReporterError ( state . path . map ( function ( elem ) {
return '[' + JSON . stringify ( elem ) + ']' ;
} ) . join ( '' ) , msg . message || msg , msg . stack ) ;
}
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
if ( ! state . options . partial )
throw err ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
if ( ! inherited )
state . errors . push ( err ) ;
return err ;
2020-05-03 14:46:05 -04:00
} ;
2021-09-04 19:00:24 -04:00
Reporter . prototype . wrapResult = function wrapResult ( result ) {
const state = this . _reporterState ;
if ( ! state . options . partial )
return result ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
return {
result : this . isError ( result ) ? null : result ,
errors : state . errors
} ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
function ReporterError ( path , msg ) {
this . path = path ;
this . rethrow ( msg ) ;
}
inherits ( ReporterError , Error ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
ReporterError . prototype . rethrow = function rethrow ( msg ) {
this . message = msg + ' at: ' + ( this . path || '(shallow)' ) ;
if ( Error . captureStackTrace )
Error . captureStackTrace ( this , ReporterError ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
if ( ! this . stack ) {
try {
// IE only adds stack when thrown
throw new Error ( this . message ) ;
} catch ( e ) {
this . stack = e . stack ;
2020-05-03 14:46:05 -04:00
}
2021-09-04 19:00:24 -04:00
}
return this ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
/***/ } ) ,
2020-05-03 14:46:05 -04:00
2021-10-15 08:08:03 -04:00
/***/ 1188 :
2021-09-04 19:00:24 -04:00
/***/ ( ( _ _unused _webpack _module , exports ) => {
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
"use strict" ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
// Helper
function reverse ( map ) {
const res = { } ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Object . keys ( map ) . forEach ( function ( key ) {
// Convert key to integer if it is stringified
if ( ( key | 0 ) == key )
key = key | 0 ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
const value = map [ key ] ;
res [ value ] = key ;
} ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
return res ;
}
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
exports . tagClass = {
0 : 'universal' ,
1 : 'application' ,
2 : 'context' ,
3 : 'private'
} ;
exports . tagClassByName = reverse ( exports . tagClass ) ;
exports . tag = {
0x00 : 'end' ,
0x01 : 'bool' ,
0x02 : 'int' ,
0x03 : 'bitstr' ,
0x04 : 'octstr' ,
0x05 : 'null_' ,
0x06 : 'objid' ,
0x07 : 'objDesc' ,
0x08 : 'external' ,
0x09 : 'real' ,
0x0a : 'enum' ,
0x0b : 'embed' ,
0x0c : 'utf8str' ,
0x0d : 'relativeOid' ,
0x10 : 'seq' ,
0x11 : 'set' ,
0x12 : 'numstr' ,
0x13 : 'printstr' ,
0x14 : 't61str' ,
0x15 : 'videostr' ,
0x16 : 'ia5str' ,
0x17 : 'utctime' ,
0x18 : 'gentime' ,
0x19 : 'graphstr' ,
0x1a : 'iso646str' ,
0x1b : 'genstr' ,
0x1c : 'unistr' ,
0x1d : 'charstr' ,
0x1e : 'bmpstr'
} ;
exports . tagByName = reverse ( exports . tag ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
/***/ } ) ,
2020-05-03 14:46:05 -04:00
2021-10-15 08:08:03 -04:00
/***/ 3371 :
2021-09-04 19:00:24 -04:00
/***/ ( ( _ _unused _webpack _module , exports , _ _webpack _require _ _ ) => {
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
"use strict" ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
const constants = exports ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
// Helper
constants . _reverse = function reverse ( map ) {
const res = { } ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Object . keys ( map ) . forEach ( function ( key ) {
// Convert key to integer if it is stringified
if ( ( key | 0 ) == key )
key = key | 0 ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
const value = map [ key ] ;
res [ value ] = key ;
} ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
return res ;
} ;
2020-05-03 14:46:05 -04:00
2021-10-15 08:08:03 -04:00
constants . der = _ _webpack _require _ _ ( 1188 ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
/***/ } ) ,
2020-05-03 14:46:05 -04:00
2021-10-15 08:08:03 -04:00
/***/ 3332 :
2021-09-04 19:00:24 -04:00
/***/ ( ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) => {
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
"use strict" ;
2020-05-03 14:46:05 -04:00
2021-10-15 08:08:03 -04:00
const inherits = _ _webpack _require _ _ ( 4124 ) ;
2020-05-03 14:46:05 -04:00
2021-10-15 08:08:03 -04:00
const bignum = _ _webpack _require _ _ ( 6641 ) ;
const DecoderBuffer = _ _webpack _require _ _ ( 5298 ) /* .DecoderBuffer */ . C ;
const Node = _ _webpack _require _ _ ( 842 ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
// Import DER constants
2021-10-15 08:08:03 -04:00
const der = _ _webpack _require _ _ ( 1188 ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
function DERDecoder ( entity ) {
this . enc = 'der' ;
this . name = entity . name ;
this . entity = entity ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
// Construct base tree
this . tree = new DERNode ( ) ;
this . tree . _init ( entity . body ) ;
}
module . exports = DERDecoder ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
DERDecoder . prototype . decode = function decode ( data , options ) {
if ( ! DecoderBuffer . isDecoderBuffer ( data ) ) {
data = new DecoderBuffer ( data , options ) ;
}
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
return this . tree . _decode ( data , options ) ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
// Tree methods
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
function DERNode ( parent ) {
Node . call ( this , 'der' , parent ) ;
}
inherits ( DERNode , Node ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
DERNode . prototype . _peekTag = function peekTag ( buffer , tag , any ) {
if ( buffer . isEmpty ( ) )
return false ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
const state = buffer . save ( ) ;
const decodedTag = derDecodeTag ( buffer , 'Failed to peek tag: "' + tag + '"' ) ;
if ( buffer . isError ( decodedTag ) )
return decodedTag ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
buffer . restore ( state ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
return decodedTag . tag === tag || decodedTag . tagStr === tag ||
( decodedTag . tagStr + 'of' ) === tag || any ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
DERNode . prototype . _decodeTag = function decodeTag ( buffer , tag , any ) {
const decodedTag = derDecodeTag ( buffer ,
'Failed to decode tag of "' + tag + '"' ) ;
if ( buffer . isError ( decodedTag ) )
return decodedTag ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
let len = derDecodeLen ( buffer ,
decodedTag . primitive ,
'Failed to get length of "' + tag + '"' ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
// Failure
if ( buffer . isError ( len ) )
return len ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
if ( ! any &&
decodedTag . tag !== tag &&
decodedTag . tagStr !== tag &&
decodedTag . tagStr + 'of' !== tag ) {
return buffer . error ( 'Failed to match tag: "' + tag + '"' ) ;
}
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
if ( decodedTag . primitive || len !== null )
return buffer . skip ( len , 'Failed to match body of: "' + tag + '"' ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
// Indefinite length... find END tag
const state = buffer . save ( ) ;
const res = this . _skipUntilEnd (
buffer ,
'Failed to skip indefinite length body: "' + this . tag + '"' ) ;
if ( buffer . isError ( res ) )
return res ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
len = buffer . offset - state . offset ;
buffer . restore ( state ) ;
return buffer . skip ( len , 'Failed to match body of: "' + tag + '"' ) ;
2020-05-03 14:46:05 -04:00
} ;
2021-09-04 19:00:24 -04:00
DERNode . prototype . _skipUntilEnd = function skipUntilEnd ( buffer , fail ) {
for ( ; ; ) {
const tag = derDecodeTag ( buffer , fail ) ;
if ( buffer . isError ( tag ) )
return tag ;
const len = derDecodeLen ( buffer , tag . primitive , fail ) ;
if ( buffer . isError ( len ) )
return len ;
let res ;
if ( tag . primitive || len !== null )
res = buffer . skip ( len ) ;
else
res = this . _skipUntilEnd ( buffer , fail ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
// Failure
if ( buffer . isError ( res ) )
return res ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
if ( tag . tagStr === 'end' )
break ;
}
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
DERNode . prototype . _decodeList = function decodeList ( buffer , tag , decoder ,
options ) {
const result = [ ] ;
while ( ! buffer . isEmpty ( ) ) {
const possibleEnd = this . _peekTag ( buffer , 'end' ) ;
if ( buffer . isError ( possibleEnd ) )
return possibleEnd ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
const res = decoder . decode ( buffer , 'der' , options ) ;
if ( buffer . isError ( res ) && possibleEnd )
break ;
result . push ( res ) ;
}
return result ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
DERNode . prototype . _decodeStr = function decodeStr ( buffer , tag ) {
if ( tag === 'bitstr' ) {
const unused = buffer . readUInt8 ( ) ;
if ( buffer . isError ( unused ) )
return unused ;
return { unused : unused , data : buffer . raw ( ) } ;
} else if ( tag === 'bmpstr' ) {
const raw = buffer . raw ( ) ;
if ( raw . length % 2 === 1 )
return buffer . error ( 'Decoding of string type: bmpstr length mismatch' ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
let str = '' ;
for ( let i = 0 ; i < raw . length / 2 ; i ++ ) {
str += String . fromCharCode ( raw . readUInt16BE ( i * 2 ) ) ;
2020-05-03 14:46:05 -04:00
}
2021-09-04 19:00:24 -04:00
return str ;
} else if ( tag === 'numstr' ) {
const numstr = buffer . raw ( ) . toString ( 'ascii' ) ;
if ( ! this . _isNumstr ( numstr ) ) {
return buffer . error ( 'Decoding of string type: ' +
'numstr unsupported characters' ) ;
}
return numstr ;
} else if ( tag === 'octstr' ) {
return buffer . raw ( ) ;
} else if ( tag === 'objDesc' ) {
return buffer . raw ( ) ;
} else if ( tag === 'printstr' ) {
const printstr = buffer . raw ( ) . toString ( 'ascii' ) ;
if ( ! this . _isPrintstr ( printstr ) ) {
return buffer . error ( 'Decoding of string type: ' +
'printstr unsupported characters' ) ;
}
return printstr ;
} else if ( /str$/ . test ( tag ) ) {
return buffer . raw ( ) . toString ( ) ;
} else {
return buffer . error ( 'Decoding of string type: ' + tag + ' unsupported' ) ;
}
} ;
DERNode . prototype . _decodeObjid = function decodeObjid ( buffer , values , relative ) {
let result ;
const identifiers = [ ] ;
let ident = 0 ;
let subident = 0 ;
while ( ! buffer . isEmpty ( ) ) {
subident = buffer . readUInt8 ( ) ;
ident <<= 7 ;
ident |= subident & 0x7f ;
if ( ( subident & 0x80 ) === 0 ) {
identifiers . push ( ident ) ;
ident = 0 ;
2020-05-03 14:46:05 -04:00
}
2021-09-04 19:00:24 -04:00
}
if ( subident & 0x80 )
identifiers . push ( ident ) ;
const first = ( identifiers [ 0 ] / 40 ) | 0 ;
const second = identifiers [ 0 ] % 40 ;
if ( relative )
result = identifiers ;
else
result = [ first , second ] . concat ( identifiers . slice ( 1 ) ) ;
if ( values ) {
let tmp = values [ result . join ( ' ' ) ] ;
if ( tmp === undefined )
tmp = values [ result . join ( '.' ) ] ;
if ( tmp !== undefined )
result = tmp ;
}
return result ;
} ;
DERNode . prototype . _decodeTime = function decodeTime ( buffer , tag ) {
const str = buffer . raw ( ) . toString ( ) ;
let year ;
let mon ;
let day ;
let hour ;
let min ;
let sec ;
if ( tag === 'gentime' ) {
year = str . slice ( 0 , 4 ) | 0 ;
mon = str . slice ( 4 , 6 ) | 0 ;
day = str . slice ( 6 , 8 ) | 0 ;
hour = str . slice ( 8 , 10 ) | 0 ;
min = str . slice ( 10 , 12 ) | 0 ;
sec = str . slice ( 12 , 14 ) | 0 ;
} else if ( tag === 'utctime' ) {
year = str . slice ( 0 , 2 ) | 0 ;
mon = str . slice ( 2 , 4 ) | 0 ;
day = str . slice ( 4 , 6 ) | 0 ;
hour = str . slice ( 6 , 8 ) | 0 ;
min = str . slice ( 8 , 10 ) | 0 ;
sec = str . slice ( 10 , 12 ) | 0 ;
if ( year < 70 )
year = 2000 + year ;
else
year = 1900 + year ;
} else {
return buffer . error ( 'Decoding ' + tag + ' time is not supported yet' ) ;
}
return Date . UTC ( year , mon - 1 , day , hour , min , sec , 0 ) ;
} ;
DERNode . prototype . _decodeNull = function decodeNull ( ) {
return null ;
} ;
DERNode . prototype . _decodeBool = function decodeBool ( buffer ) {
const res = buffer . readUInt8 ( ) ;
if ( buffer . isError ( res ) )
return res ;
else
return res !== 0 ;
} ;
DERNode . prototype . _decodeInt = function decodeInt ( buffer , values ) {
// Bigint, return as it is (assume big endian)
const raw = buffer . raw ( ) ;
let res = new bignum ( raw ) ;
if ( values )
res = values [ res . toString ( 10 ) ] || res ;
return res ;
} ;
DERNode . prototype . _use = function use ( entity , obj ) {
if ( typeof entity === 'function' )
entity = entity ( obj ) ;
return entity . _getDecoder ( 'der' ) . tree ;
} ;
// Utility methods
function derDecodeTag ( buf , fail ) {
let tag = buf . readUInt8 ( fail ) ;
if ( buf . isError ( tag ) )
return tag ;
const cls = der . tagClass [ tag >> 6 ] ;
const primitive = ( tag & 0x20 ) === 0 ;
// Multi-octet tag - load
if ( ( tag & 0x1f ) === 0x1f ) {
let oct = tag ;
tag = 0 ;
while ( ( oct & 0x80 ) === 0x80 ) {
oct = buf . readUInt8 ( fail ) ;
if ( buf . isError ( oct ) )
return oct ;
tag <<= 7 ;
tag |= oct & 0x7f ;
2020-05-03 14:46:05 -04:00
}
2021-09-04 19:00:24 -04:00
} else {
tag &= 0x1f ;
}
const tagStr = der . tag [ tag ] ;
return {
cls : cls ,
primitive : primitive ,
tag : tag ,
tagStr : tagStr
} ;
2020-05-03 14:46:05 -04:00
}
2021-09-04 19:00:24 -04:00
function derDecodeLen ( buf , primitive , fail ) {
let len = buf . readUInt8 ( fail ) ;
if ( buf . isError ( len ) )
return len ;
// Indefinite form
if ( ! primitive && len === 0x80 )
return null ;
// Definite form
if ( ( len & 0x80 ) === 0 ) {
// Short form
return len ;
}
// Long form
const num = len & 0x7f ;
if ( num > 4 )
return buf . error ( 'length octect is too long' ) ;
len = 0 ;
for ( let i = 0 ; i < num ; i ++ ) {
len <<= 8 ;
const j = buf . readUInt8 ( fail ) ;
if ( buf . isError ( j ) )
return j ;
len |= j ;
}
return len ;
2020-05-03 14:46:05 -04:00
}
2021-09-04 19:00:24 -04:00
/***/ } ) ,
2021-10-15 08:08:03 -04:00
/***/ 4952 :
2021-09-04 19:00:24 -04:00
/***/ ( ( _ _unused _webpack _module , exports , _ _webpack _require _ _ ) => {
"use strict" ;
const decoders = exports ;
2021-10-15 08:08:03 -04:00
decoders . der = _ _webpack _require _ _ ( 3332 ) ;
decoders . pem = _ _webpack _require _ _ ( 8361 ) ;
2021-09-04 19:00:24 -04:00
/***/ } ) ,
2021-10-15 08:08:03 -04:00
/***/ 8361 :
2021-09-04 19:00:24 -04:00
/***/ ( ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) => {
"use strict" ;
2021-10-15 08:08:03 -04:00
const inherits = _ _webpack _require _ _ ( 4124 ) ;
const Buffer = _ _webpack _require _ _ ( 5118 ) . Buffer ;
2021-09-04 19:00:24 -04:00
2021-10-15 08:08:03 -04:00
const DERDecoder = _ _webpack _require _ _ ( 3332 ) ;
2021-09-04 19:00:24 -04:00
function PEMDecoder ( entity ) {
DERDecoder . call ( this , entity ) ;
this . enc = 'pem' ;
2020-05-03 14:46:05 -04:00
}
2021-09-04 19:00:24 -04:00
inherits ( PEMDecoder , DERDecoder ) ;
module . exports = PEMDecoder ;
PEMDecoder . prototype . decode = function decode ( data , options ) {
const lines = data . toString ( ) . split ( /[\r\n]+/g ) ;
const label = options . label . toUpperCase ( ) ;
const re = /^-----(BEGIN|END) ([^-]+)-----$/ ;
let start = - 1 ;
let end = - 1 ;
for ( let i = 0 ; i < lines . length ; i ++ ) {
const match = lines [ i ] . match ( re ) ;
if ( match === null )
continue ;
if ( match [ 2 ] !== label )
continue ;
if ( start === - 1 ) {
if ( match [ 1 ] !== 'BEGIN' )
break ;
start = i ;
} else {
if ( match [ 1 ] !== 'END' )
break ;
end = i ;
break ;
2020-05-03 14:46:05 -04:00
}
2021-09-04 19:00:24 -04:00
}
if ( start === - 1 || end === - 1 )
throw new Error ( 'PEM section not found for: ' + label ) ;
const base64 = lines . slice ( start + 1 , end ) . join ( '' ) ;
// Remove excessive symbols
base64 . replace ( /[^a-z0-9+/=]+/gi , '' ) ;
const input = Buffer . from ( base64 , 'base64' ) ;
return DERDecoder . prototype . decode . call ( this , input , options ) ;
} ;
/***/ } ) ,
2021-10-15 08:08:03 -04:00
/***/ 5769 :
2021-09-04 19:00:24 -04:00
/***/ ( ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) => {
"use strict" ;
2021-10-15 08:08:03 -04:00
const inherits = _ _webpack _require _ _ ( 4124 ) ;
const Buffer = _ _webpack _require _ _ ( 5118 ) . Buffer ;
const Node = _ _webpack _require _ _ ( 842 ) ;
2021-09-04 19:00:24 -04:00
// Import DER constants
2021-10-15 08:08:03 -04:00
const der = _ _webpack _require _ _ ( 1188 ) ;
2021-09-04 19:00:24 -04:00
function DEREncoder ( entity ) {
this . enc = 'der' ;
this . name = entity . name ;
this . entity = entity ;
// Construct base tree
this . tree = new DERNode ( ) ;
this . tree . _init ( entity . body ) ;
2020-05-03 14:46:05 -04:00
}
2021-09-04 19:00:24 -04:00
module . exports = DEREncoder ;
DEREncoder . prototype . encode = function encode ( data , reporter ) {
return this . tree . _encode ( data , reporter ) . join ( ) ;
} ;
// Tree methods
function DERNode ( parent ) {
Node . call ( this , 'der' , parent ) ;
2020-05-03 14:46:05 -04:00
}
2021-09-04 19:00:24 -04:00
inherits ( DERNode , Node ) ;
DERNode . prototype . _encodeComposite = function encodeComposite ( tag ,
primitive ,
cls ,
content ) {
const encodedTag = encodeTag ( tag , primitive , cls , this . reporter ) ;
// Short form
if ( content . length < 0x80 ) {
const header = Buffer . alloc ( 2 ) ;
header [ 0 ] = encodedTag ;
header [ 1 ] = content . length ;
return this . _createEncoderBuffer ( [ header , content ] ) ;
}
// Long form
// Count octets required to store length
let lenOctets = 1 ;
for ( let i = content . length ; i >= 0x100 ; i >>= 8 )
lenOctets ++ ;
const header = Buffer . alloc ( 1 + 1 + lenOctets ) ;
header [ 0 ] = encodedTag ;
header [ 1 ] = 0x80 | lenOctets ;
for ( let i = 1 + lenOctets , j = content . length ; j > 0 ; i -- , j >>= 8 )
header [ i ] = j & 0xff ;
return this . _createEncoderBuffer ( [ header , content ] ) ;
} ;
DERNode . prototype . _encodeStr = function encodeStr ( str , tag ) {
if ( tag === 'bitstr' ) {
return this . _createEncoderBuffer ( [ str . unused | 0 , str . data ] ) ;
} else if ( tag === 'bmpstr' ) {
const buf = Buffer . alloc ( str . length * 2 ) ;
for ( let i = 0 ; i < str . length ; i ++ ) {
buf . writeUInt16BE ( str . charCodeAt ( i ) , i * 2 ) ;
}
return this . _createEncoderBuffer ( buf ) ;
} else if ( tag === 'numstr' ) {
if ( ! this . _isNumstr ( str ) ) {
return this . reporter . error ( 'Encoding of string type: numstr supports ' +
'only digits and space' ) ;
}
return this . _createEncoderBuffer ( str ) ;
} else if ( tag === 'printstr' ) {
if ( ! this . _isPrintstr ( str ) ) {
return this . reporter . error ( 'Encoding of string type: printstr supports ' +
'only latin upper and lower case letters, ' +
'digits, space, apostrophe, left and rigth ' +
'parenthesis, plus sign, comma, hyphen, ' +
'dot, slash, colon, equal sign, ' +
'question mark' ) ;
}
return this . _createEncoderBuffer ( str ) ;
} else if ( /str$/ . test ( tag ) ) {
return this . _createEncoderBuffer ( str ) ;
} else if ( tag === 'objDesc' ) {
return this . _createEncoderBuffer ( str ) ;
} else {
return this . reporter . error ( 'Encoding of string type: ' + tag +
' unsupported' ) ;
}
} ;
DERNode . prototype . _encodeObjid = function encodeObjid ( id , values , relative ) {
if ( typeof id === 'string' ) {
if ( ! values )
return this . reporter . error ( 'string objid given, but no values map found' ) ;
if ( ! values . hasOwnProperty ( id ) )
return this . reporter . error ( 'objid not found in values map' ) ;
id = values [ id ] . split ( /[\s.]+/g ) ;
for ( let i = 0 ; i < id . length ; i ++ )
id [ i ] |= 0 ;
} else if ( Array . isArray ( id ) ) {
id = id . slice ( ) ;
for ( let i = 0 ; i < id . length ; i ++ )
id [ i ] |= 0 ;
}
if ( ! Array . isArray ( id ) ) {
return this . reporter . error ( 'objid() should be either array or string, ' +
'got: ' + JSON . stringify ( id ) ) ;
}
if ( ! relative ) {
if ( id [ 1 ] >= 40 )
return this . reporter . error ( 'Second objid identifier OOB' ) ;
id . splice ( 0 , 2 , id [ 0 ] * 40 + id [ 1 ] ) ;
}
// Count number of octets
let size = 0 ;
for ( let i = 0 ; i < id . length ; i ++ ) {
let ident = id [ i ] ;
for ( size ++ ; ident >= 0x80 ; ident >>= 7 )
size ++ ;
}
const objid = Buffer . alloc ( size ) ;
let offset = objid . length - 1 ;
for ( let i = id . length - 1 ; i >= 0 ; i -- ) {
let ident = id [ i ] ;
objid [ offset -- ] = ident & 0x7f ;
while ( ( ident >>= 7 ) > 0 )
objid [ offset -- ] = 0x80 | ( ident & 0x7f ) ;
}
return this . _createEncoderBuffer ( objid ) ;
} ;
function two ( num ) {
if ( num < 10 )
return '0' + num ;
else
return num ;
2020-05-03 14:46:05 -04:00
}
2021-09-04 19:00:24 -04:00
DERNode . prototype . _encodeTime = function encodeTime ( time , tag ) {
let str ;
const date = new Date ( time ) ;
if ( tag === 'gentime' ) {
str = [
two ( date . getUTCFullYear ( ) ) ,
two ( date . getUTCMonth ( ) + 1 ) ,
two ( date . getUTCDate ( ) ) ,
two ( date . getUTCHours ( ) ) ,
two ( date . getUTCMinutes ( ) ) ,
two ( date . getUTCSeconds ( ) ) ,
'Z'
] . join ( '' ) ;
} else if ( tag === 'utctime' ) {
str = [
two ( date . getUTCFullYear ( ) % 100 ) ,
two ( date . getUTCMonth ( ) + 1 ) ,
two ( date . getUTCDate ( ) ) ,
two ( date . getUTCHours ( ) ) ,
two ( date . getUTCMinutes ( ) ) ,
two ( date . getUTCSeconds ( ) ) ,
'Z'
] . join ( '' ) ;
} else {
this . reporter . error ( 'Encoding ' + tag + ' time is not supported yet' ) ;
}
return this . _encodeStr ( str , 'octstr' ) ;
} ;
DERNode . prototype . _encodeNull = function encodeNull ( ) {
return this . _createEncoderBuffer ( '' ) ;
} ;
DERNode . prototype . _encodeInt = function encodeInt ( num , values ) {
if ( typeof num === 'string' ) {
if ( ! values )
return this . reporter . error ( 'String int or enum given, but no values map' ) ;
if ( ! values . hasOwnProperty ( num ) ) {
return this . reporter . error ( 'Values map doesn\'t contain: ' +
JSON . stringify ( num ) ) ;
2020-05-03 14:46:05 -04:00
}
2021-09-04 19:00:24 -04:00
num = values [ num ] ;
}
// Bignum, assume big endian
if ( typeof num !== 'number' && ! Buffer . isBuffer ( num ) ) {
const numArray = num . toArray ( ) ;
if ( ! num . sign && numArray [ 0 ] & 0x80 ) {
numArray . unshift ( 0 ) ;
2020-05-03 14:46:05 -04:00
}
2021-09-04 19:00:24 -04:00
num = Buffer . from ( numArray ) ;
}
if ( Buffer . isBuffer ( num ) ) {
let size = num . length ;
if ( num . length === 0 )
size ++ ;
const out = Buffer . alloc ( size ) ;
num . copy ( out ) ;
if ( num . length === 0 )
out [ 0 ] = 0 ;
return this . _createEncoderBuffer ( out ) ;
}
if ( num < 0x80 )
return this . _createEncoderBuffer ( num ) ;
if ( num < 0x100 )
return this . _createEncoderBuffer ( [ 0 , num ] ) ;
let size = 1 ;
for ( let i = num ; i >= 0x100 ; i >>= 8 )
size ++ ;
const out = new Array ( size ) ;
for ( let i = out . length - 1 ; i >= 0 ; i -- ) {
out [ i ] = num & 0xff ;
num >>= 8 ;
}
if ( out [ 0 ] & 0x80 ) {
out . unshift ( 0 ) ;
}
return this . _createEncoderBuffer ( Buffer . from ( out ) ) ;
} ;
DERNode . prototype . _encodeBool = function encodeBool ( value ) {
return this . _createEncoderBuffer ( value ? 0xff : 0 ) ;
} ;
DERNode . prototype . _use = function use ( entity , obj ) {
if ( typeof entity === 'function' )
entity = entity ( obj ) ;
return entity . _getEncoder ( 'der' ) . tree ;
} ;
DERNode . prototype . _skipDefault = function skipDefault ( dataBuffer , reporter , parent ) {
const state = this . _baseState ;
let i ;
if ( state [ 'default' ] === null )
return false ;
const data = dataBuffer . join ( ) ;
if ( state . defaultBuffer === undefined )
state . defaultBuffer = this . _encodeValue ( state [ 'default' ] , reporter , parent ) . join ( ) ;
if ( data . length !== state . defaultBuffer . length )
return false ;
for ( i = 0 ; i < data . length ; i ++ )
if ( data [ i ] !== state . defaultBuffer [ i ] )
return false ;
return true ;
} ;
// Utility methods
function encodeTag ( tag , primitive , cls , reporter ) {
let res ;
if ( tag === 'seqof' )
tag = 'seq' ;
else if ( tag === 'setof' )
tag = 'set' ;
if ( der . tagByName . hasOwnProperty ( tag ) )
res = der . tagByName [ tag ] ;
else if ( typeof tag === 'number' && ( tag | 0 ) === tag )
res = tag ;
else
return reporter . error ( 'Unknown tag: ' + tag ) ;
if ( res >= 0x1f )
return reporter . error ( 'Multi-octet tag encoding unsupported' ) ;
if ( ! primitive )
res |= 0x20 ;
res |= ( der . tagClassByName [ cls || 'universal' ] << 6 ) ;
return res ;
}
/***/ } ) ,
2021-10-15 08:08:03 -04:00
/***/ 9083 :
2021-09-04 19:00:24 -04:00
/***/ ( ( _ _unused _webpack _module , exports , _ _webpack _require _ _ ) => {
"use strict" ;
const encoders = exports ;
2021-10-15 08:08:03 -04:00
encoders . der = _ _webpack _require _ _ ( 5769 ) ;
2021-09-04 19:00:24 -04:00
encoders . pem = _ _webpack _require _ _ ( 279 ) ;
/***/ } ) ,
/***/ 279 :
/***/ ( ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) => {
"use strict" ;
2021-10-15 08:08:03 -04:00
const inherits = _ _webpack _require _ _ ( 4124 ) ;
2021-09-04 19:00:24 -04:00
2021-10-15 08:08:03 -04:00
const DEREncoder = _ _webpack _require _ _ ( 5769 ) ;
2021-09-04 19:00:24 -04:00
function PEMEncoder ( entity ) {
DEREncoder . call ( this , entity ) ;
this . enc = 'pem' ;
2020-05-03 14:46:05 -04:00
}
2021-09-04 19:00:24 -04:00
inherits ( PEMEncoder , DEREncoder ) ;
module . exports = PEMEncoder ;
PEMEncoder . prototype . encode = function encode ( data , options ) {
const buf = DEREncoder . prototype . encode . call ( this , data ) ;
const p = buf . toString ( 'base64' ) ;
const out = [ '-----BEGIN ' + options . label + '-----' ] ;
for ( let i = 0 ; i < p . length ; i += 64 )
out . push ( p . slice ( i , i + 64 ) ) ;
out . push ( '-----END ' + options . label + '-----' ) ;
return out . join ( '\n' ) ;
} ;
/***/ } ) ,
2020-05-03 14:46:05 -04:00
2021-10-15 08:08:03 -04:00
/***/ 6641 :
2021-09-04 19:00:24 -04:00
/***/ ( function ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) {
/* module decorator */ module = _ _webpack _require _ _ . nmd ( module ) ;
2020-05-03 14:46:05 -04:00
( function ( module , exports ) {
'use strict' ;
// Utils
function assert ( val , msg ) {
if ( ! val ) throw new Error ( msg || 'Assertion failed' ) ;
}
// Could use `inherits` module, but don't want to move from single file
// architecture yet.
function inherits ( ctor , superCtor ) {
ctor . super _ = superCtor ;
var TempCtor = function ( ) { } ;
TempCtor . prototype = superCtor . prototype ;
ctor . prototype = new TempCtor ( ) ;
ctor . prototype . constructor = ctor ;
}
// BN
function BN ( number , base , endian ) {
if ( BN . isBN ( number ) ) {
return number ;
}
this . negative = 0 ;
this . words = null ;
this . length = 0 ;
// Reduction context
this . red = null ;
if ( number !== null ) {
if ( base === 'le' || base === 'be' ) {
endian = base ;
base = 10 ;
}
this . _init ( number || 0 , base || 10 , endian || 'be' ) ;
}
}
if ( typeof module === 'object' ) {
module . exports = BN ;
} else {
exports . BN = BN ;
}
BN . BN = BN ;
BN . wordSize = 26 ;
var Buffer ;
try {
2021-10-15 08:08:03 -04:00
Buffer = _ _webpack _require _ _ ( 4293 ) . Buffer ;
2020-05-03 14:46:05 -04:00
} catch ( e ) {
}
BN . isBN = function isBN ( num ) {
if ( num instanceof BN ) {
return true ;
}
return num !== null && typeof num === 'object' &&
num . constructor . wordSize === BN . wordSize && Array . isArray ( num . words ) ;
} ;
BN . max = function max ( left , right ) {
if ( left . cmp ( right ) > 0 ) return left ;
return right ;
} ;
BN . min = function min ( left , right ) {
if ( left . cmp ( right ) < 0 ) return left ;
return right ;
} ;
BN . prototype . _init = function init ( number , base , endian ) {
if ( typeof number === 'number' ) {
return this . _initNumber ( number , base , endian ) ;
}
if ( typeof number === 'object' ) {
return this . _initArray ( number , base , endian ) ;
}
if ( base === 'hex' ) {
base = 16 ;
}
assert ( base === ( base | 0 ) && base >= 2 && base <= 36 ) ;
number = number . toString ( ) . replace ( /\s+/g , '' ) ;
var start = 0 ;
if ( number [ 0 ] === '-' ) {
start ++ ;
}
if ( base === 16 ) {
this . _parseHex ( number , start ) ;
} else {
this . _parseBase ( number , base , start ) ;
}
if ( number [ 0 ] === '-' ) {
this . negative = 1 ;
}
this . strip ( ) ;
if ( endian !== 'le' ) return ;
this . _initArray ( this . toArray ( ) , base , endian ) ;
} ;
BN . prototype . _initNumber = function _initNumber ( number , base , endian ) {
if ( number < 0 ) {
this . negative = 1 ;
number = - number ;
}
if ( number < 0x4000000 ) {
this . words = [ number & 0x3ffffff ] ;
this . length = 1 ;
} else if ( number < 0x10000000000000 ) {
this . words = [
number & 0x3ffffff ,
( number / 0x4000000 ) & 0x3ffffff
] ;
this . length = 2 ;
} else {
assert ( number < 0x20000000000000 ) ; // 2 ^ 53 (unsafe)
this . words = [
number & 0x3ffffff ,
( number / 0x4000000 ) & 0x3ffffff ,
1
] ;
this . length = 3 ;
}
if ( endian !== 'le' ) return ;
// Reverse the bytes
this . _initArray ( this . toArray ( ) , base , endian ) ;
} ;
BN . prototype . _initArray = function _initArray ( number , base , endian ) {
// Perhaps a Uint8Array
assert ( typeof number . length === 'number' ) ;
if ( number . length <= 0 ) {
this . words = [ 0 ] ;
this . length = 1 ;
return this ;
}
this . length = Math . ceil ( number . length / 3 ) ;
this . words = new Array ( this . length ) ;
for ( var i = 0 ; i < this . length ; i ++ ) {
this . words [ i ] = 0 ;
}
var j , w ;
var off = 0 ;
if ( endian === 'be' ) {
for ( i = number . length - 1 , j = 0 ; i >= 0 ; i -= 3 ) {
w = number [ i ] | ( number [ i - 1 ] << 8 ) | ( number [ i - 2 ] << 16 ) ;
this . words [ j ] |= ( w << off ) & 0x3ffffff ;
this . words [ j + 1 ] = ( w >>> ( 26 - off ) ) & 0x3ffffff ;
off += 24 ;
if ( off >= 26 ) {
off -= 26 ;
j ++ ;
}
}
} else if ( endian === 'le' ) {
for ( i = 0 , j = 0 ; i < number . length ; i += 3 ) {
w = number [ i ] | ( number [ i + 1 ] << 8 ) | ( number [ i + 2 ] << 16 ) ;
this . words [ j ] |= ( w << off ) & 0x3ffffff ;
this . words [ j + 1 ] = ( w >>> ( 26 - off ) ) & 0x3ffffff ;
off += 24 ;
if ( off >= 26 ) {
off -= 26 ;
j ++ ;
}
}
}
return this . strip ( ) ;
} ;
function parseHex ( str , start , end ) {
var r = 0 ;
var len = Math . min ( str . length , end ) ;
for ( var i = start ; i < len ; i ++ ) {
var c = str . charCodeAt ( i ) - 48 ;
r <<= 4 ;
// 'a' - 'f'
if ( c >= 49 && c <= 54 ) {
r |= c - 49 + 0xa ;
// 'A' - 'F'
} else if ( c >= 17 && c <= 22 ) {
r |= c - 17 + 0xa ;
// '0' - '9'
} else {
r |= c & 0xf ;
}
}
return r ;
}
BN . prototype . _parseHex = function _parseHex ( number , start ) {
// Create possibly bigger array to ensure that it fits the number
this . length = Math . ceil ( ( number . length - start ) / 6 ) ;
this . words = new Array ( this . length ) ;
for ( var i = 0 ; i < this . length ; i ++ ) {
this . words [ i ] = 0 ;
}
var j , w ;
// Scan 24-bit chunks and add them to the number
var off = 0 ;
for ( i = number . length - 6 , j = 0 ; i >= start ; i -= 6 ) {
w = parseHex ( number , i , i + 6 ) ;
this . words [ j ] |= ( w << off ) & 0x3ffffff ;
// NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb
this . words [ j + 1 ] |= w >>> ( 26 - off ) & 0x3fffff ;
off += 24 ;
if ( off >= 26 ) {
off -= 26 ;
j ++ ;
}
}
if ( i + 6 !== start ) {
w = parseHex ( number , start , i + 6 ) ;
this . words [ j ] |= ( w << off ) & 0x3ffffff ;
this . words [ j + 1 ] |= w >>> ( 26 - off ) & 0x3fffff ;
}
this . strip ( ) ;
} ;
function parseBase ( str , start , end , mul ) {
var r = 0 ;
var len = Math . min ( str . length , end ) ;
for ( var i = start ; i < len ; i ++ ) {
var c = str . charCodeAt ( i ) - 48 ;
r *= mul ;
// 'a'
if ( c >= 49 ) {
r += c - 49 + 0xa ;
// 'A'
} else if ( c >= 17 ) {
r += c - 17 + 0xa ;
// '0' - '9'
} else {
r += c ;
}
}
return r ;
}
BN . prototype . _parseBase = function _parseBase ( number , base , start ) {
// Initialize as zero
this . words = [ 0 ] ;
this . length = 1 ;
// Find length of limb in base
for ( var limbLen = 0 , limbPow = 1 ; limbPow <= 0x3ffffff ; limbPow *= base ) {
limbLen ++ ;
}
limbLen -- ;
limbPow = ( limbPow / base ) | 0 ;
var total = number . length - start ;
var mod = total % limbLen ;
var end = Math . min ( total , total - mod ) + start ;
var word = 0 ;
for ( var i = start ; i < end ; i += limbLen ) {
word = parseBase ( number , i , i + limbLen , base ) ;
this . imuln ( limbPow ) ;
if ( this . words [ 0 ] + word < 0x4000000 ) {
this . words [ 0 ] += word ;
} else {
this . _iaddn ( word ) ;
}
}
if ( mod !== 0 ) {
var pow = 1 ;
word = parseBase ( number , i , number . length , base ) ;
for ( i = 0 ; i < mod ; i ++ ) {
pow *= base ;
}
this . imuln ( pow ) ;
if ( this . words [ 0 ] + word < 0x4000000 ) {
this . words [ 0 ] += word ;
} else {
this . _iaddn ( word ) ;
}
}
} ;
BN . prototype . copy = function copy ( dest ) {
dest . words = new Array ( this . length ) ;
for ( var i = 0 ; i < this . length ; i ++ ) {
dest . words [ i ] = this . words [ i ] ;
}
dest . length = this . length ;
dest . negative = this . negative ;
dest . red = this . red ;
} ;
BN . prototype . clone = function clone ( ) {
var r = new BN ( null ) ;
this . copy ( r ) ;
return r ;
} ;
BN . prototype . _expand = function _expand ( size ) {
while ( this . length < size ) {
this . words [ this . length ++ ] = 0 ;
}
return this ;
} ;
// Remove leading `0` from `this`
BN . prototype . strip = function strip ( ) {
while ( this . length > 1 && this . words [ this . length - 1 ] === 0 ) {
this . length -- ;
}
return this . _normSign ( ) ;
} ;
BN . prototype . _normSign = function _normSign ( ) {
// -0 = 0
if ( this . length === 1 && this . words [ 0 ] === 0 ) {
this . negative = 0 ;
}
return this ;
} ;
BN . prototype . inspect = function inspect ( ) {
return ( this . red ? '<BN-R: ' : '<BN: ' ) + this . toString ( 16 ) + '>' ;
} ;
/ *
var zeros = [ ] ;
var groupSizes = [ ] ;
var groupBases = [ ] ;
var s = '' ;
var i = - 1 ;
while ( ++ i < BN . wordSize ) {
zeros [ i ] = s ;
s += '0' ;
}
groupSizes [ 0 ] = 0 ;
groupSizes [ 1 ] = 0 ;
groupBases [ 0 ] = 0 ;
groupBases [ 1 ] = 0 ;
var base = 2 - 1 ;
while ( ++ base < 36 + 1 ) {
var groupSize = 0 ;
var groupBase = 1 ;
while ( groupBase < ( 1 << BN . wordSize ) / base ) {
groupBase *= base ;
groupSize += 1 ;
}
groupSizes [ base ] = groupSize ;
groupBases [ base ] = groupBase ;
}
* /
var zeros = [
'' ,
'0' ,
'00' ,
'000' ,
'0000' ,
'00000' ,
'000000' ,
'0000000' ,
'00000000' ,
'000000000' ,
'0000000000' ,
'00000000000' ,
'000000000000' ,
'0000000000000' ,
'00000000000000' ,
'000000000000000' ,
'0000000000000000' ,
'00000000000000000' ,
'000000000000000000' ,
'0000000000000000000' ,
'00000000000000000000' ,
'000000000000000000000' ,
'0000000000000000000000' ,
'00000000000000000000000' ,
'000000000000000000000000' ,
'0000000000000000000000000'
] ;
var groupSizes = [
0 , 0 ,
25 , 16 , 12 , 11 , 10 , 9 , 8 ,
8 , 7 , 7 , 7 , 7 , 6 , 6 ,
6 , 6 , 6 , 6 , 6 , 5 , 5 ,
5 , 5 , 5 , 5 , 5 , 5 , 5 ,
5 , 5 , 5 , 5 , 5 , 5 , 5
] ;
var groupBases = [
0 , 0 ,
33554432 , 43046721 , 16777216 , 48828125 , 60466176 , 40353607 , 16777216 ,
43046721 , 10000000 , 19487171 , 35831808 , 62748517 , 7529536 , 11390625 ,
16777216 , 24137569 , 34012224 , 47045881 , 64000000 , 4084101 , 5153632 ,
6436343 , 7962624 , 9765625 , 11881376 , 14348907 , 17210368 , 20511149 ,
24300000 , 28629151 , 33554432 , 39135393 , 45435424 , 52521875 , 60466176
] ;
BN . prototype . toString = function toString ( base , padding ) {
base = base || 10 ;
padding = padding | 0 || 1 ;
var out ;
if ( base === 16 || base === 'hex' ) {
out = '' ;
var off = 0 ;
var carry = 0 ;
for ( var i = 0 ; i < this . length ; i ++ ) {
var w = this . words [ i ] ;
var word = ( ( ( w << off ) | carry ) & 0xffffff ) . toString ( 16 ) ;
carry = ( w >>> ( 24 - off ) ) & 0xffffff ;
if ( carry !== 0 || i !== this . length - 1 ) {
out = zeros [ 6 - word . length ] + word + out ;
} else {
out = word + out ;
}
off += 2 ;
if ( off >= 26 ) {
off -= 26 ;
i -- ;
}
}
if ( carry !== 0 ) {
out = carry . toString ( 16 ) + out ;
}
while ( out . length % padding !== 0 ) {
out = '0' + out ;
}
if ( this . negative !== 0 ) {
out = '-' + out ;
}
return out ;
}
if ( base === ( base | 0 ) && base >= 2 && base <= 36 ) {
// var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));
var groupSize = groupSizes [ base ] ;
// var groupBase = Math.pow(base, groupSize);
var groupBase = groupBases [ base ] ;
out = '' ;
var c = this . clone ( ) ;
c . negative = 0 ;
while ( ! c . isZero ( ) ) {
var r = c . modn ( groupBase ) . toString ( base ) ;
c = c . idivn ( groupBase ) ;
if ( ! c . isZero ( ) ) {
out = zeros [ groupSize - r . length ] + r + out ;
} else {
out = r + out ;
}
}
if ( this . isZero ( ) ) {
out = '0' + out ;
}
while ( out . length % padding !== 0 ) {
out = '0' + out ;
}
if ( this . negative !== 0 ) {
out = '-' + out ;
}
return out ;
}
assert ( false , 'Base should be between 2 and 36' ) ;
} ;
BN . prototype . toNumber = function toNumber ( ) {
var ret = this . words [ 0 ] ;
if ( this . length === 2 ) {
ret += this . words [ 1 ] * 0x4000000 ;
} else if ( this . length === 3 && this . words [ 2 ] === 0x01 ) {
// NOTE: at this stage it is known that the top bit is set
ret += 0x10000000000000 + ( this . words [ 1 ] * 0x4000000 ) ;
} else if ( this . length > 2 ) {
assert ( false , 'Number can only safely store up to 53 bits' ) ;
}
return ( this . negative !== 0 ) ? - ret : ret ;
} ;
BN . prototype . toJSON = function toJSON ( ) {
return this . toString ( 16 ) ;
} ;
BN . prototype . toBuffer = function toBuffer ( endian , length ) {
assert ( typeof Buffer !== 'undefined' ) ;
return this . toArrayLike ( Buffer , endian , length ) ;
} ;
BN . prototype . toArray = function toArray ( endian , length ) {
return this . toArrayLike ( Array , endian , length ) ;
} ;
BN . prototype . toArrayLike = function toArrayLike ( ArrayType , endian , length ) {
var byteLength = this . byteLength ( ) ;
var reqLength = length || Math . max ( 1 , byteLength ) ;
assert ( byteLength <= reqLength , 'byte array longer than desired length' ) ;
assert ( reqLength > 0 , 'Requested array length <= 0' ) ;
this . strip ( ) ;
var littleEndian = endian === 'le' ;
var res = new ArrayType ( reqLength ) ;
var b , i ;
var q = this . clone ( ) ;
if ( ! littleEndian ) {
// Assume big-endian
for ( i = 0 ; i < reqLength - byteLength ; i ++ ) {
res [ i ] = 0 ;
}
for ( i = 0 ; ! q . isZero ( ) ; i ++ ) {
b = q . andln ( 0xff ) ;
q . iushrn ( 8 ) ;
res [ reqLength - i - 1 ] = b ;
}
} else {
for ( i = 0 ; ! q . isZero ( ) ; i ++ ) {
b = q . andln ( 0xff ) ;
q . iushrn ( 8 ) ;
res [ i ] = b ;
}
for ( ; i < reqLength ; i ++ ) {
res [ i ] = 0 ;
}
}
return res ;
} ;
if ( Math . clz32 ) {
BN . prototype . _countBits = function _countBits ( w ) {
return 32 - Math . clz32 ( w ) ;
} ;
} else {
BN . prototype . _countBits = function _countBits ( w ) {
var t = w ;
var r = 0 ;
if ( t >= 0x1000 ) {
r += 13 ;
t >>>= 13 ;
}
if ( t >= 0x40 ) {
r += 7 ;
t >>>= 7 ;
}
if ( t >= 0x8 ) {
r += 4 ;
t >>>= 4 ;
}
if ( t >= 0x02 ) {
r += 2 ;
t >>>= 2 ;
}
return r + t ;
} ;
}
BN . prototype . _zeroBits = function _zeroBits ( w ) {
// Short-cut
if ( w === 0 ) return 26 ;
var t = w ;
var r = 0 ;
if ( ( t & 0x1fff ) === 0 ) {
r += 13 ;
t >>>= 13 ;
}
if ( ( t & 0x7f ) === 0 ) {
r += 7 ;
t >>>= 7 ;
}
if ( ( t & 0xf ) === 0 ) {
r += 4 ;
t >>>= 4 ;
}
if ( ( t & 0x3 ) === 0 ) {
r += 2 ;
t >>>= 2 ;
}
if ( ( t & 0x1 ) === 0 ) {
r ++ ;
}
return r ;
} ;
// Return number of used bits in a BN
BN . prototype . bitLength = function bitLength ( ) {
var w = this . words [ this . length - 1 ] ;
var hi = this . _countBits ( w ) ;
return ( this . length - 1 ) * 26 + hi ;
} ;
function toBitArray ( num ) {
var w = new Array ( num . bitLength ( ) ) ;
for ( var bit = 0 ; bit < w . length ; bit ++ ) {
var off = ( bit / 26 ) | 0 ;
var wbit = bit % 26 ;
w [ bit ] = ( num . words [ off ] & ( 1 << wbit ) ) >>> wbit ;
}
return w ;
}
// Number of trailing zero bits
BN . prototype . zeroBits = function zeroBits ( ) {
if ( this . isZero ( ) ) return 0 ;
var r = 0 ;
for ( var i = 0 ; i < this . length ; i ++ ) {
var b = this . _zeroBits ( this . words [ i ] ) ;
r += b ;
if ( b !== 26 ) break ;
}
return r ;
} ;
BN . prototype . byteLength = function byteLength ( ) {
return Math . ceil ( this . bitLength ( ) / 8 ) ;
} ;
BN . prototype . toTwos = function toTwos ( width ) {
if ( this . negative !== 0 ) {
return this . abs ( ) . inotn ( width ) . iaddn ( 1 ) ;
}
return this . clone ( ) ;
} ;
BN . prototype . fromTwos = function fromTwos ( width ) {
if ( this . testn ( width - 1 ) ) {
return this . notn ( width ) . iaddn ( 1 ) . ineg ( ) ;
}
return this . clone ( ) ;
} ;
BN . prototype . isNeg = function isNeg ( ) {
return this . negative !== 0 ;
} ;
// Return negative clone of `this`
BN . prototype . neg = function neg ( ) {
return this . clone ( ) . ineg ( ) ;
} ;
BN . prototype . ineg = function ineg ( ) {
if ( ! this . isZero ( ) ) {
this . negative ^= 1 ;
}
return this ;
} ;
// Or `num` with `this` in-place
BN . prototype . iuor = function iuor ( num ) {
while ( this . length < num . length ) {
this . words [ this . length ++ ] = 0 ;
}
for ( var i = 0 ; i < num . length ; i ++ ) {
this . words [ i ] = this . words [ i ] | num . words [ i ] ;
}
return this . strip ( ) ;
} ;
BN . prototype . ior = function ior ( num ) {
assert ( ( this . negative | num . negative ) === 0 ) ;
return this . iuor ( num ) ;
} ;
// Or `num` with `this`
BN . prototype . or = function or ( num ) {
if ( this . length > num . length ) return this . clone ( ) . ior ( num ) ;
return num . clone ( ) . ior ( this ) ;
} ;
BN . prototype . uor = function uor ( num ) {
if ( this . length > num . length ) return this . clone ( ) . iuor ( num ) ;
return num . clone ( ) . iuor ( this ) ;
} ;
// And `num` with `this` in-place
BN . prototype . iuand = function iuand ( num ) {
// b = min-length(num, this)
var b ;
if ( this . length > num . length ) {
b = num ;
} else {
b = this ;
}
for ( var i = 0 ; i < b . length ; i ++ ) {
this . words [ i ] = this . words [ i ] & num . words [ i ] ;
}
this . length = b . length ;
return this . strip ( ) ;
} ;
BN . prototype . iand = function iand ( num ) {
assert ( ( this . negative | num . negative ) === 0 ) ;
return this . iuand ( num ) ;
} ;
// And `num` with `this`
BN . prototype . and = function and ( num ) {
if ( this . length > num . length ) return this . clone ( ) . iand ( num ) ;
return num . clone ( ) . iand ( this ) ;
} ;
BN . prototype . uand = function uand ( num ) {
if ( this . length > num . length ) return this . clone ( ) . iuand ( num ) ;
return num . clone ( ) . iuand ( this ) ;
} ;
// Xor `num` with `this` in-place
BN . prototype . iuxor = function iuxor ( num ) {
// a.length > b.length
var a ;
var b ;
if ( this . length > num . length ) {
a = this ;
b = num ;
} else {
a = num ;
b = this ;
}
for ( var i = 0 ; i < b . length ; i ++ ) {
this . words [ i ] = a . words [ i ] ^ b . words [ i ] ;
}
if ( this !== a ) {
for ( ; i < a . length ; i ++ ) {
this . words [ i ] = a . words [ i ] ;
}
}
this . length = a . length ;
return this . strip ( ) ;
} ;
BN . prototype . ixor = function ixor ( num ) {
assert ( ( this . negative | num . negative ) === 0 ) ;
return this . iuxor ( num ) ;
} ;
// Xor `num` with `this`
BN . prototype . xor = function xor ( num ) {
if ( this . length > num . length ) return this . clone ( ) . ixor ( num ) ;
return num . clone ( ) . ixor ( this ) ;
} ;
BN . prototype . uxor = function uxor ( num ) {
if ( this . length > num . length ) return this . clone ( ) . iuxor ( num ) ;
return num . clone ( ) . iuxor ( this ) ;
} ;
// Not ``this`` with ``width`` bitwidth
BN . prototype . inotn = function inotn ( width ) {
assert ( typeof width === 'number' && width >= 0 ) ;
var bytesNeeded = Math . ceil ( width / 26 ) | 0 ;
var bitsLeft = width % 26 ;
// Extend the buffer with leading zeroes
this . _expand ( bytesNeeded ) ;
if ( bitsLeft > 0 ) {
bytesNeeded -- ;
}
// Handle complete words
for ( var i = 0 ; i < bytesNeeded ; i ++ ) {
this . words [ i ] = ~ this . words [ i ] & 0x3ffffff ;
}
// Handle the residue
if ( bitsLeft > 0 ) {
this . words [ i ] = ~ this . words [ i ] & ( 0x3ffffff >> ( 26 - bitsLeft ) ) ;
}
// And remove leading zeroes
return this . strip ( ) ;
} ;
BN . prototype . notn = function notn ( width ) {
return this . clone ( ) . inotn ( width ) ;
} ;
// Set `bit` of `this`
BN . prototype . setn = function setn ( bit , val ) {
assert ( typeof bit === 'number' && bit >= 0 ) ;
var off = ( bit / 26 ) | 0 ;
var wbit = bit % 26 ;
this . _expand ( off + 1 ) ;
if ( val ) {
this . words [ off ] = this . words [ off ] | ( 1 << wbit ) ;
} else {
this . words [ off ] = this . words [ off ] & ~ ( 1 << wbit ) ;
}
return this . strip ( ) ;
} ;
// Add `num` to `this` in-place
BN . prototype . iadd = function iadd ( num ) {
var r ;
// negative + positive
if ( this . negative !== 0 && num . negative === 0 ) {
this . negative = 0 ;
r = this . isub ( num ) ;
this . negative ^= 1 ;
return this . _normSign ( ) ;
// positive + negative
} else if ( this . negative === 0 && num . negative !== 0 ) {
num . negative = 0 ;
r = this . isub ( num ) ;
num . negative = 1 ;
return r . _normSign ( ) ;
}
// a.length > b.length
var a , b ;
if ( this . length > num . length ) {
a = this ;
b = num ;
} else {
a = num ;
b = this ;
}
var carry = 0 ;
for ( var i = 0 ; i < b . length ; i ++ ) {
r = ( a . words [ i ] | 0 ) + ( b . words [ i ] | 0 ) + carry ;
this . words [ i ] = r & 0x3ffffff ;
carry = r >>> 26 ;
}
for ( ; carry !== 0 && i < a . length ; i ++ ) {
r = ( a . words [ i ] | 0 ) + carry ;
this . words [ i ] = r & 0x3ffffff ;
carry = r >>> 26 ;
}
this . length = a . length ;
if ( carry !== 0 ) {
this . words [ this . length ] = carry ;
this . length ++ ;
// Copy the rest of the words
} else if ( a !== this ) {
for ( ; i < a . length ; i ++ ) {
this . words [ i ] = a . words [ i ] ;
}
}
return this ;
} ;
// Add `num` to `this`
BN . prototype . add = function add ( num ) {
var res ;
if ( num . negative !== 0 && this . negative === 0 ) {
num . negative = 0 ;
res = this . sub ( num ) ;
num . negative ^= 1 ;
return res ;
} else if ( num . negative === 0 && this . negative !== 0 ) {
this . negative = 0 ;
res = num . sub ( this ) ;
this . negative = 1 ;
return res ;
}
if ( this . length > num . length ) return this . clone ( ) . iadd ( num ) ;
return num . clone ( ) . iadd ( this ) ;
} ;
// Subtract `num` from `this` in-place
BN . prototype . isub = function isub ( num ) {
// this - (-num) = this + num
if ( num . negative !== 0 ) {
num . negative = 0 ;
var r = this . iadd ( num ) ;
num . negative = 1 ;
return r . _normSign ( ) ;
// -this - num = -(this + num)
} else if ( this . negative !== 0 ) {
this . negative = 0 ;
this . iadd ( num ) ;
this . negative = 1 ;
return this . _normSign ( ) ;
}
// At this point both numbers are positive
var cmp = this . cmp ( num ) ;
// Optimization - zeroify
if ( cmp === 0 ) {
this . negative = 0 ;
this . length = 1 ;
this . words [ 0 ] = 0 ;
return this ;
}
// a > b
var a , b ;
if ( cmp > 0 ) {
a = this ;
b = num ;
} else {
a = num ;
b = this ;
}
var carry = 0 ;
for ( var i = 0 ; i < b . length ; i ++ ) {
r = ( a . words [ i ] | 0 ) - ( b . words [ i ] | 0 ) + carry ;
carry = r >> 26 ;
this . words [ i ] = r & 0x3ffffff ;
}
for ( ; carry !== 0 && i < a . length ; i ++ ) {
r = ( a . words [ i ] | 0 ) + carry ;
carry = r >> 26 ;
this . words [ i ] = r & 0x3ffffff ;
}
// Copy rest of the words
if ( carry === 0 && i < a . length && a !== this ) {
for ( ; i < a . length ; i ++ ) {
this . words [ i ] = a . words [ i ] ;
}
}
this . length = Math . max ( this . length , i ) ;
if ( a !== this ) {
this . negative = 1 ;
}
return this . strip ( ) ;
} ;
// Subtract `num` from `this`
BN . prototype . sub = function sub ( num ) {
return this . clone ( ) . isub ( num ) ;
} ;
function smallMulTo ( self , num , out ) {
out . negative = num . negative ^ self . negative ;
var len = ( self . length + num . length ) | 0 ;
out . length = len ;
len = ( len - 1 ) | 0 ;
// Peel one iteration (compiler can't do it, because of code complexity)
var a = self . words [ 0 ] | 0 ;
var b = num . words [ 0 ] | 0 ;
var r = a * b ;
var lo = r & 0x3ffffff ;
var carry = ( r / 0x4000000 ) | 0 ;
out . words [ 0 ] = lo ;
for ( var k = 1 ; k < len ; k ++ ) {
// Sum all words with the same `i + j = k` and accumulate `ncarry`,
// note that ncarry could be >= 0x3ffffff
var ncarry = carry >>> 26 ;
var rword = carry & 0x3ffffff ;
var maxJ = Math . min ( k , num . length - 1 ) ;
for ( var j = Math . max ( 0 , k - self . length + 1 ) ; j <= maxJ ; j ++ ) {
var i = ( k - j ) | 0 ;
a = self . words [ i ] | 0 ;
b = num . words [ j ] | 0 ;
r = a * b + rword ;
ncarry += ( r / 0x4000000 ) | 0 ;
rword = r & 0x3ffffff ;
}
out . words [ k ] = rword | 0 ;
carry = ncarry | 0 ;
}
if ( carry !== 0 ) {
out . words [ k ] = carry | 0 ;
} else {
out . length -- ;
}
return out . strip ( ) ;
}
// TODO(indutny): it may be reasonable to omit it for users who don't need
// to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit
// multiplication (like elliptic secp256k1).
var comb10MulTo = function comb10MulTo ( self , num , out ) {
var a = self . words ;
var b = num . words ;
var o = out . words ;
var c = 0 ;
var lo ;
var mid ;
var hi ;
var a0 = a [ 0 ] | 0 ;
var al0 = a0 & 0x1fff ;
var ah0 = a0 >>> 13 ;
var a1 = a [ 1 ] | 0 ;
var al1 = a1 & 0x1fff ;
var ah1 = a1 >>> 13 ;
var a2 = a [ 2 ] | 0 ;
var al2 = a2 & 0x1fff ;
var ah2 = a2 >>> 13 ;
var a3 = a [ 3 ] | 0 ;
var al3 = a3 & 0x1fff ;
var ah3 = a3 >>> 13 ;
var a4 = a [ 4 ] | 0 ;
var al4 = a4 & 0x1fff ;
var ah4 = a4 >>> 13 ;
var a5 = a [ 5 ] | 0 ;
var al5 = a5 & 0x1fff ;
var ah5 = a5 >>> 13 ;
var a6 = a [ 6 ] | 0 ;
var al6 = a6 & 0x1fff ;
var ah6 = a6 >>> 13 ;
var a7 = a [ 7 ] | 0 ;
var al7 = a7 & 0x1fff ;
var ah7 = a7 >>> 13 ;
var a8 = a [ 8 ] | 0 ;
var al8 = a8 & 0x1fff ;
var ah8 = a8 >>> 13 ;
var a9 = a [ 9 ] | 0 ;
var al9 = a9 & 0x1fff ;
var ah9 = a9 >>> 13 ;
var b0 = b [ 0 ] | 0 ;
var bl0 = b0 & 0x1fff ;
var bh0 = b0 >>> 13 ;
var b1 = b [ 1 ] | 0 ;
var bl1 = b1 & 0x1fff ;
var bh1 = b1 >>> 13 ;
var b2 = b [ 2 ] | 0 ;
var bl2 = b2 & 0x1fff ;
var bh2 = b2 >>> 13 ;
var b3 = b [ 3 ] | 0 ;
var bl3 = b3 & 0x1fff ;
var bh3 = b3 >>> 13 ;
var b4 = b [ 4 ] | 0 ;
var bl4 = b4 & 0x1fff ;
var bh4 = b4 >>> 13 ;
var b5 = b [ 5 ] | 0 ;
var bl5 = b5 & 0x1fff ;
var bh5 = b5 >>> 13 ;
var b6 = b [ 6 ] | 0 ;
var bl6 = b6 & 0x1fff ;
var bh6 = b6 >>> 13 ;
var b7 = b [ 7 ] | 0 ;
var bl7 = b7 & 0x1fff ;
var bh7 = b7 >>> 13 ;
var b8 = b [ 8 ] | 0 ;
var bl8 = b8 & 0x1fff ;
var bh8 = b8 >>> 13 ;
var b9 = b [ 9 ] | 0 ;
var bl9 = b9 & 0x1fff ;
var bh9 = b9 >>> 13 ;
out . negative = self . negative ^ num . negative ;
out . length = 19 ;
/* k = 0 */
lo = Math . imul ( al0 , bl0 ) ;
mid = Math . imul ( al0 , bh0 ) ;
mid = ( mid + Math . imul ( ah0 , bl0 ) ) | 0 ;
hi = Math . imul ( ah0 , bh0 ) ;
var w0 = ( ( ( c + lo ) | 0 ) + ( ( mid & 0x1fff ) << 13 ) ) | 0 ;
c = ( ( ( hi + ( mid >>> 13 ) ) | 0 ) + ( w0 >>> 26 ) ) | 0 ;
w0 &= 0x3ffffff ;
/* k = 1 */
lo = Math . imul ( al1 , bl0 ) ;
mid = Math . imul ( al1 , bh0 ) ;
mid = ( mid + Math . imul ( ah1 , bl0 ) ) | 0 ;
hi = Math . imul ( ah1 , bh0 ) ;
lo = ( lo + Math . imul ( al0 , bl1 ) ) | 0 ;
mid = ( mid + Math . imul ( al0 , bh1 ) ) | 0 ;
mid = ( mid + Math . imul ( ah0 , bl1 ) ) | 0 ;
hi = ( hi + Math . imul ( ah0 , bh1 ) ) | 0 ;
var w1 = ( ( ( c + lo ) | 0 ) + ( ( mid & 0x1fff ) << 13 ) ) | 0 ;
c = ( ( ( hi + ( mid >>> 13 ) ) | 0 ) + ( w1 >>> 26 ) ) | 0 ;
w1 &= 0x3ffffff ;
/* k = 2 */
lo = Math . imul ( al2 , bl0 ) ;
mid = Math . imul ( al2 , bh0 ) ;
mid = ( mid + Math . imul ( ah2 , bl0 ) ) | 0 ;
hi = Math . imul ( ah2 , bh0 ) ;
lo = ( lo + Math . imul ( al1 , bl1 ) ) | 0 ;
mid = ( mid + Math . imul ( al1 , bh1 ) ) | 0 ;
mid = ( mid + Math . imul ( ah1 , bl1 ) ) | 0 ;
hi = ( hi + Math . imul ( ah1 , bh1 ) ) | 0 ;
lo = ( lo + Math . imul ( al0 , bl2 ) ) | 0 ;
mid = ( mid + Math . imul ( al0 , bh2 ) ) | 0 ;
mid = ( mid + Math . imul ( ah0 , bl2 ) ) | 0 ;
hi = ( hi + Math . imul ( ah0 , bh2 ) ) | 0 ;
var w2 = ( ( ( c + lo ) | 0 ) + ( ( mid & 0x1fff ) << 13 ) ) | 0 ;
c = ( ( ( hi + ( mid >>> 13 ) ) | 0 ) + ( w2 >>> 26 ) ) | 0 ;
w2 &= 0x3ffffff ;
/* k = 3 */
lo = Math . imul ( al3 , bl0 ) ;
mid = Math . imul ( al3 , bh0 ) ;
mid = ( mid + Math . imul ( ah3 , bl0 ) ) | 0 ;
hi = Math . imul ( ah3 , bh0 ) ;
lo = ( lo + Math . imul ( al2 , bl1 ) ) | 0 ;
mid = ( mid + Math . imul ( al2 , bh1 ) ) | 0 ;
mid = ( mid + Math . imul ( ah2 , bl1 ) ) | 0 ;
hi = ( hi + Math . imul ( ah2 , bh1 ) ) | 0 ;
lo = ( lo + Math . imul ( al1 , bl2 ) ) | 0 ;
mid = ( mid + Math . imul ( al1 , bh2 ) ) | 0 ;
mid = ( mid + Math . imul ( ah1 , bl2 ) ) | 0 ;
hi = ( hi + Math . imul ( ah1 , bh2 ) ) | 0 ;
lo = ( lo + Math . imul ( al0 , bl3 ) ) | 0 ;
mid = ( mid + Math . imul ( al0 , bh3 ) ) | 0 ;
mid = ( mid + Math . imul ( ah0 , bl3 ) ) | 0 ;
hi = ( hi + Math . imul ( ah0 , bh3 ) ) | 0 ;
var w3 = ( ( ( c + lo ) | 0 ) + ( ( mid & 0x1fff ) << 13 ) ) | 0 ;
c = ( ( ( hi + ( mid >>> 13 ) ) | 0 ) + ( w3 >>> 26 ) ) | 0 ;
w3 &= 0x3ffffff ;
/* k = 4 */
lo = Math . imul ( al4 , bl0 ) ;
mid = Math . imul ( al4 , bh0 ) ;
mid = ( mid + Math . imul ( ah4 , bl0 ) ) | 0 ;
hi = Math . imul ( ah4 , bh0 ) ;
lo = ( lo + Math . imul ( al3 , bl1 ) ) | 0 ;
mid = ( mid + Math . imul ( al3 , bh1 ) ) | 0 ;
mid = ( mid + Math . imul ( ah3 , bl1 ) ) | 0 ;
hi = ( hi + Math . imul ( ah3 , bh1 ) ) | 0 ;
lo = ( lo + Math . imul ( al2 , bl2 ) ) | 0 ;
mid = ( mid + Math . imul ( al2 , bh2 ) ) | 0 ;
mid = ( mid + Math . imul ( ah2 , bl2 ) ) | 0 ;
hi = ( hi + Math . imul ( ah2 , bh2 ) ) | 0 ;
lo = ( lo + Math . imul ( al1 , bl3 ) ) | 0 ;
mid = ( mid + Math . imul ( al1 , bh3 ) ) | 0 ;
mid = ( mid + Math . imul ( ah1 , bl3 ) ) | 0 ;
hi = ( hi + Math . imul ( ah1 , bh3 ) ) | 0 ;
lo = ( lo + Math . imul ( al0 , bl4 ) ) | 0 ;
mid = ( mid + Math . imul ( al0 , bh4 ) ) | 0 ;
mid = ( mid + Math . imul ( ah0 , bl4 ) ) | 0 ;
hi = ( hi + Math . imul ( ah0 , bh4 ) ) | 0 ;
var w4 = ( ( ( c + lo ) | 0 ) + ( ( mid & 0x1fff ) << 13 ) ) | 0 ;
c = ( ( ( hi + ( mid >>> 13 ) ) | 0 ) + ( w4 >>> 26 ) ) | 0 ;
w4 &= 0x3ffffff ;
/* k = 5 */
lo = Math . imul ( al5 , bl0 ) ;
mid = Math . imul ( al5 , bh0 ) ;
mid = ( mid + Math . imul ( ah5 , bl0 ) ) | 0 ;
hi = Math . imul ( ah5 , bh0 ) ;
lo = ( lo + Math . imul ( al4 , bl1 ) ) | 0 ;
mid = ( mid + Math . imul ( al4 , bh1 ) ) | 0 ;
mid = ( mid + Math . imul ( ah4 , bl1 ) ) | 0 ;
hi = ( hi + Math . imul ( ah4 , bh1 ) ) | 0 ;
lo = ( lo + Math . imul ( al3 , bl2 ) ) | 0 ;
mid = ( mid + Math . imul ( al3 , bh2 ) ) | 0 ;
mid = ( mid + Math . imul ( ah3 , bl2 ) ) | 0 ;
hi = ( hi + Math . imul ( ah3 , bh2 ) ) | 0 ;
lo = ( lo + Math . imul ( al2 , bl3 ) ) | 0 ;
mid = ( mid + Math . imul ( al2 , bh3 ) ) | 0 ;
mid = ( mid + Math . imul ( ah2 , bl3 ) ) | 0 ;
hi = ( hi + Math . imul ( ah2 , bh3 ) ) | 0 ;
lo = ( lo + Math . imul ( al1 , bl4 ) ) | 0 ;
mid = ( mid + Math . imul ( al1 , bh4 ) ) | 0 ;
mid = ( mid + Math . imul ( ah1 , bl4 ) ) | 0 ;
hi = ( hi + Math . imul ( ah1 , bh4 ) ) | 0 ;
lo = ( lo + Math . imul ( al0 , bl5 ) ) | 0 ;
mid = ( mid + Math . imul ( al0 , bh5 ) ) | 0 ;
mid = ( mid + Math . imul ( ah0 , bl5 ) ) | 0 ;
hi = ( hi + Math . imul ( ah0 , bh5 ) ) | 0 ;
var w5 = ( ( ( c + lo ) | 0 ) + ( ( mid & 0x1fff ) << 13 ) ) | 0 ;
c = ( ( ( hi + ( mid >>> 13 ) ) | 0 ) + ( w5 >>> 26 ) ) | 0 ;
w5 &= 0x3ffffff ;
/* k = 6 */
lo = Math . imul ( al6 , bl0 ) ;
mid = Math . imul ( al6 , bh0 ) ;
mid = ( mid + Math . imul ( ah6 , bl0 ) ) | 0 ;
hi = Math . imul ( ah6 , bh0 ) ;
lo = ( lo + Math . imul ( al5 , bl1 ) ) | 0 ;
mid = ( mid + Math . imul ( al5 , bh1 ) ) | 0 ;
mid = ( mid + Math . imul ( ah5 , bl1 ) ) | 0 ;
hi = ( hi + Math . imul ( ah5 , bh1 ) ) | 0 ;
lo = ( lo + Math . imul ( al4 , bl2 ) ) | 0 ;
mid = ( mid + Math . imul ( al4 , bh2 ) ) | 0 ;
mid = ( mid + Math . imul ( ah4 , bl2 ) ) | 0 ;
hi = ( hi + Math . imul ( ah4 , bh2 ) ) | 0 ;
lo = ( lo + Math . imul ( al3 , bl3 ) ) | 0 ;
mid = ( mid + Math . imul ( al3 , bh3 ) ) | 0 ;
mid = ( mid + Math . imul ( ah3 , bl3 ) ) | 0 ;
hi = ( hi + Math . imul ( ah3 , bh3 ) ) | 0 ;
lo = ( lo + Math . imul ( al2 , bl4 ) ) | 0 ;
mid = ( mid + Math . imul ( al2 , bh4 ) ) | 0 ;
mid = ( mid + Math . imul ( ah2 , bl4 ) ) | 0 ;
hi = ( hi + Math . imul ( ah2 , bh4 ) ) | 0 ;
lo = ( lo + Math . imul ( al1 , bl5 ) ) | 0 ;
mid = ( mid + Math . imul ( al1 , bh5 ) ) | 0 ;
mid = ( mid + Math . imul ( ah1 , bl5 ) ) | 0 ;
hi = ( hi + Math . imul ( ah1 , bh5 ) ) | 0 ;
lo = ( lo + Math . imul ( al0 , bl6 ) ) | 0 ;
mid = ( mid + Math . imul ( al0 , bh6 ) ) | 0 ;
mid = ( mid + Math . imul ( ah0 , bl6 ) ) | 0 ;
hi = ( hi + Math . imul ( ah0 , bh6 ) ) | 0 ;
var w6 = ( ( ( c + lo ) | 0 ) + ( ( mid & 0x1fff ) << 13 ) ) | 0 ;
c = ( ( ( hi + ( mid >>> 13 ) ) | 0 ) + ( w6 >>> 26 ) ) | 0 ;
w6 &= 0x3ffffff ;
/* k = 7 */
lo = Math . imul ( al7 , bl0 ) ;
mid = Math . imul ( al7 , bh0 ) ;
mid = ( mid + Math . imul ( ah7 , bl0 ) ) | 0 ;
hi = Math . imul ( ah7 , bh0 ) ;
lo = ( lo + Math . imul ( al6 , bl1 ) ) | 0 ;
mid = ( mid + Math . imul ( al6 , bh1 ) ) | 0 ;
mid = ( mid + Math . imul ( ah6 , bl1 ) ) | 0 ;
hi = ( hi + Math . imul ( ah6 , bh1 ) ) | 0 ;
lo = ( lo + Math . imul ( al5 , bl2 ) ) | 0 ;
mid = ( mid + Math . imul ( al5 , bh2 ) ) | 0 ;
mid = ( mid + Math . imul ( ah5 , bl2 ) ) | 0 ;
hi = ( hi + Math . imul ( ah5 , bh2 ) ) | 0 ;
lo = ( lo + Math . imul ( al4 , bl3 ) ) | 0 ;
mid = ( mid + Math . imul ( al4 , bh3 ) ) | 0 ;
mid = ( mid + Math . imul ( ah4 , bl3 ) ) | 0 ;
hi = ( hi + Math . imul ( ah4 , bh3 ) ) | 0 ;
lo = ( lo + Math . imul ( al3 , bl4 ) ) | 0 ;
mid = ( mid + Math . imul ( al3 , bh4 ) ) | 0 ;
mid = ( mid + Math . imul ( ah3 , bl4 ) ) | 0 ;
hi = ( hi + Math . imul ( ah3 , bh4 ) ) | 0 ;
lo = ( lo + Math . imul ( al2 , bl5 ) ) | 0 ;
mid = ( mid + Math . imul ( al2 , bh5 ) ) | 0 ;
mid = ( mid + Math . imul ( ah2 , bl5 ) ) | 0 ;
hi = ( hi + Math . imul ( ah2 , bh5 ) ) | 0 ;
lo = ( lo + Math . imul ( al1 , bl6 ) ) | 0 ;
mid = ( mid + Math . imul ( al1 , bh6 ) ) | 0 ;
mid = ( mid + Math . imul ( ah1 , bl6 ) ) | 0 ;
hi = ( hi + Math . imul ( ah1 , bh6 ) ) | 0 ;
lo = ( lo + Math . imul ( al0 , bl7 ) ) | 0 ;
mid = ( mid + Math . imul ( al0 , bh7 ) ) | 0 ;
mid = ( mid + Math . imul ( ah0 , bl7 ) ) | 0 ;
hi = ( hi + Math . imul ( ah0 , bh7 ) ) | 0 ;
var w7 = ( ( ( c + lo ) | 0 ) + ( ( mid & 0x1fff ) << 13 ) ) | 0 ;
c = ( ( ( hi + ( mid >>> 13 ) ) | 0 ) + ( w7 >>> 26 ) ) | 0 ;
w7 &= 0x3ffffff ;
/* k = 8 */
lo = Math . imul ( al8 , bl0 ) ;
mid = Math . imul ( al8 , bh0 ) ;
mid = ( mid + Math . imul ( ah8 , bl0 ) ) | 0 ;
hi = Math . imul ( ah8 , bh0 ) ;
lo = ( lo + Math . imul ( al7 , bl1 ) ) | 0 ;
mid = ( mid + Math . imul ( al7 , bh1 ) ) | 0 ;
mid = ( mid + Math . imul ( ah7 , bl1 ) ) | 0 ;
hi = ( hi + Math . imul ( ah7 , bh1 ) ) | 0 ;
lo = ( lo + Math . imul ( al6 , bl2 ) ) | 0 ;
mid = ( mid + Math . imul ( al6 , bh2 ) ) | 0 ;
mid = ( mid + Math . imul ( ah6 , bl2 ) ) | 0 ;
hi = ( hi + Math . imul ( ah6 , bh2 ) ) | 0 ;
lo = ( lo + Math . imul ( al5 , bl3 ) ) | 0 ;
mid = ( mid + Math . imul ( al5 , bh3 ) ) | 0 ;
mid = ( mid + Math . imul ( ah5 , bl3 ) ) | 0 ;
hi = ( hi + Math . imul ( ah5 , bh3 ) ) | 0 ;
lo = ( lo + Math . imul ( al4 , bl4 ) ) | 0 ;
mid = ( mid + Math . imul ( al4 , bh4 ) ) | 0 ;
mid = ( mid + Math . imul ( ah4 , bl4 ) ) | 0 ;
hi = ( hi + Math . imul ( ah4 , bh4 ) ) | 0 ;
lo = ( lo + Math . imul ( al3 , bl5 ) ) | 0 ;
mid = ( mid + Math . imul ( al3 , bh5 ) ) | 0 ;
mid = ( mid + Math . imul ( ah3 , bl5 ) ) | 0 ;
hi = ( hi + Math . imul ( ah3 , bh5 ) ) | 0 ;
lo = ( lo + Math . imul ( al2 , bl6 ) ) | 0 ;
mid = ( mid + Math . imul ( al2 , bh6 ) ) | 0 ;
mid = ( mid + Math . imul ( ah2 , bl6 ) ) | 0 ;
hi = ( hi + Math . imul ( ah2 , bh6 ) ) | 0 ;
lo = ( lo + Math . imul ( al1 , bl7 ) ) | 0 ;
mid = ( mid + Math . imul ( al1 , bh7 ) ) | 0 ;
mid = ( mid + Math . imul ( ah1 , bl7 ) ) | 0 ;
hi = ( hi + Math . imul ( ah1 , bh7 ) ) | 0 ;
lo = ( lo + Math . imul ( al0 , bl8 ) ) | 0 ;
mid = ( mid + Math . imul ( al0 , bh8 ) ) | 0 ;
mid = ( mid + Math . imul ( ah0 , bl8 ) ) | 0 ;
hi = ( hi + Math . imul ( ah0 , bh8 ) ) | 0 ;
var w8 = ( ( ( c + lo ) | 0 ) + ( ( mid & 0x1fff ) << 13 ) ) | 0 ;
c = ( ( ( hi + ( mid >>> 13 ) ) | 0 ) + ( w8 >>> 26 ) ) | 0 ;
w8 &= 0x3ffffff ;
/* k = 9 */
lo = Math . imul ( al9 , bl0 ) ;
mid = Math . imul ( al9 , bh0 ) ;
mid = ( mid + Math . imul ( ah9 , bl0 ) ) | 0 ;
hi = Math . imul ( ah9 , bh0 ) ;
lo = ( lo + Math . imul ( al8 , bl1 ) ) | 0 ;
mid = ( mid + Math . imul ( al8 , bh1 ) ) | 0 ;
mid = ( mid + Math . imul ( ah8 , bl1 ) ) | 0 ;
hi = ( hi + Math . imul ( ah8 , bh1 ) ) | 0 ;
lo = ( lo + Math . imul ( al7 , bl2 ) ) | 0 ;
mid = ( mid + Math . imul ( al7 , bh2 ) ) | 0 ;
mid = ( mid + Math . imul ( ah7 , bl2 ) ) | 0 ;
hi = ( hi + Math . imul ( ah7 , bh2 ) ) | 0 ;
lo = ( lo + Math . imul ( al6 , bl3 ) ) | 0 ;
mid = ( mid + Math . imul ( al6 , bh3 ) ) | 0 ;
mid = ( mid + Math . imul ( ah6 , bl3 ) ) | 0 ;
hi = ( hi + Math . imul ( ah6 , bh3 ) ) | 0 ;
lo = ( lo + Math . imul ( al5 , bl4 ) ) | 0 ;
mid = ( mid + Math . imul ( al5 , bh4 ) ) | 0 ;
mid = ( mid + Math . imul ( ah5 , bl4 ) ) | 0 ;
hi = ( hi + Math . imul ( ah5 , bh4 ) ) | 0 ;
lo = ( lo + Math . imul ( al4 , bl5 ) ) | 0 ;
mid = ( mid + Math . imul ( al4 , bh5 ) ) | 0 ;
mid = ( mid + Math . imul ( ah4 , bl5 ) ) | 0 ;
hi = ( hi + Math . imul ( ah4 , bh5 ) ) | 0 ;
lo = ( lo + Math . imul ( al3 , bl6 ) ) | 0 ;
mid = ( mid + Math . imul ( al3 , bh6 ) ) | 0 ;
mid = ( mid + Math . imul ( ah3 , bl6 ) ) | 0 ;
hi = ( hi + Math . imul ( ah3 , bh6 ) ) | 0 ;
lo = ( lo + Math . imul ( al2 , bl7 ) ) | 0 ;
mid = ( mid + Math . imul ( al2 , bh7 ) ) | 0 ;
mid = ( mid + Math . imul ( ah2 , bl7 ) ) | 0 ;
hi = ( hi + Math . imul ( ah2 , bh7 ) ) | 0 ;
lo = ( lo + Math . imul ( al1 , bl8 ) ) | 0 ;
mid = ( mid + Math . imul ( al1 , bh8 ) ) | 0 ;
mid = ( mid + Math . imul ( ah1 , bl8 ) ) | 0 ;
hi = ( hi + Math . imul ( ah1 , bh8 ) ) | 0 ;
lo = ( lo + Math . imul ( al0 , bl9 ) ) | 0 ;
mid = ( mid + Math . imul ( al0 , bh9 ) ) | 0 ;
mid = ( mid + Math . imul ( ah0 , bl9 ) ) | 0 ;
hi = ( hi + Math . imul ( ah0 , bh9 ) ) | 0 ;
var w9 = ( ( ( c + lo ) | 0 ) + ( ( mid & 0x1fff ) << 13 ) ) | 0 ;
c = ( ( ( hi + ( mid >>> 13 ) ) | 0 ) + ( w9 >>> 26 ) ) | 0 ;
w9 &= 0x3ffffff ;
/* k = 10 */
lo = Math . imul ( al9 , bl1 ) ;
mid = Math . imul ( al9 , bh1 ) ;
mid = ( mid + Math . imul ( ah9 , bl1 ) ) | 0 ;
hi = Math . imul ( ah9 , bh1 ) ;
lo = ( lo + Math . imul ( al8 , bl2 ) ) | 0 ;
mid = ( mid + Math . imul ( al8 , bh2 ) ) | 0 ;
mid = ( mid + Math . imul ( ah8 , bl2 ) ) | 0 ;
hi = ( hi + Math . imul ( ah8 , bh2 ) ) | 0 ;
lo = ( lo + Math . imul ( al7 , bl3 ) ) | 0 ;
mid = ( mid + Math . imul ( al7 , bh3 ) ) | 0 ;
mid = ( mid + Math . imul ( ah7 , bl3 ) ) | 0 ;
hi = ( hi + Math . imul ( ah7 , bh3 ) ) | 0 ;
lo = ( lo + Math . imul ( al6 , bl4 ) ) | 0 ;
mid = ( mid + Math . imul ( al6 , bh4 ) ) | 0 ;
mid = ( mid + Math . imul ( ah6 , bl4 ) ) | 0 ;
hi = ( hi + Math . imul ( ah6 , bh4 ) ) | 0 ;
lo = ( lo + Math . imul ( al5 , bl5 ) ) | 0 ;
mid = ( mid + Math . imul ( al5 , bh5 ) ) | 0 ;
mid = ( mid + Math . imul ( ah5 , bl5 ) ) | 0 ;
hi = ( hi + Math . imul ( ah5 , bh5 ) ) | 0 ;
lo = ( lo + Math . imul ( al4 , bl6 ) ) | 0 ;
mid = ( mid + Math . imul ( al4 , bh6 ) ) | 0 ;
mid = ( mid + Math . imul ( ah4 , bl6 ) ) | 0 ;
hi = ( hi + Math . imul ( ah4 , bh6 ) ) | 0 ;
lo = ( lo + Math . imul ( al3 , bl7 ) ) | 0 ;
mid = ( mid + Math . imul ( al3 , bh7 ) ) | 0 ;
mid = ( mid + Math . imul ( ah3 , bl7 ) ) | 0 ;
hi = ( hi + Math . imul ( ah3 , bh7 ) ) | 0 ;
lo = ( lo + Math . imul ( al2 , bl8 ) ) | 0 ;
mid = ( mid + Math . imul ( al2 , bh8 ) ) | 0 ;
mid = ( mid + Math . imul ( ah2 , bl8 ) ) | 0 ;
hi = ( hi + Math . imul ( ah2 , bh8 ) ) | 0 ;
lo = ( lo + Math . imul ( al1 , bl9 ) ) | 0 ;
mid = ( mid + Math . imul ( al1 , bh9 ) ) | 0 ;
mid = ( mid + Math . imul ( ah1 , bl9 ) ) | 0 ;
hi = ( hi + Math . imul ( ah1 , bh9 ) ) | 0 ;
var w10 = ( ( ( c + lo ) | 0 ) + ( ( mid & 0x1fff ) << 13 ) ) | 0 ;
c = ( ( ( hi + ( mid >>> 13 ) ) | 0 ) + ( w10 >>> 26 ) ) | 0 ;
w10 &= 0x3ffffff ;
/* k = 11 */
lo = Math . imul ( al9 , bl2 ) ;
mid = Math . imul ( al9 , bh2 ) ;
mid = ( mid + Math . imul ( ah9 , bl2 ) ) | 0 ;
hi = Math . imul ( ah9 , bh2 ) ;
lo = ( lo + Math . imul ( al8 , bl3 ) ) | 0 ;
mid = ( mid + Math . imul ( al8 , bh3 ) ) | 0 ;
mid = ( mid + Math . imul ( ah8 , bl3 ) ) | 0 ;
hi = ( hi + Math . imul ( ah8 , bh3 ) ) | 0 ;
lo = ( lo + Math . imul ( al7 , bl4 ) ) | 0 ;
mid = ( mid + Math . imul ( al7 , bh4 ) ) | 0 ;
mid = ( mid + Math . imul ( ah7 , bl4 ) ) | 0 ;
hi = ( hi + Math . imul ( ah7 , bh4 ) ) | 0 ;
lo = ( lo + Math . imul ( al6 , bl5 ) ) | 0 ;
mid = ( mid + Math . imul ( al6 , bh5 ) ) | 0 ;
mid = ( mid + Math . imul ( ah6 , bl5 ) ) | 0 ;
hi = ( hi + Math . imul ( ah6 , bh5 ) ) | 0 ;
lo = ( lo + Math . imul ( al5 , bl6 ) ) | 0 ;
mid = ( mid + Math . imul ( al5 , bh6 ) ) | 0 ;
mid = ( mid + Math . imul ( ah5 , bl6 ) ) | 0 ;
hi = ( hi + Math . imul ( ah5 , bh6 ) ) | 0 ;
lo = ( lo + Math . imul ( al4 , bl7 ) ) | 0 ;
mid = ( mid + Math . imul ( al4 , bh7 ) ) | 0 ;
mid = ( mid + Math . imul ( ah4 , bl7 ) ) | 0 ;
hi = ( hi + Math . imul ( ah4 , bh7 ) ) | 0 ;
lo = ( lo + Math . imul ( al3 , bl8 ) ) | 0 ;
mid = ( mid + Math . imul ( al3 , bh8 ) ) | 0 ;
mid = ( mid + Math . imul ( ah3 , bl8 ) ) | 0 ;
hi = ( hi + Math . imul ( ah3 , bh8 ) ) | 0 ;
lo = ( lo + Math . imul ( al2 , bl9 ) ) | 0 ;
mid = ( mid + Math . imul ( al2 , bh9 ) ) | 0 ;
mid = ( mid + Math . imul ( ah2 , bl9 ) ) | 0 ;
hi = ( hi + Math . imul ( ah2 , bh9 ) ) | 0 ;
var w11 = ( ( ( c + lo ) | 0 ) + ( ( mid & 0x1fff ) << 13 ) ) | 0 ;
c = ( ( ( hi + ( mid >>> 13 ) ) | 0 ) + ( w11 >>> 26 ) ) | 0 ;
w11 &= 0x3ffffff ;
/* k = 12 */
lo = Math . imul ( al9 , bl3 ) ;
mid = Math . imul ( al9 , bh3 ) ;
mid = ( mid + Math . imul ( ah9 , bl3 ) ) | 0 ;
hi = Math . imul ( ah9 , bh3 ) ;
lo = ( lo + Math . imul ( al8 , bl4 ) ) | 0 ;
mid = ( mid + Math . imul ( al8 , bh4 ) ) | 0 ;
mid = ( mid + Math . imul ( ah8 , bl4 ) ) | 0 ;
hi = ( hi + Math . imul ( ah8 , bh4 ) ) | 0 ;
lo = ( lo + Math . imul ( al7 , bl5 ) ) | 0 ;
mid = ( mid + Math . imul ( al7 , bh5 ) ) | 0 ;
mid = ( mid + Math . imul ( ah7 , bl5 ) ) | 0 ;
hi = ( hi + Math . imul ( ah7 , bh5 ) ) | 0 ;
lo = ( lo + Math . imul ( al6 , bl6 ) ) | 0 ;
mid = ( mid + Math . imul ( al6 , bh6 ) ) | 0 ;
mid = ( mid + Math . imul ( ah6 , bl6 ) ) | 0 ;
hi = ( hi + Math . imul ( ah6 , bh6 ) ) | 0 ;
lo = ( lo + Math . imul ( al5 , bl7 ) ) | 0 ;
mid = ( mid + Math . imul ( al5 , bh7 ) ) | 0 ;
mid = ( mid + Math . imul ( ah5 , bl7 ) ) | 0 ;
hi = ( hi + Math . imul ( ah5 , bh7 ) ) | 0 ;
lo = ( lo + Math . imul ( al4 , bl8 ) ) | 0 ;
mid = ( mid + Math . imul ( al4 , bh8 ) ) | 0 ;
mid = ( mid + Math . imul ( ah4 , bl8 ) ) | 0 ;
hi = ( hi + Math . imul ( ah4 , bh8 ) ) | 0 ;
lo = ( lo + Math . imul ( al3 , bl9 ) ) | 0 ;
mid = ( mid + Math . imul ( al3 , bh9 ) ) | 0 ;
mid = ( mid + Math . imul ( ah3 , bl9 ) ) | 0 ;
hi = ( hi + Math . imul ( ah3 , bh9 ) ) | 0 ;
var w12 = ( ( ( c + lo ) | 0 ) + ( ( mid & 0x1fff ) << 13 ) ) | 0 ;
c = ( ( ( hi + ( mid >>> 13 ) ) | 0 ) + ( w12 >>> 26 ) ) | 0 ;
w12 &= 0x3ffffff ;
/* k = 13 */
lo = Math . imul ( al9 , bl4 ) ;
mid = Math . imul ( al9 , bh4 ) ;
mid = ( mid + Math . imul ( ah9 , bl4 ) ) | 0 ;
hi = Math . imul ( ah9 , bh4 ) ;
lo = ( lo + Math . imul ( al8 , bl5 ) ) | 0 ;
mid = ( mid + Math . imul ( al8 , bh5 ) ) | 0 ;
mid = ( mid + Math . imul ( ah8 , bl5 ) ) | 0 ;
hi = ( hi + Math . imul ( ah8 , bh5 ) ) | 0 ;
lo = ( lo + Math . imul ( al7 , bl6 ) ) | 0 ;
mid = ( mid + Math . imul ( al7 , bh6 ) ) | 0 ;
mid = ( mid + Math . imul ( ah7 , bl6 ) ) | 0 ;
hi = ( hi + Math . imul ( ah7 , bh6 ) ) | 0 ;
lo = ( lo + Math . imul ( al6 , bl7 ) ) | 0 ;
mid = ( mid + Math . imul ( al6 , bh7 ) ) | 0 ;
mid = ( mid + Math . imul ( ah6 , bl7 ) ) | 0 ;
hi = ( hi + Math . imul ( ah6 , bh7 ) ) | 0 ;
lo = ( lo + Math . imul ( al5 , bl8 ) ) | 0 ;
mid = ( mid + Math . imul ( al5 , bh8 ) ) | 0 ;
mid = ( mid + Math . imul ( ah5 , bl8 ) ) | 0 ;
hi = ( hi + Math . imul ( ah5 , bh8 ) ) | 0 ;
lo = ( lo + Math . imul ( al4 , bl9 ) ) | 0 ;
mid = ( mid + Math . imul ( al4 , bh9 ) ) | 0 ;
mid = ( mid + Math . imul ( ah4 , bl9 ) ) | 0 ;
hi = ( hi + Math . imul ( ah4 , bh9 ) ) | 0 ;
var w13 = ( ( ( c + lo ) | 0 ) + ( ( mid & 0x1fff ) << 13 ) ) | 0 ;
c = ( ( ( hi + ( mid >>> 13 ) ) | 0 ) + ( w13 >>> 26 ) ) | 0 ;
w13 &= 0x3ffffff ;
/* k = 14 */
lo = Math . imul ( al9 , bl5 ) ;
mid = Math . imul ( al9 , bh5 ) ;
mid = ( mid + Math . imul ( ah9 , bl5 ) ) | 0 ;
hi = Math . imul ( ah9 , bh5 ) ;
lo = ( lo + Math . imul ( al8 , bl6 ) ) | 0 ;
mid = ( mid + Math . imul ( al8 , bh6 ) ) | 0 ;
mid = ( mid + Math . imul ( ah8 , bl6 ) ) | 0 ;
hi = ( hi + Math . imul ( ah8 , bh6 ) ) | 0 ;
lo = ( lo + Math . imul ( al7 , bl7 ) ) | 0 ;
mid = ( mid + Math . imul ( al7 , bh7 ) ) | 0 ;
mid = ( mid + Math . imul ( ah7 , bl7 ) ) | 0 ;
hi = ( hi + Math . imul ( ah7 , bh7 ) ) | 0 ;
lo = ( lo + Math . imul ( al6 , bl8 ) ) | 0 ;
mid = ( mid + Math . imul ( al6 , bh8 ) ) | 0 ;
mid = ( mid + Math . imul ( ah6 , bl8 ) ) | 0 ;
hi = ( hi + Math . imul ( ah6 , bh8 ) ) | 0 ;
lo = ( lo + Math . imul ( al5 , bl9 ) ) | 0 ;
mid = ( mid + Math . imul ( al5 , bh9 ) ) | 0 ;
mid = ( mid + Math . imul ( ah5 , bl9 ) ) | 0 ;
hi = ( hi + Math . imul ( ah5 , bh9 ) ) | 0 ;
var w14 = ( ( ( c + lo ) | 0 ) + ( ( mid & 0x1fff ) << 13 ) ) | 0 ;
c = ( ( ( hi + ( mid >>> 13 ) ) | 0 ) + ( w14 >>> 26 ) ) | 0 ;
w14 &= 0x3ffffff ;
/* k = 15 */
lo = Math . imul ( al9 , bl6 ) ;
mid = Math . imul ( al9 , bh6 ) ;
mid = ( mid + Math . imul ( ah9 , bl6 ) ) | 0 ;
hi = Math . imul ( ah9 , bh6 ) ;
lo = ( lo + Math . imul ( al8 , bl7 ) ) | 0 ;
mid = ( mid + Math . imul ( al8 , bh7 ) ) | 0 ;
mid = ( mid + Math . imul ( ah8 , bl7 ) ) | 0 ;
hi = ( hi + Math . imul ( ah8 , bh7 ) ) | 0 ;
lo = ( lo + Math . imul ( al7 , bl8 ) ) | 0 ;
mid = ( mid + Math . imul ( al7 , bh8 ) ) | 0 ;
mid = ( mid + Math . imul ( ah7 , bl8 ) ) | 0 ;
hi = ( hi + Math . imul ( ah7 , bh8 ) ) | 0 ;
lo = ( lo + Math . imul ( al6 , bl9 ) ) | 0 ;
mid = ( mid + Math . imul ( al6 , bh9 ) ) | 0 ;
mid = ( mid + Math . imul ( ah6 , bl9 ) ) | 0 ;
hi = ( hi + Math . imul ( ah6 , bh9 ) ) | 0 ;
var w15 = ( ( ( c + lo ) | 0 ) + ( ( mid & 0x1fff ) << 13 ) ) | 0 ;
c = ( ( ( hi + ( mid >>> 13 ) ) | 0 ) + ( w15 >>> 26 ) ) | 0 ;
w15 &= 0x3ffffff ;
/* k = 16 */
lo = Math . imul ( al9 , bl7 ) ;
mid = Math . imul ( al9 , bh7 ) ;
mid = ( mid + Math . imul ( ah9 , bl7 ) ) | 0 ;
hi = Math . imul ( ah9 , bh7 ) ;
lo = ( lo + Math . imul ( al8 , bl8 ) ) | 0 ;
mid = ( mid + Math . imul ( al8 , bh8 ) ) | 0 ;
mid = ( mid + Math . imul ( ah8 , bl8 ) ) | 0 ;
hi = ( hi + Math . imul ( ah8 , bh8 ) ) | 0 ;
lo = ( lo + Math . imul ( al7 , bl9 ) ) | 0 ;
mid = ( mid + Math . imul ( al7 , bh9 ) ) | 0 ;
mid = ( mid + Math . imul ( ah7 , bl9 ) ) | 0 ;
hi = ( hi + Math . imul ( ah7 , bh9 ) ) | 0 ;
var w16 = ( ( ( c + lo ) | 0 ) + ( ( mid & 0x1fff ) << 13 ) ) | 0 ;
c = ( ( ( hi + ( mid >>> 13 ) ) | 0 ) + ( w16 >>> 26 ) ) | 0 ;
w16 &= 0x3ffffff ;
/* k = 17 */
lo = Math . imul ( al9 , bl8 ) ;
mid = Math . imul ( al9 , bh8 ) ;
mid = ( mid + Math . imul ( ah9 , bl8 ) ) | 0 ;
hi = Math . imul ( ah9 , bh8 ) ;
lo = ( lo + Math . imul ( al8 , bl9 ) ) | 0 ;
mid = ( mid + Math . imul ( al8 , bh9 ) ) | 0 ;
mid = ( mid + Math . imul ( ah8 , bl9 ) ) | 0 ;
hi = ( hi + Math . imul ( ah8 , bh9 ) ) | 0 ;
var w17 = ( ( ( c + lo ) | 0 ) + ( ( mid & 0x1fff ) << 13 ) ) | 0 ;
c = ( ( ( hi + ( mid >>> 13 ) ) | 0 ) + ( w17 >>> 26 ) ) | 0 ;
w17 &= 0x3ffffff ;
/* k = 18 */
lo = Math . imul ( al9 , bl9 ) ;
mid = Math . imul ( al9 , bh9 ) ;
mid = ( mid + Math . imul ( ah9 , bl9 ) ) | 0 ;
hi = Math . imul ( ah9 , bh9 ) ;
var w18 = ( ( ( c + lo ) | 0 ) + ( ( mid & 0x1fff ) << 13 ) ) | 0 ;
c = ( ( ( hi + ( mid >>> 13 ) ) | 0 ) + ( w18 >>> 26 ) ) | 0 ;
w18 &= 0x3ffffff ;
o [ 0 ] = w0 ;
o [ 1 ] = w1 ;
o [ 2 ] = w2 ;
o [ 3 ] = w3 ;
o [ 4 ] = w4 ;
o [ 5 ] = w5 ;
o [ 6 ] = w6 ;
o [ 7 ] = w7 ;
o [ 8 ] = w8 ;
o [ 9 ] = w9 ;
o [ 10 ] = w10 ;
o [ 11 ] = w11 ;
o [ 12 ] = w12 ;
o [ 13 ] = w13 ;
o [ 14 ] = w14 ;
o [ 15 ] = w15 ;
o [ 16 ] = w16 ;
o [ 17 ] = w17 ;
o [ 18 ] = w18 ;
if ( c !== 0 ) {
o [ 19 ] = c ;
out . length ++ ;
}
return out ;
} ;
// Polyfill comb
if ( ! Math . imul ) {
comb10MulTo = smallMulTo ;
}
function bigMulTo ( self , num , out ) {
out . negative = num . negative ^ self . negative ;
out . length = self . length + num . length ;
var carry = 0 ;
var hncarry = 0 ;
for ( var k = 0 ; k < out . length - 1 ; k ++ ) {
// Sum all words with the same `i + j = k` and accumulate `ncarry`,
// note that ncarry could be >= 0x3ffffff
var ncarry = hncarry ;
hncarry = 0 ;
var rword = carry & 0x3ffffff ;
var maxJ = Math . min ( k , num . length - 1 ) ;
for ( var j = Math . max ( 0 , k - self . length + 1 ) ; j <= maxJ ; j ++ ) {
var i = k - j ;
var a = self . words [ i ] | 0 ;
var b = num . words [ j ] | 0 ;
var r = a * b ;
var lo = r & 0x3ffffff ;
ncarry = ( ncarry + ( ( r / 0x4000000 ) | 0 ) ) | 0 ;
lo = ( lo + rword ) | 0 ;
rword = lo & 0x3ffffff ;
ncarry = ( ncarry + ( lo >>> 26 ) ) | 0 ;
hncarry += ncarry >>> 26 ;
ncarry &= 0x3ffffff ;
}
out . words [ k ] = rword ;
carry = ncarry ;
ncarry = hncarry ;
}
if ( carry !== 0 ) {
out . words [ k ] = carry ;
} else {
out . length -- ;
}
return out . strip ( ) ;
}
function jumboMulTo ( self , num , out ) {
var fftm = new FFTM ( ) ;
return fftm . mulp ( self , num , out ) ;
}
BN . prototype . mulTo = function mulTo ( num , out ) {
var res ;
var len = this . length + num . length ;
if ( this . length === 10 && num . length === 10 ) {
res = comb10MulTo ( this , num , out ) ;
} else if ( len < 63 ) {
res = smallMulTo ( this , num , out ) ;
} else if ( len < 1024 ) {
res = bigMulTo ( this , num , out ) ;
} else {
res = jumboMulTo ( this , num , out ) ;
}
return res ;
} ;
// Cooley-Tukey algorithm for FFT
// slightly revisited to rely on looping instead of recursion
function FFTM ( x , y ) {
this . x = x ;
this . y = y ;
}
FFTM . prototype . makeRBT = function makeRBT ( N ) {
var t = new Array ( N ) ;
var l = BN . prototype . _countBits ( N ) - 1 ;
for ( var i = 0 ; i < N ; i ++ ) {
t [ i ] = this . revBin ( i , l , N ) ;
}
return t ;
} ;
// Returns binary-reversed representation of `x`
FFTM . prototype . revBin = function revBin ( x , l , N ) {
if ( x === 0 || x === N - 1 ) return x ;
var rb = 0 ;
for ( var i = 0 ; i < l ; i ++ ) {
rb |= ( x & 1 ) << ( l - i - 1 ) ;
x >>= 1 ;
}
return rb ;
} ;
// Performs "tweedling" phase, therefore 'emulating'
// behaviour of the recursive algorithm
FFTM . prototype . permute = function permute ( rbt , rws , iws , rtws , itws , N ) {
for ( var i = 0 ; i < N ; i ++ ) {
rtws [ i ] = rws [ rbt [ i ] ] ;
itws [ i ] = iws [ rbt [ i ] ] ;
}
} ;
FFTM . prototype . transform = function transform ( rws , iws , rtws , itws , N , rbt ) {
this . permute ( rbt , rws , iws , rtws , itws , N ) ;
for ( var s = 1 ; s < N ; s <<= 1 ) {
var l = s << 1 ;
var rtwdf = Math . cos ( 2 * Math . PI / l ) ;
var itwdf = Math . sin ( 2 * Math . PI / l ) ;
for ( var p = 0 ; p < N ; p += l ) {
var rtwdf _ = rtwdf ;
var itwdf _ = itwdf ;
for ( var j = 0 ; j < s ; j ++ ) {
var re = rtws [ p + j ] ;
var ie = itws [ p + j ] ;
var ro = rtws [ p + j + s ] ;
var io = itws [ p + j + s ] ;
var rx = rtwdf _ * ro - itwdf _ * io ;
io = rtwdf _ * io + itwdf _ * ro ;
ro = rx ;
rtws [ p + j ] = re + ro ;
itws [ p + j ] = ie + io ;
rtws [ p + j + s ] = re - ro ;
itws [ p + j + s ] = ie - io ;
/* jshint maxdepth : false */
if ( j !== l ) {
rx = rtwdf * rtwdf _ - itwdf * itwdf _ ;
itwdf _ = rtwdf * itwdf _ + itwdf * rtwdf _ ;
rtwdf _ = rx ;
}
}
}
}
} ;
FFTM . prototype . guessLen13b = function guessLen13b ( n , m ) {
var N = Math . max ( m , n ) | 1 ;
var odd = N & 1 ;
var i = 0 ;
for ( N = N / 2 | 0 ; N ; N = N >>> 1 ) {
i ++ ;
}
return 1 << i + 1 + odd ;
} ;
FFTM . prototype . conjugate = function conjugate ( rws , iws , N ) {
if ( N <= 1 ) return ;
for ( var i = 0 ; i < N / 2 ; i ++ ) {
var t = rws [ i ] ;
rws [ i ] = rws [ N - i - 1 ] ;
rws [ N - i - 1 ] = t ;
t = iws [ i ] ;
iws [ i ] = - iws [ N - i - 1 ] ;
iws [ N - i - 1 ] = - t ;
}
} ;
FFTM . prototype . normalize13b = function normalize13b ( ws , N ) {
var carry = 0 ;
for ( var i = 0 ; i < N / 2 ; i ++ ) {
var w = Math . round ( ws [ 2 * i + 1 ] / N ) * 0x2000 +
Math . round ( ws [ 2 * i ] / N ) +
carry ;
ws [ i ] = w & 0x3ffffff ;
if ( w < 0x4000000 ) {
carry = 0 ;
} else {
carry = w / 0x4000000 | 0 ;
}
}
return ws ;
} ;
FFTM . prototype . convert13b = function convert13b ( ws , len , rws , N ) {
var carry = 0 ;
for ( var i = 0 ; i < len ; i ++ ) {
carry = carry + ( ws [ i ] | 0 ) ;
rws [ 2 * i ] = carry & 0x1fff ; carry = carry >>> 13 ;
rws [ 2 * i + 1 ] = carry & 0x1fff ; carry = carry >>> 13 ;
}
// Pad with zeroes
for ( i = 2 * len ; i < N ; ++ i ) {
rws [ i ] = 0 ;
}
assert ( carry === 0 ) ;
assert ( ( carry & ~ 0x1fff ) === 0 ) ;
} ;
FFTM . prototype . stub = function stub ( N ) {
var ph = new Array ( N ) ;
for ( var i = 0 ; i < N ; i ++ ) {
ph [ i ] = 0 ;
}
return ph ;
} ;
FFTM . prototype . mulp = function mulp ( x , y , out ) {
var N = 2 * this . guessLen13b ( x . length , y . length ) ;
var rbt = this . makeRBT ( N ) ;
var _ = this . stub ( N ) ;
var rws = new Array ( N ) ;
var rwst = new Array ( N ) ;
var iwst = new Array ( N ) ;
var nrws = new Array ( N ) ;
var nrwst = new Array ( N ) ;
var niwst = new Array ( N ) ;
var rmws = out . words ;
rmws . length = N ;
this . convert13b ( x . words , x . length , rws , N ) ;
this . convert13b ( y . words , y . length , nrws , N ) ;
this . transform ( rws , _ , rwst , iwst , N , rbt ) ;
this . transform ( nrws , _ , nrwst , niwst , N , rbt ) ;
for ( var i = 0 ; i < N ; i ++ ) {
var rx = rwst [ i ] * nrwst [ i ] - iwst [ i ] * niwst [ i ] ;
iwst [ i ] = rwst [ i ] * niwst [ i ] + iwst [ i ] * nrwst [ i ] ;
rwst [ i ] = rx ;
}
this . conjugate ( rwst , iwst , N ) ;
this . transform ( rwst , iwst , rmws , _ , N , rbt ) ;
this . conjugate ( rmws , _ , N ) ;
this . normalize13b ( rmws , N ) ;
out . negative = x . negative ^ y . negative ;
out . length = x . length + y . length ;
return out . strip ( ) ;
} ;
// Multiply `this` by `num`
BN . prototype . mul = function mul ( num ) {
var out = new BN ( null ) ;
out . words = new Array ( this . length + num . length ) ;
return this . mulTo ( num , out ) ;
} ;
// Multiply employing FFT
BN . prototype . mulf = function mulf ( num ) {
var out = new BN ( null ) ;
out . words = new Array ( this . length + num . length ) ;
return jumboMulTo ( this , num , out ) ;
} ;
// In-place Multiplication
BN . prototype . imul = function imul ( num ) {
return this . clone ( ) . mulTo ( num , this ) ;
} ;
BN . prototype . imuln = function imuln ( num ) {
assert ( typeof num === 'number' ) ;
assert ( num < 0x4000000 ) ;
// Carry
var carry = 0 ;
for ( var i = 0 ; i < this . length ; i ++ ) {
var w = ( this . words [ i ] | 0 ) * num ;
var lo = ( w & 0x3ffffff ) + ( carry & 0x3ffffff ) ;
carry >>= 26 ;
carry += ( w / 0x4000000 ) | 0 ;
// NOTE: lo is 27bit maximum
carry += lo >>> 26 ;
this . words [ i ] = lo & 0x3ffffff ;
}
if ( carry !== 0 ) {
this . words [ i ] = carry ;
this . length ++ ;
}
return this ;
} ;
BN . prototype . muln = function muln ( num ) {
return this . clone ( ) . imuln ( num ) ;
} ;
// `this` * `this`
BN . prototype . sqr = function sqr ( ) {
return this . mul ( this ) ;
} ;
// `this` * `this` in-place
BN . prototype . isqr = function isqr ( ) {
return this . imul ( this . clone ( ) ) ;
} ;
// Math.pow(`this`, `num`)
BN . prototype . pow = function pow ( num ) {
var w = toBitArray ( num ) ;
if ( w . length === 0 ) return new BN ( 1 ) ;
// Skip leading zeroes
var res = this ;
for ( var i = 0 ; i < w . length ; i ++ , res = res . sqr ( ) ) {
if ( w [ i ] !== 0 ) break ;
}
if ( ++ i < w . length ) {
for ( var q = res . sqr ( ) ; i < w . length ; i ++ , q = q . sqr ( ) ) {
if ( w [ i ] === 0 ) continue ;
res = res . mul ( q ) ;
}
}
return res ;
} ;
// Shift-left in-place
BN . prototype . iushln = function iushln ( bits ) {
assert ( typeof bits === 'number' && bits >= 0 ) ;
var r = bits % 26 ;
var s = ( bits - r ) / 26 ;
var carryMask = ( 0x3ffffff >>> ( 26 - r ) ) << ( 26 - r ) ;
var i ;
if ( r !== 0 ) {
var carry = 0 ;
for ( i = 0 ; i < this . length ; i ++ ) {
var newCarry = this . words [ i ] & carryMask ;
var c = ( ( this . words [ i ] | 0 ) - newCarry ) << r ;
this . words [ i ] = c | carry ;
carry = newCarry >>> ( 26 - r ) ;
}
if ( carry ) {
this . words [ i ] = carry ;
this . length ++ ;
}
}
if ( s !== 0 ) {
for ( i = this . length - 1 ; i >= 0 ; i -- ) {
this . words [ i + s ] = this . words [ i ] ;
}
for ( i = 0 ; i < s ; i ++ ) {
this . words [ i ] = 0 ;
}
this . length += s ;
}
return this . strip ( ) ;
} ;
BN . prototype . ishln = function ishln ( bits ) {
// TODO(indutny): implement me
assert ( this . negative === 0 ) ;
return this . iushln ( bits ) ;
} ;
// Shift-right in-place
// NOTE: `hint` is a lowest bit before trailing zeroes
// NOTE: if `extended` is present - it will be filled with destroyed bits
BN . prototype . iushrn = function iushrn ( bits , hint , extended ) {
assert ( typeof bits === 'number' && bits >= 0 ) ;
var h ;
if ( hint ) {
h = ( hint - ( hint % 26 ) ) / 26 ;
} else {
h = 0 ;
}
var r = bits % 26 ;
var s = Math . min ( ( bits - r ) / 26 , this . length ) ;
var mask = 0x3ffffff ^ ( ( 0x3ffffff >>> r ) << r ) ;
var maskedWords = extended ;
h -= s ;
h = Math . max ( 0 , h ) ;
// Extended mode, copy masked part
if ( maskedWords ) {
for ( var i = 0 ; i < s ; i ++ ) {
maskedWords . words [ i ] = this . words [ i ] ;
}
maskedWords . length = s ;
}
if ( s === 0 ) {
// No-op, we should not move anything at all
} else if ( this . length > s ) {
this . length -= s ;
for ( i = 0 ; i < this . length ; i ++ ) {
this . words [ i ] = this . words [ i + s ] ;
}
} else {
this . words [ 0 ] = 0 ;
this . length = 1 ;
}
var carry = 0 ;
for ( i = this . length - 1 ; i >= 0 && ( carry !== 0 || i >= h ) ; i -- ) {
var word = this . words [ i ] | 0 ;
this . words [ i ] = ( carry << ( 26 - r ) ) | ( word >>> r ) ;
carry = word & mask ;
}
// Push carried bits as a mask
if ( maskedWords && carry !== 0 ) {
maskedWords . words [ maskedWords . length ++ ] = carry ;
}
if ( this . length === 0 ) {
this . words [ 0 ] = 0 ;
this . length = 1 ;
}
return this . strip ( ) ;
} ;
BN . prototype . ishrn = function ishrn ( bits , hint , extended ) {
// TODO(indutny): implement me
assert ( this . negative === 0 ) ;
return this . iushrn ( bits , hint , extended ) ;
} ;
// Shift-left
BN . prototype . shln = function shln ( bits ) {
return this . clone ( ) . ishln ( bits ) ;
} ;
BN . prototype . ushln = function ushln ( bits ) {
return this . clone ( ) . iushln ( bits ) ;
} ;
// Shift-right
BN . prototype . shrn = function shrn ( bits ) {
return this . clone ( ) . ishrn ( bits ) ;
} ;
BN . prototype . ushrn = function ushrn ( bits ) {
return this . clone ( ) . iushrn ( bits ) ;
} ;
// Test if n bit is set
BN . prototype . testn = function testn ( bit ) {
assert ( typeof bit === 'number' && bit >= 0 ) ;
var r = bit % 26 ;
var s = ( bit - r ) / 26 ;
var q = 1 << r ;
// Fast case: bit is much higher than all existing words
if ( this . length <= s ) return false ;
// Check bit and return
var w = this . words [ s ] ;
return ! ! ( w & q ) ;
} ;
// Return only lowers bits of number (in-place)
BN . prototype . imaskn = function imaskn ( bits ) {
assert ( typeof bits === 'number' && bits >= 0 ) ;
var r = bits % 26 ;
var s = ( bits - r ) / 26 ;
assert ( this . negative === 0 , 'imaskn works only with positive numbers' ) ;
if ( this . length <= s ) {
return this ;
}
if ( r !== 0 ) {
s ++ ;
}
this . length = Math . min ( s , this . length ) ;
if ( r !== 0 ) {
var mask = 0x3ffffff ^ ( ( 0x3ffffff >>> r ) << r ) ;
this . words [ this . length - 1 ] &= mask ;
}
return this . strip ( ) ;
} ;
// Return only lowers bits of number
BN . prototype . maskn = function maskn ( bits ) {
return this . clone ( ) . imaskn ( bits ) ;
} ;
// Add plain number `num` to `this`
BN . prototype . iaddn = function iaddn ( num ) {
assert ( typeof num === 'number' ) ;
assert ( num < 0x4000000 ) ;
if ( num < 0 ) return this . isubn ( - num ) ;
// Possible sign change
if ( this . negative !== 0 ) {
if ( this . length === 1 && ( this . words [ 0 ] | 0 ) < num ) {
this . words [ 0 ] = num - ( this . words [ 0 ] | 0 ) ;
this . negative = 0 ;
return this ;
}
this . negative = 0 ;
this . isubn ( num ) ;
this . negative = 1 ;
return this ;
}
// Add without checks
return this . _iaddn ( num ) ;
} ;
BN . prototype . _iaddn = function _iaddn ( num ) {
this . words [ 0 ] += num ;
// Carry
for ( var i = 0 ; i < this . length && this . words [ i ] >= 0x4000000 ; i ++ ) {
this . words [ i ] -= 0x4000000 ;
if ( i === this . length - 1 ) {
this . words [ i + 1 ] = 1 ;
} else {
this . words [ i + 1 ] ++ ;
}
}
this . length = Math . max ( this . length , i + 1 ) ;
return this ;
} ;
// Subtract plain number `num` from `this`
BN . prototype . isubn = function isubn ( num ) {
assert ( typeof num === 'number' ) ;
assert ( num < 0x4000000 ) ;
if ( num < 0 ) return this . iaddn ( - num ) ;
if ( this . negative !== 0 ) {
this . negative = 0 ;
this . iaddn ( num ) ;
this . negative = 1 ;
return this ;
}
this . words [ 0 ] -= num ;
if ( this . length === 1 && this . words [ 0 ] < 0 ) {
this . words [ 0 ] = - this . words [ 0 ] ;
this . negative = 1 ;
} else {
// Carry
for ( var i = 0 ; i < this . length && this . words [ i ] < 0 ; i ++ ) {
this . words [ i ] += 0x4000000 ;
this . words [ i + 1 ] -= 1 ;
}
}
return this . strip ( ) ;
} ;
BN . prototype . addn = function addn ( num ) {
return this . clone ( ) . iaddn ( num ) ;
} ;
BN . prototype . subn = function subn ( num ) {
return this . clone ( ) . isubn ( num ) ;
} ;
BN . prototype . iabs = function iabs ( ) {
this . negative = 0 ;
return this ;
} ;
BN . prototype . abs = function abs ( ) {
return this . clone ( ) . iabs ( ) ;
} ;
BN . prototype . _ishlnsubmul = function _ishlnsubmul ( num , mul , shift ) {
var len = num . length + shift ;
var i ;
this . _expand ( len ) ;
var w ;
var carry = 0 ;
for ( i = 0 ; i < num . length ; i ++ ) {
w = ( this . words [ i + shift ] | 0 ) + carry ;
var right = ( num . words [ i ] | 0 ) * mul ;
w -= right & 0x3ffffff ;
carry = ( w >> 26 ) - ( ( right / 0x4000000 ) | 0 ) ;
this . words [ i + shift ] = w & 0x3ffffff ;
}
for ( ; i < this . length - shift ; i ++ ) {
w = ( this . words [ i + shift ] | 0 ) + carry ;
carry = w >> 26 ;
this . words [ i + shift ] = w & 0x3ffffff ;
}
if ( carry === 0 ) return this . strip ( ) ;
// Subtraction overflow
assert ( carry === - 1 ) ;
carry = 0 ;
for ( i = 0 ; i < this . length ; i ++ ) {
w = - ( this . words [ i ] | 0 ) + carry ;
carry = w >> 26 ;
this . words [ i ] = w & 0x3ffffff ;
}
this . negative = 1 ;
return this . strip ( ) ;
} ;
BN . prototype . _wordDiv = function _wordDiv ( num , mode ) {
var shift = this . length - num . length ;
var a = this . clone ( ) ;
var b = num ;
// Normalize
var bhi = b . words [ b . length - 1 ] | 0 ;
var bhiBits = this . _countBits ( bhi ) ;
shift = 26 - bhiBits ;
if ( shift !== 0 ) {
b = b . ushln ( shift ) ;
a . iushln ( shift ) ;
bhi = b . words [ b . length - 1 ] | 0 ;
}
// Initialize quotient
var m = a . length - b . length ;
var q ;
if ( mode !== 'mod' ) {
q = new BN ( null ) ;
q . length = m + 1 ;
q . words = new Array ( q . length ) ;
for ( var i = 0 ; i < q . length ; i ++ ) {
q . words [ i ] = 0 ;
}
}
var diff = a . clone ( ) . _ishlnsubmul ( b , 1 , m ) ;
if ( diff . negative === 0 ) {
a = diff ;
if ( q ) {
q . words [ m ] = 1 ;
}
}
for ( var j = m - 1 ; j >= 0 ; j -- ) {
var qj = ( a . words [ b . length + j ] | 0 ) * 0x4000000 +
( a . words [ b . length + j - 1 ] | 0 ) ;
// NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max
// (0x7ffffff)
qj = Math . min ( ( qj / bhi ) | 0 , 0x3ffffff ) ;
a . _ishlnsubmul ( b , qj , j ) ;
while ( a . negative !== 0 ) {
qj -- ;
a . negative = 0 ;
a . _ishlnsubmul ( b , 1 , j ) ;
if ( ! a . isZero ( ) ) {
a . negative ^= 1 ;
}
}
if ( q ) {
q . words [ j ] = qj ;
}
}
if ( q ) {
q . strip ( ) ;
}
a . strip ( ) ;
// Denormalize
if ( mode !== 'div' && shift !== 0 ) {
a . iushrn ( shift ) ;
}
return {
div : q || null ,
mod : a
} ;
} ;
// NOTE: 1) `mode` can be set to `mod` to request mod only,
// to `div` to request div only, or be absent to
// request both div & mod
// 2) `positive` is true if unsigned mod is requested
BN . prototype . divmod = function divmod ( num , mode , positive ) {
assert ( ! num . isZero ( ) ) ;
if ( this . isZero ( ) ) {
return {
div : new BN ( 0 ) ,
mod : new BN ( 0 )
} ;
}
var div , mod , res ;
if ( this . negative !== 0 && num . negative === 0 ) {
res = this . neg ( ) . divmod ( num , mode ) ;
if ( mode !== 'mod' ) {
div = res . div . neg ( ) ;
}
if ( mode !== 'div' ) {
mod = res . mod . neg ( ) ;
if ( positive && mod . negative !== 0 ) {
mod . iadd ( num ) ;
}
}
return {
div : div ,
mod : mod
} ;
}
if ( this . negative === 0 && num . negative !== 0 ) {
res = this . divmod ( num . neg ( ) , mode ) ;
if ( mode !== 'mod' ) {
div = res . div . neg ( ) ;
}
return {
div : div ,
mod : res . mod
} ;
}
if ( ( this . negative & num . negative ) !== 0 ) {
res = this . neg ( ) . divmod ( num . neg ( ) , mode ) ;
if ( mode !== 'div' ) {
mod = res . mod . neg ( ) ;
if ( positive && mod . negative !== 0 ) {
mod . isub ( num ) ;
}
}
return {
div : res . div ,
mod : mod
} ;
}
// Both numbers are positive at this point
// Strip both numbers to approximate shift value
if ( num . length > this . length || this . cmp ( num ) < 0 ) {
return {
div : new BN ( 0 ) ,
mod : this
} ;
}
// Very short reduction
if ( num . length === 1 ) {
if ( mode === 'div' ) {
return {
div : this . divn ( num . words [ 0 ] ) ,
mod : null
} ;
}
if ( mode === 'mod' ) {
return {
div : null ,
mod : new BN ( this . modn ( num . words [ 0 ] ) )
} ;
}
return {
div : this . divn ( num . words [ 0 ] ) ,
mod : new BN ( this . modn ( num . words [ 0 ] ) )
} ;
}
return this . _wordDiv ( num , mode ) ;
} ;
// Find `this` / `num`
BN . prototype . div = function div ( num ) {
return this . divmod ( num , 'div' , false ) . div ;
} ;
// Find `this` % `num`
BN . prototype . mod = function mod ( num ) {
return this . divmod ( num , 'mod' , false ) . mod ;
} ;
BN . prototype . umod = function umod ( num ) {
return this . divmod ( num , 'mod' , true ) . mod ;
} ;
// Find Round(`this` / `num`)
BN . prototype . divRound = function divRound ( num ) {
var dm = this . divmod ( num ) ;
// Fast case - exact division
if ( dm . mod . isZero ( ) ) return dm . div ;
var mod = dm . div . negative !== 0 ? dm . mod . isub ( num ) : dm . mod ;
var half = num . ushrn ( 1 ) ;
var r2 = num . andln ( 1 ) ;
var cmp = mod . cmp ( half ) ;
// Round down
if ( cmp < 0 || r2 === 1 && cmp === 0 ) return dm . div ;
// Round up
return dm . div . negative !== 0 ? dm . div . isubn ( 1 ) : dm . div . iaddn ( 1 ) ;
} ;
BN . prototype . modn = function modn ( num ) {
assert ( num <= 0x3ffffff ) ;
var p = ( 1 << 26 ) % num ;
var acc = 0 ;
for ( var i = this . length - 1 ; i >= 0 ; i -- ) {
acc = ( p * acc + ( this . words [ i ] | 0 ) ) % num ;
}
return acc ;
} ;
// In-place division by number
BN . prototype . idivn = function idivn ( num ) {
assert ( num <= 0x3ffffff ) ;
var carry = 0 ;
for ( var i = this . length - 1 ; i >= 0 ; i -- ) {
var w = ( this . words [ i ] | 0 ) + carry * 0x4000000 ;
this . words [ i ] = ( w / num ) | 0 ;
carry = w % num ;
}
return this . strip ( ) ;
} ;
BN . prototype . divn = function divn ( num ) {
return this . clone ( ) . idivn ( num ) ;
} ;
BN . prototype . egcd = function egcd ( p ) {
assert ( p . negative === 0 ) ;
assert ( ! p . isZero ( ) ) ;
var x = this ;
var y = p . clone ( ) ;
if ( x . negative !== 0 ) {
x = x . umod ( p ) ;
} else {
x = x . clone ( ) ;
}
// A * x + B * y = x
var A = new BN ( 1 ) ;
var B = new BN ( 0 ) ;
// C * x + D * y = y
var C = new BN ( 0 ) ;
var D = new BN ( 1 ) ;
var g = 0 ;
while ( x . isEven ( ) && y . isEven ( ) ) {
x . iushrn ( 1 ) ;
y . iushrn ( 1 ) ;
++ g ;
}
var yp = y . clone ( ) ;
var xp = x . clone ( ) ;
while ( ! x . isZero ( ) ) {
for ( var i = 0 , im = 1 ; ( x . words [ 0 ] & im ) === 0 && i < 26 ; ++ i , im <<= 1 ) ;
if ( i > 0 ) {
x . iushrn ( i ) ;
while ( i -- > 0 ) {
if ( A . isOdd ( ) || B . isOdd ( ) ) {
A . iadd ( yp ) ;
B . isub ( xp ) ;
}
A . iushrn ( 1 ) ;
B . iushrn ( 1 ) ;
}
}
for ( var j = 0 , jm = 1 ; ( y . words [ 0 ] & jm ) === 0 && j < 26 ; ++ j , jm <<= 1 ) ;
if ( j > 0 ) {
y . iushrn ( j ) ;
while ( j -- > 0 ) {
if ( C . isOdd ( ) || D . isOdd ( ) ) {
C . iadd ( yp ) ;
D . isub ( xp ) ;
}
C . iushrn ( 1 ) ;
D . iushrn ( 1 ) ;
}
}
if ( x . cmp ( y ) >= 0 ) {
x . isub ( y ) ;
A . isub ( C ) ;
B . isub ( D ) ;
} else {
y . isub ( x ) ;
C . isub ( A ) ;
D . isub ( B ) ;
}
}
return {
a : C ,
b : D ,
gcd : y . iushln ( g )
} ;
} ;
// This is reduced incarnation of the binary EEA
// above, designated to invert members of the
// _prime_ fields F(p) at a maximal speed
BN . prototype . _invmp = function _invmp ( p ) {
assert ( p . negative === 0 ) ;
assert ( ! p . isZero ( ) ) ;
var a = this ;
var b = p . clone ( ) ;
if ( a . negative !== 0 ) {
a = a . umod ( p ) ;
} else {
a = a . clone ( ) ;
}
var x1 = new BN ( 1 ) ;
var x2 = new BN ( 0 ) ;
var delta = b . clone ( ) ;
while ( a . cmpn ( 1 ) > 0 && b . cmpn ( 1 ) > 0 ) {
for ( var i = 0 , im = 1 ; ( a . words [ 0 ] & im ) === 0 && i < 26 ; ++ i , im <<= 1 ) ;
if ( i > 0 ) {
a . iushrn ( i ) ;
while ( i -- > 0 ) {
if ( x1 . isOdd ( ) ) {
x1 . iadd ( delta ) ;
}
x1 . iushrn ( 1 ) ;
}
}
for ( var j = 0 , jm = 1 ; ( b . words [ 0 ] & jm ) === 0 && j < 26 ; ++ j , jm <<= 1 ) ;
if ( j > 0 ) {
b . iushrn ( j ) ;
while ( j -- > 0 ) {
if ( x2 . isOdd ( ) ) {
x2 . iadd ( delta ) ;
}
x2 . iushrn ( 1 ) ;
}
}
if ( a . cmp ( b ) >= 0 ) {
a . isub ( b ) ;
x1 . isub ( x2 ) ;
} else {
b . isub ( a ) ;
x2 . isub ( x1 ) ;
}
}
var res ;
if ( a . cmpn ( 1 ) === 0 ) {
res = x1 ;
} else {
res = x2 ;
}
if ( res . cmpn ( 0 ) < 0 ) {
res . iadd ( p ) ;
}
return res ;
} ;
BN . prototype . gcd = function gcd ( num ) {
if ( this . isZero ( ) ) return num . abs ( ) ;
if ( num . isZero ( ) ) return this . abs ( ) ;
var a = this . clone ( ) ;
var b = num . clone ( ) ;
a . negative = 0 ;
b . negative = 0 ;
// Remove common factor of two
for ( var shift = 0 ; a . isEven ( ) && b . isEven ( ) ; shift ++ ) {
a . iushrn ( 1 ) ;
b . iushrn ( 1 ) ;
}
do {
while ( a . isEven ( ) ) {
a . iushrn ( 1 ) ;
}
while ( b . isEven ( ) ) {
b . iushrn ( 1 ) ;
}
var r = a . cmp ( b ) ;
if ( r < 0 ) {
// Swap `a` and `b` to make `a` always bigger than `b`
var t = a ;
a = b ;
b = t ;
} else if ( r === 0 || b . cmpn ( 1 ) === 0 ) {
break ;
}
a . isub ( b ) ;
} while ( true ) ;
return b . iushln ( shift ) ;
} ;
// Invert number in the field F(num)
BN . prototype . invm = function invm ( num ) {
return this . egcd ( num ) . a . umod ( num ) ;
} ;
BN . prototype . isEven = function isEven ( ) {
return ( this . words [ 0 ] & 1 ) === 0 ;
} ;
BN . prototype . isOdd = function isOdd ( ) {
return ( this . words [ 0 ] & 1 ) === 1 ;
} ;
// And first word and num
BN . prototype . andln = function andln ( num ) {
return this . words [ 0 ] & num ;
} ;
// Increment at the bit position in-line
BN . prototype . bincn = function bincn ( bit ) {
assert ( typeof bit === 'number' ) ;
var r = bit % 26 ;
var s = ( bit - r ) / 26 ;
var q = 1 << r ;
// Fast case: bit is much higher than all existing words
if ( this . length <= s ) {
this . _expand ( s + 1 ) ;
this . words [ s ] |= q ;
return this ;
}
// Add bit and propagate, if needed
var carry = q ;
for ( var i = s ; carry !== 0 && i < this . length ; i ++ ) {
var w = this . words [ i ] | 0 ;
w += carry ;
carry = w >>> 26 ;
w &= 0x3ffffff ;
this . words [ i ] = w ;
}
if ( carry !== 0 ) {
this . words [ i ] = carry ;
this . length ++ ;
}
return this ;
} ;
BN . prototype . isZero = function isZero ( ) {
return this . length === 1 && this . words [ 0 ] === 0 ;
} ;
BN . prototype . cmpn = function cmpn ( num ) {
var negative = num < 0 ;
if ( this . negative !== 0 && ! negative ) return - 1 ;
if ( this . negative === 0 && negative ) return 1 ;
this . strip ( ) ;
var res ;
if ( this . length > 1 ) {
res = 1 ;
} else {
if ( negative ) {
num = - num ;
}
assert ( num <= 0x3ffffff , 'Number is too big' ) ;
var w = this . words [ 0 ] | 0 ;
res = w === num ? 0 : w < num ? - 1 : 1 ;
}
if ( this . negative !== 0 ) return - res | 0 ;
return res ;
} ;
// Compare two numbers and return:
// 1 - if `this` > `num`
// 0 - if `this` == `num`
// -1 - if `this` < `num`
BN . prototype . cmp = function cmp ( num ) {
if ( this . negative !== 0 && num . negative === 0 ) return - 1 ;
if ( this . negative === 0 && num . negative !== 0 ) return 1 ;
var res = this . ucmp ( num ) ;
if ( this . negative !== 0 ) return - res | 0 ;
return res ;
} ;
// Unsigned comparison
BN . prototype . ucmp = function ucmp ( num ) {
// At this point both numbers have the same sign
if ( this . length > num . length ) return 1 ;
if ( this . length < num . length ) return - 1 ;
var res = 0 ;
for ( var i = this . length - 1 ; i >= 0 ; i -- ) {
var a = this . words [ i ] | 0 ;
var b = num . words [ i ] | 0 ;
if ( a === b ) continue ;
if ( a < b ) {
res = - 1 ;
} else if ( a > b ) {
res = 1 ;
}
break ;
}
return res ;
} ;
BN . prototype . gtn = function gtn ( num ) {
return this . cmpn ( num ) === 1 ;
} ;
BN . prototype . gt = function gt ( num ) {
return this . cmp ( num ) === 1 ;
} ;
BN . prototype . gten = function gten ( num ) {
return this . cmpn ( num ) >= 0 ;
} ;
BN . prototype . gte = function gte ( num ) {
return this . cmp ( num ) >= 0 ;
} ;
BN . prototype . ltn = function ltn ( num ) {
return this . cmpn ( num ) === - 1 ;
} ;
BN . prototype . lt = function lt ( num ) {
return this . cmp ( num ) === - 1 ;
} ;
BN . prototype . lten = function lten ( num ) {
return this . cmpn ( num ) <= 0 ;
} ;
BN . prototype . lte = function lte ( num ) {
return this . cmp ( num ) <= 0 ;
} ;
BN . prototype . eqn = function eqn ( num ) {
return this . cmpn ( num ) === 0 ;
} ;
BN . prototype . eq = function eq ( num ) {
return this . cmp ( num ) === 0 ;
} ;
//
// A reduce context, could be using montgomery or something better, depending
// on the `m` itself.
//
BN . red = function red ( num ) {
return new Red ( num ) ;
} ;
BN . prototype . toRed = function toRed ( ctx ) {
assert ( ! this . red , 'Already a number in reduction context' ) ;
assert ( this . negative === 0 , 'red works only with positives' ) ;
return ctx . convertTo ( this ) . _forceRed ( ctx ) ;
} ;
BN . prototype . fromRed = function fromRed ( ) {
assert ( this . red , 'fromRed works only with numbers in reduction context' ) ;
return this . red . convertFrom ( this ) ;
} ;
BN . prototype . _forceRed = function _forceRed ( ctx ) {
this . red = ctx ;
return this ;
} ;
BN . prototype . forceRed = function forceRed ( ctx ) {
assert ( ! this . red , 'Already a number in reduction context' ) ;
return this . _forceRed ( ctx ) ;
} ;
BN . prototype . redAdd = function redAdd ( num ) {
assert ( this . red , 'redAdd works only with red numbers' ) ;
return this . red . add ( this , num ) ;
} ;
BN . prototype . redIAdd = function redIAdd ( num ) {
assert ( this . red , 'redIAdd works only with red numbers' ) ;
return this . red . iadd ( this , num ) ;
} ;
BN . prototype . redSub = function redSub ( num ) {
assert ( this . red , 'redSub works only with red numbers' ) ;
return this . red . sub ( this , num ) ;
} ;
BN . prototype . redISub = function redISub ( num ) {
assert ( this . red , 'redISub works only with red numbers' ) ;
return this . red . isub ( this , num ) ;
} ;
BN . prototype . redShl = function redShl ( num ) {
assert ( this . red , 'redShl works only with red numbers' ) ;
return this . red . shl ( this , num ) ;
} ;
BN . prototype . redMul = function redMul ( num ) {
assert ( this . red , 'redMul works only with red numbers' ) ;
this . red . _verify2 ( this , num ) ;
return this . red . mul ( this , num ) ;
} ;
BN . prototype . redIMul = function redIMul ( num ) {
assert ( this . red , 'redMul works only with red numbers' ) ;
this . red . _verify2 ( this , num ) ;
return this . red . imul ( this , num ) ;
} ;
BN . prototype . redSqr = function redSqr ( ) {
assert ( this . red , 'redSqr works only with red numbers' ) ;
this . red . _verify1 ( this ) ;
return this . red . sqr ( this ) ;
} ;
BN . prototype . redISqr = function redISqr ( ) {
assert ( this . red , 'redISqr works only with red numbers' ) ;
this . red . _verify1 ( this ) ;
return this . red . isqr ( this ) ;
} ;
// Square root over p
BN . prototype . redSqrt = function redSqrt ( ) {
assert ( this . red , 'redSqrt works only with red numbers' ) ;
this . red . _verify1 ( this ) ;
return this . red . sqrt ( this ) ;
} ;
BN . prototype . redInvm = function redInvm ( ) {
assert ( this . red , 'redInvm works only with red numbers' ) ;
this . red . _verify1 ( this ) ;
return this . red . invm ( this ) ;
} ;
// Return negative clone of `this` % `red modulo`
BN . prototype . redNeg = function redNeg ( ) {
assert ( this . red , 'redNeg works only with red numbers' ) ;
this . red . _verify1 ( this ) ;
return this . red . neg ( this ) ;
} ;
BN . prototype . redPow = function redPow ( num ) {
assert ( this . red && ! num . red , 'redPow(normalNum)' ) ;
this . red . _verify1 ( this ) ;
return this . red . pow ( this , num ) ;
} ;
// Prime numbers with efficient reduction
var primes = {
k256 : null ,
p224 : null ,
p192 : null ,
p25519 : null
} ;
// Pseudo-Mersenne prime
function MPrime ( name , p ) {
// P = 2 ^ N - K
this . name = name ;
this . p = new BN ( p , 16 ) ;
this . n = this . p . bitLength ( ) ;
this . k = new BN ( 1 ) . iushln ( this . n ) . isub ( this . p ) ;
this . tmp = this . _tmp ( ) ;
}
MPrime . prototype . _tmp = function _tmp ( ) {
var tmp = new BN ( null ) ;
tmp . words = new Array ( Math . ceil ( this . n / 13 ) ) ;
return tmp ;
} ;
MPrime . prototype . ireduce = function ireduce ( num ) {
// Assumes that `num` is less than `P^2`
// num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)
var r = num ;
var rlen ;
do {
this . split ( r , this . tmp ) ;
r = this . imulK ( r ) ;
r = r . iadd ( this . tmp ) ;
rlen = r . bitLength ( ) ;
} while ( rlen > this . n ) ;
var cmp = rlen < this . n ? - 1 : r . ucmp ( this . p ) ;
if ( cmp === 0 ) {
r . words [ 0 ] = 0 ;
r . length = 1 ;
} else if ( cmp > 0 ) {
r . isub ( this . p ) ;
} else {
2021-09-04 19:00:24 -04:00
if ( r . strip !== undefined ) {
// r is BN v4 instance
r . strip ( ) ;
} else {
// r is BN v5 instance
r . _strip ( ) ;
}
2020-05-03 14:46:05 -04:00
}
return r ;
} ;
MPrime . prototype . split = function split ( input , out ) {
input . iushrn ( this . n , 0 , out ) ;
} ;
MPrime . prototype . imulK = function imulK ( num ) {
return num . imul ( this . k ) ;
} ;
function K256 ( ) {
MPrime . call (
this ,
'k256' ,
'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f' ) ;
}
inherits ( K256 , MPrime ) ;
K256 . prototype . split = function split ( input , output ) {
// 256 = 9 * 26 + 22
var mask = 0x3fffff ;
var outLen = Math . min ( input . length , 9 ) ;
for ( var i = 0 ; i < outLen ; i ++ ) {
output . words [ i ] = input . words [ i ] ;
}
output . length = outLen ;
if ( input . length <= 9 ) {
input . words [ 0 ] = 0 ;
input . length = 1 ;
return ;
}
// Shift by 9 limbs
var prev = input . words [ 9 ] ;
output . words [ output . length ++ ] = prev & mask ;
for ( i = 10 ; i < input . length ; i ++ ) {
var next = input . words [ i ] | 0 ;
input . words [ i - 10 ] = ( ( next & mask ) << 4 ) | ( prev >>> 22 ) ;
prev = next ;
}
prev >>>= 22 ;
input . words [ i - 10 ] = prev ;
if ( prev === 0 && input . length > 10 ) {
input . length -= 10 ;
} else {
input . length -= 9 ;
}
} ;
K256 . prototype . imulK = function imulK ( num ) {
// K = 0x1000003d1 = [ 0x40, 0x3d1 ]
num . words [ num . length ] = 0 ;
num . words [ num . length + 1 ] = 0 ;
num . length += 2 ;
// bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390
var lo = 0 ;
for ( var i = 0 ; i < num . length ; i ++ ) {
var w = num . words [ i ] | 0 ;
lo += w * 0x3d1 ;
num . words [ i ] = lo & 0x3ffffff ;
lo = w * 0x40 + ( ( lo / 0x4000000 ) | 0 ) ;
}
// Fast length reduction
if ( num . words [ num . length - 1 ] === 0 ) {
num . length -- ;
if ( num . words [ num . length - 1 ] === 0 ) {
num . length -- ;
}
}
return num ;
} ;
function P224 ( ) {
MPrime . call (
this ,
'p224' ,
'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001' ) ;
}
inherits ( P224 , MPrime ) ;
function P192 ( ) {
MPrime . call (
this ,
'p192' ,
'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff' ) ;
}
inherits ( P192 , MPrime ) ;
function P25519 ( ) {
// 2 ^ 255 - 19
MPrime . call (
this ,
'25519' ,
'7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed' ) ;
}
inherits ( P25519 , MPrime ) ;
P25519 . prototype . imulK = function imulK ( num ) {
// K = 0x13
var carry = 0 ;
for ( var i = 0 ; i < num . length ; i ++ ) {
var hi = ( num . words [ i ] | 0 ) * 0x13 + carry ;
var lo = hi & 0x3ffffff ;
hi >>>= 26 ;
num . words [ i ] = lo ;
carry = hi ;
}
if ( carry !== 0 ) {
num . words [ num . length ++ ] = carry ;
}
return num ;
} ;
// Exported mostly for testing purposes, use plain name instead
BN . _prime = function prime ( name ) {
// Cached version of prime
if ( primes [ name ] ) return primes [ name ] ;
var prime ;
if ( name === 'k256' ) {
prime = new K256 ( ) ;
} else if ( name === 'p224' ) {
prime = new P224 ( ) ;
} else if ( name === 'p192' ) {
prime = new P192 ( ) ;
} else if ( name === 'p25519' ) {
prime = new P25519 ( ) ;
} else {
throw new Error ( 'Unknown prime ' + name ) ;
}
primes [ name ] = prime ;
return prime ;
} ;
//
// Base reduction engine
//
function Red ( m ) {
if ( typeof m === 'string' ) {
var prime = BN . _prime ( m ) ;
this . m = prime . p ;
this . prime = prime ;
} else {
assert ( m . gtn ( 1 ) , 'modulus must be greater than 1' ) ;
this . m = m ;
this . prime = null ;
}
}
Red . prototype . _verify1 = function _verify1 ( a ) {
assert ( a . negative === 0 , 'red works only with positives' ) ;
assert ( a . red , 'red works only with red numbers' ) ;
} ;
Red . prototype . _verify2 = function _verify2 ( a , b ) {
assert ( ( a . negative | b . negative ) === 0 , 'red works only with positives' ) ;
assert ( a . red && a . red === b . red ,
'red works only with red numbers' ) ;
} ;
Red . prototype . imod = function imod ( a ) {
if ( this . prime ) return this . prime . ireduce ( a ) . _forceRed ( this ) ;
return a . umod ( this . m ) . _forceRed ( this ) ;
} ;
Red . prototype . neg = function neg ( a ) {
if ( a . isZero ( ) ) {
return a . clone ( ) ;
}
return this . m . sub ( a ) . _forceRed ( this ) ;
} ;
Red . prototype . add = function add ( a , b ) {
this . _verify2 ( a , b ) ;
var res = a . add ( b ) ;
if ( res . cmp ( this . m ) >= 0 ) {
res . isub ( this . m ) ;
}
return res . _forceRed ( this ) ;
} ;
Red . prototype . iadd = function iadd ( a , b ) {
this . _verify2 ( a , b ) ;
var res = a . iadd ( b ) ;
if ( res . cmp ( this . m ) >= 0 ) {
res . isub ( this . m ) ;
}
return res ;
} ;
Red . prototype . sub = function sub ( a , b ) {
this . _verify2 ( a , b ) ;
var res = a . sub ( b ) ;
if ( res . cmpn ( 0 ) < 0 ) {
res . iadd ( this . m ) ;
}
return res . _forceRed ( this ) ;
} ;
Red . prototype . isub = function isub ( a , b ) {
this . _verify2 ( a , b ) ;
var res = a . isub ( b ) ;
if ( res . cmpn ( 0 ) < 0 ) {
res . iadd ( this . m ) ;
}
return res ;
} ;
Red . prototype . shl = function shl ( a , num ) {
this . _verify1 ( a ) ;
return this . imod ( a . ushln ( num ) ) ;
} ;
Red . prototype . imul = function imul ( a , b ) {
this . _verify2 ( a , b ) ;
return this . imod ( a . imul ( b ) ) ;
} ;
Red . prototype . mul = function mul ( a , b ) {
this . _verify2 ( a , b ) ;
return this . imod ( a . mul ( b ) ) ;
} ;
Red . prototype . isqr = function isqr ( a ) {
return this . imul ( a , a . clone ( ) ) ;
} ;
Red . prototype . sqr = function sqr ( a ) {
return this . mul ( a , a ) ;
} ;
Red . prototype . sqrt = function sqrt ( a ) {
if ( a . isZero ( ) ) return a . clone ( ) ;
var mod3 = this . m . andln ( 3 ) ;
assert ( mod3 % 2 === 1 ) ;
// Fast case
if ( mod3 === 3 ) {
var pow = this . m . add ( new BN ( 1 ) ) . iushrn ( 2 ) ;
return this . pow ( a , pow ) ;
}
// Tonelli-Shanks algorithm (Totally unoptimized and slow)
//
// Find Q and S, that Q * 2 ^ S = (P - 1)
var q = this . m . subn ( 1 ) ;
var s = 0 ;
while ( ! q . isZero ( ) && q . andln ( 1 ) === 0 ) {
s ++ ;
q . iushrn ( 1 ) ;
}
assert ( ! q . isZero ( ) ) ;
var one = new BN ( 1 ) . toRed ( this ) ;
var nOne = one . redNeg ( ) ;
// Find quadratic non-residue
// NOTE: Max is such because of generalized Riemann hypothesis.
var lpow = this . m . subn ( 1 ) . iushrn ( 1 ) ;
var z = this . m . bitLength ( ) ;
z = new BN ( 2 * z * z ) . toRed ( this ) ;
while ( this . pow ( z , lpow ) . cmp ( nOne ) !== 0 ) {
z . redIAdd ( nOne ) ;
}
var c = this . pow ( z , q ) ;
var r = this . pow ( a , q . addn ( 1 ) . iushrn ( 1 ) ) ;
var t = this . pow ( a , q ) ;
var m = s ;
while ( t . cmp ( one ) !== 0 ) {
var tmp = t ;
for ( var i = 0 ; tmp . cmp ( one ) !== 0 ; i ++ ) {
tmp = tmp . redSqr ( ) ;
}
assert ( i < m ) ;
var b = this . pow ( c , new BN ( 1 ) . iushln ( m - i - 1 ) ) ;
r = r . redMul ( b ) ;
c = b . redSqr ( ) ;
t = t . redMul ( c ) ;
m = i ;
}
return r ;
} ;
Red . prototype . invm = function invm ( a ) {
var inv = a . _invmp ( this . m ) ;
if ( inv . negative !== 0 ) {
inv . negative = 0 ;
return this . imod ( inv ) . redNeg ( ) ;
} else {
return this . imod ( inv ) ;
}
} ;
Red . prototype . pow = function pow ( a , num ) {
if ( num . isZero ( ) ) return new BN ( 1 ) . toRed ( this ) ;
if ( num . cmpn ( 1 ) === 0 ) return a . clone ( ) ;
var windowSize = 4 ;
var wnd = new Array ( 1 << windowSize ) ;
wnd [ 0 ] = new BN ( 1 ) . toRed ( this ) ;
wnd [ 1 ] = a ;
for ( var i = 2 ; i < wnd . length ; i ++ ) {
wnd [ i ] = this . mul ( wnd [ i - 1 ] , a ) ;
}
var res = wnd [ 0 ] ;
var current = 0 ;
var currentLen = 0 ;
var start = num . bitLength ( ) % 26 ;
if ( start === 0 ) {
start = 26 ;
2021-09-04 19:00:24 -04:00
}
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
for ( i = num . length - 1 ; i >= 0 ; i -- ) {
var word = num . words [ i ] ;
for ( var j = start - 1 ; j >= 0 ; j -- ) {
var bit = ( word >> j ) & 1 ;
if ( res !== wnd [ 0 ] ) {
res = this . sqr ( res ) ;
2020-08-21 07:35:04 -04:00
}
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
if ( bit === 0 && current === 0 ) {
currentLen = 0 ;
continue ;
}
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
current <<= 1 ;
current |= bit ;
currentLen ++ ;
if ( currentLen !== windowSize && ( i !== 0 || j !== 0 ) ) continue ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
res = this . mul ( res , wnd [ current ] ) ;
currentLen = 0 ;
current = 0 ;
2020-09-06 16:03:16 -04:00
}
2021-09-04 19:00:24 -04:00
start = 26 ;
2020-09-06 16:03:16 -04:00
}
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
return res ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Red . prototype . convertTo = function convertTo ( num ) {
var r = num . umod ( this . m ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
return r === num ? r . clone ( ) : r ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
Red . prototype . convertFrom = function convertFrom ( num ) {
var res = num . clone ( ) ;
res . red = null ;
return res ;
} ;
2020-08-21 07:35:04 -04:00
2021-09-04 19:00:24 -04:00
//
// Montgomery method engine
//
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
BN . mont = function mont ( num ) {
return new Mont ( num ) ;
} ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
function Mont ( m ) {
Red . call ( this , m ) ;
2020-05-03 14:46:05 -04:00
2021-09-04 19:00:24 -04:00
this . shift = this . m . bitLength ( ) ;
if ( this . shift % 26 !== 0 ) {
this . shift += 26 - ( this . shift % 26 ) ;
}
2020-05-04 10:17:14 -04:00
2021-09-04 19:00:24 -04:00
this . r = new BN ( 1 ) . iushln ( this . shift ) ;
this . r2 = this . imod ( this . r . sqr ( ) ) ;
this . rinv = this . r . _invmp ( this . m ) ;
2020-08-21 07:35:04 -04:00
2021-09-04 19:00:24 -04:00
this . minv = this . rinv . mul ( this . r ) . isubn ( 1 ) . div ( this . m ) ;
this . minv = this . minv . umod ( this . r ) ;
this . minv = this . r . sub ( this . minv ) ;
}
inherits ( Mont , Red ) ;
2020-08-21 07:35:04 -04:00
2021-09-04 19:00:24 -04:00
Mont . prototype . convertTo = function convertTo ( num ) {
return this . imod ( num . ushln ( this . shift ) ) ;
} ;
2020-08-21 07:35:04 -04:00
2021-09-04 19:00:24 -04:00
Mont . prototype . convertFrom = function convertFrom ( num ) {
var r = this . imod ( num . mul ( this . rinv ) ) ;
r . red = null ;
return r ;
} ;
2020-08-21 07:35:04 -04:00
2021-09-04 19:00:24 -04:00
Mont . prototype . imul = function imul ( a , b ) {
if ( a . isZero ( ) || b . isZero ( ) ) {
a . words [ 0 ] = 0 ;
a . length = 1 ;
return a ;
}
2020-08-21 07:35:04 -04:00
2021-09-04 19:00:24 -04:00
var t = a . imul ( b ) ;
var c = t . maskn ( this . shift ) . mul ( this . minv ) . imaskn ( this . shift ) . mul ( this . m ) ;
var u = t . isub ( c ) . iushrn ( this . shift ) ;
var res = u ;
2020-08-21 07:35:04 -04:00
2021-09-04 19:00:24 -04:00
if ( u . cmp ( this . m ) >= 0 ) {
res = u . isub ( this . m ) ;
} else if ( u . cmpn ( 0 ) < 0 ) {
res = u . iadd ( this . m ) ;
}
2020-05-04 10:17:14 -04:00
2021-09-04 19:00:24 -04:00
return res . _forceRed ( this ) ;
} ;
2020-05-04 10:17:14 -04:00
2021-09-04 19:00:24 -04:00
Mont . prototype . mul = function mul ( a , b ) {
if ( a . isZero ( ) || b . isZero ( ) ) return new BN ( 0 ) . _forceRed ( this ) ;
2020-05-04 10:17:14 -04:00
2021-09-04 19:00:24 -04:00
var t = a . mul ( b ) ;
var c = t . maskn ( this . shift ) . mul ( this . minv ) . imaskn ( this . shift ) . mul ( this . m ) ;
var u = t . isub ( c ) . iushrn ( this . shift ) ;
var res = u ;
if ( u . cmp ( this . m ) >= 0 ) {
res = u . isub ( this . m ) ;
} else if ( u . cmpn ( 0 ) < 0 ) {
res = u . iadd ( this . m ) ;
}
2020-05-05 14:01:45 -04:00
2021-09-04 19:00:24 -04:00
return res . _forceRed ( this ) ;
} ;
2020-05-05 14:01:45 -04:00
2021-09-04 19:00:24 -04:00
Mont . prototype . invm = function invm ( a ) {
// (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R
var res = this . imod ( a . _invmp ( this . m ) . mul ( this . r2 ) ) ;
return res . _forceRed ( this ) ;
} ;
} ) ( false || module , this ) ;
2020-05-05 14:01:45 -04:00
2021-09-04 19:00:24 -04:00
/***/ } ) ,
2021-10-15 08:08:03 -04:00
/***/ 4124 :
2021-09-04 19:00:24 -04:00
/***/ ( ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) => {
2020-05-05 14:01:45 -04:00
2021-09-04 19:00:24 -04:00
try {
2021-10-15 08:08:03 -04:00
var util = _ _webpack _require _ _ ( 1669 ) ;
2021-09-04 19:00:24 -04:00
/* istanbul ignore next */
if ( typeof util . inherits !== 'function' ) throw '' ;
module . exports = util . inherits ;
} catch ( e ) {
/* istanbul ignore next */
2021-10-15 08:08:03 -04:00
module . exports = _ _webpack _require _ _ ( 8544 ) ;
2021-09-04 19:00:24 -04:00
}
2020-05-05 14:01:45 -04:00
2021-09-04 19:00:24 -04:00
/***/ } ) ,
2020-05-05 14:01:45 -04:00
2021-10-15 08:08:03 -04:00
/***/ 8544 :
2021-09-04 19:00:24 -04:00
/***/ ( ( module ) => {
if ( typeof Object . create === 'function' ) {
// implementation from standard node.js 'util' module
module . exports = function inherits ( ctor , superCtor ) {
if ( superCtor ) {
ctor . super _ = superCtor
ctor . prototype = Object . create ( superCtor . prototype , {
constructor : {
value : ctor ,
enumerable : false ,
writable : true ,
configurable : true
}
} )
2020-09-06 16:03:16 -04:00
}
2021-09-04 19:00:24 -04:00
} ;
} else {
// old school shim for old browsers
module . exports = function inherits ( ctor , superCtor ) {
if ( superCtor ) {
ctor . super _ = superCtor
var TempCtor = function ( ) { }
TempCtor . prototype = superCtor . prototype
ctor . prototype = new TempCtor ( )
ctor . prototype . constructor = ctor
2020-05-05 14:01:45 -04:00
}
2020-09-06 16:03:16 -04:00
}
2021-09-04 19:00:24 -04:00
}
2020-05-05 14:01:45 -04:00
2021-09-04 19:00:24 -04:00
/***/ } ) ,
2020-05-05 14:01:45 -04:00
2021-09-04 19:00:24 -04:00
/***/ 910 :
/***/ ( ( module ) => {
2020-05-05 14:01:45 -04:00
2021-09-04 19:00:24 -04:00
module . exports = assert ;
2020-05-05 14:01:45 -04:00
2021-09-04 19:00:24 -04:00
function assert ( val , msg ) {
if ( ! val )
throw new Error ( msg || 'Assertion failed' ) ;
}
2020-05-05 14:01:45 -04:00
2021-09-04 19:00:24 -04:00
assert . equal = function assertEqual ( l , r , msg ) {
if ( l != r )
throw new Error ( msg || ( 'Assertion failed: ' + l + ' != ' + r ) ) ;
} ;
2020-05-05 14:01:45 -04:00
2020-09-06 16:03:16 -04:00
2021-09-04 19:00:24 -04:00
/***/ } ) ,
2020-09-06 16:03:16 -04:00
2021-10-15 08:08:03 -04:00
/***/ 7946 :
2021-09-04 19:00:24 -04:00
/***/ ( ( _ _unused _webpack _module , exports , _ _webpack _require _ _ ) => {
2020-09-06 16:03:16 -04:00
2021-09-04 19:00:24 -04:00
"use strict" ;
/*! OpenPGP.js v5.0.0 - 2021-09-02 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
2021-10-15 08:08:03 -04:00
const e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : { } ; Object . defineProperty ( exports , "__esModule" , ( { value : ! 0 } ) ) ; var t = _ _webpack _require _ _ ( 4293 ) , r = _ _webpack _require _ _ ( 2413 ) , i = _ _webpack _require _ _ ( 6417 ) , n = _ _webpack _require _ _ ( 8761 ) , a = _ _webpack _require _ _ ( 2087 ) , s = _ _webpack _require _ _ ( 1669 ) , o = _ _webpack _require _ _ ( 5435 ) ; function c ( e ) { return e && "object" == typeof e && "default" in e ? e : { default : e } } var u = /*#__PURE__*/ c ( t ) , h = /*#__PURE__*/ c ( r ) , d = /*#__PURE__*/ c ( i ) , f = /*#__PURE__*/ c ( n ) , l = /*#__PURE__*/ c ( a ) , p = /*#__PURE__*/ c ( s ) , y = /*#__PURE__*/ c ( o ) ; const b = Symbol ( "doneWritingPromise" ) , m = Symbol ( "doneWritingResolve" ) , g = Symbol ( "doneWritingReject" ) ; class w extends Array { constructor ( ) { super ( ) , this [ b ] = new Promise ( ( ( e , t ) => { this [ m ] = e , this [ g ] = t } ) ) , this [ b ] . catch ( ( ( ) => { } ) ) } } function v ( e ) { return e && e . getReader && Array . isArray ( e ) } function _ ( e ) { if ( ! v ( e ) ) { const t = e . getWriter ( ) , r = t . releaseLock ; return t . releaseLock = ( ) => { t . closed . catch ( ( function ( ) { } ) ) , r . call ( t ) } , t } this . stream = e } w . prototype . getReader = function ( ) { return { read : async ( ) => ( await this [ b ] , this . length ? { value : this . shift ( ) , done : ! 1 } : { value : void 0 , done : ! 0 } ) } } , _ . prototype . write = async function ( e ) { this . stream . push ( e ) } , _ . prototype . close = async function ( ) { this . stream [ m ] ( ) } , _ . prototype . abort = async function ( e ) { return this . stream [ g ] ( e ) , e } , _ . prototype . releaseLock = function ( ) { } ; const k = "object" == typeof e . process && "object" == typeof e . process . versions , A = k && h . default . Readable ; function S ( t ) { return v ( t ) ? "array" : e . ReadableStream && e . ReadableStream . prototype . isPrototypeOf ( t ) ? "web" : T && T . prototype . isPrototypeOf ( t ) ? "ponyfill" : A && A . prototype . isPrototypeOf ( t ) ? "node" : ! ( ! t || ! t . getReader ) && "web-like" } function E ( e ) { return Uint8Array . prototype . isPrototypeOf ( e ) } function P ( e ) { if ( 1 === e . length ) return e [ 0 ] ; let t = 0 ; for ( let r = 0 ; r < e . length ; r ++ ) { if ( ! E ( e [ r ] ) ) throw Error ( "concatUint8Array: Data must be in the form of a Uint8Array" ) ; t += e [ r ] . length } const r = new Uint8Array ( t ) ; let i = 0 ; return e . forEach ( ( function ( e ) { r . set ( e , i ) , i += e . length } ) ) , r } const x = k && u . default . Buffer , M = k && h . default . Readable ; let C , K ; if ( M ) { C = function ( e ) { let t = ! 1 ; return new T ( { start ( r ) { e . pause ( ) , e . on ( "data" , ( i => { t || ( x . isBuffer ( i ) && ( i = new Uint8Array ( i . buffer , i . byteOffset , i . byteLength ) ) , r . enqueue ( i ) , e . pause ( ) ) } ) ) , e . on ( "end" , ( ( ) => { t || r . close ( ) } ) ) , e . on ( "error" , ( e => r . error ( e ) ) ) } , pull ( ) { e . resume ( ) } , cancel ( r ) { t = ! 0 , e . destroy ( r ) } } ) } ; class e extends M { constructor ( e , t ) { super ( t ) , this . _reader = W ( e ) } async _read ( e ) { try { for ( ; ; ) { const { done : e , value : t } = await this . _reader . read ( ) ; if ( e ) { this . push ( null ) ; break } if ( ! this . push ( t ) || this . _cancelling ) { this . _reading = ! 1 ; break } } } catch ( e ) { this . emit ( "error" , e ) } } _destroy ( e ) { this . _reader . cancel ( e ) } } K = function ( t , r ) { return new e ( t , r ) } } const D = new WeakSet , R = Symbol ( "externalBuffer" ) ; function I ( e ) { if ( this . stream = e , e [ R ] && ( this [ R ] = e [ R ] . slice ( ) ) , v ( e ) ) { const t = e . getReader ( ) ; return this . _read = t . read . bind ( t ) , this . _releaseLock = ( ) => { } , void ( this . _cancel = ( ) => { } ) } let t = S ( e ) ; if ( "node" === t && ( e = C ( e ) ) , t ) { const t = e . getReader ( ) ; return this . _read = t . read . bind ( t ) , this . _releaseLock = ( ) => { t . closed . catch ( ( function ( ) { } ) ) , t . releaseLock ( ) } , void ( this . _cancel = t . cancel . bind ( t ) ) } let r = ! 1 ; this . _read = async ( ) => r || D . has ( e ) ? { value : void 0 , done : ! 0 } : ( r = ! 0 , { value : e , done : ! 1 } ) , this . _releaseLock = ( ) => { if ( r ) try { D . add ( e ) } catch ( e ) { } } } I . prototype . read = async function ( ) { if ( this [ R ] && this [ R ] . length ) { return { done : ! 1 , value : this [ R ] . shift ( ) } } return this . _read ( ) } , I . prototype . releaseLock = function ( ) { this [ R ] && ( this . stream [ R ] = this [ R ] ) , this . _releaseLock ( ) } , I . prototype . cancel = function ( e ) { return this . _cancel ( e ) } , I . prototype . readLine = async function ( ) { let e , t = [ ] ; for ( ; ! e ; ) { let { done : r , value : i } = await this . read ( ) ; if ( i += "" , r ) return t . length ? L ( t ) : void 0 ; const n = i . indexOf ( "\n" ) + 1 ; n && ( e = L ( t . concat ( i . substr ( 0 , n ) ) ) , t = [ ] ) , n !== i . length && t . push ( i . substr ( n ) ) } return this . unshift ( ... t ) , e } , I . prototype . readByte = async function ( ) { const { done : e , value : t } = await this . read ( ) ; if ( e ) return ; const r = t [ 0 ] ; return this . unshift ( te ( t , 1 ) ) , r } , I . prototype . readBytes = async function ( e ) { const t = [ ] ; let r = 0 ; for ( ; ; ) { const { done : i , value : n } = await this . read ( ) ; if ( i ) return t . length ? L ( t ) : void 0 ; if ( t . push ( n ) , r += n . length , r >= e ) { const r = L ( t ) ; return thi
2021-09-04 19:00:24 -04:00
/ * ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Copyright ( c ) Microsoft Corporation .
2020-09-06 16:03:16 -04:00
2021-09-04 19:00:24 -04:00
Permission to use , copy , modify , and / or distribute this software for any
purpose with or without fee is hereby granted .
2020-05-05 14:01:45 -04:00
2021-09-04 19:00:24 -04:00
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS . IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL , DIRECT ,
INDIRECT , OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE , DATA OR PROFITS , WHETHER IN AN ACTION OF CONTRACT , NEGLIGENCE OR
OTHER TORTIOUS ACTION , ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / f u n c t i o n a f ( e , t ) { i f ( " f u n c t i o n " ! = t y p e o f t & & n u l l ! = = t ) t h r o w n e w T y p e E r r o r ( " C l a s s e x t e n d s v a l u e " + t + " i s n o t a c o n s t r u c t o r o r n u l l " ) ; f u n c t i o n r ( ) { t h i s . c o n s t r u c t o r = e } n f ( e , t ) , e . p r o t o t y p e = n u l l = = = t ? O b j e c t . c r e a t e ( t ) : ( r . p r o t o t y p e = t . p r o t o t y p e , n e w r ) } f u n c t i o n s f ( e ) { i f ( ! e ) t h r o w n e w T y p e E r r o r ( " A s s e r t i o n f a i l e d " ) } f u n c t i o n o f ( ) { } f u n c t i o n c f ( e ) { r e t u r n " o b j e c t " = = t y p e o f e & & n u l l ! = = e | | " f u n c t i o n " = = t y p e o f e } f u n c t i o n u f ( e ) { i f ( " f u n c t i o n " ! = t y p e o f e ) r e t u r n ! 1 ; v a r t = ! 1 ; t r y { n e w e ( { s t a r t : f u n c t i o n ( ) { t = ! 0 } } ) } c a t c h ( e ) { } r e t u r n t } f u n c t i o n h f ( e ) { r e t u r n ! ! c f ( e ) & & " f u n c t i o n " = = t y p e o f e . g e t R e a d e r } f u n c t i o n d f ( e ) { r e t u r n ! ! c f ( e ) & & " f u n c t i o n " = = t y p e o f e . g e t W r i t e r } f u n c t i o n f f ( e ) { r e t u r n ! ! c f ( e ) & & ( ! ! h f ( e . r e a d a b l e ) & & ! ! d f ( e . w r i t a b l e ) ) } f u n c t i o n l f ( e ) { t r y { r e t u r n e . g e t R e a d e r ( { m o d e : " b y o b " } ) . r e l e a s e L o c k ( ) , ! 0 } c a t c h ( e ) { r e t u r n ! 1 } } f u n c t i o n p f ( e , t ) { v a r r = ( v o i d 0 = = = t ? { } : t ) . t y p e ; r e t u r n s f ( h f ( e ) ) , s f ( ! 1 = = = e . l o c k e d ) , " b y t e s " = = = ( r = y f ( r ) ) ? n e w w f ( e ) : n e w m f ( e ) } f u n c t i o n y f ( e ) { v a r t = e + " " ; i f ( " b y t e s " = = = t ) r e t u r n t ; i f ( v o i d 0 = = = e ) r e t u r n e ; t h r o w n e w R a n g e E r r o r ( " I n v a l i d t y p e i s s p e c i f i e d " ) } v a r b f = f u n c t i o n ( ) { f u n c t i o n e ( e ) { t h i s . _ u n d e r l y i n g R e a d e r = v o i d 0 , t h i s . _ r e a d e r M o d e = v o i d 0 , t h i s . _ r e a d a b l e S t r e a m C o n t r o l l e r = v o i d 0 , t h i s . _ p e n d i n g R e a d = v o i d 0 , t h i s . _ u n d e r l y i n g S t r e a m = e , t h i s . _ a t t a c h D e f a u l t R e a d e r ( ) } r e t u r n e . p r o t o t y p e . s t a r t = f u n c t i o n ( e ) { t h i s . _ r e a d a b l e S t r e a m C o n t r o l l e r = e } , e . p r o t o t y p e . c a n c e l = f u n c t i o n ( e ) { r e t u r n s f ( v o i d 0 ! = = t h i s . _ u n d e r l y i n g R e a d e r ) , t h i s . _ u n d e r l y i n g R e a d e r . c a n c e l ( e ) } , e . p r o t o t y p e . _ a t t a c h D e f a u l t R e a d e r = f u n c t i o n ( ) { i f ( " d e f a u l t " ! = = t h i s . _ r e a d e r M o d e ) { t h i s . _ d e t a c h R e a d e r ( ) ; v a r e = t h i s . _ u n d e r l y i n g S t r e a m . g e t R e a d e r ( ) ; t h i s . _ r e a d e r M o d e = " d e f a u l t " , t h i s . _ a t t a c h R e a d e r ( e ) } } , e . p r o t o t y p e . _ a t t a c h R e a d e r = f u n c t i o n ( e ) { v a r t = t h i s ; s f ( v o i d 0 = = = t h i s . _ u n d e r l y i n g R e a d e r ) , t h i s . _ u n d e r l y i n g R e a d e r = e ; v a r r = t h i s . _ u n d e r l y i n g R e a d e r . c l o s e d ; r & & r . t h e n ( ( f u n c t i o n ( ) { r e t u r n t . _ f i n i s h P e n d i n g R e a d ( ) } ) ) . t h e n ( ( f u n c t i o n ( ) { e = = = t . _ u n d e r l y i n g R e a d e r & & t . _ r e a d a b l e S t r e a m C o n t r o l l e r . c l o s e ( ) } ) , ( f u n c t i o n ( r ) { e = = = t . _ u n d e r l y i n g R e a d e r & & t . _ r e a d a b l e S t r e a m C o n t r o l l e r . e r r o r ( r ) } ) ) . c a t c h ( o f ) } , e . p r o t o t y p e . _ d e t a c h R e a d e r = f u n c t i o n ( ) { v o i d 0 ! = = t h i s . _ u n d e r l y i n g R e a d e r & & ( t h i s . _ u n d e r l y i n g R e a d e r . r e l e a s e L o c k ( ) , t h i s . _ u n d e r l y i n g R e a d e r = v o i d 0 , t h i s . _ r e a d e r M o d e = v o i d 0 ) } , e . p r o t o t y p e . _ p u l l W i t h D e f a u l t R e a d e r = f u n c t i o n ( ) { v a r e = t h i s ; t h i s . _ a t t a c h D e f a u l t R e a d e r ( ) ; v a r t = t h i s . _ u n d e r l y i n g R e a d e r . r e a d ( ) . t h e n ( ( f u n c t i o n ( t ) { v a r r = e . _ r e a d a b l e S t r e a m C o n t r o l l e r ; t . d o n e ? e . _ t r y C l o s e ( ) : r . e n q u e u e ( t . v a l u e ) } ) ) ; r e t u r n t h i s . _ s e t P e n d i n g R e a d ( t ) , t } , e . p r o t o t y p e . _ t r y C l o s e = f u n c t i o n ( ) { t r y { t h i s . _ r e a d a b l e S t r e a m C o n t r o l l e r . c l o s e ( ) } c a t c h ( e ) { } } , e . p r o t o t y p e . _ s e t P e n d i n g R e a d = f u n c t i o n ( e ) { v a r t , r = t h i s , i = f u n c t i o n ( ) { r . _ p e n d i n g R e a d = = = t & & ( r . _ p e n d i n g R e a d = v o i d 0 ) } ; t h i s . _ p e n d i n g R e a d = t = e . t h e n ( i , i ) } , e . p r o t o t y p e . _ f i n i s h P e n d i n g R e a d = f u n c t i o n ( ) { v a r e = t h i s ; i f ( t h i s . _ p e n d i n g R e a d ) { v a r t = f u n c t i o n ( ) { r e t u r n e . _ f i n i s h P e n d i n g R e a d ( ) } ; r e t u r n t h i s . _ p e n d i n g R e a d . t h e n ( t , t ) } } , e } ( ) , m f = f u n c t i o n ( e ) { f u n c t i o n t ( ) { r e t u r n n u l l ! = = e & & e . a p p l y ( t h i s , a r g u m e n t s ) | | t h i s } r e t u r n a f ( t , e ) , t . p r o t o t y p e . p u l l = f u n c t i o n ( ) { r e t u r n t h i s . _ p u l l W i t h D e f a u l t R e a d e r ( ) } , t } ( b f ) ; f u n c t i o n g f ( e ) { r e t u r n n e w U i n t 8 A r r a y ( e . b u f f e r , e . b y t e O f f s e t , e . b y t e L e n g t h ) } v a r w f = f u n c t i o n ( e ) { f u n c t i o n t ( t ) { v a r r = t h i s , i = l f ( t ) ; r e t u r n ( r = e . c a l l ( t h i s , t ) | | t h i s ) . _ s u p p o r t s B y o b = i , r } r e t u r n a f ( t , e ) , O b j e c t . d e f i n e P r o p e r t y ( t . p r o t o t y p e , " t y p e " , { g e t : f u n c t i o n ( ) { r e t u r n " b y t e s " } , e n u m e r a b l e : ! 1 , c o n f i g u r a b l e : ! 0 } ) , t . p r o t o t y p e . _ a t t a c h B y o b R e a d e r = f u n c t i o n ( ) { i f ( " b y o b " ! = = t h i s . _ r e a d e r M o d e ) { s f ( t h i s . _ s u p p o r t s B y o b ) , t h i s . _ d e t a c h R e a d e r ( ) ; v a r e = t h i s . _ u n d e r l y i n g S t r e a m . g e t R e a d e r ( { m o d e : " b y o b " } ) ; t h i s . _ r e a d e r M o d e = " b y o b " , t h i s . _ a t t a c h R e a d e r ( e ) } } , t . p r o t o t y p e . p u l l = f u n c t i o n ( ) { i f ( t h i s . _ s u p p o r t s B y o b ) { v a r e = t h i s . _ r e a d a b l e S t r e a m C o n t r o l l e r . b y o b R e q u e s t ; i f ( e ) r e t u r n t h i s . _ p u l l W i t h B y o b R e q u e s t ( e ) } r e t u r n t h i s . _ p u l l W i t h D e f a u l t R e a d e r ( ) } , t . p r o t o t y p e . _ p u l l W i t h B y o b R e q u e s t = f u n c t i o n ( e ) { v a r t = t h i s ; t h i s . _ a t t a c h B y o b R e a d e r ( ) ; v a r r = n e w U i n t 8 A r r a y ( e . v i e w . b y t e L e n g t h ) , i = t h i s . _ u n d e r l y i n g R e a d e r . r e a d ( r ) . t h e n ( ( f u n c t i o n ( r ) { v a r i , n , a ; t . _ r e a d a b l e S t r e a m C o n t r o l l e r , r . d o n e ? ( t . _ t r y C l o s e ( ) , e . r e s p o n d ( 0 ) ) : ( i = r . v a l u e , n = e . v i e w , a = g f ( i ) , g f ( n ) . s e t ( a , 0 ) , e . r e s p o n d ( r . v a l u e . b y t e L e n g t h ) ) } ) ) ; r e t u r n t h i s . _ s e t P e n d i n g R e a d ( i ) , i } , t } ( b f ) ; f u n c t i o n v f ( e ) { s f ( d f ( e ) ) , s
//# sourceMappingURL=openpgp.min.js.map
2020-05-05 14:01:45 -04:00
2021-09-04 19:00:24 -04:00
/***/ } ) ,
2020-05-05 14:01:45 -04:00
2021-10-15 08:08:03 -04:00
/***/ 5118 :
2021-09-04 19:00:24 -04:00
/***/ ( ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) => {
2020-05-05 14:01:45 -04:00
2021-09-04 19:00:24 -04:00
"use strict" ;
/* eslint-disable node/no-deprecated-api */
2020-05-05 14:01:45 -04:00
2021-10-15 08:08:03 -04:00
var buffer = _ _webpack _require _ _ ( 4293 )
2021-09-04 19:00:24 -04:00
var Buffer = buffer . Buffer
2020-05-05 14:01:45 -04:00
2021-09-04 19:00:24 -04:00
var safer = { }
2020-05-05 14:01:45 -04:00
2021-09-04 19:00:24 -04:00
var key
2020-05-05 14:01:45 -04:00
2021-09-04 19:00:24 -04:00
for ( key in buffer ) {
if ( ! buffer . hasOwnProperty ( key ) ) continue
if ( key === 'SlowBuffer' || key === 'Buffer' ) continue
safer [ key ] = buffer [ key ]
}
2020-05-05 14:01:45 -04:00
2021-09-04 19:00:24 -04:00
var Safer = safer . Buffer = { }
for ( key in Buffer ) {
if ( ! Buffer . hasOwnProperty ( key ) ) continue
if ( key === 'allocUnsafe' || key === 'allocUnsafeSlow' ) continue
Safer [ key ] = Buffer [ key ]
}
2020-05-05 14:01:45 -04:00
2021-09-04 19:00:24 -04:00
safer . Buffer . prototype = Buffer . prototype
2020-05-05 14:01:45 -04:00
2021-09-04 19:00:24 -04:00
if ( ! Safer . from || Safer . from === Uint8Array . from ) {
Safer . from = function ( value , encodingOrOffset , length ) {
if ( typeof value === 'number' ) {
throw new TypeError ( 'The "value" argument must not be of type number. Received type ' + typeof value )
}
if ( value && typeof value . length === 'undefined' ) {
throw new TypeError ( 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type ' + typeof value )
2020-05-05 14:01:45 -04:00
}
2021-09-04 19:00:24 -04:00
return Buffer ( value , encodingOrOffset , length )
2020-09-06 16:03:16 -04:00
}
2021-09-04 19:00:24 -04:00
}
2020-05-05 14:01:45 -04:00
2021-09-04 19:00:24 -04:00
if ( ! Safer . alloc ) {
Safer . alloc = function ( size , fill , encoding ) {
if ( typeof size !== 'number' ) {
throw new TypeError ( 'The "size" argument must be of type number. Received type ' + typeof size )
}
if ( size < 0 || size >= 2 * ( 1 << 30 ) ) {
throw new RangeError ( 'The value "' + size + '" is invalid for option "size"' )
}
var buf = Buffer ( size )
if ( ! fill || fill . length === 0 ) {
buf . fill ( 0 )
} else if ( typeof encoding === 'string' ) {
buf . fill ( fill , encoding )
} else {
buf . fill ( fill )
}
return buf
}
}
2020-05-05 14:01:45 -04:00
2021-09-04 19:00:24 -04:00
if ( ! safer . kStringMaxLength ) {
try {
safer . kStringMaxLength = process . binding ( 'buffer' ) . kStringMaxLength
} catch ( e ) {
// we can't determine kStringMaxLength in environments where process.binding
// is unsupported, so let's not set it
}
}
2020-05-05 14:01:45 -04:00
2021-09-04 19:00:24 -04:00
if ( ! safer . constants ) {
safer . constants = {
MAX _LENGTH : safer . kMaxLength
}
if ( safer . kStringMaxLength ) {
safer . constants . MAX _STRING _LENGTH = safer . kStringMaxLength
}
}
2020-09-06 16:03:16 -04:00
2021-09-04 19:00:24 -04:00
module . exports = safer
2020-09-06 16:03:16 -04:00
2020-05-05 14:01:45 -04:00
2020-05-04 10:17:14 -04:00
/***/ } ) ,
2021-10-15 08:08:03 -04:00
/***/ 4294 :
/***/ ( ( module , _ _unused _webpack _exports , _ _webpack _require _ _ ) => {
module . exports = _ _webpack _require _ _ ( 4219 ) ;
/***/ } ) ,
/***/ 4219 :
/***/ ( ( _ _unused _webpack _module , exports , _ _webpack _require _ _ ) => {
"use strict" ;
var net = _ _webpack _require _ _ ( 1631 ) ;
var tls = _ _webpack _require _ _ ( 4016 ) ;
var http = _ _webpack _require _ _ ( 8605 ) ;
var https = _ _webpack _require _ _ ( 7211 ) ;
var events = _ _webpack _require _ _ ( 8614 ) ;
var assert = _ _webpack _require _ _ ( 2357 ) ;
var util = _ _webpack _require _ _ ( 1669 ) ;
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
}
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 ] ;
}
}
}
}
return target ;
}
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:' ) ;
}
console . error . apply ( console , args ) ;
}
} else {
debug = function ( ) { } ;
}
exports . debug = debug ; // for test
/***/ } ) ,
/***/ 2357 :
2020-09-06 16:03:16 -04:00
/***/ ( ( module ) => {
2020-05-04 10:17:14 -04:00
"use strict" ;
2020-09-06 16:03:16 -04:00
module . exports = require ( "assert" ) ;
2020-05-04 10:17:14 -04:00
2020-09-06 16:03:16 -04:00
/***/ } ) ,
2021-10-15 08:08:03 -04:00
/***/ 4293 :
2021-09-04 19:00:24 -04:00
/***/ ( ( module ) => {
"use strict" ;
module . exports = require ( "buffer" ) ;
/***/ } ) ,
2021-10-15 08:08:03 -04:00
/***/ 3129 :
2020-09-06 16:03:16 -04:00
/***/ ( ( module ) => {
"use strict" ;
module . exports = require ( "child_process" ) ;
/***/ } ) ,
2021-10-15 08:08:03 -04:00
/***/ 6417 :
2021-09-04 19:00:24 -04:00
/***/ ( ( module ) => {
"use strict" ;
module . exports = require ( "crypto" ) ;
/***/ } ) ,
2021-10-15 08:08:03 -04:00
/***/ 8614 :
2020-09-06 16:03:16 -04:00
/***/ ( ( module ) => {
"use strict" ;
module . exports = require ( "events" ) ;
/***/ } ) ,
2021-10-15 08:08:03 -04:00
/***/ 5747 :
2020-09-06 16:03:16 -04:00
/***/ ( ( module ) => {
"use strict" ;
module . exports = require ( "fs" ) ;
/***/ } ) ,
2021-10-15 08:08:03 -04:00
/***/ 8605 :
/***/ ( ( module ) => {
"use strict" ;
module . exports = require ( "http" ) ;
/***/ } ) ,
/***/ 7211 :
/***/ ( ( module ) => {
"use strict" ;
module . exports = require ( "https" ) ;
/***/ } ) ,
/***/ 1631 :
/***/ ( ( module ) => {
"use strict" ;
module . exports = require ( "net" ) ;
/***/ } ) ,
/***/ 2087 :
2020-09-06 16:03:16 -04:00
/***/ ( ( module ) => {
"use strict" ;
module . exports = require ( "os" ) ;
/***/ } ) ,
2021-10-15 08:08:03 -04:00
/***/ 5622 :
2020-09-06 16:03:16 -04:00
/***/ ( ( module ) => {
"use strict" ;
module . exports = require ( "path" ) ;
/***/ } ) ,
2021-10-15 08:08:03 -04:00
/***/ 2413 :
2021-09-04 19:00:24 -04:00
/***/ ( ( module ) => {
"use strict" ;
module . exports = require ( "stream" ) ;
/***/ } ) ,
2021-10-15 08:08:03 -04:00
/***/ 4304 :
2021-08-10 02:31:09 -04:00
/***/ ( ( module ) => {
"use strict" ;
module . exports = require ( "string_decoder" ) ;
/***/ } ) ,
2021-10-15 08:08:03 -04:00
/***/ 8213 :
2021-08-10 02:31:09 -04:00
/***/ ( ( module ) => {
"use strict" ;
module . exports = require ( "timers" ) ;
/***/ } ) ,
2021-10-15 08:08:03 -04:00
/***/ 4016 :
/***/ ( ( module ) => {
"use strict" ;
module . exports = require ( "tls" ) ;
/***/ } ) ,
/***/ 1669 :
2020-09-06 16:03:16 -04:00
/***/ ( ( module ) => {
"use strict" ;
module . exports = require ( "util" ) ;
2020-05-04 10:17:14 -04:00
2021-09-04 19:00:24 -04:00
/***/ } ) ,
2021-10-15 08:08:03 -04:00
/***/ 8761 :
2021-09-04 19:00:24 -04:00
/***/ ( ( module ) => {
"use strict" ;
module . exports = require ( "zlib" ) ;
2020-05-03 14:46:05 -04:00
/***/ } )
2020-09-06 16:03:16 -04:00
/******/ } ) ;
/************************************************************************/
/******/ // The module cache
/******/ var _ _webpack _module _cache _ _ = { } ;
/******/
/******/ // The require function
/******/ function _ _webpack _require _ _ ( moduleId ) {
/******/ // Check if module is in cache
/******/ if ( _ _webpack _module _cache _ _ [ moduleId ] ) {
/******/ return _ _webpack _module _cache _ _ [ moduleId ] . exports ;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = _ _webpack _module _cache _ _ [ moduleId ] = {
2021-09-04 19:00:24 -04:00
/******/ id : moduleId ,
/******/ loaded : false ,
2020-09-06 16:03:16 -04:00
/******/ exports : { }
/******/ } ;
/******/
/******/ // Execute the module function
/******/ var threw = true ;
/******/ try {
/******/ _ _webpack _modules _ _ [ moduleId ] . call ( module . exports , module , module . exports , _ _webpack _require _ _ ) ;
/******/ threw = false ;
/******/ } finally {
/******/ if ( threw ) delete _ _webpack _module _cache _ _ [ moduleId ] ;
/******/ }
/******/
2021-09-04 19:00:24 -04:00
/******/ // Flag the module as loaded
/******/ module . loaded = true ;
/******/
2020-09-06 16:03:16 -04:00
/******/ // Return the exports of the module
/******/ return module . exports ;
/******/ }
/******/
/************************************************************************/
2021-09-04 19:00:24 -04:00
/******/ /* webpack/runtime/node module decorator */
/******/ ( ( ) => {
/******/ _ _webpack _require _ _ . nmd = ( module ) => {
/******/ module . paths = [ ] ;
/******/ if ( ! module . children ) module . children = [ ] ;
/******/ return module ;
/******/ } ;
/******/ } ) ( ) ;
/******/
2020-09-06 16:03:16 -04:00
/******/ /* webpack/runtime/compat */
/******/
/******/ _ _webpack _require _ _ . ab = _ _dirname + "/" ; /************************************************************************/
/******/ // module exports must be returned from runtime so entry inlining is disabled
/******/ // startup
/******/ // Load entry module and return exports
2021-10-15 08:08:03 -04:00
/******/ return _ _webpack _require _ _ ( 3109 ) ;
2020-09-06 16:03:16 -04:00
/******/ } ) ( )
;