Open cre8 opened 9 months ago
Importing the schema json file with
import schema from '../../plugin.schema.json' assert { type: 'json' }
and then setting the schema like: readonly schema = schema.ISphereonKeyManager
Should work. However we need to update the tsconfig.json
by setting module to ESNext
to support assertion imports.
This leads to a problem:
Beside the current file is generated outside of the rootDir of the project so it can not be referenced (I tried to include it with the file command is the tsconfig but without success)
In the meantime it can be patched like:
diff --git a/node_modules/@sphereon/ssi-sdk-ext.key-manager/dist/agent/SphereonKeyManager.js b/node_modules/@sphereon/ssi-sdk-ext.key-manager/dist/agent/SphereonKeyManager.js
index 28aa003..ea5c1b1 100644
--- a/node_modules/@sphereon/ssi-sdk-ext.key-manager/dist/agent/SphereonKeyManager.js
+++ b/node_modules/@sphereon/ssi-sdk-ext.key-manager/dist/agent/SphereonKeyManager.js
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.SphereonKeyManager = void 0;
const key_manager_1 = require("@veramo/key-manager");
const ssi_sdk_ext_kms_local_1 = require("@sphereon/ssi-sdk-ext.kms-local");
+const schema = require('../../plugin.schema.json');
class SphereonKeyManager extends key_manager_1.KeyManager {
constructor(options) {
super({ store: options.store, kms: options.kms });
@@ -20,6 +21,15 @@ class SphereonKeyManager extends key_manager_1.KeyManager {
const methods = this.methods;
methods.keyManagerVerify = this.keyManagerVerify.bind(this);
this.localMethods = methods;
+ //append the SphereonKeyManager schema to the agent schema
+ this.schema.components.schemas = {
+ ...this.schema.components.schemas,
+ ...schema.ISphereonKeyManager.components.schemas,
+ }
+ this.schema.components.methods = {
+ ...this.schema.components.methods,
+ ...schema.ISphereonKeyManager.components.methods,
+ }
}
getLocalKms(name) {
const kms = this.localKms[name];
We cannot just overwrite it, it needs to be appended.
The SphereonKeyManager is appending the Veramo Keymanager with some functions like https://github.com/Sphereon-Opensource/SSI-SDK-crypto-extensions/blob/650b1f4c4e42e1ffb29ad8e7480e900aacb80487/packages/key-manager/src/agent/SphereonKeyManager.ts#L40
However the schema value from
VeramoKeyManager
is not overwritten, it is still pointing to the schema of the veramo pluging that is not including these new functions. This will lead to an error when exposing the methods via the remote service since the objectkeyManagerVerify
does not exist in the schema.Solution: override the schema in https://github.com/Sphereon-Opensource/SSI-SDK-crypto-extensions/blob/650b1f4c4e42e1ffb29ad8e7480e900aacb80487/packages/key-manager/src/agent/SphereonKeyManager.ts#L7 with the
plugin.schema.json
that is including the function.