@onesub/server 0.15.0 → 0.16.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/index.js CHANGED
@@ -322,7 +322,6 @@ function mockValidateGoogleProduct(receipt, productId) {
322
322
  }
323
323
 
324
324
  // src/providers/apple.ts
325
- var MAX_CONSUMABLE_RECEIPT_AGE_MS = 72 * 60 * 60 * 1e3;
326
325
  function derBase64ToPem(der) {
327
326
  return "-----BEGIN CERTIFICATE-----\n" + (der.match(/.{1,64}/g) ?? []).join("\n") + "\n-----END CERTIFICATE-----";
328
327
  }
@@ -470,8 +469,9 @@ async function validateAppleConsumableReceipt(signedTransaction, config, expecte
470
469
  log.warn("[onesub/apple] Purchase was revoked/refunded");
471
470
  return null;
472
471
  }
473
- if (tx.purchaseDate && Date.now() - tx.purchaseDate > MAX_CONSUMABLE_RECEIPT_AGE_MS) {
474
- log.warn("[onesub/apple] Consumable receipt too old (>72h)");
472
+ const maxAgeMs = (config.productReceiptMaxAgeHours ?? 72) * 60 * 60 * 1e3;
473
+ if (tx.purchaseDate && Date.now() - tx.purchaseDate > maxAgeMs) {
474
+ log.warn(`[onesub/apple] Consumable receipt too old (>${config.productReceiptMaxAgeHours ?? 72}h)`);
475
475
  return null;
476
476
  }
477
477
  const transactionId = tx.transactionId ?? tx.originalTransactionId;
@@ -760,7 +760,6 @@ var GOOGLE_NOTIFICATION_TYPE = {
760
760
  SUBSCRIPTION_REVOKED: 12,
761
761
  SUBSCRIPTION_EXPIRED: 13
762
762
  };
763
- var MAX_PRODUCT_RECEIPT_AGE_MS = 72 * 60 * 60 * 1e3;
764
763
  var refreshPromises = /* @__PURE__ */ new Map();
765
764
  function googleTokenCacheKey(serviceAccountKey) {
766
765
  let hash = 0;
@@ -1037,8 +1036,9 @@ async function validateGoogleProductReceipt(purchaseToken, productId, config, ty
1037
1036
  }
1038
1037
  if (purchase.purchaseTimeMillis) {
1039
1038
  const purchaseTime = parseInt(purchase.purchaseTimeMillis, 10);
1040
- if (Date.now() - purchaseTime > MAX_PRODUCT_RECEIPT_AGE_MS) {
1041
- log.warn("[onesub/google] Product receipt too old (>72h)");
1039
+ const maxAgeMs = (config.productReceiptMaxAgeHours ?? 72) * 60 * 60 * 1e3;
1040
+ if (Date.now() - purchaseTime > maxAgeMs) {
1041
+ log.warn(`[onesub/google] Product receipt too old (>${config.productReceiptMaxAgeHours ?? 72}h)`);
1042
1042
  return null;
1043
1043
  }
1044
1044
  }