@sphereon/ssi-sdk.oid4vci-holder 0.36.1-next.11 → 0.36.1-next.113
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 +35 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -3
- package/dist/index.d.ts +12 -3
- package/dist/index.js +35 -17
- package/dist/index.js.map +1 -1
- package/package.json +23 -23
- package/src/agent/OID4VCIHolder.ts +19 -5
- package/src/link-handler/index.ts +5 -2
- package/src/machines/oid4vciMachine.ts +2 -9
- package/src/services/OID4VCIHolderService.ts +8 -2
- package/src/types/IOID4VCIHolder.ts +8 -1
package/dist/index.cjs
CHANGED
|
@@ -413,6 +413,7 @@ var createOID4VCIMachine = /* @__PURE__ */ __name((opts) => {
|
|
|
413
413
|
// TODO WAL-671 we need to store the data from OpenIdProvider here in the context and make sure we can restart the machine with it and init the OpenIdProvider
|
|
414
414
|
accessTokenOpts: opts?.accessTokenOpts,
|
|
415
415
|
requestData: opts?.requestData,
|
|
416
|
+
walletType: opts?.walletType ?? "NATURAL_PERSON",
|
|
416
417
|
trustAnchors: opts?.trustAnchors ?? [],
|
|
417
418
|
issuanceOpt: opts?.issuanceOpt,
|
|
418
419
|
didMethodPreferences: opts?.didMethodPreferences,
|
|
@@ -577,7 +578,7 @@ var createOID4VCIMachine = /* @__PURE__ */ __name((opts) => {
|
|
|
577
578
|
cond: OID4VCIMachineGuards.isFirstPartyApplication
|
|
578
579
|
},
|
|
579
580
|
{
|
|
580
|
-
target: OID4VCIMachineStates.
|
|
581
|
+
target: OID4VCIMachineStates.prepareAuthorizationRequest,
|
|
581
582
|
cond: OID4VCIMachineGuards.requireAuthorizationGuard
|
|
582
583
|
},
|
|
583
584
|
{
|
|
@@ -682,10 +683,6 @@ var createOID4VCIMachine = /* @__PURE__ */ __name((opts) => {
|
|
|
682
683
|
target: OID4VCIMachineStates.prepareAuthorizationRequest,
|
|
683
684
|
cond: OID4VCIMachineGuards.requireAuthorizationGuard
|
|
684
685
|
},
|
|
685
|
-
{
|
|
686
|
-
target: OID4VCIMachineStates.initiateAuthorizationRequest,
|
|
687
|
-
cond: OID4VCIMachineGuards.requireAuthorizationGuard
|
|
688
|
-
},
|
|
689
686
|
{
|
|
690
687
|
target: OID4VCIMachineStates.verifyPin,
|
|
691
688
|
cond: OID4VCIMachineGuards.requirePinGuard
|
|
@@ -765,10 +762,6 @@ var createOID4VCIMachine = /* @__PURE__ */ __name((opts) => {
|
|
|
765
762
|
target: OID4VCIMachineStates.verifyPin,
|
|
766
763
|
cond: OID4VCIMachineGuards.requirePinGuard
|
|
767
764
|
},
|
|
768
|
-
{
|
|
769
|
-
target: OID4VCIMachineStates.prepareAuthorizationRequest,
|
|
770
|
-
cond: OID4VCIMachineGuards.requireAuthorizationGuard
|
|
771
|
-
},
|
|
772
765
|
{
|
|
773
766
|
target: OID4VCIMachineStates.getCredentials
|
|
774
767
|
}
|
|
@@ -1814,7 +1807,7 @@ var extractCredentialFromResponse = /* @__PURE__ */ __name((credentialResponse)
|
|
|
1814
1807
|
return credential;
|
|
1815
1808
|
}, "extractCredentialFromResponse");
|
|
1816
1809
|
var getIdentifierOpts = /* @__PURE__ */ __name(async (args) => {
|
|
1817
|
-
const { issuanceOpt, context } = args;
|
|
1810
|
+
const { issuanceOpt, context, defaultHolderIdentifier } = args;
|
|
1818
1811
|
const { identifier: identifierArg } = issuanceOpt;
|
|
1819
1812
|
if (identifierArg && (0, import_ssi_sdk_ext3.isManagedIdentifierResult)(identifierArg)) {
|
|
1820
1813
|
return identifierArg;
|
|
@@ -1837,6 +1830,11 @@ var getIdentifierOpts = /* @__PURE__ */ __name(async (args) => {
|
|
|
1837
1830
|
agent: context.agent
|
|
1838
1831
|
};
|
|
1839
1832
|
if ((!identifierArg || (0, import_ssi_sdk_ext3.isIIdentifier)(identifierArg.identifier)) && supportedPreferredDidMethod && (!supportedBindingMethods || supportedBindingMethods.length === 0 || supportedBindingMethods.filter((method) => method.startsWith("did")))) {
|
|
1833
|
+
const identifierFilter = defaultHolderIdentifier ? defaultHolderIdentifier.startsWith("did:") ? {
|
|
1834
|
+
did: defaultHolderIdentifier
|
|
1835
|
+
} : {
|
|
1836
|
+
alias: defaultHolderIdentifier
|
|
1837
|
+
} : {};
|
|
1840
1838
|
const { result, created } = await (0, import_ssi_sdk_ext2.getOrCreatePrimaryIdentifier)(agentContext, {
|
|
1841
1839
|
method: supportedPreferredDidMethod,
|
|
1842
1840
|
createOpts: {
|
|
@@ -1844,7 +1842,8 @@ var getIdentifierOpts = /* @__PURE__ */ __name(async (args) => {
|
|
|
1844
1842
|
type: issuanceOpt.keyType,
|
|
1845
1843
|
use: import_ssi_sdk_ext.KeyUse.Signature,
|
|
1846
1844
|
codecName: issuanceOpt.codecName,
|
|
1847
|
-
kms: issuanceOpt.kms
|
|
1845
|
+
kms: issuanceOpt.kms,
|
|
1846
|
+
...identifierFilter
|
|
1848
1847
|
}
|
|
1849
1848
|
}
|
|
1850
1849
|
});
|
|
@@ -2223,6 +2222,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2223
2222
|
__name(this, "OID4VCIHolder");
|
|
2224
2223
|
}
|
|
2225
2224
|
hasher;
|
|
2225
|
+
defaultHolderIdentifier;
|
|
2226
2226
|
eventTypes = [
|
|
2227
2227
|
OID4VCIHolderEvent.CONTACT_IDENTITY_CREATED,
|
|
2228
2228
|
OID4VCIHolderEvent.CREDENTIAL_STORED,
|
|
@@ -2280,10 +2280,11 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2280
2280
|
onIdentifierCreated;
|
|
2281
2281
|
onVerifyEBSICredentialIssuer;
|
|
2282
2282
|
constructor(options) {
|
|
2283
|
-
const { onContactIdentityCreated, onCredentialStored, onIdentifierCreated, onVerifyEBSICredentialIssuer, vcFormatPreferences, jsonldCryptographicSuitePreferences, didMethodPreferences, jwtCryptographicSuitePreferences, defaultAuthorizationRequestOptions, hasher = import_ssi_sdk2.defaultHasher } = {
|
|
2283
|
+
const { onContactIdentityCreated, onCredentialStored, onIdentifierCreated, onVerifyEBSICredentialIssuer, vcFormatPreferences, jsonldCryptographicSuitePreferences, didMethodPreferences, jwtCryptographicSuitePreferences, defaultAuthorizationRequestOptions, hasher = import_ssi_sdk2.defaultHasher, defaultHolderIdentifier } = {
|
|
2284
2284
|
...options
|
|
2285
2285
|
};
|
|
2286
2286
|
this.hasher = hasher;
|
|
2287
|
+
this.defaultHolderIdentifier = defaultHolderIdentifier;
|
|
2287
2288
|
if (vcFormatPreferences !== void 0 && vcFormatPreferences.length > 0) {
|
|
2288
2289
|
this.vcFormatPreferences = vcFormatPreferences;
|
|
2289
2290
|
}
|
|
@@ -2473,7 +2474,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2473
2474
|
if (!clientId) {
|
|
2474
2475
|
return Promise.reject(Error(`Missing client id in contact's connectionConfig`));
|
|
2475
2476
|
}
|
|
2476
|
-
const client = await import_oid4vci_client3.
|
|
2477
|
+
const client = await import_oid4vci_client3.OpenID4VCIClientV1_0_15.fromState({
|
|
2477
2478
|
state: openID4VCIClientState
|
|
2478
2479
|
});
|
|
2479
2480
|
const authorizationCodeURL = await client.createAuthorizationRequestUrl({
|
|
@@ -2556,7 +2557,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2556
2557
|
return party;
|
|
2557
2558
|
}
|
|
2558
2559
|
async oid4vciHolderGetCredentials(args, context) {
|
|
2559
|
-
const { verificationCode, openID4VCIClientState, didMethodPreferences
|
|
2560
|
+
const { verificationCode, openID4VCIClientState, didMethodPreferences, issuanceOpt, accessTokenOpts, walletType } = args;
|
|
2560
2561
|
logger.debug(`Getting credentials`, issuanceOpt, accessTokenOpts);
|
|
2561
2562
|
if (!openID4VCIClientState) {
|
|
2562
2563
|
return Promise.reject(Error("Missing openID4VCI client state in context"));
|
|
@@ -2575,7 +2576,7 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2575
2576
|
credentialsSupported,
|
|
2576
2577
|
serverMetadata,
|
|
2577
2578
|
context,
|
|
2578
|
-
didMethodPreferences:
|
|
2579
|
+
didMethodPreferences: this.selectDidMethodPreferences(didMethodPreferences, walletType),
|
|
2579
2580
|
jwtCryptographicSuitePreferences: this.jwtCryptographicSuitePreferences,
|
|
2580
2581
|
jsonldCryptographicSuitePreferences: this.jsonldCryptographicSuitePreferences,
|
|
2581
2582
|
...issuanceOpt && {
|
|
@@ -2592,6 +2593,16 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2592
2593
|
logger.log(`Credentials received`, allCredentials);
|
|
2593
2594
|
return allCredentials;
|
|
2594
2595
|
}
|
|
2596
|
+
selectDidMethodPreferences(didMethodPreferences, walletType) {
|
|
2597
|
+
const supportedDidMethodEnums = Array.isArray(didMethodPreferences) && didMethodPreferences.length > 0 ? didMethodPreferences : this.didMethodPreferences;
|
|
2598
|
+
if (walletType === "ORGANIZATIONAL") {
|
|
2599
|
+
return [
|
|
2600
|
+
import_ssi_sdk_ext5.SupportedDidMethodEnum.DID_WEB,
|
|
2601
|
+
...supportedDidMethodEnums
|
|
2602
|
+
];
|
|
2603
|
+
}
|
|
2604
|
+
return supportedDidMethodEnums;
|
|
2605
|
+
}
|
|
2595
2606
|
async oid4vciHolderGetCredential(args, context) {
|
|
2596
2607
|
const { issuanceOpt, pin, client, accessTokenOpts } = args;
|
|
2597
2608
|
logger.info(`Getting credential`, issuanceOpt);
|
|
@@ -2600,7 +2611,8 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2600
2611
|
}
|
|
2601
2612
|
const identifier = await getIdentifierOpts({
|
|
2602
2613
|
issuanceOpt,
|
|
2603
|
-
context
|
|
2614
|
+
context,
|
|
2615
|
+
defaultHolderIdentifier: this.defaultHolderIdentifier
|
|
2604
2616
|
});
|
|
2605
2617
|
issuanceOpt.identifier = identifier;
|
|
2606
2618
|
logger.info(`ID opts`, identifier);
|
|
@@ -2659,6 +2671,9 @@ var OID4VCIHolder = class _OID4VCIHolder {
|
|
|
2659
2671
|
format: issuanceOpt.format,
|
|
2660
2672
|
// TODO: We need to update the machine and add notifications support for actual deferred credentials instead of just waiting/retrying
|
|
2661
2673
|
deferredCredentialAwait: true,
|
|
2674
|
+
...issuanceOpt.id && typeof issuanceOpt.id === "string" ? {
|
|
2675
|
+
credentialConfigurationId: issuanceOpt.id
|
|
2676
|
+
} : void 0,
|
|
2662
2677
|
...!jwk && {
|
|
2663
2678
|
kid
|
|
2664
2679
|
},
|
|
@@ -3143,6 +3158,7 @@ var OID4VCIHolderLinkHandler = class extends import_ssi_sdk4.LinkHandlerAdapter
|
|
|
3143
3158
|
stateNavigationListener;
|
|
3144
3159
|
firstPartyStateNavigationListener;
|
|
3145
3160
|
noStateMachinePersistence;
|
|
3161
|
+
walletType;
|
|
3146
3162
|
authorizationRequestOpts;
|
|
3147
3163
|
clientOpts;
|
|
3148
3164
|
trustAnchors;
|
|
@@ -3154,6 +3170,7 @@ var OID4VCIHolderLinkHandler = class extends import_ssi_sdk4.LinkHandlerAdapter
|
|
|
3154
3170
|
this.authorizationRequestOpts = args.authorizationRequestOpts;
|
|
3155
3171
|
this.clientOpts = args.clientOpts;
|
|
3156
3172
|
this.context = args.context;
|
|
3173
|
+
this.walletType = args.walletType ?? "NATURAL_PERSON";
|
|
3157
3174
|
this.noStateMachinePersistence = args.noStateMachinePersistence === true;
|
|
3158
3175
|
this.stateNavigationListener = args.stateNavigationListener;
|
|
3159
3176
|
this.firstPartyStateNavigationListener = args.firstPartyStateNavigationListener;
|
|
@@ -3190,7 +3207,8 @@ var OID4VCIHolderLinkHandler = class extends import_ssi_sdk4.LinkHandlerAdapter
|
|
|
3190
3207
|
clientOpts
|
|
3191
3208
|
},
|
|
3192
3209
|
stateNavigationListener: this.stateNavigationListener,
|
|
3193
|
-
firstPartyStateNavigationListener: this.firstPartyStateNavigationListener
|
|
3210
|
+
firstPartyStateNavigationListener: this.firstPartyStateNavigationListener,
|
|
3211
|
+
walletType: this.walletType
|
|
3194
3212
|
});
|
|
3195
3213
|
const interpreter = oid4vciMachine.interpreter;
|
|
3196
3214
|
if (!opts?.machineState && this.context.agent.availableMethods().includes("machineStatesFindActive")) {
|