@simpleview/sv-auth-client 5.0.4 → 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 +0 -1
- package/package.json +1 -1
- package/src/oauth2.js +1 -1
- package/src/prefixes/AuthPrefix.js +90 -0
- package/src/utils.js +9 -1
package/Dockerfile
CHANGED
package/package.json
CHANGED
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("
|
|
4
|
+
const { base64urlEncode } = require("./utils");
|
|
5
5
|
|
|
6
6
|
const liveAuthUrl = "https://auth.simpleviewinc.com/";
|
|
7
7
|
|
|
@@ -359,6 +359,96 @@ 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
|
+
|
|
428
|
+
async root_user({ fields, context }) {
|
|
429
|
+
context = context || this._graphServer.context;
|
|
430
|
+
|
|
431
|
+
const result = await query({
|
|
432
|
+
query: `
|
|
433
|
+
query {
|
|
434
|
+
auth {
|
|
435
|
+
root_user {
|
|
436
|
+
${fields}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
`,
|
|
441
|
+
url: this._graphUrl,
|
|
442
|
+
token: context.token
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
const returnData = result.auth.root_user;
|
|
446
|
+
|
|
447
|
+
nullToUndefined(returnData)
|
|
448
|
+
|
|
449
|
+
return returnData;
|
|
450
|
+
}
|
|
451
|
+
|
|
362
452
|
async update_root_user({ input, fields, context}) {
|
|
363
453
|
context = context || this._graphServer.context;
|
|
364
454
|
|
package/src/utils.js
CHANGED
|
@@ -22,4 +22,12 @@ function canIds(perm, node_type, bindings = {}) {
|
|
|
22
22
|
return nodeData;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
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;
|