@simpleview/sv-auth-client 5.0.5 → 5.2.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 +137 -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,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
|
|
|
@@ -410,6 +476,77 @@ class AuthPrefix {
|
|
|
410
476
|
return returnData;
|
|
411
477
|
}
|
|
412
478
|
|
|
479
|
+
async create_totp_factor({ fields, context }) {
|
|
480
|
+
context = context || this._graphServer.context;
|
|
481
|
+
|
|
482
|
+
const result = await query({
|
|
483
|
+
query : `
|
|
484
|
+
mutation {
|
|
485
|
+
auth {
|
|
486
|
+
create_totp_factor {
|
|
487
|
+
${fields}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
`,
|
|
492
|
+
url : this._graphUrl,
|
|
493
|
+
token : context.token
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
const returnData = result.auth.create_totp_factor;
|
|
497
|
+
|
|
498
|
+
nullToUndefined(returnData);
|
|
499
|
+
|
|
500
|
+
return returnData;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
async verify_totp_factor({ input, fields, context}) {
|
|
504
|
+
context = context || this._graphServer.context;
|
|
505
|
+
|
|
506
|
+
const result = await query({
|
|
507
|
+
query: `
|
|
508
|
+
query($input: auth_verify_totp_factor_input!) {
|
|
509
|
+
auth {
|
|
510
|
+
verify_totp_factor(input: $input) {
|
|
511
|
+
${fields}
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
`,
|
|
516
|
+
variables: {
|
|
517
|
+
input
|
|
518
|
+
},
|
|
519
|
+
url: this._graphUrl,
|
|
520
|
+
token: context.token
|
|
521
|
+
});
|
|
522
|
+
|
|
523
|
+
const returnData = result.auth.verify_totp_factor;
|
|
524
|
+
|
|
525
|
+
nullToUndefined(returnData)
|
|
526
|
+
|
|
527
|
+
return returnData;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
async verified_totp_factor({ input, fields }) {
|
|
531
|
+
const result = await query({
|
|
532
|
+
query : `
|
|
533
|
+
query($input: auth_verified_totp_factor_input!) {
|
|
534
|
+
auth {
|
|
535
|
+
verified_totp_factor(input: $input) {
|
|
536
|
+
${fields}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
`,
|
|
541
|
+
variables : {
|
|
542
|
+
input
|
|
543
|
+
},
|
|
544
|
+
url : this._graphUrl
|
|
545
|
+
});
|
|
546
|
+
|
|
547
|
+
return result.auth.verified_totp_factor;
|
|
548
|
+
}
|
|
549
|
+
|
|
413
550
|
async test_reset_data({ fields, context }) {
|
|
414
551
|
context = context || this._graphServer.context;
|
|
415
552
|
|
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;
|