Socket
Socket
Sign inDemoInstall

strapi-utils

Package Overview
Dependencies
Maintainers
8
Versions
282
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

strapi-utils - npm Package Compare versions

Comparing version 3.1.6 to 3.1.7

lib/__tests__/content-types.test.js

13

lib/__tests__/sanitize-entity.test.js
'use strict';
const _ = require('lodash');
const { sanitizeEntity } = require('../sanitize-entity');
const sanitizeEntity = require('../sanitize-entity');

@@ -43,2 +43,3 @@ describe('Sanitize Entity', () => {

},
privateAttributes: ['email'],
attributes: {

@@ -87,2 +88,3 @@ email: {

},
privateAttributes: ['secret'],
attributes: {

@@ -212,13 +214,6 @@ name: {

},
privateAttributes: [].concat(models.user.privateAttributes, ['firstname'], ['id']),
};
test.each(tests)(`Test n°%#`, (options, expected) => {
global.strapi = {
config: {
get: jest.fn(path => {
return path === 'api.responses.privateAttributes' ? ['id'] : [];
}),
},
};
expect(sanitizeEntity(input, { ...options, model })).toStrictEqual(expected);

@@ -225,0 +220,0 @@ });

@@ -9,3 +9,3 @@ 'use strict';

const parseMultipartData = require('./parse-multipart');
const { sanitizeEntity, getPrivateAttributes } = require('./sanitize-entity');
const sanitizeEntity = require('./sanitize-entity');
const parseType = require('./parse-type');

@@ -29,2 +29,3 @@ const finder = require('./finder');

const { generateTimestampCode } = require('./code-generator');
const contentTypes = require('./content-types');

@@ -45,3 +46,2 @@ module.exports = {

sanitizeEntity,
getPrivateAttributes,
parseType,

@@ -59,2 +59,3 @@ nameToSlug,

stringEquals,
contentTypes,
};
'use strict';
const _ = require('lodash');
const { isPrivateAttribute } = require('./content-types');

@@ -123,16 +124,5 @@ const sanitizeEntity = (dataSource, options) => {

const getPrivateAttributes = model => {
const allPrivatesAttributes = _.union(
strapi.config.get('api.responses.privateAttributes', []),
_.get(model, 'options.privateAttributes', [])
);
return allPrivatesAttributes;
};
const shouldRemoveAttribute = (model, key, attribute = {}, { withPrivate, isOutput }) => {
const privateAttributes = getPrivateAttributes(model);
const isPassword = attribute.type === 'password';
const isPrivate = attribute.private === true || privateAttributes.includes(key);
const isPrivate = isPrivateAttribute(model, key);

@@ -145,5 +135,2 @@ const shouldRemovePassword = isOutput;

module.exports = {
sanitizeEntity,
getPrivateAttributes,
};
module.exports = sanitizeEntity;
{
"name": "strapi-utils",
"version": "3.1.6",
"version": "3.1.7",
"description": "Shared utilities for the Strapi packages",

@@ -48,3 +48,3 @@ "homepage": "http://strapi.io",

"license": "SEE LICENSE IN LICENSE",
"gitHead": "3c7c33eab7bc35c60237646b41699b991fb62ff0"
"gitHead": "564f9228ca236f310d54e0ed94deee750f52301e"
}
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