-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathbase.js
More file actions
50 lines (45 loc) · 1.66 KB
/
base.js
File metadata and controls
50 lines (45 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
'use strict';
// Default provider: generic OIDC / unknown OAuth2. Also acts as the fallback
// base for providers that only override a subset of hooks.
//
// Every provider module exports the following shape (all fields optional
// except `type` and `parse`):
//
// {
// type: 'github', // lowercase identifier
// pkceDefault: false, // force PKCE on by default
// skipUserRoute: false, // skip userinfo HTTP call
// matches({ host, name, profile }) -> bool, // auto-detection heuristic
// userRouteHeaders() -> object, // extra headers for userinfo
// parse(rawProfile, { idKey }) -> normalized,// shape the profile
// fetchEmail({ strategyConfig, accessToken }) -> { email, verified } | null
// }
module.exports = {
type: 'oidc',
// The generic provider is the fallback; it never claims a match itself.
matches() {
return false;
},
parse(profile, { idKey } = {}) {
const {
id, sub,
name, nickname, preferred_username: preferredUsername, login,
given_name: givenName, middle_name: middleName, family_name: familyName,
picture, avatar_url: avatarUrl, email, email_verified: emailVerified,
} = profile;
const displayName = nickname || preferredUsername || login || name;
const combined = [givenName, middleName, familyName].filter(Boolean).join(' ');
return {
id: (idKey && profile[idKey]) || id || sub,
displayName,
fullname: name || combined || displayName,
picture: picture || avatarUrl,
email,
email_verified: emailVerified,
username: login || preferredUsername || nickname,
};
},
async fetchEmail() {
return null;
},
};