@socketsecurity/config
TypeScript icon, indicating that this package has built-in type declarations

2.1.3 • Public • Published

Socket Config

Socket Badge npm version js-standard-style Types in JS Follow @SocketSecurity

Reader/parser/validator tool for Socket.dev's socket.yml configuration files

Usage

npm install @socketsecurity/config
import { readSocketConfig } from '@socketsecurity/config'

const config = await readSocketConfig('socket.yml')

Exports

readSocketConfig(<path-to-config-file>)

Returns a Promise that resolves to the parsed config file or, if no such file was found, it fails silently and returns undefined.

If the config file can't be read, then the Promise will be rejected with an error.

The read file is parsed using parseSocketConfigand the Promise from there is what is ultimately returned when no rejection or resolve has been made already.

parseSocketConfig(<content-of-config-file>)

Returns a Promise that resolves to the parsed config.

If the config content can't be parsed or it is invalid, then the Promise will be rejected with an error.

Any additional parameters that does not conform to the schema will be silently dropped. Also: Input data will be coerced into its intended shape when possible.

socketYmlSchema

A JSON Schema object typed with JSONSchemaType<SocketYml> from Ajv

SocketValidationError

Error thrown when the parsed data doesn't conform to the JSON Schema definition.

Extends Error and adds these additional properties:

  • data – the data that's found to be invalid
  • schema – the schema used to validate the content
  • validationErrors – an array of Ajv's ErrorObject

Type exports

This module has full type coverage through a types in js where TypeScript validates JSDoc annotated javascript and exports it as standard type definition files.

SocketYml

A TypeScript type representing the shape of the parsed socket.yml config

Used by

See also

Readme

Keywords

none

Package Sidebar

Install

npm i @socketsecurity/config

Weekly Downloads

196

Version

2.1.3

License

MIT

Unpacked Size

17.5 kB

Total Files

10

Last publish

Collaborators

  • jhiesey
  • socket-bot
  • bradleymeck
  • alxhotel
  • feross