mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-02 00:00:04 +00:00
add: new test and lint fix
This commit is contained in:
2
types/node-jose/index.d.ts
vendored
2
types/node-jose/index.d.ts
vendored
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/cisco/node-jose
|
||||
// Definitions by: Nadun Indunil <https://github.com/nadunindunil>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
// TypeScript Version: 3.3
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
|
||||
@@ -39,102 +39,78 @@ everything = keystore.all({ alg: 'RSA-OAEP' });
|
||||
// filter by 'kid' + 'kty' + 'alg'
|
||||
everything = keystore.all({ kid: 'kid', kty: 'RSA', alg: 'RSA-OAEP' });
|
||||
|
||||
keystore.add('input').then(function(result) {});
|
||||
keystore.add('input').then(result => {});
|
||||
|
||||
keystore.add('input', 'json').then(function(result) {
|
||||
keystore.add('input', 'json').then(result => {
|
||||
// {result} is a jose.JWK.Key
|
||||
});
|
||||
|
||||
keystore.generate('oct', 256).then(function(result) {
|
||||
keystore.generate('oct', 256).then(result => {
|
||||
// {result} is a jose.JWK.Key
|
||||
});
|
||||
|
||||
// ... with properties
|
||||
let props = {
|
||||
const props = {
|
||||
kid: 'gBdaS-G8RLax2qgObTD94w',
|
||||
alg: 'A256GCM',
|
||||
use: 'enc'
|
||||
};
|
||||
|
||||
let key2: jose.JWK.Key;
|
||||
keystore.generate('oct', 256, props).then(function(result) {
|
||||
// {result} is a jose.JWK.Key
|
||||
keystore.generate('oct', 256, props).then(result => {
|
||||
key2 = result;
|
||||
keystore.remove(key2);
|
||||
|
||||
// where input is either a:
|
||||
// * jose.JWK.Key instance
|
||||
// * JSON Object representation of a JWK
|
||||
jose.JWK.asKey(key2).then(result => {});
|
||||
|
||||
jose.JWK.asKey(key2).then(function(result) {
|
||||
// {result} is a jose.JWK.Key
|
||||
// {result.keystore} is a unique jose.JWK.KeyStore
|
||||
});
|
||||
|
||||
// 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('input', 'json').then(function(result) {
|
||||
// {result} is a jose.JWK.Key
|
||||
// {result.keystore} is a unique jose.JWK.KeyStore
|
||||
});
|
||||
jose.JWK.asKey('input', 'json').then(result => {});
|
||||
});
|
||||
|
||||
jose.JWK.createKey('oct', 256, { alg: 'A256GCM' }).then(function(result) {
|
||||
// {result} is a jose.JWK.Key
|
||||
// {result.keystore} is a unique jose.JWK.KeyStore
|
||||
let output4 = result.toJSON(true);
|
||||
result.thumbprint('hash').then(function(print) {
|
||||
// {print} is a Buffer containing the thumbprint binary value
|
||||
});
|
||||
jose.JWK.createKey('oct', 256, { alg: 'A256GCM' }).then(result => {
|
||||
const output4 = result.toJSON(true);
|
||||
result.thumbprint('hash').then(print => {});
|
||||
|
||||
const key = result;
|
||||
|
||||
let key = result;
|
||||
jose.JWS.createSign(key)
|
||||
.update('input')
|
||||
.final()
|
||||
.then(function(result) {
|
||||
.then(result => {
|
||||
// {result} is a JSON object -- JWS using the JSON General Serialization
|
||||
});
|
||||
|
||||
jose.JWS.createSign({ format: 'flattened' }, key)
|
||||
.update('input')
|
||||
.final()
|
||||
.then(function(result) {
|
||||
.then(result => {
|
||||
// {result} is a JSON object -- JWS using the JSON Flattened Serialization
|
||||
});
|
||||
|
||||
jose.JWS.createSign({ format: 'compact' }, key)
|
||||
.update('input')
|
||||
.final()
|
||||
.then(function(result) {
|
||||
.then(result => {
|
||||
// {result} is a String -- JWS using the Compact Serialization
|
||||
});
|
||||
|
||||
jose.JWS.createSign({ alg: 'PS256' }, key)
|
||||
.update('input')
|
||||
.final()
|
||||
.then(function(result) {
|
||||
.then(result => {
|
||||
// ....
|
||||
});
|
||||
|
||||
jose.JWS.createSign({ fields: { cty: 'jwk+json' } }, key)
|
||||
.update('input')
|
||||
.final()
|
||||
.then(function(result) {
|
||||
.then(result => {
|
||||
// ....
|
||||
});
|
||||
|
||||
jose.JWS.createSign(key)
|
||||
.update('input', 'utf8')
|
||||
.final()
|
||||
.then(function(result) {
|
||||
.then(result => {
|
||||
// ....
|
||||
});
|
||||
|
||||
@@ -143,7 +119,7 @@ jose.JWK.createKey('oct', 256, { alg: 'A256GCM' }).then(function(result) {
|
||||
};
|
||||
jose.JWS.createVerify(key, opts)
|
||||
.verify('input')
|
||||
.then(function(result) {
|
||||
.then(result => {
|
||||
// ...
|
||||
});
|
||||
|
||||
@@ -152,7 +128,7 @@ jose.JWK.createKey('oct', 256, { alg: 'A256GCM' }).then(function(result) {
|
||||
};
|
||||
jose.JWS.createVerify(key, opts)
|
||||
.verify('input')
|
||||
.then(function(result) {
|
||||
.then(result => {
|
||||
// ...
|
||||
});
|
||||
|
||||
@@ -164,55 +140,55 @@ jose.JWK.createKey('oct', 256, { alg: 'A256GCM' }).then(function(result) {
|
||||
|
||||
jose.JWS.createVerify(key, opts2)
|
||||
.verify('input')
|
||||
.then(function(result) {
|
||||
.then(result => {
|
||||
// ...
|
||||
});
|
||||
|
||||
jose.JWE.createEncrypt(key)
|
||||
.update('input')
|
||||
.final()
|
||||
.then(function(result) {
|
||||
.then(result => {
|
||||
// {result} is a JSON Object -- JWE using the JSON General Serialization
|
||||
});
|
||||
|
||||
jose.JWE.createEncrypt({ format: 'compact' }, key)
|
||||
.update('input')
|
||||
.final()
|
||||
.then(function(result) {
|
||||
.then(result => {
|
||||
// {result} is a String -- JWE using the Compact Serialization
|
||||
});
|
||||
|
||||
jose.JWE.createEncrypt({ format: 'flattened' }, key)
|
||||
.update('input')
|
||||
.final()
|
||||
.then(function(result) {
|
||||
.then(result => {
|
||||
// {result} is a JSON Object -- JWE using the JSON Flattened Serialization
|
||||
});
|
||||
|
||||
jose.JWE.createEncrypt({ zip: true }, key)
|
||||
.update('input')
|
||||
.final()
|
||||
.then(function(result) {
|
||||
.then(result => {
|
||||
// ....
|
||||
});
|
||||
|
||||
jose.JWE.createEncrypt({ fields: { cty: 'jwk+json' } }, key)
|
||||
.update('input')
|
||||
.final()
|
||||
.then(function(result) {
|
||||
.then(result => {
|
||||
// ....
|
||||
});
|
||||
|
||||
jose.JWE.createEncrypt([key, key])
|
||||
.update('input')
|
||||
.final()
|
||||
.then(function(result) {
|
||||
.then(result => {
|
||||
// ....
|
||||
});
|
||||
|
||||
jose.JWE.createDecrypt(key)
|
||||
.decrypt('input')
|
||||
.then(function(result) {
|
||||
.then(result => {
|
||||
// ....
|
||||
});
|
||||
|
||||
@@ -221,7 +197,7 @@ jose.JWK.createKey('oct', 256, { alg: 'A256GCM' }).then(function(result) {
|
||||
};
|
||||
jose.JWE.createDecrypt(key, opts3)
|
||||
.decrypt('input')
|
||||
.then(function(result) {
|
||||
.then(result => {
|
||||
// ...
|
||||
});
|
||||
|
||||
@@ -230,7 +206,7 @@ jose.JWK.createKey('oct', 256, { alg: 'A256GCM' }).then(function(result) {
|
||||
};
|
||||
jose.JWS.createVerify(key, opts4)
|
||||
.verify('input')
|
||||
.then(function(result) {
|
||||
.then(result => {
|
||||
// ...
|
||||
});
|
||||
|
||||
@@ -241,14 +217,14 @@ jose.JWK.createKey('oct', 256, { alg: 'A256GCM' }).then(function(result) {
|
||||
};
|
||||
jose.JWE.createDecrypt(key, opts5)
|
||||
.decrypt('input')
|
||||
.then(function(result) {
|
||||
.then(result => {
|
||||
// ...
|
||||
});
|
||||
});
|
||||
|
||||
jose.JWS.createVerify(keystore)
|
||||
.verify('input')
|
||||
.then(function(result) {
|
||||
.then(result => {
|
||||
// {result} is a Object with:
|
||||
// * header: the combined 'protected' and 'unprotected' header members
|
||||
// * payload: Buffer of the signed content
|
||||
@@ -261,25 +237,25 @@ jose.JWS.createVerify(keystore)
|
||||
// * JSON object representing a JWK
|
||||
jose.JWS.createVerify(key)
|
||||
.verify('input')
|
||||
.then(function(result) {
|
||||
.then(result => {
|
||||
// ...
|
||||
});
|
||||
|
||||
jose.JWS.createVerify()
|
||||
.verify('input', { allowEmbeddedKey: true })
|
||||
.then(function(result) {
|
||||
.then(result => {
|
||||
// ...
|
||||
});
|
||||
|
||||
let verifier = jose.JWS.createVerify({ allowEmbeddedKey: true });
|
||||
const verifier = jose.JWS.createVerify({ allowEmbeddedKey: true });
|
||||
|
||||
verifier.verify('input').then(function(result) {
|
||||
verifier.verify('input').then(result => {
|
||||
// ...
|
||||
});
|
||||
|
||||
jose.JWE.createDecrypt(keystore)
|
||||
.decrypt('input')
|
||||
.then(function(result) {
|
||||
.then(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
|
||||
|
||||
Reference in New Issue
Block a user