@sphereon/ssi-sdk.oid4vci-holder 0.34.1-next.29 → 0.34.1-next.299
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 +426 -420
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -7
- package/dist/index.d.ts +10 -7
- package/dist/index.js +533 -527
- package/dist/index.js.map +1 -1
- package/package.json +25 -24
- package/src/agent/OID4VCIHolder.ts +35 -34
- package/src/machines/firstPartyMachine.ts +1 -1
- package/src/machines/oid4vciMachine.ts +1 -1
- package/src/mappers/OIDC4VCIBrandingMapper.ts +1 -1
- package/src/services/OID4VCIHolderService.ts +46 -45
- package/src/types/FirstPartyMachine.ts +6 -5
- package/src/types/IOID4VCIHolder.ts +4 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.oid4vci-holder",
|
|
3
|
-
"version": "0.34.1-next.
|
|
3
|
+
"version": "0.34.1-next.299+9e9f5a50",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -26,40 +26,41 @@
|
|
|
26
26
|
"build": "tsup --config ../../tsup.config.ts --tsconfig ../../tsconfig.tsup.json"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@sphereon/did-auth-siop": "0.19.1-next.
|
|
29
|
+
"@sphereon/did-auth-siop": "0.19.1-next.220",
|
|
30
30
|
"@sphereon/kmp-mdoc-core": "0.2.0-SNAPSHOT.26",
|
|
31
|
-
"@sphereon/oid4vci-client": "0.19.1-next.
|
|
32
|
-
"@sphereon/oid4vci-common": "0.19.1-next.
|
|
33
|
-
"@sphereon/ssi-sdk-ext.did-utils": "0.
|
|
34
|
-
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.
|
|
35
|
-
"@sphereon/ssi-sdk-ext.jwt-service": "0.
|
|
36
|
-
"@sphereon/ssi-sdk-ext.key-utils": "0.
|
|
37
|
-
"@sphereon/ssi-sdk.contact-manager": "0.34.1-next.
|
|
38
|
-
"@sphereon/ssi-sdk.core": "0.34.1-next.
|
|
39
|
-
"@sphereon/ssi-sdk.credential-store": "0.34.1-next.
|
|
40
|
-
"@sphereon/ssi-sdk.credential-validation": "0.34.1-next.
|
|
41
|
-
"@sphereon/ssi-sdk.data-store": "0.34.1-next.
|
|
42
|
-
"@sphereon/ssi-sdk.issuance-branding": "0.34.1-next.
|
|
43
|
-
"@sphereon/ssi-sdk.mdl-mdoc": "0.34.1-next.
|
|
44
|
-
"@sphereon/ssi-sdk.oidf-client": "0.34.1-next.
|
|
45
|
-
"@sphereon/ssi-sdk.sd-jwt": "0.34.1-next.
|
|
46
|
-
"@sphereon/ssi-sdk.siopv2-oid4vp-common": "0.34.1-next.
|
|
47
|
-
"@sphereon/ssi-sdk.siopv2-oid4vp-op-auth": "0.34.1-next.
|
|
48
|
-
"@sphereon/ssi-sdk.xstate-machine-persistence": "0.34.1-next.
|
|
49
|
-
"@sphereon/ssi-types": "0.34.1-next.
|
|
31
|
+
"@sphereon/oid4vci-client": "0.19.1-next.220",
|
|
32
|
+
"@sphereon/oid4vci-common": "0.19.1-next.220",
|
|
33
|
+
"@sphereon/ssi-sdk-ext.did-utils": "0.34.1-next.299+9e9f5a50",
|
|
34
|
+
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.34.1-next.299+9e9f5a50",
|
|
35
|
+
"@sphereon/ssi-sdk-ext.jwt-service": "0.34.1-next.299+9e9f5a50",
|
|
36
|
+
"@sphereon/ssi-sdk-ext.key-utils": "0.34.1-next.299+9e9f5a50",
|
|
37
|
+
"@sphereon/ssi-sdk.contact-manager": "0.34.1-next.299+9e9f5a50",
|
|
38
|
+
"@sphereon/ssi-sdk.core": "0.34.1-next.299+9e9f5a50",
|
|
39
|
+
"@sphereon/ssi-sdk.credential-store": "0.34.1-next.299+9e9f5a50",
|
|
40
|
+
"@sphereon/ssi-sdk.credential-validation": "0.34.1-next.299+9e9f5a50",
|
|
41
|
+
"@sphereon/ssi-sdk.data-store-types": "0.34.1-next.299+9e9f5a50",
|
|
42
|
+
"@sphereon/ssi-sdk.issuance-branding": "0.34.1-next.299+9e9f5a50",
|
|
43
|
+
"@sphereon/ssi-sdk.mdl-mdoc": "0.34.1-next.299+9e9f5a50",
|
|
44
|
+
"@sphereon/ssi-sdk.oidf-client": "0.34.1-next.299+9e9f5a50",
|
|
45
|
+
"@sphereon/ssi-sdk.sd-jwt": "0.34.1-next.299+9e9f5a50",
|
|
46
|
+
"@sphereon/ssi-sdk.siopv2-oid4vp-common": "0.34.1-next.299+9e9f5a50",
|
|
47
|
+
"@sphereon/ssi-sdk.siopv2-oid4vp-op-auth": "0.34.1-next.299+9e9f5a50",
|
|
48
|
+
"@sphereon/ssi-sdk.xstate-machine-persistence": "0.34.1-next.299+9e9f5a50",
|
|
49
|
+
"@sphereon/ssi-types": "0.34.1-next.299+9e9f5a50",
|
|
50
50
|
"@veramo/core": "4.2.0",
|
|
51
51
|
"@veramo/data-store": "4.2.0",
|
|
52
52
|
"@veramo/utils": "4.2.0",
|
|
53
53
|
"ajv": "^8.17.1",
|
|
54
54
|
"ajv-formats": "^3.0.1",
|
|
55
|
+
"dcql": "1.0.1",
|
|
55
56
|
"i18n-js": "^3.9.2",
|
|
56
57
|
"lodash.memoize": "^4.1.2",
|
|
57
58
|
"uuid": "^9.0.1",
|
|
58
59
|
"xstate": "^4.38.3"
|
|
59
60
|
},
|
|
60
61
|
"devDependencies": {
|
|
61
|
-
"@sphereon/oid4vc-common": "0.19.1-next.
|
|
62
|
-
"@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.
|
|
62
|
+
"@sphereon/oid4vc-common": "0.19.1-next.220",
|
|
63
|
+
"@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.34.1-next.299+9e9f5a50",
|
|
63
64
|
"@sphereon/ssi-sdk.siopv2-oid4vp-common": "workspace:*",
|
|
64
65
|
"@types/i18n-js": "^3.8.9",
|
|
65
66
|
"@types/lodash.memoize": "^4.1.9",
|
|
@@ -89,5 +90,5 @@
|
|
|
89
90
|
"OID4VCI",
|
|
90
91
|
"State Machine"
|
|
91
92
|
],
|
|
92
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "9e9f5a50ead9373a078cb5291cbc4fb1e7865dc2"
|
|
93
94
|
}
|
|
@@ -4,13 +4,11 @@ import {
|
|
|
4
4
|
AuthorizationRequestOpts,
|
|
5
5
|
AuthorizationServerClientOpts,
|
|
6
6
|
AuthorizationServerOpts,
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
CredentialConfigurationSupportedJwtVcJsonLdAndLdpVcV1_0_15,
|
|
8
|
+
CredentialDefinitionJwtVcJsonLdAndLdpVcV1_0_15,
|
|
9
9
|
CredentialOfferRequestWithBaseUrl,
|
|
10
10
|
DefaultURISchemes,
|
|
11
11
|
EndpointMetadataResult,
|
|
12
|
-
getTypesFromAuthorizationDetails,
|
|
13
|
-
getTypesFromCredentialOffer,
|
|
14
12
|
getTypesFromObject,
|
|
15
13
|
Jwt,
|
|
16
14
|
NotificationRequest,
|
|
@@ -30,12 +28,12 @@ import {
|
|
|
30
28
|
} from '@sphereon/ssi-sdk-ext.identifier-resolution'
|
|
31
29
|
import { IJwtService, JwsHeader } from '@sphereon/ssi-sdk-ext.jwt-service'
|
|
32
30
|
import { signatureAlgorithmFromKey } from '@sphereon/ssi-sdk-ext.key-utils'
|
|
31
|
+
import { defaultHasher } from '@sphereon/ssi-sdk.core'
|
|
32
|
+
import { ensureRawDocument } from '@sphereon/ssi-sdk.data-store-types'
|
|
33
33
|
import {
|
|
34
34
|
ConnectionType,
|
|
35
35
|
CorrelationIdentifierType,
|
|
36
36
|
CredentialCorrelationType,
|
|
37
|
-
CredentialRole,
|
|
38
|
-
ensureRawDocument,
|
|
39
37
|
FindPartyArgs,
|
|
40
38
|
IBasicCredentialLocaleBranding,
|
|
41
39
|
IBasicIssuerLocaleBranding,
|
|
@@ -44,17 +42,17 @@ import {
|
|
|
44
42
|
IIssuerLocaleBranding,
|
|
45
43
|
NonPersistedIdentity,
|
|
46
44
|
Party,
|
|
47
|
-
} from '@sphereon/ssi-sdk.data-store'
|
|
45
|
+
} from '@sphereon/ssi-sdk.data-store-types'
|
|
48
46
|
import {
|
|
49
47
|
CredentialMapper,
|
|
50
48
|
type CredentialProofFormat,
|
|
49
|
+
CredentialRole,
|
|
51
50
|
HasherSync,
|
|
52
51
|
IVerifiableCredential,
|
|
53
52
|
JoseSignatureAlgorithm,
|
|
54
53
|
JoseSignatureAlgorithmString,
|
|
55
54
|
JwtDecodedVerifiableCredential,
|
|
56
55
|
Loggers,
|
|
57
|
-
OriginalVerifiableCredential,
|
|
58
56
|
parseDid,
|
|
59
57
|
SdJwtDecodedVerifiableCredentialPayload,
|
|
60
58
|
WrappedW3CVerifiableCredential,
|
|
@@ -70,9 +68,22 @@ import {
|
|
|
70
68
|
W3CVerifiableCredential,
|
|
71
69
|
} from '@veramo/core'
|
|
72
70
|
import { asArray, computeEntryHash } from '@veramo/utils'
|
|
71
|
+
import fetch from 'cross-fetch'
|
|
73
72
|
import { decodeJWT } from 'did-jwt'
|
|
74
73
|
import { v4 as uuidv4 } from 'uuid'
|
|
75
74
|
import { OID4VCIMachine } from '../machines/oid4vciMachine'
|
|
75
|
+
import {
|
|
76
|
+
extractCredentialFromResponse,
|
|
77
|
+
getBasicIssuerLocaleBranding,
|
|
78
|
+
getCredentialBranding,
|
|
79
|
+
getCredentialConfigsSupportedMerged,
|
|
80
|
+
getIdentifierOpts,
|
|
81
|
+
getIssuanceOpts,
|
|
82
|
+
mapCredentialToAccept,
|
|
83
|
+
selectCredentialLocaleBranding,
|
|
84
|
+
startFirstPartApplicationMachine,
|
|
85
|
+
verifyCredentialToAccept,
|
|
86
|
+
} from '../services/OID4VCIHolderService'
|
|
76
87
|
import {
|
|
77
88
|
AddContactIdentityArgs,
|
|
78
89
|
AssertValidCredentialsArgs,
|
|
@@ -111,19 +122,6 @@ import {
|
|
|
111
122
|
VerifyEBSICredentialIssuerArgs,
|
|
112
123
|
VerifyEBSICredentialIssuerResult,
|
|
113
124
|
} from '../types/IOID4VCIHolder'
|
|
114
|
-
import {
|
|
115
|
-
getBasicIssuerLocaleBranding,
|
|
116
|
-
getCredentialBranding,
|
|
117
|
-
getCredentialConfigsSupportedMerged,
|
|
118
|
-
getIdentifierOpts,
|
|
119
|
-
getIssuanceOpts,
|
|
120
|
-
mapCredentialToAccept,
|
|
121
|
-
selectCredentialLocaleBranding,
|
|
122
|
-
startFirstPartApplicationMachine,
|
|
123
|
-
verifyCredentialToAccept,
|
|
124
|
-
} from '../services/OID4VCIHolderService'
|
|
125
|
-
import 'cross-fetch/polyfill'
|
|
126
|
-
import { defaultHasher } from '@sphereon/ssi-sdk.core'
|
|
127
125
|
|
|
128
126
|
/**
|
|
129
127
|
* {@inheritDoc IOID4VCIHolder}
|
|
@@ -151,7 +149,7 @@ export function signCallback(
|
|
|
151
149
|
context: IAgentContext<IKeyManager & IDIDManager & IResolver & IIdentifierResolution & IJwtService>,
|
|
152
150
|
nonce?: string,
|
|
153
151
|
) {
|
|
154
|
-
return async (jwt: Jwt, kid?: string) => {
|
|
152
|
+
return async (jwt: Jwt, kid?: string, noIssPayloadUpdate?: boolean) => {
|
|
155
153
|
let resolution = await context.agent.identifierManagedGet(identifier)
|
|
156
154
|
const jwk = jwt.header.jwk ?? (resolution.method === 'jwk' ? resolution.jwk : undefined)
|
|
157
155
|
if (!resolution.issuer && !jwt.payload.iss) {
|
|
@@ -170,7 +168,7 @@ export function signCallback(
|
|
|
170
168
|
}
|
|
171
169
|
return (
|
|
172
170
|
await context.agent.jwtCreateJwsCompactSignature({
|
|
173
|
-
issuer: { ...resolution, noIssPayloadUpdate: false },
|
|
171
|
+
issuer: { ...resolution, noIssPayloadUpdate: noIssPayloadUpdate ?? false },
|
|
174
172
|
protectedHeader: header,
|
|
175
173
|
payload,
|
|
176
174
|
})
|
|
@@ -229,7 +227,7 @@ export class OID4VCIHolder implements IAgentPlugin {
|
|
|
229
227
|
oid4vciHolderStoreIssuerBranding: this.oid4vciHolderStoreIssuerBranding.bind(this),
|
|
230
228
|
}
|
|
231
229
|
|
|
232
|
-
private readonly vcFormatPreferences: Array<string> = ['vc+sd-jwt', 'mso_mdoc', 'jwt_vc_json', 'jwt_vc', 'ldp_vc']
|
|
230
|
+
private readonly vcFormatPreferences: Array<string> = ['dc+sd-jwt', 'vc+sd-jwt', 'mso_mdoc', 'jwt_vc_json', 'jwt_vc', 'ldp_vc'] // TODO see SSISDK-52 concerning vc+sd-jwt
|
|
233
231
|
private readonly jsonldCryptographicSuitePreferences: Array<string> = [
|
|
234
232
|
'Ed25519Signature2018',
|
|
235
233
|
'EcdsaSecp256k1Signature2019',
|
|
@@ -400,7 +398,6 @@ export class OID4VCIHolder implements IAgentPlugin {
|
|
|
400
398
|
formats = Array.from(new Set(authFormats))
|
|
401
399
|
}
|
|
402
400
|
let oid4vciClient: OpenID4VCIClient
|
|
403
|
-
let types: string[][] | undefined = undefined
|
|
404
401
|
let offer: CredentialOfferRequestWithBaseUrl | undefined
|
|
405
402
|
if (requestData.existingClientState) {
|
|
406
403
|
oid4vciClient = await OpenID4VCIClient.fromState({ state: requestData.existingClientState })
|
|
@@ -442,20 +439,23 @@ export class OID4VCIHolder implements IAgentPlugin {
|
|
|
442
439
|
}
|
|
443
440
|
}
|
|
444
441
|
|
|
442
|
+
let configurationIds: Array<string> = []
|
|
445
443
|
if (offer) {
|
|
446
|
-
|
|
444
|
+
configurationIds = offer.original_credential_offer.credential_configuration_ids
|
|
447
445
|
} else {
|
|
448
|
-
|
|
449
|
-
.
|
|
450
|
-
.
|
|
446
|
+
configurationIds = asArray(authorizationRequestOpts.authorizationDetails)
|
|
447
|
+
.filter((authDetails): authDetails is Exclude<AuthorizationDetails, string> => typeof authDetails !== 'string')
|
|
448
|
+
.map((authReqOpts) => authReqOpts.credential_configuration_id)
|
|
449
|
+
.filter((id): id is string => !!id)
|
|
451
450
|
}
|
|
452
451
|
|
|
453
|
-
const serverMetadata = await oid4vciClient.retrieveServerMetadata()
|
|
454
452
|
const credentialsSupported = await getCredentialConfigsSupportedMerged({
|
|
455
453
|
client: oid4vciClient,
|
|
456
454
|
vcFormatPreferences: formats,
|
|
457
|
-
|
|
455
|
+
configurationIds,
|
|
458
456
|
})
|
|
457
|
+
|
|
458
|
+
const serverMetadata = await oid4vciClient.retrieveServerMetadata()
|
|
459
459
|
const credentialBranding = await getCredentialBranding({ credentialsSupported, context })
|
|
460
460
|
const authorizationCodeURL = oid4vciClient.authorizationURL
|
|
461
461
|
if (authorizationCodeURL) {
|
|
@@ -939,7 +939,8 @@ export class OID4VCIHolder implements IAgentPlugin {
|
|
|
939
939
|
? 'credential_accepted_holder_signed'
|
|
940
940
|
: 'credential_deleted_holder_signed'
|
|
941
941
|
logger.log(`Subject issuance/signing will be used, with event`, event)
|
|
942
|
-
|
|
942
|
+
|
|
943
|
+
const issuerVC = extractCredentialFromResponse(mappedCredentialToAccept.credentialToAccept.credentialResponse)
|
|
943
944
|
const wrappedIssuerVC = CredentialMapper.toWrappedVerifiableCredential(issuerVC, { hasher: this.hasher ?? defaultHasher })
|
|
944
945
|
console.log(`Wrapped VC: ${wrappedIssuerVC.type}, ${wrappedIssuerVC.format}`)
|
|
945
946
|
// 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!)
|
|
@@ -1169,9 +1170,9 @@ export class OID4VCIHolder implements IAgentPlugin {
|
|
|
1169
1170
|
return undefined
|
|
1170
1171
|
}
|
|
1171
1172
|
|
|
1172
|
-
private getCredentialDefinition(issuanceOpt: IssuanceOpts):
|
|
1173
|
+
private getCredentialDefinition(issuanceOpt: IssuanceOpts): CredentialDefinitionJwtVcJsonLdAndLdpVcV1_0_15 | undefined {
|
|
1173
1174
|
if (issuanceOpt.format == 'ldp_vc' || issuanceOpt.format == 'jwt_vc_json-ld') {
|
|
1174
|
-
return (issuanceOpt as
|
|
1175
|
+
return (issuanceOpt as CredentialConfigurationSupportedJwtVcJsonLdAndLdpVcV1_0_15).credential_definition
|
|
1175
1176
|
}
|
|
1176
1177
|
return undefined
|
|
1177
1178
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { assign, createMachine, DoneInvokeEvent, interpret } from 'xstate'
|
|
2
2
|
import { AuthorizationChallengeCodeResponse, AuthorizationChallengeError, AuthorizationChallengeErrorResponse } from '@sphereon/oid4vci-common'
|
|
3
|
-
import { DidAuthConfig } from '@sphereon/ssi-sdk.data-store'
|
|
3
|
+
import { DidAuthConfig } from '@sphereon/ssi-sdk.data-store-types'
|
|
4
4
|
import { CreateConfigResult } from '@sphereon/ssi-sdk.siopv2-oid4vp-op-auth'
|
|
5
5
|
import { createConfig, getSiopRequest, sendAuthorizationChallengeRequest, sendAuthorizationResponse } from '../services/FirstPartyMachineServices'
|
|
6
6
|
import { translate } from '../localization/Localization'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AuthorizationChallengeCodeResponse, AuthzFlowType, toAuthorizationResponsePayload } from '@sphereon/oid4vci-common'
|
|
2
|
-
import { IBasicIssuerLocaleBranding, Identity, IIssuerLocaleBranding, Party } from '@sphereon/ssi-sdk.data-store'
|
|
2
|
+
import { IBasicIssuerLocaleBranding, Identity, IIssuerLocaleBranding, Party } from '@sphereon/ssi-sdk.data-store-types'
|
|
3
3
|
import { assign, createMachine, DoneInvokeEvent, interpret } from 'xstate'
|
|
4
4
|
import { translate } from '../localization/Localization'
|
|
5
5
|
import {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CredentialsSupportedDisplay, NameAndLocale } from '@sphereon/oid4vci-common'
|
|
2
|
-
import { IBasicCredentialClaim, IBasicCredentialLocaleBranding, IBasicIssuerLocaleBranding } from '@sphereon/ssi-sdk.data-store'
|
|
2
|
+
import { IBasicCredentialClaim, IBasicCredentialLocaleBranding, IBasicIssuerLocaleBranding } from '@sphereon/ssi-sdk.data-store-types'
|
|
3
3
|
import { SdJwtClaimDisplayMetadata, SdJwtClaimMetadata, SdJwtClaimPath, SdJwtTypeDisplayMetadata } from '@sphereon/ssi-types'
|
|
4
4
|
import {
|
|
5
5
|
IssuerLocaleBrandingFromArgs,
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { LOG } from '@sphereon/oid4vci-client'
|
|
2
2
|
import {
|
|
3
|
+
AuthorizationChallengeCodeResponse,
|
|
3
4
|
CredentialConfigurationSupported,
|
|
4
|
-
|
|
5
|
-
CredentialConfigurationSupportedSdJwtVcV1_0_13,
|
|
6
|
-
CredentialOfferFormatV1_0_11,
|
|
5
|
+
CredentialConfigurationSupportedSdJwtVcV1_0_15,
|
|
7
6
|
CredentialResponse,
|
|
7
|
+
CredentialResponseV1_0_15,
|
|
8
|
+
CredentialSupportedSdJwtVc,
|
|
8
9
|
getSupportedCredentials,
|
|
9
10
|
getTypesFromCredentialSupported,
|
|
10
11
|
getTypesFromObject,
|
|
11
12
|
MetadataDisplay,
|
|
12
|
-
OpenId4VCIVersion,
|
|
13
|
-
AuthorizationChallengeCodeResponse,
|
|
14
13
|
} from '@sphereon/oid4vci-common'
|
|
15
14
|
import { KeyUse } from '@sphereon/ssi-sdk-ext.did-resolver-jwk'
|
|
16
15
|
import { getOrCreatePrimaryIdentifier, SupportedDidMethodEnum } from '@sphereon/ssi-sdk-ext.did-utils'
|
|
@@ -23,7 +22,8 @@ import {
|
|
|
23
22
|
managedIdentifierToJwk,
|
|
24
23
|
} from '@sphereon/ssi-sdk-ext.identifier-resolution'
|
|
25
24
|
import { keyTypeFromCryptographicSuite } from '@sphereon/ssi-sdk-ext.key-utils'
|
|
26
|
-
import {
|
|
25
|
+
import { defaultHasher } from '@sphereon/ssi-sdk.core'
|
|
26
|
+
import { IBasicCredentialLocaleBranding, IBasicIssuerLocaleBranding } from '@sphereon/ssi-sdk.data-store-types'
|
|
27
27
|
import {
|
|
28
28
|
CredentialMapper,
|
|
29
29
|
Hasher,
|
|
@@ -40,8 +40,12 @@ import {
|
|
|
40
40
|
} from '@sphereon/ssi-types'
|
|
41
41
|
import { asArray } from '@veramo/utils'
|
|
42
42
|
import { translate } from '../localization/Localization'
|
|
43
|
+
import { FirstPartyMachine } from '../machines/firstPartyMachine'
|
|
44
|
+
import { issuerLocaleBrandingFrom, oid4vciGetCredentialBrandingFrom, sdJwtGetCredentialBrandingFrom } from '../mappers/OIDC4VCIBrandingMapper'
|
|
45
|
+
import { FirstPartyMachineState, FirstPartyMachineStateTypes } from '../types/FirstPartyMachine'
|
|
43
46
|
import {
|
|
44
47
|
DidAgents,
|
|
48
|
+
GetBasicIssuerLocaleBrandingArgs,
|
|
45
49
|
GetCredentialBrandingArgs,
|
|
46
50
|
GetCredentialConfigsSupportedArgs,
|
|
47
51
|
GetCredentialConfigsSupportedBySingleTypeOrIdArgs,
|
|
@@ -49,22 +53,17 @@ import {
|
|
|
49
53
|
GetIssuanceCryptoSuiteArgs,
|
|
50
54
|
GetIssuanceDidMethodArgs,
|
|
51
55
|
GetIssuanceOptsArgs,
|
|
52
|
-
GetBasicIssuerLocaleBrandingArgs,
|
|
53
56
|
GetPreferredCredentialFormatsArgs,
|
|
54
57
|
IssuanceOpts,
|
|
55
58
|
MapCredentialToAcceptArgs,
|
|
56
59
|
MappedCredentialToAccept,
|
|
57
60
|
OID4VCIHolderEvent,
|
|
61
|
+
RequiredContext,
|
|
58
62
|
SelectAppLocaleBrandingArgs,
|
|
63
|
+
StartFirstPartApplicationMachine,
|
|
59
64
|
VerificationResult,
|
|
60
65
|
VerifyCredentialToAcceptArgs,
|
|
61
|
-
StartFirstPartApplicationMachine,
|
|
62
|
-
RequiredContext,
|
|
63
66
|
} from '../types/IOID4VCIHolder'
|
|
64
|
-
import { oid4vciGetCredentialBrandingFrom, sdJwtGetCredentialBrandingFrom, issuerLocaleBrandingFrom } from '../mappers/OIDC4VCIBrandingMapper'
|
|
65
|
-
import { FirstPartyMachine } from '../machines/firstPartyMachine'
|
|
66
|
-
import { FirstPartyMachineState, FirstPartyMachineStateTypes } from '../types/FirstPartyMachine'
|
|
67
|
-
import { defaultHasher } from '@sphereon/ssi-sdk.core'
|
|
68
67
|
|
|
69
68
|
export const getCredentialBranding = async (args: GetCredentialBrandingArgs): Promise<Record<string, Array<IBasicCredentialLocaleBranding>>> => {
|
|
70
69
|
const { credentialsSupported, context } = args
|
|
@@ -72,8 +71,8 @@ export const getCredentialBranding = async (args: GetCredentialBrandingArgs): Pr
|
|
|
72
71
|
await Promise.all(
|
|
73
72
|
Object.entries(credentialsSupported).map(async ([configId, credentialsConfigSupported]): Promise<void> => {
|
|
74
73
|
let sdJwtTypeMetadata: SdJwtTypeMetadata | undefined
|
|
75
|
-
if (credentialsConfigSupported.format === '
|
|
76
|
-
const vct = (<CredentialSupportedSdJwtVc |
|
|
74
|
+
if (credentialsConfigSupported.format === 'dc+sd-jwt') {
|
|
75
|
+
const vct = (<CredentialSupportedSdJwtVc | CredentialConfigurationSupportedSdJwtVcV1_0_15>credentialsConfigSupported).vct
|
|
77
76
|
if (vct.startsWith('http')) {
|
|
78
77
|
try {
|
|
79
78
|
sdJwtTypeMetadata = await context.agent.fetchSdJwtTypeMetadataFromVctUrl({ vct })
|
|
@@ -153,10 +152,7 @@ export const selectCredentialLocaleBranding = async (
|
|
|
153
152
|
export const verifyCredentialToAccept = async (args: VerifyCredentialToAcceptArgs): Promise<VerificationResult> => {
|
|
154
153
|
const { mappedCredential, hasher, onVerifyEBSICredentialIssuer, schemaValidation, context } = args
|
|
155
154
|
|
|
156
|
-
const credential = mappedCredential.credentialToAccept.credentialResponse
|
|
157
|
-
if (!credential) {
|
|
158
|
-
return Promise.reject(Error('No credential found in credential response'))
|
|
159
|
-
}
|
|
155
|
+
const credential = extractCredentialFromResponse(mappedCredential.credentialToAccept.credentialResponse)
|
|
160
156
|
|
|
161
157
|
const wrappedVC = CredentialMapper.toWrappedVerifiableCredential(credential, { hasher: hasher ?? defaultHasher })
|
|
162
158
|
if (
|
|
@@ -205,11 +201,7 @@ export const verifyCredentialToAccept = async (args: VerifyCredentialToAcceptArg
|
|
|
205
201
|
export const mapCredentialToAccept = async (args: MapCredentialToAcceptArgs): Promise<MappedCredentialToAccept> => {
|
|
206
202
|
const { credentialToAccept, hasher } = args
|
|
207
203
|
|
|
208
|
-
const
|
|
209
|
-
const verifiableCredential: W3CVerifiableCredential | undefined = credentialResponse.credential
|
|
210
|
-
if (!verifiableCredential) {
|
|
211
|
-
return Promise.reject(Error('No credential found in credential response'))
|
|
212
|
-
}
|
|
204
|
+
const verifiableCredential = extractCredentialFromResponse(credentialToAccept.credentialResponse) as W3CVerifiableCredential
|
|
213
205
|
|
|
214
206
|
const wrappedVerifiableCredential: WrappedVerifiableCredential = CredentialMapper.toWrappedVerifiableCredential(
|
|
215
207
|
verifiableCredential as OriginalVerifiableCredential,
|
|
@@ -240,6 +232,7 @@ export const mapCredentialToAccept = async (args: MapCredentialToAcceptArgs): Pr
|
|
|
240
232
|
? uniformVerifiableCredential.decodedPayload.iss
|
|
241
233
|
: uniformVerifiableCredential.issuer.id
|
|
242
234
|
|
|
235
|
+
const credentialResponse = credentialToAccept.credentialResponse as CredentialResponseV1_0_15
|
|
243
236
|
return {
|
|
244
237
|
correlationId,
|
|
245
238
|
credentialToAccept,
|
|
@@ -250,6 +243,27 @@ export const mapCredentialToAccept = async (args: MapCredentialToAcceptArgs): Pr
|
|
|
250
243
|
}
|
|
251
244
|
}
|
|
252
245
|
|
|
246
|
+
export const extractCredentialFromResponse = (credentialResponse: CredentialResponse): OriginalVerifiableCredential => {
|
|
247
|
+
let credential: OriginalVerifiableCredential | undefined
|
|
248
|
+
|
|
249
|
+
if ('credential' in credentialResponse) {
|
|
250
|
+
credential = credentialResponse.credential as OriginalVerifiableCredential
|
|
251
|
+
} else if (
|
|
252
|
+
'credentials' in credentialResponse &&
|
|
253
|
+
credentialResponse.credentials &&
|
|
254
|
+
Array.isArray(credentialResponse.credentials) &&
|
|
255
|
+
credentialResponse.credentials.length > 0
|
|
256
|
+
) {
|
|
257
|
+
credential = credentialResponse.credentials[0].credential as OriginalVerifiableCredential // FIXME SSISDK-13 (no multi-credential support yet)
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if (!credential) {
|
|
261
|
+
throw new Error('No credential found in credential response')
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return credential
|
|
265
|
+
}
|
|
266
|
+
|
|
253
267
|
export const getIdentifierOpts = async (args: GetIdentifierArgs): Promise<ManagedIdentifierResult> => {
|
|
254
268
|
const { issuanceOpt, context } = args
|
|
255
269
|
const { identifier: identifierArg } = issuanceOpt
|
|
@@ -370,7 +384,7 @@ export const getCredentialConfigsSupportedBySingleTypeOrId = async (
|
|
|
370
384
|
}
|
|
371
385
|
|
|
372
386
|
if (configurationId) {
|
|
373
|
-
const allSupported = client.getCredentialsSupported(
|
|
387
|
+
const allSupported = client.getCredentialsSupported(format)
|
|
374
388
|
return Object.fromEntries(
|
|
375
389
|
Object.entries(allSupported).filter(
|
|
376
390
|
([id, supported]) => id === configurationId || supported.id === configurationId || createIdFromTypes(supported) === configurationId,
|
|
@@ -378,29 +392,15 @@ export const getCredentialConfigsSupportedBySingleTypeOrId = async (
|
|
|
378
392
|
)
|
|
379
393
|
}
|
|
380
394
|
|
|
381
|
-
if (!
|
|
382
|
-
return Promise.reject(Error('openID4VCIClient has no credentialOffer
|
|
383
|
-
/*} else if (!format && !client.credentialOffer) {
|
|
384
|
-
return Promise.reject(Error('openID4VCIClient has no credentialOffer and no formats where provided'))*/
|
|
395
|
+
if (!client.credentialOffer) {
|
|
396
|
+
return Promise.reject(Error('openID4VCIClient has no credentialOffer'))
|
|
385
397
|
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
if (
|
|
389
|
-
client.version() > OpenId4VCIVersion.VER_1_0_09 &&
|
|
390
|
-
typeof client.credentialOffer.credential_offer === 'object' &&
|
|
391
|
-
'credentials' in client.credentialOffer.credential_offer
|
|
392
|
-
) {
|
|
393
|
-
format = client.credentialOffer.credential_offer.credentials
|
|
394
|
-
.filter((cred: CredentialOfferFormatV1_0_11 | string) => typeof cred !== 'string')
|
|
395
|
-
.map((cred: CredentialOfferFormatV1_0_11 | string) => (cred as CredentialOfferFormatV1_0_11).format)
|
|
396
|
-
if (format?.length === 0) {
|
|
397
|
-
format = undefined // Otherwise we would match nothing
|
|
398
|
-
}
|
|
399
|
-
}
|
|
398
|
+
if (!types) {
|
|
399
|
+
return Promise.reject(Error('openID4VCIClient has no types'))
|
|
400
400
|
}
|
|
401
401
|
|
|
402
402
|
const offerSupported = getSupportedCredentials({
|
|
403
|
-
types:
|
|
403
|
+
types: [types],
|
|
404
404
|
format,
|
|
405
405
|
version: client.version(),
|
|
406
406
|
issuerMetadata: client.endpointMetadata.credentialIssuerMetadata,
|
|
@@ -580,7 +580,8 @@ export const getIssuanceCryptoSuite = async (opts: GetIssuanceCryptoSuiteArgs):
|
|
|
580
580
|
case 'jwt':
|
|
581
581
|
case 'jwt_vc_json':
|
|
582
582
|
case 'jwt_vc':
|
|
583
|
-
case 'vc+sd-jwt':
|
|
583
|
+
//case 'vc+sd-jwt': // TODO see SSISDK-52 concerning vc+sd-jwt
|
|
584
|
+
case 'dc+sd-jwt':
|
|
584
585
|
case 'mso_mdoc': {
|
|
585
586
|
const supportedPreferences: Array<JoseSignatureAlgorithm | JoseSignatureAlgorithmString> = jwtCryptographicSuitePreferences.filter(
|
|
586
587
|
(suite: JoseSignatureAlgorithm | JoseSignatureAlgorithmString) => signing_algs_supported.includes(suite),
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RPRegistrationMetadataPayload } from '@sphereon/did-auth-siop'
|
|
2
2
|
import { OpenID4VCIClientState } from '@sphereon/oid4vci-client'
|
|
3
|
-
import { DidAuthConfig, Party } from '@sphereon/ssi-sdk.data-store'
|
|
4
|
-
import { PresentationDefinitionWithLocation, RPRegistrationMetadataPayload } from '@sphereon/did-auth-siop'
|
|
5
|
-
import { UniqueDigitalCredential } from '@sphereon/ssi-sdk.credential-store'
|
|
6
3
|
import { AuthorizationChallengeCodeResponse } from '@sphereon/oid4vci-common'
|
|
4
|
+
import { UniqueDigitalCredential } from '@sphereon/ssi-sdk.credential-store'
|
|
5
|
+
import { DidAuthConfig, Party } from '@sphereon/ssi-sdk.data-store-types'
|
|
7
6
|
import { IIdentifier } from '@veramo/core'
|
|
7
|
+
import { DcqlQuery } from 'dcql'
|
|
8
|
+
import { BaseActionObject, Interpreter, ResolveTypegenMeta, ServiceMap, State, StateMachine, StatesConfig, TypegenDisabled } from 'xstate'
|
|
8
9
|
import { ErrorDetails, RequiredContext } from './IOID4VCIHolder'
|
|
9
10
|
|
|
10
11
|
export enum FirstPartyMachineStateTypes {
|
|
@@ -149,7 +150,7 @@ export type SiopV2AuthorizationRequestData = {
|
|
|
149
150
|
clientIdScheme?: string
|
|
150
151
|
clientId?: string
|
|
151
152
|
entityId?: string
|
|
152
|
-
|
|
153
|
+
dcqlQuery: DcqlQuery
|
|
153
154
|
}
|
|
154
155
|
|
|
155
156
|
export type FirstPartyMachineNavigationArgs = {
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
CredentialConfigurationSupported,
|
|
8
8
|
CredentialOfferRequestWithBaseUrl,
|
|
9
9
|
CredentialResponse,
|
|
10
|
+
CredentialResponseV1_0_15,
|
|
10
11
|
CredentialsSupportedDisplay,
|
|
11
12
|
EndpointMetadataResult,
|
|
12
13
|
ExperimentalSubjectIssuance,
|
|
@@ -33,7 +34,7 @@ import {
|
|
|
33
34
|
Identity,
|
|
34
35
|
IIssuerLocaleBranding,
|
|
35
36
|
Party,
|
|
36
|
-
} from '@sphereon/ssi-sdk.data-store'
|
|
37
|
+
} from '@sphereon/ssi-sdk.data-store-types'
|
|
37
38
|
import { IIssuanceBranding } from '@sphereon/ssi-sdk.issuance-branding'
|
|
38
39
|
import { ImDLMdoc } from '@sphereon/ssi-sdk.mdl-mdoc'
|
|
39
40
|
import { ISDJwtPlugin } from '@sphereon/ssi-sdk.sd-jwt'
|
|
@@ -377,6 +378,7 @@ export enum OID4VCIMachineGuards {
|
|
|
377
378
|
requirePinGuard = 'oid4vciRequirePinGuard',
|
|
378
379
|
requireAuthorizationGuard = 'oid4vciRequireAuthorizationGuard',
|
|
379
380
|
noAuthorizationGuard = 'oid4vciNoAuthorizationGuard',
|
|
381
|
+
hasNonceEndpointGuard = 'oid4vciHasNonceEndpointGuard ',
|
|
380
382
|
hasAuthorizationResponse = 'oid4vciHasAuthorizationResponse',
|
|
381
383
|
hasNoContactIdentityGuard = 'oid4vciHasNoContactIdentityGuard',
|
|
382
384
|
verificationCodeGuard = 'oid4vciVerificationCodeGuard',
|
|
@@ -501,7 +503,7 @@ export type CredentialToAccept = {
|
|
|
501
503
|
id?: string
|
|
502
504
|
types: string[]
|
|
503
505
|
issuanceOpt: IssuanceOpts
|
|
504
|
-
credentialResponse: CredentialResponse
|
|
506
|
+
credentialResponse: CredentialResponseV1_0_15 | CredentialResponse
|
|
505
507
|
}
|
|
506
508
|
|
|
507
509
|
export type GetCredentialConfigsSupportedArgs = {
|