Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

backend-assistant

Package Overview
Dependencies
Maintainers
1
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

backend-assistant - npm Package Compare versions

Comparing version 0.0.67 to 0.0.68

3

package.json
{
"name": "backend-assistant",
"version": "0.0.67",
"version": "0.0.68",
"description": "Powerful assistive functions for Firebase backends",

@@ -30,4 +30,5 @@ "main": "src/index.js",

"lodash": "^4.17.21",
"resolve-account": "^0.0.1",
"uuid": "^8.3.2"
}
}

@@ -57,3 +57,3 @@ const os = require('os');

this.request.path = (this.ref.req.path || '');
this.request.user = require('./user.js')();
this.request.user = resolveAccount();
if (options.accept === 'json') {

@@ -203,4 +203,13 @@ this.request.body = tryParse(this.ref.req.body || '{}');

options = options || {};
options.resolve = typeof options.resolve === 'undefined' ? true : options.resolve;
const logOptions = {environment: options.log ? 'production' : 'development'}
function _resolve(user) {
if (options.resolve) {
return resolveAccount(user)
} else {
return user;
}
}
if (req.headers && req.headers.authorization && req.headers.authorization.startsWith('Bearer ')) {

@@ -231,3 +240,3 @@ // Read the ID Token from the Authorization header.

self.request.user.roles.admin = true;
return self.request.user;
return _resolve(self.request.user);
}

@@ -237,3 +246,3 @@ } else if (options.apiKey) {

if (options.apiKey.includes('test')) {
return self.request.user;
return _resolve(self.request.user);
}

@@ -252,3 +261,3 @@ await admin.firestore().collection(`users`)

});
return self.request.user;
return _resolve(self.request.user);
} else {

@@ -260,3 +269,3 @@ self.log('No Firebase ID token was able to be extracted.',

'or by passing backendManagerKey or authenticationToken in the body or query', logOptions);
return self.request.user;
return _resolve(self.request.user);
}

@@ -283,6 +292,6 @@

})
return self.request.user;
return _resolve(self.request.user);
} catch (error) {
self.error('Error while verifying Firebase ID token:', error, logOptions);
return self.request.user;
return _resolve(self.request.user);
}

@@ -505,2 +514,7 @@ };

function resolveAccount(user) {
const ResolveAccount = new (require('resolve-account'))();
return ResolveAccount.resolve(undefined, user)
}
module.exports = BackendAssistant;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc