Fixed tslint. Minor changes

This commit is contained in:
Alessio Paccoia
2018-06-13 17:37:39 +02:00
parent 189708112f
commit a7b02c6342
3 changed files with 26 additions and 20 deletions

View File

@@ -3,25 +3,17 @@
// Definitions by: Alessio Paccoia <https://github.com/alessiopcc>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export function pem2jwk(pem: string): RSAJWK;
export function jwk2pem(jwk: RSAJWK): string;
export type RSAJWK = RSAPrivateJWK | RSAPublicJWK;
export interface RSAPrivateJWK {
export interface RSA_JWK {
kty: string;
n: string;
e: string;
d: string;
p: string;
q: string;
dp: string;
dq: string;
qi: string;
d?: string;
p?: string;
q?: string;
dp?: string;
dq?: string;
qi?: string;
}
export interface RSAPublicJWK {
kty: string;
n: string;
e: string;
}
export function pem2jwk(rsa_pem: string): RSA_JWK;
export function jwk2pem(rsa_jwk: RSA_JWK): string;

View File

@@ -1,4 +1,17 @@
import * as pem_jwk from "pem-jwk";
import { jwk2pem, pem2jwk, RSA_JWK } from "pem-jwk";
pem_jwk.jwk2pem({kty: 'RSA', n: 'base64 modulus', e: 'base64 exponent'}); // $ExpectType string
pem_jwk.pem2jwk('PEM RSA String'); // $ExpectType pem_jwk.RSAJWK
const rsa_pem = `-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDh6RzHEsTFjD8NlB4echurwfV2
Zrlcg0k2JoP0Z3QAgXPMwJynvs2LeBHYaOFzGzjXRKsvaLwc5PjP3NcqcP3KkX5y
1VA31VrJLfFbXthi0a8c/UBwxJD8i4S35OKr6yui3bJatgYWrSQ4MT9ktaS1TP9l
XBW58V4VlkypTaQTSQIDAQAB
-----END PUBLIC KEY-----`;
const rsa_jwk: RSA_JWK = {
kty: 'RSA',
n: '4ekcxxLExYw_DZQeHnIbq8H1dma5XINJNiaD9Gd0AIFzzMCcp77Ni3gR2Gjhcxs410SrL2i8HOT4z9zXKnD9ypF-ctVQN9VayS3xW17YYtGvHP1AcMSQ_IuEt-Tiq-srot2yWrYGFq0kODE_ZLWktUz_ZVwVufFeFZZMqU2kE0k',
e: 'AQAB'
};
jwk2pem(rsa_jwk); // $ExpectType string
pem2jwk(rsa_pem); // $ExpectType RSA_JWK

View File

@@ -6,6 +6,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [