1
0
Fork 0
mirror of synced 2024-06-26 18:10:51 +12:00

Add validation to plugins uploaded using file upload and allow component uploads via non-file sources in cloud

This commit is contained in:
Andrew Kingston 2022-09-14 11:58:59 +01:00
parent 7314790839
commit 917ce9e177

View file

@ -53,10 +53,6 @@ export async function upload(ctx: any) {
export async function create(ctx: any) {
const { source, url, headers, githubToken } = ctx.request.body
if (!env.SELF_HOSTED) {
ctx.throw(400, "Plugins not supported outside of self-host.")
}
try {
let metadata
let directory
@ -87,6 +83,13 @@ export async function create(ctx: any) {
validate(metadata?.schema)
// Only allow components in cloud
if (!env.SELF_HOSTED && metadata?.schema?.type !== PluginType.COMPONENT) {
throw new Error(
"Only component plugins are supported outside of self-host"
)
}
const doc = await storePlugin(metadata, directory, source)
ctx.body = {
@ -198,6 +201,7 @@ export async function storePlugin(
export async function processPlugin(plugin: FileType, source?: string) {
const { metadata, directory } = await fileUpload(plugin)
validate(metadata?.schema)
// Only allow components in cloud
if (!env.SELF_HOSTED && metadata?.schema?.type !== PluginType.COMPONENT) {