Skip to content

Commit c9b59ed

Browse files
committed
cleanup names
1 parent 8606b80 commit c9b59ed

5 files changed

Lines changed: 48 additions & 48 deletions

File tree

‎sample/public/user-manager-sample.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ var user = null;
4646
///////////////////////////////
4747
// events
4848
///////////////////////////////
49-
mgr.events.addExpiring(function () {
49+
mgr.events.addAccessTokenExpiring(function () {
5050
console.log("token expiring");
5151
log("token expiring");
5252
});
5353

54-
mgr.events.addExpired(function () {
54+
mgr.events.addAccessTokenExpired(function () {
5555
console.log("token expired");
5656
log("token expired");
5757
});

‎src/AccessTokenEvents.js‎

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
import Log from './Log';
55
import Timer from './Timer';
66

7-
const DefaultExpiringNotificationTime = 60;
7+
const DefaultAccessTokenExpiringNotificationTime = 60;
88

99
export default class AccessTokenEvents {
1010

1111
constructor({
12-
expiringNotificationTime = DefaultExpiringNotificationTime,
13-
expiringTimer = new Timer(),
14-
expiredTimer = new Timer()
12+
accessTokenExpiringNotificationTime = DefaultAccessTokenExpiringNotificationTime,
13+
accessTokenExpiringTimer = new Timer(),
14+
accessTokenExpiredTimer = new Timer()
1515
} = {}) {
16-
this._expiringNotificationTime = expiringNotificationTime;
16+
this._accessTokenExpiringNotificationTime = accessTokenExpiringNotificationTime;
1717

18-
this._expiring = expiringTimer;
19-
this._expired = expiredTimer;
18+
this._accessTokenExpiring = accessTokenExpiringTimer;
19+
this._accessTokenExpired = accessTokenExpiredTimer;
2020
}
2121

2222
init(container) {
@@ -30,38 +30,38 @@ export default class AccessTokenEvents {
3030

3131
if (duration > 0) {
3232
// only register expiring if we still have time
33-
let expiring = duration - this._expiringNotificationTime;
33+
let expiring = duration - this._accessTokenExpiringNotificationTime;
3434
if (expiring <= 0){
3535
expiring = 1;
3636
}
3737
Log.info("registering expiring timer in:", expiring);
38-
this._expiring.init(expiring);
38+
this._accessTokenExpiring.init(expiring);
3939
}
4040

4141
// always register expired. if it's negative, it will still fire
4242
let expired = duration + 1;
4343
Log.info("registering expired timer in:", expired);
44-
this._expired.init(expired);
44+
this._accessTokenExpired.init(expired);
4545
}
4646
}
4747

4848
cancel() {
4949
Log.info("AccessTokenEvents.canceling timers");
50-
this._expiring.cancel();
51-
this._expired.cancel();
50+
this._accessTokenExpiring.cancel();
51+
this._accessTokenExpired.cancel();
5252
}
5353

54-
addExpiring(cb) {
55-
this._expiring.addHandler(cb);
54+
addAccessTokenExpiring(cb) {
55+
this._accessTokenExpiring.addHandler(cb);
5656
}
57-
removeExpiring(cb) {
58-
this._expiring.removeHandler(cb);
57+
removeAccessTokenExpiring(cb) {
58+
this._accessTokenExpiring.removeHandler(cb);
5959
}
6060

61-
addExpired(cb) {
62-
this._expired.addHandler(cb);
61+
addAccessTokenExpired(cb) {
62+
this._accessTokenExpired.addHandler(cb);
6363
}
64-
removeExpired(cb) {
65-
this._expired.removeHandler(cb);
64+
removeAccessTokenExpired(cb) {
65+
this._accessTokenExpired.removeHandler(cb);
6666
}
6767
}

‎src/UserManagerSettings.js‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44
import Log from './Log';
55
import OidcClientSettings from './OidcClientSettings';
66

7-
const DefaultExpiringNotificationTime = 60;
7+
const DefaultAccessTokenExpiringNotificationTime = 60;
88

99
export default class UserManagerSettings extends OidcClientSettings {
1010
constructor({
1111
popup_redirect_uri,
1212
silent_redirect_uri,
1313
enableAutomaticSilentRenew = true,
14-
expiringNotificationTime = DefaultExpiringNotificationTime
14+
accessTokenExpiringNotificationTime = DefaultAccessTokenExpiringNotificationTime
1515
} = {}) {
1616
super(arguments[0]);
1717

1818
this._popup_redirect_uri = popup_redirect_uri;
1919
this._silent_redirect_uri = silent_redirect_uri;
2020
this._enableAutomaticSilentRenew = !!enableAutomaticSilentRenew;
21-
this._expiringNotificationTime = expiringNotificationTime;
21+
this._accessTokenExpiringNotificationTime = accessTokenExpiringNotificationTime;
2222
}
2323

2424
get popup_redirect_uri(){
@@ -32,7 +32,7 @@ export default class UserManagerSettings extends OidcClientSettings {
3232
return !!(this.silent_redirect_uri && this._enableAutomaticSilentRenew);
3333
}
3434

35-
get expiringNotificationTime(){
36-
return this._expiringNotificationTime;
35+
get accessTokenExpiringNotificationTime(){
36+
return this._accessTokenExpiringNotificationTime;
3737
}
3838
}

‎test/unit/AccessTokenEvents.spec.js‎

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,21 @@ class StubTimer {
2828
describe("AccessTokenEvents", function () {
2929

3030
let subject;
31-
let expiringTimer;
32-
let expiredTimer;
31+
let accessTokenExpiringTimer;
32+
let accessTokenExpiredTimer;
3333

3434
beforeEach(function () {
35-
expiringTimer = new StubTimer();
36-
expiredTimer = new StubTimer();
35+
accessTokenExpiringTimer = new StubTimer();
36+
accessTokenExpiredTimer = new StubTimer();
3737
subject = new AccessTokenEvents({
38-
expiredTimer, expiringTimer
38+
accessTokenExpiringTimer, accessTokenExpiredTimer
3939
});
4040
});
4141

4242
describe("constructor", function () {
4343

4444
it("should use default expiringNotificationTime", function () {
45-
subject._expiringNotificationTime.should.equal(60);
45+
subject._accessTokenExpiringNotificationTime.should.equal(60);
4646
});
4747

4848
});
@@ -52,8 +52,8 @@ describe("AccessTokenEvents", function () {
5252
it("should cancel existing timers", function () {
5353
subject.init({});
5454

55-
expiringTimer.cancelWasCalled.should.be.true;
56-
expiredTimer.cancelWasCalled.should.be.true;
55+
accessTokenExpiringTimer.cancelWasCalled.should.be.true;
56+
accessTokenExpiredTimer.cancelWasCalled.should.be.true;
5757
});
5858

5959
it("should initialize timers", function () {
@@ -62,8 +62,8 @@ describe("AccessTokenEvents", function () {
6262
expires_in : 70
6363
});
6464

65-
expiringTimer.duration.should.equal(10);
66-
expiredTimer.duration.should.equal(71);
65+
accessTokenExpiringTimer.duration.should.equal(10);
66+
accessTokenExpiredTimer.duration.should.equal(71);
6767
});
6868

6969
it("should immediately schedule expiring timer if expiration is soon", function () {
@@ -72,7 +72,7 @@ describe("AccessTokenEvents", function () {
7272
expires_in : 10
7373
});
7474

75-
expiringTimer.duration.should.equal(1);
75+
accessTokenExpiringTimer.duration.should.equal(1);
7676
});
7777

7878
it("should not initialize expiring timer if already expired", function () {
@@ -81,7 +81,7 @@ describe("AccessTokenEvents", function () {
8181
expires_in : 0
8282
});
8383

84-
assert.isUndefined(expiringTimer.duration);
84+
assert.isUndefined(accessTokenExpiringTimer.duration);
8585
});
8686

8787
it("should initialize expired timer if already expired", function () {
@@ -90,16 +90,16 @@ describe("AccessTokenEvents", function () {
9090
expires_in : 0
9191
});
9292

93-
expiredTimer.duration.should.equal(1);
93+
accessTokenExpiredTimer.duration.should.equal(1);
9494
});
9595

9696
it("should not initialize timers if no access token", function () {
9797
subject.init({
9898
expires_in : 70
9999
});
100100

101-
assert.isUndefined(expiringTimer.duration);
102-
assert.isUndefined(expiredTimer.duration);
101+
assert.isUndefined(accessTokenExpiringTimer.duration);
102+
assert.isUndefined(accessTokenExpiredTimer.duration);
103103
});
104104

105105
});
@@ -110,8 +110,8 @@ describe("AccessTokenEvents", function () {
110110

111111
subject.cancel();
112112

113-
expiringTimer.cancelWasCalled.should.be.true;
114-
expiredTimer.cancelWasCalled.should.be.true;
113+
accessTokenExpiringTimer.cancelWasCalled.should.be.true;
114+
accessTokenExpiredTimer.cancelWasCalled.should.be.true;
115115
});
116116

117117
});

‎test/unit/UserManagerSettings.spec.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,19 @@ describe("UserManagerSettings", function () {
7272

7373
});
7474

75-
describe("expiringNotificationTime", function () {
75+
describe("accessTokenExpiringNotificationTime", function () {
7676

7777
it("should return value from initial settings", function () {
7878
let subject = new UserManagerSettings({
79-
expiringNotificationTime: 10
79+
accessTokenExpiringNotificationTime: 10
8080
});
81-
subject.expiringNotificationTime.should.equal(10);
81+
subject.accessTokenExpiringNotificationTime.should.equal(10);
8282
});
8383

8484
it("should use default value", function () {
8585
let subject = new UserManagerSettings({
8686
});
87-
subject.expiringNotificationTime.should.equal(60);
87+
subject.accessTokenExpiringNotificationTime.should.equal(60);
8888
});
8989

9090
});

0 commit comments

Comments
 (0)