|
1 | 1 | /* ©️ 2016 - present FlowCrypt a.s. Limitations apply. Contact [email protected] */ |
2 | 2 | import { Key, PrvPacket, KeyAlgo, KeyUtil, UnexpectedKeyTypeError, PubkeyInfo } from '../key.js'; |
3 | | -import { opgp } from './openpgpjs-custom.js'; |
| 3 | +import { OpenPGPDataType, opgp } from './openpgpjs-custom.js'; |
4 | 4 | import { Catch } from '../../../platform/catch.js'; |
5 | 5 | import { Str, Value } from '../../common.js'; |
6 | 6 | import { Buf } from '../../buf.js'; |
7 | 7 | import type * as OpenPGP from 'openpgp'; |
8 | 8 | import { PgpMsgMethod, VerifyRes } from './msg-util.js'; |
9 | 9 | import * as Stream from '@openpgp/web-stream-tools'; |
10 | 10 |
|
11 | | -type OpenpgpMsgOrCleartext = OpenPGP.Message<OpenPGP.Data> | OpenPGP.CleartextMessage; |
| 11 | +type OpenpgpMsgOrCleartext = OpenPGP.Message<OpenPGPDataType> | OpenPGP.CleartextMessage; |
12 | 12 | export interface KeyWithPrivateFields extends Key { |
13 | 13 | internal: OpenPGP.Key | string; // usable key without weak packets |
14 | 14 | rawArmored: string; |
@@ -117,7 +117,7 @@ export class OpenPGPKey { |
117 | 117 | await OpenPGPKey.convertExternalLibraryObjToKey(encryptedPrv, key); |
118 | 118 | } |
119 | 119 |
|
120 | | - public static async decryptMessage(message: OpenPGP.Message<OpenPGP.Data>, privateKeys: Key[], passwords?: string[]) { |
| 120 | + public static async decryptMessage(message: OpenPGP.Message<OpenPGPDataType>, privateKeys: Key[], passwords?: string[]) { |
121 | 121 | const opgpKeys = await Promise.all(privateKeys.map(key => OpenPGPKey.extractExternalLibraryObjFromKey(key))); |
122 | 122 | return await message.decrypt( |
123 | 123 | opgpKeys.filter(key => key.isPrivate()), |
@@ -477,12 +477,6 @@ export class OpenPGPKey { |
477 | 477 | return p instanceof opgp.SecretKeyPacket || p instanceof opgp.SecretSubkeyPacket; |
478 | 478 | } |
479 | 479 |
|
480 | | - public static isBaseKeyPacket(p: OpenPGP.BasePacket): p is OpenPGP.BasePublicKeyPacket { |
481 | | - return ( |
482 | | - p instanceof opgp.SecretKeyPacket || p instanceof opgp.SecretSubkeyPacket || p instanceof opgp.PublicKeyPacket || p instanceof opgp.PublicSubkeyPacket |
483 | | - ); |
484 | | - } |
485 | | - |
486 | 480 | public static async isPacketDecrypted(pubkey: Key, keyid: OpenPGP.KeyID) { |
487 | 481 | const [k] = (await OpenPGPKey.extractExternalLibraryObjFromKey(pubkey)).getKeys(keyid); // keyPacket.isDecrypted(keyID); |
488 | 482 | if (!k) { |
@@ -577,7 +571,7 @@ export class OpenPGPKey { |
577 | 571 | // mimicks OpenPGP.helper.getLatestValidSignature |
578 | 572 | private static async getLatestValidSignature( |
579 | 573 | signatures: OpenPGP.SignaturePacket[], |
580 | | - primaryKey: OpenPGP.BasePublicKeyPacket, |
| 574 | + primaryKey: OpenPGP.AnyKeyPacket, |
581 | 575 | signatureType: OpenPGP.enums.signature, |
582 | 576 | dataToVerify: object | Uint8Array |
583 | 577 | ): Promise<OpenPGP.SignaturePacket | undefined> { |
@@ -801,7 +795,7 @@ export class OpenPGPKey { |
801 | 795 | } |
802 | 796 | return undefined; |
803 | 797 | } |
804 | | - private static arePrivateParamsMissing = (packet: OpenPGP.BasePublicKeyPacket): boolean => { |
| 798 | + private static arePrivateParamsMissing = (packet: OpenPGP.AnyKeyPacket): boolean => { |
805 | 799 | // detection of missing private params to solve #2887 |
806 | 800 | if (!OpenPGPKey.paramCountByAlgo) { |
807 | 801 | OpenPGPKey.paramCountByAlgo = { |
|
0 commit comments