update to use more promises

This commit is contained in:
2016-11-03 18:57:42 +01:00
parent a2c6b6a259
commit e1f24823c6
10 changed files with 359 additions and 441 deletions

View File

@ -1,3 +1,6 @@
/// <reference types="q" />
import * as q from 'q';
import { IReqResArg } from './smartacme.classes.jwebclient';
/**
* @class AcmeClient
* @constructor
@ -7,7 +10,7 @@
*/
export declare class AcmeClient {
clientProfilePubKey: any;
days_valid: number;
daysValid: number;
defaultRsaKeySize: number;
directory: any;
directoryUrl: string;
@ -17,7 +20,7 @@ export declare class AcmeClient {
regLink: string;
tosLink: string;
webroot: string;
well_known_path: string;
wellKnownPath: string;
withInteraction: boolean;
constructor(directoryUrlArg: any);
/**
@ -25,7 +28,7 @@ export declare class AcmeClient {
* @description retrieve directory entries (directory url must be set prior to execution)
* @param {function} callback - first argument will be the answer object
*/
getDirectory(callback: any): void;
getDirectory(): q.Promise<IReqResArg>;
/**
* newRegistration
* @description try to register (directory lookup must have occured prior to execution)
@ -40,7 +43,7 @@ export declare class AcmeClient {
* @param {Object} payload - update information
* @param {function} callback - first argument will be the answer object
*/
getRegistration(uri: any, payload: any, callback: any): void;
getRegistration(uri: any, payload: any): q.Promise<IReqResArg>;
/**
* authorizeDomain
* @description authorize domain using challenge-response-method
@ -79,11 +82,10 @@ export declare class AcmeClient {
*/
requestSigning(domain: any, callback: any): void;
/**
* getProfile
* @description retrieve profile of user (will make directory lookup and registration check)
* retrieves profile of user (will make directory lookup and registration check)
* @param {function} callback - first argument will be the answer object
*/
getProfile(callback: any): void;
getProfile(): q.Promise<{}>;
/**
* createAccount
* @description create new account (assumes directory lookup has already occured)
@ -104,8 +106,9 @@ export declare class AcmeClient {
* @param {string} organization
* @param {string} country
* @param {function} callback
* @returns Promise
*/
requestCertificate(domain: any, organization: any, country: any, callback: any): void;
requestCertificate(domain: string, organization: string, country: string): q.Promise<{}>;
/**
* External: Create key pair
* @param {number} bit - key strength, expected to be already sanitized
@ -115,7 +118,7 @@ export declare class AcmeClient {
* @param {string} e - email address, expected to be already sanitized
* @param {function} callback
*/
createKeyPair(bit: any, c: any, o: any, cn: any, e: any, callback: any): void;
createKeyPair(bit: any, c: any, o: any, cn: any, e: any): q.Promise<{}>;
/**
* Helper: Empty callback
*/

File diff suppressed because one or more lines are too long

View File

@ -1,11 +1,27 @@
/// <reference types="q" />
import * as q from 'q';
export interface IReqResArg {
ans: any;
res: any;
}
/**
* @class JWebClient
* @constructor
* @description Implementation of HTTPS-based JSON-Web-Client
*/
export declare class JWebClient {
key_pair: any;
last_nonce: string;
/**
* User account key pair
*/
keyPair: any;
/**
* Cached nonce returned with last request
*/
lastNonce: string;
/**
* @member {boolean} module:JWebClient~JWebClient#verbose
* @desc Determines verbose mode
*/
verbose: boolean;
constructor();
/**
@ -27,7 +43,7 @@ export declare class JWebClient {
* @param {function} callback
* @param {function} errorCallback
*/
request(query: any, payload: any, callback: any, errorCallback: any): void;
request(query: string, payload?: string): q.Promise<{}>;
/**
* get
* @description make GET request
@ -35,27 +51,21 @@ export declare class JWebClient {
* @param {function} callback
* @param {function} errorCallback
*/
get(uri: any, callback: any, errorCallback: any): void;
get(uri: string): q.Promise<IReqResArg>;
/**
* post
* @description make POST request
* make POST request
* @param {string} uri
* @param {Object|string|number|boolean} payload
* @param {function} callback
* @param {function} errorCallback
*/
post(uri: any, payload: any, callback: any, errorCallback: any): void;
post(uri: string, payload: any): q.Promise<IReqResArg>;
/**
* evaluateStatus
* @description check if status is expected and log errors
* checks if status is expected and log errors
* @param {string} uri
* @param {Object|string|number|boolean} payload
* @param {Object|string} ans
* @param {Object} res
*/
evaluateStatus(uri: any, payload: any, ans: any, res: any): void;
/**
* Helper: Empty callback
*/
emptyCallback(): void;
}

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,5 @@
import 'typings-global';
import * as path from 'path';
import * as smartstring from 'smartstring';
export { path, smartstring };
import * as shelljs from 'shelljs';
export { path, smartstring, shelljs };

View File

@ -4,4 +4,6 @@ const path = require("path");
exports.path = path;
const smartstring = require("smartstring");
exports.smartstring = smartstring;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhY21lLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGFjbWUucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBQ3ZCLDZCQUE0QjtBQUl4QixvQkFBSTtBQUhSLDJDQUEwQztBQUl0QyxrQ0FBVyJ9
const shelljs = require("shelljs");
exports.shelljs = shelljs;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhY21lLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGFjbWUucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBQ3ZCLDZCQUE0QjtBQUt4QixvQkFBSTtBQUpSLDJDQUEwQztBQUt0QyxrQ0FBVztBQUpmLG1DQUFrQztBQUs5QiwwQkFBTyJ9