diff --git a/types/rasha/index.d.ts b/types/rasha/index.d.ts new file mode 100644 index 0000000000..eeb0dadb5e --- /dev/null +++ b/types/rasha/index.d.ts @@ -0,0 +1,57 @@ +// Type definitions for rasha 1.2 +// Project: https://git.coolaj86.com/coolaj86/rasha.js +// Definitions by: Justin Baroux +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +export as namespace Rasha; + +export interface Jwk { + kty: string; + n: string; + e: string; + d: string; + p: string; + q: string; + dp: string; + dq: string; + qi: string; +} + +export interface GenerateOptions { + format: string; + encoding?: string; + modulusLength?: number; + publicExponent?: number; +} + +export interface ImportOptions { + pem: string; + public: boolean; +} + +export interface ExportOptions { + jwk: Jwk; + format: string; + public: boolean; +} + +export interface RsaKeys { + private: string; + public: string; +} + +// Generate RSA KEY +export function generate(opts: GenerateOptions): Promise; + +// PEM-to-JWK +declare function Import(opts: ImportOptions): Promise; +export { Import as import }; + +// JWK-to-PEM +declare function Export(opts: ExportOptions): Promise; +export { Export as export }; + +// JWK Thumbprint +export function thumbprint(jwk: Jwk): Promise; diff --git a/types/rasha/rasha-tests.ts b/types/rasha/rasha-tests.ts new file mode 100644 index 0000000000..fade7c165b --- /dev/null +++ b/types/rasha/rasha-tests.ts @@ -0,0 +1,10 @@ +import * as rasha from 'rasha'; + +const gOptions: Rasha.GenerateOptions = { format: 'jwk' }; + +rasha.generate(gOptions).then((keypair: Rasha.RsaKeys) => { + console.log(keypair.private); + console.log(keypair.public); +}); + +// const rsa: RsaKeys = Rasha.generate(gOptions); diff --git a/types/rasha/tsconfig.json b/types/rasha/tsconfig.json new file mode 100644 index 0000000000..838de830c9 --- /dev/null +++ b/types/rasha/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "rasha-tests.ts" + ] +} \ No newline at end of file diff --git a/types/rasha/tslint.json b/types/rasha/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/rasha/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }