@payez/next-mvp 4.0.11 → 4.0.13

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.
@@ -140,14 +140,22 @@ function createBetterAuthInstance(idpConfig) {
140
140
  client_id: idpConfig.clientSlug || String(idpConfig.clientId),
141
141
  }),
142
142
  });
143
+ const oauthResText = await oauthRes.text();
144
+ console.log('[BETTER_AUTH] IDP oauth-callback response:', oauthRes.status, oauthResText.substring(0, 500));
143
145
  if (!oauthRes.ok) {
144
- console.error('[BETTER_AUTH] IDP oauth-callback failed:', oauthRes.status, await oauthRes.text().catch(() => ''));
146
+ console.error('[BETTER_AUTH] IDP oauth-callback failed:', oauthRes.status);
145
147
  return;
146
148
  }
147
- const idpData = await oauthRes.json();
148
- const result = idpData?.data?.result || idpData?.result || idpData;
149
+ let idpData;
150
+ try {
151
+ idpData = JSON.parse(oauthResText);
152
+ }
153
+ catch {
154
+ return;
155
+ }
156
+ const result = idpData?.data?.result || idpData?.data || idpData;
149
157
  if (!result?.access_token) {
150
- console.warn('[BETTER_AUTH] IDP oauth-callback returned no access_token');
158
+ console.warn('[BETTER_AUTH] IDP oauth-callback returned no access_token. Keys:', Object.keys(result || {}));
151
159
  return;
152
160
  }
153
161
  // Store IDP tokens in the BA Redis session
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payez/next-mvp",
3
- "version": "4.0.11",
3
+ "version": "4.0.13",
4
4
  "sideEffects": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -153,16 +153,20 @@ export function createBetterAuthInstance(idpConfig: IDPClientConfig) {
153
153
  }),
154
154
  });
155
155
 
156
+ const oauthResText = await oauthRes.text();
157
+ console.log('[BETTER_AUTH] IDP oauth-callback response:', oauthRes.status, oauthResText.substring(0, 500));
158
+
156
159
  if (!oauthRes.ok) {
157
- console.error('[BETTER_AUTH] IDP oauth-callback failed:', oauthRes.status, await oauthRes.text().catch(() => ''));
160
+ console.error('[BETTER_AUTH] IDP oauth-callback failed:', oauthRes.status);
158
161
  return;
159
162
  }
160
163
 
161
- const idpData = await oauthRes.json();
162
- const result = idpData?.data?.result || idpData?.result || idpData;
164
+ let idpData: any;
165
+ try { idpData = JSON.parse(oauthResText); } catch { return; }
166
+ const result = idpData?.data?.result || idpData?.data || idpData;
163
167
 
164
168
  if (!result?.access_token) {
165
- console.warn('[BETTER_AUTH] IDP oauth-callback returned no access_token');
169
+ console.warn('[BETTER_AUTH] IDP oauth-callback returned no access_token. Keys:', Object.keys(result || {}));
166
170
  return;
167
171
  }
168
172