/
opt
/
canhelp
/
node_modules
/
google-auth-library
/
build
/
src
/
auth
/
/opt/canhelp/node_modules/google-auth-library/build/src/auth
mkdir
upload
Name
Size
Mode
Actions
authclient.d.ts
10764
0644
edit
dl
rm
authclient.js
11247
0644
edit
dl
rm
awsclient.d.ts
5315
0644
edit
dl
rm
awsclient.js
7556
0644
edit
dl
rm
awsrequestsigner.d.ts
1626
0644
edit
dl
rm
awsrequestsigner.js
9442
0644
edit
dl
rm
baseexternalclient.d.ts
13020
0644
edit
dl
rm
baseexternalclient.js
20857
0644
edit
dl
rm
certificatesubjecttokensupplier.d.ts
2202
0644
edit
dl
rm
certificatesubjecttokensupplier.js
10619
0644
edit
dl
rm
computeclient.d.ts
1359
0644
edit
dl
rm
computeclient.js
4497
0644
edit
dl
rm
credentials.d.ts
2359
0644
edit
dl
rm
credentials.js
704
0644
edit
dl
rm
defaultawssecuritycredentialssupplier.d.ts
3795
0644
edit
dl
rm
defaultawssecuritycredentialssupplier.js
9330
0644
edit
dl
rm
downscopedclient.d.ts
6693
0644
edit
dl
rm
downscopedclient.js
12353
0644
edit
dl
rm
envDetect.d.ts
363
0644
edit
dl
rm
envDetect.js
2831
0644
edit
dl
rm
executable-response.d.ts
4489
0644
edit
dl
rm
executable-response.js
7519
0644
edit
dl
rm
externalAccountAuthorizedUserClient.d.ts
3173
0644
edit
dl
rm
externalAccountAuthorizedUserClient.js
10005
0644
edit
dl
rm
externalclient.d.ts
1528
0644
edit
dl
rm
externalclient.js
3048
0644
edit
dl
rm
filesubjecttokensupplier.d.ts
1608
0644
edit
dl
rm
filesubjecttokensupplier.js
3515
0644
edit
dl
rm
googleauth.d.ts
23574
0644
edit
dl
rm
googleauth.js
36374
0644
edit
dl
rm
iam.d.ts
623
0644
edit
dl
rm
iam.js
1373
0644
edit
dl
rm
identitypoolclient.d.ts
5626
0644
edit
dl
rm
identitypoolclient.js
6775
0644
edit
dl
rm
idtokenclient.d.ts
938
0644
edit
dl
rm
idtokenclient.js
2106
0644
edit
dl
rm
impersonated.d.ts
5687
0644
edit
dl
rm
impersonated.js
8654
0644
edit
dl
rm
jwtaccess.d.ts
2336
0644
edit
dl
rm
jwtaccess.js
7213
0644
edit
dl
rm
jwtclient.d.ts
5122
0644
edit
dl
rm
jwtclient.js
11256
0644
edit
dl
rm
loginticket.d.ts
5367
0644
edit
dl
rm
loginticket.js
1795
0644
edit
dl
rm
oauth2client.d.ts
25326
0644
edit
dl
rm
oauth2client.js
33662
0644
edit
dl
rm
oauth2common.d.ts
4094
0644
edit
dl
rm
oauth2common.js
8080
0644
edit
dl
rm
passthrough.d.ts
1097
0644
edit
dl
rm
passthrough.js
1842
0644
edit
dl
rm
pluggable-auth-client.d.ts
5485
0644
edit
dl
rm
pluggable-auth-client.js
10002
0644
edit
dl
rm
pluggable-auth-handler.d.ts
2109
0644
edit
dl
rm
pluggable-auth-handler.js
7260
0644
edit
dl
rm
refreshclient.d.ts
3436
0644
edit
dl
rm
refreshclient.js
6650
0644
edit
dl
rm
stscredentials.d.ts
5261
0644
edit
dl
rm
stscredentials.js
4738
0644
edit
dl
rm
urlsubjecttokensupplier.d.ts
2186
0644
edit
dl
rm
urlsubjecttokensupplier.js
2859
0644
edit
dl
rm
Edit:
/opt/canhelp/node_modules/google-auth-library/build/src/auth/pluggable-auth-handler.js
(7260B)
"use strict"; // Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. Object.defineProperty(exports, "__esModule", { value: true }); exports.PluggableAuthHandler = exports.ExecutableError = void 0; const executable_response_1 = require("./executable-response"); const childProcess = require("child_process"); const fs = require("fs"); /** * Error thrown from the executable run by PluggableAuthClient. */ class ExecutableError extends Error { /** * The exit code returned by the executable. */ code; constructor(message, code) { super(`The executable failed with exit code: ${code} and error message: ${message}.`); this.code = code; Object.setPrototypeOf(this, new.target.prototype); } } exports.ExecutableError = ExecutableError; /** * A handler used to retrieve 3rd party token responses from user defined * executables and cached file output for the PluggableAuthClient class. */ class PluggableAuthHandler { commandComponents; timeoutMillis; outputFile; /** * Instantiates a PluggableAuthHandler instance using the provided * PluggableAuthHandlerOptions object. */ constructor(options) { if (!options.command) { throw new Error('No command provided.'); } this.commandComponents = PluggableAuthHandler.parseCommand(options.command); this.timeoutMillis = options.timeoutMillis; if (!this.timeoutMillis) { throw new Error('No timeoutMillis provided.'); } this.outputFile = options.outputFile; } /** * Calls user provided executable to get a 3rd party subject token and * returns the response. * @param envMap a Map of additional Environment Variables required for * the executable. * @return A promise that resolves with the executable response. */ retrieveResponseFromExecutable(envMap) { return new Promise((resolve, reject) => { // Spawn process to run executable using added environment variables. const child = childProcess.spawn(this.commandComponents[0], this.commandComponents.slice(1), { env: { ...process.env, ...Object.fromEntries(envMap) }, }); let output = ''; // Append stdout to output as executable runs. child.stdout.on('data', (data) => { output += data; }); // Append stderr as executable runs. child.stderr.on('data', (err) => { output += err; }); // Set up a timeout to end the child process and throw an error. const timeout = setTimeout(() => { // Kill child process and remove listeners so 'close' event doesn't get // read after child process is killed. child.removeAllListeners(); child.kill(); return reject(new Error('The executable failed to finish within the timeout specified.')); }, this.timeoutMillis); child.on('close', (code) => { // Cancel timeout if executable closes before timeout is reached. clearTimeout(timeout); if (code === 0) { // If the executable completed successfully, try to return the parsed response. try { const responseJson = JSON.parse(output); const response = new executable_response_1.ExecutableResponse(responseJson); return resolve(response); } catch (error) { if (error instanceof executable_response_1.ExecutableResponseError) { return reject(error); } return reject(new executable_response_1.ExecutableResponseError(`The executable returned an invalid response: ${output}`)); } } else { return reject(new ExecutableError(output, code.toString())); } }); }); } /** * Checks user provided output file for response from previous run of * executable and return the response if it exists, is formatted correctly, and is not expired. */ async retrieveCachedResponse() { if (!this.outputFile || this.outputFile.length === 0) { return undefined; } let filePath; try { filePath = await fs.promises.realpath(this.outputFile); } catch { // If file path cannot be resolved, return undefined. return undefined; } if (!(await fs.promises.lstat(filePath)).isFile()) { // If path does not lead to file, return undefined. return undefined; } const responseString = await fs.promises.readFile(filePath, { encoding: 'utf8', }); if (responseString === '') { return undefined; } try { const responseJson = JSON.parse(responseString); const response = new executable_response_1.ExecutableResponse(responseJson); // Check if response is successful and unexpired. if (response.isValid()) { return new executable_response_1.ExecutableResponse(responseJson); } return undefined; } catch (error) { if (error instanceof executable_response_1.ExecutableResponseError) { throw error; } throw new executable_response_1.ExecutableResponseError(`The output file contained an invalid response: ${responseString}`); } } /** * Parses given command string into component array, splitting on spaces unless * spaces are between quotation marks. */ static parseCommand(command) { // Split the command into components by splitting on spaces, // unless spaces are contained in quotation marks. const components = command.match(/(?:[^\s"]+|"[^"]*")+/g); if (!components) { throw new Error(`Provided command: "${command}" could not be parsed.`); } // Remove quotation marks from the beginning and end of each component if they are present. for (let i = 0; i < components.length; i++) { if (components[i][0] === '"' && components[i].slice(-1) === '"') { components[i] = components[i].slice(1, -1); } } return components; } } exports.PluggableAuthHandler = PluggableAuthHandler; //# sourceMappingURL=pluggable-auth-handler.js.map
Save
cmd:
run