@attraccess/plugins-backend-sdk 1.9.0 → 1.11.0-beta.0
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/package.json +8 -3
- package/src/index.d.ts +8 -0
- package/src/index.js +8 -0
- package/src/index.js.map +1 -1
- package/src/lib/auth-decorator.d.ts +4 -0
- package/src/lib/auth-decorator.js +20 -5
- package/src/lib/auth-decorator.js.map +1 -1
- package/src/lib/auth.types.d.ts +2 -0
- package/src/lib/mqtt-credential-provisioning.d.ts +52 -0
- package/src/lib/mqtt-credential-provisioning.js +5 -0
- package/src/lib/mqtt-credential-provisioning.js.map +1 -0
- package/src/lib/plugin-audit.d.ts +94 -0
- package/src/lib/plugin-audit.js +170 -0
- package/src/lib/plugin-audit.js.map +1 -0
- package/src/lib/plugin-backend-module.d.ts +66 -0
- package/src/lib/plugin-backend-module.js +3 -0
- package/src/lib/plugin-backend-module.js.map +1 -0
- package/src/lib/plugin-context.d.ts +109 -33
- package/src/lib/plugin-context.js +6 -6
- package/src/lib/plugin-context.js.map +1 -1
- package/src/lib/plugin-flow-node.d.ts +172 -0
- package/src/lib/plugin-flow-node.js +12 -0
- package/src/lib/plugin-flow-node.js.map +1 -0
- package/src/lib/plugin-live-updates.d.ts +21 -0
- package/src/lib/plugin-live-updates.js +3 -0
- package/src/lib/plugin-live-updates.js.map +1 -0
- package/src/lib/plugin-notifications.d.ts +83 -0
- package/src/lib/plugin-notifications.js +3 -0
- package/src/lib/plugin-notifications.js.map +1 -0
- package/src/lib/plugin-resource-access.d.ts +89 -0
- package/src/lib/plugin-resource-access.js +3 -0
- package/src/lib/plugin-resource-access.js.map +1 -0
- package/src/lib/plugin.interface.d.ts +78 -5
- package/src/lib/plugin.interface.js +26 -1
- package/src/lib/plugin.interface.js.map +1 -1
- package/src/lib/reader-ui.d.ts +317 -0
- package/src/lib/reader-ui.js +115 -0
- package/src/lib/reader-ui.js.map +1 -0
- package/src/lib/shared-live-sampler.d.ts +11 -0
- package/src/lib/shared-live-sampler.js +33 -0
- package/src/lib/shared-live-sampler.js.map +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@attraccess/plugins-backend-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0-beta.0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/Attraccess/Attraccess.git",
|
|
7
|
+
"directory": "libs/plugins-backend-sdk"
|
|
8
|
+
},
|
|
4
9
|
"type": "commonjs",
|
|
5
10
|
"main": "./src/index.js",
|
|
6
11
|
"types": "./src/index.d.ts",
|
|
@@ -21,14 +26,14 @@
|
|
|
21
26
|
],
|
|
22
27
|
"dependencies": {
|
|
23
28
|
"tslib": "^2.8.1",
|
|
24
|
-
"@attraccess/database-entities": "
|
|
29
|
+
"@attraccess/database-entities": "1.11.0-beta.0",
|
|
25
30
|
"@nestjs/common": "^11.1.0",
|
|
26
31
|
"@nestjs/event-emitter": "^3.1.0",
|
|
27
32
|
"rxjs": "^7.8.2",
|
|
28
33
|
"@nestjs/core": "^11.1.0",
|
|
29
34
|
"typeorm": "0.3.31",
|
|
30
35
|
"@nestjs/swagger": "^11.2.0",
|
|
31
|
-
"express": "4.22.
|
|
36
|
+
"express": "4.22.3",
|
|
32
37
|
"@nestjs/passport": "^11.0.5",
|
|
33
38
|
"@attraccess/shared": "*"
|
|
34
39
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
export * from './lib/plugin.interface';
|
|
2
|
+
export * from './lib/plugin-flow-node';
|
|
2
3
|
export * from './lib/plugin-context';
|
|
4
|
+
export * from './lib/plugin-live-updates';
|
|
5
|
+
export * from './lib/shared-live-sampler';
|
|
6
|
+
export * from './lib/plugin-audit';
|
|
7
|
+
export * from './lib/mqtt-credential-provisioning';
|
|
3
8
|
export * from './lib/plugin-migrations';
|
|
4
9
|
export * from './lib/entity';
|
|
5
10
|
export * from './lib/semver';
|
|
11
|
+
export * from './lib/reader-ui';
|
|
12
|
+
export * from './lib/plugin-notifications';
|
|
13
|
+
export * from './lib/plugin-resource-access';
|
|
6
14
|
export * from './lib/auth-decorator';
|
|
7
15
|
export * from '@attraccess/database-entities';
|
|
8
16
|
export * as entities from '@attraccess/database-entities';
|
package/src/index.js
CHANGED
|
@@ -3,10 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.entities = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
tslib_1.__exportStar(require("./lib/plugin.interface"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./lib/plugin-flow-node"), exports);
|
|
6
7
|
tslib_1.__exportStar(require("./lib/plugin-context"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./lib/plugin-live-updates"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./lib/shared-live-sampler"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./lib/plugin-audit"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./lib/mqtt-credential-provisioning"), exports);
|
|
7
12
|
tslib_1.__exportStar(require("./lib/plugin-migrations"), exports);
|
|
8
13
|
tslib_1.__exportStar(require("./lib/entity"), exports);
|
|
9
14
|
tslib_1.__exportStar(require("./lib/semver"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./lib/reader-ui"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./lib/plugin-notifications"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./lib/plugin-resource-access"), exports);
|
|
10
18
|
tslib_1.__exportStar(require("./lib/auth-decorator"), exports);
|
|
11
19
|
tslib_1.__exportStar(require("@attraccess/database-entities"), exports);
|
|
12
20
|
exports.entities = tslib_1.__importStar(require("@attraccess/database-entities"));
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/plugins-backend-sdk/src/index.ts"],"names":[],"mappings":";;;;AAAA,iEAAuC;AACvC,+DAAqC;AACrC,kEAAwC;AACxC,uDAA6B;AAC7B,uDAA6B;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/plugins-backend-sdk/src/index.ts"],"names":[],"mappings":";;;;AAAA,iEAAuC;AACvC,iEAAuC;AACvC,+DAAqC;AACrC,oEAA0C;AAC1C,oEAA0C;AAC1C,6DAAmC;AACnC,6EAAmD;AACnD,kEAAwC;AACxC,uDAA6B;AAC7B,uDAA6B;AAC7B,0DAAgC;AAChC,qEAA2C;AAC3C,uEAA6C;AAE7C,+DAAqC;AACrC,wEAA8C;AAC9C,kFAA0D;AAC1D,2DAAiC;AACjC,gEAAsC"}
|
|
@@ -5,10 +5,14 @@ import { SystemPermission } from '@attraccess/shared';
|
|
|
5
5
|
export type { SystemPermission };
|
|
6
6
|
export declare function Auth(...permissions: SystemPermission[]): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
7
7
|
export declare function AuthAny(...permissions: SystemPermission[]): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
8
|
+
export declare function SessionAuth(...permissions: SystemPermission[]): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
8
9
|
export declare class EffectivePermissionsGuard implements CanActivate {
|
|
9
10
|
private reflector;
|
|
10
11
|
private readonly logger;
|
|
11
12
|
constructor(reflector: Reflector);
|
|
12
13
|
canActivate(context: ExecutionContext): boolean | Promise<boolean> | Observable<boolean>;
|
|
13
14
|
}
|
|
15
|
+
export declare class SessionOnlyGuard implements CanActivate {
|
|
16
|
+
canActivate(context: ExecutionContext): boolean;
|
|
17
|
+
}
|
|
14
18
|
export declare const SystemPermissionsGuard: typeof EffectivePermissionsGuard;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var EffectivePermissionsGuard_1;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.SystemPermissionsGuard = exports.EffectivePermissionsGuard = void 0;
|
|
4
|
+
exports.SystemPermissionsGuard = exports.SessionOnlyGuard = exports.EffectivePermissionsGuard = void 0;
|
|
5
5
|
exports.Auth = Auth;
|
|
6
6
|
exports.AuthAny = AuthAny;
|
|
7
|
+
exports.SessionAuth = SessionAuth;
|
|
7
8
|
const tslib_1 = require("tslib");
|
|
8
9
|
const common_1 = require("@nestjs/common");
|
|
9
10
|
const core_1 = require("@nestjs/core");
|
|
@@ -17,16 +18,16 @@ function Auth(...permissions) {
|
|
|
17
18
|
function AuthAny(...permissions) {
|
|
18
19
|
return (0, common_1.applyDecorators)(NeedsAnyPermission(permissions), (0, common_1.UseGuards)(dual_auth_guard_1.DualAuthGuard, EffectivePermissionsGuard), (0, swagger_1.ApiBearerAuth)(), (0, swagger_1.ApiUnauthorizedResponse)({ description: 'Unauthorized' }));
|
|
19
20
|
}
|
|
21
|
+
function SessionAuth(...permissions) {
|
|
22
|
+
return (0, common_1.applyDecorators)(NeedsPermissions(permissions), (0, common_1.UseGuards)(dual_auth_guard_1.DualAuthGuard, EffectivePermissionsGuard, SessionOnlyGuard), (0, swagger_1.ApiBearerAuth)(), (0, swagger_1.ApiUnauthorizedResponse)({ description: 'Unauthorized' }));
|
|
23
|
+
}
|
|
20
24
|
let EffectivePermissionsGuard = EffectivePermissionsGuard_1 = class EffectivePermissionsGuard {
|
|
21
25
|
constructor(reflector) {
|
|
22
26
|
this.reflector = reflector;
|
|
23
27
|
this.logger = new common_1.Logger(EffectivePermissionsGuard_1.name);
|
|
24
28
|
}
|
|
25
29
|
canActivate(context) {
|
|
26
|
-
const requiredAll = this.reflector.getAllAndOverride(NeedsPermissions, [
|
|
27
|
-
context.getHandler(),
|
|
28
|
-
context.getClass(),
|
|
29
|
-
]);
|
|
30
|
+
const requiredAll = this.reflector.getAllAndOverride(NeedsPermissions, [context.getHandler(), context.getClass()]);
|
|
30
31
|
const requiredAny = this.reflector.getAllAndOverride(NeedsAnyPermission, [
|
|
31
32
|
context.getHandler(),
|
|
32
33
|
context.getClass(),
|
|
@@ -62,5 +63,19 @@ exports.EffectivePermissionsGuard = EffectivePermissionsGuard = EffectivePermiss
|
|
|
62
63
|
(0, common_1.Injectable)(),
|
|
63
64
|
tslib_1.__metadata("design:paramtypes", [core_1.Reflector])
|
|
64
65
|
], EffectivePermissionsGuard);
|
|
66
|
+
let SessionOnlyGuard = class SessionOnlyGuard {
|
|
67
|
+
canActivate(context) {
|
|
68
|
+
const request = context.switchToHttp().getRequest();
|
|
69
|
+
const user = request.user;
|
|
70
|
+
if ((user === null || user === void 0 ? void 0 : user.authenticationMethod) !== 'session') {
|
|
71
|
+
throw new common_1.ForbiddenException('Session authentication required');
|
|
72
|
+
}
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
exports.SessionOnlyGuard = SessionOnlyGuard;
|
|
77
|
+
exports.SessionOnlyGuard = SessionOnlyGuard = tslib_1.__decorate([
|
|
78
|
+
(0, common_1.Injectable)()
|
|
79
|
+
], SessionOnlyGuard);
|
|
65
80
|
exports.SystemPermissionsGuard = EffectivePermissionsGuard;
|
|
66
81
|
//# sourceMappingURL=auth-decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-decorator.js","sourceRoot":"","sources":["../../../../../libs/plugins-backend-sdk/src/lib/auth-decorator.ts"],"names":[],"mappings":";;;;AAuBA,oBAOC;AAED,0BAOC;;
|
|
1
|
+
{"version":3,"file":"auth-decorator.js","sourceRoot":"","sources":["../../../../../libs/plugins-backend-sdk/src/lib/auth-decorator.ts"],"names":[],"mappings":";;;;AAuBA,oBAOC;AAED,0BAOC;AAED,kCAOC;;AAhDD,2CASwB;AAExB,uCAAyC;AAEzC,6CAAyE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AAG,CAAC,EAAE,CAAC;YAC1C,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,WAAC,OAAA,MAAA,IAAI,CAAC,oBAAoB,0CAAE,GAAG,CAAC,CAAC,CAAC,CAAA,EAAA,CAAC,CAAC;YAC1E,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC,EAAE,0CAA0C,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBACrG,MAAM,IAAI,2BAAkB,CAAC,0BAA0B,CAAC,CAAC;YAC3D,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AA1CY,8DAAyB;oCAAzB,yBAAyB;IADrC,IAAA,mBAAU,GAAE;6CAIoB,gBAAS;GAH7B,yBAAyB,CA0CrC;AAGM,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAC3B,WAAW,CAAC,OAAyB;QACnC,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QACpD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAqC,CAAC;QAE3D,IAAI,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,oBAAoB,MAAK,SAAS,EAAE,CAAC;YAC7C,MAAM,IAAI,2BAAkB,CAAC,iCAAiC,CAAC,CAAC;QAClE,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAXY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;GACA,gBAAgB,CAW5B;AAEY,QAAA,sBAAsB,GAAG,yBAAyB,CAAC"}
|
package/src/lib/auth.types.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { User } from '@attraccess/database-entities';
|
|
|
2
2
|
import { Request as BaseRequest } from 'express';
|
|
3
3
|
export interface AuthenticatedUser extends User {
|
|
4
4
|
jwtTokenId: string;
|
|
5
|
+
authenticationMethod?: 'session' | 'api-token';
|
|
6
|
+
apiTokenId?: number;
|
|
5
7
|
/**
|
|
6
8
|
* Effective permissions for this user. Stored as a Set for O(1) has() lookups.
|
|
7
9
|
* Note: A plain Set serializes as {} in JSON — spread to an array before including in any HTTP response.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { MqttServerConnectionConfig, PluginContext } from './plugin-context';
|
|
2
|
+
/** Broker-neutral topic policy supplied by an integration for one MQTT identity. */
|
|
3
|
+
export interface MqttTopicPolicy {
|
|
4
|
+
readonly publish: readonly string[];
|
|
5
|
+
readonly subscribe: readonly string[];
|
|
6
|
+
}
|
|
7
|
+
/** The broker identity an integration wants to install on a device. */
|
|
8
|
+
export interface MqttCredentialRequest {
|
|
9
|
+
readonly mqttServerId: number;
|
|
10
|
+
readonly identity: string;
|
|
11
|
+
readonly username: string;
|
|
12
|
+
readonly vhost: string;
|
|
13
|
+
readonly topicPolicy: MqttTopicPolicy;
|
|
14
|
+
}
|
|
15
|
+
/** The password is deliberately present only on create and rotate responses. */
|
|
16
|
+
export interface ProvisionedMqttCredential {
|
|
17
|
+
readonly providerId: string;
|
|
18
|
+
readonly identity: string;
|
|
19
|
+
readonly username: string;
|
|
20
|
+
readonly vhost: string;
|
|
21
|
+
readonly password: string;
|
|
22
|
+
}
|
|
23
|
+
/** A provider supplied by a broker plugin. It never exposes broker details to integrations. */
|
|
24
|
+
export interface MqttCredentialProvisioningProvider {
|
|
25
|
+
readonly id: string;
|
|
26
|
+
readonly displayName: string;
|
|
27
|
+
supports(config: MqttServerConnectionConfig): Promise<boolean>;
|
|
28
|
+
provision(request: MqttCredentialRequest): Promise<ProvisionedMqttCredential>;
|
|
29
|
+
rotate(request: MqttCredentialRequest): Promise<ProvisionedMqttCredential>;
|
|
30
|
+
revoke(request: Pick<MqttCredentialRequest, 'mqttServerId' | 'identity' | 'username' | 'vhost'>): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
export declare const MQTT_CREDENTIAL_PROVISIONING_HOST_PROVIDER: unique symbol;
|
|
33
|
+
/** Host seam through which integrations discover and use broker providers. */
|
|
34
|
+
export interface MqttCredentialProvisioningHostProvider {
|
|
35
|
+
availableProviders(mqttServerId: number): Promise<readonly {
|
|
36
|
+
providerId: string;
|
|
37
|
+
displayName: string;
|
|
38
|
+
}[]>;
|
|
39
|
+
provision(request: MqttCredentialRequest): Promise<ProvisionedMqttCredential | ManualMqttCredentialInstructions>;
|
|
40
|
+
rotate(request: MqttCredentialRequest): Promise<ProvisionedMqttCredential | ManualMqttCredentialInstructions>;
|
|
41
|
+
revoke(request: Pick<MqttCredentialRequest, 'mqttServerId' | 'identity' | 'username' | 'vhost'>): Promise<void | ManualMqttCredentialInstructions>;
|
|
42
|
+
}
|
|
43
|
+
export interface ManualMqttCredentialInstructions {
|
|
44
|
+
readonly mqttServerId: number;
|
|
45
|
+
readonly username: string;
|
|
46
|
+
readonly vhost: string;
|
|
47
|
+
readonly publishTopics: readonly string[];
|
|
48
|
+
readonly subscribeTopics: readonly string[];
|
|
49
|
+
readonly instructions: readonly string[];
|
|
50
|
+
}
|
|
51
|
+
/** Factory keeps provider dependencies private to the plugin that owns them. */
|
|
52
|
+
export type MqttCredentialProvisioningProviderFactory = (context: PluginContext) => MqttCredentialProvisioningProvider;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MQTT_CREDENTIAL_PROVISIONING_HOST_PROVIDER = void 0;
|
|
4
|
+
exports.MQTT_CREDENTIAL_PROVISIONING_HOST_PROVIDER = Symbol.for('attraccess.plugin.mqttCredentialProvisioningHostProvider');
|
|
5
|
+
//# sourceMappingURL=mqtt-credential-provisioning.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mqtt-credential-provisioning.js","sourceRoot":"","sources":["../../../../../libs/plugins-backend-sdk/src/lib/mqtt-credential-provisioning.ts"],"names":[],"mappings":";;;AAoCa,QAAA,0CAA0C,GAAG,MAAM,CAAC,GAAG,CAAC,0DAA0D,CAAC,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declarative audit policy a plugin contributes through `PluginBackendModule.auditDomains`.
|
|
3
|
+
* The host registers the declaration, then enforces it on every event the plugin records:
|
|
4
|
+
* only declared actions, subject types and detail fields are accepted, so a plugin can
|
|
5
|
+
* never write arbitrary JSON into the audit log. The host additionally applies generic
|
|
6
|
+
* bounds (identifier shapes, detail size) and rejects events whose pluginId does not own
|
|
7
|
+
* the domain.
|
|
8
|
+
*/
|
|
9
|
+
/** Domain identifiers are lowercase snake_case and prefix every action and subject type. */
|
|
10
|
+
export declare const PLUGIN_AUDIT_DOMAIN_PATTERN: RegExp;
|
|
11
|
+
/** One dot-separated segment of an action or subject type name. */
|
|
12
|
+
export declare const PLUGIN_AUDIT_SEGMENT_PATTERN: RegExp;
|
|
13
|
+
/** Detail field name: camelCase segments, optionally dot-prefixed (e.g. `before.count`). */
|
|
14
|
+
export declare const PLUGIN_AUDIT_FIELD_PATTERN: RegExp;
|
|
15
|
+
export declare const PLUGIN_AUDIT_LIMITS: {
|
|
16
|
+
readonly domainsPerPlugin: 4;
|
|
17
|
+
readonly actionsPerDomain: 64;
|
|
18
|
+
readonly subjectTypesPerAction: 8;
|
|
19
|
+
readonly fieldsPerAction: 32;
|
|
20
|
+
readonly oneOfEntries: 64;
|
|
21
|
+
readonly patternLength: 512;
|
|
22
|
+
readonly maxLengthCeiling: 4096;
|
|
23
|
+
readonly labelLocales: 8;
|
|
24
|
+
readonly labelLength: 120;
|
|
25
|
+
readonly actionLength: 128;
|
|
26
|
+
};
|
|
27
|
+
export interface PluginAuditFieldPolicy {
|
|
28
|
+
readonly type: 'string' | 'number' | 'boolean';
|
|
29
|
+
/** Full-match regex source; the host anchors it. Strings only. */
|
|
30
|
+
readonly pattern?: string;
|
|
31
|
+
/** Closed value set; entries must match `type`. */
|
|
32
|
+
readonly oneOf?: readonly (string | number)[];
|
|
33
|
+
/** Inclusive numeric bounds. Numbers only. */
|
|
34
|
+
readonly min?: number;
|
|
35
|
+
readonly max?: number;
|
|
36
|
+
/** Reject non-integers. Numbers only. */
|
|
37
|
+
readonly integer?: boolean;
|
|
38
|
+
/** Inclusive UTF-16 code-unit bound. Strings only. */
|
|
39
|
+
readonly maxLength?: number;
|
|
40
|
+
}
|
|
41
|
+
export interface PluginAuditActionPolicy {
|
|
42
|
+
/** Full action name; must start with `${domain}.`. */
|
|
43
|
+
readonly action: string;
|
|
44
|
+
/** Subject types accepted for this action; each must start with `${domain}.`. */
|
|
45
|
+
readonly subjectTypes: readonly string[];
|
|
46
|
+
/** Allowed detail fields. Events carrying any other field are rejected. */
|
|
47
|
+
readonly details?: Readonly<Record<string, PluginAuditFieldPolicy>>;
|
|
48
|
+
}
|
|
49
|
+
export interface PluginAuditDomainDeclaration {
|
|
50
|
+
/** Lowercase identifier; becomes the audit domain and the action/subject-type prefix. */
|
|
51
|
+
readonly domain: string;
|
|
52
|
+
/** Optional human-readable domain labels keyed by locale (e.g. `{ en: 'Demo devices' }`). */
|
|
53
|
+
readonly labels?: Readonly<Record<string, string>>;
|
|
54
|
+
readonly actions: readonly PluginAuditActionPolicy[];
|
|
55
|
+
}
|
|
56
|
+
/** Implemented by the generic audit foundation, not by individual plugins. */
|
|
57
|
+
export declare const PLUGIN_AUDIT_HOST_PROVIDER: unique symbol;
|
|
58
|
+
export interface PluginAuditPrincipal {
|
|
59
|
+
userId: number;
|
|
60
|
+
authenticationMethod: 'session' | 'api-token';
|
|
61
|
+
apiTokenId?: number;
|
|
62
|
+
}
|
|
63
|
+
export interface PluginAuditEvent {
|
|
64
|
+
action: string;
|
|
65
|
+
operationId: string;
|
|
66
|
+
principal: PluginAuditPrincipal;
|
|
67
|
+
outcome: 'attempted' | 'succeeded' | 'failed';
|
|
68
|
+
subject: {
|
|
69
|
+
type: string;
|
|
70
|
+
id: number;
|
|
71
|
+
};
|
|
72
|
+
/** Callers must project domain data through an explicit allowlist. */
|
|
73
|
+
details: Readonly<Record<string, string | number | boolean | null>>;
|
|
74
|
+
}
|
|
75
|
+
/** Only `recorded` means the host durably accepted the event. */
|
|
76
|
+
export type PluginAuditReceipt = {
|
|
77
|
+
status: 'recorded';
|
|
78
|
+
} | {
|
|
79
|
+
status: 'unavailable';
|
|
80
|
+
};
|
|
81
|
+
export interface PluginAuditContext {
|
|
82
|
+
record(event: PluginAuditEvent): Promise<PluginAuditReceipt>;
|
|
83
|
+
}
|
|
84
|
+
export interface PluginAuditHostProvider {
|
|
85
|
+
record(event: PluginAuditEvent & {
|
|
86
|
+
pluginId: string;
|
|
87
|
+
}): Promise<PluginAuditReceipt>;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Validates one plugin-contributed audit domain declaration and returns it unchanged.
|
|
91
|
+
* Throws a descriptive error on any violation; hosts quarantine the plugin in that case.
|
|
92
|
+
* Cross-domain concerns (collisions with core or other plugins) are checked by the host registry.
|
|
93
|
+
*/
|
|
94
|
+
export declare function validatePluginAuditDomainDeclaration<T extends PluginAuditDomainDeclaration>(declaration: T): T;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Declarative audit policy a plugin contributes through `PluginBackendModule.auditDomains`.
|
|
4
|
+
* The host registers the declaration, then enforces it on every event the plugin records:
|
|
5
|
+
* only declared actions, subject types and detail fields are accepted, so a plugin can
|
|
6
|
+
* never write arbitrary JSON into the audit log. The host additionally applies generic
|
|
7
|
+
* bounds (identifier shapes, detail size) and rejects events whose pluginId does not own
|
|
8
|
+
* the domain.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.PLUGIN_AUDIT_HOST_PROVIDER = exports.PLUGIN_AUDIT_LIMITS = exports.PLUGIN_AUDIT_FIELD_PATTERN = exports.PLUGIN_AUDIT_SEGMENT_PATTERN = exports.PLUGIN_AUDIT_DOMAIN_PATTERN = void 0;
|
|
12
|
+
exports.validatePluginAuditDomainDeclaration = validatePluginAuditDomainDeclaration;
|
|
13
|
+
/** Domain identifiers are lowercase snake_case and prefix every action and subject type. */
|
|
14
|
+
exports.PLUGIN_AUDIT_DOMAIN_PATTERN = /^[a-z][a-z_]{0,31}$/;
|
|
15
|
+
/** One dot-separated segment of an action or subject type name. */
|
|
16
|
+
exports.PLUGIN_AUDIT_SEGMENT_PATTERN = /^[a-z][a-z0-9_-]{0,63}$/;
|
|
17
|
+
/** Detail field name: camelCase segments, optionally dot-prefixed (e.g. `before.count`). */
|
|
18
|
+
exports.PLUGIN_AUDIT_FIELD_PATTERN = /^[a-z][a-zA-Z0-9]*(?:\.[a-z][a-zA-Z0-9]*)*$/;
|
|
19
|
+
exports.PLUGIN_AUDIT_LIMITS = {
|
|
20
|
+
domainsPerPlugin: 4,
|
|
21
|
+
actionsPerDomain: 64,
|
|
22
|
+
subjectTypesPerAction: 8,
|
|
23
|
+
fieldsPerAction: 32,
|
|
24
|
+
oneOfEntries: 64,
|
|
25
|
+
patternLength: 512,
|
|
26
|
+
maxLengthCeiling: 4096,
|
|
27
|
+
labelLocales: 8,
|
|
28
|
+
labelLength: 120,
|
|
29
|
+
actionLength: 128,
|
|
30
|
+
};
|
|
31
|
+
const isPlainRecord = (value) => {
|
|
32
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
33
|
+
return false;
|
|
34
|
+
const prototype = Object.getPrototypeOf(value);
|
|
35
|
+
return prototype === Object.prototype || prototype === null;
|
|
36
|
+
};
|
|
37
|
+
function validateFieldChoices(path, policy, declared) {
|
|
38
|
+
if (policy.pattern !== undefined) {
|
|
39
|
+
if (declared !== 'string')
|
|
40
|
+
throw new Error(`${path}: pattern requires type 'string'`);
|
|
41
|
+
if (typeof policy.pattern !== 'string' || policy.pattern.length > exports.PLUGIN_AUDIT_LIMITS.patternLength)
|
|
42
|
+
throw new Error(`${path}: pattern must be a string of at most ${exports.PLUGIN_AUDIT_LIMITS.patternLength} characters`);
|
|
43
|
+
try {
|
|
44
|
+
new RegExp(policy.pattern);
|
|
45
|
+
}
|
|
46
|
+
catch (_a) {
|
|
47
|
+
throw new Error(`${path}: pattern is not a valid regular expression`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (policy.oneOf !== undefined) {
|
|
51
|
+
const entries = policy.oneOf;
|
|
52
|
+
if (!Array.isArray(entries) ||
|
|
53
|
+
entries.length === 0 ||
|
|
54
|
+
entries.length > exports.PLUGIN_AUDIT_LIMITS.oneOfEntries ||
|
|
55
|
+
entries.some((entry) => typeof entry !== declared))
|
|
56
|
+
throw new Error(`${path}: oneOf must be 1-${exports.PLUGIN_AUDIT_LIMITS.oneOfEntries} values of type '${declared}'`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function validateFieldPolicy(path, policy) {
|
|
60
|
+
if (!isPlainRecord(policy))
|
|
61
|
+
throw new Error(`${path}: field policy must be a plain object`);
|
|
62
|
+
const declared = policy.type;
|
|
63
|
+
if (declared !== 'string' && declared !== 'number' && declared !== 'boolean')
|
|
64
|
+
throw new Error(`${path}: field type must be 'string', 'number' or 'boolean'`);
|
|
65
|
+
const keys = Object.keys(policy);
|
|
66
|
+
for (const key of keys)
|
|
67
|
+
if (!['type', 'pattern', 'oneOf', 'min', 'max', 'integer', 'maxLength'].includes(key))
|
|
68
|
+
throw new Error(`${path}: unknown field policy property "${key}"`);
|
|
69
|
+
validateFieldChoices(path, policy, declared);
|
|
70
|
+
for (const bound of ['min', 'max'])
|
|
71
|
+
if (policy[bound] !== undefined) {
|
|
72
|
+
if (declared !== 'number' || typeof policy[bound] !== 'number' || !Number.isFinite(policy[bound]))
|
|
73
|
+
throw new Error(`${path}: ${bound} requires a finite number and type 'number'`);
|
|
74
|
+
}
|
|
75
|
+
if (policy.integer !== undefined) {
|
|
76
|
+
if (declared !== 'number' || typeof policy.integer !== 'boolean')
|
|
77
|
+
throw new Error(`${path}: integer requires a boolean and type 'number'`);
|
|
78
|
+
}
|
|
79
|
+
if (policy.maxLength !== undefined) {
|
|
80
|
+
if (declared !== 'string' ||
|
|
81
|
+
typeof policy.maxLength !== 'number' ||
|
|
82
|
+
!Number.isSafeInteger(policy.maxLength) ||
|
|
83
|
+
policy.maxLength < 1 ||
|
|
84
|
+
policy.maxLength > exports.PLUGIN_AUDIT_LIMITS.maxLengthCeiling)
|
|
85
|
+
throw new Error(`${path}: maxLength requires an integer 1-${exports.PLUGIN_AUDIT_LIMITS.maxLengthCeiling} and type 'string'`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/** Implemented by the generic audit foundation, not by individual plugins. */
|
|
89
|
+
exports.PLUGIN_AUDIT_HOST_PROVIDER = Symbol.for('attraccess.plugin.auditHostProvider');
|
|
90
|
+
const dottedName = (prefix, value, maxLength) => {
|
|
91
|
+
if (typeof value !== 'string' || value.length > maxLength || !value.startsWith(`${prefix}.`))
|
|
92
|
+
return false;
|
|
93
|
+
const segments = value.slice(prefix.length + 1).split('.');
|
|
94
|
+
return segments.length > 0 && segments.every((segment) => exports.PLUGIN_AUDIT_SEGMENT_PATTERN.test(segment));
|
|
95
|
+
};
|
|
96
|
+
function validateDomainLabels(declaration, prefix) {
|
|
97
|
+
if (declaration.labels !== undefined) {
|
|
98
|
+
if (!isPlainRecord(declaration.labels))
|
|
99
|
+
throw new Error(`Audit domain "${prefix}": labels must be a plain object`);
|
|
100
|
+
const locales = Object.keys(declaration.labels);
|
|
101
|
+
if (locales.length > exports.PLUGIN_AUDIT_LIMITS.labelLocales)
|
|
102
|
+
throw new Error(`Audit domain "${prefix}": at most ${exports.PLUGIN_AUDIT_LIMITS.labelLocales} label locales`);
|
|
103
|
+
for (const locale of locales) {
|
|
104
|
+
const label = declaration.labels[locale];
|
|
105
|
+
if (!/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/.test(locale))
|
|
106
|
+
throw new Error(`Audit domain "${prefix}": invalid label locale "${locale}"`);
|
|
107
|
+
if (typeof label !== 'string' || label.trim().length === 0 || label.length > exports.PLUGIN_AUDIT_LIMITS.labelLength)
|
|
108
|
+
throw new Error(`Audit domain "${prefix}": label for "${locale}" must be 1-${exports.PLUGIN_AUDIT_LIMITS.labelLength} characters`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Validates one plugin-contributed audit domain declaration and returns it unchanged.
|
|
114
|
+
* Throws a descriptive error on any violation; hosts quarantine the plugin in that case.
|
|
115
|
+
* Cross-domain concerns (collisions with core or other plugins) are checked by the host registry.
|
|
116
|
+
*/
|
|
117
|
+
function validatePluginAuditDomainDeclaration(declaration) {
|
|
118
|
+
if (!isPlainRecord(declaration))
|
|
119
|
+
throw new Error('Audit domain declaration must be a plain object');
|
|
120
|
+
const where = typeof declaration.domain === 'string' ? declaration.domain : '(unknown)';
|
|
121
|
+
if (typeof declaration.domain !== 'string' || !exports.PLUGIN_AUDIT_DOMAIN_PATTERN.test(declaration.domain))
|
|
122
|
+
throw new Error(`Audit domain "${where}": domain must match ${exports.PLUGIN_AUDIT_DOMAIN_PATTERN.source}`);
|
|
123
|
+
const prefix = declaration.domain;
|
|
124
|
+
validateDomainLabels(declaration, prefix);
|
|
125
|
+
if (!Array.isArray(declaration.actions) || declaration.actions.length === 0)
|
|
126
|
+
throw new Error(`Audit domain "${prefix}": actions must be a non-empty array`);
|
|
127
|
+
if (declaration.actions.length > exports.PLUGIN_AUDIT_LIMITS.actionsPerDomain)
|
|
128
|
+
throw new Error(`Audit domain "${prefix}": at most ${exports.PLUGIN_AUDIT_LIMITS.actionsPerDomain} actions`);
|
|
129
|
+
const seenActions = new Set();
|
|
130
|
+
for (const entry of declaration.actions) {
|
|
131
|
+
if (!isPlainRecord(entry))
|
|
132
|
+
throw new Error(`Audit domain "${prefix}": action policy must be a plain object`);
|
|
133
|
+
const action = entry.action;
|
|
134
|
+
if (typeof action !== 'string' || !dottedName(prefix, action, exports.PLUGIN_AUDIT_LIMITS.actionLength))
|
|
135
|
+
throw new Error(`Audit domain "${prefix}": action must be a "${prefix}."-prefixed dotted lowercase name`);
|
|
136
|
+
if (seenActions.has(action))
|
|
137
|
+
throw new Error(`Audit domain "${prefix}": duplicate action "${action}"`);
|
|
138
|
+
seenActions.add(action);
|
|
139
|
+
const entryKeys = Object.keys(entry);
|
|
140
|
+
for (const key of entryKeys)
|
|
141
|
+
if (!['action', 'subjectTypes', 'details'].includes(key))
|
|
142
|
+
throw new Error(`Audit domain "${prefix}", action "${action}": unknown property "${key}"`);
|
|
143
|
+
if (!Array.isArray(entry.subjectTypes) || entry.subjectTypes.length === 0)
|
|
144
|
+
throw new Error(`Audit domain "${prefix}", action "${action}": subjectTypes must be a non-empty array`);
|
|
145
|
+
if (entry.subjectTypes.length > exports.PLUGIN_AUDIT_LIMITS.subjectTypesPerAction)
|
|
146
|
+
throw new Error(`Audit domain "${prefix}", action "${action}": at most ${exports.PLUGIN_AUDIT_LIMITS.subjectTypesPerAction} subject types`);
|
|
147
|
+
const seenSubjects = new Set();
|
|
148
|
+
for (const subjectType of entry.subjectTypes) {
|
|
149
|
+
if (!dottedName(prefix, subjectType, exports.PLUGIN_AUDIT_LIMITS.actionLength))
|
|
150
|
+
throw new Error(`Audit domain "${prefix}", action "${action}": subject type must be a "${prefix}."-prefixed dotted lowercase name`);
|
|
151
|
+
if (seenSubjects.has(subjectType))
|
|
152
|
+
throw new Error(`Audit domain "${prefix}", action "${action}": duplicate subject type "${subjectType}"`);
|
|
153
|
+
seenSubjects.add(subjectType);
|
|
154
|
+
}
|
|
155
|
+
if (entry.details !== undefined) {
|
|
156
|
+
if (!isPlainRecord(entry.details))
|
|
157
|
+
throw new Error(`Audit domain "${prefix}", action "${action}": details must be a plain object`);
|
|
158
|
+
const fields = Object.keys(entry.details);
|
|
159
|
+
if (fields.length > exports.PLUGIN_AUDIT_LIMITS.fieldsPerAction)
|
|
160
|
+
throw new Error(`Audit domain "${prefix}", action "${action}": at most ${exports.PLUGIN_AUDIT_LIMITS.fieldsPerAction} detail fields`);
|
|
161
|
+
for (const field of fields) {
|
|
162
|
+
if (!exports.PLUGIN_AUDIT_FIELD_PATTERN.test(field))
|
|
163
|
+
throw new Error(`Audit domain "${prefix}", action "${action}": detail field "${field}" must match ${exports.PLUGIN_AUDIT_FIELD_PATTERN.source}`);
|
|
164
|
+
validateFieldPolicy(`Audit domain "${prefix}", action "${action}", field "${field}"`, entry.details[field]);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return declaration;
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=plugin-audit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-audit.js","sourceRoot":"","sources":["../../../../../libs/plugins-backend-sdk/src/lib/plugin-audit.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAgLH,oFAyDC;AAvOD,4FAA4F;AAC/E,QAAA,2BAA2B,GAAG,qBAAqB,CAAC;AAEjE,mEAAmE;AACtD,QAAA,4BAA4B,GAAG,yBAAyB,CAAC;AAEtE,4FAA4F;AAC/E,QAAA,0BAA0B,GAAG,6CAA6C,CAAC;AAE3E,QAAA,mBAAmB,GAAG;IACjC,gBAAgB,EAAE,CAAC;IACnB,gBAAgB,EAAE,EAAE;IACpB,qBAAqB,EAAE,CAAC;IACxB,eAAe,EAAE,EAAE;IACnB,YAAY,EAAE,EAAE;IAChB,aAAa,EAAE,GAAG;IAClB,gBAAgB,EAAE,IAAI;IACtB,YAAY,EAAE,CAAC;IACf,WAAW,EAAE,GAAG;IAChB,YAAY,EAAE,GAAG;CACT,CAAC;AAkCX,MAAM,aAAa,GAAG,CAAC,KAAc,EAAoC,EAAE;IACzE,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;Q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AAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC1C,IAAI,MAAM,CAAC,MAAM,GAAG,2BAAmB,CAAC,eAAe;gBACrD,MAAM,IAAI,KAAK,CACb,iBAAiB,MAAM,cAAc,MAAM,cAAc,2BAAmB,CAAC,eAAe,gBAAgB,CAC7G,CAAC;YACJ,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;gBAC3B,IAAI,CAAC,kCAA0B,CAAC,IAAI,CAAC,KAAK,CAAC;oBACzC,MAAM,IAAI,KAAK,CACb,iBAAiB,MAAM,cAAc,MAAM,oBAAoB,KAAK,gBAAgB,kCAA0B,CAAC,MAAM,EAAE,CACxH,CAAC;gBACJ,mBAAmB,CAAC,iBAAiB,MAAM,cAAc,MAAM,aAAa,KAAK,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;YAC9G,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { PluginContext } from './plugin-context';
|
|
2
|
+
import { DynamicModule } from '@nestjs/common';
|
|
3
|
+
import type { PluginEntityClass } from './entity';
|
|
4
|
+
import type { MqttCredentialProvisioningProviderFactory } from './mqtt-credential-provisioning';
|
|
5
|
+
import type { PluginAuditDomainDeclaration } from './plugin-audit';
|
|
6
|
+
import type { PluginFlowNodeDefinition } from './plugin-flow-node';
|
|
7
|
+
import type { PluginEmailTemplate, PluginNotificationCategory } from './plugin-notifications';
|
|
8
|
+
import type { PreStartHook, ReaderUiProvider, SessionEndHook, StartBlockedQuery } from './reader-ui';
|
|
9
|
+
/**
|
|
10
|
+
* Shape every backend plugin's default export must satisfy. The host calls
|
|
11
|
+
* register(context) at load time to obtain the plugin's Nest module definition.
|
|
12
|
+
*/
|
|
13
|
+
export interface PluginBackendModule {
|
|
14
|
+
register(context: PluginContext): DynamicModule;
|
|
15
|
+
/**
|
|
16
|
+
* Optional TypeORM entity classes this plugin owns. The host registers their
|
|
17
|
+
* metadata into the shared DataSource at load time so the plugin can query
|
|
18
|
+
* them through {@link PluginContext.getRepository}. The schema itself is owned
|
|
19
|
+
* by the plugin's migrations (the host runs with `synchronize: false`), so an
|
|
20
|
+
* entity here describes an existing table rather than creating one. Requires
|
|
21
|
+
* the DATABASE_ACCESS permission. See `docs/en/plugins/database-migrations.md`.
|
|
22
|
+
*/
|
|
23
|
+
entities?: PluginEntityClass[];
|
|
24
|
+
/**
|
|
25
|
+
* Optional custom flow node types this plugin contributes. The host registers
|
|
26
|
+
* them into the flow engine so they appear in the frontend node catalog and
|
|
27
|
+
* can be executed like built-in node types. No extra permission is required.
|
|
28
|
+
*
|
|
29
|
+
* Type naming convention: "plugin.<pluginName>.<nodeName>".
|
|
30
|
+
*/
|
|
31
|
+
flowNodes?: PluginFlowNodeDefinition[] | ((context: PluginContext) => PluginFlowNodeDefinition[]);
|
|
32
|
+
/**
|
|
33
|
+
* Optional audit domains this plugin contributes. The host registers the
|
|
34
|
+
* declarations at load time and enforces them on every event the plugin
|
|
35
|
+
* records through {@link PluginContext.audit}: only declared actions, subject
|
|
36
|
+
* types and detail fields are accepted, and events are stored under the
|
|
37
|
+
* declared domain. Domains must not collide with host domains or with other
|
|
38
|
+
* plugins. No extra permission is required.
|
|
39
|
+
*/
|
|
40
|
+
auditDomains?: PluginAuditDomainDeclaration[] | ((context: PluginContext) => PluginAuditDomainDeclaration[]);
|
|
41
|
+
/** Optional broker credential provider offered to other integrations by this plugin. */
|
|
42
|
+
credentialProvisioningProvider?: MqttCredentialProvisioningProviderFactory;
|
|
43
|
+
/** Optional reader UI slot provider. Requires the READER_UI permission. */
|
|
44
|
+
readerUi?: ReaderUiProvider | ((context: PluginContext) => ReaderUiProvider);
|
|
45
|
+
/** Optional pre-start hook (allow / confirm / block). Requires ACCESS_HOOKS. */
|
|
46
|
+
preStartHook?: PreStartHook;
|
|
47
|
+
/**
|
|
48
|
+
* Optional query-side counterpart of `preStartHook`: reports a "start currently blocked" state the resource UI
|
|
49
|
+
* shows in place of the start button. Informational; the pre-start hook stays the gate. Requires ACCESS_HOOKS.
|
|
50
|
+
*/
|
|
51
|
+
startBlockedQuery?: StartBlockedQuery;
|
|
52
|
+
/** Optional advisory hook after a session ended. Requires ACCESS_HOOKS. */
|
|
53
|
+
sessionEndHook?: SessionEndHook;
|
|
54
|
+
/**
|
|
55
|
+
* Optional notification categories this plugin dispatches under. They appear in user notification
|
|
56
|
+
* preferences grouped under the plugin name as `plugin.<pluginName>.<id>`. Dispatching requires the
|
|
57
|
+
* SEND_NOTIFICATIONS permission; declaring categories without it quarantines the plugin.
|
|
58
|
+
*/
|
|
59
|
+
notificationCategories?: PluginNotificationCategory[];
|
|
60
|
+
/**
|
|
61
|
+
* Optional email templates, stored and edited like core templates (key `plugin.<pluginName>.<id>`) and sent
|
|
62
|
+
* through `notifications.dispatch({ email: { template, variables } })`. Declaring them requires the
|
|
63
|
+
* SEND_NOTIFICATIONS permission; without it the plugin is quarantined.
|
|
64
|
+
*/
|
|
65
|
+
emailTemplates?: PluginEmailTemplate[];
|
|
66
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-backend-module.js","sourceRoot":"","sources":["../../../../../libs/plugins-backend-sdk/src/lib/plugin-backend-module.ts"],"names":[],"mappings":""}
|