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