diff --git a/openpgp.d.ts b/openpgp.d.ts index fa8ec85d..137c0dfe 100644 --- a/openpgp.d.ts +++ b/openpgp.d.ts @@ -11,8 +11,9 @@ import type { WebStream as GenericWebStream, NodeWebStream as GenericNodeWebStream } from '@openpgp/web-stream-tools'; import enums from './src/enums'; +import config, { type Config, type PartialConfig } from './src/config'; -export { enums }; +export { enums, config, Config, PartialConfig }; /* ############## STREAM #################### */ type Data = Uint8Array | string; @@ -319,50 +320,6 @@ export class Message> { public appendSignature(detachedSignature: string | Uint8Array, config?: Config): Promise; } - -/* ############## CONFIG #################### */ - -interface Config { - preferredHashAlgorithm: enums.hash; - preferredSymmetricAlgorithm: enums.symmetric; - preferredCompressionAlgorithm: enums.compression; - showVersion: boolean; - showComment: boolean; - aeadProtect: boolean; - allowUnauthenticatedMessages: boolean; - allowUnauthenticatedStream: boolean; - minRSABits: number; - passwordCollisionCheck: boolean; - ignoreUnsupportedPackets: boolean; - ignoreMalformedPackets: boolean; - versionString: string; - commentString: string; - allowInsecureDecryptionWithSigningKeys: boolean; - allowInsecureVerificationWithReformattedKeys: boolean; - allowMissingKeyFlags: boolean; - constantTimePKCS1Decryption: boolean; - constantTimePKCS1DecryptionSupportedSymmetricAlgorithms: Set; - v6Keys: boolean; - enableParsingV5Entities: boolean; - preferredAEADAlgorithm: enums.aead; - aeadChunkSizeByte: number; - s2kType: enums.s2k.iterated | enums.s2k.argon2; - s2kIterationCountByte: number; - s2kArgon2Params: { passes: number, parallelism: number; memoryExponent: number; }; - maxUserIDLength: number; - knownNotations: string[]; - useEllipticFallback: boolean; - rejectHashAlgorithms: Set; - rejectMessageHashAlgorithms: Set; - rejectPublicKeyAlgorithms: Set; - rejectCurves: Set; -} -export const config: Config; - -// PartialConfig has the same properties as Config, but declared as optional. -// This interface is relevant for top-level functions, which accept a subset of configuration options -export interface PartialConfig extends Partial {} - /* ############## PACKET #################### */ export declare abstract class BasePacket { diff --git a/src/config/config.d.ts b/src/config/config.d.ts new file mode 100644 index 00000000..82d2bc5e --- /dev/null +++ b/src/config/config.d.ts @@ -0,0 +1,44 @@ +/** + * Global configuration values. + */ + +import enums from '../enums'; + +export interface Config { + preferredHashAlgorithm: enums.hash; + preferredSymmetricAlgorithm: enums.symmetric; + preferredCompressionAlgorithm: enums.compression; + showVersion: boolean; + showComment: boolean; + aeadProtect: boolean; + allowUnauthenticatedMessages: boolean; + allowUnauthenticatedStream: boolean; + minRSABits: number; + passwordCollisionCheck: boolean; + ignoreUnsupportedPackets: boolean; + ignoreMalformedPackets: boolean; + versionString: string; + commentString: string; + allowInsecureDecryptionWithSigningKeys: boolean; + allowInsecureVerificationWithReformattedKeys: boolean; + allowMissingKeyFlags: boolean; + constantTimePKCS1Decryption: boolean; + constantTimePKCS1DecryptionSupportedSymmetricAlgorithms: Set; + v6Keys: boolean; + enableParsingV5Entities: boolean; + preferredAEADAlgorithm: enums.aead; + aeadChunkSizeByte: number; + s2kType: enums.s2k.iterated | enums.s2k.argon2; + s2kIterationCountByte: number; + s2kArgon2Params: { passes: number, parallelism: number; memoryExponent: number; }; + maxUserIDLength: number; + knownNotations: string[]; + useEllipticFallback: boolean; + rejectHashAlgorithms: Set; + rejectMessageHashAlgorithms: Set; + rejectPublicKeyAlgorithms: Set; + rejectCurves: Set; +} + +declare const config: Config; +export default config; diff --git a/src/config/config.js b/src/config/config.js index 9e77710f..c24d47c7 100644 --- a/src/config/config.js +++ b/src/config/config.js @@ -87,6 +87,8 @@ export default { * by v6 keys and v6 signatures, respectively. * However, generation of v5 entities was supported behind config flag in OpenPGP.js v5, and some other libraries, * hence parsing them might be necessary in some cases. + * @memberof module:config + * @property {Boolean} enableParsingV5Entities */ enableParsingV5Entities: false, /** diff --git a/src/config/index.d.ts b/src/config/index.d.ts new file mode 100644 index 00000000..1a56960c --- /dev/null +++ b/src/config/index.d.ts @@ -0,0 +1,13 @@ +/** + * The config module cannot be written in TS directly for now, + * since our JSDoc compiler does not support TS. + */ +import config, { type Config } from './config'; + + +// PartialConfig has the same properties as Config, but declared as optional. +// This interface is relevant for top-level functions, which accept a subset of configuration options +interface PartialConfig extends Partial {} + +export { Config, PartialConfig }; +export default config;