mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-02-26 02:32:49 +00:00
Rebuild full d.ts from jsdoc in the source code of openpgp. (#33940)
Correct some declarations. Update tests for current td.ts.
This commit is contained in:
parent
0c776885f2
commit
61cd541817
5
types/openpgp/common/index.d.ts
vendored
5
types/openpgp/common/index.d.ts
vendored
@ -1,5 +0,0 @@
|
||||
export class HKP {
|
||||
constructor(keyServerUrl?: string);
|
||||
lookup(options: {keyId?: string, query?: string }): Promise<string>;
|
||||
upload(publicKeyArmored: string): Promise<Response>;
|
||||
}
|
||||
6075
types/openpgp/index.d.ts
vendored
6075
types/openpgp/index.d.ts
vendored
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,8 @@
|
||||
import { openpgp } from "openpgp"
|
||||
|
||||
// Open PGP Sample codes
|
||||
|
||||
var options: openpgp.KeyOptions = {
|
||||
const options: openpgp.KeyOptions = {
|
||||
numBits: 2048,
|
||||
userIds: [{
|
||||
name: 'Jon Smith',
|
||||
@ -8,53 +10,51 @@ var options: openpgp.KeyOptions = {
|
||||
}],
|
||||
passphrase: 'super long and hard to guess secret'
|
||||
};
|
||||
|
||||
openpgp.generateKey(options).then(function (keypair) {
|
||||
openpgp.generateKey(options).then((keypair) => {
|
||||
// success
|
||||
var privkey = keypair.privateKeyArmored;
|
||||
var pubkey = keypair.publicKeyArmored;
|
||||
}).catch(function (error) {
|
||||
const privkey = keypair.privateKeyArmored;
|
||||
const pubkey = keypair.publicKeyArmored;
|
||||
}).catch((error) => {
|
||||
// failure
|
||||
});
|
||||
|
||||
|
||||
var spubkey = '-----BEGIN PGP PUBLIC KEY BLOCK ... END PGP PUBLIC KEY BLOCK-----';
|
||||
const spubkey = '-----BEGIN PGP PUBLIC KEY BLOCK ... END PGP PUBLIC KEY BLOCK-----';
|
||||
|
||||
openpgp.key.readArmored(spubkey)
|
||||
.then(function (publicKey) {
|
||||
.then((publicKey) => {
|
||||
return {
|
||||
message: openpgp.message.fromText('Hello, World!'),
|
||||
publicKeys: publicKey.keys
|
||||
};
|
||||
})
|
||||
.then(openpgp.encrypt)
|
||||
.then(function (pgpMessage) {
|
||||
.then((pgpMessage) => {
|
||||
// success
|
||||
})
|
||||
.catch(function (error) {
|
||||
.catch((error) => {
|
||||
// failure
|
||||
});
|
||||
|
||||
var sprivkey = '-----BEGIN PGP PRIVATE KEY BLOCK ... END PGP PRIVATE KEY BLOCK-----';
|
||||
var pgpMessageStr = '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----';
|
||||
const sprivkey = '-----BEGIN PGP PRIVATE KEY BLOCK ... END PGP PRIVATE KEY BLOCK-----';
|
||||
const pgpMessageStr = '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----';
|
||||
|
||||
openpgp.message.readArmored(pgpMessageStr).then(function(pgpMessage) {
|
||||
openpgp.message.readArmored(pgpMessageStr).then((pgpMessage) => {
|
||||
const options = {
|
||||
message: pgpMessage
|
||||
};
|
||||
return openpgp.decrypt(options);
|
||||
}).then(function (plaintext) {
|
||||
}).then((plaintext) => {
|
||||
// success
|
||||
}).catch(function (error) {
|
||||
}).catch((error) => {
|
||||
// failure
|
||||
});
|
||||
|
||||
const promises: [Promise<openpgp.key.KeyResult>, Promise<openpgp.message.Message>] = [
|
||||
const promises: [Promise<{ keys: openpgp.key.Key[], err: Error[] | null }>, Promise<openpgp.message.Message>] = [
|
||||
openpgp.key.readArmored(sprivkey),
|
||||
openpgp.message.readArmored(pgpMessageStr)
|
||||
];
|
||||
|
||||
Promise.all(promises).then(function (values) {
|
||||
Promise.all(promises).then((values) => {
|
||||
const keyObject: openpgp.key.KeyResult = values[0];
|
||||
const pgpMessage: openpgp.message.Message = values[1];
|
||||
const privateKey = keyObject.keys[0];
|
||||
@ -64,13 +64,13 @@ Promise.all(promises).then(function (values) {
|
||||
message: pgpMessage
|
||||
};
|
||||
return openpgp.decrypt(options);
|
||||
}).then(function (plaintext) {
|
||||
}).then((plaintext) => {
|
||||
// success
|
||||
}).catch(function (error) {
|
||||
}).catch((error) => {
|
||||
// failure
|
||||
});
|
||||
|
||||
openpgp.initWorker({ path:'openpgp.worker.js' });
|
||||
openpgp.initWorker('openpgp.worker.js');
|
||||
|
||||
(async () => {
|
||||
let msgOptions: openpgp.EncryptOptions;
|
||||
@ -81,10 +81,10 @@ openpgp.initWorker({ path:'openpgp.worker.js' });
|
||||
armor: false,
|
||||
};
|
||||
|
||||
let cipher = await openpgp.encrypt(msgOptions);
|
||||
let encrypted = cipher.message.packets.write(); // get raw encrypted packets as Uint8Array
|
||||
const cipher = await openpgp.encrypt(msgOptions);
|
||||
const encrypted = cipher.message.packets.write(); // get raw encrypted packets as Uint8Array
|
||||
|
||||
let plain = await openpgp.decrypt({
|
||||
const plain = await openpgp.decrypt({
|
||||
message: await openpgp.message.read(encrypted),
|
||||
passwords: ['secret stuff'],
|
||||
format: 'binary'
|
||||
@ -94,14 +94,14 @@ openpgp.initWorker({ path:'openpgp.worker.js' });
|
||||
})();
|
||||
|
||||
(async () => {
|
||||
let cipher = await openpgp.encrypt({
|
||||
const cipher = await openpgp.encrypt({
|
||||
message: openpgp.message.fromText('hello world'),
|
||||
passwords: 'super secure',
|
||||
armor: true,
|
||||
});
|
||||
let encrypted = cipher.data;
|
||||
const encrypted = cipher.data;
|
||||
|
||||
let plain = await openpgp.decrypt({
|
||||
const plain = await openpgp.decrypt({
|
||||
message: await openpgp.message.readArmored(encrypted),
|
||||
passwords: 'super secure',
|
||||
});
|
||||
@ -109,10 +109,9 @@ openpgp.initWorker({ path:'openpgp.worker.js' });
|
||||
return plain.data;
|
||||
})();
|
||||
|
||||
|
||||
(async () => {
|
||||
const publicKey = (await openpgp.key.readArmored(spubkey))
|
||||
const privateKey = (await openpgp.key.readArmored(sprivkey))
|
||||
const publicKey = (await openpgp.key.readArmored(spubkey));
|
||||
const privateKey = (await openpgp.key.readArmored(sprivkey));
|
||||
const signOptions: openpgp.SignOptions = {
|
||||
message: openpgp.message.fromText('hello world'),
|
||||
privateKeys: privateKey.keys,
|
||||
@ -121,7 +120,7 @@ openpgp.initWorker({ path:'openpgp.worker.js' });
|
||||
|
||||
const signed = await openpgp.sign(signOptions);
|
||||
|
||||
const signature = signed.signature as openpgp.Signature;
|
||||
const signature = signed.signature as openpgp.signature.Signature;
|
||||
const message = signed.message;
|
||||
|
||||
const verifyOptions: openpgp.VerifyOptions = {
|
||||
@ -130,60 +129,46 @@ openpgp.initWorker({ path:'openpgp.worker.js' });
|
||||
publicKeys: publicKey.keys
|
||||
};
|
||||
|
||||
let verified = await openpgp.verify(verifyOptions);
|
||||
const verified = await openpgp.verify(verifyOptions);
|
||||
|
||||
return verified.signatures[0].valid;
|
||||
})();
|
||||
|
||||
async () => {
|
||||
let hkp = new openpgp.HKP();
|
||||
|
||||
const hkpOptions = {
|
||||
query: 'alice@example.com'
|
||||
};
|
||||
|
||||
const armoredPubkey = await hkp.lookup(hkpOptions);
|
||||
await openpgp.key.readArmored(armoredPubkey);
|
||||
|
||||
hkp = new openpgp.HKP('https://pgp.mit.edu');
|
||||
|
||||
const pubkey = '-----BEGIN PGP PUBLIC KEY BLOCK ... END PGP PUBLIC KEY BLOCK-----';
|
||||
|
||||
await hkp.upload(pubkey);
|
||||
}
|
||||
|
||||
// Open PGP Tests
|
||||
|
||||
const keyoptions: openpgp.KeyOptions = null;
|
||||
const mpi: openpgp.type.mpi.MPI = null;
|
||||
const mpis: openpgp.type.mpi.MPI[] = [];
|
||||
|
||||
var keyoptions: openpgp.KeyOptions;
|
||||
var mpi: openpgp.crypto.Mpi;
|
||||
var mpis: Array<openpgp.crypto.Mpi>;
|
||||
|
||||
openpgp.armor.armor(openpgp.enums.armor.message, {}, 0, 1);
|
||||
openpgp.armor.dearmor("");
|
||||
openpgp.encoding.armor.armor(openpgp.enums.armor.message, {}, 0, 1);
|
||||
openpgp.encoding.armor.dearmor("");
|
||||
|
||||
openpgp.cleartext.readArmored("");
|
||||
|
||||
openpgp.crypto.generateSessionKey(openpgp.enums.symmetric.aes128);
|
||||
openpgp.crypto.getPrefixRandom(openpgp.enums.symmetric.aes128);
|
||||
openpgp.crypto.getPrivateMpiCount(openpgp.enums.symmetric.aes128);
|
||||
openpgp.crypto.publicKeyDecrypt(openpgp.enums.publicKey.rsa_encrypt, mpis, mpis, mpi);
|
||||
openpgp.crypto.publicKeyEncrypt(openpgp.enums.publicKey.rsa_encrypt, mpis, mpi);
|
||||
openpgp.crypto.crypto.generateSessionKey(openpgp.enums.symmetric.aes128);
|
||||
openpgp.crypto.crypto.getPrefixRandom(openpgp.enums.symmetric.aes128);
|
||||
// openpgp.crypto.crypto.getPrivateMpiCount(openpgp.enums.symmetric.aes128);
|
||||
openpgp.crypto.crypto.publicKeyDecrypt(openpgp.enums.publicKey.rsa_encrypt, mpis, mpis, "");
|
||||
openpgp.crypto.crypto.publicKeyEncrypt(openpgp.enums.publicKey.rsa_encrypt, mpis, mpi, "");
|
||||
|
||||
openpgp.crypto;
|
||||
// API update with no documentation
|
||||
openpgp.crypto.cfb.decrypt("", "", "", true);
|
||||
openpgp.crypto.cfb.encrypt("", "", "", "", true);
|
||||
openpgp.crypto.cfb.mdc({}, "", "");
|
||||
openpgp.crypto.cfb.encrypt("", "", "", true);
|
||||
// Function removed from openpgp.crypto.cfb
|
||||
// openpgp.crypto.cfb.mdc({}, "", "");
|
||||
|
||||
openpgp.crypto.hash.digest(openpgp.enums.hash.md5, "");
|
||||
openpgp.crypto.hash.digest(openpgp.enums.hash.md5, new Uint8Array([0, 1]));
|
||||
openpgp.crypto.hash.getHashByteLength(openpgp.enums.hash.md5);
|
||||
|
||||
openpgp.crypto.random.getRandomBigInteger(0);
|
||||
openpgp.crypto.random.getRandomBN(mpi, mpi);
|
||||
openpgp.crypto.random.getRandomBytes(0);
|
||||
openpgp.crypto.random.getRandomValues(openpgp.util.str_to_Uint8Array(""));
|
||||
openpgp.crypto.random.getSecureRandom(0, 1);
|
||||
// function removed from openpgp.crypto.random
|
||||
// openpgp.crypto.random.getRandomValues(openpgp.util.str_to_Uint8Array(""));
|
||||
// openpgp.crypto.random.getSecureRandom(0, 1);
|
||||
|
||||
openpgp.crypto.signature.sign(openpgp.enums.hash.md5, openpgp.enums.publicKey.rsa_encrypt, mpis, mpis, "");
|
||||
openpgp.crypto.signature.verify(openpgp.enums.publicKey.rsa_encrypt, openpgp.enums.hash.md5, mpis, mpis, "");
|
||||
openpgp.crypto.signature.sign(openpgp.enums.publicKey.rsa_encrypt, openpgp.enums.hash.md5, mpis, new Uint8Array([0, 1]), new Uint8Array([0, 1]));
|
||||
openpgp.crypto.signature.verify(openpgp.enums.publicKey.rsa_encrypt, openpgp.enums.hash.md5, mpis, mpis, new Uint8Array([0, 1]), new Uint8Array([0, 1]));
|
||||
|
||||
openpgp.key.generate(keyoptions);
|
||||
openpgp.key.readArmored("");
|
||||
|
||||
@ -2,6 +2,10 @@
|
||||
"private": true,
|
||||
"types": "index",
|
||||
"typesVersions": {
|
||||
">=3.2.0-0": { "*": ["ts3.2/*"] }
|
||||
">=3.2.0-0": {
|
||||
"*": [
|
||||
"ts3.2/*"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
6148
types/openpgp/ts3.2/index.d.ts
vendored
6148
types/openpgp/ts3.2/index.d.ts
vendored
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,5 @@
|
||||
import { openpgp } from "openpgp";
|
||||
|
||||
// Open PGP Sample codes
|
||||
|
||||
var options: openpgp.KeyOptions = {
|
||||
@ -8,7 +10,6 @@ var options: openpgp.KeyOptions = {
|
||||
}],
|
||||
passphrase: 'super long and hard to guess secret'
|
||||
};
|
||||
|
||||
openpgp.generateKey(options).then(function (keypair) {
|
||||
// success
|
||||
var privkey = keypair.privateKeyArmored;
|
||||
@ -38,7 +39,7 @@ openpgp.key.readArmored(spubkey)
|
||||
var sprivkey = '-----BEGIN PGP PRIVATE KEY BLOCK ... END PGP PRIVATE KEY BLOCK-----';
|
||||
var pgpMessageStr = '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----';
|
||||
|
||||
openpgp.message.readArmored(pgpMessageStr).then(function(pgpMessage) {
|
||||
openpgp.message.readArmored(pgpMessageStr).then(function (pgpMessage) {
|
||||
const options = {
|
||||
message: pgpMessage
|
||||
};
|
||||
@ -49,11 +50,12 @@ openpgp.message.readArmored(pgpMessageStr).then(function(pgpMessage) {
|
||||
// failure
|
||||
});
|
||||
|
||||
const promises: [Promise<openpgp.key.KeyResult>, Promise<openpgp.message.Message>] = [
|
||||
const promises: [Promise<{ keys: Array<openpgp.key.Key>, err: Array<Error> | null }>, Promise<openpgp.message.Message>] = [
|
||||
openpgp.key.readArmored(sprivkey),
|
||||
openpgp.message.readArmored(pgpMessageStr)
|
||||
];
|
||||
|
||||
|
||||
Promise.all(promises).then(function (values) {
|
||||
const keyObject: openpgp.key.KeyResult = values[0];
|
||||
const pgpMessage: openpgp.message.Message = values[1];
|
||||
@ -70,7 +72,7 @@ Promise.all(promises).then(function (values) {
|
||||
// failure
|
||||
});
|
||||
|
||||
openpgp.initWorker({ path:'openpgp.worker.js' });
|
||||
openpgp.initWorker('openpgp.worker.js');
|
||||
|
||||
(async () => {
|
||||
let msgOptions: openpgp.EncryptOptions;
|
||||
@ -120,7 +122,7 @@ openpgp.initWorker({ path:'openpgp.worker.js' });
|
||||
|
||||
const signed = await openpgp.sign(signOptions);
|
||||
|
||||
const signature = signed.signature as openpgp.Signature;
|
||||
const signature = signed.signature as openpgp.signature.Signature;
|
||||
const message = signed.message;
|
||||
|
||||
const verifyOptions: openpgp.VerifyOptions = {
|
||||
@ -138,34 +140,38 @@ openpgp.initWorker({ path:'openpgp.worker.js' });
|
||||
|
||||
|
||||
var keyoptions: openpgp.KeyOptions;
|
||||
var mpi: openpgp.crypto.Mpi;
|
||||
var mpis: Array<openpgp.crypto.Mpi>;
|
||||
var mpi: openpgp.type.mpi.MPI;
|
||||
var mpis: Array<openpgp.type.mpi.MPI>;
|
||||
|
||||
openpgp.armor.armor(openpgp.enums.armor.message, {}, 0, 1);
|
||||
openpgp.armor.dearmor("");
|
||||
openpgp.encoding.armor.armor(openpgp.enums.armor.message, {}, 0, 1);
|
||||
openpgp.encoding.armor.dearmor("");
|
||||
|
||||
openpgp.cleartext.readArmored("");
|
||||
|
||||
openpgp.crypto.generateSessionKey(openpgp.enums.symmetric.aes128);
|
||||
openpgp.crypto.getPrefixRandom(openpgp.enums.symmetric.aes128);
|
||||
openpgp.crypto.getPrivateMpiCount(openpgp.enums.symmetric.aes128);
|
||||
openpgp.crypto.publicKeyDecrypt(openpgp.enums.publicKey.rsa_encrypt, mpis, mpis, mpi);
|
||||
openpgp.crypto.publicKeyEncrypt(openpgp.enums.publicKey.rsa_encrypt, mpis, mpi);
|
||||
openpgp.crypto.crypto.generateSessionKey(openpgp.enums.symmetric.aes128);
|
||||
openpgp.crypto.crypto.getPrefixRandom(openpgp.enums.symmetric.aes128);
|
||||
// openpgp.crypto.crypto.getPrivateMpiCount(openpgp.enums.symmetric.aes128);
|
||||
openpgp.crypto.crypto.publicKeyDecrypt(openpgp.enums.publicKey.rsa_encrypt, mpis, mpis, "");
|
||||
openpgp.crypto.crypto.publicKeyEncrypt(openpgp.enums.publicKey.rsa_encrypt, mpis, mpi, "");
|
||||
|
||||
openpgp.crypto
|
||||
// API update with no documentation
|
||||
openpgp.crypto.cfb.decrypt("", "", "", true);
|
||||
openpgp.crypto.cfb.encrypt("", "", "", "", true);
|
||||
openpgp.crypto.cfb.mdc({}, "", "");
|
||||
openpgp.crypto.cfb.encrypt("", "", "", true);
|
||||
// Function removed from openpgp.crypto.cfb
|
||||
// openpgp.crypto.cfb.mdc({}, "", "");
|
||||
|
||||
openpgp.crypto.hash.digest(openpgp.enums.hash.md5, "");
|
||||
openpgp.crypto.hash.digest(openpgp.enums.hash.md5, new Uint8Array([0, 1]));
|
||||
openpgp.crypto.hash.getHashByteLength(openpgp.enums.hash.md5);
|
||||
|
||||
openpgp.crypto.random.getRandomBigInteger(0);
|
||||
openpgp.crypto.random.getRandomBN(mpi, mpi);
|
||||
openpgp.crypto.random.getRandomBytes(0);
|
||||
openpgp.crypto.random.getRandomValues(openpgp.util.str_to_Uint8Array(""));
|
||||
openpgp.crypto.random.getSecureRandom(0, 1);
|
||||
// function removed from openpgp.crypto.random
|
||||
// openpgp.crypto.random.getRandomValues(openpgp.util.str_to_Uint8Array(""));
|
||||
// openpgp.crypto.random.getSecureRandom(0, 1);
|
||||
|
||||
openpgp.crypto.signature.sign(openpgp.enums.hash.md5, openpgp.enums.publicKey.rsa_encrypt, mpis, mpis, "");
|
||||
openpgp.crypto.signature.verify(openpgp.enums.publicKey.rsa_encrypt, openpgp.enums.hash.md5, mpis, mpis, "");
|
||||
openpgp.crypto.signature.sign(openpgp.enums.publicKey.rsa_encrypt, openpgp.enums.hash.md5, mpis, new Uint8Array([0, 1]), new Uint8Array([0, 1]));
|
||||
openpgp.crypto.signature.verify(openpgp.enums.publicKey.rsa_encrypt, openpgp.enums.hash.md5, mpis, mpis, new Uint8Array([0, 1]), new Uint8Array([0, 1]));
|
||||
|
||||
openpgp.key.generate(keyoptions);
|
||||
openpgp.key.readArmored("");
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
"lib": [
|
||||
"es6", "dom"
|
||||
],
|
||||
"esModuleInterop": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
|
||||
@ -6,8 +6,9 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": false,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
"space-before-function-paren": false,
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"whitespace": false
|
||||
"whitespace": false,
|
||||
"no-trailing-whitespace": false
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user