@veramo/cli 5.5.4-next.25 → 5.5.4-next.28
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/build/mediate.d.ts.map +1 -1
- package/build/mediate.js +37 -26
- package/build/mediate.js.map +1 -1
- package/package.json +28 -28
- package/src/mediate.ts +42 -31
package/build/mediate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mediate.d.ts","sourceRoot":"","sources":["../src/mediate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"mediate.d.ts","sourceRoot":"","sources":["../src/mediate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAiKnC,QAAA,MAAM,OAAO,SAMZ,CAAA;AA4CD,OAAO,EAAE,OAAO,EAAE,CAAA"}
|
package/build/mediate.js
CHANGED
|
@@ -23,16 +23,27 @@ const promptForDids = async (action) => {
|
|
|
23
23
|
});
|
|
24
24
|
return dids.split(' ');
|
|
25
25
|
};
|
|
26
|
+
function handler(action) {
|
|
27
|
+
return async (options, cmd) => {
|
|
28
|
+
const agent = await getAgent(cmd.optsWithGlobals().config);
|
|
29
|
+
/**
|
|
30
|
+
* NOTE: check if the mediation-manager plugin is configured
|
|
31
|
+
**/
|
|
32
|
+
if ('isMediateDefaultGrantAll' in agent)
|
|
33
|
+
return await action(options, cmd, agent);
|
|
34
|
+
console.log('[warning] it appears that the Mediation Manager plugin is not configured.');
|
|
35
|
+
console.log('[tip] refer to the README (packages/mediation-manager/README.md) for guidance. \n');
|
|
36
|
+
throw new Error('[error] Mediation Manager not configured!');
|
|
37
|
+
};
|
|
38
|
+
}
|
|
26
39
|
/**
|
|
27
40
|
* cli action functions
|
|
28
41
|
**/
|
|
29
42
|
const policy = (policy) => {
|
|
30
|
-
return async function ({ fileJson, interactive }, cmd) {
|
|
43
|
+
return async function ({ fileJson, interactive }, cmd, agent) {
|
|
31
44
|
try {
|
|
32
45
|
if (fileJson && interactive)
|
|
33
46
|
throw new Error('Please specify only one input method');
|
|
34
|
-
const agent = await getAgent(cmd.optsWithGlobals().config);
|
|
35
|
-
console.log('AGENT CREATED');
|
|
36
47
|
if (fileJson) {
|
|
37
48
|
const jsonData = await import(fileJson, { assert: { type: 'json' } });
|
|
38
49
|
const dids = jsonData.default;
|
|
@@ -53,8 +64,7 @@ const policy = (policy) => {
|
|
|
53
64
|
}
|
|
54
65
|
};
|
|
55
66
|
};
|
|
56
|
-
async
|
|
57
|
-
const agent = await getAgent(cmd.optsWithGlobals().config);
|
|
67
|
+
const readPolicies = async (options, cmd, agent) => {
|
|
58
68
|
let dids;
|
|
59
69
|
if (options.interactive)
|
|
60
70
|
dids = await promptForDids('read');
|
|
@@ -70,10 +80,9 @@ async function readPolicies(options, cmd) {
|
|
|
70
80
|
}
|
|
71
81
|
console.log('POLICIES');
|
|
72
82
|
console.table(policies);
|
|
73
|
-
}
|
|
74
|
-
async
|
|
83
|
+
};
|
|
84
|
+
const listPolicies = async (options, _cmd, agent) => {
|
|
75
85
|
try {
|
|
76
|
-
const agent = await getAgent(cmd.optsWithGlobals().config);
|
|
77
86
|
const res = await agent.mediationManagerListMediationPolicies();
|
|
78
87
|
console.log('POLICIES');
|
|
79
88
|
if (options.allowFrom)
|
|
@@ -86,10 +95,10 @@ async function listPolicies(options, cmd) {
|
|
|
86
95
|
catch (e) {
|
|
87
96
|
console.error(e.message);
|
|
88
97
|
}
|
|
89
|
-
}
|
|
90
|
-
|
|
98
|
+
};
|
|
99
|
+
const listResponses = async (options, _cmd, agent) => {
|
|
91
100
|
try {
|
|
92
|
-
const
|
|
101
|
+
const { granted, denied } = options;
|
|
93
102
|
const res = await agent.mediationManagerGetAllMediations();
|
|
94
103
|
console.log('MEDIATIONS');
|
|
95
104
|
if (granted)
|
|
@@ -102,16 +111,15 @@ async function listResponses({ granted, denied }, cmd) {
|
|
|
102
111
|
catch (e) {
|
|
103
112
|
console.error(e.message);
|
|
104
113
|
}
|
|
105
|
-
}
|
|
106
|
-
|
|
114
|
+
};
|
|
115
|
+
const removePolicies = async (options, cmd, agent) => {
|
|
107
116
|
try {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const jsonData = await import(fileJson, { assert: { type: 'json' } });
|
|
117
|
+
if (options.fileJson) {
|
|
118
|
+
const jsonData = await import(options.fileJson, { assert: { type: 'json' } });
|
|
111
119
|
const dids = jsonData.default;
|
|
112
120
|
await updatePolicies({ dids, remove: true, agent });
|
|
113
121
|
}
|
|
114
|
-
else if (interactive) {
|
|
122
|
+
else if (options.interactive) {
|
|
115
123
|
const dids = await promptForDids('Remove');
|
|
116
124
|
await updatePolicies({ dids, remove: true, agent });
|
|
117
125
|
}
|
|
@@ -124,43 +132,46 @@ async function removePolicies({ fileJson, interactive }, cmd) {
|
|
|
124
132
|
catch (e) {
|
|
125
133
|
console.error(e.message);
|
|
126
134
|
}
|
|
127
|
-
}
|
|
128
|
-
const mediate = new Command('mediate').description('Mediate allow or deny policy on dids')
|
|
135
|
+
};
|
|
136
|
+
const mediate = new Command('mediate').description('Mediate allow or deny policy on dids').addHelpText('before', `
|
|
137
|
+
IMPORTANT! in order to use the commands below, you need to configure the Mediate Manager in your agent.yml',
|
|
138
|
+
see the README (packages/mediation-manager/README.md) for guidance.
|
|
139
|
+
`);
|
|
129
140
|
mediate
|
|
130
141
|
.command('allow-from')
|
|
131
142
|
.description('add dids that should be allowed for mediation')
|
|
132
143
|
.option('-f, --file-json <string>', 'read dids from json file')
|
|
133
144
|
.option('-i, --interactive', 'interactively input dids')
|
|
134
|
-
.action(policy(ALLOW));
|
|
145
|
+
.action(handler(policy(ALLOW)));
|
|
135
146
|
mediate
|
|
136
147
|
.command('deny-from')
|
|
137
148
|
.description('deny dids that should be denied for mediation')
|
|
138
149
|
.option('-f, --file-json <string>', 'read dids from json file')
|
|
139
150
|
.option('-i, --interactive', 'interactively input dids')
|
|
140
|
-
.action(policy(DENY));
|
|
151
|
+
.action(handler(policy(DENY)));
|
|
141
152
|
mediate
|
|
142
153
|
.command('read')
|
|
143
|
-
.description('read mediation policy for a specific did')
|
|
154
|
+
.description('read mediation policy for a specific did (or list of dids)')
|
|
144
155
|
.option('-i, --interactive', 'interactively input dids')
|
|
145
156
|
.option('-f, --file-json <string>', 'read dids from json file')
|
|
146
|
-
.action(readPolicies);
|
|
157
|
+
.action(handler(readPolicies));
|
|
147
158
|
mediate
|
|
148
159
|
.command('list-policies')
|
|
149
160
|
.description('list mediation policies')
|
|
150
161
|
.option('-a, --allow-from', 'list allow policies')
|
|
151
162
|
.option('-d, --deny-from', 'list deny policies')
|
|
152
|
-
.action(listPolicies);
|
|
163
|
+
.action(handler(listPolicies));
|
|
153
164
|
mediate
|
|
154
165
|
.command('list-responses')
|
|
155
166
|
.description('list mediation responses')
|
|
156
167
|
.option('-a, --granted', 'list granted policies')
|
|
157
168
|
.option('-d, --denied', 'list denied policies')
|
|
158
|
-
.action(listResponses);
|
|
169
|
+
.action(handler(listResponses));
|
|
159
170
|
mediate
|
|
160
171
|
.command('remove')
|
|
161
172
|
.description('remove mediation policies')
|
|
162
173
|
.option('-f, --file-json <string>', 'read dids from json file')
|
|
163
174
|
.option('-i, --interactive', 'interactively input dids')
|
|
164
|
-
.action(removePolicies);
|
|
175
|
+
.action(handler(removePolicies));
|
|
165
176
|
export { mediate };
|
|
166
177
|
//# sourceMappingURL=mediate.js.map
|
package/build/mediate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mediate.js","sourceRoot":"","sources":["../src/mediate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,QAAQ,MAAM,UAAU,CAAA;AAE/B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAKrC,MAAM,KAAK,GAAG,OAAO,CAAA;AACrB,MAAM,IA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-
"version": "5.5.4-next.
|
|
4
|
+
"version": "5.5.4-next.28+5aa97a2dc",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./build/cli.d.ts",
|
|
@@ -38,32 +38,32 @@
|
|
|
38
38
|
"@transmute/credentials-context": "^0.7.0-unstable.81",
|
|
39
39
|
"@types/blessed": "^0.1.22",
|
|
40
40
|
"@types/swagger-ui-express": "^4.1.3",
|
|
41
|
-
"@veramo/core": "^5.5.4-next.
|
|
42
|
-
"@veramo/core-types": "^5.5.4-next.
|
|
43
|
-
"@veramo/credential-eip712": "^5.5.4-next.
|
|
44
|
-
"@veramo/credential-ld": "^5.5.4-next.
|
|
45
|
-
"@veramo/credential-w3c": "^5.5.4-next.
|
|
46
|
-
"@veramo/data-store": "^5.5.4-next.
|
|
47
|
-
"@veramo/did-comm": "^5.5.4-next.
|
|
48
|
-
"@veramo/did-discovery": "^5.5.4-next.
|
|
49
|
-
"@veramo/did-jwt": "^5.5.4-next.
|
|
50
|
-
"@veramo/did-manager": "^5.5.4-next.
|
|
51
|
-
"@veramo/did-provider-ethr": "^5.5.4-next.
|
|
52
|
-
"@veramo/did-provider-key": "^5.5.4-next.
|
|
53
|
-
"@veramo/did-provider-peer": "^5.5.4-next.
|
|
54
|
-
"@veramo/did-provider-pkh": "^5.5.4-next.
|
|
55
|
-
"@veramo/did-provider-web": "^5.5.4-next.
|
|
56
|
-
"@veramo/did-resolver": "^5.5.4-next.
|
|
57
|
-
"@veramo/key-manager": "^5.5.4-next.
|
|
58
|
-
"@veramo/kms-local": "^5.5.4-next.
|
|
59
|
-
"@veramo/kv-store": "^5.5.4-next.
|
|
60
|
-
"@veramo/mediation-manager": "^5.5.4-next.
|
|
61
|
-
"@veramo/message-handler": "^5.5.4-next.
|
|
62
|
-
"@veramo/remote-client": "^5.5.4-next.
|
|
63
|
-
"@veramo/remote-server": "^5.5.4-next.
|
|
64
|
-
"@veramo/selective-disclosure": "^5.5.4-next.
|
|
65
|
-
"@veramo/url-handler": "^5.5.4-next.
|
|
66
|
-
"@veramo/utils": "^5.5.4-next.
|
|
41
|
+
"@veramo/core": "^5.5.4-next.28+5aa97a2dc",
|
|
42
|
+
"@veramo/core-types": "^5.5.4-next.28+5aa97a2dc",
|
|
43
|
+
"@veramo/credential-eip712": "^5.5.4-next.28+5aa97a2dc",
|
|
44
|
+
"@veramo/credential-ld": "^5.5.4-next.28+5aa97a2dc",
|
|
45
|
+
"@veramo/credential-w3c": "^5.5.4-next.28+5aa97a2dc",
|
|
46
|
+
"@veramo/data-store": "^5.5.4-next.28+5aa97a2dc",
|
|
47
|
+
"@veramo/did-comm": "^5.5.4-next.28+5aa97a2dc",
|
|
48
|
+
"@veramo/did-discovery": "^5.5.4-next.28+5aa97a2dc",
|
|
49
|
+
"@veramo/did-jwt": "^5.5.4-next.28+5aa97a2dc",
|
|
50
|
+
"@veramo/did-manager": "^5.5.4-next.28+5aa97a2dc",
|
|
51
|
+
"@veramo/did-provider-ethr": "^5.5.4-next.28+5aa97a2dc",
|
|
52
|
+
"@veramo/did-provider-key": "^5.5.4-next.28+5aa97a2dc",
|
|
53
|
+
"@veramo/did-provider-peer": "^5.5.4-next.28+5aa97a2dc",
|
|
54
|
+
"@veramo/did-provider-pkh": "^5.5.4-next.28+5aa97a2dc",
|
|
55
|
+
"@veramo/did-provider-web": "^5.5.4-next.28+5aa97a2dc",
|
|
56
|
+
"@veramo/did-resolver": "^5.5.4-next.28+5aa97a2dc",
|
|
57
|
+
"@veramo/key-manager": "^5.5.4-next.28+5aa97a2dc",
|
|
58
|
+
"@veramo/kms-local": "^5.5.4-next.28+5aa97a2dc",
|
|
59
|
+
"@veramo/kv-store": "^5.5.4-next.28+5aa97a2dc",
|
|
60
|
+
"@veramo/mediation-manager": "^5.5.4-next.28+5aa97a2dc",
|
|
61
|
+
"@veramo/message-handler": "^5.5.4-next.28+5aa97a2dc",
|
|
62
|
+
"@veramo/remote-client": "^5.5.4-next.28+5aa97a2dc",
|
|
63
|
+
"@veramo/remote-server": "^5.5.4-next.28+5aa97a2dc",
|
|
64
|
+
"@veramo/selective-disclosure": "^5.5.4-next.28+5aa97a2dc",
|
|
65
|
+
"@veramo/url-handler": "^5.5.4-next.28+5aa97a2dc",
|
|
66
|
+
"@veramo/utils": "^5.5.4-next.28+5aa97a2dc",
|
|
67
67
|
"blessed": "^0.1.81",
|
|
68
68
|
"commander": "^11.0.0",
|
|
69
69
|
"console-table-printer": "^2.11.2",
|
|
@@ -144,5 +144,5 @@
|
|
|
144
144
|
"node_modules",
|
|
145
145
|
"src"
|
|
146
146
|
],
|
|
147
|
-
"gitHead": "
|
|
147
|
+
"gitHead": "5aa97a2dcda2b64989ac178119f00cb0ab213773"
|
|
148
148
|
}
|
package/src/mediate.ts
CHANGED
|
@@ -51,6 +51,25 @@ const promptForDids = async (action: string): Promise<string[]> => {
|
|
|
51
51
|
return dids.split(' ')
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
/**
|
|
55
|
+
* handler function instantiates agent and directs user to README if no Mediation Manager plugin is configured
|
|
56
|
+
**/
|
|
57
|
+
|
|
58
|
+
type Action<T extends Options = Options> = (options: T, cmd: Command, agent: ConfiguredAgent) => Promise<void>
|
|
59
|
+
|
|
60
|
+
function handler(action: Action) {
|
|
61
|
+
return async (options: Options, cmd: Command) => {
|
|
62
|
+
const agent = await getAgent(cmd.optsWithGlobals().config)
|
|
63
|
+
/**
|
|
64
|
+
* NOTE: check if the mediation-manager plugin is configured
|
|
65
|
+
**/
|
|
66
|
+
if ('isMediateDefaultGrantAll' in agent) return await action(options, cmd, agent)
|
|
67
|
+
console.log('[warning] it appears that the Mediation Manager plugin is not configured.')
|
|
68
|
+
console.log('[tip] refer to the README (packages/mediation-manager/README.md) for guidance. \n')
|
|
69
|
+
throw new Error('[error] Mediation Manager not configured!')
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
54
73
|
/**
|
|
55
74
|
* cli action functions
|
|
56
75
|
**/
|
|
@@ -59,13 +78,11 @@ const policy = (policy: PreMediationRequestPolicy) => {
|
|
|
59
78
|
return async function (
|
|
60
79
|
{ fileJson, interactive }: Pick<Options, 'fileJson' | 'interactive'>,
|
|
61
80
|
cmd: Command,
|
|
81
|
+
agent: ConfiguredAgent,
|
|
62
82
|
): Promise<void> {
|
|
63
83
|
try {
|
|
64
84
|
if (fileJson && interactive) throw new Error('Please specify only one input method')
|
|
65
85
|
|
|
66
|
-
const agent = await getAgent(cmd.optsWithGlobals().config)
|
|
67
|
-
console.log('AGENT CREATED')
|
|
68
|
-
|
|
69
86
|
if (fileJson) {
|
|
70
87
|
const jsonData = await import(fileJson, { assert: { type: 'json' } })
|
|
71
88
|
const dids = jsonData.default
|
|
@@ -84,9 +101,7 @@ const policy = (policy: PreMediationRequestPolicy) => {
|
|
|
84
101
|
}
|
|
85
102
|
}
|
|
86
103
|
}
|
|
87
|
-
|
|
88
|
-
async function readPolicies(options: Pick<Options, 'interactive' | 'fileJson'>, cmd: Command): Promise<void> {
|
|
89
|
-
const agent = await getAgent(cmd.optsWithGlobals().config)
|
|
104
|
+
const readPolicies: Action<Pick<Options, 'interactive' | 'fileJson'>> = async (options, cmd, agent) => {
|
|
90
105
|
let dids: string[]
|
|
91
106
|
if (options.interactive) dids = await promptForDids('read')
|
|
92
107
|
else if (options.fileJson) dids = (await import(options.fileJson, { assert: { type: 'json' } })).default
|
|
@@ -100,9 +115,8 @@ async function readPolicies(options: Pick<Options, 'interactive' | 'fileJson'>,
|
|
|
100
115
|
console.table(policies)
|
|
101
116
|
}
|
|
102
117
|
|
|
103
|
-
|
|
118
|
+
const listPolicies: Action<Pick<Options, 'allowFrom' | 'denyFrom'>> = async (options, _cmd, agent) => {
|
|
104
119
|
try {
|
|
105
|
-
const agent = await getAgent(cmd.optsWithGlobals().config)
|
|
106
120
|
const res = await agent.mediationManagerListMediationPolicies()
|
|
107
121
|
console.log('POLICIES')
|
|
108
122
|
if (options.allowFrom) return console.table(Object.entries(res).filter(([, policy]) => policy === ALLOW))
|
|
@@ -113,12 +127,9 @@ async function listPolicies(options: Pick<Options, 'allowFrom' | 'denyFrom'>, cm
|
|
|
113
127
|
}
|
|
114
128
|
}
|
|
115
129
|
|
|
116
|
-
async
|
|
117
|
-
{ granted, denied }: Pick<Options, 'granted' | 'denied'>,
|
|
118
|
-
cmd: Command,
|
|
119
|
-
): Promise<void> {
|
|
130
|
+
const listResponses: Action<Pick<Options, 'granted' | 'denied'>> = async (options, _cmd, agent) => {
|
|
120
131
|
try {
|
|
121
|
-
const
|
|
132
|
+
const { granted, denied } = options
|
|
122
133
|
const res = await agent.mediationManagerGetAllMediations()
|
|
123
134
|
console.log('MEDIATIONS')
|
|
124
135
|
if (granted) return console.table(Object.entries(res).filter(([, response]) => response === 'GRANTED'))
|
|
@@ -129,73 +140,73 @@ async function listResponses(
|
|
|
129
140
|
}
|
|
130
141
|
}
|
|
131
142
|
|
|
132
|
-
async
|
|
133
|
-
{ fileJson, interactive }: Pick<Options, 'fileJson' | 'interactive'>,
|
|
134
|
-
cmd: Command,
|
|
135
|
-
): Promise<void> {
|
|
143
|
+
const removePolicies: Action<Pick<Options, 'fileJson' | 'interactive'>> = async (options, cmd, agent) => {
|
|
136
144
|
try {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
if (fileJson) {
|
|
140
|
-
const jsonData = await import(fileJson, { assert: { type: 'json' } })
|
|
145
|
+
if (options.fileJson) {
|
|
146
|
+
const jsonData = await import(options.fileJson, { assert: { type: 'json' } })
|
|
141
147
|
const dids = jsonData.default
|
|
142
148
|
await updatePolicies({ dids, remove: true, agent })
|
|
143
|
-
} else if (interactive) {
|
|
149
|
+
} else if (options.interactive) {
|
|
144
150
|
const dids = await promptForDids('Remove')
|
|
145
151
|
await updatePolicies({ dids, remove: true, agent })
|
|
146
152
|
} else {
|
|
147
153
|
const dids = cmd.args
|
|
148
154
|
await updatePolicies({ dids, remove: true, agent })
|
|
149
155
|
}
|
|
150
|
-
|
|
151
156
|
console.log('Mediation policies removed')
|
|
152
157
|
} catch (e) {
|
|
153
158
|
console.error(e.message)
|
|
154
159
|
}
|
|
155
160
|
}
|
|
156
161
|
|
|
157
|
-
const mediate = new Command('mediate').description('Mediate allow or deny policy on dids')
|
|
162
|
+
const mediate = new Command('mediate').description('Mediate allow or deny policy on dids').addHelpText(
|
|
163
|
+
'before',
|
|
164
|
+
`
|
|
165
|
+
IMPORTANT! in order to use the commands below, you need to configure the Mediate Manager in your agent.yml',
|
|
166
|
+
see the README (packages/mediation-manager/README.md) for guidance.
|
|
167
|
+
`,
|
|
168
|
+
)
|
|
158
169
|
|
|
159
170
|
mediate
|
|
160
171
|
.command('allow-from')
|
|
161
172
|
.description('add dids that should be allowed for mediation')
|
|
162
173
|
.option('-f, --file-json <string>', 'read dids from json file')
|
|
163
174
|
.option('-i, --interactive', 'interactively input dids')
|
|
164
|
-
.action(policy(ALLOW))
|
|
175
|
+
.action(handler(policy(ALLOW)))
|
|
165
176
|
|
|
166
177
|
mediate
|
|
167
178
|
.command('deny-from')
|
|
168
179
|
.description('deny dids that should be denied for mediation')
|
|
169
180
|
.option('-f, --file-json <string>', 'read dids from json file')
|
|
170
181
|
.option('-i, --interactive', 'interactively input dids')
|
|
171
|
-
.action(policy(DENY))
|
|
182
|
+
.action(handler(policy(DENY)))
|
|
172
183
|
|
|
173
184
|
mediate
|
|
174
185
|
.command('read')
|
|
175
|
-
.description('read mediation policy for a specific did')
|
|
186
|
+
.description('read mediation policy for a specific did (or list of dids)')
|
|
176
187
|
.option('-i, --interactive', 'interactively input dids')
|
|
177
188
|
.option('-f, --file-json <string>', 'read dids from json file')
|
|
178
|
-
.action(readPolicies)
|
|
189
|
+
.action(handler(readPolicies))
|
|
179
190
|
|
|
180
191
|
mediate
|
|
181
192
|
.command('list-policies')
|
|
182
193
|
.description('list mediation policies')
|
|
183
194
|
.option('-a, --allow-from', 'list allow policies')
|
|
184
195
|
.option('-d, --deny-from', 'list deny policies')
|
|
185
|
-
.action(listPolicies)
|
|
196
|
+
.action(handler(listPolicies))
|
|
186
197
|
|
|
187
198
|
mediate
|
|
188
199
|
.command('list-responses')
|
|
189
200
|
.description('list mediation responses')
|
|
190
201
|
.option('-a, --granted', 'list granted policies')
|
|
191
202
|
.option('-d, --denied', 'list denied policies')
|
|
192
|
-
.action(listResponses)
|
|
203
|
+
.action(handler(listResponses))
|
|
193
204
|
|
|
194
205
|
mediate
|
|
195
206
|
.command('remove')
|
|
196
207
|
.description('remove mediation policies')
|
|
197
208
|
.option('-f, --file-json <string>', 'read dids from json file')
|
|
198
209
|
.option('-i, --interactive', 'interactively input dids')
|
|
199
|
-
.action(removePolicies)
|
|
210
|
+
.action(handler(removePolicies))
|
|
200
211
|
|
|
201
212
|
export { mediate }
|