mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 07:47:04 +00:00
@types/node-forge Added resolvers for the (#30278)
* types/node-forge/index.d.ts * Fix test and add functional * fix return type in method: getBytesSync * fixed options in sign and verify for eddsa
This commit is contained in:
committed by
Pranav Senthilnathan
parent
cd69e97b8b
commit
5b0300b1fc
@@ -27,3 +27,4 @@ BSD-2-Clause
|
||||
[Aakash Goenka](https://github.com/a-k-g)
|
||||
[Rafal2228](https://github.com/rafal2228)
|
||||
[Beeno Tung](https://github.com/beenotung)
|
||||
[Nikita Koryabkin](https://github.com/Apologiz)
|
||||
|
||||
Vendored
+46
-17
@@ -1,11 +1,12 @@
|
||||
// Type definitions for node-forge 0.7.6
|
||||
// Project: https://github.com/digitalbazaar/forge
|
||||
// Definitions by: Seth Westphal <https://github.com/westy92>
|
||||
// Kay Schecker <https://github.com/flynetworks>
|
||||
// Aakash Goenka <https://github.com/a-k-g>
|
||||
// Rafal2228 <https://github.com/rafal2228>
|
||||
// Beeno Tung <https://github.com/beenotung>
|
||||
// Joe Flateau <https://github.com/joeflateau>
|
||||
// Definitions by: Seth Westphal <https://github.com/westy92>
|
||||
// Kay Schecker <https://github.com/flynetworks>
|
||||
// Aakash Goenka <https://github.com/a-k-g>
|
||||
// Rafal2228 <https://github.com/rafal2228>
|
||||
// Beeno Tung <https://github.com/beenotung>
|
||||
// Joe Flateau <https://github.com/joeflateau>
|
||||
// Nikita Koryabkin <https://github.com/Apologiz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
@@ -44,16 +45,26 @@ declare module "node-forge" {
|
||||
type Key = any;
|
||||
|
||||
interface KeyPair {
|
||||
publicKey: Key;
|
||||
privateKey: Key;
|
||||
publicKey: PublicKey;
|
||||
privateKey: PrivateKey;
|
||||
}
|
||||
|
||||
interface PublicKey {
|
||||
encrypt(data: string, scheme?: string, schemeOptions?: number): Bytes
|
||||
verify(digest: string, signature: string, scheme?: string): boolean
|
||||
}
|
||||
|
||||
interface PrivateKey {
|
||||
decrypt(data: string, scheme?: string, schemeOptions?: number): string
|
||||
sign(md: string, scheme?: string): Bytes
|
||||
}
|
||||
|
||||
function pemToDer(pem: PEM): util.ByteStringBuffer;
|
||||
function privateKeyToPem(key: Key, maxline?: number): PEM;
|
||||
function privateKeyInfoToPem(key: Key, maxline?: number): PEM;
|
||||
function publicKeyToPem(key: Key, maxline?: number): PEM;
|
||||
function publicKeyFromPem(pem: PEM): Key;
|
||||
function privateKeyFromPem(pem: PEM): Key;
|
||||
function privateKeyToPem(key: PrivateKey, maxline?: number): PEM;
|
||||
function privateKeyInfoToPem(key: PrivateKey, maxline?: number): PEM;
|
||||
function publicKeyToPem(key: PublicKey, maxline?: number): PEM;
|
||||
function publicKeyFromPem(pem: PEM): PublicKey;
|
||||
function privateKeyFromPem(pem: PEM): PrivateKey;
|
||||
function certificateToPem(cert: Certificate, maxline?: number): PEM;
|
||||
function certificateFromPem(pem: PEM, computeHash?: boolean, strict?: boolean): Certificate;
|
||||
|
||||
@@ -99,9 +110,15 @@ declare module "node-forge" {
|
||||
|
||||
function publicKeyFromPrivateKey(options: { privateKey: NativeBuffer }): NativeBuffer;
|
||||
|
||||
function sign(options: { privateKey: NativeBuffer }): NativeBuffer;
|
||||
function sign(options: {
|
||||
message: string,
|
||||
encoding: string,
|
||||
privateKey: NativeBuffer
|
||||
}): NativeBuffer;
|
||||
|
||||
function verify(options: {
|
||||
message: string,
|
||||
encoding: string,
|
||||
signature: Buffer | Uint8Array | util.ByteBuffer | string,
|
||||
publicKey: NativeBuffer
|
||||
}): boolean;
|
||||
@@ -474,11 +491,14 @@ declare module "node-forge" {
|
||||
|
||||
type Algorithm = "AES-ECB" | "AES-CBC" | "AES-CFB" | "AES-OFB" | "AES-CTR" | "AES-GCM" | "3DES-ECB" | "3DES-CBC" | "DES-ECB" | "DES-CBC";
|
||||
|
||||
function createCipher(algorithm: Algorithm, payload: util.ByteBuffer): BlockCipher;
|
||||
function createDecipher(algorithm: Algorithm, payload: util.ByteBuffer): BlockCipher;
|
||||
function createCipher(algorithm: Algorithm, payload: util.ByteBuffer | Bytes): BlockCipher;
|
||||
function createDecipher(algorithm: Algorithm, payload: util.ByteBuffer | Bytes): BlockCipher;
|
||||
|
||||
interface StartOptions {
|
||||
iv?: string;
|
||||
iv?: Bytes;
|
||||
tag?: util.ByteStringBuffer;
|
||||
tagLength?: number;
|
||||
additionalData?: string;
|
||||
}
|
||||
|
||||
interface BlockCipher {
|
||||
@@ -486,6 +506,11 @@ declare module "node-forge" {
|
||||
update: (payload: util.ByteBuffer) => void;
|
||||
finish: () => boolean;
|
||||
output: util.ByteStringBuffer;
|
||||
mode: Mode;
|
||||
}
|
||||
|
||||
interface Mode {
|
||||
tag: util.ByteStringBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -498,4 +523,8 @@ declare module "node-forge" {
|
||||
function create(any: any): any;
|
||||
}
|
||||
}
|
||||
|
||||
namespace random {
|
||||
function getBytesSync(length: number): Bytes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ let x: string = forge.ssh.privateKeyToOpenSSH(key);
|
||||
let pemKey: forge.pki.PEM = publicKeyPem;
|
||||
let publicKeyRsa = forge.pki.publicKeyFromPem(pemKey);
|
||||
let privateKeyRsa = forge.pki.privateKeyFromPem(privateKeyPem);
|
||||
let privateKeyRsa2 = forge.pki.privateKeyInfoToPem(privateKeyPem);
|
||||
let byteBufferString = forge.pki.pemToDer(privateKeyRsa);
|
||||
let privateKeyRsa2 = forge.pki.privateKeyInfoToPem(privateKeyRsa);
|
||||
let byteBufferString = forge.pki.pemToDer(privateKeyPem);
|
||||
let certPem = forge.pki.certificateFromPem(pemKey);
|
||||
let cert = forge.pki.createCertificate();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user