Skip to content

Commit

Permalink
fix: x5c is an array in a JWK
Browse files Browse the repository at this point in the history
  • Loading branch information
nklomp committed Jun 19, 2024
1 parent 0474bbc commit 58f607f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/did-provider-ebsi/src/EbsiDidProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class EbsiDidProvider extends AbstractIdentifierProvider {
throw new Error(`Type ${type} not supported. Please use @sphereon/ssi-sdk-ext.did-provider-key for Natural Person EBSI DIDs`)
}

// CapabilityInvocation purpose
const secp256k1ImportKey = await generateOrUseEbsiKeyPair(
{
keyOpts: secp256k1Key,
Expand All @@ -40,6 +41,7 @@ export class EbsiDidProvider extends AbstractIdentifierProvider {
)
const secp256k1ManagedKeyInfo = await context.agent.keyManagerImport(secp256k1ImportKey)

// Authentication, assertionMethod purpose
const secp256r1ImportKey = await generateOrUseEbsiKeyPair(
{
keyOpts: secp256r1Key,
Expand Down
6 changes: 4 additions & 2 deletions packages/did-provider-ebsi/src/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export const assertedPurposes = (args: { key?: IKeyOpts }): EbsiPublicKeyPurpose
if (key?.purposes && key.purposes.length > 0 && key.purposes?.includes(EbsiPublicKeyPurpose.CapabilityInvocation)) {
return key.purposes
}
throw new Error(`Secp256k1 key requires ${EbsiPublicKeyPurpose.CapabilityInvocation} purpose`)
throw new Error(`Secp256k1/ES256K key requires ${EbsiPublicKeyPurpose.CapabilityInvocation} purpose`)
}
case 'Secp256r1': {
if (
Expand All @@ -202,7 +202,9 @@ export const assertedPurposes = (args: { key?: IKeyOpts }): EbsiPublicKeyPurpose
) {
return key.purposes
}
throw new Error(`Secp256r1 key requires ${[EbsiPublicKeyPurpose.AssertionMethod, EbsiPublicKeyPurpose.Authentication].join(', ')} purposes`)
throw new Error(
`Secp256r1/ES256 key requires ${[EbsiPublicKeyPurpose.AssertionMethod, EbsiPublicKeyPurpose.Authentication].join(', ')} purposes`
)
}
default:
throw new Error(`Unsupported key type: ${key.type}`)
Expand Down
2 changes: 1 addition & 1 deletion packages/key-utils/src/types/key-util-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const ENC_KEY_ALGS = ['X25519', 'ECDH_ES_A256KW', 'RSA_OAEP_256']

export interface JWK extends JsonWebKey {
kid?: string
x5c?: string
x5c?: string[]
x5u?: string
}

Expand Down

0 comments on commit 58f607f

Please sign in to comment.