Skip to content

Commit 4b35515

Browse files
authored
Merge pull request #211 from Sphereon-Opensource/feature/SSISDK-78_code_auth_flow
feature/SSISDK-78_code_auth_flow
2 parents 7fe1eeb + 374885d commit 4b35515

13 files changed

Lines changed: 1360 additions & 1346 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"pnpm": ">=10"
2727
},
2828
"resolutions": {
29-
"@sphereon/ssi-types": "0.34.1-feature.DIIPv4.245",
29+
"@sphereon/ssi-types": "0.34.1-feature.SSISDK.78.280",
3030
"dcql": "1.0.1",
3131
"node-fetch": "2.6.12",
3232
"typescript": "5.8.3"

packages/callback-example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"@sphereon/oid4vci-client": "workspace:^",
3131
"@sphereon/oid4vci-common": "workspace:^",
3232
"@sphereon/oid4vci-issuer": "workspace:^",
33-
"@sphereon/ssi-types": "0.34.1-feature.DIIPv4.245",
33+
"@sphereon/ssi-types": "0.34.1-feature.SSISDK.78.280",
3434
"jose": "^4.10.0"
3535
},
3636
"devDependencies": {

packages/client/lib/AuthorizationCodeClient.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,21 @@ export const createAuthorizationRequestUrl = async ({
109109
clientId?: string
110110
version?: OpenId4VCIVersion
111111
}): Promise<string> => {
112-
function removeDisplayAndValueTypes(obj: any) {
112+
113+
function removeDisplayAndValueTypes(obj: any): any {
114+
if (Array.isArray(obj)) {
115+
return obj.map(item => removeDisplayAndValueTypes(item))
116+
}
117+
118+
if (typeof obj !== 'object' || obj === null) {
119+
return obj
120+
}
121+
113122
const newObj = { ...obj }
114123
for (const prop in newObj) {
115124
if (['display', 'value_type'].includes(prop)) {
116125
delete newObj[prop]
117-
} else if (typeof newObj[prop] === 'object') {
126+
} else if (typeof newObj[prop] === 'object' && newObj[prop] !== null) {
118127
newObj[prop] = removeDisplayAndValueTypes(newObj[prop])
119128
}
120129
}
@@ -215,7 +224,7 @@ export const createAuthorizationRequestUrl = async ({
215224
...(credentialOffer?.issuerState && {
216225
issuer_state: credentialOffer.issuerState
217226
}),
218-
scope: authorizationRequest.scope
227+
scope: authorizationRequest.scope ?? 'openid'
219228
}
220229

221230
if (credentialOffer?.issuerState) {
@@ -228,12 +237,11 @@ export const createAuthorizationRequestUrl = async ({
228237
} else if (parEndpoint && parMode !== PARMode.NEVER) {
229238
logger.debug(`USING PAR with endpoint ${parEndpoint}`)
230239

231-
const parResponse = await formPost<PushedAuthorizationResponse>(
232-
parEndpoint,
233-
convertJsonToURI(queryObj, {
234-
mode: JsonURIMode.X_FORM_WWW_URLENCODED,
235-
uriTypeProperties: ['client_id', 'request_uri', 'redirect_uri', 'scope', 'authorization_details', 'issuer_state', 'state']
236-
}),
240+
const parBody = convertJsonToURI(queryObj, {
241+
mode: JsonURIMode.X_FORM_WWW_URLENCODED,
242+
uriTypeProperties: ['client_id', 'request_uri', 'redirect_uri', 'scope', 'authorization_details', 'issuer_state', 'state']
243+
})
244+
const parResponse = await formPost<PushedAuthorizationResponse>(parEndpoint, parBody,
237245
{ contentType: 'application/x-www-form-urlencoded', accept: 'application/json' }
238246
)
239247
if (parResponse.errorBody || !parResponse.successBody) {
@@ -322,6 +330,10 @@ const handleLocations = (
322330
} else {
323331
authorizationDetails.locations = [endpointMetadata.issuer]
324332
}
333+
334+
if (Array.isArray(authorizationDetails.locations)) {
335+
authorizationDetails.locations = [...new Set(authorizationDetails.locations)]
336+
}
325337
}
326338
return authorizationDetails
327339
}

packages/client/lib/CredentialRequestClient.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,12 @@ export class CredentialRequestClient {
259259
}
260260
response.access_token = requestToken
261261

262-
if ((uniformRequest.credential_subject_issuance && response.successBody) || response.successBody?.credential_subject_issuance) {
262+
/* TODO SSISDK-85
263+
if ((uniformRequest.credential_subject_issuance && response.successBody) || response.successBody?.credential_subject_issuance) {
263264
if (JSON.stringify(uniformRequest.credential_subject_issuance) !== JSON.stringify(response.successBody?.credential_subject_issuance)) {
264265
throw Error('Subject signing was requested, but issuer did not provide the options in its response')
265266
}
266-
}
267+
}*/
267268
logger.debug(`Credential endpoint ${credentialEndpoint} response:\r\n${JSON.stringify(response, null, 2)}`)
268269

269270
return {

packages/client/lib/__tests__/OpenID4VCIClient.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ describe('OpenID4VCIClient should', () => {
129129
},
130130
}),
131131
).resolves.toEqual(
132-
'https://server.example.com/v1/auth/authorize?response_type=code&code_challenge_method=S256&code_challenge=mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs&authorization_details=%5B%7B%22type%22%3A%22openid_credential%22%2C%22format%22%3A%22ldp_vc%22%2C%22credential_definition%22%3A%7B%22%40context%22%3A%5B%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fv1%22%2C%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fexamples%2Fv1%22%5D%2C%22types%22%3A%5B%22VerifiableCredential%22%2C%22UniversityDegreeCredential%22%5D%7D%2C%22locations%22%3A%5B%22https%3A%2F%2Fserver%2Eexample%2Ecom%22%5D%7D%2C%7B%22type%22%3A%22openid_credential%22%2C%22format%22%3A%22mso_mdoc%22%2C%22doctype%22%3A%22org%2Eiso%2E18013%2E5%2E1%2EmDL%22%2C%22locations%22%3A%5B%22https%3A%2F%2Fserver%2Eexample%2Ecom%22%5D%7D%5D&redirect_uri=http%3A%2F%2Flocalhost%3A8881%2Fcb&client_id=test-client',
132+
'https://server.example.com/v1/auth/authorize?response_type=code&code_challenge_method=S256&code_challenge=mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs&authorization_details=%5B%7B%22type%22%3A%22openid_credential%22%2C%22format%22%3A%22ldp_vc%22%2C%22credential_definition%22%3A%7B%22%40context%22%3A%5B%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fv1%22%2C%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fexamples%2Fv1%22%5D%2C%22types%22%3A%5B%22VerifiableCredential%22%2C%22UniversityDegreeCredential%22%5D%7D%2C%22locations%22%3A%5B%22https%3A%2F%2Fserver%2Eexample%2Ecom%22%5D%7D%2C%7B%22type%22%3A%22openid_credential%22%2C%22format%22%3A%22mso_mdoc%22%2C%22doctype%22%3A%22org%2Eiso%2E18013%2E5%2E1%2EmDL%22%2C%22locations%22%3A%5B%22https%3A%2F%2Fserver%2Eexample%2Ecom%22%5D%7D%5D&redirect_uri=http%3A%2F%2Flocalhost%3A8881%2Fcb&client_id=test-client&scope=openid',
133133
)
134134
})
135135
it('create an authorization request url with authorization_details object property', async () => {
@@ -156,7 +156,7 @@ describe('OpenID4VCIClient should', () => {
156156
},
157157
}),
158158
).resolves.toEqual(
159-
'https://server.example.com/v1/auth/authorize?response_type=code&code_challenge_method=S256&code_challenge=mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs&authorization_details=%7B%22type%22%3A%22openid_credential%22%2C%22format%22%3A%22ldp_vc%22%2C%22credential_definition%22%3A%7B%22%40context%22%3A%5B%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fv1%22%2C%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fexamples%2Fv1%22%5D%2C%22types%22%3A%5B%22VerifiableCredential%22%2C%22UniversityDegreeCredential%22%5D%7D%2C%22locations%22%3A%5B%22https%3A%2F%2Fserver%2Eexample%2Ecom%22%5D%7D&redirect_uri=http%3A%2F%2Flocalhost%3A8881%2Fcb&client_id=test-client',
159+
'https://server.example.com/v1/auth/authorize?response_type=code&code_challenge_method=S256&code_challenge=mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs&authorization_details=%7B%22type%22%3A%22openid_credential%22%2C%22format%22%3A%22ldp_vc%22%2C%22credential_definition%22%3A%7B%22%40context%22%3A%5B%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fv1%22%2C%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fexamples%2Fv1%22%5D%2C%22types%22%3A%5B%22VerifiableCredential%22%2C%22UniversityDegreeCredential%22%5D%7D%2C%22locations%22%3A%5B%22https%3A%2F%2Fserver%2Eexample%2Ecom%22%5D%7D&redirect_uri=http%3A%2F%2Flocalhost%3A8881%2Fcb&client_id=test-client&scope=openid',
160160
)
161161
})
162162

packages/client/lib/__tests__/OpenID4VCIClientV1_0_15.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ describe('OpenID4VCIClientV1_0_15 should', () => {
121121
},
122122
}),
123123
).resolves.toEqual(
124-
'https://server.example.com/v1/auth/authorize?response_type=code&code_challenge_method=S256&code_challenge=mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs&authorization_details=%5B%7B%22type%22%3A%22openid_credential%22%2C%22format%22%3A%22ldp_vc%22%2C%22credential_definition%22%3A%7B%22%40context%22%3A%5B%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fv1%22%2C%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fexamples%2Fv1%22%5D%2C%22types%22%3A%5B%22VerifiableCredential%22%2C%22UniversityDegreeCredential%22%5D%7D%2C%22locations%22%3A%5B%22https%3A%2F%2Fserver%2Eexample%2Ecom%22%5D%7D%2C%7B%22type%22%3A%22openid_credential%22%2C%22format%22%3A%22mso_mdoc%22%2C%22doctype%22%3A%22org%2Eiso%2E18013%2E5%2E1%2EmDL%22%2C%22locations%22%3A%5B%22https%3A%2F%2Fserver%2Eexample%2Ecom%22%5D%7D%5D&redirect_uri=http%3A%2F%2Flocalhost%3A8881%2Fcb&client_id=test-client',
124+
'https://server.example.com/v1/auth/authorize?response_type=code&code_challenge_method=S256&code_challenge=mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs&authorization_details=%5B%7B%22type%22%3A%22openid_credential%22%2C%22format%22%3A%22ldp_vc%22%2C%22credential_definition%22%3A%7B%22%40context%22%3A%5B%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fv1%22%2C%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fexamples%2Fv1%22%5D%2C%22types%22%3A%5B%22VerifiableCredential%22%2C%22UniversityDegreeCredential%22%5D%7D%2C%22locations%22%3A%5B%22https%3A%2F%2Fserver%2Eexample%2Ecom%22%5D%7D%2C%7B%22type%22%3A%22openid_credential%22%2C%22format%22%3A%22mso_mdoc%22%2C%22doctype%22%3A%22org%2Eiso%2E18013%2E5%2E1%2EmDL%22%2C%22locations%22%3A%5B%22https%3A%2F%2Fserver%2Eexample%2Ecom%22%5D%7D%5D&redirect_uri=http%3A%2F%2Flocalhost%3A8881%2Fcb&client_id=test-client&scope=openid',
125125
)
126126
})
127127
it('create an authorization request url with authorization_details object property', async () => {
@@ -148,7 +148,7 @@ describe('OpenID4VCIClientV1_0_15 should', () => {
148148
},
149149
}),
150150
).resolves.toEqual(
151-
'https://server.example.com/v1/auth/authorize?response_type=code&code_challenge_method=S256&code_challenge=mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs&authorization_details=%7B%22type%22%3A%22openid_credential%22%2C%22format%22%3A%22ldp_vc%22%2C%22credential_definition%22%3A%7B%22%40context%22%3A%5B%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fv1%22%2C%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fexamples%2Fv1%22%5D%2C%22types%22%3A%5B%22VerifiableCredential%22%2C%22UniversityDegreeCredential%22%5D%7D%2C%22locations%22%3A%5B%22https%3A%2F%2Fserver%2Eexample%2Ecom%22%5D%7D&redirect_uri=http%3A%2F%2Flocalhost%3A8881%2Fcb&client_id=test-client',
151+
'https://server.example.com/v1/auth/authorize?response_type=code&code_challenge_method=S256&code_challenge=mE2kPHmIprOqtkaYmESWj35yz-PB5vzdiSu0tAZ8sqs&authorization_details=%7B%22type%22%3A%22openid_credential%22%2C%22format%22%3A%22ldp_vc%22%2C%22credential_definition%22%3A%7B%22%40context%22%3A%5B%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fv1%22%2C%22https%3A%2F%2Fwww%2Ew3%2Eorg%2F2018%2Fcredentials%2Fexamples%2Fv1%22%5D%2C%22types%22%3A%5B%22VerifiableCredential%22%2C%22UniversityDegreeCredential%22%5D%7D%2C%22locations%22%3A%5B%22https%3A%2F%2Fserver%2Eexample%2Ecom%22%5D%7D&redirect_uri=http%3A%2F%2Flocalhost%3A8881%2Fcb&client_id=test-client&scope=openid',
152152
)
153153
})
154154

packages/client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"dependencies": {
3030
"@sphereon/oid4vc-common": "workspace:^",
3131
"@sphereon/oid4vci-common": "workspace:^",
32-
"@sphereon/ssi-types": "0.34.1-feature.DIIPv4.245",
32+
"@sphereon/ssi-types": "0.34.1-feature.SSISDK.78.280",
3333
"cross-fetch": "^4.1.0",
3434
"debug": "^4.4.0"
3535
},

packages/common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"test": "vitest run --config ../../vitest.config.mts --coverage"
2323
},
2424
"dependencies": {
25-
"@sphereon/ssi-types": "0.34.1-feature.DIIPv4.245",
25+
"@sphereon/ssi-types": "0.34.1-feature.SSISDK.78.280",
2626
"jwt-decode": "^4.0.0",
2727
"uint8arrays": "^3.1.1",
2828
"uuid": "^9.0.0"

packages/issuer-rest/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"@sphereon/oid4vci-common": "workspace:^",
2727
"@sphereon/oid4vci-issuer": "workspace:^",
2828
"@sphereon/ssi-express-support": "0.34.1-next.3",
29-
"@sphereon/ssi-types": "0.34.1-feature.DIIPv4.245",
29+
"@sphereon/ssi-types": "0.34.1-feature.SSISDK.78.280",
3030
"body-parser": "^1.20.2",
3131
"cookie-parser": "^1.4.6",
3232
"cors": "^2.8.5",

packages/issuer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"@sphereon/oid4vc-common": "workspace:^",
2525
"@sphereon/oid4vci-common": "workspace:^",
2626
"@sphereon/ssi-express-support": "0.34.1-next.3",
27-
"@sphereon/ssi-types": "0.34.1-feature.DIIPv4.245",
27+
"@sphereon/ssi-types": "0.34.1-feature.SSISDK.78.280",
2828
"short-uuid": "^4.2.2",
2929
"uuid": "^9.0.0"
3030
},

0 commit comments

Comments
 (0)