backend-manager 3.2.111 → 3.2.112
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 +2 -2
- package/src/manager/helpers/usage.js +30 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "backend-manager",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.112",
|
|
4
4
|
"description": "Quick tools for developing Firebase functions",
|
|
5
5
|
"main": "src/manager/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -76,4 +76,4 @@
|
|
|
76
76
|
"wonderful-log": "^1.0.5",
|
|
77
77
|
"yargs": "^17.7.2"
|
|
78
78
|
}
|
|
79
|
-
}
|
|
79
|
+
}
|
|
@@ -43,6 +43,7 @@ Usage.prototype.init = function (assistant, options) {
|
|
|
43
43
|
options.today = typeof options.today === 'undefined' ? undefined : options.today;
|
|
44
44
|
options.key = typeof options.key === 'undefined' ? undefined : options.key;
|
|
45
45
|
options.unauthenticatedMode = typeof options.unauthenticatedMode === 'undefined' ? 'firestore' : options.unauthenticatedMode;
|
|
46
|
+
options.whitelistKeys = options.whitelistKeys || [];
|
|
46
47
|
options.log = typeof options.log === 'undefined' ? false : options.log;
|
|
47
48
|
|
|
48
49
|
// Check for required options
|
|
@@ -50,6 +51,12 @@ Usage.prototype.init = function (assistant, options) {
|
|
|
50
51
|
return reject(new Error('Missing required {assistant} parameter'));
|
|
51
52
|
}
|
|
52
53
|
|
|
54
|
+
// Add BEM to whitelist keys
|
|
55
|
+
options.whitelistKeys.push(
|
|
56
|
+
Manager?.config?.backend_manager?.key
|
|
57
|
+
|| process.env.BACKEND_MANAGER_KEY
|
|
58
|
+
);
|
|
59
|
+
|
|
53
60
|
// Set options
|
|
54
61
|
self.options = options;
|
|
55
62
|
|
|
@@ -171,6 +178,14 @@ Usage.prototype.validate = function (name, options) {
|
|
|
171
178
|
return _reject();
|
|
172
179
|
}
|
|
173
180
|
|
|
181
|
+
// Check if they have a white list key
|
|
182
|
+
const hasWhitelistKey = self.options.whitelistKeys.some((key) => key && key === self?.user?.api?.privateKey);
|
|
183
|
+
if (hasWhitelistKey) {
|
|
184
|
+
self.log(`Usage.validate(): Whitelist key found for ${name}`);
|
|
185
|
+
|
|
186
|
+
return resolve(true);
|
|
187
|
+
}
|
|
188
|
+
|
|
174
189
|
// If they are under the limit, resolve
|
|
175
190
|
if (period < allowed) {
|
|
176
191
|
self.log(`Usage.validate(): Valid for ${name}`);
|
|
@@ -339,6 +354,21 @@ Usage.prototype.update = function () {
|
|
|
339
354
|
});
|
|
340
355
|
};
|
|
341
356
|
|
|
357
|
+
Usage.prototype.addWhitelistKeys = function (keys) {
|
|
358
|
+
const self = this;
|
|
359
|
+
|
|
360
|
+
const options = self.options;
|
|
361
|
+
|
|
362
|
+
// Make keys and array if not already
|
|
363
|
+
keys = Array.isArray(keys) ? keys : [keys];
|
|
364
|
+
|
|
365
|
+
// Add keys to whitelist
|
|
366
|
+
options.whitelistKeys = options.whitelistKeys.concat(keys);
|
|
367
|
+
|
|
368
|
+
// Log
|
|
369
|
+
return self;
|
|
370
|
+
};
|
|
371
|
+
|
|
342
372
|
Usage.prototype.log = function () {
|
|
343
373
|
const self = this;
|
|
344
374
|
|