@microcosmmoney/auth-react 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,13 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createTokenExchangeHandler = createTokenExchangeHandler;
|
|
4
4
|
exports.createProfileHandler = createProfileHandler;
|
|
5
5
|
function createTokenExchangeHandler(config) {
|
|
6
|
-
if (!config.clientId || !config.clientSecret) {
|
|
7
|
-
throw new Error('[MicrocosmAuth] createTokenExchangeHandler: clientId and clientSecret are required. ' +
|
|
8
|
-
'Ensure OAUTH_CLIENT_ID and OAUTH_CLIENT_SECRET environment variables are set on the server.');
|
|
9
|
-
}
|
|
10
6
|
const tokenEndpoint = config.tokenEndpoint || 'https://microcosm.money/api/oauth/token';
|
|
11
7
|
return async function POST(request) {
|
|
12
8
|
try {
|
|
9
|
+
if (!config.clientId || !config.clientSecret) {
|
|
10
|
+
console.error('[MicrocosmAuth] createTokenExchangeHandler: clientId and clientSecret are required. ' +
|
|
11
|
+
'Ensure OAUTH_CLIENT_ID and OAUTH_CLIENT_SECRET environment variables are set on the server.');
|
|
12
|
+
return jsonResponse({ error: 'server_configuration_error', error_description: 'OAuth client credentials not configured on server' }, 500);
|
|
13
|
+
}
|
|
13
14
|
const body = await request.json();
|
|
14
15
|
const grantType = body.grant_type || 'authorization_code';
|
|
15
16
|
const tokenBody = {
|