@axway/amplify-sdk
Version:
Axway Amplify SDK for Node.js
34 lines (28 loc) • 1.11 kB
JavaScript
import errors from './errors.js';
/**
* Constructs all endpoints.
*
* @param {Object} params - Required parameters.
* @param {String} params.baseUrl - The base URL.
* @param {String} params.realm - The authentication realm.
* @returns {Object}
*/
function getEndpoints({ baseUrl, realm } = {}) {
if (!baseUrl || typeof baseUrl !== 'string') {
throw errors.INVALID_ARGUMENT('Expected baseUrl to be a non-empty string');
}
if (!realm || typeof realm !== 'string') {
throw errors.INVALID_ARGUMENT('Expected realm to be a non-empty string');
}
// strip the trailing slashes
baseUrl = baseUrl.replace(/\/$/, '');
return {
auth: `${baseUrl}/auth/realms/${realm}/protocol/openid-connect/auth`,
certs: `${baseUrl}/auth/realms/${realm}/protocol/openid-connect/certs`,
token: `${baseUrl}/auth/realms/${realm}/protocol/openid-connect/token`,
userinfo: `${baseUrl}/auth/realms/${realm}/protocol/openid-connect/userinfo`,
wellKnown: `${baseUrl}/auth/realms/${realm}/.well-known/openid-configuration`
};
}
export { getEndpoints as default };
//# sourceMappingURL=endpoints.js.map