decentralized-identity / did-resolver

Universal did-resolver for javascript environments
Apache License 2.0
216 stars 44 forks source link

JsonWebKey Interface only for a public key? Missing private key parameter. #121

Closed bshambaugh closed 2 years ago

bshambaugh commented 2 years ago

Question Why doesn't the JsonWebKey interface define the "d" parameter for a private key?

See: JSON Web Key Parameters in : https://www.iana.org/assignments/jose/jose.xhtml

See the interface definition in: https://github.com/decentralized-identity/did-resolver/blob/master/src/resolver.ts#L74-L86

Context: Current Fix For context, I was hacking around the break up the test file https://github.com/bshambaugh/did-jwt/blob/master/src/__tests__/JWT/CommonSignerTest/CommonSignerTest.ts#L20-L22

so I could import creation of the DID document as a fuction; https://github.com/bshambaugh/did-jwt/blob/master/src/__tests__/JWT/JWT.ES256Signer.test.ts#L50-L54 and https://github.com/bshambaugh/did-jwt/blob/master/src/__tests__/JWT/JWT.ES256KSigner.test.ts#L43-L47 (other changes [unrelated to this issue] were so I could avoid use of the any type)

Originally it was: https://github.com/decentralized-identity/did-jwt/blob/master/src/__tests__/JWT.test.ts#L36-L91

mirceanis commented 2 years ago

This parameter is intentionally omitted from the type definition to discourage unintentional publication of private key material to a DID document. These documents are publicly resolvable so publishing a private key there never makes sense.

This does not prevent the use of key objects that contain the d property, nor any other property, since the interface is Extensible. It is only about the type seen by typescript, and IDEs. Also, there is nothing stopping you from defining an interface that extends this with an explicit member for private key data.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.