Skip to content

Commit

Permalink
chore: statuslist tweaks to allow status list selection through the c…
Browse files Browse the repository at this point in the history
…redential offer. Plus fixed for ?correlationId= & ?entityCorrelationId= in REST API
  • Loading branch information
sanderPostma committed Feb 4, 2025
1 parent 14e99ed commit a860bed
Show file tree
Hide file tree
Showing 22 changed files with 755 additions and 258 deletions.
8 changes: 4 additions & 4 deletions packages/ebsi-support/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
},
"dependencies": {
"@ethersproject/random": "^5.7.0",
"@sphereon/did-auth-siop": "0.16.1-next.339",
"@sphereon/did-auth-siop-adapter": "0.16.1-next.339",
"@sphereon/did-auth-siop": "0.16.1-feature.IATAB2B.52.345",
"@sphereon/did-auth-siop-adapter": "0.16.1-feature.IATAB2B.52.345",
"@sphereon/pex": "5.0.0-unstable.28",
"@sphereon/pex-models": "^2.3.2",
"@sphereon/ssi-sdk-ext.did-resolver-ebsi": "0.27.0",
Expand Down Expand Up @@ -44,8 +44,8 @@
"xstate": "^4.38.3"
},
"devDependencies": {
"@sphereon/oid4vci-client": "0.16.1-next.339",
"@sphereon/oid4vci-common": "0.16.1-next.339",
"@sphereon/oid4vci-client": "0.16.1-feature.IATAB2B.52.345",
"@sphereon/oid4vci-common": "0.16.1-feature.IATAB2B.52.345",
"@sphereon/ssi-express-support": "workspace:*",
"@sphereon/ssi-sdk-ext.key-manager": "0.27.0",
"@sphereon/ssi-sdk-ext.kms-local": "0.27.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/mdl-mdoc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"build:clean": "tsc --build --clean && tsc --build"
},
"dependencies": {
"@sphereon/did-auth-siop": "0.16.1-next.339",
"@sphereon/did-auth-siop": "0.16.1-feature.IATAB2B.52.345",
"@sphereon/kmp-mdoc-core": "0.2.0-SNAPSHOT.26",
"@sphereon/pex": "5.0.0-unstable.28",
"@sphereon/pex-models": "^2.3.2",
Expand All @@ -35,8 +35,8 @@
"uuid": "^9.0.1"
},
"devDependencies": {
"@sphereon/oid4vci-client": "0.16.1-next.339",
"@sphereon/oid4vci-common": "0.16.1-next.339",
"@sphereon/oid4vci-client": "0.16.1-feature.IATAB2B.52.345",
"@sphereon/oid4vci-common": "0.16.1-feature.IATAB2B.52.345",
"@sphereon/ssi-express-support": "workspace:*",
"@sphereon/ssi-sdk-ext.key-manager": "0.27.0",
"@sphereon/ssi-sdk-ext.kms-local": "0.27.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/oid4vci-holder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
},
"dependencies": {
"@sphereon/kmp-mdoc-core": "0.2.0-SNAPSHOT.26",
"@sphereon/did-auth-siop": "0.16.1-next.339",
"@sphereon/oid4vci-client": "0.16.1-next.339",
"@sphereon/oid4vci-common": "0.16.1-next.339",
"@sphereon/did-auth-siop": "0.16.1-feature.IATAB2B.52.345",
"@sphereon/oid4vci-client": "0.16.1-feature.IATAB2B.52.345",
"@sphereon/oid4vci-common": "0.16.1-feature.IATAB2B.52.345",
"@sphereon/ssi-sdk-ext.did-utils": "0.27.0",
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.27.0",
"@sphereon/ssi-sdk-ext.jwt-service": "0.27.0",
Expand Down Expand Up @@ -45,7 +45,7 @@
"xstate": "^4.38.3"
},
"devDependencies": {
"@sphereon/oid4vc-common": "0.16.1-next.339",
"@sphereon/oid4vc-common": "0.16.1-feature.IATAB2B.52.345",
"@sphereon/ssi-sdk.siopv2-oid4vp-common": "workspace:*",
"@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.27.0",
"@types/i18n-js": "^3.8.9",
Expand Down
6 changes: 3 additions & 3 deletions packages/oid4vci-issuer-rest-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"start:dev": "ts-node __tests__/RestAPI.ts"
},
"dependencies": {
"@sphereon/oid4vci-common": "0.16.1-next.339",
"@sphereon/oid4vci-issuer": "0.16.1-next.339",
"@sphereon/oid4vci-issuer-server": "0.16.1-next.339",
"@sphereon/oid4vci-common": "0.16.1-feature.IATAB2B.52.345",
"@sphereon/oid4vci-issuer": "0.16.1-feature.IATAB2B.52.345",
"@sphereon/oid4vci-issuer-server": "0.16.1-feature.IATAB2B.52.345",
"@sphereon/ssi-express-support": "workspace:*",
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.27.0",
"@sphereon/ssi-sdk-ext.jwt-service": "0.27.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/oid4vci-issuer-rest-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"generate-plugin-schema": "ts-node ../../packages/dev/bin/sphereon.js dev generate-plugin-schema"
},
"dependencies": {
"@sphereon/oid4vci-common": "0.16.1-next.339",
"@sphereon/oid4vci-common": "0.16.1-feature.IATAB2B.52.345",
"@sphereon/ssi-types": "workspace:*",
"@veramo/core": "4.2.0",
"cross-fetch": "^3.1.8"
Expand Down
2 changes: 1 addition & 1 deletion packages/oid4vci-issuer-store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"build:clean": "tsc --build --clean && tsc --build"
},
"dependencies": {
"@sphereon/oid4vci-common": "0.16.1-next.339",
"@sphereon/oid4vci-common": "0.16.1-feature.IATAB2B.52.345",
"@sphereon/ssi-sdk-ext.did-utils": "0.27.0",
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.27.0",
"@sphereon/ssi-sdk.kv-store-temp": "workspace:*",
Expand Down
6 changes: 3 additions & 3 deletions packages/oid4vci-issuer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"build:clean": "tsc --build --clean && tsc --build"
},
"dependencies": {
"@sphereon/oid4vci-common": "0.16.1-next.339",
"@sphereon/oid4vci-issuer": "0.16.1-next.339",
"@sphereon/oid4vci-common": "0.16.1-feature.IATAB2B.52.345",
"@sphereon/oid4vci-issuer": "0.16.1-feature.IATAB2B.52.345",
"@sphereon/ssi-sdk-ext.did-utils": "0.27.0",
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.27.0",
"@sphereon/ssi-sdk-ext.jwt-service": "0.27.0",
Expand All @@ -36,7 +36,7 @@
"uuid": "^9.0.1"
},
"devDependencies": {
"@sphereon/did-auth-siop": "0.16.1-next.339",
"@sphereon/did-auth-siop": "0.16.1-feature.IATAB2B.52.345",
"@sphereon/did-uni-client": "^0.6.3",
"@veramo/did-provider-key": "4.2.0",
"@veramo/did-resolver": "4.2.0",
Expand Down
26 changes: 15 additions & 11 deletions packages/oid4vci-issuer/src/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Jwt,
JwtVerifyResult,
OID4VCICredentialFormat,
StatusListOpts,
} from '@sphereon/oid4vci-common'
import { JWTHeader, JWTPayload } from '@sphereon/oid4vci-common/lib/types'
import { CredentialDataSupplier, CredentialIssuanceInput, CredentialSignerCallback, VcIssuer, VcIssuerBuilder } from '@sphereon/oid4vci-issuer'
Expand Down Expand Up @@ -182,8 +183,9 @@ export async function getCredentialSignerCallback(
credential: CredentialIssuanceInput
jwtVerifyResult: JwtVerifyResult<DIDDocument>
format?: OID4VCICredentialFormat
statusListOpts?: Array<StatusListOpts>
}): Promise<W3CVerifiableCredential | CompactSdJwtVc> {
const { jwtVerifyResult, format } = args
const { jwtVerifyResult, format, statusListOpts } = args
const credential = args.credential as ICredential // TODO: SDJWT
let proofFormat: ProofFormat

Expand All @@ -210,7 +212,7 @@ export async function getCredentialSignerCallback(
// TODO: We should extend the plugin capabilities of issuance so we do not have to tuck this into the sign callback
if (contextHasPlugin<IStatusListPlugin>(context, 'slAddStatusToCredential')) {
// Add status list if enabled (and when the input has a credentialStatus object (can be empty))
const credentialStatusVC = await context.agent.slAddStatusToCredential({ credential })
const credentialStatusVC = await context.agent.slAddStatusToCredential({ credential, statusListOpts })
if (credential.credentialStatus && !credential.credentialStatus.statusListCredential) {
credential.credentialStatus = credentialStatusVC.credentialStatus
}
Expand Down Expand Up @@ -244,16 +246,18 @@ export async function getCredentialSignerCallback(
}
}

if (contextHasPlugin<IStatusListPlugin>(context, 'slAddStatusToCredential') && sdJwtPayload.status && sdJwtPayload.status.status_list) {
// Add status list if enabled (and when the input has a credentialStatus object (can be empty))
const credentialStatusVC = await context.agent.slAddStatusToSdJwtCredential({ credential: sdJwtPayload })
if (sdJwtPayload.status?.status_list?.idx) {
if (!credentialStatusVC.status || !credentialStatusVC.status.status_list) {
// TODO check, looks like sdJwtPayload and credentialStatusVC is the same
return Promise.reject(Error('slAddStatusToSdJwtCredential did not return a status_list'))
if (contextHasPlugin<IStatusListPlugin>(context, 'slAddStatusToCredential')) {
if (sdJwtPayload.status && sdJwtPayload.status.status_list) {
// Add status list if enabled (and when the input has a credentialStatus object (can be empty))
const credentialStatusVC = await context.agent.slAddStatusToSdJwtCredential({ credential: sdJwtPayload, statusListOpts })
if (sdJwtPayload.status?.status_list?.idx) {
if (!credentialStatusVC.status || !credentialStatusVC.status.status_list) {
// TODO check, looks like sdJwtPayload and credentialStatusVC is the same
return Promise.reject(Error('slAddStatusToSdJwtCredential did not return a status_list'))
}

sdJwtPayload.status.status_list.idx = credentialStatusVC.status.status_list.idx
}

sdJwtPayload.status.status_list.idx = credentialStatusVC.status.status_list.idx
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/siopv2-oid4vp-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"access": "public"
},
"dependencies": {
"@sphereon/did-auth-siop": "0.16.1-next.339",
"@sphereon/did-auth-siop": "0.16.1-feature.IATAB2B.52.345",
"@sphereon/ssi-sdk.core": "workspace:*",
"@sphereon/ssi-types": "workspace:*",
"uint8arrays": "3.1.1"
Expand Down
6 changes: 3 additions & 3 deletions packages/siopv2-oid4vp-op-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"build:clean": "tsc --build --clean && tsc --build"
},
"dependencies": {
"@sphereon/did-auth-siop": "0.16.1-next.339",
"@sphereon/did-auth-siop-adapter": "0.16.1-next.339",
"@sphereon/oid4vc-common": "0.16.1-next.339",
"@sphereon/did-auth-siop": "0.16.1-feature.IATAB2B.52.345",
"@sphereon/did-auth-siop-adapter": "0.16.1-feature.IATAB2B.52.345",
"@sphereon/oid4vc-common": "0.16.1-feature.IATAB2B.52.345",
"@sphereon/pex": "5.0.0-unstable.28",
"@sphereon/pex-models": "^2.3.2",
"@sphereon/ssi-sdk-ext.did-utils": "0.27.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/siopv2-oid4vp-rp-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"build:clean": "tsc --build --clean && tsc --build"
},
"dependencies": {
"@sphereon/did-auth-siop": "0.16.1-next.339",
"@sphereon/did-auth-siop-adapter": "0.16.1-next.339",
"@sphereon/oid4vc-common": "0.16.1-next.339",
"@sphereon/did-auth-siop": "0.16.1-feature.IATAB2B.52.345",
"@sphereon/did-auth-siop-adapter": "0.16.1-feature.IATAB2B.52.345",
"@sphereon/oid4vc-common": "0.16.1-feature.IATAB2B.52.345",
"@sphereon/pex": "5.0.0-unstable.28",
"@sphereon/ssi-sdk-ext.did-utils": "0.27.0",
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.27.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/siopv2-oid4vp-rp-rest-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"start:dev": "ts-node __tests__/RestAPI.ts"
},
"dependencies": {
"@sphereon/did-auth-siop": "0.16.1-next.339",
"@sphereon/did-auth-siop": "0.16.1-feature.IATAB2B.52.345",
"@sphereon/ssi-express-support": "workspace:*",
"@sphereon/ssi-sdk.core": "workspace:*",
"@sphereon/ssi-sdk.credential-validation": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/ssi-types/src/types/w3c-vc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface ICredential {
expirationDate?: string
// If jti is present, the value MUST be used to set the value of the id property of the new JSON object.
id?: string
credentialStatus?: ICredentialStatus
credentialStatus?: ICredentialStatus // | Array<ICredentialStatus> TODO this is only true for VC v2.0 CREATE TICKET BEFORE PR
description?: string
name?: string

Expand Down
25 changes: 16 additions & 9 deletions packages/vc-status-list-issuer-rest-api/src/api-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const buildStatusListId = (request: Request): string => {

const forwardedPrefix = request.headers['x-forwarded-prefix']?.toString() ?? ''

return `${protocol}://${host}${forwardedPrefix}${request.originalUrl.replace(/\/status\/index\/.*/, '')}`
return `${protocol}://${host}${forwardedPrefix}${request.originalUrl.split('?')[0].replace(/\/status\/index\/.*/, '')}`
}

export function getStatusListCredentialEndpoint(router: Router, context: IRequiredContext, opts: ICredentialStatusListEndpointOpts) {
Expand All @@ -80,8 +80,12 @@ export function getStatusListCredentialEndpoint(router: Router, context: IRequir
router.get(path, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {
try {
//todo: Check index against correlationId first. Then match originalUrl against statusList id
const correlationId = request.query.correlationId?.toString() ?? request.params.index?.toString() ?? request.originalUrl
const driver = await getDriver({ id: buildStatusListId(request), correlationId, dbName: opts.dbName })
//const correlationId = request.query.correlationId?.toString() ?? request.params.index?.toString() ?? request.originalUrl TODO I so not get these
const correlationId = request.query.correlationId?.toString()
const driver = await getDriver({
...(correlationId ? { correlationId } : { id: buildStatusListId(request) }),
dbName: opts.dbName,
})
const details = await driver.getStatusList()
const statuslistPayload = details.statusListCredential
return sendStatuslistResponse(details, statuslistPayload, response)
Expand Down Expand Up @@ -110,21 +114,21 @@ export function getStatusListCredentialIndexStatusEndpoint(router: Router, conte
if (!statusListIndex || statusListIndex < 0) {
return sendErrorResponse(response, 400, `Please provide a proper statusListIndex`)
}
const correlationId = request.query.correlationId?.toString() ?? request.params.index?.toString() ?? request.originalUrl
//const correlationId = request.query.correlationId?.toString() ?? request.params.index?.toString() ?? request.originalUrl TODO I so not get these
const correlationId = request.query.correlationId?.toString()
const driver = await getDriver({
id: buildStatusListId(request),
correlationId,
...(correlationId ? { correlationId } : { id: buildStatusListId(request) }),
dbName: opts.dbName,
})
const details = await driver.getStatusList()
if (statusListIndex > details.length) {
return sendErrorResponse(response, 400, `Please provide a proper statusListIndex`)
}

const entityCorrelationId = request.query.entityCorrelationId?.toString()
let entry = await driver.getStatusListEntryByIndex({
statusListIndex,
statusListId: details.id,
correlationId: details.correlationId,
...(entityCorrelationId ? { correlationId: entityCorrelationId } : { statusListId: details.id }),
errorOnNotFound: false,
})
const type = details.type === StatusListType.StatusList2021 ? 'StatusList2021Entry' : details.type
Expand Down Expand Up @@ -170,7 +174,10 @@ export function updateStatusEndpoint(router: Router, context: IRequiredContext,
} else if (!updateRequest.credentialStatus || updateRequest.credentialStatus.length === 0) {
return sendErrorResponse(response, 400, 'No statusList updates supplied')
}
const driver = await getDriver({ id: statusListId, correlationId: statusListCorrelationId, dbName: opts.dbName })
const driver = await getDriver({
...(statusListCorrelationId ? { correlationId: statusListCorrelationId } : { id: buildStatusListId(request) }),
dbName: opts.dbName,
})

// Get status list entry based on request type
let statusListEntry: IStatusListEntryEntity | undefined
Expand Down
Loading

0 comments on commit a860bed

Please sign in to comment.