UNPKG

@kwiz/node

Version:

KWIZ utilities and helpers for node applications

34 lines 1.91 kB
"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.getAxiosConfigSharePoint = exports.ConfigureSPOAuth = void 0; const common_1 = require("@kwiz/common"); const msal_1 = require("../auth/msal"); const axios_1 = require("../axios"); var auth = null; function ConfigureSPOAuth(config) { auth = config; } exports.ConfigureSPOAuth = ConfigureSPOAuth; function getAxiosConfigSharePoint(tenantInfo, hostName, clearCache) { return __awaiter(this, void 0, void 0, function* () { if ((0, common_1.isNullOrUndefined)(auth)) throw Error("Call ConfigureSPOAuth first"); // only certificate supported // DisableCustomAppAuthentication property, that disable this kind of auth., however it can be overriden using this command: // Set-SPOTenant -DisableCustomAppAuthentication $false let token = yield (0, msal_1.GetMSALToken)(tenantInfo, (0, common_1.GetMSALSiteScope)(hostName), auth, clearCache); let config = (0, axios_1.getAxiosConfigBearer)(token, { contantType: "application/json; odata=nometadata" }); return config; }); } exports.getAxiosConfigSharePoint = getAxiosConfigSharePoint; //# sourceMappingURL=common.js.map