@adonisjs/ally 4.1.4 → 5.0.0-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 (76) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +25 -42
  3. package/build/configure.d.ts +5 -0
  4. package/build/configure.js +18 -0
  5. package/build/index.d.ts +11 -0
  6. package/build/index.js +19 -0
  7. package/build/providers/ally_provider.d.ts +9 -0
  8. package/build/providers/ally_provider.js +21 -0
  9. package/build/src/{AbstractDrivers/Oauth1/index.d.ts → abstract_drivers/oauth1.d.ts} +6 -14
  10. package/build/src/{AbstractDrivers/Oauth1/index.js → abstract_drivers/oauth1.js} +31 -29
  11. package/build/src/{AbstractDrivers/Oauth2/index.d.ts → abstract_drivers/oauth2.d.ts} +6 -10
  12. package/build/src/{AbstractDrivers/Oauth2/index.js → abstract_drivers/oauth2.js} +26 -25
  13. package/build/src/ally_manager.d.ts +14 -0
  14. package/build/src/ally_manager.js +40 -0
  15. package/build/src/bindings/http_context.d.ts +6 -0
  16. package/build/src/bindings/http_context.js +19 -0
  17. package/build/src/bindings/types.d.ts +12 -0
  18. package/build/{adonis-typings/context.js → src/bindings/types.js} +2 -1
  19. package/build/src/{Config/index.js → defaults/config.js} +12 -15
  20. package/build/src/define_config.d.ts +12 -0
  21. package/build/src/define_config.js +26 -0
  22. package/build/src/{Drivers/Discord/index.d.ts → drivers/discord.d.ts} +4 -4
  23. package/build/src/{Drivers/Discord/index.js → drivers/discord.js} +32 -35
  24. package/build/src/{Drivers/Facebook/index.d.ts → drivers/facebook.d.ts} +4 -4
  25. package/build/src/{Drivers/Facebook/index.js → drivers/facebook.js} +44 -47
  26. package/build/src/{Drivers/Github/index.d.ts → drivers/github.d.ts} +4 -4
  27. package/build/src/{Drivers/Github/index.js → drivers/github.js} +33 -36
  28. package/build/src/{Drivers/Google/index.d.ts → drivers/google.d.ts} +8 -4
  29. package/build/src/{Drivers/Google/index.js → drivers/google.js} +42 -35
  30. package/build/src/{Drivers/LinkedIn/index.d.ts → drivers/linked_in.d.ts} +4 -4
  31. package/build/src/{Drivers/LinkedIn/index.js → drivers/linked_in.js} +35 -38
  32. package/build/src/{Drivers/Spotify/index.d.ts → drivers/spotify.d.ts} +4 -4
  33. package/build/src/{Drivers/Spotify/index.js → drivers/spotify.js} +32 -35
  34. package/build/src/{Drivers/Twitter/index.d.ts → drivers/twitter.d.ts} +5 -5
  35. package/build/src/{Drivers/Twitter/index.js → drivers/twitter.js} +36 -38
  36. package/build/src/drivers_collection.d.ts +19 -0
  37. package/build/src/drivers_collection.js +50 -0
  38. package/build/src/exceptions.d.ts +2 -0
  39. package/build/src/exceptions.js +11 -0
  40. package/build/src/{RedirectRequest/index.d.ts → redirect_request.d.ts} +11 -9
  41. package/build/src/redirect_request.js +63 -0
  42. package/build/src/types.d.ts +383 -0
  43. package/build/{adonis-typings/ally.js → src/types.js} +2 -1
  44. package/build/stubs/config.stub +7 -0
  45. package/build/stubs/main.d.ts +1 -0
  46. package/build/{adonis-typings/container.js → stubs/main.js} +3 -1
  47. package/build/stubs/types.stub +12 -0
  48. package/package.json +116 -152
  49. package/build/adonis-typings/ally.d.ts +0 -418
  50. package/build/adonis-typings/container.d.ts +0 -6
  51. package/build/adonis-typings/context.d.ts +0 -6
  52. package/build/adonis-typings/index.d.ts +0 -3
  53. package/build/adonis-typings/index.js +0 -11
  54. package/build/instructions.js +0 -187
  55. package/build/instructions.md +0 -46
  56. package/build/providers/AllyProvider.d.ts +0 -19
  57. package/build/providers/AllyProvider.js +0 -40
  58. package/build/src/Ally/index.d.ts +0 -23
  59. package/build/src/Ally/index.js +0 -36
  60. package/build/src/AllyManager/index.d.ts +0 -70
  61. package/build/src/AllyManager/index.js +0 -146
  62. package/build/src/Exceptions/index.d.ts +0 -8
  63. package/build/src/Exceptions/index.js +0 -24
  64. package/build/src/RedirectRequest/index.js +0 -55
  65. package/build/standalone.d.ts +0 -7
  66. package/build/standalone.js +0 -22
  67. package/build/templates/config/ally.txt +0 -44
  68. package/build/templates/config/partials/discord.txt +0 -11
  69. package/build/templates/config/partials/facebook.txt +0 -11
  70. package/build/templates/config/partials/github.txt +0 -11
  71. package/build/templates/config/partials/google.txt +0 -11
  72. package/build/templates/config/partials/linkedin.txt +0 -11
  73. package/build/templates/config/partials/spotify.txt +0 -12
  74. package/build/templates/config/partials/twitter.txt +0 -11
  75. package/build/templates/contracts/ally.txt +0 -53
  76. /package/build/src/{Config/index.d.ts → defaults/config.d.ts} +0 -0
@@ -1,60 +1,57 @@
1
- "use strict";
2
1
  /*
3
2
  * @adonisjs/ally
4
3
  *
5
- * (c) Harminder Virk <virk@adonisjs.com>
4
+ * (c) AdonisJS
6
5
  *
7
6
  * For the full copyright and license information, please view the LICENSE
8
7
  * file that was distributed with this source code.
9
8
  */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.spotify = exports.facebook = exports.bitbucket = exports.microsoft = exports.discord = exports.patreon = exports.linkedin = exports.gitlab = exports.google = exports.github = exports.twitter = void 0;
12
- exports.twitter = {
9
+ export const twitter = {
13
10
  REQUEST_TOKEN_URL: 'https://api.twitter.com/oauth/request_token',
14
11
  AUTHORIZE_URL: 'https://api.twitter.com/oauth/authenticate',
15
12
  ACCESS_TOKEN_URL: 'https://api.twitter.com/oauth/access_token',
16
13
  };
17
- exports.github = {
14
+ export const github = {
18
15
  AUTHORIZE_URL: 'https://github.com/login/oauth/authorize',
19
16
  ACCESS_TOKEN_URL: 'https://github.com/login/oauth/access_token',
20
17
  USER_INFO_URL: 'https://api.github.com/user',
21
18
  USER_EMAIL_URL: 'https://api.github.com/user/emails',
22
19
  };
23
- exports.google = {
20
+ export const google = {
24
21
  AUTHORIZE_URL: 'https://accounts.google.com/o/oauth2/v2/auth',
25
22
  ACCESS_TOKEN_URL: 'https://oauth2.googleapis.com/token',
26
23
  USER_INFO_URL: 'https://www.googleapis.com/oauth2/v3/userinfo',
27
24
  };
28
- exports.gitlab = {
25
+ export const gitlab = {
29
26
  AUTHORIZE_URL: 'https://gitlab.com/oauth/authorize',
30
27
  ACCESS_TOKEN_URL: 'https://gitlab.com/oauth/token',
31
28
  };
32
- exports.linkedin = {
29
+ export const linkedin = {
33
30
  AUTHORIZE_URL: 'https://www.linkedin.com/oauth/v2/authorization',
34
31
  ACCESS_TOKEN_URL: 'https://www.linkedin.com/oauth/v2/accessToken',
35
32
  };
36
- exports.patreon = {
33
+ export const patreon = {
37
34
  AUTHORIZE_URL: 'https://www.patreon.com/oauth2/authorize',
38
35
  ACCESS_TOKEN_URL: 'https://www.patreon.com/api/oauth2/token',
39
36
  };
40
- exports.discord = {
37
+ export const discord = {
41
38
  AUTHORIZE_URL: 'https://discord.com/api/oauth2/authorize',
42
39
  ACCESS_TOKEN_URL: 'https://discord.com/api/oauth2/token',
43
40
  USER_INFO_URL: 'https://discord.com/api/users/@me',
44
41
  };
45
- exports.microsoft = {
42
+ export const microsoft = {
46
43
  AUTHORIZE_URL: 'https://login.microsoftonline.com/{tenant}/oauth2/v2.0/authorize',
47
44
  ACCESS_TOKEN_URL: 'https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token',
48
45
  };
49
- exports.bitbucket = {
46
+ export const bitbucket = {
50
47
  AUTHORIZE_URL: 'https://bitbucket.org/site/oauth2/authorize',
51
48
  ACCESS_TOKEN_URL: 'https://bitbucket.org/site/oauth2/access_token',
52
49
  };
53
- exports.facebook = {
50
+ export const facebook = {
54
51
  AUTHORIZE_URL: 'https://www.facebook.com/v10.0/dialog/oauth',
55
52
  ACCESS_TOKEN_URL: 'https://graph.facebook.com/v10.0/dialog/oauth/access_token',
56
53
  };
57
- exports.spotify = {
54
+ export const spotify = {
58
55
  AUTHORIZE_URL: 'https://accounts.spotify.com/authorize',
59
56
  ACCESS_TOKEN_URL: 'https://accounts.spotify.com/api/token',
60
57
  USER_INFO_URL: 'https://api.spotify.com/v1/me',
@@ -0,0 +1,12 @@
1
+ import type { HttpContext } from '@adonisjs/core/http';
2
+ import type { AllyDriversList } from './types.js';
3
+ /**
4
+ * Define config for the ally
5
+ */
6
+ export declare function defineConfig<KnownSocialProviders extends Record<string, {
7
+ [K in keyof AllyDriversList]: {
8
+ driver: K;
9
+ } & Parameters<AllyDriversList[K]>[0];
10
+ }[keyof AllyDriversList]>>(config: KnownSocialProviders): {
11
+ [K in keyof KnownSocialProviders]: (ctx: HttpContext) => ReturnType<AllyDriversList[KnownSocialProviders[K]['driver']]>;
12
+ };
@@ -0,0 +1,26 @@
1
+ /*
2
+ * @adonisjs/ally
3
+ *
4
+ * (c) Ally
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+ import allyDriversCollection from './drivers_collection.js';
10
+ /**
11
+ * Define config for the ally
12
+ */
13
+ export function defineConfig(config) {
14
+ /**
15
+ * Converting user defined config to an object of providers
16
+ * that can be injected into the AllyManager class
17
+ */
18
+ const managerHashers = Object.keys(config).reduce((result, provider) => {
19
+ const providerConfig = config[provider];
20
+ result[provider] = (ctx) => {
21
+ return allyDriversCollection.create(providerConfig.driver, providerConfig, ctx);
22
+ };
23
+ return result;
24
+ }, {});
25
+ return managerHashers;
26
+ }
@@ -1,6 +1,6 @@
1
- import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
2
- import { DiscordScopes, DiscordToken, ApiRequestContract, DiscordDriverConfig, DiscordDriverContract, RedirectRequestContract } from '@ioc:Adonis/Addons/Ally';
3
- import { Oauth2Driver } from '../../AbstractDrivers/Oauth2';
1
+ import type { HttpContext } from '@adonisjs/core/http';
2
+ import { DiscordScopes, DiscordToken, ApiRequestContract, DiscordDriverConfig, DiscordDriverContract, RedirectRequestContract } from '../types.js';
3
+ import { Oauth2Driver } from '../abstract_drivers/oauth2.js';
4
4
  /**
5
5
  * Discord driver to login user via Discord
6
6
  */
@@ -34,7 +34,7 @@ export declare class DiscordDriver extends Oauth2Driver<DiscordToken, DiscordSco
34
34
  * Scopes separator
35
35
  */
36
36
  protected scopesSeparator: string;
37
- constructor(ctx: HttpContextContract, config: DiscordDriverConfig);
37
+ constructor(ctx: HttpContext, config: DiscordDriverConfig);
38
38
  /**
39
39
  * Configuring the redirect request with defaults
40
40
  */
@@ -1,50 +1,48 @@
1
- "use strict";
2
1
  /*
3
2
  * @adonisjs/ally
4
3
  *
5
- * (c) Harminder Virk <virk@adonisjs.com>
4
+ * (c) AdonisJS
6
5
  *
7
6
  * For the full copyright and license information, please view the LICENSE
8
7
  * file that was distributed with this source code.
9
8
  */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.DiscordDriver = void 0;
12
- const Oauth2_1 = require("../../AbstractDrivers/Oauth2");
9
+ import { Oauth2Driver } from '../abstract_drivers/oauth2.js';
13
10
  /**
14
11
  * Discord driver to login user via Discord
15
12
  */
16
- class DiscordDriver extends Oauth2_1.Oauth2Driver {
13
+ export class DiscordDriver extends Oauth2Driver {
14
+ config;
15
+ accessTokenUrl = 'https://discord.com/api/oauth2/token';
16
+ authorizeUrl = 'https://discord.com/api/oauth2/authorize';
17
+ userInfoUrl = 'https://discord.com/api/users/@me';
18
+ /**
19
+ * The param name for the authorization code
20
+ */
21
+ codeParamName = 'code';
22
+ /**
23
+ * The param name for the error
24
+ */
25
+ errorParamName = 'error';
26
+ /**
27
+ * Cookie name for storing the "discord_oauth_state"
28
+ */
29
+ stateCookieName = 'discord_oauth_state';
30
+ /**
31
+ * Parameter name to be used for sending and receiving the state
32
+ * from Discord
33
+ */
34
+ stateParamName = 'state';
35
+ /**
36
+ * Parameter name for defining the scopes
37
+ */
38
+ scopeParamName = 'scope';
39
+ /**
40
+ * Scopes separator
41
+ */
42
+ scopesSeparator = ' ';
17
43
  constructor(ctx, config) {
18
44
  super(ctx, config);
19
45
  this.config = config;
20
- this.accessTokenUrl = 'https://discord.com/api/oauth2/token';
21
- this.authorizeUrl = 'https://discord.com/api/oauth2/authorize';
22
- this.userInfoUrl = 'https://discord.com/api/users/@me';
23
- /**
24
- * The param name for the authorization code
25
- */
26
- this.codeParamName = 'code';
27
- /**
28
- * The param name for the error
29
- */
30
- this.errorParamName = 'error';
31
- /**
32
- * Cookie name for storing the "discord_oauth_state"
33
- */
34
- this.stateCookieName = 'discord_oauth_state';
35
- /**
36
- * Parameter name to be used for sending and receiving the state
37
- * from Discord
38
- */
39
- this.stateParamName = 'state';
40
- /**
41
- * Parameter name for defining the scopes
42
- */
43
- this.scopeParamName = 'scope';
44
- /**
45
- * Scopes separator
46
- */
47
- this.scopesSeparator = ' ';
48
46
  /**
49
47
  * Extremely important to call the following method to clear the
50
48
  * state set by the redirect request
@@ -156,4 +154,3 @@ class DiscordDriver extends Oauth2_1.Oauth2Driver {
156
154
  };
157
155
  }
158
156
  }
159
- exports.DiscordDriver = DiscordDriver;
@@ -1,6 +1,6 @@
1
- import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
2
- import { FacebookToken, FacebookScopes, LiteralStringUnion, ApiRequestContract, FacebookDriverConfig, FacebookProfileFields, FacebookDriverContract, RedirectRequestContract } from '@ioc:Adonis/Addons/Ally';
3
- import { Oauth2Driver } from '../../AbstractDrivers/Oauth2';
1
+ import type { HttpContext } from '@adonisjs/core/http';
2
+ import { FacebookToken, FacebookScopes, LiteralStringUnion, ApiRequestContract, FacebookDriverConfig, FacebookProfileFields, FacebookDriverContract, RedirectRequestContract } from '../types.js';
3
+ import { Oauth2Driver } from '../abstract_drivers/oauth2.js';
4
4
  /**
5
5
  * Facebook driver to login user via Facebook
6
6
  */
@@ -38,7 +38,7 @@ export declare class FacebookDriver extends Oauth2Driver<FacebookToken, Facebook
38
38
  * Scopes separator
39
39
  */
40
40
  protected scopesSeparator: string;
41
- constructor(ctx: HttpContextContract, config: FacebookDriverConfig);
41
+ constructor(ctx: HttpContext, config: FacebookDriverConfig);
42
42
  /**
43
43
  * Configuring the redirect request with defaults
44
44
  */
@@ -1,62 +1,60 @@
1
- "use strict";
2
1
  /*
3
2
  * @adonisjs/ally
4
3
  *
5
- * (c) Harminder Virk <virk@adonisjs.com>
4
+ * (c) AdonisJS
6
5
  *
7
6
  * For the full copyright and license information, please view the LICENSE
8
7
  * file that was distributed with this source code.
9
8
  */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.FacebookDriver = void 0;
12
- const Oauth2_1 = require("../../AbstractDrivers/Oauth2");
9
+ import { Oauth2Driver } from '../abstract_drivers/oauth2.js';
13
10
  /**
14
11
  * Facebook driver to login user via Facebook
15
12
  */
16
- class FacebookDriver extends Oauth2_1.Oauth2Driver {
13
+ export class FacebookDriver extends Oauth2Driver {
14
+ config;
15
+ accessTokenUrl = 'https://graph.facebook.com/v10.0/oauth/access_token';
16
+ authorizeUrl = 'https://www.facebook.com/v10.0/dialog/oauth';
17
+ userInfoUrl = 'https://graph.facebook.com/v10.0/me';
18
+ /**
19
+ * The default set of fields to query for the user request
20
+ */
21
+ userFields = [
22
+ 'name',
23
+ 'first_name',
24
+ 'last_name',
25
+ 'link',
26
+ 'email',
27
+ 'picture.width(400).height(400)',
28
+ 'verified',
29
+ ];
30
+ /**
31
+ * The param name for the authorization code
32
+ */
33
+ codeParamName = 'code';
34
+ /**
35
+ * The param name for the error
36
+ */
37
+ errorParamName = 'error';
38
+ /**
39
+ * Cookie name for storing the "facebok_oauth_state"
40
+ */
41
+ stateCookieName = 'facebok_oauth_state';
42
+ /**
43
+ * Parameter name to be used for sending and receiving the state
44
+ * from Facebok
45
+ */
46
+ stateParamName = 'state';
47
+ /**
48
+ * Parameter name for defining the scopes
49
+ */
50
+ scopeParamName = 'scope';
51
+ /**
52
+ * Scopes separator
53
+ */
54
+ scopesSeparator = ' ';
17
55
  constructor(ctx, config) {
18
56
  super(ctx, config);
19
57
  this.config = config;
20
- this.accessTokenUrl = 'https://graph.facebook.com/v10.0/oauth/access_token';
21
- this.authorizeUrl = 'https://www.facebook.com/v10.0/dialog/oauth';
22
- this.userInfoUrl = 'https://graph.facebook.com/v10.0/me';
23
- /**
24
- * The default set of fields to query for the user request
25
- */
26
- this.userFields = [
27
- 'name',
28
- 'first_name',
29
- 'last_name',
30
- 'link',
31
- 'email',
32
- 'picture.width(400).height(400)',
33
- 'verified',
34
- ];
35
- /**
36
- * The param name for the authorization code
37
- */
38
- this.codeParamName = 'code';
39
- /**
40
- * The param name for the error
41
- */
42
- this.errorParamName = 'error';
43
- /**
44
- * Cookie name for storing the "facebok_oauth_state"
45
- */
46
- this.stateCookieName = 'facebok_oauth_state';
47
- /**
48
- * Parameter name to be used for sending and receiving the state
49
- * from Facebok
50
- */
51
- this.stateParamName = 'state';
52
- /**
53
- * Parameter name for defining the scopes
54
- */
55
- this.scopeParamName = 'scope';
56
- /**
57
- * Scopes separator
58
- */
59
- this.scopesSeparator = ' ';
60
58
  /**
61
59
  * Extremely important to call the following method to clear the
62
60
  * state set by the redirect request
@@ -155,4 +153,3 @@ class FacebookDriver extends Oauth2_1.Oauth2Driver {
155
153
  };
156
154
  }
157
155
  }
158
- exports.FacebookDriver = FacebookDriver;
@@ -1,6 +1,6 @@
1
- import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
2
- import { GithubToken, GithubScopes, GithubDriverConfig, ApiRequestContract, GithubDriverContract, RedirectRequestContract } from '@ioc:Adonis/Addons/Ally';
3
- import { Oauth2Driver } from '../../AbstractDrivers/Oauth2';
1
+ import type { HttpContext } from '@adonisjs/core/http';
2
+ import { GithubToken, GithubScopes, GithubDriverConfig, ApiRequestContract, GithubDriverContract, RedirectRequestContract } from '../types.js';
3
+ import { Oauth2Driver } from '../abstract_drivers/oauth2.js';
4
4
  /**
5
5
  * Github driver to login user via Github
6
6
  */
@@ -35,7 +35,7 @@ export declare class GithubDriver extends Oauth2Driver<GithubToken, GithubScopes
35
35
  * Scopes separator
36
36
  */
37
37
  protected scopesSeparator: string;
38
- constructor(ctx: HttpContextContract, config: GithubDriverConfig);
38
+ constructor(ctx: HttpContext, config: GithubDriverConfig);
39
39
  /**
40
40
  * Configuring the redirect request with defaults
41
41
  */
@@ -1,51 +1,49 @@
1
- "use strict";
2
1
  /*
3
2
  * @adonisjs/ally
4
3
  *
5
- * (c) Harminder Virk <virk@adonisjs.com>
4
+ * (c) AdonisJS
6
5
  *
7
6
  * For the full copyright and license information, please view the LICENSE
8
7
  * file that was distributed with this source code.
9
8
  */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.GithubDriver = void 0;
12
- const Oauth2_1 = require("../../AbstractDrivers/Oauth2");
9
+ import { Oauth2Driver } from '../abstract_drivers/oauth2.js';
13
10
  /**
14
11
  * Github driver to login user via Github
15
12
  */
16
- class GithubDriver extends Oauth2_1.Oauth2Driver {
13
+ export class GithubDriver extends Oauth2Driver {
14
+ config;
15
+ accessTokenUrl = 'https://github.com/login/oauth/access_token';
16
+ authorizeUrl = 'https://github.com/login/oauth/authorize';
17
+ userInfoUrl = 'https://api.github.com/user';
18
+ userEmailUrl = 'https://api.github.com/user/emails';
19
+ /**
20
+ * The param name for the authorization code
21
+ */
22
+ codeParamName = 'code';
23
+ /**
24
+ * The param name for the error
25
+ */
26
+ errorParamName = 'error';
27
+ /**
28
+ * Cookie name for storing the "gh_oauth_state"
29
+ */
30
+ stateCookieName = 'gh_oauth_state';
31
+ /**
32
+ * Parameter name to be used for sending and receiving the state
33
+ * from Github
34
+ */
35
+ stateParamName = 'state';
36
+ /**
37
+ * Parameter name for defining the scopes
38
+ */
39
+ scopeParamName = 'scope';
40
+ /**
41
+ * Scopes separator
42
+ */
43
+ scopesSeparator = ' ';
17
44
  constructor(ctx, config) {
18
45
  super(ctx, config);
19
46
  this.config = config;
20
- this.accessTokenUrl = 'https://github.com/login/oauth/access_token';
21
- this.authorizeUrl = 'https://github.com/login/oauth/authorize';
22
- this.userInfoUrl = 'https://api.github.com/user';
23
- this.userEmailUrl = 'https://api.github.com/user/emails';
24
- /**
25
- * The param name for the authorization code
26
- */
27
- this.codeParamName = 'code';
28
- /**
29
- * The param name for the error
30
- */
31
- this.errorParamName = 'error';
32
- /**
33
- * Cookie name for storing the "gh_oauth_state"
34
- */
35
- this.stateCookieName = 'gh_oauth_state';
36
- /**
37
- * Parameter name to be used for sending and receiving the state
38
- * from Github
39
- */
40
- this.stateParamName = 'state';
41
- /**
42
- * Parameter name for defining the scopes
43
- */
44
- this.scopeParamName = 'scope';
45
- /**
46
- * Scopes separator
47
- */
48
- this.scopesSeparator = ' ';
49
47
  /**
50
48
  * Extremely important to call the following method to clear the
51
49
  * state set by the redirect request
@@ -213,4 +211,3 @@ class GithubDriver extends Oauth2_1.Oauth2Driver {
213
211
  };
214
212
  }
215
213
  }
216
- exports.GithubDriver = GithubDriver;
@@ -1,6 +1,6 @@
1
- import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
2
- import { GoogleToken, GoogleScopes, GoogleDriverConfig, ApiRequestContract, GoogleDriverContract, RedirectRequestContract } from '@ioc:Adonis/Addons/Ally';
3
- import { Oauth2Driver } from '../../AbstractDrivers/Oauth2';
1
+ import type { HttpContext } from '@adonisjs/core/http';
2
+ import { GoogleToken, GoogleScopes, GoogleDriverConfig, ApiRequestContract, GoogleDriverContract, RedirectRequestContract } from '../types.js';
3
+ import { Oauth2Driver } from '../abstract_drivers/oauth2.js';
4
4
  /**
5
5
  * Google driver to login user via Google
6
6
  */
@@ -34,7 +34,7 @@ export declare class GoogleDriver extends Oauth2Driver<GoogleToken, GoogleScopes
34
34
  * Scopes separator
35
35
  */
36
36
  protected scopesSeparator: string;
37
- constructor(ctx: HttpContextContract, config: GoogleDriverConfig);
37
+ constructor(ctx: HttpContext, config: GoogleDriverConfig);
38
38
  /**
39
39
  * Configuring the redirect request with defaults
40
40
  */
@@ -59,6 +59,10 @@ export declare class GoogleDriver extends Oauth2Driver<GoogleToken, GoogleScopes
59
59
  * Find if the current error code is for access denied
60
60
  */
61
61
  accessDenied(): boolean;
62
+ /**
63
+ * Get access token
64
+ */
65
+ accessToken(callback?: (request: ApiRequestContract) => void): Promise<GoogleToken>;
62
66
  /**
63
67
  * Returns details for the authorized user
64
68
  */
@@ -1,15 +1,12 @@
1
- "use strict";
2
1
  /*
3
2
  * @adonisjs/ally
4
3
  *
5
- * (c) Harminder Virk <virk@adonisjs.com>
4
+ * (c) AdonisJS
6
5
  *
7
6
  * For the full copyright and license information, please view the LICENSE
8
7
  * file that was distributed with this source code.
9
8
  */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.GoogleDriver = void 0;
12
- const Oauth2_1 = require("../../AbstractDrivers/Oauth2");
9
+ import { Oauth2Driver } from '../abstract_drivers/oauth2.js';
13
10
  const SCOPE_PREFIXES = {
14
11
  'https://www.googleapis.com/auth': [
15
12
  'userinfo.email',
@@ -50,38 +47,39 @@ const SCOPE_PREFIXES = {
50
47
  /**
51
48
  * Google driver to login user via Google
52
49
  */
53
- class GoogleDriver extends Oauth2_1.Oauth2Driver {
50
+ export class GoogleDriver extends Oauth2Driver {
51
+ config;
52
+ accessTokenUrl = 'https://oauth2.googleapis.com/token';
53
+ authorizeUrl = 'https://accounts.google.com/o/oauth2/v2/auth';
54
+ userInfoUrl = 'https://www.googleapis.com/oauth2/v3/userinfo';
55
+ /**
56
+ * The param name for the authorization code
57
+ */
58
+ codeParamName = 'code';
59
+ /**
60
+ * The param name for the error
61
+ */
62
+ errorParamName = 'error';
63
+ /**
64
+ * Cookie name for storing the "google_oauth_state"
65
+ */
66
+ stateCookieName = 'google_oauth_state';
67
+ /**
68
+ * Parameter name to be used for sending and receiving the state
69
+ * from google
70
+ */
71
+ stateParamName = 'state';
72
+ /**
73
+ * Parameter name for defining the scopes
74
+ */
75
+ scopeParamName = 'scope';
76
+ /**
77
+ * Scopes separator
78
+ */
79
+ scopesSeparator = ' ';
54
80
  constructor(ctx, config) {
55
81
  super(ctx, config);
56
82
  this.config = config;
57
- this.accessTokenUrl = 'https://oauth2.googleapis.com/token';
58
- this.authorizeUrl = 'https://accounts.google.com/o/oauth2/v2/auth';
59
- this.userInfoUrl = 'https://www.googleapis.com/oauth2/v3/userinfo';
60
- /**
61
- * The param name for the authorization code
62
- */
63
- this.codeParamName = 'code';
64
- /**
65
- * The param name for the error
66
- */
67
- this.errorParamName = 'error';
68
- /**
69
- * Cookie name for storing the "google_oauth_state"
70
- */
71
- this.stateCookieName = 'google_oauth_state';
72
- /**
73
- * Parameter name to be used for sending and receiving the state
74
- * from google
75
- */
76
- this.stateParamName = 'state';
77
- /**
78
- * Parameter name for defining the scopes
79
- */
80
- this.scopeParamName = 'scope';
81
- /**
82
- * Scopes separator
83
- */
84
- this.scopesSeparator = ' ';
85
83
  /**
86
84
  * Extremely important to call the following method to clear the
87
85
  * state set by the redirect request
@@ -156,6 +154,16 @@ class GoogleDriver extends Oauth2_1.Oauth2Driver {
156
154
  }
157
155
  return error === 'access_denied';
158
156
  }
157
+ /**
158
+ * Get access token
159
+ */
160
+ async accessToken(callback) {
161
+ const token = await super.accessToken(callback);
162
+ return {
163
+ ...token,
164
+ idToken: token.id_token,
165
+ };
166
+ }
159
167
  /**
160
168
  * Returns details for the authorized user
161
169
  */
@@ -187,4 +195,3 @@ class GoogleDriver extends Oauth2_1.Oauth2Driver {
187
195
  });
188
196
  }
189
197
  }
190
- exports.GoogleDriver = GoogleDriver;
@@ -1,6 +1,6 @@
1
- import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
2
- import { LinkedInToken, LinkedInScopes, ApiRequestContract, LinkedInDriverConfig, LinkedInDriverContract, RedirectRequestContract } from '@ioc:Adonis/Addons/Ally';
3
- import { Oauth2Driver } from '../../AbstractDrivers/Oauth2';
1
+ import type { HttpContext } from '@adonisjs/core/http';
2
+ import { LinkedInToken, LinkedInScopes, ApiRequestContract, LinkedInDriverConfig, LinkedInDriverContract, RedirectRequestContract } from '../types.js';
3
+ import { Oauth2Driver } from '../abstract_drivers/oauth2.js';
4
4
  /**
5
5
  * LinkedIn driver to login user via LinkedIn
6
6
  */
@@ -35,7 +35,7 @@ export declare class LinkedInDriver extends Oauth2Driver<LinkedInToken, LinkedIn
35
35
  * Scopes separator
36
36
  */
37
37
  protected scopesSeparator: string;
38
- constructor(ctx: HttpContextContract, config: LinkedInDriverConfig);
38
+ constructor(ctx: HttpContext, config: LinkedInDriverConfig);
39
39
  /**
40
40
  * Configuring the redirect request with defaults
41
41
  */