Security News
The Dark Side of Open Source
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
@tryghost/admin-api-schema
Advanced tools
Readme
The package serves as a single source of truth when validating requests coming into Ghost's Admin API endpoints. It uses JSON Schema definitions under the hood to describe expected format of validated data.
npm install @tryghost/admin-api-schema --save
or
yarn add @tryghost/admin-api-schema
const jsonSchema = require('@tryghost/admin-api-schema');
// check available schemas
jsonSchema.list()
/*
> [
'images-upload', 'labels-add',
'labels-edit', 'members-add',
'members-edit', 'members-upload',
'pages-add', 'pages-edit',
'posts-add', 'posts-edit',
'tags-add', 'tags-edit',
'webhooks-add', 'webhooks-edit'
]
*/
// get schema definition
jsonSchema.get('tags-edit');
/*
> {
'$schema': 'http://json-schema.org/draft-07/schema#',
'$id': 'tags.edit',
title: 'tags.edit',
description: 'Schema for tags.edit',
type: 'object',
additionalProperties: false,
properties: {
tags: { type: 'array', minItems: 1, maxItems: 1, items: [Object] }
},
required: [ 'tags' ]
}
*/
// validate data
const data = {
posts: [{
title: 'valid'
}]
};
try {
await apiSchema.validate({data, schema: 'posts-add'});
} catch (err) {
console.log('validateion error:', err);
}
When used from Ghost core in validation layer:
const jsonSchema = require('@tryghost/admin-api-schema');
const validate = async (apiConfig, frame) => await jsonSchema.validate({
data: frame.data,
schema: `${apiConfig.docName}-${apiConfig.method}`
});
This is a mono repository, managed with lerna.
Follow the instructions for the top-level repo.
git clone
this repo & cd
into it as usualyarn
to install top-level dependencies.yarn dev
yarn lint
run just eslintyarn test
run lint and testsCopyright (c) 2013-2023 Ghost Foundation - Released under the MIT license.
FAQs
The package serves as a single source of truth when validating requests coming into Ghost's Admin API endpoints. It uses [JSON Schema](https://json-schema.org/) definitions under the hood to describe expected format of validated data.
The npm package @tryghost/admin-api-schema receives a total of 2,687 weekly downloads. As such, @tryghost/admin-api-schema popularity was classified as popular.
We found that @tryghost/admin-api-schema demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 28 open source maintainers collaborating on the project.
Did you know?
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.
Security News
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.