@protontech/openpgp 6.1.1-patch.3 → 6.1.1-patch.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/openpgp.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! OpenPGP.js v6.1.1-patch.3 - 2025-06-18 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
1
+ /*! OpenPGP.js v6.1.1-patch.5 - 2025-08-13 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
2
2
  const globalThis = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
3
3
 
4
4
  function _mergeNamespaces(n, m) {
@@ -1716,7 +1716,7 @@ var config = {
1716
1716
  * @memberof module:config
1717
1717
  * @property {String} versionString A version string to be included in armored messages
1718
1718
  */
1719
- versionString: 'OpenPGP.js 6.1.1-patch.3',
1719
+ versionString: 'OpenPGP.js 6.1.1-patch.5',
1720
1720
  /**
1721
1721
  * @memberof module:config
1722
1722
  * @property {String} commentString A comment string to be included in armored messages
@@ -6913,7 +6913,15 @@ async function generate$a(algo) {
6913
6913
  case enums.publicKey.ed25519:
6914
6914
  try {
6915
6915
  const webCrypto = util.getWebCrypto();
6916
- const webCryptoKey = await webCrypto.generateKey('Ed25519', true, ['sign', 'verify']);
6916
+ const webCryptoKey = await webCrypto.generateKey('Ed25519', true, ['sign', 'verify'])
6917
+ .catch(err => {
6918
+ if (err.name === 'OperationError') { // Temporary (hopefully) fix for WebKit on Linux
6919
+ const newErr = new Error('Unexpected key generation issue');
6920
+ newErr.name = 'NotSupportedError';
6921
+ throw newErr;
6922
+ }
6923
+ throw err;
6924
+ });
6917
6925
 
6918
6926
  const privateKey = await webCrypto.exportKey('jwk', webCryptoKey.privateKey);
6919
6927
  const publicKey = await webCrypto.exportKey('jwk', webCryptoKey.publicKey);
@@ -6923,7 +6931,7 @@ async function generate$a(algo) {
6923
6931
  seed: b64ToUint8Array(privateKey.d, true)
6924
6932
  };
6925
6933
  } catch (err) {
6926
- if (err.name !== 'NotSupportedError' && err.name !== 'OperationError') { // Temporary (hopefully) fix for WebKit on Linux
6934
+ if (err.name !== 'NotSupportedError') {
6927
6935
  throw err;
6928
6936
  }
6929
6937
  const seed = getRandomBytes(getPayloadSize$1(algo));
@@ -8341,11 +8349,25 @@ async function generate$9(algo) {
8341
8349
  case enums.publicKey.x25519:
8342
8350
  try {
8343
8351
  const webCrypto = util.getWebCrypto();
8344
- const webCryptoKey = await webCrypto.generateKey('X25519', true, ['deriveKey', 'deriveBits']);
8352
+ const webCryptoKey = await webCrypto.generateKey('X25519', true, ['deriveKey', 'deriveBits'])
8353
+ .catch(err => {
8354
+ if (err.name === 'OperationError') { // Temporary (hopefully) fix for WebKit on Linux
8355
+ const newErr = new Error('Unexpected key generation issue');
8356
+ newErr.name = 'NotSupportedError';
8357
+ throw newErr;
8358
+ }
8359
+ throw err;
8360
+ });
8345
8361
 
8346
8362
  const privateKey = await webCrypto.exportKey('jwk', webCryptoKey.privateKey);
8347
8363
  const publicKey = await webCrypto.exportKey('jwk', webCryptoKey.publicKey);
8348
8364
 
8365
+ if (privateKey.x !== publicKey.x) { // Weird issue with Webkit on Linux: https://bugs.webkit.org/show_bug.cgi?id=289693
8366
+ const err = new Error('Unexpected mismatching public point');
8367
+ err.name = 'NotSupportedError';
8368
+ throw err;
8369
+ }
8370
+
8349
8371
  return {
8350
8372
  A: new Uint8Array(b64ToUint8Array(publicKey.x)),
8351
8373
  k: b64ToUint8Array(privateKey.d)
@@ -8503,15 +8525,29 @@ async function generateEphemeralEncryptionMaterial(algo, recipientA) {
8503
8525
  case enums.publicKey.x25519:
8504
8526
  try {
8505
8527
  const webCrypto = util.getWebCrypto();
8528
+ const ephemeralKeyPair = await webCrypto.generateKey('X25519', true, ['deriveKey', 'deriveBits'])
8529
+ .catch(err => {
8530
+ if (err.name === 'OperationError') { // Temporary (hopefully) fix for WebKit on Linux
8531
+ const newErr = new Error('Unexpected key generation issue');
8532
+ newErr.name = 'NotSupportedError';
8533
+ throw newErr;
8534
+ }
8535
+ throw err;
8536
+ });
8537
+ const ephemeralPublicKeyJwt = await webCrypto.exportKey('jwk', ephemeralKeyPair.publicKey);
8538
+ const ephemeralPrivateKeyJwt = await webCrypto.exportKey('jwk', ephemeralKeyPair.privateKey);
8539
+ if (ephemeralPrivateKeyJwt.x !== ephemeralPublicKeyJwt.x) { // Weird issue with Webkit on Linux: https://bugs.webkit.org/show_bug.cgi?id=289693
8540
+ const err = new Error('Unexpected mismatching public point');
8541
+ err.name = 'NotSupportedError';
8542
+ throw err;
8543
+ }
8506
8544
  const jwk = publicKeyToJWK(algo, recipientA);
8507
- const ephemeralKeyPair = await webCrypto.generateKey('X25519', true, ['deriveKey', 'deriveBits']);
8508
8545
  const recipientPublicKey = await webCrypto.importKey('jwk', jwk, 'X25519', false, []);
8509
8546
  const sharedSecretBuffer = await webCrypto.deriveBits(
8510
8547
  { name: 'X25519', public: recipientPublicKey },
8511
8548
  ephemeralKeyPair.privateKey,
8512
8549
  getPayloadSize(algo) * 8 // in bits
8513
8550
  );
8514
- const ephemeralPublicKeyJwt = await webCrypto.exportKey('jwk', ephemeralKeyPair.publicKey);
8515
8551
  return {
8516
8552
  sharedSecret: new Uint8Array(sharedSecretBuffer),
8517
8553
  ephemeralPublicKey: new Uint8Array(b64ToUint8Array(ephemeralPublicKeyJwt.x))
package/openpgp.d.ts CHANGED
@@ -16,7 +16,7 @@ import config, { type Config, type PartialConfig } from './src/config';
16
16
  export { enums, config, Config, PartialConfig };
17
17
 
18
18
  /* ############## STREAM #################### */
19
- type Data = Uint8Array | string;
19
+ type Data = Uint8Array<ArrayBuffer> | string;
20
20
  // web-stream-tools might end up supporting additional data types, so we re-declare the types
21
21
  // to enforce the type contraint that we need.
22
22
  export type WebStream<T extends Data> = GenericWebStream<T>;
@@ -29,29 +29,29 @@ type MaybeArray<T> = T | Array<T>;
29
29
  // The Key and PublicKey types can be used interchangably since TS cannot detect the difference, as they have the same class properties.
30
30
  // The declared readKey(s) return type is Key instead of a PublicKey since it seems more obvious that a Key can be cast to a PrivateKey.
31
31
  export function readKey(options: { armoredKey: string, config?: PartialConfig }): Promise<Key>;
32
- export function readKey(options: { binaryKey: Uint8Array, config?: PartialConfig }): Promise<Key>;
32
+ export function readKey(options: { binaryKey: Uint8Array<ArrayBuffer>, config?: PartialConfig }): Promise<Key>;
33
33
  export function readKeys(options: { armoredKeys: string, config?: PartialConfig }): Promise<Key[]>;
34
- export function readKeys(options: { binaryKeys: Uint8Array, config?: PartialConfig }): Promise<Key[]>;
34
+ export function readKeys(options: { binaryKeys: Uint8Array<ArrayBuffer>, config?: PartialConfig }): Promise<Key[]>;
35
35
  export function readPrivateKey(options: { armoredKey: string, config?: PartialConfig }): Promise<PrivateKey>;
36
- export function readPrivateKey(options: { binaryKey: Uint8Array, config?: PartialConfig }): Promise<PrivateKey>;
36
+ export function readPrivateKey(options: { binaryKey: Uint8Array<ArrayBuffer>, config?: PartialConfig }): Promise<PrivateKey>;
37
37
  export function readPrivateKeys(options: { armoredKeys: string, config?: PartialConfig }): Promise<PrivateKey[]>;
38
- export function readPrivateKeys(options: { binaryKeys: Uint8Array, config?: PartialConfig }): Promise<PrivateKey[]>;
38
+ export function readPrivateKeys(options: { binaryKeys: Uint8Array<ArrayBuffer>, config?: PartialConfig }): Promise<PrivateKey[]>;
39
39
  export function generateKey(options: GenerateKeyOptions & { format?: 'armored' }): Promise<SerializedKeyPair<string> & { revocationCertificate: string }>;
40
- export function generateKey(options: GenerateKeyOptions & { format: 'binary' }): Promise<SerializedKeyPair<Uint8Array> & { revocationCertificate: string }>;
40
+ export function generateKey(options: GenerateKeyOptions & { format: 'binary' }): Promise<SerializedKeyPair<Uint8Array<ArrayBuffer>> & { revocationCertificate: string }>;
41
41
  export function generateKey(options: GenerateKeyOptions & { format: 'object' }): Promise<KeyPair & { revocationCertificate: string }>;
42
42
  export function decryptKey(options: { privateKey: PrivateKey; passphrase?: MaybeArray<string>; config?: PartialConfig }): Promise<PrivateKey>;
43
43
  export function encryptKey(options: { privateKey: PrivateKey; passphrase?: MaybeArray<string>; config?: PartialConfig }): Promise<PrivateKey>;
44
44
  export function reformatKey(options: { privateKey: PrivateKey; userIDs?: MaybeArray<UserID>; passphrase?: string; keyExpirationTime?: number; date?: Date, format?: 'armored', config?: PartialConfig }): Promise<SerializedKeyPair<string> & { revocationCertificate: string }>;
45
- export function reformatKey(options: { privateKey: PrivateKey; userIDs?: MaybeArray<UserID>; passphrase?: string; keyExpirationTime?: number; date?: Date, format: 'binary', config?: PartialConfig }): Promise<SerializedKeyPair<Uint8Array> & { revocationCertificate: string }>;
45
+ export function reformatKey(options: { privateKey: PrivateKey; userIDs?: MaybeArray<UserID>; passphrase?: string; keyExpirationTime?: number; date?: Date, format: 'binary', config?: PartialConfig }): Promise<SerializedKeyPair<Uint8Array<ArrayBuffer>> & { revocationCertificate: string }>;
46
46
  export function reformatKey(options: { privateKey: PrivateKey; userIDs?: MaybeArray<UserID>; passphrase?: string; keyExpirationTime?: number; date?: Date, format: 'object', config?: PartialConfig }): Promise<KeyPair & { revocationCertificate: string }>;
47
47
  export function revokeKey(options: { key: PrivateKey, reasonForRevocation?: ReasonForRevocation, date?: Date, format?: 'armored', config?: PartialConfig }): Promise<SerializedKeyPair<string>>;
48
- export function revokeKey(options: { key: PrivateKey, reasonForRevocation?: ReasonForRevocation, date?: Date, format: 'binary', config?: PartialConfig }): Promise<SerializedKeyPair<Uint8Array>>;
48
+ export function revokeKey(options: { key: PrivateKey, reasonForRevocation?: ReasonForRevocation, date?: Date, format: 'binary', config?: PartialConfig }): Promise<SerializedKeyPair<Uint8Array<ArrayBuffer>>>;
49
49
  export function revokeKey(options: { key: PrivateKey, reasonForRevocation?: ReasonForRevocation, date?: Date, format: 'object', config?: PartialConfig }): Promise<KeyPair>;
50
50
  export function revokeKey(options: { key: PrivateKey, revocationCertificate: string, date?: Date, format?: 'armored', config?: PartialConfig }): Promise<SerializedKeyPair<string>>;
51
- export function revokeKey(options: { key: PrivateKey, revocationCertificate: string, date?: Date, format: 'binary', config?: PartialConfig }): Promise<SerializedKeyPair<Uint8Array>>;
51
+ export function revokeKey(options: { key: PrivateKey, revocationCertificate: string, date?: Date, format: 'binary', config?: PartialConfig }): Promise<SerializedKeyPair<Uint8Array<ArrayBuffer>>>;
52
52
  export function revokeKey(options: { key: PrivateKey, revocationCertificate: string, date?: Date, format: 'object', config?: PartialConfig }): Promise<KeyPair>;
53
53
  export function revokeKey(options: { key: PublicKey, revocationCertificate: string, date?: Date, format?: 'armored', config?: PartialConfig }): Promise<{ publicKey: string, privateKey: null }>;
54
- export function revokeKey(options: { key: PublicKey, revocationCertificate: string, date?: Date, format: 'binary', config?: PartialConfig }): Promise<{ publicKey: Uint8Array, privateKey: null }>;
54
+ export function revokeKey(options: { key: PublicKey, revocationCertificate: string, date?: Date, format: 'binary', config?: PartialConfig }): Promise<{ publicKey: Uint8Array<ArrayBuffer>, privateKey: null }>;
55
55
  export function revokeKey(options: { key: PublicKey, revocationCertificate: string, date?: Date, format: 'object', config?: PartialConfig }): Promise<{ publicKey: PublicKey, privateKey: null }>;
56
56
 
57
57
  export abstract class Key {
@@ -59,7 +59,7 @@ export abstract class Key {
59
59
  public subkeys: Subkey[]; // do not add/replace users directly
60
60
  public users: User[]; // do not add/replace subkeys directly
61
61
  public revocationSignatures: SignaturePacket[];
62
- public write(): Uint8Array;
62
+ public write(): Uint8Array<ArrayBuffer>;
63
63
  public armor(config?: Config): string;
64
64
  public getExpirationTime(userID?: UserID, config?: Config): Promise<Date | typeof Infinity | null>;
65
65
  public getKeyIDs(): KeyID[];
@@ -143,12 +143,12 @@ export type AlgorithmInfo = {
143
143
  /* ############## SIG #################### */
144
144
 
145
145
  export function readSignature(options: { armoredSignature: string, config?: PartialConfig }): Promise<Signature>;
146
- export function readSignature(options: { binarySignature: Uint8Array, config?: PartialConfig }): Promise<Signature>;
146
+ export function readSignature(options: { binarySignature: Uint8Array<ArrayBuffer>, config?: PartialConfig }): Promise<Signature>;
147
147
 
148
148
  export class Signature {
149
149
  public readonly packets: PacketList<SignaturePacket>;
150
150
  constructor(packetlist: PacketList<SignaturePacket>);
151
- public write(): MaybeStream<Uint8Array>;
151
+ public write(): MaybeStream<Uint8Array<ArrayBuffer>>;
152
152
  public armor(config?: Config): string;
153
153
  public getSigningKeyIDs(): Array<KeyID>;
154
154
  }
@@ -195,15 +195,15 @@ export class CleartextMessage {
195
195
  /* ############## MSG #################### */
196
196
  export function generateSessionKey(options: { encryptionKeys: MaybeArray<PublicKey>, date?: Date, encryptionUserIDs?: MaybeArray<UserID>, config?: PartialConfig }): Promise<SessionKey>;
197
197
  export function encryptSessionKey(options: EncryptSessionKeyOptions & { format?: 'armored' }): Promise<string>;
198
- export function encryptSessionKey(options: EncryptSessionKeyOptions & { format: 'binary' }): Promise<Uint8Array>;
198
+ export function encryptSessionKey(options: EncryptSessionKeyOptions & { format: 'binary' }): Promise<Uint8Array<ArrayBuffer>>;
199
199
  export function encryptSessionKey(options: EncryptSessionKeyOptions & { format: 'object' }): Promise<Message<Data>>;
200
200
  export function decryptSessionKeys<T extends MaybeStream<Data>>(options: { message: Message<T>, decryptionKeys?: MaybeArray<PrivateKey>, passwords?: MaybeArray<string>, date?: Date, config?: PartialConfig }): Promise<DecryptedSessionKey[]>;
201
201
 
202
202
  export function readMessage<T extends MaybeStream<string>>(options: { armoredMessage: T, config?: PartialConfig }): Promise<Message<T>>;
203
- export function readMessage<T extends MaybeStream<Uint8Array>>(options: { binaryMessage: T, config?: PartialConfig }): Promise<Message<T>>;
203
+ export function readMessage<T extends MaybeStream<Uint8Array<ArrayBuffer>>>(options: { binaryMessage: T, config?: PartialConfig }): Promise<Message<T>>;
204
204
 
205
205
  export function createMessage<T extends MaybeStream<string>>(options: { text: T, filename?: string, date?: Date, format?: enums.literalFormatNames }): Promise<Message<T>>;
206
- export function createMessage<T extends MaybeStream<Uint8Array>>(options: { binary: T, filename?: string, date?: Date, format?: enums.literalFormatNames }): Promise<Message<T>>;
206
+ export function createMessage<T extends MaybeStream<Uint8Array<ArrayBuffer>>>(options: { binary: T, filename?: string, date?: Date, format?: enums.literalFormatNames }): Promise<Message<T>>;
207
207
 
208
208
  export function encrypt<T extends MaybeStream<Data>>(options: EncryptOptions & { message: Message<T>, format?: 'armored' }): Promise<
209
209
  T extends WebStream<Data> ? WebStream<string> :
@@ -211,9 +211,9 @@ export function encrypt<T extends MaybeStream<Data>>(options: EncryptOptions & {
211
211
  string
212
212
  >;
213
213
  export function encrypt<T extends MaybeStream<Data>>(options: EncryptOptions & { message: Message<T>, format: 'binary' }): Promise<
214
- T extends WebStream<Data> ? WebStream<Uint8Array> :
215
- T extends NodeWebStream<Data> ? NodeWebStream<Uint8Array> :
216
- Uint8Array
214
+ T extends WebStream<Data> ? WebStream<Uint8Array<ArrayBuffer>> :
215
+ T extends NodeWebStream<Data> ? NodeWebStream<Uint8Array<ArrayBuffer>> :
216
+ Uint8Array<ArrayBuffer>
217
217
  >;
218
218
  export function encrypt<T extends MaybeStream<Data>>(options: EncryptOptions & { message: Message<T>, format: 'object' }): Promise<Message<T>>;
219
219
 
@@ -223,9 +223,9 @@ export function sign<T extends MaybeStream<Data>>(options: SignOptions & { messa
223
223
  string
224
224
  >;
225
225
  export function sign<T extends MaybeStream<Data>>(options: SignOptions & { message: Message<T>, format: 'binary' }): Promise<
226
- T extends WebStream<Data> ? WebStream<Uint8Array> :
227
- T extends NodeWebStream<Data> ? NodeWebStream<Uint8Array> :
228
- Uint8Array
226
+ T extends WebStream<Data> ? WebStream<Uint8Array<ArrayBuffer>> :
227
+ T extends NodeWebStream<Data> ? NodeWebStream<Uint8Array<ArrayBuffer>> :
228
+ Uint8Array<ArrayBuffer>
229
229
  >;
230
230
  export function sign<T extends MaybeStream<Data>>(options: SignOptions & { message: Message<T>, format: 'object' }): Promise<Message<T>>;
231
231
  export function sign(options: SignOptions & { message: CleartextMessage, format?: 'armored' }): Promise<string>;
@@ -233,9 +233,9 @@ export function sign(options: SignOptions & { message: CleartextMessage, format:
233
233
 
234
234
  export function decrypt<T extends MaybeStream<Data>>(options: DecryptOptions & { message: Message<T>, format: 'binary' }): Promise<DecryptMessageResult & {
235
235
  data:
236
- T extends WebStream<Data> ? WebStream<Uint8Array> :
237
- T extends NodeWebStream<Data> ? NodeWebStream<Uint8Array> :
238
- Uint8Array
236
+ T extends WebStream<Data> ? WebStream<Uint8Array<ArrayBuffer>> :
237
+ T extends NodeWebStream<Data> ? NodeWebStream<Uint8Array<ArrayBuffer>> :
238
+ Uint8Array<ArrayBuffer>
239
239
  }>;
240
240
  export function decrypt<T extends MaybeStream<Data>>(options: DecryptOptions & { message: Message<T> }): Promise<DecryptMessageResult & {
241
241
  data:
@@ -246,9 +246,9 @@ export function decrypt<T extends MaybeStream<Data>>(options: DecryptOptions & {
246
246
 
247
247
  export function verify(options: VerifyOptions & { message: CleartextMessage, format?: 'utf8' }): Promise<VerifyMessageResult<string>>;
248
248
  export function verify<T extends MaybeStream<Data>>(options: VerifyOptions & { message: Message<T>, format: 'binary' }): Promise<VerifyMessageResult<
249
- T extends WebStream<Data> ? WebStream<Uint8Array> :
250
- T extends NodeWebStream<Data> ? NodeWebStream<Uint8Array> :
251
- Uint8Array
249
+ T extends WebStream<Data> ? WebStream<Uint8Array<ArrayBuffer>> :
250
+ T extends NodeWebStream<Data> ? NodeWebStream<Uint8Array<ArrayBuffer>> :
251
+ Uint8Array<ArrayBuffer>
252
252
  >>;
253
253
  export function verify<T extends MaybeStream<Data>>(options: VerifyOptions & { message: Message<T> }): Promise<VerifyMessageResult<
254
254
  T extends WebStream<Data> ? WebStream<string> :
@@ -265,7 +265,7 @@ export class Message<T extends MaybeStream<Data>> {
265
265
 
266
266
  /** Returns binary representation of message
267
267
  */
268
- public write(): MaybeStream<Uint8Array>;
268
+ public write(): MaybeStream<Uint8Array<ArrayBuffer>>;
269
269
 
270
270
  /** Returns ASCII armored text of message
271
271
  */
@@ -287,7 +287,7 @@ export class Message<T extends MaybeStream<Data>> {
287
287
 
288
288
  /** Get literal data that is the body of the message
289
289
  */
290
- public getLiteralData(): (T extends Stream<Data> ? WebStream<Uint8Array> : Uint8Array) | null;
290
+ public getLiteralData(): (T extends Stream<Data> ? WebStream<Uint8Array<ArrayBuffer>> : Uint8Array<ArrayBuffer>) | null;
291
291
 
292
292
  /** Returns the key IDs of the keys that signed the message
293
293
  */
@@ -315,17 +315,17 @@ export class Message<T extends MaybeStream<Data>> {
315
315
 
316
316
  /**
317
317
  * Append signature to unencrypted message object
318
- * @param {String|Uint8Array} detachedSignature - The detached ASCII-armored or Uint8Array PGP signature
318
+ * @param {String|Uint8Array<ArrayBuffer>} detachedSignature - The detached ASCII-armored or Uint8Array<ArrayBuffer> PGP signature
319
319
  */
320
- public appendSignature(detachedSignature: string | Uint8Array, config?: Config): Promise<void>;
320
+ public appendSignature(detachedSignature: string | Uint8Array<ArrayBuffer>, config?: Config): Promise<void>;
321
321
  }
322
322
 
323
323
  /* ############## PACKET #################### */
324
324
 
325
325
  export declare abstract class BasePacket {
326
326
  static readonly tag: enums.packet;
327
- public read(bytes: Uint8Array): void;
328
- public write(): Uint8Array;
327
+ public read(bytes: Uint8Array<ArrayBuffer>): void;
328
+ public write(): Uint8Array<ArrayBuffer>;
329
329
  }
330
330
 
331
331
  /**
@@ -339,7 +339,7 @@ declare abstract class BasePublicKeyPacket extends BasePacket {
339
339
  public version: number;
340
340
  public getAlgorithmInfo(): AlgorithmInfo;
341
341
  public getFingerprint(): string;
342
- public getFingerprintBytes(): Uint8Array | null;
342
+ public getFingerprintBytes(): Uint8Array<ArrayBuffer> | null;
343
343
  public hasSameFingerprintAs(other: BasePublicKeyPacket): boolean;
344
344
  public getCreationTime(): Date;
345
345
  public getKeyID(): KeyID;
@@ -393,9 +393,9 @@ export class SymEncryptedIntegrityProtectedDataPacket extends BasePacket {
393
393
 
394
394
  export class AEADEncryptedDataPacket extends BasePacket {
395
395
  static readonly tag: enums.packet.aeadEncryptedData;
396
- private decrypt(sessionKeyAlgorithm: enums.symmetric, sessionKey: Uint8Array, config?: Config): void;
397
- private encrypt(sessionKeyAlgorithm: enums.symmetric, sessionKey: Uint8Array, config?: Config): void;
398
- private crypt(fn: Function, sessionKey: Uint8Array, data: MaybeStream<Uint8Array>): MaybeStream<Uint8Array>;
396
+ private decrypt(sessionKeyAlgorithm: enums.symmetric, sessionKey: Uint8Array<ArrayBuffer>, config?: Config): void;
397
+ private encrypt(sessionKeyAlgorithm: enums.symmetric, sessionKey: Uint8Array<ArrayBuffer>, config?: Config): void;
398
+ private crypt(fn: Function, sessionKey: Uint8Array<ArrayBuffer>, data: MaybeStream<Uint8Array<ArrayBuffer>>): MaybeStream<Uint8Array<ArrayBuffer>>;
399
399
  }
400
400
 
401
401
  export class PublicKeyEncryptedSessionKeyPacket extends BasePacket {
@@ -413,18 +413,18 @@ export class SymEncryptedSessionKeyPacket extends BasePacket {
413
413
  export class LiteralDataPacket extends BasePacket {
414
414
  static readonly tag: enums.packet.literalData;
415
415
  private getText(clone?: boolean): MaybeStream<string>;
416
- private getBytes(clone?: boolean): MaybeStream<Uint8Array>;
416
+ private getBytes(clone?: boolean): MaybeStream<Uint8Array<ArrayBuffer>>;
417
417
  private setText(text: MaybeStream<string>, format?: enums.literal);
418
- private setBytes(bytes: MaybeStream<Uint8Array>, format: enums.literal);
418
+ private setBytes(bytes: MaybeStream<Uint8Array<ArrayBuffer>>, format: enums.literal);
419
419
  private setFilename(filename: string);
420
420
  private getFilename(): string;
421
- private writeHeader(): Uint8Array;
421
+ private writeHeader(): Uint8Array<ArrayBuffer>;
422
422
  }
423
423
 
424
424
  export class SymmetricallyEncryptedDataPacket extends BasePacket {
425
425
  static readonly tag: enums.packet.symmetricallyEncryptedData;
426
- private decrypt(sessionKeyAlgorithm: enums.symmetric, sessionKey: Uint8Array, config?: Config): void;
427
- private encrypt(sessionKeyAlgorithm: enums.symmetric, sessionKey: Uint8Array, config?: Config): void;
426
+ private decrypt(sessionKeyAlgorithm: enums.symmetric, sessionKey: Uint8Array<ArrayBuffer>, config?: Config): void;
427
+ private encrypt(sessionKeyAlgorithm: enums.symmetric, sessionKey: Uint8Array<ArrayBuffer>, config?: Config): void;
428
428
  }
429
429
 
430
430
  export class MarkerPacket extends BasePacket {
@@ -457,10 +457,10 @@ export class SignaturePacket extends BasePacket {
457
457
  public signatureType: enums.signature | null;
458
458
  public hashAlgorithm: enums.hash | null;
459
459
  public publicKeyAlgorithm: enums.publicKey | null;
460
- public signatureData: null | Uint8Array;
460
+ public signatureData: null | Uint8Array<ArrayBuffer>;
461
461
  public unhashedSubpackets: RawSubpacket[];
462
462
  public unknownSubpackets: RawSubpacket[];
463
- public signedHashValue: null | Uint8Array;
463
+ public signedHashValue: null | Uint8Array<ArrayBuffer>;
464
464
  public created: Date | null;
465
465
  public signatureExpirationTime: null | number;
466
466
  public signatureNeverExpires: boolean;
@@ -474,7 +474,7 @@ export class SignaturePacket extends BasePacket {
474
474
  public preferredSymmetricAlgorithms: enums.symmetric[] | null;
475
475
  public revocationKeyClass: null | number;
476
476
  public revocationKeyAlgorithm: null | enums.publicKey;
477
- public revocationKeyFingerprint: null | Uint8Array;
477
+ public revocationKeyFingerprint: null | Uint8Array<ArrayBuffer>;
478
478
  public issuerKeyID: KeyID;
479
479
  public notation: null | { [name: string]: string };
480
480
  public preferredHashAlgorithms: enums.hash[] | null;
@@ -483,22 +483,22 @@ export class SignaturePacket extends BasePacket {
483
483
  public preferredKeyServer: null | string;
484
484
  public isPrimaryUserID: null | boolean;
485
485
  public policyURI: null | string;
486
- public keyFlags: Uint8Array | null;
486
+ public keyFlags: Uint8Array<ArrayBuffer> | null;
487
487
  public signersUserID: null | string;
488
488
  public reasonForRevocationFlag: null | enums.reasonForRevocation;
489
489
  public reasonForRevocationString: null | string;
490
- public features: Uint8Array | null;
490
+ public features: Uint8Array<ArrayBuffer> | null;
491
491
  public signatureTargetPublicKeyAlgorithm: enums.publicKey | null;
492
492
  public signatureTargetHashAlgorithm: enums.hash | null;
493
493
  public signatureTargetHash: null | string;
494
494
  public embeddedSignature: null | SignaturePacket;
495
495
  public issuerKeyVersion: null | number;
496
- public issuerFingerprint: null | Uint8Array;
496
+ public issuerFingerprint: null | Uint8Array<ArrayBuffer>;
497
497
  public preferredAEADAlgorithms: enums.aead[] | null;
498
498
  public revoked: null | boolean;
499
499
  public rawNotations: RawNotation[];
500
- public sign(key: AnySecretKeyPacket, data: Uint8Array, date?: Date, detached?: boolean): Promise<void>;
501
- public verify(key: AnyKeyPacket, signatureType: enums.signature, data: Uint8Array | object, date?: Date, detached?: boolean, config?: Config): Promise<void>; // throws on error
500
+ public sign(key: AnySecretKeyPacket, data: Uint8Array<ArrayBuffer>, date?: Date, detached?: boolean): Promise<void>;
501
+ public verify(key: AnyKeyPacket, signatureType: enums.signature, data: Uint8Array<ArrayBuffer> | object, date?: Date, detached?: boolean, config?: Config): Promise<void>; // throws on error
502
502
  public isExpired(date?: Date): boolean;
503
503
  public getExpirationTime(): Date | typeof Infinity;
504
504
  }
@@ -506,12 +506,12 @@ export class SignaturePacket extends BasePacket {
506
506
  export interface RawSubpacket {
507
507
  type: number;
508
508
  critical: boolean;
509
- body: Uint8Array;
509
+ body: Uint8Array<ArrayBuffer>;
510
510
  }
511
511
 
512
512
  export interface RawNotation {
513
513
  name: string;
514
- value: Uint8Array;
514
+ value: Uint8Array<ArrayBuffer>;
515
515
  humanReadable: boolean;
516
516
  critical: boolean;
517
517
  }
@@ -522,7 +522,7 @@ export class TrustPacket extends BasePacket {
522
522
 
523
523
  export class UnparseablePacket {
524
524
  tag: enums.packet;
525
- write: () => Uint8Array;
525
+ write: () => Uint8Array<ArrayBuffer>;
526
526
  }
527
527
 
528
528
  export type AnyPacket = BasePacket | UnparseablePacket;
@@ -531,9 +531,9 @@ export type AnyKeyPacket = BasePublicKeyPacket;
531
531
 
532
532
  type AllowedPackets = Map<enums.packet, object>; // mapping to Packet classes (i.e. typeof LiteralDataPacket etc.)
533
533
  export class PacketList<T extends AnyPacket> extends Array<T> {
534
- static fromBinary(bytes: MaybeStream<Uint8Array>, allowedPackets: AllowedPackets, config?: Config): PacketList<AnyPacket>; // the packet types depend on`allowedPackets`
535
- public read(bytes: MaybeStream<Uint8Array>, allowedPackets: AllowedPackets, config?: Config): void;
536
- public write(): Uint8Array;
534
+ static fromBinary(bytes: MaybeStream<Uint8Array<ArrayBuffer>>, allowedPackets: AllowedPackets, config?: Config): PacketList<AnyPacket>; // the packet types depend on`allowedPackets`
535
+ public read(bytes: MaybeStream<Uint8Array<ArrayBuffer>>, allowedPackets: AllowedPackets, config?: Config): void;
536
+ public write(): Uint8Array<ArrayBuffer>;
537
537
  public filterByTag(...args: enums.packet[]): PacketList<T>;
538
538
  public indexOfTag(...tags: enums.packet[]): number[];
539
539
  public findPacket(tag: enums.packet): T | undefined;
@@ -543,13 +543,13 @@ export class PacketList<T extends AnyPacket> extends Array<T> {
543
543
 
544
544
  export interface UserID { name?: string; email?: string; comment?: string; }
545
545
  export interface SessionKey {
546
- data: Uint8Array;
546
+ data: Uint8Array<ArrayBuffer>;
547
547
  algorithm: enums.symmetricNames;
548
548
  aeadAlgorithm?: enums.aeadNames;
549
549
  }
550
550
 
551
551
  export interface DecryptedSessionKey {
552
- data: Uint8Array;
552
+ data: Uint8Array<ArrayBuffer>;
553
553
  algorithm: enums.symmetricNames | null; // `null` if the session key is associated with a SEIPDv2 packet
554
554
  }
555
555
 
@@ -594,13 +594,13 @@ export interface DecryptOptions {
594
594
  decryptionKeys?: MaybeArray<PrivateKey>;
595
595
  /** (optional) passwords to decrypt the message */
596
596
  passwords?: MaybeArray<string>;
597
- /** (optional) session keys in the form: { data:Uint8Array, algorithm:String } */
597
+ /** (optional) session keys in the form: { data:Uint8Array<ArrayBuffer>, algorithm:String } */
598
598
  sessionKeys?: MaybeArray<SessionKey>;
599
599
  /** (optional) array of public keys or single key, to verify signatures */
600
600
  verificationKeys?: MaybeArray<PublicKey>;
601
601
  /** (optional) whether data decryption should fail if the message is not signed with the provided publicKeys */
602
602
  expectSigned?: boolean;
603
- /** (optional) whether to return data as a string(Stream) or Uint8Array(Stream). If 'utf8' (the default), also normalize newlines. */
603
+ /** (optional) whether to return data as a string(Stream) or Uint8Array<ArrayBuffer>(Stream). If 'utf8' (the default), also normalize newlines. */
604
604
  format?: 'utf8' | 'binary';
605
605
  /** (optional) detached signature for verification */
606
606
  signature?: Signature;
@@ -628,7 +628,7 @@ export interface VerifyOptions {
628
628
  verificationKeys: MaybeArray<PublicKey>;
629
629
  /** (optional) whether verification should throw if the message is not signed with the provided publicKeys */
630
630
  expectSigned?: boolean;
631
- /** (optional) whether to return data as a string(Stream) or Uint8Array(Stream). If 'utf8' (the default), also normalize newlines. */
631
+ /** (optional) whether to return data as a string(Stream) or Uint8Array<ArrayBuffer>(Stream). If 'utf8' (the default), also normalize newlines. */
632
632
  format?: 'utf8' | 'binary';
633
633
  /** (optional) detached signature for verification */
634
634
  signature?: Signature;
@@ -648,7 +648,7 @@ export interface EncryptSessionKeyOptions extends SessionKey {
648
648
  config?: PartialConfig
649
649
  }
650
650
 
651
- interface SerializedKeyPair<T extends string | Uint8Array> {
651
+ interface SerializedKeyPair<T extends string | Uint8Array<ArrayBuffer>> {
652
652
  privateKey: T;
653
653
  publicKey: T;
654
654
  }
@@ -705,25 +705,25 @@ export function armor(messagetype: enums.armor, body: object, partindex?: number
705
705
  /**
706
706
  * DeArmor an OpenPGP armored message; verify the checksum and return the encoded bytes
707
707
  */
708
- export function unarmor(input: string, config?: Config): Promise<{ text: string, data: Stream<Uint8Array>, type: enums.armor }>;
708
+ export function unarmor(input: string, config?: Config): Promise<{ text: string, data: Stream<Uint8Array<ArrayBuffer>>, type: enums.armor }>;
709
709
 
710
710
  export declare class Argon2S2K {
711
711
  static reloadWasmModule(): void;
712
712
  static ARGON2_WASM_MEMORY_THRESHOLD_RELOAD: number;
713
713
  constructor(config: Config);
714
- salt: Uint8Array;
714
+ salt: Uint8Array<ArrayBuffer>;
715
715
  /** @throws Argon2OutOfMemoryError */
716
- produceKey(passphrase: string, keySize: number): Promise<Uint8Array>;
716
+ produceKey(passphrase: string, keySize: number): Promise<Uint8Array<ArrayBuffer>>;
717
717
  }
718
718
 
719
719
  interface KDFParamsData {
720
720
  version: number;
721
721
  hash: enums.hash;
722
722
  cipher: enums.symmetric;
723
- replacementFingerprint?: Uint8Array;
723
+ replacementFingerprint?: Uint8Array<ArrayBuffer>;
724
724
  }
725
725
 
726
726
  export class KDFParams {
727
727
  constructor(data: KDFParamsData);
728
- write(forReplacementParams?: boolean): Uint8Array;
728
+ write(forReplacementParams?: boolean): Uint8Array<ArrayBuffer>;
729
729
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@protontech/openpgp",
3
3
  "description": "OpenPGP.js is a Javascript implementation of the OpenPGP protocol. This is defined in RFC 4880.",
4
- "version": "6.1.1-patch.3",
4
+ "version": "6.1.1-patch.5",
5
5
  "license": "LGPL-3.0+",
6
6
  "homepage": "https://openpgpjs.org/",
7
7
  "engines": {
@@ -72,6 +72,7 @@
72
72
  "@openpgp/seek-bzip": "^1.0.5-git",
73
73
  "@openpgp/tweetnacl": "^1.0.4-1",
74
74
  "@openpgp/web-stream-tools": "~0.1.3",
75
+ "@protontech/eslint-plugin-enforce-uint8array-arraybuffer": "^1.0.0",
75
76
  "@rollup/plugin-alias": "^5.1.1",
76
77
  "@rollup/plugin-commonjs": "^25.0.8",
77
78
  "@rollup/plugin-node-resolve": "^15.3.0",
@@ -103,13 +104,13 @@
103
104
  "eslint-plugin-unicorn": "^48.0.1",
104
105
  "fflate": "^0.7.4",
105
106
  "mocha": "^10.7.3",
106
- "playwright": "^1.48.2",
107
+ "playwright": "^1.54.2",
107
108
  "rollup": "^4.24.2",
108
109
  "sinon": "^18.0.1",
109
110
  "ts-node": "^10.9.2",
110
111
  "tslib": "^2.8.0",
111
112
  "tsx": "^4.19.2",
112
- "typescript": "^5.6.3",
113
+ "typescript": "^5.9.2",
113
114
  "web-streams-polyfill": "^4.0.0"
114
115
  },
115
116
  "overrides": {