codify-plugin-lib 1.0.57 → 1.0.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/entities/errors.d.ts +4 -0
- package/dist/entities/errors.js +7 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/messages/handlers.js +8 -0
- package/package.json +1 -1
- package/src/entities/errors.ts +8 -0
- package/src/index.ts +1 -0
- package/src/messages/handlers.ts +9 -0
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from './entities/change-set.js';
|
|
|
6
6
|
export * from './entities/plan.js';
|
|
7
7
|
export * from './entities/plan-types.js';
|
|
8
8
|
export * from './entities/stateful-parameter.js';
|
|
9
|
+
export * from './entities/errors.js';
|
|
9
10
|
export * from './utils/test-utils.js';
|
|
10
11
|
export * from './utils/utils.js';
|
|
11
12
|
export declare function runPlugin(plugin: Plugin): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export * from './entities/change-set.js';
|
|
|
6
6
|
export * from './entities/plan.js';
|
|
7
7
|
export * from './entities/plan-types.js';
|
|
8
8
|
export * from './entities/stateful-parameter.js';
|
|
9
|
+
export * from './entities/errors.js';
|
|
9
10
|
export * from './utils/test-utils.js';
|
|
10
11
|
export * from './utils/utils.js';
|
|
11
12
|
export async function runPlugin(plugin) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import addFormats from 'ajv-formats';
|
|
2
2
|
import { ApplyRequestDataSchema, ApplyResponseDataSchema, InitializeRequestDataSchema, InitializeResponseDataSchema, IpcMessageSchema, MessageStatus, PlanRequestDataSchema, PlanResponseDataSchema, ResourceSchema, ValidateRequestDataSchema, ValidateResponseDataSchema } from 'codify-schemas';
|
|
3
3
|
import Ajv2020 from 'ajv/dist/2020.js';
|
|
4
|
+
import { SudoError } from '../entities/errors.js';
|
|
4
5
|
const SupportedRequests = {
|
|
5
6
|
'initialize': {
|
|
6
7
|
requestValidator: InitializeRequestDataSchema,
|
|
@@ -81,6 +82,13 @@ export class MessageHandler {
|
|
|
81
82
|
return;
|
|
82
83
|
}
|
|
83
84
|
const cmd = message.cmd + '_Response';
|
|
85
|
+
if (e instanceof SudoError) {
|
|
86
|
+
process.send?.({
|
|
87
|
+
cmd,
|
|
88
|
+
status: MessageStatus.ERROR,
|
|
89
|
+
data: `Plugin: '${this.plugin.name}'. Forbidden usage of sudo for command '${e.command}'. Please contact the plugin developer to fix this.`,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
84
92
|
const isDebug = process.env.DEBUG?.includes('*') ?? false;
|
|
85
93
|
process.send?.({
|
|
86
94
|
cmd,
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -8,6 +8,7 @@ export * from './entities/change-set.js'
|
|
|
8
8
|
export * from './entities/plan.js'
|
|
9
9
|
export * from './entities/plan-types.js'
|
|
10
10
|
export * from './entities/stateful-parameter.js'
|
|
11
|
+
export * from './entities/errors.js'
|
|
11
12
|
|
|
12
13
|
export * from './utils/test-utils.js'
|
|
13
14
|
export * from './utils/utils.js'
|
package/src/messages/handlers.ts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
ValidateResponseDataSchema
|
|
16
16
|
} from 'codify-schemas';
|
|
17
17
|
import Ajv2020, { SchemaObject, ValidateFunction } from 'ajv/dist/2020.js';
|
|
18
|
+
import { SudoError } from '../entities/errors.js';
|
|
18
19
|
|
|
19
20
|
const SupportedRequests: Record<string, { requestValidator: SchemaObject; responseValidator: SchemaObject; handler: (plugin: Plugin, data: any) => Promise<unknown> }> = {
|
|
20
21
|
'initialize': {
|
|
@@ -115,6 +116,14 @@ export class MessageHandler {
|
|
|
115
116
|
// @ts-ignore
|
|
116
117
|
const cmd = message.cmd + '_Response';
|
|
117
118
|
|
|
119
|
+
if (e instanceof SudoError) {
|
|
120
|
+
process.send?.({
|
|
121
|
+
cmd,
|
|
122
|
+
status: MessageStatus.ERROR,
|
|
123
|
+
data: `Plugin: '${this.plugin.name}'. Forbidden usage of sudo for command '${e.command}'. Please contact the plugin developer to fix this.`,
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
|
|
118
127
|
const isDebug = process.env.DEBUG?.includes('*') ?? false;
|
|
119
128
|
|
|
120
129
|
process.send?.({
|