backend-manager 5.0.181 → 5.0.182
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.
package/TODO-2.md
CHANGED
|
@@ -10,6 +10,10 @@ payments/reactivate
|
|
|
10
10
|
payments/upgrade
|
|
11
11
|
* takes a subscription id and a new plan id and upgrades the user's subscription to the new plan. this can only be done if the user has an active subscription.
|
|
12
12
|
|
|
13
|
+
---
|
|
14
|
+
GHOSTII REVAMP
|
|
15
|
+
* better logic for generating posts. better model? claude?
|
|
16
|
+
|
|
13
17
|
-------
|
|
14
18
|
UPSELL
|
|
15
19
|
* products in BEM can have an UPSELL where you link another product ID and it allows you to add it to your cart OR shows you after checkout?
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
## BEM Gap: Webhook overwrites user doc with stale subscription data
|
|
2
|
+
|
|
3
|
+
### Problem
|
|
4
|
+
When a non-current subscription is cancelled on the provider (e.g. cancelling a zombie/duplicate PayPal sub), the provider fires a cancellation webhook. BEM processes it, finds the user by UID, and overwrites `subscription.*` on the user doc with the cancelled sub's data — even though the user has a different, active subscription.
|
|
5
|
+
|
|
6
|
+
### Example
|
|
7
|
+
- User has active Chargebee sub (current) + old suspended PayPal sub (zombie)
|
|
8
|
+
- We cancel the PayPal sub → PayPal fires `BILLING.SUBSCRIPTION.CANCELLED`
|
|
9
|
+
- BEM finds user by UID → sets `subscription.status = 'cancelled'`, `subscription.payment.resourceId = <old PayPal sub>`
|
|
10
|
+
- User is now broken — their active Chargebee sub is invisible
|
|
11
|
+
|
|
12
|
+
### Fix needed in `on-write.js`
|
|
13
|
+
Before writing the unified subscription data to the user doc, check:
|
|
14
|
+
```
|
|
15
|
+
if (user.subscription.payment.resourceId !== webhook.resourceId) {
|
|
16
|
+
// This webhook is for a DIFFERENT subscription than the user's current one.
|
|
17
|
+
// Update the payments-orders doc only. Do NOT touch the user doc.
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Affected file
|
|
22
|
+
`backend-manager/src/manager/events/firestore/payments-webhooks/on-write.js` — the section that writes to `users/{uid}`
|
|
23
|
+
|
|
24
|
+
### Impact
|
|
25
|
+
Without this fix, any cancellation/suspension of a non-current subscription (duplicate cleanup, provider-side cancellation of old subs) will corrupt the user doc. Currently requires manual restoration after each occurrence.
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@ const _ = require('lodash');
|
|
|
5
5
|
// The expected source pattern for bm_api hosting rewrite
|
|
6
6
|
// Includes /backend-manager/* routes and root-level MCP OAuth paths
|
|
7
7
|
// that Claude Chat sends directly (e.g. /authorize, /token, /.well-known/*)
|
|
8
|
-
const BM_API_SOURCE = '{/backend-manager,/backend-manager/**,/.well-known/oauth-protected-resource,/.well-known/oauth-authorization-server}';
|
|
8
|
+
const BM_API_SOURCE = '{/backend-manager,/backend-manager/**,/.well-known/oauth-protected-resource,/.well-known/oauth-authorization-server,/authorize,/token}';
|
|
9
9
|
|
|
10
10
|
class HostingRewritesTest extends BaseTest {
|
|
11
11
|
getName() {
|
package/src/manager/index.js
CHANGED
|
@@ -1218,6 +1218,15 @@ function resolveMcpRoutePath(routePath) {
|
|
|
1218
1218
|
return routePath;
|
|
1219
1219
|
}
|
|
1220
1220
|
|
|
1221
|
+
// Root-level OAuth paths — Claude Chat sends these directly
|
|
1222
|
+
// regardless of what the discovery endpoints return
|
|
1223
|
+
if (routePath === 'authorize') {
|
|
1224
|
+
return 'mcp/authorize';
|
|
1225
|
+
}
|
|
1226
|
+
if (routePath === 'token') {
|
|
1227
|
+
return 'mcp/token';
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1221
1230
|
return null;
|
|
1222
1231
|
}
|
|
1223
1232
|
|