@owlmeans/server-payment 0.1.18-rc.9 → 0.1.18
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/README.md +157 -26
- package/agent-meta/manifest.json +30 -4
- package/agent-meta/skills/server-payment/SKILL.md +613 -54
- package/agent-meta/skills/server-payment/parts/reference.md +174 -0
- package/build/access/types.d.ts +46 -0
- package/build/access/types.d.ts.map +1 -0
- package/build/access/types.js +2 -0
- package/build/access/types.js.map +1 -0
- package/build/access.d.ts +6 -0
- package/build/access.d.ts.map +1 -0
- package/build/access.js +45 -0
- package/build/access.js.map +1 -0
- package/build/actions/index.d.ts +1 -0
- package/build/actions/index.d.ts.map +1 -1
- package/build/actions/index.js +1 -0
- package/build/actions/index.js.map +1 -1
- package/build/actions/resync-subscriptions.d.ts +3 -0
- package/build/actions/resync-subscriptions.d.ts.map +1 -0
- package/build/actions/resync-subscriptions.js +7 -0
- package/build/actions/resync-subscriptions.js.map +1 -0
- package/build/actions/resync.d.ts +6 -1
- package/build/actions/resync.d.ts.map +1 -1
- package/build/actions/resync.js +15 -5
- package/build/actions/resync.js.map +1 -1
- package/build/actions/webhook.d.ts +2 -1
- package/build/actions/webhook.d.ts.map +1 -1
- package/build/actions/webhook.js +10 -4
- package/build/actions/webhook.js.map +1 -1
- package/build/bootstrap/types.d.ts +16 -0
- package/build/bootstrap/types.d.ts.map +1 -0
- package/build/bootstrap/types.js +2 -0
- package/build/bootstrap/types.js.map +1 -0
- package/build/bootstrap.d.ts +6 -0
- package/build/bootstrap.d.ts.map +1 -0
- package/build/bootstrap.js +26 -0
- package/build/bootstrap.js.map +1 -0
- package/build/catalogue/types.d.ts +38 -0
- package/build/catalogue/types.d.ts.map +1 -0
- package/build/catalogue/types.js +2 -0
- package/build/catalogue/types.js.map +1 -0
- package/build/catalogue.d.ts +6 -0
- package/build/catalogue.d.ts.map +1 -0
- package/build/catalogue.js +110 -0
- package/build/catalogue.js.map +1 -0
- package/build/commit/types.d.ts +22 -0
- package/build/commit/types.d.ts.map +1 -0
- package/build/commit/types.js +2 -0
- package/build/commit/types.js.map +1 -0
- package/build/commit.d.ts +6 -0
- package/build/commit.d.ts.map +1 -0
- package/build/commit.js +125 -0
- package/build/commit.js.map +1 -0
- package/build/config.d.ts +44 -5
- package/build/config.d.ts.map +1 -1
- package/build/config.js +216 -10
- package/build/config.js.map +1 -1
- package/build/consts.d.ts +74 -16
- package/build/consts.d.ts.map +1 -1
- package/build/consts.js +86 -23
- package/build/consts.js.map +1 -1
- package/build/consts.local.d.ts +94 -0
- package/build/consts.local.d.ts.map +1 -0
- package/build/consts.local.js +44 -0
- package/build/consts.local.js.map +1 -0
- package/build/consumer/cancellation/types.d.ts +11 -0
- package/build/consumer/cancellation/types.d.ts.map +1 -0
- package/build/consumer/cancellation/types.js +2 -0
- package/build/consumer/cancellation/types.js.map +1 -0
- package/build/consumer/cancellation.d.ts +6 -0
- package/build/consumer/cancellation.d.ts.map +1 -0
- package/build/consumer/cancellation.js +33 -0
- package/build/consumer/cancellation.js.map +1 -0
- package/build/consumer/capture/types.d.ts +50 -0
- package/build/consumer/capture/types.d.ts.map +1 -0
- package/build/consumer/capture/types.js +2 -0
- package/build/consumer/capture/types.js.map +1 -0
- package/build/consumer/capture.d.ts +6 -0
- package/build/consumer/capture.d.ts.map +1 -0
- package/build/consumer/capture.js +284 -0
- package/build/consumer/capture.js.map +1 -0
- package/build/consumer/consts.local.d.ts +10 -0
- package/build/consumer/consts.local.d.ts.map +1 -0
- package/build/consumer/consts.local.js +11 -0
- package/build/consumer/consts.local.js.map +1 -0
- package/build/consumer/format/types.d.ts +30 -0
- package/build/consumer/format/types.d.ts.map +1 -0
- package/build/consumer/format/types.js +2 -0
- package/build/consumer/format/types.js.map +1 -0
- package/build/consumer/format.d.ts +4 -0
- package/build/consumer/format.d.ts.map +1 -0
- package/build/consumer/format.js +73 -0
- package/build/consumer/format.js.map +1 -0
- package/build/consumer/handlers.d.ts +21 -0
- package/build/consumer/handlers.d.ts.map +1 -0
- package/build/consumer/handlers.js +174 -0
- package/build/consumer/handlers.js.map +1 -0
- package/build/consumer/index.d.ts +10 -0
- package/build/consumer/index.d.ts.map +1 -0
- package/build/consumer/index.js +6 -0
- package/build/consumer/index.js.map +1 -0
- package/build/consumer/mail/types.d.ts +29 -0
- package/build/consumer/mail/types.d.ts.map +1 -0
- package/build/consumer/mail/types.js +2 -0
- package/build/consumer/mail/types.js.map +1 -0
- package/build/consumer/mail.d.ts +6 -0
- package/build/consumer/mail.d.ts.map +1 -0
- package/build/consumer/mail.js +313 -0
- package/build/consumer/mail.js.map +1 -0
- package/build/consumer/observers/types.d.ts +15 -0
- package/build/consumer/observers/types.d.ts.map +1 -0
- package/build/consumer/observers/types.js +2 -0
- package/build/consumer/observers/types.js.map +1 -0
- package/build/consumer/observers.d.ts +6 -0
- package/build/consumer/observers.d.ts.map +1 -0
- package/build/consumer/observers.js +74 -0
- package/build/consumer/observers.js.map +1 -0
- package/build/consumer/origin/types.d.ts +17 -0
- package/build/consumer/origin/types.d.ts.map +1 -0
- package/build/consumer/origin/types.js +2 -0
- package/build/consumer/origin/types.js.map +1 -0
- package/build/consumer/origin.d.ts +8 -0
- package/build/consumer/origin.d.ts.map +1 -0
- package/build/consumer/origin.js +43 -0
- package/build/consumer/origin.js.map +1 -0
- package/build/consumer/reconcile/types.d.ts +13 -0
- package/build/consumer/reconcile/types.d.ts.map +1 -0
- package/build/consumer/reconcile/types.js +2 -0
- package/build/consumer/reconcile/types.js.map +1 -0
- package/build/consumer/reconcile.d.ts +5 -0
- package/build/consumer/reconcile.d.ts.map +1 -0
- package/build/consumer/reconcile.js +320 -0
- package/build/consumer/reconcile.js.map +1 -0
- package/build/consumer/records/types.d.ts +66 -0
- package/build/consumer/records/types.d.ts.map +1 -0
- package/build/consumer/records/types.js +2 -0
- package/build/consumer/records/types.js.map +1 -0
- package/build/consumer/records.d.ts +6 -0
- package/build/consumer/records.d.ts.map +1 -0
- package/build/consumer/records.js +243 -0
- package/build/consumer/records.js.map +1 -0
- package/build/consumer/service.d.ts +28 -0
- package/build/consumer/service.d.ts.map +1 -0
- package/build/consumer/service.js +706 -0
- package/build/consumer/service.js.map +1 -0
- package/build/consumer/types.d.ts +84 -0
- package/build/consumer/types.d.ts.map +1 -0
- package/build/consumer/types.js +2 -0
- package/build/consumer/types.js.map +1 -0
- package/build/consumer/types.local.d.ts +26 -0
- package/build/consumer/types.local.d.ts.map +1 -0
- package/build/consumer/types.local.js +2 -0
- package/build/consumer/types.local.js.map +1 -0
- package/build/consumer/withdrawal/types.d.ts +36 -0
- package/build/consumer/withdrawal/types.d.ts.map +1 -0
- package/build/consumer/withdrawal/types.js +2 -0
- package/build/consumer/withdrawal/types.js.map +1 -0
- package/build/consumer/withdrawal.d.ts +6 -0
- package/build/consumer/withdrawal.d.ts.map +1 -0
- package/build/consumer/withdrawal.js +237 -0
- package/build/consumer/withdrawal.js.map +1 -0
- package/build/entitlement.d.ts +4 -0
- package/build/entitlement.d.ts.map +1 -0
- package/build/entitlement.js +72 -0
- package/build/entitlement.js.map +1 -0
- package/build/entrypoints.d.ts +19 -2
- package/build/entrypoints.d.ts.map +1 -1
- package/build/entrypoints.js +16 -4
- package/build/entrypoints.js.map +1 -1
- package/build/gate/request.d.ts +4 -0
- package/build/gate/request.d.ts.map +1 -0
- package/build/gate/request.js +17 -0
- package/build/gate/request.js.map +1 -0
- package/build/gate/types.d.ts +15 -0
- package/build/gate/types.d.ts.map +1 -0
- package/build/gate/types.js +2 -0
- package/build/gate/types.js.map +1 -0
- package/build/gate.d.ts +13 -9
- package/build/gate.d.ts.map +1 -1
- package/build/gate.js +36 -21
- package/build/gate.js.map +1 -1
- package/build/index.d.ts +50 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +29 -3
- package/build/index.js.map +1 -1
- package/build/limit.d.ts +11 -0
- package/build/limit.d.ts.map +1 -0
- package/build/limit.js +48 -0
- package/build/limit.js.map +1 -0
- package/build/log.d.ts +3 -0
- package/build/log.d.ts.map +1 -0
- package/build/log.js +4 -0
- package/build/log.js.map +1 -0
- package/build/models/declarations/types.d.ts +22 -0
- package/build/models/declarations/types.d.ts.map +1 -0
- package/build/models/declarations/types.js +2 -0
- package/build/models/declarations/types.js.map +1 -0
- package/build/models/declarations.d.ts +4 -0
- package/build/models/declarations.d.ts.map +1 -0
- package/build/models/declarations.js +26 -0
- package/build/models/declarations.js.map +1 -0
- package/build/models/purchase/types.d.ts +13 -0
- package/build/models/purchase/types.d.ts.map +1 -0
- package/build/models/purchase/types.js +2 -0
- package/build/models/purchase/types.js.map +1 -0
- package/build/models/purchase.d.ts +4 -0
- package/build/models/purchase.d.ts.map +1 -0
- package/build/models/purchase.js +37 -0
- package/build/models/purchase.js.map +1 -0
- package/build/observer.d.ts +9 -0
- package/build/observer.d.ts.map +1 -1
- package/build/observer.js +38 -12
- package/build/observer.js.map +1 -1
- package/build/plan/types.d.ts +21 -0
- package/build/plan/types.d.ts.map +1 -0
- package/build/plan/types.js +2 -0
- package/build/plan/types.js.map +1 -0
- package/build/plan.d.ts +7 -0
- package/build/plan.d.ts.map +1 -0
- package/build/plan.js +29 -0
- package/build/plan.js.map +1 -0
- package/build/plugins/checkout-plugins/types.d.ts +25 -0
- package/build/plugins/checkout-plugins/types.d.ts.map +1 -0
- package/build/plugins/checkout-plugins/types.js +2 -0
- package/build/plugins/checkout-plugins/types.js.map +1 -0
- package/build/plugins/checkout-plugins.d.ts +12 -0
- package/build/plugins/checkout-plugins.d.ts.map +1 -0
- package/build/plugins/checkout-plugins.js +72 -0
- package/build/plugins/checkout-plugins.js.map +1 -0
- package/build/plugins/checkout-policy/types.d.ts +18 -0
- package/build/plugins/checkout-policy/types.d.ts.map +1 -0
- package/build/plugins/checkout-policy/types.js +2 -0
- package/build/plugins/checkout-policy/types.js.map +1 -0
- package/build/plugins/checkout-policy.d.ts +4 -0
- package/build/plugins/checkout-policy.d.ts.map +1 -0
- package/build/plugins/checkout-policy.js +26 -0
- package/build/plugins/checkout-policy.js.map +1 -0
- package/build/plugins/checkout-registry/types.d.ts +7 -0
- package/build/plugins/checkout-registry/types.d.ts.map +1 -0
- package/build/plugins/checkout-registry/types.js +2 -0
- package/build/plugins/checkout-registry/types.js.map +1 -0
- package/build/plugins/checkout-registry.d.ts +8 -0
- package/build/plugins/checkout-registry.d.ts.map +1 -0
- package/build/plugins/checkout-registry.js +21 -0
- package/build/plugins/checkout-registry.js.map +1 -0
- package/build/plugins/consts.local.d.ts +13 -0
- package/build/plugins/consts.local.d.ts.map +1 -0
- package/build/plugins/consts.local.js +22 -0
- package/build/plugins/consts.local.js.map +1 -0
- package/build/plugins/customer-lock/types.d.ts +6 -0
- package/build/plugins/customer-lock/types.d.ts.map +1 -0
- package/build/plugins/customer-lock/types.js +2 -0
- package/build/plugins/customer-lock/types.js.map +1 -0
- package/build/plugins/customer-lock.d.ts +5 -0
- package/build/plugins/customer-lock.d.ts.map +1 -0
- package/build/plugins/customer-lock.js +22 -0
- package/build/plugins/customer-lock.js.map +1 -0
- package/build/plugins/estimate/cache.d.ts +4 -0
- package/build/plugins/estimate/cache.d.ts.map +1 -0
- package/build/plugins/estimate/cache.js +7 -0
- package/build/plugins/estimate/cache.js.map +1 -0
- package/build/plugins/estimate/types.d.ts +27 -0
- package/build/plugins/estimate/types.d.ts.map +1 -0
- package/build/plugins/estimate/types.js +2 -0
- package/build/plugins/estimate/types.js.map +1 -0
- package/build/plugins/estimate.d.ts +6 -0
- package/build/plugins/estimate.d.ts.map +1 -0
- package/build/plugins/estimate.js +271 -0
- package/build/plugins/estimate.js.map +1 -0
- package/build/plugins/events/types.d.ts +12 -0
- package/build/plugins/events/types.d.ts.map +1 -0
- package/build/plugins/events/types.js +2 -0
- package/build/plugins/events/types.js.map +1 -0
- package/build/plugins/events.d.ts +6 -13
- package/build/plugins/events.d.ts.map +1 -1
- package/build/plugins/events.js +441 -144
- package/build/plugins/events.js.map +1 -1
- package/build/plugins/fx/types.d.ts +33 -0
- package/build/plugins/fx/types.d.ts.map +1 -0
- package/build/plugins/fx/types.js +2 -0
- package/build/plugins/fx/types.js.map +1 -0
- package/build/plugins/fx.d.ts +6 -0
- package/build/plugins/fx.d.ts.map +1 -0
- package/build/plugins/fx.js +83 -0
- package/build/plugins/fx.js.map +1 -0
- package/build/plugins/portal/types.d.ts +44 -0
- package/build/plugins/portal/types.d.ts.map +1 -0
- package/build/plugins/portal/types.js +2 -0
- package/build/plugins/portal/types.js.map +1 -0
- package/build/plugins/portal.d.ts +6 -0
- package/build/plugins/portal.d.ts.map +1 -0
- package/build/plugins/portal.js +255 -0
- package/build/plugins/portal.js.map +1 -0
- package/build/plugins/refunds/types.d.ts +35 -0
- package/build/plugins/refunds/types.d.ts.map +1 -0
- package/build/plugins/refunds/types.js +2 -0
- package/build/plugins/refunds/types.js.map +1 -0
- package/build/plugins/refunds.d.ts +6 -0
- package/build/plugins/refunds.d.ts.map +1 -0
- package/build/plugins/refunds.js +81 -0
- package/build/plugins/refunds.js.map +1 -0
- package/build/plugins/session/types.d.ts +32 -0
- package/build/plugins/session/types.d.ts.map +1 -0
- package/build/plugins/session/types.js +2 -0
- package/build/plugins/session/types.js.map +1 -0
- package/build/plugins/session.d.ts +4 -0
- package/build/plugins/session.d.ts.map +1 -0
- package/build/plugins/session.js +58 -0
- package/build/plugins/session.js.map +1 -0
- package/build/plugins/status.d.ts +8 -0
- package/build/plugins/status.d.ts.map +1 -0
- package/build/plugins/status.js +21 -0
- package/build/plugins/status.js.map +1 -0
- package/build/plugins/stripe/types.d.ts +20 -0
- package/build/plugins/stripe/types.d.ts.map +1 -0
- package/build/plugins/stripe/types.js +2 -0
- package/build/plugins/stripe/types.js.map +1 -0
- package/build/plugins/stripe.d.ts +5 -13
- package/build/plugins/stripe.d.ts.map +1 -1
- package/build/plugins/stripe.js +481 -129
- package/build/plugins/stripe.js.map +1 -1
- package/build/plugins/subscriptions/types.d.ts +41 -0
- package/build/plugins/subscriptions/types.d.ts.map +1 -0
- package/build/plugins/subscriptions/types.js +2 -0
- package/build/plugins/subscriptions/types.js.map +1 -0
- package/build/plugins/subscriptions.d.ts +6 -0
- package/build/plugins/subscriptions.d.ts.map +1 -0
- package/build/plugins/subscriptions.js +169 -0
- package/build/plugins/subscriptions.js.map +1 -0
- package/build/plugins/types.d.ts +7 -0
- package/build/plugins/types.d.ts.map +1 -0
- package/build/plugins/types.js +2 -0
- package/build/plugins/types.js.map +1 -0
- package/build/plugins/types.local.d.ts +75 -0
- package/build/plugins/types.local.d.ts.map +1 -0
- package/build/plugins/types.local.js +2 -0
- package/build/plugins/types.local.js.map +1 -0
- package/build/plugins/webhook-manager/types.d.ts +62 -0
- package/build/plugins/webhook-manager/types.d.ts.map +1 -0
- package/build/plugins/webhook-manager/types.js +2 -0
- package/build/plugins/webhook-manager/types.js.map +1 -0
- package/build/plugins/webhook-manager.d.ts +8 -0
- package/build/plugins/webhook-manager.d.ts.map +1 -0
- package/build/plugins/webhook-manager.js +245 -0
- package/build/plugins/webhook-manager.js.map +1 -0
- package/build/protocol.d.ts +13 -0
- package/build/protocol.d.ts.map +1 -0
- package/build/protocol.js +17 -0
- package/build/protocol.js.map +1 -0
- package/build/reconcile/types.d.ts +17 -0
- package/build/reconcile/types.d.ts.map +1 -0
- package/build/reconcile/types.js +2 -0
- package/build/reconcile/types.js.map +1 -0
- package/build/reconcile.d.ts +12 -0
- package/build/reconcile.d.ts.map +1 -0
- package/build/reconcile.js +91 -0
- package/build/reconcile.js.map +1 -0
- package/build/resource.d.ts +12 -1
- package/build/resource.d.ts.map +1 -1
- package/build/resource.js +97 -6
- package/build/resource.js.map +1 -1
- package/build/schemas.d.ts +19 -0
- package/build/schemas.d.ts.map +1 -0
- package/build/schemas.js +244 -0
- package/build/schemas.js.map +1 -0
- package/build/service.d.ts +28 -3
- package/build/service.d.ts.map +1 -1
- package/build/service.js +140 -19
- package/build/service.js.map +1 -1
- package/build/subscription/types.d.ts +21 -0
- package/build/subscription/types.d.ts.map +1 -0
- package/build/subscription/types.js +2 -0
- package/build/subscription/types.js.map +1 -0
- package/build/subscription.d.ts +4 -0
- package/build/subscription.d.ts.map +1 -0
- package/build/subscription.js +84 -0
- package/build/subscription.js.map +1 -0
- package/build/sync/types.d.ts +25 -0
- package/build/sync/types.d.ts.map +1 -0
- package/build/sync/types.js +2 -0
- package/build/sync/types.js.map +1 -0
- package/build/sync.d.ts +4 -3
- package/build/sync.d.ts.map +1 -1
- package/build/sync.js +231 -79
- package/build/sync.js.map +1 -1
- package/build/types.d.ts +1258 -36
- package/build/types.d.ts.map +1 -1
- package/build/types.local.d.ts +22 -0
- package/build/types.local.d.ts.map +1 -0
- package/build/types.local.js +2 -0
- package/build/types.local.js.map +1 -0
- package/build/usage/types.d.ts +56 -0
- package/build/usage/types.d.ts.map +1 -0
- package/build/usage/types.js +2 -0
- package/build/usage/types.js.map +1 -0
- package/build/usage.d.ts +6 -0
- package/build/usage.d.ts.map +1 -0
- package/build/usage.js +365 -0
- package/build/usage.js.map +1 -0
- package/build/utils/types.d.ts +31 -0
- package/build/utils/types.d.ts.map +1 -0
- package/build/utils/types.js +2 -0
- package/build/utils/types.js.map +1 -0
- package/build/utils.d.ts +21 -7
- package/build/utils.d.ts.map +1 -1
- package/build/utils.js +56 -17
- package/build/utils.js.map +1 -1
- package/package.json +22 -17
- package/src/access/types.ts +52 -0
- package/src/access.ts +86 -0
- package/src/actions/index.ts +1 -0
- package/src/actions/resync-subscriptions.ts +10 -0
- package/src/actions/resync.ts +14 -5
- package/src/actions/webhook.ts +9 -4
- package/src/bootstrap/types.ts +16 -0
- package/src/bootstrap.ts +31 -0
- package/src/catalogue/types.ts +32 -0
- package/src/catalogue.ts +135 -0
- package/src/commit/types.ts +27 -0
- package/src/commit.ts +152 -0
- package/src/config.ts +234 -14
- package/src/consts.local.ts +62 -0
- package/src/consts.ts +100 -36
- package/src/consumer/cancellation/types.ts +13 -0
- package/src/consumer/cancellation.ts +43 -0
- package/src/consumer/capture/types.ts +53 -0
- package/src/consumer/capture.ts +321 -0
- package/src/consumer/consts.local.ts +18 -0
- package/src/consumer/format/types.ts +29 -0
- package/src/consumer/format.ts +85 -0
- package/src/consumer/handlers.ts +204 -0
- package/src/consumer/index.ts +9 -0
- package/src/consumer/mail/types.ts +31 -0
- package/src/consumer/mail.ts +353 -0
- package/src/consumer/observers/types.ts +22 -0
- package/src/consumer/observers.ts +97 -0
- package/src/consumer/origin/types.ts +17 -0
- package/src/consumer/origin.ts +61 -0
- package/src/consumer/reconcile/types.ts +13 -0
- package/src/consumer/reconcile.ts +330 -0
- package/src/consumer/records/types.ts +64 -0
- package/src/consumer/records.ts +288 -0
- package/src/consumer/service.ts +768 -0
- package/src/consumer/types.local.ts +22 -0
- package/src/consumer/types.ts +96 -0
- package/src/consumer/withdrawal/types.ts +37 -0
- package/src/consumer/withdrawal.ts +268 -0
- package/src/entitlement.ts +85 -0
- package/src/entrypoints.ts +17 -4
- package/src/gate/request.ts +24 -0
- package/src/gate/types.ts +13 -0
- package/src/gate.ts +47 -30
- package/src/index.ts +55 -3
- package/src/limit.ts +54 -0
- package/src/log.ts +4 -0
- package/src/models/declarations/types.ts +22 -0
- package/src/models/declarations.ts +30 -0
- package/src/models/purchase/types.ts +13 -0
- package/src/models/purchase.ts +43 -0
- package/src/observer.ts +44 -11
- package/src/plan/types.ts +21 -0
- package/src/plan.ts +46 -0
- package/src/plugins/checkout-plugins/types.ts +25 -0
- package/src/plugins/checkout-plugins.ts +90 -0
- package/src/plugins/checkout-policy/types.ts +18 -0
- package/src/plugins/checkout-policy.ts +34 -0
- package/src/plugins/checkout-registry/types.ts +7 -0
- package/src/plugins/checkout-registry.ts +23 -0
- package/src/plugins/consts.local.ts +30 -0
- package/src/plugins/customer-lock/types.ts +5 -0
- package/src/plugins/customer-lock.ts +25 -0
- package/src/plugins/estimate/cache.ts +12 -0
- package/src/plugins/estimate/types.ts +28 -0
- package/src/plugins/estimate.ts +305 -0
- package/src/plugins/events/types.ts +11 -0
- package/src/plugins/events.ts +466 -132
- package/src/plugins/fx/types.ts +40 -0
- package/src/plugins/fx.ts +101 -0
- package/src/plugins/portal/types.ts +45 -0
- package/src/plugins/portal.ts +284 -0
- package/src/plugins/refunds/types.ts +31 -0
- package/src/plugins/refunds.ts +95 -0
- package/src/plugins/session/types.ts +28 -0
- package/src/plugins/session.ts +73 -0
- package/src/plugins/status.ts +22 -0
- package/src/plugins/stripe/types.ts +20 -0
- package/src/plugins/stripe.ts +523 -135
- package/src/plugins/subscriptions/types.ts +39 -0
- package/src/plugins/subscriptions.ts +195 -0
- package/src/plugins/types.local.ts +61 -0
- package/src/plugins/types.ts +7 -0
- package/src/plugins/webhook-manager/types.ts +63 -0
- package/src/plugins/webhook-manager.ts +288 -0
- package/src/protocol.ts +29 -0
- package/src/reconcile/types.ts +17 -0
- package/src/reconcile.ts +110 -0
- package/src/resource.ts +158 -11
- package/src/schemas.ts +271 -0
- package/src/service.ts +161 -19
- package/src/subscription/types.ts +23 -0
- package/src/subscription.ts +104 -0
- package/src/sync/types.ts +25 -0
- package/src/sync.ts +255 -72
- package/src/types.local.ts +18 -0
- package/src/types.ts +1365 -32
- package/src/usage/types.ts +51 -0
- package/src/usage.ts +432 -0
- package/src/utils/types.ts +30 -0
- package/src/utils.ts +94 -29
- package/tests/checkout-consumer.spec.ts +366 -0
- package/tests/checkout-locks.spec.ts +161 -0
- package/tests/checkout-plugins.spec.ts +164 -0
- package/tests/checkout.spec.ts +209 -93
- package/tests/consumer-events.spec.ts +215 -0
- package/tests/consumer-fixtures.ts +134 -0
- package/tests/consumer-ops.spec.ts +350 -0
- package/tests/consumer-rights.integration.spec.ts +147 -0
- package/tests/consumer-rights.spec.ts +572 -0
- package/tests/context.ts +110 -0
- package/tests/entitlement.spec.ts +139 -0
- package/tests/estimate.spec.ts +350 -0
- package/tests/events.spec.ts +357 -0
- package/tests/fake-stripe.ts +981 -0
- package/tests/gate-handlers.spec.ts +120 -0
- package/tests/gate.spec.ts +63 -72
- package/tests/gateway-options.spec.ts +180 -0
- package/tests/limit-gate.spec.ts +66 -0
- package/tests/portal.spec.ts +202 -0
- package/tests/protocol.spec.ts +17 -3
- package/tests/sync.spec.ts +114 -0
- package/tests/usage.integration.spec.ts +133 -0
- package/tests/usage.spec.ts +169 -0
- package/tests/webhook-manager.spec.ts +149 -0
- package/build/model.d.ts +0 -6
- package/build/model.d.ts.map +0 -1
- package/build/model.js +0 -33
- package/build/model.js.map +0 -1
- package/src/model.ts +0 -37
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test'
|
|
2
|
+
import { LimitExhausted, LimitKind, LimitMisdeclared, LimitUnknown, LimitWindow, planLimitHelper } from '@owlmeans/payment'
|
|
3
|
+
import { UnsupportedArgumentError } from '@owlmeans/resource'
|
|
4
|
+
import { makeFakeContext, past, PRO } from './fake-stripe.js'
|
|
5
|
+
import type { FakeContext } from './fake-stripe.js'
|
|
6
|
+
import { paymentAccessOf } from '../src/access.js'
|
|
7
|
+
|
|
8
|
+
const ledger = (fake: FakeContext) => fake.stores['payment-usage'].rows
|
|
9
|
+
const counters = (fake: FakeContext) => fake.stores['payment-usage-counter'].rows
|
|
10
|
+
|
|
11
|
+
const pro = async (fake: FakeContext, entityId = 'entity-1'): Promise<void> => {
|
|
12
|
+
await paymentAccessOf(fake.ctx).gateway().grantInternalPlan(fake.ctx, entityId, PRO, { force: true })
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
describe('@owlmeans/server-payment — consume', () => {
|
|
16
|
+
test('admits up to the ceiling, then refuses without writing an event', async () => {
|
|
17
|
+
const fake = await makeFakeContext()
|
|
18
|
+
const service = paymentAccessOf(fake.ctx).entitlements()
|
|
19
|
+
const first = await service.consume({ entityId: 'entity-1', limitKey: 'exports', eventKey: 'export:a', ref: 'a' })
|
|
20
|
+
expect(first).toEqual(expect.objectContaining({
|
|
21
|
+
admitted: true, replayed: false, used: 1, limit: 1, remaining: 0,
|
|
22
|
+
window: planLimitHelper.windowKeyOf(LimitKind.Window, LimitWindow.Month),
|
|
23
|
+
}))
|
|
24
|
+
|
|
25
|
+
const refusal = await service.consume({ entityId: 'entity-1', limitKey: 'exports', eventKey: 'export:b' })
|
|
26
|
+
.catch(error => error)
|
|
27
|
+
expect(refusal).toBeInstanceOf(LimitExhausted)
|
|
28
|
+
expect(refusal).toEqual(expect.objectContaining({
|
|
29
|
+
limitKey: 'exports', used: 1, limit: 1, resetsAt: planLimitHelper.windowBoundsOf(LimitWindow.Month).resetsAt,
|
|
30
|
+
}))
|
|
31
|
+
expect(ledger(fake)).toHaveLength(1)
|
|
32
|
+
expect(counters(fake)[0].used).toBe(1)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
test('replays an event key — at the ceiling too — without counting it twice', async () => {
|
|
36
|
+
const fake = await makeFakeContext()
|
|
37
|
+
const service = paymentAccessOf(fake.ctx).entitlements()
|
|
38
|
+
await service.consume({ entityId: 'entity-1', limitKey: 'exports', eventKey: 'export:a' })
|
|
39
|
+
const replay = await service.consume({ entityId: 'entity-1', limitKey: 'exports', eventKey: 'export:a' })
|
|
40
|
+
|
|
41
|
+
expect(replay).toEqual(expect.objectContaining({ admitted: true, replayed: true, used: 1 }))
|
|
42
|
+
expect(ledger(fake)).toHaveLength(1)
|
|
43
|
+
expect(counters(fake)[0].used).toBe(1)
|
|
44
|
+
expect(await service.consumption('entity-1', 'exports', 'export:a')).toEqual(expect.objectContaining({ delta: 1 }))
|
|
45
|
+
expect(await service.consumption('entity-1', 'exports', 'export:unknown')).toBeNull()
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
test('a lapsed promo refuses; a grandfathered subscription keeps the allowance', async () => {
|
|
49
|
+
const fake = await makeFakeContext({ catalogue: { reportsUntil: past(1) } })
|
|
50
|
+
await pro(fake, 'late')
|
|
51
|
+
await expect(paymentAccessOf(fake.ctx).entitlements().consume({ entityId: 'late', limitKey: 'reports', eventKey: 'r:1' }))
|
|
52
|
+
.rejects.toBeInstanceOf(LimitExhausted)
|
|
53
|
+
|
|
54
|
+
await pro(fake, 'early')
|
|
55
|
+
const row = fake.stores['payment-subscription'].rows.find(item => item.entityId === 'early')!
|
|
56
|
+
row.createdAt = past(5)
|
|
57
|
+
expect((await paymentAccessOf(fake.ctx).entitlements().consume({ entityId: 'early', limitKey: 'reports', eventKey: 'r:1' })).limit).toBe(4)
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
test('an undeclared key is LimitUnknown; a non-positive amount is refused', async () => {
|
|
61
|
+
const fake = await makeFakeContext()
|
|
62
|
+
await expect(paymentAccessOf(fake.ctx).entitlements().consume({ entityId: 'entity-1', limitKey: 'nope', eventKey: 'n:1' }))
|
|
63
|
+
.rejects.toBeInstanceOf(LimitUnknown)
|
|
64
|
+
await expect(paymentAccessOf(fake.ctx).entitlements().consume({ entityId: 'entity-1', limitKey: 'exports', eventKey: 'n:1', amount: 0 }))
|
|
65
|
+
.rejects.toBeInstanceOf(UnsupportedArgumentError)
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
describe('@owlmeans/server-payment — release', () => {
|
|
70
|
+
test('frees the unit once; a second release replays; the consumption is gone', async () => {
|
|
71
|
+
const fake = await makeFakeContext()
|
|
72
|
+
await pro(fake)
|
|
73
|
+
const service = paymentAccessOf(fake.ctx).entitlements()
|
|
74
|
+
await service.consume({ entityId: 'entity-1', limitKey: 'reports', eventKey: 'report:1', ref: '1' })
|
|
75
|
+
|
|
76
|
+
expect(await service.release({ entityId: 'entity-1', limitKey: 'reports', eventKey: 'report:1' }))
|
|
77
|
+
.toEqual(expect.objectContaining({ admitted: true, replayed: false, used: 0 }))
|
|
78
|
+
expect(await service.release({ entityId: 'entity-1', limitKey: 'reports', eventKey: 'report:1' }))
|
|
79
|
+
.toEqual(expect.objectContaining({ admitted: true, replayed: true, used: 0 }))
|
|
80
|
+
expect(ledger(fake).map(event => event.delta)).toEqual([1, -1])
|
|
81
|
+
expect(await service.consumption('entity-1', 'reports', 'report:1')).toBeNull()
|
|
82
|
+
expect(await service.release({ entityId: 'entity-1', limitKey: 'reports', eventKey: 'report:never' }))
|
|
83
|
+
.toEqual(expect.objectContaining({ admitted: false, replayed: false }))
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
test('consumptionByRef finds the unit a record holds under a fresh key per cycle', async () => {
|
|
87
|
+
const fake = await makeFakeContext()
|
|
88
|
+
await pro(fake)
|
|
89
|
+
const service = paymentAccessOf(fake.ctx).entitlements()
|
|
90
|
+
expect(await service.consumptionByRef('entity-1', 'seats', 'record-1')).toBeNull()
|
|
91
|
+
|
|
92
|
+
await service.consume({ entityId: 'entity-1', limitKey: 'seats', eventKey: 'seats:record-1:1', ref: 'record-1' })
|
|
93
|
+
expect(await service.consumptionByRef('entity-1', 'seats', 'record-1'))
|
|
94
|
+
.toEqual(expect.objectContaining({ eventKey: 'seats:record-1:1', delta: 1 }))
|
|
95
|
+
|
|
96
|
+
await Bun.sleep(3)
|
|
97
|
+
await service.consume({ entityId: 'entity-1', limitKey: 'seats', eventKey: 'seats:record-1:2', ref: 'record-1' })
|
|
98
|
+
expect((await service.consumptionByRef('entity-1', 'seats', 'record-1'))?.eventKey).toBe('seats:record-1:2')
|
|
99
|
+
expect(await service.consumptionByRef('entity-1', 'seats', 'record-2')).toBeNull()
|
|
100
|
+
|
|
101
|
+
await service.release({ entityId: 'entity-1', limitKey: 'seats', eventKey: 'seats:record-1:2' })
|
|
102
|
+
expect((await service.consumptionByRef('entity-1', 'seats', 'record-1'))?.eventKey).toBe('seats:record-1:1')
|
|
103
|
+
await service.release({ entityId: 'entity-1', limitKey: 'seats', eventKey: 'seats:record-1:1' })
|
|
104
|
+
expect(await service.consumptionByRef('entity-1', 'seats', 'record-1')).toBeNull()
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
test('never takes a counter below zero', async () => {
|
|
108
|
+
const fake = await makeFakeContext()
|
|
109
|
+
await pro(fake)
|
|
110
|
+
const service = paymentAccessOf(fake.ctx).entitlements()
|
|
111
|
+
await service.consume({ entityId: 'entity-1', limitKey: 'reports', eventKey: 'report:1' })
|
|
112
|
+
counters(fake)[0].used = 0
|
|
113
|
+
|
|
114
|
+
expect((await service.release({ entityId: 'entity-1', limitKey: 'reports', eventKey: 'report:1' })).used).toBe(0)
|
|
115
|
+
expect(counters(fake)[0].used).toBe(0)
|
|
116
|
+
})
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
describe('@owlmeans/server-payment — reconciliation', () => {
|
|
120
|
+
test('reconcileCounters repairs drift from the ledger, drops empty past windows and creates the current one', async () => {
|
|
121
|
+
const fake = await makeFakeContext()
|
|
122
|
+
await pro(fake)
|
|
123
|
+
const service = paymentAccessOf(fake.ctx).entitlements()
|
|
124
|
+
await service.consume({ entityId: 'entity-1', limitKey: 'exports', eventKey: 'export:1' })
|
|
125
|
+
await service.consume({ entityId: 'entity-1', limitKey: 'exports', eventKey: 'export:2' })
|
|
126
|
+
counters(fake)[0].used = 3
|
|
127
|
+
counters(fake).push({ entityId: 'entity-1', limitKey: 'exports', window: '2001-01-01', used: 2, limit: 3, updatedAt: past(9000) })
|
|
128
|
+
counters(fake).push({ entityId: 'entity-1', limitKey: 'reports', window: 'lifetime', used: 2, limit: 4, updatedAt: past(1) })
|
|
129
|
+
|
|
130
|
+
const result = await service.reconcileCounters('entity-1')
|
|
131
|
+
expect(result.repaired).toBe(2)
|
|
132
|
+
const today = planLimitHelper.windowKeyOf(LimitKind.Window, LimitWindow.Day)
|
|
133
|
+
expect(counters(fake).find(counter => counter.window === today)?.used).toBe(2)
|
|
134
|
+
expect(counters(fake).some(counter => counter.window === '2001-01-01')).toBe(false)
|
|
135
|
+
expect(counters(fake).find(counter => counter.window === 'lifetime')?.used).toBe(0)
|
|
136
|
+
|
|
137
|
+
const fresh = await makeFakeContext()
|
|
138
|
+
await paymentAccessOf(fresh.ctx).entitlements().reconcileCounters('entity-9')
|
|
139
|
+
expect(counters(fresh)).toEqual([expect.objectContaining({
|
|
140
|
+
entityId: 'entity-9', limitKey: 'exports', window: planLimitHelper.windowKeyOf(LimitKind.Window, LimitWindow.Month), used: 0,
|
|
141
|
+
})])
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
test('reconcileOccupancy writes one adjusting event a day and flags an entity over its limit', async () => {
|
|
145
|
+
const fake = await makeFakeContext()
|
|
146
|
+
await pro(fake)
|
|
147
|
+
const service = paymentAccessOf(fake.ctx).entitlements()
|
|
148
|
+
await service.consume({ entityId: 'entity-1', limitKey: 'seats', eventKey: 'seat:1' })
|
|
149
|
+
|
|
150
|
+
const over = await service.reconcileOccupancy('entity-1', 'seats', 3)
|
|
151
|
+
expect(over).toEqual(expect.objectContaining({ used: 3, limit: 2, over: 1 }))
|
|
152
|
+
expect(over.overSince).toBeInstanceOf(Date)
|
|
153
|
+
const again = await service.reconcileOccupancy('entity-1', 'seats', 3)
|
|
154
|
+
expect(again.overSince?.getTime()).toBe(over.overSince?.getTime())
|
|
155
|
+
|
|
156
|
+
const within = await service.reconcileOccupancy('entity-1', 'seats', 1)
|
|
157
|
+
expect(within).toEqual({ limitKey: 'seats', used: 1, limit: 2, over: 0 })
|
|
158
|
+
const adjustments = ledger(fake).filter(event => event.eventKey.startsWith('reconcile:seats:'))
|
|
159
|
+
expect(adjustments).toHaveLength(1)
|
|
160
|
+
expect(ledger(fake).reduce((sum, event) => sum + event.delta, 0)).toBe(1)
|
|
161
|
+
expect(counters(fake).find(counter => counter.limitKey === 'seats')?.overSince).toBeUndefined()
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
test('reconcileOccupancy refuses a limit that is not an occupancy', async () => {
|
|
165
|
+
const fake = await makeFakeContext()
|
|
166
|
+
await expect(paymentAccessOf(fake.ctx).entitlements().reconcileOccupancy('entity-1', 'exports', 1))
|
|
167
|
+
.rejects.toBeInstanceOf(LimitMisdeclared)
|
|
168
|
+
})
|
|
169
|
+
})
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test'
|
|
2
|
+
import { WebhookSetupError } from '@owlmeans/payment'
|
|
3
|
+
import { STRIPE_SIGNATURE, WEBHOOK_EVENTS } from '../src/consts.js'
|
|
4
|
+
import { HOST, makeFakeContext, SDK_API_VERSION, SERVICE } from './fake-stripe.js'
|
|
5
|
+
import { webhookOf } from '../src/plugins/webhook-manager.js'
|
|
6
|
+
|
|
7
|
+
const URL = 'https://api.example.com/payment-gate/webhook/stripe'
|
|
8
|
+
const ours = { owlmeans: 'payment', service: SERVICE }
|
|
9
|
+
|
|
10
|
+
describe('@owlmeans/server-payment — webhook endpoint management', () => {
|
|
11
|
+
test('skips a URL Stripe cannot deliver to without calling Stripe', async () => {
|
|
12
|
+
for (const host of ['localhost', '127.0.0.1', 'api', 'payments.local']) {
|
|
13
|
+
const fake = await makeFakeContext({ host })
|
|
14
|
+
expect(await webhookOf(fake.ctx).ensureWebhookEndpoint(fake.stripe)).toBeNull()
|
|
15
|
+
expect(fake.state.calls).toEqual([])
|
|
16
|
+
}
|
|
17
|
+
const plain = await makeFakeContext()
|
|
18
|
+
;(plain.ctx.cfg as { security?: { unsecure?: boolean } }).security = { unsecure: true }
|
|
19
|
+
expect(await webhookOf(plain.ctx).ensureWebhookEndpoint(plain.stripe)).toBeNull()
|
|
20
|
+
expect(plain.state.calls).toEqual([])
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
test('creates the endpoint on the client API version, persists its secret, makes no call while nothing changed, and a forced run recreates it once deleted from outside', async () => {
|
|
24
|
+
const fake = await makeFakeContext()
|
|
25
|
+
expect(webhookOf(fake.ctx).webhookUrlOf()).toBe(URL)
|
|
26
|
+
|
|
27
|
+
const row = await webhookOf(fake.ctx).ensureWebhookEndpoint(fake.stripe)
|
|
28
|
+
expect(fake.state.calls).toEqual(['webhookEndpoints.list', 'webhookEndpoints.create'])
|
|
29
|
+
const [endpoint] = fake.state.webhookEndpoints
|
|
30
|
+
expect(endpoint).toEqual(expect.objectContaining({
|
|
31
|
+
url: URL, api_version: SDK_API_VERSION, enabled_events: [...WEBHOOK_EVENTS].sort(), metadata: ours,
|
|
32
|
+
description: `owlmeans:${SERVICE}`,
|
|
33
|
+
}))
|
|
34
|
+
expect(row).toEqual(expect.objectContaining({
|
|
35
|
+
externalId: endpoint.id, secret: endpoint.secret, apiVersion: SDK_API_VERSION, url: URL,
|
|
36
|
+
}))
|
|
37
|
+
|
|
38
|
+
fake.state.calls.length = 0
|
|
39
|
+
await webhookOf(fake.ctx).ensureWebhookEndpoint(fake.stripe)
|
|
40
|
+
expect(fake.state.calls).toEqual([])
|
|
41
|
+
|
|
42
|
+
fake.state.webhookEndpoints = []
|
|
43
|
+
await webhookOf(fake.ctx).ensureWebhookEndpoint(fake.stripe)
|
|
44
|
+
expect(fake.state.calls).toEqual([])
|
|
45
|
+
|
|
46
|
+
const healed = await webhookOf(fake.ctx).ensureWebhookEndpoint(fake.stripe, { force: true })
|
|
47
|
+
expect(fake.state.calls).toEqual(['webhookEndpoints.retrieve', 'webhookEndpoints.list', 'webhookEndpoints.create'])
|
|
48
|
+
const [recreated] = fake.state.webhookEndpoints
|
|
49
|
+
expect(recreated).toEqual(expect.objectContaining({ id: healed?.externalId, url: URL, metadata: ours }))
|
|
50
|
+
expect(fake.stores['payment-webhook'].rows).toEqual([
|
|
51
|
+
expect.objectContaining({ url: URL, externalId: recreated.id, secret: recreated.secret }),
|
|
52
|
+
])
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
test('updates changed events in place, and recreates the endpoint for a new API version', async () => {
|
|
56
|
+
const fake = await makeFakeContext()
|
|
57
|
+
await webhookOf(fake.ctx).ensureWebhookEndpoint(fake.stripe)
|
|
58
|
+
const stored = fake.stores['payment-webhook'].rows[0]
|
|
59
|
+
const firstSecret = stored.secret
|
|
60
|
+
stored.hash = 'events-of-an-older-release'
|
|
61
|
+
fake.state.calls.length = 0
|
|
62
|
+
|
|
63
|
+
await webhookOf(fake.ctx).ensureWebhookEndpoint(fake.stripe)
|
|
64
|
+
expect(fake.state.calls).toEqual(['webhookEndpoints.update'])
|
|
65
|
+
expect(fake.stores['payment-webhook'].rows[0].secret).toBe(firstSecret)
|
|
66
|
+
|
|
67
|
+
fake.state.apiVersion = '2099-01-01.future'
|
|
68
|
+
fake.state.calls.length = 0
|
|
69
|
+
await webhookOf(fake.ctx).ensureWebhookEndpoint(fake.stripe)
|
|
70
|
+
expect(fake.state.calls).toEqual(['webhookEndpoints.del', 'webhookEndpoints.list', 'webhookEndpoints.create'])
|
|
71
|
+
expect(fake.state.webhookEndpoints).toHaveLength(1)
|
|
72
|
+
expect(fake.state.webhookEndpoints[0].api_version).toBe('2099-01-01.future')
|
|
73
|
+
expect(fake.stores['payment-webhook'].rows).toHaveLength(1)
|
|
74
|
+
expect(fake.stores['payment-webhook'].rows[0].secret).not.toBe(firstSecret)
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
test('leaves another deployment\'s endpoint in a shared account alone, and replaces an untracked one at its own URL', async () => {
|
|
78
|
+
const STAGE_URL = 'https://stage.example.com/payment-gate/webhook/stripe'
|
|
79
|
+
const STAGING_URL = 'https://staging.example.com/payment-gate/webhook/stripe'
|
|
80
|
+
const stage = await makeFakeContext({
|
|
81
|
+
host: 'stage.example.com',
|
|
82
|
+
stripe: {
|
|
83
|
+
webhookEndpoints: [{ id: 'we_manual', url: STAGING_URL, metadata: {}, enabled_events: ['*'], secret: 'whsec_manual' }],
|
|
84
|
+
},
|
|
85
|
+
})
|
|
86
|
+
const staging = await makeFakeContext({ host: 'staging.example.com' })
|
|
87
|
+
|
|
88
|
+
const stageRow = await webhookOf(stage.ctx).ensureWebhookEndpoint(stage.stripe)
|
|
89
|
+
const stagingRow = await webhookOf(staging.ctx).ensureWebhookEndpoint(stage.stripe)
|
|
90
|
+
expect(stage.state.webhookEndpoints.map(({ id, url, metadata }) => ({ id, url, metadata }))).toEqual([
|
|
91
|
+
{ id: stageRow?.externalId, url: STAGE_URL, metadata: ours },
|
|
92
|
+
{ id: stagingRow?.externalId, url: STAGING_URL, metadata: ours },
|
|
93
|
+
])
|
|
94
|
+
|
|
95
|
+
stage.state.calls.length = 0
|
|
96
|
+
expect(await webhookOf(stage.ctx).ensureWebhookEndpoint(stage.stripe, { force: true }))
|
|
97
|
+
.toEqual(expect.objectContaining({ externalId: stageRow?.externalId, secret: stageRow?.secret }))
|
|
98
|
+
expect(stage.state.calls).toEqual(['webhookEndpoints.retrieve', 'webhookEndpoints.update'])
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
test('after a URL change, drops the endpoints its own former rows name and removes those rows', async () => {
|
|
102
|
+
const fake = await makeFakeContext({ host: 'old.example.com' })
|
|
103
|
+
const former = await webhookOf(fake.ctx).ensureWebhookEndpoint(fake.stripe)
|
|
104
|
+
fake.stores['payment-webhook'].rows.push({
|
|
105
|
+
id: 'older-row', paygate: 'stripe', service: SERVICE, url: 'https://older.example.com/payment-gate/webhook/stripe',
|
|
106
|
+
externalId: 'we_gone', secret: 'whsec_gone', apiVersion: SDK_API_VERSION, events: [], hash: 'x', createdAt: new Date(),
|
|
107
|
+
})
|
|
108
|
+
;(fake.ctx.cfg.services?.[SERVICE] as { host: string }).host = HOST
|
|
109
|
+
fake.state.calls.length = 0
|
|
110
|
+
|
|
111
|
+
const moved = await webhookOf(fake.ctx).ensureWebhookEndpoint(fake.stripe)
|
|
112
|
+
expect(moved).toEqual(expect.objectContaining({ url: URL }))
|
|
113
|
+
expect(fake.state.calls).toEqual([
|
|
114
|
+
'webhookEndpoints.list', 'webhookEndpoints.create', 'webhookEndpoints.del', 'webhookEndpoints.del',
|
|
115
|
+
])
|
|
116
|
+
expect(fake.state.webhookEndpoints.map(endpoint => endpoint.id)).toEqual([moved?.externalId])
|
|
117
|
+
expect(moved?.externalId).not.toBe(former?.externalId)
|
|
118
|
+
expect(fake.stores['payment-webhook'].rows).toEqual([expect.objectContaining({ url: URL, externalId: moved?.externalId })])
|
|
119
|
+
})
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
describe('@owlmeans/server-payment — webhook secret', () => {
|
|
123
|
+
test('resolves the configured secret first, then the stored one, else fails setup', async () => {
|
|
124
|
+
const bare = await makeFakeContext()
|
|
125
|
+
await expect(webhookOf(bare.ctx).stripeWebhookSecret()).rejects.toBeInstanceOf(WebhookSetupError)
|
|
126
|
+
|
|
127
|
+
await webhookOf(bare.ctx).ensureWebhookEndpoint(bare.stripe)
|
|
128
|
+
expect(await webhookOf(bare.ctx).stripeWebhookSecret()).toBe(bare.state.webhookEndpoints[0].secret)
|
|
129
|
+
|
|
130
|
+
const configured = await makeFakeContext({ webhookSecret: 'whsec_file' })
|
|
131
|
+
await webhookOf(configured.ctx).ensureWebhookEndpoint(configured.stripe)
|
|
132
|
+
expect(await webhookOf(configured.ctx).stripeWebhookSecret()).toBe('whsec_file')
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
test('verifies a delivery with either secret, and refuses a signature neither verifies', async () => {
|
|
136
|
+
const fake = await makeFakeContext({ webhookSecret: 'whsec_file' })
|
|
137
|
+
await webhookOf(fake.ctx).ensureWebhookEndpoint(fake.stripe)
|
|
138
|
+
const stored = fake.state.webhookEndpoints[0].secret
|
|
139
|
+
const body = JSON.stringify({ id: 'evt_1', type: 'customer.created', data: { object: { id: 'cus_9', metadata: { entityId: 'e9' } } } })
|
|
140
|
+
const deliver = async (signature: string) => await webhookOf(fake.ctx).handleStripeWebhook(fake.stripe, {
|
|
141
|
+
rawBody: body, headers: { [STRIPE_SIGNATURE.toLowerCase()]: signature },
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
await deliver(`sig:${stored}`)
|
|
145
|
+
await deliver('sig:whsec_file')
|
|
146
|
+
expect(fake.stores['payment-paygate-customer'].rows).toHaveLength(1)
|
|
147
|
+
await expect(deliver('sig:whsec_forged')).rejects.toThrow('signature')
|
|
148
|
+
})
|
|
149
|
+
})
|
package/build/model.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { JSONSchemaType } from 'ajv';
|
|
2
|
-
import type { FingerprintRecord, PaygateCustomerRecord, PaymentSubscriptionRecord } from './types.js';
|
|
3
|
-
export declare const PaygateCustomerSchema: JSONSchemaType<PaygateCustomerRecord>;
|
|
4
|
-
export declare const PaymentSubscriptionSchema: JSONSchemaType<PaymentSubscriptionRecord>;
|
|
5
|
-
export declare const FingerprintSchema: JSONSchemaType<FingerprintRecord>;
|
|
6
|
-
//# sourceMappingURL=model.d.ts.map
|
package/build/model.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AAGzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAA;AAErG,eAAO,MAAM,qBAAqB,EASlB,cAAc,CAAC,qBAAqB,CAAC,CAAA;AAErD,eAAO,MAAM,yBAAyB,EAWtB,cAAc,CAAC,yBAAyB,CAAC,CAAA;AAEzD,eAAO,MAAM,iBAAiB,EAOd,cAAc,CAAC,iBAAiB,CAAC,CAAA"}
|
package/build/model.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { PermissionSetSchema } from '@owlmeans/auth';
|
|
2
|
-
import { LimitConfigSchema } from '@owlmeans/payment';
|
|
3
|
-
export const PaygateCustomerSchema = {
|
|
4
|
-
type: 'object',
|
|
5
|
-
properties: {
|
|
6
|
-
id: { type: 'string', nullable: true }, paygate: { type: 'string' }, externalId: { type: 'string' },
|
|
7
|
-
entityId: { type: 'string', nullable: true }, profileId: { type: 'string', nullable: true },
|
|
8
|
-
email: { type: 'string', nullable: true }, name: { type: 'string', nullable: true },
|
|
9
|
-
taxId: { type: 'string', nullable: true },
|
|
10
|
-
},
|
|
11
|
-
required: ['paygate', 'externalId'], additionalProperties: true,
|
|
12
|
-
};
|
|
13
|
-
export const PaymentSubscriptionSchema = {
|
|
14
|
-
type: 'object',
|
|
15
|
-
properties: {
|
|
16
|
-
id: { type: 'string', nullable: true }, sku: { type: 'string' }, productSku: { type: 'string' },
|
|
17
|
-
entityId: { type: 'string' }, service: { type: 'string' }, paygate: { type: 'string' },
|
|
18
|
-
externalId: { type: 'string' }, status: { type: 'string' }, kind: { type: 'string' },
|
|
19
|
-
capabilities: { type: 'array', items: PermissionSetSchema, nullable: true },
|
|
20
|
-
limits: { type: 'object', nullable: true, additionalProperties: LimitConfigSchema, required: [] },
|
|
21
|
-
},
|
|
22
|
-
required: ['sku', 'productSku', 'entityId', 'service', 'paygate', 'externalId', 'status', 'kind'],
|
|
23
|
-
additionalProperties: true,
|
|
24
|
-
};
|
|
25
|
-
export const FingerprintSchema = {
|
|
26
|
-
type: 'object',
|
|
27
|
-
properties: {
|
|
28
|
-
id: { type: 'string', nullable: true }, sku: { type: 'string' }, hash: { type: 'string' },
|
|
29
|
-
productId: { type: 'string', nullable: true },
|
|
30
|
-
},
|
|
31
|
-
required: ['sku', 'hash'], additionalProperties: true,
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=model.js.map
|
package/build/model.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAGrD,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACnG,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC3F,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;QACnF,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;KAC1C;IACD,QAAQ,EAAE,CAAC,SAAS,EAAE,YAAY,CAAC,EAAE,oBAAoB,EAAE,IAAI;CACZ,CAAA;AAErD,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC/F,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACtF,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACpF,YAAY,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,mBAA4B,EAAE,QAAQ,EAAE,IAAI,EAAE;QACpF,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,oBAAoB,EAAE,iBAA0B,EAAE,QAAQ,EAAE,EAAE,EAAE;KAC3G;IACD,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,CAAC;IACjG,oBAAoB,EAAE,IAAI;CAC6B,CAAA;AAEzD,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACzF,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;KAC9C;IACD,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,oBAAoB,EAAE,IAAI;CACN,CAAA"}
|
package/src/model.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { JSONSchemaType } from 'ajv'
|
|
2
|
-
import { PermissionSetSchema } from '@owlmeans/auth'
|
|
3
|
-
import { LimitConfigSchema } from '@owlmeans/payment'
|
|
4
|
-
import type { FingerprintRecord, PaygateCustomerRecord, PaymentSubscriptionRecord } from './types.js'
|
|
5
|
-
|
|
6
|
-
export const PaygateCustomerSchema = {
|
|
7
|
-
type: 'object',
|
|
8
|
-
properties: {
|
|
9
|
-
id: { type: 'string', nullable: true }, paygate: { type: 'string' }, externalId: { type: 'string' },
|
|
10
|
-
entityId: { type: 'string', nullable: true }, profileId: { type: 'string', nullable: true },
|
|
11
|
-
email: { type: 'string', nullable: true }, name: { type: 'string', nullable: true },
|
|
12
|
-
taxId: { type: 'string', nullable: true },
|
|
13
|
-
},
|
|
14
|
-
required: ['paygate', 'externalId'], additionalProperties: true,
|
|
15
|
-
} as unknown as JSONSchemaType<PaygateCustomerRecord>
|
|
16
|
-
|
|
17
|
-
export const PaymentSubscriptionSchema = {
|
|
18
|
-
type: 'object',
|
|
19
|
-
properties: {
|
|
20
|
-
id: { type: 'string', nullable: true }, sku: { type: 'string' }, productSku: { type: 'string' },
|
|
21
|
-
entityId: { type: 'string' }, service: { type: 'string' }, paygate: { type: 'string' },
|
|
22
|
-
externalId: { type: 'string' }, status: { type: 'string' }, kind: { type: 'string' },
|
|
23
|
-
capabilities: { type: 'array', items: PermissionSetSchema as never, nullable: true },
|
|
24
|
-
limits: { type: 'object', nullable: true, additionalProperties: LimitConfigSchema as never, required: [] },
|
|
25
|
-
},
|
|
26
|
-
required: ['sku', 'productSku', 'entityId', 'service', 'paygate', 'externalId', 'status', 'kind'],
|
|
27
|
-
additionalProperties: true,
|
|
28
|
-
} as unknown as JSONSchemaType<PaymentSubscriptionRecord>
|
|
29
|
-
|
|
30
|
-
export const FingerprintSchema = {
|
|
31
|
-
type: 'object',
|
|
32
|
-
properties: {
|
|
33
|
-
id: { type: 'string', nullable: true }, sku: { type: 'string' }, hash: { type: 'string' },
|
|
34
|
-
productId: { type: 'string', nullable: true },
|
|
35
|
-
},
|
|
36
|
-
required: ['sku', 'hash'], additionalProperties: true,
|
|
37
|
-
} as unknown as JSONSchemaType<FingerprintRecord>
|