@zincapp/zn-vault-agent 1.6.14 → 1.6.15

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.
Files changed (2) hide show
  1. package/README.md +120 -0
  2. package/package.json +2 -1
package/README.md CHANGED
@@ -843,6 +843,126 @@ znvault_agent_sync_duration_seconds{cert_name}
843
843
  znvault_agent_api_request_duration_seconds{method}
844
844
  ```
845
845
 
846
+ ## Plugin System
847
+
848
+ The agent supports plugins that extend functionality without modifying core code. Plugins can:
849
+
850
+ - Register HTTP routes on the health server
851
+ - React to certificate/secret deployment events
852
+ - Add custom health checks
853
+ - Respond to child process events
854
+
855
+ ### Installing Plugins
856
+
857
+ Add plugins to your `config.json`:
858
+
859
+ ```json
860
+ {
861
+ "vaultUrl": "https://vault.example.com",
862
+ "tenantId": "my-tenant",
863
+ "auth": { "apiKey": "znv_..." },
864
+ "plugins": [
865
+ {
866
+ "package": "@zincapp/znvault-plugin-payara",
867
+ "config": {
868
+ "payaraHome": "/opt/payara",
869
+ "domain": "domain1",
870
+ "user": "payara",
871
+ "warPath": "/opt/app/MyApp.war",
872
+ "appName": "MyApp"
873
+ }
874
+ }
875
+ ]
876
+ }
877
+ ```
878
+
879
+ Then install the plugin package:
880
+
881
+ ```bash
882
+ npm install @zincapp/znvault-plugin-payara
883
+ ```
884
+
885
+ ### Available Plugins
886
+
887
+ | Plugin | Package | Description |
888
+ |--------|---------|-------------|
889
+ | Payara | `@zincapp/znvault-plugin-payara` | WAR diff deployment, Payara lifecycle management |
890
+
891
+ ### Plugin Configuration Options
892
+
893
+ | Option | Type | Description |
894
+ |--------|------|-------------|
895
+ | `package` | string | npm package name |
896
+ | `path` | string | Local file path (alternative to package) |
897
+ | `config` | object | Plugin-specific configuration |
898
+ | `enabled` | boolean | Enable/disable plugin (default: true) |
899
+
900
+ ### Plugin Routes
901
+
902
+ Plugins register HTTP routes under `/plugins/<name>/`. For example, the Payara plugin registers:
903
+
904
+ - `GET /plugins/payara/status` - Payara status
905
+ - `GET /plugins/payara/hashes` - WAR file hashes for diff deployment
906
+ - `POST /plugins/payara/deploy` - Apply WAR changes
907
+
908
+ ### Plugin Health
909
+
910
+ Plugin health is included in the `/health` endpoint:
911
+
912
+ ```json
913
+ {
914
+ "status": "healthy",
915
+ "plugins": [
916
+ {
917
+ "name": "payara",
918
+ "status": "healthy",
919
+ "details": {
920
+ "domain": "domain1",
921
+ "running": true,
922
+ "healthy": true
923
+ }
924
+ }
925
+ ]
926
+ }
927
+ ```
928
+
929
+ ### Writing Plugins
930
+
931
+ Plugins export a factory function that returns an `AgentPlugin` object:
932
+
933
+ ```typescript
934
+ import type { AgentPlugin, PluginContext } from '@zincapp/zn-vault-agent/plugins';
935
+
936
+ export default function createMyPlugin(config: MyConfig): AgentPlugin {
937
+ return {
938
+ name: 'my-plugin',
939
+ version: '1.0.0',
940
+
941
+ async onInit(ctx: PluginContext) {
942
+ ctx.logger.info('Initializing...');
943
+ },
944
+
945
+ async onStart(ctx: PluginContext) {
946
+ ctx.logger.info('Starting...');
947
+ },
948
+
949
+ async routes(fastify, ctx) {
950
+ fastify.get('/status', async () => ({ ok: true }));
951
+ },
952
+
953
+ async onCertificateDeployed(event, ctx) {
954
+ ctx.logger.info({ certId: event.certId }, 'Certificate deployed');
955
+ },
956
+
957
+ async healthCheck(ctx) {
958
+ return { name: 'my-plugin', status: 'healthy' };
959
+ },
960
+ };
961
+ }
962
+ ```
963
+
964
+ Plugin types are exported from `@zincapp/zn-vault-agent/plugins`.
965
+
846
966
  ## Systemd Installation
847
967
 
848
968
  ```bash
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zincapp/zn-vault-agent",
3
- "version": "1.6.14",
3
+ "version": "1.6.15",
4
4
  "description": "ZN-Vault Certificate Agent - Real-time certificate and secret distribution",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -67,6 +67,7 @@
67
67
  },
68
68
  "homepage": "https://github.com/vidaldiego/zn-vault-agent#readme",
69
69
  "dependencies": {
70
+ "@zincapp/znvault-plugin-payara": "^1.0.6",
70
71
  "chalk": "^5.3.0",
71
72
  "commander": "^12.1.0",
72
73
  "conf": "^13.0.1",