()
| 54 | } |
| 55 | |
| 56 | async getDefaultKeyFpr() { |
| 57 | let defaultKeyFpr = await getKeyringAttr(this.id, 'default_key'); |
| 58 | if (defaultKeyFpr || defaultKeyFpr === '') { |
| 59 | return defaultKeyFpr; |
| 60 | } |
| 61 | // if defaultKeyFpr is undefined check for legacy primary key setting and migrate to default key |
| 62 | const primaryKeyId = await getKeyringAttr(this.id, 'primary_key'); |
| 63 | if (primaryKeyId === '') { |
| 64 | await setKeyringAttr(this.id, {primary_key: undefined}); |
| 65 | } |
| 66 | if (!primaryKeyId) { |
| 67 | return ''; |
| 68 | } |
| 69 | const primaryKey = this.privateKeys.getForId(primaryKeyId.toLowerCase()); |
| 70 | if (!primaryKey) { |
| 71 | // primary key not found, delete primary key attribute |
| 72 | await setKeyringAttr(this.id, {primary_key: undefined}); |
| 73 | return ''; |
| 74 | } |
| 75 | defaultKeyFpr = primaryKey.getFingerprint(); |
| 76 | await this.setDefaultKey(defaultKeyFpr); |
| 77 | return defaultKeyFpr; |
| 78 | } |
| 79 | |
| 80 | async setDefaultKey(fpr) { |
| 81 | await setKeyringAttr(this.id, {default_key: fpr}); |
nothing calls this directly
no test coverage detected