-
Notifications
You must be signed in to change notification settings - Fork 292
/
index.js
41 lines (33 loc) · 1.34 KB
/
index.js
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
'use strict';
const Joi = require('joi');
const { Client } = require('./lib/client');
const AuthorizationCodeGrantType = require('./lib/authorization-code-grant-type');
const ResourceOwnerPasswordGrantType = require('./lib/resource-owner-password-grant-type');
const ClientCredentialsGrantType = require('./lib/client-credentials-grant-type');
const { AuthorizationCodeSchema, ClientCredentialsSchema, ResourceOwnerPasswordSchema } = require('./lib/config');
class AuthorizationCode extends AuthorizationCodeGrantType {
constructor(options) {
const config = Joi.attempt(options, AuthorizationCodeSchema, 'Invalid options provided to simple-oauth2');
const client = new Client(config);
super(config, client);
}
}
class ClientCredentials extends ClientCredentialsGrantType {
constructor(options) {
const config = Joi.attempt(options, ClientCredentialsSchema, 'Invalid options provided to simple-oauth2');
const client = new Client(config);
super(config, client);
}
}
class ResourceOwnerPassword extends ResourceOwnerPasswordGrantType {
constructor(options) {
const config = Joi.attempt(options, ResourceOwnerPasswordSchema, 'Invalid options provided to simple-oauth2');
const client = new Client(config);
super(config, client);
}
}
module.exports = {
ResourceOwnerPassword,
ClientCredentials,
AuthorizationCode,
};