@protontech/openpgp 5.8.0-0 → 5.9.0
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/lightweight/argon2id.min.mjs +1 -1
- package/dist/lightweight/argon2id.mjs +1 -1
- package/dist/lightweight/bn.interface.min.mjs +1 -1
- package/dist/lightweight/bn.interface.mjs +1 -1
- package/dist/lightweight/bn.min.mjs +1 -1
- package/dist/lightweight/bn.mjs +1 -1
- package/dist/lightweight/elliptic.min.mjs +1 -1
- package/dist/lightweight/elliptic.mjs +1 -1
- package/dist/lightweight/openpgp.min.mjs +2 -2
- package/dist/lightweight/openpgp.min.mjs.map +1 -1
- package/dist/lightweight/openpgp.mjs +51 -36
- package/dist/lightweight/ponyfill.es6.min.mjs +1 -1
- package/dist/lightweight/ponyfill.es6.mjs +1 -1
- package/dist/lightweight/web-streams-adapter.min.mjs +1 -1
- package/dist/lightweight/web-streams-adapter.mjs +1 -1
- package/dist/node/openpgp.js +51 -35
- package/dist/node/openpgp.min.js +3 -3
- package/dist/node/openpgp.min.js.map +1 -1
- package/dist/node/openpgp.min.mjs +3 -3
- package/dist/node/openpgp.min.mjs.map +1 -1
- package/dist/node/openpgp.mjs +51 -36
- package/dist/openpgp.js +51 -35
- package/dist/openpgp.min.js +3 -3
- package/dist/openpgp.min.js.map +1 -1
- package/dist/openpgp.min.mjs +3 -3
- package/dist/openpgp.min.mjs.map +1 -1
- package/dist/openpgp.mjs +51 -36
- package/openpgp.d.ts +21 -8
- package/package.json +1 -1
package/dist/openpgp.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! OpenPGP.js v5.
|
|
1
|
+
/*! OpenPGP.js v5.9.0 - 2023-05-15 - 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
|
const doneWritingPromise = Symbol('doneWritingPromise');
|
|
@@ -1907,7 +1907,7 @@ const util = {
|
|
|
1907
1907
|
if (!util.isString(data)) {
|
|
1908
1908
|
return false;
|
|
1909
1909
|
}
|
|
1910
|
-
const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+([a-zA-Z]{2,}
|
|
1910
|
+
const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+([a-zA-Z]{2,}[0-9]*|xn--[a-zA-Z\-0-9]+)))$/;
|
|
1911
1911
|
return re.test(data);
|
|
1912
1912
|
},
|
|
1913
1913
|
|
|
@@ -2618,6 +2618,8 @@ var enums = {
|
|
|
2618
2618
|
splitPrivateKey: 16,
|
|
2619
2619
|
/** 0x20 - This key may be used for authentication. */
|
|
2620
2620
|
authentication: 32,
|
|
2621
|
+
/** This key may be used for forwarded communications */
|
|
2622
|
+
forwardedCommunication: 64,
|
|
2621
2623
|
/** 0x80 - The private component of this key may be in the
|
|
2622
2624
|
* possession of more than one person. */
|
|
2623
2625
|
sharedPrivateKey: 128
|
|
@@ -2822,6 +2824,13 @@ var config = {
|
|
|
2822
2824
|
* @property {Boolean} allowUnauthenticatedStream
|
|
2823
2825
|
*/
|
|
2824
2826
|
allowUnauthenticatedStream: false,
|
|
2827
|
+
/**
|
|
2828
|
+
* Allow decrypting forwarded messages, using keys with 0x40 ('forwarded communication') flag.
|
|
2829
|
+
* Note: this is related to a **non-standard feature**.
|
|
2830
|
+
* @memberof module:config
|
|
2831
|
+
* @property {Boolean} allowForwardedMessages
|
|
2832
|
+
*/
|
|
2833
|
+
allowForwardedMessages: false,
|
|
2825
2834
|
/**
|
|
2826
2835
|
* @memberof module:config
|
|
2827
2836
|
* @property {Boolean} checksumRequired Do not throw error when armor is missing a checksum
|
|
@@ -2898,6 +2907,14 @@ var config = {
|
|
|
2898
2907
|
* @property {Boolean} ignoreMalformedPackets Ignore malformed packets on parsing instead of throwing an error
|
|
2899
2908
|
*/
|
|
2900
2909
|
ignoreMalformedPackets: false,
|
|
2910
|
+
/**
|
|
2911
|
+
* Parsing of packets is normally restricted to a predefined set of packets. For example a Sym. Encrypted Integrity Protected Data Packet can only
|
|
2912
|
+
* contain a certain set of packets including LiteralDataPacket. With this setting we can allow additional packets, which is probably not advisable
|
|
2913
|
+
* as a global config setting, but can be used for specific function calls (e.g. decrypt method of Message).
|
|
2914
|
+
* @memberof module:config
|
|
2915
|
+
* @property {Array} additionalAllowedPackets Allow additional packets on parsing. Defined as array of packet classes, e.g. [PublicKeyPacket]
|
|
2916
|
+
*/
|
|
2917
|
+
additionalAllowedPackets: [],
|
|
2901
2918
|
/**
|
|
2902
2919
|
* @memberof module:config
|
|
2903
2920
|
* @property {Boolean} showVersion Whether to include {@link module:config/config.versionString} in armored messages
|
|
@@ -2912,7 +2929,7 @@ var config = {
|
|
|
2912
2929
|
* @memberof module:config
|
|
2913
2930
|
* @property {String} versionString A version string to be included in armored messages
|
|
2914
2931
|
*/
|
|
2915
|
-
versionString: 'OpenPGP.js 5.
|
|
2932
|
+
versionString: 'OpenPGP.js 5.9.0',
|
|
2916
2933
|
/**
|
|
2917
2934
|
* @memberof module:config
|
|
2918
2935
|
* @property {String} commentString A comment string to be included in armored messages
|
|
@@ -14402,7 +14419,7 @@ function buildEcdhParam(public_algo, oid, kdfParams, fingerprint) {
|
|
|
14402
14419
|
return util.concatUint8Array([
|
|
14403
14420
|
oid.write(),
|
|
14404
14421
|
new Uint8Array([public_algo]),
|
|
14405
|
-
kdfParams.
|
|
14422
|
+
kdfParams.write(true),
|
|
14406
14423
|
util.stringToUint8Array('Anonymous Sender '),
|
|
14407
14424
|
kdfParams.replacementFingerprint || fingerprint.subarray(0, 20)
|
|
14408
14425
|
]);
|
|
@@ -15244,32 +15261,28 @@ class ECDHSymmetricKey {
|
|
|
15244
15261
|
|
|
15245
15262
|
// OpenPGP.js - An OpenPGP implementation in javascript
|
|
15246
15263
|
|
|
15264
|
+
const VERSION_FORWARDING = 0xFF;
|
|
15265
|
+
|
|
15247
15266
|
class KDFParams {
|
|
15248
15267
|
/**
|
|
15249
15268
|
* @param {Integer} version Version, defaults to 1
|
|
15250
15269
|
* @param {enums.hash} hash Hash algorithm
|
|
15251
15270
|
* @param {enums.symmetric} cipher Symmetric algorithm
|
|
15252
|
-
* @param {
|
|
15253
|
-
* @param {Uint8Array} replacementFingerprint (v2 only) fingerprint to use instead of recipient one (v5 keys, the 20 leftmost bytes of the fingerprint)
|
|
15254
|
-
* @param {Uint8Array} replacementKDFParams (v2 only) serialized KDF params to use in KDF digest computation
|
|
15271
|
+
* @param {Uint8Array} replacementFingerprint (forwarding only) fingerprint to use instead of recipient one (v5 keys, the 20 leftmost bytes of the fingerprint)
|
|
15255
15272
|
*/
|
|
15256
15273
|
constructor(data) {
|
|
15257
15274
|
if (data) {
|
|
15258
|
-
const { version, hash, cipher,
|
|
15275
|
+
const { version, hash, cipher, replacementFingerprint } = data;
|
|
15259
15276
|
this.version = version || 1;
|
|
15260
15277
|
this.hash = hash;
|
|
15261
15278
|
this.cipher = cipher;
|
|
15262
15279
|
|
|
15263
|
-
this.flags = flags;
|
|
15264
15280
|
this.replacementFingerprint = replacementFingerprint;
|
|
15265
|
-
this.replacementKDFParams = replacementKDFParams;
|
|
15266
15281
|
} else {
|
|
15267
15282
|
this.version = null;
|
|
15268
15283
|
this.hash = null;
|
|
15269
15284
|
this.cipher = null;
|
|
15270
|
-
this.flags = null;
|
|
15271
15285
|
this.replacementFingerprint = null;
|
|
15272
|
-
this.replacementKDFParams = null;
|
|
15273
15286
|
}
|
|
15274
15287
|
}
|
|
15275
15288
|
|
|
@@ -15279,44 +15292,41 @@ class KDFParams {
|
|
|
15279
15292
|
* @returns {Number} Number of read bytes.
|
|
15280
15293
|
*/
|
|
15281
15294
|
read(input) {
|
|
15295
|
+
const totalBytes = input[0];
|
|
15282
15296
|
this.version = input[1];
|
|
15283
15297
|
this.hash = input[2];
|
|
15284
15298
|
this.cipher = input[3];
|
|
15285
15299
|
let readBytes = 4;
|
|
15286
15300
|
|
|
15287
|
-
if (this.version ===
|
|
15288
|
-
|
|
15289
|
-
|
|
15290
|
-
|
|
15291
|
-
readBytes += 20;
|
|
15292
|
-
}
|
|
15293
|
-
if (this.flags & enums.kdfFlags.replace_kdf_params) {
|
|
15294
|
-
const fieldLength = input[readBytes] + 1; // account for length
|
|
15295
|
-
this.replacementKDFParams = input.slice(readBytes, readBytes + fieldLength);
|
|
15296
|
-
readBytes += fieldLength;
|
|
15297
|
-
}
|
|
15301
|
+
if (this.version === VERSION_FORWARDING) {
|
|
15302
|
+
const fingerprintLength = totalBytes - readBytes + 1; // acount for length byte
|
|
15303
|
+
this.replacementFingerprint = input.slice(readBytes, readBytes + fingerprintLength);
|
|
15304
|
+
readBytes += fingerprintLength;
|
|
15298
15305
|
}
|
|
15299
15306
|
return readBytes;
|
|
15300
15307
|
}
|
|
15301
15308
|
|
|
15302
15309
|
/**
|
|
15303
15310
|
* Write KDFParams to an Uint8Array
|
|
15311
|
+
* @param {Boolean} [forReplacementParams] - forwarding only: whether to serialize data to use for replacement params
|
|
15304
15312
|
* @returns {Uint8Array} Array with the KDFParams value
|
|
15305
15313
|
*/
|
|
15306
|
-
write() {
|
|
15307
|
-
if (!this.version || this.version === 1) {
|
|
15314
|
+
write(forReplacementParams) {
|
|
15315
|
+
if (!this.version || this.version === 1 || forReplacementParams) {
|
|
15308
15316
|
return new Uint8Array([3, 1, this.hash, this.cipher]);
|
|
15309
15317
|
}
|
|
15310
15318
|
|
|
15311
|
-
const
|
|
15312
|
-
new Uint8Array([
|
|
15313
|
-
|
|
15314
|
-
|
|
15319
|
+
const forwardingFields = util.concatUint8Array([
|
|
15320
|
+
new Uint8Array([
|
|
15321
|
+
3 + this.replacementFingerprint.length,
|
|
15322
|
+
this.version,
|
|
15323
|
+
this.hash,
|
|
15324
|
+
this.cipher
|
|
15325
|
+
]),
|
|
15326
|
+
this.replacementFingerprint
|
|
15315
15327
|
]);
|
|
15316
15328
|
|
|
15317
|
-
|
|
15318
|
-
v2Fields[0] = v2Fields.length - 1;
|
|
15319
|
-
return new Uint8Array(v2Fields);
|
|
15329
|
+
return forwardingFields;
|
|
15320
15330
|
}
|
|
15321
15331
|
}
|
|
15322
15332
|
|
|
@@ -24286,6 +24296,9 @@ class PacketList extends Array {
|
|
|
24286
24296
|
* @async
|
|
24287
24297
|
*/
|
|
24288
24298
|
async read(bytes, allowedPackets, config$1 = config) {
|
|
24299
|
+
if (config$1.additionalAllowedPackets.length) {
|
|
24300
|
+
allowedPackets = { ...allowedPackets, ...util.constructAllowedPackets(config$1.additionalAllowedPackets) };
|
|
24301
|
+
}
|
|
24289
24302
|
this.stream = transformPair(bytes, async (readable, writable) => {
|
|
24290
24303
|
const writer = getWriter(writable);
|
|
24291
24304
|
try {
|
|
@@ -27839,7 +27852,8 @@ function isValidDecryptionKeyPacket(signature, config) {
|
|
|
27839
27852
|
|
|
27840
27853
|
return !signature.keyFlags ||
|
|
27841
27854
|
(signature.keyFlags[0] & enums.keyFlags.encryptCommunication) !== 0 ||
|
|
27842
|
-
(signature.keyFlags[0] & enums.keyFlags.encryptStorage) !== 0
|
|
27855
|
+
(signature.keyFlags[0] & enums.keyFlags.encryptStorage) !== 0 ||
|
|
27856
|
+
(config.allowForwardedMessages && (signature.keyFlags[0] & enums.keyFlags.forwardedCommunication) !== 0);
|
|
27843
27857
|
}
|
|
27844
27858
|
|
|
27845
27859
|
/**
|
|
@@ -28787,7 +28801,7 @@ class Key {
|
|
|
28787
28801
|
throw exception || new Error('Could not find primary user');
|
|
28788
28802
|
}
|
|
28789
28803
|
await Promise.all(users.map(async function (a) {
|
|
28790
|
-
return a.
|
|
28804
|
+
return a.selfCertification.revoked || a.user.isRevoked(a.selfCertification, null, date, config$1);
|
|
28791
28805
|
}));
|
|
28792
28806
|
// sort by primary user flag and signature creation time
|
|
28793
28807
|
const primaryUser = users.sort(function(a, b) {
|
|
@@ -29010,7 +29024,8 @@ class Key {
|
|
|
29010
29024
|
|
|
29011
29025
|
results.push(...signatures.map(
|
|
29012
29026
|
signature => ({
|
|
29013
|
-
userID: user.userID.userID,
|
|
29027
|
+
userID: user.userID ? user.userID.userID : null,
|
|
29028
|
+
userAttribute: user.userAttribute,
|
|
29014
29029
|
keyID: signature.keyID,
|
|
29015
29030
|
valid: signature.valid
|
|
29016
29031
|
}))
|
|
@@ -44742,4 +44757,4 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
44742
44757
|
'default': loadWasm
|
|
44743
44758
|
});
|
|
44744
44759
|
|
|
44745
|
-
export { AEADEncryptedDataPacket, CleartextMessage, CompressedDataPacket, LiteralDataPacket, MarkerPacket, Message, OnePassSignaturePacket, PacketList, PrivateKey, PublicKey, PublicKeyEncryptedSessionKeyPacket, PublicKeyPacket, PublicSubkeyPacket, SecretKeyPacket, SecretSubkeyPacket, Signature, SignaturePacket, Subkey, SymEncryptedIntegrityProtectedDataPacket, SymEncryptedSessionKeyPacket, SymmetricallyEncryptedDataPacket, TrustPacket, UnparseablePacket, UserAttributePacket, UserIDPacket, armor, config, createCleartextMessage, createMessage, decrypt$4 as decrypt, decryptKey, decryptSessionKeys, encrypt$4 as encrypt, encryptKey, encryptSessionKey, enums, generateKey, generateSessionKey$1 as generateSessionKey, readCleartextMessage, readKey, readKeys, readMessage, readPrivateKey, readPrivateKeys, readSignature, reformatKey, revokeKey, sign$5 as sign, unarmor, verify$5 as verify };
|
|
44760
|
+
export { AEADEncryptedDataPacket, CleartextMessage, CompressedDataPacket, KDFParams, LiteralDataPacket, MarkerPacket, Message, OnePassSignaturePacket, PacketList, PrivateKey, PublicKey, PublicKeyEncryptedSessionKeyPacket, PublicKeyPacket, PublicSubkeyPacket, SecretKeyPacket, SecretSubkeyPacket, Signature, SignaturePacket, Subkey, SymEncryptedIntegrityProtectedDataPacket, SymEncryptedSessionKeyPacket, SymmetricallyEncryptedDataPacket, TrustPacket, UnparseablePacket, UserAttributePacket, UserIDPacket, armor, config, createCleartextMessage, createMessage, decrypt$4 as decrypt, decryptKey, decryptSessionKeys, encrypt$4 as encrypt, encryptKey, encryptSessionKey, enums, generateKey, generateSessionKey$1 as generateSessionKey, readCleartextMessage, readKey, readKeys, readMessage, readPrivateKey, readPrivateKeys, readSignature, reformatKey, revokeKey, sign$5 as sign, unarmor, verify$5 as verify };
|
package/openpgp.d.ts
CHANGED
|
@@ -101,6 +101,7 @@ export class Subkey {
|
|
|
101
101
|
public getExpirationTime(date?: Date, config?: Config): Promise<Date | typeof Infinity | null>
|
|
102
102
|
public isRevoked(signature: SignaturePacket, key: AnyKeyPacket, date?: Date, config?: Config): Promise<boolean>;
|
|
103
103
|
public update(subKey: Subkey, date?: Date, config?: Config): Promise<void>
|
|
104
|
+
public revoke(primaryKey: SecretKeyPacket, reasonForRevocation?: ReasonForRevocation, date?: Date, config?: Config): Promise<Subkey>;
|
|
104
105
|
}
|
|
105
106
|
|
|
106
107
|
export interface User {
|
|
@@ -227,18 +228,17 @@ export function decrypt<T extends MaybeStream<Data>>(options: DecryptOptions & {
|
|
|
227
228
|
string
|
|
228
229
|
}>;
|
|
229
230
|
|
|
230
|
-
export function verify
|
|
231
|
-
|
|
231
|
+
export function verify(options: VerifyOptions & { message: CleartextMessage, format?: 'utf8' }): Promise<VerifyMessageResult<string>>;
|
|
232
|
+
export function verify<T extends MaybeStream<Data>>(options: VerifyOptions & { message: Message<T>, format: 'binary' }): Promise<VerifyMessageResult<
|
|
232
233
|
T extends WebStream<infer X> ? WebStream<Uint8Array> :
|
|
233
234
|
T extends NodeStream<infer X> ? NodeStream<Uint8Array> :
|
|
234
235
|
Uint8Array
|
|
235
|
-
|
|
236
|
-
export function verify<T extends MaybeStream<Data>>(options: VerifyOptions & { message: Message<T> }): Promise<VerifyMessageResult
|
|
237
|
-
data:
|
|
236
|
+
>>;
|
|
237
|
+
export function verify<T extends MaybeStream<Data>>(options: VerifyOptions & { message: Message<T> }): Promise<VerifyMessageResult<
|
|
238
238
|
T extends WebStream<infer X> ? WebStream<string> :
|
|
239
239
|
T extends NodeStream<infer X> ? NodeStream<string> :
|
|
240
240
|
string
|
|
241
|
-
|
|
241
|
+
>>;
|
|
242
242
|
|
|
243
243
|
/** Class that represents an OpenPGP message. Can be an encrypted message, signed message, compressed message or literal message
|
|
244
244
|
*/
|
|
@@ -722,8 +722,8 @@ interface DecryptMessageResult {
|
|
|
722
722
|
filename: string;
|
|
723
723
|
}
|
|
724
724
|
|
|
725
|
-
interface VerifyMessageResult {
|
|
726
|
-
data:
|
|
725
|
+
interface VerifyMessageResult<T extends MaybeStream<Data> = MaybeStream<Data>> {
|
|
726
|
+
data: T;
|
|
727
727
|
signatures: VerificationResult[];
|
|
728
728
|
}
|
|
729
729
|
|
|
@@ -869,6 +869,7 @@ export namespace enums {
|
|
|
869
869
|
encryptStorage = 8,
|
|
870
870
|
splitPrivateKey = 16,
|
|
871
871
|
authentication = 32,
|
|
872
|
+
forwardedCommunication = 64,
|
|
872
873
|
sharedPrivateKey = 128,
|
|
873
874
|
}
|
|
874
875
|
|
|
@@ -913,3 +914,15 @@ export namespace enums {
|
|
|
913
914
|
gnu = 101
|
|
914
915
|
}
|
|
915
916
|
}
|
|
917
|
+
|
|
918
|
+
interface KDFParamsData {
|
|
919
|
+
version: number;
|
|
920
|
+
hash: enums.hash;
|
|
921
|
+
cipher: enums.symmetric;
|
|
922
|
+
replacementFingerprint?: Uint8Array;
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
export class KDFParams {
|
|
926
|
+
constructor(data: KDFParamsData);
|
|
927
|
+
write(forReplacementParams?: boolean): Uint8Array;
|
|
928
|
+
}
|
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": "5.
|
|
4
|
+
"version": "5.9.0",
|
|
5
5
|
"license": "LGPL-3.0+",
|
|
6
6
|
"homepage": "https://openpgpjs.org/",
|
|
7
7
|
"engines": {
|