@simpleview/sv-auth-client 5.0.5 → 5.1.0

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/Dockerfile CHANGED
@@ -6,7 +6,6 @@ COPY package-lock.json /app/package-lock.json
6
6
  RUN cd /app && npm install
7
7
 
8
8
  COPY src /app/src
9
- COPY --from=sv-auth-shared:local /app/lib/base64urlEncode.js /app/shared/base64urlEncode.js
10
9
  COPY .eslintrc.json /app/.eslintrc.json
11
10
 
12
11
  WORKDIR /app
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simpleview/sv-auth-client",
3
- "version": "5.0.5",
3
+ "version": "5.1.0",
4
4
  "description": "Client for communicating with sv-auth",
5
5
  "author": "Owen Allen <owenallenaz@gmail.com>",
6
6
  "dependencies": {
package/src/oauth2.js CHANGED
@@ -1,7 +1,7 @@
1
1
  //@ts-check
2
2
  const { request : axios } = require("axios");
3
3
  const { createHash, randomBytes } = require("crypto");
4
- const base64urlEncode = require("/app/shared/base64urlEncode");
4
+ const { base64urlEncode } = require("./utils");
5
5
 
6
6
  const liveAuthUrl = "https://auth.simpleviewinc.com/";
7
7
 
@@ -359,6 +359,72 @@ class AuthPrefix {
359
359
  return result.auth.send_email_mfa_code;
360
360
  }
361
361
 
362
+ async send_sms_mfa_code({ input, fields }) {
363
+ const result = await query({
364
+ query : `
365
+ mutation($input: auth_send_sms_mfa_code_input!) {
366
+ auth {
367
+ send_sms_mfa_code(input: $input) {
368
+ ${fields}
369
+ }
370
+ }
371
+ }
372
+ `,
373
+ variables : {
374
+ input
375
+ },
376
+ url : this._graphUrl
377
+ });
378
+
379
+ return result.auth.send_sms_mfa_code;
380
+ }
381
+
382
+ async send_sms_phone_code({ input, fields, context }) {
383
+ context = context || this._graphServer.context;
384
+
385
+ const result = await query({
386
+ query: `
387
+ mutation($input: auth_send_sms_phone_code_input!) {
388
+ auth {
389
+ send_sms_phone_code(input: $input) {
390
+ ${fields}
391
+ }
392
+ }
393
+ }
394
+ `,
395
+ variables: {
396
+ input
397
+ },
398
+ url: this._graphUrl,
399
+ token: context.token
400
+ });
401
+
402
+ return result.auth.send_sms_phone_code;
403
+ }
404
+
405
+ async verify_phone_code({ input, fields, context }) {
406
+ context = context || this._graphServer.context;
407
+
408
+ const result = await query({
409
+ query: `
410
+ query($input: auth_verify_phone_code_input!) {
411
+ auth {
412
+ verify_phone_code(input: $input) {
413
+ ${fields}
414
+ }
415
+ }
416
+ }
417
+ `,
418
+ variables: {
419
+ input
420
+ },
421
+ url: this._graphUrl,
422
+ token: context.token
423
+ });
424
+
425
+ return result.auth.verify_phone_code;
426
+ }
427
+
362
428
  async root_user({ fields, context }) {
363
429
  context = context || this._graphServer.context;
364
430
 
package/src/utils.js CHANGED
@@ -22,4 +22,12 @@ function canIds(perm, node_type, bindings = {}) {
22
22
  return nodeData;
23
23
  }
24
24
 
25
- module.exports.canIds = canIds;
25
+ const base64urlEncode = function (inputString) {
26
+ return inputString
27
+ .replace(/=$/, "")
28
+ .replace(/\+/g, "-")
29
+ .replace(/\//g, "_");
30
+ }
31
+
32
+ module.exports.canIds = canIds;
33
+ module.exports.base64urlEncode = base64urlEncode;