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

q3-core-composer

Package Overview
Dependencies
Maintainers
1
Versions
286
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

q3-core-composer

This package registers a few methods onto the request object, most of which help with authenticating and authorizing.

  • 3.4.9
  • npm
  • Socket score

Version published
Weekly downloads
36
increased by20%
Maintainers
1
Weekly downloads
 
Created
Source

Composer

API

Middleware

This package registers a few methods onto the request object, most of which help with authenticating and authorizing.

Request.authorizeBody()

Redact the request's body to safely update documents.

Parameters
  • «Object(optional)» A document to consider during redaction. Useful for triggering test cases with conditional access control grants.
  • «String(optional)» A collection to query for grants. Q3-core-rest automates this value's assignment.
  • «String(optional)» A field under which the body should be tested (i.e. sub-documents). Q3-core-rest automates this value's assignment.
  • «String(optional)» An ID to load a sub-document into the document context. Useful for triggering test cases on nested access control grants.
Returns
  • «Object» The redacted request body
Example
module.exports = async function controller(req, res) {
  const doc = await Model.findById(req.id);
  const subdoc = doc;

  const body = req.authorizeBody(
    doc, // the parent document
    'test-collection', // the collection to pull grants from
    'sample', // the sub-document name
    req.sampleId, // the sub-document id
  );

  doc.sample.id(req.sampleId).set(body);
  await doc.save();

  res.status(200).json({
    ok: 1,
  });
};

FAQs

Package last updated on 09 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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