@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 +6 -1
- package/lib/index.js +2 -0
- package/lib/oauth.js +17 -20
- package/lib/providers/index.js +0 -1
- package/package.json +2 -2
- package/lib/providers/mixer.js +0 -25
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
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 =
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
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
|
-
|
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 =
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
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
|
-
|
735
|
-
return obj ? Hoek.clone(obj) : {};
|
732
|
+
return (typeof params === 'function' ? params(request) : params) ?? {};
|
736
733
|
};
|
package/lib/providers/index.js
CHANGED
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
|
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",
|
package/lib/providers/mixer.js
DELETED
@@ -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
|
-
};
|