backend-manager 3.0.18 → 3.0.20

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": "3.0.18",
3
+ "version": "3.0.20",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
@@ -57,7 +57,7 @@
57
57
  "npm-api": "^1.0.1",
58
58
  "paypal-server-api": "^1.0.3",
59
59
  "pushid": "^1.0.0",
60
- "resolve-account": "^1.0.4",
60
+ "resolve-account": "^1.0.5",
61
61
  "semver": "^7.5.4",
62
62
  "shortid": "^2.2.16",
63
63
  "sizeitup": "^1.0.7",
@@ -1,6 +1,6 @@
1
1
  const { get, merge } = require('lodash');
2
- const functions = require('firebase-functions');
3
- const admin = require('firebase-admin');
2
+
3
+ const ERROR_TOO_MANY_ATTEMPTS = 'You have created too many accounts with our service. Please try again later.';
4
4
 
5
5
  function Module() {
6
6
  const self = this;
@@ -31,6 +31,12 @@ Module.prototype.main = function () {
31
31
 
32
32
  assistant.log(`Request: ${user.uid}`, user, context, { environment: 'production' });
33
33
 
34
+ // if (context.additionalUserInfo.recaptchaScore < 0.5) {
35
+ // assistant.error(`Recaptcha score (${context.additionalUserInfo.recaptchaScore}) too low for ${user.uid}`, { environment: 'production' });
36
+
37
+ // throw new functions.auth.HttpsError('resource-exhausted', ERROR_TOO_MANY_ATTEMPTS);
38
+ // }
39
+
34
40
  const ipAddress = context.ipAddress;
35
41
  const currentTime = Date.now();
36
42
  const oneHour = 60 * 60 * 1000; // One hour in milliseconds
@@ -45,7 +51,7 @@ Module.prototype.main = function () {
45
51
  if (currentTime - lastTime < oneHour && count >= 2) {
46
52
  assistant.error(`Too many attemps to create an account for ${ipAddress}`, { environment: 'production' });
47
53
 
48
- throw new functions.auth.HttpsError('resource-exhausted');
54
+ throw new functions.auth.HttpsError('resource-exhausted', ERROR_TOO_MANY_ATTEMPTS);
49
55
  }
50
56
 
51
57
  // Update rate-limiting data
@@ -60,7 +66,7 @@ Module.prototype.main = function () {
60
66
  if (existingAccount instanceof Error) {
61
67
  assistant.error(`Failed to get existing account ${user.uid}:`, existingAccount, { environment: 'production' });
62
68
 
63
- throw new functions.auth.HttpsError('internal');
69
+ throw new functions.auth.HttpsError('internal', `Failed to get existing account: ${existingAccount}`);
64
70
  }
65
71
 
66
72
  let account = {
@@ -105,7 +111,7 @@ Module.prototype.main = function () {
105
111
  if (update instanceof Error) {
106
112
  assistant.error(`Failed to update user ${user.uid}:`, update, { environment: 'production' });
107
113
 
108
- throw new functions.auth.HttpsError('internal');
114
+ throw new functions.auth.HttpsError('internal', `Failed to update user: ${update}`);
109
115
  }
110
116
 
111
117
  assistant.log(`User created at users/${user.uid}`, account, { environment: 'production' });
@@ -51,7 +51,7 @@ Module.prototype.main = function () {
51
51
  if (update instanceof Error) {
52
52
  assistant.error(`Failed to update user ${user.uid}:`, update, { environment: 'production' });
53
53
 
54
- throw new functions.auth.HttpsError('internal');
54
+ throw new functions.auth.HttpsError('internal', `Failed to update user: ${update}`);
55
55
  }
56
56
 
57
57
  assistant.log(`Updated user activity`, {environment: 'production'});