backend-manager 2.2.1 → 2.2.4
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "backend-manager",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.4",
|
|
4
4
|
"description": "Quick tools for developing Firebase functions",
|
|
5
5
|
"main": "src/manager/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"homepage": "https://itwcreativeworks.com",
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@firebase/rules-unit-testing": "^2.0.2",
|
|
31
|
-
"@google-cloud/storage": "^5.20.
|
|
32
|
-
"@sendgrid/mail": "^7.
|
|
31
|
+
"@google-cloud/storage": "^5.20.5",
|
|
32
|
+
"@sendgrid/mail": "^7.7.0",
|
|
33
33
|
"@sentry/node": "^6.19.7",
|
|
34
34
|
"backend-assistant": "^0.0.64",
|
|
35
35
|
"busboy": "^1.6.0",
|
|
@@ -66,4 +66,4 @@
|
|
|
66
66
|
"src/",
|
|
67
67
|
"templates/"
|
|
68
68
|
]
|
|
69
|
-
}
|
|
69
|
+
}
|
|
@@ -12,13 +12,37 @@ Module.prototype.main = function () {
|
|
|
12
12
|
return new Promise(async function(resolve, reject) {
|
|
13
13
|
|
|
14
14
|
const fetch = Manager.require('wonderful-fetch');
|
|
15
|
+
const _ = Manager.require('lodash');
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
let uid = payload.data.payload.uid;
|
|
17
18
|
const app = payload.data.payload.appId || payload.data.payload.app || Manager.config.app.id;
|
|
18
19
|
|
|
19
20
|
let uuid = null;
|
|
20
21
|
let error;
|
|
21
22
|
|
|
23
|
+
let signInToken = null;
|
|
24
|
+
|
|
25
|
+
if (payload.data.authenticationToken || payload.data.backendManagerKey) {
|
|
26
|
+
await self.Api.resolveUser({adminRequired: true})
|
|
27
|
+
.then(async (user) => {
|
|
28
|
+
uid = _.get(user, 'auth.uid', null);
|
|
29
|
+
await self.libraries.admin.auth().createCustomToken(uid)
|
|
30
|
+
.then(token => {
|
|
31
|
+
signInToken = token;
|
|
32
|
+
})
|
|
33
|
+
.catch(e => {
|
|
34
|
+
error = assistant.errorManager(`Failed to create custom token: ${e}`, {code: 500, sentry: false, send: false, log: false}).error
|
|
35
|
+
})
|
|
36
|
+
})
|
|
37
|
+
.catch(e => {
|
|
38
|
+
assistant.errorManager(`Failed to resolve user: ${e}`, {code: 500, sentry: false, send: false, log: true})
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
if (error) {
|
|
42
|
+
return reject(error)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
22
46
|
// Generate uuid
|
|
23
47
|
if (uid) {
|
|
24
48
|
await Api.import('general:generate-uuid', {version: 5, name: uid})
|
|
@@ -52,6 +76,7 @@ Module.prototype.main = function () {
|
|
|
52
76
|
return resolve({
|
|
53
77
|
data: {
|
|
54
78
|
uuid: uuid,
|
|
79
|
+
signInToken: signInToken,
|
|
55
80
|
timestamp: new Date().toISOString(),
|
|
56
81
|
ip: assistant.request.ip,
|
|
57
82
|
country: assistant.request.country,
|
|
@@ -60,9 +85,12 @@ Module.prototype.main = function () {
|
|
|
60
85
|
});
|
|
61
86
|
})
|
|
62
87
|
.catch(e => {
|
|
63
|
-
return reject(
|
|
88
|
+
return reject(assistant.errorManager(`Error fetching app details: ${e}`, {code: 500, sentry: false, send: false, log: false}).error)
|
|
64
89
|
})
|
|
65
90
|
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
66
94
|
});
|
|
67
95
|
|
|
68
96
|
};
|