From db6d4299c7980849ca2517084210bee8ce5b9330 Mon Sep 17 00:00:00 2001
From: cronon
Date: Mon, 4 Apr 2016 13:46:47 +0300
Subject: [PATCH 001/844] Add documentation for cookie-js
---
cookiejs/cookiejs.d.ts | 30 ++++++++++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/cookiejs/cookiejs.d.ts b/cookiejs/cookiejs.d.ts
index 1bc4d2b5ee..77b8973aed 100644
--- a/cookiejs/cookiejs.d.ts
+++ b/cookiejs/cookiejs.d.ts
@@ -2,20 +2,46 @@
// Project: https://github.com/js-coder/cookie.js
// Definitions by: Boltmade
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
-
+/**
+ * Shortcut for cookie.get()
+ */
declare function cookie(key : string, fallback?: string) : string;
declare function cookie(keys : string[], fallback?: string) : string;
declare namespace cookie {
+ /**
+ * Create a cookie. The value will automatically be escaped.
+ */
export function set(key : string, value : string, options? : any) : void;
+ /**
+ * Set several cookies at once
+ */
export function set(obj : any, options? : any) : void;
+ /**
+ * Remove cookies
+ */
export function remove(key : string) : void;
export function remove(keys : string[]) : void;
export function remove(...args : string[]) : void;
+ /**
+ * Remove all cookies
+ */
export function empty() : void;
+ /**
+ * Retrieve the value of the cookie
+ */
export function get(key : string, fallback?: string) : string;
- export function get(keys : string[], fallback?: string) : string;
+ /**
+ * Retrieve values of several cookies
+ */
+ export function get(keys : string[], fallback?: string) : any;
+ /**
+ * Get all currently saved cookies
+ */
export function all() : any;
+ /**
+ * Test if cookies are enabled
+ */
export function enabled() : boolean;
}
From b391281610c6c915875ba29eaa399bc48b1cc6f2 Mon Sep 17 00:00:00 2001
From: Christopher Cortes
Date: Sun, 4 Dec 2016 17:46:15 +0100
Subject: [PATCH 002/844] Add new Angular 1.5.9 methods to $compileProvider
Add new methods available in Angular 1.5.9: onChangesTtl(), commentDirectivesEnabled() and cssClassDirectivesEnabled()
---
angularjs/angular.d.ts | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts
index b16438bdcb..7d30fba2a0 100644
--- a/angularjs/angular.d.ts
+++ b/angularjs/angular.d.ts
@@ -1205,6 +1205,15 @@ declare namespace angular {
debugInfoEnabled(): boolean;
debugInfoEnabled(enabled: boolean): ICompileProvider;
+
+ onChangesTtl(): number;
+ onChangesTtl(limit: number): ICompileProvider;
+
+ commentDirectivesEnabled(): boolean;
+ commentDirectivesEnabled(enabled: boolean): ICompileProvider;
+
+ cssClassDirectivesEnabled(): boolean;
+ cssClassDirectivesEnabled(enabled: boolean): ICompileProvider;
}
interface ICloneAttachFunction {
From 82984a5325b92b1b720e3aaa361c1f6905491fa0 Mon Sep 17 00:00:00 2001
From: Christopher Cortes
Date: Mon, 5 Dec 2016 09:18:39 +0100
Subject: [PATCH 003/844] Add JSDoc to Angular 1.59 new methods of
$compileProvider
JSDoc for onChangesTtl(), commentDirectivesEnabled() and cssClassDirectivesEnabled() methods.
---
angularjs/angular.d.ts | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts
index 7d30fba2a0..ddd1056821 100644
--- a/angularjs/angular.d.ts
+++ b/angularjs/angular.d.ts
@@ -1206,12 +1206,27 @@ declare namespace angular {
debugInfoEnabled(): boolean;
debugInfoEnabled(enabled: boolean): ICompileProvider;
+ /**
+ * Sets the number of times $onChanges hooks can trigger new changes before giving up and assuming that the model is unstable.
+ * Increasing the TTL could have performance implications, so you should not change it without proper justification.
+ * Default: 10.
+ */
onChangesTtl(): number;
onChangesTtl(limit: number): ICompileProvider;
+ /**
+ * It indicates to the compiler whether or not directives on comments should be compiled.
+ * It results in a compilation performance gain since the compiler doesn't have to check comments when looking for directives.
+ * Defaults to true.
+ */
commentDirectivesEnabled(): boolean;
commentDirectivesEnabled(enabled: boolean): ICompileProvider;
+ /**
+ * It indicates to the compiler whether or not directives on element classes should be compiled.
+ * It results in a compilation performance gain since the compiler doesn't have to check element classes when looking for directives.
+ * Defaults to true.
+ */
cssClassDirectivesEnabled(): boolean;
cssClassDirectivesEnabled(enabled: boolean): ICompileProvider;
}
From 76c47b02f0a90cfef9d99912c14e371a9f958f0e Mon Sep 17 00:00:00 2001
From: Christopher Cortes
Date: Mon, 5 Dec 2016 09:23:22 +0100
Subject: [PATCH 004/844] Expand $compileProvider JSDoc
Urls added to JSDoc of Angular 1.5.9 new methods .
---
angularjs/angular.d.ts | 3 +++
1 file changed, 3 insertions(+)
diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts
index ddd1056821..87870bbbd6 100644
--- a/angularjs/angular.d.ts
+++ b/angularjs/angular.d.ts
@@ -1210,6 +1210,7 @@ declare namespace angular {
* Sets the number of times $onChanges hooks can trigger new changes before giving up and assuming that the model is unstable.
* Increasing the TTL could have performance implications, so you should not change it without proper justification.
* Default: 10.
+ * See: https://docs.angularjs.org/api/ng/provider/$compileProvider#onChangesTtl
*/
onChangesTtl(): number;
onChangesTtl(limit: number): ICompileProvider;
@@ -1218,6 +1219,7 @@ declare namespace angular {
* It indicates to the compiler whether or not directives on comments should be compiled.
* It results in a compilation performance gain since the compiler doesn't have to check comments when looking for directives.
* Defaults to true.
+ * See: https://docs.angularjs.org/api/ng/provider/$compileProvider#commentDirectivesEnabled
*/
commentDirectivesEnabled(): boolean;
commentDirectivesEnabled(enabled: boolean): ICompileProvider;
@@ -1226,6 +1228,7 @@ declare namespace angular {
* It indicates to the compiler whether or not directives on element classes should be compiled.
* It results in a compilation performance gain since the compiler doesn't have to check element classes when looking for directives.
* Defaults to true.
+ * See: https://docs.angularjs.org/api/ng/provider/$compileProvider#cssClassDirectivesEnabled
*/
cssClassDirectivesEnabled(): boolean;
cssClassDirectivesEnabled(enabled: boolean): ICompileProvider;
From 11aece9e50aa73feb5497bab8073599b699c040e Mon Sep 17 00:00:00 2001
From: Jason Burns
Date: Thu, 23 Mar 2017 20:15:25 -0700
Subject: [PATCH 005/844] Add node-jose types.
The tests are taken from the documentation currently provided on
the NPM page for node-jose. They need to be cleaned up and added
to.
---
node-jose/index.d.ts | 1379 ++++++++++++++++++++++++++++++++++
node-jose/node-jose-tests.ts | 388 ++++++++++
node-jose/tsconfig.json | 22 +
3 files changed, 1789 insertions(+)
create mode 100644 node-jose/index.d.ts
create mode 100644 node-jose/node-jose-tests.ts
create mode 100644 node-jose/tsconfig.json
diff --git a/node-jose/index.d.ts b/node-jose/index.d.ts
new file mode 100644
index 0000000000..d3a7fd891c
--- /dev/null
+++ b/node-jose/index.d.ts
@@ -0,0 +1,1379 @@
+// Type definitions for node-jose v0.9.3
+// Project: https://github.com/cisco/node-jose
+// Definitions by: Jason Burns
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+
+// Most of this documentation comes directly from the excellently documented
+// node-jose package, with only a bit added in to explain intermediate types.
+// It should currently be considered a wip, as I created it for a personal
+// project, but have not spent the necessary time to make it feature complete.
+// Uses 'object' so requires tsc >2.2
+
+///
+
+/**
+ * Exposes all implemented algorithms through a common interface comprised of
+ * six primary 'action' functions.
+ */
+export module JWA {
+
+ /**
+ * Options that can be given to the decrypt function. Additional data can be
+ * passed in with `aad` or `adata` (`aad` will take precedence if both are given),
+ * an initialization vector with `iv`, and an authentication tag or code with
+ * `tag` or `mac` (`tag` will take precedence).
+ */
+ type decryptEncryptOptions = {
+ aad?: Buffer,
+ adata?: Buffer,
+ iv?: Buffer,
+ tag?: Buffer, // Not used in encrypt
+ mac?: Buffer, // Not used in encrypt
+ epu?: Buffer, // encryption party info
+ epv?: Buffer, // encryption party info
+ kdata?: Buffer,
+ epk?: Buffer, // ephemeral pub key used in ec
+ enc?: string, // algorithm to use in ec
+ alg?: string, // variation of enc, probably oversight in lib code
+ apu?: Buffer, // agreement party info used in ec
+ apv?: Buffer, // agreement party info used in ec
+ p2s?: Buffer, // used in pbes
+ p2c?: number // used in pbes
+ };
+
+ /**
+ * Options that can be given to the derive functions. Some options are only viable
+ * for certain algorithms. Future doc will expand these use cases.
+ */
+ type deriveOptions = {
+ length?: number, // key length
+ otherInfo?: Buffer, // info used in concatkdf
+ public?: Buffer, // public key used in ecdh
+ hash?: Buffer, // hash used in ecdh
+ salt?: Buffer, // salt value used in hkdf
+ info?: Buffer, // app identifier info used in hkdf
+ };
+
+ /**
+ * Options used for all sign algorithms.
+ */
+ type signVerifyOptions = { loose?: boolean }; // used in hmac algo
+
+ /**
+ * The object that is returned from encrypt options. Some algorithms return a
+ * tag value, so a simple buffer cannot be used here.
+ */
+ type encryptReturn = {
+ data: Buffer, // The cipher text
+ tag?: Buffer // The tag used in some algorithms
+ }
+
+ /**
+ * Return object for sign functions. The data is replicated into the return for
+ * ease of use.
+ */
+ type signReturn = {
+ data: Buffer, // the data passed into the sign function
+ mac: Buffer // the signature for `data`
+ }
+
+ /**
+ * Return object for verify functions. The data and mac are replicated into the
+ * return for ease of use.
+ */
+ type verifyReturn = {
+ data: Buffer, // the data passed into the verify function
+ mac: Buffer, // the signature for `data`
+ valid: boolean // whether the signature matches the data
+ }
+
+ /**
+ * Run the decryption algorithm given by `alg`, if it is supported in the current
+ * implementation.
+ *
+ * @param {string} alg The algorithm to use
+ * @param {(string | Buffer)} key The decryption key
+ * @param {(string | Buffer)} cdata The ciphertext
+ * @param {decryptOptions} [props] Any of the allowed decryption options given in `JWA.decryptEncryptOptions`
+ * @returns {Promise} A buffer with the plain text.
+ */
+ function decrypt(alg: string, key: string | Buffer, cdata: string | Buffer, props?: decryptEncryptOptions): Promise;
+
+ /**
+ * Derive a new cryptographically strong key from weaker key material, using `alg` if it is
+ * implemented
+ *
+ * @param {string} alg The algorithm to use
+ * @param {(string | Buffer)} key The weak key material
+ * @param {deriveOptions} props Options to be used by algorithm, defined in `JWA.deriveOptions`.
+ * @returns {Promise} The stronger key material
+ */
+ function derive(alg: string, key: string | Buffer, props?: deriveOptions): Promise;
+
+ /**
+ * Create a hash of `data` using the algorithm `alg` if implemented.
+ *
+ * @param {string} alg The algorithm to use
+ * @param {(string | Buffer)} data The data to hash
+ * @param {*} props Unused at this time, left for future implementations
+ * @returns {Promise} The hash
+ */
+ function digest(alg: string, data: string | Buffer, props?: any): Promise;
+
+ /**
+ * Run the encryption algorithm given by `alg`, if it is supported by the implementation.
+ *
+ * @param {string} alg The algorithm to use
+ * @param {(string | Buffer)} key The encryption key
+ * @param {(string | Buffer)} pdata The plaintext
+ * @param {encryptOptions} props Options used by the specified algorithm in `JWA.decryptEncryptOptions`.
+ * @returns {Promise} The ciphertext in `data` field, `tag` field included if in algorithm.
+ */
+ function encrypt(alg: string, key: string | Buffer, pdata: string | Buffer, props?: decryptEncryptOptions): Promise;
+
+ /**
+ * Sign `pdata` with the request algorithm if supported.
+ *
+ * @param {string} alg The algorithm to use
+ * @param {(string | Buffer)} key The signing key
+ * @param {(string | Buffer)} pdata The data to add integrity to
+ * @param {signOptions} props Options used by the algorithm as defined in `JWA.signVerifyOptions`
+ * @returns {Promise} The signature is in the `mac` field.
+ */
+ function sign(alg: string, key: string | Buffer, pdata: string | Buffer, props: signVerifyOptions): Promise;
+
+ /**
+ * Verify the data in `pdata` is valid by using `key` and `mac`.
+ *
+ * @param {string} alg The algorithm to use
+ * @param {(string | Buffer)} key The verifying key
+ * @param {(string | Buffer)} pdata The signed data to verify
+ * @param {(string | Buffer)} mac The signature as previously returned via the `sign` function
+ * @param {signVerifyOptions} props Options used by the algorithm as defined in `JWA.signVerifyOptions`
+ * @returns {Promise;
+}
+
+/**
+ * Contains all the encrypton tools for JWTs.
+ */
+export module JWE {
+
+ /**
+ * Used to customize decryption processes. The following options are currently
+ * supported:
+ *
+ * @property {} handlers An object where each name is a JOSE header member name and
+ * the value can be a boolean, function, or an object.
+ *
+ * Handlers are intended to support 'crit' extensions. When a boolean value,
+ * the member is expected to be processed once decryption is fully complete.
+ * When a function, it is called just before the ciphertext is decrypted
+ * (processed as if it were a `prepare` handler, as decribed in `decryptCritProcessors`).
+ * Note that normal processing of `decrypt()` does not continue until all
+ * relevant handlers have completed. Any changes handlers make to the
+ * provided objects affects `decrypt()`'s processing.
+ */
+ type decryptCritHeaderOptions = {
+ handlers: { [crit_header: string]: boolean | Function | decryptCritProcessors }
+ };
+
+ /**
+ * For the critical header processing, the options may include an object like this,
+ * which defines these fields to run at various times of decryption processing.
+ * @property {Function} recipient A function called after a valid key is
+ * determined; it takes an object describing the recipient, and
+ * returns a Promise that is fulfilled once the handler's processing
+ * is complete.
+ * @property {Function} prepare A function called just prior to decrypting
+ * the ciphertext; it takes an object describing the decryption
+ * result (but containing `ciphertext` and `tag' instead of `payload`
+ * and `plaintext`), and returns a Promise that is fulfilled once
+ * the handler's processing is complete.
+ * @property {Function} complete A function called once decryption is complete,
+ * just prior to fulfilling the Promise returned by `decrypt()`; it
+ * takes the object that will be returned by `decrypt()`'s fulfilled
+ * Promise, and returns a Promise that is fulfilled once the handler's
+ * processing is complete.
+ */
+ type decryptCritProcessors = {
+ recipient?: Function,
+ prepare?: Function,
+ complete?: Function
+ };
+
+ /**
+ * Object that defines the output that is given from the `decrypt()` function
+ * of a `Decryptor`.
+ *
+ * @property {any} header The JOSE Header, combined from the relevant "header" and
+ * "protected" fields from the original JWE object.
+ * @property {string[]} protected An array containing the names of the protected fields
+ * @property {JWK.Key} key The used to decrypt the content
+ * @property {Buffer} payload The decrypted content (as a Buffer)
+ * @property {Buffer} plaintext An alias for `payload`
+ */
+ type decryptReturn = {
+ header: any,
+ protected: string[],
+ key: JWK.Key,
+ payload: Buffer,
+ plaintext: Buffer
+ };
+
+ /**
+ * The options for {@link createEncrypt}.
+ *
+ * @property {boolean|string} zip Determines the compression algorithm to
+ * apply to the plaintext (if any) before it is encrypted. This can
+ * also be `true` (which is equivalent to `"DEF"`) or **`false`**
+ * (the default, which is equivalent to no compression).
+ * @property {string} format Determines the serialization format of the
+ * output. Expected to be `"general"` for general JSON
+ * Serialization, `"flattened"` for flattened JSON Serialization,
+ * or `"compact"` for Compact Serialization (default is
+ * **`"general"`**).
+ * @property {boolean} compact Determines if the output is the Compact
+ * serialization (`true`) or the JSON serialization (**`false`**,
+ * the default).
+ * @property {string} contentAlg The algorithm used to encrypt the plaintext
+ * (default is **`"A128CBC-HS256"`**).
+ * @property {string|string[]} protect The names of the headers to integrity
+ * protect. The value `""` means that none of the header parameters
+ * are integrity protected, while `"*"` (the default) means that all
+ * header parameters are integrity protected.
+ * @property {object} fields Any extra fields to include in the JWT.
+ * @property {string} aad Additional authenticated data to include
+ * @property {string} cek A content encryption key for the underlying algorithm
+ * @property {string} iv An init vector for the underlying algorithm.
+ */
+ type encOpts = {
+ zip?: boolean | string,
+ format?: string,
+ compact?: boolean,
+ contentAlg?: string,
+ protect?: string | string[],
+ fields?: any,
+ aad?: string,
+ cek?: string,
+ iv?: string
+ };
+
+ /**
+ * Factory function that reates a new Decrypter for the given Key or KeyStore.
+ *
+ * @param {(JWK.KeyStore|JWK.Key)} ks The Key or KeyStore to use for decryption.
+ * @param {decryptCritHeaderOptions} [opts] The options for this decryptor.
+ * @returns {Decrypter} The new Decryptor.
+ */
+ function createDecrypt(ks: JWK.KeyStore | JWK.Key, opts?: decryptCritHeaderOptions): Decrypter;
+
+ /**
+ * Factory function to create `Encrypter`s. See doc for opts and return for more info.
+ *
+ * @param {enc_opts} opts The options used to create the Encrypter.
+ * @param {(JWK.Key|JWK.Key[]|{key: JWK.Key}|{key: JWK.Key}[])} rcpts The recipient list for the JWT
+ * @returns {Encrypter} An object that can perform actions turning JWTs into JWEs.
+ */
+ function createEncrypt(opts: encOpts, rcpts: JWK.Key | JWK.Key[] | { key: JWK.Key } | { key: JWK.Key }[]): Encrypter;
+ function createEncrypt(rcpts: JWK.Key | JWK.Key[] | { key: JWK.Key } | { key: JWK.Key }[]): Encrypter;
+
+ /**
+ * @class Decrypter
+ * @classdesc
+ * Processor of encrypted data.
+ *
+ * @description
+ * **NOTE:** This class cannot be instantiated directly. Instead
+ * call {@link createDecrypt}.
+ */
+ interface Decrypter {
+
+ /**
+ * Decrypts the given input.
+ *
+ * {opts}, if provided, is used to customize this specific decrypt operation.
+ * This argument has the same semantics as {JWE.createDecrypt}, and takes
+ * precedence over those options.
+ *
+ * @param {object|string} input The encrypted content
+ * @param {decryptCritHeaderOptions} [opts] The options for this decryption operation.
+ * @returns {Promise} A promise for the decyprted plaintext
+ * @memberOf Decrypter
+ */
+ decrypt(input: object | string, opts?: decryptCritHeaderOptions): Promise;
+ }
+
+ /**
+ * @class Encrypter
+ * @classdesc
+ * Generator of encrypted data.
+ *
+ * @description
+ * **NOTE:** This class cannot be instantiated directly. Instead call
+ * {@link createEncrypt}.
+ */
+ interface Encrypter {
+ /**
+ * Indicates the compression algorithm applied to the plaintext
+ * before it is encrypted. The possible values are:
+ *
+ * + **`"DEF"`**: Compress the plaintext using the DEFLATE algorithm.
+ * + **`""`**: Do not compress the plaintext.
+ *
+ * @type {string}
+ * @memberOf Encrypter
+ * @readonly
+ */
+ zip: string;
+
+ /**
+ * Indicates whether the output of this encryption generator is
+ * using the Compact serialization (`true`) or the JSON
+ * serialization (`false`).
+ *
+ * @type {boolean}
+ * @memberOf Encrypter
+ * @readonly
+ */
+ compact: boolean;
+
+ /**
+ * Indicates the format the output of this encryption generator takes.
+ *
+ * @type {string}
+ * @memberOf Encrypter
+ * @readonly
+ */
+ format: string;
+
+ /**
+ * The header parameter names that are protected. Protected header fields
+ * are first serialized to UTF-8 then encoded as util.base64url, then used as
+ * the additional authenticated data in the encryption operation.
+ *
+ * @type {string[]}
+ * @memberOf Encrypter
+ * @readonly
+ */
+ protected: string[];
+
+ /**
+ * The global header parameters, both protected and unprotected. Call
+ * {@link Encrypter#protected} to determine which parameters will
+ * be protected.
+ *
+ * @type {object}
+ * @memberOf Encrypter
+ * @readonly
+ */
+ header: object;
+
+ /**
+ * Updates the plaintext data for the encryption generator. The plaintext
+ * is appended to the end of any other plaintext already applied.
+ *
+ * If {data} is a Buffer, {encoding} is ignored. Otherwise, {data} is
+ * converted to a Buffer internally to {encoding}.
+ *
+ * @param {(Buffer|string)} [data] The plaintext to apply.
+ * @param {string} [encoding] The encoding of the plaintext.
+ * @returns {Encrypter} This encryption generator.
+ * @throws {Error} If ciphertext has already been generated.
+ * @memberOf Encrypter
+ */
+ update(data?: Buffer | string, encoding?: string): Encrypter;
+
+ /**
+ * Finishes the encryption operation.
+ *
+ * The returned Promise, when fulfilled, is the JSON Web Encryption (JWE)
+ * object, either in the Compact (if {@link Encrypter#compact} is
+ * `true`) or the JSON serialization.
+ *
+ * @param {(Buffer|string)} [data] The final plaintext data to apply.
+ * @param {string} [encoding] The encoding of the final plaintext data (if any).
+ * @returns {(Promise)} A promise for the encryption operation.
+ * @throws {Error} If ciphertext has already been generated.
+ * @memberOf Encrypter
+ */
+ final(data?: Buffer | string, encoding?: string): Promise;
+ }
+}
+
+/**
+ * Tools for creating and manipulating keys and keystores.
+ */
+export module JWK {
+
+ /**
+ * The following constants are used to select the different modes for
+ * operation, their names are self-explanatory.
+ */
+ const MODE_DECRYPT: string;
+ const MODE_ENCRYPT: string;
+ const MODE_SIGN: string;
+ const MODE_UNWRAP: string;
+ const MODE_VERIFY: string;
+ const MODE_WRAP: string;
+
+ // These are copied in code directly from KeyStore statics, don't know
+ // how to mimic that in d.ts, so for now they're copy pasta. Also, the javadoc will be
+ // on these defitions as the actual library will not usually have you executing the static
+ // methods themselves (e.g. you'll do JWK.asKey instead of JWK.KeyStore.asKey()).
+ /**
+ * Coerces the given object into a Key. If {key} is an instance of JWK.Key,
+ * it is returned directly. Otherwise, this method first creates a new
+ * JWK.KeyStore and calls {@link KeyStore#add} on this new KeyStore.
+ *
+ * @param {(object|string)} key The value to coerce into a Key
+ * @param {string} [form] The format of a String Key to expect
+ * @param {object} [extras] extra jwk fields inserted when importing from a non json string (eg "pem")
+ * @returns {Promise} A promise for the coerced Key.
+ */
+ function asKey(key: object | string, form?: string, extras?: object): Promise;
+
+ /**
+ * Coerces the given object into a KeyStore. This method uses the following
+ * algorithm to coerce {ks}:
+ *
+ * 1. if {ks} is an instance of JWK.KeyStore, it is returned directly
+ * 2. if {ks} is a string, it is parsed into a JSON value
+ * 3. if {ks} is an array, it creates a new JWK.KeyStore and calls {@link
+ * JWK.KeyStore#add} for each element in the {ks} array.
+ * 4. if {ks} is a JSON object, it creates a new JWK.KeyStore and calls {@link
+ * JWK.KeyStore#add} for each element in the "keys" property.
+ *
+ * @param {object|string} ks The value to coerce into a KeyStore
+ * @returns {Promise} A promise for the coerced KeyStore.
+ */
+ function asKeyStore(ks: object | string): Promise;
+
+ /**
+ * Creates a new empty KeyStore.
+ *
+ * @returns {JWK.KeyStore} The empty KeyStore.
+ */
+ function createKeyStore(): JWK.KeyStore;
+
+ /**
+ * Determines if the given object is a JWK.Key instance.
+ *
+ * @param {object} obj The object to test
+ * @returns {boolean} `true` if {obj} is a JWK.Key
+ */
+ function isKey(obj: any): boolean;
+
+ /**
+ * Determines if the given object is an instance of JWK.KeyStore.
+ *
+ * @param {*} obj The object to test
+ * @returns {boolean} `true` if {obj} is an instance of JWK.KeyStore,
+ * and `false` otherwise.
+ */
+ function isKeyStore(obj: any): boolean;
+
+ /**
+ * Options that can be used for searching a keystore for specific keys.
+ */
+ type KS_search_props = { alg?: string, use?: string, kid?: string, kty?: string };
+
+ /**
+ * @class JWK.KeyStore
+ * @classdesc
+ * Represents a collection of Keys.
+ *
+ * @description
+ * **NOTE:** This constructor cannot be called directly. Instead call {@link
+ * JWK.createKeyStore}.
+ */
+ interface KeyStore {
+ /**
+ * @method JWK.KeyStore#add
+ * @description
+ * Adds a Key to this KeyStore. If {jwk} is a string, it is first
+ * parsed into a plain JSON object. If {jwk} is already an instance
+ * of JWK.Key, its (public) JSON representation is first obtained
+ * then applied to a new JWK.Key object within this KeyStore.
+ *
+ * @param {(string|JWK.Key|object)} key The JSON Web Key (JWK)
+ * @param {string} [form] The formate of a string key to expect
+ * @param {*} [extras] extra jwk fields inserted when importing from a non json string (eg "pem")
+ * @returns {Promise} The promise for the added key
+ *
+ * @memberOf KeyStore
+ */
+ add(key: string | JWK.Key | object, form?: string, extras?: any): Promise;
+
+ /**
+ * Retrieves all of the contained Keys that optinally match all of the
+ * given properties.
+ *
+ * If {props} are specified, this method only returns Keys which exactly
+ * match the given properties. The properties can be any of the
+ * following:
+ *
+ * + **alg**: The algorithm for the Key.
+ * + **use**: The usage for the Key.
+ * + **kid**: The identifier for the Key.
+ *
+ * If no properties are given, this method returns all of the Keys for this
+ * KeyStore.
+ *
+ * @param {JWK.KS_search_props} [props] The properties to match against
+ * @param {boolean} [local = false] `true` if only the Keys
+ * directly contained by this KeyStore should be returned, or
+ * `false` if it should return all Keys of this KeyStore and
+ * its ancestors.
+ * @returns {JWK.Key[]} The list of matching Keys, or an empty array if no
+ * matches are found.
+ *
+ * @memberOf KeyStore
+ */
+ all(props?: JWK.KS_search_props, local?: boolean): JWK.Key[];
+
+ /**
+ * @method JWK.KeyStore#generate
+ * @description
+ * Generates a new random Key into this KeyStore.
+ *
+ * The type of {size} depends on the value of {kty}:
+ *
+ * + **`EC`**: String naming the curve to use, which can be one of:
+ * `"P-256"`, `"P-384"`, or `"P-521"` (default is **`"P-256"`**).
+ * + **`RSA`**: Number describing the size of the key, in bits (default is
+ * **`2048`**).
+ * + **`oct`**: Number describing the size of the key, in bits (default is
+ * **`256`**).
+ *
+ * Any properties in {props} are applied before the key is generated,
+ * and are expected to be data types acceptable in JSON. This allows the
+ * generated key to have a specific key identifier, or to specify its
+ * acceptable usage.
+ *
+ * The returned Promise, when fulfilled, returns the generated Key.
+ *
+ * @param {string} kty The type of generated key
+ * @param {(string|number)} [size] The size of the generated key
+ * @param {*} [props] Additional properties to apply to the generated
+ * key.
+ * @returns {Promise} The promise for the generated Key
+ * @throws {Error} If {kty} is not supported
+ *
+ * @memberOf KeyStore
+ */
+ generate(kty: string, size?: string | number, props?: any): Promise;
+
+ /**
+ * Retrieves the contained Key matching the given {kid}, and optionally
+ * all of the given properties. This method equivalent to calling
+ * {@link JWK.Store#all}, then returning the first Key whose
+ * "kid" is {kid}. If {kid} is undefined, then the first Key that
+ * is returned from `all()` is returned.
+ *
+ * @param {String} [kid]
+ * @param {object} [props]
+ * @param {Boolean} [local = false]
+ * @returns {JWK.Key}
+ *
+ * @param {string} [kid] The key identifier to match against.
+ * @param {JWK.KS_search_props} [props] The properties to match against.
+ * @param {boolean} [local = false] `true` if only the Keys
+ * directly contained by this KeyStore should be returned, or
+ * `false` if it should return all Keys of this KeyStore and
+ * its ancestors.
+ * @returns {JWK.Key} The Key matching {kid} and {props}, or `null`
+ * if no match is found.
+ *
+ * @memberOf KeyStore
+ */
+ get(kid?: string, props?: JWK.KS_search_props, local?: boolean): JWK.Key;
+ get(props?: JWK.KS_search_props, local?: boolean): JWK.Key;
+
+ /**
+ * @method JWK.KeyStore#remove
+ * @description
+ * Removes a Key from this KeyStore.
+ *
+ * **NOTE:** The removed Key's {keystore} property is not changed.
+ *
+ * @param {JWK.Key} key The key to remove.
+ *
+ * @memberOf KeyStore
+ */
+ remove(key: JWK.Key): void;
+
+ /**
+ * @method JWK.KeyStore#temp
+ * @description
+ * Creates a temporary KeyStore based on this KeyStore.
+ *
+ * @returns {JWK.KeyStore} The temporary KeyStore.
+ *
+ * @memberOf KeyStore
+ */
+ temp(): JWK.KeyStore;
+
+ /**
+ * @method JWK.KeyStore#toJSON
+ * @description
+ * Generates a JSON representation of this KeyStore, which conforms
+ * to a JWK Set from {I-D.ietf-jose-json-web-key}.
+ *
+ * @param {boolean} [isPrivate = false] `true` if the private fields
+ * of stored keys are to be included.
+ * @returns {*} The JSON representation of this KeyStore.
+ *
+ * @memberOf KeyStore
+ */
+ toJSON(isPrivate?: boolean): any;
+ }
+
+ // The below functions are technically defined as static functions on the KeyStore class,
+ // and then copied to the exports for the JWK module. See the documentation above for their
+ // use, but they are here just for completion sake, but commented out as you should use them
+ // from the module as intended.
+ /*
+ var KeyStore: {
+ asKey(key: object|string, form: string, extras: object): Promise;
+ asKeyStore(ks: any): Promise;
+ createKeyStore(): JWK.KeyStore;
+ isKey(obj: any): boolean;
+ isKeyStore(obj: any): boolean;
+ }
+ */
+
+ /**
+ * @class JWK.Key
+ * @classdesc
+ * Represents a JSON Web Key instance.
+ *
+ * @description
+ * **NOTE:** This class cannot be instantiated directly. Instead call
+ * {@link JWK.asKey}, {@link JWK.KeyStore#add}, or
+ * {@link JWK.KeyStore#generate}.
+ */
+ interface Key {
+
+ /**
+ * @member {String} JWK.Key#alg
+ * @description
+ * The sole algorithm this key can be used for.
+ *
+ * @type {string}
+ * @memberOf Key
+ */
+ alg: string;
+
+ /**
+ * @member {JWK.KeyStore} JWK.Key#keystore
+ * @description
+ * The owning keystore.
+ *
+ * @type {JWK.KeyStore}
+ * @memberOf Key
+ */
+ keystore: JWK.KeyStore;
+
+ /**
+ * @member {string} JWK.Key#kid
+ * @description
+ * The identifier for this Key.
+ *
+ * @type {string}
+ * @memberOf Key
+ */
+ kid: string;
+
+ /**
+ * @member {string} JWK.Key#kty
+ * @description
+ * The type of Key.
+ *
+ * @type {string}
+ * @memberOf Key
+ */
+ kty: string;
+
+ /**
+ * @member {number} JWK.Key#length
+ * @description
+ * The size of this Key, in bits.
+ *
+ * @type {number}
+ * @memberOf Key
+ */
+ length: number;
+
+ /**
+ * @member {String} JWK.Key#use
+ * @description
+ * The usage for this Key.
+ *
+ * @type {string}
+ * @memberOf Key
+ */
+ use: string;
+
+ /**
+ * @method JWK.Key#algorithms
+ * @description
+ * The possible algorithms this Key can be used for. The returned
+ * list is not any particular order, but is filtered based on the
+ * Key's intended usage.
+ *
+ * @param {string} mode The operation mode, see the MODE_* JWK constants.
+ * @returns {string[]} The list of supported algorithms
+ * @see JWK.Key#supports
+ * @memberOf Key
+ */
+ algorithms: (mode: string) => string[];
+
+ /**
+ * @method JWK.Key#decrypt
+ * @description
+ * Decrypts the given data using the specified algorithm.
+ *
+ * **NOTE:** This is the primitive decryption operation; the input is
+ * _**NOT**_ a JSON Web Encryption (JWE) object.
+ *
+ * **NOTE:** This operation is treated as distinct from {@link
+ * JWK.Key#unwrap}, as different algorithms and properties are often used
+ * for unwrapping a key versues decrypting arbitrary data.
+ *
+ * The Promise, when fulfilled, returns the plaintext data.
+ *
+ * @param {String} alg The decryption algorithm.
+ * @param {Buffer|String} data The data to decypt.
+ * @param {object} [props] Additional data for the decryption operation.
+ * @returns {Promise} The promise for the decryption operation.
+ * @throws {Error} If {alg} is not appropriate for this Key; or if
+ * the Key does not contain the appropriate properties.
+ *
+ *
+ * @memberOf Key
+ */
+ decrypt: (alg: string, data: string | Buffer, props?: any) => Promise
+ *
+ * The Promise, when fulfilled, returns an object with the following
+ * properties:
+ *
+ * + **data**: The data that was verified (and should be equal to
+ * {data}).
+ * + **mac**: The signature or MAC that was verified (and should be equal
+ * to {mac}).
+ * + **valid**: `true` if {mac} is valid for {data}.
+ *
+ * @param {String} alg The verification algorithm
+ * @param {String|Buffer} data The data to verify
+ * @param {String|Buffer} mac The signature or MAC to verify
+ * @param {object} [props] Additional properties for the verification
+ * algorithm.
+ * @returns {Promise} The promise for the verification operation.
+ * @throws {Error} If {alg} is not appropriate for this Key; or if
+ * the Key does not contain the appropriate properties.
+ *
+ *
+ * @memberOf Key
+ */
+ verify: (alg: string, data: string | Buffer, mac: string | Buffer, props?: any) => Promise;
+
+ /**
+ * @method JWK.Key#wrap
+ * @description
+ * Wraps the given key using the specified algorithm.
+ *
+ * **NOTE:** This is the primitive encryption operation; the output is
+ * _**NOT**_ a JSON Web Encryption (JWE) object.
+ *
+ * **NOTE:** This operation is treated as distinct from {@link
+ * JWK.Key#encrypt}, as different algorithms and properties are
+ * often used for wrapping a key versues encrypting arbitrary data.
+ *
+ * The Promise, when fulfilled, returns an object with the following
+ * properties:
+ *
+ * + **data**: The ciphertext data
+ * + **headers**: The additional header parameters to apply to a JWE.
+ *
+ * @param {String} alg The encryption algorithm
+ * @param {Buffer|String} data The data to encrypt
+ * @param {object} [props] Additional properties for the encryption
+ * algorithm.
+ * @returns {Promise} The promise for the encryption operation.
+ * @throws {Error} If {alg} is not appropriate for this Key; or if
+ * this Key does not contain the appropriate parameters.
+ * @memberOf Key
+ */
+ wrap: (alg: string, data: string | Buffer, props?: any) => Promise;
+ }
+}
+
+/**
+ * Contains all the signing tools for JWTs.
+ */
+export module JWS {
+
+ /**
+ * @property {Boolean} [compact] Use compact serialization?
+ * @property {String} [format] The serialization format to use ("compact",
+ * "flattened", "general")
+ * @property {object} [fields] Additional header fields
+ * @property {"*" | string[]} [protect] which headers to protect, "*" for all headers.
+ */
+ type signOpts = {
+ alg?: string,
+ compact?: boolean,
+ format?: string,
+ fields?: object,
+ protect?: "*" | string[]
+ };
+
+ /**
+ * @property {JWK.Key} key Key used to sign content
+ * @property {object} [header] Per-signatory header fields
+ * @property {String} [reference] Reference field to identify the key
+ * @property {"*" | string[]} [protect] List of fields to integrity
+ * protect ("*" to protect all fields)
+ */
+ type signSignatory = {
+ key: JWK.Key,
+ header?: object,
+ reference?: string,
+ protect?: "*" | string[]
+ };
+
+ /**
+ * Used to customize verification processes. The following options are currently
+ * supported:
+ *
+ * @property {} handlers An object where each name is a JOSE header member name and
+ * the value can be a boolean, function, or an object.
+ *
+ * Handlers are intended to support 'crit' extensions. When a boolean value,
+ * the member is expected to be processed once verification is fully complete.
+ * When a function, it is called just before the input is verified.
+ * (processed as if it were a `prepare` handler, as decribed in `verifyCritProcessors`).
+ * Note that normal processing of `verify()` does not continue until all
+ * relevant handlers have completed. Any changes handlers make to the
+ * provided objects affects `verify()`'s processing.
+ */
+ type verifyOptions = {
+ handlers: { [crit_header: string]: boolean | Function | verifyCritProcessors }
+ };
+
+ /**
+ * For the critical header processing, the options may include an object like this,
+ * which defines these fields to run at various times of verification processing.
+ * @property {Function} recipient A function called after a valid key is
+ * determined; it takes an object describing the recipient, and
+ * returns a Promise that is fulfilled once the handler's processing
+ * is complete.
+ * @property {Function} prepare A function called just prior to verifying
+ * the input; it takes an object describing the verification
+ * result, and returns a Promise that is fulfilled once
+ * the handler's processing is complete.
+ * @property {Function} complete A function called once verification is complete,
+ * just prior to fulfilling the Promise returned by `verify()`; it
+ * takes the object that will be returned by `verify()`'s fulfilled
+ * Promise, and returns a Promise that is fulfilled once the handler's
+ * processing is complete.
+ */
+ type verifyCritProcessors = {
+ recipient?: Function,
+ prepare?: Function,
+ complete?: Function
+ };
+
+ /**
+ * Object that defines the output that is given from the `verify()` function
+ * of a `Verifier`.
+ *
+ * @property {any} header The JOSE Header, combined from the relevant "header" and
+ * "protected" fields from the original JWE object.
+ * @property {JWK.Key} key The Key used for verifying.
+ * @property {Buffer} payload The verified content (as a Buffer)
+ * @property {string[]} protected An array containing the names of the protected fields
+ * @property {Buffer} signature The data that was used to verify payload with key.
+ */
+ type verifyReturn = {
+ header: object,
+ key: JWK.Key,
+ payload: Buffer,
+ protected: string[],
+ signature: Buffer
+ }
+
+ /**
+ * Creates a new JWS.Signer with the given options and signatories.
+ *
+ * @param {signOpts} opts The signing options.
+ * @param {(JWK.Key|JWK.Key[]|signSignatory[])} signs Signatories, either as an array of
+ * JWK.Key instances; or an array of signing signatory objects.
+ * @returns {Signer} The signature generator.
+ * @throws {Error} If Compact serialization is requested but there are
+ * multiple signatories
+ */
+ function createSign(opts: signOpts, signs: JWK.Key | JWK.Key[] | signSignatory[]): Signer;
+ function createSign(signs: JWK.Key | JWK.Key[] | signSignatory[]): Signer;
+
+ /**
+ * @description
+ * Creates a new JWS.Verifier with the given Key or KeyStore.
+ *
+ * @param {JWK.Key|JWK.KeyStore} ks The Key or KeyStore to use for verification.
+ * @returns {Verifier} The new verifier.
+ */
+ function createVerify(ks?: JWK.Key | JWK.KeyStore, opts?: verifyOptions): Verifier;
+
+ /**
+ * @class JWS.Signer
+ * @classdesc Generator of signed content.
+ *
+ * @description
+ * **NOTE:** this class cannot be instantiated directly. Instead call {@link
+ * JWS.createSign}.
+ */
+ interface Signer {
+
+ /**
+ * @member {Boolean} JWS.Signer#compact
+ * @description
+ * Indicates whether the outuput of this signature generator is using
+ * the Compact serialization (`true`) or the JSON serialization
+ * (`false`).
+ *
+ * @type {boolean}
+ * @memberOf Signer
+ */
+ compact: boolean;
+
+ /**
+ * @member {string} JWS.Signer#format
+ * @description
+ * The serialization format to use ("compact",
+ * "flattened", "general")
+ * @memberOf Signer
+ */
+ format: string;
+
+ /**
+ * @method JWS.Signer#update
+ * @description
+ * Updates the signing content for this signature content. The content
+ * is appended to the end of any other content already applied.
+ *
+ * If {data} is a Buffer, {encoding} is ignored. Otherwise, {data} is
+ * converted to a Buffer internally to {encoding}.
+ *
+ * @param {Buffer|String} data The data to sign.
+ * @param {String} [encoding="binary"] The encoding of {data}.
+ * @returns {Signer} This signature generator.
+ * @throws {Error} If a signature has already been generated.
+ * @memberOf Signer
+ */
+ update(data?: Buffer | string, encoding?: string): Signer;
+
+ /**
+ * @method JWS.Signer#final
+ * @description
+ * Finishes the signature operation.
+ *
+ * The returned Promise, when fulfilled, is the JSON Web Signature (JWS)
+ * object, either in the Compact (if {@link JWS.Signer#format} is
+ * `"compact"`), the flattened JSON (if {@link JWS.Signer#format} is
+ * "flattened"), or the general JSON serialization.
+ *
+ * @param {Buffer|String} [data] The final content to apply.
+ * @param {String} [encoding="binary"] The encoding of the final content
+ * (if any).
+ * @returns {Promise} The promise for the signatures
+ * @throws {Error} If a signature has already been generated.
+ * @memberOf Signer
+ */
+ final(data?: Buffer | string, encoding?: string): Promise;
+ }
+
+ /**
+ * @class JWS.Verifier
+ * @classdesc Parser of signed content.
+ *
+ * @description
+ * **NOTE:** this class cannot be instantiated directly. Instead call {@link
+ * JWS.createVerify}.
+ *
+ * @interface Verifier
+ */
+ interface Verifier {
+
+ /**
+ * If the verifier was created with a key, this key will be assumed to be
+ * assumed to be be the one to verify a signature, regardless of the kid of
+ * the JWT.
+ *
+ * @type {JWK.Key}
+ * @memberOf Verifier
+ */
+ defaultKey: JWK.Key;
+
+ /**
+ * The keystore that will be used to look up the `kid` from the JWT in.
+ *
+ * @type {JWK.KeyStore}
+ * @memberOf Verifier
+ */
+ keystore: JWK.KeyStore;
+
+ /**
+ * @method JWS.Verifier#verify
+ * @description
+ * Verifies the input JWS with one of the keys in the keystore associated with
+ * this verifier.
+ *
+ * @param {string} input The JWS in compact format.
+ * @param {verifyOptions} [opts] See verifyOptions documentation.
+ * @returns {Promise} See verifyReturn documentation.
+ * @memberOf Verifier
+ */
+ verify(input: string, opts?: verifyOptions): Promise
+ }
+}
+
+/**
+ * A collection of Buffer and conversion utilities.
+ */
+export module util {
+
+ /**
+ * Converts the given input into a Buffer with the given encoding.
+ *
+ * @param {(Buffer|string|Array|ArrayBuffer|ArrayBufferView)} input
+ * @param {string} encoding Defaults to 'binary'
+ * @returns {Buffer}
+ */
+ function asBuffer(input: Buffer | string | Array | ArrayBuffer | ArrayBufferView, encoding?: string): Buffer;
+
+ /**
+ * Returns a Buffer filled with random bytes of length `len`.
+ *
+ * @param {number} len
+ * @returns {Buffer}
+ */
+ function randomBytes(len: number): Buffer;
+
+ /**
+ * @namespace base64url
+ * @description
+ * Provides methods to encode and decode data according to the
+ * base64url alphabet.
+ */
+ module base64url {
+
+ /**
+ * Decodes the input from base64url.
+ *
+ * @param {String} input The data to decode.
+ * @returns {Buffer} the base64url decoding of {input}.
+ */
+ function decode(input: string): Buffer;
+
+ /**
+ * Encodes the input to base64url.
+ *
+ * If {input} is a Buffer, then {encoding} is ignored. Otherwise,
+ * {encoding} can be one of "binary", "base64", "hex", "utf8".
+ *
+ * @param {(Buffer|string)} input The data to encode.
+ * @param {string} [encoding = binary] The input encoding format.
+ * @returns {string} the base64url encoding of {input}.
+ */
+ function encode(input: Buffer | string, encoding?: string): string;
+ }
+
+ /**
+ * @namespace utf8
+ * @description
+ * Provides methods to encode and decode data as utf8.
+ */
+ module utf8 {
+
+ /**
+ * Decodes the input from utf8.
+ *
+ * @param {string} input The data to decode.
+ * @returns {string} the utf8 decoding of {input}.
+ */
+ function decode(input: string): string;
+
+ /**
+ * Encodes the input as utf8
+ *
+ * @param {string} input the data to encode.
+ * @returns {string} the ut8 encoding of {input}.
+ */
+ function encode(input: string): string;
+ }
+}
+
+/**
+ * Possible return value from the parse function. The values inside the return
+ * depend heavily on the type of JWT that is passed into it.
+ * @property {string} type Defines whether the JWT was a "JWS" or a "JWE"
+ * @property {string} format Whether the JWT was in compact or JSON format
+ * @property {Buffer|string|object} input The JWT
+ * @property {object} header All of the headers from the recipients or signatories.
+ * @property {function} perform The operation to perform. After calling parse, call the
+ * `perform` function from the return with a valid keystore to verify or decrypt the JWT.
+ */
+type parseCompactReturn = {
+ type: "JWS" | "JWE",
+ format: "compact" | "json",
+ input: Buffer | string | object,
+ header: object,
+ perform: (ks: JWK.KeyStore) => Promise | Promise
+};
+
+/**
+ * Possible return value from the parse function. The values inside the return
+ * depend heavily on the type of JWT that is passed into it.
+ * @property {string} type Defines whether the JWT was a "JWS" or a "JWE"
+ * @property {string} format Whether the JWT was in compact or JSON format
+ * @property {Buffer|string|object} input The JWT
+ * @property {object} all All of the headers from the recipients or signatories.
+ * @property {function} perform The operation to perform. After calling parse, call the
+ * `perform` function from the return with a valid keystore to verify or decrypt the JWT.
+ */
+type parseJSONReturn = {
+ type: "JWS" | "JWE",
+ format: "compact" | "json",
+ input: Buffer | string | object,
+ all: object,
+ perform: (ks: JWK.KeyStore) => Promise | Promise
+};
+
+/**
+ * Given a JWT passed in as input, the function will return all the known data about
+ * the JWT as described in the return documentation, as well as a function to process
+ * the token (either verify it or decrypt it). This is a helper function that performs
+ * guessing logic so the user does not need to manage whether a token is compact, json,
+ * JWS, or JWE.
+ *
+ * @param {Buffer|string|object} input The token
+ * @returns {parseCompactReturn|parseJSONReturn} the return object, as defined by its documentation.
+ */
+export function parse(input: Buffer | string | object): parseCompactReturn | parseJSONReturn;
+export namespace parse {
+
+ /**
+ * A helper function for `parse`, but is available for usage. This function is called
+ * for JWTs in the compact format.
+ *
+ * @param {Buffer|string|object} input The token
+ * @returns {parseCompactReturn|parseJSONReturn} the return object, as defined by its documentation.
+ */
+ function compact(input: Buffer | string | object): parseCompactReturn | parseJSONReturn;
+
+ /**
+ * A helper function for `parse`, but is available for usage. This function is called
+ * for JWTs in the JSON format.
+ *
+ * @param {Buffer|string|object} input The token
+ * @returns {parseCompactReturn|parseJSONReturn} the return object, as defined by its documentation.
+ */
+ function json(input: Buffer | string | object): parseCompactReturn | parseJSONReturn;
+}
diff --git a/node-jose/node-jose-tests.ts b/node-jose/node-jose-tests.ts
new file mode 100644
index 0000000000..fa43a262a9
--- /dev/null
+++ b/node-jose/node-jose-tests.ts
@@ -0,0 +1,388 @@
+/*
+ * Test file for node-jose. At this time these tests were taken verbatim
+ * from the documentation on the NPM page at
+ * https://www.npmjs.com/package/node-jose
+ * This file definitely needs to be cleaned up and more tests added to
+ * test the entirety of the definition file.
+ */
+
+import * as jose from 'node-jose';
+
+let keystore = jose.JWK.createKeyStore();
+let buf = new Buffer('a');
+
+jose.JWK.asKeyStore("{key: somekey}").
+ then(function (result) {
+ // {result} is a jose.JWK.KeyStore
+ keystore = result;
+ });
+
+let output = keystore.toJSON();
+output = keystore.toJSON(true);
+
+// by 'kid'
+let kid: string = "someID";
+let key = keystore.get(kid);
+
+// ... and by 'kty'
+key = keystore.get(kid, { kty: 'RSA' });
+
+// ... and by 'use'
+key = keystore.get(kid, { use: 'enc' });
+
+// ... and by 'alg'
+key = keystore.get(kid, { use: 'RSA-OAEP' });
+
+// ... and by 'kty' and 'use'
+key = keystore.get(kid, { kty: 'RSA', use: 'enc' });
+
+// same as above, but with a single {props} argument
+key = keystore.get({ kid: kid, kty: 'RSA', use: 'enc' });
+
+
+// searching for keys
+let everything = keystore.all();
+
+// filter by 'kid'
+everything = keystore.all({ kid: kid });
+
+// filter by 'kty'
+everything = keystore.all({ kty: 'RSA' });
+
+// filter by 'use'
+everything = keystore.all({ use: 'enc' });
+
+// filter by 'alg'
+everything = keystore.all({ alg: 'RSA-OAEP' });
+
+// filter by 'kid' + 'kty' + 'alg'
+everything = keystore.all({ kid: kid, kty: 'RSA', alg: 'RSA-OAEP' });
+
+// input is either a:
+// * jose.JWK.Key to copy from; or
+// * JSON object representing a JWK; or
+keystore.add({}).
+ then(function (result) {
+ // {result} is a jose.JWK.Key
+ key = result;
+ });
+
+// input is either a:
+// * String serialization of a JSON JWK/(base64-encoded) PEM/(binary-encoded) DER
+// * Buffer of a JSON JWK/(base64-encoded) PEM/(binary-encoded) DER
+// form is either a:
+// * "json" for a JSON stringified JWK
+// * "private" for a DER encoded 'raw' private key
+// * "pkcs8" for a DER encoded (unencrypted!) PKCS8 private key
+// * "public" for a DER encoded SPKI public key (alternate to 'spki')
+// * "spki" for a DER encoded SPKI public key
+// * "pkix" for a DER encoded PKIX X.509 certificate
+// * "x509" for a DER encoded PKIX X.509 certificate
+// * "pem" for a PEM encoded of PKCS8 / SPKI / PKIX
+keystore.add(buf, "json").
+ then(function (result) {
+ // {result} is a jose.JWK.Key
+ key = result;
+ });
+
+// first argument is the key type (kty)
+// second is the key size (in bits) or named curve ('crv') for "EC"
+keystore.generate("oct", 256).
+ then(function (result) {
+ // {result} is a jose.JWK.Key
+ key = result;
+ });
+
+// ... with properties
+var props = {
+ kid: 'gBdaS-G8RLax2qgObTD94w',
+ alg: 'A256GCM',
+ use: 'enc'
+};
+keystore.generate("oct", 256, props).
+ then(function (result) {
+ // {result} is a jose.JWK.Key
+ key = result;
+ });
+
+keystore.remove(key);
+// NOTE: key.keystore does not change!!
+
+// where input is either a:
+// * jose.JWK.Key instance
+// * JSON Object representation of a JWK
+jose.JWK.asKey({}).
+ then(function (result) {
+ // {result} is a jose.JWK.Key
+ // {result.keystore} is a unique jose.JWK.KeyStore
+ key = result;
+ });
+
+// where input is either a:
+// * String serialization of a JSON JWK/(base64-encoded) PEM/(binary-encoded) DER
+// * Buffer of a JSON JWK/(base64-encoded) PEM/(binary-encoded) DER
+// form is either a:
+// * "json" for a JSON stringified JWK
+// * "pkcs8" for a DER encoded (unencrypted!) PKCS8 private key
+// * "spki" for a DER encoded SPKI public key
+// * "pkix" for a DER encoded PKIX X.509 certificate
+// * "x509" for a DER encoded PKIX X.509 certificate
+// * "pem" for a PEM encoded of PKCS8 / SPKI / PKIX
+jose.JWK.asKey({}, 'json').
+ then(function (result) {
+ // {result} is a jose.JWK.Key
+ // {result.keystore} is a unique jose.JWK.KeyStore
+ key = result;
+ });
+
+output = key.toJSON();
+output = key.toJSON(true);
+
+// where hash is a supported algorithm, currently one of:
+// * SHA-1
+// * SHA-256
+// * SHA-384
+// * SHA-512
+key.thumbprint('SHA-1').
+ then(function (print) {
+ // {print} is a Buffer containing the thumbprint binary value
+ });
+
+// {input} is a Buffer
+jose.JWS.createSign(key).
+ update(buf).
+ final().
+ then(function (result) {
+ // {result} is a JSON object -- JWS using the JSON General Serialization
+ });
+
+jose.JWS.createSign({ format: 'flattened' }, key).
+ update(buf).
+ final().
+ then(function (result) {
+ // {result} is a JSON object -- JWS using the JSON Flattened Serialization
+ });
+
+jose.JWS.createSign({ format: 'compact' }, key).
+ update(buf).
+ final().
+ then(function (result) {
+ // {result} is a String -- JWS using the Compact Serialization
+ });
+
+jose.JWS.createSign({ alg: 'PS256' }, key).
+ update(buf).
+ final().
+ then(function (result) {
+ // ....
+ });
+
+jose.JWS.createSign({ fields: { cty: 'jwk+json' } }, key).
+ update(buf).
+ final().
+ then(function (result) {
+ // ....
+ });
+
+jose.JWS.createSign(key).
+ update(buf, "utf8").
+ final().
+ then(function (result) {
+ // ....
+ });
+
+// {keys} is an Array of jose.JWK.Key instances
+jose.JWS.createSign([key, key]).
+ update(buf).
+ final().
+ then(function (result) {
+ // ....
+ });
+
+jose.JWS.createVerify(keystore).
+ verify("some.jws.object").
+ then(function (result) {
+ // {result} is a Object with:
+ // * header: the combined 'protected' and 'unprotected' header members
+ // * payload: Buffer of the signed content
+ // * signature: Buffer of the verified signature
+ // * key: The key used to verify the signature
+ });
+
+// {key} can be:
+// * jose.JWK.Key
+// * JSON object representing a JWK
+jose.JWS.createVerify(key).
+ verify('some.jws.object').
+ then(function (result) {
+ // ...
+ });
+
+jose.JWS.createVerify().
+ verify('some.jws.key').
+ then(function (result) {
+ // ...
+ });
+
+var opts = {
+ handlers: {
+ "exp": true
+ }
+};
+
+jose.JWS.createVerify(key, opts).
+ verify('some.jws.key').
+ then(function (result) {
+ // ...
+ });
+
+var opts2 = {
+ handlers: {
+ "exp": function (jws: any) {
+ // {jws} is the JWS verify output, pre-verification
+ jws.header.exp = new Date(jws.header.exp);
+ }
+ }
+};
+jose.JWS.createVerify(key, opts2).
+ verify('some.jws.key').
+ then(function (result) {
+ // ...
+ });
+
+var opts3 = {
+ handlers: {
+ "exp": {
+ complete: function (jws: any) {
+ // {jws} is the JWS verify output, post-verification
+ jws.header.exp = new Date(jws.header.exp);
+ }
+ }
+ }
+};
+jose.JWS.createVerify(key, opts3).
+ verify('some.jws.key').
+ then(function (result) {
+ // ...
+ });
+
+//Encryption
+
+// {input} is a Buffer
+jose.JWE.createEncrypt(key).
+ update(buf).
+ final().
+ then(function (result) {
+ // {result} is a JSON Object -- JWE using the JSON General Serialization
+ });
+
+jose.JWE.createEncrypt({ format: 'compact' }, key).
+ update(buf).
+ final().
+ then(function (result) {
+ // {result} is a String -- JWE using the Compact Serialization
+ });
+
+jose.JWE.createEncrypt({ format: 'flattened' }, key).
+ update(buf).
+ final().
+ then(function (result) {
+ // {result} is a JSON Object -- JWE using the JSON Flattened Serialization
+ });
+
+jose.JWE.createEncrypt({ zip: true }, key).
+ update(buf).
+ final().
+ then(function (result) {
+ // ....
+ });
+
+jose.JWE.createEncrypt({ fields: { cty: 'jwk+json' } }, key).
+ update(buf).
+ final().
+ then(function (result) {
+ // ....
+ });
+
+// {keys} is an Array of jose.JWK.Key instances
+jose.JWE.createEncrypt([key, key]).
+ update(buf).
+ final().
+ then(function (result) {
+ // ....
+ });
+
+jose.JWE.createDecrypt(keystore).
+ decrypt('some.jwe').
+ then(function (result) {
+ // {result} is a Object with:
+ // * header: the combined 'protected' and 'unprotected' header members
+ // * protected: an array of the member names from the "protected" member
+ // * key: Key used to decrypt
+ // * payload: Buffer of the decrypted content
+ // * plaintext: Buffer of the decrypted content (alternate)
+ });
+
+jose.JWE.createDecrypt(key).
+ decrypt('some.jwe').
+ then(function (result) {
+ // ....
+ });
+
+var opts4 = {
+ handlers: {
+ "exp": true
+ }
+};
+jose.JWE.createDecrypt(key, opts4).
+ decrypt('some.jwe').
+ then(function (result) {
+ // ...
+ });
+//To perform additional (pre-decrypt) processing on a crit header member:
+
+var opts5 = {
+ handlers: {
+ "exp": function (jwe: any) {
+ // {jwe} is the JWE decrypt output, pre-decryption
+ jwe.header.exp = new Date(jwe.header.exp);
+ }
+ }
+};
+jose.JWE.createDecrypt(key, opts5).
+ decrypt('some.jwe').
+ then(function (result) {
+ // ...
+ });
+//To perform additional (post-decrypt) processing on a crit header member:
+
+var opts6 = {
+ handlers: {
+ "exp": {
+ complete: function (jwe: any) {
+ // {jwe} is the JWE decrypt output, post-decryption
+ jwe.header.exp = new Date(jwe.header.exp);
+ }
+ }
+ }
+};
+jose.JWE.createDecrypt(key, opts6).
+ decrypt('some.jwe').
+ then(function (result) {
+ // ...
+ });
+
+var buff = jose.util.asBuffer('input');
+
+var output2 = jose.util.base64url.encode(buf);
+
+// explicit encoding
+output2 = jose.util.base64url.encode(buf, "utf8");
+
+// implied "utf8" encoding
+output2 = jose.util.base64url.encode(buf);
+
+var output3 = jose.util.base64url.decode('input');
+
+// argument is size (in bytes)
+var rnd = jose.util.randomBytes(32);
diff --git a/node-jose/tsconfig.json b/node-jose/tsconfig.json
new file mode 100644
index 0000000000..0de8c3967e
--- /dev/null
+++ b/node-jose/tsconfig.json
@@ -0,0 +1,22 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "lib": [
+ "es6"
+ ],
+ "noImplicitAny": true,
+ "noImplicitThis": true,
+ "strictNullChecks": true,
+ "baseUrl": "../",
+ "typeRoots": [
+ "../"
+ ],
+ "types": [],
+ "noEmit": true,
+ "forceConsistentCasingInFileNames": true
+ },
+ "files": [
+ "index.d.ts",
+ "node-jose-tests.ts"
+ ]
+}
From 539308239d0da175db7577359772772d5dd48814 Mon Sep 17 00:00:00 2001
From: Jason Burns
Date: Thu, 23 Mar 2017 20:22:53 -0700
Subject: [PATCH 006/844] Add TS 2.2 header as advised by Travis.
---
node-jose/index.d.ts | 1 +
1 file changed, 1 insertion(+)
diff --git a/node-jose/index.d.ts b/node-jose/index.d.ts
index d3a7fd891c..93ae198493 100644
--- a/node-jose/index.d.ts
+++ b/node-jose/index.d.ts
@@ -2,6 +2,7 @@
// Project: https://github.com/cisco/node-jose
// Definitions by: Jason Burns
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+// TypeScript Version: 2.2
// Most of this documentation comes directly from the excellently documented
// node-jose package, with only a bit added in to explain intermediate types.
From 867cb974ead3360eda11a7341269d272bee2fa35 Mon Sep 17 00:00:00 2001
From: JuanFran
Date: Sat, 25 Mar 2017 01:02:15 +0100
Subject: [PATCH 007/844] Support for new 3.0.3 version of moment-range
---
types/moment-range/index.d.ts | 107 +++++++++++++++++------
types/moment-range/moment-range-tests.ts | 77 ++++++++++------
types/moment-range/package.json | 3 +-
3 files changed, 129 insertions(+), 58 deletions(-)
diff --git a/types/moment-range/index.d.ts b/types/moment-range/index.d.ts
index 7ff7feb9b8..25cc786acf 100644
--- a/types/moment-range/index.d.ts
+++ b/types/moment-range/index.d.ts
@@ -1,6 +1,6 @@
-// Type definitions for Moment.js 2.0.4
+// Type definitions for Moment-range.js 3.0.3
// Project: https://github.com/gf3/moment-range
-// Definitions by: Bart van den Burg , Wilgert Velinga
+// Definitions by: Bart van den Burg , Wilgert Velinga , Juan Francisco Adame
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import * as moment from 'moment';
@@ -8,48 +8,99 @@ import * as moment from 'moment';
export = moment;
declare module 'moment' {
- interface Range {
- start: Moment;
- end: Moment;
+ class DateRange implements Range {
+ start: moment.Moment;
+ end: moment.Moment;
- contains (other: Date, exclusive?: boolean): boolean;
- contains (other: Moment, exclusive?: boolean): boolean;
+ constructor(range: string | Date[] | moment.Moment[]);
+ constructor(start: Date | moment.Moment, end: Date | moment.Moment);
- overlaps (range: Range): boolean;
- intersect (other: Range): Range;
+ contains(other: DateRange | moment.Moment | Date, options?: { exclusive?: boolean }): boolean;
- add (other: Range): Range;
+ overlaps(range: DateRange, options?: { adjacent?: boolean }): boolean;
- subtract (other: Range): Range[];
+ intersect(other: DateRange): DateRange;
- by (range: string, hollaback: (current: Moment) => void, exclusive?: boolean): void;
- by (range: Range, hollaback: (current: Moment) => void, exclusive?: boolean): void;
+ add(other: DateRange): DateRange;
- isSame (other: Range): boolean;
+ subtract(other: DateRange): DateRange[];
- diff (unit?: string): number;
+ by(interval: moment.unitOfTime.Diff, options?: { exclusive?: boolean, step?: number }): Iterable;
- toDate (): Date;
+ byRange(interval: DateRange, options?: { exclusive?: boolean, step?: number }): Iterable;
- toString (): string;
+ isSame(other: DateRange): boolean;
- toArray (by: Range|String, exclusive?: boolean): Moment[];
+ diff(unit?: moment.unitOfTime.Diff, rounded?: boolean): number;
- valueOf (): number;
+ toDate(): Date[];
- center (): number;
+ toString(): string;
- clone (): Range;
+ valueOf(): number;
+
+ center(): moment.Moment;
+
+ clone(): DateRange;
+
+ isEqual(other: DateRange): boolean;
+
+ adjacent(other: DateRange): boolean;
+
+ duration(unit?: moment.unitOfTime.Diff, precise?: boolean): number;
+
+ reverseBy(interval: moment.unitOfTime.Diff, options?: { exclusive?: boolean, step?: number }): Iterable;
+
+ reverseByRange(interval: DateRange, options?: { exclusive?: boolean, step?: number }): Iterable;
}
- interface Moment {
- within (x: moment.Range): boolean;
+ interface Range {
+ start: moment.Moment;
+ end: moment.Moment;
+
+ contains(other: DateRange | moment.Moment | Date, options?: { exclusive?: boolean }): boolean;
+
+ overlaps(range: DateRange, options?: { adjacent?: boolean }): boolean;
+
+ intersect(other: DateRange): DateRange;
+
+ add(other: DateRange): DateRange;
+
+ subtract(other: DateRange): DateRange[];
+
+ by(interval: moment.unitOfTime.Diff, options?: { exclusive?: boolean, step?: number }): Iterable;
+
+ byRange(interval: DateRange, options?: { exclusive?: boolean, step?: number }): Iterable;
+
+ isSame(other: DateRange): boolean;
+
+ diff(unit?: moment.unitOfTime.Diff, rounded?: boolean): number;
+
+ toDate(): Date[];
+
+ toString(): string;
+
+ valueOf(): number;
+
+ center(): moment.Moment;
+
+ clone(): DateRange;
+
+ isEqual(other: DateRange): boolean;
+
+ adjacent(other: DateRange): boolean;
+
+ duration(unit?: moment.unitOfTime.Diff, precise?: boolean): number;
+
+ reverseBy(interval: moment.unitOfTime.Diff, options?: { exclusive?: boolean, step?: number }): Iterable;
+
+ reverseByRange(interval: DateRange, options?: { exclusive?: boolean, step?: number }): Iterable;
+
}
- function range(range: string): moment.Range;
- function range(range: Date[]): moment.Range;
- function range(range: Moment[]): moment.Range;
- function range(start: Date, end: Date): moment.Range;
- function range(start: Moment, end: Moment): moment.Range;
+ function extendMoment(moment: any): any;
+
+ function range(range: string | Date[] | moment.Moment[]): moment.Range;
+ function range(start: Date | moment.Moment, end: Date | moment.Moment): moment.Range;
}
diff --git a/types/moment-range/moment-range-tests.ts b/types/moment-range/moment-range-tests.ts
index 16bcf7c808..9667e62d75 100644
--- a/types/moment-range/moment-range-tests.ts
+++ b/types/moment-range/moment-range-tests.ts
@@ -1,47 +1,66 @@
import * as moment from 'moment';
+import * as momentRange from "moment-range";
-var range: moment.Range = moment.range(new Date(2012, 0, 15), new Date(2012, 4, 23));
-var range2: moment.Range = moment.range(moment("2011-04-15", "YYYY-MM-DD"), moment("2011-11-27", "YYYY-MM-DD"));
-var range3: moment.Range = moment.range([moment("2011-04-15", "YYYY-MM-DD"), moment("2011-11-27", "YYYY-MM-DD")]);
-var range4: moment.Range = moment.range("2015-01-17T09:50:04+00:00/2015-04-17T08:29:55+00:00");
+var range: momentRange.DateRange = new momentRange.DateRange(new Date(2012, 0, 15), new Date(2012, 4, 23));
+var range2: momentRange.DateRange = new momentRange.DateRange(moment("2011-04-15", "YYYY-MM-DD"), moment("2011-11-27", "YYYY-MM-DD"));
+var range3: momentRange.DateRange = new momentRange.DateRange([moment("2011-04-15", "YYYY-MM-DD"), moment("2011-11-27", "YYYY-MM-DD")]);
+var range4: momentRange.DateRange = new momentRange.DateRange("2015-01-17T09:50:04+00:00/2015-04-17T08:29:55+00:00");
-var date: moment.Moment = moment('2012-05- 15');
+var date: moment.Moment = moment('2012-05-15');
-var res1: boolean = range.contains(date);
-var res2: boolean = range.contains(date, false);
-var res3: boolean = range.contains(date, true);
+var res1: boolean = range.adjacent(range2);
-var res4: boolean = date.within(range);
+var it0: Iterable = range.by('days');
+var it1: Iterable = range.by('months', {exclusive: true});
+var it2: Iterable = range.by('years', {exclusive: false, step: 2});
-var res5: boolean = range.overlaps(range2);
+var it3: Iterable = range.byRange(range);
+var it4: Iterable = range.byRange(range, {exclusive: true});
+var it5: Iterable = range.byRange(range, {exclusive: false, step: 2});
-var res6: moment.Range = range.intersect(range2);
+var res2: moment.Moment = range.center();
-var res7: moment.Range = range.add(range2);
+var res3: momentRange.DateRange = range.clone();
-var res8: Array = range.subtract(range2);
+var res4: boolean = range.contains(range);
+var res5: boolean = range.contains(range, {exclusive: true});
+var res6: boolean = range.contains(range, {exclusive: false});
-range.by('days', (moment: moment.Moment) => { });
-range.by(range2, (moment: moment.Moment) => { });
-range.by('d', (moment: moment.Moment) => { }, true);
-
-var res9: boolean = range.isSame(range2);
-
-var res10: number = range.diff('months');
+var res10: number = range.diff('months', true);
var res11: number = range.diff('days');
var res12: number = range.diff();
-var res13: Date = range.toDate();
-var res14: string = range.toString();
+var res13: number = range.duration('months', true);
+var res14: number = range.duration('days');
+var res15: number = range.duration();
-var res15: number = range.valueOf();
+var res16: momentRange.DateRange = range.intersect(range2);
-var res16: number = range.center();
+var res17: boolean = range.isSame(range2);
-var res17: moment.Range = range.clone();
+var res18: boolean = range.isEqual(range2);
-var res18: moment.Moment = range.start;
-var res19: moment.Moment = range.end;
+var res20: boolean = range.overlaps(range2);
+var res21: boolean = range.overlaps(range2, {adjacent: true});
+var res22: boolean = range.overlaps(range2, {adjacent: false});
-var res20: moment.Moment[] = range.toArray('days');
-var res22: moment.Moment[] = range.toArray('days', true);
+var it6: Iterable = range.reverseBy('days');
+var it7: Iterable = range.reverseBy('months', {exclusive: true});
+var it8: Iterable = range.reverseBy('years', {exclusive: false, step: 2});
+
+var it9: Iterable = range.reverseByRange(range);
+var it10: Iterable = range.reverseByRange(range, {exclusive: true});
+var it11: Iterable = range.reverseByRange(range, {exclusive: false, step: 2});
+
+var res23: momentRange.DateRange = range.add(range2);
+
+var res24: Array = range.subtract(range2);
+
+var res25: Date[] = range.toDate();
+
+var res26: string = range.toString();
+
+var res27: number = range.valueOf();
+
+var res28: moment.Moment = range.start;
+var res29: moment.Moment = range.end;
diff --git a/types/moment-range/package.json b/types/moment-range/package.json
index 4c6d24a445..ce42336f8c 100644
--- a/types/moment-range/package.json
+++ b/types/moment-range/package.json
@@ -1,5 +1,6 @@
{
"dependencies": {
- "moment": ">=2.14.0"
+ "moment": "2.17.1",
+ "moment-range": "3.0.3"
}
}
\ No newline at end of file
From 3ab99add41868f9c1b6823b3d2658960916ef385 Mon Sep 17 00:00:00 2001
From: epicgirl1998
Date: Sat, 25 Mar 2017 04:52:25 +0200
Subject: [PATCH 008/844] Fix chrome.webNavigation filtering again
---
types/chrome/index.d.ts | 9 +++++----
types/chrome/test/index.ts | 18 +++++-------------
2 files changed, 10 insertions(+), 17 deletions(-)
diff --git a/types/chrome/index.d.ts b/types/chrome/index.d.ts
index 1b07c1c2e8..be0f59ebca 100644
--- a/types/chrome/index.d.ts
+++ b/types/chrome/index.d.ts
@@ -7074,12 +7074,13 @@ declare namespace chrome.webNavigation {
transitionQualifiers: string[];
}
- interface WebNavigationRequestFilter extends chrome.webRequest.RequestFilter {
- /** fulfills the webRequest.RequestFilter interface even though it is under web navigation **/
+ interface WebNavigationEventFilter {
+ /** Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of UrlFilter are ignored for this event. */
+ url: chrome.events.UrlFilter[];
}
interface WebNavigationEvent extends chrome.events.Event<(details: T) => void> {
- addListener(callback: (details: T) => void, filters?: WebNavigationRequestFilter): void;
+ addListener(callback: (details: T) => void, filters?: WebNavigationEventFilter): void;
}
interface WebNavigationFramedEvent extends WebNavigationEvent {}
@@ -7189,7 +7190,7 @@ declare namespace chrome.webRequest {
*/
types?: string[];
/** A list of URLs or URL patterns. Requests that cannot match any of the URLs will be filtered out. */
- urls: string[] | RegExp[] | "";
+ urls: string[];
/** Optional. */
windowId?: number;
diff --git a/types/chrome/test/index.ts b/types/chrome/test/index.ts
index 3da3f534be..ffe1ece74d 100644
--- a/types/chrome/test/index.ts
+++ b/types/chrome/test/index.ts
@@ -171,7 +171,7 @@ function catBlock () {
["blocking"]);
}
-// webNavigation.onBeforeNavigate.addListener example similar api to onBeforeRequest but without extra spec
+// webNavigation.onBeforeNavigate.addListener example
function beforeRedditNavigation() {
chrome.webNavigation.onBeforeNavigate.addListener(function (requestDetails) {
console.log("URL we want to redirect to: " + requestDetails.url);
@@ -180,18 +180,10 @@ function beforeRedditNavigation() {
return;
}
- let url = new URL(requestDetails.url);
- let splitUrl = url.hostname.split('.');
- //` Note: Does not cover the XX.co.uk type edge case
- let host = (splitUrl[(splitUrl.length -1) - 1]);
-
- if (host === null) {
- return;
- } else if (host === "reddit") {
- alert("Were you trying to go on reddit, during working hours? :(")
- return;
- }
- },{urls: ["http://*/*"], types: ["image"]});
+ alert("Were you trying to go on reddit, during working hours? :(")
+ },{url: [
+ {hostSuffix: ".reddit.com"}
+ ]});
}
// for chrome.tabs.InjectDetails.frameId
From 266710318846d12d5f6af5285c17d08e3c67abd4 Mon Sep 17 00:00:00 2001
From: rzymek
Date: Sat, 25 Mar 2017 09:49:19 +0100
Subject: [PATCH 009/844] lodash - _.zipObjectDeep
https://lodash.com/docs/4.17.4#zipObjectDeep
The same signature as _.zipObject
---
types/lodash.zipobjectdeep/index.d.ts | 8 ++
types/lodash.zipobjectdeep/tsconfig.json | 21 +++++
types/lodash.zipobjectdeep/tslint.json | 1 +
types/lodash/index.d.ts | 102 ++++++++++++++++++++++-
types/lodash/lodash-tests.ts | 22 +++++
types/lodash/zipObjectDeep/index.d.ts | 2 +
6 files changed, 153 insertions(+), 3 deletions(-)
create mode 100644 types/lodash.zipobjectdeep/index.d.ts
create mode 100644 types/lodash.zipobjectdeep/tsconfig.json
create mode 100644 types/lodash.zipobjectdeep/tslint.json
create mode 100644 types/lodash/zipObjectDeep/index.d.ts
diff --git a/types/lodash.zipobjectdeep/index.d.ts b/types/lodash.zipobjectdeep/index.d.ts
new file mode 100644
index 0000000000..1944588188
--- /dev/null
+++ b/types/lodash.zipobjectdeep/index.d.ts
@@ -0,0 +1,8 @@
+// Type definitions for lodash.zipObjectDeep 4.1
+// Project: http://lodash.com/
+// Definitions by: Brian Zengel , Ilya Mochalov , Stepan Mikhaylyuk
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+// TypeScript Version: 2.2
+
+import { zipObjectDeep } from "lodash";
+export = zipObjectDeep;
diff --git a/types/lodash.zipobjectdeep/tsconfig.json b/types/lodash.zipobjectdeep/tsconfig.json
new file mode 100644
index 0000000000..92ebbc6458
--- /dev/null
+++ b/types/lodash.zipobjectdeep/tsconfig.json
@@ -0,0 +1,21 @@
+{
+ "files": [
+ "index.d.ts"
+ ],
+ "compilerOptions": {
+ "module": "commonjs",
+ "lib": [
+ "es6"
+ ],
+ "noImplicitAny": true,
+ "noImplicitThis": true,
+ "strictNullChecks": false,
+ "baseUrl": "../",
+ "typeRoots": [
+ "../"
+ ],
+ "types": [],
+ "noEmit": true,
+ "forceConsistentCasingInFileNames": true
+ }
+}
\ No newline at end of file
diff --git a/types/lodash.zipobjectdeep/tslint.json b/types/lodash.zipobjectdeep/tslint.json
new file mode 100644
index 0000000000..377cc837d4
--- /dev/null
+++ b/types/lodash.zipobjectdeep/tslint.json
@@ -0,0 +1 @@
+{ "extends": "../tslint.json" }
diff --git a/types/lodash/index.d.ts b/types/lodash/index.d.ts
index 6326773899..170ce63aaf 100644
--- a/types/lodash/index.d.ts
+++ b/types/lodash/index.d.ts
@@ -5660,9 +5660,8 @@ declare namespace _ {
//_.zipObject
interface LoDashStatic {
/**
- * The inverse of _.pairs; this method returns an object composed from arrays of property names and values.
- * Provide either a single two dimensional array, e.g. [[key1, value1], [key2, value2]] or two arrays, one of
- * property names and one of corresponding values.
+ * This method is like _.fromPairs except that it accepts two arrays, one of property
+ * identifiers and one of corresponding values.
*
* @param props The property names.
* @param values The property values.
@@ -5672,6 +5671,17 @@ declare namespace _ {
props: List|List>,
values?: List
): TResult;
+ /**
+ * This method is like _.zipObject except that it supports property paths.
+ *
+ * @param props The property names.
+ * @param values The property values.
+ * @return Returns the new object.
+ */
+ zipObjectDeep(
+ props: List|List>,
+ values?: List
+ ): TResult;
/**
* @see _.zipObject
@@ -5680,6 +5690,13 @@ declare namespace _ {
props: List|List>,
values?: List
): TResult;
+ /**
+ * @see _.zipObjectDeep
+ */
+ zipObjectDeep(
+ props: List|List>,
+ values?: List
+ ): TResult;
/**
* @see _.zipObject
@@ -5688,6 +5705,13 @@ declare namespace _ {
props: List|List>,
values?: List
): _.Dictionary;
+ /**
+ * @see _.zipObjectDeep
+ */
+ zipObjectDepp(
+ props: List|List>,
+ values?: List
+ ): _.Dictionary;
}
interface LoDashImplicitArrayWrapper {
@@ -5697,6 +5721,12 @@ declare namespace _ {
zipObject(
values?: List
): _.LoDashImplicitObjectWrapper;
+ /**
+ * @see _.zipObjectDeep
+ */
+ zipObjectDeep(
+ values?: List
+ ): _.LoDashImplicitObjectWrapper;
/**
* @see _.zipObject
@@ -5704,6 +5734,12 @@ declare namespace _ {
zipObject(
values?: List
): _.LoDashImplicitObjectWrapper;
+ /**
+ * @see _.zipObjectDeep
+ */
+ zipObjectDeep(
+ values?: List
+ ): _.LoDashImplicitObjectWrapper;
/**
* @see _.zipObject
@@ -5711,6 +5747,12 @@ declare namespace _ {
zipObject(
values?: List
): _.LoDashImplicitObjectWrapper<_.Dictionary>;
+ /**
+ * @see _.zipObjectDeep
+ */
+ zipObjectDeep(
+ values?: List
+ ): _.LoDashImplicitObjectWrapper<_.Dictionary>;
}
interface LoDashImplicitObjectWrapper {
@@ -5720,6 +5762,12 @@ declare namespace _ {
zipObject(
values?: List
): _.LoDashImplicitObjectWrapper;
+ /**
+ * @see _.zipObjectDeep
+ */
+ zipObjectDeep(
+ values?: List
+ ): _.LoDashImplicitObjectWrapper;
/**
* @see _.zipObject
@@ -5727,6 +5775,12 @@ declare namespace _ {
zipObject(
values?: List
): _.LoDashImplicitObjectWrapper;
+ /**
+ * @see _.zipObjectDeep
+ */
+ zipObjectDeep(
+ values?: List
+ ): _.LoDashImplicitObjectWrapper;
/**
* @see _.zipObject
@@ -5734,6 +5788,12 @@ declare namespace _ {
zipObject(
values?: List
): _.LoDashImplicitObjectWrapper<_.Dictionary>;
+ /**
+ * @see _.zipObjectDeep
+ */
+ zipObjectDeep(
+ values?: List
+ ): _.LoDashImplicitObjectWrapper<_.Dictionary>;
}
interface LoDashExplicitArrayWrapper {
@@ -5743,6 +5803,12 @@ declare namespace _ {
zipObject(
values?: List
): _.LoDashExplicitObjectWrapper;
+ /**
+ * @see _.zipObjectDeep
+ */
+ zipObjectDeep(
+ values?: List
+ ): _.LoDashExplicitObjectWrapper;
/**
* @see _.zipObject
@@ -5750,6 +5816,12 @@ declare namespace _ {
zipObject(
values?: List
): _.LoDashExplicitObjectWrapper;
+ /**
+ * @see _.zipObjectDeep
+ */
+ zipObjectDeep(
+ values?: List
+ ): _.LoDashExplicitObjectWrapper;
/**
* @see _.zipObject
@@ -5757,6 +5829,12 @@ declare namespace _ {
zipObject(
values?: List
): _.LoDashExplicitObjectWrapper<_.Dictionary>;
+ /**
+ * @see _.zipObjectDeep
+ */
+ zipObjectDeep(
+ values?: List
+ ): _.LoDashExplicitObjectWrapper<_.Dictionary>;
}
interface LoDashExplicitObjectWrapper {
@@ -5766,6 +5844,12 @@ declare namespace _ {
zipObject(
values?: List
): _.LoDashExplicitObjectWrapper;
+ /**
+ * @see _.zipObjectDeep
+ */
+ zipObjectDeep(
+ values?: List
+ ): _.LoDashExplicitObjectWrapper;
/**
* @see _.zipObject
@@ -5773,6 +5857,12 @@ declare namespace _ {
zipObject(
values?: List
): _.LoDashExplicitObjectWrapper;
+ /**
+ * @see _.zipObjectDeep
+ */
+ zipObjectDeep(
+ values?: List
+ ): _.LoDashExplicitObjectWrapper;
/**
* @see _.zipObject
@@ -5780,6 +5870,12 @@ declare namespace _ {
zipObject(
values?: List
): _.LoDashExplicitObjectWrapper<_.Dictionary>;
+ /**
+ * @see _.zipObjectDeep
+ */
+ zipObjectDeep(
+ values?: List
+ ): _.LoDashExplicitObjectWrapper<_.Dictionary>;
}
//_.zipWith
diff --git a/types/lodash/lodash-tests.ts b/types/lodash/lodash-tests.ts
index b260df8ee5..311e2e8242 100644
--- a/types/lodash/lodash-tests.ts
+++ b/types/lodash/lodash-tests.ts
@@ -2608,12 +2608,18 @@ namespace TestZipObject {
let result: _.Dictionary;
result = _.zipObject(arrayOfKeys);
+ result = _.zipObjectDeep(arrayOfKeys);
result = _.zipObject(arrayOfKeys, arrayOfValues);
+ result = _.zipObjectDeep(arrayOfKeys, arrayOfValues);
result = _.zipObject(arrayOfKeys, listOfValues);
+ result = _.zipObjectDeep(arrayOfKeys, listOfValues);
result = _.zipObject(listOfKeys);
+ result = _.zipObjectDeep(listOfKeys);
result = _.zipObject(listOfKeys, listOfValues);
+ result = _.zipObjectDeep(listOfKeys, listOfValues);
result = _.zipObject(listOfKeys, arrayOfValues);
+ result = _.zipObjectDeep(listOfKeys, arrayOfValues);
result = _.zipObject<_.Dictionary>(arrayOfKeyValuePairs);
result = _.zipObject<_.Dictionary>(listOfKeyValuePairs);
@@ -2647,15 +2653,23 @@ namespace TestZipObject {
let result: _.LoDashImplicitObjectWrapper<_.Dictionary>;
result = _(arrayOfKeys).zipObject();
+ result = _(arrayOfKeys).zipObjectDeep();
result = _(arrayOfKeys).zipObject(arrayOfValues);
+ result = _(arrayOfKeys).zipObjectDeep(arrayOfValues);
result = _(arrayOfKeys).zipObject(listOfValues);
+ result = _(arrayOfKeys).zipObjectDeep(listOfValues);
result = _(listOfKeys).zipObject();
+ result = _(listOfKeys).zipObjectDeep();
result = _(listOfKeys).zipObject(listOfValues);
+ result = _(listOfKeys).zipObjectDeep(listOfValues);
result = _(listOfKeys).zipObject(arrayOfValues);
+ result = _(listOfKeys).zipObjectDeep(arrayOfValues);
result = _(listOfKeys).zipObject(arrayOfKeyValuePairs);
+ result = _(listOfKeys).zipObjectDeep(arrayOfKeyValuePairs);
result = _(listOfKeys).zipObject(listOfKeyValuePairs);
+ result = _(listOfKeys).zipObjectDeep(listOfKeyValuePairs);
}
{
@@ -2686,15 +2700,23 @@ namespace TestZipObject {
let result: _.LoDashExplicitObjectWrapper<_.Dictionary>;
result = _(arrayOfKeys).chain().zipObject();
+ result = _(arrayOfKeys).chain().zipObjectDeep();
result = _(arrayOfKeys).chain().zipObject(arrayOfValues);
+ result = _(arrayOfKeys).chain().zipObjectDeep(arrayOfValues);
result = _(arrayOfKeys).chain().zipObject(listOfValues);
+ result = _(arrayOfKeys).chain().zipObjectDeep(listOfValues);
result = _(listOfKeys).chain().zipObject();
+ result = _(listOfKeys).chain().zipObjectDeep();
result = _(listOfKeys).chain().zipObject(listOfValues);
+ result = _(listOfKeys).chain().zipObjectDeep(listOfValues);
result = _(listOfKeys).chain().zipObject(arrayOfValues);
+ result = _(listOfKeys).chain().zipObjectDeep(arrayOfValues);
result = _(listOfKeys).chain().zipObject(arrayOfKeyValuePairs);
+ result = _(listOfKeys).chain().zipObjectDeep(arrayOfKeyValuePairs);
result = _(listOfKeys).chain().zipObject(listOfKeyValuePairs);
+ result = _(listOfKeys).chain().zipObjectDeep(listOfKeyValuePairs);
}
}
diff --git a/types/lodash/zipObjectDeep/index.d.ts b/types/lodash/zipObjectDeep/index.d.ts
new file mode 100644
index 0000000000..a155901bb5
--- /dev/null
+++ b/types/lodash/zipObjectDeep/index.d.ts
@@ -0,0 +1,2 @@
+import { zipObjectDeep } from "../index";
+export = zipObjectDeep;
\ No newline at end of file
From 259d2a3ec8323aaa6e8d183c39b309f441fdfb0d Mon Sep 17 00:00:00 2001
From: rzymek
Date: Sat, 25 Mar 2017 17:23:29 +0100
Subject: [PATCH 010/844] add zipObjectDeep to tsconfig.json
fixed failed travis test: lodash/zipObjectDeep has unused file index.d.ts
---
types/lodash/tsconfig.json | 1 +
1 file changed, 1 insertion(+)
diff --git a/types/lodash/tsconfig.json b/types/lodash/tsconfig.json
index 419b6142b1..c0730d6661 100644
--- a/types/lodash/tsconfig.json
+++ b/types/lodash/tsconfig.json
@@ -288,6 +288,7 @@
"xorWith/index.d.ts",
"zip/index.d.ts",
"zipObject/index.d.ts",
+ "zipObjectDeep/index.d.ts",
"zipWith/index.d.ts"
],
"compilerOptions": {
From 5a634f7fdb5b593c50b229c5a14507789c888be7 Mon Sep 17 00:00:00 2001
From: KeitaNishimoto
Date: Sun, 26 Mar 2017 01:45:51 +0900
Subject: [PATCH 011/844] add API Gateway CustomAuthorizerEvent
---
types/aws-lambda/aws-lambda-tests.ts | 7 +++++++
types/aws-lambda/index.d.ts | 8 ++++++++
2 files changed, 15 insertions(+)
diff --git a/types/aws-lambda/aws-lambda-tests.ts b/types/aws-lambda/aws-lambda-tests.ts
index 3aede36d4c..07908b2677 100644
--- a/types/aws-lambda/aws-lambda-tests.ts
+++ b/types/aws-lambda/aws-lambda-tests.ts
@@ -5,6 +5,7 @@ var num: number = 5;
var error: Error = new Error();
var b: boolean = true;
var apiGwEvt: AWSLambda.APIGatewayEvent;
+var customAuthorizerEvt: AWSLambda.CustomAuthorizerEvent;
var clientCtx: AWSLambda.ClientContext;
var clientContextEnv: AWSLambda.ClientContextEnv;
var clientContextClient: AWSLambda.ClientContextClient;
@@ -87,6 +88,11 @@ str = apiGwEvt.requestContext.resourceId;
str = apiGwEvt.requestContext.resourcePath;
str = apiGwEvt.resource;
+/* API Gateway CustomAuthorizer Event */
+str = customAuthorizerEvt.type;
+str = customAuthorizerEvt.authorizationToken;
+str = customAuthorizerEvt.methodArn;
+
/* SNS Event */
snsEvtRecs = snsEvt.Records;
@@ -183,3 +189,4 @@ context.fail(str);
/* Handler */
let handler: AWSLambda.Handler = (event: any, context: AWSLambda.Context, cb: AWSLambda.Callback) => { };
let proxyHandler: AWSLambda.ProxyHandler = (event: AWSLambda.APIGatewayEvent, context: AWSLambda.Context, cb: AWSLambda.ProxyCallback) => { };
+let CustomAuthorizerHandler: AWSLambda.CustomAuthorizerHandler = (event: AWSLambda.CustomAuthorizerEvent, context: AWSLambda.Context, cb: AWSLambda.Callback) => { };
diff --git a/types/aws-lambda/index.d.ts b/types/aws-lambda/index.d.ts
index c5e49d54c6..f388302d24 100644
--- a/types/aws-lambda/index.d.ts
+++ b/types/aws-lambda/index.d.ts
@@ -39,6 +39,13 @@ interface APIGatewayEvent {
resource: string;
}
+// API Gateway CustomAuthorizer "event"
+interface CustomAuthorizerEvent {
+ type: string;
+ authorizationToken: string;
+ methodArn: string;
+}
+
// SNS "event"
interface SNSMessageAttribute {
Type: string;
@@ -190,6 +197,7 @@ interface ProxyResult {
*/
export type Handler = (event: any, context: Context, callback?: Callback) => void;
export type ProxyHandler = (event: APIGatewayEvent, context: Context, callback?: ProxyCallback) => void;
+export type CustomAuthorizerHandler = (event: CustomAuthorizerEvent, context: Context, callback?: Callback) => void;
/**
* Optional callback parameter.
From 0b91832778478e00e962510b97d9fae6c9b7e264 Mon Sep 17 00:00:00 2001
From: Nicolas Laplante
Date: Sat, 25 Mar 2017 12:56:05 -0400
Subject: [PATCH 012/844] add types & mtehods from dockerode current (v2.4.2)
---
types/dockerode/index.d.ts | 71 ++++++++++++++++++++++++++++++++++++++
1 file changed, 71 insertions(+)
diff --git a/types/dockerode/index.d.ts b/types/dockerode/index.d.ts
index 968199436a..71dac87f54 100644
--- a/types/dockerode/index.d.ts
+++ b/types/dockerode/index.d.ts
@@ -137,6 +137,49 @@ declare namespace Dockerode {
id?: string;
}
+ interface Plugin {
+ modem: any;
+ name: string;
+ remote: any;
+
+ inspect(callback: Callback): void;
+
+ remove(options: {}, callback: Callback): void;
+ remove(callback: Callback): void;
+
+ privileges(callback: Callback): void;
+
+ pull(options: {}, callback: Callback): void;
+
+ enable(options: {}, callback: Callback): void;
+ enable(callback: Callback): void;
+
+ disable(options: {}, callback: Callback): void;
+ disable(callback: Callback): void;
+
+ push(options: {}, callback: Callback): void;
+ push(callback: Callback): void;
+
+ configure(options: {}, callback: Callback): void;
+ configure(callback: Callback): void;
+
+ upgrade(auth: any, options: {}, callback: Callback): void;
+ upgrade(auth: any, callback: Callback): void;
+ }
+
+ interface Secret {
+ inspect(callback: Callback): void;
+
+ update(options: {}, callback: Callback): void;
+ update(callback: Callback): void;
+
+ remove(options: {}, callback: Callback): void;
+ remove(callback: Callback): void;
+
+ modem: any;
+ id?: string;
+ }
+
interface Network {
inspect(callback: Callback): void;
@@ -575,6 +618,8 @@ declare class Dockerode {
getVolume(name: string): Dockerode.Volume;
+ getPlugin(name: string, remote: any): Dockerode.Plugin;
+
getService(id: string): Dockerode.Service;
getTask(id: string): Dockerode.Task;
@@ -583,6 +628,8 @@ declare class Dockerode {
getNetwork(id: string): Dockerode.Network;
+ getSecret(id: string): Dockerode.Secret;
+
getExec(id: string): Dockerode.Exec;
listContainers(options: {}, callback: Callback): void;
@@ -600,12 +647,22 @@ declare class Dockerode {
listTasks(options: {}, callback: Callback): void;
listTasks(callback: Callback): void;
+ listSecrets(options: {}, callback: Callback): void;
+ listSecrets(callback: Callback): void;
+
+ listPlugins(options: {}, callback: Callback): void;
+ listPlugins(callback: Callback): void;
+
listVolumes(options: {}, callback: Callback): void;
listVolumes(callback: Callback): void;
listNetworks(options: {}, callback: Callback): void;
listNetworks(callback: Callback): void;
+ createSecret(options: {}, callback: Callback): void;
+
+ createPlugin(options: {}, callback: Callback): void;
+
createVolume(options: {}, callback: Callback): void;
createService(options: {}, callback: Callback): void;
@@ -614,6 +671,18 @@ declare class Dockerode {
searchImages(options: {}, callback: Callback): void;
+ pruneImages(options: {}, callback: Callback): void;
+ pruneImages(callback: Callback): void;
+
+ pruneContainers(options: {}, callback: Callback): void;
+ pruneContainers(callback: Callback): void;
+
+ pruneVolumes(options: {}, callback: Callback): void;
+ pruneVolumes(callback: Callback): void;
+
+ pruneNetworks(options: {}, callback: Callback): void;
+ pruneNetworks(callback: Callback): void;
+
info(callback: Callback): void;
version(callback: Callback): void;
@@ -638,6 +707,8 @@ declare class Dockerode {
swarmUpdate(options: {}, callback: Callback): void;
+ swarmInspect(callback: Callback): void;
+
modem: any;
}
From 701ad3fcc01782b5c366f5b507a2ee4fcb6a57ec Mon Sep 17 00:00:00 2001
From: Tamir Duberstein
Date: Fri, 24 Mar 2017 13:53:25 -0400
Subject: [PATCH 013/844] lodash: fix toPairs, toPairsIn definitions
toPairs: https://github.com/lodash/lodash/blob/4.17.4/lodash.js#L13684:L13708
toPairsIn: https://github.com/lodash/lodash/blob/4.17.4/lodash.js#L13710:L13734
Fixes #14654.
---
types/lodash/index.d.ts | 16 ++++++++--------
types/lodash/lodash-tests.ts | 24 ++++++++++++------------
2 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/types/lodash/index.d.ts b/types/lodash/index.d.ts
index 6326773899..79326724b1 100644
--- a/types/lodash/index.d.ts
+++ b/types/lodash/index.d.ts
@@ -16993,23 +16993,23 @@ declare namespace _ {
* @param object The object to query.
* @return Returns the new array of key-value pairs.
*/
- toPairs(object?: T): any[][];
+ toPairs(object?: T): [string, any][];
- toPairs(object?: T): TResult[][];
+ toPairs(object?: T): [string, TResult][];
}
interface LoDashImplicitObjectWrapper {
/**
* @see _.toPairs
*/
- toPairs(): LoDashImplicitArrayWrapper;
+ toPairs(): LoDashImplicitArrayWrapper<[string, TResult]>;
}
interface LoDashExplicitObjectWrapper {
/**
* @see _.toPairs
*/
- toPairs(): LoDashExplicitArrayWrapper;
+ toPairs(): LoDashExplicitArrayWrapper<[string, TResult]>;
}
//_.toPairsIn
@@ -17020,23 +17020,23 @@ declare namespace _ {
* @param object The object to query.
* @return Returns the new array of key-value pairs.
*/
- toPairsIn(object?: T): any[][];
+ toPairsIn(object?: T): [string, any][];
- toPairsIn(object?: T): TResult[][];
+ toPairsIn(object?: T): [string, TResult][];
}
interface LoDashImplicitObjectWrapper {
/**
* @see _.toPairsIn
*/
- toPairsIn(): LoDashImplicitArrayWrapper;
+ toPairsIn(): LoDashImplicitArrayWrapper<[string, TResult]>;
}
interface LoDashExplicitObjectWrapper {
/**
* @see _.toPairsIn
*/
- toPairsIn(): LoDashExplicitArrayWrapper;
+ toPairsIn(): LoDashExplicitArrayWrapper<[string, TResult]>;
}
//_.transform
diff --git a/types/lodash/lodash-tests.ts b/types/lodash/lodash-tests.ts
index b260df8ee5..8659859557 100644
--- a/types/lodash/lodash-tests.ts
+++ b/types/lodash/lodash-tests.ts
@@ -10176,37 +10176,37 @@ namespace TestToPairs {
let object: _.Dictionary;
{
- let result: any[][];
+ let result: [string, any][];
result = _.toPairs<_.Dictionary>(object);
}
{
- let result: string[][];
+ let result: [string, string][];
result = _.toPairs<_.Dictionary, string>(object);
}
{
- let result: _.LoDashImplicitArrayWrapper;
+ let result: _.LoDashImplicitArrayWrapper<[string, string]>;
result = _(object).toPairs();
}
{
- let result: _.LoDashImplicitArrayWrapper;
+ let result: _.LoDashImplicitArrayWrapper<[string, any]>;
result = _(object).toPairs();
}
{
- let result: _.LoDashExplicitArrayWrapper;
+ let result: _.LoDashExplicitArrayWrapper<[string, string]>;
result = _(object).chain().toPairs();
}
{
- let result: _.LoDashExplicitArrayWrapper;
+ let result: _.LoDashExplicitArrayWrapper<[string, any]>;
result = _(object).chain().toPairs();
}
@@ -10217,37 +10217,37 @@ namespace TestToPairsIn {
let object: _.Dictionary;
{
- let result: any[][];
+ let result: [string, any][];
result = _.toPairsIn<_.Dictionary>(object);
}
{
- let result: string[][];
+ let result: [string, string][];
result = _.toPairsIn<_.Dictionary, string>(object);
}
{
- let result: _.LoDashImplicitArrayWrapper;
+ let result: _.LoDashImplicitArrayWrapper<[string, string]>;
result = _(object).toPairsIn();
}
{
- let result: _.LoDashImplicitArrayWrapper;
+ let result: _.LoDashImplicitArrayWrapper<[string, any]>;
result = _(object).toPairsIn();
}
{
- let result: _.LoDashExplicitArrayWrapper;
+ let result: _.LoDashExplicitArrayWrapper<[string, string]>;
result = _(object).chain().toPairsIn();
}
{
- let result: _.LoDashExplicitArrayWrapper;
+ let result: _.LoDashExplicitArrayWrapper<[string, any]>;
result = _(object).chain().toPairs();
}
From a7d8ae9f4f015e685944be144a90a078fafb4680 Mon Sep 17 00:00:00 2001
From: Nicolas Laplante
Date: Sat, 25 Mar 2017 13:08:42 -0400
Subject: [PATCH 014/844] add definition author
---
types/dockerode/index.d.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/types/dockerode/index.d.ts b/types/dockerode/index.d.ts
index 71dac87f54..c4f7750dfd 100644
--- a/types/dockerode/index.d.ts
+++ b/types/dockerode/index.d.ts
@@ -1,6 +1,6 @@
// Type definitions for dockerode 2.3
// Project: https://github.com/apocas/dockerode
-// Definitions by: Carl Winkler
+// Definitions by: Carl Winkler , Nicolas Laplante
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
///
From 105eb862579c7e9cae4608d70ea9d95c53f95fd9 Mon Sep 17 00:00:00 2001
From: Nicolas Laplante
Date: Sat, 25 Mar 2017 13:08:52 -0400
Subject: [PATCH 015/844] upgrade dockerode version
---
types/dockerode/index.d.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/types/dockerode/index.d.ts b/types/dockerode/index.d.ts
index c4f7750dfd..8c5b1f56c7 100644
--- a/types/dockerode/index.d.ts
+++ b/types/dockerode/index.d.ts
@@ -1,4 +1,4 @@
-// Type definitions for dockerode 2.3
+// Type definitions for dockerode 2.4.2
// Project: https://github.com/apocas/dockerode
// Definitions by: Carl Winkler , Nicolas Laplante
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
From 171855d201093525e44c65c33eb49a4bba2306ce Mon Sep 17 00:00:00 2001
From: Nicolas Laplante
Date: Sat, 25 Mar 2017 13:09:02 -0400
Subject: [PATCH 016/844] add tests for new api
---
types/dockerode/dockerode-tests.ts | 68 +++++++++++++++++++++++++++++-
1 file changed, 67 insertions(+), 1 deletion(-)
diff --git a/types/dockerode/dockerode-tests.ts b/types/dockerode/dockerode-tests.ts
index 3bd1c30097..4b4e406839 100644
--- a/types/dockerode/dockerode-tests.ts
+++ b/types/dockerode/dockerode-tests.ts
@@ -55,4 +55,70 @@ docker.createContainer({ Tty: true }, (err, container) => {
container.start((err, data) => {
// NOOP
});
-});
\ No newline at end of file
+});
+
+docker.pruneContainers((err, response) => {
+ // NOOP
+});
+
+docker.pruneImages((err, response) => {
+ // NOOP
+});
+
+docker.pruneNetworks((err, response) => {
+ // NOOP
+});
+
+docker.pruneVolumes((err, response) => {
+ // NOOP
+});
+
+const plugin = docker.getPlugin('pluginName', 'remoteName');
+plugin.configure((err, response) => {
+ // NOOP;
+});
+
+plugin.disable((err, response) => {
+ // NOOP
+});
+
+plugin.enable((err, response) => {
+ // NOOP
+});
+
+plugin.inspect((err, response) => {
+ // NOOP
+});
+
+plugin.privileges((err, response) => {
+ // NOOP
+});
+
+plugin.pull({}, (err, response) => {
+ // NOOP
+});
+
+plugin.push((err, response) => {
+ // NOOP
+});
+
+plugin.remove((err, response) => {
+ // NOOP
+});
+
+plugin.upgrade({}, (err, response) => {
+ // NOOP
+});
+
+const secret = docker.getSecret('secretName');
+secret.inspect((err, response) => {
+ // NOOP
+});
+
+secret.remove((err, response) => {
+ // NOOP
+});
+
+secret.update((err, response) => {
+ // NOOP
+});
From 8a9add5b87f0f6b767e1de33b80e86f312de8ad2 Mon Sep 17 00:00:00 2001
From: Nicolas Laplante
Date: Sat, 25 Mar 2017 13:10:28 -0400
Subject: [PATCH 017/844] remove minor from version
---
types/dockerode/index.d.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/types/dockerode/index.d.ts b/types/dockerode/index.d.ts
index 8c5b1f56c7..8f82d982c6 100644
--- a/types/dockerode/index.d.ts
+++ b/types/dockerode/index.d.ts
@@ -1,4 +1,4 @@
-// Type definitions for dockerode 2.4.2
+// Type definitions for dockerode 2.4
// Project: https://github.com/apocas/dockerode
// Definitions by: Carl Winkler , Nicolas Laplante
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
From c7e08e933c62ec1dff93eaf1b857895669d2bfd9 Mon Sep 17 00:00:00 2001
From: Nicolas Laplante
Date: Sun, 26 Mar 2017 11:48:12 -0400
Subject: [PATCH 018/844] add type definitions
---
types/dockerode/index.d.ts | 165 +++++++++++++++++++++++++++++++++----
1 file changed, 149 insertions(+), 16 deletions(-)
diff --git a/types/dockerode/index.d.ts b/types/dockerode/index.d.ts
index 8f82d982c6..4d9a979665 100644
--- a/types/dockerode/index.d.ts
+++ b/types/dockerode/index.d.ts
@@ -94,8 +94,8 @@ declare namespace Dockerode {
tag(options: {}, callback: Callback): void;
tag(callback: Callback): void;
- remove(options: {}, callback: Callback): void;
- remove(callback: Callback