-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Provider rate limiting setup * Fixing defaults for api rate limits * zod tidy up * Removing redundant readme changes * Removing unused code * Unused import * Fixing linting issues * Fixing circular deps * Linting command fix * Circular dep import resolve * deps fixes * Linting * Sneaky uncaught linting error * Removing console log
- Loading branch information
Showing
11 changed files
with
216 additions
and
31 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// Copyright 2021-2024 Prosopo (UK) Ltd. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
import { AdminApiPaths, ApiPaths } from '@prosopo/types' | ||
|
||
export const getRateLimitConfig = () => { | ||
return { | ||
[ApiPaths.GetImageCaptchaChallenge]: { | ||
windowMs: process.env.PROSOPO_GET_IMAGE_CAPTCHA_CHALLENGE_WINDOW, | ||
limit: process.env.PROSOPO_GET_IMAGE_CAPTCHA_CHALLENGE_LIMIT, | ||
}, | ||
[ApiPaths.GetPowCaptchaChallenge]: { | ||
windowMs: process.env.PROSOPO_GET_POW_CAPTCHA_CHALLENGE_WINDOW, | ||
limit: process.env.PROSOPO_GET_POW_CAPTCHA_CHALLENGE_LIMIT, | ||
}, | ||
[ApiPaths.SubmitImageCaptchaSolution]: { | ||
windowMs: process.env.PROSOPO_SUBMIT_IMAGE_CAPTCHA_SOLUTION_WINDOW, | ||
limit: process.env.PROSOPO_SUBMIT_IMAGE_CAPTCHA_SOLUTION_LIMIT, | ||
}, | ||
[ApiPaths.SubmitPowCaptchaSolution]: { | ||
windowMs: process.env.PROSOPO_SUBMIT_POW_CAPTCHA_SOLUTION_WINDOW, | ||
limit: process.env.PROSOPO_SUBMIT_POW_CAPTCHA_SOLUTION_LIMIT, | ||
}, | ||
[ApiPaths.VerifyPowCaptchaSolution]: { | ||
windowMs: process.env.PROSOPO_VERIFY_POW_CAPTCHA_SOLUTION_WINDOW, | ||
limit: process.env.PROSOPO_VERIFY_POW_CAPTCHA_SOLUTION_LIMIT, | ||
}, | ||
[ApiPaths.VerifyImageCaptchaSolutionDapp]: { | ||
windowMs: process.env.PROSOPO_VERIFY_IMAGE_CAPTCHA_SOLUTION_DAPP_WINDOW, | ||
limit: process.env.PROSOPO_VERIFY_IMAGE_CAPTCHA_SOLUTION_DAPP_LIMIT, | ||
}, | ||
[ApiPaths.VerifyImageCaptchaSolutionUser]: { | ||
windowMs: process.env.PROSOPO_VERIFY_IMAGE_CAPTCHA_SOLUTION_USER_WINDOW, | ||
limit: process.env.PROSOPO_VERIFY_IMAGE_CAPTCHA_SOLUTION_USER_LIMIT, | ||
}, | ||
[ApiPaths.GetProviderStatus]: { | ||
windowMs: process.env.PROSOPO_GET_PROVIDER_STATUS_WINDOW, | ||
limit: process.env.PROSOPO_GET_PROVIDER_STATUS_LIMIT, | ||
}, | ||
[ApiPaths.GetProviderDetails]: { | ||
windowMs: process.env.PROSOPO_GET_PROVIDER_DETAILS_WINDOW, | ||
limit: process.env.PROSOPO_GET_PROVIDER_DETAILS_LIMIT, | ||
}, | ||
[ApiPaths.SubmitUserEvents]: { | ||
windowMs: process.env.PROSOPO_SUBMIT_USER_EVENTS_WINDOW, | ||
limit: process.env.PROSOPO_SUBMIT_USER_EVENTS_LIMIT, | ||
}, | ||
[AdminApiPaths.BatchCommit]: { | ||
windowMs: process.env.PROSOPO_BATCH_COMMIT_WINDOW, | ||
limit: process.env.PROSOPO_BATCH_COMMIT_LIMIT, | ||
}, | ||
[AdminApiPaths.UpdateDataset]: { | ||
windowMs: process.env.PROSOPO_UPDATE_DATASET_WINDOW, | ||
limit: process.env.PROSOPO_UPDATE_DATASET_LIMIT, | ||
}, | ||
[AdminApiPaths.ProviderDeregister]: { | ||
windowMs: process.env.PROSOPO_PROVIDER_DEREGISTER_WINDOW, | ||
limit: process.env.PROSOPO_PROVIDER_DEREGISTER_LIMIT, | ||
}, | ||
[AdminApiPaths.ProviderUpdate]: { | ||
windowMs: process.env.PROSOPO_PROVIDER_UPDATE_WINDOW, | ||
limit: process.env.PROSOPO_PROVIDER_UPDATE_LIMIT, | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright 2021-2024 Prosopo (UK) Ltd. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
const ONE_MINUTE = 60 * 1000 | ||
// The timeframe in which a user must complete an image captcha (1 minute) | ||
export const DEFAULT_IMAGE_CAPTCHA_TIMEOUT = ONE_MINUTE | ||
// The timeframe in which an image captcha solution remains valid on the page before timing out (2 minutes) | ||
export const DEFAULT_IMAGE_CAPTCHA_SOLUTION_TIMEOUT = DEFAULT_IMAGE_CAPTCHA_TIMEOUT * 2 | ||
// The timeframe in which an image captcha solution must be verified within (3 minutes) | ||
export const DEFAULT_IMAGE_CAPTCHA_VERIFIED_TIMEOUT = DEFAULT_IMAGE_CAPTCHA_TIMEOUT * 3 | ||
// The time in milliseconds that a cached, verified, image captcha solution is valid for (15 minutes) | ||
export const DEFAULT_IMAGE_MAX_VERIFIED_TIME_CACHED = DEFAULT_IMAGE_CAPTCHA_TIMEOUT * 15 | ||
// The timeframe in which a pow captcha solution remains valid on the page before timing out (1 minute) | ||
export const DEFAULT_POW_CAPTCHA_SOLUTION_TIMEOUT = ONE_MINUTE | ||
// The timeframe in which a pow captcha must be completed and verified (2 minutes) | ||
export const DEFAULT_POW_CAPTCHA_VERIFIED_TIMEOUT = DEFAULT_POW_CAPTCHA_SOLUTION_TIMEOUT * 2 | ||
// The time in milliseconds that a Provider cached, verified, pow captcha solution is valid for (3 minutes) | ||
export const DEFAULT_POW_CAPTCHA_CACHED_TIMEOUT = DEFAULT_POW_CAPTCHA_SOLUTION_TIMEOUT * 3 | ||
// The time in milliseconds since the last correct captcha recorded in the contract (15 minutes), after which point, the | ||
// user will be required to complete another captcha | ||
export const DEFAULT_MAX_VERIFIED_TIME_CONTRACT = ONE_MINUTE * 15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters