@onesub/server 0.21.1 → 0.21.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.
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Startup warning for the two conditions that leave the Google RTDN route open.
3
+ *
4
+ * `POST /onesub/webhook/google` verifies the Pub/Sub OIDC token only when an app
5
+ * declares `pushAudience`, and serves any `packageName` when none declares one.
6
+ * The route is mounted either way. Both behaviours are pre-existing and
7
+ * deliberate — a host may front the route with its own verification — so this
8
+ * warns instead of refusing, and these tests pin down that it says so exactly
9
+ * when it should and stays quiet otherwise.
10
+ */
11
+ export {};
12
+ //# sourceMappingURL=google-webhook-open-warning.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google-webhook-open-warning.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/google-webhook-open-warning.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
package/dist/index.cjs CHANGED
@@ -1751,6 +1751,21 @@ var GOOGLE_FAILURE_MESSAGES = {
1751
1751
  message: "Failed to process notification"
1752
1752
  }
1753
1753
  };
1754
+ function warnIfGoogleWebhookOpen(config) {
1755
+ if (process.env["NODE_ENV"] !== "production") return;
1756
+ const apps = getAppRegistry(config).apps;
1757
+ const googleApps = apps.map((a) => a.google).filter((g) => !!g);
1758
+ if (googleApps.length > 0 && !googleApps.some((g) => g.pushAudience)) {
1759
+ log.warn(
1760
+ "[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)."
1761
+ );
1762
+ }
1763
+ if (!apps.some((a) => a.google?.packageName)) {
1764
+ log.warn(
1765
+ "[onesub] POST /onesub/webhook/google is in open mode \u2014 no configured app declares google.packageName, so notifications for ANY package are accepted. The route is mounted whether or not Google is configured; set google.packageName, or block the path at your proxy if this deployment does not serve Google Play."
1766
+ );
1767
+ }
1768
+ }
1754
1769
  function googleResolver(config) {
1755
1770
  const registry = getAppRegistry(config);
1756
1771
  const restricted = registry.apps.some((app) => !!app.google?.packageName);
@@ -4149,6 +4164,7 @@ function createOneSubMiddleware(config) {
4149
4164
  "[onesub] apple.mockMode / google.mockMode cannot be enabled when NODE_ENV=production \u2014 these modes accept any receipt as valid."
4150
4165
  );
4151
4166
  }
4167
+ warnIfGoogleWebhookOpen(config);
4152
4168
  const store = config.store ?? new InMemorySubscriptionStore();
4153
4169
  const purchaseStore = config.purchaseStore ?? new InMemoryPurchaseStore();
4154
4170
  if (config.cache) setDefaultCache(config.cache);