@sphereon/ssi-sdk.siopv2-oid4vp-op-auth 0.34.1-feature.SSISDK.44.finish.dcql.314 → 0.34.1-feature.SSISDK.44.finish.dcql.317
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 +31 -56
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +32 -57
- package/dist/index.js.map +1 -1
- package/package.json +19 -19
- package/src/session/OID4VP.ts +39 -74
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.siopv2-oid4vp-op-auth",
|
|
3
|
-
"version": "0.34.1-feature.SSISDK.44.finish.dcql.
|
|
3
|
+
"version": "0.34.1-feature.SSISDK.44.finish.dcql.317+652e05fc",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -31,21 +31,21 @@
|
|
|
31
31
|
"@sphereon/oid4vc-common": "0.19.1-next.220",
|
|
32
32
|
"@sphereon/pex": "5.0.0-unstable.28",
|
|
33
33
|
"@sphereon/pex-models": "^2.3.2",
|
|
34
|
-
"@sphereon/ssi-sdk-ext.did-utils": "0.34.1-feature.SSISDK.44.finish.dcql.
|
|
35
|
-
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.34.1-feature.SSISDK.44.finish.dcql.
|
|
36
|
-
"@sphereon/ssi-sdk-ext.jwt-service": "0.34.1-feature.SSISDK.44.finish.dcql.
|
|
37
|
-
"@sphereon/ssi-sdk.contact-manager": "0.34.1-feature.SSISDK.44.finish.dcql.
|
|
38
|
-
"@sphereon/ssi-sdk.core": "0.34.1-feature.SSISDK.44.finish.dcql.
|
|
39
|
-
"@sphereon/ssi-sdk.credential-store": "0.34.1-feature.SSISDK.44.finish.dcql.
|
|
40
|
-
"@sphereon/ssi-sdk.credential-validation": "0.34.1-feature.SSISDK.44.finish.dcql.
|
|
41
|
-
"@sphereon/ssi-sdk.data-store-types": "0.34.1-feature.SSISDK.44.finish.dcql.
|
|
42
|
-
"@sphereon/ssi-sdk.issuance-branding": "0.34.1-feature.SSISDK.44.finish.dcql.
|
|
43
|
-
"@sphereon/ssi-sdk.pd-manager": "0.34.1-feature.SSISDK.44.finish.dcql.
|
|
44
|
-
"@sphereon/ssi-sdk.presentation-exchange": "0.34.1-feature.SSISDK.44.finish.dcql.
|
|
45
|
-
"@sphereon/ssi-sdk.sd-jwt": "0.34.1-feature.SSISDK.44.finish.dcql.
|
|
46
|
-
"@sphereon/ssi-sdk.siopv2-oid4vp-common": "0.34.1-feature.SSISDK.44.finish.dcql.
|
|
47
|
-
"@sphereon/ssi-sdk.xstate-machine-persistence": "0.34.1-feature.SSISDK.44.finish.dcql.
|
|
48
|
-
"@sphereon/ssi-types": "0.34.1-feature.SSISDK.44.finish.dcql.
|
|
34
|
+
"@sphereon/ssi-sdk-ext.did-utils": "0.34.1-feature.SSISDK.44.finish.dcql.317+652e05fc",
|
|
35
|
+
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.34.1-feature.SSISDK.44.finish.dcql.317+652e05fc",
|
|
36
|
+
"@sphereon/ssi-sdk-ext.jwt-service": "0.34.1-feature.SSISDK.44.finish.dcql.317+652e05fc",
|
|
37
|
+
"@sphereon/ssi-sdk.contact-manager": "0.34.1-feature.SSISDK.44.finish.dcql.317+652e05fc",
|
|
38
|
+
"@sphereon/ssi-sdk.core": "0.34.1-feature.SSISDK.44.finish.dcql.317+652e05fc",
|
|
39
|
+
"@sphereon/ssi-sdk.credential-store": "0.34.1-feature.SSISDK.44.finish.dcql.317+652e05fc",
|
|
40
|
+
"@sphereon/ssi-sdk.credential-validation": "0.34.1-feature.SSISDK.44.finish.dcql.317+652e05fc",
|
|
41
|
+
"@sphereon/ssi-sdk.data-store-types": "0.34.1-feature.SSISDK.44.finish.dcql.317+652e05fc",
|
|
42
|
+
"@sphereon/ssi-sdk.issuance-branding": "0.34.1-feature.SSISDK.44.finish.dcql.317+652e05fc",
|
|
43
|
+
"@sphereon/ssi-sdk.pd-manager": "0.34.1-feature.SSISDK.44.finish.dcql.317+652e05fc",
|
|
44
|
+
"@sphereon/ssi-sdk.presentation-exchange": "0.34.1-feature.SSISDK.44.finish.dcql.317+652e05fc",
|
|
45
|
+
"@sphereon/ssi-sdk.sd-jwt": "0.34.1-feature.SSISDK.44.finish.dcql.317+652e05fc",
|
|
46
|
+
"@sphereon/ssi-sdk.siopv2-oid4vp-common": "0.34.1-feature.SSISDK.44.finish.dcql.317+652e05fc",
|
|
47
|
+
"@sphereon/ssi-sdk.xstate-machine-persistence": "0.34.1-feature.SSISDK.44.finish.dcql.317+652e05fc",
|
|
48
|
+
"@sphereon/ssi-types": "0.34.1-feature.SSISDK.44.finish.dcql.317+652e05fc",
|
|
49
49
|
"@sphereon/wellknown-dids-client": "^0.1.3",
|
|
50
50
|
"@veramo/core": "4.2.0",
|
|
51
51
|
"@veramo/credential-w3c": "4.2.0",
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@sphereon/did-uni-client": "^0.6.3",
|
|
62
|
-
"@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.34.1-feature.SSISDK.44.finish.dcql.
|
|
63
|
-
"@sphereon/ssi-sdk.agent-config": "0.34.1-feature.SSISDK.44.finish.dcql.
|
|
62
|
+
"@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.34.1-feature.SSISDK.44.finish.dcql.317+652e05fc",
|
|
63
|
+
"@sphereon/ssi-sdk.agent-config": "0.34.1-feature.SSISDK.44.finish.dcql.317+652e05fc",
|
|
64
64
|
"@types/i18n-js": "^3.8.9",
|
|
65
65
|
"@types/lodash.memoize": "^4.1.9",
|
|
66
66
|
"@types/sha.js": "^2.4.4",
|
|
@@ -102,5 +102,5 @@
|
|
|
102
102
|
"OpenID Connect",
|
|
103
103
|
"Authenticator"
|
|
104
104
|
],
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "652e05fcd2cf9e149125ada93fa20719258efc67"
|
|
106
106
|
}
|
package/src/session/OID4VP.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { UniqueDigitalCredential } from '@sphereon/ssi-sdk.credential-store'
|
|
|
5
5
|
import { defaultGenerateDigest } from '@sphereon/ssi-sdk.sd-jwt'
|
|
6
6
|
import {
|
|
7
7
|
CredentialMapper,
|
|
8
|
+
DocumentFormat,
|
|
8
9
|
HasherSync,
|
|
9
10
|
Loggers,
|
|
10
11
|
OriginalVerifiableCredential,
|
|
@@ -52,39 +53,6 @@ function extractOriginalCredential(
|
|
|
52
53
|
return credential as OriginalVerifiableCredential
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
/**
|
|
56
|
-
* Determines the format of a credential
|
|
57
|
-
*/
|
|
58
|
-
function detectCredentialFormat(credential: OriginalVerifiableCredential): string {
|
|
59
|
-
if (typeof credential === 'string') {
|
|
60
|
-
// Could be JWT or SD-JWT
|
|
61
|
-
if (credential.includes('~')) {
|
|
62
|
-
return 'dc+sd-jwt'
|
|
63
|
-
}
|
|
64
|
-
// Check if it's a compact JWT format (3 parts)
|
|
65
|
-
const parts = credential.split('.')
|
|
66
|
-
if (parts.length === 3) {
|
|
67
|
-
return 'jwt_vc_json'
|
|
68
|
-
}
|
|
69
|
-
} else if (typeof credential === 'object') {
|
|
70
|
-
// Check for SD-JWT decoded format
|
|
71
|
-
if ('compactSdJwtVc' in credential) {
|
|
72
|
-
return 'dc+sd-jwt'
|
|
73
|
-
}
|
|
74
|
-
// Check for JSON-LD
|
|
75
|
-
if ('@context' in credential || 'proof' in credential) {
|
|
76
|
-
return 'ldp_vc'
|
|
77
|
-
}
|
|
78
|
-
// Check for mdoc
|
|
79
|
-
if ('doctype' in credential || 'namespaces' in credential) {
|
|
80
|
-
return 'mso_mdoc'
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Default to JWT
|
|
85
|
-
return 'jwt_vc_json'
|
|
86
|
-
}
|
|
87
|
-
|
|
88
56
|
/**
|
|
89
57
|
* Gets the issuer/holder identifier from ManagedIdentifierOptsOrResult
|
|
90
58
|
*/
|
|
@@ -113,12 +81,12 @@ export async function createVerifiablePresentationForFormat(
|
|
|
113
81
|
const { nonce, audience, agent, clockSkew = CLOCK_SKEW } = context
|
|
114
82
|
|
|
115
83
|
const originalCredential = extractOriginalCredential(credential)
|
|
116
|
-
const
|
|
84
|
+
const documentFormat = CredentialMapper.detectDocumentType(originalCredential)
|
|
117
85
|
|
|
118
|
-
logger.debug(`Creating VP for format: ${
|
|
86
|
+
logger.debug(`Creating VP for format: ${documentFormat}`)
|
|
119
87
|
|
|
120
|
-
switch (
|
|
121
|
-
case
|
|
88
|
+
switch (documentFormat) {
|
|
89
|
+
case DocumentFormat.SD_JWT_VC: {
|
|
122
90
|
// SD-JWT with KB-JWT
|
|
123
91
|
const decodedSdJwt = await CredentialMapper.decodeSdJwtVcAsync(
|
|
124
92
|
typeof originalCredential === 'string' ? originalCredential : (originalCredential as SdJwtDecodedVerifiableCredential).compactSdJwtVc,
|
|
@@ -145,40 +113,7 @@ export async function createVerifiablePresentationForFormat(
|
|
|
145
113
|
return presentationResult.presentation
|
|
146
114
|
}
|
|
147
115
|
|
|
148
|
-
case
|
|
149
|
-
// JWT VC - create JWT VP with nonce and aud in payload
|
|
150
|
-
const vcJwt = typeof originalCredential === 'string' ? originalCredential : JSON.stringify(originalCredential)
|
|
151
|
-
|
|
152
|
-
const identifierString = getIdentifierString(identifier)
|
|
153
|
-
|
|
154
|
-
// Create VP JWT using agent method
|
|
155
|
-
const vpPayload = {
|
|
156
|
-
iss: identifierString,
|
|
157
|
-
aud: audience, // Client Identifier or Origin
|
|
158
|
-
nonce, // Authorization Request nonce
|
|
159
|
-
vp: {
|
|
160
|
-
'@context': ['https://www.w3.org/2018/credentials/v1'],
|
|
161
|
-
type: ['VerifiablePresentation'],
|
|
162
|
-
holder: identifierString,
|
|
163
|
-
verifiableCredential: [vcJwt],
|
|
164
|
-
},
|
|
165
|
-
iat: Math.floor(Date.now() / 1000 - clockSkew),
|
|
166
|
-
exp: Math.floor(Date.now() / 1000 + 600), // 10 minutes
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// Use the agent's JWT creation capability
|
|
170
|
-
const vpJwt = await agent.createVerifiablePresentation({
|
|
171
|
-
presentation: vpPayload.vp,
|
|
172
|
-
proofFormat: 'jwt',
|
|
173
|
-
domain: audience,
|
|
174
|
-
challenge: nonce,
|
|
175
|
-
keyRef: identifier.kmsKeyRef || identifier.kid,
|
|
176
|
-
})
|
|
177
|
-
|
|
178
|
-
return vpJwt.proof?.jwt || vpJwt
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
case 'ldp_vc': {
|
|
116
|
+
case DocumentFormat.JSONLD: {
|
|
182
117
|
// JSON-LD VC - create JSON-LD VP with challenge and domain in proof
|
|
183
118
|
const vcObject = typeof originalCredential === 'string' ? JSON.parse(originalCredential) : originalCredential
|
|
184
119
|
|
|
@@ -198,7 +133,7 @@ export async function createVerifiablePresentationForFormat(
|
|
|
198
133
|
})
|
|
199
134
|
}
|
|
200
135
|
|
|
201
|
-
case
|
|
136
|
+
case DocumentFormat.MSO_MDOC: {
|
|
202
137
|
// ISO mdoc - create mdoc VP token
|
|
203
138
|
// This is a placeholder implementation
|
|
204
139
|
// Full implementation would require:
|
|
@@ -210,7 +145,37 @@ export async function createVerifiablePresentationForFormat(
|
|
|
210
145
|
return originalCredential
|
|
211
146
|
}
|
|
212
147
|
|
|
213
|
-
default:
|
|
214
|
-
|
|
148
|
+
default: {
|
|
149
|
+
// JWT VC - create JWT VP with nonce and aud in payload
|
|
150
|
+
const vcJwt = typeof originalCredential === 'string' ? originalCredential : JSON.stringify(originalCredential)
|
|
151
|
+
|
|
152
|
+
const identifierString = getIdentifierString(identifier)
|
|
153
|
+
|
|
154
|
+
// Create VP JWT using agent method
|
|
155
|
+
const vpPayload = {
|
|
156
|
+
iss: identifierString,
|
|
157
|
+
aud: audience, // Client Identifier or Origin
|
|
158
|
+
nonce, // Authorization Request nonce
|
|
159
|
+
vp: {
|
|
160
|
+
'@context': ['https://www.w3.org/2018/credentials/v1'],
|
|
161
|
+
type: ['VerifiablePresentation'],
|
|
162
|
+
holder: identifierString,
|
|
163
|
+
verifiableCredential: [vcJwt],
|
|
164
|
+
},
|
|
165
|
+
iat: Math.floor(Date.now() / 1000 - clockSkew),
|
|
166
|
+
exp: Math.floor(Date.now() / 1000 + 600 + clockSkew), // 10 minutes
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Use the agent's JWT creation capability
|
|
170
|
+
const vpJwt = await agent.createVerifiablePresentation({
|
|
171
|
+
presentation: vpPayload.vp,
|
|
172
|
+
proofFormat: 'jwt',
|
|
173
|
+
domain: audience,
|
|
174
|
+
challenge: nonce,
|
|
175
|
+
keyRef: identifier.kmsKeyRef || identifier.kid,
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
return vpJwt.proof?.jwt || vpJwt
|
|
179
|
+
}
|
|
215
180
|
}
|
|
216
181
|
}
|