Last active
August 26, 2020 16:05
-
-
Save bmeck/358c3def72cbf5b1ce38f95645979c4f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"type": "object", | |
"title": "Node.js Policy Manifest", | |
"description": "https://nodejs.org/api/policy.html", | |
"definitions": { | |
"cascade": { | |
"defaultSnippets": [ | |
{ | |
"label": "Allow scope fall through.", | |
"body": true | |
} | |
], | |
"oneOf": [ | |
{ | |
"description": "If a specifier for a dependency is not found, defer to containing scope's dependencies. If no integrity is supplied, defer to containing scope.", | |
"const": true | |
}, | |
{ | |
"description": "If a specifier for a dependency is not found, error. If no integrity is supplied, error.", | |
"const": false | |
} | |
] | |
}, | |
"urlSpecifier": { | |
"$comment": "a subset of all relative URLs to match new URL($, manifest location)", | |
"oneOf": [ | |
{ | |
"title": "URL to the resource.", | |
"type": "string", | |
"format": "uri", | |
"examples": ["node:fs", "file:///app.js", "data:text/javascript,"] | |
}, | |
{ | |
"title": "URL to the resource, resolved against the manifest location.", | |
"type": "string", | |
"pattern": "^\\.?\\.?/.*$", | |
"examples": ["./foo.js", "../foo.js", "/foo.js", "//foo.js"] | |
} | |
] | |
}, | |
"dependenciesTarget": { | |
"defaultSnippets": [ | |
{ | |
"label": "Error.", | |
"description": "When loading the key as a specifier, error.", | |
"body": null | |
}, | |
{ | |
"label": "Any location.", | |
"description": "When loading the key as a specifier, never error.", | |
"body": true | |
}, | |
{ | |
"label": "Specified location.", | |
"description": "When loading the key as a specifier, load resource at location.", | |
"body": "${1:url}" | |
}, | |
{ | |
"label": "Conditional routing.", | |
"body": "^{\"${1:condition}\": ${2:target}}" | |
} | |
], | |
"oneOf": [ | |
{ | |
"$ref": "#/definitions/urlSpecifier" | |
}, | |
{ | |
"type": "object", | |
"description": "When loading the key as a specifier, use the following conditions to route loading. Keys will be determined by iterating in the order they are declared.", | |
"properties": { | |
"require": { | |
"description": "When using CommonJS require(), load using this mapping.", | |
"$ref": "#/definitions/dependenciesTarget" | |
}, | |
"import": { | |
"description": "When using ECMAScript import, load using this mapping.", | |
"$ref": "#/definitions/dependenciesTarget" | |
}, | |
"node": { | |
"description": "When using Node.js, load using this mapping.", | |
"$ref": "#/definitions/dependenciesTarget" | |
}, | |
"default": { | |
"description": "Always load this mapping.", | |
"$ref": "#/definitions/dependenciesTarget" | |
} | |
}, | |
"additionalProperties": { | |
"$ref": "#/definitions/dependenciesTarget" | |
} | |
}, | |
{ | |
"const": true, | |
"description": "When loading the key as a specifier, load dependency from any location. Meant for development." | |
}, | |
{ | |
"const": null, | |
"description": "When loading the key as a specifier, error." | |
} | |
] | |
}, | |
"dependenciesMap": { | |
"title": "Map of specifiers to resource locations.", | |
"type": "object", | |
"additionalProperties": { | |
"$ref": "#/definitions/dependenciesTarget" | |
} | |
}, | |
"dependencies": { | |
"default": null, | |
"defaultSnippets": [ | |
{ | |
"label": "No dependencies.", | |
"description": "Error if any dependency is attempted to be loaded.", | |
"body": null | |
}, | |
{ | |
"label": "Any dependencies.", | |
"description": "Never error when loading a dependency.", | |
"body": true | |
}, | |
{ | |
"label": "Specified dependencies.", | |
"description": "Allow the specified dependencies. If not found, defer to \"cascade\" for next action.", | |
"body": "^{\"${1:specifier}\": ${2:target}}" | |
} | |
], | |
"oneOf": [ | |
{ | |
"description": "When loading any dependency, error.", | |
"const": null | |
}, | |
{ | |
"description": "When loading any dependency, never error. Meant for development.", | |
"const": true | |
}, | |
{ | |
"$ref": "#/definitions/dependenciesMap" | |
} | |
] | |
} | |
}, | |
"properties": { | |
"onError": { | |
"title": "Behavior when policy manifest is violated.", | |
"default": "throw", | |
"oneOf": [ | |
{ | |
"description": "Exit the process immediately.", | |
"const": "exit" | |
}, | |
{ | |
"description": "Log the violation and continue execution.", | |
"const": "log" | |
}, | |
{ | |
"description": "Turn the violation into an Error and throw an exception.", | |
"const": "throw" | |
} | |
] | |
}, | |
"resources": { | |
"title": "Policies for specific URLs.", | |
"description": "Relative URL strings as keys are resolved against the manifest location.", | |
"type": "object", | |
"propertyNames": { | |
"$ref": "#/definitions/urlSpecifier" | |
}, | |
"additionalProperties": { | |
"type": "object", | |
"properties": { | |
"cascade": { | |
"$ref": "#/definitions/cascade" | |
}, | |
"integrity": { | |
"title": "Expected contents for the body of the resource.", | |
"defaultSnippets": [ | |
{ | |
"label": "Allow any body.", | |
"body": true | |
}, | |
{ | |
"label": "Allow specific bodies.", | |
"body": "${1:integrity string}" | |
} | |
], | |
"oneOf": [ | |
{ | |
"type": "string", | |
"description": "When loading a specific body for this resource, error if it does not match a digest in this sub-resource integrity formatted list.", | |
"pattern": "^\\s*(([\\x20\\x09]*)(?:(sha(?:256|384|512))-([A-Za-z0-9+/]+[=]{0,2})(?:[?]((?:[\\x21-\\x7E]*)))?)($|\\s+))" | |
}, | |
{ | |
"const": true, | |
"description": "When loading a specific body for this resource, never error. Meant for development." | |
} | |
] | |
}, | |
"dependencies": { | |
"$ref": "#/definitions/dependencies" | |
} | |
} | |
} | |
}, | |
"scopes": { | |
"title": "Policies for URL Scopes when cascading.", | |
"description": "Relative URL strings as keys are resolved against the manifest location.", | |
"type": "object", | |
"propertyNames": { | |
"$ref": "#/definitions/urlSpecifier" | |
}, | |
"additionalProperties": { | |
"type": "object", | |
"properties": { | |
"cascade": { | |
"$ref": "#/definitions/cascade" | |
}, | |
"integrity": { | |
"title": "Expected contents for the body of the resource.", | |
"defaultSnippets": [ | |
{ | |
"label": "Allow any body.", | |
"body": true | |
} | |
], | |
"oneOf": [ | |
{ | |
"const": true, | |
"description": "When loading a specific body for a resource, never error. Meant for development." | |
} | |
] | |
}, | |
"dependencies": { | |
"$ref": "#/definitions/dependencies" | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment