@arcblock/payment-service 1.29.7 → 1.29.9
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/cf.d.ts +31 -0
- package/dist/cf.js +79 -60
- package/dist/index.d.ts +17 -0
- package/dist/index.js +264 -73
- package/package.json +4 -4
- package/web/assets/{account-DETfFe4_.js → account-Clbqiiw3.js} +1 -1
- package/web/assets/{action-B_DQJlip.js → action-DENqSeOa.js} +1 -1
- package/web/assets/{actions-BtaoyTWt.js → actions-0iWP2mcx.js} +1 -1
- package/web/assets/{actions-QPa-8lfB.js → actions-BD9BAp3M.js} +1 -1
- package/web/assets/{actions-jxGAdGfb.js → actions-BJDN6Op2.js} +1 -1
- package/web/assets/{actions-DJyfN5OU.js → actions-BSNy5bOd.js} +1 -1
- package/web/assets/{actions-Bt_jST94.js → actions-CDsj5j8l.js} +1 -1
- package/web/assets/{actions-D9MHLBFH.js → actions-CSpJGOX7.js} +1 -1
- package/web/assets/{actions-BknL4OyZ.js → actions-CZL47E9r.js} +1 -1
- package/web/assets/{actions-EPYeS5p4.js → actions-D3tJgrUn.js} +1 -1
- package/web/assets/{actions-BaDh4xWX.js → actions-DGQs8fFF.js} +1 -1
- package/web/assets/{add-price-CD-utowo.js → add-price-BpnICuHO.js} +1 -1
- package/web/assets/{admin-_nEB-lHn.js → admin-CD8ViZ7D.js} +1 -1
- package/web/assets/{assign-CkV5Q2LP.js → assign-0vMUDW_C.js} +1 -1
- package/web/assets/{attempts-DySeqBYU.js → attempts-CKlxkJuE.js} +1 -1
- package/web/assets/browser-DDv4_sgY.js +1 -0
- package/web/assets/{change-payment-CPUCUEER.js → change-payment-gAlRmJpv.js} +1 -1
- package/web/assets/{change-plan-CxE-XfWc.js → change-plan-C47wfWH8.js} +1 -1
- package/web/assets/{click-boundary-y8dVA_tr.js → click-boundary-CafubiPp.js} +1 -1
- package/web/assets/{connect-CC_l_f6Q.js → connect-BHHzrwLA.js} +1 -1
- package/web/assets/{copyable-DpX04wZz.js → copyable-QrCyyiou.js} +1 -1
- package/web/assets/{create-3SsWCAOC.js → create-0PUtkJZY.js} +1 -1
- package/web/assets/{create-BkQAaSvD.js → create-BJ1asdcy.js} +1 -1
- package/web/assets/{create-kG09X9gl.js → create-Bgv5ux17.js} +1 -1
- package/web/assets/{create-BmcRybZ5.js → create-C7GOgZZM.js} +1 -1
- package/web/assets/{create-tYebjhr9.js → create-DNar5UQD.js} +1 -1
- package/web/assets/{create-Bs65p5Ne.js → create-ke4FrPx1.js} +1 -1
- package/web/assets/{credit-grant-item-list-Bk27jIc7.js → credit-grant-item-list-CeDAM3qV.js} +1 -1
- package/web/assets/{credit-overview-DmMSEs14.js → credit-overview-4zh0H02x.js} +2 -2
- package/web/assets/{currency-restrictions-DYLv4YyW.js → currency-restrictions-BcEm8W45.js} +1 -1
- package/web/assets/{currency-select-DGS-62-L.js → currency-select-B4ieQBvv.js} +1 -1
- package/web/assets/{dayjs-B9tvQIKg.js → dayjs-DUTDpcNU.js} +1 -1
- package/web/assets/{description-Ym17DL48.js → description-SnR5WxWT.js} +1 -1
- package/web/assets/detail-46aLUdJj.js +1 -0
- package/web/assets/{detail-Cr2wG4Th.js → detail-B-ceWfZr.js} +1 -1
- package/web/assets/detail-B0IHl4MI.js +1 -0
- package/web/assets/detail-B8eOBVSQ.js +15 -0
- package/web/assets/{detail-DE3OOC5M.js → detail-BO3zglCn.js} +1 -1
- package/web/assets/{detail-DG4l2CqN.js → detail-BQpDGZJQ.js} +1 -1
- package/web/assets/{detail-CxYQYu_l.js → detail-BXTsnQny.js} +1 -1
- package/web/assets/{detail-CT9Unyrf.js → detail-B_lpOomD.js} +1 -1
- package/web/assets/{detail-Do9QO5L2.js → detail-Bfnkg0A1.js} +1 -1
- package/web/assets/detail-BwH0DwAi.js +1 -0
- package/web/assets/{detail-OZeeKI69.js → detail-C1FupF1D.js} +2 -2
- package/web/assets/{detail-cwHZbY62.js → detail-CMBRd4Ct.js} +1 -1
- package/web/assets/detail-C_Zdfa0y.js +1 -0
- package/web/assets/{detail-Cb9HBSMw.js → detail-Cg505nKX.js} +1 -1
- package/web/assets/{detail-DB56SG-k.js → detail-CsGZMimg.js} +1 -1
- package/web/assets/{detail-K9EVY3r2.js → detail-Ct5QNBqu.js} +1 -1
- package/web/assets/{detail-DuO_Jn5X.js → detail-CyMhK5K_.js} +1 -1
- package/web/assets/{detail-DuWdZIyp.js → detail-DACnmls3.js} +1 -1
- package/web/assets/{detail-BJTcK7mx.js → detail-DCTb8R7F.js} +1 -1
- package/web/assets/{detail-DPCTQLOx.js → detail-DNcp_u5S.js} +1 -1
- package/web/assets/detail-DbU3p040.js +1 -0
- package/web/assets/{detail-D5KRrQDx.js → detail-Tn2R5C8i.js} +1 -1
- package/web/assets/{detail-15zxCbV9.js → detail-wU4wNf4s.js} +1 -1
- package/web/assets/{drawer-form-Cl0T1Yyt.js → drawer-form-DspWWj3x.js} +1 -1
- package/web/assets/{edit-3HUAnaXW.js → edit-Bkj-OTJh.js} +1 -1
- package/web/assets/{editor-BF5I0siU.js → editor-AmthipP2.js} +1 -1
- package/web/assets/{embed-CsNqeCd0.js → embed-rRKjDoHi.js} +1 -1
- package/web/assets/{filter-toolbar-BydfQ-79.js → filter-toolbar-DXGSTq57.js} +1 -1
- package/web/assets/{form-DSzMo9UD.js → form-B5WW-lS5.js} +1 -1
- package/web/assets/form-BmQlJZ84.js +9 -0
- package/web/assets/{form-BGm5NPDn.js → form-CAPjlw7l.js} +1 -1
- package/web/assets/{form-CKfKLGXP.js → form-DD-EiA7W.js} +3 -3
- package/web/assets/{form-P4luyUpY.js → form-cX026J4G.js} +1 -1
- package/web/assets/{gas-Qf0SSUfS.js → gas-nyR96dB0.js} +1 -1
- package/web/assets/{generateCategoricalChart-BaWwaXky.js → generateCategoricalChart-BadryV3H.js} +1 -1
- package/web/assets/{home-HbrLyxJL.js → home-_eX1aim8.js} +1 -1
- package/web/assets/index-BBHMsIxJ.js +1 -0
- package/web/assets/{index-Dr_MwbKt.js → index-BQjlhCSt.js} +1 -1
- package/web/assets/{index-DPodCQ9c.js → index-BRENdB5m.js} +1 -1
- package/web/assets/{index-9xBRL_33.js → index-BTfJ08JU.js} +1 -1
- package/web/assets/{index-DgSc1Qy8.js → index-BarN7DfU.js} +17 -17
- package/web/assets/index-BhcoukR2.js +1 -0
- package/web/assets/index-BturOfxo.js +1 -0
- package/web/assets/{index-SYTpMMMH.js → index-BzABukCz.js} +1 -1
- package/web/assets/{index-2l22EYw9.js → index-C-RT84yb.js} +1 -1
- package/web/assets/{index-C0JaS08f.js → index-C136x0O2.js} +1 -1
- package/web/assets/{index-Cw0ugaQL.js → index-CCVDDX0c.js} +1 -1
- package/web/assets/index-CDVogp6E.js +1 -0
- package/web/assets/{index-Br7_mvEw.js → index-CW8VfoJO.js} +1 -1
- package/web/assets/{index-BIoSdRvX.js → index-CbSXdD6E.js} +3 -3
- package/web/assets/{index-CdkYrABk.js → index-Cd_BD9TM.js} +1 -1
- package/web/assets/index-D-bx9Kam.js +1 -0
- package/web/assets/index-D0mynT6_.js +1 -0
- package/web/assets/index-DEiuhiEo.js +14 -0
- package/web/assets/{index-DE2KzqXl.js → index-DNGmCIRP.js} +1 -1
- package/web/assets/{index-CI_EY4YS.js → index-DSe7Dot_.js} +1 -1
- package/web/assets/{index-BFML4-2u.js → index-DcddP3R9.js} +1 -1
- package/web/assets/index-DcrGSDby.js +1 -0
- package/web/assets/{index-fByZjxLy.js → index-DeK5Pqjv.js} +1 -1
- package/web/assets/{index-Clbt8nRm.js → index-DoX0A-rP.js} +1 -1
- package/web/assets/index-Du0Ieh1F.js +49 -0
- package/web/assets/index-Dybqd298.js +1 -0
- package/web/assets/index-EXZPddtw.js +1 -0
- package/web/assets/{index-Drav4oDH.js → index-Kd_qCyRG.js} +2 -2
- package/web/assets/{index-Dc954mDP.js → index-SOzRg0yJ.js} +1 -1
- package/web/assets/{index-BMKZToMM.js → index-UYeD8rTJ.js} +2 -2
- package/web/assets/{index-DZpJPE1Z.js → index-W2uZUlFs.js} +1 -1
- package/web/assets/{index-1y9kjPIr.js → index-XaFn2ySq.js} +1 -1
- package/web/assets/{index-fswPX_qe.js → index-YG5oc8O3.js} +1 -1
- package/web/assets/{index-B1pTTyGZ.js → index-ajD9Iotk.js} +1 -1
- package/web/assets/index-brUCsnBA.js +1 -0
- package/web/assets/{index-BP53rZV9.js → index-mn5Zdrtn.js} +1 -1
- package/web/assets/index-qulrJQ4J.js +1 -0
- package/web/assets/{index.es-BWnfUzLb.js → index.es-C8dcCHdW.js} +1 -1
- package/web/assets/{info-card-C1yxhxJG.js → info-card-BvIMFQo5.js} +1 -1
- package/web/assets/{info-metric-CNse3r66.js → info-metric-Dl4ZDm0Z.js} +1 -1
- package/web/assets/{info-row-group-BeUhWnnY.js → info-row-group-CFuMWJf1.js} +1 -1
- package/web/assets/{info-row-DOK2whMn.js → info-row-jI0h_hv4.js} +1 -1
- package/web/assets/{libphonenumber-CyphiuxQ.js → libphonenumber-Qs8PCdM-.js} +1 -1
- package/web/assets/{link-3eeclTeS.js → link-CmPoIweR.js} +1 -1
- package/web/assets/{list-DnePqZ2K.js → list-BdSkPjIa.js} +1 -1
- package/web/assets/{list-jHj_5yy3.js → list-CWMEf-_C.js} +1 -1
- package/web/assets/{list-C521zE_7.js → list-CkHExntK.js} +1 -1
- package/web/assets/{list-CO0X4L3-.js → list-DLB_hd0Q.js} +1 -1
- package/web/assets/{list-D-I0msRW.js → list-DVFJwd_I.js} +2 -2
- package/web/assets/{list-D1aevUOI.js → list-DaK9287Y.js} +2 -2
- package/web/assets/{list-1OG83xc4.js → list-DghnUOc4.js} +1 -1
- package/web/assets/{list-CNmzJKIQ.js → list-eFkvVlp5.js} +1 -1
- package/web/assets/metadata-BmQTVFku.js +55 -0
- package/web/assets/{meter-event-lmNMgmIu.js → meter-event-B1JIhVpb.js} +1 -1
- package/web/assets/{metrics-C7U41HWk.js → metrics-UvxyQbUF.js} +1 -1
- package/web/assets/{overview-Cs3-8n4e.js → overview-Cxc6WKba.js} +1 -1
- package/web/assets/{overview-CH1HnSP-.js → overview-DrMaIptb.js} +1 -1
- package/web/assets/{past-due-CGGRZmXY.js → past-due-CUXkxns0.js} +1 -1
- package/web/assets/pay-omLYkqRA.js +4 -0
- package/web/assets/{payment-method-info-BsOBbA3m.js → payment-method-info-Bsf89VxV.js} +2 -2
- package/web/assets/{preview-DjYRpRA8.js → preview-BifsgUGT.js} +1 -1
- package/web/assets/{preview-CjYh9dTg.js → preview-C-H8pGVw.js} +1 -1
- package/web/assets/{pricing-table-C3Lkhq46.js → pricing-table-B3QOaAB5.js} +2 -2
- package/web/assets/{pricing-table-edE6TJGX.js → pricing-table-BUJdtkMq.js} +1 -1
- package/web/assets/{product-select-0ScZE2e8.js → product-select-ChEyoJqJ.js} +1 -1
- package/web/assets/{recharge-DcPtT8vt.js → recharge-BVT4USAO.js} +1 -1
- package/web/assets/{related-credit-grants-BygNGPfb.js → related-credit-grants-JV2ICsR5.js} +22 -22
- package/web/assets/{safe-did-address-B0fFbUph.js → safe-did-address-CiG_V6Gy.js} +1 -1
- package/web/assets/{source-data-viewer-By_Utay-.js → source-data-viewer-i1q9wNIG.js} +1 -1
- package/web/assets/{status-l6pD08fw.js → status-CUVYrUIG.js} +1 -1
- package/web/assets/subscription-BYz_k9dq.js +1 -0
- package/web/assets/{subscription-Dq22e3D1.js → subscription-DrnSPIfs.js} +1 -1
- package/web/assets/table-BrtHemkA.js +1 -0
- package/web/assets/{tax-code-select-CWhIIiXi.js → tax-code-select-TS07I0rB.js} +1 -1
- package/web/assets/{tax-utils-DqNX34-r.js → tax-utils-bPjALcVG.js} +1 -1
- package/web/assets/{uploader-DRXDz_r0.js → uploader-CsQNHG4I.js} +1 -1
- package/web/assets/{usage-records-jjJMZ6DI.js → usage-records-DAUQMJAW.js} +1 -1
- package/web/assets/{util-mDHAL0lx.js → util-DxXTXkeY.js} +1 -1
- package/web/assets/{vendor-arcblock-ChFCRdyx.js → vendor-arcblock-BTCAQSUK.js} +1 -1
- package/web/assets/{vendor-blocklet-D_i_QeSo.js → vendor-blocklet-DcLR2Cyf.js} +43 -43
- package/web/index.html +1 -1
- package/web/assets/browser-DSLTxXlL.js +0 -1
- package/web/assets/detail-ASPdMJoW.js +0 -1
- package/web/assets/detail-CIx9vkir.js +0 -1
- package/web/assets/detail-D5NbV29V.js +0 -1
- package/web/assets/detail-DVVzYhdV.js +0 -1
- package/web/assets/detail-Dqc0OfCQ.js +0 -1
- package/web/assets/detail-uhlID8jD.js +0 -15
- package/web/assets/form-BXAuSawq.js +0 -9
- package/web/assets/index-0HK7CYm4.js +0 -1
- package/web/assets/index-BJ_E6bEO.js +0 -1
- package/web/assets/index-Bnyh4rlV.js +0 -1
- package/web/assets/index-BoQ7wf3O.js +0 -1
- package/web/assets/index-C68x-aau.js +0 -1
- package/web/assets/index-C8s2QKoe.js +0 -1
- package/web/assets/index-Cn7O-OP7.js +0 -49
- package/web/assets/index-DU39aG5u.js +0 -1
- package/web/assets/index-DtbqgSK4.js +0 -1
- package/web/assets/index-DuRu9NWB.js +0 -14
- package/web/assets/index-WMKOiUez.js +0 -1
- package/web/assets/index-dmHgoplS.js +0 -1
- package/web/assets/index-txVTkoDD.js +0 -1
- package/web/assets/metadata-CMSHcSXi.js +0 -55
- package/web/assets/pay-CSpHBUh_.js +0 -4
- package/web/assets/subscription-DcwhSOpa.js +0 -1
- package/web/assets/table-BRU4Enia.js +0 -1
package/dist/index.js
CHANGED
|
@@ -360,7 +360,6 @@ __export(env_exports, {
|
|
|
360
360
|
creditConsumptionCronTime: () => creditConsumptionCronTime,
|
|
361
361
|
creditLowBalanceThresholdPercentage: () => creditLowBalanceThresholdPercentage,
|
|
362
362
|
creditQueueConcurrency: () => creditQueueConcurrency,
|
|
363
|
-
daysUntilCancel: () => daysUntilCancel,
|
|
364
363
|
default: () => env_default,
|
|
365
364
|
depositVaultCronTime: () => depositVaultCronTime,
|
|
366
365
|
enableDevFakeAuth: () => enableDevFakeAuth,
|
|
@@ -411,6 +410,7 @@ __export(env_exports, {
|
|
|
411
410
|
stripePaymentCronTime: () => stripePaymentCronTime,
|
|
412
411
|
stripeSubscriptionCronTime: () => stripeSubscriptionCronTime,
|
|
413
412
|
stripeWebhookSecret: () => stripeWebhookSecret,
|
|
413
|
+
stripeWebhookUrl: () => stripeWebhookUrl,
|
|
414
414
|
subscriptionCronTime: () => subscriptionCronTime,
|
|
415
415
|
systemMaxPendingAmount: () => systemMaxPendingAmount,
|
|
416
416
|
tenantModeRaw: () => tenantModeRaw,
|
|
@@ -437,7 +437,7 @@ function hasConfig(key) {
|
|
|
437
437
|
const v = readConfig(key);
|
|
438
438
|
return v !== void 0 && v !== "";
|
|
439
439
|
}
|
|
440
|
-
var import_env, activeConfig, numConfig, paymentStatCronTime, subscriptionCronTime, notificationCronTime, expiredSessionCleanupCronTime, notificationCronConcurrency, stripeInvoiceCronTime, stripePaymentCronTime, stripeSubscriptionCronTime, revokeStakeCronTime,
|
|
440
|
+
var import_env, activeConfig, numConfig, TRUTHY, FALSY, parseBool, readConfigAny, paymentStatCronTime, subscriptionCronTime, notificationCronTime, expiredSessionCleanupCronTime, notificationCronConcurrency, stripeInvoiceCronTime, stripePaymentCronTime, stripeSubscriptionCronTime, revokeStakeCronTime, meteringSubscriptionDetectionCronTime, overdueDetectionCronTime, overdueThreshold, depositVaultCronTime, creditConsumptionCronTime, vendorStatusCheckCronTime, vendorReturnScanCronTime, iapReconcileCronTime, eventRetryCronTime, quoteCleanupCronTime, vendorTimeoutMinutes, webhookAlertWindowMinutes, webhookAlertMinFailures, shortUrlApiKey, shortUrlDomain, sequelizeOptionsPoolMin, sequelizeOptionsPoolMax, sequelizeOptionsPoolIdle, updateDataConcurrency, stopAcceptingOrders, exchangeRateCacheTTLSeconds, systemMaxPendingAmount, allowChangeLockedPrice, blockletMode, isProduction, nodeEnv, isTestEnv, isDevelopmentEnv, enableDevFakeAuth, tenantModeRaw, blockletAppPid, blockletAppId, blockletAppName, blockletAppUrl, blockletAppHost, blockletAppDir, blockletPort, blockletMountPoints, appStoreWriteEnabled, appStoreSkipSignatureVerify, googlePubsubSkipSignatureVerify, googlePubsubPushServiceAccount, googlePubsubAllowUnverifiedSender, googlePlayWebhookUrl, stripeWebhookSecret, stripeWebhookUrl, iapReconcileBatchSize, paymentBillingThreshold, paymentMinStakeAmount, paymentDaysUntilDue, paymentDaysUntilCancel, paymentReloadSubscriptionJobs, paymentRateVolatilityThreshold, paymentLivemode, creditLowBalanceThresholdPercentage, creditBatchSize, creditBatchWindowMs, creditQueueConcurrency, exchangeRateCacheTTLFromEnv, sqlLog, sqlBenchmark, cfEnv, isCfWorker, isBlockletServer, env_default;
|
|
441
441
|
var init_env = __esm({
|
|
442
442
|
"../../blocklets/core/api/src/libs/env.ts"() {
|
|
443
443
|
"use strict";
|
|
@@ -446,6 +446,22 @@ var init_env = __esm({
|
|
|
446
446
|
const v = readConfig(key);
|
|
447
447
|
return v ? +v : fallback;
|
|
448
448
|
};
|
|
449
|
+
TRUTHY = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
|
|
450
|
+
FALSY = /* @__PURE__ */ new Set(["0", "false", "no", "off"]);
|
|
451
|
+
parseBool = (value, fallback = false) => {
|
|
452
|
+
if (value === void 0 || value === "") return fallback;
|
|
453
|
+
const v = value.trim().toLowerCase();
|
|
454
|
+
if (TRUTHY.has(v)) return true;
|
|
455
|
+
if (FALSY.has(v)) return false;
|
|
456
|
+
return fallback;
|
|
457
|
+
};
|
|
458
|
+
readConfigAny = (...keys) => {
|
|
459
|
+
for (const key of keys) {
|
|
460
|
+
const v = readConfig(key);
|
|
461
|
+
if (v !== void 0 && v !== "") return v;
|
|
462
|
+
}
|
|
463
|
+
return void 0;
|
|
464
|
+
};
|
|
449
465
|
paymentStatCronTime = () => "0 1 0 * * *";
|
|
450
466
|
subscriptionCronTime = () => readConfig("SUBSCRIPTION_CRON_TIME") || "0 */30 * * * *";
|
|
451
467
|
notificationCronTime = () => readConfig("NOTIFICATION_CRON_TIME") || "0 5 */6 * * *";
|
|
@@ -455,7 +471,6 @@ var init_env = __esm({
|
|
|
455
471
|
stripePaymentCronTime = () => readConfig("STRIPE_PAYMENT_CRON_TIME") || "0 */20 * * * *";
|
|
456
472
|
stripeSubscriptionCronTime = () => readConfig("STRIPE_SUBSCRIPTION_CRON_TIME") || "0 10 */8 * * *";
|
|
457
473
|
revokeStakeCronTime = () => readConfig("REVOKE_STAKE_CRON_TIME") || "0 */5 * * * *";
|
|
458
|
-
daysUntilCancel = () => readConfig("DAYS_UNTIL_CANCEL");
|
|
459
474
|
meteringSubscriptionDetectionCronTime = () => readConfig("METERING_SUBSCRIPTION_DETECTION_CRON_TIME") || "0 0 10 * * *";
|
|
460
475
|
overdueDetectionCronTime = () => readConfig("OVERDUE_DETECTION_CRON_TIME") || "0 0 10 * * *";
|
|
461
476
|
overdueThreshold = () => numConfig("OVERDUE_THRESHOLD", 5);
|
|
@@ -475,16 +490,19 @@ var init_env = __esm({
|
|
|
475
490
|
sequelizeOptionsPoolMax = () => numConfig("SEQUELIZE_OPTIONS_POOL_MAX", 5);
|
|
476
491
|
sequelizeOptionsPoolIdle = () => numConfig("SEQUELIZE_OPTIONS_POOL_IDLE", 10 * 1e3);
|
|
477
492
|
updateDataConcurrency = () => numConfig("UPDATE_DATA_CONCURRENCY", 5);
|
|
478
|
-
stopAcceptingOrders = () =>
|
|
493
|
+
stopAcceptingOrders = () => parseBool(readConfigAny("PAYMENT_STOP_ACCEPTING_ORDERS", "PAYMENT_KIT_STOP_ACCEPTING_ORDERS"));
|
|
479
494
|
exchangeRateCacheTTLSeconds = () => numConfig("EXCHANGE_RATE_CACHE_TTL_SECONDS", 10 * 60);
|
|
480
|
-
systemMaxPendingAmount = () =>
|
|
481
|
-
|
|
495
|
+
systemMaxPendingAmount = () => {
|
|
496
|
+
const v = readConfigAny("PAYMENT_MAX_PENDING_AMOUNT", "PAYMENT_KIT_MAX_PENDING_AMOUNT");
|
|
497
|
+
return v ? +v : 5;
|
|
498
|
+
};
|
|
499
|
+
allowChangeLockedPrice = () => parseBool(readConfig("PAYMENT_CHANGE_LOCKED_PRICE"));
|
|
482
500
|
blockletMode = () => readConfig("BLOCKLET_MODE");
|
|
483
501
|
isProduction = () => blockletMode() === "production";
|
|
484
502
|
nodeEnv = () => readConfig("NODE_ENV");
|
|
485
503
|
isTestEnv = () => nodeEnv() === "test";
|
|
486
504
|
isDevelopmentEnv = () => nodeEnv() === "development";
|
|
487
|
-
enableDevFakeAuth = () => readConfig("ENABLE_DEV_FAKE_AUTH")
|
|
505
|
+
enableDevFakeAuth = () => parseBool(readConfig("ENABLE_DEV_FAKE_AUTH"));
|
|
488
506
|
tenantModeRaw = () => readConfig("PAYMENT_TENANT_MODE");
|
|
489
507
|
blockletAppPid = () => readConfig("BLOCKLET_APP_PID");
|
|
490
508
|
blockletAppId = () => readConfig("BLOCKLET_APP_ID");
|
|
@@ -494,31 +512,32 @@ var init_env = __esm({
|
|
|
494
512
|
blockletAppDir = () => readConfig("BLOCKLET_APP_DIR");
|
|
495
513
|
blockletPort = () => readConfig("BLOCKLET_PORT");
|
|
496
514
|
blockletMountPoints = () => readConfig("BLOCKLET_MOUNT_POINTS");
|
|
497
|
-
appStoreWriteEnabled = () => readConfig("APP_STORE_WRITE_ENABLED")
|
|
498
|
-
appStoreSkipSignatureVerify = () => readConfig("APP_STORE_SKIP_SIGNATURE_VERIFY")
|
|
499
|
-
googlePubsubSkipSignatureVerify = () => readConfig("GOOGLE_PUBSUB_SKIP_SIGNATURE_VERIFY")
|
|
515
|
+
appStoreWriteEnabled = () => parseBool(readConfig("APP_STORE_WRITE_ENABLED"));
|
|
516
|
+
appStoreSkipSignatureVerify = () => parseBool(readConfig("APP_STORE_SKIP_SIGNATURE_VERIFY"));
|
|
517
|
+
googlePubsubSkipSignatureVerify = () => parseBool(readConfig("GOOGLE_PUBSUB_SKIP_SIGNATURE_VERIFY"));
|
|
500
518
|
googlePubsubPushServiceAccount = () => readConfig("GOOGLE_PUBSUB_PUSH_SERVICE_ACCOUNT");
|
|
501
|
-
googlePubsubAllowUnverifiedSender = () => readConfig("GOOGLE_PUBSUB_ALLOW_UNVERIFIED_SENDER")
|
|
519
|
+
googlePubsubAllowUnverifiedSender = () => parseBool(readConfig("GOOGLE_PUBSUB_ALLOW_UNVERIFIED_SENDER"));
|
|
502
520
|
googlePlayWebhookUrl = () => readConfig("GOOGLE_PLAY_WEBHOOK_URL");
|
|
503
521
|
stripeWebhookSecret = () => readConfig("STRIPE_WEBHOOK_SECRET");
|
|
522
|
+
stripeWebhookUrl = () => readConfig("STRIPE_WEBHOOK_URL");
|
|
504
523
|
iapReconcileBatchSize = () => Number(readConfig("IAP_RECONCILE_BATCH_SIZE") ?? "100");
|
|
505
524
|
paymentBillingThreshold = () => +readConfig("PAYMENT_BILLING_THRESHOLD");
|
|
506
525
|
paymentMinStakeAmount = () => +readConfig("PAYMENT_MIN_STAKE_AMOUNT");
|
|
507
526
|
paymentDaysUntilDue = () => readConfig("PAYMENT_DAYS_UNTIL_DUE");
|
|
508
527
|
paymentDaysUntilCancel = () => readConfig("PAYMENT_DAYS_UNTIL_CANCEL");
|
|
509
|
-
paymentReloadSubscriptionJobs = () => readConfig("PAYMENT_RELOAD_SUBSCRIPTION_JOBS")
|
|
528
|
+
paymentReloadSubscriptionJobs = () => parseBool(readConfig("PAYMENT_RELOAD_SUBSCRIPTION_JOBS"));
|
|
510
529
|
paymentRateVolatilityThreshold = () => readConfig("PAYMENT_RATE_VOLATILITY_THRESHOLD");
|
|
511
|
-
paymentLivemode = () => readConfig("PAYMENT_LIVEMODE")
|
|
530
|
+
paymentLivemode = () => parseBool(readConfig("PAYMENT_LIVEMODE"), true);
|
|
512
531
|
creditLowBalanceThresholdPercentage = () => parseInt(readConfig("CREDIT_LOW_BALANCE_THRESHOLD_PERCENTAGE") || "10", 10);
|
|
513
532
|
creditBatchSize = () => Math.max(1, parseInt(readConfig("CREDIT_BATCH_SIZE") || "50", 10));
|
|
514
533
|
creditBatchWindowMs = () => Math.max(10, parseInt(readConfig("CREDIT_BATCH_WINDOW_MS") || "3000", 10));
|
|
515
534
|
creditQueueConcurrency = () => Math.max(1, Math.min(20, parseInt(readConfig("CREDIT_QUEUE_CONCURRENCY") || "5", 10) || 5));
|
|
516
535
|
exchangeRateCacheTTLFromEnv = () => hasConfig("EXCHANGE_RATE_CACHE_TTL_SECONDS");
|
|
517
|
-
sqlLog = () => readConfig("SQL_LOG")
|
|
518
|
-
sqlBenchmark = () => readConfig("SQL_BENCHMARK")
|
|
536
|
+
sqlLog = () => parseBool(readConfig("SQL_LOG"));
|
|
537
|
+
sqlBenchmark = () => parseBool(readConfig("SQL_BENCHMARK"));
|
|
519
538
|
cfEnv = () => globalThis.__CF_ENV__;
|
|
520
539
|
isCfWorker = () => !!cfEnv();
|
|
521
|
-
isBlockletServer = () => hasConfig("
|
|
540
|
+
isBlockletServer = () => hasConfig("BLOCKLET_DID");
|
|
522
541
|
env_default = {
|
|
523
542
|
...import_env.env
|
|
524
543
|
};
|
|
@@ -1115,6 +1134,10 @@ var init_context = __esm({
|
|
|
1115
1134
|
peekInstanceDid() {
|
|
1116
1135
|
return this.storage.getStore()?.instanceDid;
|
|
1117
1136
|
}
|
|
1137
|
+
/** Request-scoped externally reachable payment base URL, when supplied by an embedded host. */
|
|
1138
|
+
peekPublicBaseUrl() {
|
|
1139
|
+
return this.storage.getStore()?.publicBaseUrl;
|
|
1140
|
+
}
|
|
1118
1141
|
/**
|
|
1119
1142
|
* Run fn as a system operation: TenantModel scoping is bypassed for the span
|
|
1120
1143
|
* of fn so legitimate cross-tenant reads can load rows regardless of tenant.
|
|
@@ -1132,13 +1155,15 @@ var init_context = __esm({
|
|
|
1132
1155
|
run(context2, fn3) {
|
|
1133
1156
|
const requestId = context2.requestId || `req_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
1134
1157
|
const instanceDid = context2.instanceDid ?? this.storage.getStore()?.instanceDid;
|
|
1158
|
+
const publicBaseUrl = context2.publicBaseUrl ?? this.storage.getStore()?.publicBaseUrl;
|
|
1135
1159
|
this.contexts.set(requestId, {
|
|
1136
1160
|
...context2,
|
|
1137
1161
|
instanceDid,
|
|
1162
|
+
publicBaseUrl,
|
|
1138
1163
|
requestId
|
|
1139
1164
|
});
|
|
1140
1165
|
return new Promise((resolve, reject) => {
|
|
1141
|
-
this.storage.run({ ...context2, instanceDid, requestId }, async () => {
|
|
1166
|
+
this.storage.run({ ...context2, instanceDid, publicBaseUrl, requestId }, async () => {
|
|
1142
1167
|
const resource = new import_async_hooks.AsyncResource("RequestContext");
|
|
1143
1168
|
try {
|
|
1144
1169
|
const result = await resource.runInAsyncScope(fn3);
|
|
@@ -1186,6 +1211,24 @@ var init_logger = __esm({
|
|
|
1186
1211
|
}
|
|
1187
1212
|
});
|
|
1188
1213
|
|
|
1214
|
+
// ../../blocklets/core/api/src/libs/secrets.ts
|
|
1215
|
+
function encryptSecret(value) {
|
|
1216
|
+
return getSecretsDriver().encryptSync(getInstanceDid(), value);
|
|
1217
|
+
}
|
|
1218
|
+
function decryptSecret(value) {
|
|
1219
|
+
return getSecretsDriver().decryptSync(getInstanceDid(), value);
|
|
1220
|
+
}
|
|
1221
|
+
function warmupSecrets(instanceDid) {
|
|
1222
|
+
return getSecretsDriver().warmup(instanceDid ?? getInstanceDid());
|
|
1223
|
+
}
|
|
1224
|
+
var init_secrets2 = __esm({
|
|
1225
|
+
"../../blocklets/core/api/src/libs/secrets.ts"() {
|
|
1226
|
+
"use strict";
|
|
1227
|
+
init_context();
|
|
1228
|
+
init_secrets();
|
|
1229
|
+
}
|
|
1230
|
+
});
|
|
1231
|
+
|
|
1189
1232
|
// ../../blocklets/core/api/src/libs/did-connect/tenant-identity.ts
|
|
1190
1233
|
var tenant_identity_exports = {};
|
|
1191
1234
|
__export(tenant_identity_exports, {
|
|
@@ -1257,7 +1300,14 @@ async function warmTenantIdentity(instanceDidArg) {
|
|
|
1257
1300
|
try {
|
|
1258
1301
|
await resolveTenantIdentity(instanceDidArg);
|
|
1259
1302
|
} catch (err) {
|
|
1260
|
-
logger_default.warn("[tenant-identity] warm failed \u2014 wallet access will fail-closed", {
|
|
1303
|
+
logger_default.warn("[tenant-identity] wallet identity warm failed \u2014 wallet access will fail-closed", {
|
|
1304
|
+
error: err instanceof Error ? err.message : String(err)
|
|
1305
|
+
});
|
|
1306
|
+
}
|
|
1307
|
+
try {
|
|
1308
|
+
await warmupSecrets(instanceDidArg);
|
|
1309
|
+
} catch (err) {
|
|
1310
|
+
logger_default.warn("[tenant-identity] secrets warm failed \u2014 settings/Stripe decrypt will fail-closed", {
|
|
1261
1311
|
error: err instanceof Error ? err.message : String(err)
|
|
1262
1312
|
});
|
|
1263
1313
|
}
|
|
@@ -1282,6 +1332,7 @@ var init_tenant_identity = __esm({
|
|
|
1282
1332
|
init_context();
|
|
1283
1333
|
init_drivers();
|
|
1284
1334
|
init_logger();
|
|
1335
|
+
init_secrets2();
|
|
1285
1336
|
walletType = {
|
|
1286
1337
|
role: Mcrypto.types.RoleType.ROLE_APPLICATION,
|
|
1287
1338
|
pk: Mcrypto.types.KeyType.ED25519,
|
|
@@ -1756,6 +1807,13 @@ var init_auth = __esm({
|
|
|
1756
1807
|
});
|
|
1757
1808
|
|
|
1758
1809
|
// ../../blocklets/core/api/src/libs/util.ts
|
|
1810
|
+
function getPublicAssetUrl(assetUrl) {
|
|
1811
|
+
if (!assetUrl || !assetUrl.startsWith("/") || assetUrl.startsWith("//")) return assetUrl;
|
|
1812
|
+
const basePath = readConfig("PAYMENT_PUBLIC_BASE_PATH");
|
|
1813
|
+
if (!basePath) return (0, import_component.getUrl)(assetUrl);
|
|
1814
|
+
if (assetUrl === basePath || assetUrl.startsWith(`${basePath}/`)) return assetUrl;
|
|
1815
|
+
return (0, import_ufo.joinURL)(basePath, assetUrl);
|
|
1816
|
+
}
|
|
1759
1817
|
function md5(input) {
|
|
1760
1818
|
return import_crypto2.default.createHash("md5").update(input).digest("hex");
|
|
1761
1819
|
}
|
|
@@ -2180,7 +2238,7 @@ function formatLinkWithLocale(url, locale) {
|
|
|
2180
2238
|
return `${url}${separator}locale=${locale}`;
|
|
2181
2239
|
}
|
|
2182
2240
|
}
|
|
2183
|
-
var import_crypto2, import_stream, import_consumers, import_component, import_env4, import_did, import_cbor, import_nanoid, import_ufo, import_axios, import_util, import_get, import_trimEnd, OCAP_PAYMENT_TX_TYPE, MAX_SUBSCRIPTION_ITEM_COUNT, MAX_RETRY_COUNT, MIN_RETRY_MAIL, CHECKOUT_SESSION_TTL, STRIPE_API_VERSION,
|
|
2241
|
+
var import_crypto2, import_stream, import_consumers, import_component, import_env4, import_did, import_cbor, import_nanoid, import_ufo, import_axios, import_util, import_get, import_trimEnd, OCAP_PAYMENT_TX_TYPE, MAX_SUBSCRIPTION_ITEM_COUNT, MAX_RETRY_COUNT, MIN_RETRY_MAIL, CHECKOUT_SESSION_TTL, STRIPE_API_VERSION, stripeEndpoint, googlePlayEndpoint, GOOGLE_PLAY_ENDPOINT, APP_STORE_ENDPOINT, STRIPE_EVENTS, api, getNextRetry, getWebhookJobId, cachedBlockletJsonResult, CACHE_TTL, CURRENCY_SYMBOLS;
|
|
2184
2242
|
var init_util = __esm({
|
|
2185
2243
|
"../../blocklets/core/api/src/libs/util.ts"() {
|
|
2186
2244
|
"use strict";
|
|
@@ -2198,6 +2256,7 @@ var init_util = __esm({
|
|
|
2198
2256
|
import_get = __toESM(require("lodash/get"));
|
|
2199
2257
|
import_trimEnd = __toESM(require("lodash/trimEnd"));
|
|
2200
2258
|
init_env();
|
|
2259
|
+
init_context();
|
|
2201
2260
|
init_dayjs();
|
|
2202
2261
|
init_auth();
|
|
2203
2262
|
init_logger();
|
|
@@ -2207,7 +2266,13 @@ var init_util = __esm({
|
|
|
2207
2266
|
MIN_RETRY_MAIL = 13;
|
|
2208
2267
|
CHECKOUT_SESSION_TTL = 6 * 60 * 60;
|
|
2209
2268
|
STRIPE_API_VERSION = "2023-08-16";
|
|
2210
|
-
|
|
2269
|
+
stripeEndpoint = () => {
|
|
2270
|
+
const override = stripeWebhookUrl();
|
|
2271
|
+
if (override) return override;
|
|
2272
|
+
const publicBaseUrl = context.peekPublicBaseUrl();
|
|
2273
|
+
if (publicBaseUrl) return (0, import_ufo.joinURL)(publicBaseUrl, "/api/integrations/stripe/webhook");
|
|
2274
|
+
return (0, import_component.getUrl)("/api/integrations/stripe/webhook");
|
|
2275
|
+
};
|
|
2211
2276
|
googlePlayEndpoint = () => googlePlayWebhookUrl() || (0, import_component.getUrl)("/api/integrations/google-play/webhook");
|
|
2212
2277
|
GOOGLE_PLAY_ENDPOINT = googlePlayEndpoint();
|
|
2213
2278
|
APP_STORE_ENDPOINT = (0, import_component.getUrl)("/api/integrations/app-store/webhook");
|
|
@@ -2297,6 +2362,11 @@ var init_payment_currency = __esm({
|
|
|
2297
2362
|
init_util();
|
|
2298
2363
|
nextId = createIdGenerator("pc", 12);
|
|
2299
2364
|
PaymentCurrency = class _PaymentCurrency extends TenantModel {
|
|
2365
|
+
toJSON() {
|
|
2366
|
+
const data = super.toJSON();
|
|
2367
|
+
if (data.logo) data.logo = getPublicAssetUrl(data.logo);
|
|
2368
|
+
return data;
|
|
2369
|
+
}
|
|
2300
2370
|
static {
|
|
2301
2371
|
this.GENESIS_ATTRIBUTES = {
|
|
2302
2372
|
id: {
|
|
@@ -9109,21 +9179,6 @@ var init_payment_link = __esm({
|
|
|
9109
9179
|
}
|
|
9110
9180
|
});
|
|
9111
9181
|
|
|
9112
|
-
// ../../blocklets/core/api/src/libs/secrets.ts
|
|
9113
|
-
function encryptSecret(value) {
|
|
9114
|
-
return getSecretsDriver().encryptSync(getInstanceDid(), value);
|
|
9115
|
-
}
|
|
9116
|
-
function decryptSecret(value) {
|
|
9117
|
-
return getSecretsDriver().decryptSync(getInstanceDid(), value);
|
|
9118
|
-
}
|
|
9119
|
-
var init_secrets2 = __esm({
|
|
9120
|
-
"../../blocklets/core/api/src/libs/secrets.ts"() {
|
|
9121
|
-
"use strict";
|
|
9122
|
-
init_context();
|
|
9123
|
-
init_secrets();
|
|
9124
|
-
}
|
|
9125
|
-
});
|
|
9126
|
-
|
|
9127
9182
|
// ../../blocklets/core/api/src/integrations/app-store/apple-root-certs.ts
|
|
9128
9183
|
var APPLE_INC_ROOT_B64, APPLE_ROOT_CA_G2_B64, APPLE_ROOT_CA_G3_B64, APPLE_ROOT_CERTS;
|
|
9129
9184
|
var init_apple_root_certs = __esm({
|
|
@@ -9399,7 +9454,7 @@ function decodeUnsafe(jws) {
|
|
|
9399
9454
|
throw new Error(`AppStore JWS payload not valid JSON: ${err.message}`);
|
|
9400
9455
|
}
|
|
9401
9456
|
}
|
|
9402
|
-
|
|
9457
|
+
function getAllSubscriptionStatuses(originalTransactionId, creds) {
|
|
9403
9458
|
return nativeGetAllSubscriptionStatuses(originalTransactionId, creds);
|
|
9404
9459
|
}
|
|
9405
9460
|
var init_signed_data_verifier = __esm({
|
|
@@ -9966,6 +10021,11 @@ var init_payment_method = __esm({
|
|
|
9966
10021
|
googlePlayClients = /* @__PURE__ */ new Map();
|
|
9967
10022
|
appStoreClients = /* @__PURE__ */ new Map();
|
|
9968
10023
|
PaymentMethod = class _PaymentMethod extends TenantModel {
|
|
10024
|
+
toJSON() {
|
|
10025
|
+
const data = super.toJSON();
|
|
10026
|
+
if (data.logo) data.logo = getPublicAssetUrl(data.logo);
|
|
10027
|
+
return data;
|
|
10028
|
+
}
|
|
9969
10029
|
static {
|
|
9970
10030
|
this.GENESIS_ATTRIBUTES = {
|
|
9971
10031
|
id: {
|
|
@@ -10061,11 +10121,13 @@ var init_payment_method = __esm({
|
|
|
10061
10121
|
}
|
|
10062
10122
|
static encryptSettings(settings) {
|
|
10063
10123
|
const tmp = (0, import_cloneDeep3.default)(settings);
|
|
10064
|
-
if (tmp.stripe) {
|
|
10124
|
+
if (tmp.stripe?.secret_key) {
|
|
10065
10125
|
tmp.stripe.secret_key = encryptSecret(tmp.stripe.secret_key);
|
|
10126
|
+
}
|
|
10127
|
+
if (tmp.stripe?.webhook_signing_secret) {
|
|
10066
10128
|
tmp.stripe.webhook_signing_secret = encryptSecret(tmp.stripe.webhook_signing_secret);
|
|
10067
10129
|
}
|
|
10068
|
-
if (tmp.google_play) {
|
|
10130
|
+
if (tmp.google_play?.service_account_json) {
|
|
10069
10131
|
tmp.google_play.service_account_json = encryptSecret(tmp.google_play.service_account_json);
|
|
10070
10132
|
}
|
|
10071
10133
|
if (tmp.app_store?.private_key_pem) {
|
|
@@ -10078,11 +10140,13 @@ var init_payment_method = __esm({
|
|
|
10078
10140
|
}
|
|
10079
10141
|
static decryptSettings(settings) {
|
|
10080
10142
|
const tmp = (0, import_cloneDeep3.default)(settings);
|
|
10081
|
-
if (tmp.stripe) {
|
|
10143
|
+
if (tmp.stripe?.secret_key) {
|
|
10082
10144
|
tmp.stripe.secret_key = decryptSecret(tmp.stripe.secret_key);
|
|
10145
|
+
}
|
|
10146
|
+
if (tmp.stripe?.webhook_signing_secret) {
|
|
10083
10147
|
tmp.stripe.webhook_signing_secret = decryptSecret(tmp.stripe.webhook_signing_secret);
|
|
10084
10148
|
}
|
|
10085
|
-
if (tmp.google_play) {
|
|
10149
|
+
if (tmp.google_play?.service_account_json) {
|
|
10086
10150
|
tmp.google_play.service_account_json = decryptSecret(tmp.google_play.service_account_json);
|
|
10087
10151
|
}
|
|
10088
10152
|
if (tmp.app_store?.private_key_pem) {
|
|
@@ -10128,7 +10192,7 @@ var init_payment_method = __esm({
|
|
|
10128
10192
|
const host = this.settings.arcblock?.api_host;
|
|
10129
10193
|
const cached = ocapClients.has(host);
|
|
10130
10194
|
if (!cached) {
|
|
10131
|
-
const created = new import_client.default(host);
|
|
10195
|
+
const created = new import_client.default(host, false);
|
|
10132
10196
|
ocapClients.set(host, created);
|
|
10133
10197
|
return created;
|
|
10134
10198
|
}
|
|
@@ -15907,6 +15971,18 @@ function sessionMiddleware(options = {}) {
|
|
|
15907
15971
|
} catch (err) {
|
|
15908
15972
|
return c.json({ error: err.message }, 401);
|
|
15909
15973
|
}
|
|
15974
|
+
if (!result) {
|
|
15975
|
+
const injectedDid = c.req.header("x-user-did");
|
|
15976
|
+
if (injectedDid) {
|
|
15977
|
+
result = {
|
|
15978
|
+
did: injectedDid,
|
|
15979
|
+
role: c.req.header("x-user-role"),
|
|
15980
|
+
provider: c.req.header("x-user-provider"),
|
|
15981
|
+
fullName: decodeURIComponent(c.req.header("x-user-fullname") || ""),
|
|
15982
|
+
walletOS: c.req.header("x-user-wallet-os") || ""
|
|
15983
|
+
};
|
|
15984
|
+
}
|
|
15985
|
+
}
|
|
15910
15986
|
if (result) {
|
|
15911
15987
|
c.set("user", result);
|
|
15912
15988
|
}
|
|
@@ -22764,10 +22840,11 @@ __export(notification_exports, {
|
|
|
22764
22840
|
ensureBlockletSdkTransportGuard: () => ensureBlockletSdkTransportGuard
|
|
22765
22841
|
});
|
|
22766
22842
|
function noopSdkTransport(mod, fns) {
|
|
22767
|
-
const noop =
|
|
22843
|
+
const noop = () => Promise.resolve(void 0);
|
|
22768
22844
|
for (const target of [mod, mod?.default]) {
|
|
22769
|
-
if (
|
|
22770
|
-
|
|
22845
|
+
if (target) {
|
|
22846
|
+
for (const fn3 of fns) target[fn3] = noop;
|
|
22847
|
+
}
|
|
22771
22848
|
}
|
|
22772
22849
|
}
|
|
22773
22850
|
function ensureBlockletSdkTransportGuard() {
|
|
@@ -33814,10 +33891,10 @@ async function handleSubscriptionOnPaymentFailure(subscription, eventType, clien
|
|
|
33814
33891
|
const { interval } = subscription.pending_invoice_item_interval;
|
|
33815
33892
|
const dueUnit = getDueUnit(interval);
|
|
33816
33893
|
const cancelUpdates = {};
|
|
33817
|
-
const
|
|
33894
|
+
const daysUntilCancel = getDaysUntilCancel(subscription);
|
|
33818
33895
|
const cancelSubscription = shouldCancelSubscription(subscription);
|
|
33819
|
-
if (
|
|
33820
|
-
cancelUpdates.cancel_at = subscription.current_period_start +
|
|
33896
|
+
if (daysUntilCancel > 0) {
|
|
33897
|
+
cancelUpdates.cancel_at = subscription.current_period_start + daysUntilCancel * dueUnit;
|
|
33821
33898
|
} else {
|
|
33822
33899
|
cancelUpdates.cancel_at_period_end = true;
|
|
33823
33900
|
}
|
|
@@ -40756,10 +40833,10 @@ var init_payment2 = __esm({
|
|
|
40756
40833
|
return updates.terminate;
|
|
40757
40834
|
}
|
|
40758
40835
|
const dueUnit = getDueUnit(interval);
|
|
40759
|
-
const
|
|
40836
|
+
const daysUntilCancel = getDaysUntilCancel(subscription);
|
|
40760
40837
|
const cancelUpdates = {};
|
|
40761
|
-
if (
|
|
40762
|
-
cancelUpdates.cancel_at = subscription.current_period_start +
|
|
40838
|
+
if (daysUntilCancel > 0) {
|
|
40839
|
+
cancelUpdates.cancel_at = subscription.current_period_start + daysUntilCancel * dueUnit;
|
|
40763
40840
|
} else {
|
|
40764
40841
|
cancelUpdates.cancel_at_period_end = true;
|
|
40765
40842
|
}
|
|
@@ -47438,7 +47515,7 @@ async function ensureWebhookRegistered() {
|
|
|
47438
47515
|
const exist = data.find((webhook) => webhook.metadata?.appPid === import_env29.env.appPid);
|
|
47439
47516
|
if (exist) {
|
|
47440
47517
|
await stripe.webhookEndpoints.update(exist.id, {
|
|
47441
|
-
url:
|
|
47518
|
+
url: stripeEndpoint(),
|
|
47442
47519
|
description: import_env29.env.appName,
|
|
47443
47520
|
enabled_events: STRIPE_EVENTS,
|
|
47444
47521
|
disabled: false
|
|
@@ -47446,7 +47523,7 @@ async function ensureWebhookRegistered() {
|
|
|
47446
47523
|
logger_default.info("stripe webhook updated");
|
|
47447
47524
|
} else {
|
|
47448
47525
|
const result = await stripe.webhookEndpoints.create({
|
|
47449
|
-
url:
|
|
47526
|
+
url: stripeEndpoint(),
|
|
47450
47527
|
description: import_env29.env.appName,
|
|
47451
47528
|
enabled_events: STRIPE_EVENTS,
|
|
47452
47529
|
api_version: STRIPE_API_VERSION,
|
|
@@ -47592,7 +47669,9 @@ var init_payment_methods = __esm({
|
|
|
47592
47669
|
metadata: {}
|
|
47593
47670
|
});
|
|
47594
47671
|
await method.update({ default_currency_id: currency.id });
|
|
47595
|
-
ensureWebhookRegistered().catch(
|
|
47672
|
+
ensureWebhookRegistered().catch(
|
|
47673
|
+
(err) => logger_default.error("ensureWebhookRegistered failed (payments may not reconcile in real-time)", err)
|
|
47674
|
+
);
|
|
47596
47675
|
return c.json({ ...method.toJSON(), payment_currencies: [currency.toJSON()] });
|
|
47597
47676
|
}
|
|
47598
47677
|
if (EVM_CHAIN_TYPES.includes(raw.type)) {
|
|
@@ -47955,7 +48034,9 @@ var init_payment_methods = __esm({
|
|
|
47955
48034
|
}
|
|
47956
48035
|
const updatedMethod = await method.update(updateData);
|
|
47957
48036
|
if (method.type === "stripe") {
|
|
47958
|
-
ensureWebhookRegistered().catch(
|
|
48037
|
+
ensureWebhookRegistered().catch(
|
|
48038
|
+
(err) => logger_default.error("ensureWebhookRegistered failed (payments may not reconcile in real-time)", err)
|
|
48039
|
+
);
|
|
47959
48040
|
}
|
|
47960
48041
|
return c.json(updatedMethod);
|
|
47961
48042
|
} catch (err) {
|
|
@@ -49152,7 +49233,7 @@ var init_subscriptions = __esm({
|
|
|
49152
49233
|
description,
|
|
49153
49234
|
metadata = {},
|
|
49154
49235
|
days_until_due: daysUntilDue,
|
|
49155
|
-
days_until_cancel:
|
|
49236
|
+
days_until_cancel: daysUntilCancel,
|
|
49156
49237
|
billing_cycle_anchor: billingCycleAnchor,
|
|
49157
49238
|
collection_method: collectionMethod,
|
|
49158
49239
|
proration_behavior: prorationBehavior,
|
|
@@ -49244,7 +49325,7 @@ var init_subscriptions = __esm({
|
|
|
49244
49325
|
proration_behavior: prorationBehavior,
|
|
49245
49326
|
payment_behavior: "default_incomplete",
|
|
49246
49327
|
days_until_due: daysUntilDue,
|
|
49247
|
-
days_until_cancel:
|
|
49328
|
+
days_until_cancel: daysUntilCancel,
|
|
49248
49329
|
metadata: formatMetadata(metadata),
|
|
49249
49330
|
service_actions: serviceActions || []
|
|
49250
49331
|
});
|
|
@@ -51706,10 +51787,10 @@ var init_subscriptions = __esm({
|
|
|
51706
51787
|
updates.default_payment_method_id = arcblockMethod.id;
|
|
51707
51788
|
if (body.recalculate_cancel_at !== false) {
|
|
51708
51789
|
if (subscription.cancelation_details && !subscription.cancel_at) {
|
|
51709
|
-
const
|
|
51710
|
-
if (
|
|
51790
|
+
const daysUntilCancel = subscription.days_until_cancel || 0;
|
|
51791
|
+
if (daysUntilCancel > 0) {
|
|
51711
51792
|
const dueUnit = 24 * 60 * 60;
|
|
51712
|
-
updates.cancel_at = subscription.current_period_start +
|
|
51793
|
+
updates.cancel_at = subscription.current_period_start + daysUntilCancel * dueUnit;
|
|
51713
51794
|
} else {
|
|
51714
51795
|
updates.cancel_at_period_end = true;
|
|
51715
51796
|
updates.cancel_at = subscription.current_period_end;
|
|
@@ -60829,7 +60910,7 @@ var init_entitlements = __esm({
|
|
|
60829
60910
|
init_logger();
|
|
60830
60911
|
init_security();
|
|
60831
60912
|
app26 = new import_hono26.Hono();
|
|
60832
|
-
auth18 = authenticate({ component: true,
|
|
60913
|
+
auth18 = authenticate({ component: true, ensureLogin: true });
|
|
60833
60914
|
checkQuerySchema = import_joi25.default.object({
|
|
60834
60915
|
customer_did: import_joi25.default.string().required(),
|
|
60835
60916
|
product_id: import_joi25.default.string().required(),
|
|
@@ -67601,6 +67682,29 @@ var init_collect_batch = __esm({
|
|
|
67601
67682
|
}
|
|
67602
67683
|
});
|
|
67603
67684
|
|
|
67685
|
+
// ../../blocklets/core/api/src/libs/arcblock-transfer.ts
|
|
67686
|
+
async function encodeArcblockTransfer({
|
|
67687
|
+
chainHost,
|
|
67688
|
+
tx,
|
|
67689
|
+
wallet: wallet2
|
|
67690
|
+
}) {
|
|
67691
|
+
const context2 = await (0, import_encode.fetchContext)(chainHost);
|
|
67692
|
+
return (0, import_encode.encodeTx)({
|
|
67693
|
+
type: "TransferV3Tx",
|
|
67694
|
+
tx,
|
|
67695
|
+
wallet: wallet2,
|
|
67696
|
+
chainId: context2.chainId,
|
|
67697
|
+
feeConfig: context2.txFee
|
|
67698
|
+
});
|
|
67699
|
+
}
|
|
67700
|
+
var import_encode;
|
|
67701
|
+
var init_arcblock_transfer = __esm({
|
|
67702
|
+
"../../blocklets/core/api/src/libs/arcblock-transfer.ts"() {
|
|
67703
|
+
"use strict";
|
|
67704
|
+
import_encode = require("@ocap/client/encode");
|
|
67705
|
+
}
|
|
67706
|
+
});
|
|
67707
|
+
|
|
67604
67708
|
// ../../blocklets/core/api/src/libs/chain-error.ts
|
|
67605
67709
|
function parseChainError(err) {
|
|
67606
67710
|
const msg = err?.message ?? String(err);
|
|
@@ -67645,6 +67749,7 @@ var init_pay = __esm({
|
|
|
67645
67749
|
init_token();
|
|
67646
67750
|
init_tx();
|
|
67647
67751
|
init_auth();
|
|
67752
|
+
init_arcblock_transfer();
|
|
67648
67753
|
init_logger();
|
|
67649
67754
|
init_chain_error();
|
|
67650
67755
|
init_payment();
|
|
@@ -67752,20 +67857,30 @@ var init_pay = __esm({
|
|
|
67752
67857
|
}
|
|
67753
67858
|
if (paymentMethod.type === "arcblock") {
|
|
67754
67859
|
try {
|
|
67755
|
-
await paymentIntent.update({ status: "processing" });
|
|
67756
67860
|
const client = paymentMethod.getOcapClient();
|
|
67757
67861
|
const claim = claims.find((x) => x.type === "prepareTx");
|
|
67758
|
-
await client.getContext();
|
|
67759
67862
|
const tx = client.decodeTx(claim.finalTx);
|
|
67760
67863
|
if (claim.delegator && claim.from) {
|
|
67761
67864
|
tx.delegator = claim.delegator;
|
|
67762
67865
|
tx.from = claim.from;
|
|
67763
67866
|
}
|
|
67764
|
-
const
|
|
67867
|
+
const chainHost = paymentMethod.settings.arcblock?.api_host;
|
|
67868
|
+
if (!chainHost) {
|
|
67869
|
+
throw new Error("ArcBlock payment method API host is missing");
|
|
67870
|
+
}
|
|
67871
|
+
const signingWallet = (0, import_wallet5.fromAddress)(userDid);
|
|
67872
|
+
const { object: encodedTx, buffer: buffer2 } = await encodeArcblockTransfer({
|
|
67873
|
+
chainHost,
|
|
67874
|
+
tx,
|
|
67875
|
+
wallet: signingWallet
|
|
67876
|
+
});
|
|
67877
|
+
const gasPayerExtra = await getGasPayerExtra(buffer2, client.pickGasPayerHeaders(request), client);
|
|
67878
|
+
await paymentIntent.update({ status: "processing" });
|
|
67765
67879
|
const txHash = await client.sendTransferV3Tx(
|
|
67766
|
-
//
|
|
67767
|
-
|
|
67768
|
-
|
|
67880
|
+
// Passing the already-encoded signature skips the client's timer-backed
|
|
67881
|
+
// encodeTransferV3Tx/getContext path in Cloudflare Workers.
|
|
67882
|
+
{ tx: encodedTx, wallet: signingWallet, signature: encodedTx.signature },
|
|
67883
|
+
gasPayerExtra
|
|
67769
67884
|
);
|
|
67770
67885
|
const quoteValidation = await validateQuoteForPayment({
|
|
67771
67886
|
checkoutSessionId: checkoutSession?.id,
|
|
@@ -71702,9 +71817,9 @@ async function handlePostConsumptionEvents(context2, params) {
|
|
|
71702
71817
|
const cancelUpdates = {};
|
|
71703
71818
|
const { interval } = context2.subscription.pending_invoice_item_interval;
|
|
71704
71819
|
const dueUnit = getDueUnit(interval);
|
|
71705
|
-
const
|
|
71706
|
-
if (
|
|
71707
|
-
cancelUpdates.cancel_at = context2.subscription.current_period_start +
|
|
71820
|
+
const daysUntilCancel = getDaysUntilCancel(context2.subscription);
|
|
71821
|
+
if (daysUntilCancel > 0) {
|
|
71822
|
+
cancelUpdates.cancel_at = context2.subscription.current_period_start + daysUntilCancel * dueUnit;
|
|
71708
71823
|
} else {
|
|
71709
71824
|
cancelUpdates.cancel_at_period_end = true;
|
|
71710
71825
|
}
|
|
@@ -77287,6 +77402,7 @@ function csrfSecret() {
|
|
|
77287
77402
|
}
|
|
77288
77403
|
function csrf() {
|
|
77289
77404
|
return async (c, next) => {
|
|
77405
|
+
if (readConfig("PAYMENT_DISABLE_CSRF") === "true") return next();
|
|
77290
77406
|
const method = c.req.method.toUpperCase();
|
|
77291
77407
|
const loginToken = (0, import_cookie.getCookie)(c, "login_token");
|
|
77292
77408
|
const existingCsrf = (0, import_cookie.getCookie)(c, "x-csrf-token");
|
|
@@ -77549,10 +77665,18 @@ function buildConnectRoutesHono() {
|
|
|
77549
77665
|
const connectApp = new import_hono43.Hono();
|
|
77550
77666
|
connectApp.use("*", async (c, next) => {
|
|
77551
77667
|
const { context: requestCtx } = (init_context(), __toCommonJS(context_exports));
|
|
77552
|
-
|
|
77668
|
+
const { warmTenantIdentity: warmTenantIdentity2 } = (init_tenant_identity(), __toCommonJS(tenant_identity_exports));
|
|
77669
|
+
const preResolved = requestCtx.peekInstanceDid();
|
|
77670
|
+
if (preResolved) {
|
|
77671
|
+
await warmTenantIdentity2(preResolved);
|
|
77672
|
+
return next();
|
|
77673
|
+
}
|
|
77553
77674
|
const { resolveTenantForHost: resolveTenantForHost2 } = (init_identity(), __toCommonJS(identity_exports));
|
|
77554
77675
|
const instanceDid = await resolveTenantForHost2(c.req.header("host"));
|
|
77555
|
-
return requestCtx.withTenant(instanceDid, () =>
|
|
77676
|
+
return requestCtx.withTenant(instanceDid, async () => {
|
|
77677
|
+
await warmTenantIdentity2(instanceDid);
|
|
77678
|
+
return next();
|
|
77679
|
+
});
|
|
77556
77680
|
});
|
|
77557
77681
|
for (const h of connectHandlerModules()) handlers2.attach(Object.assign({ app: connectApp }, h));
|
|
77558
77682
|
return connectApp;
|
|
@@ -77644,8 +77768,20 @@ async function provisionTenant(instanceDid) {
|
|
|
77644
77768
|
const { fromTokenToUnit: fromTokenToUnit31 } = require("@ocap/util");
|
|
77645
77769
|
const { PaymentMethod: PaymentMethod3, PaymentCurrency: PaymentCurrency3 } = (init_models(), __toCommonJS(models_exports));
|
|
77646
77770
|
const CHAINS = [
|
|
77647
|
-
{
|
|
77648
|
-
|
|
77771
|
+
{
|
|
77772
|
+
chainId: "main",
|
|
77773
|
+
livemode: true,
|
|
77774
|
+
symbol: "ABT",
|
|
77775
|
+
label: "ArcBlock Main",
|
|
77776
|
+
contract: "z35nNRvYxBoHitx9yZ5ATS88psfShzPPBLxYD"
|
|
77777
|
+
},
|
|
77778
|
+
{
|
|
77779
|
+
chainId: "beta",
|
|
77780
|
+
livemode: false,
|
|
77781
|
+
symbol: "TBA",
|
|
77782
|
+
label: "ArcBlock Beta",
|
|
77783
|
+
contract: "z35n6UoHSi9MED4uaQy6ozFgKPaZj2UKrurBG"
|
|
77784
|
+
}
|
|
77649
77785
|
];
|
|
77650
77786
|
await context.withTenant(instanceDid, async () => {
|
|
77651
77787
|
const existing = await PaymentMethod3.findOne({ where: { type: "arcblock" } });
|
|
@@ -77921,9 +78057,52 @@ var init_service2 = __esm({
|
|
|
77921
78057
|
}
|
|
77922
78058
|
});
|
|
77923
78059
|
|
|
78060
|
+
// ../../blocklets/core/api/src/host-glue.ts
|
|
78061
|
+
var host_glue_exports = {};
|
|
78062
|
+
__export(host_glue_exports, {
|
|
78063
|
+
PAYMENT_PREFIX: () => PAYMENT_PREFIX,
|
|
78064
|
+
USER_HEADERS: () => USER_HEADERS,
|
|
78065
|
+
createTenantProvisioner: () => createTenantProvisioner,
|
|
78066
|
+
injectCaller: () => injectCaller
|
|
78067
|
+
});
|
|
78068
|
+
function injectCaller(headers, caller) {
|
|
78069
|
+
for (const h of USER_HEADERS) headers.delete(h);
|
|
78070
|
+
if (!caller) return;
|
|
78071
|
+
const canonicalDid2 = caller.did?.startsWith("did:abt:") ? caller.did : `did:abt:${caller.did}`;
|
|
78072
|
+
headers.set("x-user-did", canonicalDid2);
|
|
78073
|
+
headers.set("x-user-role", caller.role || "guest");
|
|
78074
|
+
headers.set("x-user-provider", caller.authMethod === "access-key" ? "access-key" : caller.authMethod || "wallet");
|
|
78075
|
+
headers.set("x-user-fullname", encodeURIComponent(caller.displayName || ""));
|
|
78076
|
+
headers.set("x-user-wallet-os", "");
|
|
78077
|
+
}
|
|
78078
|
+
function createTenantProvisioner(provision) {
|
|
78079
|
+
const inflight = /* @__PURE__ */ new Map();
|
|
78080
|
+
return (instanceDid) => {
|
|
78081
|
+
if (!instanceDid) return Promise.resolve();
|
|
78082
|
+
let p = inflight.get(instanceDid);
|
|
78083
|
+
if (!p) {
|
|
78084
|
+
p = provision(instanceDid).catch((err) => {
|
|
78085
|
+
inflight.delete(instanceDid);
|
|
78086
|
+
throw err;
|
|
78087
|
+
});
|
|
78088
|
+
inflight.set(instanceDid, p);
|
|
78089
|
+
}
|
|
78090
|
+
return p;
|
|
78091
|
+
};
|
|
78092
|
+
}
|
|
78093
|
+
var PAYMENT_PREFIX, USER_HEADERS;
|
|
78094
|
+
var init_host_glue = __esm({
|
|
78095
|
+
"../../blocklets/core/api/src/host-glue.ts"() {
|
|
78096
|
+
"use strict";
|
|
78097
|
+
PAYMENT_PREFIX = "/.well-known/payment";
|
|
78098
|
+
USER_HEADERS = ["x-user-did", "x-user-role", "x-user-provider", "x-user-fullname", "x-user-wallet-os"];
|
|
78099
|
+
}
|
|
78100
|
+
});
|
|
78101
|
+
|
|
77924
78102
|
// src/index.ts
|
|
77925
78103
|
var src_exports = {};
|
|
77926
78104
|
__export(src_exports, {
|
|
78105
|
+
PAYMENT_PREFIX: () => PAYMENT_PREFIX2,
|
|
77927
78106
|
applyPaymentCoreMigrations: () => applyPaymentCoreMigrations2,
|
|
77928
78107
|
applySqlMigrations: () => applySqlMigrations2,
|
|
77929
78108
|
createAuthStorage: () => createAuthStorage2,
|
|
@@ -77939,11 +78118,13 @@ __export(src_exports, {
|
|
|
77939
78118
|
createNodeDbDriver: () => createNodeDbDriver2,
|
|
77940
78119
|
createNodeDidConnectRuntime: () => createNodeDidConnectRuntime2,
|
|
77941
78120
|
createNodeStaticHandler: () => createNodeStaticHandler2,
|
|
78121
|
+
createTenantProvisioner: () => createTenantProvisioner2,
|
|
77942
78122
|
getCronDriver: () => getCronDriver2,
|
|
77943
78123
|
getIdentityDriver: () => getIdentityDriver2,
|
|
77944
78124
|
getPaymentCoreSqlMigrations: () => getPaymentCoreSqlMigrations,
|
|
77945
78125
|
getQueueHostHooks: () => getQueueHostHooks2,
|
|
77946
78126
|
getSecretsDriver: () => getSecretsDriver2,
|
|
78127
|
+
injectCaller: () => injectCaller2,
|
|
77947
78128
|
matchesCron: () => matchesCron2,
|
|
77948
78129
|
nodeQueueHostHooks: () => nodeQueueHostHooks2,
|
|
77949
78130
|
scopedLockName: () => scopedLockName2,
|
|
@@ -78050,8 +78231,16 @@ function createEmbeddedPaymentService2(slots) {
|
|
|
78050
78231
|
const core = (init_service2(), __toCommonJS(service_exports));
|
|
78051
78232
|
return core.createEmbeddedPaymentService(slots);
|
|
78052
78233
|
}
|
|
78234
|
+
var PAYMENT_PREFIX2 = "/.well-known/payment";
|
|
78235
|
+
function injectCaller2(headers, caller) {
|
|
78236
|
+
return (init_host_glue(), __toCommonJS(host_glue_exports)).injectCaller(headers, caller);
|
|
78237
|
+
}
|
|
78238
|
+
function createTenantProvisioner2(provision) {
|
|
78239
|
+
return (init_host_glue(), __toCommonJS(host_glue_exports)).createTenantProvisioner(provision);
|
|
78240
|
+
}
|
|
78053
78241
|
// Annotate the CommonJS export names for ESM import in node:
|
|
78054
78242
|
0 && (module.exports = {
|
|
78243
|
+
PAYMENT_PREFIX,
|
|
78055
78244
|
applyPaymentCoreMigrations,
|
|
78056
78245
|
applySqlMigrations,
|
|
78057
78246
|
createAuthStorage,
|
|
@@ -78067,11 +78256,13 @@ function createEmbeddedPaymentService2(slots) {
|
|
|
78067
78256
|
createNodeDbDriver,
|
|
78068
78257
|
createNodeDidConnectRuntime,
|
|
78069
78258
|
createNodeStaticHandler,
|
|
78259
|
+
createTenantProvisioner,
|
|
78070
78260
|
getCronDriver,
|
|
78071
78261
|
getIdentityDriver,
|
|
78072
78262
|
getPaymentCoreSqlMigrations,
|
|
78073
78263
|
getQueueHostHooks,
|
|
78074
78264
|
getSecretsDriver,
|
|
78265
|
+
injectCaller,
|
|
78075
78266
|
matchesCron,
|
|
78076
78267
|
nodeQueueHostHooks,
|
|
78077
78268
|
scopedLockName,
|