Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use null prototype for map values #622

Merged
merged 2 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"packages": ["packages/*"],
"useWorkspaces": true,
"version": "3.1.0-alpha.52",
"npmClient": "npm"
}
23 changes: 12 additions & 11 deletions packages/http-proxy-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export default class AuthXClientProxy extends EventEmitter {
[refreshToken: string]: {
[hash: string]: string;
};
} = {};
} = Object.create(null);

/**
* A request fetches fresh access tokens from AuthX.
Expand All @@ -208,7 +208,7 @@ export default class AuthXClientProxy extends EventEmitter {
timeout: ReturnType<typeof setTimeout>;
};
};
} = {};
} = Object.create(null);

/**
* A refresh timeout is responsible for initiating a request to AuthX that
Expand All @@ -218,7 +218,7 @@ export default class AuthXClientProxy extends EventEmitter {
[refreshToken: string]: {
[hash: string]: ReturnType<typeof setTimeout>;
};
} = {};
} = Object.create(null);

/**
* An eviction timeout is responsible for preventing tokens from being
Expand All @@ -230,7 +230,7 @@ export default class AuthXClientProxy extends EventEmitter {
[refreshToken: string]: {
[hash: string]: ReturnType<typeof setTimeout>;
};
} = {};
} = Object.create(null);

/**
* An expiration timeout is responsible for removing expired tokens from the
Expand All @@ -241,7 +241,7 @@ export default class AuthXClientProxy extends EventEmitter {
[refreshToken: string]: {
[hash: string]: ReturnType<typeof setTimeout>;
};
} = {};
} = Object.create(null);

public readonly server: Server;

Expand Down Expand Up @@ -458,7 +458,7 @@ export default class AuthXClientProxy extends EventEmitter {

// Create a new eviction timeout.
this._evictionTimeouts[refreshToken] =
this._evictionTimeouts[refreshToken] || {};
this._evictionTimeouts[refreshToken] || Object.create(null);
this._evictionTimeouts[refreshToken][hash] = setTimeout(
() => this._evict(refreshToken, hash),
(this._config.evictDormantCachedTokensThreshold || 600) * 1000
Expand Down Expand Up @@ -584,7 +584,7 @@ export default class AuthXClientProxy extends EventEmitter {

// Set an expiration timeout.
this._expirationTimeouts[refreshToken] =
this._expirationTimeouts[refreshToken] || {};
this._expirationTimeouts[refreshToken] || Object.create(null);
if (this._expirationTimeouts[refreshToken][hash]) {
clearTimeout(this._expirationTimeouts[refreshToken][hash]);
}
Expand All @@ -599,7 +599,7 @@ export default class AuthXClientProxy extends EventEmitter {

// Set a refresh timeout.
this._refreshTimeouts[refreshToken] =
this._refreshTimeouts[refreshToken] || {};
this._refreshTimeouts[refreshToken] || Object.create(null);
if (this._refreshTimeouts[refreshToken][hash]) {
clearTimeout(this._refreshTimeouts[refreshToken][hash]);
}
Expand All @@ -611,7 +611,7 @@ export default class AuthXClientProxy extends EventEmitter {

// Cache the access token.
this._accessTokens[refreshToken] =
this._accessTokens[refreshToken] || {};
this._accessTokens[refreshToken] || Object.create(null);
this._accessTokens[refreshToken][hash] = accessToken;

return accessToken;
Expand All @@ -632,7 +632,7 @@ export default class AuthXClientProxy extends EventEmitter {
// using incorrect credentials), and don't retry those.
if (retry) {
this._refreshTimeouts[refreshToken] =
this._refreshTimeouts[refreshToken] || {};
this._refreshTimeouts[refreshToken] || Object.create(null);
if (this._refreshTimeouts[refreshToken][hash]) {
clearTimeout(this._refreshTimeouts[refreshToken][hash]);
}
Expand Down Expand Up @@ -664,7 +664,8 @@ export default class AuthXClientProxy extends EventEmitter {
};

// Store the request.
this._requests[refreshToken] = this._requests[refreshToken] || {};
this._requests[refreshToken] =
this._requests[refreshToken] || Object.create(null);
this._requests[refreshToken][hash] = request;
return request.promise;
}
Expand Down
Loading