@veramo/cli 5.5.4-next.24 → 5.5.4-next.27
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/createCommand.d.ts.map +1 -1
- package/build/createCommand.js +3 -1
- package/build/createCommand.js.map +1 -1
- package/build/mediate.d.ts +4 -0
- package/build/mediate.d.ts.map +1 -0
- package/build/mediate.js +177 -0
- package/build/mediate.js.map +1 -0
- package/build/setup.d.ts +2 -1
- package/build/setup.d.ts.map +1 -1
- package/build/setup.js.map +1 -1
- package/default/client.yml +1 -0
- package/package.json +28 -26
- package/src/createCommand.ts +2 -0
- package/src/mediate.ts +212 -0
- package/src/setup.ts +6 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCommand.d.ts","sourceRoot":"","sources":["../src/createCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"createCommand.d.ts","sourceRoot":"","sources":["../src/createCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAmBnC,QAAA,MAAM,MAAM,SAcU,CAAA;AAEtB,OAAO,EAAE,MAAM,EAAE,CAAA"}
|
package/build/createCommand.js
CHANGED
|
@@ -11,6 +11,7 @@ import { presentation } from './presentation.js';
|
|
|
11
11
|
import { explore } from './explore/index.js';
|
|
12
12
|
import { sdr } from './sdr.js';
|
|
13
13
|
import { server } from './server.js';
|
|
14
|
+
import { mediate } from './mediate.js';
|
|
14
15
|
const requireCjs = module.createRequire(import.meta.url);
|
|
15
16
|
const { version } = requireCjs('../package.json');
|
|
16
17
|
const veramo = new Command('veramo')
|
|
@@ -26,6 +27,7 @@ const veramo = new Command('veramo')
|
|
|
26
27
|
.addCommand(message)
|
|
27
28
|
.addCommand(presentation)
|
|
28
29
|
.addCommand(sdr)
|
|
29
|
-
.addCommand(server)
|
|
30
|
+
.addCommand(server)
|
|
31
|
+
.addCommand(mediate);
|
|
30
32
|
export { veramo };
|
|
31
33
|
//# sourceMappingURL=createCommand.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCommand.js","sourceRoot":"","sources":["../src/createCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"createCommand.js","sourceRoot":"","sources":["../src/createCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OA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,SAMZ,CAAA;AA4CD,OAAO,EAAE,OAAO,EAAE,CAAA"}
|
package/build/mediate.js
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import inquirer from 'inquirer';
|
|
3
|
+
import { getAgent } from './setup.js';
|
|
4
|
+
const ALLOW = 'ALLOW';
|
|
5
|
+
const DENY = 'DENY';
|
|
6
|
+
/**
|
|
7
|
+
* private functions
|
|
8
|
+
**/
|
|
9
|
+
const updatePolicies = async (options) => {
|
|
10
|
+
const { dids, agent, policy, remove = false } = options;
|
|
11
|
+
if (remove) {
|
|
12
|
+
return dids.forEach(async (requesterDid) => await agent.mediationManagerRemoveMediationPolicy({ requesterDid }));
|
|
13
|
+
}
|
|
14
|
+
if (!policy)
|
|
15
|
+
throw new Error('No policy provided');
|
|
16
|
+
return dids.forEach(async (requesterDid) => await agent.mediationManagerSaveMediationPolicy({ requesterDid, policy }));
|
|
17
|
+
};
|
|
18
|
+
const promptForDids = async (action) => {
|
|
19
|
+
const { dids } = await inquirer.prompt({
|
|
20
|
+
type: 'input',
|
|
21
|
+
name: 'dids',
|
|
22
|
+
message: `Enter the dids you want to ${action.toLowerCase()} separated by spaces:`,
|
|
23
|
+
});
|
|
24
|
+
return dids.split(' ');
|
|
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
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* cli action functions
|
|
41
|
+
**/
|
|
42
|
+
const policy = (policy) => {
|
|
43
|
+
return async function ({ fileJson, interactive }, cmd, agent) {
|
|
44
|
+
try {
|
|
45
|
+
if (fileJson && interactive)
|
|
46
|
+
throw new Error('Please specify only one input method');
|
|
47
|
+
if (fileJson) {
|
|
48
|
+
const jsonData = await import(fileJson, { assert: { type: 'json' } });
|
|
49
|
+
const dids = jsonData.default;
|
|
50
|
+
await updatePolicies({ dids, agent, policy });
|
|
51
|
+
}
|
|
52
|
+
else if (interactive) {
|
|
53
|
+
const dids = await promptForDids(policy);
|
|
54
|
+
await updatePolicies({ dids, agent, policy });
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
const dids = cmd.args;
|
|
58
|
+
await updatePolicies({ dids, agent, policy });
|
|
59
|
+
}
|
|
60
|
+
console.log('Mediation policies updated');
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
console.error(e.message);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
const readPolicies = async (options, cmd, agent) => {
|
|
68
|
+
let dids;
|
|
69
|
+
if (options.interactive)
|
|
70
|
+
dids = await promptForDids('read');
|
|
71
|
+
else if (options.fileJson)
|
|
72
|
+
dids = (await import(options.fileJson, { assert: { type: 'json' } })).default;
|
|
73
|
+
else
|
|
74
|
+
dids = cmd.args;
|
|
75
|
+
if (!dids || !dids.length)
|
|
76
|
+
throw new Error('No dids provided');
|
|
77
|
+
const policies = {};
|
|
78
|
+
for await (const requesterDid of dids) {
|
|
79
|
+
policies[requesterDid] = await agent.mediationManagerGetMediationPolicy({ requesterDid });
|
|
80
|
+
}
|
|
81
|
+
console.log('POLICIES');
|
|
82
|
+
console.table(policies);
|
|
83
|
+
};
|
|
84
|
+
const listPolicies = async (options, _cmd, agent) => {
|
|
85
|
+
try {
|
|
86
|
+
const res = await agent.mediationManagerListMediationPolicies();
|
|
87
|
+
console.log('POLICIES');
|
|
88
|
+
if (options.allowFrom)
|
|
89
|
+
return console.table(Object.entries(res).filter(([, policy]) => policy === ALLOW));
|
|
90
|
+
if (options.denyFrom)
|
|
91
|
+
return console.table(Object.entries(res).filter(([, policy]) => policy === DENY));
|
|
92
|
+
else
|
|
93
|
+
console.table(res);
|
|
94
|
+
}
|
|
95
|
+
catch (e) {
|
|
96
|
+
console.error(e.message);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const listResponses = async (options, _cmd, agent) => {
|
|
100
|
+
try {
|
|
101
|
+
const { granted, denied } = options;
|
|
102
|
+
const res = await agent.mediationManagerGetAllMediations();
|
|
103
|
+
console.log('MEDIATIONS');
|
|
104
|
+
if (granted)
|
|
105
|
+
return console.table(Object.entries(res).filter(([, response]) => response === 'GRANTED'));
|
|
106
|
+
if (denied)
|
|
107
|
+
return console.table(Object.entries(res).filter(([, response]) => response === 'DENIED'));
|
|
108
|
+
else
|
|
109
|
+
console.table(res);
|
|
110
|
+
}
|
|
111
|
+
catch (e) {
|
|
112
|
+
console.error(e.message);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
const removePolicies = async (options, cmd, agent) => {
|
|
116
|
+
try {
|
|
117
|
+
if (options.fileJson) {
|
|
118
|
+
const jsonData = await import(options.fileJson, { assert: { type: 'json' } });
|
|
119
|
+
const dids = jsonData.default;
|
|
120
|
+
await updatePolicies({ dids, remove: true, agent });
|
|
121
|
+
}
|
|
122
|
+
else if (options.interactive) {
|
|
123
|
+
const dids = await promptForDids('Remove');
|
|
124
|
+
await updatePolicies({ dids, remove: true, agent });
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
const dids = cmd.args;
|
|
128
|
+
await updatePolicies({ dids, remove: true, agent });
|
|
129
|
+
}
|
|
130
|
+
console.log('Mediation policies removed');
|
|
131
|
+
}
|
|
132
|
+
catch (e) {
|
|
133
|
+
console.error(e.message);
|
|
134
|
+
}
|
|
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
|
+
`);
|
|
140
|
+
mediate
|
|
141
|
+
.command('allow-from')
|
|
142
|
+
.description('add dids that should be allowed for mediation')
|
|
143
|
+
.option('-f, --file-json <string>', 'read dids from json file')
|
|
144
|
+
.option('-i, --interactive', 'interactively input dids')
|
|
145
|
+
.action(handler(policy(ALLOW)));
|
|
146
|
+
mediate
|
|
147
|
+
.command('deny-from')
|
|
148
|
+
.description('deny dids that should be denied for mediation')
|
|
149
|
+
.option('-f, --file-json <string>', 'read dids from json file')
|
|
150
|
+
.option('-i, --interactive', 'interactively input dids')
|
|
151
|
+
.action(handler(policy(DENY)));
|
|
152
|
+
mediate
|
|
153
|
+
.command('read')
|
|
154
|
+
.description('read mediation policy for a specific did (or list of dids)')
|
|
155
|
+
.option('-i, --interactive', 'interactively input dids')
|
|
156
|
+
.option('-f, --file-json <string>', 'read dids from json file')
|
|
157
|
+
.action(handler(readPolicies));
|
|
158
|
+
mediate
|
|
159
|
+
.command('list-policies')
|
|
160
|
+
.description('list mediation policies')
|
|
161
|
+
.option('-a, --allow-from', 'list allow policies')
|
|
162
|
+
.option('-d, --deny-from', 'list deny policies')
|
|
163
|
+
.action(handler(listPolicies));
|
|
164
|
+
mediate
|
|
165
|
+
.command('list-responses')
|
|
166
|
+
.description('list mediation responses')
|
|
167
|
+
.option('-a, --granted', 'list granted policies')
|
|
168
|
+
.option('-d, --denied', 'list denied policies')
|
|
169
|
+
.action(handler(listResponses));
|
|
170
|
+
mediate
|
|
171
|
+
.command('remove')
|
|
172
|
+
.description('remove mediation policies')
|
|
173
|
+
.option('-f, --file-json <string>', 'read dids from json file')
|
|
174
|
+
.option('-i, --interactive', 'interactively input dids')
|
|
175
|
+
.action(handler(removePolicies));
|
|
176
|
+
export { mediate };
|
|
177
|
+
//# sourceMappingURL=mediate.js.map
|
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CAAC,2BAA2B,CAAC;KACxC,MAAM,CAAC,0BAA0B,EAAE,0BAA0B,CAAC;KAC9D,MAAM,CAAC,mBAAmB,EAAE,0BAA0B,CAAC;KACvD,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAA;AAElC,OAAO,EAAE,OAAO,EAAE,CAAA"}
|
package/build/setup.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ICredentialPlugin, IDataStore, IDataStoreORM, IDIDManager, IKeyManager, IMessageHandler, IResolver, TAgent } from '@veramo/core-types';
|
|
2
|
+
import { IMediationManager } from "@veramo/mediation-manager";
|
|
2
3
|
import { ISelectiveDisclosure } from '@veramo/selective-disclosure';
|
|
3
4
|
import { IDIDComm } from '@veramo/did-comm';
|
|
4
5
|
import { IDIDDiscovery } from '@veramo/did-discovery';
|
|
@@ -11,7 +12,7 @@ export declare const getConfig: (filePath: fs.PathLike) => Promise<{
|
|
|
11
12
|
[x: string]: any;
|
|
12
13
|
version?: number | undefined;
|
|
13
14
|
}>;
|
|
14
|
-
export type EnabledInterfaces = IDIDManager & IKeyManager & IDataStore & IDataStoreORM & IResolver & IMessageHandler & IDIDComm & ICredentialPlugin & ISelectiveDisclosure & IDIDDiscovery;
|
|
15
|
+
export type EnabledInterfaces = IDIDManager & IKeyManager & IDataStore & IDataStoreORM & IResolver & IMessageHandler & IDIDComm & ICredentialPlugin & ISelectiveDisclosure & IDIDDiscovery & IMediationManager;
|
|
15
16
|
export type ConfiguredAgent = TAgent<EnabledInterfaces>;
|
|
16
17
|
export declare function getAgent(fileName: string): Promise<ConfiguredAgent>;
|
|
17
18
|
//# sourceMappingURL=setup.d.ts.map
|
package/build/setup.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,WAAW,EACX,WAAW,E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EvD,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAOzE"}
|
package/build/setup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AAkBvB,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAE7D,OAAO,EAAE,MAAM,IAAI,CAAA;AAEnB;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAAE,QAAqB,EAAmD,EAAE;IACxG,IAAI,WAAmB,CAAA;IAEvB,kBAAkB;IAClB,IAAI;QACF,WAAW,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;KAC3D;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,yBAAyB,GAAG,QAAQ,CAAC,CAAA;QACjD,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAA;QACvD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;KAChB;IAED,IAAI,MAAM,CAAA;IAEV,IAAI;QACF,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAA;KACzD;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC,CAAA;QACvE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;KAChB;IAED,IAAI,MAAM,EAAE,OAAO,IAAI,CAAC,EAAE;QACxB,OAAO,CAAC,KAAK,CAAC,yCAAyC,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;QACxE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;KAChB;IACD,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAgBD,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,QAAgB;IAC7C,IAAI;QACF,OAAO,MAAM,qBAAqB,CAAoB,MAAM,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAA;KACjF;IAAC,OAAO,CAAM,EAAE;QACf,OAAO,CAAC,GAAG,CAAC,8BAA8B,GAAG,QAAQ,GAAG,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,CAAA;QACvE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;KAChB;AACH,CAAC"}
|
package/default/client.yml
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veramo/cli",
|
|
3
3
|
"description": "Veramo command line application.",
|
|
4
|
-
"version": "5.5.4-next.
|
|
4
|
+
"version": "5.5.4-next.27+ea2d99a67",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./build/cli.d.ts",
|
|
@@ -38,30 +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/
|
|
60
|
-
"@veramo/
|
|
61
|
-
"@veramo/
|
|
62
|
-
"@veramo/
|
|
63
|
-
"@veramo/
|
|
64
|
-
"@veramo/
|
|
41
|
+
"@veramo/core": "^5.5.4-next.27+ea2d99a67",
|
|
42
|
+
"@veramo/core-types": "^5.5.4-next.27+ea2d99a67",
|
|
43
|
+
"@veramo/credential-eip712": "^5.5.4-next.27+ea2d99a67",
|
|
44
|
+
"@veramo/credential-ld": "^5.5.4-next.27+ea2d99a67",
|
|
45
|
+
"@veramo/credential-w3c": "^5.5.4-next.27+ea2d99a67",
|
|
46
|
+
"@veramo/data-store": "^5.5.4-next.27+ea2d99a67",
|
|
47
|
+
"@veramo/did-comm": "^5.5.4-next.27+ea2d99a67",
|
|
48
|
+
"@veramo/did-discovery": "^5.5.4-next.27+ea2d99a67",
|
|
49
|
+
"@veramo/did-jwt": "^5.5.4-next.27+ea2d99a67",
|
|
50
|
+
"@veramo/did-manager": "^5.5.4-next.27+ea2d99a67",
|
|
51
|
+
"@veramo/did-provider-ethr": "^5.5.4-next.27+ea2d99a67",
|
|
52
|
+
"@veramo/did-provider-key": "^5.5.4-next.27+ea2d99a67",
|
|
53
|
+
"@veramo/did-provider-peer": "^5.5.4-next.27+ea2d99a67",
|
|
54
|
+
"@veramo/did-provider-pkh": "^5.5.4-next.27+ea2d99a67",
|
|
55
|
+
"@veramo/did-provider-web": "^5.5.4-next.27+ea2d99a67",
|
|
56
|
+
"@veramo/did-resolver": "^5.5.4-next.27+ea2d99a67",
|
|
57
|
+
"@veramo/key-manager": "^5.5.4-next.27+ea2d99a67",
|
|
58
|
+
"@veramo/kms-local": "^5.5.4-next.27+ea2d99a67",
|
|
59
|
+
"@veramo/kv-store": "^5.5.4-next.27+ea2d99a67",
|
|
60
|
+
"@veramo/mediation-manager": "^5.5.4-next.27+ea2d99a67",
|
|
61
|
+
"@veramo/message-handler": "^5.5.4-next.27+ea2d99a67",
|
|
62
|
+
"@veramo/remote-client": "^5.5.4-next.27+ea2d99a67",
|
|
63
|
+
"@veramo/remote-server": "^5.5.4-next.27+ea2d99a67",
|
|
64
|
+
"@veramo/selective-disclosure": "^5.5.4-next.27+ea2d99a67",
|
|
65
|
+
"@veramo/url-handler": "^5.5.4-next.27+ea2d99a67",
|
|
66
|
+
"@veramo/utils": "^5.5.4-next.27+ea2d99a67",
|
|
65
67
|
"blessed": "^0.1.81",
|
|
66
68
|
"commander": "^11.0.0",
|
|
67
69
|
"console-table-printer": "^2.11.2",
|
|
@@ -142,5 +144,5 @@
|
|
|
142
144
|
"node_modules",
|
|
143
145
|
"src"
|
|
144
146
|
],
|
|
145
|
-
"gitHead": "
|
|
147
|
+
"gitHead": "ea2d99a67eb5479352ec9cf4950a18b2963f132f"
|
|
146
148
|
}
|
package/src/createCommand.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { presentation } from './presentation.js'
|
|
|
12
12
|
import { explore } from './explore/index.js'
|
|
13
13
|
import { sdr } from './sdr.js'
|
|
14
14
|
import { server } from './server.js'
|
|
15
|
+
import { mediate } from './mediate.js'
|
|
15
16
|
|
|
16
17
|
const requireCjs = module.createRequire(import.meta.url)
|
|
17
18
|
const { version } = requireCjs('../package.json')
|
|
@@ -30,5 +31,6 @@ const veramo = new Command('veramo')
|
|
|
30
31
|
.addCommand(presentation)
|
|
31
32
|
.addCommand(sdr)
|
|
32
33
|
.addCommand(server)
|
|
34
|
+
.addCommand(mediate)
|
|
33
35
|
|
|
34
36
|
export { veramo }
|
package/src/mediate.ts
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { Command } from 'commander'
|
|
2
|
+
import inquirer from 'inquirer'
|
|
3
|
+
|
|
4
|
+
import { getAgent } from './setup.js'
|
|
5
|
+
import { PreMediationRequestPolicy, RecipientDid, RequesterDid } from '@veramo/mediation-manager'
|
|
6
|
+
|
|
7
|
+
type ConfiguredAgent = Awaited<ReturnType<typeof getAgent>>
|
|
8
|
+
|
|
9
|
+
const ALLOW = 'ALLOW'
|
|
10
|
+
const DENY = 'DENY'
|
|
11
|
+
|
|
12
|
+
type Options = Partial<{
|
|
13
|
+
granted: boolean
|
|
14
|
+
denied: boolean
|
|
15
|
+
allowFrom: boolean
|
|
16
|
+
denyFrom: boolean
|
|
17
|
+
interactive: boolean
|
|
18
|
+
fileJson: string
|
|
19
|
+
}>
|
|
20
|
+
|
|
21
|
+
type UpdatePolicyParams = {
|
|
22
|
+
dids: string[]
|
|
23
|
+
agent: ConfiguredAgent
|
|
24
|
+
policy?: PreMediationRequestPolicy
|
|
25
|
+
remove?: boolean
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* private functions
|
|
30
|
+
**/
|
|
31
|
+
|
|
32
|
+
const updatePolicies = async (options: UpdatePolicyParams): Promise<void> => {
|
|
33
|
+
const { dids, agent, policy, remove = false } = options
|
|
34
|
+
if (remove) {
|
|
35
|
+
return dids.forEach(
|
|
36
|
+
async (requesterDid) => await agent.mediationManagerRemoveMediationPolicy({ requesterDid }),
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
if (!policy) throw new Error('No policy provided')
|
|
40
|
+
return dids.forEach(
|
|
41
|
+
async (requesterDid) => await agent.mediationManagerSaveMediationPolicy({ requesterDid, policy }),
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const promptForDids = async (action: string): Promise<string[]> => {
|
|
46
|
+
const { dids } = await inquirer.prompt<{ dids: string }>({
|
|
47
|
+
type: 'input',
|
|
48
|
+
name: 'dids',
|
|
49
|
+
message: `Enter the dids you want to ${action.toLowerCase()} separated by spaces:`,
|
|
50
|
+
})
|
|
51
|
+
return dids.split(' ')
|
|
52
|
+
}
|
|
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
|
+
|
|
73
|
+
/**
|
|
74
|
+
* cli action functions
|
|
75
|
+
**/
|
|
76
|
+
|
|
77
|
+
const policy = (policy: PreMediationRequestPolicy) => {
|
|
78
|
+
return async function (
|
|
79
|
+
{ fileJson, interactive }: Pick<Options, 'fileJson' | 'interactive'>,
|
|
80
|
+
cmd: Command,
|
|
81
|
+
agent: ConfiguredAgent,
|
|
82
|
+
): Promise<void> {
|
|
83
|
+
try {
|
|
84
|
+
if (fileJson && interactive) throw new Error('Please specify only one input method')
|
|
85
|
+
|
|
86
|
+
if (fileJson) {
|
|
87
|
+
const jsonData = await import(fileJson, { assert: { type: 'json' } })
|
|
88
|
+
const dids = jsonData.default
|
|
89
|
+
await updatePolicies({ dids, agent, policy })
|
|
90
|
+
} else if (interactive) {
|
|
91
|
+
const dids = await promptForDids(policy)
|
|
92
|
+
await updatePolicies({ dids, agent, policy })
|
|
93
|
+
} else {
|
|
94
|
+
const dids = cmd.args
|
|
95
|
+
await updatePolicies({ dids, agent, policy })
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
console.log('Mediation policies updated')
|
|
99
|
+
} catch (e) {
|
|
100
|
+
console.error(e.message)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const readPolicies: Action<Pick<Options, 'interactive' | 'fileJson'>> = async (options, cmd, agent) => {
|
|
105
|
+
let dids: string[]
|
|
106
|
+
if (options.interactive) dids = await promptForDids('read')
|
|
107
|
+
else if (options.fileJson) dids = (await import(options.fileJson, { assert: { type: 'json' } })).default
|
|
108
|
+
else dids = cmd.args
|
|
109
|
+
if (!dids || !dids.length) throw new Error('No dids provided')
|
|
110
|
+
const policies: Record<RequesterDid, RecipientDid | null> = {}
|
|
111
|
+
for await (const requesterDid of dids) {
|
|
112
|
+
policies[requesterDid] = await agent.mediationManagerGetMediationPolicy({ requesterDid })
|
|
113
|
+
}
|
|
114
|
+
console.log('POLICIES')
|
|
115
|
+
console.table(policies)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const listPolicies: Action<Pick<Options, 'allowFrom' | 'denyFrom'>> = async (options, _cmd, agent) => {
|
|
119
|
+
try {
|
|
120
|
+
const res = await agent.mediationManagerListMediationPolicies()
|
|
121
|
+
console.log('POLICIES')
|
|
122
|
+
if (options.allowFrom) return console.table(Object.entries(res).filter(([, policy]) => policy === ALLOW))
|
|
123
|
+
if (options.denyFrom) return console.table(Object.entries(res).filter(([, policy]) => policy === DENY))
|
|
124
|
+
else console.table(res)
|
|
125
|
+
} catch (e) {
|
|
126
|
+
console.error(e.message)
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const listResponses: Action<Pick<Options, 'granted' | 'denied'>> = async (options, _cmd, agent) => {
|
|
131
|
+
try {
|
|
132
|
+
const { granted, denied } = options
|
|
133
|
+
const res = await agent.mediationManagerGetAllMediations()
|
|
134
|
+
console.log('MEDIATIONS')
|
|
135
|
+
if (granted) return console.table(Object.entries(res).filter(([, response]) => response === 'GRANTED'))
|
|
136
|
+
if (denied) return console.table(Object.entries(res).filter(([, response]) => response === 'DENIED'))
|
|
137
|
+
else console.table(res)
|
|
138
|
+
} catch (e) {
|
|
139
|
+
console.error(e.message)
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const removePolicies: Action<Pick<Options, 'fileJson' | 'interactive'>> = async (options, cmd, agent) => {
|
|
144
|
+
try {
|
|
145
|
+
if (options.fileJson) {
|
|
146
|
+
const jsonData = await import(options.fileJson, { assert: { type: 'json' } })
|
|
147
|
+
const dids = jsonData.default
|
|
148
|
+
await updatePolicies({ dids, remove: true, agent })
|
|
149
|
+
} else if (options.interactive) {
|
|
150
|
+
const dids = await promptForDids('Remove')
|
|
151
|
+
await updatePolicies({ dids, remove: true, agent })
|
|
152
|
+
} else {
|
|
153
|
+
const dids = cmd.args
|
|
154
|
+
await updatePolicies({ dids, remove: true, agent })
|
|
155
|
+
}
|
|
156
|
+
console.log('Mediation policies removed')
|
|
157
|
+
} catch (e) {
|
|
158
|
+
console.error(e.message)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
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
|
+
)
|
|
169
|
+
|
|
170
|
+
mediate
|
|
171
|
+
.command('allow-from')
|
|
172
|
+
.description('add dids that should be allowed for mediation')
|
|
173
|
+
.option('-f, --file-json <string>', 'read dids from json file')
|
|
174
|
+
.option('-i, --interactive', 'interactively input dids')
|
|
175
|
+
.action(handler(policy(ALLOW)))
|
|
176
|
+
|
|
177
|
+
mediate
|
|
178
|
+
.command('deny-from')
|
|
179
|
+
.description('deny dids that should be denied for mediation')
|
|
180
|
+
.option('-f, --file-json <string>', 'read dids from json file')
|
|
181
|
+
.option('-i, --interactive', 'interactively input dids')
|
|
182
|
+
.action(handler(policy(DENY)))
|
|
183
|
+
|
|
184
|
+
mediate
|
|
185
|
+
.command('read')
|
|
186
|
+
.description('read mediation policy for a specific did (or list of dids)')
|
|
187
|
+
.option('-i, --interactive', 'interactively input dids')
|
|
188
|
+
.option('-f, --file-json <string>', 'read dids from json file')
|
|
189
|
+
.action(handler(readPolicies))
|
|
190
|
+
|
|
191
|
+
mediate
|
|
192
|
+
.command('list-policies')
|
|
193
|
+
.description('list mediation policies')
|
|
194
|
+
.option('-a, --allow-from', 'list allow policies')
|
|
195
|
+
.option('-d, --deny-from', 'list deny policies')
|
|
196
|
+
.action(handler(listPolicies))
|
|
197
|
+
|
|
198
|
+
mediate
|
|
199
|
+
.command('list-responses')
|
|
200
|
+
.description('list mediation responses')
|
|
201
|
+
.option('-a, --granted', 'list granted policies')
|
|
202
|
+
.option('-d, --denied', 'list denied policies')
|
|
203
|
+
.action(handler(listResponses))
|
|
204
|
+
|
|
205
|
+
mediate
|
|
206
|
+
.command('remove')
|
|
207
|
+
.description('remove mediation policies')
|
|
208
|
+
.option('-f, --file-json <string>', 'read dids from json file')
|
|
209
|
+
.option('-i, --interactive', 'interactively input dids')
|
|
210
|
+
.action(handler(removePolicies))
|
|
211
|
+
|
|
212
|
+
export { mediate }
|
package/src/setup.ts
CHANGED
|
@@ -9,6 +9,10 @@ import {
|
|
|
9
9
|
IResolver,
|
|
10
10
|
TAgent,
|
|
11
11
|
} from '@veramo/core-types'
|
|
12
|
+
import {
|
|
13
|
+
IMediationManager,
|
|
14
|
+
|
|
15
|
+
} from "@veramo/mediation-manager"
|
|
12
16
|
import { ISelectiveDisclosure } from '@veramo/selective-disclosure'
|
|
13
17
|
import { IDIDComm } from '@veramo/did-comm'
|
|
14
18
|
import { IDIDDiscovery } from '@veramo/did-discovery'
|
|
@@ -57,7 +61,8 @@ export type EnabledInterfaces = IDIDManager &
|
|
|
57
61
|
IDIDComm &
|
|
58
62
|
ICredentialPlugin &
|
|
59
63
|
ISelectiveDisclosure &
|
|
60
|
-
IDIDDiscovery
|
|
64
|
+
IDIDDiscovery &
|
|
65
|
+
IMediationManager
|
|
61
66
|
|
|
62
67
|
export type ConfiguredAgent = TAgent<EnabledInterfaces>
|
|
63
68
|
|