Skip to content

Commit

Permalink
lint: fix some errors after update tslint
Browse files Browse the repository at this point in the history
  • Loading branch information
algv committed Apr 11, 2017
1 parent 63e79a5 commit df0e712
Show file tree
Hide file tree
Showing 31 changed files with 164 additions and 458 deletions.
24 changes: 3 additions & 21 deletions lib/cms/recipientInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,11 @@ namespace trusted.cms {
export class CmsRecipientInfo extends BaseObject<native.CMS.CmsRecipientInfo> {
/**
* Creates an instance of CmsRecipientInfo.
*
*
* @memberOf CmsRecipientInfo
*/
constructor();

/**
* Creates an instance of CmsRecipientInfo.
*
* @param {native.CMS.CmsRecipientInfo} handle
*
* @memberOf CmsRecipientInfo
*/
constructor(handle: native.CMS.CmsRecipientInfo);

/**
* Creates an instance of CmsRecipientInfo.
*
* @param {*} [param]
* @param {native.CMS.CmsRecipientInfo} [param]
*
* @memberOf CmsRecipientInfo
*/
constructor(param?: any) {
constructor(param?: native.CMS.CmsRecipientInfo) {
super();
if (param instanceof native.CMS.CmsRecipientInfo) {
this.handle = param;
Expand Down Expand Up @@ -74,7 +56,7 @@ namespace trusted.cms {
* @memberOf CmsRecipientInfo
*/
public ktriCertCmp(cert: pki.Certificate): number {
let cmp: any = this.handle.ktriCertCmp(cert.handle);
const cmp: number = this.handle.ktriCertCmp(cert.handle);
if (cmp < 0) {
return -1;
}
Expand Down
22 changes: 2 additions & 20 deletions lib/cms/recipientInfos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,11 @@ namespace trusted.cms {
implements core.ICollectionWrite {
/**
* Creates an instance of CmsRecipientInfoCollection.
*
*
* @memberOf CmsRecipientInfoCollection
*/
constructor();

/**
* Creates an instance of CmsRecipientInfoCollection.
*
* @param {native.CMS.CmsRecipientInfoCollection} handle
*
* @memberOf CmsRecipientInfoCollection
*/
constructor(handle: native.CMS.CmsRecipientInfoCollection);

/**
* Creates an instance of CmsRecipientInfoCollection.
*
* @param {*} [param]
* @param {native.CMS.CmsRecipientInfoCollection} [param]
*
* @memberOf CmsRecipientInfoCollection
*/
constructor(param?: any) {
constructor(param?: native.CMS.CmsRecipientInfoCollection) {
super();
if (param instanceof native.CMS.CmsRecipientInfoCollection) {
this.handle = param;
Expand Down
26 changes: 13 additions & 13 deletions lib/cms/signed_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace trusted.cms {
function EnumGetName(e: any, name: string): any {
"use strict";

for (let i in e) {
for (const i in e) {
if (i.toString().toLowerCase() === name.toLowerCase()) {
return { name: i, value: e[i] };
}
Expand All @@ -81,7 +81,7 @@ namespace trusted.cms {
* @memberOf SignedData
*/
public static load(filename: string, format: DataFormat = DEFAULT_DATA_FORMAT): SignedData {
let cms: SignedData = new SignedData();
const cms: SignedData = new SignedData();
cms.handle.load(filename, format);
return cms;
}
Expand All @@ -97,7 +97,7 @@ namespace trusted.cms {
* @memberOf SignedData
*/
public static import(buffer: Buffer, format: DataFormat = DEFAULT_DATA_FORMAT): SignedData {
let cms: SignedData = new SignedData();
const cms: SignedData = new SignedData();
cms.handle.import(buffer, format);
return cms;
}
Expand Down Expand Up @@ -125,7 +125,7 @@ namespace trusted.cms {
get content(): ISignedDataContent {
if (!this.prContent && !this.isDetached()) {
// Извлечь содержимое из подписи
let buf: Buffer = this.handle.getContent();
const buf: Buffer = this.handle.getContent();
this.prContent = {
data: buf,
type: SignedDataContentType.buffer,
Expand All @@ -145,7 +145,7 @@ namespace trusted.cms {
if (v.type === SignedDataContentType.url) {
data = v.data.toString();
} else {
data = new Buffer(<any> v.data);
data = new Buffer(v.data as any);
}
this.handle.setContent(data);
this.prContent = v;
Expand All @@ -158,11 +158,11 @@ namespace trusted.cms {
* @memberOf SignedData
*/
get policies(): string[] {
let p: string[] = new Array<string>();
const p: string[] = new Array<string>();

let flags: number = this.handle.getFlags();
const flags: number = this.handle.getFlags();

for (let i in SignedDataPolicy) {
for (const i in SignedDataPolicy) {
if (+i & flags) {
p.push(SignedDataPolicy[i]);
}
Expand All @@ -179,8 +179,8 @@ namespace trusted.cms {
*/
set policies(v: string[]) {
let flags: number = 0;
for (let i: number = 0; i < v.length; i++) {
let flag: any = EnumGetName(SignedDataPolicy, v[i]);
for (const item of v) {
const flag: any = EnumGetName(SignedDataPolicy, item);
if (flag) {
flags |= +flag.value;
}
Expand Down Expand Up @@ -228,7 +228,7 @@ namespace trusted.cms {
* @memberOf SignedData
*/
public certificates(index?: number): any {
let certs: pki.CertificateCollection = new pki.CertificateCollection(this.handle.getCertificates());
const certs: pki.CertificateCollection = new pki.CertificateCollection(this.handle.getCertificates());
if (index !== undefined) {
return certs.items(index);
}
Expand Down Expand Up @@ -263,7 +263,7 @@ namespace trusted.cms {
* @memberOf SignedData
*/
public signers(index?: number): any {
let signers: SignerCollection = new SignerCollection(this.handle.getSigners());
const signers: SignerCollection = new SignerCollection(this.handle.getSigners());
if (index !== undefined) {
return signers.items(index);
}
Expand Down Expand Up @@ -328,7 +328,7 @@ namespace trusted.cms {
* @memberOf SignedData
*/
public createSigner(cert: pki.Certificate, key: pki.Key): Signer {
let signer: any = this.handle.createSigner(cert.handle, key.handle);
const signer: any = this.handle.createSigner(cert.handle, key.handle);
return new Signer(signer);
}

Expand Down
8 changes: 4 additions & 4 deletions lib/cms/signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace trusted.cms {
* @memberOf Signer
*/
get digestAlgorithm(): Algorithm {
let alg: Algorithm = new pki.Algorithm(this.handle.getDigestAlgorithm());
const alg: Algorithm = new pki.Algorithm(this.handle.getDigestAlgorithm());
return alg;
}

Expand Down Expand Up @@ -83,7 +83,7 @@ namespace trusted.cms {
if (v.type === SignedDataContentType.url) {
data = v.data.toString();
} else {
data = new Buffer(<any> v.data);
data = new Buffer(v.data as any);
}
}
return this.handle.verifyContent(data);
Expand Down Expand Up @@ -128,7 +128,7 @@ namespace trusted.cms {
* @memberOf Signer
*/
public signedAttributes(index?: number): any {
let attrs: SignerAttributeCollection = new SignerAttributeCollection(this.handle.getSignedAttributes());
const attrs: SignerAttributeCollection = new SignerAttributeCollection(this.handle.getSignedAttributes());

if (index === undefined) {
return attrs;
Expand Down Expand Up @@ -165,7 +165,7 @@ namespace trusted.cms {
* @memberOf Signer
*/
public unsignedAttributes(index?: number): any {
let attrs: SignerAttributeCollection = new SignerAttributeCollection(this.handle.getUnsignedAttributes());
const attrs: SignerAttributeCollection = new SignerAttributeCollection(this.handle.getUnsignedAttributes());

if (index === undefined) {
return attrs;
Expand Down
4 changes: 2 additions & 2 deletions lib/cms/signer_id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ namespace trusted.cms {
export class SignerId extends BaseObject<native.CMS.SignerId> {
/**
* Creates an instance of SignerId.
*
* @param {native.CMS.SignerId} [param]
*
* @memberOf SignerId
*/
constructor(param?: any) {
constructor(param?: native.CMS.SignerId) {
super();
if (param instanceof native.CMS.SignerId) {
this.handle = param;
Expand Down
8 changes: 4 additions & 4 deletions lib/common/openssl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace trusted.common {
* @memberOf OpenSSL
*/
public static run(): void {
let openssl = new native.COMMON.OpenSSL();
const openssl = new native.COMMON.OpenSSL();
return openssl.run();
}

Expand All @@ -32,7 +32,7 @@ namespace trusted.common {
* @memberOf OpenSSL
*/
public static stop(): void {
let openssl = new native.COMMON.OpenSSL();
const openssl = new native.COMMON.OpenSSL();
return openssl.stop();
}

Expand All @@ -45,7 +45,7 @@ namespace trusted.common {
* @memberOf OpenSSL
*/
public static printErrors(): string {
let openssl = new native.COMMON.OpenSSL();
const openssl = new native.COMMON.OpenSSL();
return openssl.printErrors();
}

Expand All @@ -58,6 +58,6 @@ namespace trusted.common {
constructor() {
super();
this.handle = new native.COMMON.OpenSSL();
};
}
}
}
4 changes: 2 additions & 2 deletions lib/logger_level.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ namespace trusted {
DEBUG = 8,
TRACE = 16,
OPENSSL = 32,
ALL = ERROR | WARNING | INFO | DEBUG | TRACE | OPENSSL
}
// tslint:disable-next-line:no-bitwise
ALL = ERROR | WARNING | INFO | DEBUG | TRACE | OPENSSL}
}
16 changes: 6 additions & 10 deletions lib/native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ declare namespace native {
}

class Algorithm {
constructor();
constructor(name: string);
constructor(name?: string);
public getTypeId(): OID;
public getName(): string;
public duplicate(): Algorithm;
Expand All @@ -45,8 +44,7 @@ declare namespace native {
}

class OID {
constructor();
constructor(value: string);
constructor(value?: string);
public getLongName(): string;
public getShortName(): string;
public getValue(): string;
Expand Down Expand Up @@ -143,8 +141,7 @@ declare namespace native {
}

class CertificationRequest {
constructor();
constructor(csrinfo: PKI.CertificationRequestInfo);
constructor(csrinfo?: PKI.CertificationRequestInfo);
public load(filename: string, dataFormat: trusted.DataFormat): void;
public sign(key: Key): void;
public verify(): boolean;
Expand Down Expand Up @@ -188,7 +185,7 @@ declare namespace native {
public getCrlLocal(cert: Certificate, store: PKISTORE.PkiStore): any;
public getCrlDistPoints(cert: Certificate): string[];
public checkCrlTime(crl: CRL): boolean;
public downloadCRL(distPoints: string[], path: string, done: Function): void;
public downloadCRL(distPoints: string[], path: string, done: (err: Error, crl: PKI.CRL) => void): void;
}

class Pkcs12 {
Expand Down Expand Up @@ -404,8 +401,7 @@ declare namespace native {
public save(fileName: string);
public load(fileName: string);
public export(): IPkiItem[];
public import(items: IPkiItem[]);
public import(item: PkiItem);
public import(items: IPkiItem[] | PkiItem);
}

class Filter {
Expand Down Expand Up @@ -453,7 +449,7 @@ declare namespace native {

class Cerber {
public sign(modulePath: string, cert: PKI.Certificate, key: PKI.Key): void;
public verify(modulePath: string, cacerts?: PKI.CertificateCollection): Object;
public verify(modulePath: string, cacerts?: PKI.CertificateCollection): object;
}

class Logger {
Expand Down
4 changes: 2 additions & 2 deletions lib/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ namespace trusted {
throw TypeError("BaseObjectCheck::Wrong incoming object for wrap function");
}

let newObj: any = new this();
const newObj: any = new this();
newObj.handle = obj;
return <TOut> newObj;
return newObj as TOut;
}

public handle: T;
Expand Down
35 changes: 4 additions & 31 deletions lib/pki/alg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,11 @@ namespace trusted.pki {
export class Algorithm extends BaseObject<native.PKI.Algorithm> {
/**
* Creates an instance of Algorithm.
*
*
* @memberOf Algorithm
*/
constructor();

/**
* Creates an instance of Algorithm.
*
* @param {native.PKI.Algorithm} handle
*
* @memberOf Algorithm
*/
constructor(handle: native.PKI.Algorithm);

/**
* Creates an instance of Algorithm.
*
* @param {string} name
*
* @memberOf Algorithm
*/
constructor(name: string);

/**
* Creates an instance of Algorithm.
*
* @param {*} [param]
* @param {(native.PKI.Algorithm | string)} [param]
*
* @memberOf Algorithm
*/
constructor (param?: any) {
constructor(param?: native.PKI.Algorithm | string) {
super();

if (param instanceof native.PKI.Algorithm) {
Expand Down Expand Up @@ -86,8 +59,8 @@ namespace trusted.pki {
* @memberOf Algorithm
*/
public duplicate(): Algorithm {
let walg: any = this.handle.duplicate();
let alg: any = new Algorithm();
const walg: any = this.handle.duplicate();
const alg: any = new Algorithm();
alg.handle = walg;
return alg;
}
Expand Down
Loading

0 comments on commit df0e712

Please sign in to comment.