"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getGoogleAccessToken = exports.googleRegex = void 0;
const google_auth_library_1 = require("google-auth-library");
const logger_1 = require("../../../logger");
const regex_1 = require("../../../util/regex");
const sanitize_1 = require("../../../util/sanitize");
exports.googleRegex = (0, regex_1.regEx)(/(((eu|us|asia)\.)?gcr\.io|[a-z0-9-]+-docker\.pkg\.dev)/);
async function getGoogleAccessToken() {
    const googleAuth = new google_auth_library_1.GoogleAuth({
        scopes: 'https://www.googleapis.com/auth/cloud-platform',
    });
    const accessToken = await googleAuth.getAccessToken();
    if (accessToken) {
        // sanitize token
        (0, sanitize_1.addSecretForSanitizing)(accessToken);
        return accessToken;
    }
    logger_1.logger.warn('Could not retrieve access token using google-auth-library getAccessToken');
    return null;
}
exports.getGoogleAccessToken = getGoogleAccessToken;
//# sourceMappingURL=google.js.map