MCPcopy Index your code
hub / github.com/di-sukharev/opencommit / refresh

Function refresh

out/cli.cjs:77028–77050  ·  view source on GitHub ↗
(scopes, getTokenOptions)

Source from the content-addressed store, hash-verified

77026 /**
77027 * Produces true if the cycler MUST refresh (null or nearly-expired
77028 * token).
77029 */
77030 get mustRefresh() {
77031 return token === null || token.expiresOnTimestamp - options.forcedRefreshWindowInMs < Date.now();
77032 }
77033 };
77034 function refresh(scopes, getTokenOptions) {
77035 var _a5;
77036 if (!cycler.isRefreshing) {
77037 const tryGetAccessToken = () => credential.getToken(scopes, getTokenOptions);
77038 refreshWorker = beginRefresh(
77039 tryGetAccessToken,
77040 options.retryIntervalInMs,
77041 // If we don't have a token, then we should timeout immediately
77042 (_a5 = token === null || token === void 0 ? void 0 : token.expiresOnTimestamp) !== null && _a5 !== void 0 ? _a5 : Date.now()
77043 ).then((_token) => {
77044 refreshWorker = null;
77045 token = _token;
77046 tenantId = getTokenOptions.tenantId;
77047 return token;
77048 }).catch((reason) => {
77049 refreshWorker = null;
77050 token = null;
77051 tenantId = void 0;
77052 throw reason;
77053 });

Callers 1

createTokenCyclerFunction · 0.85

Calls 3

beginRefreshFunction · 0.85
thenMethod · 0.80
catchMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…