@adonisjs/ally 6.0.0 → 6.2.0
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/README.md +2 -2
- package/build/{chunk-KWRXS6EG.js → chunk-4QTU45GZ.js} +33 -3
- package/build/{chunk-WM3V3APX.js → chunk-7V2EH7U6.js} +92 -15
- package/build/chunk-ISWHUP4Q.js +125 -0
- package/build/{chunk-KSJ4CFTC.js → chunk-NK6X76EQ.js} +16 -25
- package/build/chunk-TSIMPJ6I.js +119 -0
- package/build/index.js +90 -21
- package/build/providers/ally_provider.d.ts +10 -0
- package/build/providers/ally_provider.js +13 -2
- package/build/src/abstract_drivers/oauth1.d.ts +26 -0
- package/build/src/abstract_drivers/oauth2.d.ts +50 -2
- package/build/src/ally_manager.d.ts +67 -3
- package/build/src/define_config.d.ts +16 -1
- package/build/src/drivers/discord.d.ts +9 -0
- package/build/src/drivers/discord.js +13 -3
- package/build/src/drivers/facebook.d.ts +9 -0
- package/build/src/drivers/facebook.js +13 -3
- package/build/src/drivers/github.d.ts +12 -0
- package/build/src/drivers/github.js +17 -4
- package/build/src/drivers/google.d.ts +9 -0
- package/build/src/drivers/google.js +13 -3
- package/build/src/drivers/linked_in.d.ts +12 -0
- package/build/src/drivers/linked_in.js +16 -3
- package/build/src/drivers/linked_in_openid_connect.d.ts +14 -5
- package/build/src/drivers/linked_in_openid_connect.js +14 -5
- package/build/src/drivers/spotify.d.ts +11 -0
- package/build/src/drivers/spotify.js +15 -3
- package/build/src/drivers/twitter.d.ts +17 -0
- package/build/src/drivers/twitter.js +22 -3
- package/build/src/drivers/twitter_x.d.ts +137 -0
- package/build/src/drivers/twitter_x.js +169 -0
- package/build/src/errors.d.ts +190 -2
- package/build/src/redirect_request.d.ts +7 -0
- package/build/src/types.d.ts +150 -0
- package/package.json +19 -9
- package/build/chunk-MLKGABMK.js +0 -9
- package/build/chunk-SZ4YJCVU.js +0 -46
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Oauth1Driver
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-4QTU45GZ.js";
|
|
4
|
+
import "../../chunk-NK6X76EQ.js";
|
|
5
|
+
import "../../chunk-TSIMPJ6I.js";
|
|
6
6
|
|
|
7
7
|
// src/drivers/twitter.ts
|
|
8
8
|
var TwitterDriver = class extends Oauth1Driver {
|
|
@@ -16,9 +16,23 @@ var TwitterDriver = class extends Oauth1Driver {
|
|
|
16
16
|
this.config = config;
|
|
17
17
|
this.loadState();
|
|
18
18
|
}
|
|
19
|
+
ctx;
|
|
20
|
+
config;
|
|
21
|
+
/**
|
|
22
|
+
* Twitter request-token endpoint URL.
|
|
23
|
+
*/
|
|
19
24
|
requestTokenUrl = "https://api.twitter.com/oauth/request_token";
|
|
25
|
+
/**
|
|
26
|
+
* Twitter authorization endpoint URL.
|
|
27
|
+
*/
|
|
20
28
|
authorizeUrl = "https://api.twitter.com/oauth/authenticate";
|
|
29
|
+
/**
|
|
30
|
+
* Twitter access-token endpoint URL.
|
|
31
|
+
*/
|
|
21
32
|
accessTokenUrl = "https://api.twitter.com/oauth/access_token";
|
|
33
|
+
/**
|
|
34
|
+
* Twitter profile endpoint URL.
|
|
35
|
+
*/
|
|
22
36
|
userInfoUrl = "https://api.twitter.com/1.1/account/verify_credentials.json";
|
|
23
37
|
/**
|
|
24
38
|
* The query string param name for the error.
|
|
@@ -46,6 +60,9 @@ var TwitterDriver = class extends Oauth1Driver {
|
|
|
46
60
|
* Twitter doesn't support scopes
|
|
47
61
|
*/
|
|
48
62
|
scopeParamName = "";
|
|
63
|
+
/**
|
|
64
|
+
* Scope separator placeholder maintained for OAuth1 compatibility.
|
|
65
|
+
*/
|
|
49
66
|
scopesSeparator = " ";
|
|
50
67
|
/**
|
|
51
68
|
* Fetches the authenticated user's profile information from the Twitter API.
|
|
@@ -119,6 +136,8 @@ var TwitterDriver = class extends Oauth1Driver {
|
|
|
119
136
|
/**
|
|
120
137
|
* Check if the error from the callback indicates that the user
|
|
121
138
|
* denied authorization.
|
|
139
|
+
*
|
|
140
|
+
* @returns `true` when the request contains the denial marker.
|
|
122
141
|
*/
|
|
123
142
|
accessDenied() {
|
|
124
143
|
return this.ctx.request.input("denied");
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type { HttpContext } from '@adonisjs/core/http';
|
|
2
|
+
import type { HttpClient } from '@poppinss/oauth-client';
|
|
3
|
+
import type { TwitterXToken, TwitterXScopes, ApiRequestContract, TwitterXDriverConfig, RedirectRequestContract } from '../types.ts';
|
|
4
|
+
import { Oauth2Driver } from '../abstract_drivers/oauth2.ts';
|
|
5
|
+
/**
|
|
6
|
+
* X OAuth2 driver for authenticating users via the OAuth 2.0 authorization
|
|
7
|
+
* code flow with PKCE.
|
|
8
|
+
*/
|
|
9
|
+
export declare class TwitterXDriver extends Oauth2Driver<TwitterXToken, TwitterXScopes> {
|
|
10
|
+
config: TwitterXDriverConfig;
|
|
11
|
+
/**
|
|
12
|
+
* X token endpoint URL.
|
|
13
|
+
*/
|
|
14
|
+
protected accessTokenUrl: string;
|
|
15
|
+
/**
|
|
16
|
+
* X authorization endpoint URL.
|
|
17
|
+
*/
|
|
18
|
+
protected authorizeUrl: string;
|
|
19
|
+
/**
|
|
20
|
+
* X user profile endpoint URL.
|
|
21
|
+
*/
|
|
22
|
+
protected userInfoUrl: string;
|
|
23
|
+
/**
|
|
24
|
+
* The param name for the authorization code
|
|
25
|
+
*/
|
|
26
|
+
protected codeParamName: string;
|
|
27
|
+
/**
|
|
28
|
+
* The param name for the error
|
|
29
|
+
*/
|
|
30
|
+
protected errorParamName: string;
|
|
31
|
+
/**
|
|
32
|
+
* Cookie name for storing the "twitter_x_oauth_state"
|
|
33
|
+
*/
|
|
34
|
+
protected stateCookieName: string;
|
|
35
|
+
/**
|
|
36
|
+
* Cookie name for storing the PKCE code verifier
|
|
37
|
+
*/
|
|
38
|
+
protected codeVerifierCookieName: string;
|
|
39
|
+
/**
|
|
40
|
+
* Parameter name to be used for sending and receiving the state from X
|
|
41
|
+
*/
|
|
42
|
+
protected stateParamName: string;
|
|
43
|
+
/**
|
|
44
|
+
* Parameter name for defining the scopes
|
|
45
|
+
*/
|
|
46
|
+
protected scopeParamName: string;
|
|
47
|
+
/**
|
|
48
|
+
* Scopes separator
|
|
49
|
+
*/
|
|
50
|
+
protected scopesSeparator: string;
|
|
51
|
+
/**
|
|
52
|
+
* Create a new X driver instance.
|
|
53
|
+
*
|
|
54
|
+
* @param ctx - The current HTTP context.
|
|
55
|
+
* @param config - X driver configuration.
|
|
56
|
+
*/
|
|
57
|
+
constructor(ctx: HttpContext, config: TwitterXDriverConfig);
|
|
58
|
+
/**
|
|
59
|
+
* Configures the redirect request with X-specific requirements.
|
|
60
|
+
*
|
|
61
|
+
* @param request - The redirect request to configure.
|
|
62
|
+
*/
|
|
63
|
+
protected configureRedirectRequest(request: RedirectRequestContract<TwitterXScopes>): void;
|
|
64
|
+
/**
|
|
65
|
+
* Configures the token request with the PKCE verifier and the Basic auth
|
|
66
|
+
* header required for confidential X clients.
|
|
67
|
+
*
|
|
68
|
+
* @param request - The token request to configure.
|
|
69
|
+
*/
|
|
70
|
+
protected configureAccessTokenRequest(request: ApiRequestContract): void;
|
|
71
|
+
/**
|
|
72
|
+
* Creates an authenticated request for X API calls.
|
|
73
|
+
*
|
|
74
|
+
* @param url - The API endpoint URL.
|
|
75
|
+
* @param token - The access token to send.
|
|
76
|
+
* @returns A configured HTTP client instance.
|
|
77
|
+
*/
|
|
78
|
+
protected getAuthenticatedRequest(url: string, token: string): HttpClient;
|
|
79
|
+
/**
|
|
80
|
+
* Fetches the authenticated user's profile from /2/users/me.
|
|
81
|
+
*
|
|
82
|
+
* @param token - The access token to use.
|
|
83
|
+
* @param includeConfirmedEmail - Whether to request the confirmed email field.
|
|
84
|
+
* @param callback - Optional callback to customize the API request.
|
|
85
|
+
*/
|
|
86
|
+
protected getUserInfo(token: string, includeConfirmedEmail: boolean, callback?: (request: ApiRequestContract) => void): Promise<{
|
|
87
|
+
id: any;
|
|
88
|
+
nickName: any;
|
|
89
|
+
name: any;
|
|
90
|
+
email: any;
|
|
91
|
+
emailVerificationState: "unsupported";
|
|
92
|
+
avatarUrl: any;
|
|
93
|
+
original: any;
|
|
94
|
+
}>;
|
|
95
|
+
/**
|
|
96
|
+
* Check if the error from the callback indicates that the user denied
|
|
97
|
+
* authorization.
|
|
98
|
+
*
|
|
99
|
+
* @returns `true` when the provider reported an access-denied error.
|
|
100
|
+
*/
|
|
101
|
+
accessDenied(): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Fetches the authenticated user using the authorization code from the
|
|
104
|
+
* callback request.
|
|
105
|
+
*
|
|
106
|
+
* @param callback - Optional callback to customize the API request.
|
|
107
|
+
*/
|
|
108
|
+
user(callback?: (request: ApiRequestContract) => void): Promise<{
|
|
109
|
+
token: TwitterXToken;
|
|
110
|
+
id: any;
|
|
111
|
+
nickName: any;
|
|
112
|
+
name: any;
|
|
113
|
+
email: any;
|
|
114
|
+
emailVerificationState: "unsupported";
|
|
115
|
+
avatarUrl: any;
|
|
116
|
+
original: any;
|
|
117
|
+
}>;
|
|
118
|
+
/**
|
|
119
|
+
* Fetches the user profile using an existing access token.
|
|
120
|
+
*
|
|
121
|
+
* @param token - The access token to use.
|
|
122
|
+
* @param callback - Optional callback to customize the API request.
|
|
123
|
+
*/
|
|
124
|
+
userFromToken(token: string, callback?: (request: ApiRequestContract) => void): Promise<{
|
|
125
|
+
token: {
|
|
126
|
+
token: string;
|
|
127
|
+
type: "bearer";
|
|
128
|
+
};
|
|
129
|
+
id: any;
|
|
130
|
+
nickName: any;
|
|
131
|
+
name: any;
|
|
132
|
+
email: any;
|
|
133
|
+
emailVerificationState: "unsupported";
|
|
134
|
+
avatarUrl: any;
|
|
135
|
+
original: any;
|
|
136
|
+
}>;
|
|
137
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Oauth2Driver
|
|
3
|
+
} from "../../chunk-7V2EH7U6.js";
|
|
4
|
+
import "../../chunk-NK6X76EQ.js";
|
|
5
|
+
import "../../chunk-TSIMPJ6I.js";
|
|
6
|
+
|
|
7
|
+
// src/drivers/twitter_x.ts
|
|
8
|
+
var TwitterXDriver = class extends Oauth2Driver {
|
|
9
|
+
/**
|
|
10
|
+
* Create a new X driver instance.
|
|
11
|
+
*
|
|
12
|
+
* @param ctx - The current HTTP context.
|
|
13
|
+
* @param config - X driver configuration.
|
|
14
|
+
*/
|
|
15
|
+
constructor(ctx, config) {
|
|
16
|
+
super(ctx, config);
|
|
17
|
+
this.config = config;
|
|
18
|
+
this.loadState();
|
|
19
|
+
}
|
|
20
|
+
config;
|
|
21
|
+
/**
|
|
22
|
+
* X token endpoint URL.
|
|
23
|
+
*/
|
|
24
|
+
accessTokenUrl = "https://api.x.com/2/oauth2/token";
|
|
25
|
+
/**
|
|
26
|
+
* X authorization endpoint URL.
|
|
27
|
+
*/
|
|
28
|
+
authorizeUrl = "https://x.com/i/oauth2/authorize";
|
|
29
|
+
/**
|
|
30
|
+
* X user profile endpoint URL.
|
|
31
|
+
*/
|
|
32
|
+
userInfoUrl = "https://api.x.com/2/users/me";
|
|
33
|
+
/**
|
|
34
|
+
* The param name for the authorization code
|
|
35
|
+
*/
|
|
36
|
+
codeParamName = "code";
|
|
37
|
+
/**
|
|
38
|
+
* The param name for the error
|
|
39
|
+
*/
|
|
40
|
+
errorParamName = "error";
|
|
41
|
+
/**
|
|
42
|
+
* Cookie name for storing the "twitter_x_oauth_state"
|
|
43
|
+
*/
|
|
44
|
+
stateCookieName = "twitter_x_oauth_state";
|
|
45
|
+
/**
|
|
46
|
+
* Cookie name for storing the PKCE code verifier
|
|
47
|
+
*/
|
|
48
|
+
codeVerifierCookieName = "twitter_x_oauth_code_verifier";
|
|
49
|
+
/**
|
|
50
|
+
* Parameter name to be used for sending and receiving the state from X
|
|
51
|
+
*/
|
|
52
|
+
stateParamName = "state";
|
|
53
|
+
/**
|
|
54
|
+
* Parameter name for defining the scopes
|
|
55
|
+
*/
|
|
56
|
+
scopeParamName = "scope";
|
|
57
|
+
/**
|
|
58
|
+
* Scopes separator
|
|
59
|
+
*/
|
|
60
|
+
scopesSeparator = " ";
|
|
61
|
+
/**
|
|
62
|
+
* Configures the redirect request with X-specific requirements.
|
|
63
|
+
*
|
|
64
|
+
* @param request - The redirect request to configure.
|
|
65
|
+
*/
|
|
66
|
+
configureRedirectRequest(request) {
|
|
67
|
+
request.scopes(this.config.scopes || ["tweet.read", "users.read", "users.email"]);
|
|
68
|
+
request.param("response_type", "code");
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Configures the token request with the PKCE verifier and the Basic auth
|
|
72
|
+
* header required for confidential X clients.
|
|
73
|
+
*
|
|
74
|
+
* @param request - The token request to configure.
|
|
75
|
+
*/
|
|
76
|
+
configureAccessTokenRequest(request) {
|
|
77
|
+
const credentials = Buffer.from(`${this.config.clientId}:${this.config.clientSecret}`).toString(
|
|
78
|
+
"base64"
|
|
79
|
+
);
|
|
80
|
+
request.header("Authorization", `Basic ${credentials}`);
|
|
81
|
+
request.clearField("client_id");
|
|
82
|
+
request.clearField("client_secret");
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Creates an authenticated request for X API calls.
|
|
86
|
+
*
|
|
87
|
+
* @param url - The API endpoint URL.
|
|
88
|
+
* @param token - The access token to send.
|
|
89
|
+
* @returns A configured HTTP client instance.
|
|
90
|
+
*/
|
|
91
|
+
getAuthenticatedRequest(url, token) {
|
|
92
|
+
const request = this.httpClient(url);
|
|
93
|
+
request.header("Authorization", `Bearer ${token}`);
|
|
94
|
+
request.header("Accept", "application/json");
|
|
95
|
+
request.parseAs("json");
|
|
96
|
+
return request;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Fetches the authenticated user's profile from /2/users/me.
|
|
100
|
+
*
|
|
101
|
+
* @param token - The access token to use.
|
|
102
|
+
* @param includeConfirmedEmail - Whether to request the confirmed email field.
|
|
103
|
+
* @param callback - Optional callback to customize the API request.
|
|
104
|
+
*/
|
|
105
|
+
async getUserInfo(token, includeConfirmedEmail, callback) {
|
|
106
|
+
const request = this.getAuthenticatedRequest(this.config.userInfoUrl || this.userInfoUrl, token);
|
|
107
|
+
request.param(
|
|
108
|
+
"user.fields",
|
|
109
|
+
includeConfirmedEmail ? "profile_image_url,confirmed_email" : "profile_image_url"
|
|
110
|
+
);
|
|
111
|
+
if (typeof callback === "function") {
|
|
112
|
+
callback(request);
|
|
113
|
+
}
|
|
114
|
+
const body = await request.get();
|
|
115
|
+
const user = body.data;
|
|
116
|
+
return {
|
|
117
|
+
id: user.id,
|
|
118
|
+
nickName: user.username,
|
|
119
|
+
name: user.name ?? user.username,
|
|
120
|
+
email: user.confirmed_email ?? null,
|
|
121
|
+
emailVerificationState: "unsupported",
|
|
122
|
+
avatarUrl: user.profile_image_url ?? null,
|
|
123
|
+
original: body
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Check if the error from the callback indicates that the user denied
|
|
128
|
+
* authorization.
|
|
129
|
+
*
|
|
130
|
+
* @returns `true` when the provider reported an access-denied error.
|
|
131
|
+
*/
|
|
132
|
+
accessDenied() {
|
|
133
|
+
const error = this.getError();
|
|
134
|
+
if (!error) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
return error === "access_denied";
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Fetches the authenticated user using the authorization code from the
|
|
141
|
+
* callback request.
|
|
142
|
+
*
|
|
143
|
+
* @param callback - Optional callback to customize the API request.
|
|
144
|
+
*/
|
|
145
|
+
async user(callback) {
|
|
146
|
+
const token = await this.accessToken(callback);
|
|
147
|
+
const user = await this.getUserInfo(token.token, token.scope.includes("users.email"), callback);
|
|
148
|
+
return {
|
|
149
|
+
...user,
|
|
150
|
+
token
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Fetches the user profile using an existing access token.
|
|
155
|
+
*
|
|
156
|
+
* @param token - The access token to use.
|
|
157
|
+
* @param callback - Optional callback to customize the API request.
|
|
158
|
+
*/
|
|
159
|
+
async userFromToken(token, callback) {
|
|
160
|
+
const user = await this.getUserInfo(token, false, callback);
|
|
161
|
+
return {
|
|
162
|
+
...user,
|
|
163
|
+
token: { token, type: "bearer" }
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
export {
|
|
168
|
+
TwitterXDriver
|
|
169
|
+
};
|
package/build/src/errors.d.ts
CHANGED
|
@@ -1,10 +1,198 @@
|
|
|
1
|
+
import { Exception } from '@adonisjs/core/exceptions';
|
|
2
|
+
import { type HttpContext } from '@adonisjs/core/http';
|
|
3
|
+
/**
|
|
4
|
+
* Base exception that self-handles by content-negotiating the
|
|
5
|
+
* HTTP response (HTML with session flash, JSON, JSONAPI)
|
|
6
|
+
* and supporting i18n translation.
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class HttpResponseException extends Exception {
|
|
9
|
+
abstract identifier: string;
|
|
10
|
+
/**
|
|
11
|
+
* Returns the message to be sent in the HTTP response.
|
|
12
|
+
* Feel free to override this method and return a custom
|
|
13
|
+
* response.
|
|
14
|
+
*/
|
|
15
|
+
getResponseMessage(error: this, ctx: HttpContext): string;
|
|
16
|
+
/**
|
|
17
|
+
* Converts exception to an HTTP response
|
|
18
|
+
*/
|
|
19
|
+
handle(error: this, ctx: HttpContext): Promise<void>;
|
|
20
|
+
}
|
|
1
21
|
/**
|
|
2
22
|
* Error thrown when the OAuth redirect is missing the required
|
|
3
23
|
* authorization code or token parameter.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* throw new errors.E_OAUTH_MISSING_CODE(['code'])
|
|
28
|
+
* ```
|
|
4
29
|
*/
|
|
5
|
-
export declare const E_OAUTH_MISSING_CODE:
|
|
30
|
+
export declare const E_OAUTH_MISSING_CODE: {
|
|
31
|
+
new (args: [string], options?: ErrorOptions): {
|
|
32
|
+
/**
|
|
33
|
+
* Translation identifier. Can be customized
|
|
34
|
+
*/
|
|
35
|
+
identifier: string;
|
|
36
|
+
/**
|
|
37
|
+
* Returns the message to be sent in the HTTP response.
|
|
38
|
+
* Feel free to override this method and return a custom
|
|
39
|
+
* response.
|
|
40
|
+
*/
|
|
41
|
+
getResponseMessage(error: /*elided*/ any, ctx: HttpContext): string;
|
|
42
|
+
/**
|
|
43
|
+
* Converts exception to an HTTP response
|
|
44
|
+
*/
|
|
45
|
+
handle(error: /*elided*/ any, ctx: HttpContext): Promise<void>;
|
|
46
|
+
name: string;
|
|
47
|
+
help?: string;
|
|
48
|
+
code?: string;
|
|
49
|
+
status: number;
|
|
50
|
+
toString(): string;
|
|
51
|
+
get [Symbol.toStringTag](): string;
|
|
52
|
+
message: string;
|
|
53
|
+
stack?: string;
|
|
54
|
+
cause?: unknown;
|
|
55
|
+
};
|
|
56
|
+
status: number;
|
|
57
|
+
code: string;
|
|
58
|
+
help?: string;
|
|
59
|
+
message?: string;
|
|
60
|
+
isError(error: unknown): error is Error;
|
|
61
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
62
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
63
|
+
stackTraceLimit: number;
|
|
64
|
+
};
|
|
6
65
|
/**
|
|
7
66
|
* Error thrown when the OAuth state parameter does not match
|
|
8
67
|
* the expected value, indicating a potential CSRF attack.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* throw new errors.E_OAUTH_STATE_MISMATCH()
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export declare const E_OAUTH_STATE_MISMATCH: {
|
|
75
|
+
new (message?: string, options?: ErrorOptions & {
|
|
76
|
+
code?: string;
|
|
77
|
+
status?: number;
|
|
78
|
+
}): {
|
|
79
|
+
/**
|
|
80
|
+
* Translation identifier. Can be customized
|
|
81
|
+
*/
|
|
82
|
+
identifier: string;
|
|
83
|
+
/**
|
|
84
|
+
* Returns the message to be sent in the HTTP response.
|
|
85
|
+
* Feel free to override this method and return a custom
|
|
86
|
+
* response.
|
|
87
|
+
*/
|
|
88
|
+
getResponseMessage(error: /*elided*/ any, ctx: HttpContext): string;
|
|
89
|
+
/**
|
|
90
|
+
* Converts exception to an HTTP response
|
|
91
|
+
*/
|
|
92
|
+
handle(error: /*elided*/ any, ctx: HttpContext): Promise<void>;
|
|
93
|
+
name: string;
|
|
94
|
+
help?: string;
|
|
95
|
+
code?: string;
|
|
96
|
+
status: number;
|
|
97
|
+
toString(): string;
|
|
98
|
+
get [Symbol.toStringTag](): string;
|
|
99
|
+
message: string;
|
|
100
|
+
stack?: string;
|
|
101
|
+
cause?: unknown;
|
|
102
|
+
};
|
|
103
|
+
status: number;
|
|
104
|
+
code: string;
|
|
105
|
+
message: string;
|
|
106
|
+
help?: string;
|
|
107
|
+
isError(error: unknown): error is Error;
|
|
108
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
109
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
110
|
+
stackTraceLimit: number;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Error thrown when attempting to use an unknown Ally provider.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```ts
|
|
117
|
+
* throw new errors.E_UNKNOWN_ALLY_PROVIDER(['github'])
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
export declare const E_UNKNOWN_ALLY_PROVIDER: {
|
|
121
|
+
new (args: [string], options?: ErrorOptions): {
|
|
122
|
+
/**
|
|
123
|
+
* Translation identifier. Can be customized
|
|
124
|
+
*/
|
|
125
|
+
identifier: string;
|
|
126
|
+
/**
|
|
127
|
+
* Returns the message to be sent in the HTTP response.
|
|
128
|
+
* Feel free to override this method and return a custom
|
|
129
|
+
* response.
|
|
130
|
+
*/
|
|
131
|
+
getResponseMessage(error: /*elided*/ any, ctx: HttpContext): string;
|
|
132
|
+
/**
|
|
133
|
+
* Converts exception to an HTTP response
|
|
134
|
+
*/
|
|
135
|
+
handle(error: /*elided*/ any, ctx: HttpContext): Promise<void>;
|
|
136
|
+
name: string;
|
|
137
|
+
help?: string;
|
|
138
|
+
code?: string;
|
|
139
|
+
status: number;
|
|
140
|
+
toString(): string;
|
|
141
|
+
get [Symbol.toStringTag](): string;
|
|
142
|
+
message: string;
|
|
143
|
+
stack?: string;
|
|
144
|
+
cause?: unknown;
|
|
145
|
+
};
|
|
146
|
+
status: number;
|
|
147
|
+
code: string;
|
|
148
|
+
help?: string;
|
|
149
|
+
message?: string;
|
|
150
|
+
isError(error: unknown): error is Error;
|
|
151
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
152
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
153
|
+
stackTraceLimit: number;
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Error thrown when a provider is used for signup but local signup
|
|
157
|
+
* is disabled for it.
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```ts
|
|
161
|
+
* throw new errors.E_LOCAL_SIGNUP_DISALLOWED(['github'])
|
|
162
|
+
* ```
|
|
9
163
|
*/
|
|
10
|
-
export declare const
|
|
164
|
+
export declare const E_LOCAL_SIGNUP_DISALLOWED: {
|
|
165
|
+
new (args: [string], options?: ErrorOptions): {
|
|
166
|
+
/**
|
|
167
|
+
* Translation identifier. Can be customized
|
|
168
|
+
*/
|
|
169
|
+
identifier: string;
|
|
170
|
+
/**
|
|
171
|
+
* Returns the message to be sent in the HTTP response.
|
|
172
|
+
* Feel free to override this method and return a custom
|
|
173
|
+
* response.
|
|
174
|
+
*/
|
|
175
|
+
getResponseMessage(error: /*elided*/ any, ctx: HttpContext): string;
|
|
176
|
+
/**
|
|
177
|
+
* Converts exception to an HTTP response
|
|
178
|
+
*/
|
|
179
|
+
handle(error: /*elided*/ any, ctx: HttpContext): Promise<void>;
|
|
180
|
+
name: string;
|
|
181
|
+
help?: string;
|
|
182
|
+
code?: string;
|
|
183
|
+
status: number;
|
|
184
|
+
toString(): string;
|
|
185
|
+
get [Symbol.toStringTag](): string;
|
|
186
|
+
message: string;
|
|
187
|
+
stack?: string;
|
|
188
|
+
cause?: unknown;
|
|
189
|
+
};
|
|
190
|
+
status: number;
|
|
191
|
+
code: string;
|
|
192
|
+
help?: string;
|
|
193
|
+
message?: string;
|
|
194
|
+
isError(error: unknown): error is Error;
|
|
195
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
196
|
+
prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
|
|
197
|
+
stackTraceLimit: number;
|
|
198
|
+
};
|
|
@@ -8,6 +8,8 @@ import { type LiteralStringUnion } from './types.ts';
|
|
|
8
8
|
export declare class RedirectRequest<Scopes extends string> extends UrlBuilder {
|
|
9
9
|
#private;
|
|
10
10
|
/**
|
|
11
|
+
* Create a redirect request builder with scope helpers.
|
|
12
|
+
*
|
|
11
13
|
* @param baseUrl - The authorization URL for the OAuth provider
|
|
12
14
|
* @param scopeParamName - The query parameter name for scopes (e.g., 'scope')
|
|
13
15
|
* @param scopeSeparator - The character used to separate multiple scopes (e.g., ' ' or ',')
|
|
@@ -19,6 +21,7 @@ export declare class RedirectRequest<Scopes extends string> extends UrlBuilder {
|
|
|
19
21
|
* require scope prefixes or transformations.
|
|
20
22
|
*
|
|
21
23
|
* @param callback - Function that transforms the scopes array
|
|
24
|
+
* @returns The current redirect request instance.
|
|
22
25
|
*
|
|
23
26
|
* @example
|
|
24
27
|
* ```ts
|
|
@@ -33,6 +36,7 @@ export declare class RedirectRequest<Scopes extends string> extends UrlBuilder {
|
|
|
33
36
|
* any previously set scopes.
|
|
34
37
|
*
|
|
35
38
|
* @param scopes - Array of scope strings to request
|
|
39
|
+
* @returns The current redirect request instance.
|
|
36
40
|
*
|
|
37
41
|
* @example
|
|
38
42
|
* ```ts
|
|
@@ -45,6 +49,7 @@ export declare class RedirectRequest<Scopes extends string> extends UrlBuilder {
|
|
|
45
49
|
* for adding scopes without replacing the default ones.
|
|
46
50
|
*
|
|
47
51
|
* @param scopes - Array of scope strings to merge
|
|
52
|
+
* @returns The current redirect request instance.
|
|
48
53
|
*
|
|
49
54
|
* @example
|
|
50
55
|
* ```ts
|
|
@@ -57,6 +62,8 @@ export declare class RedirectRequest<Scopes extends string> extends UrlBuilder {
|
|
|
57
62
|
/**
|
|
58
63
|
* Clear all existing scopes from the authorization request.
|
|
59
64
|
*
|
|
65
|
+
* @returns The current redirect request instance.
|
|
66
|
+
*
|
|
60
67
|
* @example
|
|
61
68
|
* ```ts
|
|
62
69
|
* request.clearScopes().scopes(['user'])
|