Skip to content

Commit

Permalink
Merge pull request #9 from brunokrebs/type-definition
Browse files Browse the repository at this point in the history
Type definition
  • Loading branch information
sandrinodimattia authored Jun 27, 2017
2 parents ed177e2 + 6fc054d commit b8fa525
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

# Matches multiple files with brace expansion notation
# Set default charset
[*.{js,ts}]
charset = utf-8
indent_style = space
indent_size = 2
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ node_modules
# Build output
lib
!src/lib

# IDE files
.idea/
*.iml
56 changes: 56 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
declare module 'jwks-rsa' {

import * as ExpressJwt from "express-jwt";

function JwksRsa(options: JwksRsa.Options): JwksRsa.JwksClient;

namespace JwksRsa {
class JwksClient {
constructor(options: Options);

getKeys: (cb: (err: Error, keys: Jwk[]) => any) => any;
getSigningKeys: (cb: (err: Error, keys: Jwk[]) => any) => any;
getSigningKey: (kid: string, cb: (err: Error, key: Jwk) => any) => any;
}

interface Jwk {
kid: string;
nbf?: number;
publicKey?: string;
rsaPublicKey?: string;
}

interface Options {
jwksUri: string;
rateLimit?: boolean;
cache?: boolean;
cacheMaxEntries?: number;
cacheMaxAge?: number;
jwksRequestsPerMinute?: number;
strictSsl?: boolean;
handleSigningKeyError?(err: Error, cb: (err: Error) => void): any;
}

function ExpressJwtSecret(options: JwksRsa.Options): ExpressJwt.SecretCallback;

function HapiJwt2Key(options: JwksRsa.Options): (name: string, scheme: string, options?: any) => void;

class ArgumentError extends Error {
constructor(message: string);
}

class JwksError extends Error {
constructor(message: string);
}

class JwksRateLimitError extends Error {
constructor(message: string);
}

class SigningKeyNotFoundError extends Error {
constructor(message: string);
}
}

export = JwksRsa;
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"version": "1.1.1",
"description": "Library to retrieve RSA public keys from a JWKS endpoint",
"main": "lib/index.js",
"types": "index.d.ts",
"dependencies": {
"@types/express-jwt": "0.0.34",
"debug": "^2.2.0",
"limiter": "^1.1.0",
"lru-memoizer": "^1.6.0",
Expand Down

0 comments on commit b8fa525

Please sign in to comment.