* Return list of keyrings in the preferred priority order * @param {String} keyringId - requested keyring, the leading keyring of a scenario * @return {Array }
(keyringId)
| 478 | * @return {Array<KeyringBase>} |
| 479 | */ |
| 480 | function getPreferredKeyringQueue(keyringId) { |
| 481 | const keyrings = []; |
| 482 | const hasGpgKeyring = keyringMap.has(GNUPG_KEYRING_ID); |
| 483 | // use gnupg keyring if available and preferred |
| 484 | if (hasGpgKeyring && prefs.general.prefer_gnupg) { |
| 485 | keyrings.push(keyringMap.get(GNUPG_KEYRING_ID)); |
| 486 | } |
| 487 | // next, if requested keyring is API keyring then use that |
| 488 | if (isApiKeyring(keyringId)) { |
| 489 | keyrings.push(keyringMap.get(keyringId)); |
| 490 | } |
| 491 | // always use the main keyring |
| 492 | keyrings.push(keyringMap.get(MAIN_KEYRING_ID)); |
| 493 | // if gnupg keyring is available but not preferred, we put at the end of the queue |
| 494 | if (hasGpgKeyring && !prefs.general.prefer_gnupg) { |
| 495 | keyrings.push(keyringMap.get(GNUPG_KEYRING_ID)); |
| 496 | } |
| 497 | return keyrings; |
| 498 | } |
| 499 | |
| 500 | /** |
| 501 | * Get keyring that includes at least one private key of the specified key Ids. |
no test coverage detected