blixify-server 0.1.79 → 0.1.80

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.
@@ -0,0 +1,17 @@
1
+ import { WrapperLib } from "./mongoWrapper";
2
+ /**
3
+ * @Wrapper
4
+ *
5
+ */
6
+ export declare class AuthWrapper {
7
+ fbAdmin: any;
8
+ isProd: boolean;
9
+ lib: WrapperLib;
10
+ constructor(fbAdmin: any, isProd: boolean, lib: WrapperLib);
11
+ initDisableAccount: (req: any, res: any) => Promise<void>;
12
+ initUpdatePassword: (req: any, res: any) => Promise<void>;
13
+ initUpdateEmail: (req: any, res: any, workflow?: () => Promise<any>) => Promise<void>;
14
+ initUpdateMobileNo: (req: any, res: any, workflow?: () => Promise<any>) => Promise<void>;
15
+ init: () => any;
16
+ }
17
+ //# sourceMappingURL=authWrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authWrapper.d.ts","sourceRoot":"","sources":["../../src/apis/authWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C;;;GAGG;AACH,qBAAa,WAAW;IACtB,OAAO,EAAE,GAAG,CAAM;IAClB,MAAM,UAAS;IACf,GAAG,EAAE,UAAU,CAAC;gBAEJ,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU;IAM1D,kBAAkB,QAAe,GAAG,OAAO,GAAG,mBAU5C;IAEF,kBAAkB,QAAe,GAAG,OAAO,GAAG,mBAW5C;IAEF,eAAe,QACR,GAAG,OACH,GAAG,aACG,MAAM,QAAQ,GAAG,CAAC,mBAa7B;IAEF,kBAAkB,QACX,GAAG,OACH,GAAG,aACG,MAAM,QAAQ,GAAG,CAAC,mBAa7B;IAEF,IAAI,YAuCF;CACH"}
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.AuthWrapper = void 0;
13
+ /**
14
+ * @Wrapper
15
+ *
16
+ */
17
+ class AuthWrapper {
18
+ constructor(fbAdmin, isProd, lib) {
19
+ this.fbAdmin = "";
20
+ this.isProd = false;
21
+ this.initDisableAccount = (req, res) => __awaiter(this, void 0, void 0, function* () {
22
+ const adminAuth = this.fbAdmin.auth();
23
+ try {
24
+ const userId = req.body.userId;
25
+ if (!userId)
26
+ throw "Invalid Configuration";
27
+ yield adminAuth.updateUser(userId, { disabled: true });
28
+ res.send({ success: true });
29
+ }
30
+ catch (err) {
31
+ res.status(400).json({ err: err });
32
+ }
33
+ });
34
+ this.initUpdatePassword = (req, res) => __awaiter(this, void 0, void 0, function* () {
35
+ const adminAuth = this.fbAdmin.auth();
36
+ try {
37
+ const userId = req.body.userId;
38
+ const password = req.body.password;
39
+ if (!userId || !password)
40
+ throw "Invalid Configuration";
41
+ yield adminAuth.updateUser(userId, { password: password });
42
+ res.send({ success: true });
43
+ }
44
+ catch (err) {
45
+ res.status(400).json({ err: err });
46
+ }
47
+ });
48
+ this.initUpdateEmail = (req, res, workflow) => __awaiter(this, void 0, void 0, function* () {
49
+ const adminAuth = this.fbAdmin.auth();
50
+ try {
51
+ const userId = req.body.userId;
52
+ const email = req.body.email;
53
+ if (!userId || !email)
54
+ throw "Invalid Configuration";
55
+ yield adminAuth.updateUser(userId, { email: email });
56
+ if (workflow)
57
+ yield workflow();
58
+ res.send({ success: true });
59
+ }
60
+ catch (err) {
61
+ res.status(400).json({ err: err });
62
+ }
63
+ });
64
+ this.initUpdateMobileNo = (req, res, workflow) => __awaiter(this, void 0, void 0, function* () {
65
+ const adminAuth = this.fbAdmin.auth();
66
+ try {
67
+ const userId = req.body.userId;
68
+ const phoneNumber = req.body.phoneNumber;
69
+ if (!userId || !phoneNumber)
70
+ throw "Invalid Configuration";
71
+ yield adminAuth.updateUser(userId, { phoneNumber: phoneNumber });
72
+ if (workflow)
73
+ yield workflow();
74
+ res.send({ success: true });
75
+ }
76
+ catch (err) {
77
+ res.status(400).json({ err: err });
78
+ }
79
+ });
80
+ this.init = () => {
81
+ const router = this.lib.express.Router();
82
+ /**
83
+ * @Input
84
+ * userId - string
85
+ */
86
+ router.post("/disable", (req, res) => {
87
+ this.initDisableAccount(req, res);
88
+ });
89
+ /**
90
+ * @Input
91
+ * userId - string
92
+ * password - string
93
+ */
94
+ router.post("/reset", (req, res) => {
95
+ this.initUpdatePassword(req, res);
96
+ });
97
+ /**
98
+ * @Input
99
+ * userId - string
100
+ * email - string
101
+ */
102
+ router.post("/email", (req, res) => {
103
+ this.initUpdateEmail(req, res);
104
+ });
105
+ /**
106
+ * @Input
107
+ * userId - string
108
+ * password - string
109
+ */
110
+ router.post("/mobile", (req, res) => {
111
+ this.initUpdateMobileNo(req, res);
112
+ });
113
+ return router;
114
+ };
115
+ this.fbAdmin = fbAdmin;
116
+ this.isProd = isProd;
117
+ this.lib = lib;
118
+ }
119
+ }
120
+ exports.AuthWrapper = AuthWrapper;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blixify-server",
3
- "version": "0.1.79",
3
+ "version": "0.1.80",
4
4
  "license": "MIT",
5
5
  "main": "dist/apis/index.js",
6
6
  "private": false,
@@ -24,6 +24,7 @@
24
24
  "start:postgres": "cd dist && node postgresServer.js",
25
25
  "start:mongo": "cd dist && node mongoServer.js",
26
26
  "start:fb": "cd dist && node firebaseServer.js",
27
+ "start:auth": "cd dist && node authServer.js",
27
28
  "start:aws": "cd dist && node awsServer.js",
28
29
  "start:monday": "cd dist && node mondayServer.js",
29
30
  "install:husky": "yarn husky install"