@adonisjs/ally 6.0.0-next.0 → 6.1.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-WM3V3APX.js → chunk-46TOMXWK.js} +92 -15
- package/build/chunk-6BP2DK5A.js +43 -0
- package/build/{chunk-KSJ4CFTC.js → chunk-NK6X76EQ.js} +16 -25
- package/build/{chunk-KWRXS6EG.js → chunk-SBQAXPUK.js} +33 -3
- package/build/chunk-TFPW7D75.js +125 -0
- package/build/index.js +67 -6
- 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/debug.d.ts +1 -1
- 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 +29 -0
- package/build/src/redirect_request.d.ts +7 -0
- package/build/src/types.d.ts +150 -0
- package/package.json +27 -21
- package/build/chunk-MLKGABMK.js +0 -9
- package/build/chunk-SZ4YJCVU.js +0 -46
|
@@ -36,8 +36,17 @@ import { Oauth2Driver } from '../abstract_drivers/oauth2.ts';
|
|
|
36
36
|
*/
|
|
37
37
|
export declare class FacebookDriver extends Oauth2Driver<FacebookToken, FacebookScopes> {
|
|
38
38
|
config: FacebookDriverConfig;
|
|
39
|
+
/**
|
|
40
|
+
* Facebook token endpoint URL.
|
|
41
|
+
*/
|
|
39
42
|
protected accessTokenUrl: string;
|
|
43
|
+
/**
|
|
44
|
+
* Facebook authorization endpoint URL.
|
|
45
|
+
*/
|
|
40
46
|
protected authorizeUrl: string;
|
|
47
|
+
/**
|
|
48
|
+
* Facebook profile endpoint URL.
|
|
49
|
+
*/
|
|
41
50
|
protected userInfoUrl: string;
|
|
42
51
|
/**
|
|
43
52
|
* The default set of fields to query for the user request
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Oauth2Driver
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-46TOMXWK.js";
|
|
4
|
+
import "../../chunk-NK6X76EQ.js";
|
|
5
|
+
import "../../chunk-6BP2DK5A.js";
|
|
6
6
|
|
|
7
7
|
// src/drivers/facebook.ts
|
|
8
8
|
var FacebookDriver = class extends Oauth2Driver {
|
|
@@ -15,8 +15,18 @@ var FacebookDriver = class extends Oauth2Driver {
|
|
|
15
15
|
this.config = config;
|
|
16
16
|
this.loadState();
|
|
17
17
|
}
|
|
18
|
+
config;
|
|
19
|
+
/**
|
|
20
|
+
* Facebook token endpoint URL.
|
|
21
|
+
*/
|
|
18
22
|
accessTokenUrl = "https://graph.facebook.com/v10.0/oauth/access_token";
|
|
23
|
+
/**
|
|
24
|
+
* Facebook authorization endpoint URL.
|
|
25
|
+
*/
|
|
19
26
|
authorizeUrl = "https://www.facebook.com/v10.0/dialog/oauth";
|
|
27
|
+
/**
|
|
28
|
+
* Facebook profile endpoint URL.
|
|
29
|
+
*/
|
|
20
30
|
userInfoUrl = "https://graph.facebook.com/v10.0/me";
|
|
21
31
|
/**
|
|
22
32
|
* The default set of fields to query for the user request
|
|
@@ -36,9 +36,21 @@ import { Oauth2Driver } from '../abstract_drivers/oauth2.ts';
|
|
|
36
36
|
*/
|
|
37
37
|
export declare class GithubDriver extends Oauth2Driver<GithubToken, GithubScopes> {
|
|
38
38
|
config: GithubDriverConfig;
|
|
39
|
+
/**
|
|
40
|
+
* GitHub token endpoint URL.
|
|
41
|
+
*/
|
|
39
42
|
protected accessTokenUrl: string;
|
|
43
|
+
/**
|
|
44
|
+
* GitHub authorization endpoint URL.
|
|
45
|
+
*/
|
|
40
46
|
protected authorizeUrl: string;
|
|
47
|
+
/**
|
|
48
|
+
* GitHub profile endpoint URL.
|
|
49
|
+
*/
|
|
41
50
|
protected userInfoUrl: string;
|
|
51
|
+
/**
|
|
52
|
+
* GitHub email endpoint URL.
|
|
53
|
+
*/
|
|
42
54
|
protected userEmailUrl: string;
|
|
43
55
|
/**
|
|
44
56
|
* The param name for the authorization code
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Oauth2Driver
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-46TOMXWK.js";
|
|
4
|
+
import "../../chunk-NK6X76EQ.js";
|
|
5
|
+
import "../../chunk-6BP2DK5A.js";
|
|
6
6
|
|
|
7
7
|
// src/drivers/github.ts
|
|
8
8
|
var GithubDriver = class extends Oauth2Driver {
|
|
@@ -15,9 +15,22 @@ var GithubDriver = class extends Oauth2Driver {
|
|
|
15
15
|
this.config = config;
|
|
16
16
|
this.loadState();
|
|
17
17
|
}
|
|
18
|
+
config;
|
|
19
|
+
/**
|
|
20
|
+
* GitHub token endpoint URL.
|
|
21
|
+
*/
|
|
18
22
|
accessTokenUrl = "https://github.com/login/oauth/access_token";
|
|
23
|
+
/**
|
|
24
|
+
* GitHub authorization endpoint URL.
|
|
25
|
+
*/
|
|
19
26
|
authorizeUrl = "https://github.com/login/oauth/authorize";
|
|
27
|
+
/**
|
|
28
|
+
* GitHub profile endpoint URL.
|
|
29
|
+
*/
|
|
20
30
|
userInfoUrl = "https://api.github.com/user";
|
|
31
|
+
/**
|
|
32
|
+
* GitHub email endpoint URL.
|
|
33
|
+
*/
|
|
21
34
|
userEmailUrl = "https://api.github.com/user/emails";
|
|
22
35
|
/**
|
|
23
36
|
* The param name for the authorization code
|
|
@@ -137,7 +150,7 @@ var GithubDriver = class extends Oauth2Driver {
|
|
|
137
150
|
}
|
|
138
151
|
return mainEmail;
|
|
139
152
|
} catch (error) {
|
|
140
|
-
if (error && error.response && error.response.statusCode === 404) {
|
|
153
|
+
if (error && typeof error === "object" && "response" in error && error.response && typeof error.response === "object" && "statusCode" in error.response && error.response.statusCode === 404) {
|
|
141
154
|
return;
|
|
142
155
|
}
|
|
143
156
|
throw error;
|
|
@@ -37,8 +37,17 @@ import { Oauth2Driver } from '../abstract_drivers/oauth2.ts';
|
|
|
37
37
|
*/
|
|
38
38
|
export declare class GoogleDriver extends Oauth2Driver<GoogleToken, GoogleScopes> {
|
|
39
39
|
config: GoogleDriverConfig;
|
|
40
|
+
/**
|
|
41
|
+
* Google token endpoint URL.
|
|
42
|
+
*/
|
|
40
43
|
protected accessTokenUrl: string;
|
|
44
|
+
/**
|
|
45
|
+
* Google authorization endpoint URL.
|
|
46
|
+
*/
|
|
41
47
|
protected authorizeUrl: string;
|
|
48
|
+
/**
|
|
49
|
+
* Google user profile endpoint URL.
|
|
50
|
+
*/
|
|
42
51
|
protected userInfoUrl: string;
|
|
43
52
|
/**
|
|
44
53
|
* The param name for the authorization code
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Oauth2Driver
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-46TOMXWK.js";
|
|
4
|
+
import "../../chunk-NK6X76EQ.js";
|
|
5
|
+
import "../../chunk-6BP2DK5A.js";
|
|
6
6
|
|
|
7
7
|
// src/drivers/google.ts
|
|
8
8
|
var SCOPE_PREFIXES = {
|
|
@@ -52,8 +52,18 @@ var GoogleDriver = class extends Oauth2Driver {
|
|
|
52
52
|
this.config = config;
|
|
53
53
|
this.loadState();
|
|
54
54
|
}
|
|
55
|
+
config;
|
|
56
|
+
/**
|
|
57
|
+
* Google token endpoint URL.
|
|
58
|
+
*/
|
|
55
59
|
accessTokenUrl = "https://oauth2.googleapis.com/token";
|
|
60
|
+
/**
|
|
61
|
+
* Google authorization endpoint URL.
|
|
62
|
+
*/
|
|
56
63
|
authorizeUrl = "https://accounts.google.com/o/oauth2/v2/auth";
|
|
64
|
+
/**
|
|
65
|
+
* Google user profile endpoint URL.
|
|
66
|
+
*/
|
|
57
67
|
userInfoUrl = "https://www.googleapis.com/oauth2/v3/userinfo";
|
|
58
68
|
/**
|
|
59
69
|
* The param name for the authorization code
|
|
@@ -37,9 +37,21 @@ import { Oauth2Driver } from '../abstract_drivers/oauth2.ts';
|
|
|
37
37
|
*/
|
|
38
38
|
export declare class LinkedInDriver extends Oauth2Driver<LinkedInToken, LinkedInScopes> {
|
|
39
39
|
config: LinkedInDriverConfig;
|
|
40
|
+
/**
|
|
41
|
+
* LinkedIn token endpoint URL.
|
|
42
|
+
*/
|
|
40
43
|
protected accessTokenUrl: string;
|
|
44
|
+
/**
|
|
45
|
+
* LinkedIn authorization endpoint URL.
|
|
46
|
+
*/
|
|
41
47
|
protected authorizeUrl: string;
|
|
48
|
+
/**
|
|
49
|
+
* LinkedIn profile endpoint URL.
|
|
50
|
+
*/
|
|
42
51
|
protected userInfoUrl: string;
|
|
52
|
+
/**
|
|
53
|
+
* LinkedIn email endpoint URL.
|
|
54
|
+
*/
|
|
43
55
|
protected userEmailUrl: string;
|
|
44
56
|
/**
|
|
45
57
|
* The param name for the authorization code
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Oauth2Driver
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-46TOMXWK.js";
|
|
4
|
+
import "../../chunk-NK6X76EQ.js";
|
|
5
|
+
import "../../chunk-6BP2DK5A.js";
|
|
6
6
|
|
|
7
7
|
// src/drivers/linked_in.ts
|
|
8
8
|
import { Exception } from "@adonisjs/core/exceptions";
|
|
@@ -16,9 +16,22 @@ var LinkedInDriver = class extends Oauth2Driver {
|
|
|
16
16
|
this.config = config;
|
|
17
17
|
this.loadState();
|
|
18
18
|
}
|
|
19
|
+
config;
|
|
20
|
+
/**
|
|
21
|
+
* LinkedIn token endpoint URL.
|
|
22
|
+
*/
|
|
19
23
|
accessTokenUrl = "https://www.linkedin.com/oauth/v2/accessToken";
|
|
24
|
+
/**
|
|
25
|
+
* LinkedIn authorization endpoint URL.
|
|
26
|
+
*/
|
|
20
27
|
authorizeUrl = "https://www.linkedin.com/oauth/v2/authorization";
|
|
28
|
+
/**
|
|
29
|
+
* LinkedIn profile endpoint URL.
|
|
30
|
+
*/
|
|
21
31
|
userInfoUrl = "https://api.linkedin.com/v2/me";
|
|
32
|
+
/**
|
|
33
|
+
* LinkedIn email endpoint URL.
|
|
34
|
+
*/
|
|
22
35
|
userEmailUrl = "https://api.linkedin.com/v2/clientAwareMemberHandles";
|
|
23
36
|
/**
|
|
24
37
|
* The param name for the authorization code
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { HttpContext } from '@adonisjs/core/http';
|
|
2
2
|
import type { HttpClient } from '@poppinss/oauth-client';
|
|
3
3
|
import { Oauth2Driver } from '../abstract_drivers/oauth2.ts';
|
|
4
|
-
import type { ApiRequestContract, LinkedInOpenidConnectAccessToken, LinkedInOpenidConnectDriverConfig, LinkedInOpenidConnectScopes, RedirectRequestContract } from '../types.ts';
|
|
4
|
+
import type { ApiRequestContract, LinkedInOpenidConnectAccessToken, LinkedInOpenidConnectDriverConfig, LinkedInOpenidConnectScopes, Oauth2AccessToken, RedirectRequestContract } from '../types.ts';
|
|
5
5
|
/**
|
|
6
6
|
* LinkedIn OpenID Connect OAuth2 driver for authenticating users via LinkedIn.
|
|
7
7
|
* This driver uses the OpenID Connect protocol for authentication.
|
|
@@ -37,8 +37,17 @@ import type { ApiRequestContract, LinkedInOpenidConnectAccessToken, LinkedInOpen
|
|
|
37
37
|
*/
|
|
38
38
|
export declare class LinkedInOpenidConnectDriver extends Oauth2Driver<LinkedInOpenidConnectAccessToken, LinkedInOpenidConnectScopes> {
|
|
39
39
|
config: LinkedInOpenidConnectDriverConfig;
|
|
40
|
+
/**
|
|
41
|
+
* LinkedIn OpenID authorization endpoint URL.
|
|
42
|
+
*/
|
|
40
43
|
protected authorizeUrl: string;
|
|
44
|
+
/**
|
|
45
|
+
* LinkedIn OpenID token endpoint URL.
|
|
46
|
+
*/
|
|
41
47
|
protected accessTokenUrl: string;
|
|
48
|
+
/**
|
|
49
|
+
* LinkedIn OpenID userinfo endpoint URL.
|
|
50
|
+
*/
|
|
42
51
|
protected userInfoUrl: string;
|
|
43
52
|
/**
|
|
44
53
|
* The param name for the authorization code
|
|
@@ -97,7 +106,7 @@ export declare class LinkedInOpenidConnectDriver extends Oauth2Driver<LinkedInOp
|
|
|
97
106
|
name: any;
|
|
98
107
|
avatarUrl: any;
|
|
99
108
|
email: any;
|
|
100
|
-
emailVerificationState: "
|
|
109
|
+
emailVerificationState: "unsupported";
|
|
101
110
|
original: any;
|
|
102
111
|
}>;
|
|
103
112
|
/**
|
|
@@ -122,14 +131,14 @@ export declare class LinkedInOpenidConnectDriver extends Oauth2Driver<LinkedInOp
|
|
|
122
131
|
token: string;
|
|
123
132
|
type: "bearer";
|
|
124
133
|
expiresIn: number;
|
|
125
|
-
expiresAt: Exclude<
|
|
134
|
+
expiresAt: Exclude<Oauth2AccessToken["expiresAt"], undefined>;
|
|
126
135
|
};
|
|
127
136
|
id: any;
|
|
128
137
|
nickName: any;
|
|
129
138
|
name: any;
|
|
130
139
|
avatarUrl: any;
|
|
131
140
|
email: any;
|
|
132
|
-
emailVerificationState: "
|
|
141
|
+
emailVerificationState: "unsupported";
|
|
133
142
|
original: any;
|
|
134
143
|
}>;
|
|
135
144
|
/**
|
|
@@ -154,7 +163,7 @@ export declare class LinkedInOpenidConnectDriver extends Oauth2Driver<LinkedInOp
|
|
|
154
163
|
name: any;
|
|
155
164
|
avatarUrl: any;
|
|
156
165
|
email: any;
|
|
157
|
-
emailVerificationState: "
|
|
166
|
+
emailVerificationState: "unsupported";
|
|
158
167
|
original: any;
|
|
159
168
|
}>;
|
|
160
169
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Oauth2Driver
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-46TOMXWK.js";
|
|
4
|
+
import "../../chunk-NK6X76EQ.js";
|
|
5
|
+
import "../../chunk-6BP2DK5A.js";
|
|
6
6
|
|
|
7
7
|
// src/drivers/linked_in_openid_connect.ts
|
|
8
8
|
var LinkedInOpenidConnectDriver = class extends Oauth2Driver {
|
|
@@ -15,8 +15,18 @@ var LinkedInOpenidConnectDriver = class extends Oauth2Driver {
|
|
|
15
15
|
this.config = config;
|
|
16
16
|
this.loadState();
|
|
17
17
|
}
|
|
18
|
+
config;
|
|
19
|
+
/**
|
|
20
|
+
* LinkedIn OpenID authorization endpoint URL.
|
|
21
|
+
*/
|
|
18
22
|
authorizeUrl = "https://www.linkedin.com/oauth/v2/authorization";
|
|
23
|
+
/**
|
|
24
|
+
* LinkedIn OpenID token endpoint URL.
|
|
25
|
+
*/
|
|
19
26
|
accessTokenUrl = "https://www.linkedin.com/oauth/v2/accessToken";
|
|
27
|
+
/**
|
|
28
|
+
* LinkedIn OpenID userinfo endpoint URL.
|
|
29
|
+
*/
|
|
20
30
|
userInfoUrl = "https://api.linkedin.com/v2/userinfo";
|
|
21
31
|
/**
|
|
22
32
|
* The param name for the authorization code
|
|
@@ -80,14 +90,13 @@ var LinkedInOpenidConnectDriver = class extends Oauth2Driver {
|
|
|
80
90
|
callback(request);
|
|
81
91
|
}
|
|
82
92
|
const body = await request.get();
|
|
83
|
-
const emailVerificationState = body.email_verified ? "verified" : "unverified";
|
|
84
93
|
return {
|
|
85
94
|
id: body.sub,
|
|
86
95
|
nickName: body.given_name,
|
|
87
96
|
name: body.family_name,
|
|
88
97
|
avatarUrl: body.picture,
|
|
89
98
|
email: body.email,
|
|
90
|
-
emailVerificationState,
|
|
99
|
+
emailVerificationState: "unsupported",
|
|
91
100
|
original: body
|
|
92
101
|
};
|
|
93
102
|
}
|
|
@@ -36,8 +36,17 @@ import { Oauth2Driver } from '../abstract_drivers/oauth2.ts';
|
|
|
36
36
|
*/
|
|
37
37
|
export declare class SpotifyDriver extends Oauth2Driver<SpotifyToken, SpotifyScopes> {
|
|
38
38
|
config: SpotifyDriverConfig;
|
|
39
|
+
/**
|
|
40
|
+
* Spotify token endpoint URL.
|
|
41
|
+
*/
|
|
39
42
|
protected accessTokenUrl: string;
|
|
43
|
+
/**
|
|
44
|
+
* Spotify authorization endpoint URL.
|
|
45
|
+
*/
|
|
40
46
|
protected authorizeUrl: string;
|
|
47
|
+
/**
|
|
48
|
+
* Spotify profile endpoint URL.
|
|
49
|
+
*/
|
|
41
50
|
protected userInfoUrl: string;
|
|
42
51
|
/**
|
|
43
52
|
* The param name for the authorization code
|
|
@@ -104,6 +113,8 @@ export declare class SpotifyDriver extends Oauth2Driver<SpotifyToken, SpotifySco
|
|
|
104
113
|
/**
|
|
105
114
|
* Check if the error from the callback indicates that the user
|
|
106
115
|
* denied authorization.
|
|
116
|
+
*
|
|
117
|
+
* @returns `true` when the provider reported an access-denied error.
|
|
107
118
|
*/
|
|
108
119
|
accessDenied(): boolean;
|
|
109
120
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Oauth2Driver
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-46TOMXWK.js";
|
|
4
|
+
import "../../chunk-NK6X76EQ.js";
|
|
5
|
+
import "../../chunk-6BP2DK5A.js";
|
|
6
6
|
|
|
7
7
|
// src/drivers/spotify.ts
|
|
8
8
|
var SpotifyDriver = class extends Oauth2Driver {
|
|
@@ -15,8 +15,18 @@ var SpotifyDriver = class extends Oauth2Driver {
|
|
|
15
15
|
this.config = config;
|
|
16
16
|
this.loadState();
|
|
17
17
|
}
|
|
18
|
+
config;
|
|
19
|
+
/**
|
|
20
|
+
* Spotify token endpoint URL.
|
|
21
|
+
*/
|
|
18
22
|
accessTokenUrl = "https://accounts.spotify.com/api/token";
|
|
23
|
+
/**
|
|
24
|
+
* Spotify authorization endpoint URL.
|
|
25
|
+
*/
|
|
19
26
|
authorizeUrl = "https://accounts.spotify.com/authorize";
|
|
27
|
+
/**
|
|
28
|
+
* Spotify profile endpoint URL.
|
|
29
|
+
*/
|
|
20
30
|
userInfoUrl = "https://api.spotify.com/v1/me";
|
|
21
31
|
/**
|
|
22
32
|
* The param name for the authorization code
|
|
@@ -98,6 +108,8 @@ var SpotifyDriver = class extends Oauth2Driver {
|
|
|
98
108
|
/**
|
|
99
109
|
* Check if the error from the callback indicates that the user
|
|
100
110
|
* denied authorization.
|
|
111
|
+
*
|
|
112
|
+
* @returns `true` when the provider reported an access-denied error.
|
|
101
113
|
*/
|
|
102
114
|
accessDenied() {
|
|
103
115
|
const error = this.getError();
|
|
@@ -35,9 +35,21 @@ import { Oauth1Driver } from '../abstract_drivers/oauth1.ts';
|
|
|
35
35
|
export declare class TwitterDriver extends Oauth1Driver<TwitterToken, string> {
|
|
36
36
|
protected ctx: HttpContext;
|
|
37
37
|
config: TwitterDriverConfig;
|
|
38
|
+
/**
|
|
39
|
+
* Twitter request-token endpoint URL.
|
|
40
|
+
*/
|
|
38
41
|
protected requestTokenUrl: string;
|
|
42
|
+
/**
|
|
43
|
+
* Twitter authorization endpoint URL.
|
|
44
|
+
*/
|
|
39
45
|
protected authorizeUrl: string;
|
|
46
|
+
/**
|
|
47
|
+
* Twitter access-token endpoint URL.
|
|
48
|
+
*/
|
|
40
49
|
protected accessTokenUrl: string;
|
|
50
|
+
/**
|
|
51
|
+
* Twitter profile endpoint URL.
|
|
52
|
+
*/
|
|
41
53
|
protected userInfoUrl: string;
|
|
42
54
|
/**
|
|
43
55
|
* The query string param name for the error.
|
|
@@ -65,6 +77,9 @@ export declare class TwitterDriver extends Oauth1Driver<TwitterToken, string> {
|
|
|
65
77
|
* Twitter doesn't support scopes
|
|
66
78
|
*/
|
|
67
79
|
protected scopeParamName: string;
|
|
80
|
+
/**
|
|
81
|
+
* Scope separator placeholder maintained for OAuth1 compatibility.
|
|
82
|
+
*/
|
|
68
83
|
protected scopesSeparator: string;
|
|
69
84
|
/**
|
|
70
85
|
* @param ctx - The HTTP context
|
|
@@ -131,6 +146,8 @@ export declare class TwitterDriver extends Oauth1Driver<TwitterToken, string> {
|
|
|
131
146
|
/**
|
|
132
147
|
* Check if the error from the callback indicates that the user
|
|
133
148
|
* denied authorization.
|
|
149
|
+
*
|
|
150
|
+
* @returns `true` when the request contains the denial marker.
|
|
134
151
|
*/
|
|
135
152
|
accessDenied(): boolean;
|
|
136
153
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Oauth1Driver
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-SBQAXPUK.js";
|
|
4
|
+
import "../../chunk-NK6X76EQ.js";
|
|
5
|
+
import "../../chunk-6BP2DK5A.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
|
+
}
|