@onesub/server 0.21.2 → 0.22.0
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/dist/__tests__/webhook-google-mount.test.d.ts +18 -0
- package/dist/__tests__/webhook-google-mount.test.d.ts.map +1 -0
- package/dist/index.cjs +12 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/dist/routes/webhook-google.d.ts +11 -0
- package/dist/routes/webhook-google.d.ts.map +1 -1
- package/dist/routes/webhook.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1744,18 +1744,22 @@ var GOOGLE_FAILURE_MESSAGES = {
|
|
|
1744
1744
|
message: "Failed to process notification"
|
|
1745
1745
|
}
|
|
1746
1746
|
};
|
|
1747
|
+
function servesGoogle(config) {
|
|
1748
|
+
return getAppRegistry(config).apps.some((app) => !!app.google);
|
|
1749
|
+
}
|
|
1747
1750
|
function warnIfGoogleWebhookOpen(config) {
|
|
1748
1751
|
if (process.env["NODE_ENV"] !== "production") return;
|
|
1752
|
+
if (!servesGoogle(config)) return;
|
|
1749
1753
|
const apps = getAppRegistry(config).apps;
|
|
1750
1754
|
const googleApps = apps.map((a) => a.google).filter((g) => !!g);
|
|
1751
|
-
if (
|
|
1755
|
+
if (!googleApps.some((g) => g.pushAudience)) {
|
|
1752
1756
|
log.warn(
|
|
1753
1757
|
"[onesub] SECURITY: POST /onesub/webhook/google accepts unauthenticated requests \u2014 no configured app sets google.pushAudience, so the Pub/Sub OIDC token is never verified. A caller who knows a purchaseToken or orderId can cancel a subscription or delete a one-time purchase. Set google.pushAudience (and google.pushServiceAccountEmail)."
|
|
1754
1758
|
);
|
|
1755
1759
|
}
|
|
1756
1760
|
if (!apps.some((a) => a.google?.packageName)) {
|
|
1757
1761
|
log.warn(
|
|
1758
|
-
"[onesub] POST /onesub/webhook/google is in open mode \u2014 no configured app declares google.packageName, so notifications for ANY package are accepted.
|
|
1762
|
+
"[onesub] POST /onesub/webhook/google is in open mode \u2014 no configured app declares google.packageName, so notifications for ANY package are accepted. Set google.packageName on each app you serve."
|
|
1759
1763
|
);
|
|
1760
1764
|
}
|
|
1761
1765
|
}
|
|
@@ -1974,10 +1978,12 @@ function createWebhookRouter(config, store, purchaseStore, webhookEventStore, we
|
|
|
1974
1978
|
ROUTES.WEBHOOK_APPLE,
|
|
1975
1979
|
(req, res) => handleAppleWebhook(req, res, config, store, purchaseStore, webhookEventStore, webhookQueue)
|
|
1976
1980
|
);
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
+
if (servesGoogle(config)) {
|
|
1982
|
+
router.post(
|
|
1983
|
+
ROUTES.WEBHOOK_GOOGLE,
|
|
1984
|
+
(req, res) => handleGoogleWebhook(req, res, config, store, purchaseStore, webhookEventStore, webhookQueue)
|
|
1985
|
+
);
|
|
1986
|
+
}
|
|
1981
1987
|
return router;
|
|
1982
1988
|
}
|
|
1983
1989
|
var NO_PURCHASE = { valid: false, purchase: null };
|