UNPKG

@renegade-fi/core

Version:
32 lines 1.4 kB
import invariant from 'tiny-invariant'; /** * Creates a configuration object specifically for authenticating with the relayer authentication server. * This is distinct from the main config (created by `createConfig`) which handles wallet operations. * * While `createConfig` is used for wallet-related interactions with the relayer (like creating orders * or managing wallet state), this auth config is solely for endpoints that require API key authentication, * such as external match requests of external orders. */ export function createAuthConfig(parameters) { const { apiKey, apiSecret, authServerUrl } = parameters; invariant(parameters.utils, 'Utils must be provided by the package if not supplied by the user.'); return { utils: parameters.utils, // Not used for wallet operations renegadeKeyType: 'none', apiKey, apiSecret, getBaseUrl: (route = '') => { const formattedRoute = route.startsWith('/') ? route : `/${route}`; return `${authServerUrl}/v0${formattedRoute}`; }, getWebsocketBaseUrl: () => { throw new Error('Not implemented'); }, getSymmetricKey: () => { invariant(parameters.utils, 'Utils are required'); return parameters.utils.b64_to_hex_hmac_key(apiSecret); }, }; } //# sourceMappingURL=createAuthConfig.js.map