@adonisjs/ally 5.0.0-6 → 5.0.0-8

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 (49) hide show
  1. package/README.md +5 -8
  2. package/build/chunk-CSAU5B4Q.js +10 -0
  3. package/build/chunk-CSAU5B4Q.js.map +1 -0
  4. package/build/chunk-OSVNBZ7V.js +164 -0
  5. package/build/chunk-OSVNBZ7V.js.map +1 -0
  6. package/build/chunk-UF7PETXM.js +83 -0
  7. package/build/chunk-UF7PETXM.js.map +1 -0
  8. package/build/chunk-UIZWPBWM.js +38 -0
  9. package/build/chunk-UIZWPBWM.js.map +1 -0
  10. package/build/chunk-Y3GA4Y2H.js +170 -0
  11. package/build/chunk-Y3GA4Y2H.js.map +1 -0
  12. package/build/discord-NGJGLGX7.js +136 -0
  13. package/build/discord-NGJGLGX7.js.map +1 -0
  14. package/build/facebook-WTZGLDH5.js +137 -0
  15. package/build/facebook-WTZGLDH5.js.map +1 -0
  16. package/build/github-24BPMULZ.js +173 -0
  17. package/build/github-24BPMULZ.js.map +1 -0
  18. package/build/google-NMLTQESR.js +184 -0
  19. package/build/google-NMLTQESR.js.map +1 -0
  20. package/build/index.d.ts +0 -1
  21. package/build/index.js +151 -17
  22. package/build/index.js.map +1 -0
  23. package/build/linked_in-HIRSEAEP.js +153 -0
  24. package/build/linked_in-HIRSEAEP.js.map +1 -0
  25. package/build/providers/ally_provider.js +33 -36
  26. package/build/providers/ally_provider.js.map +1 -0
  27. package/build/spotify-ESJDFUD6.js +118 -0
  28. package/build/spotify-ESJDFUD6.js.map +1 -0
  29. package/build/twitter-QISDDK24.js +101 -0
  30. package/build/twitter-QISDDK24.js.map +1 -0
  31. package/package.json +45 -33
  32. package/build/configure.js +0 -48
  33. package/build/src/abstract_drivers/oauth1.js +0 -188
  34. package/build/src/abstract_drivers/oauth2.js +0 -175
  35. package/build/src/ally_manager.js +0 -40
  36. package/build/src/debug.js +0 -10
  37. package/build/src/define_config.js +0 -75
  38. package/build/src/drivers/discord.js +0 -156
  39. package/build/src/drivers/facebook.js +0 -155
  40. package/build/src/drivers/github.js +0 -213
  41. package/build/src/drivers/google.js +0 -197
  42. package/build/src/drivers/linked_in.js +0 -166
  43. package/build/src/drivers/spotify.js +0 -130
  44. package/build/src/drivers/twitter.js +0 -117
  45. package/build/src/errors.js +0 -11
  46. package/build/src/redirect_request.js +0 -63
  47. package/build/src/types.js +0 -9
  48. package/build/stubs/main.js +0 -10
  49. /package/build/{stubs/config.stub → config/ally.stub} +0 -0
@@ -1,117 +0,0 @@
1
- /*
2
- * @adonisjs/ally
3
- *
4
- * (c) AdonisJS
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 { Oauth1Driver } from '../abstract_drivers/oauth1.js';
10
- /**
11
- * Twitter driver to login user via twitter
12
- */
13
- export class TwitterDriver extends Oauth1Driver {
14
- ctx;
15
- config;
16
- requestTokenUrl = 'https://api.twitter.com/oauth/request_token';
17
- authorizeUrl = 'https://api.twitter.com/oauth/authenticate';
18
- accessTokenUrl = 'https://api.twitter.com/oauth/access_token';
19
- userInfoUrl = 'https://api.twitter.com/1.1/account/verify_credentials.json';
20
- /**
21
- * The query string param name for the error.
22
- */
23
- errorParamName = 'error';
24
- /**
25
- * The query string param name for the "oauth_verifier". Used
26
- * for both the post redirect value access and during the
27
- * time of generating the access token
28
- */
29
- oauthTokenVerifierName = 'oauth_verifier';
30
- /**
31
- * Cookie name for storing the oauth_token. The cookie
32
- * name for storing oauth_token_secret is derived
33
- * from this property
34
- */
35
- oauthTokenCookieName = 'twitter_oauth_token';
36
- /**
37
- * Param name for defined the "oauth_token" pre redirect
38
- * and also used post redirect for reading the "oauth_token"
39
- * value
40
- */
41
- oauthTokenParamName = 'oauth_token';
42
- /**
43
- * Twitter doesn't support scopes
44
- */
45
- scopeParamName = '';
46
- scopesSeparator = ' ';
47
- constructor(ctx, config) {
48
- super(ctx, config);
49
- this.ctx = ctx;
50
- this.config = config;
51
- /**
52
- * Extremely important to call the following method to clear the
53
- * state set by the redirect request
54
- */
55
- this.loadState();
56
- }
57
- /**
58
- * Returns user info
59
- */
60
- async getUserInfo(token, secret, callback) {
61
- const requestToken = { token, secret };
62
- const userInfoUrl = this.config.userInfoUrl || this.userInfoUrl;
63
- const user = await this.makeSignedRequest(userInfoUrl, 'get', requestToken, (request) => {
64
- /**
65
- * Include email
66
- */
67
- request.param('include_email', true);
68
- /**
69
- * Parse response as JSON
70
- */
71
- request['parseAs']('json');
72
- /**
73
- * Invoke user callback
74
- */
75
- if (typeof callback === 'function') {
76
- callback(request);
77
- }
78
- });
79
- return {
80
- id: user.id_str,
81
- nickName: user.screen_name,
82
- name: user.name || user.screen_name,
83
- email: user.email,
84
- emailVerificationState: 'unsupported',
85
- avatarUrl: user.profile_image_url_https.replace('_normal.jpg', '_400x400.jpg'),
86
- original: user,
87
- };
88
- }
89
- /**
90
- * Returns details for the authorized user
91
- */
92
- async user(callback) {
93
- const token = await this.accessToken();
94
- const userInfo = await this.getUserInfo(token.token, token.secret, callback);
95
- return {
96
- ...userInfo,
97
- token,
98
- };
99
- }
100
- /**
101
- * Finds the user info from the "oauth_token" and "oauth_token_secret"
102
- * access from the access token.
103
- */
104
- async userFromTokenAndSecret(token, secret, callback) {
105
- const userInfo = await this.getUserInfo(token, secret, callback);
106
- return {
107
- ...userInfo,
108
- token: { token, secret },
109
- };
110
- }
111
- /**
112
- * Find if the current error code is for access denied
113
- */
114
- accessDenied() {
115
- return this.ctx.request.input('denied');
116
- }
117
- }
@@ -1,11 +0,0 @@
1
- /*
2
- * @adonisjs/ally
3
- *
4
- * (c) AdonisJS
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 { createError } from '@poppinss/utils';
10
- export const E_OAUTH_MISSING_CODE = createError('Cannot request access token. Redirect request is missing the "%s" param', 'E_OAUTH_MISSING_CODE', 500);
11
- export const E_OAUTH_STATE_MISMATCH = createError('Unable to verify re-redirect state', 'E_OAUTH_STATE_MISMATCH', 400);
@@ -1,63 +0,0 @@
1
- /*
2
- * @adonisjs/ally
3
- *
4
- * (c) AdonisJS
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 { UrlBuilder } from '@poppinss/oauth-client';
10
- /**
11
- * Redirect request with first class support for defining scopes.
12
- */
13
- export class RedirectRequest extends UrlBuilder {
14
- #scopesTransformer;
15
- #scopeParamName;
16
- #scopeSeparator;
17
- constructor(baseUrl, scopeParamName, scopeSeparator) {
18
- super(baseUrl);
19
- this.#scopeParamName = scopeParamName;
20
- this.#scopeSeparator = scopeSeparator;
21
- }
22
- /**
23
- * Register a custom function to transform scopes. Exposed for drivers
24
- * to implement.
25
- */
26
- transformScopes(callback) {
27
- this.#scopesTransformer = callback;
28
- return this;
29
- }
30
- /**
31
- * Define an array of scopes.
32
- */
33
- scopes(scopes) {
34
- if (typeof this.#scopesTransformer === 'function') {
35
- scopes = this.#scopesTransformer(scopes);
36
- }
37
- this.param(this.#scopeParamName, scopes.join(this.#scopeSeparator));
38
- return this;
39
- }
40
- /**
41
- * Merge to existing scopes
42
- */
43
- mergeScopes(scopes) {
44
- if (typeof this.#scopesTransformer === 'function') {
45
- scopes = this.#scopesTransformer(scopes);
46
- }
47
- const existingScopes = this.getParams()[this.#scopeParamName];
48
- const scopesString = scopes.join(this.#scopeSeparator);
49
- if (!existingScopes) {
50
- this.param(this.#scopeParamName, scopesString);
51
- return this;
52
- }
53
- this.param(this.#scopeParamName, `${existingScopes}${this.#scopeSeparator}${scopesString}`);
54
- return this;
55
- }
56
- /**
57
- * Clear existing scopes
58
- */
59
- clearScopes() {
60
- this.clearParam(this.#scopeParamName);
61
- return this;
62
- }
63
- }
@@ -1,9 +0,0 @@
1
- /*
2
- * @adonisjs/ally
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- export {};
@@ -1,10 +0,0 @@
1
- /*
2
- * @adonisjs/ally
3
- *
4
- * (c) AdonisJS
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 { getDirname } from '@poppinss/utils';
10
- export const stubsRoot = getDirname(import.meta.url);
File without changes