@8ms/helpers 1.1.94 → 1.1.95
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.
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const post_1 = __importDefault(require("../../axios/post"));
|
|
7
|
+
const defaultTo_1 = __importDefault(require("../../util/defaultTo"));
|
|
7
8
|
global.deepcrawlGraphql = {
|
|
8
9
|
lastUpdated: null,
|
|
9
10
|
token: null,
|
|
@@ -17,17 +18,23 @@ const initClient = async ({ auth }) => {
|
|
|
17
18
|
// todo: Or was more than 6 hours ago
|
|
18
19
|
if (null === global.deepcrawlGraphql.token) {
|
|
19
20
|
const apiResponse = await (0, post_1.default)({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
data: {
|
|
22
|
+
query: "mutation LoginWithUserKey($secret: String!, $userKeyId: ObjectID!) { createSessionUsingUserKey(input: {userKeyId: $userKeyId, secret: $secret}) { token }}",
|
|
23
|
+
variables: {
|
|
24
|
+
userKeyId: auth.id,
|
|
25
|
+
secret: auth.secret,
|
|
24
26
|
},
|
|
25
27
|
},
|
|
26
|
-
url: `https://
|
|
28
|
+
url: `https://graph.deepcrawl.com/`,
|
|
29
|
+
});
|
|
30
|
+
const token = (0, defaultTo_1.default)({
|
|
31
|
+
defaultValue: null,
|
|
32
|
+
instance: apiResponse,
|
|
33
|
+
keys: ['data', 'data', 'createSessionUsingUserKey', 'token'],
|
|
27
34
|
});
|
|
28
35
|
// Ensure the value exists
|
|
29
|
-
if (
|
|
30
|
-
global.deepcrawlGraphql.token =
|
|
36
|
+
if (token) {
|
|
37
|
+
global.deepcrawlGraphql.token = token;
|
|
31
38
|
}
|
|
32
39
|
}
|
|
33
40
|
};
|