@sphereon/ssi-sdk.oid4vci-holder 0.34.1-feature.SSISDK.73.dcql.array.fix.267 → 0.34.1-feature.SSISDK.78.279
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 +77 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +61 -14
- package/dist/index.js.map +1 -1
- package/package.json +24 -24
- package/src/agent/OID4VCIHolder.ts +44 -8
- package/src/machines/oid4vciMachine.ts +29 -5
- package/src/types/IOID4VCIHolder.ts +8 -1
package/dist/index.cjs
CHANGED
|
@@ -142,7 +142,6 @@ var import_ssi_sdk_ext6 = require("@sphereon/ssi-sdk-ext.identifier-resolution")
|
|
|
142
142
|
var import_ssi_sdk_ext7 = require("@sphereon/ssi-sdk-ext.key-utils");
|
|
143
143
|
var import_ssi_sdk2 = require("@sphereon/ssi-sdk.core");
|
|
144
144
|
var import_ssi_sdk3 = require("@sphereon/ssi-sdk.data-store-types");
|
|
145
|
-
var import_ssi_sdk4 = require("@sphereon/ssi-sdk.data-store-types");
|
|
146
145
|
var import_ssi_types2 = require("@sphereon/ssi-types");
|
|
147
146
|
var import_utils2 = require("@veramo/utils");
|
|
148
147
|
var import_cross_fetch = __toESM(require("cross-fetch"), 1);
|
|
@@ -185,6 +184,7 @@ var OID4VCIMachineStates = /* @__PURE__ */ (function(OID4VCIMachineStates2) {
|
|
|
185
184
|
OID4VCIMachineStates2["selectCredentials"] = "selectCredentials";
|
|
186
185
|
OID4VCIMachineStates2["transitionFromSelectingCredentials"] = "transitionFromSelectingCredentials";
|
|
187
186
|
OID4VCIMachineStates2["verifyPin"] = "verifyPin";
|
|
187
|
+
OID4VCIMachineStates2["prepareAuthorizationRequest"] = "prepareAuthorizationRequest";
|
|
188
188
|
OID4VCIMachineStates2["initiateAuthorizationRequest"] = "initiateAuthorizationRequest";
|
|
189
189
|
OID4VCIMachineStates2["waitForAuthorizationResponse"] = "waitForAuthorizationResponse";
|
|
190
190
|
OID4VCIMachineStates2["getCredentials"] = "getCredentials";
|
|
@@ -249,6 +249,7 @@ var OID4VCIMachineServices = /* @__PURE__ */ (function(OID4VCIMachineServices2)
|
|
|
249
249
|
OID4VCIMachineServices2["getFederationTrust"] = "getFederationTrust";
|
|
250
250
|
OID4VCIMachineServices2["addContactIdentity"] = "addContactIdentity";
|
|
251
251
|
OID4VCIMachineServices2["createCredentialsToSelectFrom"] = "createCredentialsToSelectFrom";
|
|
252
|
+
OID4VCIMachineServices2["prepareAuthorizationRequest"] = "prepareAuthorizationRequest";
|
|
252
253
|
OID4VCIMachineServices2["getIssuerBranding"] = "getIssuerBranding";
|
|
253
254
|
OID4VCIMachineServices2["storeIssuerBranding"] = "storeIssuerBranding";
|
|
254
255
|
OID4VCIMachineServices2["getCredentials"] = "getCredentials";
|
|
@@ -390,9 +391,7 @@ var oid4vciRequireAuthorizationGuard = /* @__PURE__ */ __name((ctx, _event) => {
|
|
|
390
391
|
if (!openID4VCIClientState) {
|
|
391
392
|
throw Error("Missing openID4VCI client state in context");
|
|
392
393
|
}
|
|
393
|
-
if (
|
|
394
|
-
return false;
|
|
395
|
-
} else if (openID4VCIClientState.authorizationRequestOpts) {
|
|
394
|
+
if (openID4VCIClientState.authorizationRequestOpts) {
|
|
396
395
|
return !ctx.openID4VCIClientState?.authorizationCodeResponse;
|
|
397
396
|
} else if (openID4VCIClientState.credentialOffer?.supportedFlows?.includes(import_oid4vci_common.AuthzFlowType.AUTHORIZATION_CODE_FLOW)) {
|
|
398
397
|
return !ctx.openID4VCIClientState?.authorizationCodeResponse;
|
|
@@ -443,7 +442,6 @@ var createOID4VCIMachine = /* @__PURE__ */ __name((opts) => {
|
|
|
443
442
|
onDone: {
|
|
444
443
|
target: OID4VCIMachineStates.createCredentialsToSelectFrom,
|
|
445
444
|
actions: (0, import_xstate.assign)({
|
|
446
|
-
authorizationCodeURL: /* @__PURE__ */ __name((_ctx, _event) => _event.data.authorizationCodeURL, "authorizationCodeURL"),
|
|
447
445
|
credentialBranding: /* @__PURE__ */ __name((_ctx, _event) => _event.data.credentialBranding ?? {}, "credentialBranding"),
|
|
448
446
|
credentialsSupported: /* @__PURE__ */ __name((_ctx, _event) => _event.data.credentialsSupported, "credentialsSupported"),
|
|
449
447
|
serverMetadata: /* @__PURE__ */ __name((_ctx, _event) => _event.data.serverMetadata, "serverMetadata"),
|
|
@@ -760,7 +758,7 @@ var createOID4VCIMachine = /* @__PURE__ */ __name((opts) => {
|
|
|
760
758
|
cond: OID4VCIMachineGuards.requirePinGuard
|
|
761
759
|
},
|
|
762
760
|
{
|
|
763
|
-
target: OID4VCIMachineStates.
|
|
761
|
+
target: OID4VCIMachineStates.prepareAuthorizationRequest,
|
|
764
762
|
cond: OID4VCIMachineGuards.requireAuthorizationGuard
|
|
765
763
|
},
|
|
766
764
|
{
|
|
@@ -768,6 +766,28 @@ var createOID4VCIMachine = /* @__PURE__ */ __name((opts) => {
|
|
|
768
766
|
}
|
|
769
767
|
]
|
|
770
768
|
},
|
|
769
|
+
[OID4VCIMachineStates.prepareAuthorizationRequest]: {
|
|
770
|
+
id: OID4VCIMachineStates.prepareAuthorizationRequest,
|
|
771
|
+
invoke: {
|
|
772
|
+
src: OID4VCIMachineServices.prepareAuthorizationRequest,
|
|
773
|
+
onDone: {
|
|
774
|
+
target: OID4VCIMachineStates.initiateAuthorizationRequest,
|
|
775
|
+
actions: (0, import_xstate.assign)({
|
|
776
|
+
authorizationCodeURL: /* @__PURE__ */ __name((_ctx, _event) => _event.data.authorizationCodeURL, "authorizationCodeURL")
|
|
777
|
+
})
|
|
778
|
+
},
|
|
779
|
+
onError: {
|
|
780
|
+
target: OID4VCIMachineStates.handleError,
|
|
781
|
+
actions: (0, import_xstate.assign)({
|
|
782
|
+
error: /* @__PURE__ */ __name((_ctx, _event) => ({
|
|
783
|
+
title: translate("oid4vci_machine_prepare_authorization_error_title"),
|
|
784
|
+
message: _event.data.message,
|
|
785
|
+
stack: _event.data.stack
|
|
786
|
+
}), "error")
|
|
787
|
+
})
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
},
|
|
771
791
|
[OID4VCIMachineStates.initiateAuthorizationRequest]: {
|
|
772
792
|
id: OID4VCIMachineStates.initiateAuthorizationRequest,
|
|
773
793
|
on: {
|
|
@@ -2203,6 +2223,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2203
2223
|
oid4vciHolderStart: this.oid4vciHolderStart.bind(this),
|
|
2204
2224
|
oid4vciHolderGetIssuerMetadata: this.oid4vciHolderGetIssuerMetadata.bind(this),
|
|
2205
2225
|
oid4vciHolderGetMachineInterpreter: this.oid4vciHolderGetMachineInterpreter.bind(this),
|
|
2226
|
+
oid4vciHolderPrepareAuthorizationRequest: this.oid4vciHolderPrepareAuthorizationRequest.bind(this),
|
|
2206
2227
|
oid4vciHolderCreateCredentialsToSelectFrom: this.oid4vciHolderCreateCredentialsToSelectFrom.bind(this),
|
|
2207
2228
|
oid4vciHolderGetContact: this.oid4vciHolderGetContact.bind(this),
|
|
2208
2229
|
oid4vciHolderGetCredentials: this.oid4vciHolderGetCredentials.bind(this),
|
|
@@ -2307,6 +2328,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2307
2328
|
stateNavigationListener: opts.firstPartyStateNavigationListener
|
|
2308
2329
|
}, context),
|
|
2309
2330
|
[OID4VCIMachineServices.createCredentialsToSelectFrom]: (args) => this.oid4vciHolderCreateCredentialsToSelectFrom(args, context),
|
|
2331
|
+
[OID4VCIMachineServices.prepareAuthorizationRequest]: (args) => this.oid4vciHolderPrepareAuthorizationRequest(args, context),
|
|
2310
2332
|
[OID4VCIMachineServices.getContact]: (args) => this.oid4vciHolderGetContact(args, context),
|
|
2311
2333
|
[OID4VCIMachineServices.getCredentials]: (args) => this.oid4vciHolderGetCredentials({
|
|
2312
2334
|
accessTokenOpts: args.accessTokenOpts ?? opts.accessTokenOpts,
|
|
@@ -2391,7 +2413,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2391
2413
|
credentialIssuer: uri,
|
|
2392
2414
|
authorizationRequest: authorizationRequestOpts,
|
|
2393
2415
|
clientId: authorizationRequestOpts.clientId,
|
|
2394
|
-
createAuthorizationRequestURL:
|
|
2416
|
+
createAuthorizationRequestURL: false
|
|
2395
2417
|
});
|
|
2396
2418
|
} else {
|
|
2397
2419
|
logger.log(`Credential offer received: ${uri}`);
|
|
@@ -2399,7 +2421,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2399
2421
|
uri,
|
|
2400
2422
|
authorizationRequest: authorizationRequestOpts,
|
|
2401
2423
|
clientId: authorizationRequestOpts.clientId,
|
|
2402
|
-
createAuthorizationRequestURL:
|
|
2424
|
+
createAuthorizationRequestURL: false
|
|
2403
2425
|
});
|
|
2404
2426
|
}
|
|
2405
2427
|
}
|
|
@@ -2419,19 +2441,44 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2419
2441
|
credentialsSupported,
|
|
2420
2442
|
context
|
|
2421
2443
|
});
|
|
2422
|
-
const authorizationCodeURL = oid4vciClient.authorizationURL;
|
|
2423
|
-
if (authorizationCodeURL) {
|
|
2424
|
-
logger.log(`authorization code URL ${authorizationCodeURL}`);
|
|
2425
|
-
}
|
|
2426
2444
|
const oid4vciClientState = JSON.parse(await oid4vciClient.exportState());
|
|
2427
2445
|
return {
|
|
2428
|
-
authorizationCodeURL,
|
|
2429
2446
|
credentialBranding,
|
|
2430
2447
|
credentialsSupported,
|
|
2431
2448
|
serverMetadata,
|
|
2432
2449
|
oid4vciClientState
|
|
2433
2450
|
};
|
|
2434
2451
|
}
|
|
2452
|
+
async oid4vciHolderPrepareAuthorizationRequest(args, context) {
|
|
2453
|
+
const { openID4VCIClientState, contact } = args;
|
|
2454
|
+
if (!openID4VCIClientState) {
|
|
2455
|
+
return Promise.reject(Error("Missing openID4VCI client state in context"));
|
|
2456
|
+
}
|
|
2457
|
+
const clientId = contact?.identities.map((identity) => {
|
|
2458
|
+
const connectionConfig = identity.connection?.config;
|
|
2459
|
+
if (connectionConfig && "clientId" in connectionConfig) {
|
|
2460
|
+
return connectionConfig.clientId;
|
|
2461
|
+
}
|
|
2462
|
+
return void 0;
|
|
2463
|
+
}).find((clientId2) => clientId2);
|
|
2464
|
+
if (!clientId) {
|
|
2465
|
+
return Promise.reject(Error(`Missing client id in contact's connectionConfig`));
|
|
2466
|
+
}
|
|
2467
|
+
const client = await import_oid4vci_client3.OpenID4VCIClient.fromState({
|
|
2468
|
+
state: openID4VCIClientState
|
|
2469
|
+
});
|
|
2470
|
+
const authorizationCodeURL = await client.createAuthorizationRequestUrl({
|
|
2471
|
+
authorizationRequest: {
|
|
2472
|
+
clientId
|
|
2473
|
+
}
|
|
2474
|
+
});
|
|
2475
|
+
if (authorizationCodeURL) {
|
|
2476
|
+
logger.log(`authorization code URL ${authorizationCodeURL}`);
|
|
2477
|
+
}
|
|
2478
|
+
return {
|
|
2479
|
+
authorizationCodeURL
|
|
2480
|
+
};
|
|
2481
|
+
}
|
|
2435
2482
|
async oid4vciHolderCreateCredentialsToSelectFrom(args, context) {
|
|
2436
2483
|
const { credentialBranding, locale, selectedCredentials, credentialsSupported } = args;
|
|
2437
2484
|
logger.info(`Credentials supported ${Object.keys(credentialsSupported).join(", ")}`);
|
|
@@ -2631,16 +2678,16 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2631
2678
|
return Promise.reject(Error("Missing credential offers in context"));
|
|
2632
2679
|
}
|
|
2633
2680
|
let correlationId = credentialsToAccept[0].correlationId;
|
|
2634
|
-
let identifierType =
|
|
2681
|
+
let identifierType = import_ssi_sdk3.CorrelationIdentifierType.DID;
|
|
2635
2682
|
if (!correlationId.toLowerCase().startsWith("did:")) {
|
|
2636
|
-
identifierType =
|
|
2683
|
+
identifierType = import_ssi_sdk3.CorrelationIdentifierType.URL;
|
|
2637
2684
|
if (correlationId.startsWith("http")) {
|
|
2638
2685
|
correlationId = new URL(correlationId).hostname;
|
|
2639
2686
|
}
|
|
2640
2687
|
}
|
|
2641
2688
|
const identity = {
|
|
2642
2689
|
alias: credentialsToAccept[0].correlationId,
|
|
2643
|
-
origin:
|
|
2690
|
+
origin: import_ssi_sdk3.IdentityOrigin.EXTERNAL,
|
|
2644
2691
|
roles: [
|
|
2645
2692
|
import_ssi_types2.CredentialRole.ISSUER
|
|
2646
2693
|
],
|
|
@@ -2648,9 +2695,9 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2648
2695
|
type: identifierType,
|
|
2649
2696
|
correlationId
|
|
2650
2697
|
},
|
|
2651
|
-
...identifierType ===
|
|
2698
|
+
...identifierType === import_ssi_sdk3.CorrelationIdentifierType.URL && {
|
|
2652
2699
|
connection: {
|
|
2653
|
-
type:
|
|
2700
|
+
type: import_ssi_sdk3.ConnectionType.OPENID_CONNECT,
|
|
2654
2701
|
config: {
|
|
2655
2702
|
clientId: "138d7bf8-c930-4c6e-b928-97d3a4928b01",
|
|
2656
2703
|
clientSecret: "03b3955f-d020-4f2a-8a27-4e452d4e27a0",
|
|
@@ -2910,7 +2957,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2910
2957
|
kmsKeyRef,
|
|
2911
2958
|
identifierMethod: method,
|
|
2912
2959
|
credentialRole: import_ssi_types2.CredentialRole.HOLDER,
|
|
2913
|
-
issuerCorrelationType: issuer?.startsWith("did:") ?
|
|
2960
|
+
issuerCorrelationType: issuer?.startsWith("did:") ? import_ssi_sdk3.CredentialCorrelationType.DID : import_ssi_sdk3.CredentialCorrelationType.URL,
|
|
2914
2961
|
issuerCorrelationId: issuer,
|
|
2915
2962
|
subjectCorrelationType,
|
|
2916
2963
|
subjectCorrelationId
|
|
@@ -2978,12 +3025,12 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2978
3025
|
case "did":
|
|
2979
3026
|
if ((0, import_ssi_sdk_ext6.isManagedIdentifierResult)(identifier) && (0, import_ssi_sdk_ext6.isManagedIdentifierDidResult)(identifier)) {
|
|
2980
3027
|
return [
|
|
2981
|
-
|
|
3028
|
+
import_ssi_sdk3.CredentialCorrelationType.DID,
|
|
2982
3029
|
identifier.did
|
|
2983
3030
|
];
|
|
2984
3031
|
} else if ((0, import_ssi_sdk_ext6.isManagedIdentifierDidOpts)(identifier)) {
|
|
2985
3032
|
return [
|
|
2986
|
-
|
|
3033
|
+
import_ssi_sdk3.CredentialCorrelationType.DID,
|
|
2987
3034
|
typeof identifier.identifier === "string" ? identifier.identifier : identifier.identifier.did
|
|
2988
3035
|
];
|
|
2989
3036
|
}
|
|
@@ -2991,12 +3038,12 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2991
3038
|
case "kid":
|
|
2992
3039
|
if ((0, import_ssi_sdk_ext6.isManagedIdentifierResult)(identifier) && (0, import_ssi_sdk_ext6.isManagedIdentifierKidResult)(identifier)) {
|
|
2993
3040
|
return [
|
|
2994
|
-
|
|
3041
|
+
import_ssi_sdk3.CredentialCorrelationType.KID,
|
|
2995
3042
|
identifier.kid
|
|
2996
3043
|
];
|
|
2997
3044
|
} else if ((0, import_ssi_sdk_ext6.isManagedIdentifierDidOpts)(identifier)) {
|
|
2998
3045
|
return [
|
|
2999
|
-
|
|
3046
|
+
import_ssi_sdk3.CredentialCorrelationType.KID,
|
|
3000
3047
|
identifier.identifier
|
|
3001
3048
|
];
|
|
3002
3049
|
}
|
|
@@ -3004,19 +3051,19 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
3004
3051
|
case "x5c":
|
|
3005
3052
|
if ((0, import_ssi_sdk_ext6.isManagedIdentifierResult)(identifier) && (0, import_ssi_sdk_ext6.isManagedIdentifierX5cResult)(identifier)) {
|
|
3006
3053
|
return [
|
|
3007
|
-
|
|
3054
|
+
import_ssi_sdk3.CredentialCorrelationType.X509_SAN,
|
|
3008
3055
|
identifier.x5c.join("\r\n")
|
|
3009
3056
|
];
|
|
3010
3057
|
} else if ((0, import_ssi_sdk_ext6.isManagedIdentifierX5cOpts)(identifier)) {
|
|
3011
3058
|
return [
|
|
3012
|
-
|
|
3059
|
+
import_ssi_sdk3.CredentialCorrelationType.X509_SAN,
|
|
3013
3060
|
identifier.identifier.join("\r\n")
|
|
3014
3061
|
];
|
|
3015
3062
|
}
|
|
3016
3063
|
break;
|
|
3017
3064
|
}
|
|
3018
3065
|
return [
|
|
3019
|
-
|
|
3066
|
+
import_ssi_sdk3.CredentialCorrelationType.URL,
|
|
3020
3067
|
issuer
|
|
3021
3068
|
];
|
|
3022
3069
|
}
|
|
@@ -3075,9 +3122,9 @@ var OID4VCICallbackStateListener = /* @__PURE__ */ __name((callbacks) => {
|
|
|
3075
3122
|
// src/link-handler/index.ts
|
|
3076
3123
|
var import_oid4vci_client4 = require("@sphereon/oid4vci-client");
|
|
3077
3124
|
var import_oid4vci_common5 = require("@sphereon/oid4vci-common");
|
|
3078
|
-
var
|
|
3079
|
-
var
|
|
3080
|
-
var OID4VCIHolderLinkHandler = class extends
|
|
3125
|
+
var import_ssi_sdk4 = require("@sphereon/ssi-sdk.core");
|
|
3126
|
+
var import_ssi_sdk5 = require("@sphereon/ssi-sdk.xstate-machine-persistence");
|
|
3127
|
+
var OID4VCIHolderLinkHandler = class extends import_ssi_sdk4.LinkHandlerAdapter {
|
|
3081
3128
|
static {
|
|
3082
3129
|
__name(this, "OID4VCIHolderLinkHandler");
|
|
3083
3130
|
}
|
|
@@ -3137,7 +3184,7 @@ var OID4VCIHolderLinkHandler = class extends import_ssi_sdk5.LinkHandlerAdapter
|
|
|
3137
3184
|
const interpreter = oid4vciMachine.interpreter;
|
|
3138
3185
|
if (!opts?.machineState && this.context.agent.availableMethods().includes("machineStatesFindActive")) {
|
|
3139
3186
|
const stateType = hasCode ? "existing" : "new";
|
|
3140
|
-
await (0,
|
|
3187
|
+
await (0, import_ssi_sdk5.interpreterStartOrResume)({
|
|
3141
3188
|
stateType,
|
|
3142
3189
|
interpreter,
|
|
3143
3190
|
context: this.context,
|