@sphereon/ssi-sdk-ext.identifier-resolution 0.36.1-feature.integration.fides.68 → 0.36.1-feature.integration.fides.74
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/dist/index.cjs +37 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +37 -3
- package/dist/index.js.map +1 -1
- package/package.json +13 -13
- package/src/functions/managedIdentifierFunctions.ts +56 -8
package/dist/index.js
CHANGED
|
@@ -4780,7 +4780,6 @@ async function getManagedDidIdentifier(opts, context) {
|
|
|
4780
4780
|
identifier = opts.identifier;
|
|
4781
4781
|
}
|
|
4782
4782
|
const did = identifier.did;
|
|
4783
|
-
const keys = identifier?.keys;
|
|
4784
4783
|
const extendedKey = await getFirstKeyWithRelation({
|
|
4785
4784
|
...opts,
|
|
4786
4785
|
// Make sure we use offline mode if no pref was supplied. We are looking for managed DIDs after all. Could be it is not published yet
|
|
@@ -4789,7 +4788,6 @@ async function getManagedDidIdentifier(opts, context) {
|
|
|
4789
4788
|
vmRelationship: opts.vmRelationship ?? "verificationMethod"
|
|
4790
4789
|
}, context);
|
|
4791
4790
|
const key = extendedKey;
|
|
4792
|
-
const controllerKeyId = identifier.controllerKeyId;
|
|
4793
4791
|
const jwk = toJwk(key.publicKeyHex, key.type, {
|
|
4794
4792
|
key
|
|
4795
4793
|
});
|
|
@@ -4802,6 +4800,42 @@ async function getManagedDidIdentifier(opts, context) {
|
|
|
4802
4800
|
kid = `${did}${hash}${kid}`;
|
|
4803
4801
|
}
|
|
4804
4802
|
const issuer = opts.issuer ?? did;
|
|
4803
|
+
let filteredKeys = identifier?.keys ?? [];
|
|
4804
|
+
if (opts.kmsKeyRef) {
|
|
4805
|
+
const keysByKmsKeyRef = filteredKeys.filter((k) => k.kid === opts.kmsKeyRef);
|
|
4806
|
+
if (keysByKmsKeyRef.length > 0) {
|
|
4807
|
+
filteredKeys = keysByKmsKeyRef;
|
|
4808
|
+
}
|
|
4809
|
+
}
|
|
4810
|
+
if (filteredKeys.length === identifier?.keys?.length && opts.vmRelationship) {
|
|
4811
|
+
const keysByVmRelationship = filteredKeys.filter((k) => {
|
|
4812
|
+
const purposes = k.meta?.purposes;
|
|
4813
|
+
if (!purposes || purposes.length === 0) {
|
|
4814
|
+
return opts.vmRelationship === "verificationMethod";
|
|
4815
|
+
}
|
|
4816
|
+
return purposes.includes(opts.vmRelationship);
|
|
4817
|
+
});
|
|
4818
|
+
if (keysByVmRelationship.length > 0) {
|
|
4819
|
+
filteredKeys = keysByVmRelationship;
|
|
4820
|
+
}
|
|
4821
|
+
}
|
|
4822
|
+
if (filteredKeys.length === identifier?.keys?.length && typeof opts.identifier === "string" && opts.identifier.includes("#")) {
|
|
4823
|
+
const fragment = opts.identifier.split("#")[1];
|
|
4824
|
+
const keysByFragment = filteredKeys.filter((k) => {
|
|
4825
|
+
const vmId = k.meta?.verificationMethod?.id;
|
|
4826
|
+
return vmId === `${did}#${fragment}` || vmId === fragment || k.kid === fragment;
|
|
4827
|
+
});
|
|
4828
|
+
if (keysByFragment.length > 0) {
|
|
4829
|
+
filteredKeys = keysByFragment;
|
|
4830
|
+
}
|
|
4831
|
+
}
|
|
4832
|
+
const keys = filteredKeys;
|
|
4833
|
+
const controllerKeyId = key.kid;
|
|
4834
|
+
const filteredIdentifier = {
|
|
4835
|
+
...identifier,
|
|
4836
|
+
keys: filteredKeys,
|
|
4837
|
+
controllerKeyId
|
|
4838
|
+
};
|
|
4805
4839
|
return {
|
|
4806
4840
|
method,
|
|
4807
4841
|
key,
|
|
@@ -4813,7 +4847,7 @@ async function getManagedDidIdentifier(opts, context) {
|
|
|
4813
4847
|
kid,
|
|
4814
4848
|
keys,
|
|
4815
4849
|
issuer,
|
|
4816
|
-
identifier,
|
|
4850
|
+
identifier: filteredIdentifier,
|
|
4817
4851
|
clientId: opts.clientId,
|
|
4818
4852
|
clientIdScheme: opts.clientIdScheme,
|
|
4819
4853
|
opts
|