@sphereon/ssi-sdk-ext.identifier-resolution 0.36.1-next.11 → 0.36.1-next.115
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 +53 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +53 -10
- package/dist/index.js.map +1 -1
- package/package.json +13 -13
- package/plugin.schema.json +2 -2
- package/src/functions/externalIdentifierFunctions.ts +7 -0
- package/src/functions/managedIdentifierFunctions.ts +65 -12
package/dist/index.cjs
CHANGED
|
@@ -1088,9 +1088,9 @@ var require_plugin_schema = __commonJS({
|
|
|
1088
1088
|
type: "object"
|
|
1089
1089
|
},
|
|
1090
1090
|
DidDocumentJwks: {
|
|
1091
|
-
$ref: '#/components/schemas/Record<Exclude<DIDDocumentSection,("publicKey"|"service")>,def-interface-.ts-
|
|
1091
|
+
$ref: '#/components/schemas/Record<Exclude<DIDDocumentSection,("publicKey"|"service")>,def-interface-.ts-36172-36897-.ts-0-63936[]>'
|
|
1092
1092
|
},
|
|
1093
|
-
'Record<Exclude<DIDDocumentSection,("publicKey"|"service")>,def-interface-.ts-
|
|
1093
|
+
'Record<Exclude<DIDDocumentSection,("publicKey"|"service")>,def-interface-.ts-36172-36897-.ts-0-63936[]>': {
|
|
1094
1094
|
type: "object",
|
|
1095
1095
|
properties: {
|
|
1096
1096
|
verificationMethod: {
|
|
@@ -4866,7 +4866,6 @@ async function getManagedDidIdentifier(opts, context) {
|
|
|
4866
4866
|
identifier = opts.identifier;
|
|
4867
4867
|
}
|
|
4868
4868
|
const did = identifier.did;
|
|
4869
|
-
const keys = identifier?.keys;
|
|
4870
4869
|
const extendedKey = await (0, import_ssi_sdk_ext.getFirstKeyWithRelation)({
|
|
4871
4870
|
...opts,
|
|
4872
4871
|
// 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
|
|
@@ -4875,19 +4874,57 @@ async function getManagedDidIdentifier(opts, context) {
|
|
|
4875
4874
|
vmRelationship: opts.vmRelationship ?? "verificationMethod"
|
|
4876
4875
|
}, context);
|
|
4877
4876
|
const key = extendedKey;
|
|
4878
|
-
const controllerKeyId = identifier.controllerKeyId;
|
|
4879
4877
|
const jwk = (0, import_ssi_sdk_ext2.toJwk)(key.publicKeyHex, key.type, {
|
|
4880
4878
|
key
|
|
4881
4879
|
});
|
|
4882
4880
|
const jwkThumbprint = key.meta?.jwkThumbprint ?? (0, import_ssi_sdk_ext2.calculateJwkThumbprint)({
|
|
4883
4881
|
jwk
|
|
4884
4882
|
});
|
|
4885
|
-
let kid = opts.kid ?? extendedKey.meta?.verificationMethod?.id;
|
|
4886
|
-
if (!kid.startsWith(did)) {
|
|
4883
|
+
let kid = opts.kid ?? extendedKey.meta?.verificationMethod?.id ?? extendedKey.kid;
|
|
4884
|
+
if (kid && !kid.startsWith(did)) {
|
|
4887
4885
|
const hash = kid.startsWith("#") ? "" : "#";
|
|
4888
4886
|
kid = `${did}${hash}${kid}`;
|
|
4889
4887
|
}
|
|
4890
4888
|
const issuer = opts.issuer ?? did;
|
|
4889
|
+
let filteredKeys = identifier?.keys ?? [];
|
|
4890
|
+
let isFiltered = false;
|
|
4891
|
+
if (opts.kmsKeyRef) {
|
|
4892
|
+
const keysByKmsKeyRef = filteredKeys.filter((k) => k.kid === opts.kmsKeyRef);
|
|
4893
|
+
if (keysByKmsKeyRef.length > 0) {
|
|
4894
|
+
filteredKeys = keysByKmsKeyRef;
|
|
4895
|
+
isFiltered = true;
|
|
4896
|
+
}
|
|
4897
|
+
}
|
|
4898
|
+
if (!isFiltered && opts.vmRelationship) {
|
|
4899
|
+
const keysByVmRelationship = filteredKeys.filter((k) => {
|
|
4900
|
+
const purposes = k.meta?.purposes;
|
|
4901
|
+
if (!purposes || purposes.length === 0) {
|
|
4902
|
+
return opts.vmRelationship === "verificationMethod";
|
|
4903
|
+
}
|
|
4904
|
+
return purposes.includes(opts.vmRelationship);
|
|
4905
|
+
});
|
|
4906
|
+
if (keysByVmRelationship.length > 0) {
|
|
4907
|
+
filteredKeys = keysByVmRelationship;
|
|
4908
|
+
isFiltered = true;
|
|
4909
|
+
}
|
|
4910
|
+
}
|
|
4911
|
+
if (!isFiltered && typeof opts.identifier === "string" && opts.identifier.includes("#")) {
|
|
4912
|
+
const fragment = opts.identifier.split("#")[1];
|
|
4913
|
+
const keysByFragment = filteredKeys.filter((k) => {
|
|
4914
|
+
const vmId = k.meta?.verificationMethod?.id;
|
|
4915
|
+
return vmId === `${did}#${fragment}` || vmId === fragment || k.kid === fragment;
|
|
4916
|
+
});
|
|
4917
|
+
if (keysByFragment.length > 0) {
|
|
4918
|
+
filteredKeys = keysByFragment;
|
|
4919
|
+
}
|
|
4920
|
+
}
|
|
4921
|
+
const keys = filteredKeys;
|
|
4922
|
+
const controllerKeyId = key.kid;
|
|
4923
|
+
const filteredIdentifier = {
|
|
4924
|
+
...identifier,
|
|
4925
|
+
keys: filteredKeys,
|
|
4926
|
+
controllerKeyId
|
|
4927
|
+
};
|
|
4891
4928
|
return {
|
|
4892
4929
|
method,
|
|
4893
4930
|
key,
|
|
@@ -4899,7 +4936,7 @@ async function getManagedDidIdentifier(opts, context) {
|
|
|
4899
4936
|
kid,
|
|
4900
4937
|
keys,
|
|
4901
4938
|
issuer,
|
|
4902
|
-
identifier,
|
|
4939
|
+
identifier: filteredIdentifier,
|
|
4903
4940
|
clientId: opts.clientId,
|
|
4904
4941
|
clientIdScheme: opts.clientIdScheme,
|
|
4905
4942
|
opts
|
|
@@ -5019,10 +5056,10 @@ async function getManagedOID4VCIssuerIdentifier(opts, context) {
|
|
|
5019
5056
|
}
|
|
5020
5057
|
__name(getManagedOID4VCIssuerIdentifier, "getManagedOID4VCIssuerIdentifier");
|
|
5021
5058
|
async function getManagedIdentifier(opts, context) {
|
|
5022
|
-
let resolutionResult;
|
|
5023
5059
|
if (isManagedIdentifierResult(opts)) {
|
|
5024
|
-
opts;
|
|
5060
|
+
return opts;
|
|
5025
5061
|
}
|
|
5062
|
+
let resolutionResult;
|
|
5026
5063
|
if (isManagedIdentifierKidOpts(opts)) {
|
|
5027
5064
|
resolutionResult = await getManagedKidIdentifier(opts, context);
|
|
5028
5065
|
} else if (isManagedIdentifierDidOpts(opts)) {
|
|
@@ -5262,7 +5299,13 @@ async function resolveExternalDidIdentifier(opts, context) {
|
|
|
5262
5299
|
}).resolve(did);
|
|
5263
5300
|
const didDocument = didResolutionResult.didDocument ?? void 0;
|
|
5264
5301
|
const didJwks = didDocument ? (0, import_ssi_sdk_ext4.didDocumentToJwks)(didDocument) : void 0;
|
|
5265
|
-
const jwks = didJwks ? Array.from(new Set(Array.from(Object.values(didJwks).filter((jwks2) => (0, import_utils.isDefined)(jwks2) && jwks2.length > 0).flatMap((jwks2) => jwks2)).
|
|
5302
|
+
const jwks = didJwks ? Array.from(new Set(Array.from(Object.values(didJwks).filter((jwks2) => (0, import_utils.isDefined)(jwks2) && jwks2.length > 0).flatMap((jwks2) => jwks2)).filter((jwk) => {
|
|
5303
|
+
if (!didParsed.fragment) {
|
|
5304
|
+
return true;
|
|
5305
|
+
}
|
|
5306
|
+
const fullKid = `${didParsed.did}#${didParsed.fragment}`;
|
|
5307
|
+
return jwk.kid === fullKid || jwk.kid === didParsed.fragment;
|
|
5308
|
+
}).flatMap((jwk) => {
|
|
5266
5309
|
return {
|
|
5267
5310
|
jwk,
|
|
5268
5311
|
jwkThumbprint: (0, import_ssi_sdk_ext5.calculateJwkThumbprint)({
|