Files
tom goriunovandGitHub 0a8b7d7767 Add API keys button and alert message configuration (#3307)
feat: add API keys button and alert message configuration

- Introduced `NEXT_PUBLIC_ACCOUNT_API_KEYS_BUTTON` to control the visibility of the "Add API key" button, allowing it to be a boolean or a URL.
- Added `NEXT_PUBLIC_API_DOCS_ALERT_MESSAGE` for custom alerts on the API documentation page.
- Updated relevant schemas and documentation to reflect these new environment variables.
- Enhanced the account and API documentation features to utilize the new configurations.
2026-03-02 09:52:46 +01:00

66 lines
1.4 KiB
TypeScript

import type { Feature } from './types';
import type { AuthProvider } from 'types/client/account';
import app from '../app';
import services from '../services';
import { getEnvValue } from '../utils';
const title = 'My account';
const apiKeysButton = (() => {
const value = getEnvValue('NEXT_PUBLIC_ACCOUNT_API_KEYS_BUTTON');
if (value === undefined || value === 'true') {
return true;
}
if (value === 'false') {
return false;
}
return value;
})();
const config: Feature<{
isEnabled: true;
authProvider: AuthProvider;
dynamic?: {
environmentId: string;
};
apiKeysButton: boolean | string;
}> = (() => {
if (
!app.isPrivateMode &&
getEnvValue('NEXT_PUBLIC_IS_ACCOUNT_SUPPORTED') === 'true'
) {
const authProvider = getEnvValue('NEXT_PUBLIC_ACCOUNT_AUTH_PROVIDER');
const dynamicEnvironmentId = getEnvValue('NEXT_PUBLIC_ACCOUNT_DYNAMIC_ENVIRONMENT_ID');
if (authProvider === 'dynamic' && dynamicEnvironmentId) {
return Object.freeze({
title,
isEnabled: true,
authProvider: 'dynamic',
dynamic: {
environmentId: dynamicEnvironmentId,
},
apiKeysButton,
});
}
if (services.reCaptchaV2.siteKey) {
return Object.freeze({
title,
isEnabled: true,
authProvider: 'auth0',
apiKeysButton,
});
}
}
return Object.freeze({
title,
isEnabled: false,
});
})();
export default config;