@things-factory/auth-azure-ad 6.1.178 → 6.1.180

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.
@@ -6,7 +6,7 @@ const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
6
6
  const env_1 = require("@things-factory/env");
7
7
  const SSOAzureADConfig = env_1.config.get('SSOAzureAD');
8
8
  const authorityHostUrl = 'https://login.microsoftonline.com';
9
- const authorityUrl = `${authorityHostUrl}/${SSOAzureADConfig.tenantID}`;
9
+ const authorityUrl = `${authorityHostUrl}/${SSOAzureADConfig === null || SSOAzureADConfig === void 0 ? void 0 : SSOAzureADConfig.tenantID}`;
10
10
  const resource = 'https://graph.microsoft.com';
11
11
  const OAUTH2_URL = `${authorityUrl}/oauth2/token?api-version=1.0`;
12
12
  async function getAccessToken() {
@@ -1 +1 @@
1
- {"version":3,"file":"get-access-token.js","sourceRoot":"","sources":["../../server/controllers/get-access-token.ts"],"names":[],"mappings":";;;;AAAA,oEAA8B;AAE9B,6CAA4C;AAE5C,MAAM,gBAAgB,GAAG,YAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;AAEjD,MAAM,gBAAgB,GAAG,mCAAmC,CAAA;AAC5D,MAAM,YAAY,GAAG,GAAG,gBAAgB,IAAI,gBAAgB,CAAC,QAAQ,EAAE,CAAA;AACvE,MAAM,QAAQ,GAAG,6BAA6B,CAAA;AAC9C,MAAM,UAAU,GAAG,GAAG,YAAY,+BAA+B,CAAA;AAE1D,KAAK,UAAU,cAAc;IAClC,IAAI;QACF,MAAM,aAAa,GAAG,MAAM,IAAA,oBAAK,EAAC,UAAU,EAAE;YAC5C,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,mCAAmC;aACpD;YACD,IAAI,EAAE,aAAa,gBAAgB,CAAC,QAAQ,aAAa,QAAQ,kBAAkB,gBAAgB,CAAC,YAAY,gCAAgC;SACjJ,CAAC,CAAA;QAEF,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,IAAI,EAAE,CAAA;QACzC,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,CAAA;QAC/B,OAAO,YAAY,CAAA;KACpB;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,KAAK,CAAC,CAAA;QACpD,OAAO,IAAI,CAAA;KACZ;AACH,CAAC;AAjBD,wCAiBC","sourcesContent":["import fetch from 'node-fetch'\n\nimport { config } from '@things-factory/env'\n\nconst SSOAzureADConfig = config.get('SSOAzureAD')\n\nconst authorityHostUrl = 'https://login.microsoftonline.com'\nconst authorityUrl = `${authorityHostUrl}/${SSOAzureADConfig.tenantID}`\nconst resource = 'https://graph.microsoft.com'\nconst OAUTH2_URL = `${authorityUrl}/oauth2/token?api-version=1.0`\n\nexport async function getAccessToken(): Promise<string | null> {\n try {\n const tokenResponse = await fetch(OAUTH2_URL, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded'\n },\n body: `client_id=${SSOAzureADConfig.clientID}&resource=${resource}&client_secret=${SSOAzureADConfig.clientSecret}&grant_type=client_credentials`\n })\n\n const result = await tokenResponse.json()\n const { access_token } = result\n return access_token\n } catch (error) {\n console.error('Error fetching access token:', error)\n return null\n }\n}\n"]}
1
+ {"version":3,"file":"get-access-token.js","sourceRoot":"","sources":["../../server/controllers/get-access-token.ts"],"names":[],"mappings":";;;;AAAA,oEAA8B;AAE9B,6CAA4C;AAE5C,MAAM,gBAAgB,GAAG,YAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;AAEjD,MAAM,gBAAgB,GAAG,mCAAmC,CAAA;AAC5D,MAAM,YAAY,GAAG,GAAG,gBAAgB,IAAI,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,QAAQ,EAAE,CAAA;AACxE,MAAM,QAAQ,GAAG,6BAA6B,CAAA;AAC9C,MAAM,UAAU,GAAG,GAAG,YAAY,+BAA+B,CAAA;AAE1D,KAAK,UAAU,cAAc;IAClC,IAAI;QACF,MAAM,aAAa,GAAG,MAAM,IAAA,oBAAK,EAAC,UAAU,EAAE;YAC5C,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,mCAAmC;aACpD;YACD,IAAI,EAAE,aAAa,gBAAgB,CAAC,QAAQ,aAAa,QAAQ,kBAAkB,gBAAgB,CAAC,YAAY,gCAAgC;SACjJ,CAAC,CAAA;QAEF,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,IAAI,EAAE,CAAA;QACzC,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,CAAA;QAC/B,OAAO,YAAY,CAAA;KACpB;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,KAAK,CAAC,CAAA;QACpD,OAAO,IAAI,CAAA;KACZ;AACH,CAAC;AAjBD,wCAiBC","sourcesContent":["import fetch from 'node-fetch'\n\nimport { config } from '@things-factory/env'\n\nconst SSOAzureADConfig = config.get('SSOAzureAD')\n\nconst authorityHostUrl = 'https://login.microsoftonline.com'\nconst authorityUrl = `${authorityHostUrl}/${SSOAzureADConfig?.tenantID}`\nconst resource = 'https://graph.microsoft.com'\nconst OAUTH2_URL = `${authorityUrl}/oauth2/token?api-version=1.0`\n\nexport async function getAccessToken(): Promise<string | null> {\n try {\n const tokenResponse = await fetch(OAUTH2_URL, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded'\n },\n body: `client_id=${SSOAzureADConfig.clientID}&resource=${resource}&client_secret=${SSOAzureADConfig.clientSecret}&grant_type=client_credentials`\n })\n\n const result = await tokenResponse.json()\n const { access_token } = result\n return access_token\n } catch (error) {\n console.error('Error fetching access token:', error)\n return null\n }\n}\n"]}