@adonisjs/ally 5.1.0 → 6.0.0-next.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.
Files changed (52) hide show
  1. package/build/{chunk-N72DEJC2.js → chunk-KSJ4CFTC.js} +45 -8
  2. package/build/{chunk-VHORNQLN.js → chunk-KWRXS6EG.js} +65 -28
  3. package/build/{chunk-PZ5AY32C.js → chunk-MLKGABMK.js} +0 -1
  4. package/build/{chunk-NZT2DLWM.js → chunk-SZ4YJCVU.js} +15 -3
  5. package/build/chunk-WM3V3APX.js +210 -0
  6. package/build/index.d.ts +8 -8
  7. package/build/index.js +6 -8
  8. package/build/providers/ally_provider.d.ts +1 -1
  9. package/build/providers/ally_provider.js +3 -4
  10. package/build/src/abstract_drivers/oauth1.d.ts +115 -49
  11. package/build/src/abstract_drivers/oauth2.d.ts +121 -50
  12. package/build/src/ally_manager.d.ts +31 -4
  13. package/build/src/debug.d.ts +9 -0
  14. package/build/src/define_config.d.ts +45 -11
  15. package/build/src/drivers/discord.d.ts +76 -11
  16. package/build/src/drivers/discord.js +47 -12
  17. package/build/src/drivers/facebook.d.ts +73 -10
  18. package/build/src/drivers/facebook.js +44 -11
  19. package/build/src/drivers/github.d.ts +85 -13
  20. package/build/src/drivers/github.js +56 -14
  21. package/build/src/drivers/google.d.ts +80 -11
  22. package/build/src/drivers/google.js +50 -12
  23. package/build/src/drivers/linked_in.d.ts +76 -10
  24. package/build/src/drivers/linked_in.js +47 -12
  25. package/build/src/drivers/linked_in_openid_connect.d.ts +72 -9
  26. package/build/src/drivers/linked_in_openid_connect.js +42 -10
  27. package/build/src/drivers/spotify.d.ts +73 -10
  28. package/build/src/drivers/spotify.js +44 -11
  29. package/build/src/drivers/twitter.d.ts +65 -8
  30. package/build/src/drivers/twitter.js +37 -9
  31. package/build/src/errors.d.ts +10 -2
  32. package/build/src/redirect_request.d.ts +47 -7
  33. package/build/src/types.d.ts +1 -1
  34. package/build/src/types.js +0 -1
  35. package/package.json +57 -68
  36. package/build/chunk-GWAQFMNS.js +0 -164
  37. package/build/chunk-GWAQFMNS.js.map +0 -1
  38. package/build/chunk-N72DEJC2.js.map +0 -1
  39. package/build/chunk-NZT2DLWM.js.map +0 -1
  40. package/build/chunk-PZ5AY32C.js.map +0 -1
  41. package/build/chunk-VHORNQLN.js.map +0 -1
  42. package/build/index.js.map +0 -1
  43. package/build/providers/ally_provider.js.map +0 -1
  44. package/build/src/drivers/discord.js.map +0 -1
  45. package/build/src/drivers/facebook.js.map +0 -1
  46. package/build/src/drivers/github.js.map +0 -1
  47. package/build/src/drivers/google.js.map +0 -1
  48. package/build/src/drivers/linked_in.js.map +0 -1
  49. package/build/src/drivers/linked_in_openid_connect.js.map +0 -1
  50. package/build/src/drivers/spotify.js.map +0 -1
  51. package/build/src/drivers/twitter.js.map +0 -1
  52. package/build/src/types.js.map +0 -1
@@ -1,9 +1,39 @@
1
- import { Oauth2Driver } from '../abstract_drivers/oauth2.js';
2
1
  import type { HttpContext } from '@adonisjs/core/http';
3
- import type { ApiRequestContract, LinkedInOpenidConnectAccessToken, LinkedInOpenidConnectDriverConfig, LinkedInOpenidConnectScopes, RedirectRequestContract } from '@adonisjs/ally/types';
4
2
  import type { HttpClient } from '@poppinss/oauth-client';
3
+ import { Oauth2Driver } from '../abstract_drivers/oauth2.ts';
4
+ import type { ApiRequestContract, LinkedInOpenidConnectAccessToken, LinkedInOpenidConnectDriverConfig, LinkedInOpenidConnectScopes, RedirectRequestContract } from '../types.ts';
5
5
  /**
6
- * LinkedIn openid connect driver to login user via LinkedIn using openid connect requirements
6
+ * LinkedIn OpenID Connect OAuth2 driver for authenticating users via LinkedIn.
7
+ * This driver uses the OpenID Connect protocol for authentication.
8
+ * Supports fetching user profile information including name, email, and profile picture.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * router.get('/linkedin/redirect', ({ ally }) => {
13
+ * return ally.use('linkedinOpenidConnect').redirect((request) => {
14
+ * request.scopes(['openid', 'profile', 'email'])
15
+ * })
16
+ * })
17
+ *
18
+ * router.get('/linkedin/callback', async ({ ally }) => {
19
+ * const linkedin = ally.use('linkedinOpenidConnect')
20
+ *
21
+ * if (linkedin.accessDenied()) {
22
+ * return 'Access was denied'
23
+ * }
24
+ *
25
+ * if (linkedin.stateMisMatch()) {
26
+ * return 'State mismatch error'
27
+ * }
28
+ *
29
+ * if (linkedin.hasError()) {
30
+ * return linkedin.getError()
31
+ * }
32
+ *
33
+ * const user = await linkedin.user()
34
+ * return user
35
+ * })
36
+ * ```
7
37
  */
8
38
  export declare class LinkedInOpenidConnectDriver extends Oauth2Driver<LinkedInOpenidConnectAccessToken, LinkedInOpenidConnectScopes> {
9
39
  config: LinkedInOpenidConnectDriverConfig;
@@ -35,17 +65,31 @@ export declare class LinkedInOpenidConnectDriver extends Oauth2Driver<LinkedInOp
35
65
  * Scopes separator
36
66
  */
37
67
  protected scopesSeparator: string;
68
+ /**
69
+ * @param ctx - The HTTP context
70
+ * @param config - Configuration for the LinkedIn OpenID Connect driver
71
+ */
38
72
  constructor(ctx: HttpContext, config: LinkedInOpenidConnectDriverConfig);
39
73
  /**
40
- * Configuring the redirect request with defaults
74
+ * Configures the redirect request with default scopes for OpenID Connect.
75
+ *
76
+ * @param request - The redirect request to configure
41
77
  */
42
78
  protected configureRedirectRequest(request: RedirectRequestContract<LinkedInOpenidConnectScopes>): void;
43
79
  /**
44
- * Returns the HTTP request with the authorization header set
80
+ * Creates an authenticated HTTP request with the proper authorization
81
+ * header for LinkedIn API calls.
82
+ *
83
+ * @param url - The API endpoint URL
84
+ * @param token - The access token
45
85
  */
46
86
  protected getAuthenticatedRequest(url: string, token: string): HttpClient;
47
87
  /**
48
- * Fetches the user info from the LinkedIn API
88
+ * Fetches the authenticated user's profile information from the LinkedIn API
89
+ * using the OpenID Connect userinfo endpoint.
90
+ *
91
+ * @param token - The access token
92
+ * @param callback - Optional callback to customize the API request
49
93
  */
50
94
  protected getUserInfo(token: string, callback?: (request: ApiRequestContract) => void): Promise<{
51
95
  id: any;
@@ -57,11 +101,21 @@ export declare class LinkedInOpenidConnectDriver extends Oauth2Driver<LinkedInOp
57
101
  original: any;
58
102
  }>;
59
103
  /**
60
- * Find if the current error code is for access denied
104
+ * Check if the error from the callback indicates that the user
105
+ * denied authorization or cancelled the login.
61
106
  */
62
107
  accessDenied(): boolean;
63
108
  /**
64
- * Returns details for the authorized user
109
+ * Get the authenticated user's profile information using
110
+ * the authorization code from the callback request.
111
+ *
112
+ * @param callback - Optional callback to customize the API request
113
+ *
114
+ * @example
115
+ * ```ts
116
+ * const user = await ally.use('linkedinOpenidConnect').user()
117
+ * console.log(user.name, user.email)
118
+ * ```
65
119
  */
66
120
  user(callback?: (request: ApiRequestContract) => void): Promise<{
67
121
  token: {
@@ -79,7 +133,16 @@ export declare class LinkedInOpenidConnectDriver extends Oauth2Driver<LinkedInOp
79
133
  original: any;
80
134
  }>;
81
135
  /**
82
- * Finds the user by the access token
136
+ * Get the user's profile information using an existing
137
+ * access token.
138
+ *
139
+ * @param token - The LinkedIn access token
140
+ * @param callback - Optional callback to customize the API request
141
+ *
142
+ * @example
143
+ * ```ts
144
+ * const user = await ally.use('linkedinOpenidConnect').userFromToken(accessToken)
145
+ * ```
83
146
  */
84
147
  userFromToken(token: string, callback?: (request: ApiRequestContract) => void): Promise<{
85
148
  token: {
@@ -1,11 +1,15 @@
1
1
  import {
2
2
  Oauth2Driver
3
- } from "../../chunk-GWAQFMNS.js";
4
- import "../../chunk-N72DEJC2.js";
5
- import "../../chunk-PZ5AY32C.js";
3
+ } from "../../chunk-WM3V3APX.js";
4
+ import "../../chunk-KSJ4CFTC.js";
5
+ import "../../chunk-MLKGABMK.js";
6
6
 
7
7
  // src/drivers/linked_in_openid_connect.ts
8
8
  var LinkedInOpenidConnectDriver = class extends Oauth2Driver {
9
+ /**
10
+ * @param ctx - The HTTP context
11
+ * @param config - Configuration for the LinkedIn OpenID Connect driver
12
+ */
9
13
  constructor(ctx, config) {
10
14
  super(ctx, config);
11
15
  this.config = config;
@@ -40,14 +44,20 @@ var LinkedInOpenidConnectDriver = class extends Oauth2Driver {
40
44
  */
41
45
  scopesSeparator = " ";
42
46
  /**
43
- * Configuring the redirect request with defaults
47
+ * Configures the redirect request with default scopes for OpenID Connect.
48
+ *
49
+ * @param request - The redirect request to configure
44
50
  */
45
51
  configureRedirectRequest(request) {
46
52
  request.scopes(this.config.scopes || ["openid", "profile", "email"]);
47
53
  request.param("response_type", "code");
48
54
  }
49
55
  /**
50
- * Returns the HTTP request with the authorization header set
56
+ * Creates an authenticated HTTP request with the proper authorization
57
+ * header for LinkedIn API calls.
58
+ *
59
+ * @param url - The API endpoint URL
60
+ * @param token - The access token
51
61
  */
52
62
  getAuthenticatedRequest(url, token) {
53
63
  const request = this.httpClient(url);
@@ -57,7 +67,11 @@ var LinkedInOpenidConnectDriver = class extends Oauth2Driver {
57
67
  return request;
58
68
  }
59
69
  /**
60
- * Fetches the user info from the LinkedIn API
70
+ * Fetches the authenticated user's profile information from the LinkedIn API
71
+ * using the OpenID Connect userinfo endpoint.
72
+ *
73
+ * @param token - The access token
74
+ * @param callback - Optional callback to customize the API request
61
75
  */
62
76
  async getUserInfo(token, callback) {
63
77
  let url = this.config.userInfoUrl || this.userInfoUrl;
@@ -78,7 +92,8 @@ var LinkedInOpenidConnectDriver = class extends Oauth2Driver {
78
92
  };
79
93
  }
80
94
  /**
81
- * Find if the current error code is for access denied
95
+ * Check if the error from the callback indicates that the user
96
+ * denied authorization or cancelled the login.
82
97
  */
83
98
  accessDenied() {
84
99
  const error = this.getError();
@@ -88,7 +103,16 @@ var LinkedInOpenidConnectDriver = class extends Oauth2Driver {
88
103
  return error === "user_cancelled_login" || error === "user_cancelled_authorize";
89
104
  }
90
105
  /**
91
- * Returns details for the authorized user
106
+ * Get the authenticated user's profile information using
107
+ * the authorization code from the callback request.
108
+ *
109
+ * @param callback - Optional callback to customize the API request
110
+ *
111
+ * @example
112
+ * ```ts
113
+ * const user = await ally.use('linkedinOpenidConnect').user()
114
+ * console.log(user.name, user.email)
115
+ * ```
92
116
  */
93
117
  async user(callback) {
94
118
  const accessToken = await this.accessToken(callback);
@@ -99,7 +123,16 @@ var LinkedInOpenidConnectDriver = class extends Oauth2Driver {
99
123
  };
100
124
  }
101
125
  /**
102
- * Finds the user by the access token
126
+ * Get the user's profile information using an existing
127
+ * access token.
128
+ *
129
+ * @param token - The LinkedIn access token
130
+ * @param callback - Optional callback to customize the API request
131
+ *
132
+ * @example
133
+ * ```ts
134
+ * const user = await ally.use('linkedinOpenidConnect').userFromToken(accessToken)
135
+ * ```
103
136
  */
104
137
  async userFromToken(token, callback) {
105
138
  const user = await this.getUserInfo(token, callback);
@@ -112,4 +145,3 @@ var LinkedInOpenidConnectDriver = class extends Oauth2Driver {
112
145
  export {
113
146
  LinkedInOpenidConnectDriver
114
147
  };
115
- //# sourceMappingURL=linked_in_openid_connect.js.map
@@ -1,9 +1,38 @@
1
1
  import type { HttpContext } from '@adonisjs/core/http';
2
2
  import type { HttpClient } from '@poppinss/oauth-client';
3
- import type { SpotifyScopes, SpotifyToken, ApiRequestContract, SpotifyDriverConfig, RedirectRequestContract } from '../types.js';
4
- import { Oauth2Driver } from '../abstract_drivers/oauth2.js';
3
+ import type { SpotifyScopes, SpotifyToken, ApiRequestContract, SpotifyDriverConfig, RedirectRequestContract } from '../types.ts';
4
+ import { Oauth2Driver } from '../abstract_drivers/oauth2.ts';
5
5
  /**
6
- * Spotify driver to login user via Spotify
6
+ * Spotify OAuth2 driver for authenticating users via Spotify.
7
+ * Supports fetching user profile information including display name, email, and profile images.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * router.get('/spotify/redirect', ({ ally }) => {
12
+ * return ally.use('spotify').redirect((request) => {
13
+ * request.scopes(['user-read-email', 'user-read-private'])
14
+ * })
15
+ * })
16
+ *
17
+ * router.get('/spotify/callback', async ({ ally }) => {
18
+ * const spotify = ally.use('spotify')
19
+ *
20
+ * if (spotify.accessDenied()) {
21
+ * return 'Access was denied'
22
+ * }
23
+ *
24
+ * if (spotify.stateMisMatch()) {
25
+ * return 'State mismatch error'
26
+ * }
27
+ *
28
+ * if (spotify.hasError()) {
29
+ * return spotify.getError()
30
+ * }
31
+ *
32
+ * const user = await spotify.user()
33
+ * return user
34
+ * })
35
+ * ```
7
36
  */
8
37
  export declare class SpotifyDriver extends Oauth2Driver<SpotifyToken, SpotifyScopes> {
9
38
  config: SpotifyDriverConfig;
@@ -35,18 +64,33 @@ export declare class SpotifyDriver extends Oauth2Driver<SpotifyToken, SpotifySco
35
64
  * Scopes separator
36
65
  */
37
66
  protected scopesSeparator: string;
67
+ /**
68
+ * @param ctx - The HTTP context
69
+ * @param config - Configuration for the Spotify driver
70
+ */
38
71
  constructor(ctx: HttpContext, config: SpotifyDriverConfig);
39
72
  /**
40
- * Configuring the redirect request with defaults
73
+ * Configures the redirect request with default scopes and Spotify-specific
74
+ * parameters like show_dialog.
75
+ *
76
+ * @param request - The redirect request to configure
41
77
  */
42
78
  protected configureRedirectRequest(request: RedirectRequestContract<SpotifyScopes>): void;
43
79
  /**
44
- * Returns the HTTP request with the authorization header set
80
+ * Creates an authenticated HTTP request with the proper authorization
81
+ * header for Spotify API calls.
82
+ *
83
+ * @param url - The API endpoint URL
84
+ * @param token - The access token
45
85
  */
46
86
  protected getAuthenticatedRequest(url: string, token: string): HttpClient;
47
87
  /**
48
- * Fetches the user info from the Spotify API
49
- * https://discord.com/developers/docs/resources/user#get-current-user
88
+ * Fetches the authenticated user's profile information from the Spotify API.
89
+ *
90
+ * @param token - The access token
91
+ * @param callback - Optional callback to customize the API request
92
+ *
93
+ * @see https://developer.spotify.com/documentation/web-api/reference/get-current-users-profile
50
94
  */
51
95
  protected getUserInfo(token: string, callback?: (request: ApiRequestContract) => void): Promise<{
52
96
  id: any;
@@ -58,11 +102,21 @@ export declare class SpotifyDriver extends Oauth2Driver<SpotifyToken, SpotifySco
58
102
  original: any;
59
103
  }>;
60
104
  /**
61
- * Find if the current error code is for access denied
105
+ * Check if the error from the callback indicates that the user
106
+ * denied authorization.
62
107
  */
63
108
  accessDenied(): boolean;
64
109
  /**
65
- * Returns details for the authorized user
110
+ * Get the authenticated user's profile information using
111
+ * the authorization code from the callback request.
112
+ *
113
+ * @param callback - Optional callback to customize the API request
114
+ *
115
+ * @example
116
+ * ```ts
117
+ * const user = await ally.use('spotify').user()
118
+ * console.log(user.name, user.email)
119
+ * ```
66
120
  */
67
121
  user(callback?: (request: ApiRequestContract) => void): Promise<{
68
122
  token: SpotifyToken;
@@ -75,7 +129,16 @@ export declare class SpotifyDriver extends Oauth2Driver<SpotifyToken, SpotifySco
75
129
  original: any;
76
130
  }>;
77
131
  /**
78
- * Finds the user by the access token
132
+ * Get the user's profile information using an existing
133
+ * access token.
134
+ *
135
+ * @param token - The Spotify access token
136
+ * @param callback - Optional callback to customize the API request
137
+ *
138
+ * @example
139
+ * ```ts
140
+ * const user = await ally.use('spotify').userFromToken(accessToken)
141
+ * ```
79
142
  */
80
143
  userFromToken(token: string, callback?: (request: ApiRequestContract) => void): Promise<{
81
144
  token: {
@@ -1,11 +1,15 @@
1
1
  import {
2
2
  Oauth2Driver
3
- } from "../../chunk-GWAQFMNS.js";
4
- import "../../chunk-N72DEJC2.js";
5
- import "../../chunk-PZ5AY32C.js";
3
+ } from "../../chunk-WM3V3APX.js";
4
+ import "../../chunk-KSJ4CFTC.js";
5
+ import "../../chunk-MLKGABMK.js";
6
6
 
7
7
  // src/drivers/spotify.ts
8
8
  var SpotifyDriver = class extends Oauth2Driver {
9
+ /**
10
+ * @param ctx - The HTTP context
11
+ * @param config - Configuration for the Spotify driver
12
+ */
9
13
  constructor(ctx, config) {
10
14
  super(ctx, config);
11
15
  this.config = config;
@@ -40,7 +44,10 @@ var SpotifyDriver = class extends Oauth2Driver {
40
44
  */
41
45
  scopesSeparator = " ";
42
46
  /**
43
- * Configuring the redirect request with defaults
47
+ * Configures the redirect request with default scopes and Spotify-specific
48
+ * parameters like show_dialog.
49
+ *
50
+ * @param request - The redirect request to configure
44
51
  */
45
52
  configureRedirectRequest(request) {
46
53
  request.scopes(this.config.scopes || ["user-read-email"]);
@@ -51,7 +58,11 @@ var SpotifyDriver = class extends Oauth2Driver {
51
58
  }
52
59
  }
53
60
  /**
54
- * Returns the HTTP request with the authorization header set
61
+ * Creates an authenticated HTTP request with the proper authorization
62
+ * header for Spotify API calls.
63
+ *
64
+ * @param url - The API endpoint URL
65
+ * @param token - The access token
55
66
  */
56
67
  getAuthenticatedRequest(url, token) {
57
68
  const request = this.httpClient(url);
@@ -61,8 +72,12 @@ var SpotifyDriver = class extends Oauth2Driver {
61
72
  return request;
62
73
  }
63
74
  /**
64
- * Fetches the user info from the Spotify API
65
- * https://discord.com/developers/docs/resources/user#get-current-user
75
+ * Fetches the authenticated user's profile information from the Spotify API.
76
+ *
77
+ * @param token - The access token
78
+ * @param callback - Optional callback to customize the API request
79
+ *
80
+ * @see https://developer.spotify.com/documentation/web-api/reference/get-current-users-profile
66
81
  */
67
82
  async getUserInfo(token, callback) {
68
83
  const request = this.getAuthenticatedRequest(this.userInfoUrl, token);
@@ -81,7 +96,8 @@ var SpotifyDriver = class extends Oauth2Driver {
81
96
  };
82
97
  }
83
98
  /**
84
- * Find if the current error code is for access denied
99
+ * Check if the error from the callback indicates that the user
100
+ * denied authorization.
85
101
  */
86
102
  accessDenied() {
87
103
  const error = this.getError();
@@ -91,7 +107,16 @@ var SpotifyDriver = class extends Oauth2Driver {
91
107
  return error === "access_denied";
92
108
  }
93
109
  /**
94
- * Returns details for the authorized user
110
+ * Get the authenticated user's profile information using
111
+ * the authorization code from the callback request.
112
+ *
113
+ * @param callback - Optional callback to customize the API request
114
+ *
115
+ * @example
116
+ * ```ts
117
+ * const user = await ally.use('spotify').user()
118
+ * console.log(user.name, user.email)
119
+ * ```
95
120
  */
96
121
  async user(callback) {
97
122
  const token = await this.accessToken(callback);
@@ -102,7 +127,16 @@ var SpotifyDriver = class extends Oauth2Driver {
102
127
  };
103
128
  }
104
129
  /**
105
- * Finds the user by the access token
130
+ * Get the user's profile information using an existing
131
+ * access token.
132
+ *
133
+ * @param token - The Spotify access token
134
+ * @param callback - Optional callback to customize the API request
135
+ *
136
+ * @example
137
+ * ```ts
138
+ * const user = await ally.use('spotify').userFromToken(accessToken)
139
+ * ```
106
140
  */
107
141
  async userFromToken(token, callback) {
108
142
  const user = await this.getUserInfo(token, callback);
@@ -115,4 +149,3 @@ var SpotifyDriver = class extends Oauth2Driver {
115
149
  export {
116
150
  SpotifyDriver
117
151
  };
118
- //# sourceMappingURL=spotify.js.map
@@ -1,8 +1,36 @@
1
1
  import type { HttpContext } from '@adonisjs/core/http';
2
- import { TwitterToken, AllyUserContract, ApiRequestContract, TwitterDriverConfig } from '../types.js';
3
- import { Oauth1Driver } from '../abstract_drivers/oauth1.js';
2
+ import { type TwitterToken, type AllyUserContract, type ApiRequestContract, type TwitterDriverConfig } from '../types.ts';
3
+ import { Oauth1Driver } from '../abstract_drivers/oauth1.ts';
4
4
  /**
5
- * Twitter driver to login user via twitter
5
+ * Twitter OAuth1 driver for authenticating users via Twitter.
6
+ * Supports fetching user profile information including username, name, and email.
7
+ * Uses OAuth 1.0a protocol.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * router.get('/twitter/redirect', ({ ally }) => {
12
+ * return ally.use('twitter').redirect()
13
+ * })
14
+ *
15
+ * router.get('/twitter/callback', async ({ ally }) => {
16
+ * const twitter = ally.use('twitter')
17
+ *
18
+ * if (twitter.accessDenied()) {
19
+ * return 'Access was denied'
20
+ * }
21
+ *
22
+ * if (twitter.stateMisMatch()) {
23
+ * return 'State mismatch error'
24
+ * }
25
+ *
26
+ * if (twitter.hasError()) {
27
+ * return twitter.getError()
28
+ * }
29
+ *
30
+ * const user = await twitter.user()
31
+ * return user
32
+ * })
33
+ * ```
6
34
  */
7
35
  export declare class TwitterDriver extends Oauth1Driver<TwitterToken, string> {
8
36
  protected ctx: HttpContext;
@@ -38,9 +66,19 @@ export declare class TwitterDriver extends Oauth1Driver<TwitterToken, string> {
38
66
  */
39
67
  protected scopeParamName: string;
40
68
  protected scopesSeparator: string;
69
+ /**
70
+ * @param ctx - The HTTP context
71
+ * @param config - Configuration for the Twitter driver
72
+ */
41
73
  constructor(ctx: HttpContext, config: TwitterDriverConfig);
42
74
  /**
43
- * Returns user info
75
+ * Fetches the authenticated user's profile information from the Twitter API.
76
+ *
77
+ * @param token - The OAuth token
78
+ * @param secret - The OAuth token secret
79
+ * @param callback - Optional callback to customize the API request
80
+ *
81
+ * @see https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/get-account-verify_credentials
44
82
  */
45
83
  protected getUserInfo(token: string, secret: string, callback?: (request: ApiRequestContract) => void): Promise<{
46
84
  id: any;
@@ -52,7 +90,16 @@ export declare class TwitterDriver extends Oauth1Driver<TwitterToken, string> {
52
90
  original: any;
53
91
  }>;
54
92
  /**
55
- * Returns details for the authorized user
93
+ * Get the authenticated user's profile information using
94
+ * the OAuth verifier from the callback request.
95
+ *
96
+ * @param callback - Optional callback to customize the API request
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * const user = await ally.use('twitter').user()
101
+ * console.log(user.name, user.email)
102
+ * ```
56
103
  */
57
104
  user(callback?: (request: ApiRequestContract) => void): Promise<{
58
105
  token: TwitterToken;
@@ -65,15 +112,25 @@ export declare class TwitterDriver extends Oauth1Driver<TwitterToken, string> {
65
112
  original: any;
66
113
  }>;
67
114
  /**
68
- * Finds the user info from the "oauth_token" and "oauth_token_secret"
69
- * access from the access token.
115
+ * Get the user's profile information using an existing OAuth token
116
+ * and token secret.
117
+ *
118
+ * @param token - The OAuth token
119
+ * @param secret - The OAuth token secret
120
+ * @param callback - Optional callback to customize the API request
121
+ *
122
+ * @example
123
+ * ```ts
124
+ * const user = await ally.use('twitter').userFromTokenAndSecret(token, secret)
125
+ * ```
70
126
  */
71
127
  userFromTokenAndSecret(token: string, secret: string, callback?: (request: ApiRequestContract) => void): Promise<AllyUserContract<{
72
128
  token: string;
73
129
  secret: string;
74
130
  }>>;
75
131
  /**
76
- * Find if the current error code is for access denied
132
+ * Check if the error from the callback indicates that the user
133
+ * denied authorization.
77
134
  */
78
135
  accessDenied(): boolean;
79
136
  }
@@ -1,11 +1,15 @@
1
1
  import {
2
2
  Oauth1Driver
3
- } from "../../chunk-VHORNQLN.js";
4
- import "../../chunk-N72DEJC2.js";
5
- import "../../chunk-PZ5AY32C.js";
3
+ } from "../../chunk-KWRXS6EG.js";
4
+ import "../../chunk-KSJ4CFTC.js";
5
+ import "../../chunk-MLKGABMK.js";
6
6
 
7
7
  // src/drivers/twitter.ts
8
8
  var TwitterDriver = class extends Oauth1Driver {
9
+ /**
10
+ * @param ctx - The HTTP context
11
+ * @param config - Configuration for the Twitter driver
12
+ */
9
13
  constructor(ctx, config) {
10
14
  super(ctx, config);
11
15
  this.ctx = ctx;
@@ -44,7 +48,13 @@ var TwitterDriver = class extends Oauth1Driver {
44
48
  scopeParamName = "";
45
49
  scopesSeparator = " ";
46
50
  /**
47
- * Returns user info
51
+ * Fetches the authenticated user's profile information from the Twitter API.
52
+ *
53
+ * @param token - The OAuth token
54
+ * @param secret - The OAuth token secret
55
+ * @param callback - Optional callback to customize the API request
56
+ *
57
+ * @see https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/get-account-verify_credentials
48
58
  */
49
59
  async getUserInfo(token, secret, callback) {
50
60
  const requestToken = { token, secret };
@@ -67,7 +77,16 @@ var TwitterDriver = class extends Oauth1Driver {
67
77
  };
68
78
  }
69
79
  /**
70
- * Returns details for the authorized user
80
+ * Get the authenticated user's profile information using
81
+ * the OAuth verifier from the callback request.
82
+ *
83
+ * @param callback - Optional callback to customize the API request
84
+ *
85
+ * @example
86
+ * ```ts
87
+ * const user = await ally.use('twitter').user()
88
+ * console.log(user.name, user.email)
89
+ * ```
71
90
  */
72
91
  async user(callback) {
73
92
  const token = await this.accessToken();
@@ -78,8 +97,17 @@ var TwitterDriver = class extends Oauth1Driver {
78
97
  };
79
98
  }
80
99
  /**
81
- * Finds the user info from the "oauth_token" and "oauth_token_secret"
82
- * access from the access token.
100
+ * Get the user's profile information using an existing OAuth token
101
+ * and token secret.
102
+ *
103
+ * @param token - The OAuth token
104
+ * @param secret - The OAuth token secret
105
+ * @param callback - Optional callback to customize the API request
106
+ *
107
+ * @example
108
+ * ```ts
109
+ * const user = await ally.use('twitter').userFromTokenAndSecret(token, secret)
110
+ * ```
83
111
  */
84
112
  async userFromTokenAndSecret(token, secret, callback) {
85
113
  const userInfo = await this.getUserInfo(token, secret, callback);
@@ -89,7 +117,8 @@ var TwitterDriver = class extends Oauth1Driver {
89
117
  };
90
118
  }
91
119
  /**
92
- * Find if the current error code is for access denied
120
+ * Check if the error from the callback indicates that the user
121
+ * denied authorization.
93
122
  */
94
123
  accessDenied() {
95
124
  return this.ctx.request.input("denied");
@@ -98,4 +127,3 @@ var TwitterDriver = class extends Oauth1Driver {
98
127
  export {
99
128
  TwitterDriver
100
129
  };
101
- //# sourceMappingURL=twitter.js.map
@@ -1,2 +1,10 @@
1
- export declare const E_OAUTH_MISSING_CODE: new (args: [string], options?: ErrorOptions) => import("@poppinss/utils").Exception;
2
- export declare const E_OAUTH_STATE_MISMATCH: new (args?: any, options?: ErrorOptions) => import("@poppinss/utils").Exception;
1
+ /**
2
+ * Error thrown when the OAuth redirect is missing the required
3
+ * authorization code or token parameter.
4
+ */
5
+ export declare const E_OAUTH_MISSING_CODE: new (args: [string], options?: ErrorOptions) => import("@adonisjs/core/exceptions").Exception;
6
+ /**
7
+ * Error thrown when the OAuth state parameter does not match
8
+ * the expected value, indicating a potential CSRF attack.
9
+ */
10
+ export declare const E_OAUTH_STATE_MISMATCH: new (args?: any, options?: ErrorOptions) => import("@adonisjs/core/exceptions").Exception;