MCPcopy
hub / github.com/authts/oidc-client-ts / load

Method load

src/AccessTokenEvents.ts:26–57  ·  view source on GitHub ↗
(container: User)

Source from the content-addressed store, hash-verified

24 }
25
26 public async load(container: User): Promise<void> {
27 const logger = this._logger.create("load");
28 // only register events if there's an access token and it has an expiration
29 if (container.access_token && container.expires_in !== undefined) {
30 const duration = container.expires_in;
31 logger.debug("access token present, remaining duration:", duration);
32
33 if (duration > 0) {
34 // only register expiring if we still have time
35 let expiring = duration - this._expiringNotificationTimeInSeconds;
36 if (expiring <= 0) {
37 expiring = 1;
38 }
39
40 logger.debug("registering expiring timer, raising in", expiring, "seconds");
41 this._expiringTimer.init(expiring);
42 }
43 else {
44 logger.debug("canceling existing expiring timer because we're past expiration.");
45 this._expiringTimer.cancel();
46 }
47
48 // if it's negative, it will still fire
49 const expired = duration + 1;
50 logger.debug("registering expired timer, raising in", expired, "seconds");
51 this._expiredTimer.init(expired);
52 }
53 else {
54 this._expiringTimer.cancel();
55 this._expiredTimer.cancel();
56 }
57 }
58
59 public async unload(): Promise<void> {
60 this._logger.debug("unload: canceling existing access token timers");

Callers 8

getUserMethod · 0.45
_useRefreshTokenMethod · 0.45
_buildUserMethod · 0.45
_revokeInternalMethod · 0.45
SessionMonitorClass · 0.45

Calls 4

debugMethod · 0.65
createMethod · 0.45
initMethod · 0.45
cancelMethod · 0.45

Tested by

no test coverage detected