Skip to content

Commit

Permalink
fix(typescript): add error constructors (#483)
Browse files Browse the repository at this point in the history
  • Loading branch information
mthadley authored Apr 14, 2022
1 parent 96b367d commit 9505cba
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as http2 from 'http2';
import { URL } from 'url';
import * as jose from 'jose';
import * as crypto from 'crypto';
import { format } from 'util';

export type HttpOptions = Partial<
Pick<
Expand Down Expand Up @@ -572,6 +573,18 @@ export namespace errors {
scope?: string;
session_state?: string;
response?: { body?: UnknownObject | Buffer } & http.IncomingMessage;

constructor(
params: {
error: string;
error_description?: string;
error_uri?: string;
state?: string;
scope?: string;
session_state?: string;
},
response?: { body?: UnknownObject | Buffer } & http.IncomingMessage,
);
}

class RPError extends Error {
Expand All @@ -586,6 +599,14 @@ export namespace errors {
exp?: number;
iat?: number;
auth_time?: number;

constructor(...args: Parameters<typeof format>);
constructor(options: {
message?: string;
printf?: Parameters<typeof format>;
response?: { body?: UnknownObject | Buffer } & http.IncomingMessage;
[key: string]: unknown;
});
}
}

Expand Down

0 comments on commit 9505cba

Please sign in to comment.