@hapi/bell 13.0.2 → 13.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/lib/index.d.ts CHANGED
@@ -30,7 +30,6 @@ export type Provider =
30
30
  | 'live'
31
31
  | 'medium'
32
32
  | 'meetup'
33
- | 'mixer'
34
33
  | 'nest'
35
34
  | 'okta'
36
35
  | 'phabricator'
@@ -125,6 +124,12 @@ export interface OptionalOptions {
125
124
  | { extendedProfile?: boolean | undefined; getMethod?: string | undefined }
126
125
  | { uri?: string | undefined }
127
126
  | undefined;
127
+ /**
128
+ * provider-specific query parameters for the token endpoint.
129
+ * It may be passed either as an object to merge into the query string,
130
+ * or a function which takes the client's request and returns an object.
131
+ */
132
+ tokenParams?: StringLikeMap | ((request: Request) => StringLikeMap) | undefined;
128
133
  /**
129
134
  * an object of key-value pairs that specify additional
130
135
  * URL query parameters to send with the profile request to the provider.
package/lib/index.js CHANGED
@@ -104,6 +104,8 @@ internals.schema = Joi.object({
104
104
 
105
105
  config: Joi.object(),
106
106
 
107
+ tokenParams: Joi.alternatives(Joi.object(), Joi.func()),
108
+
107
109
  profileParams: Joi.object(),
108
110
 
109
111
  skipProfile: internals.flexBoolean.optional().default(false),
package/lib/oauth.js CHANGED
@@ -72,12 +72,11 @@ exports.v1 = function (settings) {
72
72
 
73
73
  h.state(cookie, state);
74
74
 
75
- const authQuery = internals.resolveProviderParams(request, settings.providerParams);
76
- authQuery.oauth_token = temp.oauth_token;
77
-
78
- if (settings.allowRuntimeProviderParams) {
79
- Hoek.merge(authQuery, request.query);
80
- }
75
+ const authQuery = {
76
+ ...internals.resolveProviderParams(request, settings.providerParams),
77
+ oauth_token: temp.oauth_token,
78
+ ...(settings.allowRuntimeProviderParams && request.query)
79
+ };
81
80
 
82
81
  return h.redirect(settings.provider.auth + '?' + internals.queryString(authQuery)).takeover();
83
82
  }
@@ -123,7 +122,7 @@ exports.v1 = function (settings) {
123
122
  const get = async (uri, params = {}) => {
124
123
 
125
124
  if (settings.profileParams) {
126
- Hoek.merge(params, settings.profileParams);
125
+ Object.assign(params, settings.profileParams);
127
126
  }
128
127
 
129
128
  const { payload: resource } = await client.resource('get', uri, params, { token: token.oauth_token, secret: token.oauth_token_secret });
@@ -178,16 +177,14 @@ exports.v2 = function (settings) {
178
177
  credentials.query = request.query;
179
178
 
180
179
  const nonce = Cryptiles.randomAlphanumString(internals.nonceLength);
181
- const query = internals.resolveProviderParams(request, settings.providerParams);
182
-
183
- if (settings.allowRuntimeProviderParams) {
184
- Hoek.merge(query, request.query);
185
- }
186
-
187
- query.client_id = settings.clientId;
188
- query.response_type = 'code';
189
- query.redirect_uri = internals.location(request, protocol, settings.location);
190
- query.state = nonce;
180
+ const query = {
181
+ ...internals.resolveProviderParams(request, settings.providerParams),
182
+ ...(settings.allowRuntimeProviderParams && request.query),
183
+ client_id: settings.clientId,
184
+ response_type: 'code',
185
+ redirect_uri: internals.location(request, protocol, settings.location),
186
+ state: nonce
187
+ };
191
188
 
192
189
  if (settings.runtimeStateCallback) {
193
190
  const runtimeState = settings.runtimeStateCallback(request);
@@ -251,7 +248,8 @@ exports.v2 = function (settings) {
251
248
  const query = {
252
249
  grant_type: 'authorization_code',
253
250
  code: request.query.code,
254
- redirect_uri: internals.location(request, protocol, settings.location)
251
+ redirect_uri: internals.location(request, protocol, settings.location),
252
+ ...internals.resolveProviderParams(request, settings.tokenParams)
255
253
  };
256
254
 
257
255
  if (settings.provider.pkce) {
@@ -731,6 +729,5 @@ internals.getProtocol = function (request, settings) {
731
729
 
732
730
  internals.resolveProviderParams = function (request, params) {
733
731
 
734
- const obj = typeof params === 'function' ? params(request) : params;
735
- return obj ? Hoek.clone(obj) : {};
732
+ return (typeof params === 'function' ? params(request) : params) ?? {};
736
733
  };
@@ -25,7 +25,6 @@ exports = module.exports = {
25
25
  live: require('./live'),
26
26
  medium: require('./medium'),
27
27
  meetup: require('./meetup'),
28
- mixer: require('./mixer'),
29
28
  nest: require('./nest'),
30
29
  okta: require('./okta'),
31
30
  phabricator: require('./phabricator'),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hapi/bell",
3
3
  "description": "Third-party login plugin for hapi",
4
- "version": "13.0.2",
4
+ "version": "13.1.0",
5
5
  "repository": "git://github.com/hapijs/bell",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
@@ -59,7 +59,7 @@
59
59
  },
60
60
  "devDependencies": {
61
61
  "@hapi/code": "^9.0.3",
62
- "@hapi/eslint-plugin": "*",
62
+ "@hapi/eslint-plugin": "^6.0.0",
63
63
  "@hapi/hapi": "^21.2.1",
64
64
  "@hapi/hawk": "^8.0.0",
65
65
  "@hapi/lab": "^25.0.1",
@@ -1,25 +0,0 @@
1
- 'use strict';
2
-
3
- const internals = {};
4
-
5
-
6
- exports = module.exports = function (options) {
7
-
8
- return {
9
- protocol: 'oauth2',
10
- useParamsAuth: true,
11
- auth: 'https://mixer.com/oauth/authorize',
12
- token: 'https://mixer.com/api/v1/oauth/token',
13
- scope: ['user:details:self'],
14
- scopeSeparator: ' ',
15
- profile: async function (credentials, params, get) {
16
-
17
- const queryOptions = {
18
- oauth_token: params.access_token
19
- };
20
-
21
- const profile = await get('https://mixer.com/api/v1/users/current', queryOptions);
22
- credentials.profile = profile;
23
- }
24
- };
25
- };