Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not force isW3cCredential for non-sd-jwt credentials #253

Open
wants to merge 1 commit into
base: feature/SPRIND-61_JARM_pex_fixes
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions packages/oid4vci-issuer/src/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,32 @@ export async function getCredentialSignerCallback(
proofFormat = format?.includes('ld') ? 'lds' : 'jwt'
const issuer = resolution.issuer ?? resolution.kmsKeyRef

if (CredentialMapper.isW3cCredential(credential)) {
if (CredentialMapper.isSdJwtDecodedCredentialPayload(credential)) {
const sdJwtPayload = credential as SdJwtVcPayload
if (sdJwtPayload.iss === undefined) {
sdJwtPayload.iss = issuer
}
if (sdJwtPayload.iat === undefined) {
sdJwtPayload.iat = Math.floor(new Date().getTime() / 1000)
}

let disclosureFrame
if ('disclosureFrame' in credential) {
disclosureFrame = credential['disclosureFrame']
delete credential['disclosureFrame']
} else {
disclosureFrame = {
_sd: credential['_sd'],
}
}
const result = await context.agent.createSdJwtVc({
credentialPayload: sdJwtPayload,
disclosureFrame: disclosureFrame,
})
return result.credential
} /*else if (CredentialMapper.isMsoMdocDecodedCredential(credential)) {
TODO
}*/ else {
if (!credential.issuer) {
credential.issuer = { id: issuer }
} else if (typeof credential.issuer === 'object' && !credential.issuer.id) {
Expand Down Expand Up @@ -179,32 +204,7 @@ export async function getCredentialSignerCallback(
domain: typeof credential.issuer === 'object' ? credential.issuer.id : credential.issuer,
})
return (proofFormat === 'jwt' && 'jwt' in result.proof ? result.proof.jwt : result) as W3CVerifiableCredential
} else if (CredentialMapper.isSdJwtDecodedCredentialPayload(credential)) {
const sdJwtPayload = credential as SdJwtVcPayload
if (sdJwtPayload.iss === undefined) {
sdJwtPayload.iss = issuer
}
if (sdJwtPayload.iat === undefined) {
sdJwtPayload.iat = Math.floor(new Date().getTime() / 1000)
}

let disclosureFrame
if ('disclosureFrame' in credential) {
disclosureFrame = credential['disclosureFrame']
delete credential['disclosureFrame']
} else {
disclosureFrame = {
_sd: credential['_sd'],
}
}
const result = await context.agent.createSdJwtVc({
credentialPayload: sdJwtPayload,
disclosureFrame: disclosureFrame,
})
return result.credential
} /*else if (CredentialMapper.isMsoMdocDecodedCredential(credential)) {
TODO
}*/
}
return Promise.reject('VC issuance failed, an incorrect or unsupported credential was supplied')
}

Expand Down
Loading