@tennantje/identity-types 1.0.18 → 1.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/OAuthError.d.ts +50 -0
- package/dist/OAuthError.js +125 -0
- package/package.json +1 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export interface OAuthErrorInput {
|
|
2
|
+
error: string;
|
|
3
|
+
errorDescription: string;
|
|
4
|
+
code: number;
|
|
5
|
+
redirectUri?: string;
|
|
6
|
+
state?: string;
|
|
7
|
+
sendCorsHeaders?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface OAuthChildErrorInput {
|
|
10
|
+
code: number;
|
|
11
|
+
redirectUri?: string;
|
|
12
|
+
state?: string;
|
|
13
|
+
sendCorsHeaders?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare class OAuthError extends Error {
|
|
16
|
+
error: string;
|
|
17
|
+
errorDescription: string;
|
|
18
|
+
code: number;
|
|
19
|
+
redirectUri?: string;
|
|
20
|
+
state?: string;
|
|
21
|
+
sendCorsHeaders: boolean;
|
|
22
|
+
constructor(input: OAuthErrorInput);
|
|
23
|
+
}
|
|
24
|
+
export declare class OAuthInvalidRequestError extends OAuthError {
|
|
25
|
+
constructor({ code, redirectUri, state, sendCorsHeaders, }: OAuthChildErrorInput);
|
|
26
|
+
}
|
|
27
|
+
export declare class OAuthInvalidGrantError extends OAuthError {
|
|
28
|
+
constructor({ code, redirectUri, state, sendCorsHeaders, }: OAuthChildErrorInput);
|
|
29
|
+
}
|
|
30
|
+
export declare class OAuthUnauthorizedClientError extends OAuthError {
|
|
31
|
+
constructor({ code, redirectUri, state, sendCorsHeaders, }: OAuthChildErrorInput);
|
|
32
|
+
}
|
|
33
|
+
export declare class OAuthAccessDeniedError extends OAuthError {
|
|
34
|
+
constructor({ code, redirectUri, state, sendCorsHeaders, }: OAuthChildErrorInput);
|
|
35
|
+
}
|
|
36
|
+
export declare class OAuthUnsupportedResponseTypeError extends OAuthError {
|
|
37
|
+
constructor({ code, redirectUri, state, sendCorsHeaders, }: OAuthChildErrorInput);
|
|
38
|
+
}
|
|
39
|
+
export declare class OAuthInvalidScopeError extends OAuthError {
|
|
40
|
+
constructor({ code, redirectUri, state, sendCorsHeaders, }: OAuthChildErrorInput);
|
|
41
|
+
}
|
|
42
|
+
export declare class OAuthServerError extends OAuthError {
|
|
43
|
+
constructor({ code, redirectUri, state, sendCorsHeaders, }: OAuthChildErrorInput);
|
|
44
|
+
}
|
|
45
|
+
export declare class OAuthTemporarilyUnavailableError extends OAuthError {
|
|
46
|
+
constructor({ code, redirectUri, state, sendCorsHeaders, }: OAuthChildErrorInput);
|
|
47
|
+
}
|
|
48
|
+
export declare class OAuthUnsupportedGrantTypeError extends OAuthError {
|
|
49
|
+
constructor({ code, redirectUri, state, sendCorsHeaders, }: OAuthChildErrorInput);
|
|
50
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
export class OAuthError extends Error {
|
|
2
|
+
error;
|
|
3
|
+
errorDescription;
|
|
4
|
+
code;
|
|
5
|
+
redirectUri;
|
|
6
|
+
state;
|
|
7
|
+
sendCorsHeaders;
|
|
8
|
+
constructor(input) {
|
|
9
|
+
super(input.error);
|
|
10
|
+
this.error = input.error;
|
|
11
|
+
this.code = input.code;
|
|
12
|
+
this.errorDescription = input.errorDescription;
|
|
13
|
+
this.redirectUri = input.redirectUri;
|
|
14
|
+
this.state = input.state;
|
|
15
|
+
this.sendCorsHeaders = input.sendCorsHeaders ?? false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export class OAuthInvalidRequestError extends OAuthError {
|
|
19
|
+
constructor({ code, redirectUri, state, sendCorsHeaders, }) {
|
|
20
|
+
super({
|
|
21
|
+
code,
|
|
22
|
+
error: "invalid_request",
|
|
23
|
+
errorDescription: "The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.",
|
|
24
|
+
redirectUri,
|
|
25
|
+
state,
|
|
26
|
+
sendCorsHeaders,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export class OAuthInvalidGrantError extends OAuthError {
|
|
31
|
+
constructor({ code, redirectUri, state, sendCorsHeaders, }) {
|
|
32
|
+
super({
|
|
33
|
+
code,
|
|
34
|
+
error: "invalid_grant",
|
|
35
|
+
errorDescription: "The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirect URI used in the authorization request, or was issued to another client.",
|
|
36
|
+
redirectUri,
|
|
37
|
+
state,
|
|
38
|
+
sendCorsHeaders,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export class OAuthUnauthorizedClientError extends OAuthError {
|
|
43
|
+
constructor({ code, redirectUri, state, sendCorsHeaders, }) {
|
|
44
|
+
super({
|
|
45
|
+
code,
|
|
46
|
+
error: "unauthorized_client",
|
|
47
|
+
errorDescription: "The client is not authorized to request an authorization code using this method.",
|
|
48
|
+
redirectUri,
|
|
49
|
+
state,
|
|
50
|
+
sendCorsHeaders,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export class OAuthAccessDeniedError extends OAuthError {
|
|
55
|
+
constructor({ code, redirectUri, state, sendCorsHeaders, }) {
|
|
56
|
+
super({
|
|
57
|
+
code,
|
|
58
|
+
error: "access_denied",
|
|
59
|
+
errorDescription: "The resource owner or authorization server denied the request.",
|
|
60
|
+
redirectUri,
|
|
61
|
+
state,
|
|
62
|
+
sendCorsHeaders,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export class OAuthUnsupportedResponseTypeError extends OAuthError {
|
|
67
|
+
constructor({ code, redirectUri, state, sendCorsHeaders, }) {
|
|
68
|
+
super({
|
|
69
|
+
code,
|
|
70
|
+
error: "unsupported_response_type",
|
|
71
|
+
errorDescription: "The authorization server does not support obtaining an authorization code using this method.",
|
|
72
|
+
redirectUri,
|
|
73
|
+
state,
|
|
74
|
+
sendCorsHeaders,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
export class OAuthInvalidScopeError extends OAuthError {
|
|
79
|
+
constructor({ code, redirectUri, state, sendCorsHeaders, }) {
|
|
80
|
+
super({
|
|
81
|
+
code,
|
|
82
|
+
error: "invalid_scope",
|
|
83
|
+
errorDescription: "The requested scope is invalid, unknown, or malformed.",
|
|
84
|
+
redirectUri,
|
|
85
|
+
state,
|
|
86
|
+
sendCorsHeaders,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
export class OAuthServerError extends OAuthError {
|
|
91
|
+
constructor({ code, redirectUri, state, sendCorsHeaders, }) {
|
|
92
|
+
super({
|
|
93
|
+
code,
|
|
94
|
+
error: "server_error",
|
|
95
|
+
errorDescription: "The authorization server encountered an unexpected condition that prevented it from fulfilling the request.",
|
|
96
|
+
redirectUri,
|
|
97
|
+
state,
|
|
98
|
+
sendCorsHeaders,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
export class OAuthTemporarilyUnavailableError extends OAuthError {
|
|
103
|
+
constructor({ code, redirectUri, state, sendCorsHeaders, }) {
|
|
104
|
+
super({
|
|
105
|
+
code,
|
|
106
|
+
error: "temporarily_unavailable",
|
|
107
|
+
errorDescription: "The authorization server is currently unable to handle the request due to a temporary overloading or maintenance of the server.",
|
|
108
|
+
redirectUri,
|
|
109
|
+
state,
|
|
110
|
+
sendCorsHeaders,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
export class OAuthUnsupportedGrantTypeError extends OAuthError {
|
|
115
|
+
constructor({ code, redirectUri, state, sendCorsHeaders, }) {
|
|
116
|
+
super({
|
|
117
|
+
code,
|
|
118
|
+
error: "unsupported_grant_type",
|
|
119
|
+
errorDescription: "The authorization grant type is not supported by the authorization server.",
|
|
120
|
+
redirectUri,
|
|
121
|
+
state,
|
|
122
|
+
sendCorsHeaders,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|