@simpleview/sv-auth-client 4.5.0 → 4.6.2

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/.eslintrc.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "parser": "@babel/eslint-parser",
3
+ "parserOptions": {
4
+ "ecmaVersion": 11,
5
+ "sourceType": "script",
6
+ "ecmaFeatures": {},
7
+ "requireConfigFile": false
8
+ },
9
+ "rules": {
10
+ "constructor-super": 2,
11
+ "for-direction": 2,
12
+ "getter-return": 2,
13
+ "no-async-promise-executor": 2,
14
+ "no-case-declarations": 2,
15
+ "no-class-assign": 2,
16
+ "no-compare-neg-zero": 2,
17
+ "no-cond-assign": 2,
18
+ "no-const-assign": 2,
19
+ "no-constant-condition": [2, {"checkLoops": false}],
20
+ "no-control-regex": 2,
21
+ "no-debugger": 2,
22
+ "no-delete-var": 2,
23
+ "no-dupe-args": 2,
24
+ "no-dupe-class-members": 2,
25
+ "no-dupe-keys": 2,
26
+ "no-duplicate-case": 2,
27
+ "no-empty": 2,
28
+ "no-empty-character-class": 2,
29
+ "no-empty-pattern": 2,
30
+ "no-ex-assign": 2,
31
+ "no-extra-boolean-cast": 2,
32
+ "no-extra-semi": 2,
33
+ "no-fallthrough": 2,
34
+ "no-func-assign": 2,
35
+ "no-global-assign": 2,
36
+ "no-inner-declarations": 2,
37
+ "no-invalid-regexp": 2,
38
+ "no-irregular-whitespace": 2,
39
+ "no-misleading-character-class": 2,
40
+ "no-mixed-spaces-and-tabs": 2,
41
+ "no-new-symbol": 2,
42
+ "no-obj-calls": 2,
43
+ "no-octal": 2,
44
+ "no-prototype-builtins": 2,
45
+ "no-redeclare": 2,
46
+ "no-regex-spaces": 2,
47
+ "no-self-assign": 2,
48
+ "no-shadow-restricted-names": 2,
49
+ "no-sparse-arrays": 2,
50
+ "no-this-before-super": 2,
51
+ "no-undef": 2,
52
+ "no-unexpected-multiline": 2,
53
+ "no-unreachable": 2,
54
+ "no-unsafe-finally": 2,
55
+ "no-unsafe-negation": 2,
56
+ "no-unused-labels": 2,
57
+ "no-unused-vars": [2, {"vars": "all", "args": "none"}],
58
+ "no-useless-catch": 2,
59
+ "no-useless-escape": 2,
60
+ "no-with": 2,
61
+ "require-yield": 2,
62
+ "use-isnan": 2,
63
+ "valid-typeof": 2,
64
+ "no-var": 2,
65
+ "one-var-declaration-per-line": 2,
66
+ "indent": ["error", "tab", { "SwitchCase": 1 }],
67
+ "space-infix-ops": 2,
68
+ "keyword-spacing" : 2,
69
+ "space-before-blocks" : 2,
70
+ "no-trailing-spaces": 2
71
+ },
72
+ "env": {
73
+ "node": true,
74
+ "es6": true,
75
+ "mongo": true,
76
+ "mocha": true
77
+ }
78
+ }
package/Dockerfile ADDED
@@ -0,0 +1,13 @@
1
+ FROM node:14.16.0
2
+
3
+ COPY package.json /app/package.json
4
+ COPY package-lock.json /app/package-lock.json
5
+
6
+ RUN cd /app && npm install
7
+
8
+ COPY src /app/src
9
+ COPY .eslintrc.json /app/.eslintrc.json
10
+
11
+ WORKDIR /app
12
+
13
+ CMD ["sleep", "infinity"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simpleview/sv-auth-client",
3
- "version": "4.5.0",
3
+ "version": "4.6.2",
4
4
  "description": "Client for communicating with sv-auth",
5
5
  "author": "Owen Allen <owenallenaz@gmail.com>",
6
6
  "dependencies": {
@@ -11,24 +11,22 @@
11
11
  "jsonwebtoken": "8.5.1"
12
12
  },
13
13
  "devDependencies": {
14
+ "@babel/core": "7.14.5",
15
+ "@babel/eslint-parser": "7.14.5",
14
16
  "@simpleview/mochalib": "1.0.1",
15
17
  "@simpleview/assertlib": "1.2.0",
16
18
  "apollo-server": "2.21.2",
17
19
  "cookie": "0.5.0",
18
20
  "cookie-session": "2.0.0",
21
+ "eslint": "7.28.0",
19
22
  "mocha": "5.2.0",
20
23
  "supertest": "6.2.4"
21
24
  },
22
25
  "main": "src/index.js",
23
26
  "browser": "src/browser.js",
24
27
  "scripts": {
25
- "test": "mocha testing --check-leaks",
26
- "docker": "./dev/build && ./dev/run || true",
27
- "publish": "./dev/publish"
28
- },
29
- "repository": {
30
- "type": "git",
31
- "url": "https://github.com/simpleviewinc/sv-auth-client"
28
+ "test": "mocha src/testing --check-leaks",
29
+ "style": "eslint ."
32
30
  },
33
31
  "license": "MIT"
34
32
  }
package/src/AuthClient.js CHANGED
@@ -8,7 +8,7 @@ function AuthClient({ graphUrl, cacheDuration = 1000 * 60 * 60 }) {
8
8
  this._cache = {};
9
9
  this._interval = setInterval(() => {
10
10
  const now = Date.now();
11
- for(var i in this._cache) {
11
+ for (const i in this._cache) {
12
12
  if (this._cache[i].created + cacheDuration > now) {
13
13
  delete this._cache[i];
14
14
  }
@@ -53,7 +53,7 @@ AuthClient.prototype._getUserDoc = async function({ acct_id, token }) {
53
53
  delete this._cache[cacheKey];
54
54
  }
55
55
  }
56
-
56
+
57
57
  const userResult = await this._graphServer.auth.current({
58
58
  acct_id,
59
59
  fields : `
@@ -78,13 +78,13 @@ AuthClient.prototype._getUserDoc = async function({ acct_id, token }) {
78
78
  token
79
79
  }
80
80
  });
81
-
81
+
82
82
  if (userResult.success === false) {
83
83
  // if the user pull fails then either the user is wrong, the token is wrong
84
84
  // bottom line is that the current request should fail
85
85
  return;
86
86
  }
87
-
87
+
88
88
  this._cache[cacheKey] = {
89
89
  user : userResult.doc,
90
90
  created : Date.now(),
@@ -7,7 +7,7 @@ const { defaultFieldResolver } = require("graphql");
7
7
  const AdminPrefix = require("./prefixes/AdminPrefix");
8
8
 
9
9
  function getDirectiveCheckPerm({ name, graphUrl }) {
10
- const graphServer = new GraphServer({ graphUrl, prefixes : [AdminPrefix] });;
10
+ const graphServer = new GraphServer({ graphUrl, prefixes : [AdminPrefix] });
11
11
 
12
12
  class DirectiveCheckPerm extends SchemaDirectiveVisitor {
13
13
  visitFieldDefinition(field) {
@@ -32,7 +32,7 @@ function getDirectiveCheckPerm({ name, graphUrl }) {
32
32
 
33
33
  if (context.headers) {
34
34
  const allowedHeaders = ["x-sv-object-bindings"];
35
- for(let header of allowedHeaders) {
35
+ for (let header of allowedHeaders) {
36
36
  if (context.headers[header]) {
37
37
  headers[header] = context.headers[header];
38
38
  }
@@ -4,7 +4,7 @@ const { defaultFieldResolver } = require("graphql");
4
4
 
5
5
  const AuthClient = require("./AuthClient");
6
6
 
7
- function getDirectiveGetUser({ name, graphUrl }){
7
+ function getDirectiveGetUser({ name, graphUrl }) {
8
8
  const authClient = new AuthClient({ graphUrl });
9
9
 
10
10
  class DirectiveGetUser extends SchemaDirectiveVisitor {
@@ -8,7 +8,7 @@ const {
8
8
  oauth2CreateRandomKey,
9
9
  oauth2GetTokens,
10
10
  oauth2GetTokensFromRefresh
11
- } = require("../src/oauth2");
11
+ } = require("./oauth2");
12
12
 
13
13
  class Oauth2Express {
14
14
  /**
@@ -36,7 +36,7 @@ class Oauth2Express {
36
36
  ]
37
37
 
38
38
  if (validUrls.indexOf(authUrl) === -1 && !/http[^.]+.ui-service.default.svc.cluster.local/.test(authUrl)) {
39
- throw new Error("authUrl must be one of " + validUrls.join(", "));
39
+ throw new Error("authUrl must be one of " + validUrls.join(", "));
40
40
  }
41
41
 
42
42
  if (!client_id) {
@@ -78,7 +78,7 @@ async function middleware(req, res, next) {
78
78
  const oauth2 = session?.oauth2;
79
79
 
80
80
  // If we don't have a token or a refresh_token than we need to redirect to Auth to log the user in
81
- if (!oauth2) {
81
+ if (!oauth2 || oauth2.type === "initial") {
82
82
  if (req.method !== "GET") {
83
83
  throw new Error("User is not authorized to access this resource.");
84
84
  }
@@ -109,10 +109,6 @@ async function middleware(req, res, next) {
109
109
  return res.redirect(302, loginUrl);
110
110
  }
111
111
 
112
- if (oauth2.type === "initial") {
113
- throw new Error("Invalid session state.");
114
- }
115
-
116
112
  if (oauth2.type === "logged_in") {
117
113
  // If the token is older than 1 day we refresh
118
114
  if (Date.now() - oauth2.token_created > 1000 * 60 * 60 * 24) {
package/src/User.js CHANGED
@@ -3,7 +3,7 @@ const { canIds } = require("./utils");
3
3
  class User {
4
4
  constructor(args) {
5
5
  Object.assign(this, args);
6
-
6
+
7
7
  this.permissionObj = JSON.parse(this.permissionJson);
8
8
  /**
9
9
  * @type {import("./types").ObjectBindingsPermissionObj}
@@ -11,12 +11,12 @@ class User {
11
11
  this.permissionObjBindings;
12
12
  }
13
13
  can(perms) {
14
- var allowed = [];
15
-
16
- for(var perm of perms) {
17
- var terms = perm.split(".");
18
- var current = this.permissionObj;
19
- for(var [i, term] of Object.entries(terms)) {
14
+ const allowed = [];
15
+
16
+ for (const perm of perms) {
17
+ const terms = perm.split(".");
18
+ let current = this.permissionObj;
19
+ for (const [i, term] of Object.entries(terms)) {
20
20
  if (current[term] === undefined) {
21
21
  // user hit the end of their tree, doesn't have permission
22
22
  allowed.push(false);
@@ -35,21 +35,21 @@ class User {
35
35
  }
36
36
  }
37
37
  }
38
-
38
+
39
39
  return allowed.indexOf(false) === -1;
40
40
  }
41
41
  /**
42
42
  * Return what objects a user has this permission for the given node type
43
- * @param {string} perm
44
- * @param {string} node_type
43
+ * @param {string} perm
44
+ * @param {string} node_type
45
45
  */
46
46
  canIds(perm, node_type) {
47
47
  return canIds(perm, node_type, this.permissionObjBindings);
48
48
  }
49
49
  toJSON() {
50
- var temp = Object.assign({}, this);
50
+ const temp = Object.assign({}, this);
51
51
  delete temp.permissionObj;
52
-
52
+
53
53
  return temp;
54
54
  }
55
55
  toPlain() {
package/src/browser.js CHANGED
@@ -7,11 +7,11 @@ function getTokenFromHeaders(headers) {
7
7
  if (!headers.authorization) {
8
8
  return;
9
9
  }
10
-
10
+
11
11
  return headers.authorization.replace(/^Bearer /, "");
12
12
  }
13
13
 
14
- function isCommonPassword(val){
14
+ function isCommonPassword(val) {
15
15
  // https://en.wikipedia.org/wiki/List_of_the_most_common_passwords#cite_note-splashdata2018-10
16
16
  // https://gizmodo.com/the-25-most-popular-passwords-of-2018-will-make-you-fee-1831052705
17
17
  // most common passwords 8 characters or longer.
@@ -14,11 +14,11 @@ const apis = {
14
14
  class AdminPrefix {
15
15
  constructor({ graphUrl, graphServer }) {
16
16
  this.name = "admin";
17
-
17
+
18
18
  this._graphUrl = graphUrl;
19
19
  this._graphServer = graphServer;
20
-
21
- for(let [name, Api] of Object.entries(apis)) {
20
+
21
+ for (let [name, Api] of Object.entries(apis)) {
22
22
  const api = new Api({ graphUrl, name, graphServer : graphServer });
23
23
  this[name] = api.find.bind(api);
24
24
  this[`${name}_upsert`] = api.upsert.bind(api);
@@ -27,11 +27,11 @@ class AdminPrefix {
27
27
  }
28
28
  async users_import({fields, context }) {
29
29
  context = context || this._graphServer.context;
30
-
30
+
31
31
  const variables = {
32
32
  acct_id : context.acct_id
33
33
  }
34
-
34
+
35
35
  const response = await query({
36
36
  query : `
37
37
  mutation($acct_id: String!) {
@@ -46,21 +46,21 @@ class AdminPrefix {
46
46
  url : this._graphUrl,
47
47
  token : context.token
48
48
  });
49
-
49
+
50
50
  const returnData = response.admin.users_import;
51
-
51
+
52
52
  nullToUndefined(returnData);
53
-
53
+
54
54
  return returnData;
55
55
  }
56
56
  async users_send_invitation({ input, fields, context }) {
57
57
  context = context || this._graphServer.context;
58
-
58
+
59
59
  const variables = {
60
60
  input,
61
61
  acct_id : context.acct_id
62
62
  }
63
-
63
+
64
64
  const response = await query({
65
65
  query : `
66
66
  mutation($acct_id: String!, $input: admin_users_send_invitation_input!) {
@@ -75,20 +75,20 @@ class AdminPrefix {
75
75
  url : this._graphUrl,
76
76
  token : context.token
77
77
  });
78
-
78
+
79
79
  const returnData = response.admin.users_send_invitation;
80
-
80
+
81
81
  nullToUndefined(returnData);
82
-
82
+
83
83
  return returnData;
84
84
  }
85
85
  async setup({ context, fields }) {
86
86
  context = context || this._graphServer.context;
87
-
87
+
88
88
  const variables = {
89
89
  acct_id : context.acct_id
90
90
  }
91
-
91
+
92
92
  const result = await query({
93
93
  query : `
94
94
  mutation($acct_id: String!) {
@@ -103,11 +103,11 @@ class AdminPrefix {
103
103
  url : this._graphUrl,
104
104
  token : context.token
105
105
  });
106
-
106
+
107
107
  const returnData = result.admin.setup;
108
-
108
+
109
109
  nullToUndefined(returnData);
110
-
110
+
111
111
  return returnData;
112
112
  }
113
113
  /**
@@ -126,7 +126,7 @@ class AdminPrefix {
126
126
  filter,
127
127
  acct_id : context.acct_id
128
128
  }
129
-
129
+
130
130
  const result = await query({
131
131
  query : `
132
132
  query($acct_id: String!, $filter: admin_object_bindings_mine_filter) {
@@ -142,11 +142,11 @@ class AdminPrefix {
142
142
  token : context.token,
143
143
  headers
144
144
  });
145
-
145
+
146
146
  const returnData = result.admin.object_bindings_mine;
147
-
147
+
148
148
  nullToUndefined(returnData)
149
-
149
+
150
150
  return returnData;
151
151
  }
152
152
  }
@@ -6,10 +6,10 @@ const { query, nullToUndefined } = require("@simpleview/sv-graphql-client");
6
6
  class AuthPrefix {
7
7
  constructor({ graphUrl, graphServer }) {
8
8
  this.name = "auth";
9
-
9
+
10
10
  this._graphUrl = graphUrl;
11
11
  this._graphServer = graphServer;
12
-
12
+
13
13
  this._accounts = new Accounts({
14
14
  graphUrl,
15
15
  name : "accounts",
@@ -39,7 +39,7 @@ class AuthPrefix {
39
39
  }
40
40
  async account_public({ filter, fields, context }) {
41
41
  context = context || this._graphServer.context;
42
-
42
+
43
43
  const result = await query({
44
44
  query : `
45
45
  query($filter: auth_account_public_filter!) {
@@ -55,11 +55,11 @@ class AuthPrefix {
55
55
  },
56
56
  url : this._graphUrl
57
57
  });
58
-
58
+
59
59
  const returnData = result.auth.account_public;
60
-
60
+
61
61
  nullToUndefined(returnData)
62
-
62
+
63
63
  return returnData;
64
64
  }
65
65
  async accounts_sync({ fields, context }) {
@@ -80,7 +80,7 @@ class AuthPrefix {
80
80
  });
81
81
 
82
82
  const returnData = result.auth.accounts_sync;
83
-
83
+
84
84
  nullToUndefined(returnData);
85
85
 
86
86
  return returnData;
@@ -113,7 +113,7 @@ class AuthPrefix {
113
113
  }
114
114
  async current({ acct_id, fields, context }) {
115
115
  context = context || this._graphServer.context;
116
-
116
+
117
117
  const result = await query({
118
118
  query : `
119
119
  query($acct_id: String!) {
@@ -130,11 +130,11 @@ class AuthPrefix {
130
130
  url : this._graphUrl,
131
131
  token : context.token
132
132
  });
133
-
133
+
134
134
  const returnData = result.auth.current;
135
-
135
+
136
136
  nullToUndefined(returnData)
137
-
137
+
138
138
  return returnData;
139
139
  }
140
140
  async reset_password_start({ input, fields }) {
@@ -153,11 +153,11 @@ class AuthPrefix {
153
153
  },
154
154
  url : this._graphUrl
155
155
  });
156
-
156
+
157
157
  const returnData = result.auth.reset_password_start;
158
-
158
+
159
159
  nullToUndefined(returnData);
160
-
160
+
161
161
  return returnData;
162
162
  }
163
163
  async update_password({ token, new_pass, fields }) {
@@ -177,7 +177,7 @@ class AuthPrefix {
177
177
  },
178
178
  url : this._graphUrl
179
179
  });
180
-
180
+
181
181
  return result.auth.update_password;
182
182
  }
183
183
  async refresh_token({ refresh_token, fields }) {
@@ -189,7 +189,7 @@ class AuthPrefix {
189
189
  ${fields}
190
190
  }
191
191
  }
192
-
192
+
193
193
  }
194
194
  `,
195
195
  variables : {
@@ -197,7 +197,7 @@ class AuthPrefix {
197
197
  },
198
198
  url : this._graphUrl
199
199
  });
200
-
200
+
201
201
  return result.auth.refresh_token;
202
202
  }
203
203
  async login({ input, fields }) {
@@ -209,7 +209,7 @@ class AuthPrefix {
209
209
  ${fields}
210
210
  }
211
211
  }
212
-
212
+
213
213
  }
214
214
  `,
215
215
  variables : {
@@ -217,7 +217,7 @@ class AuthPrefix {
217
217
  },
218
218
  url : this._graphUrl
219
219
  });
220
-
220
+
221
221
  return result.auth.login;
222
222
  }
223
223
  async login_google({ token, fields }) {
@@ -236,7 +236,7 @@ class AuthPrefix {
236
236
  },
237
237
  url : this._graphUrl
238
238
  });
239
-
239
+
240
240
  return result.auth.login_google;
241
241
  }
242
242
  async login_service_account({ input, fields }) {
@@ -255,7 +255,7 @@ class AuthPrefix {
255
255
  },
256
256
  url : this._graphUrl
257
257
  });
258
-
258
+
259
259
  return result.auth.login_service_account;
260
260
  }
261
261
  async login_sso_token({ input, fields }) {
@@ -279,7 +279,7 @@ class AuthPrefix {
279
279
  }
280
280
  async check_token_cache({ date, acct_id, fields, context }) {
281
281
  context = context || this._graphServer.context;
282
-
282
+
283
283
  const result = await query({
284
284
  query : `
285
285
  query($date: auth_date!, $acct_id: String!) {
@@ -297,7 +297,7 @@ class AuthPrefix {
297
297
  url : this._graphUrl,
298
298
  token : context.token
299
299
  });
300
-
300
+
301
301
  return result.auth.check_token_cache;
302
302
  }
303
303
  async test_reset_data({ fields, context }) {
@@ -316,11 +316,11 @@ class AuthPrefix {
316
316
  url : this._graphUrl,
317
317
  token : context.token
318
318
  });
319
-
319
+
320
320
  const returnData = result.auth.test_reset_data;
321
-
321
+
322
322
  nullToUndefined(returnData);
323
-
323
+
324
324
  return returnData;
325
325
  }
326
326
  async test_clear_data({ fields, context }) {
@@ -339,11 +339,11 @@ class AuthPrefix {
339
339
  url : this._graphUrl,
340
340
  token : context.token
341
341
  });
342
-
342
+
343
343
  const returnData = result.auth.test_clear_data;
344
-
344
+
345
345
  nullToUndefined(returnData);
346
-
346
+
347
347
  return returnData;
348
348
  }
349
349
  async test_items(...args) {
@@ -351,7 +351,7 @@ class AuthPrefix {
351
351
  }
352
352
  async setup({ context, fields }) {
353
353
  context = context || this._graphServer.context;
354
-
354
+
355
355
  const result = await query({
356
356
  query : `
357
357
  mutation {
@@ -365,11 +365,11 @@ class AuthPrefix {
365
365
  url : this._graphUrl,
366
366
  token : context.token
367
367
  });
368
-
368
+
369
369
  const returnData = result.auth.setup;
370
-
370
+
371
371
  nullToUndefined(returnData);
372
-
372
+
373
373
  return returnData;
374
374
  }
375
375
  }
@@ -8,15 +8,15 @@ class GraphAdminApi {
8
8
  }
9
9
  async find({ filter, options, fields, context, headers }) {
10
10
  const method = this._name;
11
-
11
+
12
12
  context = context || this._graphServer.context;
13
-
13
+
14
14
  const variables = {
15
15
  filter,
16
16
  options,
17
17
  acct_id : context.acct_id
18
18
  };
19
-
19
+
20
20
  const response = await query({
21
21
  query : `
22
22
  query($acct_id: String!, $filter: admin_${method}_filter, $options: admin_${method}_options) {
@@ -32,23 +32,23 @@ class GraphAdminApi {
32
32
  token : context.token,
33
33
  headers
34
34
  });
35
-
35
+
36
36
  const returnData = response.admin[this._name];
37
-
37
+
38
38
  nullToUndefined(returnData)
39
-
39
+
40
40
  return returnData;
41
41
  }
42
42
  async upsert({ input, fields, context, headers }) {
43
43
  const method = `${this._name}_upsert`;
44
-
44
+
45
45
  context = context || this._graphServer.context;
46
-
46
+
47
47
  const variables = {
48
48
  input,
49
49
  acct_id : context.acct_id
50
50
  }
51
-
51
+
52
52
  const response = await query({
53
53
  query : `
54
54
  mutation($acct_id: String!, $input: admin_${method}!) {
@@ -64,23 +64,23 @@ class GraphAdminApi {
64
64
  token : context.token,
65
65
  headers
66
66
  });
67
-
67
+
68
68
  const returnData = response.admin[method];
69
-
69
+
70
70
  nullToUndefined(returnData);
71
-
71
+
72
72
  return returnData;
73
73
  }
74
74
  async remove({ filter, fields, context, headers }) {
75
75
  const method = `${this._name}_remove`;
76
-
76
+
77
77
  context = context || this._graphServer.context;
78
-
78
+
79
79
  const variables = {
80
80
  filter,
81
81
  acct_id : context.acct_id
82
82
  }
83
-
83
+
84
84
  const response = await query({
85
85
  query : `
86
86
  mutation($acct_id: String!, $filter: admin_${method}_filter) {
@@ -96,11 +96,11 @@ class GraphAdminApi {
96
96
  token : context.token,
97
97
  headers
98
98
  });
99
-
99
+
100
100
  const returnData = response.admin[method];
101
-
101
+
102
102
  nullToUndefined(returnData);
103
-
103
+
104
104
  return returnData;
105
105
  }
106
106
  }
@@ -8,14 +8,14 @@ class GraphAuthApi {
8
8
  }
9
9
  async find({ filter, options, fields, context, headers }) {
10
10
  const method = this._name;
11
-
11
+
12
12
  context = context || this._graphServer.context;
13
-
13
+
14
14
  const variables = {
15
15
  filter,
16
16
  options
17
17
  };
18
-
18
+
19
19
  const response = await query({
20
20
  query : `
21
21
  query($filter: auth_${method}_filter, $options: auth_${method}_options) {
@@ -31,22 +31,22 @@ class GraphAuthApi {
31
31
  token : context.token,
32
32
  headers
33
33
  });
34
-
34
+
35
35
  const returnData = response.auth[this._name];
36
-
36
+
37
37
  nullToUndefined(returnData)
38
-
38
+
39
39
  return returnData;
40
40
  }
41
41
  async upsert({ input, fields, context, headers }) {
42
42
  const method = `${this._name}_upsert`;
43
-
43
+
44
44
  context = context || this._graphServer.context;
45
-
45
+
46
46
  const variables = {
47
47
  input
48
48
  }
49
-
49
+
50
50
  const response = await query({
51
51
  query : `
52
52
  mutation($input: auth_${method}!) {
@@ -62,22 +62,22 @@ class GraphAuthApi {
62
62
  token : context.token,
63
63
  headers
64
64
  });
65
-
65
+
66
66
  const returnData = response.auth[method];
67
-
67
+
68
68
  nullToUndefined(returnData);
69
-
69
+
70
70
  return returnData;
71
71
  }
72
72
  async remove({ filter, fields, context, headers }) {
73
73
  const method = `${this._name}_remove`;
74
-
74
+
75
75
  context = context || this._graphServer.context;
76
-
76
+
77
77
  const variables = {
78
78
  filter
79
79
  }
80
-
80
+
81
81
  const response = await query({
82
82
  query : `
83
83
  mutation($filter: auth_${method}_filter!) {
@@ -93,11 +93,11 @@ class GraphAuthApi {
93
93
  token : context.token,
94
94
  headers
95
95
  });
96
-
96
+
97
97
  const returnData = response.auth[method];
98
-
98
+
99
99
  nullToUndefined(returnData);
100
-
100
+
101
101
  return returnData;
102
102
  }
103
103
  }
@@ -7,12 +7,12 @@ class TestItems {
7
7
  }
8
8
  async find({ filter, options, fields, context }) {
9
9
  context = context || this._graphServer.context;
10
-
10
+
11
11
  const variables = {
12
12
  filter,
13
13
  options
14
14
  };
15
-
15
+
16
16
  const response = await query({
17
17
  query : `
18
18
  query($filter: auth_test_items_filter, $options: auth_options) {
@@ -27,11 +27,11 @@ class TestItems {
27
27
  url : this._graphUrl,
28
28
  token : context.token
29
29
  });
30
-
30
+
31
31
  const returnData = response.auth.test_items;
32
-
32
+
33
33
  nullToUndefined(returnData)
34
-
34
+
35
35
  return returnData;
36
36
  }
37
37
  }
@@ -4,13 +4,11 @@ const { GraphServer } = require("@simpleview/sv-graphql-client");
4
4
 
5
5
  const { AdminPrefix, AuthPrefix } = require("../");
6
6
 
7
- const graphUrl = "https://graphql.kube.simpleview.io/link/auth-v2/";
8
-
9
7
  const prefixes = [AdminPrefix, AuthPrefix];
10
- const authGraphServer = new GraphServer({ graphUrl, prefixes })
8
+ const authGraphServer = new GraphServer({ graphUrl: process.env.GRAPHQL_URL, prefixes })
11
9
 
12
10
  const init = async function() {
13
- const serviceJson = JSON.parse(fs.readFileSync(`${__dirname}/../auth_test.serviceAccount.json`));
11
+ const serviceJson = JSON.parse(fs.readFileSync("/var/lib/credentials/auth_test.serviceAccount.json"));
14
12
  const serviceLogin = await authGraphServer.auth.login_service_account({
15
13
  input : {
16
14
  email : serviceJson.client_email,
@@ -18,7 +16,7 @@ const init = async function() {
18
16
  },
19
17
  fields : `success message token`
20
18
  });
21
-
19
+
22
20
  assert.strictEqual(serviceLogin.success, true);
23
21
 
24
22
  authGraphServer.context.token = serviceLogin.token;
@@ -49,7 +47,7 @@ const servers = {
49
47
  init,
50
48
  authGraphServer,
51
49
  acct0test0 : new GraphServer({
52
- graphUrl,
50
+ graphUrl: process.env.GRAPHQL_URL,
53
51
  prefixes,
54
52
  context : {
55
53
  acct_id : "test-0"
@@ -1,5 +0,0 @@
1
- {
2
- "files.trimTrailingWhitespace": true,
3
- "files.insertFinalNewline": true,
4
- "files.eol": "\n"
5
- }