@azure/identity
Version:
Provides credential implementations for Azure SDK libraries that can authenticate with Microsoft Entra ID
59 lines (58 loc) • 2.45 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var tokenExchangeMsi_exports = {};
__export(tokenExchangeMsi_exports, {
tokenExchangeMsi: () => tokenExchangeMsi
});
module.exports = __toCommonJS(tokenExchangeMsi_exports);
var import_workloadIdentityCredential = require("../workloadIdentityCredential.js");
var import_logging = require("../../util/logging.js");
const msiName = "ManagedIdentityCredential - Token Exchange";
const logger = (0, import_logging.credentialLogger)(msiName);
const tokenExchangeMsi = {
name: "tokenExchangeMsi",
async isAvailable(clientId) {
const env = process.env;
const result = Boolean(
(clientId || env.AZURE_CLIENT_ID) && env.AZURE_TENANT_ID && process.env.AZURE_FEDERATED_TOKEN_FILE
);
if (!result) {
logger.info(
`${msiName}: Unavailable. The environment variables needed are: AZURE_CLIENT_ID (or the client ID sent through the parameters), AZURE_TENANT_ID and AZURE_FEDERATED_TOKEN_FILE`
);
}
return result;
},
async getToken(configuration, getTokenOptions = {}) {
const { scopes, clientId } = configuration;
const identityClientTokenCredentialOptions = {};
const workloadIdentityCredential = new import_workloadIdentityCredential.WorkloadIdentityCredential({
clientId,
tenantId: process.env.AZURE_TENANT_ID,
tokenFilePath: process.env.AZURE_FEDERATED_TOKEN_FILE,
...identityClientTokenCredentialOptions,
disableInstanceDiscovery: true
});
return workloadIdentityCredential.getToken(scopes, getTokenOptions);
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
tokenExchangeMsi
});
//# sourceMappingURL=tokenExchangeMsi.js.map