@kwiz/node
Version:
KWIZ utilities and helpers for node applications
33 lines • 1.7 kB
JavaScript
;
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.getAxiosConfigGraph = exports.ConfigureGraphAuth = exports.graphScope = void 0;
const common_1 = require("@kwiz/common");
const msal_1 = require("../auth/msal");
const axios_1 = require("../axios");
/** "https://graph.microsoft.com" */
exports.graphScope = "https://graph.microsoft.com";
var auth = null;
function ConfigureGraphAuth(config) {
auth = config;
}
exports.ConfigureGraphAuth = ConfigureGraphAuth;
function getAxiosConfigGraph(tenantInfo, clearCache) {
return __awaiter(this, void 0, void 0, function* () {
if ((0, common_1.isNullOrUndefined)(auth))
throw Error("Call ConfigureGraphAuth first");
// secret or certificate supported
let token = yield (0, msal_1.GetMSALToken)(tenantInfo, exports.graphScope, auth, clearCache);
return (0, axios_1.getAxiosConfigBearer)(token);
});
}
exports.getAxiosConfigGraph = getAxiosConfigGraph;
//# sourceMappingURL=graph.js.map