@sphereon/ssi-sdk.oid4vci-holder 0.32.1-next.54 → 0.33.1-feature.jose.vcdm.55
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 +3143 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +786 -0
- package/dist/index.d.ts +784 -9
- package/dist/index.js +3112 -30
- package/dist/index.js.map +1 -1
- package/package.json +45 -33
- package/src/agent/OID4VCIHolder.ts +42 -16
- package/src/index.ts +1 -0
- package/src/link-handler/index.ts +6 -8
- package/src/machines/firstPartyMachine.ts +60 -69
- package/src/machines/oid4vciMachine.ts +9 -11
- package/src/mappers/OIDC4VCIBrandingMapper.ts +26 -25
- package/src/services/FirstPartyMachineServices.ts +11 -10
- package/src/services/OID4VCIHolderService.ts +25 -24
- package/src/types/FirstPartyMachine.ts +56 -64
- package/src/types/IOID4VCIHolder.ts +35 -32
- package/dist/agent/OID4VCIHolder.d.ts +0 -58
- package/dist/agent/OID4VCIHolder.d.ts.map +0 -1
- package/dist/agent/OID4VCIHolder.js +0 -870
- package/dist/agent/OID4VCIHolder.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/link-handler/index.d.ts +0 -31
- package/dist/link-handler/index.d.ts.map +0 -1
- package/dist/link-handler/index.js +0 -65
- package/dist/link-handler/index.js.map +0 -1
- package/dist/listeners/headlessStateNavListener.d.ts +0 -3
- package/dist/listeners/headlessStateNavListener.d.ts.map +0 -1
- package/dist/listeners/headlessStateNavListener.js +0 -45
- package/dist/listeners/headlessStateNavListener.js.map +0 -1
- package/dist/localization/Localization.d.ts +0 -9
- package/dist/localization/Localization.d.ts.map +0 -1
- package/dist/localization/Localization.js +0 -46
- package/dist/localization/Localization.js.map +0 -1
- package/dist/localization/translations/en.json +0 -19
- package/dist/localization/translations/nl.json +0 -18
- package/dist/machines/firstPartyMachine.d.ts +0 -15
- package/dist/machines/firstPartyMachine.d.ts.map +0 -1
- package/dist/machines/firstPartyMachine.js +0 -222
- package/dist/machines/firstPartyMachine.js.map +0 -1
- package/dist/machines/oid4vciMachine.d.ts +0 -7
- package/dist/machines/oid4vciMachine.d.ts.map +0 -1
- package/dist/machines/oid4vciMachine.js +0 -727
- package/dist/machines/oid4vciMachine.js.map +0 -1
- package/dist/mappers/OIDC4VCIBrandingMapper.d.ts +0 -16
- package/dist/mappers/OIDC4VCIBrandingMapper.d.ts.map +0 -1
- package/dist/mappers/OIDC4VCIBrandingMapper.js +0 -201
- package/dist/mappers/OIDC4VCIBrandingMapper.js.map +0 -1
- package/dist/services/FirstPartyMachineServices.d.ts +0 -9
- package/dist/services/FirstPartyMachineServices.d.ts.map +0 -1
- package/dist/services/FirstPartyMachineServices.js +0 -52
- package/dist/services/FirstPartyMachineServices.js.map +0 -1
- package/dist/services/OID4VCIHolderService.d.ts +0 -28
- package/dist/services/OID4VCIHolderService.d.ts.map +0 -1
- package/dist/services/OID4VCIHolderService.js +0 -523
- package/dist/services/OID4VCIHolderService.js.map +0 -1
- package/dist/types/FirstPartyMachine.d.ts +0 -112
- package/dist/types/FirstPartyMachine.d.ts.map +0 -1
- package/dist/types/FirstPartyMachine.js +0 -30
- package/dist/types/FirstPartyMachine.js.map +0 -1
- package/dist/types/IOID4VCIHolder.d.ts +0 -558
- package/dist/types/IOID4VCIHolder.d.ts.map +0 -1
- package/dist/types/IOID4VCIHolder.js +0 -114
- package/dist/types/IOID4VCIHolder.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,39 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.oid4vci-holder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.1-feature.jose.vcdm.55+6f02f6f8",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
"react-native": "./dist/index.js",
|
|
11
|
+
"import": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"require": {
|
|
16
|
+
"types": "./dist/index.d.cts",
|
|
17
|
+
"require": "./dist/index.cjs"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
7
20
|
"veramo": {
|
|
8
21
|
"pluginInterfaces": {
|
|
9
22
|
"IOID4VCIHolder": "./src/types/IOID4VCIHolder.ts"
|
|
10
23
|
}
|
|
11
24
|
},
|
|
12
25
|
"scripts": {
|
|
13
|
-
"build": "
|
|
14
|
-
"build:clean": "tsc --build --clean && tsc --build"
|
|
26
|
+
"build": "tsup --config ../../tsup.config.ts --tsconfig ../../tsconfig.tsup.json"
|
|
15
27
|
},
|
|
16
28
|
"dependencies": {
|
|
17
|
-
"@sphereon/did-auth-siop": "0.
|
|
29
|
+
"@sphereon/did-auth-siop": "0.17.1-feature.esm.cjs.39",
|
|
18
30
|
"@sphereon/kmp-mdoc-core": "0.2.0-SNAPSHOT.26",
|
|
19
|
-
"@sphereon/oid4vci-client": "0.
|
|
20
|
-
"@sphereon/oid4vci-common": "0.
|
|
21
|
-
"@sphereon/ssi-sdk-ext.did-utils": "0.
|
|
22
|
-
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.
|
|
23
|
-
"@sphereon/ssi-sdk-ext.jwt-service": "0.
|
|
24
|
-
"@sphereon/ssi-sdk-ext.key-utils": "0.
|
|
25
|
-
"@sphereon/ssi-sdk.contact-manager": "0.
|
|
26
|
-
"@sphereon/ssi-sdk.core": "0.
|
|
27
|
-
"@sphereon/ssi-sdk.credential-store": "0.
|
|
28
|
-
"@sphereon/ssi-sdk.credential-validation": "0.
|
|
29
|
-
"@sphereon/ssi-sdk.data-store": "0.
|
|
30
|
-
"@sphereon/ssi-sdk.issuance-branding": "0.
|
|
31
|
-
"@sphereon/ssi-sdk.mdl-mdoc": "0.
|
|
32
|
-
"@sphereon/ssi-sdk.oidf-client": "0.
|
|
33
|
-
"@sphereon/ssi-sdk.sd-jwt": "0.
|
|
34
|
-
"@sphereon/ssi-sdk.siopv2-oid4vp-
|
|
35
|
-
"@sphereon/ssi-sdk.
|
|
36
|
-
"@sphereon/ssi-
|
|
31
|
+
"@sphereon/oid4vci-client": "0.17.1-feature.esm.cjs.39",
|
|
32
|
+
"@sphereon/oid4vci-common": "0.17.1-feature.esm.cjs.39",
|
|
33
|
+
"@sphereon/ssi-sdk-ext.did-utils": "0.28.1-feature.esm.cjs.18",
|
|
34
|
+
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.28.1-feature.esm.cjs.18",
|
|
35
|
+
"@sphereon/ssi-sdk-ext.jwt-service": "0.28.1-feature.esm.cjs.18",
|
|
36
|
+
"@sphereon/ssi-sdk-ext.key-utils": "0.28.1-feature.esm.cjs.18",
|
|
37
|
+
"@sphereon/ssi-sdk.contact-manager": "0.33.1-feature.jose.vcdm.55+6f02f6f8",
|
|
38
|
+
"@sphereon/ssi-sdk.core": "0.33.1-feature.jose.vcdm.55+6f02f6f8",
|
|
39
|
+
"@sphereon/ssi-sdk.credential-store": "0.33.1-feature.jose.vcdm.55+6f02f6f8",
|
|
40
|
+
"@sphereon/ssi-sdk.credential-validation": "0.33.1-feature.jose.vcdm.55+6f02f6f8",
|
|
41
|
+
"@sphereon/ssi-sdk.data-store": "0.33.1-feature.jose.vcdm.55+6f02f6f8",
|
|
42
|
+
"@sphereon/ssi-sdk.issuance-branding": "0.33.1-feature.jose.vcdm.55+6f02f6f8",
|
|
43
|
+
"@sphereon/ssi-sdk.mdl-mdoc": "0.33.1-feature.jose.vcdm.55+6f02f6f8",
|
|
44
|
+
"@sphereon/ssi-sdk.oidf-client": "0.33.1-feature.jose.vcdm.55+6f02f6f8",
|
|
45
|
+
"@sphereon/ssi-sdk.sd-jwt": "0.33.1-feature.jose.vcdm.55+6f02f6f8",
|
|
46
|
+
"@sphereon/ssi-sdk.siopv2-oid4vp-common": "0.33.1-feature.jose.vcdm.55+6f02f6f8",
|
|
47
|
+
"@sphereon/ssi-sdk.siopv2-oid4vp-op-auth": "0.33.1-feature.jose.vcdm.55+6f02f6f8",
|
|
48
|
+
"@sphereon/ssi-sdk.xstate-machine-persistence": "0.33.1-feature.jose.vcdm.55+6f02f6f8",
|
|
49
|
+
"@sphereon/ssi-types": "0.33.1-feature.jose.vcdm.55+6f02f6f8",
|
|
37
50
|
"@veramo/core": "4.2.0",
|
|
38
51
|
"@veramo/data-store": "4.2.0",
|
|
39
52
|
"@veramo/utils": "4.2.0",
|
|
@@ -45,21 +58,21 @@
|
|
|
45
58
|
"xstate": "^4.38.3"
|
|
46
59
|
},
|
|
47
60
|
"devDependencies": {
|
|
48
|
-
"@sphereon/oid4vc-common": "0.
|
|
49
|
-
"@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.
|
|
50
|
-
"@sphereon/ssi-sdk.siopv2-oid4vp-common": "
|
|
61
|
+
"@sphereon/oid4vc-common": "0.17.1-feature.esm.cjs.39",
|
|
62
|
+
"@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.28.1-feature.esm.cjs.18",
|
|
63
|
+
"@sphereon/ssi-sdk.siopv2-oid4vp-common": "workspace:*",
|
|
51
64
|
"@types/i18n-js": "^3.8.9",
|
|
52
65
|
"@types/lodash.memoize": "^4.1.9",
|
|
53
66
|
"@types/uuid": "^9.0.8",
|
|
54
67
|
"@veramo/remote-client": "4.2.0",
|
|
55
68
|
"@veramo/remote-server": "4.2.0",
|
|
56
69
|
"nock": "^13.5.4",
|
|
57
|
-
"typeorm": "
|
|
58
|
-
"typescript": "5.
|
|
70
|
+
"typeorm": "0.3.20",
|
|
71
|
+
"typescript": "5.8.3"
|
|
59
72
|
},
|
|
60
73
|
"files": [
|
|
61
|
-
"dist
|
|
62
|
-
"src
|
|
74
|
+
"dist",
|
|
75
|
+
"src",
|
|
63
76
|
"README.md",
|
|
64
77
|
"plugin.schema.json",
|
|
65
78
|
"LICENSE"
|
|
@@ -76,6 +89,5 @@
|
|
|
76
89
|
"OID4VCI",
|
|
77
90
|
"State Machine"
|
|
78
91
|
],
|
|
79
|
-
"
|
|
80
|
-
"gitHead": "3b988a2bb62a7c4534a2670ea3a0985fd93d00f2"
|
|
92
|
+
"gitHead": "6f02f6f83679198268c6e1ea956be24cc1017234"
|
|
81
93
|
}
|
|
@@ -4,6 +4,8 @@ import {
|
|
|
4
4
|
AuthorizationRequestOpts,
|
|
5
5
|
AuthorizationServerClientOpts,
|
|
6
6
|
AuthorizationServerOpts,
|
|
7
|
+
CredentialConfigurationSupportedJwtVcJsonLdAndLdpVcV1_0_13,
|
|
8
|
+
CredentialDefinitionJwtVcJsonLdAndLdpVcV1_0_13,
|
|
7
9
|
CredentialOfferRequestWithBaseUrl,
|
|
8
10
|
DefaultURISchemes,
|
|
9
11
|
EndpointMetadataResult,
|
|
@@ -45,7 +47,8 @@ import {
|
|
|
45
47
|
} from '@sphereon/ssi-sdk.data-store'
|
|
46
48
|
import {
|
|
47
49
|
CredentialMapper,
|
|
48
|
-
|
|
50
|
+
type CredentialProofFormat,
|
|
51
|
+
HasherSync,
|
|
49
52
|
IVerifiableCredential,
|
|
50
53
|
JoseSignatureAlgorithm,
|
|
51
54
|
JoseSignatureAlgorithmString,
|
|
@@ -63,7 +66,6 @@ import {
|
|
|
63
66
|
IDIDManager,
|
|
64
67
|
IKeyManager,
|
|
65
68
|
IResolver,
|
|
66
|
-
ProofFormat,
|
|
67
69
|
VerifiableCredential,
|
|
68
70
|
W3CVerifiableCredential,
|
|
69
71
|
} from '@veramo/core'
|
|
@@ -107,7 +109,7 @@ import {
|
|
|
107
109
|
StoreIssuerBrandingArgs,
|
|
108
110
|
VerificationResult,
|
|
109
111
|
VerifyEBSICredentialIssuerArgs,
|
|
110
|
-
VerifyEBSICredentialIssuerResult
|
|
112
|
+
VerifyEBSICredentialIssuerResult,
|
|
111
113
|
} from '../types/IOID4VCIHolder'
|
|
112
114
|
import {
|
|
113
115
|
getBasicIssuerLocaleBranding,
|
|
@@ -117,10 +119,11 @@ import {
|
|
|
117
119
|
getIssuanceOpts,
|
|
118
120
|
mapCredentialToAccept,
|
|
119
121
|
selectCredentialLocaleBranding,
|
|
122
|
+
startFirstPartApplicationMachine,
|
|
120
123
|
verifyCredentialToAccept,
|
|
121
|
-
startFirstPartApplicationMachine
|
|
122
124
|
} from '../services/OID4VCIHolderService'
|
|
123
125
|
import 'cross-fetch/polyfill'
|
|
126
|
+
import { defaultHasher } from '@sphereon/ssi-sdk.core'
|
|
124
127
|
|
|
125
128
|
/**
|
|
126
129
|
* {@inheritDoc IOID4VCIHolder}
|
|
@@ -192,7 +195,7 @@ export async function verifyEBSICredentialIssuer(args: VerifyEBSICredentialIssue
|
|
|
192
195
|
throw Error('The issuer of the VC cannot be trusted')
|
|
193
196
|
}
|
|
194
197
|
|
|
195
|
-
const payload = await response.json()
|
|
198
|
+
const payload = (await response.json()) as VerifyEBSICredentialIssuerResult
|
|
196
199
|
|
|
197
200
|
if (!payload.attributes.some((a: Attribute) => issuerType.includes(a.issuerType))) {
|
|
198
201
|
throw Error(`The issuer type is required to be one of: ${issuerType.join(', ')}`)
|
|
@@ -202,7 +205,7 @@ export async function verifyEBSICredentialIssuer(args: VerifyEBSICredentialIssue
|
|
|
202
205
|
}
|
|
203
206
|
|
|
204
207
|
export class OID4VCIHolder implements IAgentPlugin {
|
|
205
|
-
private readonly hasher?:
|
|
208
|
+
private readonly hasher?: HasherSync
|
|
206
209
|
readonly eventTypes: Array<OID4VCIHolderEvent> = [
|
|
207
210
|
OID4VCIHolderEvent.CONTACT_IDENTITY_CREATED,
|
|
208
211
|
OID4VCIHolderEvent.CREDENTIAL_STORED,
|
|
@@ -264,7 +267,7 @@ export class OID4VCIHolder implements IAgentPlugin {
|
|
|
264
267
|
didMethodPreferences,
|
|
265
268
|
jwtCryptographicSuitePreferences,
|
|
266
269
|
defaultAuthorizationRequestOptions,
|
|
267
|
-
hasher,
|
|
270
|
+
hasher = defaultHasher,
|
|
268
271
|
} = { ...options }
|
|
269
272
|
|
|
270
273
|
this.hasher = hasher
|
|
@@ -319,15 +322,19 @@ export class OID4VCIHolder implements IAgentPlugin {
|
|
|
319
322
|
},
|
|
320
323
|
context,
|
|
321
324
|
),
|
|
322
|
-
[OID4VCIMachineServices.startFirstPartApplicationFlow]: (args: StartFirstPartApplicationMachine) =>
|
|
323
|
-
|
|
325
|
+
[OID4VCIMachineServices.startFirstPartApplicationFlow]: (args: StartFirstPartApplicationMachine) =>
|
|
326
|
+
startFirstPartApplicationMachine({ ...args, stateNavigationListener: opts.firstPartyStateNavigationListener }, context),
|
|
327
|
+
[OID4VCIMachineServices.createCredentialsToSelectFrom]: (args: CreateCredentialsToSelectFromArgs) =>
|
|
328
|
+
this.oid4vciHolderCreateCredentialsToSelectFrom(args, context),
|
|
324
329
|
[OID4VCIMachineServices.getContact]: (args: GetContactArgs) => this.oid4vciHolderGetContact(args, context),
|
|
325
|
-
[OID4VCIMachineServices.getCredentials]: (args: GetCredentialsArgs) =>
|
|
330
|
+
[OID4VCIMachineServices.getCredentials]: (args: GetCredentialsArgs) =>
|
|
331
|
+
this.oid4vciHolderGetCredentials({ accessTokenOpts: args.accessTokenOpts ?? opts.accessTokenOpts, ...args }, context),
|
|
326
332
|
[OID4VCIMachineServices.addContactIdentity]: (args: AddContactIdentityArgs) => this.oid4vciHolderAddContactIdentity(args, context),
|
|
327
333
|
[OID4VCIMachineServices.getIssuerBranding]: (args: GetIssuerBrandingArgs) => this.oid4vciHolderGetIssuerBranding(args, context),
|
|
328
334
|
[OID4VCIMachineServices.storeIssuerBranding]: (args: StoreIssuerBrandingArgs) => this.oid4vciHolderStoreIssuerBranding(args, context),
|
|
329
335
|
[OID4VCIMachineServices.assertValidCredentials]: (args: AssertValidCredentialsArgs) => this.oid4vciHolderAssertValidCredentials(args, context),
|
|
330
|
-
[OID4VCIMachineServices.storeCredentialBranding]: (args: StoreCredentialBrandingArgs) =>
|
|
336
|
+
[OID4VCIMachineServices.storeCredentialBranding]: (args: StoreCredentialBrandingArgs) =>
|
|
337
|
+
this.oid4vciHolderStoreCredentialBranding(args, context),
|
|
331
338
|
[OID4VCIMachineServices.storeCredentials]: (args: StoreCredentialsArgs) => this.oid4vciHolderStoreCredentials(args, context),
|
|
332
339
|
[OID4VCIMachineServices.sendNotification]: (args: SendNotificationArgs) => this.oid4vciHolderSendNotification(args, context),
|
|
333
340
|
[OID4VCIMachineServices.getFederationTrust]: (args: GetFederationTrustArgs) => this.getFederationTrust(args, context),
|
|
@@ -632,7 +639,7 @@ export class OID4VCIHolder implements IAgentPlugin {
|
|
|
632
639
|
// The VCI lib either expects a jwk or a kid
|
|
633
640
|
const jwk = isManagedIdentifierJwkResult(identifier) ? identifier.jwk : undefined
|
|
634
641
|
|
|
635
|
-
const callbacks: ProofOfPossessionCallbacks
|
|
642
|
+
const callbacks: ProofOfPossessionCallbacks = {
|
|
636
643
|
signCallback: signCallback(identifier, context),
|
|
637
644
|
}
|
|
638
645
|
|
|
@@ -678,7 +685,10 @@ export class OID4VCIHolder implements IAgentPlugin {
|
|
|
678
685
|
if (!credentialTypes || credentialTypes.length === 0) {
|
|
679
686
|
return Promise.reject(Error('cannot determine credential id to request'))
|
|
680
687
|
}
|
|
688
|
+
|
|
689
|
+
const credentialDefinition = this.getCredentialDefinition(issuanceOpt)
|
|
681
690
|
const credentialResponse = await client.acquireCredentials({
|
|
691
|
+
...(credentialDefinition && { context: credentialDefinition['@context'] }),
|
|
682
692
|
credentialTypes,
|
|
683
693
|
proofCallbacks: callbacks,
|
|
684
694
|
format: issuanceOpt.format,
|
|
@@ -911,7 +921,7 @@ export class OID4VCIHolder implements IAgentPlugin {
|
|
|
911
921
|
: 'credential_deleted_holder_signed'
|
|
912
922
|
logger.log(`Subject issuance/signing will be used, with event`, event)
|
|
913
923
|
const issuerVC = mappedCredentialToAccept.credentialToAccept.credentialResponse.credential as OriginalVerifiableCredential
|
|
914
|
-
const wrappedIssuerVC = CredentialMapper.toWrappedVerifiableCredential(issuerVC, { hasher: this.hasher })
|
|
924
|
+
const wrappedIssuerVC = CredentialMapper.toWrappedVerifiableCredential(issuerVC, { hasher: this.hasher ?? defaultHasher })
|
|
915
925
|
console.log(`Wrapped VC: ${wrappedIssuerVC.type}, ${wrappedIssuerVC.format}`)
|
|
916
926
|
// We will use the subject of the VCI Issuer (the holder, as the issuer of the new credential, so the below is not a mistake!)
|
|
917
927
|
|
|
@@ -920,7 +930,11 @@ export class OID4VCIHolder implements IAgentPlugin {
|
|
|
920
930
|
if (CredentialMapper.isWrappedSdJwtVerifiableCredential(wrappedIssuerVC)) {
|
|
921
931
|
issuer = trimmed(wrappedIssuerVC.decoded?.sub)
|
|
922
932
|
} else if (CredentialMapper.isWrappedW3CVerifiableCredential(wrappedIssuerVC)) {
|
|
923
|
-
issuer =
|
|
933
|
+
issuer =
|
|
934
|
+
trimmed(wrappedIssuerVC.credential?.sub) ??
|
|
935
|
+
// @ts-ignore
|
|
936
|
+
trimmed(wrappedIssuerVC.credential?.credentialSubject?.id) ??
|
|
937
|
+
trimmed(this.idFromW3cCredentialSubject(wrappedIssuerVC))
|
|
924
938
|
} else if (CredentialMapper.isWrappedMdocCredential(wrappedIssuerVC)) {
|
|
925
939
|
return Promise.reject(Error('mdoc not yet supported'))
|
|
926
940
|
}
|
|
@@ -952,7 +966,7 @@ export class OID4VCIHolder implements IAgentPlugin {
|
|
|
952
966
|
logger.log(`Issuer for self-issued credential will be: ${issuer}`)
|
|
953
967
|
|
|
954
968
|
const holderCredentialToSign = wrappedIssuerVC.decoded
|
|
955
|
-
let proofFormat:
|
|
969
|
+
let proofFormat: CredentialProofFormat = 'lds'
|
|
956
970
|
if (wrappedIssuerVC.format.includes('jwt') && !wrappedIssuerVC.format.includes('mso_mdoc')) {
|
|
957
971
|
holderCredentialToSign.iss = issuer
|
|
958
972
|
proofFormat = 'jwt'
|
|
@@ -980,7 +994,7 @@ export class OID4VCIHolder implements IAgentPlugin {
|
|
|
980
994
|
|
|
981
995
|
logger.log(`Subject issuance/signing will sign credential of type ${proofFormat}:`, holderCredentialToSign)
|
|
982
996
|
const issuedVC = await context.agent.createVerifiableCredential({
|
|
983
|
-
credential: holderCredentialToSign as CredentialPayload,
|
|
997
|
+
credential: ('vc' in holderCredentialToSign ? holderCredentialToSign.vc : holderCredentialToSign) as CredentialPayload,
|
|
984
998
|
fetchRemoteContexts: true,
|
|
985
999
|
save: false,
|
|
986
1000
|
proofFormat,
|
|
@@ -1078,6 +1092,11 @@ export class OID4VCIHolder implements IAgentPlugin {
|
|
|
1078
1092
|
const params = new URLSearchParams(url.search)
|
|
1079
1093
|
const openidFederation = params.get('openid_federation')
|
|
1080
1094
|
const entityIdentifier = openidFederation ?? serverMetadata.issuer
|
|
1095
|
+
if (entityIdentifier.startsWith('http://')) {
|
|
1096
|
+
console.warn(`OpenID federation does not support http://, only https:// allowed; got: (${url.toString()})`)
|
|
1097
|
+
// OIDF always needs to be https
|
|
1098
|
+
return []
|
|
1099
|
+
}
|
|
1081
1100
|
|
|
1082
1101
|
const result = await context.agent.identifierExternalResolveByOIDFEntityId({
|
|
1083
1102
|
method: 'entity_id',
|
|
@@ -1130,4 +1149,11 @@ export class OID4VCIHolder implements IAgentPlugin {
|
|
|
1130
1149
|
}
|
|
1131
1150
|
return undefined
|
|
1132
1151
|
}
|
|
1152
|
+
|
|
1153
|
+
private getCredentialDefinition(issuanceOpt: IssuanceOpts): CredentialDefinitionJwtVcJsonLdAndLdpVcV1_0_13 | undefined {
|
|
1154
|
+
if (issuanceOpt.format == 'ldp_vc' || issuanceOpt.format == 'jwt_vc_json-ld') {
|
|
1155
|
+
return (issuanceOpt as CredentialConfigurationSupportedJwtVcJsonLdAndLdpVcV1_0_13).credential_definition
|
|
1156
|
+
}
|
|
1157
|
+
return undefined
|
|
1158
|
+
}
|
|
1133
1159
|
}
|
package/src/index.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
export { OID4VCIHolder, oid4vciHolderContextMethods, signCallback } from './agent/OID4VCIHolder'
|
|
6
|
+
export * from './mappers/OIDC4VCIBrandingMapper'
|
|
6
7
|
export * from './services/OID4VCIHolderService'
|
|
7
8
|
export * from './services/FirstPartyMachineServices'
|
|
8
9
|
export * from './types/IOID4VCIHolder'
|
|
@@ -3,12 +3,7 @@ import { AuthorizationRequestOpts, AuthorizationServerClientOpts, AuthzFlowType,
|
|
|
3
3
|
import { DefaultLinkPriorities, LinkHandlerAdapter } from '@sphereon/ssi-sdk.core'
|
|
4
4
|
import { IMachineStatePersistence, interpreterStartOrResume, SerializableState } from '@sphereon/ssi-sdk.xstate-machine-persistence'
|
|
5
5
|
import { IAgentContext } from '@veramo/core'
|
|
6
|
-
import {
|
|
7
|
-
GetMachineArgs,
|
|
8
|
-
IOID4VCIHolder,
|
|
9
|
-
OID4VCIMachineEvents,
|
|
10
|
-
OID4VCIMachineStateNavigationListener
|
|
11
|
-
} from '../types/IOID4VCIHolder'
|
|
6
|
+
import { GetMachineArgs, IOID4VCIHolder, OID4VCIMachineEvents, OID4VCIMachineStateNavigationListener } from '../types/IOID4VCIHolder'
|
|
12
7
|
import { FirstPartyMachineStateNavigationListener } from '../types/FirstPartyMachine'
|
|
13
8
|
|
|
14
9
|
/**
|
|
@@ -24,7 +19,10 @@ export class OID4VCIHolderLinkHandler extends LinkHandlerAdapter {
|
|
|
24
19
|
private readonly trustAnchors?: Array<string>
|
|
25
20
|
|
|
26
21
|
constructor(
|
|
27
|
-
args: Pick<
|
|
22
|
+
args: Pick<
|
|
23
|
+
GetMachineArgs,
|
|
24
|
+
'stateNavigationListener' | 'authorizationRequestOpts' | 'clientOpts' | 'trustAnchors' | 'firstPartyStateNavigationListener'
|
|
25
|
+
> & {
|
|
28
26
|
priority?: number | DefaultLinkPriorities
|
|
29
27
|
protocols?: Array<string | RegExp>
|
|
30
28
|
noStateMachinePersistence?: boolean
|
|
@@ -69,7 +67,7 @@ export class OID4VCIHolderLinkHandler extends LinkHandlerAdapter {
|
|
|
69
67
|
authorizationRequestOpts: { ...this.authorizationRequestOpts, ...opts?.authorizationRequestOpts },
|
|
70
68
|
...((clientOpts.clientId || clientOpts.clientAssertionType) && { clientOpts: clientOpts as AuthorizationServerClientOpts }),
|
|
71
69
|
stateNavigationListener: this.stateNavigationListener,
|
|
72
|
-
firstPartyStateNavigationListener: this.firstPartyStateNavigationListener
|
|
70
|
+
firstPartyStateNavigationListener: this.firstPartyStateNavigationListener,
|
|
73
71
|
})
|
|
74
72
|
|
|
75
73
|
const interpreter = oid4vciMachine.interpreter
|
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
import { assign, createMachine, DoneInvokeEvent, interpret } from 'xstate'
|
|
2
|
-
import {
|
|
3
|
-
AuthorizationChallengeCodeResponse,
|
|
4
|
-
AuthorizationChallengeError,
|
|
5
|
-
AuthorizationChallengeErrorResponse
|
|
6
|
-
} from '@sphereon/oid4vci-common'
|
|
2
|
+
import { AuthorizationChallengeCodeResponse, AuthorizationChallengeError, AuthorizationChallengeErrorResponse } from '@sphereon/oid4vci-common'
|
|
7
3
|
import { DidAuthConfig } from '@sphereon/ssi-sdk.data-store'
|
|
8
4
|
import { CreateConfigResult } from '@sphereon/ssi-sdk.siopv2-oid4vp-op-auth'
|
|
9
|
-
import {
|
|
10
|
-
createConfig,
|
|
11
|
-
getSiopRequest,
|
|
12
|
-
sendAuthorizationChallengeRequest,
|
|
13
|
-
sendAuthorizationResponse
|
|
14
|
-
} from '../services/FirstPartyMachineServices'
|
|
5
|
+
import { createConfig, getSiopRequest, sendAuthorizationChallengeRequest, sendAuthorizationResponse } from '../services/FirstPartyMachineServices'
|
|
15
6
|
import { translate } from '../localization/Localization'
|
|
16
7
|
import { ErrorDetails } from '../types/IOID4VCIHolder'
|
|
17
8
|
import {
|
|
@@ -31,7 +22,7 @@ import {
|
|
|
31
22
|
InstanceFirstPartyMachineOpts,
|
|
32
23
|
SiopV2AuthorizationRequestData,
|
|
33
24
|
SendAuthorizationResponseArgs,
|
|
34
|
-
FirstPartySelectCredentialsEvent
|
|
25
|
+
FirstPartySelectCredentialsEvent,
|
|
35
26
|
} from '../types/FirstPartyMachine'
|
|
36
27
|
|
|
37
28
|
const firstPartyMachineStates: FirstPartyMachineStatesConfig = {
|
|
@@ -42,16 +33,18 @@ const firstPartyMachineStates: FirstPartyMachineStatesConfig = {
|
|
|
42
33
|
onDone: {
|
|
43
34
|
target: FirstPartyMachineStateTypes.done,
|
|
44
35
|
actions: assign({
|
|
45
|
-
authorizationCodeResponse: (_ctx: FirstPartyMachineContext, _event: DoneInvokeEvent<AuthorizationChallengeCodeResponse>) => _event.data
|
|
46
|
-
})
|
|
36
|
+
authorizationCodeResponse: (_ctx: FirstPartyMachineContext, _event: DoneInvokeEvent<AuthorizationChallengeCodeResponse>) => _event.data,
|
|
37
|
+
}),
|
|
47
38
|
},
|
|
48
39
|
onError: [
|
|
49
40
|
{
|
|
50
41
|
target: FirstPartyMachineStateTypes.createConfig,
|
|
51
|
-
cond: (_ctx: FirstPartyMachineContext, _event: DoneInvokeEvent<AuthorizationChallengeErrorResponse>): boolean =>
|
|
42
|
+
cond: (_ctx: FirstPartyMachineContext, _event: DoneInvokeEvent<AuthorizationChallengeErrorResponse>): boolean =>
|
|
43
|
+
_event.data.error === AuthorizationChallengeError.insufficient_authorization,
|
|
52
44
|
actions: assign({
|
|
53
45
|
authSession: (_ctx: FirstPartyMachineContext, _event: DoneInvokeEvent<AuthorizationChallengeErrorResponse>) => _event.data.auth_session,
|
|
54
|
-
presentationUri: (_ctx: FirstPartyMachineContext, _event: DoneInvokeEvent<AuthorizationChallengeErrorResponse>) =>
|
|
46
|
+
presentationUri: (_ctx: FirstPartyMachineContext, _event: DoneInvokeEvent<AuthorizationChallengeErrorResponse>) =>
|
|
47
|
+
_event.data.presentation,
|
|
55
48
|
}),
|
|
56
49
|
},
|
|
57
50
|
{
|
|
@@ -63,9 +56,9 @@ const firstPartyMachineStates: FirstPartyMachineStatesConfig = {
|
|
|
63
56
|
stack: _event.data.stack,
|
|
64
57
|
}),
|
|
65
58
|
}),
|
|
66
|
-
}
|
|
59
|
+
},
|
|
67
60
|
],
|
|
68
|
-
}
|
|
61
|
+
},
|
|
69
62
|
},
|
|
70
63
|
[FirstPartyMachineStateTypes.createConfig]: {
|
|
71
64
|
id: FirstPartyMachineStateTypes.createConfig,
|
|
@@ -115,7 +108,7 @@ const firstPartyMachineStates: FirstPartyMachineStatesConfig = {
|
|
|
115
108
|
id: FirstPartyMachineStateTypes.selectCredentials,
|
|
116
109
|
on: {
|
|
117
110
|
[FirstPartyMachineEvents.SET_SELECTED_CREDENTIALS]: {
|
|
118
|
-
actions: assign({selectedCredentials: (_ctx: FirstPartyMachineContext, _event: FirstPartySelectCredentialsEvent) => _event.data}),
|
|
111
|
+
actions: assign({ selectedCredentials: (_ctx: FirstPartyMachineContext, _event: FirstPartySelectCredentialsEvent) => _event.data }),
|
|
119
112
|
},
|
|
120
113
|
[FirstPartyMachineEvents.NEXT]: {
|
|
121
114
|
target: FirstPartyMachineStateTypes.sendAuthorizationResponse,
|
|
@@ -148,15 +141,15 @@ const firstPartyMachineStates: FirstPartyMachineStatesConfig = {
|
|
|
148
141
|
}),
|
|
149
142
|
}),
|
|
150
143
|
},
|
|
151
|
-
}
|
|
144
|
+
},
|
|
152
145
|
},
|
|
153
146
|
[FirstPartyMachineStateTypes.aborted]: {
|
|
154
147
|
id: FirstPartyMachineStateTypes.aborted,
|
|
155
|
-
type: 'final'
|
|
148
|
+
type: 'final',
|
|
156
149
|
},
|
|
157
150
|
[FirstPartyMachineStateTypes.declined]: {
|
|
158
151
|
id: FirstPartyMachineStateTypes.declined,
|
|
159
|
-
type: 'final'
|
|
152
|
+
type: 'final',
|
|
160
153
|
},
|
|
161
154
|
[FirstPartyMachineStateTypes.error]: {
|
|
162
155
|
id: FirstPartyMachineStateTypes.error,
|
|
@@ -165,7 +158,7 @@ const firstPartyMachineStates: FirstPartyMachineStatesConfig = {
|
|
|
165
158
|
[FirstPartyMachineStateTypes.done]: {
|
|
166
159
|
id: FirstPartyMachineStateTypes.done,
|
|
167
160
|
type: 'final',
|
|
168
|
-
}
|
|
161
|
+
},
|
|
169
162
|
}
|
|
170
163
|
|
|
171
164
|
const createFirstPartyActivationMachine = (opts: CreateFirstPartyMachineOpts): FirstPartyStateMachine => {
|
|
@@ -173,66 +166,64 @@ const createFirstPartyActivationMachine = (opts: CreateFirstPartyMachineOpts): F
|
|
|
173
166
|
openID4VCIClientState: opts.openID4VCIClientState,
|
|
174
167
|
contact: opts.contact,
|
|
175
168
|
selectedCredentials: [],
|
|
176
|
-
}
|
|
169
|
+
}
|
|
177
170
|
|
|
178
|
-
return createMachine<FirstPartyMachineContext, FirstPartyMachineEventTypes>(
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
data: void
|
|
190
|
-
},
|
|
191
|
-
[FirstPartyMachineServices.createConfig]: {
|
|
192
|
-
data: CreateConfigResult
|
|
193
|
-
},
|
|
194
|
-
[FirstPartyMachineServices.getSiopRequest]: {
|
|
195
|
-
data: SiopV2AuthorizationRequestData
|
|
196
|
-
},
|
|
197
|
-
[FirstPartyMachineServices.sendAuthorizationResponse]: {
|
|
198
|
-
data: string
|
|
199
|
-
}
|
|
171
|
+
return createMachine<FirstPartyMachineContext, FirstPartyMachineEventTypes>({
|
|
172
|
+
id: opts?.machineId ?? 'FirstParty',
|
|
173
|
+
predictableActionArguments: true,
|
|
174
|
+
initial: FirstPartyMachineStateTypes.sendAuthorizationChallengeRequest,
|
|
175
|
+
context: initialContext,
|
|
176
|
+
states: firstPartyMachineStates,
|
|
177
|
+
schema: {
|
|
178
|
+
events: {} as FirstPartyMachineEventTypes,
|
|
179
|
+
services: {} as {
|
|
180
|
+
[FirstPartyMachineServices.sendAuthorizationChallengeRequest]: {
|
|
181
|
+
data: void
|
|
200
182
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
183
|
+
[FirstPartyMachineServices.createConfig]: {
|
|
184
|
+
data: CreateConfigResult
|
|
185
|
+
}
|
|
186
|
+
[FirstPartyMachineServices.getSiopRequest]: {
|
|
187
|
+
data: SiopV2AuthorizationRequestData
|
|
188
|
+
}
|
|
189
|
+
[FirstPartyMachineServices.sendAuthorizationResponse]: {
|
|
190
|
+
data: string
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
})
|
|
195
|
+
}
|
|
205
196
|
|
|
206
197
|
export class FirstPartyMachine {
|
|
207
|
-
private static _instance: FirstPartyMachineInterpreter | undefined
|
|
198
|
+
private static _instance: FirstPartyMachineInterpreter | undefined
|
|
208
199
|
|
|
209
200
|
static hasInstance(): boolean {
|
|
210
|
-
return FirstPartyMachine._instance !== undefined
|
|
201
|
+
return FirstPartyMachine._instance !== undefined
|
|
211
202
|
}
|
|
212
203
|
|
|
213
204
|
static get instance(): FirstPartyMachineInterpreter {
|
|
214
205
|
if (!FirstPartyMachine._instance) {
|
|
215
|
-
throw Error('Please initialize ESIMActivation machine first')
|
|
206
|
+
throw Error('Please initialize ESIMActivation machine first')
|
|
216
207
|
}
|
|
217
|
-
return FirstPartyMachine._instance
|
|
208
|
+
return FirstPartyMachine._instance
|
|
218
209
|
}
|
|
219
210
|
|
|
220
|
-
static clearInstance(opts: {stop: boolean}) {
|
|
221
|
-
const {stop} = opts
|
|
211
|
+
static clearInstance(opts: { stop: boolean }) {
|
|
212
|
+
const { stop } = opts
|
|
222
213
|
if (FirstPartyMachine.hasInstance()) {
|
|
223
214
|
if (stop) {
|
|
224
|
-
FirstPartyMachine.stopInstance()
|
|
215
|
+
FirstPartyMachine.stopInstance()
|
|
225
216
|
}
|
|
226
217
|
}
|
|
227
|
-
FirstPartyMachine._instance = undefined
|
|
218
|
+
FirstPartyMachine._instance = undefined
|
|
228
219
|
}
|
|
229
220
|
|
|
230
221
|
static stopInstance(): void {
|
|
231
222
|
if (!FirstPartyMachine.hasInstance()) {
|
|
232
|
-
return
|
|
223
|
+
return
|
|
233
224
|
}
|
|
234
|
-
FirstPartyMachine.instance.stop()
|
|
235
|
-
FirstPartyMachine._instance = undefined
|
|
225
|
+
FirstPartyMachine.instance.stop()
|
|
226
|
+
FirstPartyMachine._instance = undefined
|
|
236
227
|
}
|
|
237
228
|
|
|
238
229
|
public static newInstance(opts: InstanceFirstPartyMachineOpts): FirstPartyMachineInterpreter {
|
|
@@ -254,10 +245,10 @@ export class FirstPartyMachine {
|
|
|
254
245
|
...opts?.guards,
|
|
255
246
|
},
|
|
256
247
|
}),
|
|
257
|
-
)
|
|
248
|
+
)
|
|
258
249
|
|
|
259
250
|
if (typeof opts?.subscription === 'function') {
|
|
260
|
-
newInst.onTransition(opts.subscription)
|
|
251
|
+
newInst.onTransition(opts.subscription)
|
|
261
252
|
}
|
|
262
253
|
|
|
263
254
|
if (opts?.requireCustomNavigationHook !== true) {
|
|
@@ -265,23 +256,23 @@ export class FirstPartyMachine {
|
|
|
265
256
|
if (opts?.stateNavigationListener) {
|
|
266
257
|
void opts.stateNavigationListener(newInst, snapshot)
|
|
267
258
|
}
|
|
268
|
-
})
|
|
259
|
+
})
|
|
269
260
|
}
|
|
270
261
|
|
|
271
|
-
return newInst
|
|
262
|
+
return newInst
|
|
272
263
|
}
|
|
273
264
|
|
|
274
265
|
static getInstance(
|
|
275
266
|
opts: InstanceFirstPartyMachineOpts & {
|
|
276
|
-
requireExisting?: boolean
|
|
267
|
+
requireExisting?: boolean
|
|
277
268
|
},
|
|
278
269
|
): FirstPartyMachineInterpreter {
|
|
279
270
|
if (!FirstPartyMachine._instance) {
|
|
280
271
|
if (opts?.requireExisting === true) {
|
|
281
|
-
throw Error(`Existing FirstPartyMachine instance requested, but none was created at this point!`)
|
|
272
|
+
throw Error(`Existing FirstPartyMachine instance requested, but none was created at this point!`)
|
|
282
273
|
}
|
|
283
|
-
FirstPartyMachine._instance = FirstPartyMachine.newInstance(opts)
|
|
274
|
+
FirstPartyMachine._instance = FirstPartyMachine.newInstance(opts)
|
|
284
275
|
}
|
|
285
|
-
return FirstPartyMachine._instance
|
|
276
|
+
return FirstPartyMachine._instance
|
|
286
277
|
}
|
|
287
278
|
}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AuthorizationChallengeCodeResponse,
|
|
3
|
-
AuthzFlowType,
|
|
4
|
-
toAuthorizationResponsePayload
|
|
5
|
-
} from '@sphereon/oid4vci-common'
|
|
1
|
+
import { AuthorizationChallengeCodeResponse, AuthzFlowType, toAuthorizationResponsePayload } from '@sphereon/oid4vci-common'
|
|
6
2
|
import { IBasicIssuerLocaleBranding, Identity, IIssuerLocaleBranding, Party } from '@sphereon/ssi-sdk.data-store'
|
|
7
3
|
import { assign, createMachine, DoneInvokeEvent, interpret } from 'xstate'
|
|
8
4
|
import { translate } from '../localization/Localization'
|
|
@@ -456,18 +452,20 @@ const createOID4VCIMachine = (opts?: CreateOID4VCIMachineOpts): OID4VCIStateMach
|
|
|
456
452
|
},
|
|
457
453
|
],
|
|
458
454
|
},
|
|
459
|
-
[OID4VCIMachineStates.startFirstPartApplicationFlow]
|
|
455
|
+
[OID4VCIMachineStates.startFirstPartApplicationFlow]: {
|
|
460
456
|
id: OID4VCIMachineStates.startFirstPartApplicationFlow,
|
|
461
457
|
invoke: {
|
|
462
458
|
src: OID4VCIMachineServices.startFirstPartApplicationFlow,
|
|
463
459
|
onDone: [
|
|
464
460
|
{
|
|
465
461
|
target: OID4VCIMachineStates.aborted,
|
|
466
|
-
cond: (_ctx: OID4VCIMachineContext, _event: DoneInvokeEvent<FirstPartyMachineStateTypes>): boolean =>
|
|
462
|
+
cond: (_ctx: OID4VCIMachineContext, _event: DoneInvokeEvent<FirstPartyMachineStateTypes>): boolean =>
|
|
463
|
+
_event.data === FirstPartyMachineStateTypes.aborted,
|
|
467
464
|
},
|
|
468
465
|
{
|
|
469
466
|
target: OID4VCIMachineStates.declined,
|
|
470
|
-
cond: (_ctx: OID4VCIMachineContext, _event: DoneInvokeEvent<FirstPartyMachineStateTypes>): boolean =>
|
|
467
|
+
cond: (_ctx: OID4VCIMachineContext, _event: DoneInvokeEvent<FirstPartyMachineStateTypes>): boolean =>
|
|
468
|
+
_event.data === FirstPartyMachineStateTypes.declined,
|
|
471
469
|
},
|
|
472
470
|
{
|
|
473
471
|
target: OID4VCIMachineStates.getCredentials,
|
|
@@ -475,9 +473,9 @@ const createOID4VCIMachine = (opts?: CreateOID4VCIMachineOpts): OID4VCIStateMach
|
|
|
475
473
|
openID4VCIClientState: (_ctx: OID4VCIMachineContext, _event: DoneInvokeEvent<AuthorizationChallengeCodeResponse>) => {
|
|
476
474
|
const authorizationCodeResponse = toAuthorizationResponsePayload(_event.data)
|
|
477
475
|
return { ..._ctx.openID4VCIClientState!, authorizationCodeResponse }
|
|
478
|
-
}
|
|
479
|
-
})
|
|
480
|
-
}
|
|
476
|
+
},
|
|
477
|
+
}),
|
|
478
|
+
},
|
|
481
479
|
],
|
|
482
480
|
onError: {
|
|
483
481
|
target: OID4VCIMachineStates.handleError,
|