Skip to content

Commit 3428ef8

Browse files
[rename-resource-owner-password-grant] Rename resource owner password grant public API
1 parent e48c90f commit 3428ef8

File tree

6 files changed

+29
-29
lines changed

6 files changed

+29
-29
lines changed

API.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Additional options will be automatically serialized as params for the token requ
6060

6161
* `httpOptions` All [wreck](https://github.com/hapijs/wreck) options can be overriden as documented by the module `http` options.
6262

63-
### new PasswordOwner(options)
63+
### new ResourceOwnerPassword(options)
6464
This submodule provides support for the OAuth2 [Resource Owner Password Credentials](https://oauth.net/2/grant-types/password/) grant type.
6565

6666
#### .getToken(params, [httpOptions]) => Promise<AccessToken>

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const config = {
5959
}
6060
};
6161

62-
const { ClientCredentials, PasswordOwner, AuthorizationCode } = require('simple-oauth2');
62+
const { ClientCredentials, ResourceOwnerPassword, AuthorizationCode } = require('simple-oauth2');
6363
```
6464

6565
For a complete reference of configuration options, see the [API Options](./API.md#options)
@@ -109,7 +109,7 @@ The [Resource Owner Password Credentials](https://oauth.net/2/grant-types/passwo
109109

110110
```javascript
111111
async function run() {
112-
const client = new PasswordOwner(config);
112+
const client = new ResourceOwnerPassword(config);
113113

114114
const tokenParams = {
115115
username: 'username',
@@ -127,7 +127,7 @@ async function run() {
127127
run();
128128
```
129129

130-
See the [API reference](./API.md#new-passwordowneroptions) for a complete reference of available options.
130+
See the [API reference](./API.md#new-resourceownerpasswordoptions) for a complete reference of available options.
131131

132132
#### Client Credentials Grant
133133

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const Client = require('./lib/client');
44
const Config = require('./lib/config');
55
const AuthorizationCodeGrant = require('./lib/grants/authorization-code');
6-
const PasswordOwnerGrant = require('./lib/grants/password-owner');
6+
const ResourceOwnerPasswordGrant = require('./lib/grants/resource-owner-password');
77
const ClientCredentialsGrant = require('./lib/grants/client-credentials');
88

99
class AuthorizationCode extends AuthorizationCodeGrant {
@@ -24,7 +24,7 @@ class ClientCredentials extends ClientCredentialsGrant {
2424
}
2525
}
2626

27-
class PasswordOwner extends PasswordOwnerGrant {
27+
class ResourceOwnerPassword extends ResourceOwnerPasswordGrant {
2828
constructor(options) {
2929
const config = Config.apply(options);
3030
const client = new Client(config);
@@ -34,7 +34,7 @@ class PasswordOwner extends PasswordOwnerGrant {
3434
}
3535

3636
module.exports = {
37-
PasswordOwner,
37+
ResourceOwnerPassword,
3838
ClientCredentials,
3939
AuthorizationCode,
4040
};

lib/grants/password-owner.js renamed to lib/grants/resource-owner-password.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const GrantParams = require('../grant-params');
44
const AccessToken = require('../access-token');
55

6-
module.exports = class PasswordOwner {
6+
module.exports = class ResourceOwnerPassword {
77
#config = null;
88
#client = null;
99

test/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
const test = require('ava');
44

5-
const { PasswordOwner, ClientCredentials, AuthorizationCode } = require('../index');
5+
const { ResourceOwnerPassword, ClientCredentials, AuthorizationCode } = require('../index');
66
const { createModuleConfig } = require('./_module-config');
77

88
test('@create => throws a validation error when no configuration is provided', (t) => {
9-
t.throws(() => new PasswordOwner());
9+
t.throws(() => new ResourceOwnerPassword());
1010
t.throws(() => new ClientCredentials());
1111
t.throws(() => new AuthorizationCode());
1212
});
1313

1414
test('@create => creates a new instance with the minimal required configuration', (t) => {
1515
const config = createModuleConfig();
1616

17-
t.notThrows(() => new PasswordOwner(config));
17+
t.notThrows(() => new ResourceOwnerPassword(config));
1818
t.notThrows(() => new ClientCredentials(config));
1919
t.notThrows(() => new AuthorizationCode(config));
2020
});
@@ -27,7 +27,7 @@ test('@create => creates a new instance with empty credentials', (t) => {
2727
},
2828
});
2929

30-
t.notThrows(() => new PasswordOwner(config));
30+
t.notThrows(() => new ResourceOwnerPassword(config));
3131
t.notThrows(() => new ClientCredentials(config));
3232
t.notThrows(() => new AuthorizationCode(config));
3333
});
@@ -40,7 +40,7 @@ test('@create => creates a new instance with visual non-control characters', (t)
4040
},
4141
});
4242

43-
t.notThrows(() => new PasswordOwner(config));
43+
t.notThrows(() => new ResourceOwnerPassword(config));
4444
t.notThrows(() => new ClientCredentials(config));
4545
t.notThrows(() => new AuthorizationCode(config));
4646
});

test/password-owner.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const test = require('ava');
4-
const { PasswordOwner } = require('../index');
4+
const { ResourceOwnerPassword } = require('../index');
55
const AccessToken = require('../lib/access-token');
66
const { createModuleConfig } = require('./_module-config');
77
const {
@@ -36,7 +36,7 @@ test.serial('@getToken => resolves to an access token (body credentials and JSON
3636
password: 'secret',
3737
};
3838

39-
const oauth2 = new PasswordOwner(config);
39+
const oauth2 = new ResourceOwnerPassword(config);
4040
const accessToken = await oauth2.getToken(tokenParams);
4141

4242
scope.done();
@@ -68,7 +68,7 @@ test.serial('@getToken => resolves to an access token (body credentials and form
6868
password: 'secret',
6969
};
7070

71-
const oauth2 = new PasswordOwner(config);
71+
const oauth2 = new ResourceOwnerPassword(config);
7272
const accessToken = await oauth2.getToken(tokenParams);
7373

7474
scope.done();
@@ -97,7 +97,7 @@ test.serial('@getToken => resolves to an access token (header credentials)', asy
9797
password: 'secret',
9898
};
9999

100-
const oauth2 = new PasswordOwner(config);
100+
const oauth2 = new ResourceOwnerPassword(config);
101101
const accessToken = await oauth2.getToken(tokenParams);
102102

103103
scope.done();
@@ -136,7 +136,7 @@ test.serial('@getToken => resolves to an access token with custom module configu
136136
password: 'secret',
137137
};
138138

139-
const oauth2 = new PasswordOwner(config);
139+
const oauth2 = new ResourceOwnerPassword(config);
140140
const accessToken = await oauth2.getToken(tokenParams);
141141

142142
scope.done();
@@ -175,7 +175,7 @@ test.serial('@getToken => resolves to an access token with custom module configu
175175
password: 'secret',
176176
};
177177

178-
const oauth2 = new PasswordOwner(config);
178+
const oauth2 = new ResourceOwnerPassword(config);
179179
const accessToken = await oauth2.getToken(tokenParams);
180180

181181
scope.done();
@@ -205,7 +205,7 @@ test.serial('@getToken => resolves to an access token with custom module configu
205205
password: 'secret',
206206
};
207207

208-
const oauth2 = new PasswordOwner(config);
208+
const oauth2 = new ResourceOwnerPassword(config);
209209
const accessToken = await oauth2.getToken(tokenParams);
210210

211211
scope.done();
@@ -243,7 +243,7 @@ test.serial('@getToken => resolves to an access token with custom module configu
243243
password: 'secret',
244244
};
245245

246-
const oauth2 = new PasswordOwner(config);
246+
const oauth2 = new ResourceOwnerPassword(config);
247247
const accessToken = await oauth2.getToken(tokenParams);
248248

249249
scope.done();
@@ -274,7 +274,7 @@ test.serial('@getToken => resolves to an access token with custom module configu
274274
},
275275
});
276276

277-
const oauth2 = new PasswordOwner(config);
277+
const oauth2 = new ResourceOwnerPassword(config);
278278

279279
const accessToken = await oauth2.getToken(tokenParams);
280280

@@ -301,7 +301,7 @@ test.serial('@getToken => resolves to an access token while following redirectio
301301
};
302302

303303
const config = createModuleConfig();
304-
const oauth2 = new PasswordOwner(config);
304+
const oauth2 = new ResourceOwnerPassword(config);
305305

306306
const accessToken = await oauth2.getToken(tokenParams);
307307

@@ -330,7 +330,7 @@ test.serial('@getToken => resolves to an access token while requesting multiple
330330
};
331331

332332
const config = createModuleConfig();
333-
const oauth2 = new PasswordOwner(config);
333+
const oauth2 = new ResourceOwnerPassword(config);
334334

335335
const accessToken = await oauth2.getToken(tokenParams);
336336

@@ -356,7 +356,7 @@ test.serial('@getToken => resolves to an access token with a custom grant type',
356356
};
357357

358358
const config = createModuleConfig();
359-
const oauth2 = new PasswordOwner(config);
359+
const oauth2 = new ResourceOwnerPassword(config);
360360

361361
const accessToken = await oauth2.getToken(tokenParams);
362362

@@ -374,7 +374,7 @@ test.serial('@getToken => resolves to an access token with no params', async (t)
374374
const scope = server.tokenSuccess(scopeOptions, tokenRequestParams);
375375

376376
const config = createModuleConfig();
377-
const oauth2 = new PasswordOwner(config);
377+
const oauth2 = new ResourceOwnerPassword(config);
378378

379379
const accessToken = await oauth2.getToken();
380380

@@ -397,7 +397,7 @@ test.serial('@getToken => resolves to an access token with custom (inline) http
397397
const scope = server.tokenSuccess(scopeOptions, tokenRequestParams);
398398

399399
const config = createModuleConfig();
400-
const oauth2 = new PasswordOwner(config);
400+
const oauth2 = new ResourceOwnerPassword(config);
401401

402402
const httpOptions = {
403403
headers: {
@@ -421,7 +421,7 @@ test.serial('@getToken => resolves to an access token with custom (inline) http
421421
const scope = server.tokenSuccess(scopeOptions, tokenRequestParams);
422422

423423
const config = createModuleConfig();
424-
const oauth2 = new PasswordOwner(config);
424+
const oauth2 = new ResourceOwnerPassword(config);
425425

426426
const httpOptions = {
427427
headers: {
@@ -460,7 +460,7 @@ test.serial('@getToken => rejects the operation when a non json response is rece
460460
password: 'secret',
461461
};
462462

463-
const oauth2 = new PasswordOwner(config);
463+
const oauth2 = new ResourceOwnerPassword(config);
464464
const error = await t.throwsAsync(() => oauth2.getToken(tokenParams));
465465

466466
scope.done();

0 commit comments

Comments
 (0)