@kwiz/node 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,4 @@
1
1
  export * from './auth/exports-index';
2
+ export * from './graph/exports-index';
2
3
  export * from './spo/exports-index';
3
4
  export * from './axios';
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./auth/exports-index"), exports);
18
+ __exportStar(require("./graph/exports-index"), exports);
18
19
  __exportStar(require("./spo/exports-index"), exports);
19
20
  __exportStar(require("./axios"), exports);
20
21
  //# sourceMappingURL=exports-index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"exports-index.js","sourceRoot":"","sources":["../src/exports-index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,sDAAoC;AACpC,0CAAwB"}
1
+ {"version":3,"file":"exports-index.js","sourceRoot":"","sources":["../src/exports-index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,wDAAsC;AACtC,sDAAoC;AACpC,0CAAwB"}
@@ -0,0 +1 @@
1
+ export * from './graph';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./graph"), exports);
18
+ //# sourceMappingURL=exports-index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exports-index.js","sourceRoot":"","sources":["../../src/graph/exports-index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB"}
@@ -0,0 +1,5 @@
1
+ import { AuthContextType, ITenantInfo } from "@kwiz/common";
2
+ /** "https://graph.microsoft.com" */
3
+ export declare const graphScope = "https://graph.microsoft.com";
4
+ export declare function ConfigureGraphAuth(config?: AuthContextType): void;
5
+ export declare function getAxiosConfigGraph(tenantInfo: ITenantInfo): Promise<import("axios").AxiosRequestConfig<any>>;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getAxiosConfigGraph = exports.ConfigureGraphAuth = exports.graphScope = void 0;
13
+ const common_1 = require("@kwiz/common");
14
+ const msal_1 = require("../auth/msal");
15
+ const axios_1 = require("../axios");
16
+ /** "https://graph.microsoft.com" */
17
+ exports.graphScope = "https://graph.microsoft.com";
18
+ var auth = null;
19
+ function ConfigureGraphAuth(config) {
20
+ auth = config;
21
+ }
22
+ exports.ConfigureGraphAuth = ConfigureGraphAuth;
23
+ function getAxiosConfigGraph(tenantInfo) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ if ((0, common_1.isNullOrUndefined)(auth))
26
+ throw Error("Call ConfigureGraphAuth first");
27
+ // secret or certificate supported
28
+ let token = yield (0, msal_1.GetMSALToken)(tenantInfo, exports.graphScope, auth);
29
+ return (0, axios_1.getAxiosConfigBearer)(token);
30
+ });
31
+ }
32
+ exports.getAxiosConfigGraph = getAxiosConfigGraph;
33
+ //# sourceMappingURL=graph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph.js","sourceRoot":"","sources":["../../src/graph/graph.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAA+E;AAC/E,uCAA4C;AAC5C,oCAAgD;AAEhD,oCAAoC;AACvB,QAAA,UAAU,GAAG,6BAA6B,CAAC;AAExD,IAAI,IAAI,GAAoB,IAAI,CAAC;AACjC,SAAgB,kBAAkB,CAAC,MAAwB;IACvD,IAAI,GAAG,MAAM,CAAC;AAClB,CAAC;AAFD,gDAEC;AACD,SAAsB,mBAAmB,CAAC,UAAuB;;QAC7D,IAAI,IAAA,0BAAiB,EAAC,IAAI,CAAC;YAAE,MAAM,KAAK,CAAC,+BAA+B,CAAC,CAAC;QAE1E,kCAAkC;QAClC,IAAI,KAAK,GAAG,MAAM,IAAA,mBAAY,EAAC,UAAU,EAAE,kBAAU,EAAE,IAAI,CAAC,CAAC;QAC7D,OAAO,IAAA,4BAAoB,EAAC,KAAK,CAAC,CAAC;IACvC,CAAC;CAAA;AAND,kDAMC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kwiz/node",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "KWIZ utilities and helpers for node applications",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,3 +1,4 @@
1
1
  export * from './auth/exports-index';
2
+ export * from './graph/exports-index';
2
3
  export * from './spo/exports-index';
3
4
  export * from './axios';
@@ -0,0 +1 @@
1
+ export * from './graph';
@@ -0,0 +1,18 @@
1
+ import { AuthContextType, ITenantInfo, isNullOrUndefined } from "@kwiz/common";
2
+ import { GetMSALToken } from "../auth/msal";
3
+ import { getAxiosConfigBearer } from "../axios";
4
+
5
+ /** "https://graph.microsoft.com" */
6
+ export const graphScope = "https://graph.microsoft.com";
7
+
8
+ var auth: AuthContextType = null;
9
+ export function ConfigureGraphAuth(config?: AuthContextType) {
10
+ auth = config;
11
+ }
12
+ export async function getAxiosConfigGraph(tenantInfo: ITenantInfo) {
13
+ if (isNullOrUndefined(auth)) throw Error("Call ConfigureGraphAuth first");
14
+
15
+ // secret or certificate supported
16
+ let token = await GetMSALToken(tenantInfo, graphScope, auth);
17
+ return getAxiosConfigBearer(token);
18
+ }