@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.
@@ -1,7 +1,7 @@
1
1
  declare type InitClient = {
2
2
  auth: {
3
- apiId: string;
4
- apiKey: string;
3
+ id: string;
4
+ secret: string;
5
5
  };
6
6
  };
7
7
  /**
@@ -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
- config: {
21
- auth: {
22
- username: auth.apiId,
23
- password: auth.apiKey,
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://api.deepcrawl.com/sessions`,
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 (undefined !== apiResponse.data && undefined !== apiResponse.data.token) {
30
- global.deepcrawlGraphql.token = apiResponse.data.token;
36
+ if (token) {
37
+ global.deepcrawlGraphql.token = token;
31
38
  }
32
39
  }
33
40
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
3
  "license": "UNLICENSED",
4
- "version": "1.1.94",
4
+ "version": "1.1.95",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"