@@ -244,7 +244,7 @@ class PublicKey {
244244 * @param {String } keyId (optional) The public key ID
245245 * @return {Promise<Object> } The verified key document
246246 */
247- async getVerified ( { userIds, fingerprint, keyId} ) {
247+ async getVerified ( { userIds, fingerprint, keyId, wkd } ) {
248248 let queries = [ ] ;
249249 // query by fingerprint
250250 if ( fingerprint ) {
@@ -260,8 +260,19 @@ class PublicKey {
260260 'userIds.verified' : true
261261 } ) ;
262262 }
263- // query by user ID
264- if ( userIds ) {
263+ // query by wkd hash
264+ if ( userIds && wkd ) {
265+ queries = queries . concat ( userIds . map ( uid => ( {
266+ userIds : {
267+ $elemMatch : {
268+ 'wkdhash' : uid . email ,
269+ 'verified' : true
270+ }
271+ }
272+ } ) ) ) ;
273+ }
274+ // query by user id
275+ if ( userIds && ! wkd ) {
265276 queries = queries . concat ( userIds . map ( uid => ( {
266277 userIds : {
267278 $elemMatch : {
@@ -283,10 +294,10 @@ class PublicKey {
283294 * @param {Object } i18n i18n object
284295 * @return {Promise<Object> } The public key document
285296 */
286- async get ( { fingerprint, keyId, email, i18n} ) {
297+ async get ( { fingerprint, keyId, email, wkd , i18n} ) {
287298 // look for verified key
288299 const userIds = email ? [ { email} ] : undefined ;
289- const key = await this . getVerified ( { keyId, fingerprint, userIds} ) ;
300+ const key = await this . getVerified ( { keyId, fingerprint, userIds, wkd } ) ;
290301 if ( ! key ) {
291302 throw Boom . notFound ( i18n . __ ( 'key_not_found' ) ) ;
292303 }
0 commit comments