@sphereon/ssi-sdk.oid4vci-holder 0.34.1-feature.SSISDK.26.48 → 0.34.1-feature.SSISDK.26.54
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 +50 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +29 -6
- package/dist/index.js.map +1 -1
- package/package.json +24 -24
- package/src/agent/OID4VCIHolder.ts +31 -17
- package/src/services/OID4VCIHolderService.ts +24 -2
- package/src/types/IOID4VCIHolder.ts +3 -1
package/dist/index.cjs
CHANGED
|
@@ -139,7 +139,8 @@ var import_oid4vci_common4 = require("@sphereon/oid4vci-common");
|
|
|
139
139
|
var import_ssi_sdk_ext5 = require("@sphereon/ssi-sdk-ext.did-utils");
|
|
140
140
|
var import_ssi_sdk_ext6 = require("@sphereon/ssi-sdk-ext.identifier-resolution");
|
|
141
141
|
var import_ssi_sdk_ext7 = require("@sphereon/ssi-sdk-ext.key-utils");
|
|
142
|
-
var import_ssi_sdk2 = require("@sphereon/ssi-sdk.
|
|
142
|
+
var import_ssi_sdk2 = require("@sphereon/ssi-sdk.core");
|
|
143
|
+
var import_ssi_sdk3 = require("@sphereon/ssi-sdk.data-store");
|
|
143
144
|
var import_ssi_types2 = require("@sphereon/ssi-types");
|
|
144
145
|
var import_utils2 = require("@veramo/utils");
|
|
145
146
|
var import_did_jwt = require("did-jwt");
|
|
@@ -228,6 +229,7 @@ var OID4VCIMachineGuards = /* @__PURE__ */ function(OID4VCIMachineGuards2) {
|
|
|
228
229
|
OID4VCIMachineGuards2["requirePinGuard"] = "oid4vciRequirePinGuard";
|
|
229
230
|
OID4VCIMachineGuards2["requireAuthorizationGuard"] = "oid4vciRequireAuthorizationGuard";
|
|
230
231
|
OID4VCIMachineGuards2["noAuthorizationGuard"] = "oid4vciNoAuthorizationGuard";
|
|
232
|
+
OID4VCIMachineGuards2["hasNonceEndpointGuard"] = "oid4vciHasNonceEndpointGuard ";
|
|
231
233
|
OID4VCIMachineGuards2["hasAuthorizationResponse"] = "oid4vciHasAuthorizationResponse";
|
|
232
234
|
OID4VCIMachineGuards2["hasNoContactIdentityGuard"] = "oid4vciHasNoContactIdentityGuard";
|
|
233
235
|
OID4VCIMachineGuards2["verificationCodeGuard"] = "oid4vciVerificationCodeGuard";
|
|
@@ -1683,7 +1685,13 @@ var selectCredentialLocaleBranding = /* @__PURE__ */ __name(async (args) => {
|
|
|
1683
1685
|
}, "selectCredentialLocaleBranding");
|
|
1684
1686
|
var verifyCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
1685
1687
|
const { mappedCredential, hasher, onVerifyEBSICredentialIssuer, schemaValidation, context } = args;
|
|
1686
|
-
const
|
|
1688
|
+
const credentialResponse = mappedCredential.credentialToAccept.credentialResponse;
|
|
1689
|
+
let credential;
|
|
1690
|
+
if ("credential" in credentialResponse) {
|
|
1691
|
+
credential = credentialResponse.credential;
|
|
1692
|
+
} else if ("credentials" in credentialResponse && credentialResponse.credentials && Array.isArray(credentialResponse.credentials) && credentialResponse.credentials.length > 0) {
|
|
1693
|
+
credential = credentialResponse.credentials[0].credential;
|
|
1694
|
+
}
|
|
1687
1695
|
if (!credential) {
|
|
1688
1696
|
return Promise.reject(Error("No credential found in credential response"));
|
|
1689
1697
|
}
|
|
@@ -1739,7 +1747,12 @@ var verifyCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
|
1739
1747
|
var mapCredentialToAccept = /* @__PURE__ */ __name(async (args) => {
|
|
1740
1748
|
const { credentialToAccept, hasher } = args;
|
|
1741
1749
|
const credentialResponse = credentialToAccept.credentialResponse;
|
|
1742
|
-
|
|
1750
|
+
let verifiableCredential;
|
|
1751
|
+
if ("credential" in credentialResponse) {
|
|
1752
|
+
verifiableCredential = credentialResponse.credential;
|
|
1753
|
+
} else if ("credentials" in credentialResponse && credentialResponse.credentials && Array.isArray(credentialResponse.credentials) && credentialResponse.credentials.length > 0) {
|
|
1754
|
+
verifiableCredential = credentialResponse.credentials[0].credential;
|
|
1755
|
+
}
|
|
1743
1756
|
if (!verifiableCredential) {
|
|
1744
1757
|
return Promise.reject(Error("No credential found in credential response"));
|
|
1745
1758
|
}
|
|
@@ -2073,6 +2086,7 @@ var getIssuanceCryptoSuite = /* @__PURE__ */ __name(async (opts) => {
|
|
|
2073
2086
|
case "jwt":
|
|
2074
2087
|
case "jwt_vc_json":
|
|
2075
2088
|
case "jwt_vc":
|
|
2089
|
+
case "vc+sd-jwt":
|
|
2076
2090
|
case "dc+sd-jwt":
|
|
2077
2091
|
case "mso_mdoc": {
|
|
2078
2092
|
const supportedPreferences = jwtCryptographicSuitePreferences.filter((suite) => signing_algs_supported.includes(suite));
|
|
@@ -2142,7 +2156,6 @@ var startFirstPartApplicationMachine = /* @__PURE__ */ __name(async (args, conte
|
|
|
2142
2156
|
|
|
2143
2157
|
// src/agent/OID4VCIHolder.ts
|
|
2144
2158
|
var import_polyfill = require("cross-fetch/polyfill");
|
|
2145
|
-
var import_ssi_sdk3 = require("@sphereon/ssi-sdk.core");
|
|
2146
2159
|
var oid4vciHolderContextMethods = [
|
|
2147
2160
|
"cmGetContacts",
|
|
2148
2161
|
"cmGetContact",
|
|
@@ -2158,7 +2171,7 @@ var oid4vciHolderContextMethods = [
|
|
|
2158
2171
|
];
|
|
2159
2172
|
var logger = import_ssi_types2.Loggers.DEFAULT.get("sphereon:oid4vci:holder");
|
|
2160
2173
|
function signCallback(identifier, context, nonce) {
|
|
2161
|
-
return async (jwt, kid) => {
|
|
2174
|
+
return async (jwt, kid, noIssPayloadUpdate) => {
|
|
2162
2175
|
let resolution = await context.agent.identifierManagedGet(identifier);
|
|
2163
2176
|
const jwk = jwt.header.jwk ?? (resolution.method === "jwk" ? resolution.jwk : void 0);
|
|
2164
2177
|
if (!resolution.issuer && !jwt.payload.iss) {
|
|
@@ -2176,7 +2189,7 @@ function signCallback(identifier, context, nonce) {
|
|
|
2176
2189
|
return (await context.agent.jwtCreateJwsCompactSignature({
|
|
2177
2190
|
issuer: {
|
|
2178
2191
|
...resolution,
|
|
2179
|
-
noIssPayloadUpdate: false
|
|
2192
|
+
noIssPayloadUpdate: noIssPayloadUpdate ?? false
|
|
2180
2193
|
},
|
|
2181
2194
|
protectedHeader: header,
|
|
2182
2195
|
payload
|
|
@@ -2212,6 +2225,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2212
2225
|
};
|
|
2213
2226
|
vcFormatPreferences = [
|
|
2214
2227
|
"dc+sd-jwt",
|
|
2228
|
+
"vc+sd-jwt",
|
|
2215
2229
|
"mso_mdoc",
|
|
2216
2230
|
"jwt_vc_json",
|
|
2217
2231
|
"jwt_vc",
|
|
@@ -2244,7 +2258,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2244
2258
|
onIdentifierCreated;
|
|
2245
2259
|
onVerifyEBSICredentialIssuer;
|
|
2246
2260
|
constructor(options) {
|
|
2247
|
-
const { onContactIdentityCreated, onCredentialStored, onIdentifierCreated, onVerifyEBSICredentialIssuer, vcFormatPreferences, jsonldCryptographicSuitePreferences, didMethodPreferences, jwtCryptographicSuitePreferences, defaultAuthorizationRequestOptions, hasher =
|
|
2261
|
+
const { onContactIdentityCreated, onCredentialStored, onIdentifierCreated, onVerifyEBSICredentialIssuer, vcFormatPreferences, jsonldCryptographicSuitePreferences, didMethodPreferences, jwtCryptographicSuitePreferences, defaultAuthorizationRequestOptions, hasher = import_ssi_sdk2.defaultHasher } = {
|
|
2248
2262
|
...options
|
|
2249
2263
|
};
|
|
2250
2264
|
this.hasher = hasher;
|
|
@@ -2625,26 +2639,26 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2625
2639
|
return Promise.reject(Error("Missing credential offers in context"));
|
|
2626
2640
|
}
|
|
2627
2641
|
let correlationId = credentialsToAccept[0].correlationId;
|
|
2628
|
-
let identifierType =
|
|
2642
|
+
let identifierType = import_ssi_sdk3.CorrelationIdentifierType.DID;
|
|
2629
2643
|
if (!correlationId.toLowerCase().startsWith("did:")) {
|
|
2630
|
-
identifierType =
|
|
2644
|
+
identifierType = import_ssi_sdk3.CorrelationIdentifierType.URL;
|
|
2631
2645
|
if (correlationId.startsWith("http")) {
|
|
2632
2646
|
correlationId = new URL(correlationId).hostname;
|
|
2633
2647
|
}
|
|
2634
2648
|
}
|
|
2635
2649
|
const identity = {
|
|
2636
2650
|
alias: credentialsToAccept[0].correlationId,
|
|
2637
|
-
origin:
|
|
2651
|
+
origin: import_ssi_sdk3.IdentityOrigin.EXTERNAL,
|
|
2638
2652
|
roles: [
|
|
2639
|
-
|
|
2653
|
+
import_ssi_sdk3.CredentialRole.ISSUER
|
|
2640
2654
|
],
|
|
2641
2655
|
identifier: {
|
|
2642
2656
|
type: identifierType,
|
|
2643
2657
|
correlationId
|
|
2644
2658
|
},
|
|
2645
|
-
...identifierType ===
|
|
2659
|
+
...identifierType === import_ssi_sdk3.CorrelationIdentifierType.URL && {
|
|
2646
2660
|
connection: {
|
|
2647
|
-
type:
|
|
2661
|
+
type: import_ssi_sdk3.ConnectionType.OPENID_CONNECT,
|
|
2648
2662
|
config: {
|
|
2649
2663
|
clientId: "138d7bf8-c930-4c6e-b928-97d3a4928b01",
|
|
2650
2664
|
clientSecret: "03b3955f-d020-4f2a-8a27-4e452d4e27a0",
|
|
@@ -2671,7 +2685,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2671
2685
|
}
|
|
2672
2686
|
async oid4vciHolderGetIssuerBranding(args, context) {
|
|
2673
2687
|
const { serverMetadata, contact } = args;
|
|
2674
|
-
const issuerCorrelationId = contact?.identities.filter((identity) => identity.roles.includes(
|
|
2688
|
+
const issuerCorrelationId = contact?.identities.filter((identity) => identity.roles.includes(import_ssi_sdk3.CredentialRole.ISSUER)).map((identity) => identity.identifier.correlationId)[0];
|
|
2675
2689
|
if (issuerCorrelationId) {
|
|
2676
2690
|
const branding = await context.agent.ibGetIssuerBranding({
|
|
2677
2691
|
filter: [
|
|
@@ -2701,7 +2715,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2701
2715
|
if (!contact) {
|
|
2702
2716
|
return Promise.reject(Error("Missing contact in context"));
|
|
2703
2717
|
}
|
|
2704
|
-
const issuerCorrelationId = contact?.identities.filter((identity) => identity.roles.includes(
|
|
2718
|
+
const issuerCorrelationId = contact?.identities.filter((identity) => identity.roles.includes(import_ssi_sdk3.CredentialRole.ISSUER)).map((identity) => identity.identifier.correlationId)[0];
|
|
2705
2719
|
const branding = await context.agent.ibGetIssuerBranding({
|
|
2706
2720
|
filter: [
|
|
2707
2721
|
{
|
|
@@ -2797,9 +2811,18 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2797
2811
|
if (Array.isArray(subjectIssuance?.notification_events_supported)) {
|
|
2798
2812
|
event = subjectIssuance.notification_events_supported.includes("credential_accepted_holder_signed") ? "credential_accepted_holder_signed" : "credential_deleted_holder_signed";
|
|
2799
2813
|
logger.log(`Subject issuance/signing will be used, with event`, event);
|
|
2800
|
-
const
|
|
2814
|
+
const credentialResponse = mappedCredentialToAccept.credentialToAccept.credentialResponse;
|
|
2815
|
+
let issuerVC;
|
|
2816
|
+
if ("credential" in credentialResponse) {
|
|
2817
|
+
issuerVC = credentialResponse.credential;
|
|
2818
|
+
} else if ("credentials" in credentialResponse && credentialResponse.credentials && Array.isArray(credentialResponse.credentials) && credentialResponse.credentials.length > 0) {
|
|
2819
|
+
issuerVC = credentialResponse.credentials[0].credential;
|
|
2820
|
+
}
|
|
2821
|
+
if (!issuerVC) {
|
|
2822
|
+
return Promise.reject(Error("No credential found in credential response"));
|
|
2823
|
+
}
|
|
2801
2824
|
const wrappedIssuerVC = import_ssi_types2.CredentialMapper.toWrappedVerifiableCredential(issuerVC, {
|
|
2802
|
-
hasher: this.hasher ??
|
|
2825
|
+
hasher: this.hasher ?? import_ssi_sdk2.defaultHasher
|
|
2803
2826
|
});
|
|
2804
2827
|
console.log(`Wrapped VC: ${wrappedIssuerVC.type}, ${wrappedIssuerVC.format}`);
|
|
2805
2828
|
let issuer;
|
|
@@ -2900,11 +2923,11 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2900
2923
|
const [subjectCorrelationType, subjectCorrelationId] = this.determineSubjectCorrelation(issuanceOpt.identifier, issuer);
|
|
2901
2924
|
const persistedCredential = await context.agent.crsAddCredential({
|
|
2902
2925
|
credential: {
|
|
2903
|
-
rawDocument: (0,
|
|
2926
|
+
rawDocument: (0, import_ssi_sdk3.ensureRawDocument)(persistCredential),
|
|
2904
2927
|
kmsKeyRef,
|
|
2905
2928
|
identifierMethod: method,
|
|
2906
|
-
credentialRole:
|
|
2907
|
-
issuerCorrelationType: issuer?.startsWith("did:") ?
|
|
2929
|
+
credentialRole: import_ssi_sdk3.CredentialRole.HOLDER,
|
|
2930
|
+
issuerCorrelationType: issuer?.startsWith("did:") ? import_ssi_sdk3.CredentialCorrelationType.DID : import_ssi_sdk3.CredentialCorrelationType.URL,
|
|
2908
2931
|
issuerCorrelationId: issuer,
|
|
2909
2932
|
subjectCorrelationType,
|
|
2910
2933
|
subjectCorrelationId
|
|
@@ -2972,12 +2995,12 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2972
2995
|
case "did":
|
|
2973
2996
|
if ((0, import_ssi_sdk_ext6.isManagedIdentifierResult)(identifier) && (0, import_ssi_sdk_ext6.isManagedIdentifierDidResult)(identifier)) {
|
|
2974
2997
|
return [
|
|
2975
|
-
|
|
2998
|
+
import_ssi_sdk3.CredentialCorrelationType.DID,
|
|
2976
2999
|
identifier.did
|
|
2977
3000
|
];
|
|
2978
3001
|
} else if ((0, import_ssi_sdk_ext6.isManagedIdentifierDidOpts)(identifier)) {
|
|
2979
3002
|
return [
|
|
2980
|
-
|
|
3003
|
+
import_ssi_sdk3.CredentialCorrelationType.DID,
|
|
2981
3004
|
typeof identifier.identifier === "string" ? identifier.identifier : identifier.identifier.did
|
|
2982
3005
|
];
|
|
2983
3006
|
}
|
|
@@ -2985,12 +3008,12 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2985
3008
|
case "kid":
|
|
2986
3009
|
if ((0, import_ssi_sdk_ext6.isManagedIdentifierResult)(identifier) && (0, import_ssi_sdk_ext6.isManagedIdentifierKidResult)(identifier)) {
|
|
2987
3010
|
return [
|
|
2988
|
-
|
|
3011
|
+
import_ssi_sdk3.CredentialCorrelationType.KID,
|
|
2989
3012
|
identifier.kid
|
|
2990
3013
|
];
|
|
2991
3014
|
} else if ((0, import_ssi_sdk_ext6.isManagedIdentifierDidOpts)(identifier)) {
|
|
2992
3015
|
return [
|
|
2993
|
-
|
|
3016
|
+
import_ssi_sdk3.CredentialCorrelationType.KID,
|
|
2994
3017
|
identifier.identifier
|
|
2995
3018
|
];
|
|
2996
3019
|
}
|
|
@@ -2998,19 +3021,19 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2998
3021
|
case "x5c":
|
|
2999
3022
|
if ((0, import_ssi_sdk_ext6.isManagedIdentifierResult)(identifier) && (0, import_ssi_sdk_ext6.isManagedIdentifierX5cResult)(identifier)) {
|
|
3000
3023
|
return [
|
|
3001
|
-
|
|
3024
|
+
import_ssi_sdk3.CredentialCorrelationType.X509_SAN,
|
|
3002
3025
|
identifier.x5c.join("\r\n")
|
|
3003
3026
|
];
|
|
3004
3027
|
} else if ((0, import_ssi_sdk_ext6.isManagedIdentifierX5cOpts)(identifier)) {
|
|
3005
3028
|
return [
|
|
3006
|
-
|
|
3029
|
+
import_ssi_sdk3.CredentialCorrelationType.X509_SAN,
|
|
3007
3030
|
identifier.identifier.join("\r\n")
|
|
3008
3031
|
];
|
|
3009
3032
|
}
|
|
3010
3033
|
break;
|
|
3011
3034
|
}
|
|
3012
3035
|
return [
|
|
3013
|
-
|
|
3036
|
+
import_ssi_sdk3.CredentialCorrelationType.URL,
|
|
3014
3037
|
issuer
|
|
3015
3038
|
];
|
|
3016
3039
|
}
|