Skip to content

Commit

Permalink
fix: Make sure we follow JWS detached signing for JsonWebSignature2020
Browse files Browse the repository at this point in the history
  • Loading branch information
nklomp committed Jan 15, 2023
1 parent b163872 commit 3da5bad
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/vc-handler-ld-local/src/suites/JsonWebSignature2020.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,17 @@ export class SphereonJsonWebSignature2020 extends SphereonLdSignature {
b64: false,
crit: ['b64'],
}

const headerString = encodeJoseBlob(header)
const messageBuffer = u8a.concat([u8a.fromString(`${headerString}.`, 'utf-8'), args.data])
const messageString = u8a.toString(messageBuffer, 'utf-8')
const dataString = u8a.toString(args.data, 'base64url')
const messageString = `${headerString}.${dataString}`

const signature = await context.agent.keyManagerSign({
keyRef: key.kid,
algorithm: alg,
data: messageString,
encoding: 'base64',
})
encoding: 'utf-8',
}) // returns base64url signature
return `${headerString}..${signature}`
},
}
Expand Down

0 comments on commit 3da5bad

Please sign in to comment.