@things-factory/auth-google 6.1.189 → 6.1.194
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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/auth-google",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.194",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "dist-client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@operato/graphql": "^1.0.0",
|
|
31
31
|
"@operato/shell": "^1.0.0",
|
|
32
|
-
"@things-factory/auth-base": "^6.1.
|
|
33
|
-
"@things-factory/shell": "^6.1.
|
|
32
|
+
"@things-factory/auth-base": "^6.1.194",
|
|
33
|
+
"@things-factory/shell": "^6.1.194",
|
|
34
34
|
"googleapis": "^126.0.1",
|
|
35
35
|
"passport": "^0.6.0",
|
|
36
36
|
"passport-google-oauth20": "^2.0.0"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "46a864f442dbad3b1eecadf8670a27c824eafc40"
|
|
39
39
|
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAccessToken = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
|
|
6
|
-
const authorityHostUrl = 'https://login.microsoftonline.com';
|
|
7
|
-
async function getAccessToken(authProvider) {
|
|
8
|
-
try {
|
|
9
|
-
const { clientId, clientSecret, tenantId } = authProvider;
|
|
10
|
-
const authorityUrl = `${authorityHostUrl}/${tenantId}`;
|
|
11
|
-
const resource = 'https://graph.microsoft.com';
|
|
12
|
-
const OAUTH2_URL = `${authorityUrl}/oauth2/token?api-version=1.0`;
|
|
13
|
-
const tokenResponse = await (0, node_fetch_1.default)(OAUTH2_URL, {
|
|
14
|
-
method: 'POST',
|
|
15
|
-
headers: {
|
|
16
|
-
'Content-Type': 'application/x-www-form-urlencoded'
|
|
17
|
-
},
|
|
18
|
-
body: `client_id=${clientId}&resource=${resource}&client_secret=${clientSecret}&grant_type=client_credentials`
|
|
19
|
-
});
|
|
20
|
-
const result = await tokenResponse.json();
|
|
21
|
-
const { access_token } = result;
|
|
22
|
-
return access_token;
|
|
23
|
-
}
|
|
24
|
-
catch (error) {
|
|
25
|
-
console.error('Error fetching access token:', error);
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
exports.getAccessToken = getAccessToken;
|
|
30
|
-
//# sourceMappingURL=get-access-token.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-access-token.js","sourceRoot":"","sources":["../../server/controllers/get-access-token.ts"],"names":[],"mappings":";;;;AAAA,oEAA8B;AAI9B,MAAM,gBAAgB,GAAG,mCAAmC,CAAA;AAErD,KAAK,UAAU,cAAc,CAAC,YAA0B;IAC7D,IAAI;QACF,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,YAAY,CAAA;QAEzD,MAAM,YAAY,GAAG,GAAG,gBAAgB,IAAI,QAAQ,EAAE,CAAA;QACtD,MAAM,QAAQ,GAAG,6BAA6B,CAAA;QAC9C,MAAM,UAAU,GAAG,GAAG,YAAY,+BAA+B,CAAA;QAEjE,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,QAAQ,aAAa,QAAQ,kBAAkB,YAAY,gCAAgC;SAC/G,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;AAvBD,wCAuBC","sourcesContent":["import fetch from 'node-fetch'\n\nimport { AuthProvider } from '@things-factory/auth-base'\n\nconst authorityHostUrl = 'https://login.microsoftonline.com'\n\nexport async function getAccessToken(authProvider: AuthProvider): Promise<string | null> {\n try {\n const { clientId, clientSecret, tenantId } = authProvider\n\n const authorityUrl = `${authorityHostUrl}/${tenantId}`\n const resource = 'https://graph.microsoft.com'\n const OAUTH2_URL = `${authorityUrl}/oauth2/token?api-version=1.0`\n\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=${clientId}&resource=${resource}&client_secret=${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"]}
|